summaryrefslogtreecommitdiff
path: root/library
Unidiff
Diffstat (limited to 'library') (more/less context) (ignore whitespace changes)
-rw-r--r--library/qpedecoration_qws.cpp23
1 files changed, 12 insertions, 11 deletions
diff --git a/library/qpedecoration_qws.cpp b/library/qpedecoration_qws.cpp
index 222d906..c2eb751 100644
--- a/library/qpedecoration_qws.cpp
+++ b/library/qpedecoration_qws.cpp
@@ -19,49 +19,49 @@
19**********************************************************************/ 19**********************************************************************/
20#ifdef QWS 20#ifdef QWS
21#define QTOPIA_INTERNAL_LANGLIST 21#define QTOPIA_INTERNAL_LANGLIST
22#include <qapplication.h> 22#include <qapplication.h>
23#include <qstyle.h> 23#include <qstyle.h>
24#include <qwidget.h> 24#include <qwidget.h>
25#include <qpainter.h> 25#include <qpainter.h>
26#include <qtimer.h> 26#include <qtimer.h>
27#include <qwhatsthis.h> 27#include <qwhatsthis.h>
28#include "qcopenvelope_qws.h" 28#include "qcopenvelope_qws.h"
29#include "qpedecoration_qws.h" 29#include "qpedecoration_qws.h"
30#include <qdialog.h> 30#include <qdialog.h>
31#include <qdrawutil.h> 31#include <qdrawutil.h>
32#include <qgfx_qws.h> 32#include <qgfx_qws.h>
33#include "qpeapplication.h" 33#include "qpeapplication.h"
34#include "resource.h" 34#include "resource.h"
35#include "global.h" 35#include "global.h"
36#include "qlibrary.h" 36#include "qlibrary.h"
37#include "windowdecorationinterface.h" 37#include "windowdecorationinterface.h"
38#include <qfile.h> 38#include <qfile.h>
39#include <qsignal.h> 39#include <qsignal.h>
40 40
41#include <stdlib.h> 41#include <stdlib.h>
42 42
43extern QRect qt_maxWindowRect; 43extern QRect qt_maxWindowRect;
44 44
45#define WHATSTHIS_MODE 45#define WHATSTHIS_MODE
46 46
47#ifndef QT_NO_QWS_QPE_WM_STYLE 47#ifndef QT_NO_QWS_QPE_WM_STYLE
48 48
49#ifndef QT_NO_IMAGEIO_XPM 49#ifndef QT_NO_IMAGEIO_XPM
50 50
51/* XPM */ 51/* XPM */
52static const char * const qpe_close_xpm[] = { 52static const char * const qpe_close_xpm[] = {
53"16 16 3 1", 53"16 16 3 1",
54" c None", 54" c None",
55". c #FFFFFF", 55". c #FFFFFF",
56"+ c #000000", 56"+ c #000000",
57" ", 57" ",
58" ", 58" ",
59" ..... ", 59" ..... ",
60" ..+++++.. ", 60" ..+++++.. ",
61" .+++++++++. ", 61" .+++++++++. ",
62" .+..+++..+. ", 62" .+..+++..+. ",
63" .++...+...++. ", 63" .++...+...++. ",
64" .+++.....+++. ", 64" .+++.....+++. ",
65" .++++...++++. ", 65" .++++...++++. ",
66" .+++.....+++. ", 66" .+++.....+++. ",
67" .++...+...++. ", 67" .++...+...++. ",
@@ -86,49 +86,50 @@ static const char * const qpe_accept_xpm[] = {
86" .+++++++..++. ", 86" .+++++++..++. ",
87" .++.+++...++. ", 87" .++.+++...++. ",
88" .+...+...+++. ", 88" .+...+...+++. ",
89" .+......++++. ", 89" .+......++++. ",
90" .++....+++++. ", 90" .++....+++++. ",
91" .++..+++++. ", 91" .++..+++++. ",
92" .+++++++++. ", 92" .+++++++++. ",
93" ..+++++.. ", 93" ..+++++.. ",
94" ..... ", 94" ..... ",
95" "}; 95" "};
96 96
97#endif // QT_NO_IMAGEIO_XPM 97#endif // QT_NO_IMAGEIO_XPM
98 98
99class HackWidget : public QWidget 99class HackWidget : public QWidget
100{ 100{
101public: 101public:
102 bool needsOk() { 102 bool needsOk() {
103 return (getWState() & WState_Reserved1 ) || 103 return (getWState() & WState_Reserved1 ) ||
104 (inherits( "QDialog" ) && !inherits( "QMessageBox" ) ); 104 (inherits( "QDialog" ) && !inherits( "QMessageBox" ) );
105 } 105 }
106}; 106};
107 107
108static QImage scaleButton( const QImage &img, int height ) 108static QImage scaleButton( const QImage &img, int height )
109{ 109{
110 if ( img.height() != height ) { 110 qWarning("Height %d %d", height, img.height() );
111 if ( img.height()!=0 && img.height() != height ) {
111 return img.smoothScale( img.width()*height/img.height(), height ); 112 return img.smoothScale( img.width()*height/img.height(), height );
112 } else { 113 } else {
113 return img; 114 return img;
114 } 115 }
115} 116}
116 117
117class TLWidget : public QWidget 118class TLWidget : public QWidget
118{ 119{
119public: 120public:
120 QWSManager *manager() 121 QWSManager *manager()
121 { 122 {
122 return topData()->qwsManager; 123 return topData()->qwsManager;
123 } 124 }
124 125
125 QTLWExtra *topExtra() 126 QTLWExtra *topExtra()
126 { 127 {
127 return topData(); 128 return topData();
128 } 129 }
129 130
130 void setWState( uint s ) { QWidget::setWState( s ); } 131 void setWState( uint s ) { QWidget::setWState( s ); }
131 void clearWState( uint s ) { QWidget::clearWState( s ); } 132 void clearWState( uint s ) { QWidget::clearWState( s ); }
132}; 133};
133 134
134 135
@@ -626,105 +627,105 @@ QRegion QPEDecoration::region(const QWidget *widget, const QRect &rect, QWSDecor
626 int width = rect.width() - helpWidth - closeWidth; 627 int width = rect.width() - helpWidth - closeWidth;
627 if ( ((HackWidget *)widget)->needsOk() ) 628 if ( ((HackWidget *)widget)->needsOk() )
628 width -= okWidth; 629 width -= okWidth;
629 QRect r(rect.left()+helpWidth, rect.top() - titleHeight, 630 QRect r(rect.left()+helpWidth, rect.top() - titleHeight,
630 width, titleHeight); 631 width, titleHeight);
631 if (r.width() > 0) 632 if (r.width() > 0)
632 region = r; 633 region = r;
633 } 634 }
634 break; 635 break;
635 case Help: 636 case Help:
636 if ( helpExists || widget->testWFlags(Qt::WStyle_ContextHelp) ) { 637 if ( helpExists || widget->testWFlags(Qt::WStyle_ContextHelp) ) {
637 QRect r(rect.left(), rect.top() - titleHeight, 638 QRect r(rect.left(), rect.top() - titleHeight,
638 helpWidth, titleHeight); 639 helpWidth, titleHeight);
639 region = r; 640 region = r;
640 } 641 }
641 break; 642 break;
642 case Top: 643 case Top:
643 if ( !widget->isMaximized() ) { 644 if ( !widget->isMaximized() ) {
644 QRegion m = wdiface->mask(&wd); 645 QRegion m = wdiface->mask(&wd);
645 QRect br = m.boundingRect(); 646 QRect br = m.boundingRect();
646 int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 647 int b = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
647 region = m & QRect( br.left()+grab, br.top(), 648 region = m & QRect( br.left()+grab, br.top(),
648 br.width()-2*grab, b ); 649 br.width()-2*grab, b );
649 } 650 }
650 break; 651 break;
651 case Left: 652 case Left:
652 if ( !widget->isMaximized() ) { 653 if ( !widget->isMaximized() ) {
653 QRegion m = wdiface->mask(&wd); 654 QRegion m = wdiface->mask(&wd);
654 QRect br = m.boundingRect(); 655 QRect br = m.boundingRect();
655 int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); 656 int b = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd);
656 region = m & QRect( br.left(), br.top()+grab, 657 region = m & QRect( br.left(), br.top()+grab,
657 b, br.height()-2*grab ); 658 b, br.height()-2*grab );
658 } 659 }
659 break; 660 break;
660 case Right: 661 case Right:
661 if ( !widget->isMaximized() ) { 662 if ( !widget->isMaximized() ) {
662 QRegion m = wdiface->mask(&wd); 663 QRegion m = wdiface->mask(&wd);
663 QRect br = m.boundingRect(); 664 QRect br = m.boundingRect();
664 int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); 665 int b = wdiface->metric(WindowDecorationInterface::RightBorder,&wd);
665 region = m & QRect( rect.right(), br.top()+grab, 666 region = m & QRect( rect.right(), br.top()+grab,
666 b, br.height()-2*grab ); 667 b, br.height()-2*grab );
667 } 668 }
668 break; 669 break;
669 case Bottom: 670 case Bottom:
670 if ( !widget->isMaximized() ) { 671 if ( !widget->isMaximized() ) {
671 QRegion m = wdiface->mask(&wd); 672 QRegion m = wdiface->mask(&wd);
672 QRect br = m.boundingRect(); 673 QRect br = m.boundingRect();
673 int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd); 674 int b = wdiface->metric(WindowDecorationInterface::BottomBorder,&wd);
674 region = m & QRect( br.left()+grab, rect.bottom(), 675 region = m & QRect( br.left()+grab, rect.bottom(),
675 br.width()-2*grab, b ); 676 br.width()-2*grab, b );
676 } 677 }
677 break; 678 break;
678 case TopLeft: 679 case TopLeft:
679 if ( !widget->isMaximized() ) { 680 if ( !widget->isMaximized() ) {
680 QRegion m = wdiface->mask(&wd); 681 QRegion m = wdiface->mask(&wd);
681 QRect br = m.boundingRect(); 682 QRect br = m.boundingRect();
682 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 683 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
683 int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd); 684 int lb = wdiface->metric(WindowDecorationInterface::LeftBorder,&wd);
684 QRegion crgn( br.left(), br.top(), grab, tb ); 685 QRegion crgn( br.left(), br.top(), grab, tb );
685 crgn |= QRect( br.left(), br.top(), lb, grab ); 686 crgn |= QRect( br.left(), br.top(), lb, grab );
686 region = m & crgn; 687 region = m & crgn;
687 } 688 }
688 break; 689 break;
689 case TopRight: 690 case TopRight:
690 if ( !widget->isMaximized() ) { 691 if ( !widget->isMaximized() ) {
691 QRegion m = wdiface->mask(&wd); 692 QRegion m = wdiface->mask(&wd);
692 QRect br = m.boundingRect(); 693 QRect br = m.boundingRect();
693 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd); 694 int tb = wdiface->metric(WindowDecorationInterface::TopBorder,&wd);
694 int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd); 695 int rb = wdiface->metric(WindowDecorationInterface::RightBorder,&wd);
695 QRegion crgn( br.right()-grab, br.top(), grab, tb ); 696 QRegion crgn( br.right()-grab, br.top(), grab, tb );
696 crgn |= QRect( br.right()-rb, br.top(), rb, grab ); 697 crgn |= QRect( br.right()-rb, br.top(), rb, grab );
697 region = m & crgn; 698 region = m & crgn;
698 } 699 }
699 break; 700 break;
700 case BottomLeft: 701 case BottomLeft:
701 if ( !widget->isMaximized() ) { 702 if ( !widget->isMaximized() ) {
702 QRegion m = wdiface->mask(&wd); 703 QRegion m = wdiface->mask(&wd);
703 QRect br = m.boundingRect(); 704 QRect br = m.boundingRect();
704 region = m & QRect( br.left(), br.bottom()-grab, grab, grab ); 705 region = m & QRect( br.left(), br.bottom()-grab, grab, grab );
705 } 706 }
706 break; 707 break;
707 case BottomRight: 708 case BottomRight:
708 if ( !widget->isMaximized() ) { 709 if ( !widget->isMaximized() ) {
709 QRegion m = wdiface->mask(&wd); 710 QRegion m = wdiface->mask(&wd);
710 QRect br = m.boundingRect(); 711 QRect br = m.boundingRect();
711 region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab ); 712 region = m & QRect( br.right()-grab, br.bottom()-grab, grab, grab );
712 } 713 }
713 break; 714 break;
714 case All: 715 case All:
715 if ( widget->isMaximized() ) 716 if ( widget->isMaximized() )
716 region = QWSDefaultDecoration::region(widget, rect, type); 717 region = QWSDefaultDecoration::region(widget, rect, type);
717 else 718 else
718 region = wdiface->mask(&wd) - rect; 719 region = wdiface->mask(&wd) - rect;
719 break; 720 break;
720 default: 721 default:
721 region = QWSDefaultDecoration::region(widget, rect, type); 722 region = QWSDefaultDecoration::region(widget, rect, type);
722 break; 723 break;
723 } 724 }
724 725
725 return region; 726 return region;
726} 727}
727 728
728void QPEDecoration::paint(QPainter *painter, const QWidget *widget) 729void QPEDecoration::paint(QPainter *painter, const QWidget *widget)
729{ 730{
730 WindowDecorationInterface::WindowData wd; 731 WindowDecorationInterface::WindowData wd;
@@ -801,80 +802,80 @@ void QPEDecoration::paintButton(QPainter *painter, const QWidget *w,
801 windowData( w, wd ); 802 windowData( w, wd );
802 803
803 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd); 804 int titleHeight = wdiface->metric(WindowDecorationInterface::TitleHeight,&wd);
804 QRect rect(w->rect()); 805 QRect rect(w->rect());
805 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight ); 806 QRect tr( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
806 QRect brect(region(w, w->rect(), type).boundingRect()); 807 QRect brect(region(w, w->rect(), type).boundingRect());
807 808
808 const QColorGroup &cg = w->palette().active(); 809 const QColorGroup &cg = w->palette().active();
809 if ( wd.flags & WindowDecorationInterface::WindowData::Active ) 810 if ( wd.flags & WindowDecorationInterface::WindowData::Active )
810 painter->setPen( cg.color(QColorGroup::HighlightedText) ); 811 painter->setPen( cg.color(QColorGroup::HighlightedText) );
811 else 812 else
812 painter->setPen( cg.color(QColorGroup::Text) ); 813 painter->setPen( cg.color(QColorGroup::Text) );
813 814
814 QRegion oldClip = painter->clipRegion(); 815 QRegion oldClip = painter->clipRegion();
815 painter->setClipRegion( QRect(brect.x(), tr.y(), brect.width(), tr.height()) ); // reduce flicker 816 painter->setClipRegion( QRect(brect.x(), tr.y(), brect.width(), tr.height()) ); // reduce flicker
816 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd ); 817 wdiface->drawArea( WindowDecorationInterface::Title, painter, &wd );
817 wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state ); 818 wdiface->drawButton( b, painter, &wd, brect.x(), brect.y(), brect.width(), brect.height(), (QWSButton::State)state );
818 painter->setClipRegion( oldClip ); 819 painter->setClipRegion( oldClip );
819} 820}
820 821
821//#define QPE_DONT_SHOW_TITLEBAR 822//#define QPE_DONT_SHOW_TITLEBAR
822 823
823void QPEDecoration::maximize( QWidget *widget ) 824void QPEDecoration::maximize( QWidget *widget )
824{ 825{
825#ifdef QPE_DONT_SHOW_TITLEBAR 826#ifdef QPE_DONT_SHOW_TITLEBAR
826 if ( !widget->inherits( "QDialog" ) ) { 827 if ( !widget->inherits( "QDialog" ) ) {
827 widget->setGeometry( qt_maxWindowRect ); 828 widget->setGeometry( qt_maxWindowRect );
828 } else 829 } else
829 #endif 830#endif
830 { 831 {
831 QWSDecoration::maximize( widget ); 832 QWSDecoration::maximize( widget );
832 } 833 }
833} 834}
834 835
835#ifndef QT_NO_DIALOG 836#ifndef QT_NO_DIALOG
836class HackDialog : public QDialog 837class HackDialog : public QDialog
837{ 838{
838public: 839public:
839 void acceptIt() { 840 void acceptIt() {
840 if ( isA( "QMessageBox" ) ) 841 if ( isA( "QMessageBox" ) )
841 qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) ); 842 qApp->postEvent( this, new QKeyEvent( QEvent::KeyPress, Key_Enter, '\n', 0, "\n" ) );
842 else 843 else
843 accept(); 844 accept();
844 } 845 }
845}; 846};
846#endif 847#endif
847 848
848 849
849void QPEDecoration::minimize( QWidget *widget ) 850void QPEDecoration::minimize( QWidget *widget )
850{ 851{
851#ifndef QT_NO_DIALOG 852#ifndef QT_NO_DIALOG
852 // We use the minimize button as an "accept" button. 853 // We use the minimize button as an "accept" button.
853 if ( widget->inherits( "QDialog" ) ) { 854 if ( widget->inherits( "QDialog" ) ) {
854 HackDialog *d = (HackDialog *)widget; 855 HackDialog *d = (HackDialog *)widget;
855 d->acceptIt(); 856 d->acceptIt();
856 } 857 }
857#endif 858#endif
858 else if ( ((HackWidget *)widget)->needsOk() ) { 859 else if ( ((HackWidget *)widget)->needsOk() ) {
859 QSignal s; 860 QSignal s;
860 s.connect( widget, SLOT( accept() ) ); 861 s.connect( widget, SLOT( accept() ) );
861 s.activate(); 862 s.activate();
862 } else { 863 } else {
863 help( widget ); 864 help( widget );
864 } 865 }
865} 866}
866 867
867void QPEDecoration::help( QWidget *w ) 868void QPEDecoration::help( QWidget *w )
868{ 869{
869 if ( helpExists ) { 870 if ( helpExists ) {
870 Global::execute( "helpbrowser", helpFile ); 871 Global::execute( "helpbrowser", helpFile );
871 } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) { 872 } else if ( w && w->testWFlags(Qt::WStyle_ContextHelp) ) {
872 QWhatsThis::enterWhatsThisMode(); 873 QWhatsThis::enterWhatsThisMode();
873 QWhatsThis::leaveWhatsThisMode( qApp->tr( 874 QWhatsThis::leaveWhatsThisMode( qApp->tr(
874 "<Qt>Comprehensive help is not available for this application, " 875 "<Qt>Comprehensive help is not available for this application, "
875 "however there is context-sensitive help.<p>To use context-sensitive help:<p>" 876 "however there is context-sensitive help.<p>To use context-sensitive help:<p>"
876 "<ol><li>click and hold the help button." 877 "<ol><li>click and hold the help button."
877 "<li>when the title bar shows <b>What's this...</b>, " 878 "<li>when the title bar shows <b>What's this...</b>, "
878 "click on any control.</ol></Qt>" ) ); 879 "click on any control.</ol></Qt>" ) );
879 } 880 }
880} 881}