author | wazlaf <wazlaf> | 2002-10-13 11:15:57 (UTC) |
---|---|---|
committer | wazlaf <wazlaf> | 2002-10-13 11:15:57 (UTC) |
commit | fb76065a9041fb9c0fef43127509dcdb2478c1ab (patch) (unidiff) | |
tree | e8d131f99f34d35b434484cd13805c0a32762d3e | |
parent | 72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c (diff) | |
download | opie-fb76065a9041fb9c0fef43127509dcdb2478c1ab.zip opie-fb76065a9041fb9c0fef43127509dcdb2478c1ab.tar.gz opie-fb76065a9041fb9c0fef43127509dcdb2478c1ab.tar.bz2 |
compilation fixes
-rw-r--r-- | noncore/apps/opie-console/widget_layer.cpp | 11 |
1 files changed, 0 insertions, 11 deletions
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp index 3875a6e..0364e66 100644 --- a/noncore/apps/opie-console/widget_layer.cpp +++ b/noncore/apps/opie-console/widget_layer.cpp | |||
@@ -1,249 +1,238 @@ | |||
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 | } | 42 | } |
43 | 43 | ||
44 | 44 | ||
45 | WidgetLayer::~WidgetLayer() | 45 | WidgetLayer::~WidgetLayer() |
46 | { | 46 | { |
47 | // clean up | 47 | // clean up |
48 | delete m_image; | 48 | delete m_image; |
49 | } | 49 | } |
50 | 50 | ||
51 | /* --------------------------------- audio ---------------------------------- */ | 51 | /* --------------------------------- audio ---------------------------------- */ |
52 | 52 | ||
53 | void WidgetLayer::bell() | 53 | void WidgetLayer::bell() |
54 | { | 54 | { |
55 | QApplication::beep(); | 55 | QApplication::beep(); |
56 | } | 56 | } |
57 | 57 | ||
58 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) | 58 | bool WidgetLayer::eventFilter( QObject *obj, QEvent *e ) |
59 | { | 59 | { |
60 | if ( (e->type() == QEvent::Accel || | 60 | if ( (e->type() == QEvent::Accel || |
61 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | 61 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { |
62 | static_cast<QKeyEvent *>( e )->ignore(); | 62 | static_cast<QKeyEvent *>( e )->ignore(); |
63 | return true; | 63 | return true; |
64 | } | 64 | } |
65 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | 65 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) |
66 | return FALSE; // not us | 66 | return FALSE; // not us |
67 | if ( e->type() == QEvent::Wheel) { | ||
68 | QApplication::sendEvent( m_scrollbar, e); | ||
69 | } | ||
70 | 67 | ||
71 | #ifdef FAKE_CTRL_AND_ALT | 68 | #ifdef FAKE_CTRL_AND_ALT |
72 | static bool control = FALSE; | 69 | static bool control = FALSE; |
73 | static bool alt = FALSE; | 70 | static bool alt = FALSE; |
74 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | 71 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); |
75 | bool dele=FALSE; | 72 | bool dele=FALSE; |
76 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | 73 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { |
77 | QKeyEvent* ke = (QKeyEvent*)e; | 74 | QKeyEvent* ke = (QKeyEvent*)e; |
78 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | 75 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); |
79 | switch (ke->key()) { | 76 | switch (ke->key()) { |
80 | case Key_F9: // let this be "Control" | 77 | case Key_F9: // let this be "Control" |
81 | control = keydown; | 78 | control = keydown; |
82 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | 79 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); |
83 | dele=TRUE; | 80 | dele=TRUE; |
84 | break; | 81 | break; |
85 | case Key_F13: // let this be "Alt" | 82 | case Key_F13: // let this be "Alt" |
86 | alt = keydown; | 83 | alt = keydown; |
87 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | 84 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); |
88 | dele=TRUE; | 85 | dele=TRUE; |
89 | break; | 86 | break; |
90 | default: | 87 | default: |
91 | if ( control ) { | 88 | if ( control ) { |
92 | int a = toupper(ke->ascii())-64; | 89 | int a = toupper(ke->ascii())-64; |
93 | if ( a >= 0 && a < ' ' ) { | 90 | if ( a >= 0 && a < ' ' ) { |
94 | e = new QKeyEvent(e->type(), ke->key(), | 91 | e = new QKeyEvent(e->type(), ke->key(), |
95 | a, ke->state()|ControlButton, | 92 | a, ke->state()|ControlButton, |
96 | QChar(a,0)); | 93 | QChar(a,0)); |
97 | dele=TRUE; | 94 | dele=TRUE; |
98 | } | 95 | } |
99 | } | 96 | } |
100 | if ( alt ) { | 97 | if ( alt ) { |
101 | e = new QKeyEvent(e->type(), ke->key(), | 98 | e = new QKeyEvent(e->type(), ke->key(), |
102 | ke->ascii(), ke->state()|AltButton, ke->text()); | 99 | ke->ascii(), ke->state()|AltButton, ke->text()); |
103 | dele=TRUE; | 100 | dele=TRUE; |
104 | } | 101 | } |
105 | } | 102 | } |
106 | } | 103 | } |
107 | #endif | 104 | #endif |
108 | 105 | ||
109 | if ( e->type() == QEvent::KeyPress ) { | 106 | if ( e->type() == QEvent::KeyPress ) { |
110 | QKeyEvent* ke = (QKeyEvent*)e; | 107 | QKeyEvent* ke = (QKeyEvent*)e; |
111 | //actSel=0; // Key stroke implies a screen update, so Widget won't | 108 | //actSel=0; // Key stroke implies a screen update, so Widget won't |
112 | // know where the current selection is. | 109 | // know where the current selection is. |
113 | 110 | ||
114 | // qDebug("key pressed is 0x%x",ke->key()); | 111 | // qDebug("key pressed is 0x%x",ke->key()); |
115 | 112 | ||
116 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | 113 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker |
117 | insertText("\\"); // expose | 114 | insertText("\\"); // expose |
118 | } else | 115 | } else |
119 | emit keyPressed( ke ); // expose | 116 | emit keyPressed( ke ); // expose |
120 | ke->accept(); | 117 | ke->accept(); |
121 | #ifdef FAKE_CTRL_AND_ALT | 118 | #ifdef FAKE_CTRL_AND_ALT |
122 | if ( dele ) delete e; | 119 | if ( dele ) delete e; |
123 | #endif | 120 | #endif |
124 | return true; // stop the event | 121 | return true; // stop the event |
125 | } | 122 | } |
126 | if ( e->type() == QEvent::Enter ) { | ||
127 | QObject::disconnect( (QObject*)cb, SIGNAL(dataChanged()), | ||
128 | this, SLOT(onClearSelection()) ); | ||
129 | } | ||
130 | if ( e->type() == QEvent::Leave ) { | ||
131 | QObject::connect( (QObject*)cb, SIGNAL(dataChanged()), | ||
132 | this, SLOT(onClearSelection()) ); | ||
133 | } | ||
134 | return QFrame::eventFilter( obj, e ); | 123 | return QFrame::eventFilter( obj, e ); |
135 | } | 124 | } |
136 | 125 | ||
137 | 126 | ||
138 | /* --------------------------------- screen --------------------------------- */ | 127 | /* --------------------------------- screen --------------------------------- */ |
139 | 128 | ||
140 | 129 | ||
141 | void WidgetLayer::propagateSize() | 130 | void WidgetLayer::propagateSize() |
142 | { | 131 | { |
143 | QArray<Character> oldimage = m_image.copy(); | 132 | QArray<Character> oldimage = m_image.copy(); |
144 | int oldlines = m_lines; | 133 | int oldlines = m_lines; |
145 | int oldcolumns = m_columns; | 134 | int oldcolumns = m_columns; |
146 | 135 | ||
147 | makeImage(); | 136 | makeImage(); |
148 | 137 | ||
149 | // copy old image, to reduce flicker | 138 | // copy old image, to reduce flicker |
150 | if ( ! oldimage.isEmpty() ) | 139 | if ( ! oldimage.isEmpty() ) |
151 | { | 140 | { |
152 | int lins = QMIN( oldlines, m_lines ); | 141 | int lins = QMIN( oldlines, m_lines ); |
153 | int cols = QMIN( oldcolumns, m_columns ); | 142 | int cols = QMIN( oldcolumns, m_columns ); |
154 | for ( int lin = 0; lin < lins; ++lin ) | 143 | for ( int lin = 0; lin < lins; ++lin ) |
155 | { | 144 | { |
156 | memcpy( (void*) &m_image[m_columns*lin], | 145 | memcpy( (void*) &m_image[m_columns*lin], |
157 | (void*) &oldimage[oldcolumns*lin], | 146 | (void*) &oldimage[oldcolumns*lin], |
158 | cols*sizeof( Character ) ); | 147 | cols*sizeof( Character ) ); |
159 | } | 148 | } |
160 | } | 149 | } |
161 | else | 150 | else |
162 | clearImage(); | 151 | clearImage(); |
163 | 152 | ||
164 | delete oldimage; | 153 | delete oldimage; |
165 | 154 | ||
166 | m_resizing = true; | 155 | m_resizing = true; |
167 | emit imageSizeChanged( m_lines, m_columns ); | 156 | emit imageSizeChanged( m_lines, m_columns ); |
168 | m_resizing = false; | 157 | m_resizing = false; |
169 | } | 158 | } |
170 | 159 | ||
171 | void WidgetLayer::makeImage() | 160 | void WidgetLayer::makeImage() |
172 | { | 161 | { |
173 | calcGeometry(); | 162 | calcGeometry(); |
174 | m_image = QArray<Character>( m_columns * m_lines ); | 163 | m_image = QArray<Character>( m_columns * m_lines ); |
175 | clearImage(); | 164 | clearImage(); |
176 | } | 165 | } |
177 | 166 | ||
178 | void WidgetLayer::clearImage() | 167 | void WidgetLayer::clearImage() |
179 | { | 168 | { |
180 | //should this belong here?? | 169 | //should this belong here?? |
181 | for ( int y = 0; y < m_lines; y++ ) | 170 | for ( int y = 0; y < m_lines; y++ ) |
182 | for ( int x = 0; x < m_columns; x++ ) | 171 | for ( int x = 0; x < m_columns; x++ ) |
183 | { | 172 | { |
184 | m_image[loc(x,y)].c = 0xff; | 173 | m_image[loc(x,y)].c = 0xff; |
185 | m_image[loc(x,y)].f = 0xff; | 174 | m_image[loc(x,y)].f = 0xff; |
186 | m_image[loc(x,y)].b = 0xff; | 175 | m_image[loc(x,y)].b = 0xff; |
187 | m_image[loc(x,y)].r = 0xff; | 176 | m_image[loc(x,y)].r = 0xff; |
188 | } | 177 | } |
189 | } | 178 | } |
190 | 179 | ||
191 | /* --------------------------------- selection ------------------------------ */ | 180 | /* --------------------------------- selection ------------------------------ */ |
192 | 181 | ||
193 | void WidgetLayer::pasteClipboard() | 182 | void WidgetLayer::pasteClipboard() |
194 | { | 183 | { |
195 | insertSelection(); | 184 | insertSelection(); |
196 | } | 185 | } |
197 | 186 | ||
198 | 187 | ||
199 | void WidgetLayer::insertSelection() | 188 | void WidgetLayer::insertSelection() |
200 | { | 189 | { |
201 | QString text = QApplication::clipboard()->text(); | 190 | QString text = QApplication::clipboard()->text(); |
202 | if ( ! text.isNull() ) | 191 | if ( ! text.isNull() ) |
203 | { | 192 | { |
204 | text.replace( QRegExp( "\n" ), "\r" ); | 193 | text.replace( QRegExp( "\n" ), "\r" ); |
205 | insertText( text ); | 194 | insertText( text ); |
206 | // selection should be unselected | 195 | // selection should be unselected |
207 | emit selectionCleared(); | 196 | emit selectionCleared(); |
208 | } | 197 | } |
209 | } | 198 | } |
210 | 199 | ||
211 | void WidgetLayer::insertText( QString text ) | 200 | void WidgetLayer::insertText( QString text ) |
212 | { | 201 | { |
213 | // text is inserted as key event | 202 | // text is inserted as key event |
214 | QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); | 203 | QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); |
215 | emit keyPressed( &e ); | 204 | emit keyPressed( &e ); |
216 | } | 205 | } |
217 | 206 | ||
218 | void WidgetLayer::onClearSelection() | 207 | void WidgetLayer::onClearSelection() |
219 | { | 208 | { |
220 | emit selectionCleared(); | 209 | emit selectionCleared(); |
221 | } | 210 | } |
222 | 211 | ||
223 | void WidgetLayer::setSelection( const QString& text ) | 212 | void WidgetLayer::setSelection( const QString& text ) |
224 | { | 213 | { |
225 | // why get the clipboard, we have it as instance var... | 214 | // why get the clipboard, we have it as instance var... |
226 | QObject *m_clipboard = QApplication::clipboard(); | 215 | QObject *m_clipboard = QApplication::clipboard(); |
227 | 216 | ||
228 | // we know, that cliboard changes, when we change clipboard | 217 | // we know, that cliboard changes, when we change clipboard |
229 | QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 218 | QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
230 | (QObject*) this, SLOT( selectionCleared() ) ); | 219 | (QObject*) this, SLOT( selectionCleared() ) ); |
231 | 220 | ||
232 | QApplication::clipboard()->setText( text ); | 221 | QApplication::clipboard()->setText( text ); |
233 | 222 | ||
234 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 223 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
235 | (QObject*) this, SLOT( selectionCleared() ) ); | 224 | (QObject*) this, SLOT( selectionCleared() ) ); |
236 | } | 225 | } |
237 | 226 | ||
238 | 227 | ||
239 | ///////// | 228 | ///////// |
240 | // special font characters | 229 | // special font characters |
241 | ///////// | 230 | ///////// |
242 | unsigned short vt100_graphics[32] = | 231 | unsigned short vt100_graphics[32] = |
243 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | 232 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 |
244 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | 233 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
245 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | 234 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
246 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | 235 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, |
247 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | 236 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 |
248 | }; | 237 | }; |
249 | 238 | ||