author | ibotty <ibotty> | 2002-10-13 10:49:21 (UTC) |
---|---|---|
committer | ibotty <ibotty> | 2002-10-13 10:49:21 (UTC) |
commit | 72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c (patch) (unidiff) | |
tree | 95ddc3c8ec3740d9544d6df08695a26fb52d46c9 | |
parent | b8377d9c462d7edbc92c6809503cb53a09f8fd98 (diff) | |
download | opie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.zip opie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.tar.gz opie-72d9ce37fdd97b7ff37111e365cc8a14e0bbc52c.tar.bz2 |
does not work... but committed to get things started
-rw-r--r-- | noncore/apps/opie-console/widget_layer.cpp | 79 | ||||
-rw-r--r-- | noncore/apps/opie-console/widget_layer.h | 2 |
2 files changed, 81 insertions, 0 deletions
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp index c00871f..3875a6e 100644 --- a/noncore/apps/opie-console/widget_layer.cpp +++ b/noncore/apps/opie-console/widget_layer.cpp | |||
@@ -1,170 +1,249 @@ | |||
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 ) | ||
59 | { | ||
60 | if ( (e->type() == QEvent::Accel || | ||
61 | e->type() == QEvent::AccelAvailable ) && qApp->focusWidget() == this ) { | ||
62 | static_cast<QKeyEvent *>( e )->ignore(); | ||
63 | return true; | ||
64 | } | ||
65 | if ( obj != this /* when embedded */ && obj != parent() /* when standalone */ ) | ||
66 | return FALSE; // not us | ||
67 | if ( e->type() == QEvent::Wheel) { | ||
68 | QApplication::sendEvent( m_scrollbar, e); | ||
69 | } | ||
70 | |||
71 | #ifdef FAKE_CTRL_AND_ALT | ||
72 | static bool control = FALSE; | ||
73 | static bool alt = FALSE; | ||
74 | // qDebug(" Has a keyboard with no CTRL and ALT keys, but we fake it:"); | ||
75 | bool dele=FALSE; | ||
76 | if ( e->type() == QEvent::KeyPress || e->type() == QEvent::KeyRelease ) { | ||
77 | QKeyEvent* ke = (QKeyEvent*)e; | ||
78 | bool keydown = e->type() == QEvent::KeyPress || ke->isAutoRepeat(); | ||
79 | switch (ke->key()) { | ||
80 | case Key_F9: // let this be "Control" | ||
81 | control = keydown; | ||
82 | e = new QKeyEvent(QEvent::KeyPress, Key_Control, 0, ke->state()); | ||
83 | dele=TRUE; | ||
84 | break; | ||
85 | case Key_F13: // let this be "Alt" | ||
86 | alt = keydown; | ||
87 | e = new QKeyEvent(QEvent::KeyPress, Key_Alt, 0, ke->state()); | ||
88 | dele=TRUE; | ||
89 | break; | ||
90 | default: | ||
91 | if ( control ) { | ||
92 | int a = toupper(ke->ascii())-64; | ||
93 | if ( a >= 0 && a < ' ' ) { | ||
94 | e = new QKeyEvent(e->type(), ke->key(), | ||
95 | a, ke->state()|ControlButton, | ||
96 | QChar(a,0)); | ||
97 | dele=TRUE; | ||
98 | } | ||
99 | } | ||
100 | if ( alt ) { | ||
101 | e = new QKeyEvent(e->type(), ke->key(), | ||
102 | ke->ascii(), ke->state()|AltButton, ke->text()); | ||
103 | dele=TRUE; | ||
104 | } | ||
105 | } | ||
106 | } | ||
107 | #endif | ||
108 | |||
109 | if ( e->type() == QEvent::KeyPress ) { | ||
110 | QKeyEvent* ke = (QKeyEvent*)e; | ||
111 | //actSel=0; // Key stroke implies a screen update, so Widget won't | ||
112 | // know where the current selection is. | ||
113 | |||
114 | // qDebug("key pressed is 0x%x",ke->key()); | ||
115 | |||
116 | if( ke->state() == ShiftButton && ke->key() == Key_Tab) { //lets hardcode this sucker | ||
117 | insertText("\\"); // expose | ||
118 | } else | ||
119 | emit keyPressed( ke ); // expose | ||
120 | ke->accept(); | ||
121 | #ifdef FAKE_CTRL_AND_ALT | ||
122 | if ( dele ) delete e; | ||
123 | #endif | ||
124 | return true; // stop the event | ||
125 | } | ||
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 ); | ||
135 | } | ||
136 | |||
58 | 137 | ||
59 | /* --------------------------------- screen --------------------------------- */ | 138 | /* --------------------------------- screen --------------------------------- */ |
60 | 139 | ||
61 | 140 | ||
62 | void WidgetLayer::propagateSize() | 141 | void WidgetLayer::propagateSize() |
63 | { | 142 | { |
64 | QArray<Character> oldimage = m_image.copy(); | 143 | QArray<Character> oldimage = m_image.copy(); |
65 | int oldlines = m_lines; | 144 | int oldlines = m_lines; |
66 | int oldcolumns = m_columns; | 145 | int oldcolumns = m_columns; |
67 | 146 | ||
68 | makeImage(); | 147 | makeImage(); |
69 | 148 | ||
70 | // copy old image, to reduce flicker | 149 | // copy old image, to reduce flicker |
71 | if ( ! oldimage.isEmpty() ) | 150 | if ( ! oldimage.isEmpty() ) |
72 | { | 151 | { |
73 | int lins = QMIN( oldlines, m_lines ); | 152 | int lins = QMIN( oldlines, m_lines ); |
74 | int cols = QMIN( oldcolumns, m_columns ); | 153 | int cols = QMIN( oldcolumns, m_columns ); |
75 | for ( int lin = 0; lin < lins; ++lin ) | 154 | for ( int lin = 0; lin < lins; ++lin ) |
76 | { | 155 | { |
77 | memcpy( (void*) &m_image[m_columns*lin], | 156 | memcpy( (void*) &m_image[m_columns*lin], |
78 | (void*) &oldimage[oldcolumns*lin], | 157 | (void*) &oldimage[oldcolumns*lin], |
79 | cols*sizeof( Character ) ); | 158 | cols*sizeof( Character ) ); |
80 | } | 159 | } |
81 | } | 160 | } |
82 | else | 161 | else |
83 | clearImage(); | 162 | clearImage(); |
84 | 163 | ||
85 | delete oldimage; | 164 | delete oldimage; |
86 | 165 | ||
87 | m_resizing = true; | 166 | m_resizing = true; |
88 | emit imageSizeChanged( m_lines, m_columns ); | 167 | emit imageSizeChanged( m_lines, m_columns ); |
89 | m_resizing = false; | 168 | m_resizing = false; |
90 | } | 169 | } |
91 | 170 | ||
92 | void WidgetLayer::makeImage() | 171 | void WidgetLayer::makeImage() |
93 | { | 172 | { |
94 | calcGeometry(); | 173 | calcGeometry(); |
95 | m_image = QArray<Character>( m_columns * m_lines ); | 174 | m_image = QArray<Character>( m_columns * m_lines ); |
96 | clearImage(); | 175 | clearImage(); |
97 | } | 176 | } |
98 | 177 | ||
99 | void WidgetLayer::clearImage() | 178 | void WidgetLayer::clearImage() |
100 | { | 179 | { |
101 | //should this belong here?? | 180 | //should this belong here?? |
102 | for ( int y = 0; y < m_lines; y++ ) | 181 | for ( int y = 0; y < m_lines; y++ ) |
103 | for ( int x = 0; x < m_columns; x++ ) | 182 | for ( int x = 0; x < m_columns; x++ ) |
104 | { | 183 | { |
105 | m_image[loc(x,y)].c = 0xff; | 184 | m_image[loc(x,y)].c = 0xff; |
106 | m_image[loc(x,y)].f = 0xff; | 185 | m_image[loc(x,y)].f = 0xff; |
107 | m_image[loc(x,y)].b = 0xff; | 186 | m_image[loc(x,y)].b = 0xff; |
108 | m_image[loc(x,y)].r = 0xff; | 187 | m_image[loc(x,y)].r = 0xff; |
109 | } | 188 | } |
110 | } | 189 | } |
111 | 190 | ||
112 | /* --------------------------------- selection ------------------------------ */ | 191 | /* --------------------------------- selection ------------------------------ */ |
113 | 192 | ||
114 | void WidgetLayer::pasteClipboard() | 193 | void WidgetLayer::pasteClipboard() |
115 | { | 194 | { |
116 | insertSelection(); | 195 | insertSelection(); |
117 | } | 196 | } |
118 | 197 | ||
119 | 198 | ||
120 | void WidgetLayer::insertSelection() | 199 | void WidgetLayer::insertSelection() |
121 | { | 200 | { |
122 | QString text = QApplication::clipboard()->text(); | 201 | QString text = QApplication::clipboard()->text(); |
123 | if ( ! text.isNull() ) | 202 | if ( ! text.isNull() ) |
124 | { | 203 | { |
125 | text.replace( QRegExp( "\n" ), "\r" ); | 204 | text.replace( QRegExp( "\n" ), "\r" ); |
126 | insertText( text ); | 205 | insertText( text ); |
127 | // selection should be unselected | 206 | // selection should be unselected |
128 | emit selectionCleared(); | 207 | emit selectionCleared(); |
129 | } | 208 | } |
130 | } | 209 | } |
131 | 210 | ||
132 | void WidgetLayer::insertText( QString text ) | 211 | void WidgetLayer::insertText( QString text ) |
133 | { | 212 | { |
134 | // text is inserted as key event | 213 | // text is inserted as key event |
135 | QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); | 214 | QKeyEvent e( QEvent::KeyPress, 0, -1, 0, text); |
136 | emit keyPressed( &e ); | 215 | emit keyPressed( &e ); |
137 | } | 216 | } |
138 | 217 | ||
139 | void WidgetLayer::onClearSelection() | 218 | void WidgetLayer::onClearSelection() |
140 | { | 219 | { |
141 | emit selectionCleared(); | 220 | emit selectionCleared(); |
142 | } | 221 | } |
143 | 222 | ||
144 | void WidgetLayer::setSelection( const QString& text ) | 223 | void WidgetLayer::setSelection( const QString& text ) |
145 | { | 224 | { |
146 | // why get the clipboard, we have it as instance var... | 225 | // why get the clipboard, we have it as instance var... |
147 | QObject *m_clipboard = QApplication::clipboard(); | 226 | QObject *m_clipboard = QApplication::clipboard(); |
148 | 227 | ||
149 | // we know, that cliboard changes, when we change clipboard | 228 | // we know, that cliboard changes, when we change clipboard |
150 | QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 229 | QObject::disconnect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
151 | (QObject*) this, SLOT( selectionCleared() ) ); | 230 | (QObject*) this, SLOT( selectionCleared() ) ); |
152 | 231 | ||
153 | QApplication::clipboard()->setText( text ); | 232 | QApplication::clipboard()->setText( text ); |
154 | 233 | ||
155 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 234 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
156 | (QObject*) this, SLOT( selectionCleared() ) ); | 235 | (QObject*) this, SLOT( selectionCleared() ) ); |
157 | } | 236 | } |
158 | 237 | ||
159 | 238 | ||
160 | ///////// | 239 | ///////// |
161 | // special font characters | 240 | // special font characters |
162 | ///////// | 241 | ///////// |
163 | unsigned short vt100_graphics[32] = | 242 | unsigned short vt100_graphics[32] = |
164 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 | 243 | { // 0/8 1/9 2/10 3/11 4/12 5/13 6/14 7/15 |
165 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, | 244 | 0x0020, 0x25C6, 0x2592, 0x2409, 0x240c, 0x240d, 0x240a, 0x00b0, |
166 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, | 245 | 0x00b1, 0x2424, 0x240b, 0x2518, 0x2510, 0x250c, 0x2514, 0x253c, |
167 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, | 246 | 0xF800, 0xF801, 0x2500, 0xF803, 0xF804, 0x251c, 0x2524, 0x2534, |
168 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 | 247 | 0x252c, 0x2502, 0x2264, 0x2265, 0x03C0, 0x2260, 0x00A3, 0x00b7 |
169 | }; | 248 | }; |
170 | 249 | ||
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h index 067f3da..1d96bf4 100644 --- a/noncore/apps/opie-console/widget_layer.h +++ b/noncore/apps/opie-console/widget_layer.h | |||
@@ -1,258 +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 | |||
125 | virtual bool eventFilter( QObject *obj, QEvent *event ); | ||
124 | signals: | 126 | signals: |
125 | 127 | ||
126 | /** | 128 | /** |
127 | * key was pressed | 129 | * key was pressed |
128 | */ | 130 | */ |
129 | void keyPressed( QKeyEvent *e ); | 131 | void keyPressed( QKeyEvent *e ); |
130 | 132 | ||
131 | /** | 133 | /** |
132 | * whenever Mouse selects something | 134 | * whenever Mouse selects something |
133 | * @param int button, the button that us pressed : | 135 | * @param int button, the button that us pressed : |
134 | * 0left Button | 136 | * 0left Button |
135 | * 3Button released | 137 | * 3Button released |
136 | * @param int x, x position | 138 | * @param int x, x position |
137 | * @param int y, y position | 139 | * @param int y, y position |
138 | * | 140 | * |
139 | * // numbering due to layout in old TEWidget | 141 | * // numbering due to layout in old TEWidget |
140 | */ | 142 | */ |
141 | void mousePressed( int button, int x, int y ); | 143 | void mousePressed( int button, int x, int y ); |
142 | 144 | ||
143 | /** | 145 | /** |
144 | * size of image changed | 146 | * size of image changed |
145 | * @param int lines, line count of new size | 147 | * @param int lines, line count of new size |
146 | * @param int columns, column count of new size | 148 | * @param int columns, column count of new size |
147 | */ | 149 | */ |
148 | void imageSizeChanged( int lines, int columns ); | 150 | void imageSizeChanged( int lines, int columns ); |
149 | 151 | ||
150 | /** | 152 | /** |
151 | * cursor in history changed | 153 | * cursor in history changed |
152 | * @param int value, value of history cursor | 154 | * @param int value, value of history cursor |
153 | */ | 155 | */ |
154 | void historyCursorChanged( int value ); | 156 | void historyCursorChanged( int value ); |
155 | 157 | ||
156 | /** | 158 | /** |
157 | * selection should be cleared | 159 | * selection should be cleared |
158 | */ | 160 | */ |
159 | void selectionCleared(); | 161 | void selectionCleared(); |
160 | 162 | ||
161 | /** | 163 | /** |
162 | * selection begin | 164 | * selection begin |
163 | * @param const int x, x position | 165 | * @param const int x, x position |
164 | * @param const int y, y position | 166 | * @param const int y, y position |
165 | */ | 167 | */ |
166 | void selectionBegin( const int x, const int y ); | 168 | void selectionBegin( const int x, const int y ); |
167 | 169 | ||
168 | /** | 170 | /** |
169 | * selection extended | 171 | * selection extended |
170 | * (from begin (s.a.) to x, y) | 172 | * (from begin (s.a.) to x, y) |
171 | * @param const int x, x position | 173 | * @param const int x, x position |
172 | * @param const int y, y position | 174 | * @param const int y, y position |
173 | */ | 175 | */ |
174 | void selectionExtended( const int x, const int y ); | 176 | void selectionExtended( const int x, const int y ); |
175 | 177 | ||
176 | /** | 178 | /** |
177 | * selection end | 179 | * selection end |
178 | * @param const bool lineBreakPreserve, preserve line breaks in selection | 180 | * @param const bool lineBreakPreserve, preserve line breaks in selection |
179 | */ | 181 | */ |
180 | void selectionEnd( const bool lineBreakPreserve ); | 182 | void selectionEnd( const bool lineBreakPreserve ); |
181 | 183 | ||
182 | 184 | ||
183 | 185 | ||
184 | // protected methods | 186 | // protected methods |
185 | protected: | 187 | protected: |
186 | 188 | ||
187 | // image operations | 189 | // image operations |
188 | 190 | ||
189 | /** | 191 | /** |
190 | * changes image, to suit new size | 192 | * changes image, to suit new size |
191 | * TODO: find meaningful name! | 193 | * TODO: find meaningful name! |
192 | */ | 194 | */ |
193 | void propagateSize(); | 195 | void propagateSize(); |
194 | 196 | ||
195 | /** | 197 | /** |
196 | *determines count of lines and columns | 198 | *determines count of lines and columns |
197 | */ | 199 | */ |
198 | virtual void calcGeometry() = 0; | 200 | virtual void calcGeometry() = 0; |
199 | 201 | ||
200 | /** | 202 | /** |
201 | * makes an empty image | 203 | * makes an empty image |
202 | */ | 204 | */ |
203 | void makeImage(); | 205 | void makeImage(); |
204 | 206 | ||
205 | /** | 207 | /** |
206 | * clears the image | 208 | * clears the image |
207 | */ | 209 | */ |
208 | void clearImage(); | 210 | void clearImage(); |
209 | 211 | ||
210 | protected slots: | 212 | protected slots: |
211 | 213 | ||
212 | /** | 214 | /** |
213 | * clear selection | 215 | * clear selection |
214 | */ | 216 | */ |
215 | void onClearSelection(); | 217 | void onClearSelection(); |
216 | 218 | ||
217 | 219 | ||
218 | // protected vars | 220 | // protected vars |
219 | protected: | 221 | protected: |
220 | 222 | ||
221 | /** | 223 | /** |
222 | * current Session | 224 | * current Session |
223 | */ | 225 | */ |
224 | Session *m_session; | 226 | Session *m_session; |
225 | 227 | ||
226 | /** | 228 | /** |
227 | * current character image | 229 | * current character image |
228 | * | 230 | * |
229 | * a Character at loc( column, line ) | 231 | * a Character at loc( column, line ) |
230 | * has the actual index: | 232 | * has the actual index: |
231 | * ix = line * m_columns + column; | 233 | * ix = line * m_columns + column; |
232 | * | 234 | * |
233 | * use loc( x, y ) macro to access. | 235 | * use loc( x, y ) macro to access. |
234 | */ | 236 | */ |
235 | QArray<Character> m_image; | 237 | QArray<Character> m_image; |
236 | 238 | ||
237 | /** | 239 | /** |
238 | * lines count | 240 | * lines count |
239 | */ | 241 | */ |
240 | int m_lines; | 242 | int m_lines; |
241 | 243 | ||
242 | /** | 244 | /** |
243 | * columns count | 245 | * columns count |
244 | */ | 246 | */ |
245 | int m_columns; | 247 | int m_columns; |
246 | 248 | ||
247 | /** | 249 | /** |
248 | * clipboard | 250 | * clipboard |
249 | */ | 251 | */ |
250 | QClipboard* m_clipboard; | 252 | QClipboard* m_clipboard; |
251 | 253 | ||
252 | /** | 254 | /** |
253 | * whether widget is resizing | 255 | * whether widget is resizing |
254 | */ | 256 | */ |
255 | bool m_resizing; | 257 | bool m_resizing; |
256 | }; | 258 | }; |
257 | 259 | ||
258 | #endif // WIDGET_LAYER_H | 260 | #endif // WIDGET_LAYER_H |