summaryrefslogtreecommitdiff
authorzecke <zecke>2002-09-17 17:05:19 (UTC)
committer zecke <zecke>2002-09-17 17:05:19 (UTC)
commite1614b49cf61ee37350828ce5b5178a9da752f39 (patch) (unidiff)
tree836d16a45aaeb47cba40405ff8956a1661315637
parent01b2fc89a105bf5b56bc1aa467343d14589dadd2 (diff)
downloadopie-e1614b49cf61ee37350828ce5b5178a9da752f39.zip
opie-e1614b49cf61ee37350828ce5b5178a9da752f39.tar.gz
opie-e1614b49cf61ee37350828ce5b5178a9da752f39.tar.bz2
update
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--library/fileselector.h2
-rw-r--r--library/qpedecoration_qws.cpp3
2 files changed, 2 insertions, 3 deletions
diff --git a/library/fileselector.h b/library/fileselector.h
index ef57626..f1c9eb1 100644
--- a/library/fileselector.h
+++ b/library/fileselector.h
@@ -1,113 +1,113 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifndef FILESELECTOR_H 20#ifndef FILESELECTOR_H
21#define FILESELECTOR_H 21#define FILESELECTOR_H
22 22
23#include <qhbox.h> 23#include <qhbox.h>
24#include <qvbox.h> 24#include <qvbox.h>
25#include <qtoolbutton.h> 25#include <qtoolbutton.h>
26#include <qlistview.h> 26#include <qlistview.h>
27 27
28#include "filemanager.h" 28#include "filemanager.h"
29#include "applnk.h" 29#include "applnk.h"
30 30
31class QPopupMenu; 31class QPopupMenu;
32class QPushButton; 32class QPushButton;
33class FileSelectorView; 33class FileSelectorView;
34 34
35class FileSelectorItem : public QListViewItem 35class FileSelectorItem : public QListViewItem
36{ 36{
37public: 37public:
38 FileSelectorItem( QListView *parent, const DocLnk& f ); 38 FileSelectorItem( QListView *parent, const DocLnk& f );
39 ~FileSelectorItem(); 39 ~FileSelectorItem();
40 40
41 DocLnk file() const { return fl; } 41 DocLnk file() const { return fl; }
42 42
43private: 43private:
44 DocLnk fl; 44 DocLnk fl;
45}; 45};
46 46
47class FileSelectorPrivate; 47class FileSelectorPrivate;
48class FileSelector : public QVBox 48class FileSelector : public QVBox
49{ 49{
50 Q_OBJECT 50 Q_OBJECT
51 51
52public: 52public:
53 FileSelector( const QString &mimefilter, QWidget *parent, const char *name=0, bool newVisible = TRUE, bool closeVisible = TRUE ); 53 FileSelector( const QString &mimefilter, QWidget *parent, const char *name=0, bool newVisible = TRUE, bool closeVisible = TRUE );
54 ~FileSelector(); 54 ~FileSelector();
55 void setNewVisible( bool b ); 55 void setNewVisible( bool b );
56 void setCloseVisible( bool b ); 56 void setCloseVisible( bool b );
57 void reread(); 57 void reread();
58 int fileCount(); 58 int fileCount();
59 DocLnk selectedDocument() const 59 DocLnk selectedDocument() const
60 { 60 {
61 const DocLnk* rp = ((FileSelector*)this)->selected(); 61 const DocLnk* rp = ((FileSelector*)this)->selected();
62 if (!rp) { 62 if (!rp) {
63 DocLnk r; 63 DocLnk r;
64 return r; 64 return r;
65 } 65 }
66 DocLnk r(*rp); 66 DocLnk r(*rp);
67 delete rp; 67 delete rp;
68 return r; 68 return r;
69 } 69 }
70 70
71 QValueList<DocLnk> fileList() const 71 QValueList<DocLnk> fileList() const
72 { 72 {
73 ((FileSelector*)this)->fileCount(); // ensure all loaded when this is extended 73 ((FileSelector*)this)->fileCount(); // ensure all loaded when this is extended
74 74
75 QValueList<DocLnk> list; 75 QValueList<DocLnk> list;
76 FileSelectorItem *item = (FileSelectorItem *)((QListView*)view)->firstChild(); 76 FileSelectorItem *item = (FileSelectorItem *)((QListView*)view)->firstChild();
77 while (item) { 77 while (item) {
78 list.append(item->file()); 78 list.append(item->file());
79 item = (FileSelectorItem *)item->nextSibling(); 79 item = (FileSelectorItem *)item->nextSibling();
80 } 80 }
81 81
82 return list; 82 return list;
83 } 83 }
84 84
85signals: 85signals:
86 void fileSelected( const DocLnk & ); 86 void fileSelected( const DocLnk & );
87 void newSelected( const DocLnk & ); 87 void newSelected( const DocLnk & );
88 void closeMe(); 88 void closeMe();
89 89
90private slots: 90private slots:
91 void createNew(); 91 void createNew();
92 void fileClicked( int, QListViewItem *, const QPoint &, int ); 92 void fileClicked( int, QListViewItem *, const QPoint &, int );
93 // pressed to get 'right down' 93 // pressed to get 'right down'
94 void filePressed( int, QListViewItem *, const QPoint &, int ); 94 void filePressed( int, QListViewItem *, const QPoint &, int );
95 void fileClicked( QListViewItem *); 95 void fileClicked( QListViewItem *);
96 void typeSelected( const QString &type ); 96 void typeSelected( const QString &type );
97 void catSelected( int ); 97 void catSelected( int );
98 void cardMessage( const QCString &, const QByteArray &); 98 void cardMessage( const QCString &, const QByteArray &);
99 99
100private: 100private:
101 void updateView(); 101 void updateView();
102 void updateWhatsThis(); 102 void updateWhatsThis();
103 103
104private: 104private:
105 // RESOLVE please -zecke@handhelds.org 105 // RESOLVE please -zecke@handhelds.org
106 const DocLnk *selected(); // use selectedDocument() that's no luckily no compiler is putting the access into the symbol name 106 const DocLnk *selected(); // use selectedDocument() luckily no compiler is putting the access into the symbol name
107 FileSelectorView *view; 107 FileSelectorView *view;
108 QString filter; 108 QString filter;
109 QToolButton *buttonNew, *buttonClose; 109 QToolButton *buttonNew, *buttonClose;
110 FileSelectorPrivate *d; 110 FileSelectorPrivate *d;
111}; 111};
112 112
113#endif 113#endif
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp
index c2eb751..708dd23 100644
--- a/library/qpedecoration_qws.cpp
+++ b/library/qpedecoration_qws.cpp
@@ -1,879 +1,878 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved. 2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3** 3**
4** This file is part of the Qtopia Environment. 4** This file is part of the Qtopia Environment.
5** 5**
6** This file may be distributed and/or modified under the terms of the 6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software 7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the 8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file. 9** packaging of this file.
10** 10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20#ifdef QWS 20#ifdef QWS
21#define QTOPIA_INTERNAL_LANGLIST 21#define QTOPIA_INTERNAL_LANGLIST
22#include <qapplication.h> 22#include <qapplication.h>
23#include <qstyle.h> 23#include <qstyle.h>
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include "qcopenvelope_qws.h" 28#include "qcopenvelope_qws.h"
29#include "qpedecoration_qws.h" 29#include "qpedecoration_qws.h"
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qdrawutil.h> 31#include <qdrawutil.h>
32#include <qgfx_qws.h> 32#include <qgfx_qws.h>
33#include "qpeapplication.h" 33#include "qpeapplication.h"
34#include "resource.h" 34#include "resource.h"
35#include "global.h" 35#include "global.h"
36#include "qlibrary.h" 36#include "qlibrary.h"
37#include "windowdecorationinterface.h" 37#include "windowdecorationinterface.h"
38#include <qfile.h> 38#include <qfile.h>
39#include <qsignal.h> 39#include <qsignal.h>
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42 42
43extern QRect qt_maxWindowRect; 43extern QRect qt_maxWindowRect;
44 44
45#define WHATSTHIS_MODE 45#define WHATSTHIS_MODE
46 46
47#ifndef QT_NO_QWS_QPE_WM_STYLE 47#ifndef QT_NO_QWS_QPE_WM_STYLE
48 48
49#ifndef QT_NO_IMAGEIO_XPM 49#ifndef QT_NO_IMAGEIO_XPM
50 50
51/* XPM */ 51/* XPM */
52static const char * const qpe_close_xpm[] = { 52static const char * const qpe_close_xpm[] = {
53"16 16 3 1", 53"16 16 3 1",
54" c None", 54" c None",
55". c #FFFFFF", 55". c #FFFFFF",
56"+ c #000000", 56"+ c #000000",
57" ", 57" ",
58" ", 58" ",
59" ..... ", 59" ..... ",
60" ..+++++.. ", 60" ..+++++.. ",
61" .+++++++++. ", 61" .+++++++++. ",
62" .+..+++..+. ", 62" .+..+++..+. ",
63" .++...+...++. ", 63" .++...+...++. ",
64" .+++.....+++. ", 64" .+++.....+++. ",
65" .++++...++++. ", 65" .++++...++++. ",
66" .+++.....+++. ", 66" .+++.....+++. ",
67" .++...+...++. ", 67" .++...+...++. ",
68" .+..+++..+. ", 68" .+..+++..+. ",
69" .+++++++++. ", 69" .+++++++++. ",
70" ..+++++.. ", 70" ..+++++.. ",
71" ..... ", 71" ..... ",
72" "}; 72" "};
73 73
74/* XPM */ 74/* XPM */
75static const char * const qpe_accept_xpm[] = { 75static const char * const qpe_accept_xpm[] = {
76"16 16 3 1", 76"16 16 3 1",
77" c None", 77" c None",
78". c #FFFFFF", 78". c #FFFFFF",
79"+ c #000000", 79"+ c #000000",
80" ", 80" ",
81" ", 81" ",
82" ..... ", 82" ..... ",
83" ..+++++.. ", 83" ..+++++.. ",
84" .+++++++++. ", 84" .+++++++++. ",
85" .+++++++++. ", 85" .+++++++++. ",
86" .+++++++..++. ", 86" .+++++++..++. ",
87" .++.+++...++. ", 87" .++.+++...++. ",
88" .+...+...+++. ", 88" .+...+...+++. ",
89" .+......++++. ", 89" .+......++++. ",
90" .++....+++++. ", 90" .++....+++++. ",
91" .++..+++++. ", 91" .++..+++++. ",
92" .+++++++++. ", 92" .+++++++++. ",
93" ..+++++.. ", 93" ..+++++.. ",
94" ..... ", 94" ..... ",
95" "}; 95" "};
96 96
97#endif // QT_NO_IMAGEIO_XPM 97#endif // QT_NO_IMAGEIO_XPM
98 98
99class HackWidget : public QWidget 99class HackWidget : public QWidget
100{ 100{
101public: 101public:
102 bool needsOk() { 102 bool needsOk() {
103 return (getWState() & WState_Reserved1 ) || 103 return (getWState() & WState_Reserved1 ) ||
104 (inherits( "QDialog" ) && !inherits( "QMessageBox" ) ); 104 (inherits( "QDialog" ) && !inherits( "QMessageBox" ) );
105 } 105 }
106}; 106};
107 107
108static QImage scaleButton( const QImage &img, int height ) 108static QImage scaleButton( const QImage &img, int height )
109{ 109{
110 qWarning("Height %d %d", height, img.height() ); 110 if ( img.height() != 0 && img.height() != height ) {
111 if ( img.height()!=0 && img.height() != height ) {
112 return img.smoothScale( img.width()*height/img.height(), height ); 111 return img.smoothScale( img.width()*height/img.height(), height );
113 } else { 112 } else {
114 return img; 113 return img;
115 } 114 }
116} 115}
117 116
118class TLWidget : public QWidget 117class TLWidget : public QWidget
119{ 118{
120public: 119public:
121 QWSManager *manager() 120 QWSManager *manager()
122 { 121 {
123 return topData()->qwsManager; 122 return topData()->qwsManager;
124 } 123 }
125 124
126 QTLWExtra *topExtra() 125 QTLWExtra *topExtra()
127 { 126 {
128 return topData(); 127 return topData();
129 } 128 }
130 129
131 void setWState( uint s ) { QWidget::setWState( s ); } 130 void setWState( uint s ) { QWidget::setWState( s ); }
132 void clearWState( uint s ) { QWidget::clearWState( s ); } 131 void clearWState( uint s ) { QWidget::clearWState( s ); }
133}; 132};
134 133
135 134
136QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) 135QPEManager::QPEManager( QPEDecoration *d, QObject *parent )
137 : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) 136 : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE)
138{ 137{
139 wtTimer = new QTimer( this ); 138 wtTimer = new QTimer( this );
140 connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); 139 connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) );
141} 140}
142 141
143 142
144void QPEManager::updateActive() 143void QPEManager::updateActive()
145{ 144{
146 QWidget *newActive = qApp->activeWindow(); 145 QWidget *newActive = qApp->activeWindow();
147 if ( newActive && (QWidget*)active == newActive ) 146 if ( newActive && (QWidget*)active == newActive )
148 return; 147 return;
149 148
150 if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { 149 if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) {
151 ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); 150 ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this );
152 } 151 }
153 152
154 if ( newActive && ((TLWidget *)newActive)->manager() ) { 153 if ( newActive && ((TLWidget *)newActive)->manager() ) {
155 active = newActive; 154 active = newActive;
156 ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); 155 ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this );
157 } else if ( !newActive ) { 156 } else if ( !newActive ) {
158 active = 0; 157 active = 0;
159 } 158 }
160} 159}
161 160
162int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) 161int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p )
163{ 162{
164 QRect rect(w->geometry()); 163 QRect rect(w->geometry());
165 164
166 if ( decoration->region( w, rect, 165 if ( decoration->region( w, rect,
167 (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) 166 (QWSDecoration::Region)QPEDecoration::Help ).contains(p) )
168 return QPEDecoration::Help; 167 return QPEDecoration::Help;
169 168
170 for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { 169 for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) {
171 if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) 170 if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p))
172 return (QWSDecoration::Region)i; 171 return (QWSDecoration::Region)i;
173 } 172 }
174 173
175 return QWSDecoration::None; 174 return QWSDecoration::None;
176} 175}
177 176
178bool QPEManager::eventFilter( QObject *o, QEvent *e ) 177bool QPEManager::eventFilter( QObject *o, QEvent *e )
179{ 178{
180 QWSManager *mgr = (QWSManager *)o; 179 QWSManager *mgr = (QWSManager *)o;
181 QWidget *w = mgr->widget(); 180 QWidget *w = mgr->widget();
182 switch ( e->type() ) { 181 switch ( e->type() ) {
183 case QEvent::MouseButtonPress: 182 case QEvent::MouseButtonPress:
184 { 183 {
185 pressTime = QTime::currentTime(); 184 pressTime = QTime::currentTime();
186 QPoint p = ((QMouseEvent*)e)->globalPos(); 185 QPoint p = ((QMouseEvent*)e)->globalPos();
187 int inRegion = pointInQpeRegion( w, p ); 186 int inRegion = pointInQpeRegion( w, p );
188#ifdef WHATSTHIS_MODE 187#ifdef WHATSTHIS_MODE
189 if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { 188 if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) {
190 QString text; 189 QString text;
191 switch ( inRegion ) { 190 switch ( inRegion ) {
192 case QWSDecoration::Close: 191 case QWSDecoration::Close:
193 if ( ((HackWidget*)w)->needsOk() ) 192 if ( ((HackWidget*)w)->needsOk() )
194 text = tr("Click to close this window, discarding changes."); 193 text = tr("Click to close this window, discarding changes.");
195 else 194 else
196 text = tr("Click to close this window."); 195 text = tr("Click to close this window.");
197 break; 196 break;
198 case QWSDecoration::Minimize: 197 case QWSDecoration::Minimize:
199 text = tr("Click to close this window and apply changes."); 198 text = tr("Click to close this window and apply changes.");
200 break; 199 break;
201 case QWSDecoration::Maximize: 200 case QWSDecoration::Maximize:
202 if ( w->isMaximized() ) 201 if ( w->isMaximized() )
203 text = tr("Click to make this window moveable."); 202 text = tr("Click to make this window moveable.");
204 else 203 else
205 text = tr("Click to make this window use all available screen area."); 204 text = tr("Click to make this window use all available screen area.");
206 break; 205 break;
207 default: 206 default:
208 break; 207 break;
209 } 208 }
210 QWhatsThis::leaveWhatsThisMode( text ); 209 QWhatsThis::leaveWhatsThisMode( text );
211 whatsThisTimeout(); 210 whatsThisTimeout();
212 helpState = 0; 211 helpState = 0;
213 return true; 212 return true;
214 } 213 }
215#endif 214#endif
216 if ( inRegion == QPEDecoration::Help ) { 215 if ( inRegion == QPEDecoration::Help ) {
217#ifdef WHATSTHIS_MODE 216#ifdef WHATSTHIS_MODE
218 wtTimer->start( 400, TRUE ); 217 wtTimer->start( 400, TRUE );
219#endif 218#endif
220 helpState = QWSButton::Clicked|QWSButton::MouseOver; 219 helpState = QWSButton::Clicked|QWSButton::MouseOver;
221 drawButton( w, QPEDecoration::Help, helpState ); 220 drawButton( w, QPEDecoration::Help, helpState );
222 return true; 221 return true;
223 } 222 }
224 } 223 }
225 break; 224 break;
226 case QEvent::MouseButtonRelease: 225 case QEvent::MouseButtonRelease:
227 if ( helpState & QWSButton::Clicked ) { 226 if ( helpState & QWSButton::Clicked ) {
228 wtTimer->stop(); 227 wtTimer->stop();
229 helpState = 0; 228 helpState = 0;
230 drawButton( w, QPEDecoration::Help, helpState ); 229 drawButton( w, QPEDecoration::Help, helpState );
231 QPoint p = ((QMouseEvent*)e)->globalPos(); 230 QPoint p = ((QMouseEvent*)e)->globalPos();
232 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { 231 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) {
233 decoration->help( w ); 232 decoration->help( w );
234 } 233 }
235 return true; 234 return true;
236 } 235 }
237 break; 236 break;
238 case QEvent::MouseMove: 237 case QEvent::MouseMove:
239 if ( helpState & QWSButton::Clicked ) { 238 if ( helpState & QWSButton::Clicked ) {
240 int oldState = helpState; 239 int oldState = helpState;
241 QPoint p = ((QMouseEvent*)e)->globalPos(); 240 QPoint p = ((QMouseEvent*)e)->globalPos();
242 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { 241 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) {
243 helpState = QWSButton::Clicked|QWSButton::MouseOver; 242 helpState = QWSButton::Clicked|QWSButton::MouseOver;
244 } else { 243 } else {
245 helpState = 0; 244 helpState = 0;
246 } 245 }
247 if ( helpState != oldState ) 246 if ( helpState != oldState )
248 drawButton( w, QPEDecoration::Help, helpState ); 247 drawButton( w, QPEDecoration::Help, helpState );
249 } 248 }
250 break; 249 break;
251 default: 250 default:
252 break; 251 break;
253 } 252 }
254 return QObject::eventFilter( o, e ); 253 return QObject::eventFilter( o, e );
255} 254}
256 255
257void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) 256void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state )
258{ 257{
259 QPainter painter(w); 258 QPainter painter(w);
260 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; 259 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region;
261 painter.internalGfx()->setWidgetDeviceRegion( rgn ); 260 painter.internalGfx()->setWidgetDeviceRegion( rgn );
262 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); 261 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All));
263 decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); 262 decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state );
264} 263}
265 264
266void QPEManager::drawTitle( QWidget *w ) 265void QPEManager::drawTitle( QWidget *w )
267{ 266{
268 QPainter painter(w); 267 QPainter painter(w);
269 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; 268 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region;
270 painter.internalGfx()->setWidgetDeviceRegion( rgn ); 269 painter.internalGfx()->setWidgetDeviceRegion( rgn );
271 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); 270 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All));
272 decoration->paint( &painter, w ); 271 decoration->paint( &painter, w );
273 decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); 272 decoration->paintButton(&painter, w, QWSDecoration::Menu, 0);
274 decoration->paintButton(&painter, w, QWSDecoration::Close, 0); 273 decoration->paintButton(&painter, w, QWSDecoration::Close, 0);
275 decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); 274 decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0);
276 decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); 275 decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0);
277} 276}
278 277
279void QPEManager::whatsThisTimeout() 278void QPEManager::whatsThisTimeout()
280{ 279{
281 if ( !QWhatsThis::inWhatsThisMode() ) { 280 if ( !QWhatsThis::inWhatsThisMode() ) {
282 if ( inWhatsThis ) { 281 if ( inWhatsThis ) {
283 if ( whatsThis ) { 282 if ( whatsThis ) {
284 QWidget *w = whatsThis; 283 QWidget *w = whatsThis;
285 whatsThis = 0; 284 whatsThis = 0;
286 drawTitle( w ); 285 drawTitle( w );
287 } 286 }
288 wtTimer->stop(); 287 wtTimer->stop();
289 } else { 288 } else {
290 QWhatsThis::enterWhatsThisMode(); 289 QWhatsThis::enterWhatsThisMode();
291 helpState = 0; 290 helpState = 0;
292 updateActive(); 291 updateActive();
293 if ( active ) { 292 if ( active ) {
294 whatsThis = active; 293 whatsThis = active;
295 drawTitle( active ); 294 drawTitle( active );
296 // check periodically to see if we've left whats this mode 295 // check periodically to see if we've left whats this mode
297 wtTimer->start( 250 ); 296 wtTimer->start( 250 );
298 } 297 }
299 } 298 }
300 inWhatsThis = !inWhatsThis; 299 inWhatsThis = !inWhatsThis;
301 } 300 }
302} 301}
303 302
304//=========================================================================== 303//===========================================================================
305 304
306static QImage *okImage( int th ) 305static QImage *okImage( int th )
307{ 306{
308 static QImage *i = 0; 307 static QImage *i = 0;
309 if ( !i || i->height() != th ) { 308 if ( !i || i->height() != th ) {
310 delete i; 309 delete i;
311 i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); 310 i = new QImage(scaleButton(Resource::loadImage("OKButton"),th));
312 } 311 }
313 return i; 312 return i;
314} 313}
315 314
316static QImage *closeImage( int th ) 315static QImage *closeImage( int th )
317{ 316{
318 static QImage *i = 0; 317 static QImage *i = 0;
319 if ( !i || i->height() != th ) { 318 if ( !i || i->height() != th ) {
320 delete i; 319 delete i;
321 i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); 320 i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th));
322 } 321 }
323 return i; 322 return i;
324} 323}
325 324
326static QImage *helpImage( int th ) 325static QImage *helpImage( int th )
327{ 326{
328 static QImage *i = 0; 327 static QImage *i = 0;
329 if ( !i || i->height() != th ) { 328 if ( !i || i->height() != th ) {
330 delete i; 329 delete i;
331 i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); 330 i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th));
332 } 331 }
333 return i; 332 return i;
334} 333}
335 334
336static QImage *maximizeImage( int th ) 335static QImage *maximizeImage( int th )
337{ 336{
338 static QImage *i = 0; 337 static QImage *i = 0;
339 if ( !i || i->height() != th ) { 338 if ( !i || i->height() != th ) {
340 delete i; 339 delete i;
341 i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); 340 i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th));
342 } 341 }
343 return i; 342 return i;
344} 343}
345 344
346int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const 345int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const
347{ 346{
348 switch ( m ) { 347 switch ( m ) {
349 case TitleHeight: 348 case TitleHeight:
350 if ( QApplication::desktop()->height() > 320 ) 349 if ( QApplication::desktop()->height() > 320 )
351 return 19; 350 return 19;
352 else 351 else
353 return 15; 352 return 15;
354 case LeftBorder: 353 case LeftBorder:
355 case RightBorder: 354 case RightBorder:
356 case TopBorder: 355 case TopBorder:
357 case BottomBorder: 356 case BottomBorder:
358 return 4; 357 return 4;
359 case OKWidth: 358 case OKWidth:
360 return okImage(metric(TitleHeight,wd))->width(); 359 return okImage(metric(TitleHeight,wd))->width();
361 case CloseWidth: 360 case CloseWidth:
362 return closeImage(metric(TitleHeight,wd))->width(); 361 return closeImage(metric(TitleHeight,wd))->width();
363 case HelpWidth: 362 case HelpWidth:
364 return helpImage(metric(TitleHeight,wd))->width(); 363 return helpImage(metric(TitleHeight,wd))->width();
365 case MaximizeWidth: 364 case MaximizeWidth:
366 return maximizeImage(metric(TitleHeight,wd))->width(); 365 return maximizeImage(metric(TitleHeight,wd))->width();
367 case CornerGrabSize: 366 case CornerGrabSize:
368 return 16; 367 return 16;
369 } 368 }
370 369
371 return 0; 370 return 0;
372} 371}
373 372
374void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const 373void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const
375{ 374{
376 int th = metric( TitleHeight, wd ); 375 int th = metric( TitleHeight, wd );
377 QRect r = wd->rect; 376 QRect r = wd->rect;
378 377
379 switch ( a ) { 378 switch ( a ) {
380 case Border: 379 case Border:
381 { 380 {
382 const QColorGroup &cg = wd->palette.active(); 381 const QColorGroup &cg = wd->palette.active();
383 qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), 382 qDrawWinPanel(p, r.x()-metric(LeftBorder,wd),
384 r.y()-th-metric(TopBorder,wd), 383 r.y()-th-metric(TopBorder,wd),
385 r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), 384 r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd),
386 r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), 385 r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd),
387 cg, FALSE, &cg.brush(QColorGroup::Background)); 386 cg, FALSE, &cg.brush(QColorGroup::Background));
388 } 387 }
389 break; 388 break;
390 case Title: 389 case Title:
391 { 390 {
392 const QColorGroup &cg = wd->palette.active(); 391 const QColorGroup &cg = wd->palette.active();
393 QBrush titleBrush; 392 QBrush titleBrush;
394 QPen titleLines; 393 QPen titleLines;
395 394
396 if ( wd->flags & WindowData::Active ) { 395 if ( wd->flags & WindowData::Active ) {
397 titleBrush = cg.brush(QColorGroup::Highlight); 396 titleBrush = cg.brush(QColorGroup::Highlight);
398 titleLines = titleBrush.color().dark(); 397 titleLines = titleBrush.color().dark();
399 } else { 398 } else {
400 titleBrush = cg.brush(QColorGroup::Background); 399 titleBrush = cg.brush(QColorGroup::Background);
401 titleLines = titleBrush.color(); 400 titleLines = titleBrush.color();
402 } 401 }
403 402
404 p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); 403 p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush);
405 404
406 p->setPen( titleLines ); 405 p->setPen( titleLines );
407 for ( int i = r.y()-th; i < r.y(); i += 2 ) 406 for ( int i = r.y()-th; i < r.y(); i += 2 )
408 p->drawLine( r.left(), i, r.right(), i ); 407 p->drawLine( r.left(), i, r.right(), i );
409 } 408 }
410 break; 409 break;
411 case TitleText: 410 case TitleText:
412 p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th, 411 p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th,
413 r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), 412 r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd),
414 th, QPainter::AlignVCenter, wd->caption); 413 th, QPainter::AlignVCenter, wd->caption);
415 break; 414 break;
416 } 415 }
417} 416}
418 417
419void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const 418void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const
420{ 419{
421 QImage *img = 0; 420 QImage *img = 0;
422 switch ( b ) { 421 switch ( b ) {
423 case OK: 422 case OK:
424 img = okImage(metric(TitleHeight,wd)); 423 img = okImage(metric(TitleHeight,wd));
425 break; 424 break;
426 case Close: 425 case Close:
427 img = closeImage(metric(TitleHeight,wd)); 426 img = closeImage(metric(TitleHeight,wd));
428 break; 427 break;
429 case Help: 428 case Help:
430 img = helpImage(metric(TitleHeight,wd)); 429 img = helpImage(metric(TitleHeight,wd));
431 break; 430 break;
432 case Maximize: 431 case Maximize:
433 img = maximizeImage(metric(TitleHeight,wd)); 432 img = maximizeImage(metric(TitleHeight,wd));
434 break; 433 break;
435 } 434 }
436 435
437 if ( img ) { 436 if ( img ) {
438 if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) 437 if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked))
439 p->drawImage(x+2, y+2, *img); 438 p->drawImage(x+2, y+2, *img);
440 else 439 else
441 p->drawImage(x+1, y+1, *img); 440 p->drawImage(x+1, y+1, *img);
442 } 441 }
443} 442}
444 443
445QRegion WindowDecorationInterface::mask( const WindowData *wd ) const 444QRegion WindowDecorationInterface::mask( const WindowData *wd ) const
446{ 445{
447 int th = metric(TitleHeight,wd); 446 int th = metric(TitleHeight,wd);
448 QRect rect( wd->rect ); 447 QRect rect( wd->rect );
449 QRect r(rect.left() - metric(LeftBorder,wd), 448 QRect r(rect.left() - metric(LeftBorder,wd),
450 rect.top() - th - metric(TopBorder,wd), 449 rect.top() - th - metric(TopBorder,wd),
451 rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), 450 rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd),
452 rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); 451 rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd));
453 return QRegion(r) - rect; 452 return QRegion(r) - rect;
454} 453}
455 454
456class DefaultWindowDecoration : public WindowDecorationInterface 455class DefaultWindowDecoration : public WindowDecorationInterface
457{ 456{
458public: 457public:
459 DefaultWindowDecoration() : ref(0) {} 458 DefaultWindowDecoration() : ref(0) {}
460 QString name() const { 459 QString name() const {
461 return "Default"; 460 return "Default";
462 } 461 }
463 QPixmap icon() const { 462 QPixmap icon() const {
464 return QPixmap(); 463 return QPixmap();
465 } 464 }
466 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 465 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
467 *iface = 0; 466 *iface = 0;
468 if ( uuid == IID_QUnknown ) 467 if ( uuid == IID_QUnknown )
469 *iface = this; 468 *iface = this;
470 else if ( uuid == IID_WindowDecoration ) 469 else if ( uuid == IID_WindowDecoration )
471 *iface = this; 470 *iface = this;
472 471
473 if ( *iface ) 472 if ( *iface )
474 (*iface)->addRef(); 473 (*iface)->addRef();
475 return QS_OK; 474 return QS_OK;
476 } 475 }
477 Q_REFCOUNT 476 Q_REFCOUNT
478 477
479private: 478private:
480 ulong ref; 479 ulong ref;
481}; 480};
482 481
483static WindowDecorationInterface *wdiface = 0; 482static WindowDecorationInterface *wdiface = 0;
484static QLibrary *wdlib = 0; 483static QLibrary *wdlib = 0;
485 484
486//=========================================================================== 485//===========================================================================
487 486
488QPEDecoration::QPEDecoration() 487QPEDecoration::QPEDecoration()
489 : QWSDefaultDecoration() 488 : QWSDefaultDecoration()
490{ 489{
491 if ( wdlib ) { 490 if ( wdlib ) {
492 wdiface->release(); 491 wdiface->release();
493 wdlib->unload(); 492 wdlib->unload();
494 delete wdlib; 493 delete wdlib;
495 wdlib = 0; 494 wdlib = 0;
496 } else { 495 } else {
497 delete wdiface; 496 delete wdiface;
498 } 497 }
499 wdiface = new DefaultWindowDecoration; 498 wdiface = new DefaultWindowDecoration;
500 499
501 helpFile = QString(qApp->argv()[0]) + ".html"; 500 helpFile = QString(qApp->argv()[0]) + ".html";
502 QStringList helpPath = Global::helpPath(); 501 QStringList helpPath = Global::helpPath();
503 helpExists = FALSE; 502 helpExists = FALSE;
504 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) 503 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it)
505 helpExists = QFile::exists( *it + "/" + helpFile ); 504 helpExists = QFile::exists( *it + "/" + helpFile );
506 qpeManager = new QPEManager( this ); 505 qpeManager = new QPEManager( this );
507} 506}
508 507
509QPEDecoration::QPEDecoration( const QString &plugin ) 508QPEDecoration::QPEDecoration( const QString &plugin )
510 : QWSDefaultDecoration() 509 : QWSDefaultDecoration()
511{ 510{
512 if ( wdlib ) { 511 if ( wdlib ) {
513 wdiface->release(); 512 wdiface->release();
514 wdlib->unload(); 513 wdlib->unload();
515 delete wdlib; 514 delete wdlib;
516 wdlib = 0; 515 wdlib = 0;
517 } else { 516 } else {
518 delete wdiface; 517 delete wdiface;
519 } 518 }
520 WindowDecorationInterface *iface = 0; 519 WindowDecorationInterface *iface = 0;
521 QString path = QPEApplication::qpeDir() + "/plugins/decorations"; 520 QString path = QPEApplication::qpeDir() + "/plugins/decorations";
522 QLibrary *lib = new QLibrary( path + "/" + plugin ); 521 QLibrary *lib = new QLibrary( path + "/" + plugin );
523 if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 522 if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
524 wdiface = iface; 523 wdiface = iface;
525 wdlib = lib; 524 wdlib = lib;
526 } else { 525 } else {
527 delete lib; 526 delete lib;
528 wdiface = new DefaultWindowDecoration; 527 wdiface = new DefaultWindowDecoration;
529 } 528 }
530 529
531 helpFile = QString(qApp->argv()[0]) + ".html"; 530 helpFile = QString(qApp->argv()[0]) + ".html";
532 QStringList helpPath = Global::helpPath(); 531 QStringList helpPath = Global::helpPath();
533 helpExists = FALSE; 532 helpExists = FALSE;
534 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) 533 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it)
535 helpExists = QFile::exists( *it + "/" + helpFile ); 534 helpExists = QFile::exists( *it + "/" + helpFile );
536 qpeManager = new QPEManager( this ); 535 qpeManager = new QPEManager( this );
537} 536}
538 537
539QPEDecoration::~QPEDecoration() 538QPEDecoration::~QPEDecoration()
540{ 539{
541 delete qpeManager; 540 delete qpeManager;
542} 541}
543 542
544const char **QPEDecoration::menuPixmap() 543const char **QPEDecoration::menuPixmap()
545{ 544{
546 return (const char **)0; 545 return (const char **)0;
547} 546}
548 547
549const char **QPEDecoration::closePixmap() 548const char **QPEDecoration::closePixmap()
550{ 549{
551 return (const char **)qpe_close_xpm; 550 return (const char **)qpe_close_xpm;
552} 551}
553 552
554const char **QPEDecoration::minimizePixmap() 553const char **QPEDecoration::minimizePixmap()
555{ 554{
556 return (const char **)qpe_accept_xpm; 555 return (const char **)qpe_accept_xpm;
557} 556}
558 557
559const char **QPEDecoration::maximizePixmap() 558const char **QPEDecoration::maximizePixmap()
560{ 559{
561 return (const char **)0; 560 return (const char **)0;
562} 561}
563 562
564const char **QPEDecoration::normalizePixmap() 563const char **QPEDecoration::normalizePixmap()
565{ 564{
566 return (const char **)0; 565 return (const char **)0;
567} 566}
568 567
569int QPEDecoration::getTitleHeight( const QWidget *w ) 568int QPEDecoration::getTitleHeight( const QWidget *w )
570{ 569{
571 WindowDecorationInterface::WindowData wd; 570 WindowDecorationInterface::WindowData wd;
572 windowData( w, wd ); 571 windowData( w, wd );
573 return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 572 return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
574} 573}
575 574
576/* 575/*
577 If rect is empty, no frame is added. (a hack, really) 576 If rect is empty, no frame is added. (a hack, really)
578*/ 577*/
579QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) 578QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type)
580{ 579{
581 qpeManager->updateActive(); 580 qpeManager->updateActive();
582 581
583 WindowDecorationInterface::WindowData wd; 582 WindowDecorationInterface::WindowData wd;
584 windowData( widget, wd ); 583 windowData( widget, wd );
585 wd.rect = rect; 584 wd.rect = rect;
586 585
587 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 586 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
588 int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); 587 int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd);
589 int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); 588 int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd);
590 int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); 589 int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd);
591 int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); 590 int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd);
592 591
593 QRegion region; 592 QRegion region;
594 593
595 switch ((int)type) { 594 switch ((int)type) {
596 case Menu: 595 case Menu:
597 break; 596 break;
598 case Maximize: 597 case Maximize:
599 if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { 598 if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) {
600 int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); 599 int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd);
601 int left = rect.right() - maximizeWidth - closeWidth; 600 int left = rect.right() - maximizeWidth - closeWidth;
602 if ( ((HackWidget *)widget)->needsOk() ) 601 if ( ((HackWidget *)widget)->needsOk() )
603 left -= okWidth; 602 left -= okWidth;
604 QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); 603 QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight);
605 region = r; 604 region = r;
606 } 605 }
607 break; 606 break;
608 case Minimize: 607 case Minimize:
609 if ( ((HackWidget *)widget)->needsOk() ) { 608 if ( ((HackWidget *)widget)->needsOk() ) {
610 QRect r(rect.right() - okWidth, 609 QRect r(rect.right() - okWidth,
611 rect.top() - titleHeight, okWidth, titleHeight); 610 rect.top() - titleHeight, okWidth, titleHeight);
612 if (r.left() > rect.left() + titleHeight) 611 if (r.left() > rect.left() + titleHeight)
613 region = r; 612 region = r;
614 } 613 }
615 break; 614 break;
616 case Close: 615 case Close:
617 { 616 {
618 int left = rect.right() - closeWidth; 617 int left = rect.right() - closeWidth;
619 if ( ((HackWidget *)widget)->needsOk() ) 618 if ( ((HackWidget *)widget)->needsOk() )
620 left -= okWidth; 619 left -= okWidth;
621 QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); 620 QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight);
622 region = r; 621 region = r;
623 } 622 }
624 break; 623 break;
625 case Title: 624 case Title:
626 if ( !widget->isMaximized() ) { 625 if ( !widget->isMaximized() ) {
627 int width = rect.width() - helpWidth - closeWidth; 626 int width = rect.width() - helpWidth - closeWidth;
628 if ( ((HackWidget *)widget)->needsOk() ) 627 if ( ((HackWidget *)widget)->needsOk() )
629 width -= okWidth; 628 width -= okWidth;
630 QRect r(rect.left()+helpWidth, rect.top() - titleHeight, 629 QRect r(rect.left()+helpWidth, rect.top() - titleHeight,
631 width, titleHeight); 630 width, titleHeight);
632 if (r.width() > 0) 631 if (r.width() > 0)
633 region = r; 632 region = r;
634 } 633 }
635 break; 634 break;
636 case Help: 635 case Help:
637 if ( helpExists || widget->testWFlags(Qt::WStyle_ContextHelp) ) { 636 if ( helpExists || widget->testWFlags(Qt::WStyle_ContextHelp) ) {
638 QRect r(rect.left(), rect.top() - titleHeight, 637 QRect r(rect.left(), rect.top() - titleHeight,
639 helpWidth, titleHeight); 638 helpWidth, titleHeight);
640 region = r; 639 region = r;
641 } 640 }
642 break; 641 break;
643 case Top: 642 case Top:
644 if ( !widget->isMaximized() ) { 643 if ( !widget->isMaximized() ) {
645 QRegion m = wdiface->mask(&wd); 644 QRegion m = wdiface->mask(&wd);
646 QRect br = m.boundingRect(); 645 QRect br = m.boundingRect();
647 int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 646 int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
648 region = m & QRect( br.left()+grab, br.top(), 647 region = m & QRect( br.left()+grab, br.top(),
649 br.width()-2*grab, b ); 648 br.width()-2*grab, b );
650 } 649 }
651 break; 650 break;
652 case Left: 651 case Left:
653 if ( !widget->isMaximized() ) { 652 if ( !widget->isMaximized() ) {
654 QRegion m = wdiface->mask(&wd); 653 QRegion m = wdiface->mask(&wd);
655 QRect br = m.boundingRect(); 654 QRect br = m.boundingRect();
656 int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); 655 int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd);
657 region = m & QRect( br.left(), br.top()+grab, 656 region = m & QRect( br.left(), br.top()+grab,
658 b, br.height()-2*grab ); 657 b, br.height()-2*grab );
659 } 658 }
660 break; 659 break;
661 case Right: 660 case Right:
662 if ( !widget->isMaximized() ) { 661 if ( !widget->isMaximized() ) {
663 QRegion m = wdiface->mask(&wd); 662 QRegion m = wdiface->mask(&wd);
664 QRect br = m.boundingRect(); 663 QRect br = m.boundingRect();
665 int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); 664 int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd);
666 region = m & QRect( rect.right(), br.top()+grab, 665 region = m & QRect( rect.right(), br.top()+grab,
667 b, br.height()-2*grab ); 666 b, br.height()-2*grab );
668 } 667 }
669 break; 668 break;
670 case Bottom: 669 case Bottom:
671 if ( !widget->isMaximized() ) { 670 if ( !widget->isMaximized() ) {
672 QRegion m = wdiface->mask(&wd); 671 QRegion m = wdiface->mask(&wd);
673 QRect br = m.boundingRect(); 672 QRect br = m.boundingRect();
674 int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd); 673 int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd);
675 region = m & QRect( br.left()+grab, rect.bottom(), 674 region = m & QRect( br.left()+grab, rect.bottom(),
676 br.width()-2*grab, b ); 675 br.width()-2*grab, b );
677 } 676 }
678 break; 677 break;
679 case TopLeft: 678 case TopLeft:
680 if ( !widget->isMaximized() ) { 679 if ( !widget->isMaximized() ) {
681 QRegion m = wdiface->mask(&wd); 680 QRegion m = wdiface->mask(&wd);
682 QRect br = m.boundingRect(); 681 QRect br = m.boundingRect();
683 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 682 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
684 int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); 683 int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd);
685 QRegion crgn( br.left(), br.top(), grab, tb ); 684 QRegion crgn( br.left(), br.top(), grab, tb );
686 crgn |= QRect( br.left(), br.top(), lb, grab ); 685 crgn |= QRect( br.left(), br.top(), lb, grab );
687 region = m & crgn; 686 region = m & crgn;
688 } 687 }
689 break; 688 break;
690 case TopRight: 689 case TopRight:
691 if ( !widget->isMaximized() ) { 690 if ( !widget->isMaximized() ) {
692 QRegion m = wdiface->mask(&wd); 691 QRegion m = wdiface->mask(&wd);
693 QRect br = m.boundingRect(); 692 QRect br = m.boundingRect();
694 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 693 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
695 int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); 694 int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd);
696 QRegion crgn( br.right()-grab, br.top(), grab, tb ); 695 QRegion crgn( br.right()-grab, br.top(), grab, tb );
697 crgn |= QRect( br.right()-rb, br.top(), rb, grab ); 696 crgn |= QRect( br.right()-rb, br.top(), rb, grab );
698 region = m & crgn; 697 region = m & crgn;
699 } 698 }
700 break; 699 break;
701 case BottomLeft: 700 case BottomLeft:
702 if ( !widget->isMaximized() ) { 701 if ( !widget->isMaximized() ) {
703 QRegion m = wdiface->mask(&wd); 702 QRegion m = wdiface->mask(&wd);
704 QRect br = m.boundingRect(); 703 QRect br = m.boundingRect();
705 region = m & QRect( br.left(), br.bottom()-grab, grab, grab ); 704 region = m & QRect( br.left(), br.bottom()-grab, grab, grab );
706 } 705 }
707 break; 706 break;
708 case BottomRight: 707 case BottomRight:
709 if ( !widget->isMaximized() ) { 708 if ( !widget->isMaximized() ) {
710 QRegion m = wdiface->mask(&wd); 709 QRegion m = wdiface->mask(&wd);
711 QRect br = m.boundingRect(); 710 QRect br = m.boundingRect();
712 region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab ); 711 region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab );
713 } 712 }
714 break; 713 break;
715 case All: 714 case All:
716 if ( widget->isMaximized() ) 715 if ( widget->isMaximized() )
717 region = QWSDefaultDecoration::region(widget, rect, type); 716 region = QWSDefaultDecoration::region(widget, rect, type);
718 else 717 else
719 region = wdiface->mask(&wd) - rect; 718 region = wdiface->mask(&wd) - rect;
720 break; 719 break;
721 default: 720 default:
722 region = QWSDefaultDecoration::region(widget, rect, type); 721 region = QWSDefaultDecoration::region(widget, rect, type);
723 break; 722 break;
724 } 723 }
725 724
726 return region; 725 return region;
727} 726}
728 727
729void QPEDecoration::paint(QPainter *painter, const QWidget *widget) 728void QPEDecoration::paint(QPainter *painter, const QWidget *widget)
730{ 729{
731 WindowDecorationInterface::WindowData wd; 730 WindowDecorationInterface::WindowData wd;
732 windowData( widget, wd ); 731 windowData( widget, wd );
733 732
734 int titleWidth = getTitleWidth(widget); 733 int titleWidth = getTitleWidth(widget);
735 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 734 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
736 735
737 QRect rect(widget->rect()); 736 QRect rect(widget->rect());
738 737
739 // title bar rect 738 // title bar rect
740 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); 739 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
741 740
742#ifndef QT_NO_PALETTE 741#ifndef QT_NO_PALETTE
743 QRegion oldClip = painter->clipRegion(); 742 QRegion oldClip = painter->clipRegion();
744 painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker 743 painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker
745 wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd ); 744 wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd );
746 painter->setClipRegion( oldClip ); 745 painter->setClipRegion( oldClip );
747 746
748 if (titleWidth > 0) { 747 if (titleWidth > 0) {
749 const QColorGroup &cg = widget->palette().active(); 748 const QColorGroup &cg = widget->palette().active();
750 QBrush titleBrush; 749 QBrush titleBrush;
751 QPen titlePen; 750 QPen titlePen;
752 751
753 if ( wd.flags & WindowDecorationInterface::WindowData::Active ) { 752 if ( wd.flags & WindowDecorationInterface::WindowData::Active ) {
754 titleBrush = cg.brush(QColorGroup::Highlight); 753 titleBrush = cg.brush(QColorGroup::Highlight);
755 titlePen = cg.color(QColorGroup::HighlightedText); 754 titlePen = cg.color(QColorGroup::HighlightedText);
756 } else { 755 } else {
757 titleBrush = cg.brush(QColorGroup::Background); 756 titleBrush = cg.brush(QColorGroup::Background);
758 titlePen = cg.color(QColorGroup::Text); 757 titlePen = cg.color(QColorGroup::Text);
759 } 758 }
760 759
761 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); 760 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd );
762 761
763 // Draw caption 762 // Draw caption
764 painter->setPen(titlePen); 763 painter->setPen(titlePen);
765 QFont f( QApplication::font() ); 764 QFont f( QApplication::font() );
766 f.setWeight( QFont::Bold ); 765 f.setWeight( QFont::Bold );
767 painter->setFont(f); 766 painter->setFont(f);
768 wdiface->drawArea( WindowDecorationInterface::TitleText, painter, &wd ); 767 wdiface->drawArea( WindowDecorationInterface::TitleText, painter, &wd );
769 } 768 }
770#endif //QT_NO_PALETTE 769#endif //QT_NO_PALETTE
771 770
772 paintButton( painter, widget, (QWSDecoration::Region)Help, 0 ); 771 paintButton( painter, widget, (QWSDecoration::Region)Help, 0 );
773} 772}
774 773
775void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, 774void QPEDecoration::paintButton(QPainter *painter, const QWidget *w,
776 QWSDecoration::Region type, int state) 775 QWSDecoration::Region type, int state)
777{ 776{
778 WindowDecorationInterface::Button b; 777 WindowDecorationInterface::Button b;
779 switch ((int)type) { 778 switch ((int)type) {
780 case Close: 779 case Close:
781 b = WindowDecorationInterface::Close; 780 b = WindowDecorationInterface::Close;
782 break; 781 break;
783 case Minimize: 782 case Minimize:
784 if ( ((HackWidget *)w)->needsOk() ) 783 if ( ((HackWidget *)w)->needsOk() )
785 b = WindowDecorationInterface::OK; 784 b = WindowDecorationInterface::OK;
786 else if ( helpExists ) 785 else if ( helpExists )
787 b = WindowDecorationInterface::Help; 786 b = WindowDecorationInterface::Help;
788 else 787 else
789 return; 788 return;
790 break; 789 break;
791 case Help: 790 case Help:
792 b = WindowDecorationInterface::Help; 791 b = WindowDecorationInterface::Help;
793 break; 792 break;
794 case Maximize: 793 case Maximize:
795 b = WindowDecorationInterface::Maximize; 794 b = WindowDecorationInterface::Maximize;
796 break; 795 break;
797 default: 796 default:
798 return; 797 return;
799 } 798 }
800 799
801 WindowDecorationInterface::WindowData wd; 800 WindowDecorationInterface::WindowData wd;
802 windowData( w, wd ); 801 windowData( w, wd );
803 802
804 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 803 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
805 QRect rect(w->rect()); 804 QRect rect(w->rect());
806 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); 805 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
807 QRect brect(region(w, w->rect(), type).boundingRect()); 806 QRect brect(region(w, w->rect(), type).boundingRect());
808 807
809 const QColorGroup &cg = w->palette().active(); 808 const QColorGroup &cg = w->palette().active();
810 if ( wd.flags & WindowDecorationInterface::WindowData::Active ) 809 if ( wd.flags & WindowDecorationInterface::WindowData::Active )
811 painter->setPen( cg.color(QColorGroup::HighlightedText) ); 810 painter->setPen( cg.color(QColorGroup::HighlightedText) );
812 else 811 else
813 painter->setPen( cg.color(QColorGroup::Text) ); 812 painter->setPen( cg.color(QColorGroup::Text) );
814 813
815 QRegion oldClip = painter->clipRegion(); 814 QRegion oldClip = painter->clipRegion();
816 painter->setClipRegion( QRect(brect.x(), tr.y(), brect.width(), tr.height()) ); // reduce flicker 815 painter->setClipRegion( QRect(brect.x(), tr.y(), brect.width(), tr.height()) ); // reduce flicker
817 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); 816 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd );
818 wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state ); 817 wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state );
819 painter->setClipRegion( oldClip ); 818 painter->setClipRegion( oldClip );
820} 819}
821 820
822//#define QPE_DONT_SHOW_TITLEBAR 821//#define QPE_DONT_SHOW_TITLEBAR
823 822
824void QPEDecoration::maximize( QWidget *widget ) 823void QPEDecoration::maximize( QWidget *widget )
825{ 824{
826#ifdef QPE_DONT_SHOW_TITLEBAR 825#ifdef QPE_DONT_SHOW_TITLEBAR
827 if ( !widget->inherits( "QDialog" ) ) { 826 if ( !widget->inherits( "QDialog" ) ) {
828 widget->setGeometry( qt_maxWindowRect ); 827 widget->setGeometry( qt_maxWindowRect );
829 } else 828 } else
830#endif 829#endif
831 { 830 {
832 QWSDecoration::maximize( widget ); 831 QWSDecoration::maximize( widget );
833 } 832 }
834} 833}
835 834
836#ifndef QT_NO_DIALOG 835#ifndef QT_NO_DIALOG
837class HackDialog : public QDialog 836class HackDialog : public QDialog
838{ 837{
839public: 838public:
840 void acceptIt() { 839 void acceptIt() {
841 if ( isA( "QMessageBox" ) ) 840 if ( isA( "QMessageBox" ) )
842 qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); 841 qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) );
843 else 842 else
844 accept(); 843 accept();
845 } 844 }
846}; 845};
847#endif 846#endif
848 847
849 848
850void QPEDecoration::minimize( QWidget *widget ) 849void QPEDecoration::minimize( QWidget *widget )
851{ 850{
852#ifndef QT_NO_DIALOG 851#ifndef QT_NO_DIALOG
853 // We use the minimize button as an "accept" button. 852 // We use the minimize button as an "accept" button.
854 if ( widget->inherits( "QDialog" ) ) { 853 if ( widget->inherits( "QDialog" ) ) {
855 HackDialog *d = (HackDialog *)widget; 854 HackDialog *d = (HackDialog *)widget;
856 d->acceptIt(); 855 d->acceptIt();
857 } 856 }
858#endif 857#endif
859 else if ( ((HackWidget *)widget)->needsOk() ) { 858 else if ( ((HackWidget *)widget)->needsOk() ) {
860 QSignal s; 859 QSignal s;
861 s.connect( widget, SLOT( accept() ) ); 860 s.connect( widget, SLOT( accept() ) );
862 s.activate(); 861 s.activate();
863 } else { 862 } else {
864 help( widget ); 863 help( widget );
865 } 864 }
866} 865}
867 866
868void QPEDecoration::help( QWidget *w ) 867void QPEDecoration::help( QWidget *w )
869{ 868{
870 if ( helpExists ) { 869 if ( helpExists ) {
871 Global::execute( "helpbrowser", helpFile ); 870 Global::execute( "helpbrowser", helpFile );
872 } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { 871 } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) {
873 QWhatsThis::enterWhatsThisMode(); 872 QWhatsThis::enterWhatsThisMode();
874 QWhatsThis::leaveWhatsThisMode( qApp->tr( 873 QWhatsThis::leaveWhatsThisMode( qApp->tr(
875 "<Qt>Comprehensive help is not available for this application, " 874 "<Qt>Comprehensive help is not available for this application, "
876 "however there is context-sensitive help.<p>To use context-sensitive help:<p>" 875 "however there is context-sensitive help.<p>To use context-sensitive help:<p>"
877 "<ol><li>click and hold the help button." 876 "<ol><li>click and hold the help button."
878 "<li>when the title bar shows <b>What's this...</b>, " 877 "<li>when the title bar shows <b>What's this...</b>, "
879 "click on any control.</ol></Qt>" ) ); 878 "click on any control.</ol></Qt>" ) );