summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpedecoration_qws.cpp7
-rw-r--r--library/task-opie-applets.control2
-rw-r--r--library/task-opie-complete.control2
-rw-r--r--library/task-opie-games.control2
-rw-r--r--library/task-opie-pim.control2
-rw-r--r--library/task-opie-settings.control2
6 files changed, 10 insertions, 7 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp
index 708dd23..214c721 100644
--- a/library/qpedecoration_qws.cpp
+++ b/library/qpedecoration_qws.cpp
@@ -1,911 +1,914 @@
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 if ( img.height() != 0 && img.height() != height ) { 110 if ( img.height() != 0 && img.height() != height ) {
111 return img.smoothScale( img.width()*height/img.height(), height ); 111 return img.smoothScale( img.width()*height/img.height(), height );
112 } else { 112 } else {
113 return img; 113 return img;
114 } 114 }
115} 115}
116 116
117class TLWidget : public QWidget 117class TLWidget : public QWidget
118{ 118{
119public: 119public:
120 QWSManager *manager() 120 QWSManager *manager()
121 { 121 {
122 return topData()->qwsManager; 122 return topData()->qwsManager;
123 } 123 }
124 124
125 QTLWExtra *topExtra() 125 QTLWExtra *topExtra()
126 { 126 {
127 return topData(); 127 return topData();
128 } 128 }
129 129
130 void setWState( uint s ) { QWidget::setWState( s ); } 130 void setWState( uint s ) { QWidget::setWState( s ); }
131 void clearWState( uint s ) { QWidget::clearWState( s ); } 131 void clearWState( uint s ) { QWidget::clearWState( s ); }
132}; 132};
133 133
134 134
135QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) 135QPEManager::QPEManager( QPEDecoration *d, QObject *parent )
136 : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) 136 : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE)
137{ 137{
138 wtTimer = new QTimer( this ); 138 wtTimer = new QTimer( this );
139 connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); 139 connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) );
140} 140}
141 141
142 142
143void QPEManager::updateActive() 143void QPEManager::updateActive()
144{ 144{
145 QWidget *newActive = qApp->activeWindow(); 145 QWidget *newActive = qApp->activeWindow();
146 if ( newActive && (QWidget*)active == newActive ) 146 if ( newActive && (QWidget*)active == newActive )
147 return; 147 return;
148 148
149 if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { 149 if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) {
150 ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); 150 ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this );
151 } 151 }
152 152
153 if ( newActive && ((TLWidget *)newActive)->manager() ) { 153 if ( newActive && ((TLWidget *)newActive)->manager() ) {
154 active = newActive; 154 active = newActive;
155 ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); 155 ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this );
156 } else if ( !newActive ) { 156 } else if ( !newActive ) {
157 active = 0; 157 active = 0;
158 } 158 }
159} 159}
160 160
161int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) 161int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p )
162{ 162{
163 QRect rect(w->geometry()); 163 QRect rect(w->geometry());
164 164
165 if ( decoration->region( w, rect, 165 if ( decoration->region( w, rect,
166 (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) 166 (QWSDecoration::Region)QPEDecoration::Help ).contains(p) )
167 return QPEDecoration::Help; 167 return QPEDecoration::Help;
168 168
169 for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { 169 for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) {
170 if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) 170 if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p))
171 return (QWSDecoration::Region)i; 171 return (QWSDecoration::Region)i;
172 } 172 }
173 173
174 return QWSDecoration::None; 174 return QWSDecoration::None;
175} 175}
176 176
177bool QPEManager::eventFilter( QObject *o, QEvent *e ) 177bool QPEManager::eventFilter( QObject *o, QEvent *e )
178{ 178{
179 QWSManager *mgr = (QWSManager *)o; 179 QWSManager *mgr = (QWSManager *)o;
180 QWidget *w = mgr->widget(); 180 QWidget *w = mgr->widget();
181 switch ( e->type() ) { 181 switch ( e->type() ) {
182 case QEvent::MouseButtonPress: 182 case QEvent::MouseButtonPress:
183 { 183 {
184 pressTime = QTime::currentTime(); 184 pressTime = QTime::currentTime();
185 QPoint p = ((QMouseEvent*)e)->globalPos(); 185 QPoint p = ((QMouseEvent*)e)->globalPos();
186 int inRegion = pointInQpeRegion( w, p ); 186 int inRegion = pointInQpeRegion( w, p );
187#ifdef WHATSTHIS_MODE 187#ifdef WHATSTHIS_MODE
188 if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { 188 if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) {
189 QString text; 189 QString text;
190 switch ( inRegion ) { 190 switch ( inRegion ) {
191 case QWSDecoration::Close: 191 case QWSDecoration::Close:
192 if ( ((HackWidget*)w)->needsOk() ) 192 if ( ((HackWidget*)w)->needsOk() )
193 text = tr("Click to close this window, discarding changes."); 193 text = tr("Click to close this window, discarding changes.");
194 else 194 else
195 text = tr("Click to close this window."); 195 text = tr("Click to close this window.");
196 break; 196 break;
197 case QWSDecoration::Minimize: 197 case QWSDecoration::Minimize:
198 text = tr("Click to close this window and apply changes."); 198 text = tr("Click to close this window and apply changes.");
199 break; 199 break;
200 case QWSDecoration::Maximize: 200 case QWSDecoration::Maximize:
201 if ( w->isMaximized() ) 201 if ( w->isMaximized() )
202 text = tr("Click to make this window moveable."); 202 text = tr("Click to make this window moveable.");
203 else 203 else
204 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.");
205 break; 205 break;
206 default: 206 default:
207 break; 207 break;
208 } 208 }
209 QWhatsThis::leaveWhatsThisMode( text ); 209 QWhatsThis::leaveWhatsThisMode( text );
210 whatsThisTimeout(); 210 whatsThisTimeout();
211 helpState = 0; 211 helpState = 0;
212 return true; 212 return true;
213 } 213 }
214#endif 214#endif
215 if ( inRegion == QPEDecoration::Help ) { 215 if ( inRegion == QPEDecoration::Help ) {
216#ifdef WHATSTHIS_MODE 216#ifdef WHATSTHIS_MODE
217 wtTimer->start( 400, TRUE ); 217 wtTimer->start( 400, TRUE );
218#endif 218#endif
219 helpState = QWSButton::Clicked|QWSButton::MouseOver; 219 helpState = QWSButton::Clicked|QWSButton::MouseOver;
220 drawButton( w, QPEDecoration::Help, helpState ); 220 drawButton( w, QPEDecoration::Help, helpState );
221 return true; 221 return true;
222 } 222 }
223 } 223 }
224 break; 224 break;
225 case QEvent::MouseButtonRelease: 225 case QEvent::MouseButtonRelease:
226 if ( helpState & QWSButton::Clicked ) { 226 if ( helpState & QWSButton::Clicked ) {
227 wtTimer->stop(); 227 wtTimer->stop();
228 helpState = 0; 228 helpState = 0;
229 drawButton( w, QPEDecoration::Help, helpState ); 229 drawButton( w, QPEDecoration::Help, helpState );
230 QPoint p = ((QMouseEvent*)e)->globalPos(); 230 QPoint p = ((QMouseEvent*)e)->globalPos();
231 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { 231 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) {
232 decoration->help( w ); 232 decoration->help( w );
233 } 233 }
234 return true; 234 return true;
235 } 235 }
236 break; 236 break;
237 case QEvent::MouseMove: 237 case QEvent::MouseMove:
238 if ( helpState & QWSButton::Clicked ) { 238 if ( helpState & QWSButton::Clicked ) {
239 int oldState = helpState; 239 int oldState = helpState;
240 QPoint p = ((QMouseEvent*)e)->globalPos(); 240 QPoint p = ((QMouseEvent*)e)->globalPos();
241 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { 241 if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) {
242 helpState = QWSButton::Clicked|QWSButton::MouseOver; 242 helpState = QWSButton::Clicked|QWSButton::MouseOver;
243 } else { 243 } else {
244 helpState = 0; 244 helpState = 0;
245 } 245 }
246 if ( helpState != oldState ) 246 if ( helpState != oldState )
247 drawButton( w, QPEDecoration::Help, helpState ); 247 drawButton( w, QPEDecoration::Help, helpState );
248 } 248 }
249 break; 249 break;
250 default: 250 default:
251 break; 251 break;
252 } 252 }
253 return QObject::eventFilter( o, e ); 253 return QObject::eventFilter( o, e );
254} 254}
255 255
256void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) 256void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state )
257{ 257{
258 QPainter painter(w); 258 QPainter painter(w);
259 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; 259 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region;
260 painter.internalGfx()->setWidgetDeviceRegion( rgn ); 260 painter.internalGfx()->setWidgetDeviceRegion( rgn );
261 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); 261 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All));
262 decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); 262 decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state );
263} 263}
264 264
265void QPEManager::drawTitle( QWidget *w ) 265void QPEManager::drawTitle( QWidget *w )
266{ 266{
267 QPainter painter(w); 267 QPainter painter(w);
268 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; 268 QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region;
269 painter.internalGfx()->setWidgetDeviceRegion( rgn ); 269 painter.internalGfx()->setWidgetDeviceRegion( rgn );
270 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); 270 painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All));
271 decoration->paint( &painter, w ); 271 decoration->paint( &painter, w );
272 decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); 272 decoration->paintButton(&painter, w, QWSDecoration::Menu, 0);
273 decoration->paintButton(&painter, w, QWSDecoration::Close, 0); 273 decoration->paintButton(&painter, w, QWSDecoration::Close, 0);
274 decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); 274 decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0);
275 decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); 275 decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0);
276} 276}
277 277
278void QPEManager::whatsThisTimeout() 278void QPEManager::whatsThisTimeout()
279{ 279{
280 if ( !QWhatsThis::inWhatsThisMode() ) { 280 if ( !QWhatsThis::inWhatsThisMode() ) {
281 if ( inWhatsThis ) { 281 if ( inWhatsThis ) {
282 if ( whatsThis ) { 282 if ( whatsThis ) {
283 QWidget *w = whatsThis; 283 QWidget *w = whatsThis;
284 whatsThis = 0; 284 whatsThis = 0;
285 drawTitle( w ); 285 drawTitle( w );
286 } 286 }
287 wtTimer->stop(); 287 wtTimer->stop();
288 } else { 288 } else {
289 QWhatsThis::enterWhatsThisMode(); 289 QWhatsThis::enterWhatsThisMode();
290 helpState = 0; 290 helpState = 0;
291 updateActive(); 291 updateActive();
292 if ( active ) { 292 if ( active ) {
293 whatsThis = active; 293 whatsThis = active;
294 drawTitle( active ); 294 drawTitle( active );
295 // check periodically to see if we've left whats this mode 295 // check periodically to see if we've left whats this mode
296 wtTimer->start( 250 ); 296 wtTimer->start( 250 );
297 } 297 }
298 } 298 }
299 inWhatsThis = !inWhatsThis; 299 inWhatsThis = !inWhatsThis;
300 } 300 }
301} 301}
302 302
303//=========================================================================== 303//===========================================================================
304 304
305static QImage *okImage( int th ) 305static QImage *okImage( int th )
306{ 306{
307 static QImage *i = 0; 307 static QImage *i = 0;
308 if ( !i || i->height() != th ) { 308 if ( !i || i->height() != th ) {
309 delete i; 309 delete i;
310 i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); 310 i = new QImage(scaleButton(Resource::loadImage("OKButton"),th));
311 } 311 }
312 return i; 312 return i;
313} 313}
314 314
315static QImage *closeImage( int th ) 315static QImage *closeImage( int th )
316{ 316{
317 static QImage *i = 0; 317 static QImage *i = 0;
318 if ( !i || i->height() != th ) { 318 if ( !i || i->height() != th ) {
319 delete i; 319 delete i;
320 i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); 320 i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th));
321 } 321 }
322 return i; 322 return i;
323} 323}
324 324
325static QImage *helpImage( int th ) 325static QImage *helpImage( int th )
326{ 326{
327 static QImage *i = 0; 327 static QImage *i = 0;
328 if ( !i || i->height() != th ) { 328 if ( !i || i->height() != th ) {
329 delete i; 329 delete i;
330 i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); 330 i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th));
331 } 331 }
332 return i; 332 return i;
333} 333}
334 334
335static QImage *maximizeImage( int th ) 335static QImage *maximizeImage( int th )
336{ 336{
337 static QImage *i = 0; 337 static QImage *i = 0;
338 if ( !i || i->height() != th ) { 338 if ( !i || i->height() != th ) {
339 delete i; 339 delete i;
340 i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); 340 i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th));
341 } 341 }
342 return i; 342 return i;
343} 343}
344 344
345int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const 345int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const
346{ 346{
347 switch ( m ) { 347 switch ( m ) {
348 case TitleHeight: 348 case TitleHeight:
349 if ( QApplication::desktop()->height() > 320 ) 349 if ( QApplication::desktop()->height() > 320 )
350 return 19; 350 return 19;
351 else 351 else
352 return 15; 352 return 15;
353 case LeftBorder: 353 case LeftBorder:
354 case RightBorder: 354 case RightBorder:
355 case TopBorder: 355 case TopBorder:
356 case BottomBorder: 356 case BottomBorder:
357 return 4; 357 return 4;
358 case OKWidth: 358 case OKWidth:
359 return okImage(metric(TitleHeight,wd))->width(); 359 return okImage(metric(TitleHeight,wd))->width();
360 case CloseWidth: 360 case CloseWidth:
361 return closeImage(metric(TitleHeight,wd))->width(); 361 return closeImage(metric(TitleHeight,wd))->width();
362 case HelpWidth: 362 case HelpWidth:
363 return helpImage(metric(TitleHeight,wd))->width(); 363 return helpImage(metric(TitleHeight,wd))->width();
364 case MaximizeWidth: 364 case MaximizeWidth:
365 return maximizeImage(metric(TitleHeight,wd))->width(); 365 return maximizeImage(metric(TitleHeight,wd))->width();
366 case CornerGrabSize: 366 case CornerGrabSize:
367 return 16; 367 return 16;
368 } 368 }
369 369
370 return 0; 370 return 0;
371} 371}
372 372
373void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const 373void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const
374{ 374{
375 int th = metric( TitleHeight, wd ); 375 int th = metric( TitleHeight, wd );
376 QRect r = wd->rect; 376 QRect r = wd->rect;
377 377
378 switch ( a ) { 378 switch ( a ) {
379 case Border: 379 case Border:
380 { 380 {
381 const QColorGroup &cg = wd->palette.active(); 381 const QColorGroup &cg = wd->palette.active();
382 qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), 382 qDrawWinPanel(p, r.x()-metric(LeftBorder,wd),
383 r.y()-th-metric(TopBorder,wd), 383 r.y()-th-metric(TopBorder,wd),
384 r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), 384 r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd),
385 r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), 385 r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd),
386 cg, FALSE, &cg.brush(QColorGroup::Background)); 386 cg, FALSE, &cg.brush(QColorGroup::Background));
387 } 387 }
388 break; 388 break;
389 case Title: 389 case Title:
390 { 390 {
391 const QColorGroup &cg = wd->palette.active(); 391 const QColorGroup &cg = wd->palette.active();
392 QBrush titleBrush; 392 QBrush titleBrush;
393 QPen titleLines; 393 QPen titleLines;
394 394
395 if ( wd->flags & WindowData::Active ) { 395 if ( wd->flags & WindowData::Active ) {
396 titleBrush = cg.brush(QColorGroup::Highlight); 396 titleBrush = cg.brush(QColorGroup::Highlight);
397 titleLines = titleBrush.color().dark(); 397 titleLines = titleBrush.color().dark();
398 } else { 398 } else {
399 titleBrush = cg.brush(QColorGroup::Background); 399 titleBrush = cg.brush(QColorGroup::Background);
400 titleLines = titleBrush.color(); 400 titleLines = titleBrush.color();
401 } 401 }
402 402
403 p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); 403 p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush);
404 404
405 p->setPen( titleLines ); 405 p->setPen( titleLines );
406 for ( int i = r.y()-th; i < r.y(); i += 2 ) 406 for ( int i = r.y()-th; i < r.y(); i += 2 )
407 p->drawLine( r.left(), i, r.right(), i ); 407 p->drawLine( r.left(), i, r.right(), i );
408 } 408 }
409 break; 409 break;
410 case TitleText: 410 case TitleText:
411 p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th, 411 p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th,
412 r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), 412 r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd),
413 th, QPainter::AlignVCenter, wd->caption); 413 th, QPainter::AlignVCenter, wd->caption);
414 break; 414 break;
415 } 415 }
416} 416}
417 417
418void 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
419{ 419{
420 QImage *img = 0; 420 QImage *img = 0;
421 switch ( b ) { 421 switch ( b ) {
422 case OK: 422 case OK:
423 img = okImage(metric(TitleHeight,wd)); 423 img = okImage(metric(TitleHeight,wd));
424 break; 424 break;
425 case Close: 425 case Close:
426 img = closeImage(metric(TitleHeight,wd)); 426 img = closeImage(metric(TitleHeight,wd));
427 break; 427 break;
428 case Help: 428 case Help:
429 img = helpImage(metric(TitleHeight,wd)); 429 img = helpImage(metric(TitleHeight,wd));
430 break; 430 break;
431 case Maximize: 431 case Maximize:
432 img = maximizeImage(metric(TitleHeight,wd)); 432 img = maximizeImage(metric(TitleHeight,wd));
433 break; 433 break;
434 } 434 }
435 435
436 if ( img ) { 436 if ( img ) {
437 if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) 437 if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked))
438 p->drawImage(x+2, y+2, *img); 438 p->drawImage(x+2, y+2, *img);
439 else 439 else
440 p->drawImage(x+1, y+1, *img); 440 p->drawImage(x+1, y+1, *img);
441 } 441 }
442} 442}
443 443
444QRegion WindowDecorationInterface::mask( const WindowData *wd ) const 444QRegion WindowDecorationInterface::mask( const WindowData *wd ) const
445{ 445{
446 int th = metric(TitleHeight,wd); 446 int th = metric(TitleHeight,wd);
447 QRect rect( wd->rect ); 447 QRect rect( wd->rect );
448 QRect r(rect.left() - metric(LeftBorder,wd), 448 QRect r(rect.left() - metric(LeftBorder,wd),
449 rect.top() - th - metric(TopBorder,wd), 449 rect.top() - th - metric(TopBorder,wd),
450 rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), 450 rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd),
451 rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); 451 rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd));
452 return QRegion(r) - rect; 452 return QRegion(r) - rect;
453} 453}
454 454
455class DefaultWindowDecoration : public WindowDecorationInterface 455class DefaultWindowDecoration : public WindowDecorationInterface
456{ 456{
457public: 457public:
458 DefaultWindowDecoration() : ref(0) {} 458 DefaultWindowDecoration() : ref(0) {}
459 QString name() const { 459 QString name() const {
460 return "Default"; 460 return "Default";
461 } 461 }
462 QPixmap icon() const { 462 QPixmap icon() const {
463 return QPixmap(); 463 return QPixmap();
464 } 464 }
465 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { 465 QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) {
466 *iface = 0; 466 *iface = 0;
467 if ( uuid == IID_QUnknown ) 467 if ( uuid == IID_QUnknown )
468 *iface = this; 468 *iface = this;
469 else if ( uuid == IID_WindowDecoration ) 469 else if ( uuid == IID_WindowDecoration )
470 *iface = this; 470 *iface = this;
471 471
472 if ( *iface ) 472 if ( *iface )
473 (*iface)->addRef(); 473 (*iface)->addRef();
474 return QS_OK; 474 return QS_OK;
475 } 475 }
476 Q_REFCOUNT 476 Q_REFCOUNT
477 477
478private: 478private:
479 ulong ref; 479 ulong ref;
480}; 480};
481 481
482static WindowDecorationInterface *wdiface = 0; 482static WindowDecorationInterface *wdiface = 0;
483static QLibrary *wdlib = 0; 483static QLibrary *wdlib = 0;
484 484
485//=========================================================================== 485//===========================================================================
486 486
487QPEDecoration::QPEDecoration() 487QPEDecoration::QPEDecoration()
488 : QWSDefaultDecoration() 488 : QWSDefaultDecoration()
489{ 489{
490 if ( wdlib ) { 490 if ( wdlib ) {
491 wdiface->release(); 491 wdiface->release();
492 wdlib->unload(); 492 wdlib->unload();
493 delete wdlib; 493 delete wdlib;
494 wdlib = 0; 494 wdlib = 0;
495 } else { 495 } else {
496 delete wdiface; 496 delete wdiface;
497 } 497 }
498 wdiface = new DefaultWindowDecoration; 498 wdiface = new DefaultWindowDecoration;
499 499
500 helpFile = QString(qApp->argv()[0]) + ".html"; 500 helpFile = QString(qApp->argv()[0]) + ".html";
501 QStringList helpPath = Global::helpPath(); 501 QStringList helpPath = Global::helpPath();
502 helpExists = FALSE; 502 helpExists = FALSE;
503 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) 503 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) {
504 helpExists = QFile::exists( *it + "/" + helpFile ); 504 helpExists = QFile::exists( *it + "/" + helpFile );
505 qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists);
506 }
505 qpeManager = new QPEManager( this ); 507 qpeManager = new QPEManager( this );
506} 508}
507 509
508QPEDecoration::QPEDecoration( const QString &plugin ) 510QPEDecoration::QPEDecoration( const QString &plugin )
509 : QWSDefaultDecoration() 511 : QWSDefaultDecoration()
510{ 512{
511 if ( wdlib ) { 513 if ( wdlib ) {
512 wdiface->release(); 514 wdiface->release();
513 wdlib->unload(); 515 wdlib->unload();
514 delete wdlib; 516 delete wdlib;
515 wdlib = 0; 517 wdlib = 0;
516 } else { 518 } else {
517 delete wdiface; 519 delete wdiface;
518 } 520 }
519 WindowDecorationInterface *iface = 0; 521 WindowDecorationInterface *iface = 0;
520 QString path = QPEApplication::qpeDir() + "/plugins/decorations"; 522 QString path = QPEApplication::qpeDir() + "/plugins/decorations";
521 QLibrary *lib = new QLibrary( path + "/" + plugin ); 523 QLibrary *lib = new QLibrary( path + "/" + plugin );
522 if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { 524 if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) {
523 wdiface = iface; 525 wdiface = iface;
524 wdlib = lib; 526 wdlib = lib;
525 } else { 527 } else {
526 delete lib; 528 delete lib;
527 wdiface = new DefaultWindowDecoration; 529 wdiface = new DefaultWindowDecoration;
528 } 530 }
529 531
530 helpFile = QString(qApp->argv()[0]) + ".html"; 532 helpFile = QString(qApp->argv()[0]) + ".html";
531 QStringList helpPath = Global::helpPath(); 533 QStringList helpPath = Global::helpPath();
532 helpExists = FALSE; 534 helpExists = FALSE;
533 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) 535 for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) {
534 helpExists = QFile::exists( *it + "/" + helpFile ); 536 helpExists = QFile::exists( *it + "/" + helpFile );
537 qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); }
535 qpeManager = new QPEManager( this ); 538 qpeManager = new QPEManager( this );
536} 539}
537 540
538QPEDecoration::~QPEDecoration() 541QPEDecoration::~QPEDecoration()
539{ 542{
540 delete qpeManager; 543 delete qpeManager;
541} 544}
542 545
543const char **QPEDecoration::menuPixmap() 546const char **QPEDecoration::menuPixmap()
544{ 547{
545 return (const char **)0; 548 return (const char **)0;
546} 549}
547 550
548const char **QPEDecoration::closePixmap() 551const char **QPEDecoration::closePixmap()
549{ 552{
550 return (const char **)qpe_close_xpm; 553 return (const char **)qpe_close_xpm;
551} 554}
552 555
553const char **QPEDecoration::minimizePixmap() 556const char **QPEDecoration::minimizePixmap()
554{ 557{
555 return (const char **)qpe_accept_xpm; 558 return (const char **)qpe_accept_xpm;
556} 559}
557 560
558const char **QPEDecoration::maximizePixmap() 561const char **QPEDecoration::maximizePixmap()
559{ 562{
560 return (const char **)0; 563 return (const char **)0;
561} 564}
562 565
563const char **QPEDecoration::normalizePixmap() 566const char **QPEDecoration::normalizePixmap()
564{ 567{
565 return (const char **)0; 568 return (const char **)0;
566} 569}
567 570
568int QPEDecoration::getTitleHeight( const QWidget *w ) 571int QPEDecoration::getTitleHeight( const QWidget *w )
569{ 572{
570 WindowDecorationInterface::WindowData wd; 573 WindowDecorationInterface::WindowData wd;
571 windowData( w, wd ); 574 windowData( w, wd );
572 return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 575 return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
573} 576}
574 577
575/* 578/*
576 If rect is empty, no frame is added. (a hack, really) 579 If rect is empty, no frame is added. (a hack, really)
577*/ 580*/
578QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) 581QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type)
579{ 582{
580 qpeManager->updateActive(); 583 qpeManager->updateActive();
581 584
582 WindowDecorationInterface::WindowData wd; 585 WindowDecorationInterface::WindowData wd;
583 windowData( widget, wd ); 586 windowData( widget, wd );
584 wd.rect = rect; 587 wd.rect = rect;
585 588
586 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 589 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
587 int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); 590 int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd);
588 int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); 591 int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd);
589 int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); 592 int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd);
590 int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); 593 int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd);
591 594
592 QRegion region; 595 QRegion region;
593 596
594 switch ((int)type) { 597 switch ((int)type) {
595 case Menu: 598 case Menu:
596 break; 599 break;
597 case Maximize: 600 case Maximize:
598 if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { 601 if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) {
599 int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); 602 int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd);
600 int left = rect.right() - maximizeWidth - closeWidth; 603 int left = rect.right() - maximizeWidth - closeWidth;
601 if ( ((HackWidget *)widget)->needsOk() ) 604 if ( ((HackWidget *)widget)->needsOk() )
602 left -= okWidth; 605 left -= okWidth;
603 QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); 606 QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight);
604 region = r; 607 region = r;
605 } 608 }
606 break; 609 break;
607 case Minimize: 610 case Minimize:
608 if ( ((HackWidget *)widget)->needsOk() ) { 611 if ( ((HackWidget *)widget)->needsOk() ) {
609 QRect r(rect.right() - okWidth, 612 QRect r(rect.right() - okWidth,
610 rect.top() - titleHeight, okWidth, titleHeight); 613 rect.top() - titleHeight, okWidth, titleHeight);
611 if (r.left() > rect.left() + titleHeight) 614 if (r.left() > rect.left() + titleHeight)
612 region = r; 615 region = r;
613 } 616 }
614 break; 617 break;
615 case Close: 618 case Close:
616 { 619 {
617 int left = rect.right() - closeWidth; 620 int left = rect.right() - closeWidth;
618 if ( ((HackWidget *)widget)->needsOk() ) 621 if ( ((HackWidget *)widget)->needsOk() )
619 left -= okWidth; 622 left -= okWidth;
620 QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); 623 QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight);
621 region = r; 624 region = r;
622 } 625 }
623 break; 626 break;
624 case Title: 627 case Title:
625 if ( !widget->isMaximized() ) { 628 if ( !widget->isMaximized() ) {
626 int width = rect.width() - helpWidth - closeWidth; 629 int width = rect.width() - helpWidth - closeWidth;
627 if ( ((HackWidget *)widget)->needsOk() ) 630 if ( ((HackWidget *)widget)->needsOk() )
628 width -= okWidth; 631 width -= okWidth;
629 QRect r(rect.left()+helpWidth, rect.top() - titleHeight, 632 QRect r(rect.left()+helpWidth, rect.top() - titleHeight,
630 width, titleHeight); 633 width, titleHeight);
631 if (r.width() > 0) 634 if (r.width() > 0)
632 region = r; 635 region = r;
633 } 636 }
634 break; 637 break;
635 case Help: 638 case Help:
636 if ( helpExists || widget->testWFlags(Qt::WStyle_ContextHelp) ) { 639 if ( helpExists || widget->testWFlags(Qt::WStyle_ContextHelp) ) {
637 QRect r(rect.left(), rect.top() - titleHeight, 640 QRect r(rect.left(), rect.top() - titleHeight,
638 helpWidth, titleHeight); 641 helpWidth, titleHeight);
639 region = r; 642 region = r;
640 } 643 }
641 break; 644 break;
642 case Top: 645 case Top:
643 if ( !widget->isMaximized() ) { 646 if ( !widget->isMaximized() ) {
644 QRegion m = wdiface->mask(&wd); 647 QRegion m = wdiface->mask(&wd);
645 QRect br = m.boundingRect(); 648 QRect br = m.boundingRect();
646 int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 649 int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
647 region = m & QRect( br.left()+grab, br.top(), 650 region = m & QRect( br.left()+grab, br.top(),
648 br.width()-2*grab, b ); 651 br.width()-2*grab, b );
649 } 652 }
650 break; 653 break;
651 case Left: 654 case Left:
652 if ( !widget->isMaximized() ) { 655 if ( !widget->isMaximized() ) {
653 QRegion m = wdiface->mask(&wd); 656 QRegion m = wdiface->mask(&wd);
654 QRect br = m.boundingRect(); 657 QRect br = m.boundingRect();
655 int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); 658 int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd);
656 region = m & QRect( br.left(), br.top()+grab, 659 region = m & QRect( br.left(), br.top()+grab,
657 b, br.height()-2*grab ); 660 b, br.height()-2*grab );
658 } 661 }
659 break; 662 break;
660 case Right: 663 case Right:
661 if ( !widget->isMaximized() ) { 664 if ( !widget->isMaximized() ) {
662 QRegion m = wdiface->mask(&wd); 665 QRegion m = wdiface->mask(&wd);
663 QRect br = m.boundingRect(); 666 QRect br = m.boundingRect();
664 int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); 667 int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd);
665 region = m & QRect( rect.right(), br.top()+grab, 668 region = m & QRect( rect.right(), br.top()+grab,
666 b, br.height()-2*grab ); 669 b, br.height()-2*grab );
667 } 670 }
668 break; 671 break;
669 case Bottom: 672 case Bottom:
670 if ( !widget->isMaximized() ) { 673 if ( !widget->isMaximized() ) {
671 QRegion m = wdiface->mask(&wd); 674 QRegion m = wdiface->mask(&wd);
672 QRect br = m.boundingRect(); 675 QRect br = m.boundingRect();
673 int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd); 676 int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd);
674 region = m & QRect( br.left()+grab, rect.bottom(), 677 region = m & QRect( br.left()+grab, rect.bottom(),
675 br.width()-2*grab, b ); 678 br.width()-2*grab, b );
676 } 679 }
677 break; 680 break;
678 case TopLeft: 681 case TopLeft:
679 if ( !widget->isMaximized() ) { 682 if ( !widget->isMaximized() ) {
680 QRegion m = wdiface->mask(&wd); 683 QRegion m = wdiface->mask(&wd);
681 QRect br = m.boundingRect(); 684 QRect br = m.boundingRect();
682 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 685 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
683 int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); 686 int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd);
684 QRegion crgn( br.left(), br.top(), grab, tb ); 687 QRegion crgn( br.left(), br.top(), grab, tb );
685 crgn |= QRect( br.left(), br.top(), lb, grab ); 688 crgn |= QRect( br.left(), br.top(), lb, grab );
686 region = m & crgn; 689 region = m & crgn;
687 } 690 }
688 break; 691 break;
689 case TopRight: 692 case TopRight:
690 if ( !widget->isMaximized() ) { 693 if ( !widget->isMaximized() ) {
691 QRegion m = wdiface->mask(&wd); 694 QRegion m = wdiface->mask(&wd);
692 QRect br = m.boundingRect(); 695 QRect br = m.boundingRect();
693 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 696 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
694 int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); 697 int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd);
695 QRegion crgn( br.right()-grab, br.top(), grab, tb ); 698 QRegion crgn( br.right()-grab, br.top(), grab, tb );
696 crgn |= QRect( br.right()-rb, br.top(), rb, grab ); 699 crgn |= QRect( br.right()-rb, br.top(), rb, grab );
697 region = m & crgn; 700 region = m & crgn;
698 } 701 }
699 break; 702 break;
700 case BottomLeft: 703 case BottomLeft:
701 if ( !widget->isMaximized() ) { 704 if ( !widget->isMaximized() ) {
702 QRegion m = wdiface->mask(&wd); 705 QRegion m = wdiface->mask(&wd);
703 QRect br = m.boundingRect(); 706 QRect br = m.boundingRect();
704 region = m & QRect( br.left(), br.bottom()-grab, grab, grab ); 707 region = m & QRect( br.left(), br.bottom()-grab, grab, grab );
705 } 708 }
706 break; 709 break;
707 case BottomRight: 710 case BottomRight:
708 if ( !widget->isMaximized() ) { 711 if ( !widget->isMaximized() ) {
709 QRegion m = wdiface->mask(&wd); 712 QRegion m = wdiface->mask(&wd);
710 QRect br = m.boundingRect(); 713 QRect br = m.boundingRect();
711 region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab ); 714 region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab );
712 } 715 }
713 break; 716 break;
714 case All: 717 case All:
715 if ( widget->isMaximized() ) 718 if ( widget->isMaximized() )
716 region = QWSDefaultDecoration::region(widget, rect, type); 719 region = QWSDefaultDecoration::region(widget, rect, type);
717 else 720 else
718 region = wdiface->mask(&wd) - rect; 721 region = wdiface->mask(&wd) - rect;
719 break; 722 break;
720 default: 723 default:
721 region = QWSDefaultDecoration::region(widget, rect, type); 724 region = QWSDefaultDecoration::region(widget, rect, type);
722 break; 725 break;
723 } 726 }
724 727
725 return region; 728 return region;
726} 729}
727 730
728void QPEDecoration::paint(QPainter *painter, const QWidget *widget) 731void QPEDecoration::paint(QPainter *painter, const QWidget *widget)
729{ 732{
730 WindowDecorationInterface::WindowData wd; 733 WindowDecorationInterface::WindowData wd;
731 windowData( widget, wd ); 734 windowData( widget, wd );
732 735
733 int titleWidth = getTitleWidth(widget); 736 int titleWidth = getTitleWidth(widget);
734 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 737 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
735 738
736 QRect rect(widget->rect()); 739 QRect rect(widget->rect());
737 740
738 // title bar rect 741 // title bar rect
739 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); 742 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
740 743
741#ifndef QT_NO_PALETTE 744#ifndef QT_NO_PALETTE
742 QRegion oldClip = painter->clipRegion(); 745 QRegion oldClip = painter->clipRegion();
743 painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker 746 painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker
744 wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd ); 747 wdiface->drawArea( WindowDecorationInterface::Border, painter, &wd );
745 painter->setClipRegion( oldClip ); 748 painter->setClipRegion( oldClip );
746 749
747 if (titleWidth > 0) { 750 if (titleWidth > 0) {
748 const QColorGroup &cg = widget->palette().active(); 751 const QColorGroup &cg = widget->palette().active();
749 QBrush titleBrush; 752 QBrush titleBrush;
750 QPen titlePen; 753 QPen titlePen;
751 754
752 if ( wd.flags & WindowDecorationInterface::WindowData::Active ) { 755 if ( wd.flags & WindowDecorationInterface::WindowData::Active ) {
753 titleBrush = cg.brush(QColorGroup::Highlight); 756 titleBrush = cg.brush(QColorGroup::Highlight);
754 titlePen = cg.color(QColorGroup::HighlightedText); 757 titlePen = cg.color(QColorGroup::HighlightedText);
755 } else { 758 } else {
756 titleBrush = cg.brush(QColorGroup::Background); 759 titleBrush = cg.brush(QColorGroup::Background);
757 titlePen = cg.color(QColorGroup::Text); 760 titlePen = cg.color(QColorGroup::Text);
758 } 761 }
759 762
760 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); 763 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd );
761 764
762 // Draw caption 765 // Draw caption
763 painter->setPen(titlePen); 766 painter->setPen(titlePen);
764 QFont f( QApplication::font() ); 767 QFont f( QApplication::font() );
765 f.setWeight( QFont::Bold ); 768 f.setWeight( QFont::Bold );
766 painter->setFont(f); 769 painter->setFont(f);
767 wdiface->drawArea( WindowDecorationInterface::TitleText, painter, &wd ); 770 wdiface->drawArea( WindowDecorationInterface::TitleText, painter, &wd );
768 } 771 }
769#endif //QT_NO_PALETTE 772#endif //QT_NO_PALETTE
770 773
771 paintButton( painter, widget, (QWSDecoration::Region)Help, 0 ); 774 paintButton( painter, widget, (QWSDecoration::Region)Help, 0 );
772} 775}
773 776
774void QPEDecoration::paintButton(QPainter *painter, const QWidget *w, 777void QPEDecoration::paintButton(QPainter *painter, const QWidget *w,
775 QWSDecoration::Region type, int state) 778 QWSDecoration::Region type, int state)
776{ 779{
777 WindowDecorationInterface::Button b; 780 WindowDecorationInterface::Button b;
778 switch ((int)type) { 781 switch ((int)type) {
779 case Close: 782 case Close:
780 b = WindowDecorationInterface::Close; 783 b = WindowDecorationInterface::Close;
781 break; 784 break;
782 case Minimize: 785 case Minimize:
783 if ( ((HackWidget *)w)->needsOk() ) 786 if ( ((HackWidget *)w)->needsOk() )
784 b = WindowDecorationInterface::OK; 787 b = WindowDecorationInterface::OK;
785 else if ( helpExists ) 788 else if ( helpExists )
786 b = WindowDecorationInterface::Help; 789 b = WindowDecorationInterface::Help;
787 else 790 else
788 return; 791 return;
789 break; 792 break;
790 case Help: 793 case Help:
791 b = WindowDecorationInterface::Help; 794 b = WindowDecorationInterface::Help;
792 break; 795 break;
793 case Maximize: 796 case Maximize:
794 b = WindowDecorationInterface::Maximize; 797 b = WindowDecorationInterface::Maximize;
795 break; 798 break;
796 default: 799 default:
797 return; 800 return;
798 } 801 }
799 802
800 WindowDecorationInterface::WindowData wd; 803 WindowDecorationInterface::WindowData wd;
801 windowData( w, wd ); 804 windowData( w, wd );
802 805
803 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 806 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
804 QRect rect(w->rect()); 807 QRect rect(w->rect());
805 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); 808 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
806 QRect brect(region(w, w->rect(), type).boundingRect()); 809 QRect brect(region(w, w->rect(), type).boundingRect());
807 810
808 const QColorGroup &cg = w->palette().active(); 811 const QColorGroup &cg = w->palette().active();
809 if ( wd.flags & WindowDecorationInterface::WindowData::Active ) 812 if ( wd.flags & WindowDecorationInterface::WindowData::Active )
810 painter->setPen( cg.color(QColorGroup::HighlightedText) ); 813 painter->setPen( cg.color(QColorGroup::HighlightedText) );
811 else 814 else
812 painter->setPen( cg.color(QColorGroup::Text) ); 815 painter->setPen( cg.color(QColorGroup::Text) );
813 816
814 QRegion oldClip = painter->clipRegion(); 817 QRegion oldClip = painter->clipRegion();
815 painter->setClipRegion( QRect(brect.x(), tr.y(), brect.width(), tr.height()) ); // reduce flicker 818 painter->setClipRegion( QRect(brect.x(), tr.y(), brect.width(), tr.height()) ); // reduce flicker
816 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); 819 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd );
817 wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state ); 820 wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state );
818 painter->setClipRegion( oldClip ); 821 painter->setClipRegion( oldClip );
819} 822}
820 823
821//#define QPE_DONT_SHOW_TITLEBAR 824//#define QPE_DONT_SHOW_TITLEBAR
822 825
823void QPEDecoration::maximize( QWidget *widget ) 826void QPEDecoration::maximize( QWidget *widget )
824{ 827{
825#ifdef QPE_DONT_SHOW_TITLEBAR 828#ifdef QPE_DONT_SHOW_TITLEBAR
826 if ( !widget->inherits( "QDialog" ) ) { 829 if ( !widget->inherits( "QDialog" ) ) {
827 widget->setGeometry( qt_maxWindowRect ); 830 widget->setGeometry( qt_maxWindowRect );
828 } else 831 } else
829#endif 832#endif
830 { 833 {
831 QWSDecoration::maximize( widget ); 834 QWSDecoration::maximize( widget );
832 } 835 }
833} 836}
834 837
835#ifndef QT_NO_DIALOG 838#ifndef QT_NO_DIALOG
836class HackDialog : public QDialog 839class HackDialog : public QDialog
837{ 840{
838public: 841public:
839 void acceptIt() { 842 void acceptIt() {
840 if ( isA( "QMessageBox" ) ) 843 if ( isA( "QMessageBox" ) )
841 qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); 844 qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) );
842 else 845 else
843 accept(); 846 accept();
844 } 847 }
845}; 848};
846#endif 849#endif
847 850
848 851
849void QPEDecoration::minimize( QWidget *widget ) 852void QPEDecoration::minimize( QWidget *widget )
850{ 853{
851#ifndef QT_NO_DIALOG 854#ifndef QT_NO_DIALOG
852 // We use the minimize button as an "accept" button. 855 // We use the minimize button as an "accept" button.
853 if ( widget->inherits( "QDialog" ) ) { 856 if ( widget->inherits( "QDialog" ) ) {
854 HackDialog *d = (HackDialog *)widget; 857 HackDialog *d = (HackDialog *)widget;
855 d->acceptIt(); 858 d->acceptIt();
856 } 859 }
857#endif 860#endif
858 else if ( ((HackWidget *)widget)->needsOk() ) { 861 else if ( ((HackWidget *)widget)->needsOk() ) {
859 QSignal s; 862 QSignal s;
860 s.connect( widget, SLOT( accept() ) ); 863 s.connect( widget, SLOT( accept() ) );
861 s.activate(); 864 s.activate();
862 } else { 865 } else {
863 help( widget ); 866 help( widget );
864 } 867 }
865} 868}
866 869
867void QPEDecoration::help( QWidget *w ) 870void QPEDecoration::help( QWidget *w )
868{ 871{
869 if ( helpExists ) { 872 if ( helpExists ) {
870 Global::execute( "helpbrowser", helpFile ); 873 Global::execute( "helpbrowser", helpFile );
871 } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { 874 } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) {
872 QWhatsThis::enterWhatsThisMode(); 875 QWhatsThis::enterWhatsThisMode();
873 QWhatsThis::leaveWhatsThisMode( qApp->tr( 876 QWhatsThis::leaveWhatsThisMode( qApp->tr(
874 "<Qt>Comprehensive help is not available for this application, " 877 "<Qt>Comprehensive help is not available for this application, "
875 "however there is context-sensitive help.<p>To use context-sensitive help:<p>" 878 "however there is context-sensitive help.<p>To use context-sensitive help:<p>"
876 "<ol><li>click and hold the help button." 879 "<ol><li>click and hold the help button."
877 "<li>when the title bar shows <b>What's this...</b>, " 880 "<li>when the title bar shows <b>What's this...</b>, "
878 "click on any control.</ol></Qt>" ) ); 881 "click on any control.</ol></Qt>" ) );
879 } 882 }
880} 883}
881 884
882void QPEDecoration::windowData( const QWidget *w, WindowDecorationInterface::WindowData &wd ) const 885void QPEDecoration::windowData( const QWidget *w, WindowDecorationInterface::WindowData &wd ) const
883{ 886{
884 wd.rect = w->rect(); 887 wd.rect = w->rect();
885 if ( qpeManager->whatsThisWidget() == w ) 888 if ( qpeManager->whatsThisWidget() == w )
886 wd.caption = qApp->tr("What's this..." ); 889 wd.caption = qApp->tr("What's this..." );
887 else 890 else
888 wd.caption = w->caption(); 891 wd.caption = w->caption();
889 wd.palette = qApp->palette(); 892 wd.palette = qApp->palette();
890 wd.flags = 0; 893 wd.flags = 0;
891 wd.flags |= w->isMaximized() ? WindowDecorationInterface::WindowData::Maximized : 0; 894 wd.flags |= w->isMaximized() ? WindowDecorationInterface::WindowData::Maximized : 0;
892 wd.flags |= w->testWFlags(Qt::WStyle_Dialog) ? WindowDecorationInterface::WindowData::Dialog : 0; 895 wd.flags |= w->testWFlags(Qt::WStyle_Dialog) ? WindowDecorationInterface::WindowData::Dialog : 0;
893 const QWidget *active = qpeManager->activeWidget(); 896 const QWidget *active = qpeManager->activeWidget();
894 wd.flags |= w == active ? WindowDecorationInterface::WindowData::Active : 0; 897 wd.flags |= w == active ? WindowDecorationInterface::WindowData::Active : 0;
895 wd.reserved = 1; 898 wd.reserved = 1;
896} 899}
897 900
898/* 901/*
899#ifndef QT_NO_POPUPMENU 902#ifndef QT_NO_POPUPMENU
900QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&) 903QPopupMenu *QPEDecoration::menu(QWSManager*, const QWidget*, const QPoint&)
901{ 904{
902 return 0; 905 return 0;
903} 906}
904#endif 907#endif
905*/ 908*/
906 909
907 910
908 911
909 912
910#endif // QT_NO_QWS_QPE_WM_STYLE 913#endif // QT_NO_QWS_QPE_WM_STYLE
911#endif 914#endif
diff --git a/library/task-opie-applets.control b/library/task-opie-applets.control
index f0e7780..11e2eae 100644
--- a/library/task-opie-applets.control
+++ b/library/task-opie-applets.control
@@ -1,9 +1,9 @@
1Files: 1Files:
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: Maximilian Reiss <max.reiss@gmx.de> 4Maintainer: Maximilian Reiss <max.reiss@gmx.de>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-batteryapplet, opie-clockapplet, opie-vmemo, opie-volumeapplet, opie-screenshotapplet, opie-netmonapplet, opie-pickboard, opie-keyboard, opie-jumpx, opie-handwriting, opie-dvorak, opie-unikeyboard 7Depends: opie-batteryapplet, opie-clockapplet, opie-vmemo, opie-volumeapplet, opie-screenshotapplet, opie-netmonapplet, opie-pickboard, opie-keyboard, opie-jumpx, opie-handwriting, opie-dvorak, opie-unikeyboard
8Description: Opie taskbar applets 8Description: Opie taskbar applets
9 All applets for the taskbar \ No newline at end of file 9 All applets for the taskbar
diff --git a/library/task-opie-complete.control b/library/task-opie-complete.control
index 226a278..6dafc0c 100644
--- a/library/task-opie-complete.control
+++ b/library/task-opie-complete.control
@@ -1,9 +1,9 @@
1Files: 1Files:
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: Maximilian Reiss <max.reiss@gmx.de> 4Maintainer: Maximilian Reiss <max.reiss@gmx.de>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: task-opie, task-opie-apps, task-opie-settings, task-opie-games, task-opie-applets 7Depends: task-opie, task-opie-apps, task-opie-settings, task-opie-games, task-opie-applets
8Description: All off Opie 8Description: All off Opie
9 All apps that are in the feed. \ No newline at end of file 9 All apps that are in the feed.
diff --git a/library/task-opie-games.control b/library/task-opie-games.control
index 014a56d..9695a40 100644
--- a/library/task-opie-games.control
+++ b/library/task-opie-games.control
@@ -1,9 +1,9 @@
1Files: 1Files:
2Priority: optional 2Priority: optional
3Section: opie/games 3Section: opie/games
4Maintainer: Maximilian Reiss <max.reiss@gmx.de> 4Maintainer: Maximilian Reiss <max.reiss@gmx.de>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-fifteen, opie-go, opie-kbill, opie-kcheckers, opie-kpacman, opie-minesweep, opie-parashoot, opie-qasteroids, opie-snake, opie-solitaire, opie-tetrix, opie-tictac, opie-wordgame 7Depends: opie-fifteen, opie-go, opie-kbill, opie-kcheckers, opie-kpacman, opie-minesweep, opie-parashoot, opie-qasteroids, opie-snake, opie-solitaire, opie-tetrix, opie-tictac, opie-wordgame
8Description: Opie game pack 8Description: Opie game pack
9 The full load of Opie games. \ No newline at end of file 9 The full load of Opie games.
diff --git a/library/task-opie-pim.control b/library/task-opie-pim.control
index e971780..6df8c22 100644
--- a/library/task-opie-pim.control
+++ b/library/task-opie-pim.control
@@ -1,9 +1,9 @@
1Files: 1Files:
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: Maximilian Reiss <max.reiss@gmx.de> 4Maintainer: Maximilian Reiss <max.reiss@gmx.de>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-datebook, opie-todo, opie-addressbook, task-opie-today, opie-drawpad, opie-keyboard 7Depends: opie-datebook, opie-todo, opie-addressbook, task-opie-today, opie-drawpad, opie-keyboard
8Description: Opie pim applications 8Description: Opie pim applications
9 Base pack of opie pim applications. Also includes keyboard input. \ No newline at end of file 9 Base pack of opie pim applications. Also includes keyboard input.
diff --git a/library/task-opie-settings.control b/library/task-opie-settings.control
index 2fbb4e8..0b572b0 100644
--- a/library/task-opie-settings.control
+++ b/library/task-opie-settings.control
@@ -1,9 +1,9 @@
1Files: 1Files:
2Priority: optional 2Priority: optional
3Section: opie/applications 3Section: opie/applications
4Maintainer: Maximilian Reiss <max.reiss@gmx.de> 4Maintainer: Maximilian Reiss <max.reiss@gmx.de>
5Architecture: arm 5Architecture: arm
6Version: $QPE_VERSION-$SUB_VERSION 6Version: $QPE_VERSION-$SUB_VERSION
7Depends: opie-appearance, opie-security, opie-systemtime, opie-light-and-power, opie-rotation, opie-tabmanager, opie-wlansetup 7Depends: opie-appearance, opie-security, opie-systemtime, opie-light-and-power, opie-rotation, opie-tabmanager, opie-wlansetup
8Description: Opie settings app 8Description: Opie settings app
9 All settings apps \ No newline at end of file 9 All settings apps