kexiframeutils_p.cpp
1/* This file is part of the KDE project
2 Copyright (C) 2005-2006 Jaroslaw Staniek <js@iidea.pl>
3
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this program; see the file COPYING. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20/* This file is included by KexiDBLabel and KexiFrame */
21
23void ClassName::drawFrame( TQPainter *p )
24{
25 if (frameShape() == TQFrame::Box) {
26 if ( frameShadow() == Plain )
27 qDrawPlainRect( p, frameRect(), d->frameColor, lineWidth() );
28 else
29 qDrawShadeRect( p, frameRect(), colorGroup(), frameShadow() == TQFrame::Sunken,
30 lineWidth(), midLineWidth() );
31 }
32 else {
33 SuperClassName::drawFrame(p);
34 }
35}
36
37void ClassName::setPalette( const TQPalette &pal )
38{
39 TQPalette pal2(pal);
40 TQColorGroup cg( pal2.active() );
41 cg.setColor(TQColorGroup::Light, KexiUtils::bleachedColor( d->frameColor, 150 ));
42 cg.setColor(TQColorGroup::Mid, d->frameColor);
43 cg.setColor(TQColorGroup::Dark, d->frameColor.dark(150));
44 pal2.setActive(cg);
45 TQColorGroup cg2( pal2.inactive() );
46 cg2.setColor(TQColorGroup::Light, cg.light() );
47 cg2.setColor(TQColorGroup::Mid, cg.mid());
48 cg2.setColor(TQColorGroup::Dark, cg.dark());
49 pal2.setInactive(cg2);
50 SuperClassName::setPalette(pal2);
51}
52
53const TQColor& ClassName::frameColor() const
54{
55 return d->frameColor;
56}
57
58void ClassName::setFrameColor(const TQColor& color)
59{
60 d->frameColor = color;
61 //update light and dark colors
62 setPalette( palette() );
63}
64
65#if 0
66//todo
67ClassName::Shape ClassName::frameShape() const
68{
69 return d->frameShape;
70}
71
72void ClassName::setFrameShape( ClassName::Shape shape )
73{
74 d->frameShape = shape;
75 update();
76}
77
78ClassName::Shadow ClassName::frameShadow() const
79{
80 return d->frameShadow;
81}
82
83void ClassName::setFrameShadow( ClassName::Shadow shadow )
84{
85 d->frameShadow = shadow;
86 update();
87}
88#endif
89
90#if 0
91void TQFrame::drawFrame( TQPainter *p )
92{
93 TQPoint p1, p2;
94 TQRect r = frameRect();
95 int type = fstyle & MShape;
96 int cstyle = fstyle & MShadow;
97#ifdef TQT_NO_DRAWUTIL
98 p->setPen( black ); // ####
99 p->drawRect( r ); //### a bit too simple
100#else
101 const TQColorGroup & g = colorGroup();
102
103#ifndef TQT_NO_STYLE
104 TQStyleOption opt(lineWidth(),midLineWidth());
105
106 TQStyle::SFlags flags = TQStyle::Style_Default;
107 if (isEnabled())
108 flags |= TQStyle::Style_Enabled;
109 if (cstyle == Sunken)
110 flags |= TQStyle::Style_Sunken;
111 else if (cstyle == Raised)
112 flags |= TQStyle::Style_Raised;
113 if (hasFocus())
114 flags |= TQStyle::Style_HasFocus;
115 if (hasMouse())
116 flags |= TQStyle::Style_MouseOver;
117#endif // TQT_NO_STYLE
118
119 switch ( type ) {
120
121 case Box:
122 if ( cstyle == Plain )
123 qDrawPlainRect( p, r, g.foreground(), lwidth );
124 else
125 qDrawShadeRect( p, r, g, cstyle == Sunken, lwidth,
126 midLineWidth() );
127 break;
128
129 case LineEditPanel:
130 style().drawPrimitive( TQStyle::PE_PanelLineEdit, p, r, g, flags, opt );
131 break;
132
133 case GroupBoxPanel:
134 style().drawPrimitive( TQStyle::PE_PanelGroupBox, p, r, g, flags, opt );
135 break;
136
137 case TabWidgetPanel:
138 style().drawPrimitive( TQStyle::PE_PanelTabWidget, p, r, g, flags, opt );
139 break;
140
141 case MenuBarPanel:
142#ifndef TQT_NO_STYLE
143 style().drawPrimitive(TQStyle::PE_PanelMenuBar, p, r, g, flags, opt);
144 break;
145#endif // fall through to Panel if TQT_NO_STYLE
146
147 case ToolBarPanel:
148#ifndef TQT_NO_STYLE
149 style().drawPrimitive( TQStyle::PE_PanelDockWindow, p, rect(), g, flags, opt);
150 break;
151#endif // fall through to Panel if TQT_NO_STYLE
152
153 case StyledPanel:
154#ifndef TQT_NO_STYLE
155 if ( cstyle == Plain )
156 qDrawPlainRect( p, r, g.foreground(), lwidth );
157 else
158 style().drawPrimitive(TQStyle::PE_Panel, p, r, g, flags, opt);
159 break;
160#endif // fall through to Panel if TQT_NO_STYLE
161
162 case PopupPanel:
163#ifndef TQT_NO_STYLE
164 {
165 int vextra = style().pixelMetric(TQStyle::PM_PopupMenuFrameVerticalExtra, this),
166 hextra = style().pixelMetric(TQStyle::PM_PopupMenuFrameHorizontalExtra, this);
167 if(vextra > 0 || hextra > 0) {
168 TQRect fr = frameRect();
169 int fw = frameWidth();
170 if(vextra > 0) {
171 style().drawControl(TQStyle::CE_PopupMenuVerticalExtra, p, this,
172 TQRect(fr.x() + fw, fr.y() + fw, fr.width() - (fw*2), vextra),
173 g, flags, opt);
174 style().drawControl(TQStyle::CE_PopupMenuVerticalExtra, p, this,
175 TQRect(fr.x() + fw, fr.bottom() - fw - vextra, fr.width() - (fw*2), vextra),
176 g, flags, opt);
177 }
178 if(hextra > 0) {
179 style().drawControl(TQStyle::CE_PopupMenuHorizontalExtra, p, this,
180 TQRect(fr.x() + fw, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
181 g, flags, opt);
182 style().drawControl(TQStyle::CE_PopupMenuHorizontalExtra, p, this,
183 TQRect(fr.right() - fw - hextra, fr.y() + fw + vextra, hextra, fr.height() - (fw*2) - vextra),
184 g, flags, opt);
185 }
186 }
187
188 if ( cstyle == Plain )
189 qDrawPlainRect( p, r, g.foreground(), lwidth );
190 else
191 style().drawPrimitive(TQStyle::PE_PanelPopup, p, r, g, flags, opt);
192 break;
193 }
194#endif // fall through to Panel if TQT_NO_STYLE
195
196 case Panel:
197 if ( cstyle == Plain )
198 qDrawPlainRect( p, r, g.foreground(), lwidth );
199 else
200 qDrawShadePanel( p, r, g, cstyle == Sunken, lwidth );
201 break;
202
203 case WinPanel:
204 if ( cstyle == Plain )
205 qDrawPlainRect( p, r, g.foreground(), wpwidth );
206 else
207 qDrawWinPanel( p, r, g, cstyle == Sunken );
208 break;
209 case HLine:
210 case VLine:
211 if ( type == HLine ) {
212 p1 = TQPoint( r.x(), r.height()/2 );
213 p2 = TQPoint( r.x()+r.width(), p1.y() );
214 }
215 else {
216 p1 = TQPoint( r.x()+r.width()/2, 0 );
217 p2 = TQPoint( p1.x(), r.height() );
218 }
219 if ( cstyle == Plain ) {
220 TQPen oldPen = p->pen();
221 p->setPen( TQPen(g.foreground(),lwidth) );
222 p->drawLine( p1, p2 );
223 p->setPen( oldPen );
224 }
225 else
226 qDrawShadeLine( p, p1, p2, g, cstyle == Sunken,
227 lwidth, midLineWidth() );
228 break;
229 }
230#endif // TQT_NO_DRAWUTIL
231
232#endif
KEXIUTILS_EXPORT TQColor bleachedColor(const TQColor &c, int factor)