texteditor.h
author insilmaril
Wed, 01 Apr 2009 15:06:57 +0000
changeset 749 9ff332964015
parent 746 ee6b0f3a4c2f
child 804 14f2b1b15242
permissions -rw-r--r--
moved scroll functions from BranchObj to BranchItem
     1 #ifndef TEXTEDITOR_H 
     2 #define TEXTEDITOR_H
     3 
     4 #include <QtGui>
     5 
     6 enum EditorState {inactiveEditor,emptyEditor,filledEditor};
     7 
     8 class MyTextEdit;
     9 class NoteObj;
    10 
    11 class TextEditor : public QMainWindow {
    12     Q_OBJECT
    13 public:
    14     TextEditor();
    15     ~TextEditor();
    16 
    17 	bool isEmpty();
    18 	void setShowWithMain (bool);
    19 	bool showWithMain ();
    20 	void setFontHint(const QString&);
    21 	QString getFontHint();
    22 	QString getFontHintDefault();
    23 	void setFilename (const QString&);
    24 	QString getFilename ();
    25 	void setFilenameHint (const QString&);
    26 	QString getFilenameHint ();
    27 	QString getText();
    28 	NoteObj getNoteObj();
    29 	void setNote(const NoteObj &note);
    30 
    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 slots:
    42 	void editorChanged();			// received when text() changed
    43 	void setText(const QString &);	// set Text (by MapEditor)
    44 	void setInactive();				// Nothing can be entered
    45 	void editCopyAll();
    46 
    47 signals:
    48 	void textHasChanged();
    49 	void windowClosed();
    50 	void fontFamilyHasChanged();
    51 	void fontSizeHasChanged();
    52 	
    53 private slots:
    54     void textLoad();
    55     void textSaveAs();
    56     void textSave();
    57 	void textExportAsASCII();
    58     void textPrint();
    59 	void textEditUndo();
    60     void toggleFonthint();
    61     void setFixedFont();
    62     void setVarFont();
    63     void textBold();
    64     void textUnderline();
    65     void textItalic();
    66     void textFamily( const QString &f );
    67     void textSize( const QString &p );
    68 	void textColor();
    69 	void textAlign(QAction*);
    70 	void textVAlign();
    71     void fontChanged( const QFont &f );
    72     void colorChanged( const QColor &c );
    73 	void formatChanged (const QTextCharFormat &f);
    74     void alignmentChanged( int a );
    75     void verticalAlignmentChanged(QTextCharFormat::VerticalAlignment);
    76 	void enableActions();
    77 	void disableActions();
    78 	void setState (EditorState);
    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 	bool blockChangedSignal;
    93 
    94 	QFont varFont;
    95 	QFont fixedFont;
    96     QComboBox *comboFont, *comboSize;
    97 	
    98 	QAction *actionFileLoad,
    99 	*actionFileSave,
   100 	*actionFileSaveAs,
   101 	*actionFilePrint,
   102 	*actionEditUndo,
   103 	*actionEditRedo,
   104 	*actionEditCopy,
   105 	*actionEditCut,
   106 	*actionEditPaste,
   107 	*actionEditDeleteAll,
   108 	*actionFormatUseFixedFont,
   109 	*actionSettingsVarFont,
   110 	*actionSettingsFixedFont,
   111 	*actionSettingsFonthintDefault,
   112     *actionTextBold,
   113 	*actionTextUnderline,
   114 	*actionTextItalic,
   115 	*actionTextColor,
   116 	*actionAlignSubScript,
   117 	*actionAlignSuperScript,
   118 	*actionAlignLeft,
   119 	*actionAlignCenter,
   120 	*actionAlignRight,
   121 	*actionAlignJustify;
   122 };
   123 
   124 #endif