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