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