-rw-r--r-- | library/qpedecoration_qws.cpp | 55 |
1 files changed, 15 insertions, 40 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index fb47c14..1afae88 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -244,168 +244,143 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e ) | |||
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 | #define IMAGE_METHOD( methodName, imageName ) \ | |
309 | static QImage *okImage( int th ) | 309 | static QImage* methodName( int th ) { \ |
310 | { | 310 | static QImage *i = 0; \ |
311 | static QImage *i = 0; | 311 | if ( !i || ::abs( i->height()-th ) > 4 ) { \ |
312 | if ( !i || ::abs( i->height()-th ) > 4 ) { | 312 | delete i; \ |
313 | delete i; | 313 | i = new QImage(scaleButton(Resource::loadImage(#imageName),th)); \ |
314 | i = new QImage(scaleButton(Resource::loadImage("OKButton"),th)); | 314 | } \ |
315 | } | 315 | \ |
316 | return i; | 316 | return i; \ |
317 | } | 317 | } |
318 | 318 | ||
319 | static QImage *closeImage( int th ) | 319 | IMAGE_METHOD(okImage, OKButton ); |
320 | { | 320 | IMAGE_METHOD(closeImage, CloseButton ); |
321 | static QImage *i = 0; | 321 | IMAGE_METHOD(helpImage, HelpButton ); |
322 | if ( !i || ::abs( i->height()-th ) > 4 ) { | 322 | IMAGE_METHOD(maximizeImage,MaximizeButton ); |
323 | delete i; | ||
324 | i = new QImage(scaleButton(Resource::loadImage("CloseButton"),th)); | ||
325 | } | ||
326 | return i; | ||
327 | } | ||
328 | |||
329 | static QImage *helpImage( int th ) | ||
330 | { | ||
331 | static QImage *i = 0; | ||
332 | if ( !i || ::abs( i->height()-th ) > 4 ) { | ||
333 | delete i; | ||
334 | i = new QImage(scaleButton(Resource::loadImage("HelpButton"),th)); | ||
335 | } | ||
336 | return i; | ||
337 | } | ||
338 | |||
339 | static QImage *maximizeImage( int th ) | ||
340 | { | ||
341 | static QImage *i = 0; | ||
342 | if ( !i || ::abs( i->height()-th ) > 4 ) { | ||
343 | delete i; | ||
344 | i = new QImage(scaleButton(Resource::loadImage("MaximizeButton"),th)); | ||
345 | } | ||
346 | return i; | ||
347 | } | ||
348 | 323 | ||
349 | int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const | 324 | int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const |
350 | { | 325 | { |
351 | switch ( m ) { | 326 | switch ( m ) { |
352 | case TitleHeight: | 327 | case TitleHeight: |
353 | if ( QApplication::desktop()->height() > 320 ) | 328 | if ( QApplication::desktop()->height() > 320 ) |
354 | return 19; | 329 | return 19; |
355 | else | 330 | else |
356 | return 15; | 331 | return 15; |
357 | case LeftBorder: | 332 | case LeftBorder: |
358 | case RightBorder: | 333 | case RightBorder: |
359 | case TopBorder: | 334 | case TopBorder: |
360 | case BottomBorder: | 335 | case BottomBorder: |
361 | return 4; | 336 | return 4; |
362 | case OKWidth: | 337 | case OKWidth: |
363 | return okImage(metric(TitleHeight,wd))->width(); | 338 | return okImage(metric(TitleHeight,wd))->width(); |
364 | case CloseWidth: | 339 | case CloseWidth: |
365 | return closeImage(metric(TitleHeight,wd))->width(); | 340 | return closeImage(metric(TitleHeight,wd))->width(); |
366 | case HelpWidth: | 341 | case HelpWidth: |
367 | return helpImage(metric(TitleHeight,wd))->width(); | 342 | return helpImage(metric(TitleHeight,wd))->width(); |
368 | case MaximizeWidth: | 343 | case MaximizeWidth: |
369 | return maximizeImage(metric(TitleHeight,wd))->width(); | 344 | return maximizeImage(metric(TitleHeight,wd))->width(); |
370 | case CornerGrabSize: | 345 | case CornerGrabSize: |
371 | return 16; | 346 | return 16; |
372 | } | 347 | } |
373 | 348 | ||
374 | return 0; | 349 | return 0; |
375 | } | 350 | } |
376 | 351 | ||
377 | void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const | 352 | void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const |
378 | { | 353 | { |
379 | int th = metric( TitleHeight, wd ); | 354 | int th = metric( TitleHeight, wd ); |
380 | QRect r = wd->rect; | 355 | QRect r = wd->rect; |
381 | 356 | ||
382 | switch ( a ) { | 357 | switch ( a ) { |
383 | case Border: | 358 | case Border: |
384 | { | 359 | { |
385 | const QColorGroup &cg = wd->palette.active(); | 360 | const QColorGroup &cg = wd->palette.active(); |
386 | qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), | 361 | qDrawWinPanel(p, r.x()-metric(LeftBorder,wd), |
387 | r.y()-th-metric(TopBorder,wd), | 362 | r.y()-th-metric(TopBorder,wd), |
388 | r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), | 363 | r.width()+metric(LeftBorder,wd)+metric(RightBorder,wd), |
389 | r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), | 364 | r.height()+th+metric(TopBorder,wd)+metric(BottomBorder,wd), |
390 | cg, FALSE, &cg.brush(QColorGroup::Background)); | 365 | cg, FALSE, &cg.brush(QColorGroup::Background)); |
391 | } | 366 | } |
392 | break; | 367 | break; |
393 | case Title: | 368 | case Title: |
394 | { | 369 | { |
395 | const QColorGroup &cg = wd->palette.active(); | 370 | const QColorGroup &cg = wd->palette.active(); |
396 | QBrush titleBrush; | 371 | QBrush titleBrush; |
397 | QPen titleLines; | 372 | QPen titleLines; |
398 | 373 | ||
399 | if ( wd->flags & WindowData::Active ) { | 374 | if ( wd->flags & WindowData::Active ) { |
400 | titleBrush = cg.brush(QColorGroup::Highlight); | 375 | titleBrush = cg.brush(QColorGroup::Highlight); |
401 | titleLines = titleBrush.color().dark(); | 376 | titleLines = titleBrush.color().dark(); |
402 | } else { | 377 | } else { |
403 | titleBrush = cg.brush(QColorGroup::Background); | 378 | titleBrush = cg.brush(QColorGroup::Background); |
404 | titleLines = titleBrush.color(); | 379 | titleLines = titleBrush.color(); |
405 | } | 380 | } |
406 | 381 | ||
407 | p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); | 382 | p->fillRect( r.x(), r.y()-th, r.width(), th, titleBrush); |
408 | 383 | ||
409 | p->setPen( titleLines ); | 384 | p->setPen( titleLines ); |
410 | for ( int i = r.y()-th; i < r.y(); i += 2 ) | 385 | for ( int i = r.y()-th; i < r.y(); i += 2 ) |
411 | p->drawLine( r.left(), i, r.right(), i ); | 386 | p->drawLine( r.left(), i, r.right(), i ); |