-rw-r--r-- | noncore/apps/opie-console/widget_layer.cpp | 8 | ||||
-rw-r--r-- | noncore/apps/opie-console/widget_layer.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp index 6682708..e4b0ede 100644 --- a/noncore/apps/opie-console/widget_layer.cpp +++ b/noncore/apps/opie-console/widget_layer.cpp | |||
@@ -1,243 +1,243 @@ | |||
1 | /* ------------------------------------------------------------------------- */ | 1 | /* ------------------------------------------------------------------------- */ |
2 | /* */ | 2 | /* */ |
3 | /* widget_layer.cpp Widget Layer */ | 3 | /* widget_layer.cpp Widget Layer */ |
4 | /* */ | 4 | /* */ |
5 | /* opie developers <opie@handhelds.org> */ | 5 | /* opie developers <opie@handhelds.org> */ |
6 | /* */ | 6 | /* */ |
7 | /* ------------------------------------------------------------------------- */ | 7 | /* ------------------------------------------------------------------------- */ |
8 | 8 | ||
9 | 9 | ||
10 | 10 | ||
11 | #include "widget_layer.h" | 11 | #include "widget_layer.h" |
12 | 12 | ||
13 | #include <qclipboard.h> | 13 | #include <qclipboard.h> |
14 | #include <qregexp.h> | 14 | #include <qregexp.h> |
15 | #include <qglobal.h> | 15 | #include <qglobal.h> |
16 | 16 | ||
17 | #include <string.h> | 17 | #include <string.h> |
18 | //#include < | 18 | //#include < |
19 | 19 | ||
20 | #include "common.h" | 20 | #include "common.h" |
21 | 21 | ||
22 | 22 | ||
23 | 23 | ||
24 | WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name ) | 24 | WidgetLayer::WidgetLayer( const Profile &config, QWidget *parent, const char *name ) : QFrame( parent, name ) |
25 | { | 25 | { |
26 | // get the clipboard | 26 | // get the clipboard |
27 | m_clipboard = QApplication::clipboard(); | 27 | m_clipboard = QApplication::clipboard(); |
28 | 28 | ||
29 | // when data on clipboard changes, clear selection | 29 | // when data on clipboard changes, clear selection |
30 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 30 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
31 | (QObject*)this, SLOT( onClearSelection() ) ); | 31 | (QObject*)this, SLOT( onClearSelection() ) ); |
32 | 32 | ||
33 | // initialize vars: | 33 | // initialize vars: |
34 | m_lines = 1; | 34 | m_lines = 1; |
35 | m_columns = 1; | 35 | m_columns = 1; |
36 | m_resizing = false; | 36 | m_resizing = false; |
37 | 37 | ||
38 | // just for demonstrating | 38 | // just for demonstrating |
39 | //m_image = QArray<Character>( m_lines * m_columns ); | 39 | //m_image = QArray<Character>( m_lines * m_columns ); |
40 | m_image = QArray<Character>( 1 ); | 40 | m_image = QArray<Character>( 1 ); |
41 | 41 | ||
42 | // we need to install an event filter, | 42 | // we need to install an event filter, |
43 | // to emit keypresses. | 43 | // to emit keypresses. |
44 | qApp->installEventFilter( this ); | 44 | qApp->installEventFilter( this ); |
45 | 45 | ||
46 | } | 46 | } |
47 | 47 | ||
48 | 48 | ||
49 | WidgetLayer::~WidgetLayer() | 49 | WidgetLayer::~WidgetLayer() |
50 | { | 50 | { |
51 | // clean up | 51 | // clean up |
52 | delete m_image; | 52 | delete m_image; |
53 | } | 53 | } |
54 | 54 | ||
55 | 55 | ||
56 | /* --------------------------------- audio ---------------------------------- */ | 56 | /* --------------------------------- audio ---------------------------------- */ |
57 | 57 | ||
58 | void WidgetLayer::bell() | 58 | void WidgetLayer::bell() |
59 | { | 59 | { |
60 | QApplication::beep(); | 60 | QApplication::beep(); |
61 | } | 61 | } |
62 | 62 | ||
63 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) | 63 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) |
64 | { | 64 | { |
65 | if ( (e->type() == QEvent::Accel || | 65 | if ( (e->type() == QEvent::Accel || |
66 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 66 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
67 | static_cast<QKeyEvent *>( e )->ignore(); | 67 | static_cast<QKeyEvent *>( e )->ignore(); |
68 | return true; | 68 | return true; |
69 | } | 69 | } |
70 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 70 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
71 | return FALSE; // not us | 71 | return false; // not us |
72 | 72 | ||
73 | #ifdef FAKE_CTRL_AND_ALT | 73 | #ifdef FAKE_CTRL_AND_ALT |
74 | static bool control = FALSE; | 74 | static bool control = false; |
75 | static bool alt = FALSE; | 75 | static bool alt = false; |
76 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 76 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
77 | bool dele=FALSE; | 77 | bool dele = false; |
78 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 78 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
79 | QKeyEvent* ke = (QKeyEvent*)e; | 79 | QKeyEvent* ke = (QKeyEvent*)e; |
80 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 80 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
81 | switch (ke->key()) { | 81 | switch (ke->key()) { |
82 | case Key_F9: // let this be "Control" | 82 | case Key_F9: // let this be "Control" |
83 | control = keydown; | 83 | control = keydown; |
84 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 84 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
85 | dele=TRUE; | 85 | dele=TRUE; |
86 | break; | 86 | break; |
87 | case Key_F13: // let this be "Alt" | 87 | case Key_F13: // let this be "Alt" |
88 | alt = keydown; | 88 | alt = keydown; |
89 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 89 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
90 | dele=TRUE; | 90 | dele=TRUE; |
91 | break; | 91 | break; |
92 | default: | 92 | default: |
93 | if ( control ) { | 93 | if ( control ) { |
94 | int a = toupper(ke->ascii())-64; | 94 | int a = toupper(ke->ascii())-64; |
95 | if ( a >= 0 && a < ' ' ) { | 95 | if ( a >= 0 && a < ' ' ) { |
96 | e = new QKeyEvent(e->type(), ke->key(), | 96 | e = new QKeyEvent(e->type(), ke->key(), |
97 | a, ke->state()|ControlButton, | 97 | a, ke->state()|ControlButton, |
98 | QChar(a,0)); | 98 | QChar(a,0)); |
99 | dele=TRUE; | 99 | dele=TRUE; |
100 | } | 100 | } |
101 | } | 101 | } |
102 | if ( alt ) { | 102 | if ( alt ) { |
103 | e = new QKeyEvent(e->type(), ke->key(), | 103 | e = new QKeyEvent(e->type(), ke->key(), |
104 | ke->ascii(), ke->state()|AltButton, ke->text()); | 104 | ke->ascii(), ke->state()|AltButton, ke->text()); |
105 | dele=TRUE; | 105 | dele=TRUE; |
106 | } | 106 | } |
107 | } | 107 | } |
108 | } | 108 | } |
109 | #endif | 109 | #endif |
110 | 110 | ||
111 | if ( e->type() == QEvent::KeyPress ) { | 111 | if ( e->type() == QEvent::KeyPress ) { |
112 | QKeyEvent* ke = (QKeyEvent*)e; | 112 | QKeyEvent* ke = (QKeyEvent*)e; |
113 | //actSel=0; // Key stroke implies a screen update, so Widget won't | 113 | //actSel=0; // Key stroke implies a screen update, so Widget won't |
114 | // know where the current selection is. | 114 | // know where the current selection is. |
115 | 115 | ||
116 | // qDebug("key pressed is 0x%x",ke->key()); | 116 | // qDebug("key pressed is 0x%x",ke->key()); |
117 | 117 | ||
118 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | 118 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker |
119 | insertText("\\"); // expose | 119 | insertText("\\"); // expose |
120 | } else | 120 | } else |
121 | emit keyPressed( ke ); // expose | 121 | emit keyPressed( ke ); // expose |
122 | ke->accept(); | 122 | ke->accept(); |
123 | #ifdef FAKE_CTRL_AND_ALT | 123 | #ifdef FAKE_CTRL_AND_ALT |
124 | if ( dele ) delete e; | 124 | if ( dele ) delete e; |
125 | #endif | 125 | #endif |
126 | return true; // stop the event | 126 | return true; // stop the event |
127 | } | 127 | } |
128 | return QFrame::eventFilter( obj, e ); | 128 | return QFrame::eventFilter( obj, e ); |
129 | } | 129 | } |
130 | 130 | ||
131 | 131 | ||
132 | /* --------------------------------- screen --------------------------------- */ | 132 | /* --------------------------------- screen --------------------------------- */ |
133 | 133 | ||
134 | 134 | ||
135 | void WidgetLayer::propagateSize() | 135 | void WidgetLayer::propagateSize() |
136 | { | 136 | { |
137 | QArray<Character> oldimage = m_image.copy(); | 137 | QArray<Character> oldimage = m_image.copy(); |
138 | int oldlines = m_lines; | 138 | int oldlines = m_lines; |
139 | int oldcolumns = m_columns; | 139 | int oldcolumns = m_columns; |
140 | 140 | ||
141 | makeImage(); | 141 | makeImage(); |
142 | 142 | ||
143 | // copy old image, to reduce flicker | 143 | // copy old image, to reduce flicker |
144 | if ( ! oldimage.isEmpty() ) | 144 | if ( ! oldimage.isEmpty() ) |
145 | { | 145 | { |
146 | int lins = QMIN( oldlines, m_lines ); | 146 | int lins = QMIN( oldlines, m_lines ); |
147 | int cols = QMIN( oldcolumns, m_columns ); | 147 | int cols = QMIN( oldcolumns, m_columns ); |
148 | for ( int lin = 0; lin < lins; ++lin ) | 148 | for ( int lin = 0; lin < lins; ++lin ) |
149 | { | 149 | { |
150 | memcpy( (void*) &m_image[m_columns*lin], | 150 | memcpy( (void*) &m_image[m_columns*lin], |
151 | (void*) &oldimage[oldcolumns*lin], | 151 | (void*) &oldimage[oldcolumns*lin], |
152 | cols*sizeof( Character ) ); | 152 | cols*sizeof( Character ) ); |
153 | } | 153 | } |
154 | } | 154 | } |
155 | else | 155 | else |
156 | clearImage(); | 156 | clearImage(); |
157 | 157 | ||
158 | delete oldimage; | 158 | delete oldimage; |
159 | 159 | ||
160 | m_resizing = true; | 160 | m_resizing = true; |
161 | emit imageSizeChanged( m_lines, m_columns ); | 161 | emit imageSizeChanged( m_lines, m_columns ); |
162 | m_resizing = false; | 162 | m_resizing = false; |
163 | } | 163 | } |
164 | 164 | ||
165 | void WidgetLayer::makeImage() | 165 | void WidgetLayer::makeImage() |
166 | { | 166 | { |
167 | calcGeometry(); | 167 | calcGeometry(); |
168 | m_image = QArray<Character>( m_columns * m_lines ); | 168 | m_image = QArray<Character>( m_columns * m_lines ); |
169 | clearImage(); | 169 | clearImage(); |
170 | } | 170 | } |
171 | 171 | ||
172 | void WidgetLayer::clearImage() | 172 | void WidgetLayer::clearImage() |
173 | { | 173 | { |
174 | //should this belong here?? | 174 | //should this belong here?? |
175 | for ( int y = 0; y < m_lines; y++ ) | 175 | for ( int y = 0; y < m_lines; y++ ) |
176 | for ( int x = 0; x < m_columns; x++ ) | 176 | for ( int x = 0; x < m_columns; x++ ) |
177 | { | 177 | { |
178 | m_image[loc(x,y)].c = 0xff; | 178 | m_image[loc(x,y)].c = 0xff; |
179 | m_image[loc(x,y)].f = 0xff; | 179 | m_image[loc(x,y)].f = 0xff; |
180 | m_image[loc(x,y)].b = 0xff; | 180 | m_image[loc(x,y)].b = 0xff; |
181 | m_image[loc(x,y)].r = 0xff; | 181 | m_image[loc(x,y)].r = 0xff; |
182 | } | 182 | } |
183 | } | 183 | } |
184 | 184 | ||
185 | /* --------------------------------- selection ------------------------------ */ | 185 | /* --------------------------------- selection ------------------------------ */ |
186 | 186 | ||
187 | void WidgetLayer::pasteClipboard() | 187 | void WidgetLayer::pasteClipboard() |
188 | { | 188 | { |
189 | insertSelection(); | 189 | insertSelection(); |
190 | } | 190 | } |
191 | 191 | ||
192 | 192 | ||
193 | void WidgetLayer::insertSelection() | 193 | void WidgetLayer::insertSelection() |
194 | { | 194 | { |
195 | QString text = QApplication::clipboard()->text(); | 195 | QString text = QApplication::clipboard()->text(); |
196 | if ( ! text.isNull() ) | 196 | if ( ! text.isNull() ) |
197 | { | 197 | { |
198 | text.replace( QRegExp( "\n" ), "\r" ); | 198 | text.replace( QRegExp( "\n" ), "\r" ); |
199 | insertText( text ); | 199 | insertText( text ); |
200 | // selection should be unselected | 200 | // selection should be unselected |
201 | emit selectionCleared(); | 201 | emit selectionCleared(); |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||
205 | void WidgetLayer::insertText( QString text ) | 205 | void WidgetLayer::insertText( QString text ) |
206 | { | 206 | { |
207 | // text is inserted as key event | 207 | // text is inserted as key event |
208 | QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); | 208 | QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); |
209 | emit keyPressed( &e ); | 209 | emit keyPressed( &e ); |
210 | } | 210 | } |
211 | 211 | ||
212 | void WidgetLayer::onClearSelection() | 212 | void WidgetLayer::onClearSelection() |
213 | { | 213 | { |
214 | emit selectionCleared(); | 214 | emit selectionCleared(); |
215 | } | 215 | } |
216 | 216 | ||
217 | void WidgetLayer::setSelection( const QString& text ) | 217 | void WidgetLayer::setSelection( const QString& text ) |
218 | { | 218 | { |
219 | // why get the clipboard, we have it as instance var... | 219 | // why get the clipboard, we have it as instance var... |
220 | QObject *m_clipboard = QApplication::clipboard(); | 220 | QObject *m_clipboard = QApplication::clipboard(); |
221 | 221 | ||
222 | // we know, that cliboard changes, when we change clipboard | 222 | // we know, that cliboard changes, when we change clipboard |
223 | QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 223 | QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
224 | (QObject*) this, SLOT( selectionCleared() ) ); | 224 | (QObject*) this, SLOT( selectionCleared() ) ); |
225 | 225 | ||
226 | QApplication::clipboard()->setText( text ); | 226 | QApplication::clipboard()->setText( text ); |
227 | 227 | ||
228 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 228 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
229 | (QObject*) this, SLOT( selectionCleared() ) ); | 229 | (QObject*) this, SLOT( selectionCleared() ) ); |
230 | } | 230 | } |
231 | 231 | ||
232 | 232 | ||
233 | ///////// | 233 | ///////// |
234 | // special font characters | 234 | // special font characters |
235 | ///////// | 235 | ///////// |
236 | unsigned short vt100_graphics[32] = | 236 | unsigned short vt100_graphics[32] = |
237 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | 237 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 |
238 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | 238 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
239 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | 239 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
240 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | 240 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, |
241 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | 241 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 |
242 | }; | 242 | }; |
243 | 243 | ||
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h index 1d96bf4..0c290f3 100644 --- a/noncore/apps/opie-console/widget_layer.h +++ b/noncore/apps/opie-console/widget_layer.h | |||
@@ -1,260 +1,260 @@ | |||
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 | #include "profile.h" | 28 | #include "profile.h" |
29 | 29 | ||
30 | 30 | ||
31 | /* | 31 | /* |
32 | * given a pseudo location ( column, line ), | 32 | * given a pseudo location ( column, line ), |
33 | * returns the actual index, in the QArray<Character> | 33 | * returns the actual index, in the QArray<Character> |
34 | */ | 34 | */ |
35 | #define loc(X,Y) ((Y)*m_columns+(X)) | 35 | #define loc(X,Y) ((Y)*m_columns+(X)) |
36 | 36 | ||
37 | 37 | ||
38 | 38 | ||
39 | extern unsigned short vt100_graphics[32]; | 39 | extern unsigned short vt100_graphics[32]; |
40 | 40 | ||
41 | class WidgetLayer : public QFrame | 41 | class WidgetLayer : public QFrame |
42 | { Q_OBJECT | 42 | { Q_OBJECT |
43 | 43 | ||
44 | public: | 44 | public: |
45 | 45 | ||
46 | /** | 46 | /** |
47 | * constructor | 47 | * constructor |
48 | * @param const Profile &config, the configuration for this widget | 48 | * @param const Profile &config, the configuration for this widget |
49 | * @param QWidget *parent, the parent widget | 49 | * @param QWidget *parent, the parent widget |
50 | * @param const char *name, the name of the widget, defaults to "" | 50 | * @param const char *name, the name of the widget, defaults to "" |
51 | */ | 51 | */ |
52 | WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 ); | 52 | WidgetLayer( const Profile& config, QWidget *parent=0, const char *name=0 ); |
53 | 53 | ||
54 | /** | 54 | /** |
55 | * destructor | 55 | * destructor |
56 | */ | 56 | */ |
57 | virtual ~WidgetLayer(); | 57 | virtual ~WidgetLayer(); |
58 | 58 | ||
59 | public: | 59 | public: |
60 | /** | 60 | /** |
61 | * sets the image | 61 | * sets the image |
62 | * @param QArray<Character> const newimg, the new image | 62 | * @param QArray<Character> const newimg, the new image |
63 | * @param int lines, lines count of newimg | 63 | * @param int lines, lines count of newimg |
64 | * @param int columns, columns count of newimg | 64 | * @param int columns, columns count of newimg |
65 | */ | 65 | */ |
66 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; | 66 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ) = 0; |
67 | 67 | ||
68 | /** | 68 | /** |
69 | * annoy the user | 69 | * annoy the user |
70 | */ | 70 | */ |
71 | void bell(); | 71 | void bell(); |
72 | 72 | ||
73 | /** | 73 | /** |
74 | * @return int m_lines, the lines count | 74 | * @return int m_lines, the lines count |
75 | */ | 75 | */ |
76 | int lines(){ return m_lines; } | 76 | int lines(){ return m_lines; } |
77 | 77 | ||
78 | /** | 78 | /** |
79 | * @return int m_columns, the columns count | 79 | * @return int m_columns, the columns count |
80 | */ | 80 | */ |
81 | int columns(){ return m_columns; } | 81 | int columns(){ return m_columns; } |
82 | 82 | ||
83 | /** | 83 | /** |
84 | * insert current selection (currently this is only the clipboard) | 84 | * insert current selection (currently this is only the clipboard) |
85 | */ | 85 | */ |
86 | void insertSelection(); | 86 | void insertSelection(); |
87 | 87 | ||
88 | /** | 88 | /** |
89 | * insert text | 89 | * insert text |
90 | * @param QString text, the text to be inserted | 90 | * @param QString text, the text to be inserted |
91 | */ | 91 | */ |
92 | void insertText( QString text ); | 92 | void insertText( QString text ); |
93 | 93 | ||
94 | /** | 94 | /** |
95 | * set selection (clipboard) to text | 95 | * set selection (clipboard) to text |
96 | * @param const QString &text, the text to be selected | 96 | * @param const QString &text, the text to be selected |
97 | */ | 97 | */ |
98 | void setSelection( const QString &text ); | 98 | void setSelection( const QString &text ); |
99 | 99 | ||
100 | /** | 100 | /** |
101 | * paste content of clipboard | 101 | * paste content of clipboard |
102 | */ | 102 | */ |
103 | void pasteClipboard(); | 103 | void pasteClipboard(); |
104 | 104 | ||
105 | 105 | ||
106 | /** | 106 | /** |
107 | * reload configuration | 107 | * reload configuration |
108 | * @param const Profile& config, the config to be used (may be the same as in constructor) | 108 | * @param const Profile& config, the config to be used (may be the same as in constructor) |
109 | */ | 109 | */ |
110 | virtual void reloadConfig( const Profile& config ) = 0; | 110 | virtual void reloadConfig( const Profile& config ) = 0; |
111 | 111 | ||
112 | 112 | ||
113 | /** | 113 | /** |
114 | * sets the scrollbar (if implemented by successor of this class) | 114 | * sets the scrollbar (if implemented by successor of this class) |
115 | */ | 115 | */ |
116 | virtual void setScroll( int cursor, int slines ) = 0; | 116 | virtual void setScroll( int cursor, int slines ) = 0; |
117 | 117 | ||
118 | /** | 118 | /** |
119 | * scrolls (if implemented, by successor of this class) | 119 | * scrolls (if implemented, by successor of this class) |
120 | * @param int value, how much the widget should scroll up (positive value) or down (negative value) | 120 | * @param int value, how much the widget should scroll up (positive value) or down (negative value) |
121 | */ | 121 | */ |
122 | virtual void scroll( int value ) = 0; | 122 | virtual void scroll( int value ) = 0; |
123 | 123 | ||
124 | 124 | ||
125 | virtual bool eventFilter( QObject *obj, QEvent *event ); | 125 | virtual bool eventFilter( QObject *obj, QEvent *event ); |
126 | signals: | 126 | signals: |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * key was pressed | 129 | * key was pressed |
130 | */ | 130 | */ |
131 | void keyPressed( QKeyEvent *e ); | 131 | void keyPressed( QKeyEvent *e ); |
132 | 132 | ||
133 | /** | 133 | /** |
134 | * whenever Mouse selects something | 134 | * whenever Mouse selects something |
135 | * @param int button, the button that us pressed : | 135 | * @param int button, the button that us pressed : |
136 | * 0left Button | 136 | * 0left Button |
137 | * 3Button released | 137 | * 3Button released |
138 | * @param int x, x position | 138 | * @param int x, x position |
139 | * @param int y, y position | 139 | * @param int y, y position |
140 | * | 140 | * |
141 | * // numbering due to layout in old TEWidget | 141 | * // numbering due to layout in old TEWidget |
142 | */ | 142 | */ |
143 | void mousePressed( int button, int x, int y ); | 143 | void mousePressed( int button, int x, int y ); |
144 | 144 | ||
145 | /** | 145 | /** |
146 | * size of image changed | 146 | * size of image changed |
147 | * @param int lines, line count of new size | 147 | * @param int lines, line count of new size |
148 | * @param int columns, column count of new size | 148 | * @param int columns, column count of new size |
149 | */ | 149 | */ |
150 | void imageSizeChanged( int lines, int columns ); | 150 | void imageSizeChanged( int lines, int columns ); |
151 | 151 | ||
152 | /** | 152 | /** |
153 | * cursor in history changed | 153 | * cursor in history changed |
154 | * @param int value, value of history cursor | 154 | * @param int value, value of history cursor |
155 | */ | 155 | */ |
156 | void historyCursorChanged( int value ); | 156 | void historyCursorChanged( int value ); |
157 | 157 | ||
158 | /** | 158 | /** |
159 | * selection should be cleared | 159 | * selection should be cleared |
160 | */ | 160 | */ |
161 | void selectionCleared(); | 161 | void selectionCleared(); |
162 | 162 | ||
163 | /** | 163 | /** |
164 | * selection begin | 164 | * selection begin |
165 | * @param const int x, x position | 165 | * @param const int x, x position |
166 | * @param const int y, y position | 166 | * @param const int y, y position |
167 | */ | 167 | */ |
168 | void selectionBegin( const int x, const int y ); | 168 | void selectionBegin( const int x, const int y ); |
169 | 169 | ||
170 | /** | 170 | /** |
171 | * selection extended | 171 | * selection extended |
172 | * (from begin (s.a.) to x, y) | 172 | * (from begin (s.a.) to x, y) |
173 | * @param const int x, x position | 173 | * @param const int x, x position |
174 | * @param const int y, y position | 174 | * @param const int y, y position |
175 | */ | 175 | */ |
176 | void selectionExtended( const int x, const int y ); | 176 | void selectionExtended( const int x, const int y ); |
177 | 177 | ||
178 | /** | 178 | /** |
179 | * selection end | 179 | * selection end |
180 | * @param const bool lineBreakPreserve, preserve line breaks in selection | 180 | * @param const bool lineBreakPreserve, preserve line breaks in selection |
181 | */ | 181 | */ |
182 | void selectionEnd( const bool lineBreakPreserve ); | 182 | void selectionEnd( const bool lineBreakPreserve ); |
183 | 183 | ||
184 | 184 | ||
185 | 185 | ||
186 | // protected methods | 186 | // protected methods |
187 | protected: | 187 | protected: |
188 | 188 | ||
189 | // image operations | 189 | // image operations |
190 | 190 | ||
191 | /** | 191 | /** |
192 | * changes image, to suit new size | 192 | * changes image, to suit new size |
193 | * TODO: find meaningful name! | 193 | * TODO: find meaningful name! |
194 | */ | 194 | */ |
195 | void propagateSize(); | 195 | void propagateSize(); |
196 | 196 | ||
197 | /** | 197 | /** |
198 | *determines count of lines and columns | 198 | *determines count of lines and columns |
199 | */ | 199 | */ |
200 | virtual void calcGeometry() = 0; | 200 | virtual void calcGeometry() = 0; |
201 | 201 | ||
202 | /** | 202 | /** |
203 | * makes an empty image | 203 | * makes an empty image |
204 | */ | 204 | */ |
205 | void makeImage(); | 205 | void makeImage(); |
206 | 206 | ||
207 | /** | 207 | /** |
208 | * clears the image | 208 | * clears the image |
209 | */ | 209 | */ |
210 | void clearImage(); | 210 | void clearImage(); |
211 | 211 | ||
212 | protected slots: | 212 | protected slots: |
213 | 213 | ||
214 | /** | 214 | /** |
215 | * clear selection | 215 | * clear selection |
216 | */ | 216 | */ |
217 | void onClearSelection(); | 217 | void onClearSelection(); |
218 | 218 | ||
219 | 219 | ||
220 | // protected vars | 220 | // protected vars |
221 | protected: | 221 | protected: |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * current Session | 224 | * current Session |
225 | */ | 225 | */ |
226 | Session *m_session; | 226 | Session *m_session; |
227 | 227 | ||
228 | /** | 228 | /** |
229 | * current character image | 229 | * current character image |
230 | * | 230 | * |
231 | * a Character at loc( column, line ) | 231 | * a Character at loc( column, line ) |
232 | * has the actual index: | 232 | * has the actual index: |
233 | * ix = line * m_columns + column; | 233 | * ix = line * m_columns + column; |
234 | * | 234 | * |
235 | * use loc( x, y ) macro to access. | 235 | * use loc( x, y ) macro to access. |
236 | */ | 236 | */ |
237 | QArray<Character> m_image; | 237 | QArray<Character> m_image; |
238 | 238 | ||
239 | /** | 239 | /** |
240 | * lines count | 240 | * lines count |
241 | */ | 241 | */ |
242 | int m_lines; | 242 | int m_lines; |
243 | 243 | ||
244 | /** | 244 | /** |
245 | * columns count | 245 | * columns count |
246 | */ | 246 | */ |
247 | int m_columns; | 247 | int m_columns; |
248 | 248 | ||
249 | /** | 249 | /** |
250 | * clipboard | 250 | * clipboard |
251 | */ | 251 | */ |
252 | QClipboard* m_clipboard; | 252 | QClipboard* m_clipboard; |
253 | 253 | ||
254 | /** | 254 | /** |
255 | * whether widget is resizing | 255 | * whether widget is resizing |
256 | */ | 256 | */ |
257 | bool m_resizing; | 257 | bool m_resizing; |
258 | }; | 258 | }; |
259 | 259 | ||
260 | #endif // WIDGET_LAYER_H | 260 | #endif // WIDGET_LAYER_H |