summaryrefslogtreecommitdiff
path: root/library
authorzecke <zecke>2005-02-22 22:46:25 (UTC)
committer zecke <zecke>2005-02-22 22:46:25 (UTC)
commit9e755f078a806d6c81e1dbdbc54d12888041bbff (patch) (unidiff)
tree0b49051c792eee3bb09674568e492cdac145de18 /library
parente33e10f5643a2fb5c640667939e4139bf7b580e2 (diff)
downloadopie-9e755f078a806d6c81e1dbdbc54d12888041bbff.zip
opie-9e755f078a806d6c81e1dbdbc54d12888041bbff.tar.gz
opie-9e755f078a806d6c81e1dbdbc54d12888041bbff.tar.bz2
Do not scale the buttons in the decoration over and over again.
The logic was if the requested size is not the size of the pixmap load and scale it to the right size. The problem was the scaleButton method was changed to not scale the pixmap (to avoid bluring al will kill me for that) if the delta of the sizes was <= 4. We now do not try to scale if the delta is <= 4
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpedecoration_qws.cpp8
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
@@ -216,223 +216,223 @@ bool QPEManager::eventFilter( QObject *o, QEvent *e )
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
260void QPEManager::drawButton( QWidget *w, QPEDecoration::QPERegion r, int state ) 260void 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
269void QPEManager::drawTitle( QWidget *w ) 269void 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
282void QPEManager::whatsThisTimeout() 282void 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
309static QImage *okImage( int th ) 309static 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
319static QImage *closeImage( int th ) 319static 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
329static QImage *helpImage( int th ) 329static 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
339static QImage *maximizeImage( int th ) 339static 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
349int WindowDecorationInterface::metric( Metric m, const WindowData *wd ) const 349int 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
377void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData *wd ) const 377void 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
422void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const 422void 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 }