author | ibotty <ibotty> | 2002-10-07 13:23:14 (UTC) |
---|---|---|
committer | ibotty <ibotty> | 2002-10-07 13:23:14 (UTC) |
commit | 68d98791b05217163f97d7c233952df8075416bb (patch) (unidiff) | |
tree | da2ad4d16d62053ca5b836cd08d37364ec12b635 | |
parent | a513a88322196c8caa21b00b83d454feae84200c (diff) | |
download | opie-68d98791b05217163f97d7c233952df8075416bb.zip opie-68d98791b05217163f97d7c233952df8075416bb.tar.gz opie-68d98791b05217163f97d7c233952df8075416bb.tar.bz2 |
changed WidgetLayer to a new (well partial) image storage
WidgetLayer is now to be considered stable.
there wont be any api removals.
newwidget.{h,cpp} will inherit WidgetLayer, soon.
i will try to be logic compatible with current widget.{h,cpp}, but will NOT
guarantee api compatibility.
-rw-r--r-- | noncore/apps/opie-console/widget_layer.cpp | 26 | ||||
-rw-r--r-- | noncore/apps/opie-console/widget_layer.h | 27 |
2 files changed, 36 insertions, 17 deletions
diff --git a/noncore/apps/opie-console/widget_layer.cpp b/noncore/apps/opie-console/widget_layer.cpp index 28227e4..f428ed4 100644 --- a/noncore/apps/opie-console/widget_layer.cpp +++ b/noncore/apps/opie-console/widget_layer.cpp | |||
@@ -21,8 +21,6 @@ | |||
21 | 21 | ||
22 | 22 | ||
23 | #define loc(X,Y) ((Y)*m_columns+(X)) | ||
24 | 23 | ||
25 | 24 | WidgetLayer::WidgetLayer( QWidget *parent, const char *name ) : QFrame( parent, name ) | |
26 | WidgetLayer::WidgetLayer( QObject *parent, const char *name ) : QObject( parent, name ) | ||
27 | { | 25 | { |
28 | // get the clipboard | 26 | // get the clipboard |
@@ -38,10 +36,15 @@ WidgetLayer::WidgetLayer( QObject *parent, const char *name ) : QObject( parent | |||
38 | m_resizing = false; | 36 | m_resizing = false; |
39 | 37 | ||
40 | m_image = QArray<Character>(); | 38 | // just for demonstrating |
39 | //m_image = QArray<Character>( m_lines * m_columns ); | ||
40 | m_image = QArray<Character>( 1 ); | ||
41 | |||
41 | } | 42 | } |
42 | 43 | ||
44 | |||
43 | WidgetLayer::~WidgetLayer() | 45 | WidgetLayer::~WidgetLayer() |
44 | { | 46 | { |
45 | // clean up! | 47 | // clean up |
48 | delete m_image; | ||
46 | } | 49 | } |
47 | 50 | ||
@@ -59,5 +62,5 @@ void WidgetLayer::bell() | |||
59 | void WidgetLayer::propagateSize() | 62 | void WidgetLayer::propagateSize() |
60 | { | 63 | { |
61 | QArray<Character> oldimage = m_image; | 64 | QArray<Character> oldimage = m_image.copy(); |
62 | int oldlines = m_lines; | 65 | int oldlines = m_lines; |
63 | int oldcolumns = m_columns; | 66 | int oldcolumns = m_columns; |
@@ -66,8 +69,6 @@ void WidgetLayer::propagateSize() | |||
66 | 69 | ||
67 | // copy old image, to reduce flicker | 70 | // copy old image, to reduce flicker |
68 | if ( oldimage ) | 71 | if ( ! oldimage.isEmpty() ) |
69 | { | 72 | { |
70 | //FIXME: is it possible to do this with QArray.dublicate()? | ||
71 | |||
72 | int lins = QMIN( oldlines, m_lines ); | 73 | int lins = QMIN( oldlines, m_lines ); |
73 | int cols = QMIN( oldcolumns, m_columns ); | 74 | int cols = QMIN( oldcolumns, m_columns ); |
@@ -78,9 +79,10 @@ void WidgetLayer::propagateSize() | |||
78 | cols*sizeof( Character ) ); | 79 | cols*sizeof( Character ) ); |
79 | } | 80 | } |
80 | //free( oldimage ); | ||
81 | } | 81 | } |
82 | else | 82 | else |
83 | clearImage(); | 83 | clearImage(); |
84 | 84 | ||
85 | delete oldimage; | ||
86 | |||
85 | m_resizing = true; | 87 | m_resizing = true; |
86 | emit imageSizeChanged( m_lines, m_columns ); | 88 | emit imageSizeChanged( m_lines, m_columns ); |
@@ -91,6 +93,6 @@ void WidgetLayer::makeImage() | |||
91 | { | 93 | { |
92 | calcGeometry(); | 94 | calcGeometry(); |
93 | m_image = QArray<Character>(); | 95 | m_image = QArray<Character>( m_columns * m_lines ); |
94 | clearImage(); | 96 | clearImage(); |
95 | } | 97 | } |
96 | 98 | ||
diff --git a/noncore/apps/opie-console/widget_layer.h b/noncore/apps/opie-console/widget_layer.h index 07ec12a..99d248e 100644 --- a/noncore/apps/opie-console/widget_layer.h +++ b/noncore/apps/opie-console/widget_layer.h | |||
@@ -16,4 +16,6 @@ | |||
16 | // qt includes | 16 | // qt includes |
17 | #include <qapplication.h> | 17 | #include <qapplication.h> |
18 | #include <qframe.h> | ||
19 | #include <qarray.h> | ||
18 | #include <qtimer.h> | 20 | #include <qtimer.h> |
19 | #include <qkeycode.h> | 21 | #include <qkeycode.h> |
@@ -25,5 +27,14 @@ | |||
25 | #include "common.h" | 27 | #include "common.h" |
26 | 28 | ||
27 | class WidgetLayer : public QObject | 29 | /* |
30 | * given a pseudo location ( column, line ), | ||
31 | * returns the actual index, in the QArray<Character> | ||
32 | */ | ||
33 | #define loc(X,Y) ((Y)*m_columns+(X)) | ||
34 | |||
35 | |||
36 | |||
37 | |||
38 | class WidgetLayer : public QFrame | ||
28 | { Q_OBJECT | 39 | { Q_OBJECT |
29 | 40 | ||
@@ -33,5 +44,5 @@ public: | |||
33 | * constructor | 44 | * constructor |
34 | */ | 45 | */ |
35 | WidgetLayer( QObject *parent=0, const char *name=0 ); | 46 | WidgetLayer( QWidget *parent=0, const char *name=0 ); |
36 | 47 | ||
37 | /** | 48 | /** |
@@ -44,5 +55,5 @@ public: | |||
44 | * sets the image | 55 | * sets the image |
45 | */ | 56 | */ |
46 | virtual void setImage( const Character* const newimg, int lines, int colums ) = 0; | 57 | virtual void setImage( QArray<Character> const newimg, int lines, int colums ); |
47 | 58 | ||
48 | /** | 59 | /** |
@@ -142,5 +153,5 @@ protected: | |||
142 | 153 | ||
143 | /** | 154 | /** |
144 | * | 155 | *determines count of lines and columns |
145 | */ | 156 | */ |
146 | virtual void calcGeometry() = 0; | 157 | virtual void calcGeometry() = 0; |
@@ -174,4 +185,10 @@ protected: | |||
174 | /** | 185 | /** |
175 | * current character image | 186 | * current character image |
187 | * | ||
188 | * a Character at loc( column, line ) | ||
189 | * has the actual index: | ||
190 | * ix = line * m_columns + column; | ||
191 | * | ||
192 | * use loc( x, y ) macro to access. | ||
176 | */ | 193 | */ |
177 | QArray<Character> m_image; | 194 | QArray<Character> m_image; |
@@ -193,5 +210,5 @@ protected: | |||
193 | 210 | ||
194 | /** | 211 | /** |
195 | * whether widget was resized | 212 | * whether widget is resizing |
196 | */ | 213 | */ |
197 | bool m_resizing; | 214 | bool m_resizing; |