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 /noncore/apps/opie-console/widget_layer.cpp | |
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.
Diffstat (limited to 'noncore/apps/opie-console/widget_layer.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/apps/opie-console/widget_layer.cpp | 26 |
1 files changed, 14 insertions, 12 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 | |||
@@ -17,16 +17,14 @@ | |||
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 | #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 |
29 | m_clipboard = QApplication::clipboard(); | 27 | m_clipboard = QApplication::clipboard(); |
30 | 28 | ||
31 | // when data on clipboard changes, clear selection | 29 | // when data on clipboard changes, clear selection |
32 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), | 30 | QObject::connect( (QObject*) m_clipboard, SIGNAL( dataChanged() ), |
@@ -34,18 +32,23 @@ WidgetLayer::WidgetLayer( QObject *parent, const char *name ) : QObject( parent | |||
34 | 32 | ||
35 | // initialize vars: | 33 | // initialize vars: |
36 | m_lines = 1; | 34 | m_lines = 1; |
37 | m_columns = 1; | 35 | m_columns = 1; |
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 | ||
48 | /* --------------------------------- audio ---------------------------------- */ | 51 | /* --------------------------------- audio ---------------------------------- */ |
49 | 52 | ||
50 | void WidgetLayer::bell() | 53 | void WidgetLayer::bell() |
51 | { | 54 | { |
@@ -55,46 +58,45 @@ void WidgetLayer::bell() | |||
55 | 58 | ||
56 | /* --------------------------------- screen --------------------------------- */ | 59 | /* --------------------------------- screen --------------------------------- */ |
57 | 60 | ||
58 | 61 | ||
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; |
64 | 67 | ||
65 | makeImage(); | 68 | makeImage(); |
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 ); |
74 | for ( int lin = 0; lin < lins; ++lin ) | 75 | for ( int lin = 0; lin < lins; ++lin ) |
75 | { | 76 | { |
76 | memcpy( (void*) &m_image[m_columns*lin], | 77 | memcpy( (void*) &m_image[m_columns*lin], |
77 | (void*) &oldimage[oldcolumns*lin], | 78 | (void*) &oldimage[oldcolumns*lin], |
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 ); |
87 | m_resizing = false; | 89 | m_resizing = false; |
88 | } | 90 | } |
89 | 91 | ||
90 | void WidgetLayer::makeImage() | 92 | 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 | ||
97 | void WidgetLayer::clearImage() | 99 | void WidgetLayer::clearImage() |
98 | { | 100 | { |
99 | //should this belong here?? | 101 | //should this belong here?? |
100 | for ( int y = 0; y < m_lines; y++ ) | 102 | for ( int y = 0; y < m_lines; y++ ) |