QtCurve widget style for TDE
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

8775 lines
352 KiB

  1. /*
  2. QtCurve (C) Craig Drummond, 2003 - 2010 craig.p.drummond@gmail.com
  3. ----
  4. Based upon B???Curve style (Copyright (c) 2002 R?d H?t, Inc)
  5. Bernhard Rosenkrazer <bero@r?dh?t.com>
  6. Preston Brown <pbrown@r?dh?t.com>
  7. Than Ngo <than@r?dh?t.com>
  8. This program is free software; you can redistribute it and/or
  9. modify it under the terms of the GNU General Public
  10. License version 2 as published by the Free Software Foundation.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; see the file COPYING. If not, write to
  17. the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18. Boston, MA 02110-1301, USA.
  19. ----
  20. B???Curve is based on the KDE Light style, 2nd revision:
  21. Copyright(c)2000-2001 Trolltech AS (info@trolltech.com). The light style
  22. license is as follows:
  23. Permission is hereby granted, free of charge, to any person obtaining a
  24. copy of this software and associated documentation files(the "Software"),
  25. to deal in the Software without restriction, including without limitation
  26. the rights to use, copy, modify, merge, publish, distribute, sublicense,
  27. and/or sell copies of the Software, and to permit persons to whom the
  28. Software is furnished to do so, subject to the following conditions:
  29. The above copyright notice and this permission notice shall be included in
  30. all copies or substantial portions of the Software.
  31. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  32. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  33. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  34. THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  35. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  36. FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  37. DEALINGS IN THE SOFTWARE.
  38. */
  39. /*
  40. KHTML
  41. -----
  42. Srollbars:
  43. For some reason Scrollbars in KHTML seem to lose the bottom/left pixels. As if KHTML expects
  44. the scrollbar to be 1 pixel smaller/thinner than it actually is. To 'fix' this, the pixelMetric
  45. function will return 1 scrollbar with 1 greater than standard for form widgets, or where widget==0L
  46. In the CC_ScrollBar draw code, the rects used for each component are shrunk by 1, in the appropriate
  47. dimension, so as to draw the scrollbar at the correct size.
  48. */
  49. #include <tqtable.h>
  50. #include "config.h"
  51. #ifndef TQTC_TQT_ONLY
  52. #include <tdeversion.h>
  53. #endif
  54. #include <tqsettings.h>
  55. #include <tqmenubar.h>
  56. #include <tqapplication.h>
  57. #include <tqpainter.h>
  58. #include <tqpalette.h>
  59. #include <tqframe.h>
  60. #include <tqpushbutton.h>
  61. #include <tqdrawutil.h>
  62. #include <tqscrollbar.h>
  63. #include <tqtabbar.h>
  64. #include <tqtabwidget.h>
  65. #include <tqlineedit.h>
  66. #include <tqlistview.h>
  67. #include <tqtable.h>
  68. #include <tqimage.h>
  69. #include <tqcombobox.h>
  70. #include <tqslider.h>
  71. #include <tqcleanuphandler.h>
  72. #include <tqcheckbox.h>
  73. #include <tqradiobutton.h>
  74. #include <tqtoolbutton.h>
  75. #include <tqtoolbar.h>
  76. #include <tqprogressbar.h>
  77. #include <tqheader.h>
  78. #include <tqwidgetstack.h>
  79. #include <tqsplitter.h>
  80. #include <tqtextedit.h>
  81. #include <tqlabel.h>
  82. #include <tqlistbox.h>
  83. #include <tqhbox.h>
  84. #include <tqvbox.h>
  85. #include <tqtimer.h>
  86. #include <tqdatetimeedit.h>
  87. #include <tqobjectlist.h>
  88. #include <tqpixmapcache.h>
  89. #include <tqbitmap.h>
  90. #include <tqmainwindow.h>
  91. #include <tqstyle.h>
  92. #include <math.h>
  93. #include <stdlib.h>
  94. #include <unistd.h>
  95. #include <sys/types.h>
  96. #include <iostream>
  97. #define COMMON_FUNCTIONS
  98. #include "qtcurve.h"
  99. #define CONFIG_READ
  100. #include "config_file.c"
  101. #include "pixmaps.h"
  102. #include <tqdialog.h>
  103. #include <tqprogressdialog.h>
  104. #include <tqstyleplugin.h>
  105. #include <tqgroupbox.h>
  106. #include <tqdir.h>
  107. // Need access to classname from within TQMetaObject...
  108. #define private public
  109. #include <tqmetaobject.h>
  110. #include <X11/Xlib.h>
  111. #include <X11/Xatom.h>
  112. #include "qtc_fixx11h.h"
  113. #ifndef HAVE_REAL_TQT
  114. #define TQTitleBar QTitleBar
  115. #endif
  116. static const Atom constNetMoveResize = XInternAtom(tqt_xdisplay(), "_NET_WM_MOVERESIZE", False);
  117. static const TQWidget * getTopLevel(const TQWidget *widget)
  118. {
  119. const TQWidget *w=widget;
  120. while(w && !w->isTopLevel())
  121. w=w->parentWidget();
  122. return w;
  123. }
  124. static void emitMenuSize(const TQWidget *widget, unsigned short size)
  125. {
  126. const TQWidget *w=getTopLevel(widget);
  127. if(w)
  128. {
  129. static const Atom constAtom = XInternAtom(tqt_xdisplay(), MENU_SIZE_ATOM, False);
  130. XChangeProperty(tqt_xdisplay(), w->parentWidget() ? w->parentWidget()->winId() : w->winId(),
  131. constAtom, XA_CARDINAL, 16, PropModeReplace, (unsigned char *)&size, 1);
  132. }
  133. }
  134. void setBgndProp(TQWidget *widget, unsigned short app)
  135. {
  136. const TQWidget *w=getTopLevel(widget);
  137. if(w)
  138. {
  139. static const Atom constAtom = XInternAtom(tqt_xdisplay(), BGND_ATOM, False);
  140. XChangeProperty(tqt_xdisplay(), w->parentWidget() ? w->parentWidget()->winId() : w->winId(),
  141. constAtom, XA_CARDINAL, 16, PropModeReplace, (unsigned char *)&app, 1);
  142. }
  143. }
  144. static void triggerWMMove(const TQWidget *w, const TQPoint &p)
  145. {
  146. //...Taken from bespin...
  147. // stolen... errr "adapted!" from TQSizeGrip
  148. XEvent xev;
  149. xev.xclient.type = ClientMessage;
  150. xev.xclient.message_type = constNetMoveResize;
  151. xev.xclient.display = tqt_xdisplay();
  152. xev.xclient.window = w->parentWidget() ? w->parentWidget()->winId() : w->winId();
  153. xev.xclient.format = 32;
  154. xev.xclient.data.l[0] = p.x();
  155. xev.xclient.data.l[1] = p.y();
  156. xev.xclient.data.l[2] = 8; // NET::Move
  157. xev.xclient.data.l[3] = Button1;
  158. xev.xclient.data.l[4] = 0;
  159. XUngrabPointer(tqt_xdisplay(), CurrentTime);
  160. XSendEvent(tqt_xdisplay(), tqt_xrootwin(), False,
  161. SubstructureRedirectMask | SubstructureNotifyMask, &xev);
  162. }
  163. #define MO_ARROW_X(FLAGS, COL) (MO_NONE!=opts.coloredMouseOver && FLAGS&Style_MouseOver && FLAGS&Style_Enabled ? itsMouseOverCols[ARROW_MO_SHADE] : COL)
  164. #define MO_ARROW(COL) MO_ARROW_X(flags, COL)
  165. static const int constMenuPixmapWidth=22;
  166. static bool useTQt3Settings()
  167. {
  168. static int ver=0;
  169. if(0==ver)
  170. {
  171. const char *sessionVersion=getenv("TDE_SESSION_VERSION");
  172. ver=sessionVersion
  173. ? atoi(sessionVersion)<4
  174. ? 3
  175. : 4
  176. #ifdef TQTC_DEFAULT_TO_KDE3
  177. : 3;
  178. #else
  179. : getenv("TDE_FULL_SESSION")
  180. ? 3
  181. : 4;
  182. #endif
  183. }
  184. return 3==ver;
  185. }
  186. static TQRect adjusted(const TQRect r, int xp1, int yp1, int xp2, int yp2)
  187. {
  188. int x1, y1, x2, y2;
  189. r.coords(&x1, &y1, &x2, &y2);
  190. return TQRect(TQPoint(x1 + xp1, y1 + yp1), TQPoint(x2 + xp2, y2 + yp2));
  191. }
  192. static void adjust(TQRect &r, int dx1, int dy1, int dx2, int dy2)
  193. {
  194. int x1, y1, x2, y2;
  195. r.coords(&x1, &y1, &x2, &y2);
  196. x1 += dx1;
  197. y1 += dy1;
  198. x2 += dx2;
  199. y2 += dy2;
  200. r.setCoords(x1, y1, x2, y2);
  201. }
  202. inline bool isSpecialHover(TQWidget *w)
  203. {
  204. return w && (
  205. #if 0x039999 >= 0x030200
  206. ::tqqt_cast<TQRadioButton *>(w) ||
  207. ::tqqt_cast<TQCheckBox *>(w) ||
  208. #endif
  209. ::tqqt_cast<TQScrollBar *>(w) ||
  210. #if defined TDE_VERSION && TDE_VERSION >= 0x30400 && TDE_VERSION < 0x30500
  211. ::tqqt_cast<TQToolButton *>(w) ||
  212. #endif
  213. ::tqqt_cast<TQHeader *>(w) ||
  214. ::tqqt_cast<TQSpinWidget *>(w) ||
  215. ::tqqt_cast<TQComboBox *>(w) ||
  216. ::tqqt_cast<TQTabBar *>(w)
  217. );
  218. }
  219. static TQString readEnvPath(const char *env)
  220. {
  221. TQCString path=getenv(env);
  222. return path.isEmpty() ? TQString() : TQFile::decodeName(path);
  223. }
  224. static TQString kdeHome(bool trinity=false)
  225. {
  226. static TQString kdeHome[2];
  227. // Execute tde-config to ascertain users TDEHOME
  228. if(kdeHome[trinity ? 0 : 1].isEmpty())
  229. {
  230. FILE *fpipe;
  231. if ((fpipe = (FILE*)popen(trinity ? "tde-config --localprefix 2> /dev/null" : "kde4-config --localprefix 2> /dev/null", "r")))
  232. {
  233. char line[1024];
  234. while(fgets(line, sizeof line, fpipe))
  235. {
  236. kdeHome[trinity ? 0 : 1]=TQString(TQFile::decodeName(line)).replace("\n", "");
  237. break;
  238. }
  239. pclose(fpipe);
  240. }
  241. }
  242. // Try env vars...
  243. if(kdeHome[trinity ? 0 : 1].isEmpty())
  244. {
  245. kdeHome[trinity ? 0 : 1]=readEnvPath(getuid() ? "TDEHOME" : "TDEROOTHOME");
  246. if (kdeHome[trinity ? 0 : 1].isEmpty())
  247. {
  248. TQDir homeDir(TQDir::homeDirPath());
  249. TQString kdeConfDir("/.kde");
  250. if (!trinity && homeDir.exists(".kde4"))
  251. kdeConfDir = TQString("/.kde4");
  252. kdeHome[trinity ? 0 : 1] = TQDir::homeDirPath() + kdeConfDir;
  253. }
  254. }
  255. return kdeHome[trinity ? 0 : 1];
  256. }
  257. #ifdef TQTC_STYLE_SUPPORT
  258. static void getStyles(const TQString &dir, const char *sub, TQStringList &styles)
  259. {
  260. TQDir d(dir+sub);
  261. if(d.exists())
  262. {
  263. d.setNameFilter(THEME_PREFIX"*"THEME_SUFFIX);
  264. TQStringList entries(d.entryList());
  265. TQStringList::ConstIterator it(entries.begin()),
  266. end(entries.end());
  267. for(; it!=end; ++it)
  268. {
  269. TQString style((*it).left((*it).findRev(THEME_SUFFIX)));
  270. if(!styles.contains(style))
  271. styles.append(style);
  272. }
  273. }
  274. }
  275. static void getStyles(const TQString &dir, TQStringList &styles)
  276. {
  277. getStyles(dir, THEME_DIR, styles);
  278. getStyles(dir, THEME_DIR4, styles);
  279. }
  280. static TQString themeFile(const TQString &dir, const TQString &n, const char *sub)
  281. {
  282. TQString name(dir+sub+n+THEME_SUFFIX);
  283. return TQFile(name).exists() ? name : TQString();
  284. }
  285. static TQString themeFile(const TQString &dir, const TQString &n, bool trinity=true)
  286. {
  287. TQString name(themeFile(dir, n, trinity ? THEME_DIR : THEME_DIR4));
  288. if(name.isEmpty())
  289. name=themeFile(dir, n, trinity ? THEME_DIR4 : THEME_DIR);
  290. return name;
  291. }
  292. #endif
  293. class QtCurveStylePlugin : public TQStylePlugin
  294. {
  295. public:
  296. QtCurveStylePlugin() : TQStylePlugin() { }
  297. TQStringList keys() const
  298. {
  299. TQStringList list;
  300. list << "QtCurve";
  301. #ifdef TQTC_STYLE_SUPPORT
  302. getStyles(kdeHome(useTQt3Settings()), list);
  303. getStyles(kdeHome(!useTQt3Settings()), list);
  304. getStyles(KDE_PREFIX(useTQt3Settings() ? 3 : 4), list);
  305. getStyles(KDE_PREFIX(useTQt3Settings() ? 4 : 3), list);
  306. #endif
  307. return list;
  308. }
  309. TQStyle * create(const TQString &s)
  310. {
  311. return "qtcurve"==s.lower()
  312. ? new QtCurveStyle
  313. #ifdef TQTC_STYLE_SUPPORT
  314. : 0==s.find(THEME_PREFIX)
  315. ? new QtCurveStyle(s)
  316. #endif
  317. : 0;
  318. }
  319. };
  320. TQ_EXPORT_PLUGIN(QtCurveStylePlugin)
  321. #define SKIP_TASKBAR (APP_SKIP_TASKBAR==itsThemedApp || APP_KPRINTER==itsThemedApp || APP_KDIALOG==itsThemedApp)
  322. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  323. #include <tqfile.h>
  324. #endif
  325. #define NO_SECT -1
  326. #define VERTICAL_TB_BUTTON 0x01000000
  327. #define CHECK_BUTTON 0x02000000
  328. #define STD_TOOLBUTTON 0x04000000
  329. #define TOGGLE_BUTTON 0x08000000
  330. #define NO_ETCH_BUTTON 0x10000000
  331. #define DW_CLOSE_BUTTON 0x80000000
  332. #define LISTVIEW_ITEM 0x20000000
  333. #define MENU_ITEM 0x40000000
  334. #define WINDOWTITLE_SPACER 0x10000000
  335. #define DW_BGND 105
  336. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  337. // Try to read $TDEHOME/share/config/kickerrc to find out if kicker is transparent...
  338. static bool kickerIsTrans()
  339. {
  340. TQString cfgFileName(kdeHome(true)+"/share/config/kickerrc");
  341. bool trans(false);
  342. TQFile cfgFile(cfgFileName);
  343. if (cfgFile.open(IO_ReadOnly))
  344. {
  345. TQTextStream stream(&cfgFile);
  346. TQString line;
  347. bool stop(false),
  348. inGen(false);
  349. while (!stream.atEnd() && !stop)
  350. {
  351. line=stream.readLine();
  352. if(inGen)
  353. {
  354. if(0==line.find("Transparent=", false)) // Found it!
  355. {
  356. if(-1!=line.find("true", false))
  357. trans=true;
  358. stop=true;
  359. }
  360. else if(line[0]==TQChar('[')) // Then wasn't in General section...
  361. stop=true;
  362. }
  363. else if(0==line.find("[General]", false))
  364. inGen=true;
  365. }
  366. cfgFile.close();
  367. }
  368. return trans;
  369. }
  370. #endif
  371. static bool isKhtmlWidget(const TQWidget *w, int level=1)
  372. {
  373. return w && ((w->name() && 0==strcmp(w->name(), "__khtml")) ||
  374. (level && isKhtmlWidget(w->parentWidget(), --level)));
  375. }
  376. static bool isKhtmlFormWidget(const TQWidget *widget)
  377. {
  378. if(isKhtmlWidget(widget))
  379. return true;
  380. // Copied from Keramik...
  381. //Form widgets are in the KHTMLView, but that has 2 further inner levels
  382. //of widgets - TQClipperWidget, and outside of that, TQViewportWidget
  383. TQWidget *potentialClipPort(widget ? widget->parentWidget() : 0L);
  384. if (!potentialClipPort || potentialClipPort->isTopLevel())
  385. return false;
  386. TQWidget *potentialViewPort(potentialClipPort->parentWidget());
  387. if (!potentialViewPort || potentialViewPort->isTopLevel() ||
  388. qstrcmp(potentialViewPort->name(), "qt_viewport"))
  389. return false;
  390. TQWidget *potentialKHTML(potentialViewPort->parentWidget());
  391. if (!potentialKHTML || potentialKHTML->isTopLevel() ||
  392. qstrcmp(potentialKHTML->className(), "KHTMLView"))
  393. return false;
  394. return true;
  395. }
  396. static bool inStackWidget(const TQWidget *w)
  397. {
  398. while(w)
  399. {
  400. if(::tqqt_cast<const TQTabWidget *>(w))
  401. return true;
  402. w=w->parentWidget();
  403. }
  404. return false;
  405. }
  406. static void setRgb(TQColor *col, const TQStringList &rgb)
  407. {
  408. if(3==rgb.size())
  409. *col=TQColor(rgb[0].toInt(), rgb[1].toInt(), rgb[2].toInt());
  410. }
  411. struct KDESettings
  412. {
  413. KDESettings()
  414. {
  415. inactiveHighlight=false;
  416. }
  417. bool inactiveHighlight;
  418. TQColor hover,
  419. focus;
  420. };
  421. static KDESettings kdeSettings;
  422. static bool readKdeGlobals()
  423. {
  424. static int lastCheck=0;
  425. int now=time(0L);
  426. // Dont keep on reading kdeglobals file - only read if its been at least 2 seconds since the last time...
  427. if(abs(now-lastCheck)<3)
  428. return false;
  429. TQColor highlight(TQApplication::palette().active().highlight());
  430. bool inactiveEnabled(false),
  431. changeSelectionColor(false),
  432. useTQt3(useTQt3Settings());
  433. TQFile f(kdeHome(useTQt3)+"/share/config/kdeglobals");
  434. lastCheck=now;
  435. if(useTQt3)
  436. kdeSettings.hover=kdeSettings.focus=highlight;
  437. else
  438. {
  439. kdeSettings.hover=TQColor(119, 183, 255);
  440. kdeSettings.focus=TQColor( 43, 116, 199);
  441. }
  442. if(f.open(IO_ReadOnly))
  443. {
  444. TQTextStream in(&f);
  445. bool inPal(false),
  446. inInactive(false),
  447. donePal(useTQt3),
  448. doneInactive(false);
  449. while (!in.atEnd() && (!donePal || !doneInactive))
  450. {
  451. TQString line(in.readLine());
  452. if(inPal)
  453. {
  454. if(0==line.find("DecorationFocus=", false))
  455. setRgb(&kdeSettings.focus, TQStringList::split(",", line.mid(16)));
  456. else if(0==line.find("DecorationHover=", false))
  457. setRgb(&kdeSettings.hover, TQStringList::split(",", line.mid(16)));
  458. else if (-1!=line.find('['))
  459. {
  460. donePal=true;
  461. inPal=false;
  462. }
  463. }
  464. else if(inInactive)
  465. {
  466. if(0==line.find("ChangeSelectionColor=", false))
  467. changeSelectionColor=line.find("=true");
  468. else if(0==line.find("Enable=", false))
  469. inactiveEnabled=line.find("=true");
  470. else if (-1!=line.find('['))
  471. {
  472. doneInactive=true;
  473. inInactive=false;
  474. }
  475. }
  476. if(!inPal && !inInactive) {
  477. if(!useTQt3 && 0==line.find("[Colors:Button]", false)) {
  478. inPal=true;
  479. }
  480. else if(!useTQt3 && 0==line.find("[ColorEffects:Inactive]", false)) {
  481. inInactive=true;
  482. }
  483. }
  484. }
  485. f.close();
  486. }
  487. kdeSettings.inactiveHighlight=changeSelectionColor && inactiveEnabled;
  488. return true;
  489. }
  490. static void drawLines(TQPainter *p, const TQRect &r, bool horiz, int nLines, int offset,
  491. const TQColor *cols, int startOffset, int dark, ELine type)
  492. {
  493. int space((nLines*2)+(LINE_DASHES!=type ? (nLines-1) : 0)),
  494. step(LINE_DASHES!=type ? 3 : 2),
  495. etchedDisp(LINE_SUNKEN==type ? 1 : 0),
  496. x(horiz ? r.x(): r.x()+((r.width()-space)>>1)),
  497. y(horiz ? r.y()+((r.height()-space)>>1): r.y()),
  498. x2(r.x()+r.width()-1),
  499. y2(r.y()+r.height()-1),
  500. i;
  501. if(horiz)
  502. {
  503. if(startOffset && y+startOffset>0)
  504. y+=startOffset;
  505. p->setPen(cols[dark]);
  506. for(i=0; i<space; i+=step)
  507. p->drawLine(x+offset, y+i, x2-offset, y+i);
  508. if(LINE_FLAT!=type)
  509. {
  510. x+=etchedDisp;
  511. x2+=etchedDisp;
  512. p->setPen(cols[0]);
  513. for(i=1; i<space; i+=step)
  514. p->drawLine(x+offset, y+i, x2-offset, y+i);
  515. }
  516. }
  517. else
  518. {
  519. if(startOffset && x+startOffset>0)
  520. x+=startOffset;
  521. p->setPen(cols[dark]);
  522. for(i=0; i<space; i+=step)
  523. p->drawLine(x+i, y+offset, x+i, y2-offset);
  524. if(LINE_FLAT!=type)
  525. {
  526. y+=etchedDisp;
  527. y2+=etchedDisp;
  528. p->setPen(cols[0]);
  529. for(i=1; i<space; i+=step)
  530. p->drawLine(x+i, y+offset, x+i, y2-offset);
  531. }
  532. }
  533. }
  534. static void drawDots(TQPainter *p, const TQRect &r, bool horiz, int nLines, int offset,
  535. const TQColor *cols, int startOffset, int dark)
  536. {
  537. int space((nLines*2)+(nLines-1)),
  538. x(horiz ? r.x() : r.x()+((r.width()-space)>>1)),
  539. y(horiz ? r.y()+((r.height()-space)>>1) : r.y()),
  540. i, j,
  541. numDots((horiz ? (r.width()-(2*offset))/3 : (r.height()-(2*offset))/3)+1);
  542. if(horiz)
  543. {
  544. if(startOffset && y+startOffset>0)
  545. y+=startOffset;
  546. p->setPen(cols[dark]);
  547. for(i=0; i<space; i+=3)
  548. for(j=0; j<numDots; j++)
  549. p->drawPoint(x+offset+(3*j), y+i);
  550. p->setPen(cols[0]);
  551. for(i=1; i<space; i+=3)
  552. for(j=0; j<numDots; j++)
  553. p->drawPoint(x+offset+1+(3*j), y+i);
  554. }
  555. else
  556. {
  557. if(startOffset && x+startOffset>0)
  558. x+=startOffset;
  559. p->setPen(cols[dark]);
  560. for(i=0; i<space; i+=3)
  561. for(j=0; j<numDots; j++)
  562. p->drawPoint(x+i, y+offset+(3*j));
  563. p->setPen(cols[0]);
  564. for(i=1; i<space; i+=3)
  565. for(j=0; j<numDots; j++)
  566. p->drawPoint(x+i, y+offset+1+(3*j));
  567. }
  568. }
  569. static bool onToolBar(TQWidget *widget, int l=0)
  570. {
  571. return l<3 && widget && widget->parentWidget()
  572. ? widget->parentWidget()->inherits(TQTOOLBAR_OBJECT_NAME_STRING) ||
  573. onToolBar(widget->parentWidget(), ++l)
  574. : false;
  575. }
  576. #define PIXMAP_DIMENSION 10
  577. enum ECacheFlags
  578. {
  579. CACHE_STD,
  580. CACHE_COL_SEL_TAB
  581. };
  582. static TQString createKey(int size, TQRgb color, bool horiz, int app, ECacheFlags flags)
  583. {
  584. TQString key;
  585. TQTextOStream(&key) << size << '-' << color << '-' << horiz << '-' << app << '-' << flags;
  586. return key;
  587. }
  588. static TQString createKey(TQRgb color, char type='p')
  589. {
  590. TQString key;
  591. TQTextOStream(&key) << type << color;
  592. return key;
  593. }
  594. static TQString createKey(TQRgb color, EPixmap p)
  595. {
  596. TQString key;
  597. TQTextOStream(&key) << 'P' << color << p;
  598. return key;
  599. }
  600. #ifdef SET_MDI_WINDOW_BUTTON_POSITIONS
  601. static void parseWindowLine(const TQString &line, TQValueList<int> &data)
  602. {
  603. int len(line.length());
  604. for(int i=0; i<len; ++i)
  605. switch(line[i].latin1())
  606. {
  607. case 'M':
  608. data.append(TQStyle::SC_TitleBarSysMenu);
  609. break;
  610. case '_':
  611. data.append(WINDOWTITLE_SPACER);
  612. break;
  613. // case 'H':
  614. // data.append(TQStyle::SC_TitleBarContextHelpButton);
  615. // break;
  616. case 'L':
  617. data.append(TQStyle::SC_TitleBarShadeButton);
  618. break;
  619. case 'I':
  620. data.append(TQStyle::SC_TitleBarMinButton);
  621. break;
  622. case 'A':
  623. data.append(TQStyle::SC_TitleBarMaxButton);
  624. break;
  625. case 'X':
  626. data.append(TQStyle::SC_TitleBarCloseButton);
  627. default:
  628. break;
  629. }
  630. }
  631. #endif
  632. static bool isCheckBoxOfGroupBox(const TQObject *w)
  633. {
  634. return w && w->parent() &&
  635. ::tqqt_cast<TQCheckBox *>(w) && ::tqqt_cast<TQGroupBox *>(w->parent()) &&
  636. !qstrcmp(w->name(), "qt_groupbox_checkbox");
  637. }
  638. static void drawArrow(TQPainter *p, const TQRect &r, const TQColor &col, TQStyle::TQ_PrimitiveElement pe, const Options &opts, bool small=false)
  639. {
  640. TQPointArray a;
  641. if(small)
  642. switch(pe)
  643. {
  644. case TQStyle::PE_ArrowUp:
  645. a.setPoints(opts.vArrows ? 6 : 3, 2,0, 0,-2, -2,0, -2,1, 0,-1, 2,1);
  646. break;
  647. case TQStyle::PE_ArrowDown:
  648. a.setPoints(opts.vArrows ? 6 : 3, 2,0, 0,2, -2,0, -2,-1, 0,1, 2,-1);
  649. break;
  650. case TQStyle::PE_ArrowRight:
  651. a.setPoints(opts.vArrows ? 6 : 3, 0,-2, 2,0, 0,2, -1,2, 1,0 -1,-2);
  652. break;
  653. case TQStyle::PE_ArrowLeft:
  654. a.setPoints(opts.vArrows ? 6 : 3, 0,-2, -2,0, 0,2, 1,2, -1,0, 1,-2);
  655. break;
  656. default:
  657. return;
  658. }
  659. else // Large arrows...
  660. switch(pe)
  661. {
  662. case TQStyle::PE_ArrowUp:
  663. a.setPoints(opts.vArrows ? 8 : 3, 3,1, 0,-2, -3,1, -3,2, -2,2, 0,0, 2,2, 3,2);
  664. break;
  665. case TQStyle::PE_ArrowDown:
  666. a.setPoints(opts.vArrows ? 8 : 3, 3,-1, 0,2, -3,-1, -3,-2, -2,-2, 0,0, 2,-2, 3,-2);
  667. break;
  668. case TQStyle::PE_ArrowRight:
  669. a.setPoints(opts.vArrows ? 8 : 3, -1,-3, 2,0, -1,3, -2,3, -2,2, 0,0, -2,-2, -2,-3);
  670. break;
  671. case TQStyle::PE_ArrowLeft:
  672. a.setPoints(opts.vArrows ? 8 : 3, 1,-3, -2,0, 1,3, 2,3, 2,2, 0,0, 2,-2, 2,-3);
  673. break;
  674. default:
  675. return;
  676. }
  677. if(a.isNull())
  678. return;
  679. p->save();
  680. a.translate((r.x()+(r.width()>>1)),(r.y()+(r.height()>>1)));
  681. p->setBrush(col);
  682. p->setPen(col);
  683. p->drawPolygon(a);
  684. p->restore();
  685. }
  686. #ifdef TQTC_STYLE_SUPPORT
  687. QtCurveStyle::QtCurveStyle(const TQString &name)
  688. #else
  689. QtCurveStyle::QtCurveStyle()
  690. #endif
  691. : BASE_STYLE(AllowMenuTransparency, WindowsStyleScrollBar),
  692. itsSliderCols(0L),
  693. itsDefBtnCols(0L),
  694. itsMouseOverCols(0L),
  695. itsComboBtnCols(0L),
  696. itsCheckRadioSelCols(0L),
  697. itsSortedLvColors(0L),
  698. itsProgressCols(0L),
  699. itsSidebarButtonsCols(0L),
  700. itsActiveMdiColors(0L),
  701. itsMdiColors(0L),
  702. itsThemedApp(APP_OTHER),
  703. itsPixmapCache(150000, 499),
  704. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  705. itsIsTransKicker(false),
  706. #endif
  707. itsHover(HOVER_NONE),
  708. itsOldPos(-1, -1),
  709. itsFormMode(false),
  710. itsHoverWidget(0L),
  711. itsHoverSect(NO_SECT),
  712. itsHoverTab(0L),
  713. itsMactorPal(0L),
  714. itsActive(true),
  715. itsIsSpecialHover(false),
  716. itsDragWidget(0L),
  717. itsDragWidgetHadMouseTracking(false)
  718. {
  719. #ifdef TQTC_STYLE_SUPPORT
  720. TQString rcFile;
  721. if(!name.isEmpty())
  722. {
  723. rcFile=themeFile(kdeHome(), name, useTQt3Settings());
  724. if(rcFile.isEmpty())
  725. {
  726. rcFile=themeFile(kdeHome(true), name);
  727. if(rcFile.isEmpty())
  728. {
  729. rcFile=themeFile(KDE_PREFIX(useTQt3Settings() ? 3 : 4), name, useTQt3Settings());
  730. if(rcFile.isEmpty())
  731. rcFile=themeFile(KDE_PREFIX(useTQt3Settings() ? 4 : 3), name, !useTQt3Settings());
  732. }
  733. }
  734. }
  735. readConfig(rcFile, &opts);
  736. #else
  737. readConfig(TQString(), &opts);
  738. #endif
  739. if(FRAME_LINE==opts.groupBox || opts.gbLabel&GB_LBL_BOLD)
  740. opts.groupBox=FRAME_NONE;
  741. opts.contrast=TQSettings().readNumEntry("/TQt/KDE/contrast", DEFAULT_CONTRAST);
  742. if(opts.contrast<0 || opts.contrast>10)
  743. opts.contrast=DEFAULT_CONTRAST;
  744. itsPixmapCache.setAutoDelete(true);
  745. shadeColors(TQApplication::palette().active().highlight(), itsHighlightCols);
  746. shadeColors(TQApplication::palette().active().background(), itsBackgroundCols);
  747. shadeColors(TQApplication::palette().active().button(), itsButtonCols);
  748. setDecorationColors(true);
  749. switch(opts.shadeSliders)
  750. {
  751. default:
  752. case SHADE_DARKEN:
  753. case SHADE_NONE:
  754. break;
  755. case SHADE_SELECTED:
  756. itsSliderCols=itsHighlightCols;
  757. break;
  758. case SHADE_BLEND_SELECTED:
  759. case SHADE_CUSTOM:
  760. if(!itsSliderCols)
  761. itsSliderCols=new TQColor [TOTAL_SHADES+1];
  762. shadeColors(SHADE_BLEND_SELECTED==opts.shadeSliders
  763. ? midColor(itsHighlightCols[ORIGINAL_SHADE],
  764. itsButtonCols[ORIGINAL_SHADE])
  765. : opts.customSlidersColor,
  766. itsSliderCols);
  767. }
  768. switch(opts.defBtnIndicator)
  769. {
  770. case IND_GLOW:
  771. case IND_SELECTED:
  772. itsDefBtnCols=itsHighlightCols;
  773. break;
  774. case IND_TINT:
  775. itsDefBtnCols=new TQColor [TOTAL_SHADES+1];
  776. shadeColors(tint(itsButtonCols[ORIGINAL_SHADE],
  777. itsHighlightCols[ORIGINAL_SHADE], DEF_BNT_TINT), itsDefBtnCols);
  778. break;
  779. default:
  780. break;
  781. case IND_COLORED:
  782. if(SHADE_BLEND_SELECTED==opts.shadeSliders)
  783. itsDefBtnCols=itsSliderCols;
  784. else
  785. {
  786. itsDefBtnCols=new TQColor [TOTAL_SHADES+1];
  787. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
  788. itsButtonCols[ORIGINAL_SHADE]), itsDefBtnCols);
  789. }
  790. }
  791. switch(opts.comboBtn)
  792. {
  793. default:
  794. case SHADE_DARKEN:
  795. case SHADE_NONE:
  796. break;
  797. case SHADE_SELECTED:
  798. itsComboBtnCols=itsHighlightCols;
  799. break;
  800. case SHADE_BLEND_SELECTED:
  801. if(opts.shadeSliders==SHADE_BLEND_SELECTED)
  802. {
  803. itsComboBtnCols=itsSliderCols;
  804. break;
  805. }
  806. case SHADE_CUSTOM:
  807. if(opts.shadeSliders==SHADE_CUSTOM && opts.customSlidersColor==opts.customComboBtnColor)
  808. {
  809. itsComboBtnCols=itsSliderCols;
  810. break;
  811. }
  812. if(!itsComboBtnCols)
  813. itsComboBtnCols=new TQColor [TOTAL_SHADES+1];
  814. shadeColors(SHADE_BLEND_SELECTED==opts.comboBtn
  815. ? midColor(itsHighlightCols[ORIGINAL_SHADE],
  816. itsButtonCols[ORIGINAL_SHADE])
  817. : opts.customComboBtnColor,
  818. itsComboBtnCols);
  819. }
  820. switch(opts.sortedLv)
  821. {
  822. case SHADE_DARKEN:
  823. if(!itsSortedLvColors)
  824. itsSortedLvColors=new TQColor [TOTAL_SHADES+1];
  825. shadeColors(shade(opts.lvButton ? itsButtonCols[ORIGINAL_SHADE] : itsBackgroundCols[ORIGINAL_SHADE], LV_HEADER_DARK_FACTOR), itsSortedLvColors);
  826. break;
  827. default:
  828. case SHADE_NONE:
  829. break;
  830. case SHADE_SELECTED:
  831. itsSortedLvColors=itsHighlightCols;
  832. break;
  833. case SHADE_BLEND_SELECTED:
  834. if(SHADE_BLEND_SELECTED==opts.shadeSliders)
  835. {
  836. itsSortedLvColors=itsSliderCols;
  837. break;
  838. }
  839. else if(SHADE_BLEND_SELECTED==opts.comboBtn)
  840. {
  841. itsSortedLvColors=itsComboBtnCols;
  842. break;
  843. }
  844. case SHADE_CUSTOM:
  845. if(opts.shadeSliders==SHADE_CUSTOM && opts.customSlidersColor==opts.customSortedLvColor)
  846. {
  847. itsSortedLvColors=itsSliderCols;
  848. break;
  849. }
  850. if(opts.comboBtn==SHADE_CUSTOM && opts.customComboBtnColor==opts.customSortedLvColor)
  851. {
  852. itsSortedLvColors=itsComboBtnCols;
  853. break;
  854. }
  855. if(!itsSortedLvColors)
  856. itsSortedLvColors=new TQColor [TOTAL_SHADES+1];
  857. shadeColors(SHADE_BLEND_SELECTED==opts.sortedLv
  858. ? midColor(itsHighlightCols[ORIGINAL_SHADE],
  859. (opts.lvButton ? itsButtonCols[ORIGINAL_SHADE] : itsBackgroundCols[ORIGINAL_SHADE]))
  860. : opts.customSortedLvColor,
  861. itsSortedLvColors);
  862. }
  863. switch(opts.crColor)
  864. {
  865. default:
  866. case SHADE_NONE:
  867. itsCheckRadioSelCols=itsButtonCols;
  868. break;
  869. case SHADE_DARKEN:
  870. if(!itsCheckRadioSelCols)
  871. itsCheckRadioSelCols=new TQColor [TOTAL_SHADES+1];
  872. shadeColors(shade(itsButtonCols[ORIGINAL_SHADE], LV_HEADER_DARK_FACTOR), itsCheckRadioSelCols);
  873. break;
  874. case SHADE_SELECTED:
  875. itsCheckRadioSelCols=itsHighlightCols;
  876. break;
  877. case SHADE_CUSTOM:
  878. if(SHADE_CUSTOM==opts.shadeSliders && opts.customSlidersColor==opts.customCrBgndColor)
  879. itsCheckRadioSelCols=itsSliderCols;
  880. else if(SHADE_CUSTOM==opts.comboBtn && opts.customComboBtnColor==opts.customCrBgndColor)
  881. itsCheckRadioSelCols=itsComboBtnCols;
  882. else if(SHADE_CUSTOM==opts.sortedLv && opts.customSortedLvColor==opts.customCrBgndColor)
  883. itsCheckRadioSelCols=itsSortedLvColors;
  884. else
  885. {
  886. if(!itsCheckRadioSelCols)
  887. itsCheckRadioSelCols=new TQColor [TOTAL_SHADES+1];
  888. shadeColors(opts.customCrBgndColor, itsCheckRadioSelCols);
  889. }
  890. break;
  891. case SHADE_BLEND_SELECTED:
  892. if(SHADE_BLEND_SELECTED==opts.shadeSliders)
  893. itsCheckRadioSelCols=itsSliderCols;
  894. else if(SHADE_BLEND_SELECTED==opts.comboBtn)
  895. itsCheckRadioSelCols=itsComboBtnCols;
  896. else if(SHADE_BLEND_SELECTED==opts.sortedLv)
  897. itsCheckRadioSelCols=itsSortedLvColors;
  898. else
  899. {
  900. if(!itsCheckRadioSelCols)
  901. itsCheckRadioSelCols=new TQColor [TOTAL_SHADES+1];
  902. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]), itsCheckRadioSelCols);
  903. }
  904. }
  905. switch(opts.progressColor)
  906. {
  907. case SHADE_NONE:
  908. itsProgressCols=itsBackgroundCols;
  909. break;
  910. default:
  911. // Not set!
  912. break;
  913. case SHADE_CUSTOM:
  914. if(SHADE_CUSTOM==opts.shadeSliders && opts.customSlidersColor==opts.customProgressColor)
  915. itsProgressCols=itsSliderCols;
  916. else if(SHADE_CUSTOM==opts.comboBtn && opts.customComboBtnColor==opts.customProgressColor)
  917. itsProgressCols=itsComboBtnCols;
  918. else if(SHADE_CUSTOM==opts.sortedLv && opts.customSortedLvColor==opts.customProgressColor)
  919. itsProgressCols=itsSortedLvColors;
  920. else if(SHADE_CUSTOM==opts.crColor && opts.customCrBgndColor==opts.customProgressColor)
  921. itsProgressCols=itsCheckRadioSelCols;
  922. else
  923. {
  924. if(!itsProgressCols)
  925. itsProgressCols=new TQColor [TOTAL_SHADES+1];
  926. shadeColors(opts.customProgressColor, itsProgressCols);
  927. }
  928. break;
  929. case SHADE_BLEND_SELECTED:
  930. if(SHADE_BLEND_SELECTED==opts.shadeSliders)
  931. itsProgressCols=itsSliderCols;
  932. else if(SHADE_BLEND_SELECTED==opts.comboBtn)
  933. itsProgressCols=itsComboBtnCols;
  934. else if(SHADE_BLEND_SELECTED==opts.sortedLv)
  935. itsProgressCols=itsSortedLvColors;
  936. else
  937. {
  938. if(!itsProgressCols)
  939. itsProgressCols=new TQColor [TOTAL_SHADES+1];
  940. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsBackgroundCols[ORIGINAL_SHADE]), itsProgressCols);
  941. }
  942. }
  943. setMenuColors(TQApplication::palette().active());
  944. if(USE_LIGHTER_POPUP_MENU)
  945. itsLighterPopupMenuBgndCol=shade(itsBackgroundCols[ORIGINAL_SHADE],
  946. TO_FACTOR(opts.lighterPopupMenuBgnd));
  947. if ((SHADE_CUSTOM==opts.shadeMenubars || SHADE_BLEND_SELECTED==opts.shadeMenubars || SHADE_SELECTED==opts.shadeMenubars) &&
  948. "soffice.bin"==TQString(tqApp->argv()[0]) && TOO_DARK(SHADE_CUSTOM==opts.shadeMenubars
  949. ? opts.customMenubarsColor
  950. : itsHighlightCols[ORIGINAL_SHADE]))
  951. opts.shadeMenubars=SHADE_DARKEN;
  952. switch(opts.shadeCheckRadio)
  953. {
  954. default:
  955. itsCheckRadioCol=opts.crButton ? TQApplication::palette().active().buttonText()
  956. : TQApplication::palette().active().text();
  957. break;
  958. case SHADE_BLEND_SELECTED:
  959. case SHADE_SELECTED:
  960. itsCheckRadioCol=TQApplication::palette().active().highlight();
  961. break;
  962. case SHADE_CUSTOM:
  963. itsCheckRadioCol=opts.customCheckRadioColor;
  964. }
  965. if (opts.animatedProgress)
  966. {
  967. itsAnimationTimer = new TQTimer(this);
  968. connect(itsAnimationTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updateProgressPos()));
  969. }
  970. setSbType();
  971. }
  972. QtCurveStyle::~QtCurveStyle()
  973. {
  974. if(itsSidebarButtonsCols!=itsSliderCols &&
  975. itsSidebarButtonsCols!=itsDefBtnCols)
  976. delete [] itsSidebarButtonsCols;
  977. if(itsActiveMdiColors && itsActiveMdiColors!=itsHighlightCols)
  978. delete [] itsActiveMdiColors;
  979. if(itsMdiColors && itsMdiColors!=itsBackgroundCols)
  980. delete [] itsMdiColors;
  981. if(itsMouseOverCols && itsMouseOverCols!=itsDefBtnCols &&
  982. itsMouseOverCols!=itsSliderCols)
  983. delete [] itsMouseOverCols;
  984. if(itsDefBtnCols && itsDefBtnCols!=itsSliderCols && itsDefBtnCols!=itsFocusCols && itsDefBtnCols!=itsHighlightCols)
  985. delete [] itsDefBtnCols;
  986. if(itsProgressCols && itsProgressCols!=itsHighlightCols && itsProgressCols!=itsBackgroundCols &&
  987. itsProgressCols!=itsSliderCols && itsProgressCols!=itsComboBtnCols && itsProgressCols!=itsCheckRadioSelCols && itsProgressCols!=itsSortedLvColors)
  988. delete [] itsProgressCols;
  989. if(itsCheckRadioSelCols && itsCheckRadioSelCols!=itsDefBtnCols && itsCheckRadioSelCols!=itsSliderCols &&
  990. itsCheckRadioSelCols!=itsComboBtnCols && itsCheckRadioSelCols!=itsSortedLvColors &&
  991. itsCheckRadioSelCols!=itsButtonCols && itsCheckRadioSelCols!=itsHighlightCols)
  992. delete [] itsCheckRadioSelCols;
  993. if(itsSortedLvColors && itsSortedLvColors!=itsHighlightCols && itsSortedLvColors!=itsSliderCols &&
  994. itsSortedLvColors!=itsComboBtnCols)
  995. delete [] itsSortedLvColors;
  996. if(itsComboBtnCols && itsComboBtnCols!=itsHighlightCols && itsComboBtnCols!=itsSliderCols)
  997. delete [] itsComboBtnCols;
  998. if(itsSliderCols && itsSliderCols!=itsHighlightCols)
  999. delete [] itsSliderCols;
  1000. delete itsMactorPal;
  1001. }
  1002. static TQString getFile(const TQString &f)
  1003. {
  1004. TQString d(f);
  1005. int slashPos(d.findRev('/'));
  1006. if(slashPos!=-1)
  1007. d.remove(0, slashPos+1);
  1008. return d;
  1009. }
  1010. void QtCurveStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
  1011. {
  1012. if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
  1013. TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
  1014. TQString appName(getFile(app->argv()[0]));
  1015. if(NULL!=getenv("QTCURVE_DEBUG"))
  1016. std::cout << "QtCurve: Application name: \"" << appName.latin1() << "\"\n";
  1017. if ("kicker"==appName || "appletproxy"==appName)
  1018. {
  1019. itsThemedApp=APP_KICKER;
  1020. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  1021. itsIsTransKicker=kickerIsTrans();
  1022. #endif
  1023. }
  1024. else if ("kontact"==appName)
  1025. itsThemedApp=APP_KONTACT;
  1026. else if ("konqueror"==appName)
  1027. itsThemedApp=APP_KONQUEROR;
  1028. else if ("kate"==appName)
  1029. itsThemedApp=APP_KATE;
  1030. else if ("kpresenter"==appName)
  1031. itsThemedApp=APP_KPRESENTER;
  1032. else if ("soffice.bin"==appName)
  1033. {
  1034. itsThemedApp=APP_OPENOFFICE;
  1035. opts.groupBox=FRAME_PLAIN;
  1036. opts.gbLabel=0;
  1037. }
  1038. else if ("kdefilepicker"==appName)
  1039. itsThemedApp=APP_SKIP_TASKBAR;
  1040. else if ("kprinter"==appName)
  1041. itsThemedApp=APP_KPRINTER;
  1042. else if ("kdialog"==appName)
  1043. itsThemedApp=APP_KDIALOG;
  1044. else if ("kdialogd"==appName)
  1045. itsThemedApp=APP_KDIALOGD;
  1046. else if ("tora"==appName)
  1047. itsThemedApp=APP_TORA;
  1048. else if ("opera"==appName)
  1049. itsThemedApp=APP_OPERA;
  1050. else if ("systemsettings"==appName)
  1051. itsThemedApp=APP_SYSTEMSETTINGS;
  1052. else if ("korn"==appName)
  1053. {
  1054. itsThemedApp=APP_KORN;
  1055. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  1056. itsIsTransKicker=kickerIsTrans();
  1057. #endif
  1058. }
  1059. else if ("mactor"==appName)
  1060. {
  1061. if(!itsMactorPal)
  1062. itsMactorPal=new TQPalette(TQApplication::palette());
  1063. itsThemedApp=APP_MACTOR;
  1064. }
  1065. else
  1066. itsThemedApp=APP_OTHER;
  1067. if(APP_OPENOFFICE==itsThemedApp)
  1068. {
  1069. //
  1070. // OO.o 2.x checks to see whether the used theme "inherits" from HighContrastStyle,
  1071. // if so it uses the highlightedText color to draw highlighted menubar and popup menu
  1072. // items. Otherwise it uses the standard color. Changing the metaobject's class name
  1073. // works around this...
  1074. if(opts.useHighlightForMenu)
  1075. {
  1076. TQMetaObject *meta=(TQMetaObject *)metaObject();
  1077. #ifdef USE_QT4
  1078. #warning Qt4 does not allow the metaobject classname to be set (skipping)
  1079. #else // USE_QT4
  1080. meta->classname="HighContrastStyle";
  1081. #endif // USE_QT4
  1082. }
  1083. if(opts.scrollbarType==SCROLLBAR_NEXT)
  1084. opts.scrollbarType=SCROLLBAR_KDE;
  1085. else if(opts.scrollbarType==SCROLLBAR_NONE)
  1086. opts.scrollbarType=SCROLLBAR_WINDOWS;
  1087. setSbType();
  1088. }
  1089. if(SHADE_NONE!=opts.menuStripe && opts.noMenuStripeApps.contains(appName))
  1090. opts.menuStripe=SHADE_NONE;
  1091. #ifdef TQTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
  1092. if(opts.fixParentlessDialogs && (opts.noDlgFixApps.contains(appName) || opts.noDlgFixApps.contains("kde")))
  1093. opts.fixParentlessDialogs=false;
  1094. #endif
  1095. }
  1096. }
  1097. void QtCurveStyle::polish(TQPalette &pal)
  1098. {
  1099. if(APP_MACTOR==itsThemedApp && itsMactorPal &&
  1100. pal.active().background()!=itsMactorPal->active().background())
  1101. return;
  1102. TQSettings settings;
  1103. int contrast(settings.readNumEntry("/TQt/KDE/contrast", DEFAULT_CONTRAST));
  1104. bool newContrast(false);
  1105. readKdeGlobals();
  1106. if(!kdeSettings.inactiveHighlight)// Read in TQt3 palette... Required for the inactive settings...
  1107. {
  1108. TQStringList active(settings.readListEntry("/TQt/Palette/active")),
  1109. inactive(settings.readListEntry("/TQt/Palette/inactive"));
  1110. // Only set if: the active highlight is the same, and the inactive highlight is different.
  1111. // If the user has no ~/.qt/qtrc, then TQSettings will return a default palette. However, the palette
  1112. // passed in to this ::polish function will be the KDE one - which maybe different. Hence, we need to
  1113. // check that TQt active == KDE active, before reading inactive...
  1114. if (TQColorGroup::NColorRoles==active.count() &&
  1115. TQColorGroup::NColorRoles==inactive.count() &&
  1116. TQColor(active[TQColorGroup::Highlight])==pal.color(TQPalette::Active, TQColorGroup::Highlight) &&
  1117. TQColor(active[TQColorGroup::HighlightedText])==pal.color(TQPalette::Active, TQColorGroup::HighlightedText))
  1118. {
  1119. TQColor h(inactive[TQColorGroup::Highlight]),
  1120. t(inactive[TQColorGroup::HighlightedText]);
  1121. if(h!=pal.color(TQPalette::Inactive, TQColorGroup::Highlight) || t!=TQPalette::Inactive, TQColorGroup::HighlightedText)
  1122. {
  1123. pal.setColor(TQPalette::Inactive, TQColorGroup::Highlight, h);
  1124. pal.setColor(TQPalette::Inactive, TQColorGroup::HighlightedText, t);
  1125. }
  1126. }
  1127. }
  1128. if(contrast<0 || contrast>10)
  1129. contrast=DEFAULT_CONTRAST;
  1130. if(contrast!=opts.contrast)
  1131. {
  1132. opts.contrast=contrast;
  1133. newContrast=true;
  1134. }
  1135. if(kdeSettings.inactiveHighlight)
  1136. {
  1137. pal.setColor(TQPalette::Inactive, TQColorGroup::Highlight,
  1138. tint(TQApplication::palette().active().background(),
  1139. TQApplication::palette().active().highlight(), 0.4));
  1140. // KDE4 does not set text colour :-(
  1141. //pal.setColor(TQPalette::Inactive, TQColorGroup::HighlightedText, pal.color(TQPalette::Active, TQColorGroup::Foreground));
  1142. }
  1143. bool newMenu(newContrast ||
  1144. itsHighlightCols[ORIGINAL_SHADE]!=TQApplication::palette().active().highlight()),
  1145. newGray(newContrast ||
  1146. itsBackgroundCols[ORIGINAL_SHADE]!=TQApplication::palette().active().background()),
  1147. newButton(newContrast ||
  1148. itsButtonCols[ORIGINAL_SHADE]!=TQApplication::palette().active().button()),
  1149. newSlider(itsSliderCols && SHADE_BLEND_SELECTED==opts.shadeSliders &&
  1150. (newContrast || newButton || newMenu)),
  1151. newDefBtn(itsDefBtnCols && /*( (IND_COLORED==opts.defBtnIndicator &&*/
  1152. SHADE_BLEND_SELECTED!=opts.shadeSliders/*) ||*/
  1153. /*(IND_TINT==opts.defBtnIndicator) )*/ &&
  1154. IND_SELECTED!=opts.defBtnIndicator && IND_GLOW!=opts.defBtnIndicator &&
  1155. (newContrast || newButton || newMenu)),
  1156. newComboBtn(itsComboBtnCols && itsHighlightCols!=itsComboBtnCols && itsSliderCols!=itsComboBtnCols &&
  1157. SHADE_BLEND_SELECTED==opts.comboBtn &&
  1158. (newContrast || newButton || newMenu)),
  1159. newSortedLv(itsSortedLvColors && ( (SHADE_BLEND_SELECTED==opts.sortedLv && itsHighlightCols!=itsSortedLvColors && itsSliderCols!=itsSortedLvColors &&
  1160. itsComboBtnCols!=itsSortedLvColors) ||
  1161. SHADE_DARKEN==opts.sortedLv) &&
  1162. (newContrast || (opts.lvButton ? newButton : newGray))),
  1163. newCheckRadioSelCols(itsCheckRadioSelCols && ( (SHADE_BLEND_SELECTED==opts.crColor && itsDefBtnCols!=itsCheckRadioSelCols &&
  1164. itsSliderCols!=itsCheckRadioSelCols && itsComboBtnCols!=itsCheckRadioSelCols &&
  1165. itsSortedLvColors!=itsCheckRadioSelCols) ||
  1166. SHADE_DARKEN==opts.crColor) &&
  1167. (newContrast || newButton)),
  1168. newProgressCols(itsProgressCols && SHADE_BLEND_SELECTED==opts.progressColor &&
  1169. itsSliderCols!=itsProgressCols && itsComboBtnCols!=itsProgressCols &&
  1170. itsSortedLvColors!=itsProgressCols && itsCheckRadioSelCols!=itsProgressCols && (newContrast || newButton));
  1171. if(newGray)
  1172. shadeColors(TQApplication::palette().active().background(), itsBackgroundCols);
  1173. if(newButton)
  1174. shadeColors(TQApplication::palette().active().button(), itsButtonCols);
  1175. if(newMenu)
  1176. shadeColors(TQApplication::palette().active().highlight(), itsHighlightCols);
  1177. setDecorationColors();
  1178. setMenuColors(TQApplication::palette().active());
  1179. if(newSlider)
  1180. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]), itsSliderCols);
  1181. if(newComboBtn)
  1182. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]), itsComboBtnCols);
  1183. if(newSortedLv) {
  1184. if(SHADE_BLEND_SELECTED==opts.sortedLv) {
  1185. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
  1186. opts.lvButton ? itsButtonCols[ORIGINAL_SHADE] : itsBackgroundCols[ORIGINAL_SHADE]), itsSortedLvColors);
  1187. }
  1188. else {
  1189. shadeColors(shade(opts.lvButton ? itsButtonCols[ORIGINAL_SHADE] : itsBackgroundCols[ORIGINAL_SHADE], LV_HEADER_DARK_FACTOR), itsSortedLvColors);
  1190. }
  1191. }
  1192. if(newDefBtn) {
  1193. if(IND_TINT==opts.defBtnIndicator) {
  1194. shadeColors(tint(itsButtonCols[ORIGINAL_SHADE],
  1195. itsHighlightCols[ORIGINAL_SHADE], DEF_BNT_TINT), itsDefBtnCols);
  1196. }
  1197. else if(IND_GLOW!=opts.defBtnIndicator) {
  1198. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
  1199. itsButtonCols[ORIGINAL_SHADE]), itsDefBtnCols);
  1200. }
  1201. }
  1202. if(itsSidebarButtonsCols && SHADE_BLEND_SELECTED!=opts.shadeSliders &&
  1203. IND_COLORED!=opts.defBtnIndicator)
  1204. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE],
  1205. itsButtonCols[ORIGINAL_SHADE]), itsSidebarButtonsCols);
  1206. if(USE_LIGHTER_POPUP_MENU && newGray)
  1207. itsLighterPopupMenuBgndCol=shade(itsBackgroundCols[ORIGINAL_SHADE],
  1208. TO_FACTOR(opts.lighterPopupMenuBgnd));
  1209. if(newCheckRadioSelCols) {
  1210. if(SHADE_BLEND_SELECTED==opts.crColor) {
  1211. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsButtonCols[ORIGINAL_SHADE]), itsCheckRadioSelCols);
  1212. }
  1213. else {
  1214. shadeColors(shade(itsButtonCols[ORIGINAL_SHADE], LV_HEADER_DARK_FACTOR), itsCheckRadioSelCols);
  1215. }
  1216. }
  1217. if(newProgressCols) {
  1218. shadeColors(midColor(itsHighlightCols[ORIGINAL_SHADE], itsBackgroundCols[ORIGINAL_SHADE]), itsProgressCols);
  1219. }
  1220. pal.setActive(setColorGroup(pal.active(), pal.active()));
  1221. pal.setInactive(setColorGroup(pal.inactive(), pal.active()));
  1222. pal.setDisabled(setColorGroup(pal.disabled(), pal.active(), true));
  1223. switch(opts.shadeCheckRadio)
  1224. {
  1225. default:
  1226. itsCheckRadioCol=opts.crButton ? TQApplication::palette().active().buttonText()
  1227. : TQApplication::palette().active().text();
  1228. break;
  1229. case SHADE_SELECTED:
  1230. case SHADE_BLEND_SELECTED:
  1231. itsCheckRadioCol=TQApplication::palette().active().highlight();
  1232. break;
  1233. case SHADE_CUSTOM:
  1234. itsCheckRadioCol=opts.customCheckRadioColor;
  1235. }
  1236. if(itsMactorPal)
  1237. *itsMactorPal=pal;
  1238. // Force this to be re-generated!
  1239. if(SHADE_BLEND_SELECTED==opts.menuStripe)
  1240. opts.customMenuStripeColor=TQt::black;
  1241. if(APPEARANCE_STRIPED==opts.bgndAppearance)
  1242. pal.setBrush(TQColorGroup::Background, TQBrush(pal.active().background(), *createStripePixmap(pal.active().background(), true)));
  1243. }
  1244. static TQColor disable(const TQColor &col, const TQColor &bgnd)
  1245. {
  1246. TQColor c = col;
  1247. c = ColorUtils_darken(&c, 0.1, 1.0);
  1248. c = ColorUtils_mix(&c, &bgnd, 0.65);
  1249. return c;
  1250. }
  1251. TQColorGroup QtCurveStyle::setColorGroup(const TQColorGroup &old, const TQColorGroup &act, bool dis)
  1252. {
  1253. TQColor mid(old.mid());
  1254. if(dis)
  1255. mid=disable(act.foreground(), old.background());
  1256. const TQColor *use(backgroundColors(old));
  1257. TQColorGroup newGrp(old.foreground(), old.button(), use[0], use[STD_BORDER],
  1258. mid, old.text(), old.brightText(),
  1259. old.base(), old.background());
  1260. TQColorGroup::ColorRole roles[]={TQColorGroup::Midlight, TQColorGroup::ButtonText,
  1261. TQColorGroup::Shadow, TQColorGroup::Highlight,
  1262. TQColorGroup::HighlightedText, TQColorGroup::Link,
  1263. TQColorGroup::LinkVisited, TQColorGroup::NColorRoles };
  1264. int r(0);
  1265. for(r=0; roles[r]!=TQColorGroup::NColorRoles; ++r)
  1266. newGrp.setColor(roles[r], old.color(roles[r]));
  1267. if(dis)
  1268. {
  1269. newGrp.setColor(TQColorGroup::ButtonText, disable(act.buttonText(), old.button()));
  1270. newGrp.setColor(TQColorGroup::Text, disable(act.text(), old.background()));
  1271. }
  1272. return newGrp;
  1273. }
  1274. static const char * kdeToolbarWidget="kde toolbar widget";
  1275. void QtCurveStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
  1276. {
  1277. if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
  1278. TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
  1279. bool enableFilter(opts.highlightFactor || opts.coloredMouseOver);
  1280. if(::isKhtmlFormWidget(widget))
  1281. {
  1282. itsKhtmlWidgets[widget]=true;
  1283. connect(widget, TQT_SIGNAL(destroyed(TQObject *)), this, TQT_SLOT(khtmlWidgetDestroyed(TQObject *)));
  1284. }
  1285. if(enableFilter && isSpecialHover(widget))
  1286. connect(widget, TQT_SIGNAL(destroyed(TQObject *)), this, TQT_SLOT(hoverWidgetDestroyed(TQObject *)));
  1287. if(isWindowDragWidget(TQT_TQOBJECT(widget)))
  1288. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1289. if(APPEARANCE_STRIPED==opts.bgndAppearance && (::tqqt_cast<TQDialog *>(widget) || ::tqqt_cast<TQMainWindow *>(widget)))
  1290. setBgndProp(widget, APPEARANCE_STRIPED);
  1291. if(widget->parentWidget() && ::tqqt_cast<TQScrollView *>(widget) && ::tqqt_cast<TQComboBox *>(widget->parentWidget()))
  1292. {
  1293. TQPalette pal(widget->palette());
  1294. #if 0
  1295. TQPalette orig(pal);
  1296. #endif
  1297. TQColorGroup act(pal.active());
  1298. #if 0
  1299. if(opts.gtkComboMenus)
  1300. act.setColor(TQColorGroup::Base, USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol : itsBackgroundCols[ORIGINAL_SHADE]);
  1301. act.setColor(TQColorGroup::Background, opts.gtkComboMenus
  1302. ? USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol : itsBackgroundCols[ORIGINAL_SHADE]
  1303. : TQApplication::palette().active().base());
  1304. #endif
  1305. act.setColor(TQColorGroup::Foreground, itsBackgroundCols[STD_BORDER]);
  1306. pal.setActive(act);
  1307. widget->setPalette(pal);
  1308. #if 0
  1309. //((TQScrollView *)widget)->setMargin(1);
  1310. const TQObjectList *children(widget->children());
  1311. if(children)
  1312. {
  1313. TQObjectList::Iterator it(children->begin()),
  1314. end(children->end());
  1315. for(; it!=end; ++it)
  1316. if(::tqqt_cast<TQWidget *>(*it))
  1317. ((TQWidget *)(*it))->setPalette(orig);
  1318. }
  1319. #endif
  1320. }
  1321. if (APP_MACTOR==itsThemedApp && itsMactorPal && !widget->inherits("TQTipLabel"))
  1322. widget->setPalette(*itsMactorPal);
  1323. // Get rid of Kontact's frame...
  1324. if(APP_KONTACT==itsThemedApp && ::tqqt_cast<TQHBox *>(widget) && widget->parentWidget() &&
  1325. 0==qstrcmp(widget->parentWidget()->className(), "Kontact::MainWindow"))
  1326. ((TQHBox *)widget)->setLineWidth(0);
  1327. if(!IS_FLAT_BGND(opts.menuBgndAppearance) && ::tqqt_cast<const TQPopupMenu *>(widget))
  1328. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1329. #if 0
  1330. if(opts.menubarHiding && ::tqqt_cast<TQMainWindow *>(widget) && static_cast<TQMainWindow *>(widget)->menuBar())
  1331. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1332. #endif
  1333. if ((opts.square&SQUARE_SCROLLVIEW) && widget &&
  1334. (::tqqt_cast<const TQScrollView *>(widget) ||
  1335. (widget->parentWidget() && ::tqqt_cast<const TQFrame *>(widget) &&
  1336. widget->parentWidget()->inherits("KateView"))) &&
  1337. ((TQFrame *)widget)->lineWidth()>1)
  1338. ((TQFrame *)widget)->setLineWidth(opts.gtkScrollViews ? 1 : 2);
  1339. else if(!opts.popupBorder && widget &&
  1340. (::tqqt_cast<const TQPopupMenu *>(widget) ||
  1341. (widget->parentWidget() && ::tqqt_cast<const TQListBox *>(widget) &&
  1342. ::tqqt_cast<const TQComboBox *>(widget->parentWidget()))))
  1343. ((TQFrame *)widget)->setLineWidth(0);
  1344. else if ((USE_LIGHTER_POPUP_MENU || !IS_FLAT_BGND(opts.menuBgndAppearance)) && !opts.borderMenuitems &&
  1345. widget && ::tqqt_cast<const TQPopupMenu *>(widget))
  1346. ((TQFrame *)widget)->setLineWidth(1);
  1347. if (::tqqt_cast<TQRadioButton *>(widget) || ::tqqt_cast<TQCheckBox *>(widget))
  1348. {
  1349. bool framelessGroupBoxCheckBox=(NO_FRAME(opts.groupBox) && isCheckBoxOfGroupBox(TQT_TQOBJECT(widget)));
  1350. if(framelessGroupBoxCheckBox || enableFilter)
  1351. {
  1352. #if 0x039999 >= 0x030200
  1353. if(!isFormWidget(widget))
  1354. widget->setMouseTracking(true);
  1355. #endif
  1356. if(framelessGroupBoxCheckBox)
  1357. {
  1358. TQFont fnt(widget->font());
  1359. fnt.setBold(true);
  1360. widget->setFont(fnt);
  1361. }
  1362. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1363. }
  1364. }
  1365. else if (::tqqt_cast<TQHeader *>(widget) || ::tqqt_cast<TQTabBar *>(widget) || ::tqqt_cast<TQSpinWidget *>(widget)/* ||
  1366. ::tqqt_cast<TQDateTimeEditBase*>(widget)*/)
  1367. {
  1368. if(enableFilter)
  1369. {
  1370. widget->setMouseTracking(true);
  1371. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1372. }
  1373. }
  1374. else if (::tqqt_cast<TQToolButton *>(widget))
  1375. {
  1376. if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
  1377. widget->setBackgroundMode(PaletteBackground);
  1378. if(enableFilter)
  1379. {
  1380. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1381. #if defined TDE_VERSION && TDE_VERSION >= 0x30400 && TDE_VERSION < 0x30500
  1382. widget->setMouseTracking(true);
  1383. #endif
  1384. }
  1385. }
  1386. else if (::tqqt_cast<TQButton *>(widget) || widget->inherits("TQToolBarExtensionWidget"))
  1387. {
  1388. /*if(onToolBar(widget))
  1389. widget->setBackgroundMode(NoBackground);
  1390. else*/ if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
  1391. widget->setBackgroundMode(PaletteBackground);
  1392. if(enableFilter)
  1393. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1394. }
  1395. else if (::tqqt_cast<TQComboBox *>(widget))
  1396. {
  1397. if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
  1398. widget->setBackgroundMode(PaletteBackground);
  1399. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1400. if(DO_EFFECT && onToolBar(widget))
  1401. widget->setName(kdeToolbarWidget);
  1402. if(enableFilter)
  1403. widget->setMouseTracking(true);
  1404. if(((TQComboBox *)widget)->listBox())
  1405. ((TQComboBox *)widget)->listBox()->installEventFilter(this);
  1406. // FIXME
  1407. // installObjectEventHandler(ceData, elementFlags, ptr, this);
  1408. }
  1409. else if(::tqqt_cast<TQMenuBar *>(widget))
  1410. {
  1411. if(NoBackground!=widget->backgroundMode())
  1412. widget->setBackgroundMode(PaletteBackground);
  1413. if(SHADE_NONE!=opts.shadeMenubars)
  1414. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1415. if(BLEND_TITLEBAR || opts.windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR)
  1416. emitMenuSize(widget, widget->rect().height());
  1417. if(SHADE_WINDOW_BORDER==opts.shadeMenubars)
  1418. {
  1419. TQPalette pal(widget->palette());
  1420. TQColorGroup act(pal.active());
  1421. TQColorGroup inact(pal.inactive());
  1422. getMdiColors(act, true);
  1423. act.setColor(TQColorGroup::Foreground, itsActiveMdiTextColor);
  1424. inact.setColor(TQColorGroup::Foreground, opts.shadeMenubarOnlyWhenActive ? itsMdiTextColor : itsActiveMdiTextColor);
  1425. pal.setInactive(inact);
  1426. pal.setActive(act);
  1427. widget->setPalette(pal);
  1428. }
  1429. else if(opts.customMenuTextColor || SHADE_BLEND_SELECTED==opts.shadeMenubars || SHADE_SELECTED==opts.shadeMenubars ||
  1430. (SHADE_CUSTOM==opts.shadeMenubars && TOO_DARK(itsMenubarCols[ORIGINAL_SHADE])))
  1431. {
  1432. TQPalette pal(widget->palette());
  1433. TQColorGroup act(pal.active());
  1434. act.setColor(TQColorGroup::Foreground, opts.customMenuTextColor
  1435. ? opts.customMenuNormTextColor
  1436. : TQApplication::palette().active().highlightedText());
  1437. if(!opts.shadeMenubarOnlyWhenActive)
  1438. {
  1439. TQColorGroup inact(pal.inactive());
  1440. inact.setColor(TQColorGroup::Foreground, act.color(TQColorGroup::Foreground));
  1441. pal.setInactive(inact);
  1442. }
  1443. pal.setActive(act);
  1444. widget->setPalette(pal);
  1445. }
  1446. }
  1447. else if(::tqqt_cast<TQToolBar *>(widget))
  1448. {
  1449. if(NoBackground!=widget->backgroundMode())
  1450. widget->setBackgroundMode(PaletteBackground);
  1451. }
  1452. else if(::tqqt_cast<TQPopupMenu *>(widget))
  1453. widget->setBackgroundMode(NoBackground); // PaletteBackground);
  1454. else if (widget->inherits("KToolBarSeparator") ||
  1455. (widget->inherits("KListViewSearchLineWidget") &&
  1456. widget->parent() && ::tqqt_cast<TQToolBar *>(widget->parent())))
  1457. {
  1458. widget->setName(kdeToolbarWidget);
  1459. widget->setBackgroundMode(NoBackground);
  1460. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1461. }
  1462. else if (::tqqt_cast<TQScrollBar *>(widget))
  1463. {
  1464. if(enableFilter)
  1465. {
  1466. widget->setMouseTracking(true);
  1467. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1468. }
  1469. //widget->setBackgroundMode(NoBackground);
  1470. }
  1471. else if (::tqqt_cast<TQSlider *>(widget))
  1472. {
  1473. if(enableFilter)
  1474. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1475. if(widget->parent() && ::tqqt_cast<TQToolBar *>(widget->parent()))
  1476. {
  1477. widget->setName(kdeToolbarWidget);
  1478. widget->setBackgroundMode(NoBackground); // We paint whole background.
  1479. if(!enableFilter)
  1480. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1481. }
  1482. // This bit stolen form polyester...
  1483. connect(widget, TQT_SIGNAL(sliderMoved(int)), this, TQT_SLOT(sliderThumbMoved(int)));
  1484. connect(widget, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(sliderThumbMoved(int)));
  1485. }
  1486. else if (::tqqt_cast<TQLineEdit*>(widget) || ::tqqt_cast<TQTextEdit*>(widget))
  1487. {
  1488. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1489. if(onToolBar(widget))
  1490. widget->setName(kdeToolbarWidget);
  1491. if(widget && widget->parentWidget() &&
  1492. widget->inherits("KLineEdit") && widget->parentWidget()->inherits("KIO::DefaultProgress") &&
  1493. ::tqqt_cast<TQFrame *>(widget))
  1494. ((TQFrame *)widget)->setLineWidth(0);
  1495. }
  1496. else if (widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) || widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) || widget->inherits("TQDockWindowResizeHandle"))
  1497. {
  1498. if(enableFilter)
  1499. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1500. }
  1501. else if (0==qstrcmp(widget->name(), kdeToolbarWidget))
  1502. {
  1503. if(!widget->parent() ||
  1504. 0!=qstrcmp(TQT_TQWIDGET(widget->parent())->className(),
  1505. "KListViewSearchLineWidget") ||
  1506. onToolBar(widget))
  1507. {
  1508. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1509. widget->setBackgroundMode(NoBackground); // We paint whole background.
  1510. }
  1511. }
  1512. if (widget->parentWidget() && ::tqqt_cast<TQMenuBar *>(widget->parentWidget()) && !qstrcmp(widget->className(), TQFRAME_OBJECT_NAME_STRING))
  1513. {
  1514. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1515. widget->setBackgroundMode(NoBackground); // We paint whole background.
  1516. }
  1517. else if (TQt::X11ParentRelative!=widget->backgroundMode() &&
  1518. (::tqqt_cast<TQLabel *>(widget) || ::tqqt_cast<TQHBox *>(widget) ||
  1519. ::tqqt_cast<TQVBox *>(widget)) &&
  1520. widget->parent() &&
  1521. ( 0==qstrcmp(TQT_TQWIDGET(widget->parent())->className(),
  1522. "MainWindow") || onToolBar(widget)))
  1523. {
  1524. widget->setName(kdeToolbarWidget);
  1525. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1526. widget->setBackgroundMode(NoBackground); // We paint the whole background.
  1527. }
  1528. else if(::tqqt_cast<TQProgressBar *>(widget))
  1529. {
  1530. if(widget->palette().inactive().highlightedText()!=widget->palette().active().highlightedText())
  1531. {
  1532. TQPalette pal(widget->palette());
  1533. pal.setInactive(widget->palette().active());
  1534. widget->setPalette(pal);
  1535. }
  1536. if(opts.animatedProgress)
  1537. {
  1538. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1539. itsProgAnimWidgets[widget] = 0;
  1540. connect(widget, TQT_SIGNAL(destroyed(TQObject *)), this, TQT_SLOT(progressBarDestroyed(TQObject *)));
  1541. if (!itsAnimationTimer->isActive())
  1542. itsAnimationTimer->start(PROGRESS_ANIMATION, false);
  1543. }
  1544. }
  1545. else if(opts.highlightScrollViews && ::tqqt_cast<TQScrollView*>(widget))
  1546. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1547. else if(!qstrcmp(widget->className(), "KonqFrameStatusBar"))
  1548. {
  1549. // This disables the white background of the KonquerorFrameStatusBar.
  1550. // When the green led is shown the background is set to
  1551. // applications cg.midlight() so we override it to standard background.
  1552. // Thanks Comix! (because this was ugly from day one!)
  1553. // NOTE: Check if we can set it earlier (before painting), cause
  1554. // on slow machines we can see the repainting of the bar (from white to background...)
  1555. TQPalette pal(TQApplication::palette());
  1556. pal.setColor(TQColorGroup::Midlight, pal.active().background());
  1557. TQApplication::setPalette(pal);
  1558. }
  1559. else if(widget->inherits("KTabCtl"))
  1560. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1561. else if(NO_FRAME(opts.groupBox) && ::tqqt_cast<TQGroupBox *>(widget))
  1562. {
  1563. ((TQGroupBox *)widget)->setFlat(false);
  1564. ((TQGroupBox *)widget)->setFrameShape(TQFrame::NoFrame);
  1565. }
  1566. #ifdef TQTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
  1567. else if(opts.fixParentlessDialogs && ::tqqt_cast<TQDialog *>(widget))
  1568. {
  1569. TQDialog *dlg=(TQDialog *)widget;
  1570. // The parent->isShown is needed for KWord. It's insert picure file dialog is a child of
  1571. // the insert picture dialog - but the file dialog is shown *before* the picture dialog!
  1572. if( (SKIP_TASKBAR && !dlg->parentWidget()) ||
  1573. ( (!dlg->parentWidget() || !dlg->parentWidget()->isShown())// &&
  1574. /*(dlg->isModal() || ::tqqt_cast<TQProgressDialog *>(widget))*/) )
  1575. installObjectEventHandler(ceData, elementFlags, ptr, this);
  1576. }
  1577. if(opts.fixParentlessDialogs && (APP_KPRINTER==itsThemedApp || APP_KDIALOG==itsThemedApp ||
  1578. APP_KDIALOGD==itsThemedApp))
  1579. {
  1580. TQString cap(widget->caption());
  1581. int index=-1;
  1582. // Remove horrible "Open - KDialog" titles...
  1583. if( cap.length() &&
  1584. ( (APP_KPRINTER==itsThemedApp && (-1!=(index=cap.find(" - KPrinter"))) &&
  1585. (index+11)==(int)cap.length()) ||
  1586. (APP_KDIALOG==itsThemedApp && (-1!=(index=cap.find(" - KDialog"))) &&
  1587. (index+10)==(int)cap.length()) ||
  1588. (APP_KDIALOGD==itsThemedApp && (-1!=(index=cap.find(" - KDialog Daemon"))) &&
  1589. (index+17)==(int)cap.length())) )
  1590. widget->TQWidget::setCaption(cap.left(index));
  1591. }
  1592. #endif
  1593. if(APP_SYSTEMSETTINGS==itsThemedApp)
  1594. {
  1595. if(widget && widget->parentWidget() && widget->parentWidget()->parentWidget() &&
  1596. ::tqqt_cast<TQFrame *>(widget) && TQFrame::NoFrame!=((TQFrame *)widget)->frameShape() &&
  1597. ::tqqt_cast<TQFrame *>(widget->parentWidget()) &&
  1598. ::tqqt_cast<TQTabWidget *>(widget->parentWidget()->parentWidget()))
  1599. ((TQFrame *)widget)->setFrameShape(TQFrame::NoFrame);
  1600. if(widget->parentWidget() && widget->parentWidget()->parentWidget() &&
  1601. ::tqqt_cast<TQScrollView *>(widget->parentWidget()->parentWidget()) &&
  1602. widget->inherits("KCMultiWidget") && widget->parentWidget()->inherits("TQViewportWidget"))
  1603. ((TQScrollView *)(widget->parentWidget()->parentWidget()))->setLineWidth(0);
  1604. }
  1605. if(opts.tabBgnd && widget && widget->parentWidget() && ::tqqt_cast<TQWidgetStack *>(widget) &&
  1606. ::tqqt_cast<TQTabWidget *>(widget->parentWidget()) &&
  1607. 0==qstrcmp(widget->name(), "tab pages"))
  1608. {
  1609. TQPalette pal(widget->palette());
  1610. pal.setColor(TQColorGroup::Background, shade(pal.active().background(), TO_FACTOR(opts.tabBgnd)));
  1611. widget->setBackgroundMode(PaletteBackground);
  1612. widget->setPalette(pal);
  1613. }
  1614. if(APPEARANCE_STRIPED==opts.bgndAppearance)
  1615. widget->setBackgroundOrigin(TQWidget::WindowOrigin);
  1616. }
  1617. BASE_STYLE::polish(ceData, elementFlags, ptr);
  1618. }
  1619. void QtCurveStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr)
  1620. {
  1621. if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
  1622. TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
  1623. if(isFormWidget(widget))
  1624. itsKhtmlWidgets.remove(widget);
  1625. if(!IS_FLAT_BGND(opts.menuBgndAppearance) && ::tqqt_cast<const TQPopupMenu *>(widget))
  1626. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1627. #if 0
  1628. if(opts.menubarHiding && ::tqqt_cast<TQMainWindow *>(widget) && static_cast<TQMainWindow *>(widget)->menuBar())
  1629. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1630. #endif
  1631. if(isWindowDragWidget(TQT_TQOBJECT(widget)))
  1632. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1633. if (::tqqt_cast<TQRadioButton *>(widget) || ::tqqt_cast<TQCheckBox *>(widget))
  1634. {
  1635. #if 0x039999 >= 0x030200
  1636. widget->setMouseTracking(false);
  1637. #endif
  1638. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1639. }
  1640. else if (::tqqt_cast<TQHeader *>(widget) || ::tqqt_cast<TQTabBar *>(widget) || ::tqqt_cast<TQSpinWidget *>(widget) /*||
  1641. ::tqqt_cast<TQDateTimeEditBase*>(widget)*/)
  1642. {
  1643. widget->setMouseTracking(false);
  1644. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1645. }
  1646. else if (::tqqt_cast<TQButton *>(widget) || widget->inherits("TQToolBarExtensionWidget"))
  1647. {
  1648. if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
  1649. widget->setBackgroundMode(PaletteButton);
  1650. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1651. }
  1652. else if (::tqqt_cast<TQToolButton *>(widget))
  1653. {
  1654. if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
  1655. widget->setBackgroundMode(PaletteButton);
  1656. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1657. #if defined TDE_VERSION && TDE_VERSION >= 0x30400 && TDE_VERSION < 0x30500
  1658. widget->setMouseTracking(false);
  1659. #endif
  1660. }
  1661. else if (::tqqt_cast<TQComboBox *>(widget))
  1662. {
  1663. if(NoBackground!=widget->backgroundMode()) // && onToolBar(widget))
  1664. widget->setBackgroundMode(PaletteButton);
  1665. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1666. widget->setMouseTracking(false);
  1667. if(((TQComboBox *)widget)->listBox())
  1668. ((TQComboBox *)widget)->listBox()->removeEventFilter(this);
  1669. // FIXME
  1670. // removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1671. }
  1672. else if (::tqqt_cast<TQToolBar *>(widget) || ::tqqt_cast<TQPopupMenu *>(widget))
  1673. {
  1674. if(NoBackground!=widget->backgroundMode())
  1675. widget->setBackgroundMode(PaletteBackground);
  1676. }
  1677. else if (::tqqt_cast<TQMenuBar *>(widget))
  1678. {
  1679. if(NoBackground!=widget->backgroundMode())
  1680. widget->setBackgroundMode(PaletteBackground);
  1681. if(SHADE_NONE!=opts.shadeMenubars)
  1682. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1683. if(SHADE_WINDOW_BORDER==opts.shadeMenubars || opts.customMenuTextColor || SHADE_BLEND_SELECTED==opts.shadeMenubars ||
  1684. SHADE_SELECTED==opts.shadeMenubars || (SHADE_CUSTOM==opts.shadeMenubars &&TOO_DARK(itsMenubarCols[ORIGINAL_SHADE])))
  1685. widget->setPalette(TQApplication::palette());
  1686. }
  1687. else if (widget->inherits("KToolBarSeparator"))
  1688. {
  1689. widget->setBackgroundMode(PaletteBackground);
  1690. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1691. }
  1692. else if (::tqqt_cast<TQScrollBar *>(widget))
  1693. {
  1694. widget->setMouseTracking(false);
  1695. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1696. widget->setBackgroundMode(PaletteButton);
  1697. }
  1698. else if (::tqqt_cast<TQSlider *>(widget))
  1699. {
  1700. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1701. if(widget->parent() && ::tqqt_cast<TQToolBar *>(widget->parent()))
  1702. widget->setBackgroundMode(PaletteBackground);
  1703. }
  1704. else if (::tqqt_cast<TQLineEdit*>(widget) || ::tqqt_cast<TQTextEdit*>(widget))
  1705. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1706. else if (widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) || widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) || widget->inherits("TQDockWindowResizeHandle"))
  1707. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1708. else if (::tqqt_cast<TQProgressBar*>(widget))
  1709. {
  1710. itsProgAnimWidgets.remove(widget);
  1711. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1712. }
  1713. else if(opts.highlightScrollViews && ::tqqt_cast<TQScrollView*>(widget))
  1714. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1715. else if(0==qstrcmp(widget->name(), kdeToolbarWidget))
  1716. {
  1717. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1718. widget->setBackgroundMode(PaletteBackground);
  1719. }
  1720. if (widget->parentWidget() && ::tqqt_cast<TQMenuBar *>(widget->parentWidget()) && !qstrcmp(widget->className(), TQFRAME_OBJECT_NAME_STRING))
  1721. {
  1722. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1723. widget->setBackgroundMode(PaletteBackground); // We paint whole background.
  1724. }
  1725. else if(widget->inherits("KTabCtl"))
  1726. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1727. #ifdef TQTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
  1728. else if(opts.fixParentlessDialogs && ::tqqt_cast<TQDialog *>(widget))
  1729. removeObjectEventHandler(ceData, elementFlags, ptr, this);
  1730. #endif
  1731. }
  1732. BASE_STYLE::unPolish(ceData, elementFlags, ptr);
  1733. }
  1734. static void sendXEvent(TQDialog *dlg, const char *msg)
  1735. {
  1736. static Atom msgTypeAtom = XInternAtom(tqt_xdisplay(), "_NET_WM_STATE", False);
  1737. XEvent xev;
  1738. Atom atom=XInternAtom(tqt_xdisplay(), msg, False);
  1739. xev.xclient.type = ClientMessage;
  1740. xev.xclient.serial = 0;
  1741. xev.xclient.send_event = True;
  1742. xev.xclient.window = dlg->winId();
  1743. xev.xclient.message_type = msgTypeAtom;
  1744. xev.xclient.format = 32;
  1745. xev.xclient.data.l[0] = 1;
  1746. xev.xclient.data.l[1] = atom;
  1747. xev.xclient.data.l[2] = 0;
  1748. xev.xclient.data.l[3] = 0;
  1749. xev.xclient.data.l[4] = 0;
  1750. XSendEvent(tqt_xdisplay(), tqt_xrootwin(), False,
  1751. SubstructureRedirectMask | SubstructureNotifyMask, &xev);
  1752. }
  1753. bool QtCurveStyle::appIsNotEmbedded(TQDialog *dlg)
  1754. {
  1755. Window win;
  1756. if(!XGetTransientForHint(tqt_xdisplay(), dlg->winId(), &win) || (int)win < 1000)
  1757. return true;
  1758. // OK, dialog has been set transient, so there is no need for this event filter anymore :-)
  1759. dlg->removeEventFilter(this);
  1760. return false;
  1761. }
  1762. bool QtCurveStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
  1763. {
  1764. if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) {
  1765. TQObject* object = reinterpret_cast<TQObject*>(source);
  1766. if(itsHoverWidget && TQT_BASE_OBJECT(object)==TQT_BASE_OBJECT(itsHoverWidget) && (TQEvent::Destroy==event->type() || TQEvent::Hide==event->type()))
  1767. resetHover();
  1768. #if 0
  1769. // Works for qtconfig, but k3b hangs?
  1770. if(opts.menubarHiding && TQEvent::KeyRelease==event->type() && ::tqqt_cast<TQMainWindow *>(object))
  1771. {
  1772. TQMainWindow *window=static_cast<TQMainWindow *>(object);
  1773. if(window->isVisible() && window->menuBar())
  1774. {
  1775. TQKeyEvent *k=static_cast<TQKeyEvent *>(event);
  1776. if(k->state()&TQt::ControlButton && k->state()&TQt::AltButton && TQt::Key_M==k->key())
  1777. window->menuBar()->setHidden(window->menuBar()->isVisible());
  1778. }
  1779. }
  1780. #endif
  1781. if(object->parent() && 0==qstrcmp(object->name(), kdeToolbarWidget))
  1782. {
  1783. // Draw background for custom widgets in the toolbar that have specified a
  1784. // "kde toolbar widget" name.
  1785. if(TQEvent::Paint==event->type())
  1786. {
  1787. TQWidget *widget(TQT_TQWIDGET(object)),
  1788. *parent(TQT_TQWIDGET(object->parent()));
  1789. if(IS_FLAT(opts.toolbarAppearance))
  1790. TQPainter(widget).fillRect(widget->rect(), parent->colorGroup().background());
  1791. else
  1792. {
  1793. int y_offset(widget->y());
  1794. while(parent && parent->parent() && 0==qstrcmp(parent->name(), kdeToolbarWidget))
  1795. {
  1796. y_offset += parent->y();
  1797. parent = TQT_TQWIDGET(parent->parent());
  1798. }
  1799. TQRect r(widget->rect()),
  1800. pr(parent->rect());
  1801. bool horiz=pr.width() > pr.height();
  1802. TQPainter p(widget);
  1803. TQToolBar *tb(::tqqt_cast<TQToolBar*>(parent));
  1804. // If parent is a TQToolbar use its orientation, else just base on width>height.
  1805. if (tb)
  1806. horiz = Qt::Horizontal==tb->orientation();
  1807. TQRect bgndRect(r.x(), r.y()-y_offset, r.width(), pr.height());
  1808. if(!IS_FLAT(opts.toolbarAppearance)) {
  1809. if(horiz) {
  1810. bgndRect.addCoords(0, -1, 0, 1);
  1811. }
  1812. else {
  1813. bgndRect.addCoords(-1, 0, 1, 0);
  1814. }
  1815. }
  1816. drawMenuOrToolBarBackground(&p, bgndRect, parent->colorGroup(), false, horiz);
  1817. }
  1818. if(!::tqqt_cast<TQLineEdit*>(object) && !::tqqt_cast<TQTextEdit*>(object) &&
  1819. !(DO_EFFECT && ::tqqt_cast<TQComboBox*>(object)))
  1820. return false; // Now draw the contents
  1821. }
  1822. }
  1823. else if (NO_FRAME(opts.groupBox) && TQEvent::Move==event->type() && isCheckBoxOfGroupBox(object))
  1824. {
  1825. TQCheckBox *cb=static_cast<TQCheckBox *>(TQT_TQWIDGET(object));
  1826. TQRect r(cb->geometry());
  1827. removeObjectEventHandler(ceData, elementFlags, source, this);
  1828. if(TQApplication::reverseLayout())
  1829. r.setWidth(r.width()+8);
  1830. else
  1831. r.setX(0);
  1832. cb->setGeometry(r);
  1833. installObjectEventHandler(ceData, elementFlags, source, this);
  1834. return false;
  1835. }
  1836. else if (TQEvent::Paint==event->type())
  1837. {
  1838. if(!IS_FLAT_BGND(opts.menuBgndAppearance) && ::tqqt_cast<TQPopupMenu *>(object))
  1839. {
  1840. TQWidget *widget=(TQWidget*)object;
  1841. TQPainter painter(widget);
  1842. TQColor col(USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol : widget->palette().active().background());
  1843. if(APPEARANCE_STRIPED==opts.menuBgndAppearance)
  1844. painter.drawTiledPixmap(widget->rect(), *createStripePixmap(col, false));
  1845. else
  1846. drawBevelGradientReal(col, &painter, widget->rect(), GT_HORIZ==opts.menuBgndGrad, false,
  1847. opts.menuBgndAppearance, WIDGET_OTHER);
  1848. return false;
  1849. }
  1850. else if (object->inherits("KToolBarSeparator"))
  1851. {
  1852. TQFrame *frame(::tqqt_cast<TQFrame *>(object));
  1853. if(frame && TQFrame::NoFrame!=frame->frameShape())
  1854. {
  1855. TQPainter painter(frame);
  1856. if (TQFrame::VLine==frame->frameShape())
  1857. drawPrimitive(PE_DockWindowSeparator, &painter, TQStyleControlElementData(), CEF_None, frame->rect(),
  1858. frame->colorGroup(), Style_Horizontal);
  1859. else if (TQFrame::HLine==frame->frameShape())
  1860. drawPrimitive(PE_DockWindowSeparator, &painter, TQStyleControlElementData(), CEF_None, frame->rect(),
  1861. frame->colorGroup());
  1862. else
  1863. return false;
  1864. return true; // been drawn!
  1865. }
  1866. }
  1867. else if(object->inherits("KTabCtl") && ::tqqt_cast<TQWidget*>(object))
  1868. {
  1869. TQWidget *widget((TQWidget*)object);
  1870. TQObject *child(object->child("_tabbar"));
  1871. TQTabBar *tb(child ? ::tqqt_cast<TQTabBar *>(child) : 0L);
  1872. TQPainter painter(widget);
  1873. TQRect r(widget->rect());
  1874. int tbHeight(tb ? tb->height()-1 : 28);
  1875. if(tb && (TQTabBar::RoundedBelow == tb->shape() ||
  1876. TQTabBar::TriangularBelow == tb->shape()))
  1877. r.addCoords(0, 0, 0, -tbHeight);
  1878. else
  1879. r.addCoords(0, tbHeight, 0, 0);
  1880. drawPrimitive(PE_PanelTabWidget, &painter, TQStyleControlElementData(), CEF_None, r, widget->colorGroup(),
  1881. Style_Horizontal|Style_Enabled);
  1882. return true;
  1883. }
  1884. }
  1885. // Fix mdi buttons in menubars...
  1886. if(::tqqt_cast<TQWidget*>(object) && ((TQWidget *)object)->parentWidget() &&
  1887. ::tqqt_cast<TQMenuBar*>(((TQWidget *)object)->parentWidget()))
  1888. {
  1889. bool drawMenubar=false;
  1890. switch(event->type())
  1891. {
  1892. case TQEvent::Paint:
  1893. drawMenubar=true;
  1894. break;
  1895. case TQEvent::WindowActivate:
  1896. itsActive=true;
  1897. drawMenubar=opts.shadeMenubarOnlyWhenActive && SHADE_NONE!=opts.shadeMenubars;
  1898. break;
  1899. case TQEvent::WindowDeactivate:
  1900. itsActive=false;
  1901. drawMenubar=opts.shadeMenubarOnlyWhenActive && SHADE_NONE!=opts.shadeMenubars;
  1902. default:
  1903. break;
  1904. }
  1905. if(drawMenubar)
  1906. {
  1907. TQWidget *widget(TQT_TQWIDGET(object)),
  1908. *parent(TQT_TQWIDGET(object->parent()));
  1909. TQRect r(widget->rect());
  1910. TQPainter p(widget);
  1911. int y_offset(widget->y()+parent->y());
  1912. r.setY(r.y()-y_offset);
  1913. r.setHeight(parent->rect().height());
  1914. drawMenuOrToolBarBackground(&p, r, parent->colorGroup());
  1915. return true;
  1916. }
  1917. }
  1918. // Taken from plastik...
  1919. // focus highlight
  1920. if (::tqqt_cast<TQLineEdit*>(object) || ::tqqt_cast<TQTextEdit*>(object)/* || ::tqqt_cast<TQDateTimeEditBase*>(object)*/)
  1921. {
  1922. if(TQEvent::FocusIn==event->type() || TQEvent::FocusOut==event->type() || TQEvent::Enter==event->type() || TQEvent::Leave==event->type())
  1923. {
  1924. TQWidget *widget(TQT_TQWIDGET(object));
  1925. if (::tqqt_cast<TQSpinWidget*>(widget->parentWidget()))
  1926. {
  1927. widget->parentWidget()->repaint(false);
  1928. return false;
  1929. }
  1930. widget->repaint(false);
  1931. }
  1932. return false;
  1933. }
  1934. if(::tqqt_cast<TQMenuBar *>(object))
  1935. {
  1936. bool useWindowCols=SHADE_WINDOW_BORDER==opts.shadeMenubars;
  1937. if( (useWindowCols || opts.customMenuTextColor || SHADE_BLEND_SELECTED==opts.shadeMenubars || SHADE_SELECTED==opts.shadeMenubars ||
  1938. SHADE_CUSTOM==opts.shadeMenubars) && TQEvent::Paint==event->type())
  1939. {
  1940. const TQColor &col(((TQWidget *)object)->palette().active().color(TQColorGroup::Foreground));
  1941. // If we're relouring the menubar text, check to see if menubar palette has changed, if so set back to
  1942. // our values. This fixes opera - which seems to change the widgets palette after it is polished.
  1943. if((opts.customMenuTextColor && col!=opts.customMenuNormTextColor) ||
  1944. ( (SHADE_BLEND_SELECTED==opts.shadeMenubars || SHADE_SELECTED==opts.shadeMenubars ||
  1945. (SHADE_CUSTOM==opts.shadeMenubars && TOO_DARK(itsMenubarCols[ORIGINAL_SHADE]))) &&
  1946. col!=TQApplication::palette().active().highlightedText()))
  1947. {
  1948. TQPalette pal(((TQWidget *)object)->palette());
  1949. TQColorGroup act(pal.active());
  1950. act.setColor(TQColorGroup::Foreground, useWindowCols
  1951. ? itsActiveMdiTextColor
  1952. : opts.customMenuTextColor
  1953. ? opts.customMenuNormTextColor
  1954. : TQApplication::palette().active().highlightedText());
  1955. if(!opts.shadeMenubarOnlyWhenActive || useWindowCols)
  1956. {
  1957. TQColorGroup inact(pal.inactive());
  1958. inact.setColor(TQColorGroup::Foreground, useWindowCols ? itsMdiTextColor : act.color(TQColorGroup::Foreground));
  1959. pal.setInactive(inact);
  1960. }
  1961. pal.setActive(act);
  1962. ((TQWidget *)object)->setPalette(pal);
  1963. }
  1964. }
  1965. if(opts.shadeMenubarOnlyWhenActive && SHADE_NONE!=opts.shadeMenubars)
  1966. switch(event->type())
  1967. {
  1968. case TQEvent::WindowActivate:
  1969. itsActive=true;
  1970. ((TQWidget *)object)->repaint(false);
  1971. return false;
  1972. case TQEvent::WindowDeactivate:
  1973. itsActive=false;
  1974. ((TQWidget *)object)->repaint(false);
  1975. return false;
  1976. default:
  1977. break;
  1978. }
  1979. if(BLEND_TITLEBAR || opts.windowBorder&WINDOW_BORDER_USE_MENUBAR_COLOR_FOR_TITLEBAR)
  1980. switch(event->type())
  1981. {
  1982. case TQEvent::Resize:
  1983. {
  1984. TQResizeEvent *re = TQT_TQRESIZEEVENT(event);
  1985. if (re->size().height() != re->oldSize().height())
  1986. emitMenuSize((TQMenuBar *)object, re->size().height());
  1987. break;
  1988. }
  1989. default:
  1990. break;
  1991. }
  1992. }
  1993. if(dynamic_cast<TQMouseEvent*>(event))
  1994. switch(event->type())
  1995. {
  1996. case TQEvent::MouseMove: // Only occurs for widgets with mouse tracking enabled
  1997. if(itsDragWidget)
  1998. {
  1999. itsDragWidget->setMouseTracking(itsDragWidgetHadMouseTracking);
  2000. bool move=isWindowDragWidget(object);
  2001. if(move)
  2002. triggerWMMove(itsDragWidget, ((TQMouseEvent *)event)->globalPos());
  2003. itsDragWidget = 0L;
  2004. return move;
  2005. }
  2006. case TQEvent::MouseButtonPress:
  2007. {
  2008. TQMouseEvent *mev = (TQMouseEvent *)event;
  2009. if(isWindowDragWidget(object, mev->pos()))
  2010. {
  2011. if(/*TQt::NoModifier==mev->modifiers() && */ Qt::LeftButton==mev->button())
  2012. {
  2013. TQWidget *wid = TQT_TQWIDGET(object);
  2014. itsDragWidget=wid;
  2015. itsDragWidgetHadMouseTracking=itsDragWidget->hasMouseTracking();
  2016. itsDragWidget->setMouseTracking(true);
  2017. return false;
  2018. }
  2019. }
  2020. break;
  2021. }
  2022. case TQEvent::MouseButtonRelease:
  2023. if(itsDragWidget)
  2024. {
  2025. itsDragWidget->setMouseTracking(itsDragWidgetHadMouseTracking);
  2026. itsDragWidget = 0L;
  2027. return false;
  2028. }
  2029. default:
  2030. break;
  2031. }
  2032. #ifdef TQTC_ENABLE_PARENTLESS_DIALOG_FIX_SUPPORT
  2033. if(opts.fixParentlessDialogs && ::tqqt_cast<TQDialog *>(object))
  2034. {
  2035. TQDialog *dlg=(TQDialog *)object;
  2036. switch(event->type())
  2037. {
  2038. case TQEvent::ShowMinimized:
  2039. if(SKIP_TASKBAR && appIsNotEmbedded(dlg))
  2040. {
  2041. // Ugly hack :-( Cant seem to get KWin to remove the minimize button. So when
  2042. // the dialog gets minimized, restore.
  2043. dlg->setWindowState(dlg->windowState() & ~WindowMinimized | WindowActive);
  2044. return true;
  2045. }
  2046. break;
  2047. case TQEvent::WindowActivate:
  2048. if(SKIP_TASKBAR && appIsNotEmbedded(dlg))
  2049. {
  2050. // OO.o's filepicker is a spawned process - but is not set transient :-(
  2051. // --plus no reliable way of finding which widget to make it transient for...
  2052. sendXEvent(dlg, "_NET_WM_STATE_SKIP_PAGER");
  2053. sendXEvent(dlg, "_NET_WM_STATE_SKIP_TASKBAR");
  2054. sendXEvent(dlg, "_NET_WM_STATE_ABOVE");
  2055. sendXEvent(dlg, "_NET_WM_STATE_STAYS_ON_TOP");
  2056. //setActions(dlg);
  2057. }
  2058. break;
  2059. case TQEvent::Show:
  2060. // The parent->isShown is needed for KWord. It's insert picure file dialog is a
  2061. // child of the insert picture dialog - but the file dialog is shown *before* the
  2062. // picture dialog!
  2063. if((!dlg->parentWidget() || !dlg->parentWidget()->isShown())) // &&
  2064. //(dlg->isModal() || ::tqqt_cast<TQProgressDialog *>(object)))
  2065. {
  2066. TQWidget *activeWindow=tqApp->activeWindow();
  2067. if(activeWindow)
  2068. {
  2069. XWindowAttributes attr;
  2070. int rx, ry;
  2071. Window win;
  2072. if(!XGetTransientForHint(tqt_xdisplay(), dlg->winId(), &win) ||
  2073. win!=activeWindow->winId())
  2074. {
  2075. XSetTransientForHint(tqt_xdisplay(), dlg->winId(),
  2076. activeWindow->winId());
  2077. if(XGetWindowAttributes(tqt_xdisplay(), activeWindow->winId(), &attr))
  2078. {
  2079. XTranslateCoordinates(tqt_xdisplay(), activeWindow->winId(),
  2080. attr.root, -attr.border_width, -16,
  2081. &rx, &ry, &win);
  2082. rx=(rx+(attr.width/2))-(dlg->width()/2);
  2083. if(rx<0)
  2084. rx=0;
  2085. ry=(ry+(attr.height/2))-(dlg->height()/2);
  2086. if(ry<0)
  2087. ry=0;
  2088. dlg->move(rx, ry);
  2089. if(!dlg->isModal())
  2090. dlg->setModal(true);
  2091. }
  2092. }
  2093. }
  2094. }
  2095. default:
  2096. break;
  2097. }
  2098. return false;
  2099. }
  2100. #endif
  2101. // Track show events for progress bars
  2102. if (opts.animatedProgress && ::tqqt_cast<TQProgressBar*>(object))
  2103. {
  2104. if(TQEvent::Show==event->type() && !itsAnimationTimer->isActive())
  2105. itsAnimationTimer->start(PROGRESS_ANIMATION, false);
  2106. return false;
  2107. }
  2108. switch(event->type())
  2109. {
  2110. case TQEvent::FocusIn:
  2111. case TQEvent::FocusOut:
  2112. if(opts.highlightScrollViews && object->isWidgetType() && ::tqqt_cast<TQScrollView*>(object))
  2113. ((TQWidget *)object)->repaint(false);
  2114. break;
  2115. case TQEvent::Hide:
  2116. case TQEvent::Show:
  2117. if(::tqqt_cast<TQListBox *>(object) &&
  2118. (((TQListBox *)object)->parentWidget() &&
  2119. ::tqqt_cast<TQComboBox *>(((TQListBox *)object)->parentWidget())))
  2120. ((TQComboBox *)(((TQListBox *)object)->parentWidget()))->repaint(false);
  2121. // else if(::tqqt_cast<TQFrame *>(object) &&
  2122. // (TQFrame::Box==((TQFrame *)object)->frameShape() || TQFrame::Panel==((TQFrame *)object)->frameShape() ||
  2123. // TQFrame::WinPanel==((TQFrame *)object)->frameShape()))
  2124. // ((TQFrame *)object)->setFrameShape(TQFrame::StyledPanel);
  2125. break;
  2126. case TQEvent::Enter:
  2127. if(object->isWidgetType())
  2128. {
  2129. itsHoverWidget=(TQWidget *)object;
  2130. if(itsHoverWidget && itsHoverWidget->isEnabled())
  2131. {
  2132. if(::tqqt_cast<TQTabBar*>(object) && TQT_TQWIDGET(object)->isEnabled())
  2133. {
  2134. itsHoverTab=0L;
  2135. itsHoverWidget->repaint(false);
  2136. }
  2137. else if(!itsHoverWidget->hasMouseTracking() ||
  2138. (itsFormMode=isFormWidget(itsHoverWidget)))
  2139. {
  2140. itsHoverWidget->repaint(false);
  2141. itsFormMode=false;
  2142. }
  2143. }
  2144. else
  2145. itsHoverWidget=0L;
  2146. if(itsHoverWidget && !itsIsSpecialHover && isSpecialHover(itsHoverWidget))
  2147. itsIsSpecialHover=true;
  2148. }
  2149. break;
  2150. case TQEvent::Leave:
  2151. if(itsHoverWidget && TQT_BASE_OBJECT(object)==TQT_BASE_OBJECT(itsHoverWidget))
  2152. {
  2153. resetHover();
  2154. ((TQWidget *)object)->repaint(false);
  2155. }
  2156. break;
  2157. case TQEvent::MouseMove: // Only occurs for widgets with mouse tracking enabled
  2158. {
  2159. TQMouseEvent *me = TQT_TQMOUSEEVENT(event);
  2160. if(me && itsHoverWidget && object->isWidgetType())
  2161. {
  2162. if(!me->pos().isNull() && itsIsSpecialHover && redrawHoverWidget(me->pos()))
  2163. itsHoverWidget->repaint(false);
  2164. itsOldPos=me->pos();
  2165. }
  2166. break;
  2167. }
  2168. default:
  2169. break;
  2170. }
  2171. }
  2172. return BASE_STYLE::objectEventHandler(ceData, elementFlags, source, event);
  2173. }
  2174. void QtCurveStyle::drawLightBevel(const TQColor &bgnd, TQPainter *p, const TQRect &rOrig,
  2175. const TQColorGroup &cg, SFlags flags,
  2176. int round, const TQColor &fill, const TQColor *custom,
  2177. bool doBorder, bool doCorners, EWidget w) const
  2178. {
  2179. EAppearance app(widgetApp(w, &opts));
  2180. TQRect r(rOrig),
  2181. br(r);
  2182. bool bevelledButton(WIDGET_BUTTON(w) && APPEARANCE_BEVELLED==app),
  2183. sunken(flags &(Style_Down|Style_On|Style_Sunken)),
  2184. flatWidget(WIDGET_PROGRESSBAR==w && !opts.borderProgress),
  2185. lightBorder(!flatWidget && DRAW_LIGHT_BORDER(sunken , w, app)),
  2186. draw3dfull(!flatWidget && !lightBorder && DRAW_3D_FULL_BORDER(sunken, app)),
  2187. draw3d(!flatWidget && (draw3dfull || (!lightBorder && DRAW_3D_BORDER(sunken, app)))),
  2188. doColouredMouseOver(!sunken && doBorder &&
  2189. opts.coloredMouseOver && flags&Style_MouseOver &&
  2190. WIDGET_SPIN!=w && WIDGET_COMBO_BUTTON!=w && WIDGET_SB_BUTTON!=w &&
  2191. (WIDGET_SB_SLIDER!=w || !opts.colorSliderMouseOver) &&
  2192. !(flags&DW_CLOSE_BUTTON) &&
  2193. (opts.coloredTbarMo || !(flags&STD_TOOLBUTTON)) &&
  2194. (flags&CHECK_BUTTON || flags&TOGGLE_BUTTON || !sunken)),
  2195. plastikMouseOver(doColouredMouseOver && MO_PLASTIK==opts.coloredMouseOver),
  2196. colouredMouseOver(doColouredMouseOver &&
  2197. (MO_COLORED==opts.coloredMouseOver || MO_COLORED_THICK==opts.coloredMouseOver ||
  2198. (MO_GLOW==opts.coloredMouseOver && itsFormMode))),
  2199. doEtch(!itsFormMode && doBorder && ETCH_WIDGET(w) && !(flags&CHECK_BUTTON) &&
  2200. DO_EFFECT),
  2201. glowFocus(doEtch && USE_GLOW_FOCUS(flags&Style_MouseOver) && flags&Style_HasFocus && flags&Style_Enabled),
  2202. sunkenToggleMo(sunken && !(flags&Style_Down) && flags&(Style_MouseOver|TOGGLE_BUTTON)),
  2203. horiz(flags&Style_Horizontal);
  2204. const TQColor *cols(custom ? custom : itsBackgroundCols),
  2205. *border(colouredMouseOver ? borderColors(flags, cols) : cols);
  2206. p->save();
  2207. if(doEtch)
  2208. {
  2209. r.addCoords(1, 1, -1, -1);
  2210. br=r;
  2211. }
  2212. // fill
  2213. if(br.width()>0 && br.height()>0)
  2214. {
  2215. // Adjust paint rect, so that gradient is drawn from the same coords as KDE4 and Gtk2
  2216. if(WIDGET_PROGRESSBAR==w && opts.stripedProgress)
  2217. {
  2218. p->save();
  2219. p->setClipRegion(p->clipRegion().eor(TQRegion(br)));
  2220. }
  2221. br.addCoords(1, 1,-1,-1);
  2222. drawBevelGradient(fill, p, br, horiz, sunken, app, w);
  2223. br.addCoords(-1, -1, 1, 1);
  2224. if(WIDGET_PROGRESSBAR==w && opts.stripedProgress)
  2225. p->restore();
  2226. }
  2227. if(!colouredMouseOver && lightBorder)
  2228. br.addCoords(1, 1,-1,-1);
  2229. else if(colouredMouseOver || (draw3d && flags&Style_Raised))
  2230. {
  2231. int dark(/*bevelledButton ? */2/* : 4*/);
  2232. if(colouredMouseOver)
  2233. p->setPen(border[MO_STD_LIGHT(w, sunken)]);
  2234. else
  2235. p->setPen(border[sunken ? dark : 0]);
  2236. if(colouredMouseOver || bevelledButton || draw3dfull)
  2237. {
  2238. //Left & top
  2239. p->drawLine(br.x()+1, br.y()+2, br.x()+1, br.y()+br.height()-3);
  2240. p->drawLine(br.x()+1, br.y()+1, br.x()+br.width()-2, br.y()+1);
  2241. if(colouredMouseOver)
  2242. p->setPen(border[MO_STD_DARK(w)]);
  2243. else
  2244. p->setPen(border[sunken ? 0 : dark]);
  2245. //Right & bottom
  2246. p->drawLine(br.x()+br.width()-2, br.y()+1, br.x()+br.width()-2, br.y()+br.height()-3);
  2247. p->drawLine(br.x()+1, br.y()+br.height()-2, br.x()+br.width()-2, br.y()+br.height()-2);
  2248. br.addCoords(2, 2,-2,-2);
  2249. }
  2250. else
  2251. {
  2252. //Left & top
  2253. p->drawLine(br.x()+1, br.y()+2, br.x()+1, br.y()+br.height()-2);
  2254. p->drawLine(br.x()+1, br.y()+1, br.x()+br.width()-2, br.y()+1);
  2255. br.addCoords(2, 2,-1,-1);
  2256. }
  2257. }
  2258. else
  2259. br.addCoords(1, 1,-1,-1);
  2260. if(!colouredMouseOver && lightBorder && br.width()>0 && br.height()>0)
  2261. {
  2262. TQColor col(cols[APPEARANCE_DULL_GLASS==app ? 1 : 0]);
  2263. p->setPen(col);
  2264. br=r;
  2265. br.addCoords(1,1,-1,-1);
  2266. p->drawRect(br);
  2267. if(IS_CUSTOM(app) || (WIDGET_PROGRESSBAR==w && (!IS_GLASS(app) || opts.fillProgress)))
  2268. br.addCoords(1,1,-1,-1);
  2269. else if(horiz)
  2270. br.addCoords(1,0,-1,-1);
  2271. else
  2272. br.addCoords(0,1,-1,-1);
  2273. }
  2274. // fill
  2275. if(br.width()>0 && br.height()>0 && (!sunken || sunkenToggleMo)) {
  2276. if(plastikMouseOver)
  2277. {
  2278. if(WIDGET_SB_SLIDER==w)
  2279. {
  2280. int len(SB_SLIDER_MO_LEN(horiz ? r.width() : r.height())),
  2281. so(lightBorder ? SLIDER_MO_PLASTIK_BORDER : 1),
  2282. eo(len+so),
  2283. col(SLIDER_MO_SHADE);
  2284. if(horiz)
  2285. {
  2286. drawBevelGradient(itsMouseOverCols[col], p, TQRect(r.x()+so, r.y(), len, r.height()),
  2287. horiz, sunken, app, w);
  2288. drawBevelGradient(itsMouseOverCols[col], p, TQRect(r.x()+r.width()-eo, r.y(), len, r.height()),
  2289. horiz, sunken, app, w);
  2290. }
  2291. else
  2292. {
  2293. drawBevelGradient(itsMouseOverCols[col], p, TQRect(r.x(), r.y()+so, r.width(), len),
  2294. horiz, sunken, app, w);
  2295. drawBevelGradient(itsMouseOverCols[col], p, TQRect(r.x(), r.y()+r.height()-eo, r.width(), len),
  2296. horiz, sunken, app, w);
  2297. }
  2298. }
  2299. else
  2300. {
  2301. bool horizontal((horiz && WIDGET_SB_BUTTON!=w)|| (!horiz && WIDGET_SB_BUTTON==w)),
  2302. thin(WIDGET_SB_BUTTON==w || WIDGET_SPIN==w || ((horiz ? r.height() : r.width())<16));
  2303. p->setPen(itsMouseOverCols[MO_PLASTIK_DARK(w)]);
  2304. if(horizontal)
  2305. {
  2306. p->drawLine(r.x()+1, r.y()+1, r.x()+r.width()-2, r.y()+1);
  2307. p->drawLine(r.x()+1, r.y()+r.height()-2, r.x()+r.width()-2, r.y()+r.height()-2);
  2308. }
  2309. else
  2310. {
  2311. p->drawLine(r.x()+1, r.y()+1, r.x()+1, r.y()+r.height()-2);
  2312. p->drawLine(r.x()+r.width()-2, r.y()+1, r.x()+r.width()-2, r.y()+r.height()-2);
  2313. }
  2314. if(!thin)
  2315. {
  2316. p->setPen(itsMouseOverCols[MO_PLASTIK_LIGHT(w)]);
  2317. if(horizontal)
  2318. {
  2319. p->drawLine(r.x()+1, r.y()+2, r.x()+r.width()-2, r.y()+2);
  2320. p->drawLine(r.x()+1, r.y()+r.height()-3, r.x()+r.width()-2, r.y()+r.height()-3);
  2321. }
  2322. else
  2323. {
  2324. p->drawLine(r.x()+2, r.y()+1, r.x()+2, r.y()+r.height()-2);
  2325. p->drawLine(r.x()+r.width()-3, r.y()+1, r.x()+r.width()-3, r.y()+r.height()-2);
  2326. }
  2327. }
  2328. }
  2329. }
  2330. else if(colouredMouseOver && 0!=round && FULLLY_ROUNDED)
  2331. {
  2332. p->setPen(itsMouseOverCols[MO_STD_LIGHT(w, sunken)]);
  2333. if(round&CORNER_TL)
  2334. p->drawPoint(br.left(), br.top());
  2335. if(round&CORNER_BL)
  2336. p->drawPoint(br.left(), br.bottom());
  2337. if(round&CORNER_BR)
  2338. p->drawPoint(br.right(), br.bottom());
  2339. if(round&CORNER_TR)
  2340. p->drawPoint(br.right(), br.top());
  2341. }
  2342. }
  2343. if(doBorder)
  2344. {
  2345. const TQColor *borderCols=glowFocus ||
  2346. (WIDGET_COMBO==w && USE_GLOW_FOCUS(flags&Style_MouseOver) && flags&Style_HasFocus && flags&Style_Enabled)
  2347. ? itsFocusCols
  2348. : (WIDGET_COMBO==w || WIDGET_COMBO_BUTTON==w) && cols==itsComboBtnCols
  2349. ? flags&Style_MouseOver && MO_GLOW==opts.coloredMouseOver && !sunken
  2350. ? itsMouseOverCols
  2351. : itsButtonCols
  2352. : cols;
  2353. if((!sunken || sunkenToggleMo) && flags&Style_Enabled && !glowFocus &&
  2354. ((((doEtch && WIDGET_OTHER!=w && WIDGET_SLIDER_TROUGH!=w) || WIDGET_COMBO==w || WIDGET_SB_SLIDER==w) &&
  2355. MO_GLOW==opts.coloredMouseOver && flags&Style_MouseOver) ||
  2356. (WIDGET_DEF_BUTTON==w && IND_GLOW==opts.defBtnIndicator)))
  2357. drawBorder(bgnd, p, r, cg, flags, round,
  2358. WIDGET_DEF_BUTTON==w && IND_GLOW==opts.defBtnIndicator &&
  2359. (!(flags&Style_MouseOver) || !itsMouseOverCols)
  2360. ? itsDefBtnCols : itsMouseOverCols, w, doCorners);
  2361. else
  2362. drawBorder(bgnd, p, r, cg, flags, round,
  2363. colouredMouseOver && MO_COLORED_THICK==opts.coloredMouseOver ? itsMouseOverCols : borderCols,
  2364. w, doCorners);
  2365. }
  2366. if(doEtch || glowFocus) {
  2367. if( (!sunken || sunkenToggleMo) &&
  2368. ((WIDGET_OTHER!=w && WIDGET_SLIDER_TROUGH!=w && MO_GLOW==opts.coloredMouseOver && flags&Style_MouseOver) ||
  2369. glowFocus ||
  2370. (WIDGET_DEF_BUTTON==w && IND_GLOW==opts.defBtnIndicator)/* ||
  2371. (flags&Style_HasFocus && FOCUS_FULL==opts.focus)*/ ))
  2372. drawGlow(p, rOrig, cg, WIDGET_DEF_BUTTON==w && flags&Style_MouseOver ? WIDGET_STD_BUTTON : w,
  2373. glowFocus ? itsFocusCols : 0);
  2374. else
  2375. drawEtch(p, rOrig, cg, EFFECT_SHADOW==opts.buttonEffect && WIDGET_BUTTON(w) && !sunken, ROUNDED_NONE==round);
  2376. }
  2377. p->restore();
  2378. }
  2379. void QtCurveStyle::drawGlow(TQPainter *p, const TQRect &r, const TQColorGroup &cg, EWidget w, const TQColor *cols) const
  2380. {
  2381. if(itsMouseOverCols || itsDefBtnCols || cols)
  2382. {
  2383. bool def(WIDGET_DEF_BUTTON==w && IND_GLOW==opts.defBtnIndicator),
  2384. defShade=def && (!itsDefBtnCols ||
  2385. (itsMouseOverCols && itsDefBtnCols[ORIGINAL_SHADE]==itsMouseOverCols[ORIGINAL_SHADE]));
  2386. TQColor col(cols ? cols[GLOW_MO]
  2387. : (def && itsDefBtnCols) || !itsMouseOverCols
  2388. ? itsDefBtnCols[GLOW_DEFBTN] : itsMouseOverCols[GLOW_MO]);
  2389. col=midColorF(cg.background(), col, 1.5-GLOW_ALPHA(defShade));
  2390. p->setPen(col);
  2391. if(ROUND_NONE==opts.round)
  2392. p->drawRect(r);
  2393. else
  2394. {
  2395. p->drawLine(r.x()+2, r.y()+r.height()-1, r.x()+r.width()-3, r.y()+r.height()-1);
  2396. p->drawLine(r.x()+r.width()-1, r.y()+2, r.x()+r.width()-1, r.y()+r.height()-3);
  2397. p->drawLine(r.x()+3, r.y(), r.x()+r.width()-4, r.y());
  2398. p->drawLine(r.x(), r.y()+3, r.x(), r.y()+r.height()-4);
  2399. //p->setPen(midColor(col, cg.background()));
  2400. p->drawLine(r.x()+r.width()-1, r.y()+r.height()-3, r.x()+r.width()-3, r.y()+r.height()-1);
  2401. p->drawLine(r.x(), r.y()+r.height()-3, r.x()+2, r.y()+r.height()-1);
  2402. p->drawLine(r.x(), r.y()+2, r.x()+2, r.y());
  2403. p->drawLine(r.x()+r.width()-3, r.y(), r.x()+r.width()-1, r.y()+2);
  2404. p->setPen(midColor(col, cg.background()));
  2405. p->drawLine(r.x()+r.width()-1, r.y()+r.height()-2, r.x()+r.width()-2, r.y()+r.height()-1);
  2406. p->drawLine(r.x(), r.y()+r.height()-2, r.x()+1, r.y()+r.height()-1);
  2407. p->drawLine(r.x(), r.y()+1, r.x()+1, r.y());
  2408. p->drawLine(r.x()+r.width()-2, r.y(), r.x()+r.width()-1, r.y()+1);
  2409. }
  2410. }
  2411. }
  2412. void QtCurveStyle::drawEtch(TQPainter *p, const TQRect &r, const TQColorGroup &cg, bool raised, bool square) const
  2413. {
  2414. square=square || ROUND_NONE==opts.round;
  2415. int mod(square ? 0 : 2);
  2416. {
  2417. TQColor col(raised ? shade(cg.background(), ETCHED_DARK) : itsBackgroundCols[1]);
  2418. p->setPen(col);
  2419. p->drawLine(r.x()+mod, r.y()+r.height()-1, r.x()+r.width()-(1+mod), r.y()+r.height()-1);
  2420. p->drawLine(r.x()+r.width()-1, r.y()+mod, r.x()+r.width()-1, r.y()+r.height()-(1+mod));
  2421. if(!square)
  2422. {
  2423. p->setPen(midColor(raised ? col : itsBackgroundCols[0], cg.background()));
  2424. p->drawLine(r.x()+r.width()-1, r.y()+r.height()-3, r.x()+r.width()-3, r.y()+r.height()-1);
  2425. p->drawLine(r.x()+1, r.y()+r.height()-2, r.x()+2, r.y()+r.height()-1);
  2426. p->drawLine(r.x()+r.width()-2, r.y()+1, r.x()+r.width()-1, r.y()+2);
  2427. }
  2428. }
  2429. if(!raised)
  2430. {
  2431. TQColor darkCol(shade(cg.background(), ETCHED_DARK));
  2432. p->setPen(darkCol);
  2433. p->drawLine(r.x()+1+mod, r.y(), r.x()+r.width()-(2+mod), r.y());
  2434. p->drawLine(r.x(), r.y()+1+mod, r.x(), r.y()+r.height()-(2+mod));
  2435. if(!square)
  2436. {
  2437. p->setPen(midColor(darkCol, cg.background()));
  2438. p->drawLine(r.x(), r.y()+2, r.x()+2, r.y());
  2439. p->drawLine(r.x()+r.width()-3, r.y(), r.x()+r.width()-2, r.y()+1);
  2440. p->drawLine(r.x(), r.y()+r.height()-3, r.x()+1, r.y()+r.height()-2);
  2441. }
  2442. }
  2443. }
  2444. void QtCurveStyle::drawBorder(const TQColor &bgnd, TQPainter *p, const TQRect &r, const TQColorGroup &cg,
  2445. SFlags flags, int round, const TQColor *custom, EWidget w, bool doCorners,
  2446. EBorder borderProfile, bool blendBorderColors, int borderVal) const
  2447. {
  2448. EAppearance app(widgetApp(w, &opts));
  2449. const TQColor *cols(custom ? custom : itsBackgroundCols);
  2450. TQColor border(flags&Style_ButtonDefault && IND_FONT_COLOR==opts.defBtnIndicator &&
  2451. flags&Style_Enabled
  2452. ? cg.buttonText()
  2453. : cols[WIDGET_PROGRESSBAR==w
  2454. ? PBAR_BORDER
  2455. : !(flags&Style_Enabled) && (WIDGET_BUTTON(w) || WIDGET_SLIDER_TROUGH==w ||
  2456. flags&CHECK_BUTTON)
  2457. ? DISABLED_BORDER
  2458. : itsMouseOverCols==cols && IS_SLIDER(w)
  2459. ? SLIDER_MO_BORDER_VAL
  2460. : borderVal]);
  2461. bool hasFocus(cols==itsFocusCols /* CPD USED TO INDICATE FOCUS! */),
  2462. hasMouseOver(cols==itsMouseOverCols && ENTRY_MO);
  2463. if(WIDGET_TAB_BOT==w || WIDGET_TAB_TOP==w)
  2464. cols=itsBackgroundCols;
  2465. switch(borderProfile)
  2466. {
  2467. case BORDER_FLAT:
  2468. break;
  2469. case BORDER_RAISED:
  2470. case BORDER_SUNKEN:
  2471. case BORDER_LIGHT:
  2472. if(flags&Style_Enabled && (hasMouseOver || hasFocus) && (WIDGET_ENTRY==w || WIDGET_SCROLLVIEW==w || WIDGET_COMBO==w || WIDGET_SPIN==w))
  2473. p->setPen(midColorF(cg.background(), cols[BORDER_RAISED==borderProfile || BORDER_LIGHT==borderProfile
  2474. ? 0 : FRAME_DARK_SHADOW], 1.5-ENTRY_INNER_ALPHA));
  2475. else
  2476. p->setPen(flags&Style_Enabled && (BORDER_RAISED==borderProfile || BORDER_LIGHT==borderProfile || APPEARANCE_FLAT!=app)
  2477. ? blendBorderColors
  2478. ? midColor(cg.background(), cols[BORDER_RAISED==borderProfile
  2479. ? 0 : FRAME_DARK_SHADOW]) // Was base???
  2480. : cols[BORDER_RAISED==borderProfile || BORDER_LIGHT==borderProfile ? 0 : FRAME_DARK_SHADOW]
  2481. : cg.background());
  2482. p->drawLine(r.x()+1, r.y()+1, r.x()+1, r.y()+r.height()-2);
  2483. p->drawLine(r.x()+1, r.y()+1, r.x()+r.width()-2, r.y()+1);
  2484. if(!hasFocus && !hasMouseOver && BORDER_LIGHT!=borderProfile)
  2485. p->setPen(WIDGET_SCROLLVIEW==w
  2486. ? cg.background()
  2487. : WIDGET_ENTRY==w
  2488. ? cg.base()
  2489. : flags&Style_Enabled && (BORDER_SUNKEN==borderProfile || APPEARANCE_FLAT!=app ||
  2490. WIDGET_TAB_TOP==w || WIDGET_TAB_BOT==w)
  2491. ? blendBorderColors
  2492. ? midColor(cg.background(), cols[BORDER_RAISED==borderProfile
  2493. ? FRAME_DARK_SHADOW : 0]) // Was base???
  2494. : cols[BORDER_RAISED==borderProfile ? FRAME_DARK_SHADOW : 0]
  2495. : cg.background());
  2496. p->drawLine(r.x()+r.width()-2, r.y()+1, r.x()+r.width()-2, r.y()+r.height()-2);
  2497. p->drawLine(r.x()+1, r.y()+r.height()-2, r.x()+r.width()-2, r.y()+r.height()-2);
  2498. }
  2499. if(ROUNDED && ROUNDED_NONE!=round)
  2500. {
  2501. bool largeArc(WIDGET_FOCUS!=w && FULLLY_ROUNDED && !(flags&CHECK_BUTTON) &&
  2502. r.width()>=MIN_ROUND_FULL_SIZE && r.height()>=MIN_ROUND_FULL_SIZE &&
  2503. !(flags&DW_CLOSE_BUTTON) && (WIDGET_PROGRESSBAR!=w || opts.fillProgress));
  2504. p->setPen(border);
  2505. if(itsFormMode)
  2506. {
  2507. // If we're itsFormMode (KHTML) then we need to draw the aa borders using pixmaps
  2508. // - so we need to draw 2 pixels away from each corner (so that the alpha
  2509. // blend lets through the background color...
  2510. p->drawLine(r.x()+2, r.y(), r.x()+r.width()-3, r.y());
  2511. p->drawLine(r.x()+2, r.y()+r.height()-1, r.x()+r.width()-3, r.y()+r.height()-1);
  2512. p->drawLine(r.x(), r.y()+2, r.x(), r.y()+r.height()-3);
  2513. p->drawLine(r.x()+r.width()-1, r.y()+2, r.x()+r.width()-1, r.y()+r.height()-3);
  2514. // If not rounding a corner need to draw the missing pixels!
  2515. if(!(round&CORNER_TL) || !largeArc)
  2516. {
  2517. p->drawPoint(r.x()+1, r.y());
  2518. p->drawPoint(r.x(), r.y()+1);
  2519. }
  2520. if(!(round&CORNER_TR) || !largeArc)
  2521. {
  2522. p->drawPoint(r.x()+r.width()-2, r.y());
  2523. p->drawPoint(r.x()+r.width()-1, r.y()+1);
  2524. }
  2525. if(!(round&CORNER_BR) || !largeArc)
  2526. {
  2527. p->drawPoint(r.x()+r.width()-2, r.y()+r.height()-1);
  2528. p->drawPoint(r.x()+r.width()-1, r.y()+r.height()-2);
  2529. }
  2530. if(!(round&CORNER_BL) || !largeArc)
  2531. {
  2532. p->drawPoint(r.x()+1, r.y()+r.height()-1);
  2533. p->drawPoint(r.x(), r.y()+r.height()-2);
  2534. }
  2535. }
  2536. else
  2537. {
  2538. // If we're not itsFormMode (ie. not KHTML) then we can just draw 1 pixel in - as
  2539. // we can overwrite with the alpha colour.
  2540. p->drawLine(r.x()+1, r.y(), r.x()+r.width()-2, r.y());
  2541. p->drawLine(r.x()+1, r.y()+r.height()-1, r.x()+r.width()-2, r.y()+r.height()-1);
  2542. p->drawLine(r.x(), r.y()+1, r.x(), r.y()+r.height()-2);
  2543. p->drawLine(r.x()+r.width()-1, r.y()+1, r.x()+r.width()-1, r.y()+r.height()-2);
  2544. }
  2545. //if(!opts.fillProgress || WIDGET_PROGRESSBAR!=w)
  2546. {
  2547. TQColor largeArcMid(midColor(border, bgnd)),
  2548. aaColor(midColor(custom ? custom[3] : itsBackgroundCols[3], bgnd));
  2549. TQPixmap *pix=itsFormMode ? getPixelPixmap(border) : 0L;
  2550. if(round&CORNER_TL)
  2551. {
  2552. if(largeArc)
  2553. {
  2554. p->drawPoint(r.x()+1, r.y()+1);
  2555. if(itsFormMode)
  2556. {
  2557. p->drawPixmap(r.x(), r.y()+1, *pix);
  2558. p->drawPixmap(r.x()+1, r.y(), *pix);
  2559. }
  2560. else
  2561. {
  2562. p->setPen(largeArcMid);
  2563. p->drawLine(r.x(), r.y()+1, r.x()+1, r.y());
  2564. }
  2565. }
  2566. if(doCorners) {
  2567. if(itsFormMode)
  2568. {
  2569. if(!largeArc)
  2570. p->drawPixmap(r.x(), r.y(), *pix);
  2571. }
  2572. else
  2573. {
  2574. p->setPen(largeArc ? bgnd : aaColor);
  2575. p->drawPoint(r.x(), r.y());
  2576. }
  2577. }
  2578. }
  2579. else
  2580. p->drawPoint(r.x(), r.y());
  2581. p->setPen(border);
  2582. if(round&CORNER_TR)
  2583. {
  2584. if(largeArc)
  2585. {
  2586. p->drawPoint(r.x()+r.width()-2, r.y()+1);
  2587. if(itsFormMode)
  2588. {
  2589. p->drawPixmap(r.x()+r.width()-2, r.y(), *pix);
  2590. p->drawPixmap(r.x()+r.width()-1, r.y()+1, *pix);
  2591. }
  2592. else
  2593. {
  2594. p->setPen(largeArcMid);
  2595. p->drawLine(r.x()+r.width()-2, r.y(), r.x()+r.width()-1, r.y()+1);
  2596. }
  2597. }
  2598. if(doCorners) {
  2599. if(itsFormMode)
  2600. {
  2601. if(!largeArc)
  2602. p->drawPixmap(r.x()+r.width()-1, r.y(), *pix);
  2603. }
  2604. else
  2605. {
  2606. p->setPen(largeArc ? bgnd : aaColor);
  2607. p->drawPoint(r.x()+r.width()-1, r.y());
  2608. }
  2609. }
  2610. }
  2611. else
  2612. p->drawPoint(r.x()+r.width()-1, r.y());
  2613. p->setPen(border);
  2614. if(round&CORNER_BR)
  2615. {
  2616. if(largeArc)
  2617. {
  2618. p->drawPoint(r.x()+r.width()-2, r.y()+r.height()-2);
  2619. if(itsFormMode)
  2620. {
  2621. p->drawPixmap(r.x()+r.width()-2, r.y()+r.height()-1, *pix);
  2622. p->drawPixmap(r.x()+r.width()-1, r.y()+r.height()-2, *pix);
  2623. }
  2624. else
  2625. {
  2626. p->setPen(largeArcMid);
  2627. p->drawLine(r.x()+r.width()-2, r.y()+r.height()-1, r.x()+r.width()-1,
  2628. r.y()+r.height()-2);
  2629. }
  2630. }
  2631. if(doCorners) {
  2632. if(itsFormMode)
  2633. {
  2634. if(!largeArc)
  2635. p->drawPixmap(r.x()+r.width()-1, r.y()+r.height()-1, *pix);
  2636. }
  2637. else
  2638. {
  2639. p->setPen(largeArc ? bgnd : aaColor);
  2640. p->drawPoint(r.x()+r.width()-1, r.y()+r.height()-1);
  2641. }
  2642. }
  2643. }
  2644. else
  2645. p->drawPoint(r.x()+r.width()-1, r.y()+r.height()-1);
  2646. p->setPen(border);
  2647. if(round&CORNER_BL)
  2648. {
  2649. if(largeArc)
  2650. {
  2651. p->drawPoint(r.x()+1, r.y()+r.height()-2);
  2652. if(itsFormMode)
  2653. {
  2654. p->drawPixmap(r.x(), r.y()+r.height()-2, *pix);
  2655. p->drawPixmap(r.x()+1, r.y()+r.height()-1, *pix);
  2656. }
  2657. else
  2658. {
  2659. p->setPen(largeArcMid);
  2660. p->drawLine(r.x(), r.y()+r.height()-2, r.x()+1, r.y()+r.height()-1);
  2661. }
  2662. }
  2663. if(doCorners) {
  2664. if(itsFormMode)
  2665. {
  2666. if(!largeArc)
  2667. p->drawPixmap(r.x(), r.y()+r.height()-1, *pix);
  2668. }
  2669. else
  2670. {
  2671. p->setPen(largeArc ? bgnd : aaColor);
  2672. p->drawPoint(r.x(), r.y()+r.height()-1);
  2673. }
  2674. }
  2675. }
  2676. else
  2677. p->drawPoint(r.x(), r.y()+r.height()-1);
  2678. }
  2679. }
  2680. else
  2681. {
  2682. p->setPen(border);
  2683. p->setBrush(NoBrush);
  2684. p->drawRect(r);
  2685. }
  2686. }
  2687. void QtCurveStyle::drawMdiIcon(TQPainter *painter, const TQColor &color, const TQColor &shadow, const TQRect &r, bool sunken, int margin,
  2688. SubControl button) const
  2689. {
  2690. if(!sunken)
  2691. drawWindowIcon(painter, shadow, adjusted(r, 1, 1, 1, 1), sunken, margin, button);
  2692. drawWindowIcon(painter, color, r, sunken, margin, button);
  2693. }
  2694. void QtCurveStyle::drawWindowIcon(TQPainter *painter, const TQColor &color, const TQRect &r, bool sunken, int margin, SubControl button) const
  2695. {
  2696. TQRect rect(r);
  2697. // Icons look best at 22x22...
  2698. if(rect.height()>22)
  2699. {
  2700. int diff=(rect.height()-22)/2;
  2701. adjust(rect, diff, diff, -diff, -diff);
  2702. }
  2703. if(sunken)
  2704. adjust(rect, 1, 1, 1, 1);
  2705. if(margin)
  2706. adjust(rect, margin, margin, -margin, -margin);
  2707. painter->setPen(color);
  2708. switch(button)
  2709. {
  2710. case SC_TitleBarMinButton:
  2711. painter->drawLine(rect.center().x() - 2, rect.center().y() + 3, rect.center().x() + 3, rect.center().y() + 3);
  2712. painter->drawLine(rect.center().x() - 2, rect.center().y() + 4, rect.center().x() + 3, rect.center().y() + 4);
  2713. painter->drawLine(rect.center().x() - 3, rect.center().y() + 3, rect.center().x() - 3, rect.center().y() + 4);
  2714. painter->drawLine(rect.center().x() + 4, rect.center().y() + 3, rect.center().x() + 4, rect.center().y() + 4);
  2715. break;
  2716. case SC_TitleBarMaxButton:
  2717. painter->drawRect(rect); // adjusted(rect, 0, 0, -1, -1));
  2718. painter->drawLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.top() + 1);
  2719. painter->drawPoint(rect.topLeft());
  2720. painter->drawPoint(rect.topRight());
  2721. painter->drawPoint(rect.bottomLeft());
  2722. painter->drawPoint(rect.bottomRight());
  2723. break;
  2724. case SC_TitleBarCloseButton:
  2725. painter->drawLine(rect.left() + 1, rect.top(), rect.right(), rect.bottom() - 1);
  2726. painter->drawLine(rect.left(), rect.top() + 1, rect.right() - 1, rect.bottom());
  2727. painter->drawLine(rect.right() - 1, rect.top(), rect.left(), rect.bottom() - 1);
  2728. painter->drawLine(rect.right(), rect.top() + 1, rect.left() + 1, rect.bottom());
  2729. painter->drawPoint(rect.topLeft());
  2730. painter->drawPoint(rect.topRight());
  2731. painter->drawPoint(rect.bottomLeft());
  2732. painter->drawPoint(rect.bottomRight());
  2733. painter->drawLine(rect.left() + 1, rect.top() + 1, rect.right() - 1, rect.bottom() - 1);
  2734. painter->drawLine(rect.left() + 1, rect.bottom() - 1, rect.right() - 1, rect.top() + 1);
  2735. break;
  2736. case SC_TitleBarNormalButton:
  2737. {
  2738. TQRect r2 = adjusted(rect, 0, 3, -3, 0);
  2739. painter->drawRect(r2); // adjusted(r2, 0, 0, -1, -1));
  2740. painter->drawLine(r2.left() + 1, r2.top() + 1, r2.right() - 1, r2.top() + 1);
  2741. painter->drawPoint(r2.topLeft());
  2742. painter->drawPoint(r2.topRight());
  2743. painter->drawPoint(r2.bottomLeft());
  2744. painter->drawPoint(r2.bottomRight());
  2745. TQRect backWindowRect(adjusted(rect, 3, 0, 0, -3));
  2746. TQRegion clipRegion(backWindowRect);
  2747. clipRegion -= r2;
  2748. if(sunken)
  2749. adjust(backWindowRect, 1, 1, 1, 1);
  2750. painter->drawRect(backWindowRect); // adjusted(backWindowRect, 0, 0, -1, -1));
  2751. painter->drawLine(backWindowRect.left() + 1, backWindowRect.top() + 1,
  2752. backWindowRect.right() - 1, backWindowRect.top() + 1);
  2753. painter->drawPoint(backWindowRect.topLeft());
  2754. painter->drawPoint(backWindowRect.topRight());
  2755. painter->drawPoint(backWindowRect.bottomLeft());
  2756. painter->drawPoint(backWindowRect.bottomRight());
  2757. break;
  2758. }
  2759. case SC_TitleBarShadeButton:
  2760. ::drawArrow(painter, rect, color, PE_ArrowUp, opts, true);
  2761. break;
  2762. case SC_TitleBarUnshadeButton:
  2763. ::drawArrow(painter, rect, color, PE_ArrowDown, opts, true);
  2764. default:
  2765. break;
  2766. }
  2767. }
  2768. void QtCurveStyle::drawEntryField(TQPainter *p, const TQRect &rx, const TQColorGroup &cg,
  2769. SFlags flags, EntryColor coloration, int round, EWidget w) const
  2770. {
  2771. const TQColor *use(ENTRY_MOUSE_OVER==coloration && itsMouseOverCols
  2772. ? itsMouseOverCols
  2773. : ENTRY_FOCUS==coloration && itsFocusCols
  2774. ? itsFocusCols
  2775. : backgroundColors(cg));
  2776. bool isSpin(WIDGET_SPIN==w),
  2777. doEtch(!itsFormMode && opts.etchEntry && (!isSpin || opts.unifySpin) && WIDGET_COMBO!=w && DO_EFFECT),
  2778. reverse(TQApplication::reverseLayout());
  2779. if(WIDGET_SCROLLVIEW!=w && (opts.square&SQUARE_ENTRY))
  2780. round=ROUNDED_NONE;
  2781. TQRect r(rx);
  2782. if(doEtch)
  2783. r.addCoords(1, 1, -1, -1);
  2784. if(!itsFormMode)
  2785. {
  2786. p->setPen(cg.background());
  2787. p->drawRect(rx);
  2788. }
  2789. if(isSpin || WIDGET_ENTRY==w || WIDGET_COMBO==w)
  2790. {
  2791. if(reverse && isSpin)
  2792. r.addCoords(-1, 0, 0, 0);
  2793. if(isSpin || WIDGET_COMBO==w)
  2794. p->fillRect(r, flags&Style_Enabled ? cg.base() : cg.background());
  2795. }
  2796. if(ENTRY_NONE!=coloration && isSpin && !opts.unifySpin) {
  2797. if(reverse) {
  2798. r.addCoords(1, 0, 0, 0);
  2799. }
  2800. else {
  2801. r.addCoords(0, 0, -1, 0);
  2802. }
  2803. }
  2804. drawBorder(cg.background(), p, r, cg, (SFlags)(flags|Style_Horizontal), round, use,
  2805. WIDGET_SCROLLVIEW==w ? w : WIDGET_ENTRY, true, isSpin && !(flags&Style_Enabled) ? BORDER_FLAT : BORDER_SUNKEN);
  2806. if(doEtch)
  2807. {
  2808. TQRect r(rx);
  2809. p->setClipRegion(r);
  2810. if(!(round&CORNER_TR) && !(round&CORNER_BR))
  2811. r.addCoords(0, 0, 2, 0);
  2812. if(!(round&CORNER_TL) && !(round&CORNER_BL))
  2813. r.addCoords(-2, 0, 0, 0);
  2814. drawEtch(p, r, cg, EFFECT_SHADOW==opts.buttonEffect && WIDGET_BUTTON(w) &&
  2815. !(flags &(Style_Down | Style_On | Style_Sunken)), ROUNDED_NONE==round);
  2816. p->setClipping(false);
  2817. }
  2818. }
  2819. void QtCurveStyle::drawArrow(TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags,
  2820. TQ_PrimitiveElement pe, bool small, bool checkActive) const
  2821. {
  2822. const TQColor &col(flags&Style_Enabled
  2823. ? checkActive && flags&Style_Active
  2824. ? cg.highlightedText()
  2825. : cg.text()
  2826. : cg.mid());
  2827. ::drawArrow(p, r, p->pen().style()==TQPen::NoPen ? col : TQColor(p->pen().color()), pe, opts, small);
  2828. }
  2829. void QtCurveStyle::drawPrimitive(TQ_PrimitiveElement pe, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQRect &r,
  2830. const TQColorGroup &cg, SFlags flags, const TQStyleOption &data) const
  2831. {
  2832. switch(pe)
  2833. {
  2834. case PE_HeaderSectionMenu:
  2835. case PE_HeaderSection:
  2836. {
  2837. // Is it a taskbar button? Kicker uses PE_HeaderSection for these! :-(
  2838. // If the painter device is a TQWidger, assume its not a taskbar button...
  2839. if(APP_KICKER==itsThemedApp && (!p->device() || !dynamic_cast<TQWidget *>(p->device())))
  2840. {
  2841. const TQColor *use(buttonColors(cg));
  2842. if(flags&Style_Down)
  2843. flags=((flags|Style_Down)^Style_Down)| Style_Sunken;
  2844. flags|=Style_Enabled;
  2845. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  2846. #if defined TDE_VERSION && TDE_VERSION >= 0x30400 && TDE_VERSION < 0x30500
  2847. if(HOVER_KICKER==itsHover && itsHoverWidget) // && itsHoverWidget==p->device())
  2848. flags|=Style_MouseOver;
  2849. #endif
  2850. itsFormMode=itsIsTransKicker;
  2851. #endif
  2852. drawLightBevel(p, r, cg, flags|Style_Horizontal, ROUNDED_ALL,
  2853. getFill(flags, use), use, true, false);
  2854. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  2855. itsFormMode=false;
  2856. #endif
  2857. }
  2858. else
  2859. {
  2860. bool isFirst(false), isLast(false), isSort(false);
  2861. TQHeader *header(p && p->device() ? dynamic_cast<TQHeader*>(p->device()) : 0L);
  2862. if (header)
  2863. {
  2864. if(header->parent() && ::tqqt_cast<const TQTable *>(header->parent()))
  2865. {
  2866. TQTable *tbl((TQTable *)(header->parent()));
  2867. if(flags&Style_Horizontal)
  2868. isFirst=tbl->columnAt(r.x()+header->offset())==0;
  2869. else
  2870. isLast=tbl->rowAt(r.y()+header->offset())==(tbl->numRows()-1);
  2871. }
  2872. else
  2873. {
  2874. int index=header->mapToIndex(header->sectionAt(r.x()+header->offset()));
  2875. isFirst = index == 0;
  2876. isSort = header->sortIndicatorSection() == index;
  2877. }
  2878. }
  2879. else if(0==flags) // Header on popup menu?
  2880. { TQWidget *widget(p && p->device() ? dynamic_cast<TQWidget*>(p->device()) : 0L);
  2881. bool menuTitle(widget && 0==qstrcmp(widget->className(), "KPopupTitle"));
  2882. const TQColor *use(buttonColors(cg));
  2883. TQRect r2(r);
  2884. if(menuTitle)
  2885. r2.addCoords(2, 2, -2, -2);
  2886. drawLightBevel(p, r2, cg, flags|Style_Horizontal, ROUNDED_ALL, getFill(flags, use), use);
  2887. break;
  2888. }
  2889. const TQColor *use(flags&Style_Enabled && itsSortedLvColors && isSort
  2890. ? itsSortedLvColors
  2891. : opts.lvButton ? buttonColors(cg) : backgroundColors(cg));
  2892. flags=((flags|Style_Sunken)^Style_Sunken)| Style_Raised;
  2893. if(NO_SECT!=itsHoverSect && HOVER_HEADER==itsHover && itsHoverWidget)
  2894. {
  2895. TQHeader *hd(::tqqt_cast<TQHeader *>(itsHoverWidget));
  2896. if(hd && hd->isClickEnabled(itsHoverSect) && r==hd->sectionRect(itsHoverSect))
  2897. flags|=Style_MouseOver;
  2898. }
  2899. bool sunken(flags &(Style_Down | Style_On | Style_Sunken));
  2900. drawBevelGradient(getFill(flags, use), p, r, flags&Style_Horizontal,
  2901. sunken, opts.lvAppearance, WIDGET_LISTVIEW_HEADER);
  2902. if(APPEARANCE_RAISED==opts.lvAppearance)
  2903. {
  2904. p->setPen(use[4]);
  2905. if(flags&Style_Horizontal)
  2906. p->drawLine(r.x(), r.y()+r.height()-2, r.x()+r.width()-1, r.y()+r.height()-2);
  2907. else
  2908. p->drawLine(r.x()+r.width()-2, r.y(), r.x()+r.width()-2, r.y()+r.height()-1);
  2909. }
  2910. if(flags&Style_Horizontal)
  2911. {
  2912. p->setPen(use[STD_BORDER]);
  2913. p->drawLine(r.x(), r.y()+r.height()-1, r.x()+r.width()-1, r.y()+r.height()-1);
  2914. if(itsMouseOverCols && opts.coloredMouseOver && flags&Style_MouseOver)
  2915. drawHighlight(p, TQRect(r.x(), r.y()+r.height()-2, r.width(), 2), cg, true, true);
  2916. if(!isFirst)
  2917. {
  2918. p->setPen(use[STD_BORDER]);
  2919. p->drawLine(r.x(), r.y()+5, r.x(), r.y()+r.height()-6);
  2920. p->setPen(use[0]);
  2921. p->drawLine(r.x()+1, r.y()+5, r.x()+1, r.y()+r.height()-6);
  2922. }
  2923. }
  2924. else
  2925. {
  2926. p->setPen(use[STD_BORDER]);
  2927. p->drawLine(r.x()+r.width()-1, r.y(), r.x()+r.width()-1, r.y()+r.height()-1);
  2928. if(!isLast)
  2929. {
  2930. p->setPen(use[STD_BORDER]);
  2931. p->drawLine(r.x()+5, r.y()+r.height()-2, r.x()+r.width()-6,
  2932. r.y()+r.height()-2);
  2933. p->setPen(use[0]);
  2934. p->drawLine(r.x()+5, r.y()+r.height()-1, r.x()+r.width()-6,
  2935. r.y()+r.height()-1);
  2936. }
  2937. if(itsMouseOverCols && opts.coloredMouseOver && flags&Style_MouseOver)
  2938. drawHighlight(p, TQRect(r.x(), r.y()+r.height()-3, r.width(), 2), cg, true, true);
  2939. }
  2940. }
  2941. break;
  2942. }
  2943. case PE_HeaderArrow:
  2944. ::drawArrow(p, r, MO_ARROW(cg.buttonText()), flags&Style_Up ? PE_ArrowUp : PE_ArrowDown, opts, false);
  2945. break;
  2946. case PE_ButtonBevel:
  2947. flags|=Style_Enabled;
  2948. case PE_ButtonCommand:
  2949. case PE_ButtonTool:
  2950. case PE_ButtonDropDown:
  2951. {
  2952. const TQColor *use((IND_TINT==opts.defBtnIndicator || IND_SELECTED==opts.defBtnIndicator) && flags&Style_Enabled && flags&Style_ButtonDefault
  2953. ? itsDefBtnCols : buttonColors(cg));
  2954. bool glassMod(PE_ButtonTool==pe && IS_GLASS(opts.appearance) &&
  2955. IS_GLASS(opts.toolbarAppearance)),
  2956. mdi(!(flags&CHECK_BUTTON) && (!(flags&STD_TOOLBUTTON)||flags&NO_ETCH_BUTTON) &&
  2957. PE_ButtonTool==pe && r.width()<=16 && r.height()<=16),
  2958. operaMdi(PE_ButtonTool==pe && APP_OPERA==itsThemedApp && r.width()==16 && r.height()==16);
  2959. // If its not sunken, its raised-don't want flat buttons.
  2960. if(!(flags&Style_Sunken))
  2961. flags|=Style_Raised;
  2962. if(PE_ButtonTool==pe && flags&VERTICAL_TB_BUTTON)
  2963. {
  2964. flags-=VERTICAL_TB_BUTTON;
  2965. if(flags&Style_Horizontal)
  2966. flags-=Style_Horizontal;
  2967. }
  2968. // Dont AA' MDI windows' control buttons...
  2969. itsFormMode=itsFormMode || mdi || operaMdi;
  2970. if(mdi || operaMdi)
  2971. {
  2972. flags|=Style_Horizontal;
  2973. if(!operaMdi)
  2974. {
  2975. if(flags<0x14000000 && !(flags&(Style_Down|Style_On|Style_Sunken|Style_MouseOver)))
  2976. break;
  2977. if(flags<0x14000000)
  2978. use=getMdiColors(cg, true);
  2979. }
  2980. }
  2981. drawLightBevel(/*flags&DW_CLOSE_BUTTON
  2982. ? cg.background().dark(DW_BGND)
  2983. : */cg.background(),
  2984. p, r, cg, glassMod ? flags : flags|Style_Horizontal,
  2985. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  2986. (APP_KORN==itsThemedApp && itsIsTransKicker && PE_ButtonTool==pe) ||
  2987. #endif
  2988. operaMdi || mdi
  2989. ? ROUNDED_NONE
  2990. : ROUNDED_ALL,
  2991. getFill(flags, use, false,
  2992. flags&Style_ButtonDefault && flags&Style_Enabled && IND_DARKEN==opts.defBtnIndicator),
  2993. use, true, true,
  2994. flags&NO_ETCH_BUTTON
  2995. ? WIDGET_NO_ETCH_BTN
  2996. : flags&Style_ButtonDefault && flags&Style_Enabled && IND_COLORED!=opts.defBtnIndicator
  2997. ? WIDGET_DEF_BUTTON
  2998. : WIDGET_STD_BUTTON);
  2999. if(IND_COLORED==opts.defBtnIndicator && flags&Style_ButtonDefault && flags&Style_Enabled)
  3000. {
  3001. TQRegion outer(r);
  3002. TQRect r2(r);
  3003. if(!itsFormMode && DO_EFFECT)
  3004. r2.addCoords(1, 1, -1, -1);
  3005. r2.addCoords(COLORED_BORDER_SIZE, COLORED_BORDER_SIZE, -COLORED_BORDER_SIZE,
  3006. -COLORED_BORDER_SIZE);
  3007. TQRegion inner(r2);
  3008. p->setClipRegion(outer.eor(inner));
  3009. drawLightBevel(p, r, cg, glassMod ? flags : flags|Style_Horizontal,
  3010. flags&CHECK_BUTTON
  3011. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  3012. || (APP_KORN==itsThemedApp && itsIsTransKicker && PE_ButtonTool==pe)
  3013. #endif
  3014. ? ROUNDED_NONE : ROUNDED_ALL,
  3015. itsDefBtnCols[MO_DEF_BTN], itsDefBtnCols, true, true,
  3016. WIDGET_DEF_BUTTON);
  3017. p->setClipping(false);
  3018. }
  3019. itsFormMode=false;
  3020. break;
  3021. }
  3022. case PE_ButtonDefault:
  3023. switch(opts.defBtnIndicator)
  3024. {
  3025. case IND_CORNER:
  3026. {
  3027. TQPointArray points;
  3028. bool sunken(flags&Style_Down || flags&Style_Sunken);
  3029. int offset(sunken ? 5 : 4),
  3030. etchOffset(DO_EFFECT ? 1 : 0);
  3031. const TQColor *cols(itsFocusCols ? itsFocusCols : itsHighlightCols);
  3032. points.setPoints(3, r.x()+offset+etchOffset, r.y()+offset+etchOffset, r.x()+offset+6+etchOffset, r.y()+offset+etchOffset,
  3033. r.x()+offset+etchOffset, r.y()+offset+6+etchOffset);
  3034. p->setBrush(cols[sunken ? 0 : 4]);
  3035. p->setPen(cols[sunken ? 0 : 4]);
  3036. p->drawPolygon(points);
  3037. break;
  3038. }
  3039. default:
  3040. break;
  3041. }
  3042. break;
  3043. case PE_CheckMark:
  3044. if(flags&Style_On)
  3045. {
  3046. TQPixmap *pix(getPixmap(checkRadioCol(flags, cg), PIX_CHECK, 1.0));
  3047. p->drawPixmap(r.center().x()-(pix->width()/2), r.center().y()-(pix->height()/2),
  3048. *pix);
  3049. }
  3050. else if (!(flags&Style_Off)) // tri-state
  3051. {
  3052. int x(r.center().x()), y(r.center().y());
  3053. p->setPen(checkRadioCol(flags, cg));
  3054. p->drawLine(x-3, y, x+3, y);
  3055. p->drawLine(x-3, y+1, x+3, y+1);
  3056. }
  3057. break;
  3058. case PE_CheckListController:
  3059. {
  3060. TQCheckListItem *item(data.checkListItem());
  3061. if(item)
  3062. {
  3063. const TQColor *bc(borderColors(flags, 0L)),
  3064. *btn(buttonColors(cg)),
  3065. *use(bc ? bc : btn);
  3066. int x(r.x()+1), y(r.y()+2);
  3067. p->drawPixmap(x, y, *getPixmap(use[opts.coloredMouseOver && flags&Style_MouseOver
  3068. ? 4 : BORDER_VAL(flags&Style_Enabled)],
  3069. PIX_RADIO_BORDER, 0.8));
  3070. ::drawArrow(p, TQRect(r.x()-1, r.y()-1, r.width(), r.height()),
  3071. use[opts.coloredMouseOver && flags&Style_MouseOver ? 4:5], PE_ArrowDown, opts);
  3072. }
  3073. break;
  3074. }
  3075. case PE_CheckListIndicator:
  3076. {
  3077. TQCheckListItem *item(data.checkListItem());
  3078. if(item)
  3079. {
  3080. TQListView *lv(item->listView());
  3081. p->setPen(TQPen(flags&Style_Enabled ? cg.text()
  3082. : lv->palette().color(TQPalette::Disabled,
  3083. TQColorGroup::Text)));
  3084. if (flags&Style_Selected)
  3085. {
  3086. flags-=Style_Selected;
  3087. if(!lv->rootIsDecorated() && !((item->parent() && 1==item->parent()->rtti() &&
  3088. TQCheckListItem::Controller==((TQCheckListItem*)item->parent())->type())))
  3089. {
  3090. p->fillRect(0, 0, r.x()+lv->itemMargin()+r.width()+4, item->height(),
  3091. cg.brush(TQColorGroup::Highlight));
  3092. if(item->isEnabled())
  3093. {
  3094. p->setPen(TQPen(cg.highlightedText()));
  3095. flags+=Style_Selected;
  3096. }
  3097. }
  3098. }
  3099. TQRect checkRect(r.x()+1, r.y()+1, opts.crSize, opts.crSize);
  3100. drawPrimitive(PE_Indicator, p, ceData, elementFlags, checkRect, cg, flags|LISTVIEW_ITEM);
  3101. }
  3102. break;
  3103. }
  3104. case PE_IndicatorMask:
  3105. if(ROUNDED)
  3106. {
  3107. p->fillRect(r, color0);
  3108. p->fillRect(r.x()+1, r.y(), r.width()-2, r.height(), color1);
  3109. p->setPen(color1);
  3110. p->drawLine(r.x(), r.y()+1, r.x(), r.y()+r.height()-2);
  3111. p->drawLine(r.x()+r.width()-1, r.y()+1, r.x()+r.width()-1, r.y()+r.height()-2);
  3112. }
  3113. else
  3114. p->fillRect(r, color1);
  3115. break;
  3116. case PE_Indicator:
  3117. {
  3118. bool doEtch(DO_EFFECT && !itsFormMode && !(flags&LISTVIEW_ITEM)),
  3119. on(flags&Style_On || !(flags&Style_Off)),
  3120. sunken(flags&Style_Down);
  3121. TQRect rect(doEtch ? TQRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2) : r);
  3122. SFlags sflags(!(flags&Style_Off) ? flags|Style_On : flags);
  3123. if(sunken || (!itsFormMode && HOVER_NONE==itsHover))
  3124. sflags&=~Style_MouseOver;
  3125. bool glowFocus(USE_GLOW_FOCUS(flags&Style_MouseOver) && sflags&Style_Enabled && sflags&Style_HasFocus),
  3126. glow(doEtch && sflags&Style_Enabled && ((MO_GLOW==opts.coloredMouseOver && sflags&Style_MouseOver) || glowFocus));
  3127. const TQColor *bc(glowFocus ? itsFocusCols : borderColors(sflags, 0L)),
  3128. *btn(checkRadioColors(cg, sflags)),
  3129. *use(bc ? bc : btn),
  3130. &bgnd(opts.crButton
  3131. ? getFill(flags, btn, true)
  3132. : sflags&Style_Enabled && !sunken
  3133. ? MO_NONE==opts.coloredMouseOver && !opts.crHighlight && sflags&Style_MouseOver
  3134. ? use[CR_MO_FILL]
  3135. : cg.base()
  3136. : cg.background());
  3137. EWidget wid=opts.crButton ? WIDGET_STD_BUTTON : WIDGET_TROUGH;
  3138. EAppearance app=opts.crButton ? opts.appearance : APPEARANCE_INVERTED;
  3139. bool drawSunken=opts.crButton ? sunken : false,
  3140. lightBorder=DRAW_LIGHT_BORDER(drawSunken, wid, app),
  3141. draw3dFull=!lightBorder && DRAW_3D_FULL_BORDER(drawSunken, app),
  3142. draw3d=draw3dFull || (!lightBorder && DRAW_3D_BORDER(drawSunken, app)),
  3143. drawLight=opts.crButton && !drawSunken && (lightBorder || draw3d),
  3144. drawDark=drawLight && draw3dFull && !lightBorder;
  3145. if(IS_FLAT(opts.appearance))
  3146. p->fillRect(TQRect(rect.x()+1, rect.y()+1, rect.width()-2, rect.height()-2), bgnd);
  3147. else
  3148. drawBevelGradient(bgnd, p, TQRect(rect.x()+1, rect.y()+1, rect.width()-2, rect.height()-2), true,
  3149. drawSunken, app, wid);
  3150. if(MO_NONE!=opts.coloredMouseOver && !glow && sflags&Style_MouseOver && sflags&Style_Enabled)
  3151. {
  3152. p->setPen(use[CR_MO_FILL]);
  3153. p->drawRect(TQRect(rect.x()+1, rect.y()+1, rect.width()-2, rect.height()-2));
  3154. // p->drawRect(TQRect(rect.x()+2, rect.y()+2, rect.width()-4, rect.height()-4));
  3155. }
  3156. else if(!opts.crButton || drawLight)
  3157. {
  3158. p->setPen(drawLight ? btn[LIGHT_BORDER(app)] : midColor(sflags&Style_Enabled ? cg.base() : cg.background(), use[3]));
  3159. if(lightBorder)
  3160. p->drawRect(TQRect(rect.x()+1, rect.y()+1, rect.width()-2, rect.height()-2));
  3161. else
  3162. {
  3163. p->drawLine(rect.x()+1, rect.y()+1, rect.x()+1, rect.y()+rect.height()-2);
  3164. p->drawLine(rect.x()+1, rect.y()+1, rect.x()+rect.width()-2, rect.y()+1);
  3165. if(drawDark)
  3166. {
  3167. p->setPen(btn[2]);
  3168. p->drawLine(rect.x()+rect.width()-2, rect.y()+1,
  3169. rect.x()+rect.width()-2, rect.y()+rect.height()-2);
  3170. p->drawLine(rect.x()+1, rect.y()+rect.height()-2,
  3171. rect.x()+rect.width()-2, rect.y()+rect.height()-2);
  3172. }
  3173. }
  3174. }
  3175. drawBorder(cg.background(), p, rect, cg, (SFlags)(sflags|Style_Horizontal|CHECK_BUTTON),
  3176. ROUNDED_ALL, use, WIDGET_OTHER, !(flags&LISTVIEW_ITEM));
  3177. if(doEtch)
  3178. {
  3179. TQColor topCol(glow
  3180. ? glowFocus ? itsFocusCols[GLOW_MO] : itsMouseOverCols[GLOW_MO]
  3181. : shade(cg.background(), ETCHED_DARK)),
  3182. botCol(glow
  3183. ? topCol
  3184. : itsBackgroundCols[1]);
  3185. p->setBrush(TQt::NoBrush);
  3186. p->setPen(topCol);
  3187. if(!opts.crButton || EFFECT_SHADOW!=opts.buttonEffect || drawSunken || glow)
  3188. {
  3189. p->drawLine(r.x()+1, r.y(), r.x()+r.width()-2, r.y());
  3190. p->drawLine(r.x(), r.y()+1, r.x(), r.y()+r.height()-2);
  3191. p->setPen(botCol);
  3192. }
  3193. p->drawLine(r.x()+1, r.y()+r.height()-1, r.x()+r.width()-2, r.y()+r.height()-1);
  3194. p->drawLine(r.x()+r.width()-1, r.y()+1, r.x()+r.width()-1, r.y()+r.height()-2);
  3195. }
  3196. if(on)
  3197. drawPrimitive(PE_CheckMark, p, ceData, elementFlags, rect, cg, flags);
  3198. break;
  3199. }
  3200. case PE_CheckListExclusiveIndicator:
  3201. {
  3202. TQCheckListItem *item(data.checkListItem());
  3203. if(item)
  3204. {
  3205. const TQColor *bc(borderColors(flags, 0L)),
  3206. *btn(buttonColors(cg)),
  3207. *use(bc ? bc : btn),
  3208. &on(checkRadioCol(flags, cg));
  3209. int x(r.x()), y(r.y()+2);
  3210. p->drawPixmap(x, y, *getPixmap(use[opts.coloredMouseOver && flags&Style_MouseOver ? 4 : BORDER_VAL(flags&Style_Enabled)],
  3211. PIX_RADIO_BORDER, 0.8));
  3212. if(flags&Style_On)
  3213. p->drawPixmap(x, y, *getPixmap(on, PIX_RADIO_ON, 1.0));
  3214. }
  3215. break;
  3216. }
  3217. case PE_ExclusiveIndicator:
  3218. case PE_ExclusiveIndicatorMask:
  3219. if(PE_ExclusiveIndicatorMask==pe)
  3220. {
  3221. p->fillRect(r, color0);
  3222. p->setPen(TQt::color1);
  3223. p->setBrush(TQt::color1);
  3224. p->drawPie(r, 0, 5760);
  3225. }
  3226. else
  3227. {
  3228. bool doEtch(DO_EFFECT && !itsFormMode),
  3229. sunken(flags&Style_Down);
  3230. TQRect rect(doEtch ? TQRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2) : r);
  3231. int x(rect.x()), y(rect.y());
  3232. TQPointArray clipRegion;
  3233. clipRegion.setPoints(8, x, y+8, x, y+4, x+4, y, x+8, y,
  3234. x+12, y+4, x+12, y+8, x+8, y+12, x+4, y+12);
  3235. SFlags sflags(flags);
  3236. if(sunken || (!itsFormMode && HOVER_NONE==itsHover))
  3237. sflags&=~Style_MouseOver;
  3238. bool glowFocus(USE_GLOW_FOCUS(flags&Style_MouseOver) && sflags&Style_Enabled && sflags&Style_HasFocus),
  3239. glow(doEtch && sflags&Style_Enabled && ((MO_GLOW==opts.coloredMouseOver && sflags&Style_MouseOver) ||
  3240. glowFocus)),
  3241. set(sflags&Style_On),
  3242. coloredMo(MO_NONE!=opts.coloredMouseOver && !glow &&
  3243. sflags&Style_MouseOver && sflags&Style_Enabled);
  3244. const TQColor *bc(glowFocus ? itsFocusCols : borderColors(sflags, 0L)),
  3245. *btn(checkRadioColors(cg, sflags)),
  3246. *use(bc ? bc : btn);
  3247. const TQColor &on(checkRadioCol(flags, cg)),
  3248. &bgnd(opts.crButton
  3249. ? getFill(flags, btn, true)
  3250. : sflags&Style_Enabled && !sunken
  3251. ? MO_NONE==opts.coloredMouseOver && !opts.crHighlight && sflags&Style_MouseOver
  3252. ? use[CR_MO_FILL]
  3253. : cg.base()
  3254. : cg.background());
  3255. EWidget wid=opts.crButton ? WIDGET_STD_BUTTON : WIDGET_TROUGH;
  3256. EAppearance app=opts.crButton ? opts.appearance : APPEARANCE_INVERTED;
  3257. bool drawSunken=opts.crButton ? sunken : EFFECT_NONE!=opts.buttonEffect,
  3258. lightBorder=DRAW_LIGHT_BORDER(drawSunken, wid, app),
  3259. draw3d=!lightBorder &&
  3260. (DRAW_3D_BORDER(drawSunken, app) || DRAW_3D_FULL_BORDER(drawSunken, app)),
  3261. drawLight=opts.crButton && !drawSunken && (lightBorder || draw3d),
  3262. doneShadow=false;
  3263. p->save();
  3264. if(opts.crHighlight && sflags&Style_MouseOver)
  3265. drawBevelGradient(shade(cg.background(), TO_FACTOR(opts.crHighlight)), p, r, true,
  3266. false, opts.selectionAppearance, WIDGET_SELECTION);
  3267. else
  3268. p->fillRect(r, cg.background());
  3269. if(doEtch && !glow && opts.crButton && !drawSunken && EFFECT_SHADOW==opts.buttonEffect)
  3270. {
  3271. p->setBrush(TQt::NoBrush);
  3272. p->setPen(shade(cg.background(), ETCHED_DARK));
  3273. p->drawArc(TQRect(r.x(), r.y(), opts.crSize, opts.crSize), 225*16, 180*16);
  3274. doneShadow=true;
  3275. }
  3276. p->setClipRegion(TQRegion(clipRegion));
  3277. if(IS_FLAT(opts.appearance))
  3278. p->fillRect(TQRect(x+1, y+1, rect.width()-2, rect.height()-2), bgnd);
  3279. else
  3280. drawBevelGradient(bgnd, p, TQRect(x+1, y+1, rect.width()-2, rect.height()-2), true,
  3281. drawSunken, app, wid);
  3282. if(coloredMo)
  3283. {
  3284. p->setPen(use[CR_MO_FILL]);
  3285. p->drawArc(TQRect(x+1, y+1, opts.crSize-2, opts.crSize-2), 0, 360*16);
  3286. // p->drawArc(TQRect(x+2, y+2, opts.crSize-4, opts.crSize-4), 0, 360*16);
  3287. // p->drawArc(TQRect(x+3, y+3, opts.crSize-6, opts.crSize-6), 0, 360*16);
  3288. p->drawPoint(x+2, y+4);
  3289. p->drawPoint(x+4, y+2);
  3290. p->drawPoint(x+8, y+2);
  3291. p->drawPoint(x+10, y+4);
  3292. p->drawPoint(x+2, y+8);
  3293. p->drawPoint(x+4, y+10);
  3294. p->drawPoint(x+8, y+10);
  3295. p->drawPoint(x+10, y+8);
  3296. }
  3297. p->setClipping(false);
  3298. if(doEtch && !doneShadow)
  3299. {
  3300. TQColor topCol(glow
  3301. ? glowFocus ? itsFocusCols[GLOW_MO] : itsMouseOverCols[GLOW_MO]
  3302. : shade(cg.background(), ETCHED_DARK)),
  3303. botCol(glow
  3304. ? topCol
  3305. : itsBackgroundCols[1]);
  3306. p->setBrush(TQt::NoBrush);
  3307. p->setPen(topCol);
  3308. if(drawSunken || glow)
  3309. {
  3310. p->drawArc(TQRect(r.x(), r.y(), opts.crSize, opts.crSize), 45*16, 180*16);
  3311. p->setPen(botCol);
  3312. }
  3313. p->drawArc(TQRect(r.x(), r.y(), opts.crSize, opts.crSize), 225*16, 180*16);
  3314. }
  3315. p->drawPixmap(rect.x(), rect.y(),
  3316. *getPixmap(use[BORDER_VAL(flags&Style_Enabled)], PIX_RADIO_BORDER, 0.8));
  3317. if(TQApplication::NormalColor!=TQApplication::colorSpec() || itsFormMode)
  3318. {
  3319. p->setPen(TQPen(use[opts.coloredMouseOver && sflags&Style_MouseOver ? 4 : BORDER_VAL(flags&Style_Enabled)], 1));
  3320. p->drawArc(rect, 0, 5760);
  3321. }
  3322. if(set)
  3323. p->drawPixmap(rect.x(), rect.y(), *getPixmap(on, PIX_RADIO_ON, 1.0));
  3324. if(!coloredMo && (!opts.crButton || drawLight) && (TQApplication::NormalColor==TQApplication::colorSpec() || itsFormMode))
  3325. p->drawPixmap(rect.x(), rect.y(),
  3326. *getPixmap(btn[drawLight ? LIGHT_BORDER(app)
  3327. : (sflags&Style_MouseOver ? 3 : 4)],
  3328. lightBorder ? PIX_RADIO_INNER : PIX_RADIO_LIGHT));
  3329. p->restore();
  3330. }
  3331. break;
  3332. case PE_DockWindowSeparator:
  3333. {
  3334. TQRect r2(r);
  3335. r2.addCoords(-1, -1, 2, 2);
  3336. drawMenuOrToolBarBackground(p, r2, cg, false, flags&Style_Horizontal);
  3337. switch(opts.toolbarSeparators)
  3338. {
  3339. case LINE_NONE:
  3340. break;
  3341. case LINE_FLAT:
  3342. case LINE_SUNKEN:
  3343. if(r.width()<r.height())
  3344. {
  3345. int x(r.x()+((r.width()-2) / 2));
  3346. p->setPen(itsBackgroundCols[LINE_SUNKEN==opts.toolbarSeparators ? 3 : 4]);
  3347. p->drawLine(x, r.y()+6, x, r.y()+r.height()-7);
  3348. if(LINE_SUNKEN==opts.toolbarSeparators)
  3349. {
  3350. p->setPen(itsBackgroundCols[0]);
  3351. p->drawLine(x+1, r.y()+6, x+1, r.y()+r.height()-7);
  3352. }
  3353. }
  3354. else
  3355. {
  3356. int y(r.y()+((r.height()-2) / 2));
  3357. p->setPen(itsBackgroundCols[LINE_SUNKEN==opts.toolbarSeparators ? 3 : 4]);
  3358. p->drawLine(r.x()+6, y, r.x()+r.width()-7, y);
  3359. if(LINE_SUNKEN==opts.toolbarSeparators)
  3360. {
  3361. p->setPen(itsBackgroundCols[0]);
  3362. p->drawLine(r.x()+6, y+1, r.x()+r.width()-7, y+1);
  3363. }
  3364. }
  3365. break;
  3366. case LINE_1DOT:
  3367. drawDot(p, r, itsBackgroundCols);
  3368. break;
  3369. default:
  3370. case LINE_DOTS:
  3371. drawDots(p, r, !(flags & Style_Horizontal), 1, 5, itsBackgroundCols, 0, 5);
  3372. }
  3373. break;
  3374. }
  3375. case PE_DockWindowResizeHandle:
  3376. if(flags&Style_Horizontal)
  3377. flags-=Style_Horizontal;
  3378. else
  3379. flags+=Style_Horizontal;
  3380. // Fall through intentional
  3381. case PE_Splitter:
  3382. {
  3383. if(itsHoverWidget && itsHoverWidget == p->device())
  3384. flags|=Style_MouseOver;
  3385. const TQColor *use(buttonColors(cg));
  3386. const TQColor *border(borderColors(flags, use));
  3387. TQColor color(cg.background());
  3388. if(0!=opts.tabBgnd && p->device() && inStackWidget(dynamic_cast<const TQWidget *>(p->device())))
  3389. color=shade(color, TO_FACTOR(opts.tabBgnd));
  3390. if(flags&Style_MouseOver && opts.splitterHighlight)
  3391. drawBevelGradient(shade(cg.background(), TO_FACTOR(opts.splitterHighlight)), p, r, !(flags&Style_Horizontal),
  3392. false, opts.selectionAppearance, WIDGET_SELECTION);
  3393. else
  3394. p->fillRect(r, color);
  3395. switch(opts.splitters)
  3396. {
  3397. case LINE_NONE:
  3398. break;
  3399. default:
  3400. case LINE_1DOT:
  3401. drawDot(p, r, border);
  3402. break;
  3403. case LINE_DOTS:
  3404. drawDots(p, r, flags&Style_Horizontal, NUM_SPLITTER_DASHES, 1, border, 0, 5);
  3405. break;
  3406. case LINE_FLAT:
  3407. case LINE_SUNKEN:
  3408. case LINE_DASHES:
  3409. drawLines(p, r, flags&Style_Horizontal, NUM_SPLITTER_DASHES, 3, border, 0, 3, opts.splitters);
  3410. }
  3411. break;
  3412. }
  3413. case PE_GroupBoxFrame:
  3414. case PE_PanelGroupBox:
  3415. if(FRAME_LINE==opts.groupBox)
  3416. {
  3417. TQRect r2(r);
  3418. if(p && p->device() && dynamic_cast<TQGroupBox *>(p->device()) &&
  3419. (!((TQGroupBox *)(p->device()))->title().isEmpty() || ((TQGroupBox *)(p->device()))->isCheckable()))
  3420. r2.addCoords(8, 0, -8, 0);
  3421. p->setPen(backgroundColors(cg)[STD_BORDER]);
  3422. p->drawLine(r2.x(), r2.y(), r2.x()+r2.width()-1, r2.y());
  3423. }
  3424. else if (FRAME_NONE!=opts.groupBox) {
  3425. if(APP_OPENOFFICE==itsThemedApp || data.lineWidth()>0 || data.isDefault())
  3426. {
  3427. const TQColor *use(backgroundColors(cg));
  3428. drawBorder(cg.background(), p, r, cg, (SFlags)(flags|Style_Horizontal),
  3429. opts.square&SQUARE_FRAME ? ROUNDED_NONE : ROUNDED_ALL, use, WIDGET_OTHER, true, BORDER_FLAT);
  3430. }
  3431. else {
  3432. TQCommonStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, data);
  3433. }
  3434. }
  3435. break;
  3436. case PE_WindowFrame:
  3437. if(data.lineWidth()>0 || data.isDefault())
  3438. drawBorder(cg.background(), p, r, cg, (SFlags)(flags|Style_Horizontal),
  3439. ROUNDED_NONE, backgroundColors(cg), WIDGET_MDI_WINDOW, true, BORDER_RAISED, false);
  3440. break;
  3441. case PE_Panel:
  3442. if((APP_KICKER==itsThemedApp && data.isDefault()) ||
  3443. dynamic_cast<TQDockWindow *>(p->device()))
  3444. break;
  3445. if(APP_OPENOFFICE==itsThemedApp || data.lineWidth()>0 || data.isDefault())
  3446. {
  3447. const TQWidget *widget=p && p->device() ? dynamic_cast<const TQWidget *>(p->device()) : 0L;
  3448. bool sv(widget && ::tqqt_cast<const TQScrollView *>(widget)),
  3449. square((opts.square&SQUARE_SCROLLVIEW) &&
  3450. (sv ||
  3451. (widget && widget->parentWidget() && ::tqqt_cast<const TQFrame *>(widget) &&
  3452. widget->parentWidget()->inherits("KateView"))));
  3453. const TQColor *use(opts.highlightScrollViews && /*!square &&*/ flags&Style_HasFocus ? itsHighlightCols :
  3454. backgroundColors(cg));
  3455. // if(square)
  3456. // {
  3457. // p->setPen(use[STD_BORDER]);
  3458. // p->drawLine(r.bottomLeft(), r.topLeft());
  3459. // p->drawLine(r.topLeft(), r.topRight());
  3460. // if(!opts.gtkScrollViews)
  3461. // p->setPen(use[STD_BORDER_BR]);
  3462. // p->drawLine(r.topRight(), r.bottomRight());
  3463. // p->drawLine(r.bottomRight(), r.bottomLeft());
  3464. // }
  3465. // else
  3466. {
  3467. itsFormMode=itsIsTransKicker;
  3468. if(sv && !opts.highlightScrollViews)
  3469. flags&=~Style_HasFocus;
  3470. if(sv && opts.etchEntry && ((TQFrame *)widget)->lineWidth()>2)
  3471. {
  3472. drawEntryField(p, r, cg, flags, flags&Style_Enabled
  3473. ? /*flags&Style_MouseOver
  3474. ? ENTRY_MOUSE_OVER
  3475. :*/ flags&Style_HasFocus
  3476. ? ENTRY_FOCUS
  3477. : ENTRY_NONE
  3478. : ENTRY_NONE, square ? ROUNDED_NONE : ROUNDED_ALL, WIDGET_SCROLLVIEW);
  3479. }
  3480. else
  3481. drawBorder(cg.background(), p, r, cg,
  3482. (SFlags)(flags|Style_Horizontal|Style_Enabled),
  3483. square ? ROUNDED_NONE : ROUNDED_ALL, use, sv ? WIDGET_SCROLLVIEW : WIDGET_OTHER, APP_KICKER!=itsThemedApp,
  3484. itsIsTransKicker ? BORDER_FLAT : (flags&Style_Sunken ? BORDER_SUNKEN : BORDER_RAISED) );
  3485. itsFormMode=false;
  3486. }
  3487. }
  3488. else
  3489. TQCommonStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, data);
  3490. break;
  3491. case PE_PanelTabWidget:
  3492. {
  3493. const TQColor *use(backgroundColors(cg));
  3494. drawBorder(cg.background(), p, r, cg,
  3495. (SFlags)(flags|Style_Horizontal|Style_Enabled),
  3496. opts.square&SQUARE_TAB_FRAME ? ROUNDED_NONE : ROUNDED_ALL, use, WIDGET_OTHER, true,
  3497. opts.borderTab ? BORDER_LIGHT : BORDER_RAISED, false);
  3498. break;
  3499. }
  3500. case PE_PanelPopup:
  3501. {
  3502. const TQColor *use(backgroundColors(cg));
  3503. p->setPen(use[STD_BORDER]);
  3504. p->setBrush(NoBrush);
  3505. p->drawRect(r);
  3506. if(!IS_FLAT_BGND(opts.menuBgndAppearance))
  3507. ;
  3508. else if(USE_LIGHTER_POPUP_MENU)
  3509. {
  3510. p->setPen(/*USE_LIGHTER_POPUP_MENU ? */itsLighterPopupMenuBgndCol/* : cg.background()*/);
  3511. p->drawRect(TQRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2));
  3512. }
  3513. else
  3514. {
  3515. p->setPen(use[0]);
  3516. p->drawLine(r.x()+1, r.y()+1, r.x()+r.width()-2, r.y()+1);
  3517. p->drawLine(r.x()+1, r.y()+1, r.x()+1, r.y()+r.height()-2);
  3518. p->setPen(use[FRAME_DARK_SHADOW]);
  3519. p->drawLine(r.x()+1, r.y()+r.height()-2, r.x()+r.width()-2, r.y()+r.height()-2);
  3520. p->drawLine(r.x()+r.width()-2, r.y()+1, r.x()+r.width()-2, r.y()+r.height()-2);
  3521. }
  3522. break;
  3523. }
  3524. case PE_TabBarBase:
  3525. {
  3526. const TQColor *use(backgroundColors(cg));
  3527. bool flat(APPEARANCE_FLAT==opts.appearance);
  3528. if(data.isDefault() || data.lineWidth()>1)
  3529. {
  3530. p->setPen(use[STD_BORDER]);
  3531. p->setBrush(NoBrush);
  3532. p->drawRect(r);
  3533. qDrawShadePanel(p, r.x()+1, r.y()+1, r.width()-2, r.height()-2,
  3534. TQColorGroup(use[flat ? ORIGINAL_SHADE : 4], use[ORIGINAL_SHADE],
  3535. use[0], use[flat ? ORIGINAL_SHADE : 4], use[2],
  3536. cg.text(), use[ORIGINAL_SHADE]), flags & Style_Sunken,
  3537. data.isDefault() ? 1 : data.lineWidth()-1);
  3538. }
  3539. else
  3540. qDrawShadePanel(p, r, TQColorGroup(use[flat ? ORIGINAL_SHADE : 5],
  3541. use[ORIGINAL_SHADE], use[0], use[flat ? ORIGINAL_SHADE : 5], use[2],
  3542. cg.text(), use[ORIGINAL_SHADE]), flags & Style_Sunken,
  3543. data.isDefault() ? 2 : data.lineWidth());
  3544. break;
  3545. }
  3546. case PE_PanelDockWindow:
  3547. case PE_PanelMenuBar:
  3548. {
  3549. // fix for toolbar lag (from Mosfet Liquid)
  3550. TQWidget *w = dynamic_cast<TQWidget *>(p->device());
  3551. if(w)
  3552. {
  3553. if(PaletteButton==w->backgroundMode())
  3554. w->setBackgroundMode(PaletteBackground);
  3555. if(itsActive && opts.shadeMenubarOnlyWhenActive && SHADE_NONE!=opts.shadeMenubars)
  3556. {
  3557. TQWidget *top=w->topLevelWidget();
  3558. if(top && !top->isActiveWindow())
  3559. itsActive=false;
  3560. }
  3561. }
  3562. drawMenuOrToolBarBackground(p, r, cg, PE_PanelMenuBar==pe,
  3563. PE_PanelMenuBar==pe || r.width()>r.height());
  3564. if(TB_NONE!=opts.toolbarBorders)
  3565. {
  3566. const TQColor *use=PE_PanelMenuBar==pe
  3567. ? menuColors(cg, itsActive)
  3568. : backgroundColors(cg.background());
  3569. bool dark(TB_DARK==opts.toolbarBorders || TB_DARK_ALL==opts.toolbarBorders);
  3570. if(TB_DARK_ALL==opts.toolbarBorders || TB_LIGHT_ALL==opts.toolbarBorders)
  3571. {
  3572. p->setPen(use[0]);
  3573. p->drawLine(r.x(), r.y(), r.x()+r.width()-1, r.y());
  3574. p->drawLine(r.x(), r.y(), r.x(), r.y()+r.width()-1);
  3575. p->setPen(use[dark ? 3 : 4]);
  3576. p->drawLine(r.x(), r.y()+r.height()-1, r.x()+r.width()-1, r.y()+r.height()-1);
  3577. p->drawLine(r.x()+r.width()-1, r.y(), r.x()+r.width()-1, r.y()+r.height()-1);
  3578. }
  3579. else if(PE_PanelMenuBar==pe || r.width()>r.height())
  3580. {
  3581. if(PE_PanelMenuBar!=pe)
  3582. {
  3583. p->setPen(use[0]);
  3584. p->drawLine(r.x(), r.y(), r.x()+r.width()-1, r.y());
  3585. }
  3586. p->setPen(use[dark ? 3 : 4]);
  3587. p->drawLine(r.x(), r.y()+r.height()-1, r.x()+r.width()-1, r.y()+r.height()-1);
  3588. }
  3589. else
  3590. {
  3591. p->setPen(use[0]);
  3592. p->drawLine(r.x(), r.y(), r.x(), r.y()+r.height()-1);
  3593. p->setPen(use[dark ? 3 : 4]);
  3594. p->drawLine(r.x()+r.width()-1, r.y(), r.x()+r.width()-1, r.y()+r.height()-1);
  3595. }
  3596. }
  3597. break;
  3598. }
  3599. case PE_ScrollBarAddLine:
  3600. case PE_ScrollBarSubLine:
  3601. {
  3602. TQRect br(r),
  3603. ar(r);
  3604. const TQColor *use(flags&Style_Enabled ? itsButtonCols : itsBackgroundCols); // buttonColors(cg));
  3605. pe=flags&Style_Horizontal
  3606. ? PE_ScrollBarAddLine==pe ? PE_ArrowRight : PE_ArrowLeft
  3607. : PE_ScrollBarAddLine==pe ? PE_ArrowDown : PE_ArrowUp;
  3608. int round=PE_ArrowRight==pe ? ROUNDED_RIGHT :
  3609. PE_ArrowLeft==pe ? ROUNDED_LEFT :
  3610. PE_ArrowDown==pe ? ROUNDED_BOTTOM :
  3611. PE_ArrowUp==pe ? ROUNDED_TOP : ROUNDED_NONE;
  3612. if(flags&Style_Down && !opts.flatSbarButtons)
  3613. ar.addCoords(1, 1, 1, 1);
  3614. switch(opts.scrollbarType)
  3615. {
  3616. default:
  3617. case SCROLLBAR_WINDOWS:
  3618. break;
  3619. case SCROLLBAR_KDE:
  3620. case SCROLLBAR_PLATINUM:
  3621. if(PE_ArrowLeft==pe && r.x()>3)
  3622. {
  3623. round=ROUNDED_NONE;
  3624. br.addCoords(0, 0, 1, 0);
  3625. if(opts.flatSbarButtons || !opts.vArrows)
  3626. ar.addCoords(1, 0, 1, 0);
  3627. }
  3628. else if(PE_ArrowUp==pe && r.y()>3)
  3629. {
  3630. round=ROUNDED_NONE;
  3631. br.addCoords(0, 0, 0, 1);
  3632. if(opts.flatSbarButtons || !opts.vArrows)
  3633. ar.addCoords(0, 1, 0, 1);
  3634. }
  3635. break;
  3636. case SCROLLBAR_NEXT:
  3637. if(PE_ArrowRight==pe)
  3638. {
  3639. round=ROUNDED_NONE;
  3640. br.addCoords(-1, 0, 0, 0);
  3641. if(opts.flatSbarButtons || !opts.vArrows)
  3642. ar.addCoords(-1, 0, 0, -1);
  3643. }
  3644. else if(PE_ArrowDown==pe)
  3645. {
  3646. round=ROUNDED_NONE;
  3647. br.addCoords(0, -1, 0, 0);
  3648. if(opts.flatSbarButtons || !opts.vArrows)
  3649. ar.addCoords(0, -1, 0, -1);
  3650. }
  3651. break;
  3652. }
  3653. if(!opts.flatSbarButtons)
  3654. // No need to draw background here - drawn in CC_ScrollBar
  3655. // {
  3656. // if(!IS_FLAT(opts.sbarBgndAppearance) && SCROLLBAR_NONE!=opts.scrollbarType)
  3657. // drawBevelGradient(itsBackgroundCols[ORIGINAL_SHADE], p, r, flags&Style_Horizontal, false,
  3658. // opts.sbarBgndAppearance, WIDGET_SB_BGND);
  3659. // else
  3660. // p->fillRect(br, itsBackgroundCols[ORIGINAL_SHADE]);
  3661. // }
  3662. // else
  3663. drawLightBevel(p, br, cg, flags|Style_Raised,
  3664. round, getFill(flags, use), use, true, true, WIDGET_SB_BUTTON);
  3665. ::drawArrow(p, ar, MO_ARROW(cg.buttonText()), pe, opts, false);
  3666. break;
  3667. }
  3668. case PE_ScrollBarSlider:
  3669. drawSbSliderHandle(p, r, cg, flags);
  3670. break;
  3671. case PE_FocusRect:
  3672. #if 0
  3673. // Menu item style selection...
  3674. if(opts.gtkComboMenus)
  3675. {
  3676. TQWidget *widget(dynamic_cast<TQWidget*>(p->device()));
  3677. if(widget && 0==qstrcmp(widget->className(), "TQViewportWidget") &&
  3678. widget->parentWidget() && ::tqqt_cast<TQListBox *>(widget->parentWidget()) &&
  3679. widget->parentWidget()->parentWidget() && ::tqqt_cast<TQComboBox *>(widget->parentWidget()->parentWidget()))
  3680. {
  3681. struct QtCurveListBoxItem : public TQListBoxItem
  3682. {
  3683. void paintContents(TQPainter *p)
  3684. {
  3685. paint(p);
  3686. }
  3687. };
  3688. TQListBox *box=(TQListBox *)widget->parentWidget();
  3689. QtCurveListBoxItem *item=(QtCurveListBoxItem *)(box->item(box->currentItem()));
  3690. if(item)
  3691. {
  3692. //p->fillRect(r, TQt::black);
  3693. drawMenuItem(p, r, cg, false, ROUNDED_ALL,
  3694. USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol
  3695. : itsBackgroundCols[ORIGINAL_SHADE], itsHighlightCols);
  3696. item->paintContents(p);
  3697. break;
  3698. }
  3699. }
  3700. }
  3701. #endif
  3702. if(FOCUS_STANDARD==opts.focus)
  3703. {
  3704. p->setPen(TQt::black);
  3705. p->drawWinFocusRect(r);
  3706. }
  3707. else
  3708. {
  3709. //Figuring out in what beast we are painting...
  3710. TQWidget *widget(dynamic_cast<TQWidget*>(p->device()));
  3711. bool view(widget && (dynamic_cast<TQScrollView*>(widget->parent()) ||
  3712. dynamic_cast<TQListBox*>(widget->parent())));
  3713. if(widget && FOCUS_GLOW==opts.focus &&
  3714. (dynamic_cast<const TQButton *>(widget) || dynamic_cast<const TQComboBox *>(widget)))
  3715. return;
  3716. if(FOCUS_LINE==opts.focus)
  3717. {
  3718. p->setPen(view && flags&Style_Selected
  3719. ? cg.highlightedText()
  3720. : itsFocusCols[FOCUS_SHADE(flags&Style_Selected)]);
  3721. p->drawLine(r.x(), r.y()+r.height()-1, r.x()+r.width()-1, r.y()+r.height()-1);
  3722. }
  3723. else if(r.width()<4 || r.height()<4 || view)
  3724. {
  3725. // TQRect r2(r);
  3726. p->setPen(view ? (flags&Style_Selected ? cg.highlightedText() : cg.text())
  3727. : itsFocusCols[FOCUS_SHADE(flags&Style_Selected)]);
  3728. // if(view)
  3729. // r2.addCoords(0, 0, 0, -2);
  3730. p->drawRect(r); // r2);
  3731. }
  3732. else
  3733. drawBorder(cg.background(), p, r, cg, Style_Horizontal,
  3734. ROUNDED_ALL, itsFocusCols, WIDGET_FOCUS, false, BORDER_FLAT, true,
  3735. FOCUS_SHADE(flags&Style_Selected));
  3736. }
  3737. break;
  3738. case PE_ArrowUp:
  3739. case PE_ArrowDown:
  3740. case PE_ArrowRight:
  3741. case PE_ArrowLeft:
  3742. drawArrow(p, r, cg, flags, pe);
  3743. break;
  3744. case PE_SpinWidgetUp:
  3745. case PE_SpinWidgetDown:
  3746. case PE_SpinWidgetPlus:
  3747. case PE_SpinWidgetMinus:
  3748. {
  3749. TQRect sr(r);
  3750. const TQColor *use(buttonColors(cg));
  3751. bool reverse(TQApplication::reverseLayout());
  3752. if((!opts.unifySpinBtns || flags&Style_Sunken) && !opts.unifySpin)
  3753. drawLightBevel(p, sr, cg, flags|Style_Horizontal, PE_SpinWidgetDown==pe || PE_SpinWidgetMinus==pe
  3754. ? reverse
  3755. ? ROUNDED_BOTTOMLEFT
  3756. : ROUNDED_BOTTOMRIGHT
  3757. : reverse
  3758. ? ROUNDED_TOPLEFT
  3759. : ROUNDED_TOPRIGHT,
  3760. getFill(flags, use), use, true, true, WIDGET_SPIN);
  3761. if(PE_SpinWidgetUp==pe || PE_SpinWidgetDown==pe)
  3762. {
  3763. sr.setY(sr.y()+(PE_SpinWidgetDown==pe ? -2 : 1));
  3764. if(opts.unifySpin)
  3765. {
  3766. sr.addCoords(reverse ? 1 : -1, 0, reverse ? 1 : -1, 0);
  3767. if(!opts.vArrows)
  3768. sr.setY(sr.y()+(PE_SpinWidgetDown==pe ? -2 : 2));
  3769. }
  3770. else if(flags&Style_Sunken)
  3771. sr.addCoords(1, 1, 1, 1);
  3772. ::drawArrow(p, sr, MO_ARROW(cg.buttonText()), PE_SpinWidgetUp==pe ? PE_ArrowUp : PE_ArrowDown, opts, !opts.unifySpin);
  3773. }
  3774. else
  3775. {
  3776. int l(TQMIN(r.width()-6, r.height()-6));
  3777. TQPoint c(r.x()+(r.width()/2), r.y()+(r.height()/2));
  3778. l/=2;
  3779. if(l%2 != 0)
  3780. --l;
  3781. if(flags&Style_Sunken && !opts.unifySpin)
  3782. c+=TQPoint(1, 1);
  3783. p->setPen(MO_ARROW(cg.buttonText()));
  3784. p->drawLine(c.x()-l, c.y(), c.x()+l, c.y());
  3785. if(PE_SpinWidgetPlus==pe)
  3786. p->drawLine(c.x(), c.y()-l, c.x(), c.y()+l);
  3787. }
  3788. break;
  3789. }
  3790. case PE_PanelLineEdit:
  3791. {
  3792. const TQWidget *widget=p && p->device() ? dynamic_cast<const TQWidget *>(p->device()) : 0L;
  3793. bool scrollView=widget && ::tqqt_cast<const TQScrollView *>(widget);
  3794. // if((opts.square&SQUARE_SCROLLVIEW) && scrollView)
  3795. // {
  3796. // const TQColor *use(backgroundColors(cg));
  3797. //
  3798. // p->setPen(use[STD_BORDER]);
  3799. // p->drawLine(r.bottomLeft(), r.topLeft());
  3800. // p->drawLine(r.topLeft(), r.topRight());
  3801. // if(!opts.gtkScrollViews)
  3802. // p->setPen(use[STD_BORDER_BR]);
  3803. // p->drawLine(r.topRight(), r.bottomRight());
  3804. // p->drawLine(r.bottomRight(), r.bottomLeft());
  3805. // break;
  3806. // }
  3807. bool isReadOnly(false),
  3808. isEnabled(true);
  3809. // panel is highlighted by default if it has focus, but if we have access to the
  3810. // widget itself we can try to avoid highlighting in case it's readOnly or disabled.
  3811. if (!scrollView && widget && dynamic_cast<const TQLineEdit*>(widget))
  3812. {
  3813. const TQLineEdit *lineEdit(dynamic_cast<const TQLineEdit*>(widget));
  3814. isReadOnly = lineEdit->isReadOnly();
  3815. isEnabled = lineEdit->isEnabled();
  3816. if(flags&Style_Enabled && isReadOnly)
  3817. flags-=Style_Enabled;
  3818. }
  3819. // HACK!! (From Plastik)
  3820. //
  3821. // In this place there is no reliable way to detect if we are in khtml; the
  3822. // only thing we know is that khtml buffers its widgets into a pixmap. So
  3823. // when the paint device is a TQPixmap, chances are high that we are in khtml.
  3824. // It's possible that this breaks other things, so let's see how it works...
  3825. if (p->device() && dynamic_cast<TQPixmap*>(p->device()))
  3826. itsFormMode=true;
  3827. if(scrollView && !opts.highlightScrollViews)
  3828. flags&=~Style_HasFocus;
  3829. TQRect r2(r);
  3830. r2.addCoords(1, 1, -1, -1);
  3831. // p->fillRect(r2, flags&Style_Enabled ? cg.base() : cg.background());
  3832. drawEntryField(p, r, cg, flags, !isReadOnly && isEnabled
  3833. ? flags&Style_MouseOver && !scrollView
  3834. ? ENTRY_MOUSE_OVER
  3835. : flags&Style_HasFocus
  3836. ? ENTRY_FOCUS
  3837. : ENTRY_NONE
  3838. : ENTRY_NONE,
  3839. (opts.square&SQUARE_SCROLLVIEW) && scrollView ? ROUNDED_NONE : ROUNDED_ALL,
  3840. scrollView ? WIDGET_SCROLLVIEW : WIDGET_ENTRY);
  3841. itsFormMode=false;
  3842. break;
  3843. }
  3844. case PE_StatusBarSection:
  3845. if(opts.drawStatusBarFrames)
  3846. BASE_STYLE::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, data);
  3847. break;
  3848. case PE_SizeGrip:
  3849. {
  3850. TQPointArray a;
  3851. if (TQApplication::reverseLayout())
  3852. {
  3853. a.setPoints(3, 0,0, SIZE_GRIP_SIZE,SIZE_GRIP_SIZE, 0,SIZE_GRIP_SIZE);
  3854. a.translate(r.x(), r.y()+(r.height()-SIZE_GRIP_SIZE));
  3855. }
  3856. else
  3857. {
  3858. a.setPoints(3, SIZE_GRIP_SIZE,0, SIZE_GRIP_SIZE,SIZE_GRIP_SIZE, 0,SIZE_GRIP_SIZE);
  3859. a.translate(r.x()+(r.width()-SIZE_GRIP_SIZE), r.y()+(r.height()-SIZE_GRIP_SIZE));
  3860. }
  3861. p->save();
  3862. p->setBrush(itsBackgroundCols[2]);
  3863. p->setPen(itsBackgroundCols[2]);
  3864. p->drawPolygon(a);
  3865. p->restore();
  3866. break;
  3867. }
  3868. default:
  3869. BASE_STYLE::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, data);
  3870. }
  3871. }
  3872. static TQString elliditide(const TQString &text, const TQFontMetrics &fontMetrics, int space)
  3873. {
  3874. // Chop and insert ellide into title if text is too wide
  3875. TQString title(text);
  3876. if (fontMetrics.width(text) > space)
  3877. {
  3878. TQString ellipsis("...");
  3879. while (fontMetrics.width(title+ellipsis)>space && !title.isEmpty())
  3880. title=title.left(title.length()-1);
  3881. return title+ellipsis;
  3882. }
  3883. return title;
  3884. }
  3885. void QtCurveStyle::drawKStylePrimitive(KStylePrimitive kpe, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
  3886. const TQRect &r, const TQColorGroup &cg, SFlags flags,
  3887. const TQStyleOption &opt, const TQWidget *widget) const
  3888. {
  3889. ELine handles(kpe!=KPE_ToolBarHandle && LINE_DASHES==opts.handles ? LINE_SUNKEN
  3890. : opts.handles);
  3891. switch(kpe)
  3892. {
  3893. case KPE_ToolBarHandle:
  3894. {
  3895. if(APPEARANCE_STRIPED!=opts.bgndAppearance)
  3896. {
  3897. TQRect r2(r);
  3898. r2.addCoords(-1, -1, 2, 2);
  3899. drawMenuOrToolBarBackground(p, r2, cg, false, flags&Style_Horizontal);
  3900. }
  3901. drawHandleMarkers(p, r, flags, true, handles);
  3902. break;
  3903. }
  3904. case KPE_DockWindowHandle:
  3905. {
  3906. int x, y, w, h;
  3907. bool horizontal(flags & Style_Horizontal);
  3908. r.rect(&x, &y, &w, &h);
  3909. if(!IS_FLAT(opts.dwtAppearance))
  3910. drawBevelGradient(cg.background(), p, r, horizontal, false, opts.dwtAppearance, WIDGET_DOCK_WIDGET_TITLE);
  3911. else
  3912. p->fillRect(r, cg.background()); // .dark(DW_BGND));
  3913. // p->setPen(itsBackgroundCols[STD_BORDER]);
  3914. // if(horizontal)
  3915. // p->drawLine(r.right(), r.top()-1, r.right(), r.bottom());
  3916. // else
  3917. // p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
  3918. if (w > 2 && h > 2)
  3919. {
  3920. TQWidget *wid(const_cast<TQWidget*>(widget));
  3921. bool hasClose(dynamic_cast<const TQDockWindow *>(wid->parentWidget()) &&
  3922. ((TQDockWindow *)(wid->parentWidget()))->area() &&
  3923. ((TQDockWindow *)(wid->parentWidget()))->isCloseEnabled());
  3924. TQFont fnt(TQApplication::font(wid));
  3925. TQPixmap pix;
  3926. TQString title(wid->parentWidget()->caption());
  3927. TQPainter p2;
  3928. fnt.setPointSize(fnt.pointSize()-2);
  3929. if(hasClose) {
  3930. if (horizontal) {
  3931. h-=15;
  3932. }
  3933. else {
  3934. w-=15;
  3935. }
  3936. }
  3937. // Draw the item on an off-screen pixmap to preserve Xft antialiasing for
  3938. // vertically oriented handles.
  3939. if (horizontal)
  3940. pix.resize(h, w);
  3941. else
  3942. pix.resize(w, h);
  3943. p2.begin(&pix);
  3944. p2.fillRect(pix.rect(), cg.background()); // .dark(DW_BGND));
  3945. p2.setPen(itsBackgroundCols[STD_BORDER]);
  3946. p2.drawLine(pix.rect().left(), pix.rect().bottom(), pix.rect().right(), pix.rect().bottom());
  3947. p2.setPen(cg.text());
  3948. p2.setFont(fnt);
  3949. TQRect textRect(pix.rect());
  3950. textRect.addCoords(2, -3, -2, 0);
  3951. p2.drawText(textRect, AlignVCenter|(TQApplication::reverseLayout() ? AlignRight : AlignLeft),
  3952. elliditide(title, TQFontMetrics(fnt), pix.width()));
  3953. p2.end();
  3954. if (horizontal)
  3955. {
  3956. TQWMatrix m;
  3957. m.rotate(-90.0);
  3958. TQPixmap vpix(pix.xForm(m));
  3959. bitBlt(wid, r.x(), r.y()+(hasClose ? 15 : 0), &vpix);
  3960. }
  3961. else
  3962. bitBlt(wid, r.x(), r.y(), &pix);
  3963. }
  3964. break;
  3965. }
  3966. case KPE_GeneralHandle:
  3967. drawHandleMarkers(p, r, flags, false, handles);
  3968. break;
  3969. case KPE_SliderGroove:
  3970. drawSliderGroove(p, r, cg, flags, widget);
  3971. break;
  3972. case KPE_SliderHandle:
  3973. drawSliderHandle(p, r, cg, flags, widget ? ::tqqt_cast<TQSlider *>(widget) : 0L);
  3974. break;
  3975. case KPE_ListViewExpander:
  3976. {
  3977. TQRect ar(r.x()+((r.width()-(LV_SIZE+4))>>1), r.y()+((r.height()-(LV_SIZE+4))>>1), LV_SIZE+4,
  3978. LV_SIZE+4);
  3979. if(LV_OLD==opts.lvLines)
  3980. {
  3981. int lo(ROUNDED ? 2 : 0);
  3982. p->setPen(cg.mid());
  3983. p->drawLine(ar.x()+lo, ar.y(), (ar.x()+ar.width()-1)-lo, ar.y());
  3984. p->drawLine(ar.x()+lo, ar.y()+ar.height()-1, (ar.x()+ar.width()-1)-lo,
  3985. ar.y()+ar.height()-1);
  3986. p->drawLine(ar.x(), ar.y()+lo, ar.x(), (ar.y()+ar.height()-1)-lo);
  3987. p->drawLine(ar.x()+ar.width()-1, ar.y()+lo, ar.x()+ar.width()-1,
  3988. (ar.y()+ar.height()-1)-lo);
  3989. if(ROUNDED)
  3990. {
  3991. p->drawPoint(ar.x()+1, ar.y()+1);
  3992. p->drawPoint(ar.x()+1, ar.y()+ar.height()-2);
  3993. p->drawPoint(ar.x()+ar.width()-2, ar.y()+1);
  3994. p->drawPoint(ar.x()+ar.width()-2, ar.y()+ar.height()-2);
  3995. p->setPen(midColor(cg.mid(), cg.background()));
  3996. p->drawLine(ar.x(), ar.y()+1, ar.x()+1, ar.y());
  3997. p->drawLine(ar.x()+ar.width()-2, ar.y(), ar.x()+ar.width()-1, ar.y()+1);
  3998. p->drawLine(ar.x(), ar.y()+ar.height()-2, ar.x()+1, ar.y()+ar.height()-1);
  3999. p->drawLine(ar.x()+ar.width()-2, ar.y()+ar.height()-1, ar.x()+ar.width()-1,
  4000. ar.y()+ar.height()-2);
  4001. }
  4002. }
  4003. ::drawArrow(p, ar, flags&Style_Enabled ? cg.mid() : cg.text(), flags&Style_On // Collapsed = On
  4004. ? TQApplication::reverseLayout()
  4005. ? PE_ArrowLeft
  4006. : PE_ArrowRight
  4007. : PE_ArrowDown, opts);
  4008. break;
  4009. }
  4010. case KPE_ListViewBranch:
  4011. if(opts.lvLines)
  4012. {
  4013. p->setPen(cg.mid());
  4014. if (flags&Style_Horizontal)
  4015. {
  4016. if(r.width()>0)
  4017. p->drawLine(r.x(), r.y(), r.x()+r.width()-1, r.y());
  4018. }
  4019. else
  4020. if(r.height()>0)
  4021. p->drawLine(r.x(), r.y(), r.x(), r.y()+r.height()-1);
  4022. }
  4023. break;
  4024. default:
  4025. BASE_STYLE::drawKStylePrimitive(kpe, p, ceData, elementFlags, r, cg, flags, opt, widget);
  4026. }
  4027. }
  4028. void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
  4029. const TQRect &r, const TQColorGroup &cg, SFlags flags,
  4030. const TQStyleOption &data, const TQWidget *widget) const
  4031. {
  4032. if(widget==itsHoverWidget)
  4033. flags|=Style_MouseOver;
  4034. switch(control)
  4035. {
  4036. case CE_TabBarTab:
  4037. {
  4038. int tabIndex(ceData.tabBarData.identIndexMap[data.tab()->identifier()]),
  4039. dark(APPEARANCE_FLAT==opts.appearance ? ORIGINAL_SHADE : FRAME_DARK_SHADOW),
  4040. moOffset(ROUNDED_NONE==opts.round || TAB_MO_TOP!=opts.tabMouseOver ? 1 : opts.round);
  4041. bool cornerWidget(false),
  4042. bottomCornerWidget(false),
  4043. reverse(TQApplication::reverseLayout()),
  4044. firstTab(0==tabIndex),
  4045. lastTab((ceData.tabBarData.tabCount-1)==tabIndex),
  4046. // isFirstKTabCtlTab(firstTab && widget->parent()
  4047. // ? 0==qstrcmp("KTabCtl", widget->parent()->className())
  4048. // : false),
  4049. active(flags & Style_Selected),
  4050. itsHover(itsHoverTab && itsHoverTab->isEnabled() && data.tab()==itsHoverTab &&
  4051. !(flags&Style_Selected) &&
  4052. ceData.tabBarData.currentTabIndex!=tabIndex),
  4053. glowMo(!active && itsHover && opts.coloredMouseOver && TAB_MO_GLOW==opts.tabMouseOver);
  4054. int sizeAdjust(!active && TAB_MO_GLOW==opts.tabMouseOver ? 1 : 0);
  4055. const TQColor &fill(getTabFill(flags&Style_Selected, itsHover, itsBackgroundCols));
  4056. EBorder borderProfile(active || opts.borderInactiveTab
  4057. ? opts.borderTab
  4058. ? BORDER_LIGHT
  4059. : opts.colorSelTab && active
  4060. ? BORDER_FLAT
  4061. : BORDER_RAISED
  4062. : BORDER_FLAT);
  4063. if(reverse)
  4064. {
  4065. bool oldLast=lastTab;
  4066. lastTab=firstTab;
  4067. firstTab=oldLast;
  4068. }
  4069. if (!ceData.tabBarData.cornerWidgets[TQStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes.isEmpty()) {
  4070. cornerWidget=true;
  4071. }
  4072. if (!ceData.tabBarData.cornerWidgets[TQStyleControlElementTabBarData::CWL_BottomLeft].widgetObjectTypes.isEmpty()) {
  4073. bottomCornerWidget=true;
  4074. }
  4075. TQRect tr(r);
  4076. bool top(TQTabBar::TriangularAbove==ceData.tabBarData.shape || TQTabBar::RoundedAbove==ceData.tabBarData.shape);
  4077. if(active && opts.tabBgnd)
  4078. {
  4079. TQRect rx(tr);
  4080. if(top)
  4081. rx.addCoords(1, 6, -1, 0);
  4082. else
  4083. rx.addCoords(1, 0, -1, -6);
  4084. p->fillRect(rx, shade(cg.background(), TO_FACTOR(opts.tabBgnd)));
  4085. }
  4086. if(!active) {
  4087. if(top) {
  4088. tr.addCoords(0, 2, 0, 0);
  4089. }
  4090. else {
  4091. tr.addCoords(0, 0, 0, -2);
  4092. }
  4093. }
  4094. if(!firstTab && top && (APP_TORA==itsThemedApp || (APP_OPENOFFICE==itsThemedApp && !active)))
  4095. tr.addCoords(-1, 0, 0, 0);
  4096. TQRect glowTr(tr);
  4097. if(!active && TAB_MO_GLOW==opts.tabMouseOver)
  4098. glowTr.addCoords(sizeAdjust, 0, -sizeAdjust, 0);
  4099. p->setClipRect(TQRect(tr.x(), top ? tr.y()-sizeAdjust : tr.y()+2, tr.width(), top ? tr.height()-2+(2*sizeAdjust) : tr.height()),
  4100. TQPainter::CoordPainter);
  4101. bool invertedSel=APPEARANCE_INVERTED==opts.appearance && active;
  4102. TQColor col(invertedSel ? cg.background() : fill);
  4103. if(opts.tabBgnd)
  4104. col=shade(col, TO_FACTOR(opts.tabBgnd));
  4105. if(invertedSel)
  4106. p->fillRect(glowTr, col);
  4107. else
  4108. drawBevelGradient(col, p, glowTr, true,
  4109. active, active ? SEL_TAB_APP : NORM_TAB_APP, top ? WIDGET_TAB_TOP : WIDGET_TAB_BOT);
  4110. drawBorder(cg.background(), p, glowTr, cg, flags|Style_Horizontal|Style_Enabled,
  4111. active || TAB_MO_GLOW==opts.tabMouseOver || opts.roundAllTabs
  4112. ? (top ? ROUNDED_TOP : ROUNDED_BOTTOM)
  4113. : firstTab
  4114. ? (top ? ROUNDED_TOPLEFT : ROUNDED_BOTTOMLEFT)
  4115. : lastTab
  4116. ? (top ? ROUNDED_TOPRIGHT : ROUNDED_BOTTOMRIGHT)
  4117. : ROUNDED_NONE, glowMo ? itsMouseOverCols : 0L, top ? WIDGET_TAB_TOP : WIDGET_TAB_BOT, true,
  4118. borderProfile, false);
  4119. if(glowMo)
  4120. {
  4121. glowTr.addCoords(-1, -1, 1, 1);
  4122. drawGlow(p, glowTr, cg, top ? WIDGET_TAB_TOP : WIDGET_TAB_BOT);
  4123. }
  4124. p->setClipping(false);
  4125. if(top)
  4126. {
  4127. if(active)
  4128. {
  4129. p->setPen(itsBackgroundCols[STD_BORDER]);
  4130. p->drawPoint(r.x(), r.y()+r.height()-2);
  4131. p->drawPoint(r.x()+r.width()-1, r.y()+r.height()-2);
  4132. p->setPen(itsBackgroundCols[0]);
  4133. p->drawLine(r.x()+1, r.y()+r.height()-3, r.x()+1, r.y()+r.height()-1);
  4134. //p->drawPoint(r.x()+r.width()-2, r.y()+r.height()-1);
  4135. p->setPen(itsBackgroundCols[opts.borderTab ? 0 : FRAME_DARK_SHADOW]);
  4136. p->drawPoint(r.x()+r.width()-2, r.y()+r.height()-2);
  4137. }
  4138. else
  4139. {
  4140. p->setPen(itsBackgroundCols[0]);
  4141. p->drawLine(r.x(), r.y()+r.height()-1, r.x()+r.width()-1, r.y()+r.height()-1);
  4142. p->setPen(itsBackgroundCols[STD_BORDER]);
  4143. p->drawLine(r.x(), r.y()+r.height()-2, r.x()+r.width()-1, r.y()+r.height()-2);
  4144. if(opts.coloredMouseOver && itsHover && TAB_MO_GLOW!=opts.tabMouseOver)
  4145. drawHighlight(p, TQRect(tr.x()+(firstTab ? moOffset : 1),
  4146. tr.y()+(TAB_MO_TOP==opts.tabMouseOver ? 0 : tr.height()-3),
  4147. tr.width()-(firstTab || lastTab ? moOffset : 1), 2),
  4148. cg, true, !TAB_MO_TOP==opts.tabMouseOver);
  4149. }
  4150. if(((!reverse && firstTab) || (lastTab && reverse)) && !cornerWidget)
  4151. {
  4152. int x(reverse ? r.x()+r.width()-1 : r.x()),
  4153. x2(reverse ? x-1 : x+1);
  4154. p->setPen(itsBackgroundCols[!active && TAB_MO_GLOW==opts.tabMouseOver && opts.round>ROUND_SLIGHT && !(opts.square&SQUARE_TAB_FRAME)
  4155. ? ORIGINAL_SHADE : STD_BORDER]);
  4156. p->drawLine(x, r.y()+r.height()-1, x, r.height()-2);
  4157. if(active)
  4158. {
  4159. p->setPen(itsBackgroundCols[reverse ? dark : 0]);
  4160. p->drawLine(x2, r.y()+r.height()-1, x2, r.y()+r.height()-2);
  4161. }
  4162. }
  4163. if(active && opts.highlightTab)
  4164. {
  4165. p->setPen(itsHighlightCols[0]);
  4166. p->drawLine(tr.left(), tr.top()+1, tr.right(), tr.top()+1);
  4167. p->setPen(midColor(fill, itsHighlightCols[0])); // , IS_FLAT(opts.activeTabAppearance) ? 1.0 : 1.2));
  4168. p->drawLine(tr.left(), tr.top()+2, tr.right(), tr.top()+2);
  4169. p->setClipRect(TQRect(tr.x(), tr.y(), tr.width(), 3), TQPainter::CoordPainter);
  4170. drawBorder(cg.background(), p, tr, cg, flags|Style_Horizontal|Style_Enabled,
  4171. ROUNDED_ALL, itsHighlightCols, top ? WIDGET_TAB_TOP : WIDGET_TAB_BOT,
  4172. true, BORDER_FLAT, false, 3);
  4173. p->setClipping(false);
  4174. }
  4175. // Round top-left corner...
  4176. if(!(opts.square&SQUARE_TAB_FRAME) && FULLLY_ROUNDED && APP_TORA!=itsThemedApp && firstTab && !active && !cornerWidget && !reverse) // && !isFirstKTabCtlTab)
  4177. {
  4178. p->setPen(itsBackgroundCols[STD_BORDER]);
  4179. p->drawPoint(r.x()+1, r.y()+r.height()-1);
  4180. p->setPen(TAB_MO_GLOW==opts.tabMouseOver
  4181. ? itsBackgroundCols[STD_BORDER]
  4182. : midColor(itsBackgroundCols[STD_BORDER], cg.background()));
  4183. p->drawPoint(r.x()+1, r.y()+r.height()-2);
  4184. }
  4185. }
  4186. else
  4187. {
  4188. if(active)
  4189. {
  4190. p->setPen(itsBackgroundCols[STD_BORDER]);
  4191. p->drawPoint(r.x(), r.y()+1);
  4192. p->drawPoint(r.x()+r.width()-1, r.y()+1);
  4193. p->setPen(itsBackgroundCols[0]);
  4194. p->drawLine(r.x()+1, r.y()+2, r.x()+1, r.y());
  4195. p->setPen(itsBackgroundCols[opts.borderTab ? 0 : FRAME_DARK_SHADOW]);
  4196. p->drawLine(r.x()+r.width()-2, r.y()+1, r.x()+r.width()-2, r.y());
  4197. p->drawPoint(r.x()+r.width()-1, r.y());
  4198. }
  4199. else
  4200. {
  4201. p->setPen(itsBackgroundCols[opts.borderTab ? 0 : dark]);
  4202. p->drawLine(r.x(), r.y(), r.x()+r.width()-1, r.y());
  4203. p->setPen(itsBackgroundCols[STD_BORDER]);
  4204. p->drawLine(r.x(), r.y()+1, r.x()+r.width()-1, r.y()+1);
  4205. if(opts.coloredMouseOver && itsHover && TAB_MO_GLOW!=opts.tabMouseOver)
  4206. drawHighlight(p, TQRect(tr.x()+(firstTab ? moOffset : 1),
  4207. tr.y()+(TAB_MO_TOP==opts.tabMouseOver ? tr.height()-2 : 1),
  4208. tr.width()-(firstTab || lastTab ? moOffset : 1), 2),
  4209. cg, true, TAB_MO_TOP==opts.tabMouseOver);
  4210. }
  4211. if(TAB_MO_GLOW==opts.tabMouseOver && opts.round<=ROUND_SLIGHT && !(opts.square&SQUARE_TAB_FRAME) && !reverse && firstTab && !cornerWidget)
  4212. {
  4213. p->setPen(itsBackgroundCols[STD_BORDER]);
  4214. p->drawPoint(r.x(), r.y());
  4215. }
  4216. if(active && opts.highlightTab)
  4217. {
  4218. p->setPen(itsHighlightCols[0]);
  4219. p->drawLine(tr.left(), tr.bottom()-1, tr.right(), tr.bottom()-1);
  4220. p->setPen(midColor(fill, itsHighlightCols[0]));
  4221. p->drawLine(tr.left(), tr.bottom()-2, tr.right(), tr.bottom()-2);
  4222. p->setClipRect(TQRect(tr.x(), tr.y()+r.height()-3, tr.width(), 3), TQPainter::CoordPainter);
  4223. drawBorder(cg.background(), p, tr, cg, flags|Style_Horizontal|Style_Enabled,
  4224. ROUNDED_ALL, itsHighlightCols, top ? WIDGET_TAB_TOP : WIDGET_TAB_BOT,
  4225. true, BORDER_FLAT, false, 3);
  4226. p->setClipping(false);
  4227. }
  4228. if(!(opts.square&SQUARE_TAB_FRAME) && FULLLY_ROUNDED && APP_TORA!=itsThemedApp && firstTab && !bottomCornerWidget)// && !isFirstKTabCtlTab)
  4229. {
  4230. p->setPen(itsBackgroundCols[STD_BORDER]);
  4231. p->drawPoint(r.x(), reverse ? r.y()+r.width()-1 : r.y());
  4232. // Round bottom-left corner...
  4233. if(!active&& !reverse)
  4234. {
  4235. p->drawPoint(r.x()+1, r.y()-1);
  4236. p->setPen(midColor(itsBackgroundCols[STD_BORDER], cg.background()));
  4237. p->drawPoint(r.x()+1, r.y());
  4238. }
  4239. }
  4240. }
  4241. break;
  4242. }
  4243. #if 0x039999 >= 0x030200
  4244. case CE_TabBarLabel:
  4245. {
  4246. if (data.isDefault())
  4247. break;
  4248. const TQTabBar *tb((const TQTabBar *) widget);
  4249. TQTab *t(data.tab());
  4250. TQRect tr(r);
  4251. int shift(pixelMetric(PM_TabBarTabShiftVertical, ceData, elementFlags, tb));
  4252. if (t->identifier() == ceData.tabBarData.currentTabIndex)
  4253. {
  4254. if(TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape)
  4255. tr.addCoords(0, -shift, 0, -shift);
  4256. }
  4257. else
  4258. if(TQTabBar::RoundedBelow==ceData.tabBarData.shape || TQTabBar::TriangularBelow==ceData.tabBarData.shape)
  4259. tr.addCoords(0, shift, 0, shift);
  4260. if(APP_MACTOR==itsThemedApp)
  4261. {
  4262. drawControl(CE_TabBarTab, p, ceData, elementFlags, t->rect(), cg, flags, data, widget);
  4263. if(t->iconSet())
  4264. {
  4265. TQIconSet::Mode mode((t->isEnabled() && (elementFlags & CEF_IsEnabled))
  4266. ? TQIconSet::Normal : TQIconSet::Disabled);
  4267. if (mode == TQIconSet::Normal && (flags&Style_HasFocus))
  4268. mode = TQIconSet::Active;
  4269. TQPixmap pixmap(t->iconSet()->pixmap(TQIconSet::Small, mode));
  4270. int pixh(pixmap.height()),
  4271. xoff(0),
  4272. yoff(0);
  4273. if(!(flags&Style_Selected))
  4274. {
  4275. xoff = pixelMetric(PM_TabBarTabShiftHorizontal, ceData, elementFlags, widget);
  4276. yoff = pixelMetric(PM_TabBarTabShiftVertical, ceData, elementFlags, widget);
  4277. }
  4278. p->drawPixmap(t->rect().left()+8+xoff, t->rect().center().y()-pixh/2 + yoff,
  4279. pixmap);
  4280. }
  4281. }
  4282. drawItem(p, tr, AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text());
  4283. if ((flags & Style_HasFocus) && !t->text().isEmpty())
  4284. {
  4285. TQRect fr(r);
  4286. if(TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape)
  4287. fr.addCoords(0, 1, 0, -1);
  4288. else
  4289. fr.addCoords(0, 0, 0, -1);
  4290. drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg);
  4291. }
  4292. break;
  4293. }
  4294. #endif
  4295. case CE_PushButtonLabel: // Taken from Highcolor and Plastik...
  4296. {
  4297. int x, y, w, h, arrowOffset=DO_EFFECT ? 1 : 0;
  4298. r.rect(&x, &y, &w, &h);
  4299. const TQPushButton *button(static_cast<const TQPushButton *>(widget));
  4300. bool active(button->isOn() || button->isDown()),
  4301. cornArrow(false);
  4302. // Shift button contents if pushed.
  4303. if (active)
  4304. {
  4305. x += pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget);
  4306. y += pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget);
  4307. flags |= Style_Sunken;
  4308. }
  4309. // Does the button have a popup menu?
  4310. if (button->isMenuButton())
  4311. {
  4312. int dx(pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags, widget)),
  4313. margin(pixelMetric(PM_ButtonMargin, ceData, elementFlags, widget));
  4314. if(button->iconSet() && !button->iconSet()->isNull() &&
  4315. (dx+button->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal, TQIconSet::Off
  4316. ).width()) >= w )
  4317. cornArrow = true; //To little room. Draw the arrow in the corner, don't adjust
  4318. //the widget
  4319. else
  4320. {
  4321. ::drawArrow(p, visualRect(TQRect((x + w) - (dx + margin + arrowOffset), y, dx, h), r),
  4322. MO_ARROW(cg.buttonText()), PE_ArrowDown, opts);
  4323. w-=(dx+arrowOffset);
  4324. }
  4325. }
  4326. // Draw the icon if there is one
  4327. if (button->iconSet() && !button->iconSet()->isNull())
  4328. {
  4329. TQIconSet::Mode mode(TQIconSet::Disabled);
  4330. TQIconSet::State state(TQIconSet::Off);
  4331. if (button->isEnabled())
  4332. mode = button->hasFocus() ? TQIconSet::Active : TQIconSet::Normal;
  4333. if (button->isToggleButton() && button->isOn())
  4334. state = TQIconSet::On;
  4335. TQPixmap pixmap = button->iconSet()->pixmap(TQIconSet::Small, mode, state);
  4336. static const int constSpace(2);
  4337. int xo(0),
  4338. pw(pixmap.width()),
  4339. iw(0);
  4340. if (button->text().isEmpty() && !button->pixmap())
  4341. p->drawPixmap(x + (w>>1) - (pixmap.width()>>1),
  4342. y + (h>>1) - (pixmap.height()>>1),
  4343. pixmap);
  4344. else
  4345. {
  4346. iw=button->pixmap() ? button->pixmap()->width()
  4347. : widget->fontMetrics().size(TQt::ShowPrefix,
  4348. button->text()).width();
  4349. int cw(iw+pw+constSpace);
  4350. xo=cw<w ? (w-cw)>>1 : constSpace;
  4351. p->drawPixmap(x+xo, y + (h>>1) - (pixmap.height()>>1), pixmap);
  4352. xo+=pw;
  4353. }
  4354. if (cornArrow) //Draw over the icon
  4355. ::drawArrow(p, visualRect(TQRect(x + w - (6+arrowOffset), y + h - (6+arrowOffset), 7, 7), r),
  4356. MO_ARROW(cg.buttonText()), PE_ArrowDown, opts);
  4357. if(xo && iw)
  4358. {
  4359. x+= xo+constSpace;
  4360. w=iw;
  4361. }
  4362. else
  4363. {
  4364. x+= pw+constSpace;
  4365. w-= pw+constSpace;
  4366. }
  4367. }
  4368. // Make the label indicate if the button is a default button or not
  4369. int i,
  4370. j(opts.embolden && button->isDefault() ? 2 : 1);
  4371. bool sidebar(!opts.stdSidebarButtons &&
  4372. ((button->isFlat() && button->inherits("KMultiTabBarTab")) ||
  4373. (button->parentWidget() && button->inherits("Ideal::Button") &&
  4374. button->parentWidget()->inherits("Ideal::ButtonBar"))));
  4375. const TQColor &textCol(sidebar && (button->isOn() || flags&Style_On)
  4376. ? TQApplication::palette().active().highlightedText()
  4377. : button->colorGroup().buttonText());
  4378. for(i=0; i<j; i++)
  4379. drawItem(p, TQRect(x+i, y, w, h), AlignCenter|ShowPrefix, button->colorGroup(),
  4380. button->isEnabled(),
  4381. button->pixmap(), button->text(), -1, &textCol);
  4382. // Draw a focus rect if the button has focus
  4383. if (flags&Style_HasFocus && FOCUS_GLOW!=opts.focus &&
  4384. !(flags&Style_MouseOver && FOCUS_FULL==opts.focus && MO_NONE!=opts.coloredMouseOver))
  4385. drawPrimitive(PE_FocusRect, p, ceData, elementFlags, visualRect(subRect(SR_PushButtonFocusRect, ceData, elementFlags,
  4386. widget), ceData, elementFlags), cg, flags);
  4387. break;
  4388. }
  4389. case CE_PopupMenuItem:
  4390. {
  4391. if(!widget || data.isDefault())
  4392. break;
  4393. TQMenuItem *mi(data.menuItem());
  4394. int tab(data.tabWidth()),
  4395. maxpmw(data.maxIconWidth()),
  4396. x, y, w, h;
  4397. bool reverse(TQApplication::reverseLayout());
  4398. maxpmw=TQMAX(maxpmw, constMenuPixmapWidth);
  4399. r.rect(&x, &y, &w, &h);
  4400. if(widget->erasePixmap() && !widget->erasePixmap()->isNull())
  4401. p->drawPixmap(x, y, *widget->erasePixmap(), x, y, w, h);
  4402. else
  4403. {
  4404. if(IS_FLAT_BGND(opts.menuBgndAppearance))
  4405. p->fillRect(r, USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol
  4406. : itsBackgroundCols[ORIGINAL_SHADE]);
  4407. if(opts.menuStripe)
  4408. drawBevelGradient(menuStripeCol(), p,
  4409. TQRect(reverse ? r.right()-maxpmw : r.x(),
  4410. r.y(), maxpmw, r.height()), false,
  4411. false, opts.menuStripeAppearance, WIDGET_OTHER);
  4412. }
  4413. if((flags&Style_Active) && (flags&Style_Enabled))
  4414. drawMenuItem(p, r, flags, cg, false, ROUNDED_ALL,
  4415. USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol
  4416. : itsBackgroundCols[ORIGINAL_SHADE],
  4417. opts.useHighlightForMenu ? itsHighlightCols : itsBackgroundCols);
  4418. if(!mi)
  4419. break;
  4420. if(mi->isSeparator())
  4421. {
  4422. y=r.y()+(r.height()>>1);
  4423. p->setPen(itsBackgroundCols[MENU_SEP_SHADE]);
  4424. p->drawLine(r.x()+3+(!reverse && opts.menuStripe ? maxpmw : 0), y,
  4425. r.x()+r.width()-4-(reverse && opts.menuStripe ? maxpmw : 0), y);
  4426. // p->setPen(itsBackgroundCols[0]);
  4427. // p->drawLine(r.x()+4, y+1, r.x()+r.width()-5, y+1);
  4428. break;
  4429. }
  4430. TQRect cr, ir, tr, sr;
  4431. // check column
  4432. cr.setRect(r.left(), r.top(), maxpmw, r.height());
  4433. // submenu indicator column
  4434. sr.setCoords(r.right()-maxpmw, r.top(), r.right(), r.bottom());
  4435. // tab/accelerator column
  4436. tr.setCoords(sr.left()-tab-4, r.top(), sr.left(), r.bottom());
  4437. // item column
  4438. ir.setCoords(cr.right()+4, r.top(), tr.right()-4, r.bottom());
  4439. if(reverse)
  4440. {
  4441. cr=visualRect(cr, r);
  4442. sr=visualRect(sr, r);
  4443. tr=visualRect(tr, r);
  4444. ir=visualRect(ir, r);
  4445. }
  4446. if(mi->iconSet() && opts.menuIcons)
  4447. {
  4448. // Select the correct icon from the iconset
  4449. TQIconSet::Mode mode=flags & Style_Active
  4450. ? (mi->isEnabled() ? TQIconSet::Active : TQIconSet::Disabled)
  4451. : (mi->isEnabled() ? TQIconSet::Normal : TQIconSet::Disabled);
  4452. cr=visualRect(TQRect(x, y, maxpmw, h), r);
  4453. // Do we have an icon and are checked at the same time?
  4454. // Then draw a "pressed" background behind the icon
  4455. if((elementFlags & CEF_IsCheckable) && mi->isChecked())
  4456. drawLightBevel((flags & Style_Active)&&(flags & Style_Enabled)
  4457. ? itsHighlightCols[ORIGINAL_SHADE]
  4458. : cg.background(), p, TQRect(cr.x()+1, cr.y()+2, cr.width()-2, cr.height()-4),
  4459. cg, flags|Style_Sunken|Style_Horizontal, ROUNDED_ALL,
  4460. getFill(flags|Style_Sunken|Style_Enabled, itsBackgroundCols),
  4461. itsBackgroundCols, true, false, WIDGET_NO_ETCH_BTN);
  4462. // Draw the icon
  4463. TQPixmap pixmap(mi->iconSet()->pixmap(TQIconSet::Small, mode));
  4464. TQRect pmr(0, 0, pixmap.width(), pixmap.height());
  4465. pmr.moveCenter(cr.center());
  4466. p->drawPixmap(pmr.topLeft(), pixmap);
  4467. }
  4468. else if((elementFlags & CEF_IsCheckable) && mi->isChecked())
  4469. drawPrimitive(PE_CheckMark, p, ceData, elementFlags, cr, cg,
  4470. (flags &(Style_Enabled|(opts.useHighlightForMenu ? Style_Active : 0)))| Style_On|MENU_ITEM);
  4471. TQColor textCol(flags&Style_Enabled
  4472. ? flags&Style_Active && opts.useHighlightForMenu
  4473. ? cg.highlightedText()
  4474. : cg.foreground()
  4475. : cg.mid());
  4476. p->setPen(textCol);
  4477. if(mi->custom())
  4478. {
  4479. p->save();
  4480. mi->custom()->paint(p, cg,(flags & Style_Enabled)?(flags & Style_Active): 0,
  4481. flags & Style_Enabled, ir.x(), ir.y(), ir.width(), ir.height());
  4482. p->restore();
  4483. }
  4484. TQString text=mi->text();
  4485. if(!text.isNull())
  4486. {
  4487. int t(text.find('\t'));
  4488. // draw accelerator/tab-text
  4489. if(t>=0)
  4490. p->drawText(tr, AlignVCenter|ShowPrefix|DontClip|SingleLine|(reverse ? AlignLeft : AlignRight),
  4491. text.mid(t+1));
  4492. p->drawText(ir, AlignVCenter|ShowPrefix|DontClip|SingleLine|(reverse ? AlignRight : AlignLeft), text, t);
  4493. }
  4494. else if(mi->pixmap())
  4495. {
  4496. TQPixmap *pixmap(mi->pixmap());
  4497. if(1==pixmap->depth())
  4498. p->setBackgroundMode(Qt::OpaqueMode);
  4499. int diffw(((r.width() - pixmap->width())/2) +
  4500. ((r.width() - pixmap->width())%2));
  4501. p->drawPixmap(r.x()+diffw, r.y()+1, *pixmap );
  4502. if(1==pixmap->depth())
  4503. p->setBackgroundMode(Qt::TransparentMode);
  4504. }
  4505. if(mi->popup())
  4506. ::drawArrow(p, sr, textCol, reverse ? PE_ArrowLeft : PE_ArrowRight, opts);
  4507. break;
  4508. }
  4509. case CE_MenuBarItem:
  4510. {
  4511. bool down( (flags&Style_Enabled) && (flags&Style_Active) && (flags&Style_Down) ),
  4512. active( (flags&Style_Enabled) && (flags&Style_Active) &&
  4513. ( (flags&Style_Down) || opts.menubarMouseOver ) );
  4514. if(!active || IS_GLASS(opts.menubarAppearance) || SHADE_NONE!=opts.shadeMenubars)
  4515. {
  4516. TQMenuBar *mb((TQMenuBar*)widget);
  4517. TQRect r2(r);
  4518. r2.setY(mb->rect().y()+1);
  4519. r2.setHeight(mb->rect().height()-2);
  4520. drawMenuOrToolBarBackground(p, r2, cg);
  4521. }
  4522. if(active)
  4523. drawMenuItem(p, r, flags, cg, true, down && opts.roundMbTopOnly ? ROUNDED_TOP : ROUNDED_ALL,
  4524. itsMenubarCols[ORIGINAL_SHADE],
  4525. opts.useHighlightForMenu && (opts.colorMenubarMouseOver || down)
  4526. ? itsHighlightCols : itsBackgroundCols);
  4527. if(data.isDefault())
  4528. break;
  4529. TQMenuItem *mi(data.menuItem());
  4530. if(mi->text().isEmpty()) // Draw pixmap...
  4531. drawItem(p, r, AlignCenter|ShowPrefix|DontClip|SingleLine, cg, flags&Style_Enabled,
  4532. mi->pixmap(), TQString());
  4533. else
  4534. {
  4535. const TQColor *col=((opts.colorMenubarMouseOver && active) || (!opts.colorMenubarMouseOver && down))
  4536. ? opts.customMenuTextColor
  4537. ? &opts.customMenuSelTextColor
  4538. : opts.useHighlightForMenu
  4539. ? &cg.highlightedText()
  4540. : &cg.foreground()
  4541. : &cg.foreground();
  4542. p->setPen(*col);
  4543. p->drawText(r, AlignCenter|ShowPrefix|DontClip|SingleLine, mi->text());
  4544. }
  4545. break;
  4546. }
  4547. case CE_MenuBarEmptyArea:
  4548. drawMenuOrToolBarBackground(p, r, cg);
  4549. break;
  4550. case CE_DockWindowEmptyArea:
  4551. if(widget && widget->inherits(TQTOOLBAR_OBJECT_NAME_STRING))
  4552. {
  4553. TQDockWindow *wind((TQDockWindow*)widget);
  4554. drawMenuOrToolBarBackground(p, r, cg, false, Qt::Horizontal==wind->orientation());
  4555. }
  4556. else
  4557. BASE_STYLE::drawControl(control, p, ceData, elementFlags, r, cg, flags, data, widget);
  4558. break;
  4559. case CE_ProgressBarGroove:
  4560. {
  4561. TQRect rx(r);
  4562. bool doEtch(DO_EFFECT && opts.borderProgress);
  4563. TQColor col;
  4564. if(doEtch)
  4565. rx.addCoords(1, 1, -1, -1);
  4566. switch(opts.progressGrooveColor)
  4567. {
  4568. default:
  4569. case ECOLOR_BASE:
  4570. col=cg.base();
  4571. break;
  4572. case ECOLOR_BACKGROUND:
  4573. col=cg.background();
  4574. break;
  4575. case ECOLOR_DARK:
  4576. col=itsBackgroundCols[2];
  4577. }
  4578. drawBevelGradient(col, p, rx, true,
  4579. false, opts.progressGrooveAppearance, WIDGET_PBAR_TROUGH);
  4580. const TQColor *use(backgroundColors(cg));
  4581. if(opts.borderProgress)
  4582. drawBorder(cg.background(), p, rx, cg, (SFlags)(flags|Style_Horizontal),
  4583. (opts.square&SQUARE_PROGRESS) ? ROUNDED_NONE : ROUNDED_ALL, use, WIDGET_OTHER, true,
  4584. IS_FLAT(opts.progressGrooveAppearance) && ECOLOR_DARK!=opts.progressGrooveColor ? BORDER_SUNKEN : BORDER_FLAT);
  4585. else
  4586. {
  4587. p->setPen(itsBackgroundCols[STD_BORDER]);
  4588. p->drawLine(r.topLeft(), r.topRight());
  4589. p->drawLine(r.bottomLeft(), r.bottomRight());
  4590. }
  4591. if(doEtch)
  4592. drawEtch(p, r, cg, false, (opts.square&SQUARE_PROGRESS));
  4593. break;
  4594. }
  4595. case CE_ProgressBarContents:
  4596. {
  4597. const TQProgressBar *pb((const TQProgressBar*)widget);
  4598. int steps(pb->totalSteps());
  4599. if(0==steps)//Busy indicator
  4600. {
  4601. static const int barWidth(PROGRESS_CHUNK_WIDTH*3.4);
  4602. int progress(pb->progress() % (2*(r.width()-barWidth)));
  4603. if(progress < 0)
  4604. progress = 0;
  4605. else if(progress > r.width()-barWidth)
  4606. progress = (r.width()-barWidth)-(progress-(r.width()-barWidth));
  4607. drawProgress(p, TQRect(r.x()+progress, r.y(), barWidth, r.height()), cg, flags,
  4608. (opts.square&SQUARE_PROGRESS) ? ROUNDED_NONE : ROUNDED_ALL, widget);
  4609. }
  4610. else
  4611. {
  4612. TQRect cr(subRect(SR_ProgressBarContents, ceData, elementFlags, widget));
  4613. if(cr.isValid() && pb->progress()>0)
  4614. {
  4615. double pg(((double)pb->progress()) / steps);
  4616. int width(TQMIN(cr.width(), (int)(pg * cr.width())));
  4617. if(TQApplication::reverseLayout())
  4618. drawProgress(p, TQRect(cr.x()+(cr.width()-width), cr.y(), width,
  4619. cr.height()), cg, flags,
  4620. width==cr.width() || (opts.square&SQUARE_PROGRESS) ? ROUNDED_NONE : ROUNDED_ALL, widget);
  4621. else
  4622. drawProgress(p, TQRect(cr.x(), cr.y(), width, cr.height()), cg, flags,
  4623. width==cr.width() || (opts.square&SQUARE_PROGRESS) ? ROUNDED_NONE : ROUNDED_ALL, widget);
  4624. }
  4625. }
  4626. break;
  4627. }
  4628. case CE_ProgressBarLabel:
  4629. {
  4630. const TQProgressBar* pb = (const TQProgressBar*)widget;
  4631. TQRect cr = subRect(SR_ProgressBarContents, ceData, elementFlags, widget);
  4632. double progress = pb->progress();
  4633. bool reverse = TQApplication::reverseLayout();
  4634. int steps = pb->totalSteps();
  4635. if (!cr.isValid())
  4636. return;
  4637. if(opts.boldProgress) // This is the only change fro the KStyle code!
  4638. {
  4639. TQFont font = p->font();
  4640. font.setBold(true);
  4641. p->setFont(font);
  4642. }
  4643. // Draw label
  4644. if (progress > 0 || steps == 0)
  4645. {
  4646. double pg = (steps == 0) ? 1.0 : progress / steps;
  4647. int width = TQMIN(cr.width(), (int)(pg * cr.width()));
  4648. TQRect crect;
  4649. if (reverse)
  4650. crect.setRect(cr.x()+(cr.width()-width), cr.y(), cr.width(), cr.height());
  4651. else
  4652. crect.setRect(cr.x()+width, cr.y(), cr.width(), cr.height());
  4653. p->save();
  4654. p->setPen(pb->isEnabled() ? (reverse ? cg.text() : cg.highlightedText()) : cg.text());
  4655. p->drawText(r, AlignCenter, pb->progressString());
  4656. p->setClipRect(crect);
  4657. p->setPen(reverse ? cg.highlightedText() : cg.text());
  4658. p->drawText(r, AlignCenter, pb->progressString());
  4659. p->restore();
  4660. }
  4661. else
  4662. {
  4663. p->setPen(cg.text());
  4664. p->drawText(r, AlignCenter, pb->progressString());
  4665. }
  4666. break;
  4667. }
  4668. case CE_PushButton:
  4669. {
  4670. const TQPushButton *button(static_cast<const TQPushButton *>(widget));
  4671. bool sidebar(!opts.stdSidebarButtons &&
  4672. ((button->isFlat() && button->inherits("KMultiTabBarTab")) ||
  4673. (button->parentWidget() && button->inherits("Ideal::Button") &&
  4674. button->parentWidget()->inherits("Ideal::ButtonBar"))));
  4675. if(sidebar)
  4676. {
  4677. TQRect r2(r);
  4678. flags|=TOGGLE_BUTTON;
  4679. if(button->isOn())
  4680. flags|=Style_On;
  4681. const TQColor *use(flags&Style_On ? getSidebarButtons() : buttonColors(cg));
  4682. if((flags&Style_On ) || flags&Style_MouseOver)
  4683. {
  4684. r2.addCoords(-1, -1, 1, 1);
  4685. drawLightBevel(p, r2, cg, flags|Style_Horizontal, ROUNDED_NONE,
  4686. getFill(flags, use), use, false, false, WIDGET_MENU_ITEM);
  4687. }
  4688. else
  4689. p->fillRect(r2, cg.background());
  4690. if(flags&Style_MouseOver && opts.coloredMouseOver)
  4691. {
  4692. r2=r;
  4693. if(MO_PLASTIK==opts.coloredMouseOver)
  4694. r2.addCoords(0, 1, 0, -1);
  4695. else
  4696. r2.addCoords(1, 1, -1, -1);
  4697. p->setPen(itsMouseOverCols[flags&Style_On ? 0 : 1]);
  4698. p->drawLine(r.x(), r.y(), r.x()+r.width()-1, r.y());
  4699. p->drawLine(r2.x(), r2.y(), r2.x()+r2.width()-1, r2.y());
  4700. if(MO_PLASTIK!=opts.coloredMouseOver)
  4701. {
  4702. p->drawLine(r.x(), r.y(), r.x(), r.y()+r.height()-1);
  4703. p->drawLine(r2.x(), r2.y(), r2.x(), r2.y()+r2.height()-1);
  4704. p->setPen(itsMouseOverCols[flags&Style_On ? 1 : 2]);
  4705. }
  4706. p->drawLine(r.x(), r.y()+r.height()-1, r.x()+r.width()-1, r.y()+r.height()-1);
  4707. p->drawLine(r2.x(), r2.y()+r2.height()-1, r2.x()+r2.width()-1,
  4708. r2.y()+r2.height()-1);
  4709. if(MO_PLASTIK!=opts.coloredMouseOver)
  4710. {
  4711. p->drawLine(r.x()+r.width()-1, r.y(), r.x()+r.width()-1, r.y()+r.height()-1);
  4712. p->drawLine(r2.x()+r2.width()-1, r2.y(), r2.x()+r2.width()-1,
  4713. r2.y()+r2.height()-1);
  4714. }
  4715. }
  4716. }
  4717. else
  4718. {
  4719. itsFormMode = isFormWidget(widget);
  4720. if(IND_FONT_COLOR==opts.defBtnIndicator && button->isDefault())
  4721. flags|=Style_ButtonDefault;
  4722. if(button->isToggleButton())
  4723. flags|=TOGGLE_BUTTON;
  4724. if(sidebar)
  4725. flags|=NO_ETCH_BUTTON;
  4726. drawPrimitive(PE_ButtonCommand, p, ceData, elementFlags, r, cg, flags);
  4727. if (button->isDefault() && IND_CORNER==opts.defBtnIndicator)
  4728. drawPrimitive(PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags);
  4729. itsFormMode = false;
  4730. }
  4731. break;
  4732. }
  4733. case CE_CheckBox:
  4734. itsFormMode = isFormWidget(widget);
  4735. drawPrimitive(PE_Indicator, p, ceData, elementFlags, r, cg, flags, data);
  4736. itsFormMode = false;
  4737. break;
  4738. case CE_CheckBoxLabel:
  4739. if(opts.crHighlight || FOCUS_GLOW==opts.focus)
  4740. {
  4741. const TQCheckBox *checkbox((const TQCheckBox *)widget);
  4742. if(flags&Style_MouseOver && opts.crHighlight &&
  4743. #if 0x039999 >= 0x030200
  4744. HOVER_CHECK==itsHover && itsHoverWidget && itsHoverWidget==widget &&
  4745. #endif
  4746. !isFormWidget(widget))
  4747. {
  4748. #if 0x039999 >= 0x030200
  4749. TQRect cr(checkbox->rect());
  4750. TQRegion r(TQRect(cr.x(), cr.y(), visualRect(subRect(SR_CheckBoxFocusRect, ceData, elementFlags, widget),
  4751. ceData, elementFlags).width()+
  4752. pixelMetric(PM_IndicatorWidth, ceData, elementFlags)+4,
  4753. cr.height()));
  4754. #else
  4755. TQRegion r(checkbox->rect());
  4756. #endif
  4757. r-=visualRect(subRect(SR_CheckBoxIndicator, ceData, elementFlags, widget), ceData, elementFlags);
  4758. p->setClipRegion(r);
  4759. drawBevelGradient(shade(cg.background(), TO_FACTOR(opts.crHighlight)), p, checkbox->rect(), true,
  4760. false, opts.selectionAppearance, WIDGET_SELECTION);
  4761. p->setClipping(false);
  4762. }
  4763. int alignment(TQApplication::reverseLayout() ? AlignRight : AlignLeft);
  4764. drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg,
  4765. flags & Style_Enabled, checkbox->pixmap(), checkbox->text());
  4766. if(checkbox->hasFocus() && FOCUS_GLOW!=opts.focus)
  4767. drawPrimitive(PE_FocusRect, p, ceData, elementFlags, visualRect(subRect(SR_CheckBoxFocusRect, ceData, elementFlags, widget),
  4768. ceData, elementFlags), cg, flags);
  4769. }
  4770. else
  4771. BASE_STYLE::drawControl(control, p, ceData, elementFlags, r, cg, flags, data, widget);
  4772. break;
  4773. case CE_RadioButton:
  4774. itsFormMode=isFormWidget(widget);
  4775. drawPrimitive(PE_ExclusiveIndicator, p, ceData, elementFlags, r, cg, flags, data);
  4776. itsFormMode=false;
  4777. break;
  4778. case CE_RadioButtonLabel:
  4779. if(opts.crHighlight || FOCUS_GLOW==opts.focus)
  4780. {
  4781. const TQRadioButton *radiobutton((const TQRadioButton *)widget);
  4782. if(flags&Style_MouseOver && opts.crHighlight &&
  4783. #if 0x039999 >= 0x030200
  4784. HOVER_RADIO==itsHover && itsHoverWidget && itsHoverWidget==widget &&
  4785. #endif
  4786. !isFormWidget(widget))
  4787. {
  4788. #if 0x039999 >= 0x030200
  4789. TQRect rb(radiobutton->rect());
  4790. TQRegion r(TQRect(rb.x(), rb.y(),
  4791. visualRect(subRect(SR_RadioButtonFocusRect, ceData, elementFlags, widget),
  4792. ceData, elementFlags).width()+
  4793. pixelMetric(PM_ExclusiveIndicatorWidth, ceData, elementFlags)+4,
  4794. rb.height()));
  4795. #else
  4796. TQRegion r(radiobutton->rect());
  4797. #endif
  4798. r-=visualRect(subRect(SR_RadioButtonIndicator, ceData, elementFlags, widget), ceData, elementFlags);
  4799. p->setClipRegion(r);
  4800. drawBevelGradient(shade(cg.background(), TO_FACTOR(opts.crHighlight)), p, radiobutton->rect(), true,
  4801. false, opts.selectionAppearance, WIDGET_SELECTION);
  4802. p->setClipping(false);
  4803. }
  4804. int alignment(TQApplication::reverseLayout() ? AlignRight : AlignLeft);
  4805. drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg, flags & Style_Enabled,
  4806. radiobutton->pixmap(), radiobutton->text());
  4807. if(radiobutton->hasFocus() && FOCUS_GLOW!=opts.focus)
  4808. drawPrimitive(PE_FocusRect, p, ceData, elementFlags, visualRect(subRect(SR_RadioButtonFocusRect, ceData, elementFlags,
  4809. widget), ceData, elementFlags), cg, flags);
  4810. break;
  4811. }
  4812. // Fall through intentional!
  4813. default:
  4814. BASE_STYLE::drawControl(control, p, ceData, elementFlags, r, cg, flags, data, widget);
  4815. }
  4816. }
  4817. void QtCurveStyle::drawControlMask(ControlElement control, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
  4818. const TQRect &r, const TQStyleOption &data, const TQWidget *widget) const
  4819. {
  4820. switch(control)
  4821. {
  4822. case CE_PushButton:
  4823. case CE_MenuBarItem:
  4824. {
  4825. int offset(r.width()<MIN_ROUND_FULL_SIZE || r.height()<MIN_ROUND_FULL_SIZE ? 1 : 2);
  4826. p->fillRect(r, color0);
  4827. p->fillRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2, color1);
  4828. p->setPen(color1);
  4829. p->drawLine(r.x()+offset, r.y(), r.x()+r.width()-(offset+1), r.y());
  4830. p->drawLine(r.x()+offset, r.y()+r.height()-1, r.x()+r.width()-(offset+1),
  4831. r.y()+r.height()-1);
  4832. p->drawLine(r.x(), r.y()+offset, r.x(), r.y()+r.height()-(offset+1));
  4833. p->drawLine(r.x()+r.width()-1, r.y()+offset, r.x()+r.width()-1,
  4834. r.y()+r.height()-(offset+1));
  4835. break;
  4836. }
  4837. default:
  4838. BASE_STYLE::drawControlMask(control, p, ceData, elementFlags, r, data, widget);
  4839. }
  4840. }
  4841. void QtCurveStyle::drawComplexControlMask(ComplexControl control, TQPainter *p, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags,
  4842. const TQRect &r, const TQStyleOption &data, const TQWidget *widget) const
  4843. {
  4844. switch (control)
  4845. {
  4846. case CC_SpinWidget:
  4847. case CC_ComboBox:
  4848. case CC_ToolButton:
  4849. drawControlMask(CE_PushButton, p, ceData, elementFlags, r, data, widget);
  4850. break;
  4851. default:
  4852. BASE_STYLE::drawComplexControlMask(control, p, ceData, elementFlags, r, data, widget);
  4853. }
  4854. }
  4855. TQRect QtCurveStyle::subRect(SubRect subrect, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget)const
  4856. {
  4857. TQRect rect,
  4858. wrect(widget->rect());
  4859. switch(subrect)
  4860. {
  4861. case SR_PushButtonFocusRect:
  4862. {
  4863. if(FOCUS_FULL==opts.focus)
  4864. rect=wrect;
  4865. else
  4866. {
  4867. int dbw1(pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget)),
  4868. dbw2(dbw1*2),
  4869. border(3),
  4870. border2=(border*2);
  4871. rect.setRect(wrect.x()+border +dbw1, wrect.y()+border +dbw1,
  4872. wrect.width()-border2-dbw2,
  4873. wrect.height()-border2-dbw2);
  4874. }
  4875. if(!isFormWidget(widget) && DO_EFFECT)
  4876. rect.addCoords(1, 1, -1, -1);
  4877. return rect;
  4878. }
  4879. case SR_ProgressBarContents:
  4880. return opts.fillProgress
  4881. ? DO_EFFECT && opts.borderProgress
  4882. ? wrect
  4883. : TQRect(wrect.left()-1, wrect.top()-1, wrect.width()+2, wrect.height()+2)
  4884. : DO_EFFECT && opts.borderProgress
  4885. ? TQRect(wrect.left()+2, wrect.top()+2, wrect.width()-4, wrect.height()-4)
  4886. : TQRect(wrect.left()+1, wrect.top()+1, wrect.width()-2, wrect.height()-2);
  4887. case SR_ProgressBarLabel:
  4888. case SR_ProgressBarGroove:
  4889. return wrect;
  4890. case SR_DockWindowHandleRect:
  4891. return wrect;
  4892. default:
  4893. return BASE_STYLE::subRect(subrect, ceData, elementFlags, widget);
  4894. }
  4895. return rect;
  4896. }
  4897. // This is a hack, as TQTitleBar is private!!!
  4898. class TQTitleBar : public TQWidget
  4899. {
  4900. public:
  4901. bool isActive() const;
  4902. TQWidget *window() const;
  4903. };
  4904. void QtCurveStyle::drawComplexControl(ComplexControl control, TQPainter *p, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
  4905. const TQRect &r, const TQColorGroup &cg, SFlags flags,
  4906. SCFlags controls, SCFlags active,
  4907. const TQStyleOption &data, const TQWidget *widget) const
  4908. {
  4909. if(widget==itsHoverWidget)
  4910. flags |=Style_MouseOver;
  4911. switch(control)
  4912. {
  4913. case CC_ToolButton:
  4914. {
  4915. const TQToolButton *toolbutton((const TQToolButton *)widget);
  4916. TQRect button(querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, data, widget)),
  4917. menuarea(querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu,
  4918. data, widget));
  4919. SFlags bflags(flags|STD_TOOLBUTTON),
  4920. mflags(flags);
  4921. if (APP_KORN==itsThemedApp)
  4922. {
  4923. drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, data);
  4924. break;
  4925. }
  4926. const TQToolBar *tb(widget->parentWidget()
  4927. ? ::tqqt_cast<const TQToolBar *>(widget->parentWidget()) : 0L);
  4928. bool onControlButtons(false),
  4929. onExtender(!tb &&
  4930. widget->parentWidget() &&
  4931. widget->parentWidget()->inherits( "TQToolBarExtensionWidget") &&
  4932. ::tqqt_cast<TQToolBar *>(widget->parentWidget()->parentWidget())),
  4933. isDWClose(!tb && !onExtender &&
  4934. widget->parentWidget() &&
  4935. widget->parentWidget()->inherits( TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING));
  4936. if(isDWClose)
  4937. {
  4938. p->fillRect(r, cg.background());//.dark(DW_BGND));
  4939. if(!(flags&Style_MouseOver) && !(active & SC_ToolButton))
  4940. break;
  4941. bflags|=DW_CLOSE_BUTTON;
  4942. }
  4943. if (!tb && !onExtender && widget->parentWidget() &&
  4944. !qstrcmp(widget->parentWidget()->name(), "qt_maxcontrols"))
  4945. onControlButtons = true;
  4946. if(active & SC_ToolButton)
  4947. bflags |=Style_Down;
  4948. if(active & SC_ToolButtonMenu)
  4949. mflags |=Style_Down;
  4950. itsFormMode = isFormWidget(widget);
  4951. if(controls&SC_ToolButton)
  4952. {
  4953. if(onControlButtons ||
  4954. (toolbutton->parentWidget() && toolbutton->parentWidget()->parentWidget() &&
  4955. ::tqqt_cast<const TQMenuBar *>(toolbutton->parentWidget()->parentWidget())))
  4956. bflags|=NO_ETCH_BUTTON;
  4957. // If we're pressed, on, or raised...
  4958. #if defined TQTC_TQT_ONLY || !defined TDE_VERSION || TDE_VERSION >= 0x30200
  4959. if(bflags &(Style_Down | Style_On | Style_Raised) || onControlButtons)
  4960. #else
  4961. if(bflags &(Style_Down | Style_On | Style_Raised | Style_MouseOver) ||
  4962. onControlButtons)
  4963. #endif
  4964. {
  4965. //Make sure the standalone toolbuttons have a gradient in the right direction
  4966. if (!tb && !onControlButtons)
  4967. bflags |= Style_Horizontal;
  4968. if(tb) {
  4969. if(Qt::Vertical==tb->orientation()) {
  4970. bflags|=VERTICAL_TB_BUTTON;
  4971. }
  4972. else {
  4973. bflags|=Style_Horizontal;
  4974. }
  4975. }
  4976. if(toolbutton->isToggleButton())
  4977. bflags|=TOGGLE_BUTTON;
  4978. drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, data);
  4979. }
  4980. // Check whether to draw a background pixmap
  4981. else if(APP_MACTOR!=itsThemedApp && toolbutton->parentWidget() &&
  4982. toolbutton->parentWidget()->backgroundPixmap() &&
  4983. !toolbutton->parentWidget()->backgroundPixmap()->isNull())
  4984. p->drawTiledPixmap(r, *(toolbutton->parentWidget()->backgroundPixmap()),
  4985. toolbutton->pos());
  4986. else if(widget->parent())
  4987. {
  4988. TQToolBar *tb(0L);
  4989. if(::tqqt_cast<const TQToolBar *>(widget->parent()))
  4990. tb=(TQToolBar*)widget->parent();
  4991. else if(widget->parent()->inherits("TQToolBarExtensionWidget"))
  4992. {
  4993. TQWidget *parent=(TQWidget*)widget->parent();
  4994. tb=(TQToolBar*)parent->parent();
  4995. }
  4996. if(tb)
  4997. {
  4998. TQRect tbr(tb->rect());
  4999. bool horiz(Qt::Horizontal==tb->orientation());
  5000. if(!IS_FLAT(opts.toolbarAppearance)) {
  5001. if(horiz) {
  5002. tbr.addCoords(0, -1, 0, 0);
  5003. }
  5004. else {
  5005. tbr.addCoords(-1, 0, 0, 0);
  5006. }
  5007. }
  5008. drawMenuOrToolBarBackground(p, tbr, cg, false, horiz);
  5009. }
  5010. }
  5011. }
  5012. if(controls&SC_ToolButtonMenu)
  5013. {
  5014. if(mflags &(Style_Down | Style_On | Style_Raised))
  5015. drawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, data);
  5016. ::drawArrow(p, menuarea, MO_ARROW(cg.buttonText()), PE_ArrowDown, opts, true);
  5017. }
  5018. if(toolbutton->hasFocus() && !toolbutton->focusProxy())
  5019. {
  5020. TQRect fr(toolbutton->rect());
  5021. if(FOCUS_FULL!=opts.focus) {
  5022. fr.addCoords(2, 2,-2,-2);
  5023. }
  5024. if(DO_EFFECT) {
  5025. fr.addCoords(1, 1,-1,-1);
  5026. }
  5027. drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg);
  5028. }
  5029. itsFormMode=false;
  5030. break;
  5031. }
  5032. case CC_ComboBox:
  5033. {
  5034. if(APP_OPENOFFICE==itsThemedApp)
  5035. flags&=~Style_MouseOver;
  5036. itsFormMode = isFormWidget(widget);
  5037. const TQComboBox *combobox((const TQComboBox *)widget);
  5038. TQRect frame(TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, ceData, elementFlags,
  5039. SC_ComboBoxFrame,
  5040. data, widget), ceData, elementFlags)),
  5041. arrow(TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, ceData, elementFlags,
  5042. SC_ComboBoxArrow,
  5043. data, widget), ceData, elementFlags)),
  5044. field(TQStyle::visualRect(querySubControlMetrics(CC_ComboBox, ceData, elementFlags,
  5045. SC_ComboBoxEditField,
  5046. data, widget), ceData, elementFlags));
  5047. const TQColor *use(buttonColors(cg));
  5048. bool editable(combobox->editable()),
  5049. sunken(combobox->listBox() ? combobox->listBox()->isShown() : false),
  5050. reverse(TQApplication::reverseLayout());
  5051. SFlags fillFlags(flags),
  5052. doEtch(!itsFormMode && DO_EFFECT && (!editable || opts.etchEntry));
  5053. if(doEtch)
  5054. {
  5055. frame.addCoords(1, 1, -1, -1);
  5056. field.addCoords(reverse ? -1 : 1, 1, reverse ? -1 : 0, -1);
  5057. }
  5058. if(sunken)
  5059. {
  5060. fillFlags|=Style_Sunken;
  5061. if(fillFlags&Style_MouseOver)
  5062. fillFlags-=Style_MouseOver;
  5063. }
  5064. if(editable ||(!itsFormMode && DO_EFFECT && qstrcmp(widget->name(), kdeToolbarWidget)))
  5065. {
  5066. p->setPen(cg.background());
  5067. p->drawRect(r);
  5068. }
  5069. if(controls&SC_ComboBoxFrame && frame.isValid())
  5070. {
  5071. if(editable && opts.unifyCombo)
  5072. {
  5073. if(reverse)
  5074. frame.addCoords(0, 1, 2, -1);
  5075. else
  5076. frame.addCoords(-1, 1, -1, -1);
  5077. p->fillRect(frame, flags&Style_Enabled ? cg.base() : cg.background());
  5078. }
  5079. else
  5080. {
  5081. const TQColor *cols=itsComboBtnCols && editable && flags&Style_Enabled ? itsComboBtnCols : use;
  5082. if(editable && HOVER_CB_ARROW!=itsHover)
  5083. fillFlags&=~Style_MouseOver;
  5084. // if(opts.coloredMouseOver && fillFlags&Style_MouseOver && editable && !sunken)
  5085. // frame.addCoords(reverse ? 0 : 1, 0, reverse ? 1 : 0, 0);
  5086. drawLightBevel(p, frame, cg, fillFlags|Style_Raised|Style_Horizontal,
  5087. controls&SC_ComboBoxEditField && field.isValid() && editable
  5088. ? (reverse ? ROUNDED_LEFT : ROUNDED_RIGHT) : ROUNDED_ALL,
  5089. getFill(fillFlags, cols, false, (SHADE_DARKEN==opts.comboBtn ||
  5090. (SHADE_NONE!=opts.comboBtn && !(flags&Style_Enabled))) &&
  5091. editable),
  5092. cols, true, true, editable ? WIDGET_COMBO_BUTTON : WIDGET_COMBO);
  5093. }
  5094. }
  5095. if(controls&SC_ComboBoxEditField && field.isValid())
  5096. {
  5097. if(editable)
  5098. {
  5099. if(opts.unifyCombo)
  5100. {
  5101. field=r;
  5102. if(DO_EFFECT)
  5103. field.addCoords(1, 1, -1, -1);
  5104. }
  5105. else
  5106. field.addCoords(-1,-1, 0, 1);
  5107. p->setPen(flags&Style_Enabled ? cg.base() : cg.background());
  5108. p->drawRect(field);
  5109. if(!opts.unifyCombo)
  5110. field.addCoords(-2,-2, 2, 2);
  5111. SFlags fieldFlags(flags);
  5112. if(!opts.unifyCombo && HOVER_CB_ENTRY!=itsHover)
  5113. fieldFlags&=~Style_MouseOver;
  5114. drawEntryField(p, field, cg, fillFlags, fieldFlags&Style_Enabled
  5115. ? fieldFlags&Style_MouseOver
  5116. ? ENTRY_MOUSE_OVER
  5117. : fieldFlags&Style_HasFocus
  5118. ? ENTRY_FOCUS
  5119. : ENTRY_NONE
  5120. : ENTRY_NONE,
  5121. (opts.square&SQUARE_ENTRY)
  5122. ? ROUNDED_NONE
  5123. : opts.unifyCombo
  5124. ? ROUNDED_ALL
  5125. : reverse
  5126. ? ROUNDED_RIGHT
  5127. : ROUNDED_LEFT,
  5128. WIDGET_COMBO);
  5129. }
  5130. else if(opts.comboSplitter && !(SHADE_DARKEN==opts.comboBtn || itsComboBtnCols))
  5131. {
  5132. field.addCoords(1, sunken ? 2 : 1, sunken ? 2 : 1, -1);
  5133. p->setPen(use[BORDER_VAL(flags&Style_Enabled)]);
  5134. p->drawLine(reverse ? field.left()-3 : field.right(), field.top(),
  5135. reverse ? field.left()-3 : field.right(), field.bottom());
  5136. if(!sunken)
  5137. {
  5138. p->setPen(use[0]);
  5139. p->drawLine(reverse ? field.left()-2 : field.right()+1, field.top(),
  5140. reverse ? field.left()-2 : field.right()+1, field.bottom());
  5141. }
  5142. }
  5143. if(flags&Style_HasFocus && !editable && FOCUS_GLOW!=opts.focus)
  5144. {
  5145. TQRect fr;
  5146. if(FOCUS_FULL==opts.focus)
  5147. fr=frame;
  5148. else if(opts.comboSplitter)
  5149. {
  5150. fr=TQStyle::visualRect(subRect(SR_ComboBoxFocusRect, ceData, elementFlags, widget), ceData, elementFlags);
  5151. if(reverse)
  5152. fr.addCoords(3, 0, 0, 0);
  5153. else
  5154. fr.addCoords(0, 0, -2, 0);
  5155. if(!itsFormMode && DO_EFFECT)
  5156. fr.addCoords(1, 1, -1, -1);
  5157. }
  5158. else
  5159. {
  5160. fr=frame;
  5161. fr.addCoords(3, 3, -3, -3);
  5162. }
  5163. if(!(flags&Style_MouseOver && FOCUS_FULL==opts.focus && MO_NONE!=opts.coloredMouseOver))
  5164. drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags | Style_FocusAtBorder,
  5165. TQStyleOption(cg.highlight()));
  5166. }
  5167. }
  5168. if(controls&SC_ComboBoxArrow && arrow.isValid())
  5169. {
  5170. if(!editable && (SHADE_DARKEN==opts.comboBtn || itsComboBtnCols))
  5171. {
  5172. SFlags btnFlags(flags);
  5173. TQRect btn(arrow.x(), frame.y(), arrow.width()+1, frame.height());
  5174. const TQColor *cols=SHADE_DARKEN==opts.comboBtn || !(flags&Style_Enabled) ? use : itsComboBtnCols;
  5175. if(!sunken)
  5176. btnFlags|=Style_Raised;
  5177. p->save();
  5178. p->setClipRect(btn);
  5179. if(!opts.comboSplitter)
  5180. btn.addCoords(reverse ? 0 : -2, 0, reverse ? 2 : 0, 0);
  5181. if(!DO_EFFECT)
  5182. btn.addCoords(0, 0, 1, 0);
  5183. drawLightBevel(p, btn, cg, btnFlags|Style_Horizontal, reverse ? ROUNDED_LEFT : ROUNDED_RIGHT,
  5184. getFill(btnFlags, cols, false, SHADE_DARKEN==opts.comboBtn ||
  5185. (SHADE_NONE!=opts.comboBtn && !(flags&Style_Enabled))),
  5186. cols, true, true, WIDGET_COMBO);
  5187. p->restore();
  5188. }
  5189. SFlags arrowFlags(flags);
  5190. if(sunken && !opts.unifyCombo)
  5191. arrow.addCoords(1, 1, 1, 1);
  5192. if(editable && HOVER_CB_ARROW!=itsHover)
  5193. arrowFlags&=~Style_MouseOver;
  5194. ::drawArrow(p, arrow, MO_ARROW_X(arrowFlags, cg.buttonText()), PE_ArrowDown, opts);
  5195. }
  5196. if(doEtch)
  5197. {
  5198. bool glowFocus(USE_GLOW_FOCUS(flags&Style_MouseOver) && flags&Style_HasFocus && flags&Style_Enabled);
  5199. if(!sunken && !editable &&
  5200. ((MO_GLOW==opts.coloredMouseOver && flags&Style_MouseOver)/* ||
  5201. (FOCUS_FULL==opts.focus && flags&Style_HasFocus)*/ || glowFocus))
  5202. drawGlow(p, widget ? TQT_TQRECT_OBJECT(widget->rect()) : r, cg, WIDGET_COMBO, glowFocus ? itsFocusCols : NULL);
  5203. else
  5204. drawEtch(p, widget ? TQT_TQRECT_OBJECT(widget->rect()) : r, cg,
  5205. !editable && EFFECT_SHADOW==opts.buttonEffect && !sunken, editable && (opts.square&SQUARE_ENTRY));
  5206. }
  5207. p->setPen(cg.buttonText());
  5208. itsFormMode = false;
  5209. break;
  5210. }
  5211. case CC_SpinWidget:
  5212. {
  5213. itsFormMode = isFormWidget(widget);
  5214. const TQSpinWidget *spinwidget((const TQSpinWidget *)widget);
  5215. TQRect frame(querySubControlMetrics(CC_SpinWidget, ceData, elementFlags, SC_SpinWidgetFrame,
  5216. data, widget)),
  5217. up(spinwidget->upRect()),
  5218. down(spinwidget->downRect()),
  5219. all(frame.unite(up).unite(down));
  5220. bool hw(itsHoverWidget && itsHoverWidget==spinwidget),
  5221. reverse(TQApplication::reverseLayout()),
  5222. doFrame((controls&SC_SpinWidgetFrame) && frame.isValid()),
  5223. doEtch(!itsFormMode && DO_EFFECT && opts.etchEntry);
  5224. if(doEtch)
  5225. {
  5226. down.addCoords(reverse ? 1 : 0, 0, reverse ? 0 : -1, -1);
  5227. up.addCoords(reverse ? 1 : 0, 1, reverse ? 0 : -1, 0);
  5228. frame.addCoords(reverse ? 0 : 1, 1, reverse ? -1 : 0, -1);
  5229. }
  5230. if(flags&Style_MouseOver)
  5231. flags-=Style_MouseOver;
  5232. if(opts.unifySpin)
  5233. drawEntryField(p, all, cg, flags, spinwidget && flags&Style_Enabled
  5234. ? flags&Style_MouseOver || hw
  5235. ? ENTRY_MOUSE_OVER
  5236. : flags&Style_HasFocus || spinwidget->hasFocus()
  5237. ? ENTRY_FOCUS
  5238. : ENTRY_NONE
  5239. : ENTRY_NONE,
  5240. ROUNDED_ALL, WIDGET_SPIN);
  5241. else
  5242. {
  5243. if(!reverse && doFrame)
  5244. {
  5245. frame.setWidth(frame.width()+1);
  5246. drawEntryField(p, frame, cg, flags,
  5247. spinwidget && flags&Style_Enabled
  5248. ? flags&Style_MouseOver || hw
  5249. ? ENTRY_MOUSE_OVER
  5250. : flags&Style_HasFocus || spinwidget->hasFocus()
  5251. ? ENTRY_FOCUS
  5252. : ENTRY_NONE
  5253. : ENTRY_NONE,
  5254. ROUNDED_LEFT, WIDGET_SPIN);
  5255. }
  5256. if(opts.unifySpinBtns)
  5257. {
  5258. TQRect btns=up.unite(down);
  5259. const TQColor *use(buttonColors(cg));
  5260. int btnFlags=flags;
  5261. btnFlags&=~(Style_Sunken|Style_MouseOver);
  5262. btnFlags|=Style_Horizontal;
  5263. drawLightBevel(p, btns, cg, btnFlags, reverse ? ROUNDED_LEFT : ROUNDED_RIGHT, getFill(btnFlags, use),
  5264. use, true, true, WIDGET_SPIN);
  5265. if(hw && (HOVER_SW_DOWN==itsHover || HOVER_SW_UP==itsHover) && flags&Style_Enabled && !(flags&Style_Sunken))
  5266. {
  5267. btnFlags|=Style_MouseOver;
  5268. p->save();
  5269. p->setClipRect(HOVER_SW_UP==itsHover ? up : down);
  5270. drawLightBevel(p, btns, cg, btnFlags, reverse ? ROUNDED_LEFT : ROUNDED_RIGHT, getFill(btnFlags, use),
  5271. use, true, true, WIDGET_SPIN);
  5272. p->restore();
  5273. }
  5274. p->setPen(use[BORDER_VAL(style&Style_Enabled)]);
  5275. p->drawLine(down.x()+2, down.y(), down.x()+down.width()-3, down.y());
  5276. }
  5277. }
  5278. if((controls&SC_SpinWidgetUp) && up.isValid())
  5279. {
  5280. PrimitiveElement pe(PE_SpinWidgetUp);
  5281. SFlags upflags(flags);
  5282. if(hw && HOVER_SW_UP==itsHover)
  5283. upflags|=Style_MouseOver;
  5284. up.setHeight(up.height()+1);
  5285. if(spinwidget->buttonSymbols()==TQSpinWidget::PlusMinus)
  5286. pe=PE_SpinWidgetPlus;
  5287. if(!spinwidget->isUpEnabled())
  5288. upflags&=~Style_Enabled;
  5289. drawPrimitive(pe, p, ceData, elementFlags, up, !(upflags&Style_Enabled) && spinwidget ? spinwidget->palette().disabled() : cg,
  5290. upflags |((active==SC_SpinWidgetUp)
  5291. ? Style_On | Style_Sunken : Style_Raised));
  5292. }
  5293. if((controls&SC_SpinWidgetDown) && down.isValid())
  5294. {
  5295. PrimitiveElement pe(PE_SpinWidgetDown);
  5296. SFlags downflags(flags);
  5297. if(hw && HOVER_SW_DOWN==itsHover)
  5298. downflags|=Style_MouseOver;
  5299. if(spinwidget->buttonSymbols()==TQSpinWidget::PlusMinus)
  5300. pe=PE_SpinWidgetMinus;
  5301. if(!spinwidget->isDownEnabled())
  5302. downflags&=~Style_Enabled;
  5303. drawPrimitive(pe, p, ceData, elementFlags, down, !(downflags&Style_Enabled) && spinwidget ? spinwidget->palette().disabled() : cg,
  5304. downflags |((active==SC_SpinWidgetDown)
  5305. ? Style_On | Style_Sunken : Style_Raised));
  5306. }
  5307. if(!opts.unifySpin)
  5308. {
  5309. if(reverse && doFrame)
  5310. {
  5311. frame.setWidth(frame.width()+1);
  5312. drawEntryField(p, frame, cg, flags,
  5313. spinwidget && flags&Style_Enabled
  5314. ? flags&Style_MouseOver || hw
  5315. ? ENTRY_MOUSE_OVER
  5316. : flags&Style_HasFocus || spinwidget->hasFocus()
  5317. ? ENTRY_FOCUS
  5318. : ENTRY_NONE
  5319. : ENTRY_NONE,
  5320. ROUNDED_RIGHT, WIDGET_SPIN);
  5321. }
  5322. if(doEtch)
  5323. drawEtch(p, spinwidget ? TQT_TQRECT_OBJECT(spinwidget->rect()) : r, cg, false, (opts.square&SQUARE_ENTRY));
  5324. }
  5325. itsFormMode=false;
  5326. break;
  5327. }
  5328. case CC_ScrollBar:
  5329. {
  5330. const TQScrollBar *sb((const TQScrollBar *)widget);
  5331. bool hw(itsHoverWidget && itsHoverWidget==sb),
  5332. useThreeButtonScrollBar(SCROLLBAR_KDE==opts.scrollbarType),
  5333. horiz(Qt::Horizontal==sb->orientation()),
  5334. maxed(sb->minValue() == sb->maxValue()),
  5335. atMin(maxed || sb->value()==sb->minValue()),
  5336. atMax(maxed || sb->value()==sb->maxValue());
  5337. SFlags sflags((horiz ? Style_Horizontal : Style_Default) |
  5338. (maxed || !widget->isEnabled() ? Style_Default : Style_Enabled));
  5339. TQRect subline(querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubLine,
  5340. data, widget)),
  5341. addline(querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddLine,
  5342. data, widget)),
  5343. subpage(querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSubPage,
  5344. data, widget)),
  5345. addpage(querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarAddPage,
  5346. data, widget)),
  5347. slider(querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarSlider,
  5348. data, widget)),
  5349. first(querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarFirst,
  5350. data, widget)),
  5351. last(querySubControlMetrics(control, ceData, elementFlags, SC_ScrollBarLast,
  5352. data, widget)),
  5353. subline2(addline),
  5354. sbRect(sb->rect());
  5355. itsFormMode=isFormWidget(widget);
  5356. if(itsFormMode)
  5357. {
  5358. // See KHTML note at top of file
  5359. if(horiz)
  5360. {
  5361. subline.addCoords(0, 0, 0, -1);
  5362. addline.addCoords(0, 0, 0, -1);
  5363. subpage.addCoords(0, 0, 0, -1);
  5364. addpage.addCoords(0, 0, 0, -1);
  5365. slider.addCoords(0, 0, 0, -1);
  5366. first.addCoords(0, 0, 0, -1);
  5367. last.addCoords(0, 0, 0, -1);
  5368. subline2.addCoords(0, 0, 0, -1);
  5369. sbRect.addCoords(0, 0, 0, -1);
  5370. }
  5371. else
  5372. {
  5373. subline.addCoords(0, 0, -1, 0);
  5374. addline.addCoords(0, 0, -1, 0);
  5375. subpage.addCoords(0, 0, -1, 0);
  5376. addpage.addCoords(0, 0, -1, 0);
  5377. slider.addCoords(0, 0, -1, 0);
  5378. first.addCoords(0, 0, -1, 0);
  5379. last.addCoords(0, 0, -1, 0);
  5380. subline2.addCoords(0, 0, -1, 0);
  5381. sbRect.addCoords(0, 0, -1, 0);
  5382. }
  5383. #ifndef SIMPLE_SCROLLBARS
  5384. if(sbRect.isValid() && (SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons)) {
  5385. if(horiz) {
  5386. sbRect.addCoords(0, 0, -1, 0);
  5387. }
  5388. else {
  5389. sbRect.addCoords(0, 0, 0, -1);
  5390. }
  5391. }
  5392. #endif
  5393. }
  5394. else if (useThreeButtonScrollBar) {
  5395. if (horiz) {
  5396. subline2.moveBy(-addline.width(), 0);
  5397. }
  5398. else {
  5399. subline2.moveBy(0, -addline.height());
  5400. }
  5401. }
  5402. if(opts.flatSbarButtons) {
  5403. switch(opts.scrollbarType)
  5404. {
  5405. case SCROLLBAR_KDE:
  5406. if(horiz)
  5407. sbRect.addCoords(subline.width(), 0, -(addline.width()+subline2.width()), 0);
  5408. else
  5409. sbRect.addCoords(0, subline.height(), 0, -(addline.height()+subline2.height()));
  5410. break;
  5411. case SCROLLBAR_WINDOWS:
  5412. if(horiz)
  5413. sbRect.addCoords(subline.width(), 0, -(addline.width()), 0);
  5414. else
  5415. sbRect.addCoords(0, subline.height(), 0, -(addline.height()));
  5416. break;
  5417. case SCROLLBAR_NEXT:
  5418. if(horiz)
  5419. sbRect.addCoords(subline.width()+subline2.width(), 0, 0, 0);
  5420. else
  5421. sbRect.addCoords(0, subline.height()+subline2.height(), 0, 0);
  5422. break;
  5423. case SCROLLBAR_PLATINUM:
  5424. if(horiz)
  5425. sbRect.addCoords(0, 0, -(addline.width()+subline2.width()), 0);
  5426. else
  5427. sbRect.addCoords(0, 0, 0, -(addline.height()+subline2.height()));
  5428. default:
  5429. break;
  5430. }
  5431. }
  5432. // Draw trough...
  5433. const TQColor *trough(itsBackgroundCols); // backgroundColors(cg));
  5434. bool noButtons((SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons) && ROUNDED);
  5435. TQRect s2(subpage), a2(addpage);
  5436. #ifndef SIMPLE_SCROLLBARS
  5437. if(noButtons)
  5438. {
  5439. // Increase clipping to allow trough to "bleed" into slider corners...
  5440. a2.addCoords(-2, -2, 2, 2);
  5441. s2.addCoords(-2, -2, 2, 2);
  5442. }
  5443. #endif
  5444. p->save();
  5445. if(opts.flatSbarButtons)
  5446. p->setClipRegion(TQRegion(s2)+TQRegion(addpage)+TQRegion(addline)+TQRegion(subline)+TQRegion(subline2));
  5447. else
  5448. p->setClipRegion(TQRegion(s2)+TQRegion(addpage));
  5449. if(opts.flatSbarButtons && SCROLLBAR_NONE!=opts.scrollbarType && ROUNDED && !IS_FLAT(opts.sbarBgndAppearance))
  5450. drawBevelGradient(itsBackgroundCols[ORIGINAL_SHADE], p, r, flags&Style_Horizontal, false,
  5451. opts.sbarBgndAppearance, WIDGET_SB_BGND);
  5452. else if(opts.thinSbarGroove && (SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons) && IS_FLAT(opts.sbarBgndAppearance))
  5453. {
  5454. TQColor color(cg.background());
  5455. if(0!=opts.tabBgnd && inStackWidget(widget))
  5456. color=shade(color, TO_FACTOR(opts.tabBgnd));
  5457. p->fillRect(sbRect, cg.background());
  5458. }
  5459. sflags&=~(Style_Down|Style_On|Style_Sunken);
  5460. if(opts.thinSbarGroove && (SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons)) {
  5461. if(horiz) {
  5462. sbRect.addCoords(0, THIN_SBAR_MOD, 0, -THIN_SBAR_MOD);
  5463. }
  5464. else {
  5465. sbRect.addCoords(THIN_SBAR_MOD, 0, -THIN_SBAR_MOD, 0);
  5466. }
  5467. }
  5468. drawLightBevel(p, sbRect, cg, sflags/*|Style_Down*/,
  5469. #ifndef SIMPLE_SCROLLBARS
  5470. !(opts.square&SQUARE_SB_SLIDER) && (SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons)
  5471. ? ROUNDED_ALL :
  5472. #endif
  5473. ROUNDED_NONE,
  5474. trough[2], trough, true, true,
  5475. opts.thinSbarGroove && (SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons)
  5476. ? WIDGET_SLIDER_TROUGH : WIDGET_TROUGH);
  5477. p->restore();
  5478. if(/*(controls&SC_ScrollBarSubLine) && */subline.isValid())
  5479. {
  5480. bool enable=!atMin;
  5481. drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline, !enable && sb ? sb->palette().disabled() : cg,
  5482. sflags |
  5483. //(enable ? Style_Enabled : Style_Default) |
  5484. (enable && hw && HOVER_SB_SUB==itsHover
  5485. ? Style_MouseOver : Style_Default) |
  5486. (enable && (!hw || HOVER_SB_SUB==itsHover || HOVER_NONE==itsHover)
  5487. && SC_ScrollBarSubLine==active ? Style_Down : Style_Default));
  5488. if (useThreeButtonScrollBar && subline2.isValid())
  5489. {
  5490. if(IS_FLAT(opts.sbarBgndAppearance))
  5491. p->fillRect(subline2, cg.background());
  5492. drawPrimitive(PE_ScrollBarSubLine, p, ceData, elementFlags, subline2, !enable && sb ? sb->palette().disabled() : cg,
  5493. sflags |
  5494. //(enable ? Style_Enabled : Style_Default) |
  5495. (enable && hw && HOVER_SB_SUB2==itsHover
  5496. ? Style_MouseOver : Style_Default) |
  5497. (enable && (!hw || HOVER_SB_SUB2==itsHover || HOVER_NONE==itsHover)
  5498. && SC_ScrollBarSubLine==active ? Style_Down : Style_Default));
  5499. }
  5500. }
  5501. if(/*(controls&SC_ScrollBarAddLine) && */addline.isValid())
  5502. {
  5503. bool enable=!atMax;
  5504. // See KHTML note at top of file
  5505. if(itsFormMode && SCROLLBAR_NEXT!=opts.scrollbarType) {
  5506. if(horiz) {
  5507. addline.addCoords(0, 0, -1, 0);
  5508. }
  5509. else {
  5510. addline.addCoords(0, 0, 0, -1);
  5511. }
  5512. }
  5513. drawPrimitive(PE_ScrollBarAddLine, p, ceData, elementFlags, addline, !enable && sb ? sb->palette().disabled() : cg,
  5514. sflags |
  5515. //(enable ? Style_Enabled : Style_Default) |
  5516. (enable && hw && HOVER_SB_ADD==itsHover
  5517. ? Style_MouseOver : Style_Default) |
  5518. (enable && SC_ScrollBarAddLine==active
  5519. ? Style_Down : Style_Default));
  5520. }
  5521. if((controls&SC_ScrollBarFirst) && first.isValid())
  5522. drawPrimitive(PE_ScrollBarFirst, p, ceData, elementFlags, first, cg, sflags |
  5523. //(maxed ? Style_Default : Style_Enabled) |
  5524. (!maxed && SC_ScrollBarFirst==active ? Style_Down : Style_Default));
  5525. if((controls&SC_ScrollBarLast) && last.isValid())
  5526. drawPrimitive(PE_ScrollBarLast, p, ceData, elementFlags, last, cg, sflags |
  5527. //(maxed ? Style_Default : Style_Enabled) |
  5528. (!maxed && SC_ScrollBarLast==active ? Style_Down : Style_Default));
  5529. if(((controls&SC_ScrollBarSlider) || noButtons) && slider.isValid())
  5530. {
  5531. // If "SC_ScrollBarSlider" wasn't pecified, then we only want to draw the portion
  5532. // of the slider that overlaps with the tough. So, once again set the clipping
  5533. // region...
  5534. if(!(controls&SC_ScrollBarSlider))
  5535. p->setClipRegion(TQRegion(s2)+TQRegion(addpage));
  5536. #ifdef INCREASE_SB_SLIDER
  5537. else if(!opts.flatSbarButtons)
  5538. {
  5539. if(atMax)
  5540. switch(opts.scrollbarType)
  5541. {
  5542. case SCROLLBAR_KDE:
  5543. case SCROLLBAR_WINDOWS:
  5544. case SCROLLBAR_PLATINUM:
  5545. if(horiz)
  5546. slider.addCoords(0, 0, 1, 0);
  5547. else
  5548. slider.addCoords(0, 0, 0, 1);
  5549. default:
  5550. break;
  5551. }
  5552. if(atMin)
  5553. switch(opts.scrollbarType)
  5554. {
  5555. case SCROLLBAR_KDE:
  5556. case SCROLLBAR_WINDOWS:
  5557. case SCROLLBAR_NEXT:
  5558. if(horiz)
  5559. slider.addCoords(-1, 0, 0, 0);
  5560. else
  5561. slider.addCoords(0, -1, 0, 0);
  5562. default:
  5563. break;
  5564. }
  5565. }
  5566. #endif
  5567. if(opts.thinSbarGroove) {
  5568. if(opts.flatSbarButtons && SCROLLBAR_NONE!=opts.scrollbarType && ROUNDED) {
  5569. drawBevelGradient(itsBackgroundCols[ORIGINAL_SHADE], p, slider, flags&Style_Horizontal, false,
  5570. opts.sbarBgndAppearance, WIDGET_SB_BGND);
  5571. }
  5572. else if(opts.thinSbarGroove && (SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons) &&
  5573. IS_FLAT(opts.sbarBgndAppearance)) {
  5574. p->fillRect(slider, cg.background());
  5575. }
  5576. }
  5577. drawPrimitive(PE_ScrollBarSlider, p, ceData, elementFlags, slider, cg, sflags |
  5578. //(maxed ? Style_Default : Style_Enabled) |
  5579. (!maxed && hw && HOVER_SB_SLIDER==itsHover
  5580. ? Style_MouseOver : Style_Default) |
  5581. (!maxed && SC_ScrollBarSlider==active
  5582. ? Style_Down : Style_Default));
  5583. // ### perhaps this should not be able to accept focus if maxedOut?
  5584. if(sb->hasFocus()) {
  5585. drawPrimitive(PE_FocusRect, p, ceData, elementFlags, TQRect(slider.x()+2, slider.y()+2,
  5586. slider.width()-5, slider.height()-5), cg, Style_Default);
  5587. }
  5588. #ifndef SIMPLE_SCROLLBARS
  5589. if(noButtons && (!atMin || !atMax) && !opts.thinSbarGroove)
  5590. {
  5591. p->setPen(backgroundColors(cg)[STD_BORDER]);
  5592. if(horiz)
  5593. {
  5594. if(!atMin)
  5595. {
  5596. p->drawLine(slider.x(), slider.y(),
  5597. slider.x()+1, slider.y());
  5598. p->drawLine(slider.x(), slider.y()+slider.height()-1,
  5599. slider.x()+1, slider.y()+slider.height()-1);
  5600. }
  5601. if(!atMax)
  5602. {
  5603. p->drawLine(slider.x()+slider.width()-1, slider.y(),
  5604. slider.x()+slider.width()-2, slider.y());
  5605. p->drawLine(slider.x()+slider.width()-1,
  5606. slider.y()+slider.height()-1,
  5607. slider.x()+slider.width()-2,
  5608. slider.y()+slider.height()-1);
  5609. }
  5610. }
  5611. else
  5612. {
  5613. if(!atMin)
  5614. {
  5615. p->drawLine(slider.x(), slider.y(),
  5616. slider.x(), slider.y()+1);
  5617. p->drawLine(slider.x()+slider.width()-1, slider.y(),
  5618. slider.x()+slider.width()-1, slider.y()+1);
  5619. }
  5620. if(!atMax)
  5621. {
  5622. p->drawLine(slider.x(), slider.y()+slider.height()-1,
  5623. slider.x(), slider.y()+slider.height()-2);
  5624. p->drawLine(slider.x()+slider.width()-1,
  5625. slider.y()+slider.height()-1,
  5626. slider.x()+slider.width()-1,
  5627. slider.y()+slider.height()-2);
  5628. }
  5629. }
  5630. }
  5631. #endif
  5632. // if(!(controls&SC_ScrollBarSlider))
  5633. // p->setClipping(false);
  5634. }
  5635. break;
  5636. }
  5637. case CC_Slider:
  5638. //
  5639. // Note: Can't use KStyle's drawing routine, as this doesnt work for sliders on gradient
  5640. // toolbars. It also draws groove, focus, slider - wherease QtCurve needs groove,
  5641. // slider, focus. We also ony double-buffer if not on a toolbar, as we dont know
  5642. // the background, etc, if on a toolbar - and that is handled in eventFilter
  5643. {
  5644. bool tb(!IS_FLAT(opts.toolbarAppearance) && widget &&
  5645. 0==qstrcmp(widget->name(), kdeToolbarWidget));
  5646. TQRect groove=querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, data, widget),
  5647. handle=querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, data, widget);
  5648. TQPixmap pix(widget->size());
  5649. TQPainter p2,
  5650. *paint(tb ? p : &p2);
  5651. if(!tb)
  5652. {
  5653. paint->begin(&pix);
  5654. if (widget->parentWidget() && widget->parentWidget()->backgroundPixmap() &&
  5655. !widget->parentWidget()->backgroundPixmap()->isNull())
  5656. paint->drawTiledPixmap(r, *(widget->parentWidget()->backgroundPixmap()), widget->pos());
  5657. else
  5658. pix.fill(cg.background());
  5659. }
  5660. if((controls & SC_SliderGroove)&& groove.isValid())
  5661. drawSliderGroove(paint, groove, cg, flags, widget);
  5662. if((controls & SC_SliderHandle)&& handle.isValid())
  5663. drawSliderHandle(paint, handle, cg, flags, widget ? ::tqqt_cast<TQSlider *>(widget) : 0L, tb);
  5664. if(controls & SC_SliderTickmarks)
  5665. TQCommonStyle::drawComplexControl(control, paint, ceData, elementFlags, r, cg, flags, SC_SliderTickmarks,
  5666. active, data, widget);
  5667. if(flags&Style_HasFocus && FOCUS_GLOW!=opts.focus)
  5668. drawPrimitive(PE_FocusRect, paint, ceData, elementFlags, groove, cg);
  5669. if(!tb)
  5670. {
  5671. paint->end();
  5672. bitBlt((TQWidget*)widget, r.x(), r.y(), &pix);
  5673. }
  5674. break;
  5675. }
  5676. case CC_TitleBar:
  5677. {
  5678. const int buttonMargin(3);
  5679. const TQTitleBar *tb((const TQTitleBar *)widget);
  5680. bool isActive((tb->isActive() && widget->isActiveWindow()) ||
  5681. (!tb->window() && widget->topLevelWidget()->isActiveWindow()));
  5682. TQColorGroup cgroup(isActive
  5683. ? widget->palette().active()
  5684. : widget->palette().inactive());
  5685. const TQColor *cols(getMdiColors(cg, isActive));
  5686. TQColor textCol(isActive ? itsActiveMdiTextColor : itsMdiTextColor),
  5687. shdCol(shadowColor(textCol)),
  5688. shadowCol(midColor(cols[ORIGINAL_SHADE], shdCol));
  5689. if (controls&SC_TitleBarLabel)
  5690. {
  5691. int alignment=AlignVCenter|SingleLine;
  5692. bool full=false;
  5693. switch(opts.titlebarAlignment)
  5694. {
  5695. default:
  5696. case ALIGN_LEFT:
  5697. alignment|=TQt::AlignLeft;
  5698. break;
  5699. case ALIGN_CENTER:
  5700. alignment|=TQt::AlignHCenter;
  5701. break;
  5702. case ALIGN_FULL_CENTER:
  5703. alignment|=TQt::AlignHCenter;
  5704. full=true;
  5705. break;
  5706. case ALIGN_RIGHT:
  5707. alignment|=TQt::AlignRight;
  5708. }
  5709. TQRect ir(visualRect(querySubControlMetrics(CC_TitleBar, ceData, elementFlags, SC_TitleBarLabel, TQStyleOption::Default, widget), ceData, elementFlags)),
  5710. textRect(full ? tb->rect().x() : ir.x(), ir.y(), full ? tb->rect().width() : ir.width(), ir.height());
  5711. EAppearance app=isActive ? opts.titlebarAppearance : opts.inactiveTitlebarAppearance;
  5712. drawBevelGradient(cols[ORIGINAL_SHADE], p, r, true, false, app, WIDGET_MDI_WINDOW);
  5713. ir.addCoords(2, 0, -4, 0);
  5714. TQFontMetrics fm(TQFontMetrics(widget->font()));
  5715. TQString titleString(elliditide(widget->caption(), fm, textRect.width()));
  5716. if(full)
  5717. {
  5718. int textWidth=fm.boundingRect(titleString).width();
  5719. if(ir.left()>((textRect.width()-textWidth)>>1))
  5720. {
  5721. alignment=TQt::AlignVCenter|TQt::AlignLeft;
  5722. textRect=ir;
  5723. full=false;
  5724. }
  5725. else if(ir.right()<((textRect.width()+textWidth)>>1))
  5726. {
  5727. alignment=TQt::AlignVCenter|TQt::AlignRight;
  5728. textRect=ir;
  5729. full=false;
  5730. }
  5731. else
  5732. p->setClipRect(ir);
  5733. }
  5734. p->setPen(shadowCol);
  5735. p->drawText(textRect.x()+1, textRect.y()+1, textRect.width(), textRect.height(), alignment, titleString);
  5736. p->setPen(textCol);
  5737. p->drawText(textRect.x(), textRect.y(), textRect.width(), textRect.height(), alignment, titleString);
  5738. if(full)
  5739. p->setClipping(false);
  5740. //controls-=SC_TitleBarLabel;
  5741. }
  5742. TQRect ir;
  5743. bool down(false);
  5744. TQPixmap pm;
  5745. if (controls&SC_TitleBarCloseButton)
  5746. {
  5747. ir = visualRect(querySubControlMetrics(CC_TitleBar, ceData, elementFlags, SC_TitleBarCloseButton, TQStyleOption::Default, widget), ceData, elementFlags);
  5748. down = active & SC_TitleBarCloseButton;
  5749. drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, tb->colorGroup(), down ? Style_Down : Style_Raised);
  5750. drawMdiIcon(p, textCol, shadowCol, ir, down, buttonMargin, SC_TitleBarCloseButton);
  5751. }
  5752. if (tb->window())
  5753. {
  5754. if (controls &SC_TitleBarMaxButton)
  5755. {
  5756. ir = visualRect(querySubControlMetrics(CC_TitleBar, ceData, elementFlags, SC_TitleBarMaxButton, TQStyleOption::Default, widget), ceData, elementFlags);
  5757. down = active & SC_TitleBarMaxButton;
  5758. drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, tb->colorGroup(), down ? Style_Down : Style_Raised);
  5759. drawMdiIcon(p, textCol, shadowCol, ir, down, buttonMargin, SC_TitleBarMaxButton);
  5760. }
  5761. if (controls&SC_TitleBarNormalButton || controls&SC_TitleBarMinButton)
  5762. {
  5763. ir = visualRect(querySubControlMetrics(CC_TitleBar, ceData, elementFlags, SC_TitleBarMinButton, TQStyleOption::Default, widget), ceData, elementFlags);
  5764. TQStyle::SubControl ctrl = (controls & SC_TitleBarNormalButton ?
  5765. SC_TitleBarNormalButton :
  5766. SC_TitleBarMinButton);
  5767. down = active & ctrl;
  5768. drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, tb->colorGroup(), down ? Style_Down : Style_Raised);
  5769. drawMdiIcon(p, textCol, shadowCol, ir, down, buttonMargin, ctrl);
  5770. }
  5771. if (controls&SC_TitleBarShadeButton)
  5772. {
  5773. ir = visualRect(querySubControlMetrics(CC_TitleBar, ceData, elementFlags, SC_TitleBarShadeButton, TQStyleOption::Default, widget), ceData, elementFlags);
  5774. down = active & SC_TitleBarShadeButton;
  5775. drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, tb->colorGroup(), down ? Style_Down : Style_Raised);
  5776. drawMdiIcon(p, textCol, shadowCol, ir, down, buttonMargin, SC_TitleBarShadeButton);
  5777. }
  5778. if (controls&SC_TitleBarUnshadeButton)
  5779. {
  5780. ir = visualRect(querySubControlMetrics(CC_TitleBar, ceData, elementFlags, SC_TitleBarUnshadeButton, TQStyleOption::Default, widget), ceData, elementFlags);
  5781. down = active & SC_TitleBarUnshadeButton;
  5782. drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, tb->colorGroup(), down ? Style_Down : Style_Raised);
  5783. drawMdiIcon(p, textCol, shadowCol, ir, down, buttonMargin, SC_TitleBarUnshadeButton);
  5784. }
  5785. }
  5786. if (controls&SC_TitleBarSysMenu && tb->icon())
  5787. {
  5788. ir = visualRect(querySubControlMetrics(CC_TitleBar, ceData, elementFlags, SC_TitleBarSysMenu, TQStyleOption::Default, widget), ceData, elementFlags);
  5789. down = active & SC_TitleBarSysMenu;
  5790. drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, ir, tb->colorGroup(), down ? Style_Down : Style_Raised);
  5791. drawItem(p, ir, AlignCenter, tb->colorGroup(), true, tb->icon(), TQString());
  5792. }
  5793. break;
  5794. }
  5795. default:
  5796. BASE_STYLE::drawComplexControl(control, p, ceData, elementFlags, r, cg, flags, controls, active, data, widget);
  5797. }
  5798. }
  5799. TQRect QtCurveStyle::querySubControlMetrics(TQ_ComplexControl control, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
  5800. SubControl sc, const TQStyleOption &data, const TQWidget *widget) const
  5801. {
  5802. bool reverse(TQApplication::reverseLayout());
  5803. switch(control)
  5804. {
  5805. case CC_SpinWidget:
  5806. {
  5807. if(!widget)
  5808. return TQRect();
  5809. int fw(pixelMetric(PM_SpinBoxFrameWidth, ceData, elementFlags, 0));
  5810. TQSize bs;
  5811. bs.setHeight(widget->height()>>1);
  5812. if(bs.height()< 8)
  5813. bs.setHeight(8);
  5814. bs.setWidth(DO_EFFECT ? 16 : 15);
  5815. bs=bs.expandedTo(TQApplication::globalStrut());
  5816. int extra(bs.height()*2==widget->height()? 0 : 1),
  5817. y(0), x(widget->width()-bs.width()),
  5818. rx(x-fw*2);
  5819. switch(sc)
  5820. {
  5821. case SC_SpinWidgetUp:
  5822. return TQRect(x, y, bs.width(), bs.height());
  5823. case SC_SpinWidgetDown:
  5824. return TQRect(x, y+bs.height(), bs.width(), bs.height()+extra);
  5825. case SC_SpinWidgetButtonField:
  5826. return TQRect(x, y, bs.width(), widget->height()-2*fw);
  5827. case SC_SpinWidgetEditField:
  5828. return TQRect(fw, fw, rx, widget->height()-2*fw);
  5829. case SC_SpinWidgetFrame:
  5830. return reverse
  5831. ? TQRect(widget->x()+bs.width(), widget->y(),
  5832. widget->width()-bs.width()-1, widget->height())
  5833. : TQRect(widget->x(), widget->y(),
  5834. widget->width()-bs.width(),widget->height());
  5835. default:
  5836. break; // Remove compiler warnings...
  5837. }
  5838. }
  5839. case CC_ComboBox:
  5840. {
  5841. TQRect r(BASE_STYLE::querySubControlMetrics(control, ceData, elementFlags, sc, data, widget));
  5842. if(SC_ComboBoxFrame==sc)
  5843. {
  5844. const TQComboBox *cb(::tqqt_cast<const TQComboBox *>(widget));
  5845. if(cb && cb->editable())
  5846. r=TQRect(r.x()+r.width()-19, r.y(), 19, r.height());
  5847. }
  5848. else if (SC_ComboBoxEditField==sc && !DO_EFFECT)
  5849. r.addCoords(0, 0, -1, 0);
  5850. return r;
  5851. }
  5852. case CC_ScrollBar:
  5853. {
  5854. // Taken from kstyle.cpp, and modified so as to allow for no scrollbar butttons...
  5855. bool threeButtonScrollBar(SCROLLBAR_KDE==opts.scrollbarType),
  5856. platinumScrollBar(SCROLLBAR_PLATINUM==opts.scrollbarType),
  5857. nextScrollBar(SCROLLBAR_NEXT==opts.scrollbarType),
  5858. noButtons(SCROLLBAR_NONE==opts.scrollbarType);
  5859. TQRect ret;
  5860. const TQScrollBar *sb((const TQScrollBar*)widget);
  5861. bool horizontal(sb->orientation() == Qt::Horizontal);
  5862. int sliderstart(sb->sliderStart()),
  5863. sbextent(pixelMetric(PM_ScrollBarExtent, ceData, elementFlags, widget)),
  5864. maxlen((horizontal ? sb->width() : sb->height())
  5865. - (noButtons ? 0 : (sbextent * (threeButtonScrollBar ? 3 : 2)))),
  5866. sliderlen;
  5867. // calculate slider length
  5868. if (sb->maxValue() != sb->minValue())
  5869. {
  5870. uint range = sb->maxValue() - sb->minValue();
  5871. sliderlen = (sb->pageStep() * maxlen) / (range + sb->pageStep());
  5872. int slidermin = pixelMetric( PM_ScrollBarSliderMin, ceData, elementFlags, widget );
  5873. if ( sliderlen < slidermin || range > INT_MAX / 2 )
  5874. sliderlen = slidermin;
  5875. if ( sliderlen > maxlen )
  5876. sliderlen = maxlen;
  5877. }
  5878. else
  5879. sliderlen = maxlen;
  5880. // Subcontrols
  5881. switch(sc)
  5882. {
  5883. case SC_ScrollBarSubLine:
  5884. if(noButtons)
  5885. return TQRect();
  5886. // top/left button
  5887. if (platinumScrollBar)
  5888. if (horizontal)
  5889. ret.setRect(sb->width() - 2 * sbextent, 0, sbextent, sbextent);
  5890. else
  5891. ret.setRect(0, sb->height() - 2 * sbextent, sbextent, sbextent);
  5892. else
  5893. ret.setRect(0, 0, sbextent, sbextent);
  5894. break;
  5895. case SC_ScrollBarAddLine:
  5896. if(noButtons)
  5897. return TQRect();
  5898. // bottom/right button
  5899. if (nextScrollBar)
  5900. if (horizontal)
  5901. ret.setRect(sbextent, 0, sbextent, sbextent);
  5902. else
  5903. ret.setRect(0, sbextent, sbextent, sbextent);
  5904. else
  5905. if (horizontal)
  5906. ret.setRect(sb->width() - sbextent, 0, sbextent, sbextent);
  5907. else
  5908. ret.setRect(0, sb->height() - sbextent, sbextent, sbextent);
  5909. break;
  5910. case SC_ScrollBarSubPage:
  5911. // between top/left button and slider
  5912. if (platinumScrollBar)
  5913. if (horizontal)
  5914. ret.setRect(0, 0, sliderstart, sbextent);
  5915. else
  5916. ret.setRect(0, 0, sbextent, sliderstart);
  5917. else if (nextScrollBar)
  5918. if (horizontal)
  5919. ret.setRect(sbextent*2, 0, sliderstart-2*sbextent, sbextent);
  5920. else
  5921. ret.setRect(0, sbextent*2, sbextent, sliderstart-2*sbextent);
  5922. else
  5923. if (horizontal)
  5924. ret.setRect(noButtons ? 0 : sbextent, 0,
  5925. noButtons ? sliderstart
  5926. : (sliderstart - sbextent), sbextent);
  5927. else
  5928. ret.setRect(0, noButtons ? 0 : sbextent, sbextent,
  5929. noButtons ? sliderstart : (sliderstart - sbextent));
  5930. break;
  5931. case SC_ScrollBarAddPage:
  5932. {
  5933. // between bottom/right button and slider
  5934. int fudge;
  5935. if (platinumScrollBar)
  5936. fudge = 0;
  5937. else if (nextScrollBar)
  5938. fudge = 2*sbextent;
  5939. else if(noButtons)
  5940. fudge = 0;
  5941. else
  5942. fudge = sbextent;
  5943. if (horizontal)
  5944. ret.setRect(sliderstart + sliderlen, 0,
  5945. maxlen - sliderstart - sliderlen + fudge, sbextent);
  5946. else
  5947. ret.setRect(0, sliderstart + sliderlen, sbextent,
  5948. maxlen - sliderstart - sliderlen + fudge);
  5949. break;
  5950. }
  5951. case SC_ScrollBarGroove:
  5952. if(noButtons)
  5953. {
  5954. if (horizontal)
  5955. ret.setRect(0, 0, sb->width(), sb->height());
  5956. else
  5957. ret.setRect(0, 0, sb->width(), sb->height());
  5958. }
  5959. else
  5960. {
  5961. int multi = threeButtonScrollBar ? 3 : 2,
  5962. fudge;
  5963. if (platinumScrollBar)
  5964. fudge = 0;
  5965. else if (nextScrollBar)
  5966. fudge = 2*sbextent;
  5967. else
  5968. fudge = sbextent;
  5969. if (horizontal)
  5970. ret.setRect(fudge, 0, sb->width() - sbextent * multi, sb->height());
  5971. else
  5972. ret.setRect(0, fudge, sb->width(), sb->height() - sbextent * multi);
  5973. }
  5974. break;
  5975. case SC_ScrollBarSlider:
  5976. if (horizontal)
  5977. ret.setRect(sliderstart, 0, sliderlen, sbextent);
  5978. else
  5979. ret.setRect(0, sliderstart, sbextent, sliderlen);
  5980. break;
  5981. default:
  5982. ret = TQCommonStyle::querySubControlMetrics(control, ceData, elementFlags, sc, data, widget);
  5983. break;
  5984. }
  5985. return ret;
  5986. }
  5987. #ifdef SET_MDI_WINDOW_BUTTON_POSITIONS // TODO
  5988. case CC_TitleBar:
  5989. if (widget)
  5990. {
  5991. bool isMinimized(tb->titleBarState&TQt::WindowMinimized),
  5992. isMaximized(tb->titleBarState&TQt::WindowMaximized);
  5993. if( (isMaximized && SC_TitleBarMaxButton==subControl) ||
  5994. (isMinimized && SC_TitleBarMinButton==subControl) ||
  5995. (isMinimized && SC_TitleBarShadeButton==subControl) ||
  5996. (!isMinimized && SC_TitleBarUnshadeButton==subControl))
  5997. return TQRect();
  5998. readMdiPositions();
  5999. const int windowMargin(2);
  6000. const int controlSize(tb->rect.height() - windowMargin *2);
  6001. TQList<int>::ConstIterator it(itsMdiButtons[0].begin()),
  6002. end(itsMdiButtons[0].end());
  6003. int sc(SC_TitleBarUnshadeButton==subControl
  6004. ? SC_TitleBarShadeButton
  6005. : SC_TitleBarNormalButton==subControl
  6006. ? isMaximized
  6007. ? SC_TitleBarMaxButton
  6008. : SC_TitleBarMinButton
  6009. : subControl),
  6010. pos(0),
  6011. totalLeft(0),
  6012. totalRight(0);
  6013. bool rhs(false),
  6014. found(false);
  6015. for(; it!=end; ++it)
  6016. if(SC_TitleBarCloseButton==(*it) || WINDOWTITLE_SPACER==(*it) || tb->titleBarFlags&(toHint(*it)))
  6017. {
  6018. totalLeft+=WINDOWTITLE_SPACER==(*it) ? controlSize/2 : controlSize;
  6019. if(*it==sc)
  6020. found=true;
  6021. else if(!found)
  6022. pos+=WINDOWTITLE_SPACER==(*it) ? controlSize/2 : controlSize;
  6023. }
  6024. if(!found)
  6025. {
  6026. pos=0;
  6027. rhs=true;
  6028. }
  6029. it=itsMdiButtons[1].begin();
  6030. end=itsMdiButtons[1].end();
  6031. for(; it!=end; ++it)
  6032. if(SC_TitleBarCloseButton==(*it) || WINDOWTITLE_SPACER==(*it) || tb->titleBarFlags&(toHint(*it)))
  6033. {
  6034. if(WINDOWTITLE_SPACER!=(*it) || totalRight)
  6035. totalRight+=WINDOWTITLE_SPACER==(*it) ? controlSize/2 : controlSize;
  6036. if(rhs)
  6037. if(*it==sc)
  6038. {
  6039. pos+=controlSize;
  6040. found=true;
  6041. }
  6042. else if(found)
  6043. pos+=WINDOWTITLE_SPACER==(*it) ? controlSize/2 : controlSize;
  6044. }
  6045. totalLeft+=(windowMargin*(totalLeft ? 2 : 1));
  6046. totalRight+=(windowMargin*(totalRight ? 2 : 1));
  6047. if(SC_TitleBarLabel==subControl)
  6048. r.adjust(totalLeft, 0, -totalRight, 0);
  6049. else if(!found)
  6050. return TQRect();
  6051. else if(rhs)
  6052. r.setRect(r.right()-(pos+windowMargin),
  6053. r.top()+windowMargin,
  6054. controlSize, controlSize);
  6055. else
  6056. r.setRect(r.left()+windowMargin+pos, r.top()+windowMargin,
  6057. controlSize, controlSize);
  6058. return visualRect(tb->direction, tb->rect, r);
  6059. }
  6060. }
  6061. #endif
  6062. default:
  6063. break; // Remove compiler warnings...
  6064. }
  6065. return BASE_STYLE::querySubControlMetrics(control, ceData, elementFlags, sc, data, widget);
  6066. }
  6067. int QtCurveStyle::pixelMetric(PixelMetric metric, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget) const
  6068. {
  6069. switch(metric)
  6070. {
  6071. case PM_MenuBarFrameWidth:
  6072. return TB_NONE==opts.toolbarBorders ? 0 : 1;
  6073. case PM_MenuButtonIndicator:
  6074. return 7;
  6075. case PM_ButtonMargin:
  6076. return 3;
  6077. #if 0x039999 >= 0x030200
  6078. case PM_TabBarTabShiftVertical:
  6079. {
  6080. return (ceData.widgetObjectTypes.contains(TQTABBAR_OBJECT_NAME_STRING))
  6081. ? TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape
  6082. ? 1
  6083. : -1
  6084. : BASE_STYLE::pixelMetric(metric, ceData, elementFlags, widget);
  6085. }
  6086. case PM_TabBarTabShiftHorizontal:
  6087. return 0;
  6088. #endif
  6089. case PM_ButtonShiftHorizontal:
  6090. case PM_ButtonShiftVertical:
  6091. return 1;
  6092. case PM_ButtonDefaultIndicator:
  6093. return 0;
  6094. case PM_DefaultFrameWidth:
  6095. if(APP_KATE==itsThemedApp && widget && widget->parentWidget() && widget->parentWidget()->parentWidget() &&
  6096. ::tqqt_cast<const TQWidgetStack *>(widget) &&
  6097. ::tqqt_cast<const TQTabWidget *>(widget->parentWidget()) &&
  6098. ::tqqt_cast<const TQVBox *>(widget->parentWidget()->parentWidget()))
  6099. return 0;
  6100. if ((opts.square&SQUARE_SCROLLVIEW) && widget && ::tqqt_cast<const TQScrollView *>(widget))
  6101. return (opts.gtkScrollViews || opts.thinSbarGroove) && !opts.highlightScrollViews ? 1 : 2;
  6102. if(DO_EFFECT && opts.etchEntry && widget && !isFormWidget(widget) &&
  6103. (::tqqt_cast<const TQLineEdit *>(widget) || ::tqqt_cast<const TQDateTimeEditBase*>(widget) ||
  6104. ::tqqt_cast<const TQTextEdit*>(widget) || ::tqqt_cast<const TQScrollView*>(widget)))
  6105. return 3;
  6106. else
  6107. return 2;
  6108. case PM_SpinBoxFrameWidth:
  6109. return DO_EFFECT && !isFormWidget(widget) ? 3 : 2;
  6110. case PM_IndicatorWidth:
  6111. case PM_IndicatorHeight:
  6112. return DO_EFFECT && widget && !isFormWidget(widget) ? opts.crSize+2 : opts.crSize;
  6113. case PM_ExclusiveIndicatorWidth:
  6114. case PM_ExclusiveIndicatorHeight:
  6115. return DO_EFFECT && widget && !isFormWidget(widget) ? opts.crSize+2 : opts.crSize;
  6116. case PM_TabBarTabOverlap:
  6117. return TAB_MO_GLOW==opts.tabMouseOver ? 0 : 1;
  6118. case PM_ProgressBarChunkWidth:
  6119. return PROGRESS_CHUNK_WIDTH*3.4;
  6120. case PM_DockWindowSeparatorExtent:
  6121. return 4;
  6122. case PM_DockWindowHandleExtent:
  6123. return 10;
  6124. case PM_SplitterWidth:
  6125. return widget && widget->inherits("TQDockWindowResizeHandle")
  6126. ? 9
  6127. : LINE_1DOT==opts.splitters
  6128. ? 7
  6129. : 6;
  6130. case PM_ScrollBarSliderMin:
  6131. return opts.sliderWidth+1;
  6132. case PM_SliderThickness:
  6133. return SLIDER_TRIANGULAR==opts.sliderStyle ? 22 : (SLIDER_SIZE+(ROTATED_SLIDER ? 8 : 3));
  6134. case PM_SliderControlThickness:
  6135. return SLIDER_TRIANGULAR==opts.sliderStyle ? 19 : (SLIDER_SIZE+(ROTATED_SLIDER ? 8 : 0)); // This equates to 13, as we draw the handle 2 pix smaller for focus rect...
  6136. case PM_SliderLength:
  6137. return SLIDER_TRIANGULAR==opts.sliderStyle ? 11 : (SLIDER_SIZE+(ROTATED_SLIDER ? -2 : 6));
  6138. case PM_ScrollBarExtent:
  6139. // See KHTML note at top of file
  6140. return opts.sliderWidth+
  6141. (APP_KPRESENTER==itsThemedApp ||
  6142. ((APP_KONQUEROR==itsThemedApp || APP_KONTACT==itsThemedApp) && (!widget || isFormWidget(widget)))
  6143. ? 1 : 0);
  6144. case PM_MaximumDragDistance:
  6145. return -1;
  6146. case PM_TabBarTabVSpace:
  6147. return opts.highlightTab ? 11 : 9;
  6148. default:
  6149. return BASE_STYLE::pixelMetric(metric, ceData, elementFlags, widget);
  6150. }
  6151. }
  6152. int QtCurveStyle::kPixelMetric(KStylePixelMetric kpm, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget) const
  6153. {
  6154. switch(kpm)
  6155. {
  6156. case KPM_MenuItemSeparatorHeight:
  6157. return 2;
  6158. default:
  6159. return BASE_STYLE::kPixelMetric(kpm, ceData, elementFlags, widget);
  6160. }
  6161. }
  6162. TQSize QtCurveStyle::sizeFromContents(ContentsType contents, TQStyleControlElementData ceData, ControlElementFlags elementFlags,
  6163. const TQSize &contentsSize, const TQStyleOption &data, const TQWidget *widget) const
  6164. {
  6165. switch(contents)
  6166. {
  6167. case CT_PushButton:
  6168. {
  6169. const TQPushButton *button(static_cast<const TQPushButton *>(widget));
  6170. if (button && !button->text().isEmpty())
  6171. {
  6172. int margin(2*pixelMetric(PM_ButtonMargin, ceData, elementFlags, widget)),
  6173. mbi(button->isMenuButton() ? pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags, widget) : 0),
  6174. w(contentsSize.width() + margin + mbi + 16);
  6175. // if(button->text()=="...")
  6176. // w+=24;
  6177. // else
  6178. if("..."!=button->text())
  6179. {
  6180. const int constMinW(84);
  6181. if(opts.embolden)
  6182. w+=6; // add room for bold font - Assume all buttons can be default!
  6183. if(w<constMinW)
  6184. w=constMinW;
  6185. }
  6186. return TQSize(w, contentsSize.height() + margin+(DO_EFFECT && !isFormWidget(widget) && !opts.thinnerBtns
  6187. ? 6 : 4));
  6188. }
  6189. break;
  6190. }
  6191. case CT_ComboBox:
  6192. {
  6193. TQSize sz(BASE_STYLE::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget));
  6194. return TQSize(sz.width(), sz.height()+(DO_EFFECT && !isFormWidget(widget) && !opts.thinnerBtns ? 4 : 2));
  6195. }
  6196. case CT_PopupMenuItem:
  6197. {
  6198. if (!widget || data.isDefault())
  6199. break;
  6200. const int constMinH(opts.thinnerMenuItems ? 25 : 27);
  6201. TQMenuItem *mi(data.menuItem());
  6202. int maxpmw(data.maxIconWidth()),
  6203. w(contentsSize.width()), h(contentsSize.height());
  6204. if (mi->custom())
  6205. {
  6206. w = mi->custom()->sizeHint().width();
  6207. h = mi->custom()->sizeHint().height();
  6208. if (!mi->custom()->fullSpan() && h < constMinH)
  6209. h = constMinH;
  6210. }
  6211. else if(mi->widget())
  6212. ;
  6213. else if (mi->isSeparator())
  6214. {
  6215. w = 10;
  6216. h = 7;
  6217. }
  6218. else
  6219. {
  6220. // check is at least 16x16
  6221. if (h < 16)
  6222. h = 16;
  6223. if (mi->pixmap())
  6224. h = TQMAX(h, mi->pixmap()->height());
  6225. else if (!mi->text().isNull())
  6226. h = TQMAX(h, TQFontMetrics(ceData.font).height() + 2);
  6227. if (mi->iconSet()!= 0)
  6228. h = TQMAX(h, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height());
  6229. h+=(opts.thinnerMenuItems ? 2 : 4);
  6230. }
  6231. // check | 4 pixels | item | 8 pixels | accel | 4 pixels | check
  6232. // check is at least 16x16
  6233. maxpmw=TQMAX(maxpmw, constMenuPixmapWidth);
  6234. w += (maxpmw * 2) + 8;
  6235. if (! mi->text().isNull() && mi->text().find('\t') >= 0)
  6236. w += 8;
  6237. return TQSize(w, h);
  6238. }
  6239. case CT_SpinBox:
  6240. {
  6241. TQSize size(BASE_STYLE::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget));
  6242. if(!(size.height()%2))
  6243. size.setHeight(size.height()+1);
  6244. // if(!isFormWidget(widget))
  6245. // size.setHeight(size.height()+2);
  6246. return size;
  6247. }
  6248. case CT_ToolButton:
  6249. if(widget->parent() && ::tqqt_cast<TQToolBar *>(widget->parent()))
  6250. return TQSize(contentsSize.width()+8, contentsSize.height()+8);
  6251. default:
  6252. break; // Remove compiler warnings...
  6253. }
  6254. return BASE_STYLE::sizeFromContents(contents, ceData, elementFlags, contentsSize, data, widget);
  6255. }
  6256. int QtCurveStyle::styleHint(StyleHint stylehint, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption &option,
  6257. TQStyleHintReturn *returnData, const TQWidget *widget) const
  6258. {
  6259. switch(stylehint)
  6260. {
  6261. case SH_PopupMenu_SubMenuPopupDelay:
  6262. return opts.menuDelay;
  6263. case SH_ScrollView_FrameOnlyAroundContents:
  6264. return opts.gtkScrollViews;
  6265. case SH_EtchDisabledText:
  6266. return 0;
  6267. case SH_Slider_SnapToValue:
  6268. case SH_PrintDialog_RightAlignButtons:
  6269. case SH_FontDialog_SelectAssociatedText:
  6270. case SH_PopupMenu_MouseTracking:
  6271. case SH_PopupMenu_SpaceActivatesItem:
  6272. case SH_ComboBox_ListMouseTracking:
  6273. case SH_ScrollBar_MiddleClickAbsolutePosition:
  6274. return 1;
  6275. case SH_MenuBar_AltKeyNavigation:
  6276. return 0;
  6277. case SH_LineEdit_PasswordCharacter:
  6278. if(opts.passwordChar)
  6279. {
  6280. int chars[4]={opts.passwordChar, 0x25CF, 0x2022, 0};
  6281. const TQFontMetrics &fm(widget ? widget->fontMetrics() : TQFontMetrics(TQFont()));
  6282. for(int i=0; chars[i]; ++i)
  6283. if (fm.inFont(TQChar(chars[i])))
  6284. return chars[i];
  6285. return '*';
  6286. }
  6287. else
  6288. return '\0';
  6289. case SH_MainWindow_SpaceBelowMenuBar:
  6290. return 0;
  6291. case SH_PopupMenu_AllowActiveAndDisabled:
  6292. return 0;
  6293. case SH_MenuBar_MouseTracking:
  6294. return opts.menubarMouseOver ? 1 : 0;
  6295. case SH_TabBar_Alignment:
  6296. return AlignLeft;
  6297. default:
  6298. return BASE_STYLE::styleHint(stylehint, ceData, elementFlags, option, returnData, widget);
  6299. }
  6300. }
  6301. void QtCurveStyle::drawItem(TQPainter *p, const TQRect &r, int flags, const TQColorGroup &cg, bool enabled,
  6302. const TQPixmap *pixmap, const TQString &text, int len, const TQColor *penColor) const
  6303. {
  6304. TQRect r2(r);
  6305. if((opts.gbLabel&GB_LBL_BOLD) && text.length() && p->device() && dynamic_cast<TQGroupBox *>(p->device()))
  6306. {
  6307. TQGroupBox *box=static_cast<TQGroupBox*>(p->device());
  6308. if (!box->isCheckable())
  6309. {
  6310. int left,
  6311. top,
  6312. width,
  6313. height;
  6314. TQFontMetrics fm(p->fontMetrics());
  6315. TQRect rb(box->rect());
  6316. int th(fm.height()+2);
  6317. TQFont f(p->font());
  6318. rb.rect(&left, &top, &width, &height);
  6319. //rb.coords(&left, &top, &right, &bottom);
  6320. f.setBold(true);
  6321. p->setPen(box->colorGroup().foreground());
  6322. p->setFont(f);
  6323. p->drawText(TQRect(left, top, width, th), (TQApplication::reverseLayout()
  6324. ? AlignRight
  6325. : AlignLeft)|AlignVCenter|ShowPrefix|SingleLine,
  6326. text);
  6327. return;
  6328. }
  6329. }
  6330. int x = r.x(),
  6331. y = r.y(),
  6332. w = r.width(),
  6333. h = r.height();
  6334. p->setPen(penColor ? *penColor : cg.foreground());
  6335. if (pixmap)
  6336. {
  6337. TQPixmap pm(*pixmap);
  6338. bool clip = (flags&TQt::DontClip) == 0;
  6339. if (clip)
  6340. {
  6341. if (pm.width() < w && pm.height() < h)
  6342. clip = false;
  6343. else
  6344. {
  6345. p->save();
  6346. TQRegion cr = TQRect(x, y, w, h);
  6347. if (p->hasClipping())
  6348. cr &= p->clipRegion(TQPainter::CoordPainter);
  6349. p->setClipRegion(cr);
  6350. }
  6351. }
  6352. if ((flags&TQt::AlignVCenter) == TQt::AlignVCenter)
  6353. y += h/2 - pm.height()/2;
  6354. else if ((flags&TQt::AlignBottom) == TQt::AlignBottom)
  6355. y += h - pm.height();
  6356. if ((flags&TQt::AlignRight) == TQt::AlignRight)
  6357. x += w - pm.width();
  6358. else if ((flags&TQt::AlignHCenter) == TQt::AlignHCenter)
  6359. x += w/2 - pm.width()/2;
  6360. else if (((flags&TQt::AlignLeft) != TQt::AlignLeft) && TQApplication::reverseLayout()) // AlignAuto && rightToLeft
  6361. x += w - pm.width();
  6362. if (!enabled)
  6363. {
  6364. if (pm.mask()) // pixmap with a mask
  6365. {
  6366. if (!pm.selfMask()) // mask is not pixmap itself
  6367. {
  6368. TQPixmap pmm(*pm.mask());
  6369. pmm.setMask(*((TQBitmap *)&pmm));
  6370. pm = pmm;
  6371. }
  6372. }
  6373. else if (pm.depth() == 1) // monochrome pixmap, no mask
  6374. {
  6375. pm.setMask(*((TQBitmap *)&pm));
  6376. #ifndef TQT_NO_IMAGE_HEURISTIC_MASK
  6377. }
  6378. else // color pixmap, no mask
  6379. {
  6380. TQString k;
  6381. k.sprintf("$qt-drawitem-%x", pm.serialNumber());
  6382. TQPixmap *mask = TQPixmapCache::find(k);
  6383. bool del=false;
  6384. if (!mask)
  6385. {
  6386. mask = new TQPixmap(pm.createHeuristicMask());
  6387. mask->setMask(*((TQBitmap*)mask));
  6388. del = !TQPixmapCache::insert(k, mask);
  6389. }
  6390. pm = *mask;
  6391. if (del)
  6392. delete mask;
  6393. #endif
  6394. }
  6395. p->setPen(cg.text());
  6396. }
  6397. p->drawPixmap(x, y, pm);
  6398. if (clip)
  6399. p->restore();
  6400. }
  6401. else if (!text.isNull())
  6402. {
  6403. if (!enabled)
  6404. p->setPen(cg.text());
  6405. p->drawText(x, y, w, h, flags, text, len);
  6406. }
  6407. }
  6408. void QtCurveStyle::drawMenuItem(TQPainter *p, const TQRect &r, int flags, const TQColorGroup &cg,
  6409. bool mbi, int round, const TQColor &bgnd, const TQColor *cols) const
  6410. {
  6411. int fill=opts.useHighlightForMenu && (!mbi || itsHighlightCols==cols) ? ORIGINAL_SHADE : 4,
  6412. border=opts.borderMenuitems ? 0 : fill;
  6413. if(itsHighlightCols!=cols && mbi && !((flags&Style_Enabled) && (flags&Style_Active) && (flags&Style_Down)) &&
  6414. !opts.colorMenubarMouseOver && (opts.borderMenuitems || !IS_FLAT(opts.menuitemAppearance)))
  6415. fill=ORIGINAL_SHADE;
  6416. if(!mbi && APPEARANCE_FADE==opts.menuitemAppearance)
  6417. {
  6418. bool reverse=TQApplication::reverseLayout();
  6419. int roundOffet=ROUNDED ? 1 : 0;
  6420. TQRect main(r.x()+(reverse ? 1+MENUITEM_FADE_SIZE : roundOffet+1), r.y()+roundOffet+1,
  6421. r.width()-(1+MENUITEM_FADE_SIZE), r.height()-(2+(roundOffet*2))),
  6422. fade(reverse ? r.x()+1 : r.width()-MENUITEM_FADE_SIZE, r.y()+1, MENUITEM_FADE_SIZE, r.height()-2);
  6423. p->fillRect(main, cols[fill]);
  6424. if(ROUNDED)
  6425. {
  6426. main.addCoords(-1, -1, 1, 1);
  6427. drawBorder(USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol : itsBackgroundCols[ORIGINAL_SHADE], p, main,
  6428. cg, Style_Horizontal|Style_Raised, reverse ? ROUNDED_RIGHT : ROUNDED_LEFT,
  6429. cols, WIDGET_MENU_ITEM, false, BORDER_FLAT, false, fill);
  6430. }
  6431. TQColor bgnd(USE_LIGHTER_POPUP_MENU ? itsLighterPopupMenuBgndCol : itsBackgroundCols[ORIGINAL_SHADE]);
  6432. drawGradient(reverse ? bgnd : cols[fill], reverse ? cols[fill] : bgnd, p, fade, false);
  6433. }
  6434. else if(mbi || opts.borderMenuitems)
  6435. {
  6436. int flags(Style_Raised);
  6437. bool stdColor(!mbi || (SHADE_BLEND_SELECTED!=opts.shadeMenubars && SHADE_SELECTED!=opts.shadeMenubars));
  6438. itsFormMode=true;
  6439. flags|=Style_Horizontal;
  6440. if(stdColor && opts.borderMenuitems)
  6441. drawLightBevel(bgnd, p, r, cg, flags, round, cols[fill],
  6442. cols, stdColor, !(mbi && IS_GLASS(opts.menubarAppearance)), WIDGET_MENU_ITEM);
  6443. else
  6444. {
  6445. TQRect fr(r);
  6446. fr.addCoords(1, 1, -1, -1);
  6447. if(fr.width()>0 && fr.height()>0)
  6448. drawBevelGradient(cols[fill], p, fr, true, false, opts.menuitemAppearance, WIDGET_MENU_ITEM);
  6449. drawBorder(bgnd, p, r, cg, flags, round, cols, WIDGET_OTHER, false, BORDER_FLAT, false, border);
  6450. }
  6451. itsFormMode=false;
  6452. }
  6453. else
  6454. drawBevelGradient(cols[fill], p, r, true, false, opts.menuitemAppearance, WIDGET_MENU_ITEM);
  6455. }
  6456. void QtCurveStyle::drawProgress(TQPainter *p, const TQRect &rx, const TQColorGroup &cg, SFlags flags,
  6457. int round, const TQWidget *widget) const
  6458. {
  6459. if(rx.width()<1)
  6460. return;
  6461. TQRect r=opts.borderProgress
  6462. ? TQRect(rx.x()+1, rx.y()+1, rx.width()-2, rx.height()-2)
  6463. : rx;
  6464. int minWidth(3);
  6465. bool drawStripe(r.width()>(minWidth*1.5));
  6466. TQRegion outer(r);
  6467. if(r.width()<3)
  6468. r.setWidth(3);
  6469. if(drawStripe)
  6470. {
  6471. int animShift=-PROGRESS_CHUNK_WIDTH;
  6472. if (opts.animatedProgress)
  6473. {
  6474. // find the animation Offset for the current Widget
  6475. TQWidget *nonConstWidget(const_cast<TQWidget*>(widget));
  6476. TQMapConstIterator<TQWidget*, int> it(itsProgAnimWidgets.find(nonConstWidget));
  6477. if (it!=itsProgAnimWidgets.end())
  6478. animShift += it.data();
  6479. }
  6480. switch(opts.stripedProgress)
  6481. {
  6482. default:
  6483. case STRIPE_NONE:
  6484. break;
  6485. case STRIPE_PLAIN:
  6486. for(int offset=0; offset<(r.width()+PROGRESS_CHUNK_WIDTH); offset+=(PROGRESS_CHUNK_WIDTH*2))
  6487. {
  6488. TQRect r2(r.x()+offset+animShift, r.y(), PROGRESS_CHUNK_WIDTH, r.height());
  6489. TQRegion inner(r2);
  6490. outer=outer.eor(inner);
  6491. }
  6492. break;
  6493. case STRIPE_DIAGONAL:
  6494. {
  6495. TQPointArray a;
  6496. int shift(r.height());
  6497. for(int offset=0; offset<(r.width()+shift+2); offset+=(PROGRESS_CHUNK_WIDTH*2))
  6498. {
  6499. a.setPoints(4, r.x()+offset+animShift, r.y(),
  6500. r.x()+offset+animShift+PROGRESS_CHUNK_WIDTH, r.y(),
  6501. (r.x()+offset+animShift+PROGRESS_CHUNK_WIDTH)-shift, r.y()+r.height()-1,
  6502. (r.x()+offset+animShift)-shift, r.y()+r.height()-1);
  6503. outer=outer.eor(TQRegion(a));
  6504. }
  6505. }
  6506. }
  6507. }
  6508. const TQColor *use=flags&Style_Enabled || ECOLOR_BACKGROUND==opts.progressGrooveColor
  6509. ? itsProgressCols
  6510. ? itsProgressCols
  6511. : itsHighlightCols
  6512. : itsBackgroundCols;
  6513. flags|=Style_Raised|Style_Horizontal;
  6514. drawLightBevel(cg.background(), p, r, cg, flags, round, use[ORIGINAL_SHADE],
  6515. use, false, true, WIDGET_PROGRESSBAR);
  6516. if(drawStripe && opts.stripedProgress)
  6517. {
  6518. p->setClipRegion(outer);
  6519. drawLightBevel(cg.background(), p, r, cg, flags, round, use[1],
  6520. use, false, true, WIDGET_PROGRESSBAR);
  6521. p->setClipping(false);
  6522. }
  6523. if(opts.borderProgress)
  6524. drawBorder(cg.background(), p, r, cg, flags, !(opts.square&SQUARE_PROGRESS) && opts.fillProgress ? ROUNDED_ALL : round,
  6525. use, WIDGET_PROGRESSBAR, false, BORDER_FLAT, false, PBAR_BORDER);
  6526. else
  6527. {
  6528. r.addCoords(1, 1, -1, -1);
  6529. p->setPen(use[PBAR_BORDER]);
  6530. p->drawLine(r.topLeft(), r.topRight());
  6531. p->drawLine(r.bottomLeft(), r.bottomRight());
  6532. }
  6533. }
  6534. void QtCurveStyle::drawBevelGradient(const TQColor &base, TQPainter *p, const TQRect &origRect, bool horiz, bool sel, EAppearance bevApp, EWidget w) const
  6535. {
  6536. if(IS_FLAT(bevApp) && opts.colorSelTab && sel)
  6537. bevApp=APPEARANCE_GRADIENT;
  6538. if(IS_FLAT(bevApp))
  6539. p->fillRect(origRect, base);
  6540. else
  6541. {
  6542. bool tab(WIDGET_TAB_TOP==w || WIDGET_TAB_BOT==w),
  6543. selected(tab ? false : sel);
  6544. EAppearance app(selected
  6545. ? opts.sunkenAppearance
  6546. : WIDGET_LISTVIEW_HEADER==w && APPEARANCE_BEVELLED==bevApp
  6547. ? APPEARANCE_LV_BEVELLED
  6548. : APPEARANCE_BEVELLED!=bevApp || WIDGET_BUTTON(w) || WIDGET_LISTVIEW_HEADER==w ||
  6549. WIDGET_NO_ETCH_BTN==w || WIDGET_MENU_BUTTON==w
  6550. ? bevApp
  6551. : APPEARANCE_GRADIENT);
  6552. TQRect r(0, 0, horiz ? PIXMAP_DIMENSION : origRect.width(),
  6553. horiz ? origRect.height() : PIXMAP_DIMENSION);
  6554. TQString key(createKey(horiz ? r.height() : r.width(), base.rgb(), horiz, app,
  6555. tab && sel && opts.colorSelTab ? CACHE_COL_SEL_TAB : CACHE_STD));
  6556. TQPixmap *pix(itsPixmapCache.find(key));
  6557. bool inCache(true);
  6558. if(!pix)
  6559. {
  6560. pix=new TQPixmap(r.width(), r.height());
  6561. TQPainter pixPainter(pix);
  6562. drawBevelGradientReal(base, &pixPainter, r, horiz, sel, app, w);
  6563. pixPainter.end();
  6564. int cost(pix->width()*pix->height()*(pix->depth()/8));
  6565. if(cost<itsPixmapCache.maxCost())
  6566. itsPixmapCache.insert(key, pix, cost);
  6567. else
  6568. inCache=false;
  6569. }
  6570. p->drawTiledPixmap(origRect, *pix);
  6571. if(!inCache)
  6572. delete pix;
  6573. }
  6574. }
  6575. void QtCurveStyle::drawBevelGradientReal(const TQColor &base, TQPainter *p, const TQRect &r, bool horiz, bool sel, EAppearance app, EWidget w) const
  6576. {
  6577. const Gradient *grad=getGradient(app, &opts);
  6578. int numStops(grad->stops.size()),
  6579. lastPos(0),
  6580. size(horiz ? r.height() : r.width());
  6581. bool topTab(WIDGET_TAB_TOP==w),
  6582. botTab(WIDGET_TAB_BOT==w);
  6583. TQColor prev;
  6584. if(botTab)
  6585. {
  6586. GradientStopCont::reverse_iterator it(grad->stops.rbegin()),
  6587. end(grad->stops.rend());
  6588. for(int i=0; it!=end; ++it, ++i)
  6589. {
  6590. TQColor col;
  6591. int pos((int)(((1.0-(*it).pos)*size)+0.5));
  6592. if(sel && 0==i)
  6593. col=base;
  6594. else
  6595. shade(base, &col, opts.invertBotTab ? TQMAX(INVERT_SHADE((*it).val), 0.9) : (*it).val);
  6596. if(/*sel && */opts.colorSelTab && i>0)
  6597. col=tint(col, itsHighlightCols[0], (1.0-(*it).pos)*(0.2+TO_ALPHA(opts.colorSelTab)));
  6598. if(i)
  6599. drawGradient(prev, col, p,
  6600. horiz
  6601. ? TQRect(r.x(), lastPos, r.width(), pos-lastPos)
  6602. : TQRect(lastPos, r.y(), pos-lastPos, r.height()),
  6603. horiz);
  6604. prev=col;
  6605. lastPos=pos;
  6606. }
  6607. }
  6608. else
  6609. {
  6610. GradientStopCont::const_iterator it(grad->stops.begin()),
  6611. end(grad->stops.end());
  6612. for(int i=0; it!=end; ++it, ++i)
  6613. {
  6614. TQColor col;
  6615. int pos((int)(((*it).pos*size)+0.5));
  6616. if(/*sel && */topTab && i==numStops-1)
  6617. col=base;
  6618. else
  6619. shade(base, &col, WIDGET_TAB_BOT==w ? TQMAX((*it).val, 0.9) : (*it).val);
  6620. if(sel && opts.colorSelTab && topTab && i<numStops-1)
  6621. col=tint(col, itsHighlightCols[0], (1.0-(*it).pos)*(0.2+TO_ALPHA(opts.colorSelTab)));
  6622. if(i)
  6623. drawGradient(prev, col, p,
  6624. horiz
  6625. ? TQRect(r.x(), lastPos, r.width(), pos-lastPos)
  6626. : TQRect(lastPos, r.y(), pos-lastPos, r.height()),
  6627. horiz);
  6628. prev=col;
  6629. lastPos=pos;
  6630. }
  6631. }
  6632. }
  6633. void QtCurveStyle::drawGradient(const TQColor &top, const TQColor &bot,
  6634. TQPainter *p, TQRect const &r, bool horiz) const
  6635. {
  6636. if(r.width()>0 && r.height()>0)
  6637. {
  6638. if(top==bot)
  6639. p->fillRect(r, top);
  6640. else
  6641. {
  6642. int rh(r.height()), rw(r.width()),
  6643. rTop(top.red()), gTop(top.green()), bTop(top.blue()),
  6644. rx, ry, rx2, ry2,
  6645. size(horiz ? rh : rw);
  6646. r.coords(&rx, &ry, &rx2, &ry2);
  6647. register int rl(rTop << 16);
  6648. register int gl(gTop << 16);
  6649. register int bl(bTop << 16);
  6650. register int i;
  6651. int dr(((1<<16) * (bot.red() - rTop)) / size),
  6652. dg(((1<<16) * (bot.green() - gTop)) / size),
  6653. db(((1<<16) * (bot.blue() - bTop)) / size);
  6654. if(horiz)
  6655. {
  6656. for (i=0; i < size; i++)
  6657. {
  6658. p->setPen(TQColor(rl>>16, gl>>16, bl>>16));
  6659. p->drawLine(rx, ry+i, rx2, ry+i);
  6660. rl += dr;
  6661. gl += dg;
  6662. bl += db;
  6663. }
  6664. }
  6665. else
  6666. for(i=0; i < size; i++)
  6667. {
  6668. p->setPen(TQColor(rl>>16, gl>>16, bl>>16));
  6669. p->drawLine(rx+i, ry, rx+i, ry2);
  6670. rl += dr;
  6671. gl += dg;
  6672. bl += db;
  6673. }
  6674. }
  6675. }
  6676. }
  6677. void QtCurveStyle::drawSbSliderHandle(TQPainter *p, const TQRect &orig, const TQColorGroup &cg,
  6678. SFlags flags, bool slider) const
  6679. {
  6680. int min(MIN_SLIDER_SIZE(opts.sliderThumbs));
  6681. const TQColor *use(sliderColors(/*cg, */flags));
  6682. TQRect r(orig);
  6683. // EShade shade(opts.shadeSliders);
  6684. if(flags&(Style_Sunken|Style_Down))
  6685. flags|=Style_MouseOver;
  6686. flags&=~Style_Down;
  6687. if(r.width()>r.height())
  6688. flags|=Style_Horizontal;
  6689. flags|=Style_Raised;
  6690. drawLightBevel(p, r, cg, flags, (slider && !(opts.square&SQUARE_SLIDER))
  6691. #ifndef SIMPLE_SCROLLBARS
  6692. || (!slider && !(opts.square&SQUARE_SB_SLIDER) && (SCROLLBAR_NONE==opts.scrollbarType || opts.flatSbarButtons))
  6693. #endif
  6694. ? ROUNDED_ALL : ROUNDED_NONE,
  6695. getFill(flags, use, false, SHADE_DARKEN==opts.shadeSliders), use, true, false, WIDGET_SB_SLIDER);
  6696. if(LINE_NONE!=opts.sliderThumbs && (slider || ((flags & Style_Horizontal && r.width()>=min)|| r.height()>=min)))
  6697. {
  6698. const TQColor *markers(/*opts.coloredMouseOver && flags&Style_MouseOver
  6699. ? itsMouseOverCols
  6700. : */use);
  6701. bool horiz(flags&Style_Horizontal);
  6702. if(LINE_SUNKEN==opts.sliderThumbs)
  6703. if(horiz)
  6704. r.addCoords(0, -1, 0, 0);
  6705. else
  6706. r.addCoords(-1, 0, 0, 0);
  6707. else
  6708. r.addCoords(horiz ? 1 : 0, horiz ? 0 : 1, 0, 0);
  6709. switch(opts.sliderThumbs)
  6710. {
  6711. case LINE_FLAT:
  6712. drawLines(p, r, !horiz, 3, 5, markers, 0, 5, opts.sliderThumbs);
  6713. break;
  6714. case LINE_SUNKEN:
  6715. drawLines(p, r, !horiz, 4, 3, markers, 0, 3, opts.sliderThumbs);
  6716. break;
  6717. case LINE_1DOT:
  6718. drawDot(p, r, markers);
  6719. break;
  6720. case LINE_DOTS:
  6721. default:
  6722. drawDots(p, r, !horiz, slider ? 3 : 5, slider ? 5 : 2, markers, 0, 5);
  6723. }
  6724. }
  6725. }
  6726. void QtCurveStyle::drawSliderHandle(TQPainter *p, const TQRect &r, const TQColorGroup &cg,
  6727. SFlags flags, TQSlider *slider, bool tb) const
  6728. {
  6729. bool horiz(SLIDER_TRIANGULAR==opts.sliderStyle ? r.height()>r.width() : r.width()>r.height());
  6730. if(SLIDER_TRIANGULAR==opts.sliderStyle || ((SLIDER_ROUND==opts.sliderStyle || SLIDER_ROUND_ROTATED==opts.sliderStyle) && FULLLY_ROUNDED))
  6731. {
  6732. const TQColor *use(sliderColors(/*cg, */flags)),
  6733. *border(flags&Style_MouseOver && (MO_GLOW==opts.coloredMouseOver ||
  6734. MO_COLORED==opts.coloredMouseOver)
  6735. ? itsMouseOverCols : use);
  6736. const TQColor &fill(getFill(flags, use, false, SHADE_DARKEN==opts.shadeSliders));
  6737. int x(r.x()),
  6738. y(r.y()),
  6739. xo(horiz ? 8 : 0),
  6740. yo(horiz ? 0 : 8);
  6741. PrimitiveElement direction(horiz ? PE_ArrowDown : PE_ArrowRight);
  6742. bool drawLight(MO_PLASTIK!=opts.coloredMouseOver || !(flags&Style_MouseOver) ||
  6743. ((SLIDER_ROUND==opts.sliderStyle || SLIDER_ROUND_ROTATED)==opts.sliderStyle &&
  6744. (SHADE_BLEND_SELECTED==opts.shadeSliders || SHADE_SELECTED==opts.shadeSliders)));
  6745. int size(SLIDER_TRIANGULAR==opts.sliderStyle ? 15 : 13),
  6746. borderVal(itsMouseOverCols==border ? SLIDER_MO_BORDER_VAL : BORDER_VAL(flags&Style_Enabled));
  6747. if(SLIDER_ROUND_ROTATED!=opts.sliderStyle) {
  6748. if(horiz) {
  6749. y++;
  6750. }
  6751. else {
  6752. x++;
  6753. }
  6754. }
  6755. TQPointArray clipRegion;
  6756. p->save();
  6757. if(SLIDER_TRIANGULAR==opts.sliderStyle)
  6758. {
  6759. if(slider)
  6760. switch(slider->tickmarks())
  6761. {
  6762. case TQSlider::Both:
  6763. case TQSlider::NoMarks:
  6764. case TQSlider::Below:
  6765. direction=horiz ? PE_ArrowDown : PE_ArrowRight;
  6766. break;
  6767. case TQSlider::Above:
  6768. direction=horiz ? PE_ArrowUp : PE_ArrowLeft;
  6769. }
  6770. switch(direction)
  6771. {
  6772. default:
  6773. case PE_ArrowDown:
  6774. y+=2;
  6775. clipRegion.setPoints(7, x, y+2, x+2, y, x+8, y, x+10, y+2, x+10, y+9, x+5, y+14, x, y+9);
  6776. break;
  6777. case PE_ArrowUp:
  6778. y-=2;
  6779. clipRegion.setPoints(7, x, y+12, x+2, y+14, x+8, y+14, x+10, y+12, x+10, y+5, x+5, y, x, y+5);
  6780. break;
  6781. case PE_ArrowLeft:
  6782. x-=2;
  6783. clipRegion.setPoints(7, x+12, y, x+14, y+2, x+14, y+8, x+12, y+10, x+5, y+10, x, y+5, x+5, y );
  6784. break;
  6785. case PE_ArrowRight:
  6786. x+=2;
  6787. clipRegion.setPoints(7, x+2, y, x, y+2, x, y+8, x+2, y+10, x+9, y+10, x+14, y+5, x+9, y);
  6788. }
  6789. }
  6790. else
  6791. clipRegion.setPoints(8, x, y+8+yo, x, y+4, x+4, y, x+8+xo, y,
  6792. x+12+xo, y+4, x+12+xo, y+8+yo, x+8+xo, y+12+yo, x+4, y+12+yo);
  6793. if(!tb)
  6794. p->fillRect(TQRect(x, y, r.width()-(horiz ? 0 : 2), r.height()-(horiz ? 2 : 0)), cg.background());
  6795. p->setClipRegion(TQRegion(clipRegion)); // , TQPainter::CoordPainter);
  6796. if(IS_FLAT(opts.sliderAppearance))
  6797. {
  6798. p->fillRect(r, fill);
  6799. if(MO_PLASTIK==opts.coloredMouseOver && flags&Style_MouseOver && !opts.colorSliderMouseOver)
  6800. {
  6801. int col(SLIDER_MO_SHADE),
  6802. len(SLIDER_MO_LEN);
  6803. if(horiz)
  6804. {
  6805. p->fillRect(TQRect(x+1, y+1, len, size-2), itsMouseOverCols[col]);
  6806. p->fillRect(TQRect(x+r.width()-(1+len), y+1, len, r.height()-2), itsMouseOverCols[col]);
  6807. }
  6808. else
  6809. {
  6810. p->fillRect(TQRect(x+1, y+1, size-2, len), itsMouseOverCols[col]);
  6811. p->fillRect(TQRect(x+1, y+r.height()-(1+len), r.width()-2, len), itsMouseOverCols[col]);
  6812. }
  6813. }
  6814. }
  6815. else
  6816. {
  6817. drawBevelGradient(fill, p, TQRect(x, y, horiz ? r.width()-1 : size, horiz ? size : r.height()-1),
  6818. horiz, false, opts.sliderAppearance);
  6819. if(MO_PLASTIK==opts.coloredMouseOver && flags&Style_MouseOver && !opts.colorSliderMouseOver)
  6820. {
  6821. int col(SLIDER_MO_SHADE),
  6822. len(SLIDER_MO_LEN);
  6823. if(horiz)
  6824. {
  6825. drawBevelGradient(itsMouseOverCols[col], p, TQRect(x+1, y+1, len, size-2),
  6826. horiz, false, opts.sliderAppearance);
  6827. drawBevelGradient(itsMouseOverCols[col], p,
  6828. TQRect(x+r.width()-((SLIDER_ROUND_ROTATED==opts.sliderStyle ? 3 : 1)+len),
  6829. y+1, len, size-2),
  6830. horiz, false, opts.sliderAppearance);
  6831. }
  6832. else
  6833. {
  6834. drawBevelGradient(itsMouseOverCols[col], p, TQRect(x+1, y+1, size-2, len),
  6835. horiz, false, opts.sliderAppearance);
  6836. drawBevelGradient(itsMouseOverCols[col], p,
  6837. TQRect(x+1, y+r.height()-((SLIDER_ROUND_ROTATED==opts.sliderStyle ? 3 : 1)+len),
  6838. size-2, len),
  6839. horiz, false, opts.sliderAppearance);
  6840. }
  6841. }
  6842. }
  6843. p->setClipping(false);
  6844. if(SLIDER_TRIANGULAR==opts.sliderStyle)
  6845. {
  6846. TQPointArray aa,
  6847. light;
  6848. switch(direction)
  6849. {
  6850. default:
  6851. case PE_ArrowDown:
  6852. aa.setPoints(8, x, y+1, x+1, y, x+9, y, x+10, y+1, x+10, y+10, x+6, y+14, x+4, y+14, x, y+10);
  6853. light.setPoints(3, x+1, y+9, x+1, y+1, x+8, y+1);
  6854. break;
  6855. case PE_ArrowUp:
  6856. aa.setPoints(8, x, y+13, x+1, y+14, x+9, y+14, x+10, y+13, x+10, y+4, x+6, y, x+4, y, x, y+4);
  6857. light.setPoints(3, x+1, y+13, x+1, y+5, x+5, y+1);
  6858. break;
  6859. case PE_ArrowLeft:
  6860. aa.setPoints(8, x+13, y, x+14, y+1, x+14, y+9, x+13, y+10, x+4, y+10, x, y+6, x, y+4, x+4, y);
  6861. light.setPoints(3, x+1, y+5, x+5, y+1, x+13, y+1);
  6862. break;
  6863. case PE_ArrowRight:
  6864. aa.setPoints(8, x+1, y, x, y+1, x, y+9, x+1, y+10, x+10, y+10, x+14, y+6, x+14, y+4, x+10, y);
  6865. light.setPoints(3, x+1, y+8, x+1, y+1, x+9, y+1);
  6866. }
  6867. p->setPen(midColor(border[borderVal], cg.background()));
  6868. p->drawPolygon(aa);
  6869. if(drawLight)
  6870. {
  6871. p->setPen(use[APPEARANCE_DULL_GLASS==opts.sliderAppearance ? 1 : 0]);
  6872. p->drawPolyline(light);
  6873. }
  6874. p->setPen(border[borderVal]);
  6875. p->drawPolygon(clipRegion);
  6876. }
  6877. else
  6878. {
  6879. p->drawPixmap(x, y,
  6880. *getPixmap(border[borderVal],
  6881. horiz ? PIX_SLIDER : PIX_SLIDER_V, 0.8));
  6882. if(drawLight)
  6883. p->drawPixmap(x, y, *getPixmap(use[0], horiz ? PIX_SLIDER_LIGHT : PIX_SLIDER_LIGHT_V));
  6884. }
  6885. p->restore();
  6886. }
  6887. else
  6888. {
  6889. TQRect sr(r);
  6890. if(!ROTATED_SLIDER) {
  6891. if(horiz) {
  6892. sr.addCoords(0, 1, 0, 0);
  6893. }
  6894. else {
  6895. sr.addCoords(1, 0, 0, 0);
  6896. }
  6897. }
  6898. drawSbSliderHandle(p, sr, cg, flags|(horiz ? Style_Horizontal : 0), true);
  6899. }
  6900. }
  6901. void QtCurveStyle::drawSliderGroove(TQPainter *p, const TQRect &r, const TQColorGroup &cg,
  6902. SFlags flags, const TQWidget *widget) const
  6903. {
  6904. const TQSlider *sliderWidget((const TQSlider *)widget);
  6905. TQRect groove(r);
  6906. bool horiz(Qt::Horizontal==sliderWidget->orientation()),
  6907. reverse(TQApplication::reverseLayout());
  6908. flags&=~Style_MouseOver;
  6909. if(horiz)
  6910. {
  6911. int dh=(groove.height()-5)>>1;
  6912. groove.addCoords(0, dh, 0, -dh);
  6913. flags|=Style_Horizontal;
  6914. if(!itsFormMode && DO_EFFECT)
  6915. groove.addCoords(0, -1, 0, 1);
  6916. }
  6917. else
  6918. {
  6919. int dw=(groove.width()-5)>>1;
  6920. groove.addCoords(dw, 0, -dw, 0);
  6921. if(!itsFormMode && DO_EFFECT)
  6922. groove.addCoords(-1, 0, 1, 0);
  6923. }
  6924. drawLightBevel(p, groove, cg, flags, opts.square&SQUARE_SLIDER ? ROUNDED_NONE : ROUNDED_ALL,
  6925. itsBackgroundCols[flags&Style_Enabled ? 2 : ORIGINAL_SHADE],
  6926. itsBackgroundCols, true, true, WIDGET_SLIDER_TROUGH);
  6927. if(opts.fillSlider && (horiz ? sliderWidget->value()>0 : sliderWidget->value()<sliderWidget->maxValue()) &&
  6928. sliderWidget->maxValue()!=sliderWidget->minValue() && flags&Style_Enabled)
  6929. {
  6930. TQRect used(groove);
  6931. int pos((int)(((double)(horiz ? groove.width() : groove.height()) /
  6932. (sliderWidget->maxValue()-sliderWidget->minValue())) *
  6933. (sliderWidget->value() - sliderWidget->minValue())));
  6934. if(pos>0)
  6935. {
  6936. const TQColor *usedCols=itsSliderCols ? itsSliderCols : itsHighlightCols;
  6937. if(horiz)
  6938. {
  6939. pos+=(groove.width()>10 && pos<(groove.width()/2)) ? 3 : 0;
  6940. if(reverse)
  6941. used.addCoords(groove.width()-pos, 0, 0, 0);
  6942. else