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