-rw-r--r-- | library/qpedecoration_qws.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index fa38180..fb47c14 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -120,415 +120,415 @@ static QImage scaleButton( const QImage &img, int height ) | |||
120 | 120 | ||
121 | class TLWidget : public QWidget | 121 | class TLWidget : public QWidget |
122 | { | 122 | { |
123 | public: | 123 | public: |
124 | QWSManager *manager() | 124 | QWSManager *manager() |
125 | { | 125 | { |
126 | return topData()->qwsManager; | 126 | return topData()->qwsManager; |
127 | } | 127 | } |
128 | 128 | ||
129 | QTLWExtra *topExtra() | 129 | QTLWExtra *topExtra() |
130 | { | 130 | { |
131 | return topData(); | 131 | return topData(); |
132 | } | 132 | } |
133 | 133 | ||
134 | void setWState( uint s ) { QWidget::setWState( s ); } | 134 | void setWState( uint s ) { QWidget::setWState( s ); } |
135 | void clearWState( uint s ) { QWidget::clearWState( s ); } | 135 | void clearWState( uint s ) { QWidget::clearWState( s ); } |
136 | }; | 136 | }; |
137 | 137 | ||
138 | 138 | ||
139 | QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) | 139 | QPEManager::QPEManager( QPEDecoration *d, QObject *parent ) |
140 | : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) | 140 | : QObject( parent ), decoration( d ), helpState(0), inWhatsThis(FALSE) |
141 | { | 141 | { |
142 | wtTimer = new QTimer( this ); | 142 | wtTimer = new QTimer( this ); |
143 | connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); | 143 | connect( wtTimer, SIGNAL(timeout()), this, SLOT(whatsThisTimeout()) ); |
144 | } | 144 | } |
145 | 145 | ||
146 | 146 | ||
147 | void QPEManager::updateActive() | 147 | void QPEManager::updateActive() |
148 | { | 148 | { |
149 | QWidget *newActive = qApp->activeWindow(); | 149 | QWidget *newActive = qApp->activeWindow(); |
150 | if ( newActive && (QWidget*)active == newActive ) | 150 | if ( newActive && (QWidget*)active == newActive ) |
151 | return; | 151 | return; |
152 | 152 | ||
153 | if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { | 153 | if ( active && (!newActive || ((TLWidget *)newActive)->manager()) ) { |
154 | ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); | 154 | ((TLWidget *)(QWidget*)active)->manager()->removeEventFilter( this ); |
155 | } | 155 | } |
156 | 156 | ||
157 | if ( newActive && ((TLWidget *)newActive)->manager() ) { | 157 | if ( newActive && ((TLWidget *)newActive)->manager() ) { |
158 | active = newActive; | 158 | active = newActive; |
159 | ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); | 159 | ((TLWidget *)(QWidget*)active)->manager()->installEventFilter( this ); |
160 | } else if ( !newActive ) { | 160 | } else if ( !newActive ) { |
161 | active = 0; | 161 | active = 0; |
162 | } | 162 | } |
163 | } | 163 | } |
164 | 164 | ||
165 | int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) | 165 | int QPEManager::pointInQpeRegion( QWidget *w, const QPoint &p ) |
166 | { | 166 | { |
167 | QRect rect(w->geometry()); | 167 | QRect rect(w->geometry()); |
168 | 168 | ||
169 | if ( decoration->region( w, rect, | 169 | if ( decoration->region( w, rect, |
170 | (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) | 170 | (QWSDecoration::Region)QPEDecoration::Help ).contains(p) ) |
171 | return QPEDecoration::Help; | 171 | return QPEDecoration::Help; |
172 | 172 | ||
173 | for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { | 173 | for (int i = QWSDecoration::LastRegion; i >= QWSDecoration::Title; i--) { |
174 | if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) | 174 | if (decoration->region(w, rect, (QWSDecoration::Region)i).contains(p)) |
175 | return (QWSDecoration::Region)i; | 175 | return (QWSDecoration::Region)i; |
176 | } | 176 | } |
177 | 177 | ||
178 | return QWSDecoration::None; | 178 | return QWSDecoration::None; |
179 | } | 179 | } |
180 | 180 | ||
181 | bool QPEManager::eventFilter( QObject *o, QEvent *e ) | 181 | bool QPEManager::eventFilter( QObject *o, QEvent *e ) |
182 | { | 182 | { |
183 | QWSManager *mgr = (QWSManager *)o; | 183 | QWSManager *mgr = (QWSManager *)o; |
184 | QWidget *w = mgr->widget(); | 184 | QWidget *w = mgr->widget(); |
185 | switch ( e->type() ) { | 185 | switch ( e->type() ) { |
186 | case QEvent::MouseButtonPress: | 186 | case QEvent::MouseButtonPress: |
187 | { | 187 | { |
188 | pressTime = QTime::currentTime(); | 188 | pressTime = QTime::currentTime(); |
189 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 189 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
190 | int inRegion = pointInQpeRegion( w, p ); | 190 | int inRegion = pointInQpeRegion( w, p ); |
191 | #ifdef WHATSTHIS_MODE | 191 | #ifdef WHATSTHIS_MODE |
192 | if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { | 192 | if ( !w->geometry().contains(p) && QWhatsThis::inWhatsThisMode() ) { |
193 | QString text; | 193 | QString text; |
194 | switch ( inRegion ) { | 194 | switch ( inRegion ) { |
195 | case QWSDecoration::Close: | 195 | case QWSDecoration::Close: |
196 | if ( ((DecorHackWidget*)w)->needsOk() ) | 196 | if ( ((DecorHackWidget*)w)->needsOk() ) |
197 | text = tr("Click to close this window, discarding changes."); | 197 | text = tr("Click to close this window, discarding changes."); |
198 | else | 198 | else |
199 | text = tr("Click to close this window."); | 199 | text = tr("Click to close this window."); |
200 | break; | 200 | break; |
201 | case QWSDecoration::Minimize: | 201 | case QWSDecoration::Minimize: |
202 | text = tr("Click to close this window and apply changes."); | 202 | text = tr("Click to close this window and apply changes."); |
203 | break; | 203 | break; |
204 | case QWSDecoration::Maximize: | 204 | case QWSDecoration::Maximize: |
205 | if ( w->isMaximized() ) | 205 | if ( w->isMaximized() ) |
206 | text = tr("Click to make this window movable."); | 206 | text = tr("Click to make this window movable."); |
207 | else | 207 | else |
208 | text = tr("Click to make this window use all available screen area."); | 208 | text = tr("Click to make this window use all available screen area."); |
209 | break; | 209 | break; |
210 | default: | 210 | default: |
211 | break; | 211 | break; |
212 | } | 212 | } |
213 | QWhatsThis::leaveWhatsThisMode( text ); | 213 | QWhatsThis::leaveWhatsThisMode( text ); |
214 | whatsThisTimeout(); | 214 | whatsThisTimeout(); |
215 | helpState = 0; | 215 | helpState = 0; |
216 | return true; | 216 | return true; |
217 | } | 217 | } |
218 | #endif | 218 | #endif |
219 | if ( inRegion == QPEDecoration::Help ) { | 219 | if ( inRegion == QPEDecoration::Help ) { |
220 | #ifdef WHATSTHIS_MODE | 220 | #ifdef WHATSTHIS_MODE |
221 | wtTimer->start( 400, TRUE ); | 221 | wtTimer->start( 400, TRUE ); |
222 | #endif | 222 | #endif |
223 | helpState = QWSButton::Clicked|QWSButton::MouseOver; | 223 | helpState = QWSButton::Clicked|QWSButton::MouseOver; |
224 | drawButton( w, QPEDecoration::Help, helpState ); | 224 | drawButton( w, QPEDecoration::Help, helpState ); |
225 | return true; | 225 | return true; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | break; | 228 | break; |
229 | case QEvent::MouseButtonRelease: | 229 | case QEvent::MouseButtonRelease: |
230 | if ( helpState & QWSButton::Clicked ) { | 230 | if ( helpState & QWSButton::Clicked ) { |
231 | wtTimer->stop(); | 231 | wtTimer->stop(); |
232 | helpState = 0; | 232 | helpState = 0; |
233 | drawButton( w, QPEDecoration::Help, helpState ); | 233 | drawButton( w, QPEDecoration::Help, helpState ); |
234 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 234 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
235 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { | 235 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { |
236 | decoration->help( w ); | 236 | decoration->help( w ); |
237 | } | 237 | } |
238 | return true; | 238 | return true; |
239 | } | 239 | } |
240 | break; | 240 | break; |
241 | case QEvent::MouseMove: | 241 | case QEvent::MouseMove: |
242 | if ( helpState & QWSButton::Clicked ) { | 242 | if ( helpState & QWSButton::Clicked ) { |
243 | int oldState = helpState; | 243 | int oldState = helpState; |
244 | QPoint p = ((QMouseEvent*)e)->globalPos(); | 244 | QPoint p = ((QMouseEvent*)e)->globalPos(); |
245 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { | 245 | if ( pointInQpeRegion( w, p ) == QPEDecoration::Help ) { |
246 | helpState = QWSButton::Clicked|QWSButton::MouseOver; | 246 | helpState = QWSButton::Clicked|QWSButton::MouseOver; |
247 | } else { | 247 | } else { |
248 | helpState = 0; | 248 | helpState = 0; |
249 | } | 249 | } |
250 | if ( helpState != oldState ) | 250 | if ( helpState != oldState ) |
251 | drawButton( w, QPEDecoration::Help, helpState ); | 251 | drawButton( w, QPEDecoration::Help, helpState ); |
252 | } | 252 | } |
253 | break; | 253 | break; |
254 | default: | 254 | default: |
255 | break; | 255 | break; |
256 | } | 256 | } |
257 | return QObject::eventFilter( o, e ); | 257 | return QObject::eventFilter( o, e ); |
258 | } | 258 | } |
259 | 259 | ||
260 | void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) | 260 | void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) |
261 | { | 261 | { |
262 | QPainter painter(w); | 262 | QPainter painter(w); |
263 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; | 263 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; |
264 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); | 264 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); |
265 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); | 265 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); |
266 | decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); | 266 | decoration->paintButton( &painter, w, (QWSDecoration::Region)r, state ); |
267 | } | 267 | } |
268 | 268 | ||
269 | void QPEManager::drawTitle( QWidget *w ) | 269 | void QPEManager::drawTitle( QWidget *w ) |
270 | { | 270 | { |
271 | QPainter painter(w); | 271 | QPainter painter(w); |
272 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; | 272 | QRegion rgn = ((TLWidget *)w)->topExtra()->decor_allocated_region; |
273 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); | 273 | painter.internalGfx()->setWidgetDeviceRegion( rgn ); |
274 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); | 274 | painter.setClipRegion(decoration->region(w, w->rect(),QWSDecoration::All)); |
275 | decoration->paint( &painter, w ); | 275 | decoration->paint( &painter, w ); |
276 | decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); | 276 | decoration->paintButton(&painter, w, QWSDecoration::Menu, 0); |
277 | decoration->paintButton(&painter, w, QWSDecoration::Close, 0); | 277 | decoration->paintButton(&painter, w, QWSDecoration::Close, 0); |
278 | decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); | 278 | decoration->paintButton(&painter, w, QWSDecoration::Minimize, 0); |
279 | decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); | 279 | decoration->paintButton(&painter, w, QWSDecoration::Maximize, 0); |
280 | } | 280 | } |
281 | 281 | ||
282 | void QPEManager::whatsThisTimeout() | 282 | void QPEManager::whatsThisTimeout() |
283 | { | 283 | { |
284 | if ( !QWhatsThis::inWhatsThisMode() ) { | 284 | if ( !QWhatsThis::inWhatsThisMode() ) { |
285 | if ( inWhatsThis ) { | 285 | if ( inWhatsThis ) { |
286 | if ( whatsThis ) { | 286 | if ( whatsThis ) { |
287 | QWidget *w = whatsThis; | 287 | QWidget *w = whatsThis; |
288 | whatsThis = 0; | 288 | whatsThis = 0; |
289 | drawTitle( w ); | 289 | drawTitle( w ); |
290 | } | 290 | } |
291 | wtTimer->stop(); | 291 | wtTimer->stop(); |
292 | } else { | 292 | } else { |
293 | QWhatsThis::enterWhatsThisMode(); | 293 | QWhatsThis::enterWhatsThisMode(); |
294 | helpState = 0; | 294 | helpState = 0; |
295 | updateActive(); | 295 | updateActive(); |
296 | if ( active ) { | 296 | if ( active ) { |
297 | whatsThis = active; | 297 | whatsThis = active; |
298 | drawTitle( active ); | 298 | drawTitle( active ); |
299 | // check periodically to see if we've left whats this mode | 299 | // check periodically to see if we've left whats this mode |
300 | wtTimer->start( 250 ); | 300 | wtTimer->start( 250 ); |
301 | } | 301 | } |
302 | } | 302 | } |
303 | inWhatsThis = !inWhatsThis; | 303 | inWhatsThis = !inWhatsThis; |
304 | } | 304 | } |
305 | } | 305 | } |
306 | 306 | ||
307 | //=========================================================================== | 307 | //=========================================================================== |
308 | 308 | ||
309 | static QImage *okImage( int th ) | 309 | static QImage *okImage( int th ) |
310 | { | 310 | { |
311 | static QImage *i = 0; | 311 | static QImage *i = 0; |
312 | if ( !i || i->height() != th ) { | 312 | if ( !i || ::abs( i->height()-th ) > 4 ) { |
313 | delete i; | 313 | delete i; |
314 | i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); | 314 | i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); |
315 | } | 315 | } |
316 | return i; | 316 | return i; |
317 | } | 317 | } |
318 | 318 | ||
319 | static QImage *closeImage( int th ) | 319 | static QImage *closeImage( int th ) |
320 | { | 320 | { |
321 | static QImage *i = 0; | 321 | static QImage *i = 0; |
322 | if ( !i || i->height() != th ) { | 322 | if ( !i || ::abs( i->height()-th ) > 4 ) { |
323 | delete i; | 323 | delete i; |
324 | i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); | 324 | i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); |
325 | } | 325 | } |
326 | return i; | 326 | return i; |
327 | } | 327 | } |
328 | 328 | ||
329 | static QImage *helpImage( int th ) | 329 | static QImage *helpImage( int th ) |
330 | { | 330 | { |
331 | static QImage *i = 0; | 331 | static QImage *i = 0; |
332 | if ( !i || i->height() != th ) { | 332 | if ( !i || ::abs( i->height()-th ) > 4 ) { |
333 | delete i; | 333 | delete i; |
334 | i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); | 334 | i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); |
335 | } | 335 | } |
336 | return i; | 336 | return i; |
337 | } | 337 | } |
338 | 338 | ||
339 | static QImage *maximizeImage( int th ) | 339 | static QImage *maximizeImage( int th ) |
340 | { | 340 | { |
341 | static QImage *i = 0; | 341 | static QImage *i = 0; |
342 | if ( !i || i->height() != th ) { | 342 | if ( !i || ::abs( i->height()-th ) > 4 ) { |
343 | delete i; | 343 | delete i; |
344 | i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); | 344 | i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); |
345 | } | 345 | } |
346 | return i; | 346 | return i; |
347 | } | 347 | } |
348 | 348 | ||
349 | int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const | 349 | int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const |
350 | { | 350 | { |
351 | switch ( m ) { | 351 | switch ( m ) { |
352 | case TitleHeight: | 352 | case TitleHeight: |
353 | if ( QApplication::desktop()->height() > 320 ) | 353 | if ( QApplication::desktop()->height() > 320 ) |
354 | return 19; | 354 | return 19; |
355 | else | 355 | else |
356 | return 15; | 356 | return 15; |
357 | case LeftBorder: | 357 | case LeftBorder: |
358 | case RightBorder: | 358 | case RightBorder: |
359 | case TopBorder: | 359 | case TopBorder: |
360 | case BottomBorder: | 360 | case BottomBorder: |
361 | return 4; | 361 | return 4; |
362 | case OKWidth: | 362 | case OKWidth: |
363 | return okImage(metric(TitleHeight,wd))->width(); | 363 | return okImage(metric(TitleHeight,wd))->width(); |
364 | case CloseWidth: | 364 | case CloseWidth: |
365 | return closeImage(metric(TitleHeight,wd))->width(); | 365 | return closeImage(metric(TitleHeight,wd))->width(); |
366 | case HelpWidth: | 366 | case HelpWidth: |
367 | return helpImage(metric(TitleHeight,wd))->width(); | 367 | return helpImage(metric(TitleHeight,wd))->width(); |
368 | case MaximizeWidth: | 368 | case MaximizeWidth: |
369 | return maximizeImage(metric(TitleHeight,wd))->width(); | 369 | return maximizeImage(metric(TitleHeight,wd))->width(); |
370 | case CornerGrabSize: | 370 | case CornerGrabSize: |
371 | return 16; | 371 | return 16; |
372 | } | 372 | } |
373 | 373 | ||
374 | return 0; | 374 | return 0; |
375 | } | 375 | } |
376 | 376 | ||
377 | void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const | 377 | void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const |
378 | { | 378 | { |
379 | int th = metric( TitleHeight, wd ); | 379 | int th = metric( TitleHeight, wd ); |
380 | QRect r = wd->rect; | 380 | QRect r = wd->rect; |
381 | 381 | ||
382 | switch ( a ) { | 382 | switch ( a ) { |
383 | case Border: | 383 | case Border: |
384 | { | 384 | { |
385 | const QColorGroup &cg = wd->palette.active(); | 385 | const QColorGroup &cg = wd->palette.active(); |
386 | qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), | 386 | qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), |
387 | r.y()-th-metric(TopBorder,wd), | 387 | r.y()-th-metric(TopBorder,wd), |
388 | r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), | 388 | r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), |
389 | r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), | 389 | r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), |
390 | cg, FALSE, &cg.brush(QColorGroup::Background)); | 390 | cg, FALSE, &cg.brush(QColorGroup::Background)); |
391 | } | 391 | } |
392 | break; | 392 | break; |
393 | case Title: | 393 | case Title: |
394 | { | 394 | { |
395 | const QColorGroup &cg = wd->palette.active(); | 395 | const QColorGroup &cg = wd->palette.active(); |
396 | QBrush titleBrush; | 396 | QBrush titleBrush; |
397 | QPen titleLines; | 397 | QPen titleLines; |
398 | 398 | ||
399 | if ( wd->flags & WindowData::Active ) { | 399 | if ( wd->flags & WindowData::Active ) { |
400 | titleBrush = cg.brush(QColorGroup::Highlight); | 400 | titleBrush = cg.brush(QColorGroup::Highlight); |
401 | titleLines = titleBrush.color().dark(); | 401 | titleLines = titleBrush.color().dark(); |
402 | } else { | 402 | } else { |
403 | titleBrush = cg.brush(QColorGroup::Background); | 403 | titleBrush = cg.brush(QColorGroup::Background); |
404 | titleLines = titleBrush.color(); | 404 | titleLines = titleBrush.color(); |
405 | } | 405 | } |
406 | 406 | ||
407 | p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); | 407 | p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); |
408 | 408 | ||
409 | p->setPen( titleLines ); | 409 | p->setPen( titleLines ); |
410 | for ( int i = r.y()-th; i < r.y(); i += 2 ) | 410 | for ( int i = r.y()-th; i < r.y(); i += 2 ) |
411 | p->drawLine( r.left(), i, r.right(), i ); | 411 | p->drawLine( r.left(), i, r.right(), i ); |
412 | } | 412 | } |
413 | break; | 413 | break; |
414 | case TitleText: | 414 | case TitleText: |
415 | p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th, | 415 | p->drawText( r.x()+3+metric(HelpWidth,wd), r.top()-th, |
416 | r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), | 416 | r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), |
417 | th, QPainter::AlignVCenter, wd->caption); | 417 | th, QPainter::AlignVCenter, wd->caption); |
418 | break; | 418 | break; |
419 | } | 419 | } |
420 | } | 420 | } |
421 | 421 | ||
422 | void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const | 422 | void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const |
423 | { | 423 | { |
424 | QImage *img = 0; | 424 | QImage *img = 0; |
425 | switch ( b ) { | 425 | switch ( b ) { |
426 | case OK: | 426 | case OK: |
427 | img = okImage(metric(TitleHeight,wd)); | 427 | img = okImage(metric(TitleHeight,wd)); |
428 | break; | 428 | break; |
429 | case Close: | 429 | case Close: |
430 | img = closeImage(metric(TitleHeight,wd)); | 430 | img = closeImage(metric(TitleHeight,wd)); |
431 | break; | 431 | break; |
432 | case Help: | 432 | case Help: |
433 | img = helpImage(metric(TitleHeight,wd)); | 433 | img = helpImage(metric(TitleHeight,wd)); |
434 | break; | 434 | break; |
435 | case Maximize: | 435 | case Maximize: |
436 | img = maximizeImage(metric(TitleHeight,wd)); | 436 | img = maximizeImage(metric(TitleHeight,wd)); |
437 | break; | 437 | break; |
438 | } | 438 | } |
439 | 439 | ||
440 | if ( img ) { | 440 | if ( img ) { |
441 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) | 441 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) |
442 | p->drawImage(x+2, y+2, *img); | 442 | p->drawImage(x+2, y+2, *img); |
443 | else | 443 | else |
444 | p->drawImage(x+1, y+1, *img); | 444 | p->drawImage(x+1, y+1, *img); |
445 | } | 445 | } |
446 | } | 446 | } |
447 | 447 | ||
448 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const | 448 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const |
449 | { | 449 | { |
450 | int th = metric(TitleHeight,wd); | 450 | int th = metric(TitleHeight,wd); |
451 | QRect rect( wd->rect ); | 451 | QRect rect( wd->rect ); |
452 | QRect r(rect.left() - metric(LeftBorder,wd), | 452 | QRect r(rect.left() - metric(LeftBorder,wd), |
453 | rect.top() - th - metric(TopBorder,wd), | 453 | rect.top() - th - metric(TopBorder,wd), |
454 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), | 454 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), |
455 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); | 455 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); |
456 | return QRegion(r) - rect; | 456 | return QRegion(r) - rect; |
457 | } | 457 | } |
458 | 458 | ||
459 | class DefaultWindowDecoration : public WindowDecorationInterface | 459 | class DefaultWindowDecoration : public WindowDecorationInterface |
460 | { | 460 | { |
461 | public: | 461 | public: |
462 | DefaultWindowDecoration(){} | 462 | DefaultWindowDecoration(){} |
463 | QString name() const { | 463 | QString name() const { |
464 | return qApp->translate("WindowDecoration", "Default", | 464 | return qApp->translate("WindowDecoration", "Default", |
465 | "List box text for default window decoration"); | 465 | "List box text for default window decoration"); |
466 | } | 466 | } |
467 | QPixmap icon() const { | 467 | QPixmap icon() const { |
468 | return QPixmap(); | 468 | return QPixmap(); |
469 | } | 469 | } |
470 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 470 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
471 | *iface = 0; | 471 | *iface = 0; |
472 | if ( uuid == IID_QUnknown ) | 472 | if ( uuid == IID_QUnknown ) |
473 | *iface = this; | 473 | *iface = this; |
474 | else if ( uuid == IID_WindowDecoration ) | 474 | else if ( uuid == IID_WindowDecoration ) |
475 | *iface = this; | 475 | *iface = this; |
476 | else | 476 | else |
477 | return QS_FALSE; | 477 | return QS_FALSE; |
478 | 478 | ||
479 | if ( *iface ) | 479 | if ( *iface ) |
480 | (*iface)->addRef(); | 480 | (*iface)->addRef(); |
481 | return QS_OK; | 481 | return QS_OK; |
482 | } | 482 | } |
483 | Q_REFCOUNT | 483 | Q_REFCOUNT |
484 | 484 | ||
485 | }; | 485 | }; |
486 | 486 | ||
487 | static WindowDecorationInterface *wdiface = 0; | 487 | static WindowDecorationInterface *wdiface = 0; |
488 | static QLibrary* wdlib = 0; | 488 | static QLibrary* wdlib = 0; |
489 | static QString libname; | 489 | static QString libname; |
490 | 490 | ||
491 | //=========================================================================== | 491 | //=========================================================================== |
492 | bool QPEDecoration::helpExists() const | 492 | bool QPEDecoration::helpExists() const |
493 | { | 493 | { |
494 | if ( helpFile.isNull() ) { | 494 | if ( helpFile.isNull() ) { |
495 | QStringList helpPath = Global::helpPath(); | 495 | QStringList helpPath = Global::helpPath(); |
496 | QString hf = QString(qApp->argv()[0]) + ".html"; | 496 | QString hf = QString(qApp->argv()[0]) + ".html"; |
497 | bool he = FALSE; | 497 | bool he = FALSE; |
498 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) | 498 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !he; ++it) |
499 | he = QFile::exists( *it + "/" + hf ); | 499 | he = QFile::exists( *it + "/" + hf ); |
500 | ((QPEDecoration*)this)->helpFile = hf; | 500 | ((QPEDecoration*)this)->helpFile = hf; |
501 | ((QPEDecoration*)this)->helpexists = he; | 501 | ((QPEDecoration*)this)->helpexists = he; |
502 | return he; | 502 | return he; |
503 | } | 503 | } |
504 | return helpexists; | 504 | return helpexists; |
505 | } | 505 | } |
506 | 506 | ||
507 | QPEDecoration::QPEDecoration() | 507 | QPEDecoration::QPEDecoration() |
508 | : QWSDefaultDecoration() | 508 | : QWSDefaultDecoration() |
509 | { | 509 | { |
510 | if ( wdlib ) { | 510 | if ( wdlib ) { |
511 | delete wdlib; | 511 | delete wdlib; |
512 | wdlib = 0; | 512 | wdlib = 0; |
513 | } else { | 513 | } else { |
514 | delete wdiface; | 514 | delete wdiface; |
515 | } | 515 | } |
516 | wdiface = new DefaultWindowDecoration; | 516 | wdiface = new DefaultWindowDecoration; |
517 | 517 | ||
518 | helpexists = FALSE; // We don't know (flagged by helpFile being null) | 518 | helpexists = FALSE; // We don't know (flagged by helpFile being null) |
519 | qpeManager = new QPEManager( this ); | 519 | qpeManager = new QPEManager( this ); |
520 | imageOk = Resource::loadImage( "OKButton" ); | 520 | imageOk = Resource::loadImage( "OKButton" ); |
521 | imageClose = Resource::loadImage( "CloseButton" ); | 521 | imageClose = Resource::loadImage( "CloseButton" ); |
522 | imageHelp = Resource::loadImage( "HelpButton" ); | 522 | imageHelp = Resource::loadImage( "HelpButton" ); |
523 | } | 523 | } |
524 | 524 | ||
525 | QPEDecoration::QPEDecoration( const QString &plugin ) | 525 | QPEDecoration::QPEDecoration( const QString &plugin ) |
526 | : QWSDefaultDecoration() | 526 | : QWSDefaultDecoration() |
527 | { | 527 | { |
528 | libname = plugin; | 528 | libname = plugin; |
529 | 529 | ||
530 | if ( wdlib ) { | 530 | if ( wdlib ) { |
531 | wdiface->release(); | 531 | wdiface->release(); |
532 | wdlib->unload(); | 532 | wdlib->unload(); |
533 | delete wdlib; | 533 | delete wdlib; |
534 | wdlib = 0; | 534 | wdlib = 0; |