author | ibotty <ibotty> | 2002-10-13 21:37:12 (UTC) |
---|---|---|
committer | ibotty <ibotty> | 2002-10-13 21:37:12 (UTC) |
commit | 49269558da49b0429e4b13f4ed8ac2b3ac4f3513 (patch) (unidiff) | |
tree | 799475cf2819088c12714258307ceb72652e6895 | |
parent | 5a6ecdac2e62708b55300ca6eef8441fea0a7b05 (diff) | |
download | opie-49269558da49b0429e4b13f4ed8ac2b3ac4f3513.zip opie-49269558da49b0429e4b13f4ed8ac2b3ac4f3513.tar.gz opie-49269558da49b0429e4b13f4ed8ac2b3ac4f3513.tar.bz2 |
added additional functionality (dont really know what anymore....)
-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 | |||
@@ -7,135 +7,135 @@ | |||
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(); |
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 | |||
@@ -59,129 +59,129 @@ public: | |||
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: |