summaryrefslogtreecommitdiff
path: root/noncore/styles/liquid/liquiddeco.cpp
authorsandman <sandman>2002-06-30 20:34:40 (UTC)
committer sandman <sandman>2002-06-30 20:34:40 (UTC)
commit8d8081142f19cf697c4a1fe044add4e2db9a36b2 (patch) (unidiff)
tree200b2c26f47cb8b66652414dbc0fa5f96686cc6a /noncore/styles/liquid/liquiddeco.cpp
parent1c6b25945236e3d6e4dd611ec6fc6003d5f87280 (diff)
downloadopie-8d8081142f19cf697c4a1fe044add4e2db9a36b2.zip
opie-8d8081142f19cf697c4a1fe044add4e2db9a36b2.tar.gz
opie-8d8081142f19cf697c4a1fe044add4e2db9a36b2.tar.bz2
ew feature - when liquid is active a new window decoration is set
(this deco is inspired by the classic KDE liquid kwin style)
Diffstat (limited to 'noncore/styles/liquid/liquiddeco.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquiddeco.cpp183
1 files changed, 183 insertions, 0 deletions
diff --git a/noncore/styles/liquid/liquiddeco.cpp b/noncore/styles/liquid/liquiddeco.cpp
new file mode 100644
index 0000000..8eee1b1
--- a/dev/null
+++ b/noncore/styles/liquid/liquiddeco.cpp
@@ -0,0 +1,183 @@
1/**********************************************************************
2** Copyright (C) 2000 Trolltech AS. All rights reserved.
3**
4** This file is part of Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qapplication.h>
22#include <qstyle.h>
23#include <qwidget.h>
24#include <qpainter.h>
25#include <qtimer.h>
26#include <qwhatsthis.h>
27#include <qpe/qcopenvelope_qws.h>
28#include <qpe/qpedecoration_qws.h>
29#include <qdialog.h>
30#include <qdrawutil.h>
31#include <qgfx_qws.h>
32#include <qpe/qpeapplication.h>
33#include <qpe/resource.h>
34#include <qpe/global.h>
35#include <qfile.h>
36#include <qsignal.h>
37
38#include "liquiddeco.h"
39
40#include <stdlib.h>
41
42extern QRect qt_maxWindowRect;
43
44class HackWidget : public QWidget
45{
46public:
47 bool needsOk()
48 {
49 return ( getWState() & WState_Reserved1 );
50 }
51};
52
53
54LiquidDecoration::LiquidDecoration()
55 : QPEDecoration()
56{}
57
58LiquidDecoration::~LiquidDecoration()
59{}
60
61int LiquidDecoration::getTitleHeight( const QWidget * )
62{
63 return 15;
64}
65
66
67void LiquidDecoration::paint( QPainter *painter, const QWidget *widget )
68{
69 int titleWidth = getTitleWidth( widget );
70 int titleHeight = getTitleHeight( widget );
71
72 QRect rect( widget->rect() );
73
74 // Border rect
75 QRect br( rect.left() - BORDER_WIDTH,
76 rect.top() - BORDER_WIDTH - titleHeight,
77 rect.width() + 2 * BORDER_WIDTH,
78 rect.height() + BORDER_WIDTH + BOTTOM_BORDER_WIDTH + titleHeight );
79
80 // title bar rect
81 QRect tr;
82
83 tr = QRect( rect.left(), rect.top() - titleHeight, rect.width(), titleHeight );
84
85 QRegion oldClip = painter->clipRegion();
86 painter->setClipRegion( oldClip - QRegion( tr ) );// reduce flicker
87
88 bool isActive = ( widget == qApp->activeWindow() );
89
90 QColorGroup cg = QApplication::palette().active();
91 if ( isActive )
92 cg. setBrush ( QColorGroup::Button, cg. brush ( QColorGroup::Highlight ) );
93
94 qDrawWinPanel( painter, br.x(), br.y(), br.width(),
95 br.height() - 4, cg, FALSE,
96 &cg.brush( QColorGroup::Background ) );
97
98 painter->setClipRegion( oldClip );
99
100 if ( titleWidth > 0 ) {
101 QBrush titleBrush;
102 QPen titlePen;
103 QPen titleLines;
104 int titleLeft = titleHeight + 4;
105
106 titleLeft = rect.left() + 5;
107 painter->setPen( cg.midlight() );
108 painter->drawLine( rect.left() - BORDER_WIDTH + 2,
109 rect.bottom() + 1, rect.right() + BORDER_WIDTH - 2,
110 rect.bottom() + 1 );
111
112 QRect t ( rect.left() - 2, rect.top() - titleHeight - 2, rect.width() + 3, titleHeight + 2 );
113
114
115
116 QApplication::style().drawBevelButton( painter, t.x(), t.y(), t.width(), t.height(), cg, isActive );
117
118 t.setLeft( t.left() + 4 );
119 t.setRight( t.right() - 2 );
120
121 QFont f( QApplication::font() );
122 f.setWeight( QFont::Bold );
123
124 painter-> setFont( f );
125
126 QColor textcol = cg.color( isActive ? QColorGroup::HighlightedText : QColorGroup::Text );
127 QColor shadecol = ( qGray ( textcol. rgb ( ) ) > 128 ) ? textcol. dark ( 130 ) : textcol.light( 200 );
128
129 if ( textcol == shadecol ) {
130 if ( qGray ( shadecol. rgb ( ) ) < 128 )
131 shadecol = QColor ( 225, 225, 225 );
132 else
133 shadecol = QColor ( 30, 30, 30 );
134 }
135
136 painter-> setPen( shadecol );
137 painter-> drawText( t.x() + 1, t.y() + 1, t.width(), t.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, widget->caption() );
138 painter-> setPen( textcol );
139 painter-> drawText( t.x(), t.y(), t.width(), t.height(), Qt::AlignLeft | Qt::AlignVCenter | Qt::SingleLine, widget->caption() );
140 }
141
142#ifndef MINIMIZE_HELP_HACK
143 paintButton( painter, widget, ( QWSDecoration::Region ) Help, 0 );
144#endif
145}
146
147void LiquidDecoration::paintButton( QPainter *painter, const QWidget *w,
148 QWSDecoration::Region type, int state )
149{
150 const QColorGroup & cg = w->palette().active();
151
152 QRect brect( region( w, w->rect(), type ).boundingRect() );
153
154 const QImage *img = 0;
155
156 switch ( ( int ) type ) {
157 case Close:
158 img = &imageClose;
159 break;
160 case Minimize:
161 if ( ( ( HackWidget * ) w ) ->needsOk() ||
162 ( w->inherits( "QDialog" ) && !w->inherits( "QMessageBox" ) ) )
163 img = &imageOk;
164 else if ( helpExists )
165 img = &imageHelp;
166 break;
167 case Help:
168 img = &imageHelp;
169 break;
170 default:
171 return ;
172 }
173
174 if ( img ) {
175 if ( ( state & QWSButton::MouseOver ) && ( state & QWSButton::Clicked ) )
176 painter->drawImage( brect.x() + 1, brect.y() + 3, *img );
177 else
178 painter->drawImage( brect.x(), brect.y() + 2, *img );
179 }
180}
181
182
183