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