texteditor.h
author insilmaril
Mon Jul 25 20:35:01 2005 +0000 (2005-07-25)
changeset 137 88d2a027ef14
parent 106 4083860dd82e
child 142 3590c3490789
permissions -rw-r--r--
changed MapEditor::undo and saveState so that selection is saved, too (bugfix)
     1 #ifndef TEXTEDITOR_H 
     2 #define TEXTEDITOR_H
     3 
     4 #include <qmainwindow.h>
     5 #include <qtextedit.h>
     6 #include <qaction.h>
     7 #include <qfontdatabase.h>
     8 #include <qcombobox.h>
     9 
    10 
    11 enum EditorState {inactiveEditor,emptyEditor,filledEditor};
    12 
    13 QString textConvertToASCII(const QString &);
    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 bool &); // 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 textConvertPar();
    60 	void textJoinLines();
    61 	void textExportAsASCII();
    62     void textPrint();
    63 	void textEditUndo();
    64     void toggleFonthint();
    65     void setFixedFont();
    66     void setVarFont();
    67     void textBold();
    68     void textUnderline();
    69     void textItalic();
    70     void textFamily( const QString &f );
    71     void textSize( const QString &p );
    72 	void textColor();
    73 	void textAlign(QAction*);
    74     void fontChanged( const QFont &f );
    75     void colorChanged( const QColor &c );
    76     void alignmentChanged( int a );
    77 	void enableActions();
    78 	void disableActions();
    79 
    80 private:
    81     QPrinter *printer;
    82     QTextEdit *e;
    83 	QPoint lastPos;			// save last position of window
    84     QString filename;
    85     QString filenameHint;
    86 
    87 	QBrush emptyPaper;		// setting the background color
    88 	QBrush filledPaper;		// depending on the state
    89 	QBrush inactivePaper;	// depending on the state
    90 	EditorState state;
    91 	bool showwithmain;		// same visibility as mainwindow?
    92 
    93 	QFont varFont;
    94 	QFont fixedFont;
    95     QComboBox
    96 	*comboFont,
    97 	*comboSize;
    98 	
    99 	QAction *actionFileLoad,
   100 	*actionFileSave,
   101 	*actionFileSaveAs,
   102 	*actionFilePrint,
   103 	*actionEditUndo,
   104 	*actionEditRedo,
   105 	*actionEditCopy,
   106 	*actionEditCut,
   107 	*actionEditPaste,
   108 	*actionEditDeleteAll,
   109 	*actionEditConvertPar,
   110 	*actionEditJoinLines,
   111 	*actionFormatUseFixedFont,
   112 	*actionSettingsVarFont,
   113 	*actionSettingsFixedFont,
   114 	*actionSettingsFonthintDefault,
   115     *actionTextBold,
   116 	*actionTextUnderline,
   117 	*actionTextItalic,
   118 	*actionTextColor,
   119 	*actionAlignLeft,
   120 	*actionAlignCenter,
   121 	*actionAlignRight,
   122 	*actionAlignJustify;
   123 };
   124 
   125 #endif