• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdefx
 

tdefx

  • tdefx
kdrawutil.cpp
1 /* This file is part of the KDE libraries
2  Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 */
18 #include "kdrawutil.h"
19 #include <tqdrawutil.h>
20 
21 TDEFX_EXPORT void kDrawNextButton(TQPainter *p, int x, int y, int w, int h,
22  const TQColorGroup &g, bool sunken,
23  const TQBrush *fill)
24 {
25  TQPen oldPen = p->pen();
26  int x2 = x+w-1;
27  int y2 = y+h-1;
28  p->fillRect(x+1, y+1, w-2, h-2,
29  fill ? *fill : g.brush(TQColorGroup::Button));
30  p->setPen(sunken ? TQt::black : g.light());
31  p->drawLine(x, y, x2-1, y);
32  p->drawLine(x, y, x, y2-1);
33  p->setPen(sunken ? g.midlight() : g.mid());
34  p->drawLine(x+1, y2-1, x2-1, y2-1);
35  p->drawLine(x2-1, y+1, x2-1, y2-1);
36  p->setPen(sunken ? g.light() : TQt::black);
37  p->drawLine(x, y2, x2, y2);
38  p->drawLine(x2, y, x2, y2);
39  p->setPen(oldPen);
40 }
41 
42 
43 TDEFX_EXPORT void kDrawNextButton(TQPainter *p, const TQRect &r, const TQColorGroup &g,
44  bool sunken, const TQBrush *fill)
45 {
46  kDrawNextButton(p, r.x(), r.y(), r.width(), r.height(), g, sunken, fill);
47 }
48 
49 TDEFX_EXPORT void kDrawBeButton(TQPainter *p, int x, int y, int w, int h,
50  const TQColorGroup &g, bool sunken, const TQBrush *fill)
51 {
52  TQPen oldPen = p->pen();
53  int x2 = x+w-1;
54  int y2 = y+h-1;
55  p->setPen(g.dark());
56  p->drawLine(x+1, y, x2-1, y);
57  p->drawLine(x, y+1, x, y2-1);
58  p->drawLine(x+1, y2, x2-1, y2);
59  p->drawLine(x2, y+1, x2, y2-1);
60 
61 
62  if(!sunken){
63  p->setPen(g.light());
64  p->drawLine(x+2, y+2, x2-1, y+2);
65  p->drawLine(x+2, y+3, x2-2, y+3);
66  p->drawLine(x+2, y+4, x+2, y2-1);
67  p->drawLine(x+3, y+4, x+3, y2-2);
68  }
69  else{
70  p->setPen(g.mid());
71  p->drawLine(x+2, y+2, x2-1, y+2);
72  p->drawLine(x+2, y+3, x2-2, y+3);
73  p->drawLine(x+2, y+4, x+2, y2-1);
74  p->drawLine(x+3, y+4, x+3, y2-2);
75  }
76 
77 
78  p->setPen(sunken? g.light() : g.mid());
79  p->drawLine(x2-1, y+2, x2-1, y2-1);
80  p->drawLine(x+2, y2-1, x2-1, y2-1);
81 
82  p->setPen(g.mid());
83  p->drawLine(x+1, y+1, x2-1, y+1);
84  p->drawLine(x+1, y+2, x+1, y2-1);
85  p->drawLine(x2-2, y+3, x2-2, y2-2);
86 
87  if(fill)
88  p->fillRect(x+4, y+4, w-6, h-6, *fill);
89 
90  p->setPen(oldPen);
91 }
92 
93 TDEFX_EXPORT void kDrawBeButton(TQPainter *p, TQRect &r, const TQColorGroup &g, bool sunken,
94  const TQBrush *fill)
95 {
96  kDrawBeButton(p, r.x(), r.y(), r.width(), r.height(), g, sunken, fill);
97 }
98 
99 TDEFX_EXPORT void kDrawRoundButton(TQPainter *p, const TQRect &r, const TQColorGroup &g,
100  bool sunken)
101 {
102  int x, y, x2, y2;
103  r.coords(&x, &y, &x2, &y2);
104  if(r.width() > 16 && r.height() > 16){
105  TQPen oldPen = p->pen();
106  TQPointArray hPntArray, lPntArray;
107  hPntArray.putPoints(0, 12, x+4,y+1, x+5,y+1, // top left
108  x+3,y+2, x+2,y+3, x+1,y+4, x+1,y+5,
109  x+1,y2-5, x+1,y2-4, x+2,y2-3, // half corners
110  x2-5,y+1, x2-4,y+1, x2-3,y+2);
111 
112  lPntArray.putPoints(0, 17, x2-5,y2-1, x2-4,y2-1, // btm right
113  x2-3,y2-2, x2-2,y2-3, x2-1,y2-5, x2-1,y2-4,
114 
115  x+3,y2-2, x+4,y2-1, x+5,y2-1, //half corners
116  x2-2,y+3, x2-1,y+4, x2-1,y+5,
117 
118  x2-5,y2-2, x2-4,y2-2, // testing
119  x2-3,y2-3,
120  x2-2,y2-5, x2-2,y2-4);
121 
122  p->setPen(sunken ? g.dark() : g.light());
123  p->drawLine(x+6, y, x2-6, y);
124  p->drawLine(0, y+6, 0, y2-6);
125  p->drawPoints(hPntArray);
126 
127  p->setPen(sunken ? g.light() : g.dark());
128  p->drawLine(x+6, y2, x2-6, y2);
129  p->drawLine(x+6, y2-1, x2-6, y2-1);
130  p->drawLine(x2, y+6, x2, y2-6);
131  p->drawLine(x2-1, y+6, x2-1, y2-6);
132  p->drawPoints(lPntArray);
133  p->setPen(oldPen);
134  }
135  else
136  qDrawWinPanel(p, x, y, r.width(), r.height(), g, sunken);
137 }
138 
139 TDEFX_EXPORT void kDrawRoundButton(TQPainter *p, int x, int y, int w, int h,
140  const TQColorGroup &g, bool sunken)
141 {
142  TQRect r(x, y, w, h);
143  kDrawRoundButton(p, r, g, sunken);
144 }
145 
146 #define QCOORDARRLEN(x) sizeof(x)/(sizeof(TQCOORD)*2)
147 
148 TDEFX_EXPORT void kDrawRoundMask(TQPainter *p, int x, int y, int w, int h, bool clear)
149 {
150  // round edge fills
151  static const TQCOORD btm_left_fill[]={ 0,0,1,0,2,0,3,0,4,0,0,1,1,1,2,1,3,1,4,1,
152  1,2,2,2,3,2,4,2,2,3,3,3,4,3,3,4,4,4 };
153 
154  static const TQCOORD btm_right_fill[]={ 0,0,1,0,2,0,3,0,4,0,0,1,1,1,2,1,3,1,4,
155  1,0,2,1,2,2,2,3,2,0,3,1,3,2,3,0,4,1,4 };
156 
157  static const TQCOORD top_left_fill[]={ 3,0,4,0,2,1,3,1,4,1,1,2,2,2,3,2,4,2,0,3,
158  1,3,2,3,3,3,4,3,0,4,1,4,2,4,3,4,4,4 };
159 
160  static const TQCOORD top_right_fill[]={ 0,0,1,0,0,1,1,1,2,1,0,2,1,2,2,2,3,2,0,
161  3,1,3,2,3,3,3,4,3,0,4,1,4,2,4,3,4,4,4 };
162 
163  if(clear)
164  p->fillRect(x, y, w, h, TQBrush(TQt::color0, TQt::SolidPattern));
165 
166  TQBrush fillBrush(TQt::color1, TQt::SolidPattern);
167  p->setPen(TQt::color1);
168  if(w > 16 && h > 16){
169  int x2 = x+w-1;
170  int y2 = y+h-1;
171  TQPointArray a(QCOORDARRLEN(top_left_fill), top_left_fill);
172  a.translate(1, 1);
173  p->drawPoints(a);
174  a.setPoints(QCOORDARRLEN(btm_left_fill), btm_left_fill);
175  a.translate(1, h-6);
176  p->drawPoints(a);
177  a.setPoints(QCOORDARRLEN(top_right_fill), top_right_fill);
178  a.translate(w-6, 1);
179  p->drawPoints(a);
180  a.setPoints(QCOORDARRLEN(btm_right_fill), btm_right_fill);
181  a.translate(w-6, h-6);
182  p->drawPoints(a);
183 
184  p->fillRect(x+6, y, w-12, h, fillBrush);
185  p->fillRect(x, y+6, x+6, h-12, fillBrush);
186  p->fillRect(x2-6, y+6, x2, h-12, fillBrush);
187  p->drawLine(x+6, y, x2-6, y);
188  p->drawLine(x+6, y2, x2-6, y2);
189  p->drawLine(x, y+6, x, y2-6);
190  p->drawLine(x2, y+6, x2, y2-6);
191 
192  }
193  else
194  p->fillRect(x, y, w, h, fillBrush);
195 }
196 
197 TDEFX_EXPORT void kRoundMaskRegion(TQRegion &r, int x, int y, int w, int h)
198 {
199  // using a bunch of TQRect lines seems much more efficient than bitmaps or
200  // point arrays, even tho it uses more statements
201  r += TQRect(x+6, y+0, w-12, h);
202  r += TQRect(x+5, y+1, 1, h-2); // left
203  r += TQRect(x+4, y+1, 1, h-2);
204  r += TQRect(x+3, y+2, 1, h-4);
205  r += TQRect(x+2, y+3, 1, h-6);
206  r += TQRect(x+1, y+4, 1, h-8);
207  r += TQRect(x, y+6, 1, h-12);
208  int x2 = x+w-1;
209  r += TQRect(x2-5, y+1, 1, h-2); // right
210  r += TQRect(x2-4, y+1, 1, h-2);
211  r += TQRect(x2-3, y+2, 1, h-4);
212  r += TQRect(x2-2, y+3, 1, h-6);
213  r += TQRect(x2-1, y+4, 1, h-8);
214  r += TQRect(x2, y+6, 1, h-12);
215 }
216 
217 TDEFX_EXPORT void kColorBitmaps(TQPainter *p, const TQColorGroup &g, int x, int y,
218  TQBitmap *lightColor, TQBitmap *midColor,
219  TQBitmap *midlightColor, TQBitmap *darkColor,
220  TQBitmap *blackColor, TQBitmap *whiteColor)
221 {
222  TQBitmap *bitmaps[]={lightColor, midColor, midlightColor, darkColor,
223  blackColor, whiteColor};
224 
225  TQColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
226  TQt::black, TQt::white};
227 
228  int i;
229  for(i=0; i < 6; ++i){
230  if(bitmaps[i]){
231  if(!bitmaps[i]->mask())
232  bitmaps[i]->setMask(*bitmaps[i]);
233  p->setPen(colors[i]);
234  p->drawPixmap(x, y, *bitmaps[i]);
235  }
236  }
237 }
238 
239 TDEFX_EXPORT void kColorBitmaps(TQPainter *p, const TQColorGroup &g, int x, int y, int w,
240  int h, bool isXBitmaps, const uchar *lightColor,
241  const uchar *midColor, const uchar *midlightColor,
242  const uchar *darkColor, const uchar *blackColor,
243  const uchar *whiteColor)
244 {
245  const uchar *data[]={lightColor, midColor, midlightColor, darkColor,
246  blackColor, whiteColor};
247 
248  TQColor colors[]={g.light(), g.mid(), g.midlight(), g.dark(),
249  TQt::black, TQt::white};
250 
251  int i;
252  TQBitmap b;
253  for(i=0; i < 6; ++i){
254  if(data[i]){
255  b = TQBitmap(w, h, data[i], isXBitmaps);
256  b.setMask(b);
257  p->setPen(colors[i]);
258  p->drawPixmap(x, y, b);
259  }
260  }
261 }
262 
263 
264 
TDEStyle::kRoundMaskRegion
TDEFX_EXPORT void kRoundMaskRegion(TQRegion &r, int x, int y, int w, int h)
#include <kdrawutil.h>
Definition: kdrawutil.cpp:197
TDEStyle::kDrawRoundButton
TDEFX_EXPORT void kDrawRoundButton(TQPainter *p, const TQRect &r, const TQColorGroup &g, bool sunken=false)
#include <kdrawutil.h>
Definition: kdrawutil.cpp:99
TDEStyle::kDrawRoundMask
TDEFX_EXPORT void kDrawRoundMask(TQPainter *p, int x, int y, int w, int h, bool clear=false)
#include <kdrawutil.h>
Definition: kdrawutil.cpp:148
TDEStyle::kDrawNextButton
TDEFX_EXPORT void kDrawNextButton(TQPainter *p, const TQRect &r, const TQColorGroup &g, bool sunken=false, const TQBrush *fill=0)
#include <kdrawutil.h>
Definition: kdrawutil.cpp:43
TDEStyle::kColorBitmaps
TDEFX_EXPORT void kColorBitmaps(TQPainter *p, const TQColorGroup &g, int x, int y, TQBitmap *lightColor=0, TQBitmap *midColor=0, TQBitmap *midlightColor=0, TQBitmap *darkColor=0, TQBitmap *blackColor=0, TQBitmap *whiteColor=0)
#include <kdrawutil.h>
Definition: kdrawutil.cpp:217
TDEStyle::kDrawBeButton
TDEFX_EXPORT void kDrawBeButton(TQPainter *p, TQRect &r, const TQColorGroup &g, bool sunken=false, const TQBrush *fill=0)
#include <kdrawutil.h>
Definition: kdrawutil.cpp:93

tdefx

Skip menu "tdefx"
  • Main Page
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdefx

Skip menu "tdefx"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdefx by doxygen 1.9.1
This website is maintained by Timothy Pearson.