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