author | sandman <sandman> | 2002-11-22 21:57:47 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-11-22 21:57:47 (UTC) |
commit | a71b9d79a05ab2b6bc891afe4df4d5fdcf641550 (patch) (unidiff) | |
tree | 12852a47649207eb46b6bd6f7d41ab2fc2156259 | |
parent | 0f9ce3f60b6fbd350f79485ee8fc5fe37be692e1 (diff) | |
download | opie-a71b9d79a05ab2b6bc891afe4df4d5fdcf641550.zip opie-a71b9d79a05ab2b6bc891afe4df4d5fdcf641550.tar.gz opie-a71b9d79a05ab2b6bc891afe4df4d5fdcf641550.tar.bz2 |
Added some code for backward compatibility .. this enabled tkc apps with
custom window decoration to work on Opie (the X and OK button have a 1
pixel offset though, but I can't do anything about it)
-rw-r--r-- | library/qpedecoration_qws.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp index 9cbe92b..6221f5b 100644 --- a/library/qpedecoration_qws.cpp +++ b/library/qpedecoration_qws.cpp | |||
@@ -411,192 +411,197 @@ void WindowDecorationInterface::drawArea( Area a, QPainter *p, const WindowData | |||
411 | r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), | 411 | r.width()-metric(OKWidth,wd)-metric(CloseWidth,wd), |
412 | th, QPainter::AlignVCenter, wd->caption); | 412 | th, QPainter::AlignVCenter, wd->caption); |
413 | break; | 413 | break; |
414 | } | 414 | } |
415 | } | 415 | } |
416 | 416 | ||
417 | void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const | 417 | void WindowDecorationInterface::drawButton( Button b, QPainter *p, const WindowData *wd, int x, int y, int, int, QWSButton::State state ) const |
418 | { | 418 | { |
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 | 483 | ||
484 | //=========================================================================== | 484 | //=========================================================================== |
485 | 485 | ||
486 | QPEDecoration::QPEDecoration() | 486 | QPEDecoration::QPEDecoration() |
487 | : QWSDefaultDecoration() | 487 | : QWSDefaultDecoration() |
488 | { | 488 | { |
489 | if ( wdlib ) { | 489 | if ( wdlib ) { |
490 | wdiface->release(); | 490 | wdiface->release(); |
491 | wdlib->unload(); | 491 | wdlib->unload(); |
492 | delete wdlib; | 492 | delete wdlib; |
493 | wdlib = 0; | 493 | wdlib = 0; |
494 | } else { | 494 | } else { |
495 | delete wdiface; | 495 | delete wdiface; |
496 | } | 496 | } |
497 | wdiface = new DefaultWindowDecoration; | 497 | wdiface = new DefaultWindowDecoration; |
498 | 498 | ||
499 | helpFile = QString(qApp->argv()[0]) + ".html"; | 499 | helpFile = QString(qApp->argv()[0]) + ".html"; |
500 | QStringList helpPath = Global::helpPath(); | 500 | QStringList helpPath = Global::helpPath(); |
501 | helpExists = FALSE; | 501 | helpExists = FALSE; |
502 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { | 502 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { |
503 | helpExists = QFile::exists( *it + "/" + helpFile ); | 503 | helpExists = QFile::exists( *it + "/" + helpFile ); |
504 | qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); | 504 | qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); |
505 | } | 505 | } |
506 | qpeManager = new QPEManager( this ); | 506 | qpeManager = new QPEManager( this ); |
507 | |||
508 | // for backward compatibility: | ||
509 | imageOk = *okImage ( 15 ); | ||
510 | imageClose = *closeImage ( 15 ); | ||
511 | imageHelp = *helpImage ( 15 ); | ||
507 | } | 512 | } |
508 | 513 | ||
509 | QPEDecoration::QPEDecoration( const QString &plugin ) | 514 | QPEDecoration::QPEDecoration( const QString &plugin ) |
510 | : QWSDefaultDecoration() | 515 | : QWSDefaultDecoration() |
511 | { | 516 | { |
512 | if ( wdlib ) { | 517 | if ( wdlib ) { |
513 | wdiface->release(); | 518 | wdiface->release(); |
514 | wdlib->unload(); | 519 | wdlib->unload(); |
515 | delete wdlib; | 520 | delete wdlib; |
516 | wdlib = 0; | 521 | wdlib = 0; |
517 | } else { | 522 | } else { |
518 | delete wdiface; | 523 | delete wdiface; |
519 | } | 524 | } |
520 | WindowDecorationInterface *iface = 0; | 525 | WindowDecorationInterface *iface = 0; |
521 | QString path = QPEApplication::qpeDir() + "/plugins/decorations"; | 526 | QString path = QPEApplication::qpeDir() + "/plugins/decorations"; |
522 | QLibrary *lib = new QLibrary( path + "/" + plugin ); | 527 | QLibrary *lib = new QLibrary( path + "/" + plugin ); |
523 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { | 528 | if ( lib->queryInterface( IID_WindowDecoration, (QUnknownInterface**)&iface ) == QS_OK && iface ) { |
524 | wdiface = iface; | 529 | wdiface = iface; |
525 | wdlib = lib; | 530 | wdlib = lib; |
526 | } else { | 531 | } else { |
527 | delete lib; | 532 | delete lib; |
528 | wdiface = new DefaultWindowDecoration; | 533 | wdiface = new DefaultWindowDecoration; |
529 | } | 534 | } |
530 | 535 | ||
531 | helpFile = QString(qApp->argv()[0]) + ".html"; | 536 | helpFile = QString(qApp->argv()[0]) + ".html"; |
532 | QStringList helpPath = Global::helpPath(); | 537 | QStringList helpPath = Global::helpPath(); |
533 | helpExists = FALSE; | 538 | helpExists = FALSE; |
534 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { | 539 | for (QStringList::ConstIterator it=helpPath.begin(); it!=helpPath.end() && !helpExists; ++it) { |
535 | helpExists = QFile::exists( *it + "/" + helpFile ); | 540 | helpExists = QFile::exists( *it + "/" + helpFile ); |
536 | qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); } | 541 | qDebug ( "Checking %s/%s for help: %d", (*it).latin1(), helpFile.latin1(),helpExists); } |
537 | qpeManager = new QPEManager( this ); | 542 | qpeManager = new QPEManager( this ); |
538 | } | 543 | } |
539 | 544 | ||
540 | QPEDecoration::~QPEDecoration() | 545 | QPEDecoration::~QPEDecoration() |
541 | { | 546 | { |
542 | delete qpeManager; | 547 | delete qpeManager; |
543 | } | 548 | } |
544 | 549 | ||
545 | const char **QPEDecoration::menuPixmap() | 550 | const char **QPEDecoration::menuPixmap() |
546 | { | 551 | { |
547 | return (const char **)0; | 552 | return (const char **)0; |
548 | } | 553 | } |
549 | 554 | ||
550 | const char **QPEDecoration::closePixmap() | 555 | const char **QPEDecoration::closePixmap() |
551 | { | 556 | { |
552 | return (const char **)qpe_close_xpm; | 557 | return (const char **)qpe_close_xpm; |
553 | } | 558 | } |
554 | 559 | ||
555 | const char **QPEDecoration::minimizePixmap() | 560 | const char **QPEDecoration::minimizePixmap() |
556 | { | 561 | { |
557 | return (const char **)qpe_accept_xpm; | 562 | return (const char **)qpe_accept_xpm; |
558 | } | 563 | } |
559 | 564 | ||
560 | const char **QPEDecoration::maximizePixmap() | 565 | const char **QPEDecoration::maximizePixmap() |
561 | { | 566 | { |
562 | return (const char **)0; | 567 | return (const char **)0; |
563 | } | 568 | } |
564 | 569 | ||
565 | const char **QPEDecoration::normalizePixmap() | 570 | const char **QPEDecoration::normalizePixmap() |
566 | { | 571 | { |
567 | return (const char **)0; | 572 | return (const char **)0; |
568 | } | 573 | } |
569 | 574 | ||
570 | int QPEDecoration::getTitleHeight( const QWidget *w ) | 575 | int QPEDecoration::getTitleHeight( const QWidget *w ) |
571 | { | 576 | { |
572 | WindowDecorationInterface::WindowData wd; | 577 | WindowDecorationInterface::WindowData wd; |
573 | windowData( w, wd ); | 578 | windowData( w, wd ); |
574 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 579 | return wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
575 | } | 580 | } |
576 | 581 | ||
577 | /* | 582 | /* |
578 | If rect is empty, no frame is added. (a hack, really) | 583 | If rect is empty, no frame is added. (a hack, really) |
579 | */ | 584 | */ |
580 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) | 585 | QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecoration::Region type) |
581 | { | 586 | { |
582 | qpeManager->updateActive(); | 587 | qpeManager->updateActive(); |
583 | 588 | ||
584 | WindowDecorationInterface::WindowData wd; | 589 | WindowDecorationInterface::WindowData wd; |
585 | windowData( widget, wd ); | 590 | windowData( widget, wd ); |
586 | wd.rect = rect; | 591 | wd.rect = rect; |
587 | 592 | ||
588 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); | 593 | int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); |
589 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); | 594 | int okWidth = wdiface->metric(WindowDecorationInterface::OKWidth,&wd); |
590 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); | 595 | int closeWidth = wdiface->metric(WindowDecorationInterface::CloseWidth,&wd); |
591 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); | 596 | int helpWidth = wdiface->metric(WindowDecorationInterface::HelpWidth,&wd); |
592 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); | 597 | int grab = wdiface->metric(WindowDecorationInterface::CornerGrabSize,&wd); |
593 | 598 | ||
594 | QRegion region; | 599 | QRegion region; |
595 | 600 | ||
596 | switch ((int)type) { | 601 | switch ((int)type) { |
597 | case Menu: | 602 | case Menu: |
598 | break; | 603 | break; |
599 | case Maximize: | 604 | case Maximize: |
600 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { | 605 | if ( !widget->inherits( "QDialog" ) && qApp->desktop()->width() > 350 ) { |
601 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); | 606 | int maximizeWidth = wdiface->metric(WindowDecorationInterface::MaximizeWidth,&wd); |
602 | int left = rect.right() - maximizeWidth - closeWidth; | 607 | int left = rect.right() - maximizeWidth - closeWidth; |