-rw-r--r-- | noncore/apps/opie-console/widget_layer.h | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h index adf2038..d821f1d 100644 --- a/noncore/apps/opie-console/widget_layer.h +++ b/noncore/apps/opie-console/widget_layer.h | |||
@@ -1,217 +1,237 @@ | |||
1 | /* -------------------------------------------------------------------------- */ | 1 | /* -------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* [widget_layer.h] Widget Layer */ | 3 | /* [widget_layer.h] Widget Layer */ |
4 | /* */ | 4 | /* */ |
5 | /* -------------------------------------------------------------------------- */ | 5 | /* -------------------------------------------------------------------------- */ |
6 | 6 | ||
7 | // proposal of a widget Layer in opie-console | 7 | // proposal of a widget Layer in opie-console |
8 | // | 8 | // |
9 | // fellow devels: | 9 | // fellow devels: |
10 | // just mail me (ibotty@web.de), what you additionally need from the main widget | 10 | // just mail me (ibotty@web.de), what you additionally need from the main widget |
11 | // (or say in chat) | 11 | // (or say in chat) |
12 | 12 | ||
13 | #ifndef WIDGET_LAYER_H | 13 | #ifndef WIDGET_LAYER_H |
14 | #define WIDGET_LAYER_H | 14 | #define WIDGET_LAYER_H |
15 | 15 | ||
16 | // qt includes | 16 | // qt includes |
17 | #include <qapplication.h> | 17 | #include <qapplication.h> |
18 | #include <qframe.h> | 18 | #include <qframe.h> |
19 | #include <qarray.h> | 19 | #include <qarray.h> |
20 | #include <qtimer.h> | 20 | #include <qtimer.h> |
21 | #include <qkeycode.h> | 21 | #include <qkeycode.h> |
22 | #include <qclipboard.h> | 22 | #include <qclipboard.h> |
23 | 23 | ||
24 | 24 | ||
25 | // opie-console includes | 25 | // opie-console includes |
26 | #include "session.h" | 26 | #include "session.h" |
27 | #include "common.h" | 27 | #include "common.h" |
28 | 28 | ||
29 | /* | 29 | /* |
30 | * given a pseudo location ( column, line ), | 30 | * given a pseudo location ( column, line ), |
31 | * returns the actual index, in the QArray<Character> | 31 | * returns the actual index, in the QArray<Character> |
32 | */ | 32 | */ |
33 | #define loc(X,Y) ((Y)*m_columns+(X)) | 33 | #define loc(X,Y) ((Y)*m_columns+(X)) |
34 | 34 | ||
35 | 35 | ||
36 | 36 | ||
37 | 37 | ||
38 | class WidgetLayer : public QFrame | 38 | class WidgetLayer : public QFrame |
39 | { Q_OBJECT | 39 | { Q_OBJECT |
40 | 40 | ||
41 | public: | 41 | public: |
42 | 42 | ||
43 | /** | 43 | /** |
44 | * constructor | 44 | * constructor |
45 | * @param const Profile &config, the configuration for this widget | ||
46 | * @param QWidget *parent, the parent widget | ||
47 | * @param const char *name, the name of the widget, defaults to "" | ||
45 | */ | 48 | */ |
46 | WidgetLayer( QWidget *parent=0, const char *name=0 ); | 49 | WidgetLayer( const Profile &config, QWidget *parent=0, const char *name=0 ); |
47 | 50 | ||
48 | /** | 51 | /** |
49 | * destructor | 52 | * destructor |
50 | */ | 53 | */ |
51 | virtual ~WidgetLayer(); | 54 | virtual ~WidgetLayer(); |
52 | 55 | ||
53 | public: | 56 | public: |
54 | /** | 57 | /** |
55 | * sets the image | 58 | * sets the image |
59 | * @param QArray<Character> const newimg, the new image | ||
60 | * @param int lines, lines count of newimg | ||
61 | * @param int columns, columns count of newimg | ||
56 | */ | 62 | */ |
57 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; | 63 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; |
58 | 64 | ||
59 | /** | 65 | /** |
60 | * annoy the user | 66 | * annoy the user |
61 | */ | 67 | */ |
62 | void bell(); | 68 | void bell(); |
63 | 69 | ||
64 | /** | 70 | /** |
65 | * return the lines count | 71 | * @return int m_lines, the lines count |
66 | */ | 72 | */ |
67 | int lines(){ return m_lines; } | 73 | int lines(){ return m_lines; } |
68 | 74 | ||
69 | /** | 75 | /** |
70 | * return the columns count | 76 | * @return int m_columns, the columns count |
71 | */ | 77 | */ |
72 | int columns(){ return m_columns; } | 78 | int columns(){ return m_columns; } |
73 | 79 | ||
74 | /** | 80 | /** |
75 | * insert current selection (currently this is only the clipboard) | 81 | * insert current selection (currently this is only the clipboard) |
76 | */ | 82 | */ |
77 | void insertSelection(); | 83 | void insertSelection(); |
78 | 84 | ||
79 | /** | 85 | /** |
80 | * insert text | 86 | * insert text |
87 | * @param QString text, the text to be inserted | ||
81 | */ | 88 | */ |
82 | void insertText( QString text ); | 89 | void insertText( QString text ); |
90 | |||
83 | /** | 91 | /** |
84 | * set selection (clipboard) to text | 92 | * set selection (clipboard) to text |
93 | * @param const QString &text, the text to be selected | ||
85 | */ | 94 | */ |
86 | void setSelection( const QString &text ); | 95 | void setSelection( const QString &text ); |
87 | 96 | ||
88 | /** | 97 | /** |
89 | * paste content of clipboard | 98 | * paste content of clipboard |
90 | */ | 99 | */ |
91 | void pasteClipboard(); | 100 | void pasteClipboard(); |
92 | 101 | ||
93 | 102 | ||
94 | signals: | 103 | signals: |
95 | 104 | ||
96 | /** | 105 | /** |
97 | * key was pressed | 106 | * key was pressed |
98 | */ | 107 | */ |
99 | void keyPressed( QKeyEvent *e ); | 108 | void keyPressed( QKeyEvent *e ); |
100 | 109 | ||
101 | /** | 110 | /** |
102 | * whenever Mouse selects something | 111 | * whenever Mouse selects something |
103 | * 0left Button | 112 | * @param int button, the button that us pressed : |
104 | * 3Button released | 113 | * 0left Button |
114 | * 3Button released | ||
115 | * @param int x, x position | ||
116 | * @param int y, y position | ||
117 | * | ||
105 | * // numbering due to layout in old TEWidget | 118 | * // numbering due to layout in old TEWidget |
106 | */ | 119 | */ |
107 | void mousePressed( int button, int x, int y ); | 120 | void mousePressed( int button, int x, int y ); |
108 | 121 | ||
109 | /** | 122 | /** |
110 | * size of image changed | 123 | * size of image changed |
124 | * @param int lines, line count of new size | ||
125 | * @param int columns, column count of new size | ||
111 | */ | 126 | */ |
112 | void imageSizeChanged( int lines, int columns ); | 127 | void imageSizeChanged( int lines, int columns ); |
113 | 128 | ||
114 | /** | 129 | /** |
115 | * cursor in history changed | 130 | * cursor in history changed |
131 | * @param int value, value of history cursor | ||
116 | */ | 132 | */ |
117 | void historyCursorChanged( int value ); | 133 | void historyCursorChanged( int value ); |
118 | 134 | ||
119 | /** | 135 | /** |
120 | * selection should be cleared | 136 | * selection should be cleared |
121 | */ | 137 | */ |
122 | void selectionCleared(); | 138 | void selectionCleared(); |
123 | 139 | ||
124 | /** | 140 | /** |
125 | * selection begin | 141 | * selection begin |
142 | * @param const int x, x position | ||
143 | * @param const int y, y position | ||
126 | */ | 144 | */ |
127 | void selectionBegin( const int x, const int y ); | 145 | void selectionBegin( const int x, const int y ); |
128 | 146 | ||
129 | /** | 147 | /** |
130 | * selection extended | 148 | * selection extended |
131 | * (from begin (s.a.) to x, y) | 149 | * (from begin (s.a.) to x, y) |
150 | * @param const int x, x position | ||
151 | * @param const int y, y position | ||
132 | */ | 152 | */ |
133 | void selectionExtended( const int x, const int y ); | 153 | void selectionExtended( const int x, const int y ); |
134 | 154 | ||
135 | /** | 155 | /** |
136 | * selection end | 156 | * selection end |
137 | * bool: preserve line breaks in selection | 157 | * @param const bool lineBreakPreserve, preserve line breaks in selection |
138 | */ | 158 | */ |
139 | void selectionEnd( const bool lineBreakPreserve ); | 159 | void selectionEnd( const bool lineBreakPreserve ); |
140 | 160 | ||
141 | 161 | ||
142 | 162 | ||
143 | // protected methods | 163 | // protected methods |
144 | protected: | 164 | protected: |
145 | 165 | ||
146 | // image operations | 166 | // image operations |
147 | 167 | ||
148 | /** | 168 | /** |
149 | * changes image, to suit new size | 169 | * changes image, to suit new size |
150 | * TODO: find meaningful name! | 170 | * TODO: find meaningful name! |
151 | */ | 171 | */ |
152 | void propagateSize(); | 172 | void propagateSize(); |
153 | 173 | ||
154 | /** | 174 | /** |
155 | *determines count of lines and columns | 175 | *determines count of lines and columns |
156 | */ | 176 | */ |
157 | virtual void calcGeometry() = 0; | 177 | virtual void calcGeometry() = 0; |
158 | 178 | ||
159 | /** | 179 | /** |
160 | * makes an empty image | 180 | * makes an empty image |
161 | */ | 181 | */ |
162 | void makeImage(); | 182 | void makeImage(); |
163 | 183 | ||
164 | /** | 184 | /** |
165 | * clears the image | 185 | * clears the image |
166 | */ | 186 | */ |
167 | void clearImage(); | 187 | void clearImage(); |
168 | 188 | ||
169 | protected slots: | 189 | protected slots: |
170 | 190 | ||
171 | /** | 191 | /** |
172 | * clear selection | 192 | * clear selection |
173 | */ | 193 | */ |
174 | void onClearSelection(); | 194 | void onClearSelection(); |
175 | 195 | ||
176 | 196 | ||
177 | // protected vars | 197 | // protected vars |
178 | protected: | 198 | protected: |
179 | 199 | ||
180 | /** | 200 | /** |
181 | * current Session | 201 | * current Session |
182 | */ | 202 | */ |
183 | Session *m_session; | 203 | Session *m_session; |
184 | 204 | ||
185 | /** | 205 | /** |
186 | * current character image | 206 | * current character image |
187 | * | 207 | * |
188 | * a Character at loc( column, line ) | 208 | * a Character at loc( column, line ) |
189 | * has the actual index: | 209 | * has the actual index: |
190 | * ix = line * m_columns + column; | 210 | * ix = line * m_columns + column; |
191 | * | 211 | * |
192 | * use loc( x, y ) macro to access. | 212 | * use loc( x, y ) macro to access. |
193 | */ | 213 | */ |
194 | QArray<Character> m_image; | 214 | QArray<Character> m_image; |
195 | 215 | ||
196 | /** | 216 | /** |
197 | * lines count | 217 | * lines count |
198 | */ | 218 | */ |
199 | int m_lines; | 219 | int m_lines; |
200 | 220 | ||
201 | /** | 221 | /** |
202 | * columns count | 222 | * columns count |
203 | */ | 223 | */ |
204 | int m_columns; | 224 | int m_columns; |
205 | 225 | ||
206 | /** | 226 | /** |
207 | * clipboard | 227 | * clipboard |
208 | */ | 228 | */ |
209 | QClipboard* m_clipboard; | 229 | QClipboard* m_clipboard; |
210 | 230 | ||
211 | /** | 231 | /** |
212 | * whether widget is resizing | 232 | * whether widget is resizing |
213 | */ | 233 | */ |
214 | bool m_resizing; | 234 | bool m_resizing; |
215 | }; | 235 | }; |
216 | 236 | ||
217 | #endif // WIDGET_LAYER_H | 237 | #endif // WIDGET_LAYER_H |