author | ar <ar> | 2005-01-21 20:19:00 (UTC) |
---|---|---|
committer | ar <ar> | 2005-01-21 20:19:00 (UTC) |
commit | 55eccecc08f839878e5743d6e6be25af386b5a3f (patch) (unidiff) | |
tree | fd663ded2a2c097ce53bac6c021ca652ef5b5508 /libopie2/opieui | |
parent | cd51d382be50bc021739395309e23760f1619759 (diff) | |
download | opie-55eccecc08f839878e5743d6e6be25af386b5a3f.zip opie-55eccecc08f839878e5743d6e6be25af386b5a3f.tar.gz opie-55eccecc08f839878e5743d6e6be25af386b5a3f.tar.bz2 |
- make opie compilable against qte 2.3.10 snapshot
change QT_VERSION > 290 into QT_VERSION <= 0x030000
-rw-r--r-- | libopie2/opieui/olistview.cpp | 8 | ||||
-rw-r--r-- | libopie2/opieui/opopupmenu.cpp | 4 | ||||
-rw-r--r-- | libopie2/opieui/oselector.cpp | 2 | ||||
-rw-r--r-- | libopie2/opieui/oselector.h | 4 |
4 files changed, 9 insertions, 9 deletions
diff --git a/libopie2/opieui/olistview.cpp b/libopie2/opieui/olistview.cpp index 67b4b83..4386e0e 100644 --- a/libopie2/opieui/olistview.cpp +++ b/libopie2/opieui/olistview.cpp | |||
@@ -1,199 +1,199 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> | 3 | =. (C) 2003-2004 Michael 'Mickey' Lauer <mickey@Vanille.de> |
4 | .=l. | 4 | .=l. |
5 | .>+-= | 5 | .>+-= |
6 | _;:, .> :=|. This program is free software; you can | 6 | _;:, .> :=|. This program is free software; you can |
7 | .> <`_, > . <= redistribute it and/or modify it under | 7 | .> <`_, > . <= redistribute it and/or modify it under |
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
9 | .="- .-=="i, .._ License as published by the Free Software | 9 | .="- .-=="i, .._ License as published by the Free Software |
10 | - . .-<_> .<> Foundation; either version 2 of the License, | 10 | - . .-<_> .<> Foundation; either version 2 of the License, |
11 | ._= =} : or (at your option) any later version. | 11 | ._= =} : or (at your option) any later version. |
12 | .%`+i> _;_. | 12 | .%`+i> _;_. |
13 | .i_,=:_. -<s. This program is distributed in the hope that | 13 | .i_,=:_. -<s. This program is distributed in the hope that |
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
15 | : .. .:, . . . without even the implied warranty of | 15 | : .. .:, . . . without even the implied warranty of |
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
18 | ..}^=.= = ; Library General Public License for more | 18 | ..}^=.= = ; Library General Public License for more |
19 | ++= -. .` .: details. | 19 | ++= -. .` .: details. |
20 | : = ...= . :.=- | 20 | : = ...= . :.=- |
21 | -. .:....=;==+<; You should have received a copy of the GNU | 21 | -. .:....=;==+<; You should have received a copy of the GNU |
22 | -_. . . )=. = Library General Public License along with | 22 | -_. . . )=. = Library General Public License along with |
23 | -- :-=` this library; see the file COPYING.LIB. | 23 | -- :-=` this library; see the file COPYING.LIB. |
24 | If not, write to the Free Software Foundation, | 24 | If not, write to the Free Software Foundation, |
25 | Inc., 59 Temple Place - Suite 330, | 25 | Inc., 59 Temple Place - Suite 330, |
26 | Boston, MA 02111-1307, USA. | 26 | Boston, MA 02111-1307, USA. |
27 | 27 | ||
28 | */ | 28 | */ |
29 | 29 | ||
30 | /* QT */ | 30 | /* QT */ |
31 | 31 | ||
32 | #include <qpixmap.h> | 32 | #include <qpixmap.h> |
33 | 33 | ||
34 | /* OPIE */ | 34 | /* OPIE */ |
35 | 35 | ||
36 | #include <opie2/odebug.h> | 36 | #include <opie2/odebug.h> |
37 | #include <opie2/olistview.h> | 37 | #include <opie2/olistview.h> |
38 | 38 | ||
39 | using namespace Opie::Core; | 39 | using namespace Opie::Core; |
40 | 40 | ||
41 | 41 | ||
42 | namespace Opie { | 42 | namespace Opie { |
43 | namespace Ui { | 43 | namespace Ui { |
44 | /*====================================================================================== | 44 | /*====================================================================================== |
45 | * OListView | 45 | * OListView |
46 | *======================================================================================*/ | 46 | *======================================================================================*/ |
47 | 47 | ||
48 | OListView::OListView( QWidget *parent, const char *name, WFlags fl ) | 48 | OListView::OListView( QWidget *parent, const char *name, WFlags fl ) |
49 | :QListView( parent, name, fl ) | 49 | :QListView( parent, name, fl ) |
50 | { | 50 | { |
51 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* | 51 | //FIXME: get from global settings and calculate ==> see oglobalsettings.* |
52 | 52 | ||
53 | m_alternateBackground = QColor( 238, 246, 255 ); | 53 | m_alternateBackground = QColor( 238, 246, 255 ); |
54 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); | 54 | m_columnSeparator = QPen( QColor( 150, 160, 170 ), 0, DotLine ); |
55 | m_fullWidth = true; | 55 | m_fullWidth = true; |
56 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); | 56 | connect( this, SIGNAL(expanded(QListViewItem*)), SLOT(expand(QListViewItem*))); |
57 | } | 57 | } |
58 | 58 | ||
59 | OListView::~OListView() | 59 | OListView::~OListView() |
60 | { | 60 | { |
61 | } | 61 | } |
62 | 62 | ||
63 | void OListView::setFullWidth( bool fullWidth ) | 63 | void OListView::setFullWidth( bool fullWidth ) |
64 | { | 64 | { |
65 | m_fullWidth = fullWidth; | 65 | m_fullWidth = fullWidth; |
66 | #if QT_VERSION > 290 | 66 | #if QT_VERSION >= 0x030000 |
67 | header()->setStretchEnabled( fullWidth, columns()-1 ); | 67 | header()->setStretchEnabled( fullWidth, columns()-1 ); |
68 | #endif | 68 | #endif |
69 | } | 69 | } |
70 | 70 | ||
71 | bool OListView::fullWidth() const | 71 | bool OListView::fullWidth() const |
72 | { | 72 | { |
73 | return m_fullWidth; | 73 | return m_fullWidth; |
74 | } | 74 | } |
75 | 75 | ||
76 | int OListView::addColumn( const QString& label, int width ) | 76 | int OListView::addColumn( const QString& label, int width ) |
77 | { | 77 | { |
78 | int result = QListView::addColumn( label, width ); | 78 | int result = QListView::addColumn( label, width ); |
79 | #if QT_VERSION > 290 | 79 | #if QT_VERSION >= 0x030000 |
80 | if (m_fullWidth) { | 80 | if (m_fullWidth) { |
81 | header()->setStretchEnabled( false, columns()-2 ); | 81 | header()->setStretchEnabled( false, columns()-2 ); |
82 | header()->setStretchEnabled( true, columns()-1 ); | 82 | header()->setStretchEnabled( true, columns()-1 ); |
83 | } | 83 | } |
84 | #endif | 84 | #endif |
85 | return result; | 85 | return result; |
86 | } | 86 | } |
87 | 87 | ||
88 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) | 88 | int OListView::addColumn( const QIconSet& iconset, const QString& label, int width ) |
89 | { | 89 | { |
90 | int result = QListView::addColumn( iconset, label, width ); | 90 | int result = QListView::addColumn( iconset, label, width ); |
91 | #if QT_VERSION > 290 | 91 | #if QT_VERSION >= 0x030000 |
92 | if (m_fullWidth) { | 92 | if (m_fullWidth) { |
93 | header()->setStretchEnabled( false, columns()-2 ); | 93 | header()->setStretchEnabled( false, columns()-2 ); |
94 | header()->setStretchEnabled( true, columns()-1 ); | 94 | header()->setStretchEnabled( true, columns()-1 ); |
95 | } | 95 | } |
96 | #endif | 96 | #endif |
97 | return result; | 97 | return result; |
98 | } | 98 | } |
99 | 99 | ||
100 | void OListView::removeColumn( int index ) | 100 | void OListView::removeColumn( int index ) |
101 | { | 101 | { |
102 | QListView::removeColumn(index); | 102 | QListView::removeColumn(index); |
103 | #if QT_VERSION > 290 | 103 | #if QT_VERSION >= 0x030000 |
104 | if ( m_fullWidth && index == columns() ) | 104 | if ( m_fullWidth && index == columns() ) |
105 | { | 105 | { |
106 | header()->setStretchEnabled( true, columns()-1 ); | 106 | header()->setStretchEnabled( true, columns()-1 ); |
107 | } | 107 | } |
108 | #endif | 108 | #endif |
109 | } | 109 | } |
110 | 110 | ||
111 | const QColor& OListView::alternateBackground() const | 111 | const QColor& OListView::alternateBackground() const |
112 | { | 112 | { |
113 | return m_alternateBackground; | 113 | return m_alternateBackground; |
114 | } | 114 | } |
115 | 115 | ||
116 | void OListView::setAlternateBackground( const QColor &c ) | 116 | void OListView::setAlternateBackground( const QColor &c ) |
117 | { | 117 | { |
118 | m_alternateBackground = c; | 118 | m_alternateBackground = c; |
119 | repaint(); | 119 | repaint(); |
120 | } | 120 | } |
121 | 121 | ||
122 | const QPen& OListView::columnSeparator() const | 122 | const QPen& OListView::columnSeparator() const |
123 | { | 123 | { |
124 | return m_columnSeparator; | 124 | return m_columnSeparator; |
125 | } | 125 | } |
126 | 126 | ||
127 | void OListView::setColumnSeparator( const QPen& p ) | 127 | void OListView::setColumnSeparator( const QPen& p ) |
128 | { | 128 | { |
129 | m_columnSeparator = p; | 129 | m_columnSeparator = p; |
130 | repaint(); | 130 | repaint(); |
131 | } | 131 | } |
132 | 132 | ||
133 | void OListView::expand(QListViewItem *item) | 133 | void OListView::expand(QListViewItem *item) |
134 | { | 134 | { |
135 | ((OListViewItem*)item)->expand(); | 135 | ((OListViewItem*)item)->expand(); |
136 | } | 136 | } |
137 | 137 | ||
138 | OListViewItem* OListView::childFactory() | 138 | OListViewItem* OListView::childFactory() |
139 | { | 139 | { |
140 | return new OListViewItem( this ); | 140 | return new OListViewItem( this ); |
141 | } | 141 | } |
142 | 142 | ||
143 | #ifndef QT_NO_DATASTREAM | 143 | #ifndef QT_NO_DATASTREAM |
144 | void OListView::serializeTo( QDataStream& s ) const | 144 | void OListView::serializeTo( QDataStream& s ) const |
145 | { | 145 | { |
146 | #warning Caution... the binary format is still under construction... | 146 | #warning Caution... the binary format is still under construction... |
147 | odebug << "storing OListView..." << oendl; | 147 | odebug << "storing OListView..." << oendl; |
148 | 148 | ||
149 | // store number of columns and the labels | 149 | // store number of columns and the labels |
150 | s << columns(); | 150 | s << columns(); |
151 | for ( int i = 0; i < columns(); ++i ) | 151 | for ( int i = 0; i < columns(); ++i ) |
152 | s << columnText( i ); | 152 | s << columnText( i ); |
153 | 153 | ||
154 | // calculate the number of top-level items to serialize | 154 | // calculate the number of top-level items to serialize |
155 | int items = 0; | 155 | int items = 0; |
156 | QListViewItem* item = firstChild(); | 156 | QListViewItem* item = firstChild(); |
157 | while ( item ) | 157 | while ( item ) |
158 | { | 158 | { |
159 | item = item->nextSibling(); | 159 | item = item->nextSibling(); |
160 | items++; | 160 | items++; |
161 | } | 161 | } |
162 | 162 | ||
163 | // store number of items and the items itself | 163 | // store number of items and the items itself |
164 | s << items; | 164 | s << items; |
165 | item = firstChild(); | 165 | item = firstChild(); |
166 | for ( int i = 0; i < items; ++i ) | 166 | for ( int i = 0; i < items; ++i ) |
167 | { | 167 | { |
168 | s << *static_cast<OListViewItem*>( item ); | 168 | s << *static_cast<OListViewItem*>( item ); |
169 | item = item->nextSibling(); | 169 | item = item->nextSibling(); |
170 | } | 170 | } |
171 | 171 | ||
172 | odebug << "OListview stored." << oendl; | 172 | odebug << "OListview stored." << oendl; |
173 | } | 173 | } |
174 | 174 | ||
175 | void OListView::serializeFrom( QDataStream& s ) | 175 | void OListView::serializeFrom( QDataStream& s ) |
176 | { | 176 | { |
177 | #warning Caution... the binary format is still under construction... | 177 | #warning Caution... the binary format is still under construction... |
178 | odebug << "loading OListView..." << oendl; | 178 | odebug << "loading OListView..." << oendl; |
179 | 179 | ||
180 | int cols; | 180 | int cols; |
181 | s >> cols; | 181 | s >> cols; |
182 | odebug << "read number of columns = " << cols << oendl; | 182 | odebug << "read number of columns = " << cols << oendl; |
183 | 183 | ||
184 | while ( columns() < cols ) addColumn( QString::null ); | 184 | while ( columns() < cols ) addColumn( QString::null ); |
185 | 185 | ||
186 | for ( int i = 0; i < cols; ++i ) | 186 | for ( int i = 0; i < cols; ++i ) |
187 | { | 187 | { |
188 | QString coltext; | 188 | QString coltext; |
189 | s >> coltext; | 189 | s >> coltext; |
190 | odebug << "read text '" << coltext << "' for column " << i << "" << oendl; | 190 | odebug << "read text '" << coltext << "' for column " << i << "" << oendl; |
191 | setColumnText( i, coltext ); | 191 | setColumnText( i, coltext ); |
192 | } | 192 | } |
193 | 193 | ||
194 | int items; | 194 | int items; |
195 | s >> items; | 195 | s >> items; |
196 | odebug << "read number of items = " << items << oendl; | 196 | odebug << "read number of items = " << items << oendl; |
197 | 197 | ||
198 | for ( int i = 0; i < items; ++i ) | 198 | for ( int i = 0; i < items; ++i ) |
199 | { | 199 | { |
diff --git a/libopie2/opieui/opopupmenu.cpp b/libopie2/opieui/opopupmenu.cpp index 50c613f..5ce048e 100644 --- a/libopie2/opieui/opopupmenu.cpp +++ b/libopie2/opieui/opopupmenu.cpp | |||
@@ -1,184 +1,184 @@ | |||
1 | /* This file is part of the KDE libraries | 1 | /* This file is part of the KDE libraries |
2 | Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> | 2 | Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> |
3 | Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> | 3 | Copyright (C) 2002 Hamish Rodda <meddie@yoyo.its.monash.edu.au> |
4 | 4 | ||
5 | This library is free software; you can redistribute it and/or | 5 | This library is free software; you can redistribute it and/or |
6 | modify it under the terms of the GNU Library General Public | 6 | modify it under the terms of the GNU Library General Public |
7 | License version 2 as published by the Free Software Foundation. | 7 | License version 2 as published by the Free Software Foundation. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | /* OPIE */ | 20 | /* OPIE */ |
21 | #include <opie2/opopupmenu.h> | 21 | #include <opie2/opopupmenu.h> |
22 | #include <opie2/oconfig.h> | 22 | #include <opie2/oconfig.h> |
23 | #include <opie2/odebug.h> | 23 | #include <opie2/odebug.h> |
24 | 24 | ||
25 | /* QT */ | 25 | /* QT */ |
26 | #include <qdrawutil.h> | 26 | #include <qdrawutil.h> |
27 | #include <qtimer.h> | 27 | #include <qtimer.h> |
28 | 28 | ||
29 | 29 | ||
30 | using namespace Opie::Core; | 30 | using namespace Opie::Core; |
31 | using namespace Opie::Ui; | 31 | using namespace Opie::Ui; |
32 | 32 | ||
33 | OPopupTitle::OPopupTitle(QWidget *parent, const char *name) | 33 | OPopupTitle::OPopupTitle(QWidget *parent, const char *name) |
34 | : QWidget(parent, name) | 34 | : QWidget(parent, name) |
35 | { | 35 | { |
36 | setMinimumSize(16, fontMetrics().height()+8); | 36 | setMinimumSize(16, fontMetrics().height()+8); |
37 | } | 37 | } |
38 | 38 | ||
39 | OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, | 39 | OPopupTitle::OPopupTitle(OPixmapEffect::GradientType /* gradient */, |
40 | const QColor &/* color */, const QColor &/* textColor */, | 40 | const QColor &/* color */, const QColor &/* textColor */, |
41 | QWidget *parent, const char *name) | 41 | QWidget *parent, const char *name) |
42 | : QWidget(parent, name) | 42 | : QWidget(parent, name) |
43 | { | 43 | { |
44 | setMinimumSize(16, fontMetrics().height()+8); | 44 | setMinimumSize(16, fontMetrics().height()+8); |
45 | } | 45 | } |
46 | 46 | ||
47 | OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, | 47 | OPopupTitle::OPopupTitle(const OPixmap & /* background */, const QColor &/* color */, |
48 | const QColor &/* textColor */, QWidget *parent, | 48 | const QColor &/* textColor */, QWidget *parent, |
49 | const char *name) | 49 | const char *name) |
50 | : QWidget(parent, name) | 50 | : QWidget(parent, name) |
51 | { | 51 | { |
52 | setMinimumSize(16, fontMetrics().height()+8); | 52 | setMinimumSize(16, fontMetrics().height()+8); |
53 | } | 53 | } |
54 | 54 | ||
55 | void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) | 55 | void OPopupTitle::setTitle(const QString &text, const QPixmap *icon) |
56 | { | 56 | { |
57 | titleStr = text; | 57 | titleStr = text; |
58 | if (icon) | 58 | if (icon) |
59 | miniicon = *icon; | 59 | miniicon = *icon; |
60 | else | 60 | else |
61 | miniicon.resize(0, 0); | 61 | miniicon.resize(0, 0); |
62 | 62 | ||
63 | int w = miniicon.width()+fontMetrics().width(titleStr); | 63 | int w = miniicon.width()+fontMetrics().width(titleStr); |
64 | int h = QMAX( fontMetrics().height(), miniicon.height() ); | 64 | int h = QMAX( fontMetrics().height(), miniicon.height() ); |
65 | setMinimumSize( w+16, h+8 ); | 65 | setMinimumSize( w+16, h+8 ); |
66 | } | 66 | } |
67 | 67 | ||
68 | void OPopupTitle::setText( const QString &text ) | 68 | void OPopupTitle::setText( const QString &text ) |
69 | { | 69 | { |
70 | titleStr = text; | 70 | titleStr = text; |
71 | int w = miniicon.width()+fontMetrics().width(titleStr); | 71 | int w = miniicon.width()+fontMetrics().width(titleStr); |
72 | int h = QMAX( fontMetrics().height(), miniicon.height() ); | 72 | int h = QMAX( fontMetrics().height(), miniicon.height() ); |
73 | setMinimumSize( w+16, h+8 ); | 73 | setMinimumSize( w+16, h+8 ); |
74 | } | 74 | } |
75 | 75 | ||
76 | void OPopupTitle::setIcon( const QPixmap &pix ) | 76 | void OPopupTitle::setIcon( const QPixmap &pix ) |
77 | { | 77 | { |
78 | miniicon = pix; | 78 | miniicon = pix; |
79 | int w = miniicon.width()+fontMetrics().width(titleStr); | 79 | int w = miniicon.width()+fontMetrics().width(titleStr); |
80 | int h = QMAX( fontMetrics().height(), miniicon.height() ); | 80 | int h = QMAX( fontMetrics().height(), miniicon.height() ); |
81 | setMinimumSize( w+16, h+8 ); | 81 | setMinimumSize( w+16, h+8 ); |
82 | } | 82 | } |
83 | 83 | ||
84 | void OPopupTitle::paintEvent(QPaintEvent *) | 84 | void OPopupTitle::paintEvent(QPaintEvent *) |
85 | { | 85 | { |
86 | QRect r(rect()); | 86 | QRect r(rect()); |
87 | QPainter p(this); | 87 | QPainter p(this); |
88 | #if QT_VERSION > 290 | 88 | #if QT_VERSION >= 0x030000 |
89 | qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); | 89 | qApp->style().drawPrimitive(QStyle::PE_HeaderSection, &p, r, palette().active()); |
90 | #else | 90 | #else |
91 | #warning OPopupMenu is not fully functional on Qt2 | 91 | #warning OPopupMenu is not fully functional on Qt2 |
92 | #endif | 92 | #endif |
93 | 93 | ||
94 | if (!miniicon.isNull()) | 94 | if (!miniicon.isNull()) |
95 | p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); | 95 | p.drawPixmap(4, (r.height()-miniicon.height())/2, miniicon); |
96 | 96 | ||
97 | if (!titleStr.isNull()) | 97 | if (!titleStr.isNull()) |
98 | { | 98 | { |
99 | p.setPen(palette().active().text()); | 99 | p.setPen(palette().active().text()); |
100 | QFont f = p.font(); | 100 | QFont f = p.font(); |
101 | f.setBold(true); | 101 | f.setBold(true); |
102 | p.setFont(f); | 102 | p.setFont(f); |
103 | if(!miniicon.isNull()) | 103 | if(!miniicon.isNull()) |
104 | { | 104 | { |
105 | p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), | 105 | p.drawText(miniicon.width()+8, 0, width()-(miniicon.width()+8), |
106 | height(), AlignLeft | AlignVCenter | SingleLine, | 106 | height(), AlignLeft | AlignVCenter | SingleLine, |
107 | titleStr); | 107 | titleStr); |
108 | } | 108 | } |
109 | else | 109 | else |
110 | { | 110 | { |
111 | p.drawText(0, 0, width(), height(), | 111 | p.drawText(0, 0, width(), height(), |
112 | AlignCenter | SingleLine, titleStr); | 112 | AlignCenter | SingleLine, titleStr); |
113 | } | 113 | } |
114 | } | 114 | } |
115 | 115 | ||
116 | p.setPen(palette().active().highlight()); | 116 | p.setPen(palette().active().highlight()); |
117 | p.drawLine(0, 0, r.right(), 0); | 117 | p.drawLine(0, 0, r.right(), 0); |
118 | } | 118 | } |
119 | 119 | ||
120 | QSize OPopupTitle::sizeHint() const | 120 | QSize OPopupTitle::sizeHint() const |
121 | { | 121 | { |
122 | return(minimumSize()); | 122 | return(minimumSize()); |
123 | } | 123 | } |
124 | 124 | ||
125 | class OPopupMenu::OPopupMenuPrivate | 125 | class OPopupMenu::OPopupMenuPrivate |
126 | { | 126 | { |
127 | public: | 127 | public: |
128 | OPopupMenuPrivate () | 128 | OPopupMenuPrivate () |
129 | : noMatches(false) | 129 | : noMatches(false) |
130 | , shortcuts(false) | 130 | , shortcuts(false) |
131 | , autoExec(false) | 131 | , autoExec(false) |
132 | , lastHitIndex(-1) | 132 | , lastHitIndex(-1) |
133 | , m_ctxMenu(0) | 133 | , m_ctxMenu(0) |
134 | {} | 134 | {} |
135 | 135 | ||
136 | ~OPopupMenuPrivate () | 136 | ~OPopupMenuPrivate () |
137 | { | 137 | { |
138 | delete m_ctxMenu; | 138 | delete m_ctxMenu; |
139 | } | 139 | } |
140 | 140 | ||
141 | QString m_lastTitle; | 141 | QString m_lastTitle; |
142 | 142 | ||
143 | // variables for keyboard navigation | 143 | // variables for keyboard navigation |
144 | QTimer clearTimer; | 144 | QTimer clearTimer; |
145 | 145 | ||
146 | bool noMatches : 1; | 146 | bool noMatches : 1; |
147 | bool shortcuts : 1; | 147 | bool shortcuts : 1; |
148 | bool autoExec : 1; | 148 | bool autoExec : 1; |
149 | 149 | ||
150 | QString keySeq; | 150 | QString keySeq; |
151 | QString originalText; | 151 | QString originalText; |
152 | 152 | ||
153 | int lastHitIndex; | 153 | int lastHitIndex; |
154 | 154 | ||
155 | // support for RMB menus on menus | 155 | // support for RMB menus on menus |
156 | QPopupMenu* m_ctxMenu; | 156 | QPopupMenu* m_ctxMenu; |
157 | static bool s_continueCtxMenuShow; | 157 | static bool s_continueCtxMenuShow; |
158 | static int s_highlightedItem; | 158 | static int s_highlightedItem; |
159 | static OPopupMenu* s_contextedMenu; | 159 | static OPopupMenu* s_contextedMenu; |
160 | }; | 160 | }; |
161 | 161 | ||
162 | int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1); | 162 | int OPopupMenu::OPopupMenuPrivate::s_highlightedItem(-1); |
163 | OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0); | 163 | OPopupMenu* OPopupMenu::OPopupMenuPrivate::s_contextedMenu(0); |
164 | bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true); | 164 | bool OPopupMenu::OPopupMenuPrivate::s_continueCtxMenuShow(true); |
165 | 165 | ||
166 | OPopupMenu::OPopupMenu(QWidget *parent, const char *name) | 166 | OPopupMenu::OPopupMenu(QWidget *parent, const char *name) |
167 | : QPopupMenu(parent, name) | 167 | : QPopupMenu(parent, name) |
168 | { | 168 | { |
169 | d = new OPopupMenuPrivate; | 169 | d = new OPopupMenuPrivate; |
170 | resetKeyboardVars(); | 170 | resetKeyboardVars(); |
171 | connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); | 171 | connect(&(d->clearTimer), SIGNAL(timeout()), SLOT(resetKeyboardVars())); |
172 | } | 172 | } |
173 | 173 | ||
174 | OPopupMenu::~OPopupMenu() | 174 | OPopupMenu::~OPopupMenu() |
175 | { | 175 | { |
176 | if (OPopupMenuPrivate::s_contextedMenu == this) | 176 | if (OPopupMenuPrivate::s_contextedMenu == this) |
177 | { | 177 | { |
178 | OPopupMenuPrivate::s_contextedMenu = 0; | 178 | OPopupMenuPrivate::s_contextedMenu = 0; |
179 | OPopupMenuPrivate::s_highlightedItem = -1; | 179 | OPopupMenuPrivate::s_highlightedItem = -1; |
180 | } | 180 | } |
181 | 181 | ||
182 | delete d; | 182 | delete d; |
183 | } | 183 | } |
184 | 184 | ||
@@ -456,145 +456,145 @@ void OPopupMenu::resetKeyboardVars(bool noMatches /* = false */) | |||
456 | } | 456 | } |
457 | 457 | ||
458 | void OPopupMenu::setKeyboardShortcutsEnabled(bool enable) | 458 | void OPopupMenu::setKeyboardShortcutsEnabled(bool enable) |
459 | { | 459 | { |
460 | d->shortcuts = enable; | 460 | d->shortcuts = enable; |
461 | } | 461 | } |
462 | 462 | ||
463 | void OPopupMenu::setKeyboardShortcutsExecute(bool enable) | 463 | void OPopupMenu::setKeyboardShortcutsExecute(bool enable) |
464 | { | 464 | { |
465 | d->autoExec = enable; | 465 | d->autoExec = enable; |
466 | } | 466 | } |
467 | /** | 467 | /** |
468 | * End keyboard navigation. | 468 | * End keyboard navigation. |
469 | */ | 469 | */ |
470 | 470 | ||
471 | /** | 471 | /** |
472 | * RMB menus on menus | 472 | * RMB menus on menus |
473 | */ | 473 | */ |
474 | QPopupMenu* OPopupMenu::contextMenu() | 474 | QPopupMenu* OPopupMenu::contextMenu() |
475 | { | 475 | { |
476 | if (!d->m_ctxMenu) | 476 | if (!d->m_ctxMenu) |
477 | { | 477 | { |
478 | d->m_ctxMenu = new QPopupMenu(this); | 478 | d->m_ctxMenu = new QPopupMenu(this); |
479 | installEventFilter(this); | 479 | installEventFilter(this); |
480 | connect(d->m_ctxMenu, SIGNAL(aboutToHide()), this, SLOT(ctxMenuHiding())); | 480 | connect(d->m_ctxMenu, SIGNAL(aboutToHide()), this, SLOT(ctxMenuHiding())); |
481 | } | 481 | } |
482 | 482 | ||
483 | return d->m_ctxMenu; | 483 | return d->m_ctxMenu; |
484 | } | 484 | } |
485 | 485 | ||
486 | void OPopupMenu::cancelContextMenuShow() | 486 | void OPopupMenu::cancelContextMenuShow() |
487 | { | 487 | { |
488 | OPopupMenuPrivate::s_continueCtxMenuShow = false; | 488 | OPopupMenuPrivate::s_continueCtxMenuShow = false; |
489 | } | 489 | } |
490 | 490 | ||
491 | int OPopupMenu::contextMenuFocusItem() | 491 | int OPopupMenu::contextMenuFocusItem() |
492 | { | 492 | { |
493 | return OPopupMenuPrivate::s_highlightedItem; | 493 | return OPopupMenuPrivate::s_highlightedItem; |
494 | } | 494 | } |
495 | 495 | ||
496 | OPopupMenu* OPopupMenu::contextMenuFocus() | 496 | OPopupMenu* OPopupMenu::contextMenuFocus() |
497 | { | 497 | { |
498 | return OPopupMenuPrivate::s_contextedMenu; | 498 | return OPopupMenuPrivate::s_contextedMenu; |
499 | } | 499 | } |
500 | 500 | ||
501 | void OPopupMenu::itemHighlighted(int /* whichItem */) | 501 | void OPopupMenu::itemHighlighted(int /* whichItem */) |
502 | { | 502 | { |
503 | if (!d->m_ctxMenu || !d->m_ctxMenu->isVisible()) | 503 | if (!d->m_ctxMenu || !d->m_ctxMenu->isVisible()) |
504 | { | 504 | { |
505 | return; | 505 | return; |
506 | } | 506 | } |
507 | 507 | ||
508 | d->m_ctxMenu->hide(); | 508 | d->m_ctxMenu->hide(); |
509 | showCtxMenu(mapFromGlobal(QCursor::pos())); | 509 | showCtxMenu(mapFromGlobal(QCursor::pos())); |
510 | } | 510 | } |
511 | 511 | ||
512 | void OPopupMenu::showCtxMenu(QPoint pos) | 512 | void OPopupMenu::showCtxMenu(QPoint pos) |
513 | { | 513 | { |
514 | OPopupMenuPrivate::s_highlightedItem = idAt(pos); | 514 | OPopupMenuPrivate::s_highlightedItem = idAt(pos); |
515 | 515 | ||
516 | if (OPopupMenuPrivate::s_highlightedItem == -1) | 516 | if (OPopupMenuPrivate::s_highlightedItem == -1) |
517 | { | 517 | { |
518 | OPopupMenuPrivate::s_contextedMenu = 0; | 518 | OPopupMenuPrivate::s_contextedMenu = 0; |
519 | return; | 519 | return; |
520 | } | 520 | } |
521 | 521 | ||
522 | emit aboutToShowContextMenu(this, OPopupMenuPrivate::s_highlightedItem, d->m_ctxMenu); | 522 | emit aboutToShowContextMenu(this, OPopupMenuPrivate::s_highlightedItem, d->m_ctxMenu); |
523 | 523 | ||
524 | if (!OPopupMenuPrivate::s_continueCtxMenuShow) | 524 | if (!OPopupMenuPrivate::s_continueCtxMenuShow) |
525 | { | 525 | { |
526 | OPopupMenuPrivate::s_continueCtxMenuShow = true; | 526 | OPopupMenuPrivate::s_continueCtxMenuShow = true; |
527 | return; | 527 | return; |
528 | } | 528 | } |
529 | 529 | ||
530 | OPopupMenuPrivate::s_contextedMenu = this; | 530 | OPopupMenuPrivate::s_contextedMenu = this; |
531 | d->m_ctxMenu->popup(this->mapToGlobal(pos)); | 531 | d->m_ctxMenu->popup(this->mapToGlobal(pos)); |
532 | connect(this, SIGNAL(highlighted(int)), this, SLOT(itemHighlighted(int))); | 532 | connect(this, SIGNAL(highlighted(int)), this, SLOT(itemHighlighted(int))); |
533 | } | 533 | } |
534 | 534 | ||
535 | void OPopupMenu::ctxMenuHiding() | 535 | void OPopupMenu::ctxMenuHiding() |
536 | { | 536 | { |
537 | disconnect(this, SIGNAL(highlighted(int)), this, SLOT(itemHighlighted(int))); | 537 | disconnect(this, SIGNAL(highlighted(int)), this, SLOT(itemHighlighted(int))); |
538 | OPopupMenuPrivate::s_continueCtxMenuShow = true; | 538 | OPopupMenuPrivate::s_continueCtxMenuShow = true; |
539 | } | 539 | } |
540 | 540 | ||
541 | bool OPopupMenu::eventFilter(QObject* obj, QEvent* event) | 541 | bool OPopupMenu::eventFilter(QObject* obj, QEvent* event) |
542 | { | 542 | { |
543 | if (d->m_ctxMenu && obj == this) | 543 | if (d->m_ctxMenu && obj == this) |
544 | { | 544 | { |
545 | if (event->type() == QEvent::MouseButtonRelease) | 545 | if (event->type() == QEvent::MouseButtonRelease) |
546 | { | 546 | { |
547 | if (d->m_ctxMenu->isVisible()) | 547 | if (d->m_ctxMenu->isVisible()) |
548 | { | 548 | { |
549 | return true; | 549 | return true; |
550 | } | 550 | } |
551 | } | 551 | } |
552 | #if QT_VERSION > 290 | 552 | #if QT_VERSION >= 0x030000 |
553 | else if (event->type() == QEvent::ContextMenu) | 553 | else if (event->type() == QEvent::ContextMenu) |
554 | #else | 554 | #else |
555 | else if ( (event->type() == QEvent::MouseButtonPress) && | 555 | else if ( (event->type() == QEvent::MouseButtonPress) && |
556 | ( (QMouseEvent*) event )->button() == QMouseEvent::RightButton ) | 556 | ( (QMouseEvent*) event )->button() == QMouseEvent::RightButton ) |
557 | #endif | 557 | #endif |
558 | { | 558 | { |
559 | showCtxMenu(mapFromGlobal(QCursor::pos())); | 559 | showCtxMenu(mapFromGlobal(QCursor::pos())); |
560 | return true; | 560 | return true; |
561 | } | 561 | } |
562 | } | 562 | } |
563 | 563 | ||
564 | return QWidget::eventFilter(obj, event); | 564 | return QWidget::eventFilter(obj, event); |
565 | } | 565 | } |
566 | 566 | ||
567 | void OPopupMenu::hideEvent(QHideEvent*) | 567 | void OPopupMenu::hideEvent(QHideEvent*) |
568 | { | 568 | { |
569 | if (d->m_ctxMenu) | 569 | if (d->m_ctxMenu) |
570 | { | 570 | { |
571 | d->m_ctxMenu->hide(); | 571 | d->m_ctxMenu->hide(); |
572 | } | 572 | } |
573 | } | 573 | } |
574 | /** | 574 | /** |
575 | * end of RMB menus on menus support | 575 | * end of RMB menus on menus support |
576 | */ | 576 | */ |
577 | 577 | ||
578 | // Obsolete | 578 | // Obsolete |
579 | OPopupMenu::OPopupMenu(const QString& title, QWidget *parent, const char *name) | 579 | OPopupMenu::OPopupMenu(const QString& title, QWidget *parent, const char *name) |
580 | : QPopupMenu(parent, name) | 580 | : QPopupMenu(parent, name) |
581 | { | 581 | { |
582 | d = new OPopupMenuPrivate; | 582 | d = new OPopupMenuPrivate; |
583 | setTitle(title); | 583 | setTitle(title); |
584 | } | 584 | } |
585 | 585 | ||
586 | // Obsolete | 586 | // Obsolete |
587 | void OPopupMenu::setTitle(const QString &title) | 587 | void OPopupMenu::setTitle(const QString &title) |
588 | { | 588 | { |
589 | OPopupTitle *titleItem = new OPopupTitle(); | 589 | OPopupTitle *titleItem = new OPopupTitle(); |
590 | titleItem->setTitle(title); | 590 | titleItem->setTitle(title); |
591 | insertItem(titleItem); | 591 | insertItem(titleItem); |
592 | d->m_lastTitle = title; | 592 | d->m_lastTitle = title; |
593 | } | 593 | } |
594 | 594 | ||
595 | void OPopupTitle::virtual_hook( int, void* ) | 595 | void OPopupTitle::virtual_hook( int, void* ) |
596 | { /*BASE::virtual_hook( id, data );*/ } | 596 | { /*BASE::virtual_hook( id, data );*/ } |
597 | 597 | ||
598 | void OPopupMenu::virtual_hook( int, void* ) | 598 | void OPopupMenu::virtual_hook( int, void* ) |
599 | { /*BASE::virtual_hook( id, data );*/ } | 599 | { /*BASE::virtual_hook( id, data );*/ } |
600 | 600 | ||
diff --git a/libopie2/opieui/oselector.cpp b/libopie2/opieui/oselector.cpp index 05543c5..936dfe6 100644 --- a/libopie2/opieui/oselector.cpp +++ b/libopie2/opieui/oselector.cpp | |||
@@ -46,193 +46,193 @@ OXYSelector::OXYSelector( QWidget *parent, const char *name ) | |||
46 | minX = 0; | 46 | minX = 0; |
47 | minY = 0; | 47 | minY = 0; |
48 | maxX = 100; | 48 | maxX = 100; |
49 | maxY = 100; | 49 | maxY = 100; |
50 | store.setOptimization( QPixmap::BestOptim ); | 50 | store.setOptimization( QPixmap::BestOptim ); |
51 | store.resize( STORE_W2, STORE_W2 ); | 51 | store.resize( STORE_W2, STORE_W2 ); |
52 | } | 52 | } |
53 | 53 | ||
54 | 54 | ||
55 | OXYSelector::~OXYSelector() | 55 | OXYSelector::~OXYSelector() |
56 | {} | 56 | {} |
57 | 57 | ||
58 | 58 | ||
59 | void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY ) | 59 | void OXYSelector::setRange( int _minX, int _minY, int _maxX, int _maxY ) |
60 | { | 60 | { |
61 | px = 2; | 61 | px = 2; |
62 | py = 2; | 62 | py = 2; |
63 | minX = _minX; | 63 | minX = _minX; |
64 | minY = _minY; | 64 | minY = _minY; |
65 | maxX = _maxX; | 65 | maxX = _maxX; |
66 | maxY = _maxY; | 66 | maxY = _maxY; |
67 | } | 67 | } |
68 | 68 | ||
69 | void OXYSelector::setValues( int _xPos, int _yPos ) | 69 | void OXYSelector::setValues( int _xPos, int _yPos ) |
70 | { | 70 | { |
71 | xPos = _xPos; | 71 | xPos = _xPos; |
72 | yPos = _yPos; | 72 | yPos = _yPos; |
73 | 73 | ||
74 | if ( xPos > maxX ) | 74 | if ( xPos > maxX ) |
75 | xPos = maxX; | 75 | xPos = maxX; |
76 | else if ( xPos < minX ) | 76 | else if ( xPos < minX ) |
77 | xPos = minX; | 77 | xPos = minX; |
78 | 78 | ||
79 | if ( yPos > maxY ) | 79 | if ( yPos > maxY ) |
80 | yPos = maxY; | 80 | yPos = maxY; |
81 | else if ( yPos < minY ) | 81 | else if ( yPos < minY ) |
82 | yPos = minY; | 82 | yPos = minY; |
83 | 83 | ||
84 | int xp = 2 + (width() - 4) * xPos / (maxX - minX); | 84 | int xp = 2 + (width() - 4) * xPos / (maxX - minX); |
85 | int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); | 85 | int yp = height() - 2 - (height() - 4) * yPos / (maxY - minY); |
86 | 86 | ||
87 | setPosition( xp, yp ); | 87 | setPosition( xp, yp ); |
88 | } | 88 | } |
89 | 89 | ||
90 | QRect OXYSelector::contentsRect() const | 90 | QRect OXYSelector::contentsRect() const |
91 | { | 91 | { |
92 | return QRect( 2, 2, width()-4, height()-4 ); | 92 | return QRect( 2, 2, width()-4, height()-4 ); |
93 | } | 93 | } |
94 | 94 | ||
95 | void OXYSelector::paintEvent( QPaintEvent *ev ) | 95 | void OXYSelector::paintEvent( QPaintEvent *ev ) |
96 | { | 96 | { |
97 | QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); | 97 | QRect cursorRect( px - STORE_W, py - STORE_W, STORE_W2, STORE_W2); |
98 | QRect paintRect = ev->rect(); | 98 | QRect paintRect = ev->rect(); |
99 | 99 | ||
100 | QPainter painter; | 100 | QPainter painter; |
101 | painter.begin( this ); | 101 | painter.begin( this ); |
102 | 102 | ||
103 | QBrush brush; | 103 | QBrush brush; |
104 | qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), | 104 | qDrawShadePanel( &painter, 0, 0, width(), height(), colorGroup(), |
105 | TRUE, 2, &brush ); | 105 | TRUE, 2, &brush ); |
106 | 106 | ||
107 | drawContents( &painter ); | 107 | drawContents( &painter ); |
108 | if (paintRect.contains(cursorRect)) | 108 | if (paintRect.contains(cursorRect)) |
109 | { | 109 | { |
110 | bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, | 110 | bitBlt( &store, 0, 0, this, px - STORE_W, py - STORE_W, |
111 | STORE_W2, STORE_W2, CopyROP ); | 111 | STORE_W2, STORE_W2, CopyROP ); |
112 | drawCursor( &painter, px, py ); | 112 | drawCursor( &painter, px, py ); |
113 | } | 113 | } |
114 | else if (paintRect.intersects(cursorRect)) | 114 | else if (paintRect.intersects(cursorRect)) |
115 | { | 115 | { |
116 | repaint( cursorRect, false); | 116 | repaint( cursorRect, false); |
117 | } | 117 | } |
118 | 118 | ||
119 | painter.end(); | 119 | painter.end(); |
120 | } | 120 | } |
121 | 121 | ||
122 | void OXYSelector::mousePressEvent( QMouseEvent *e ) | 122 | void OXYSelector::mousePressEvent( QMouseEvent *e ) |
123 | { | 123 | { |
124 | int xVal, yVal; | 124 | int xVal, yVal; |
125 | valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); | 125 | valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); |
126 | setValues( xVal, yVal ); | 126 | setValues( xVal, yVal ); |
127 | 127 | ||
128 | emit valueChanged( xPos, yPos ); | 128 | emit valueChanged( xPos, yPos ); |
129 | } | 129 | } |
130 | 130 | ||
131 | void OXYSelector::mouseMoveEvent( QMouseEvent *e ) | 131 | void OXYSelector::mouseMoveEvent( QMouseEvent *e ) |
132 | { | 132 | { |
133 | int xVal, yVal; | 133 | int xVal, yVal; |
134 | valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); | 134 | valuesFromPosition( e->pos().x() - 2, e->pos().y() - 2, xVal, yVal ); |
135 | setValues( xVal, yVal ); | 135 | setValues( xVal, yVal ); |
136 | 136 | ||
137 | emit valueChanged( xPos, yPos ); | 137 | emit valueChanged( xPos, yPos ); |
138 | } | 138 | } |
139 | 139 | ||
140 | void OXYSelector::wheelEvent( QWheelEvent *e ) | 140 | void OXYSelector::wheelEvent( QWheelEvent *e ) |
141 | { | 141 | { |
142 | #if QT_VERSION > 290 | 142 | #if QT_VERSION >= 0x030000 |
143 | if ( e->orientation() == Qt::Horizontal ) | 143 | if ( e->orientation() == Qt::Horizontal ) |
144 | setValues( xValue() + e->delta()/120, yValue() ); | 144 | setValues( xValue() + e->delta()/120, yValue() ); |
145 | else | 145 | else |
146 | setValues( xValue(), yValue() + e->delta()/120 ); | 146 | setValues( xValue(), yValue() + e->delta()/120 ); |
147 | 147 | ||
148 | emit valueChanged( xPos, yPos ); | 148 | emit valueChanged( xPos, yPos ); |
149 | #else | 149 | #else |
150 | Q_UNUSED( e ) | 150 | Q_UNUSED( e ) |
151 | #endif | 151 | #endif |
152 | } | 152 | } |
153 | 153 | ||
154 | void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const | 154 | void OXYSelector::valuesFromPosition( int x, int y, int &xVal, int &yVal ) const |
155 | { | 155 | { |
156 | xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 ); | 156 | xVal = ( (maxX-minX) * (x-2) ) / ( width()-4 ); |
157 | yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) ); | 157 | yVal = maxY - ( ( (maxY-minY) * (y-2) ) / ( height()-4 ) ); |
158 | 158 | ||
159 | if ( xVal > maxX ) | 159 | if ( xVal > maxX ) |
160 | xVal = maxX; | 160 | xVal = maxX; |
161 | else if ( xVal < minX ) | 161 | else if ( xVal < minX ) |
162 | xVal = minX; | 162 | xVal = minX; |
163 | 163 | ||
164 | if ( yVal > maxY ) | 164 | if ( yVal > maxY ) |
165 | yVal = maxY; | 165 | yVal = maxY; |
166 | else if ( yVal < minY ) | 166 | else if ( yVal < minY ) |
167 | yVal = minY; | 167 | yVal = minY; |
168 | } | 168 | } |
169 | 169 | ||
170 | void OXYSelector::setPosition( int xp, int yp ) | 170 | void OXYSelector::setPosition( int xp, int yp ) |
171 | { | 171 | { |
172 | if ( xp < 2 ) | 172 | if ( xp < 2 ) |
173 | xp = 2; | 173 | xp = 2; |
174 | else if ( xp > width() - 2 ) | 174 | else if ( xp > width() - 2 ) |
175 | xp = width() - 2; | 175 | xp = width() - 2; |
176 | 176 | ||
177 | if ( yp < 2 ) | 177 | if ( yp < 2 ) |
178 | yp = 2; | 178 | yp = 2; |
179 | else if ( yp > height() - 2 ) | 179 | else if ( yp > height() - 2 ) |
180 | yp = height() - 2; | 180 | yp = height() - 2; |
181 | 181 | ||
182 | QPainter painter; | 182 | QPainter painter; |
183 | painter.begin( this ); | 183 | painter.begin( this ); |
184 | 184 | ||
185 | bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0, | 185 | bitBlt( this, px - STORE_W, py - STORE_W, &store, 0, 0, |
186 | STORE_W2, STORE_W2, CopyROP ); | 186 | STORE_W2, STORE_W2, CopyROP ); |
187 | bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W, | 187 | bitBlt( &store, 0, 0, this, xp - STORE_W, yp - STORE_W, |
188 | STORE_W2, STORE_W2, CopyROP ); | 188 | STORE_W2, STORE_W2, CopyROP ); |
189 | drawCursor( &painter, xp, yp ); | 189 | drawCursor( &painter, xp, yp ); |
190 | px = xp; | 190 | px = xp; |
191 | py = yp; | 191 | py = yp; |
192 | 192 | ||
193 | painter.end(); | 193 | painter.end(); |
194 | } | 194 | } |
195 | 195 | ||
196 | void OXYSelector::drawContents( QPainter * ) | 196 | void OXYSelector::drawContents( QPainter * ) |
197 | {} | 197 | {} |
198 | 198 | ||
199 | 199 | ||
200 | void OXYSelector::drawCursor( QPainter *p, int xp, int yp ) | 200 | void OXYSelector::drawCursor( QPainter *p, int xp, int yp ) |
201 | { | 201 | { |
202 | p->setPen( QPen( white ) ); | 202 | p->setPen( QPen( white ) ); |
203 | 203 | ||
204 | p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 ); | 204 | p->drawLine( xp - 6, yp - 6, xp - 2, yp - 2 ); |
205 | p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 ); | 205 | p->drawLine( xp - 6, yp + 6, xp - 2, yp + 2 ); |
206 | p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 ); | 206 | p->drawLine( xp + 6, yp - 6, xp + 2, yp - 2 ); |
207 | p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 ); | 207 | p->drawLine( xp + 6, yp + 6, xp + 2, yp + 2 ); |
208 | } | 208 | } |
209 | 209 | ||
210 | //----------------------------------------------------------------------------- | 210 | //----------------------------------------------------------------------------- |
211 | /* | 211 | /* |
212 | * 1D value selector with contents drawn by derived class. | 212 | * 1D value selector with contents drawn by derived class. |
213 | * See OColorDialog for example. | 213 | * See OColorDialog for example. |
214 | */ | 214 | */ |
215 | 215 | ||
216 | 216 | ||
217 | OSelector::OSelector( QWidget *parent, const char *name ) | 217 | OSelector::OSelector( QWidget *parent, const char *name ) |
218 | : QWidget( parent, name ), QRangeControl() | 218 | : QWidget( parent, name ), QRangeControl() |
219 | { | 219 | { |
220 | _orientation = Horizontal; | 220 | _orientation = Horizontal; |
221 | _indent = TRUE; | 221 | _indent = TRUE; |
222 | } | 222 | } |
223 | 223 | ||
224 | OSelector::OSelector( Orientation o, QWidget *parent, const char *name ) | 224 | OSelector::OSelector( Orientation o, QWidget *parent, const char *name ) |
225 | : QWidget( parent, name ), QRangeControl() | 225 | : QWidget( parent, name ), QRangeControl() |
226 | { | 226 | { |
227 | _orientation = o; | 227 | _orientation = o; |
228 | _indent = TRUE; | 228 | _indent = TRUE; |
229 | } | 229 | } |
230 | 230 | ||
231 | 231 | ||
232 | OSelector::~OSelector() | 232 | OSelector::~OSelector() |
233 | {} | 233 | {} |
234 | 234 | ||
235 | 235 | ||
236 | QRect OSelector::contentsRect() const | 236 | QRect OSelector::contentsRect() const |
237 | { | 237 | { |
238 | if ( orientation() == Vertical ) | 238 | if ( orientation() == Vertical ) |
diff --git a/libopie2/opieui/oselector.h b/libopie2/opieui/oselector.h index fe75a46..3dbdb38 100644 --- a/libopie2/opieui/oselector.h +++ b/libopie2/opieui/oselector.h | |||
@@ -115,208 +115,208 @@ protected: | |||
115 | /** | 115 | /** |
116 | * @reimplemented | 116 | * @reimplemented |
117 | */ | 117 | */ |
118 | virtual void wheelEvent( QWheelEvent * ); | 118 | virtual void wheelEvent( QWheelEvent * ); |
119 | /** | 119 | /** |
120 | * Converts a pixel position to its corresponding values. | 120 | * Converts a pixel position to its corresponding values. |
121 | */ | 121 | */ |
122 | void valuesFromPosition( int x, int y, int& xVal, int& yVal ) const; | 122 | void valuesFromPosition( int x, int y, int& xVal, int& yVal ) const; |
123 | 123 | ||
124 | private: | 124 | private: |
125 | void setPosition( int xp, int yp ); | 125 | void setPosition( int xp, int yp ); |
126 | int px; | 126 | int px; |
127 | int py; | 127 | int py; |
128 | int xPos; | 128 | int xPos; |
129 | int yPos; | 129 | int yPos; |
130 | int minX; | 130 | int minX; |
131 | int maxX; | 131 | int maxX; |
132 | int minY; | 132 | int minY; |
133 | int maxY; | 133 | int maxY; |
134 | QPixmap store; | 134 | QPixmap store; |
135 | 135 | ||
136 | private: | 136 | private: |
137 | class OXYSelectorPrivate; | 137 | class OXYSelectorPrivate; |
138 | OXYSelectorPrivate *d; | 138 | OXYSelectorPrivate *d; |
139 | }; | 139 | }; |
140 | 140 | ||
141 | 141 | ||
142 | /** | 142 | /** |
143 | * OSelector is the base class for other widgets which | 143 | * OSelector is the base class for other widgets which |
144 | * provides the ability to choose from a one-dimensional | 144 | * provides the ability to choose from a one-dimensional |
145 | * range of values. An example is the @ref OGradientSelector | 145 | * range of values. An example is the @ref OGradientSelector |
146 | * which allows to choose from a range of colors. | 146 | * which allows to choose from a range of colors. |
147 | * | 147 | * |
148 | * A custom drawing routine for the widget surface has | 148 | * A custom drawing routine for the widget surface has |
149 | * to be provided by the subclass. | 149 | * to be provided by the subclass. |
150 | */ | 150 | */ |
151 | class OSelector : public QWidget, public QRangeControl | 151 | class OSelector : public QWidget, public QRangeControl |
152 | { | 152 | { |
153 | Q_OBJECT | 153 | Q_OBJECT |
154 | Q_PROPERTY( int value READ value WRITE setValue ) | 154 | Q_PROPERTY( int value READ value WRITE setValue ) |
155 | Q_PROPERTY( int minValue READ minValue WRITE setMinValue ) | 155 | Q_PROPERTY( int minValue READ minValue WRITE setMinValue ) |
156 | Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue ) | 156 | Q_PROPERTY( int maxValue READ maxValue WRITE setMaxValue ) |
157 | public: | 157 | public: |
158 | 158 | ||
159 | /** | 159 | /** |
160 | * Constructs a horizontal one-dimensional selection widget. | 160 | * Constructs a horizontal one-dimensional selection widget. |
161 | */ | 161 | */ |
162 | OSelector( QWidget *parent=0, const char *name=0 ); | 162 | OSelector( QWidget *parent=0, const char *name=0 ); |
163 | /** | 163 | /** |
164 | * Constructs a one-dimensional selection widget with | 164 | * Constructs a one-dimensional selection widget with |
165 | * a given orientation. | 165 | * a given orientation. |
166 | */ | 166 | */ |
167 | OSelector( Orientation o, QWidget *parent = 0L, const char *name = 0L ); | 167 | OSelector( Orientation o, QWidget *parent = 0L, const char *name = 0L ); |
168 | /* | 168 | /* |
169 | * Destructs the widget. | 169 | * Destructs the widget. |
170 | */ | 170 | */ |
171 | ~OSelector(); | 171 | ~OSelector(); |
172 | 172 | ||
173 | /** | 173 | /** |
174 | * @return the orientation of the widget. | 174 | * @return the orientation of the widget. |
175 | */ | 175 | */ |
176 | Orientation orientation() const | 176 | Orientation orientation() const |
177 | {return _orientation; } | 177 | {return _orientation; } |
178 | 178 | ||
179 | /** | 179 | /** |
180 | * @return the rectangle on which subclasses should draw. | 180 | * @return the rectangle on which subclasses should draw. |
181 | */ | 181 | */ |
182 | QRect contentsRect() const; | 182 | QRect contentsRect() const; |
183 | 183 | ||
184 | /** | 184 | /** |
185 | * Sets the indent option of the widget to i. | 185 | * Sets the indent option of the widget to i. |
186 | * This determines whether a shaded frame is drawn. | 186 | * This determines whether a shaded frame is drawn. |
187 | */ | 187 | */ |
188 | void setIndent( bool i ) | 188 | void setIndent( bool i ) |
189 | {_indent = i; } | 189 | {_indent = i; } |
190 | /** | 190 | /** |
191 | * @return whether the indent option is set. | 191 | * @return whether the indent option is set. |
192 | */ | 192 | */ |
193 | bool indent() const | 193 | bool indent() const |
194 | {return _indent; } | 194 | {return _indent; } |
195 | 195 | ||
196 | /** | 196 | /** |
197 | * Sets the value. | 197 | * Sets the value. |
198 | */ | 198 | */ |
199 | void setValue(int value) | 199 | void setValue(int value) |
200 | { QRangeControl::setValue(value); } | 200 | { QRangeControl::setValue(value); } |
201 | 201 | ||
202 | /** | 202 | /** |
203 | * @returns the value. | 203 | * @returns the value. |
204 | */ | 204 | */ |
205 | int value() const | 205 | int value() const |
206 | { return QRangeControl::value(); } | 206 | { return QRangeControl::value(); } |
207 | 207 | ||
208 | /** | 208 | /** |
209 | * Sets the min value. | 209 | * Sets the min value. |
210 | */ | 210 | */ |
211 | #if ( QT_VERSION > 290 ) | 211 | #if ( QT_VERSION >= 0x030000 ) |
212 | void setMinValue(int value) { QRangeControl::setMinValue(value); } | 212 | void setMinValue(int value) { QRangeControl::setMinValue(value); } |
213 | #else | 213 | #else |
214 | void setMinValue(int value) { QRangeControl::setRange(value,QRangeControl::maxValue()); } | 214 | void setMinValue(int value) { QRangeControl::setRange(value,QRangeControl::maxValue()); } |
215 | #endif | 215 | #endif |
216 | 216 | ||
217 | /** | 217 | /** |
218 | * @return the min value. | 218 | * @return the min value. |
219 | */ | 219 | */ |
220 | int minValue() const | 220 | int minValue() const |
221 | { return QRangeControl::minValue(); } | 221 | { return QRangeControl::minValue(); } |
222 | 222 | ||
223 | /** | 223 | /** |
224 | * Sets the max value. | 224 | * Sets the max value. |
225 | */ | 225 | */ |
226 | #if ( QT_VERSION > 290 ) | 226 | #if ( QT_VERSION >= 0x030000 ) |
227 | void setMaxValue(int value) { QRangeControl::setMaxValue(value); } | 227 | void setMaxValue(int value) { QRangeControl::setMaxValue(value); } |
228 | #else | 228 | #else |
229 | void setMaxValue(int value) { QRangeControl::setRange(QRangeControl::minValue(),value); } | 229 | void setMaxValue(int value) { QRangeControl::setRange(QRangeControl::minValue(),value); } |
230 | #endif | 230 | #endif |
231 | 231 | ||
232 | /** | 232 | /** |
233 | * @return the max value. | 233 | * @return the max value. |
234 | */ | 234 | */ |
235 | int maxValue() const | 235 | int maxValue() const |
236 | { return QRangeControl::maxValue(); } | 236 | { return QRangeControl::maxValue(); } |
237 | 237 | ||
238 | signals: | 238 | signals: |
239 | /** | 239 | /** |
240 | * This signal is emitted whenever the user chooses a value, | 240 | * This signal is emitted whenever the user chooses a value, |
241 | * e.g. by clicking with the mouse on the widget. | 241 | * e.g. by clicking with the mouse on the widget. |
242 | */ | 242 | */ |
243 | void valueChanged( int value ); | 243 | void valueChanged( int value ); |
244 | 244 | ||
245 | protected: | 245 | protected: |
246 | /** | 246 | /** |
247 | * Override this function to draw the contents of the control. | 247 | * Override this function to draw the contents of the control. |
248 | * The default implementation does nothing. | 248 | * The default implementation does nothing. |
249 | * | 249 | * |
250 | * Draw only within contentsRect(). | 250 | * Draw only within contentsRect(). |
251 | */ | 251 | */ |
252 | virtual void drawContents( QPainter * ); | 252 | virtual void drawContents( QPainter * ); |
253 | /** | 253 | /** |
254 | * Override this function to draw the cursor which | 254 | * Override this function to draw the cursor which |
255 | * indicates the current value. This function is | 255 | * indicates the current value. This function is |
256 | * always called twice, once with argument show=false | 256 | * always called twice, once with argument show=false |
257 | * to clear the old cursor, once with argument show=true | 257 | * to clear the old cursor, once with argument show=true |
258 | * to draw the new one. | 258 | * to draw the new one. |
259 | */ | 259 | */ |
260 | virtual void drawArrow( QPainter *painter, bool show, const QPoint &pos ); | 260 | virtual void drawArrow( QPainter *painter, bool show, const QPoint &pos ); |
261 | 261 | ||
262 | /** | 262 | /** |
263 | * @reimplemented | 263 | * @reimplemented |
264 | */ | 264 | */ |
265 | virtual void valueChange(); | 265 | virtual void valueChange(); |
266 | /** | 266 | /** |
267 | * @reimplemented | 267 | * @reimplemented |
268 | */ | 268 | */ |
269 | virtual void paintEvent( QPaintEvent * ); | 269 | virtual void paintEvent( QPaintEvent * ); |
270 | /** | 270 | /** |
271 | * @reimplemented | 271 | * @reimplemented |
272 | */ | 272 | */ |
273 | virtual void mousePressEvent( QMouseEvent *e ); | 273 | virtual void mousePressEvent( QMouseEvent *e ); |
274 | /** | 274 | /** |
275 | * @reimplemented | 275 | * @reimplemented |
276 | */ | 276 | */ |
277 | virtual void mouseMoveEvent( QMouseEvent *e ); | 277 | virtual void mouseMoveEvent( QMouseEvent *e ); |
278 | /** | 278 | /** |
279 | * @reimplemented | 279 | * @reimplemented |
280 | */ | 280 | */ |
281 | virtual void wheelEvent( QWheelEvent * ); | 281 | virtual void wheelEvent( QWheelEvent * ); |
282 | 282 | ||
283 | private: | 283 | private: |
284 | QPoint calcArrowPos( int val ); | 284 | QPoint calcArrowPos( int val ); |
285 | void moveArrow( const QPoint &pos ); | 285 | void moveArrow( const QPoint &pos ); |
286 | 286 | ||
287 | Orientation _orientation; | 287 | Orientation _orientation; |
288 | bool _indent; | 288 | bool _indent; |
289 | 289 | ||
290 | private: | 290 | private: |
291 | class OSelectorPrivate; | 291 | class OSelectorPrivate; |
292 | OSelectorPrivate *d; | 292 | OSelectorPrivate *d; |
293 | }; | 293 | }; |
294 | 294 | ||
295 | 295 | ||
296 | /** | 296 | /** |
297 | * The OGradientSelector widget allows the user to choose | 297 | * The OGradientSelector widget allows the user to choose |
298 | * from a one-dimensional range of colors which is given as a | 298 | * from a one-dimensional range of colors which is given as a |
299 | * gradient between two colors provided by the programmer. | 299 | * gradient between two colors provided by the programmer. |
300 | */ | 300 | */ |
301 | class OGradientSelector : public OSelector | 301 | class OGradientSelector : public OSelector |
302 | { | 302 | { |
303 | Q_OBJECT | 303 | Q_OBJECT |
304 | 304 | ||
305 | Q_PROPERTY( QColor firstColor READ firstColor WRITE setFirstColor ) | 305 | Q_PROPERTY( QColor firstColor READ firstColor WRITE setFirstColor ) |
306 | Q_PROPERTY( QColor secondColor READ secondColor WRITE setSecondColor ) | 306 | Q_PROPERTY( QColor secondColor READ secondColor WRITE setSecondColor ) |
307 | Q_PROPERTY( QString firstText READ firstText WRITE setFirstText ) | 307 | Q_PROPERTY( QString firstText READ firstText WRITE setFirstText ) |
308 | Q_PROPERTY( QString secondText READ secondText WRITE setSecondText ) | 308 | Q_PROPERTY( QString secondText READ secondText WRITE setSecondText ) |
309 | 309 | ||
310 | public: | 310 | public: |
311 | /** | 311 | /** |
312 | * Constructs a horizontal color selector which | 312 | * Constructs a horizontal color selector which |
313 | * contains a gradient between white and black. | 313 | * contains a gradient between white and black. |
314 | */ | 314 | */ |
315 | OGradientSelector( QWidget *parent=0, const char *name=0 ); | 315 | OGradientSelector( QWidget *parent=0, const char *name=0 ); |
316 | /** | 316 | /** |
317 | * Constructs a colors selector with orientation o which | 317 | * Constructs a colors selector with orientation o which |
318 | * contains a gradient between white and black. | 318 | * contains a gradient between white and black. |
319 | */ | 319 | */ |
320 | OGradientSelector( Orientation o, QWidget *parent=0, const char *name=0 ); | 320 | OGradientSelector( Orientation o, QWidget *parent=0, const char *name=0 ); |
321 | /** | 321 | /** |
322 | * Destructs the widget. | 322 | * Destructs the widget. |