texteditor.h
author insilmaril
Mon, 18 Jun 2007 15:10:19 +0000
changeset 507 2f57a7d2315e
parent 498 2c40ff8ca7ba
child 746 ee6b0f3a4c2f
permissions -rw-r--r--
1.8.73 - beta testing
     1 #ifndef TEXTEDITOR_H 
     2 #define TEXTEDITOR_H
     3 
     4 #include <QtGui>
     5 
     6 enum EditorState {inactiveEditor,emptyEditor,filledEditor};
     7 
     8 class MyTextEdit;
     9 
    10 class TextEditor : public QMainWindow {
    11     Q_OBJECT
    12 public:
    13     TextEditor();
    14     ~TextEditor();
    15 
    16 	bool isEmpty();
    17 	void setShowWithMain (bool);
    18 	bool showWithMain ();
    19 	void setFontHint(const QString&);
    20 	QString getFontHint();
    21 	QString getFontHintDefault();
    22 	void setFilename (const QString&);
    23 	QString getFilename ();
    24 	void setFilenameHint (const QString&);
    25 	QString getFilenameHint ();
    26 	bool findText(const QString &, const QTextDocument::FindFlags &); // find Text 
    27 
    28 protected:
    29 	void setupFileActions();
    30 	void setupEditActions();
    31 	void setupFormatActions();
    32 	void setupSettingsActions();
    33     void closeEvent( QCloseEvent* );
    34 	
    35 
    36 public:
    37 	QString getText();
    38 
    39 public slots:
    40 	void editorChanged();	// received when text() changed
    41 	void setText(QString);	// set Text (by MapEditor)
    42 	void setInactive();		// Nothing can be entered
    43 	void editCopyAll();
    44 
    45 signals:
    46 	void textHasChanged();
    47 	void windowClosed();
    48 	void fontFamilyHasChanged();
    49 	void fontSizeHasChanged();
    50 	
    51 private slots:
    52     void textLoad();
    53     void textSaveAs();
    54     void textSave();
    55 	void textExportAsASCII();
    56     void textPrint();
    57 	void textEditUndo();
    58     void toggleFonthint();
    59     void setFixedFont();
    60     void setVarFont();
    61     void textBold();
    62     void textUnderline();
    63     void textItalic();
    64     void textFamily( const QString &f );
    65     void textSize( const QString &p );
    66 	void textColor();
    67 	void textAlign(QAction*);
    68 	void textVAlign();
    69     void fontChanged( const QFont &f );
    70     void colorChanged( const QColor &c );
    71 	void formatChanged (const QTextCharFormat &f);
    72     void alignmentChanged( int a );
    73     void verticalAlignmentChanged(QTextCharFormat::VerticalAlignment);
    74 	void enableActions();
    75 	void disableActions();
    76 	void setState (EditorState);
    77 
    78 private:
    79     QPrinter *printer;
    80     QTextEdit *e;
    81 	QPoint lastPos;			// save last position of window
    82     QString filename;
    83     QString filenameHint;
    84 
    85 	QBrush emptyPaper;		// setting the background color
    86 	QBrush filledPaper;		// depending on the state
    87 	QBrush inactivePaper;	// depending on the state
    88 	EditorState state;
    89 	bool showwithmain;		// same visibility as mainwindow?
    90 	bool blockChangedSignal;
    91 
    92 	QFont varFont;
    93 	QFont fixedFont;
    94     QComboBox *comboFont, *comboSize;
    95 	
    96 	QAction *actionFileLoad,
    97 	*actionFileSave,
    98 	*actionFileSaveAs,
    99 	*actionFilePrint,
   100 	*actionEditUndo,
   101 	*actionEditRedo,
   102 	*actionEditCopy,
   103 	*actionEditCut,
   104 	*actionEditPaste,
   105 	*actionEditDeleteAll,
   106 	*actionFormatUseFixedFont,
   107 	*actionSettingsVarFont,
   108 	*actionSettingsFixedFont,
   109 	*actionSettingsFonthintDefault,
   110     *actionTextBold,
   111 	*actionTextUnderline,
   112 	*actionTextItalic,
   113 	*actionTextColor,
   114 	*actionAlignSubScript,
   115 	*actionAlignSuperScript,
   116 	*actionAlignLeft,
   117 	*actionAlignCenter,
   118 	*actionAlignRight,
   119 	*actionAlignJustify;
   120 };
   121 
   122 #endif