jhilmer@142
|
1 |
/* emacs: -*- Mode: C; c-style: "bsd"; c-basic-offset: 4; c-recognize-knr-p: nil; -*- */
|
insilmaril@0
|
2 |
#ifndef TEXTEDITOR_H
|
insilmaril@0
|
3 |
#define TEXTEDITOR_H
|
insilmaril@0
|
4 |
|
insilmaril@0
|
5 |
#include <qmainwindow.h>
|
insilmaril@0
|
6 |
#include <qtextedit.h>
|
insilmaril@0
|
7 |
#include <qaction.h>
|
insilmaril@0
|
8 |
#include <qfontdatabase.h>
|
insilmaril@0
|
9 |
#include <qcombobox.h>
|
insilmaril@0
|
10 |
|
insilmaril@0
|
11 |
|
insilmaril@0
|
12 |
enum EditorState {inactiveEditor,emptyEditor,filledEditor};
|
insilmaril@0
|
13 |
|
jhilmer@142
|
14 |
class MyTextEdit;
|
jhilmer@142
|
15 |
|
insilmaril@0
|
16 |
class TextEditor : public QMainWindow {
|
insilmaril@0
|
17 |
Q_OBJECT
|
insilmaril@0
|
18 |
public:
|
insilmaril@0
|
19 |
TextEditor();
|
insilmaril@0
|
20 |
~TextEditor();
|
insilmaril@0
|
21 |
|
insilmaril@0
|
22 |
bool isEmpty();
|
insilmaril@0
|
23 |
void setShowWithMain (bool);
|
insilmaril@0
|
24 |
bool showWithMain ();
|
insilmaril@0
|
25 |
void setFontHint(const QString&);
|
insilmaril@0
|
26 |
QString getFontHint();
|
insilmaril@0
|
27 |
QString getFontHintDefault();
|
insilmaril@0
|
28 |
void setFilename (const QString&);
|
insilmaril@0
|
29 |
QString getFilename ();
|
insilmaril@106
|
30 |
void setFilenameHint (const QString&);
|
insilmaril@106
|
31 |
QString getFilenameHint ();
|
insilmaril@0
|
32 |
bool findText(const QString &, const bool &); // find Text
|
insilmaril@0
|
33 |
|
insilmaril@0
|
34 |
protected:
|
insilmaril@0
|
35 |
void setupFileActions();
|
insilmaril@0
|
36 |
void setupEditActions();
|
insilmaril@0
|
37 |
void setupFormatActions();
|
insilmaril@0
|
38 |
void setupSettingsActions();
|
insilmaril@0
|
39 |
void closeEvent( QCloseEvent* );
|
insilmaril@0
|
40 |
|
insilmaril@0
|
41 |
|
insilmaril@0
|
42 |
public:
|
insilmaril@0
|
43 |
QString getText();
|
insilmaril@0
|
44 |
|
insilmaril@0
|
45 |
public slots:
|
insilmaril@0
|
46 |
void editorChanged(); // received when text() changed
|
insilmaril@0
|
47 |
void setText(QString); // set Text (by MapEditor)
|
insilmaril@0
|
48 |
void setInactive(); // Nothing can be entered
|
insilmaril@0
|
49 |
void editCopyAll();
|
insilmaril@0
|
50 |
|
insilmaril@0
|
51 |
signals:
|
insilmaril@0
|
52 |
void textHasChanged();
|
insilmaril@0
|
53 |
void fontFamilyHasChanged();
|
insilmaril@0
|
54 |
void fontSizeHasChanged();
|
insilmaril@0
|
55 |
|
insilmaril@0
|
56 |
private slots:
|
insilmaril@0
|
57 |
void textLoad();
|
insilmaril@0
|
58 |
void textSaveAs();
|
insilmaril@0
|
59 |
void textSave();
|
insilmaril@0
|
60 |
void textConvertPar();
|
insilmaril@0
|
61 |
void textJoinLines();
|
insilmaril@0
|
62 |
void textExportAsASCII();
|
insilmaril@0
|
63 |
void textPrint();
|
insilmaril@0
|
64 |
void textEditUndo();
|
insilmaril@0
|
65 |
void toggleFonthint();
|
insilmaril@0
|
66 |
void setFixedFont();
|
insilmaril@0
|
67 |
void setVarFont();
|
insilmaril@0
|
68 |
void textBold();
|
insilmaril@0
|
69 |
void textUnderline();
|
insilmaril@0
|
70 |
void textItalic();
|
insilmaril@0
|
71 |
void textFamily( const QString &f );
|
insilmaril@0
|
72 |
void textSize( const QString &p );
|
insilmaril@0
|
73 |
void textColor();
|
insilmaril@0
|
74 |
void textAlign(QAction*);
|
jhilmer@142
|
75 |
void textVAlign();
|
insilmaril@0
|
76 |
void fontChanged( const QFont &f );
|
insilmaril@0
|
77 |
void colorChanged( const QColor &c );
|
insilmaril@0
|
78 |
void alignmentChanged( int a );
|
jhilmer@142
|
79 |
void verticalAlignmentChanged(int a);
|
insilmaril@0
|
80 |
void enableActions();
|
insilmaril@0
|
81 |
void disableActions();
|
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 |
|
jhilmer@142
|
130 |
/* 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:
|
jhilmer@142
|
142 |
MyTextEdit(QWidget *parent, const char *name) : QTextEdit(parent, name) {
|
jhilmer@142
|
143 |
connect(this,
|
jhilmer@142
|
144 |
SIGNAL(currentVerticalAlignmentChanged(VerticalAlignment)),
|
jhilmer@142
|
145 |
this,
|
jhilmer@142
|
146 |
SLOT(verticalAlignmentChanged(VerticalAlignment)));
|
jhilmer@142
|
147 |
}
|
jhilmer@142
|
148 |
int verticalAlignment() const { return m_verticalAlignment; }
|
jhilmer@142
|
149 |
signals:
|
jhilmer@142
|
150 |
void currentVerticalAlignmentChanged(int a);
|
jhilmer@142
|
151 |
public slots:
|
jhilmer@142
|
152 |
void verticalAlignmentChanged(VerticalAlignment a) {
|
jhilmer@142
|
153 |
m_verticalAlignment = a;
|
jhilmer@142
|
154 |
emit currentVerticalAlignmentChanged((int)a);
|
jhilmer@142
|
155 |
}
|
jhilmer@142
|
156 |
private:
|
jhilmer@142
|
157 |
int m_verticalAlignment;
|
insilmaril@0
|
158 |
};
|
insilmaril@0
|
159 |
|
insilmaril@0
|
160 |
#endif
|