texteditor.h
author insilmaril
Tue Sep 05 15:05:18 2006 +0000 (2006-09-05)
changeset 376 626fd85b1f69
parent 190 68c49789ec0b
child 388 3a58c9ef4a18
permissions -rw-r--r--
Fixed lost script update-bookmarks
insilmaril@0
     1
#ifndef TEXTEDITOR_H 
insilmaril@0
     2
#define TEXTEDITOR_H
insilmaril@0
     3
insilmaril@366
     4
#include <QtGui>
insilmaril@366
     5
#include <QTextEdit>
insilmaril@366
     6
#include <QFontDatabase>
insilmaril@366
     7
#include <QComboBox>
insilmaril@366
     8
#include <QCloseEvent>
insilmaril@0
     9
insilmaril@0
    10
insilmaril@0
    11
enum EditorState {inactiveEditor,emptyEditor,filledEditor};
insilmaril@0
    12
jhilmer@142
    13
class MyTextEdit;
jhilmer@142
    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@366
    31
	bool findText(const QString &, const QTextDocument::FindFlags &); // 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*);
jhilmer@142
    74
	void textVAlign();
insilmaril@0
    75
    void fontChanged( const QFont &f );
insilmaril@0
    76
    void colorChanged( const QColor &c );
insilmaril@0
    77
    void alignmentChanged( int a );
jhilmer@142
    78
    void verticalAlignmentChanged(int a);
insilmaril@0
    79
	void enableActions();
insilmaril@0
    80
	void disableActions();
insilmaril@366
    81
	void setState (EditorState);
insilmaril@0
    82
insilmaril@0
    83
private:
insilmaril@0
    84
    QPrinter *printer;
jhilmer@142
    85
    MyTextEdit *e;
insilmaril@0
    86
	QPoint lastPos;			// save last position of window
insilmaril@0
    87
    QString filename;
insilmaril@106
    88
    QString filenameHint;
insilmaril@0
    89
insilmaril@0
    90
	QBrush emptyPaper;		// setting the background color
insilmaril@0
    91
	QBrush filledPaper;		// depending on the state
insilmaril@0
    92
	QBrush inactivePaper;	// depending on the state
insilmaril@0
    93
	EditorState state;
insilmaril@0
    94
	bool showwithmain;		// same visibility as mainwindow?
insilmaril@0
    95
insilmaril@0
    96
	QFont varFont;
insilmaril@0
    97
	QFont fixedFont;
insilmaril@0
    98
    QComboBox
insilmaril@0
    99
	*comboFont,
insilmaril@0
   100
	*comboSize;
insilmaril@0
   101
	
insilmaril@0
   102
	QAction *actionFileLoad,
insilmaril@0
   103
	*actionFileSave,
insilmaril@0
   104
	*actionFileSaveAs,
insilmaril@0
   105
	*actionFilePrint,
insilmaril@0
   106
	*actionEditUndo,
insilmaril@0
   107
	*actionEditRedo,
insilmaril@0
   108
	*actionEditCopy,
insilmaril@0
   109
	*actionEditCut,
insilmaril@0
   110
	*actionEditPaste,
insilmaril@0
   111
	*actionEditDeleteAll,
insilmaril@0
   112
	*actionEditConvertPar,
insilmaril@0
   113
	*actionEditJoinLines,
insilmaril@0
   114
	*actionFormatUseFixedFont,
insilmaril@0
   115
	*actionSettingsVarFont,
insilmaril@0
   116
	*actionSettingsFixedFont,
insilmaril@0
   117
	*actionSettingsFonthintDefault,
insilmaril@0
   118
    *actionTextBold,
insilmaril@0
   119
	*actionTextUnderline,
insilmaril@0
   120
	*actionTextItalic,
insilmaril@0
   121
	*actionTextColor,
insilmaril@0
   122
	*actionAlignLeft,
insilmaril@0
   123
	*actionAlignCenter,
insilmaril@0
   124
	*actionAlignRight,
jhilmer@142
   125
	*actionAlignJustify,
jhilmer@142
   126
	*actionAlignSubScript,
jhilmer@142
   127
	*actionAlignSuperScript;
jhilmer@142
   128
};
jhilmer@142
   129
insilmaril@366
   130
/* FIXME Wraps currentVerticalAlignmentChanged(VerticalAlignment)
jhilmer@142
   131
 * to currentVerticalAlignmentChanged(int) 
jhilmer@142
   132
 * this way the signal can be used without use of the internal 
jhilmer@142
   133
 * VerticalAlignment enum of QTextEdit 
jhilmer@142
   134
 * If VerticalAlignment has been a global like the normal alignment there
jhilmer@142
   135
 * have been no problems!
jhilmer@142
   136
 */
jhilmer@142
   137
 
jhilmer@142
   138
class MyTextEdit : public QTextEdit 
jhilmer@142
   139
{
jhilmer@142
   140
    Q_OBJECT;
jhilmer@142
   141
 public:
insilmaril@366
   142
    MyTextEdit(QWidget *parent, const char *name) : QTextEdit(parent, name) 
insilmaril@366
   143
	{
insilmaril@366
   144
	/*
insilmaril@366
   145
		connect(
insilmaril@366
   146
			this, SIGNAL(currentVerticalAlignmentChanged(VerticalAlignment)), 
insilmaril@366
   147
			this, SLOT(verticalAlignmentChanged(VerticalAlignment)));
insilmaril@366
   148
	*/		
jhilmer@142
   149
    }
insilmaril@366
   150
//    int verticalAlignment() const { return m_verticalAlignment; } 
jhilmer@142
   151
 signals:
insilmaril@366
   152
//    void currentVerticalAlignmentChanged(int a);
jhilmer@142
   153
 public slots:
insilmaril@366
   154
 /*
insilmaril@366
   155
    void verticalAlignmentChanged(VerticalAlignment a) 
insilmaril@366
   156
	{
insilmaril@366
   157
		m_verticalAlignment = a;
insilmaril@366
   158
		emit currentVerticalAlignmentChanged((int)a);
jhilmer@142
   159
    }
insilmaril@366
   160
*/	
jhilmer@142
   161
 private: 
insilmaril@366
   162
//	 int m_verticalAlignment;
insilmaril@0
   163
};
insilmaril@0
   164
insilmaril@0
   165
#endif