Diffstat (limited to 'library/qpedecoration_qws.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | library/qpedecoration_qws.cpp | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index 933542d..bac1a75 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -419,197 +419,205 @@ void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowD | |||
419 | QImage *img = 0; | 419 | QImage *img = 0; |
420 | switch ( b ) { | 420 | switch ( b ) { |
421 | case OK: | 421 | case OK: |
422 | img = okImage(metric(TitleHeight,wd)); | 422 | img = okImage(metric(TitleHeight,wd)); |
423 | break; | 423 | break; |
424 | case Close: | 424 | case Close: |
425 | img = closeImage(metric(TitleHeight,wd)); | 425 | img = closeImage(metric(TitleHeight,wd)); |
426 | break; | 426 | break; |
427 | case Help: | 427 | case Help: |
428 | img = helpImage(metric(TitleHeight,wd)); | 428 | img = helpImage(metric(TitleHeight,wd)); |
429 | break; | 429 | break; |
430 | case Maximize: | 430 | case Maximize: |
431 | img = maximizeImage(metric(TitleHeight,wd)); | 431 | img = maximizeImage(metric(TitleHeight,wd)); |
432 | break; | 432 | break; |
433 | } | 433 | } |
434 | 434 | ||
435 | if ( img ) { | 435 | if ( img ) { |
436 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) | 436 | if ((state & QWSButton::MouseOver) && (state & QWSButton::Clicked)) |
437 | p->drawImage(x+2, y+2, *img); | 437 | p->drawImage(x+2, y+2, *img); |
438 | else | 438 | else |
439 | p->drawImage(x+1, y+1, *img); | 439 | p->drawImage(x+1, y+1, *img); |
440 | } | 440 | } |
441 | } | 441 | } |
442 | 442 | ||
443 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const | 443 | QRegion WindowDecorationInterface::mask( const WindowData *wd ) const |
444 | { | 444 | { |
445 | int th = metric(TitleHeight,wd); | 445 | int th = metric(TitleHeight,wd); |
446 | QRect rect( wd->rect ); | 446 | QRect rect( wd->rect ); |
447 | QRect r(rect.left() - metric(LeftBorder,wd), | 447 | QRect r(rect.left() - metric(LeftBorder,wd), |
448 | rect.top() - th - metric(TopBorder,wd), | 448 | rect.top() - th - metric(TopBorder,wd), |
449 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), | 449 | rect.width() + metric(LeftBorder,wd) + metric(RightBorder,wd), |
450 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); | 450 | rect.height() + th + metric(TopBorder,wd) + metric(BottomBorder,wd)); |
451 | return QRegion(r) - rect; | 451 | return QRegion(r) - rect; |
452 | } | 452 | } |
453 | 453 | ||
454 | class DefaultWindowDecoration : public WindowDecorationInterface | 454 | class DefaultWindowDecoration : public WindowDecorationInterface |
455 | { | 455 | { |
456 | public: | 456 | public: |
457 | DefaultWindowDecoration() : ref(0) {} | 457 | DefaultWindowDecoration() : ref(0) {} |
458 | QString name() const { | 458 | QString name() const { |
459 | return "Default"; | 459 | return "Default"; |
460 | } | 460 | } |
461 | QPixmap icon() const { | 461 | QPixmap icon() const { |
462 | return QPixmap(); | 462 | return QPixmap(); |
463 | } | 463 | } |
464 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { | 464 | QRESULT queryInterface( const QUuid &uuid, QUnknownInterface **iface ) { |
465 | *iface = 0; | 465 | *iface = 0; |
466 | if ( uuid == IID_QUnknown ) | 466 | if ( uuid == IID_QUnknown ) |
467 | *iface = this; | 467 | *iface = this; |
468 | else if ( uuid == IID_WindowDecoration ) | 468 | else if ( uuid == IID_WindowDecoration ) |
469 | *iface = this; | 469 | *iface = this; |
470 | 470 | ||
471 | if ( *iface ) | 471 | if ( *iface ) |
472 | (*iface)->addRef(); | 472 | (*iface)->addRef(); |
473 | return QS_OK; | 473 | return QS_OK; |
474 | } | 474 | } |
475 | Q_REFCOUNT | 475 | Q_REFCOUNT |
476 | 476 | ||
477 | private: | 477 | private: |
478 | ulong ref; | 478 | ulong ref; |
479 | }; | 479 | }; |
480 | 480 | ||
481 | static WindowDecorationInterface *wdiface = 0; | 481 | static WindowDecorationInterface *wdiface = 0; |
482 | static QLibrary *wdlib = 0; | 482 | static QLibrary *wdlib = 0; |
483 | static QString libname; | 483 | static QString libname; |
484 | 484 | ||
485 | //=========================================================================== | 485 | //=========================================================================== |
486 | 486 | ||
487 | QPEDecoration::QPEDecoration() | 487 | QPEDecoration::QPEDecoration() |
488 | : QWSDefaultDecoration() | 488 | : QWSDefaultDecoration() |
489 | { | 489 | { |
490 | init ( libname ); | 490 | init ( libname ); |
491 | } | 491 | } |
492 | 492 | ||
493 | QPEDecoration::QPEDecoration( const QString &plugin ) | 493 | QPEDecoration::QPEDecoration( const QString &plugin ) |
494 | : QWSDefaultDecoration() | 494 | : QWSDefaultDecoration() |
495 | { | 495 | { |
496 | init ( plugin ); | 496 | init ( plugin ); |
497 | } | 497 | } |
498 | 498 | ||
499 | void QPEDecoration::init ( const QString &plugin ) | 499 | void QPEDecoration::init ( const QString &plugin ) |
500 | { | 500 | { |
501 | libname = plugin; | 501 | libname = plugin; |
502 | 502 | ||
503 | if ( wdlib ) { | 503 | if ( wdlib ) { |
504 | wdiface->release(); | 504 | wdiface->release(); |
505 | wdlib->unload(); | 505 | wdlib->unload(); |
506 | delete wdlib; | 506 | delete wdlib; |
507 | wdlib = 0; | 507 | wdlib = 0; |
508 | } else { | 508 | } else { |
509 | delete wdiface; | 509 | delete wdiface; |
510 | } | 510 | } |
511 | 511 | ||
512 | WindowDecorationInterface *iface = 0; | 512 | WindowDecorationInterface *iface = 0; |
513 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; | 513 | QString path = QPEApplication::qpeDir() + "/plugins/decorations/"; |
514 | 514 | ||
515 | #ifdef Q_OS_MACX | ||
516 | if ( plugin.find( ".dylib" ) > 0 ) { | ||
517 | #else | ||
515 | if ( plugin.find( ".so" ) > 0 ) { | 518 | if ( plugin.find( ".so" ) > 0 ) { |
519 | #endif | ||
516 | // full library name supplied | 520 | // full library name supplied |
517 | path += plugin; | 521 | path += plugin; |
518 | } else { | 522 | } else { |
523 | #ifdef Q_OS_MACX | ||
524 | path += "lib" + plugin.lower() + ".dylib"; // compatibility | ||
525 | #else | ||
519 | path += "lib" + plugin.lower() + ".so"; // compatibility | 526 | path += "lib" + plugin.lower() + ".so"; // compatibility |
527 | #endif | ||
520 | } | 528 | } |
521 | 529 | ||
522 | QLibrary *lib = new QLibrary( path ); | 530 | QLibrary *lib = new QLibrary( path ); |
523 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 531 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
524 | wdiface = iface; | 532 | wdiface = iface; |
525 | wdlib = lib; | 533 | wdlib = lib; |
526 | } else { | 534 | } else { |
527 | delete lib; | 535 | delete lib; |
528 | wdiface = new DefaultWindowDecoration; | 536 | wdiface = new DefaultWindowDecoration; |
529 | } | 537 | } |
530 | 538 | ||
531 | helpFile = QString(qApp->argv()[0]) + ".html"; | 539 | helpFile = QString(qApp->argv()[0]) + ".html"; |
532 | QStringList helpPath = Global::helpPath(); | 540 | QStringList helpPath = Global::helpPath(); |
533 | helpExists = FALSE; | 541 | helpExists = FALSE; |
534 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { | 542 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { |
535 | helpExists = QFile::exists( *it + "/" + helpFile ); | 543 | helpExists = QFile::exists( *it + "/" + helpFile ); |
536 | //qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); | 544 | //qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); |
537 | } | 545 | } |
538 | qpeManager = new QPEManager( this ); | 546 | qpeManager = new QPEManager( this ); |
539 | 547 | ||
540 | // Qtopia 1.5 compatibility | 548 | // Qtopia 1.5 compatibility |
541 | imageOk = *okImage ( 15 ); | 549 | imageOk = *okImage ( 15 ); |
542 | imageClose = *closeImage ( 15 ); | 550 | imageClose = *closeImage ( 15 ); |
543 | imageHelp = *helpImage ( 15 ); | 551 | imageHelp = *helpImage ( 15 ); |
544 | } | 552 | } |
545 | 553 | ||
546 | QPEDecoration::~QPEDecoration() | 554 | QPEDecoration::~QPEDecoration() |
547 | { | 555 | { |
548 | delete qpeManager; | 556 | delete qpeManager; |
549 | } | 557 | } |
550 | 558 | ||
551 | const char **QPEDecoration::menuPixmap() | 559 | const char **QPEDecoration::menuPixmap() |
552 | { | 560 | { |
553 | return (const char **)0; | 561 | return (const char **)0; |
554 | } | 562 | } |
555 | 563 | ||
556 | const char **QPEDecoration::closePixmap() | 564 | const char **QPEDecoration::closePixmap() |
557 | { | 565 | { |
558 | return (const char **)qpe_close_xpm; | 566 | return (const char **)qpe_close_xpm; |
559 | } | 567 | } |
560 | 568 | ||
561 | const char **QPEDecoration::minimizePixmap() | 569 | const char **QPEDecoration::minimizePixmap() |
562 | { | 570 | { |
563 | return (const char **)qpe_accept_xpm; | 571 | return (const char **)qpe_accept_xpm; |
564 | } | 572 | } |
565 | 573 | ||
566 | const char **QPEDecoration::maximizePixmap() | 574 | const char **QPEDecoration::maximizePixmap() |
567 | { | 575 | { |
568 | return (const char **)0; | 576 | return (const char **)0; |
569 | } | 577 | } |
570 | 578 | ||
571 | const char **QPEDecoration::normalizePixmap() | 579 | const char **QPEDecoration::normalizePixmap() |
572 | { | 580 | { |
573 | return (const char **)0; | 581 | return (const char **)0; |
574 | } | 582 | } |
575 | 583 | ||
576 | int QPEDecoration::getTitleHeight( const QWidget *w ) | 584 | int QPEDecoration::getTitleHeight( const QWidget *w ) |
577 | { | 585 | { |
578 | WindowDecorationInterface::WindowData wd; | 586 | WindowDecorationInterface::WindowData wd; |
579 | windowData( w, wd ); | 587 | windowData( w, wd ); |
580 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 588 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
581 | } | 589 | } |
582 | 590 | ||
583 | /* | 591 | /* |
584 | If rect is empty, no frame is added. (a hack, really) | 592 | If rect is empty, no frame is added. (a hack, really) |
585 | */ | 593 | */ |
586 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) | 594 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) |
587 | { | 595 | { |
588 | qpeManager->updateActive(); | 596 | qpeManager->updateActive(); |
589 | 597 | ||
590 | WindowDecorationInterface::WindowData wd; | 598 | WindowDecorationInterface::WindowData wd; |
591 | windowData( widget, wd ); | 599 | windowData( widget, wd ); |
592 | wd.rect = rect; | 600 | wd.rect = rect; |
593 | 601 | ||
594 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 602 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
595 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); | 603 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); |
596 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); | 604 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); |
597 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); | 605 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); |
598 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); | 606 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); |
599 | 607 | ||
600 | QRegion region; | 608 | QRegion region; |
601 | 609 | ||
602 | switch ((int)type) { | 610 | switch ((int)type) { |
603 | case Menu: | 611 | case Menu: |
604 | break; | 612 | break; |
605 | case Maximize: | 613 | case Maximize: |
606 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { | 614 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { |
607 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); | 615 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); |
608 | int left = rect.right() - maximizeWidth - closeWidth; | 616 | int left = rect.right() - maximizeWidth - closeWidth; |
609 | if ( ((HackWidget *)widget)->needsOk() ) | 617 | if ( ((HackWidget *)widget)->needsOk() ) |
610 | left -= okWidth; | 618 | left -= okWidth; |
611 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); | 619 | QRect r(left, rect.top() - titleHeight, closeWidth, titleHeight); |
612 | region = r; | 620 | region = r; |
613 | } | 621 | } |
614 | break; | 622 | break; |
615 | case Minimize: | 623 | case Minimize: |