Baghira 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.
 
 
 
 
 
 

3430 lines
140 KiB

  1. #include "baghira.h"
  2. #include "bitmaps.h"
  3. #include "pixmaps.h"
  4. //#include "../deco/baghiradecobuttons.h"
  5. #include <tqapplication.h>
  6. #include <tqbitmap.h>
  7. #include <tqbrush.h>
  8. #include <tqbutton.h>
  9. #include <tqcleanuphandler.h>
  10. #include <tqcolor.h>
  11. #include <tqcombobox.h>
  12. //#include <tqevent.h>
  13. #include <tqfont.h>
  14. #include <tqframe.h>
  15. #include <tqgroupbox.h>
  16. #include <tqheader.h>
  17. #include <tqiconset.h>
  18. #include <tqimage.h>
  19. #include <tqlayout.h>
  20. #include <tqlistbox.h>
  21. #include <tqlistview.h>
  22. #include <tqmenubar.h>
  23. #include <tqobject.h>
  24. #include <tqobjectlist.h>
  25. #include <tqpaintdevice.h>
  26. #include <tqpainter.h>
  27. #include <tqpalette.h>
  28. #include <tqpen.h>
  29. #include <tqpoint.h>
  30. #include <tqpopupmenu.h>
  31. #include <tqpushbutton.h>
  32. //#include <tqrangecontrol.h>
  33. #include <tqrect.h>
  34. #include <tqscrollbar.h>
  35. #include <tqscrollview.h>
  36. #include <tqsize.h>
  37. #include <tqslider.h>
  38. #include <tqstring.h>
  39. #include <tqstyleplugin.h>
  40. #include <tqtabbar.h>
  41. #include <tqtabwidget.h>
  42. #include <tqvariant.h>
  43. #include <tdetoolbar.h>
  44. #include <tdetoolbarbutton.h>
  45. #include <kwordwrap.h>
  46. #include "config.h"
  47. #define PRINTDEVICE(p) tqWarning("device is %s", (p->device()->devType() == TQInternal::Widget) ?\
  48. "Widget": (p->device()->devType() == TQInternal::Pixmap) ?\
  49. "Pixmap": (p->device()->devType() == TQInternal::Printer) ?\
  50. "Printer": (p->device()->devType() == TQInternal::Picture) ?\
  51. "Picture": (p->device()->devType() == TQInternal::UndefinedDevice) ?\
  52. "UndefinedDevice": "fuckdevice!" );
  53. #define GCC_VERSION (__GNUC__ * 10000 \
  54. + __GNUC_MINOR__ * 100 \
  55. + __GNUC_PATCHLEVEL__)
  56. static const int windowsItemFrame = 1; // menu item frame width
  57. static const int windowsSepHeight = 2; // separator item height
  58. static const int windowsItemHMargin = 3; // menu item hor text margin
  59. static const int windowsItemVMargin = 1; // menu item ver text margin
  60. static const int windowsArrowHMargin = 6; // arrow horizontal margin
  61. static const int windowsTabSpacing = 12; // space between text and tab
  62. static const int windowsCheckMarkHMargin = 2; // horiz. margins of check mark
  63. static const int windowsRightBorder = 12; // right border on windows
  64. static const int windowsCheckMarkWidth = 12; // checkmarks width on windows
  65. // options
  66. int OptionHandler::menuBackground;
  67. int OptionHandler::menuOpacity;
  68. bool OptionHandler::menuColorButton;
  69. bool OptionHandler::shadowText;
  70. //color
  71. TQColor OptionHandler::customButtonColor, OptionHandler::menuStripeColor_;
  72. //widgets
  73. bool OptionHandler::customWidgetColor;
  74. TQColor OptionHandler::customColors[ 10 ];
  75. //menu
  76. bool OptionHandler::useCustomMenuColor;
  77. TQColor OptionHandler::color, OptionHandler::color2, OptionHandler::colorHigh, OptionHandler::fgColor, OptionHandler::fgColorHigh;
  78. //Panel
  79. // bool OptionHandler::panelCustom;
  80. // TQColor OptionHandler::customPanelColor;
  81. //incativeButton
  82. int OptionHandler::inactiveButtonColor;
  83. TQColor OptionHandler::customInactiveButtonColor;
  84. //Design
  85. //stipples
  86. bool OptionHandler::bgStipple, /*OptionHandler::panelStipple,*/ OptionHandler::bevelHighlights_, OptionHandler::drawMenuStripe_, OptionHandler::glossyMenus_;
  87. Style OptionHandler::style_;
  88. int OptionHandler::contrast;
  89. //shadows
  90. bool OptionHandler::groupboxshadow;
  91. int OptionHandler::shadowDarkness;
  92. //istviews;
  93. bool OptionHandler::drawDotlines, OptionHandler::useCustomExpanderColor;
  94. int OptionHandler::expanderStyle;
  95. TQColor OptionHandler::expanderColor, OptionHandler::dotlineColor;
  96. int OptionHandler::dotlineStyle;
  97. //slider
  98. bool OptionHandler::squeezesbslider;
  99. bool OptionHandler::shadowsbslider;
  100. bool OptionHandler::animateSlider;
  101. bool OptionHandler::animateProgress;
  102. //toolbar
  103. bool OptionHandler::reverseBtnColor, OptionHandler::tbFrame;
  104. //tweaks
  105. bool OptionHandler::centerTabs;
  106. bool OptionHandler::smoothListViewHeaders;
  107. bool OptionHandler::smootherLVH;
  108. bool OptionHandler::icyButtons;
  109. Style OptionHandler::_buttonStyle;
  110. int OptionHandler::progressBar;
  111. bool OptionHandler::removeKickerBevel;
  112. Style OptionHandler::_toolbuttonStyle;
  113. bool OptionHandler::drawProgressLabel;
  114. TQColor OptionHandler::brushTint;
  115. TQColor OptionHandler::aDecoColor1_;
  116. TQColor OptionHandler::aDecoColor2_;
  117. TQColor OptionHandler::titleColor_[2];
  118. TQColor OptionHandler::titleButtonColor_[3];
  119. bool OptionHandler::tintBrush;
  120. tabStyle OptionHandler::tabStyle_;
  121. unsigned long OptionHandler::wmDesign;
  122. bool OptionHandler::animateButton;
  123. int OptionHandler::custCols[8];
  124. TQPixmap LiquidStyle::popupBack;
  125. //============
  126. class KAccessToolBarButton : public TDEToolBarButton
  127. {
  128. // to get me access to the toolbbar
  129. friend class LiquidStyle;
  130. public:
  131. KAccessToolBarButton( TQWidget* parent=0, const char* name=0 )
  132. : TDEToolBarButton( parent, name ) {}
  133. };
  134. class LiquidStylePlugin : public TQStylePlugin {
  135. public:
  136. LiquidStylePlugin() {
  137. ;
  138. }
  139. ~LiquidStylePlugin() {
  140. ;
  141. }
  142. TQStringList keys() const {
  143. return ( TQStringList() << "Baghira" );
  144. }
  145. TQStyle *create( const TQString & );
  146. };
  147. TQStyle *LiquidStylePlugin::create( const TQString &s ) {
  148. if ( s.lower() == "baghira" )
  149. return ( new LiquidStyle() );
  150. return ( 0 );
  151. }
  152. Q_EXPORT_PLUGIN( LiquidStylePlugin )
  153. static const int itemFrame = 1;
  154. static const int itemHMargin = 3;
  155. static const int itemVMargin = 1;
  156. static const int arrowHMargin = 6;
  157. static const int rightBorder = 12;
  158. LiquidStyle::LiquidStyle() : TDEStyle( AllowMenuTransparency | FilledFrameWorkaround, ThreeButtonScrollBar )
  159. {
  160. TQIntDict<ButtonFadeInfo>bfi(31);// assuming 31 btns will be enough - a pointer list would be more accurate, but we need to lookup this every 50ms...
  161. TQIntDict<ButtonTile>btnShadowedDict(223);// we need around 10/color, 3 colors/button assuming 10 different colors (e.g. kcalc)
  162. TQIntDict<ButtonTile>buttonGlowDict(109);
  163. TQIntDict<ButtonTile>buttonDict(331);
  164. headerHoverID = -1;
  165. headerSortID = -1;
  166. hoveredTabIndex = -1;
  167. currentTabBar = 0L;
  168. paintWidget = 0L;
  169. highlightWidget = 0L;
  170. currentTaskContainer = 0L;
  171. taskContainerHover = false;
  172. isTaskContainer = false;
  173. isHTMLButton = false;
  174. inExitPolish = false;
  175. inactiveRoundFrame = 0L;
  176. activeRoundFrame = 0L;
  177. eventKiller = new EventKiller;
  178. bmShower = 0L; // only if b/m
  179. btnDict.setAutoDelete( true );
  180. btnShadowedDict.setAutoDelete( true );
  181. bfi.setAutoDelete( true );
  182. // inverseTabDict.setAutoDelete( true );
  183. // tabDict.setAutoDelete( true );
  184. initialPaletteLoaded = false;
  185. qtrcModificationTime = 0;
  186. // animations kram!
  187. progAnimShift = 0;
  188. prog2AnimShift = 0;
  189. sliderAnimShift = 0;
  190. TQTimer* timer = new TQTimer( this );
  191. timer->start(50, false);
  192. // if (optionHandler->AnimateProgress())
  193. connect(timer, SIGNAL(timeout()), this, SLOT(updateProgressPos()));
  194. activeScroller = NULL;
  195. //--------------------------------------
  196. tooltipPalette = tqApp->palette();
  197. tooltipPalette.setBrush( TQColorGroup::Background, TQColor( 255, 255, 220 ) );
  198. tooltipPalette.setBrush( TQColorGroup::Foreground, TQt::black );
  199. rMatrix.rotate( 90.0 );
  200. lMatrix.rotate( 270.0 );
  201. iMatrix.rotate( 180.0 );
  202. mMatrix.setMatrix ( -1, 0, 0, 1, 0, 0);
  203. m2Matrix.setMatrix ( 1, 0, 0, -1, 0, 0);
  204. optionHandler = new OptionHandler( this );
  205. if (optionHandler->style() != Milk && optionHandler->AnimateSlider())
  206. connect(timer, SIGNAL(timeout()), this, SLOT(updateSliderPos()));
  207. if (optionHandler->style() == Brushed)
  208. bmShower = new BMShower(this);
  209. switch (optionHandler->buttonStyle())
  210. {
  211. case Jaguar:
  212. btnBorderImg = new TQImage( uic_findImage("button-jaguar") );
  213. btnShadowImg = new TQImage( uic_findImage( "button-shadow" ) );
  214. buttonGlow = new TQImage( uic_findImage( "button-glow" ) );
  215. combo = new TQImage( uic_findImage("combo-jaguar") );
  216. comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
  217. if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders())
  218. rectbutton = new TQImage( uic_findImage( "rectbutton" ) );
  219. else rectbutton = 0L;
  220. break;
  221. case Panther:
  222. case Tiger:
  223. btnBorderImg = new TQImage( uic_findImage("button-base") );
  224. btnShadowImg = new TQImage( uic_findImage( "button-shadow" ) );
  225. buttonGlow = new TQImage( uic_findImage( "button-glow" ) );
  226. combo = new TQImage( uic_findImage("combo") );
  227. comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
  228. if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders())
  229. rectbutton = new TQImage( uic_findImage( "rectbutton" ) );
  230. else rectbutton = 0L;
  231. break;
  232. case Brushed:
  233. btnBorderImg = 0L;
  234. btnShadowImg = 0L;
  235. buttonGlow = 0L;
  236. rectbutton = new TQImage( uic_findImage( "rectbutton" ) );
  237. switch (optionHandler->toolbuttonStyle())
  238. {
  239. case Jaguar:
  240. combo = new TQImage( uic_findImage("combo-jaguar") );
  241. comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
  242. break;
  243. case Panther:
  244. case Tiger:
  245. case Brushed:
  246. combo = new TQImage( uic_findImage("combo") );
  247. comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
  248. break;
  249. case Milk:
  250. combo = new TQImage( uic_findImage("combo-milk") );
  251. comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
  252. default:
  253. break;
  254. }
  255. break;
  256. case Milk:
  257. btnBorderImg = new TQImage( uic_findImage("button-milk") );
  258. btnShadowImg = 0L;
  259. buttonGlow = 0L;
  260. combo = new TQImage( uic_findImage("combo-milk") );
  261. comboShadow = new TQImage( uic_findImage( "combo-shadow" ) );
  262. if (optionHandler->toolbuttonStyle() == Brushed || !optionHandler->SmoothListViewHeaders())
  263. rectbutton = new TQImage( uic_findImage( "rectbutton" ) );
  264. else rectbutton = 0L;
  265. default:
  266. break;
  267. }
  268. if ( btnBorderImg && btnBorderImg->depth() < 32 )
  269. * btnBorderImg = btnBorderImg->convertDepth( 32 );
  270. if ( btnShadowImg && btnShadowImg->depth() < 32 )
  271. * btnShadowImg = btnShadowImg->convertDepth( 32 );
  272. if ( buttonGlow && buttonGlow->depth() < 32 )
  273. * buttonGlow = buttonGlow->convertDepth( 32 );
  274. if ( combo && combo->depth() < 32 )
  275. * combo = combo->convertDepth( 32 );
  276. if ( comboShadow && comboShadow->depth() < 32 )
  277. * comboShadow = comboShadow->convertDepth( 32 );
  278. if ( rectbutton && rectbutton->depth() < 32 )
  279. * rectbutton = rectbutton->convertDepth( 32 );
  280. if (optionHandler->style() == Milk)
  281. {
  282. slider_top = new TQImage( uic_findImage( "sbslider_top-milk" ) );
  283. slider_btm = new TQImage( uic_findImage( "sbslider_btm-milk" ) );
  284. }
  285. else
  286. {
  287. slider_top = new TQImage( uic_findImage( "sbslider_top" ) );
  288. slider_btm = new TQImage( uic_findImage( "sbslider_btm" ) );
  289. }
  290. if ( slider_top->depth() < 32 )
  291. * slider_top = slider_top->convertDepth( 32 );
  292. if ( slider_btm->depth() < 32 )
  293. * slider_btm = slider_btm->convertDepth( 32 );
  294. if (optionHandler->shadowSbSlider())
  295. {
  296. slider_top_shd = new TQImage( uic_findImage( "sbslider_top_shd" ) );
  297. if ( slider_top_shd->depth() < 32 )
  298. * slider_top_shd = slider_top_shd->convertDepth( 32 );
  299. slider_btm_shd = new TQImage( uic_findImage( "sbslider_btm_shd" ) );
  300. if ( slider_btm_shd->depth() < 32 )
  301. * slider_btm_shd = slider_btm_shd->convertDepth( 32 );
  302. }
  303. else
  304. {
  305. slider_top_shd = 0L;
  306. slider_btm_shd = 0L;
  307. }
  308. roundFrame = new TQImage( uic_findImage( "roundFrame" ) );
  309. if ( roundFrame->depth() < 32 )
  310. * roundFrame = roundFrame->convertDepth( 32 );
  311. menuPix = NULL;
  312. tmpBtnPix = NULL;
  313. int i;
  314. for ( i = 0; i < BITMAP_ITEMS; ++i ) {
  315. pixmaps[ i ] = NULL;
  316. }
  317. sbLeft = new TQBitmap( 6, 7, sbarrow_left_bits, true );
  318. sbLeft->setMask( *sbLeft );
  319. sbRight = new TQBitmap( 6, 7, sbarrow_right_bits, true );
  320. sbRight->setMask( *sbRight );
  321. sbUp = new TQBitmap( 7, 6, sbarrow_up_bits, true );
  322. sbUp->setMask( *sbUp );
  323. sbDown = new TQBitmap( 7, 6, sbarrow_down_bits, true );
  324. sbDown->setMask( *sbDown );
  325. checkmark = new TQBitmap( 6, 7, checkmark_bits, true );
  326. checkmark->setMask( *checkmark );
  327. isKicker = ( qstrcmp( tqApp->argv() [ 0 ], "kicker" ) == 0 ) ||
  328. ( qstrcmp( tqApp->argv() [ 0 ], "appletproxy" ) == 0 );
  329. isOOO = !qstrcmp( tqApp->argv() [ 0 ], "soffice.bin" );
  330. groupShadow = new TQPixmap( 64, 64 );
  331. TQColor c;
  332. optionHandler->custCols[0] != -1 ? c = TQColor(optionHandler->custCols[0]) : c= TQColor(tqApp->palette().color(TQPalette::Active, isKicker?TQColorGroup::Button:TQColorGroup::Background));
  333. groupShadow->fill( ( c.dark( 100 + optionHandler->ShadowDarkness() ) ).rgb() );
  334. if ( (optionHandler->style() != Brushed) && optionHandler->useBgStipple() ) {
  335. TQPainter p;
  336. p.begin( groupShadow );
  337. p.setPen( c.dark( 100 + optionHandler->ShadowDarkness() + (int)(optionHandler->stippleContrast()/2) ) );
  338. for ( int i = 1; i < 64; i += 4 ) {
  339. p.drawLine( 0, i, 63, i );
  340. p.drawLine( 0, i+2, 63, i+2 );
  341. }
  342. p.setPen( c.dark( 100 + optionHandler->ShadowDarkness() + optionHandler->stippleContrast()) );
  343. for ( int i = 2; i < 63; i += 4 ) {
  344. p.drawLine( 0, i, 63, i );
  345. }
  346. }
  347. if (optionHandler->style() == Brushed)
  348. {
  349. plainBrush = optionHandler->TintBrush() ?
  350. *tintBrush(uic_findImage( "brushed-tile" ), optionHandler->BrushTint()) :
  351. uic_findImage( "brushed-tile" );
  352. gradBrush = optionHandler->TintBrush() ?
  353. *tintBrush(uic_findImage( "brushed-gradient" ), optionHandler->BrushTint()) :
  354. uic_findImage( "brushed-gradient" );
  355. }
  356. }
  357. LiquidStyle::~LiquidStyle() {
  358. // btnDict.setAutoDelete(true);
  359. btnDict.clear();
  360. // btnShadowedDict.setAutoDelete(true);
  361. btnShadowedDict.clear();
  362. // buttonGlowDict.setAutoDelete(true);
  363. buttonGlowDict.clear();
  364. // comboDict.setAutoDelete(true);
  365. comboDict.clear();
  366. // comboShadowedDict.setAutoDelete(true);
  367. comboShadowedDict.clear();
  368. // if (! tabDict.isEmpty()) tabDict.clear();
  369. // if (! inverseTabDict.isEmpty()) inverseTabDict.clear();
  370. // rectBtnDict.setAutoDelete(true);
  371. rectBtnDict.clear();
  372. // progress2Dict.setAutoDelete(true);
  373. progress2Dict.clear();
  374. // bfi.setAutoDelete(true);
  375. bfi.clear();
  376. // fadeColorMap.setAutoDelete(true);
  377. fadeColorMap.clear();
  378. delete optionHandler;
  379. delete sbUp;
  380. delete sbDown;
  381. delete sbLeft;
  382. delete sbRight;
  383. delete checkmark;
  384. if ( btnBorderImg )
  385. delete btnBorderImg;
  386. if ( btnShadowImg )
  387. delete btnShadowImg;
  388. if (combo)
  389. delete combo;
  390. if (comboShadow)
  391. delete comboShadow;
  392. if (buttonGlow)
  393. delete buttonGlow;
  394. delete slider_top;
  395. delete slider_btm;
  396. if (slider_top_shd)
  397. delete slider_top_shd;
  398. if (slider_btm_shd)
  399. delete slider_btm_shd;
  400. if (rectbutton)
  401. delete rectbutton;
  402. delete roundFrame;
  403. if ( tmpBtnPix )
  404. delete tmpBtnPix;
  405. if ( menuPix )
  406. delete menuPix;
  407. int i;
  408. for ( i = 0; i < BITMAP_ITEMS; ++i ) {
  409. if ( pixmaps[ i ] )
  410. delete pixmaps[ i ];
  411. }
  412. if ( groupShadow )
  413. delete groupShadow;
  414. }
  415. inline void LiquidStyle::updateProgressPos()
  416. {
  417. progAnimShift = (progAnimShift + 1) % 20;
  418. prog2AnimShift = (prog2AnimShift + 1) % 38;
  419. //Update the registered progressbars.
  420. TQMap<TQWidget*, int>::iterator iter;
  421. for (iter = progAnimWidgets.begin(); iter != progAnimWidgets.end(); iter++)
  422. {
  423. if ( !::tqt_cast<TQProgressBar*>(iter.key()) )
  424. continue;
  425. (iter.key())->repaint(false);
  426. }
  427. }
  428. inline void LiquidStyle::updateSliderPos(){
  429. sliderAnimShift = (sliderAnimShift + 1) % 32;
  430. if (activeScroller)
  431. activeScroller->repaint(false);
  432. }
  433. void LiquidStyle::progressBarDestroyed(TQObject* obj){
  434. progAnimWidgets.remove(static_cast<TQWidget*>(obj));
  435. }
  436. bool LiquidStyle::isPlain() const {
  437. return ( !optionHandler->useBgStipple() );
  438. }
  439. void LiquidStyle::drawPrimitive( PrimitiveElement pe,
  440. TQPainter *p,
  441. const TQStyleControlElementData &ceData,
  442. ControlElementFlags elementFlags,
  443. const TQRect &r,
  444. const TQColorGroup &cg,
  445. SFlags flags,
  446. const TQStyleOption &opt ) const
  447. {
  448. bool down = flags & Style_Down;
  449. bool on = flags & Style_On;
  450. switch ( pe )
  451. {
  452. case PE_TabBarBase:
  453. {
  454. bool isDialog = false;
  455. if (p->device() && p->device()->devType() == TQInternal::Widget)
  456. {
  457. TQWidget *w = (TQWidget*)p->device();
  458. if (w && ::tqt_cast<TQTabWidget*>(w) && w->children())
  459. {
  460. TQObjectListIt it( *w->children() ); // iterate over the buttons
  461. TQObject *obj;
  462. TQTabBar *tabBar = 0L;
  463. while ( (obj = it.current()) != 0 )
  464. {
  465. ++it;
  466. if (::tqt_cast<TQTabBar*>(obj))
  467. {
  468. tabBar = (TQTabBar*)obj;
  469. break;
  470. }
  471. }
  472. if (!tabBar || !tabBar->isVisible())
  473. break;
  474. }
  475. isDialog = optionHandler->TabStyle() == Clever && w->topLevelWidget()->inherits("TQDialog");
  476. }
  477. if (isDialog || optionHandler->TabStyle() == Chooser)
  478. {
  479. int x = r.x(); int right = r.right(); int bottom = r.bottom(); int y2 = r.y() + 1;
  480. TQColor bright( cg.background().dark( 110 ) );
  481. TQColor mid( cg.background().dark( 130 ) );
  482. TQColor dark( cg.background().dark( 150 ) );
  483. p->setPen( dark );
  484. p->drawLine( x + 6, y2, right - 6, y2 );
  485. p->drawPoint(x+3,y2+1);p->drawPoint(x+4,y2+1);
  486. p->drawPoint(x+2,y2+2);
  487. p->drawPoint(x+1,y2+3);
  488. p->drawPoint(right-3,y2+1);p->drawPoint(right-4,y2+1);
  489. p->drawPoint(right-2,y2+2);
  490. p->drawPoint(right-1,y2+3);
  491. p->drawLine(x,y2+5,x,bottom);
  492. p->drawLine(right,y2+5,right,bottom);
  493. p->setPen( mid );
  494. p->drawPoint(x+4, y2);p->drawPoint(x+5,y2);
  495. p->drawPoint(right-4, y2);p->drawPoint(right-5,y2);
  496. p->drawPoint(x+2, y2+1);
  497. p->drawPoint(right-2, y2+1);
  498. p->drawLine(x+5,y2 + 1, right - 5, y2 + 1);
  499. p->drawPoint(x+1,y2+2);
  500. p->drawPoint(right-1,y2+2);
  501. p->drawPoint(x+2,y2+3);
  502. p->drawPoint(right-2,y2+3);
  503. p->drawPoint(x,y2+4);p->drawPoint(x+1,y2+4);
  504. p->drawPoint(right,y2+4);p->drawPoint(right+1,y2+4);
  505. p->setPen(bright);
  506. p->drawPoint(x+3,y2);p->drawPoint(right-3,y2);
  507. p->drawLine(x+4,y2+2,right-4,y2+2);
  508. p->drawPoint(x,y2+3);p->drawPoint(x+3,y2+3);
  509. p->drawPoint(right,y2+3);p->drawPoint(right-3,y2+3);
  510. p->drawPoint(x+2,y2+4);p->drawPoint(right-2,y2+4);
  511. p->drawLine(x+1,y2+5,x+1,bottom);
  512. p->drawLine(right-1,y2+5,right-1,bottom);
  513. break;
  514. }
  515. else
  516. {
  517. drawCombo( p, cg, cg.button(), r.x()+1, r.y()+1, r.width()-2, r.height()+1, false, false, false, center);
  518. TQPen oldPen = p->pen();
  519. // p->setClipping ( false );
  520. p->setPen( cg.button().dark( 158 ) );
  521. p->drawRect(r);
  522. // p->fillRect(r, TQt::red);
  523. // p->flush();
  524. p->setPen(oldPen);
  525. }
  526. break;
  527. }
  528. case PE_ButtonCommand:
  529. case PE_ButtonDefault:
  530. {
  531. bool sunken = on || down;
  532. bool hover = flags & Style_MouseOver;
  533. bool focused = flags & Style_HasFocus;
  534. TQColor newColor = sunken ? cg.button().dark( 110 ) : hover || focused ? cg.button() : optionHandler->InactiveButtonColor();
  535. if (optionHandler->AnimateButton() && (sunken || hover || focused))
  536. {
  537. ButtonFadeInfo *bfi_ = /*(::tqt_cast<TQWidget*>(*/opt.widget()/*))*/ ? bfi[opt.widget()->winId()] : 0L;
  538. if (bfi_)
  539. {
  540. int index = bfi_->index;
  541. newColor = mapFadeColor(newColor, index);
  542. }
  543. }
  544. if (optionHandler->buttonStyle() == Brushed)
  545. {
  546. drawRectangularButton( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full);
  547. }
  548. else if ( ( r.width() < 21 || r.height() < 25 ))
  549. {
  550. drawCombo( p, cg, newColor, r.x(), r.y(), r.width(), r.height()+2, sunken, hover, false, center, isHTMLButton );
  551. TQPen oldpen(p->pen());
  552. p->setPen( newColor.dark(150));
  553. p->drawRect(r.x(), r.y(), r.width(), r.height());
  554. if (sunken)
  555. {
  556. p->setPen(newColor.dark(180));
  557. p->drawRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
  558. }
  559. p->setPen(oldpen);
  560. break;
  561. }
  562. else if (optionHandler->buttonStyle() == Milk)
  563. drawCombo( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full, isHTMLButton );
  564. else
  565. {
  566. drawRoundButton( p, cg, newColor, r.x(), r.y(), r.width(), r.height(), sunken, hover, btnOffset.x(), btnOffset.y() );
  567. }
  568. break;
  569. }
  570. case PE_ButtonBevel:
  571. case PE_ButtonDropDown:
  572. {
  573. bool sunken = on || down;
  574. bool hover = flags & Style_MouseOver;
  575. if (optionHandler->buttonStyle() == Brushed)
  576. drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full);
  577. else
  578. drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full );
  579. break;
  580. }
  581. case PE_ButtonTool:
  582. {
  583. bool sunken = on || down;
  584. bool hover = flags & Style_MouseOver;
  585. if (optionHandler->buttonStyle() == Brushed)
  586. drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full);
  587. else
  588. drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, full );
  589. break;
  590. }
  591. case PE_HeaderSection:
  592. {
  593. bool sunken = on || down;
  594. bool hover = flags & Style_MouseOver;
  595. TQPen oldpen(p->pen());
  596. if ( isTaskContainer ) // is kicker?
  597. {
  598. if (optionHandler->SmoothListViewHeaders())
  599. {
  600. drawCombo( p, cg, sunken ? cg.button() : taskContainerHover ? cg.button().light( 110 ) : cg.background(), r.x(), r.y(), r.width(), isKicker ? r.height() + 2 : r.height(), sunken, hover, false, optionHandler->SmootherLVH() ? full : center );
  601. if (isKicker && !optionHandler->SmootherLVH())
  602. {
  603. p->setPen(cg.background().dark(150));
  604. p->drawRect(r.x(), r.y(), r.width(), r.height());
  605. if (sunken)
  606. {
  607. p->setPen(cg.background().dark(200));
  608. p->drawRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
  609. }
  610. }
  611. }
  612. else
  613. {
  614. drawRectangularButton( p, cg, sunken ? cg.button() : taskContainerHover ? cg.button().light( 110 ) : cg.background(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center);
  615. p->setPen(cg.background().dark(150));
  616. p->drawLine(r.x(),r.y()+1,r.x(),r.height()-2);
  617. }
  618. const_cast<LiquidStyle*>( this ) ->isTaskContainer = false;
  619. const_cast<LiquidStyle*>( this ) ->taskContainerHover = false;
  620. }
  621. else
  622. {
  623. if ( (p->device() && p->device()->devType() == TQInternal::Widget) && ::tqt_cast<TQHeader*>((TQWidget*)p->device()) )
  624. {
  625. TQHeader *header = (TQHeader*)p->device();
  626. int id = header->orientation() == TQt::Horizontal ? header->sectionAt( r.x() + 2 + header->offset() ) : header->sectionAt( r.y() + 2 + header->offset() );
  627. hover = ((id != -1) && ((currentHeader == header && id == headerHoverID ) || id == headerSortID));
  628. if (header->mapToIndex(id) == header->count()-1 && (r.bottom() < header->rect().bottom() || r.right() < header->rect().right()))
  629. {
  630. bool hadClip = p->hasClipping();
  631. p->setClipping( false );
  632. if (header->orientation() == TQt::Horizontal)
  633. p->fillRect(r.right()+1, r.y(), header->width()-r.right(), r.height(), cg.base());
  634. else
  635. p->fillRect(r.x(), r.bottom()+1, r.width(), header->height()-r.bottom(), cg.base());
  636. p->setClipping( hadClip );
  637. }
  638. }
  639. if (optionHandler->SmoothListViewHeaders())
  640. {
  641. drawCombo( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center);
  642. }
  643. else
  644. drawRectangularButton( p, cg, sunken ? cg.button().dark( 110 ) : hover ? cg.button() : optionHandler->InactiveButtonColor(), r.x(), r.y(), r.width(), r.height(), sunken, hover, false, center);
  645. }
  646. p->setPen(oldpen);
  647. break;
  648. }
  649. case PE_FocusRect:
  650. {
  651. p->drawWinFocusRect( r );
  652. break;
  653. }
  654. case PE_ScrollBarSlider:
  655. case PE_ScrollBarAddPage:
  656. case PE_ScrollBarSubPage:
  657. {
  658. TQColor sbBgColor = optionHandler->useCustomColors() ?
  659. optionHandler->customColor( CustomSBGroove ) :
  660. tqApp->palette().active().background();
  661. bool isActive = optionHandler->ScrollerActive();
  662. bool isHover = currentScrollBar->hasMouse();
  663. bool isPressed = currentScrollBar->draggingSlider();
  664. bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue();
  665. // horizontal slider
  666. if ( flags & Style_Horizontal )
  667. {
  668. int extent = currentScrollBar->height();
  669. TQRect bgR( extent, 0, currentScrollBar->width() - extent * 3 + 1, extent );
  670. if ( sbBuffer.size() != currentScrollBar->size() )
  671. const_cast<LiquidStyle*>( this )->sbBuffer.resize( currentScrollBar->size() );
  672. TQPainter painter;
  673. painter.begin( &sbBuffer );
  674. // pixmaps
  675. if (drawSlider)
  676. {
  677. painter.drawPixmap( bgR.x(), bgR.y() + 1, *getPixmap( HSBSliderBtmBg ) );
  678. painter.drawTiledPixmap( bgR.x() + 7, bgR.y() + 1, bgR.width() - 15, 13, *getPixmap( HSBSliderMidBg ) );
  679. painter.drawPixmap( bgR.right() - 8, bgR.y() + 1, *getPixmap( HSBSliderTopBg ) );
  680. }
  681. else
  682. painter.drawTiledPixmap( bgR.x(), bgR.y() + 1, bgR.width(), 13, *getPixmap( HSBSliderMidBg ) );
  683. // lines
  684. painter.setPen( sbBgColor.dark( 110 ) );
  685. painter.drawLine( bgR.x(), bgR.y(), bgR.right(), bgR.y());
  686. painter.drawLine( bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
  687. if ( pe == PE_ScrollBarSlider && drawSlider)
  688. {
  689. int offset = isPressed * ( optionHandler->squeezeSbSlider() + optionHandler->shadowSbSlider()*2);
  690. int offset2 = optionHandler->shadowSbSlider()*2 + (isPressed && optionHandler->squeezeSbSlider());
  691. painter.drawPixmap( r.x() + offset, r.y() + 1,
  692. isPressed ? *getPixmap( HSBSliderBtmPressed ) :
  693. (isHover || isActive || isOOO) ? *getPixmap( HSBSliderBtmActive ) :
  694. *getPixmap( HSBSliderBtm));
  695. painter.drawPixmap( r.right() - 6 - offset2, r.y() + 1,
  696. isPressed ? *getPixmap( HSBSliderTopPressed ) :
  697. (isHover || isActive || isOOO) ? *getPixmap( HSBSliderTopActive ) :
  698. *getPixmap( HSBSliderTop ) );
  699. // mid part last, as i have to redefine clip section
  700. painter.setClipRect(r.x() + 7 + offset2, r.y() + 1, r.width() - 14 - 2*offset2, 13, TQPainter::CoordPainter);
  701. painter.drawTiledPixmap( r.x() + 7 + offset2 + ((isHover && !isPressed) ? (sliderAnimShift - 32) : 0), r.y() + 1, r.width() - 14 - 2*offset2 - ((isHover && !isPressed) ?
  702. (sliderAnimShift - 32) : 0), 13, isPressed ? *getPixmap( HSBSliderMidPressed ) :
  703. (isHover || isActive || isOOO) ? *getPixmap( HSBSliderMidActive ) :
  704. *getPixmap( HSBSliderMid ), isPressed?r.x() : 0, 0);
  705. }
  706. painter.end();
  707. }
  708. // vertical slider
  709. else
  710. {
  711. int extent = currentScrollBar->width();
  712. TQRect bgR( 0, extent, extent, currentScrollBar->height() - extent * 3 + 1 );
  713. if ( sbBuffer.size() != currentScrollBar->size() )
  714. const_cast<LiquidStyle*>( this ) -> sbBuffer.resize( currentScrollBar->size() );
  715. TQPainter painter;
  716. painter.begin( &sbBuffer ); // set painter to pixelbuffer
  717. if (drawSlider)
  718. {
  719. // top slidergroove rounder
  720. painter.drawPixmap( bgR.x() + 1, bgR.y(), *getPixmap( VSBSliderTopBg ) );
  721. // the groove
  722. painter.drawTiledPixmap( bgR.x() + 1, bgR.y() + 8, 13, bgR.height() - 15, *getPixmap( VSBSliderMidBg ) );
  723. // bottom slidergroove rounder
  724. painter.drawPixmap( bgR.x() + 1, bgR.bottom() - 7, *getPixmap( VSBSliderBtmBg ) );
  725. }
  726. else
  727. painter.drawTiledPixmap( bgR.x() + 1, bgR.y(), 13, bgR.height(), *getPixmap( VSBSliderMidBg ) );
  728. painter.setPen( sbBgColor.dark( 110 ) );
  729. painter.drawLine( bgR.x(), bgR.y(), bgR.x(), bgR.bottom() );
  730. painter.drawLine( bgR.right(), bgR.y(), bgR.right(), bgR.bottom() );
  731. // here we are, now the slider
  732. if ( pe == PE_ScrollBarSlider && drawSlider )
  733. {
  734. int offset = isPressed * ( optionHandler->squeezeSbSlider() + optionHandler->shadowSbSlider()*2);
  735. int offset2 = (isPressed * optionHandler->squeezeSbSlider()) + optionHandler->shadowSbSlider()*2;
  736. painter.drawPixmap( r.x() + 1, r.y() + offset, isPressed ?
  737. *getPixmap( VSBSliderTopPressed ) :
  738. (isHover || isActive || isOOO) ? *getPixmap( VSBSliderTopActive ) :
  739. *getPixmap( VSBSliderTop));
  740. painter.drawPixmap( r.x() + 1, r.bottom() - 6 - offset2, isPressed ?
  741. *getPixmap( VSBSliderBtmPressed ) :
  742. (isHover || isActive || isOOO) ? *getPixmap( VSBSliderBtmActive ) :
  743. *getPixmap( VSBSliderBtm ) );
  744. // mid part last, as i have to redefine clipping section
  745. painter.setClipRect(r.x() + 1, r.y() + 7+offset2, 13, r.height() - 14 - 2*offset2, TQPainter::CoordPainter);
  746. painter.drawTiledPixmap( r.x() + 1, r.y() + 7 + offset2 - ((isHover && !isPressed) ? sliderAnimShift : 0),
  747. 13, r.height() - 14 - 2*offset2 + ((isHover && !isPressed) ?
  748. sliderAnimShift : 0), isPressed ? *getPixmap( VSBSliderMidPressed ) :
  749. (isHover || isActive || isOOO) ? *getPixmap( VSBSliderMidActive ) :
  750. *getPixmap( VSBSliderMid ),0,isPressed?r.y():0 );
  751. }
  752. painter.end();
  753. }
  754. p->drawPixmap( r.x(), r.y(), sbBuffer, r.x(), r.y(), r.width(), r.height() );
  755. break;
  756. }
  757. case PE_ScrollBarAddLine:
  758. {
  759. TQColor c( optionHandler->useCustomColors() ?
  760. optionHandler->customColor( CustomSBGroove ) :
  761. tqApp->palette().active().background() );
  762. TQColor pixColor = flags & Style_Down ? tqApp->palette().active().button() : c;
  763. bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue();
  764. if ( flags & Style_Horizontal )
  765. {
  766. p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg));
  767. p->setPen( c.dark( 110 ) );
  768. p->drawLine( r.x(), r.y(), r.right(), r.y());
  769. p->drawLine( r.x(), r.bottom(), r.right(), r.bottom());
  770. }
  771. else
  772. {
  773. p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg));
  774. p->setPen( c.dark( 110 ) );
  775. p->drawLine( r.x(), r.y(), r.x(), r.bottom());
  776. p->drawLine( r.right(), r.y(), r.right(), r.bottom());
  777. }
  778. if (drawSlider)
  779. {
  780. p->setPen( flags & Style_Down ? cg.button() : TQColor(85,85,85) );
  781. p->setBrush( flags & Style_Down ? cg.button() : TQColor(85,85,85) );
  782. p->drawPixmap( r.x() + 4, r.y() + 4, flags & Style_Horizontal ? *sbRight : *sbDown );
  783. }
  784. break;
  785. }
  786. case PE_ScrollBarSubLine:
  787. {
  788. TQColor c( optionHandler->useCustomColors() ?
  789. optionHandler->customColor( CustomSBGroove ) :
  790. tqApp->palette().active().background() );
  791. TQColor pixColor = flags & Style_Down ? tqApp->palette().active().button() : c;
  792. bool top = flags & Style_Horizontal ? r.x() == 0 : r.y() == 0;
  793. bool drawSlider = currentScrollBar->minValue() < currentScrollBar->maxValue();
  794. if ( flags & Style_Horizontal )
  795. {
  796. if ( top )
  797. {
  798. p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg));
  799. }
  800. else
  801. {
  802. p->drawTiledPixmap( r.x(), r.y() + 1, r.width(), 13, *getPixmap(drawSlider ? HSBSliderMidBgI : HSBSliderMidBg));
  803. }
  804. p->setPen( c.dark( 110 ) );
  805. p->drawLine( r.x(), r.y(), r.right(), r.y());
  806. p->drawLine( r.x(), r.bottom(), r.right(), r.bottom());
  807. }
  808. else
  809. {
  810. if ( top )
  811. {
  812. p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg));
  813. }
  814. else
  815. {
  816. p->drawTiledPixmap( r.x() + 1, r.y(), 13, r.height(), *getPixmap(drawSlider ? VSBSliderMidBgI : VSBSliderMidBg));
  817. }
  818. p->setPen( c.dark( 110 ) );
  819. p->drawLine( r.x(), r.y(), r.x(), r.bottom());
  820. p->drawLine( r.right(), r.y(), r.right(), r.bottom());
  821. }
  822. if (drawSlider)
  823. {
  824. p->setPen( flags & Style_Down ? cg.button() : TQColor(85,85,85) );
  825. p->setBrush( flags & Style_Down ? cg.button() : TQColor(85,85,85) );
  826. if (currentScrollBar->minValue() < currentScrollBar->maxValue()) p->drawPixmap( r.x() + 4, r.y() + 4, flags & Style_Horizontal ? *sbLeft : *sbUp );
  827. }
  828. break;
  829. }
  830. case PE_Indicator:
  831. {
  832. bool hover = flags & Style_MouseOver;
  833. bool pressed = flags & Style_Down;
  834. // bool isMasked = p->device() && p->device() ->devType() == TQInternal::Widget && ( ( TQWidget * ) p->device() ) ->autoMask();
  835. #if 0
  836. if ( isMasked )
  837. {
  838. if ( !( flags & Style_Off ) )
  839. p->drawPixmap( r.x(), r.y(),
  840. hover ? *getPixmap( HTMLCBDownHover ) :
  841. *getPixmap( HTMLCBDown ) );
  842. else
  843. p->drawPixmap( r.x(), r.y(), hover ?
  844. *getPixmap( HTMLCBHover ) : *getPixmap( HTMLCB ) );
  845. }
  846. else
  847. #endif
  848. {
  849. if ( flags & Style_On )
  850. p->drawPixmap( r.x(), r.y(),
  851. pressed ? *getPixmap( CBDownPressed ) :
  852. hover ? *getPixmap( CBDownHover ) :
  853. *getPixmap( CBDown ) );
  854. else if ( flags & Style_Off )
  855. p->drawPixmap( r.x(), r.y(),
  856. pressed ? *getPixmap( CBPressed ) :
  857. hover ? *getPixmap( CBHover ) :
  858. *getPixmap( CB ) );
  859. else //tristate
  860. p->drawPixmap( r.x(), r.y(),
  861. pressed ? *getPixmap( CBTriPressed ) :
  862. hover ? *getPixmap( CBTriHover ) :
  863. *getPixmap( CBTri ) );
  864. }
  865. break;
  866. }
  867. case PE_IndicatorMask:
  868. {
  869. p->fillRect( r, TQt::color1 );
  870. break;
  871. }
  872. case PE_ExclusiveIndicator:
  873. {
  874. bool hover = flags & Style_MouseOver;
  875. bool pressed = flags & Style_Down;
  876. if ( on || down )
  877. p->drawPixmap( r.x(), r.y(),
  878. pressed ? *getPixmap( RadioOnPressed ) :
  879. hover ? *getPixmap( RadioOnHover ) :
  880. *getPixmap( RadioOn ) );
  881. else
  882. p->drawPixmap( r.x(), r.y(),
  883. pressed ? *getPixmap( RadioOffPressed ) :
  884. hover ? *getPixmap( RadioOffHover ) :
  885. *getPixmap( RadioOff ) );
  886. break;
  887. }
  888. case PE_ExclusiveIndicatorMask:
  889. {
  890. break;
  891. }
  892. case PE_Splitter:
  893. case PE_DockWindowResizeHandle:
  894. {
  895. TQPen oldpen(p->pen());
  896. TQBrush oldbrush(p->brush());
  897. if (highlightWidget == p->device())
  898. {
  899. if (flags & Style_Horizontal)
  900. { //vertical?
  901. p->setPen(cg.mid());
  902. p->drawLine(r.x(), r.y(), r.x(), r.bottom());
  903. p->drawLine(r.right(), r.y(), r.right(), r.bottom());
  904. p->setPen(cg.button().dark(140));
  905. p->setBrush(cg.button().dark(140));
  906. p->drawEllipse(r.x()+1,r.y() + (int)(r.height() / 2.5), 4, 4);
  907. }
  908. else
  909. {
  910. p->setPen(cg.mid());
  911. p->drawLine(r.x(), r.y(), r.right(), r.y());
  912. p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
  913. p->setPen(cg.button().dark(140));
  914. p->setBrush(cg.button().dark(140));
  915. p->drawEllipse(r.x()+r.width()/2,r.y() + 1, 4, 4);
  916. }
  917. }
  918. else
  919. {
  920. if (flags & Style_Horizontal)
  921. {
  922. p->setPen(cg.mid());
  923. p->drawLine(r.x(), r.y(), r.x(), r.bottom());
  924. p->drawLine(r.right(), r.y(), r.right(), r.bottom());
  925. p->setPen(cg.background().dark(130));
  926. p->setBrush(cg.background().dark(150));
  927. p->drawEllipse(r.x()+1,r.y() + (int)(r.height() / 2.5), 4, 4);
  928. }
  929. else
  930. {
  931. p->setPen(cg.mid());
  932. p->drawLine(r.x(), r.y(), r.right(), r.y());
  933. p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
  934. p->setPen(cg.background().dark(130));
  935. p->setBrush(cg.background().dark(150));
  936. p->drawEllipse(r.x()+r.width()/2,r.y() + 1, 4, 4);
  937. }
  938. }
  939. p->setPen(oldpen);
  940. p->setBrush(oldbrush);
  941. break;
  942. }
  943. // case PE_BoxFrame:
  944. case PE_PanelGroupBox:
  945. case PE_GroupBoxFrame:
  946. {
  947. TQColor bgColor;
  948. TQWidget* w = (p->device() && p->device()->devType() == TQInternal::Widget) ?
  949. (TQWidget*)(p->device()) : 0;
  950. TQGroupBox* gb = ::tqt_cast<TQGroupBox*>(w);
  951. optionHandler->drawGroupBoxShadow() ?
  952. bgColor = TQColor(cg.background().dark( 100 + optionHandler->ShadowDarkness() )) :
  953. bgColor = TQColor(cg.background());
  954. TQColor bright( bgColor.dark( 110 ) );
  955. TQColor mid( bgColor.dark( 130 ) );
  956. TQColor dark( bgColor.dark( 150 ) );
  957. int titleHeight = (gb && !gb->title().isEmpty() && pe == PE_PanelGroupBox) ?
  958. p->fontMetrics().height()+(gb->isCheckable()?4:1) : 0;
  959. int x = r.x(); int right = r.right(); int bottom = r.bottom();
  960. int y2 = r.y();
  961. /***
  962. ok, to get the sunken look somwhat efficient and less glitchy
  963. we reset the groupbox brush and only repaint the title
  964. (saves us from several is item in groupbox checks as well)
  965. only problem left: draw the parents brush on the title window aligned...
  966. ***/
  967. if (gb && titleHeight)
  968. {
  969. bool hadClip = p->hasClipping();
  970. TQRegion oldClip = p->clipRegion();
  971. if (gb->parentWidget())
  972. {
  973. const TQPixmap *pix = gb->parentWidget()->paletteBackgroundPixmap();
  974. if (optionHandler->drawGroupBoxShadow())
  975. {
  976. TQPointArray pa1(3);
  977. pa1.setPoint(0, x,y2);
  978. pa1.setPoint(1, x+5,y2);
  979. pa1.setPoint(2, x,y2+5);
  980. TQPointArray pa2(3);
  981. pa2.setPoint(0, right-5,y2);
  982. pa2.setPoint(1, right,y2);
  983. pa2.setPoint(2, right,y2+5);
  984. TQPointArray pa3(3);
  985. pa3.setPoint(0, right,bottom-5);
  986. pa3.setPoint(1, right,bottom);
  987. pa3.setPoint(2, right-5,bottom);
  988. TQPointArray pa4(3);
  989. pa4.setPoint(0, x+5,bottom);
  990. pa4.setPoint(1, x,bottom);
  991. pa4.setPoint(2, x,bottom-5);
  992. TQRegion reg2(0,0, r.right(), titleHeight);
  993. p->setClipRegion(TQRegion(pa1)+TQRegion(pa2)+TQRegion(pa3)+TQRegion(pa4)+reg2);
  994. }
  995. else
  996. p->setClipRect(0,0,r.right(),titleHeight);
  997. pix ? p->drawTiledPixmap( TQRect( 0, 0, w->width(), w->height()), *pix, w->backgroundOffset()) : p->fillRect(TQRect(0, 0, w->width(), w->height()),w->parentWidget()->backgroundBrush());
  998. }
  999. if (gb && !gb->isCheckable())
  1000. {
  1001. TQString title = gb->title();
  1002. TQFont font( p->font() );
  1003. font.setBold( true );
  1004. p->setFont( font );
  1005. drawItem( p, TQRect(10,0,r.width(),titleHeight), ShowPrefix, cg, flags & Style_Enabled, 0, title, -1, &cg.text() );
  1006. }
  1007. p->setClipRegion(oldClip);
  1008. p->setClipping(hadClip);
  1009. }
  1010. //outer rect
  1011. // top
  1012. p->setPen( dark );
  1013. if (pe == PE_PanelGroupBox)
  1014. {
  1015. p->drawLine( x + 6, y2, right - 6, y2 );
  1016. // left points
  1017. p->drawPoint(x+3,y2+1);p->drawPoint(x+4,y2+1);
  1018. p->drawPoint(x+2,y2+2);
  1019. p->drawPoint(x+1,y2+3);
  1020. // right points
  1021. p->drawPoint(right-3,y2+1);p->drawPoint(right-4,y2+1);
  1022. p->drawPoint(right-2,y2+2);
  1023. p->drawPoint(right-1,y2+3);
  1024. // vertcal outer lines
  1025. p->drawLine(x,y2+5,x,bottom-5);
  1026. p->drawLine(right,y2+5,right,bottom-5);
  1027. }
  1028. else
  1029. {
  1030. // vertcal outer lines
  1031. p->drawLine(x,y2,x,bottom-5);
  1032. p->drawLine(right,y2,right,bottom-5);
  1033. }
  1034. p->setPen( mid );
  1035. if (pe == PE_PanelGroupBox)
  1036. {
  1037. // top stuff
  1038. p->drawPoint(x+4, y2);p->drawPoint(x+5,y2);
  1039. p->drawPoint(right-4, y2);p->drawPoint(right-5,y2);
  1040. p->drawPoint(x+2, y2+1);
  1041. p->drawPoint(right-2, y2+1);
  1042. p->drawLine(x+5,y2 + 1, right - 5, y2 + 1);
  1043. p->drawPoint(x+1,y2+2);
  1044. p->drawPoint(right-1,y2+2);
  1045. p->drawPoint(x+2,y2+3);
  1046. p->drawPoint(right-2,y2+3);
  1047. p->drawPoint(x,y2+4);p->drawPoint(x+1,y2+4);
  1048. p->drawPoint(right,y2+4);p->drawPoint(right+1,y2+4);
  1049. }
  1050. // bottom stuff
  1051. p->drawPoint(x,bottom - 4); p->drawPoint(x+1,bottom - 4);
  1052. p->drawPoint(right,bottom - 4); p->drawPoint(right-1,bottom - 4);
  1053. p->drawPoint(x+1,bottom - 3);
  1054. p->drawPoint(right-1,bottom - 3);
  1055. p->drawPoint(x+1,bottom - 2); p->drawPoint(x+2,bottom - 2);
  1056. p->drawPoint(right-1,bottom - 2); p->drawPoint(right-2,bottom - 2);
  1057. p->drawPoint(x+2, bottom - 1); p->drawPoint(x+3, bottom - 1);
  1058. p->drawPoint(right-2, bottom - 1); p->drawPoint(right-3, bottom - 1);
  1059. p->drawLine(x + 4, bottom,right - 4, bottom);
  1060. p->setPen(bright);
  1061. // top stuff
  1062. if (pe == PE_PanelGroupBox)
  1063. {
  1064. p->drawPoint(x+3,y2);p->drawPoint(right-3,y2);
  1065. p->drawLine(x+4,y2+2,right-4,y2+2);
  1066. p->drawPoint(x,y2+3);p->drawPoint(x+3,y2+3);
  1067. p->drawPoint(right,y2+3);p->drawPoint(right-3,y2+3);
  1068. p->drawPoint(x+2,y2+4);p->drawPoint(right-2,y2+4);
  1069. // vertical lines
  1070. p->drawLine(x+1,y2+5,x+1,bottom-5);
  1071. p->drawLine(right-1,y2+5,right-1,bottom-5);
  1072. }
  1073. else
  1074. {
  1075. // vertical lines
  1076. p->drawLine(x+1,y2,x+1,bottom-5);
  1077. p->drawLine(right-1,y2,right-1,bottom-5);
  1078. }
  1079. // bottom stuff
  1080. p->drawPoint(x, bottom-3);p->drawPoint(right, bottom-3);
  1081. p->drawPoint(x+3, bottom);p->drawPoint(right-3, bottom);
  1082. break;
  1083. }
  1084. case PE_StatusBarSection:
  1085. {
  1086. break;
  1087. }
  1088. case PE_WindowFrame:
  1089. {
  1090. drawEditFrame( p, r, cg, false, false, true );
  1091. break;
  1092. }
  1093. case PE_Panel:
  1094. {
  1095. bool sunken = flags & Style_Sunken;
  1096. if (!(isKicker && optionHandler->RemoveKickerBevel()))
  1097. sunken ? drawEditFrame( p, r, cg ) : drawEditFrame( p, r, cg, false, false, true );
  1098. break;
  1099. }
  1100. case PE_PanelTabWidget:
  1101. {
  1102. // don't ask
  1103. bool isDialog = optionHandler->TabStyle() == Clever &&
  1104. (p->device() && p->device()->devType() == TQInternal::Widget)&&
  1105. ((TQWidget*)p->device())->topLevelWidget()->inherits("TQDialog");
  1106. TQColor bright( cg.background().dark( 110 ) );
  1107. TQColor mid( cg.background().dark( 130 ) );
  1108. TQColor dark( cg.background().dark( 150 ) );
  1109. int x = r.x(); int right = r.right(); int bottom = r.bottom(); int y2 = r.y();
  1110. if (isDialog || optionHandler->TabStyle() == Chooser)
  1111. {
  1112. //outer rect
  1113. // top
  1114. p->setPen( dark );
  1115. // vertcal outer lines
  1116. p->drawLine(x,y2,x,bottom-5);
  1117. p->drawLine(right,y2,right,bottom-5);
  1118. p->setPen( mid );
  1119. // bottom stuff
  1120. p->drawPoint(x,bottom - 4); p->drawPoint(x+1,bottom - 4);
  1121. p->drawPoint(right,bottom - 4); p->drawPoint(right-1,bottom - 4);
  1122. p->drawPoint(x+1,bottom - 3);
  1123. p->drawPoint(right-1,bottom - 3);
  1124. p->drawPoint(x+1,bottom - 2); p->drawPoint(x+2,bottom - 2);
  1125. p->drawPoint(right-1,bottom - 2); p->drawPoint(right-2,bottom - 2);
  1126. p->drawPoint(x+2, bottom - 1); p->drawPoint(x+3, bottom - 1);
  1127. p->drawPoint(right-2, bottom - 1); p->drawPoint(right-3, bottom - 1);
  1128. p->drawLine(x + 4, bottom,right - 4, bottom);
  1129. p->setPen(bright);
  1130. // top stuff
  1131. // vertical lines
  1132. p->drawLine(x+1,y2,x+1,bottom-5);
  1133. p->drawLine(right-1,y2,right-1,bottom-5);
  1134. // bottom stuff
  1135. p->drawPoint(x, bottom-3);p->drawPoint(right, bottom-3);
  1136. p->drawPoint(x+3, bottom);p->drawPoint(right-3, bottom);
  1137. break;
  1138. }
  1139. else
  1140. {
  1141. p->setPen( mid );
  1142. p->drawLine( x, y2, x, bottom-2 );
  1143. p->drawLine( right, y2, right, bottom-2 );
  1144. p->setPen( dark );
  1145. p->drawLine( x, bottom-1, right, bottom-1 );
  1146. p->drawLine( x, bottom, right, bottom );
  1147. break;
  1148. }
  1149. }
  1150. case PE_PanelLineEdit:
  1151. {
  1152. bool focused = flags & Style_HasFocus;
  1153. bool isHTML = p->device() && p->device()->devType() == TQInternal::Widget && isHTMLWidget((TQWidget*)p->device());
  1154. drawEditFrame( p, r, cg, isHTML, focused, false);
  1155. break;
  1156. }
  1157. case PE_PanelPopup:
  1158. {
  1159. int x, y, w , h;
  1160. r.rect( &x, &y, &w, &h );
  1161. TQColor c( optionHandler->UseCustomMenuColor()?
  1162. optionHandler->Color():
  1163. optionHandler->MenuColorButton()?
  1164. optionHandler->buttonColor():
  1165. optionHandler->bgColor() );
  1166. p->setPen( c.dark( 140 ) );
  1167. p->drawRect( x, y, w, h );
  1168. p->setPen( c.light( 120 ) );
  1169. p->drawRect( x + 1, y + 1, w - 2, h - 2 );
  1170. break;
  1171. }
  1172. case PE_PanelMenuBar:
  1173. {
  1174. break;
  1175. }
  1176. case PE_PanelDockWindow:
  1177. {
  1178. break;
  1179. }
  1180. case PE_Separator:
  1181. case PE_DockWindowSeparator:
  1182. {
  1183. break; //don't draw anything
  1184. if (!(p->device() && p->device()->devType() == TQInternal::Widget && ::tqt_cast<TQToolBar*>((TQWidget*)p->device())))
  1185. {
  1186. if ( !( flags & Style_Horizontal ) )
  1187. {
  1188. p->setPen( cg.mid() );
  1189. p->drawLine( 4, r.height() / 2, r.width() - 5, r.height() / 2 );
  1190. p->setPen( cg.light() );
  1191. p->drawLine( 4, r.height() / 2 + 1, r.width() - 5, r.height() / 2 + 1 );
  1192. }
  1193. else
  1194. {
  1195. p->setPen( cg.mid() );
  1196. p->drawLine( r.width() / 2, 4, r.width() / 2, r.height() - 5 );
  1197. p->setPen( cg.light() );
  1198. p->drawLine( r.width() / 2 + 1, 4, r.width() / 2 + 1, r.height() - 5 );
  1199. }
  1200. }
  1201. break;
  1202. }
  1203. case PE_SpinWidgetUp:
  1204. case PE_SpinWidgetDown:
  1205. {
  1206. bool sunken = on || down;
  1207. bool hover = flags & Style_MouseOver;
  1208. int x = r.x() + ( r.width() - 7 ) / 2;
  1209. int y = pe == PE_SpinWidgetDown ? r.y() + 1 : r.bottom() - 7;
  1210. TQPen oldPen( p->pen() );
  1211. TQBrush oldBrush( p->brush() );
  1212. p->setPen( sunken ? cg.button() : hover ? cg.mid() : cg.text() );
  1213. p->setBrush( sunken ? cg.button() : hover ? cg.mid() : cg.text() );
  1214. p->drawPixmap( x, y, pe == PE_SpinWidgetUp ? *sbUp : *sbDown );
  1215. p->setBrush( oldBrush );
  1216. p->setPen( oldPen );
  1217. break;
  1218. }
  1219. case PE_CheckMark:
  1220. {
  1221. TQPen oldPen( p->pen() );
  1222. p->setPen( flags & Style_On ? cg.highlightedText() : optionHandler->textColor() );
  1223. p->drawPixmap(r.x() + r.width()/2 - 4,r.y() + r.height()/2 - 4,*checkmark);
  1224. p->setPen( oldPen );
  1225. break;
  1226. }
  1227. default:
  1228. {
  1229. if ( (pe >= PE_ArrowUp && pe <= PE_ArrowLeft ) || pe == PE_HeaderArrow)
  1230. {
  1231. TQBrush oldBrush(p->brush());
  1232. TQColor tmpC = flags & Style_Enabled ? (flags & Style_Down || flags & Style_Sunken) && pe != PE_HeaderArrow ? cg.light() : cg.buttonText() : cg.mid();
  1233. if (tmpC == TQt::black) tmpC = TQColor(85,85,85);
  1234. p->setBrush(tmpC);
  1235. int x = r.width() > 7 ? r.x() + r.width()/2 - 4 : r.right() - 7;
  1236. int y = r.height() > 7 ? r.y() + r.height()/2 - 4 : r.bottom() - 7;
  1237. switch ( pe )
  1238. {
  1239. case PE_ArrowRight:
  1240. {
  1241. p->drawPixmap(x,y,*sbRight);
  1242. break;
  1243. }
  1244. case PE_ArrowUp:
  1245. {
  1246. p->drawPixmap(x,y,*sbUp);
  1247. break;
  1248. }
  1249. case PE_ArrowDown:
  1250. {
  1251. p->drawPixmap(x,y,*sbDown);
  1252. break;
  1253. }
  1254. case PE_HeaderArrow:
  1255. {
  1256. if (flags & Style_Up)
  1257. p->drawPixmap(x,y,*sbUp);
  1258. else
  1259. p->drawPixmap(x,y,*sbDown);
  1260. break;
  1261. }
  1262. default:
  1263. {
  1264. p->drawPixmap(x,y,*sbLeft);
  1265. break;
  1266. }
  1267. }
  1268. p->setBrush( oldBrush );
  1269. }
  1270. else
  1271. TDEStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
  1272. }
  1273. } // general switch
  1274. }
  1275. void LiquidStyle::drawTDEStylePrimitive( TDEStylePrimitive kpe,
  1276. TQPainter* p,
  1277. const TQStyleControlElementData &ceData,
  1278. ControlElementFlags elementFlags,
  1279. const TQRect &r,
  1280. const TQColorGroup &cg,
  1281. SFlags flags,
  1282. const TQStyleOption &opt,
  1283. const TQWidget* widget ) const
  1284. {
  1285. switch ( kpe )
  1286. {
  1287. case KPE_ToolBarHandle:
  1288. {
  1289. if (widget && widget->parentWidget() && widget->parentWidget()->hasMouse())
  1290. {
  1291. int x, y, w, h;
  1292. r.rect( &x, &y, &w, &h );
  1293. w = (int)((w-3)/2);
  1294. TQColor c( (optionHandler->style() == Brushed) ? cg.background() : cg.background().dark(120) );
  1295. p->setPen(c);
  1296. p->setBrush(c);
  1297. for (int i = 0; i < h-3; i += 5 )
  1298. p->drawEllipse(x+w,y+i,3,3);
  1299. }
  1300. break;
  1301. }
  1302. case KPE_GeneralHandle:
  1303. {
  1304. if (!widget)
  1305. break;
  1306. if ( widget->inherits( "AppletHandleDrag" ) )
  1307. {
  1308. int x, y, w, h;
  1309. r.rect( &x, &y, &w, &h );
  1310. w = (int)((w-3)/2);
  1311. TQColor c( widget->hasMouse() ? cg.button() : cg.background().dark(110) );
  1312. p->setPen(c);
  1313. p->setBrush(c);
  1314. for (int i = 0; i < h-3; i += 5 )
  1315. p->drawEllipse(x+w,y+i,3,3);
  1316. break;
  1317. }
  1318. else if (widget->hasMouse())
  1319. {
  1320. if (optionHandler->style() == Brushed)
  1321. {
  1322. drawCombo( p, cg, cg.button(), r.x(), r.y(), r.width(), r.height()+2, false, false, false, center);
  1323. }
  1324. else
  1325. {
  1326. p->fillRect(r,cg.button());
  1327. p->setPen(cg.button().dark( 100 + optionHandler->stippleContrast() ));
  1328. int x=r.x();
  1329. int y=r.y();
  1330. int w=r.width();
  1331. int h=r.height();
  1332. for (int i = y;i < y+h; i += 4 )
  1333. {
  1334. p->drawLine( x, i, x+w, i );
  1335. p->drawLine( x, i + 1, x+w, i + 1 );
  1336. }
  1337. }
  1338. }
  1339. else if (optionHandler->style() == Brushed && widget->parentWidget()) // needs alignment
  1340. {
  1341. p->drawTiledPixmap(r, *widget->paletteBackgroundPixmap(), widget->parentWidget()->backgroundOffset());
  1342. }
  1343. break;
  1344. }
  1345. case KPE_SliderGroove:
  1346. {
  1347. int x, y, w, h;
  1348. r.rect( &x, &y, &w, &h );
  1349. if (qstrcmp( tqApp->argv() [ 0 ], "kmix" ) == 0) x = x+3;
  1350. if ( ceData.orientation == TQt::Horizontal )
  1351. {
  1352. int x2 = x + w - 1;
  1353. y = y + ( h - 5 ) / 2;
  1354. p->setPen( cg.background().dark( 135 ) );
  1355. p->drawLine( x + 1, y, x2 - 1, y ); //1
  1356. p->drawLine( x, y + 4, x2, y + 4 ); //5
  1357. p->setPen( cg.background().dark( 150 ) );
  1358. p->drawLine( x, y + 1, x2, y + 1 ); //2
  1359. p->setPen( cg.background().dark( 115 ) );
  1360. p->drawLine( x, y + 2, x2, y + 2 ); //3
  1361. p->drawLine( x, y + 3, x2, y + 3 ); //4
  1362. p->setPen( cg.background().light( 130 ) );
  1363. p->drawLine( x + 1, y + 5, x2 - 1, y + 5 ); //6
  1364. }
  1365. else
  1366. {
  1367. int y2 = y + h - 1;
  1368. x = x + ( w - 5 ) / 2;
  1369. p->setPen( cg.background().dark( 135 ) );
  1370. p->drawLine( x, y + 1, x, y2 - 1 );
  1371. p->drawLine( x + 4, y, x + 4, y2 );
  1372. p->setPen( cg.background().dark( 150 ) );
  1373. p->drawLine( x + 1, y, x + 1, y2 );
  1374. p->setPen( cg.background().dark( 115 ) );
  1375. p->drawLine( x + 2, y, x + 2, y2 );
  1376. p->drawLine( x + 3, y, x + 3, y2 );
  1377. p->setPen( cg.background().light( 130 ) );
  1378. p->drawLine( x + 5, y + 1, x + 5, y2 - 1 );
  1379. }
  1380. break;
  1381. }
  1382. case KPE_SliderHandle:
  1383. {
  1384. if (!widget)
  1385. {
  1386. p->drawPixmap( r.x(), r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff));
  1387. break;
  1388. }
  1389. if ( ceData.orientation == TQt::Horizontal )
  1390. (widget && widget->height() < 17) ? p->drawPixmap( r.x(), r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff)) : p->drawPixmap( r.x(), (optionHandler->style() == Milk) ? r.y() : r.y()+2, *getPixmap( flags & Style_Enabled ? HSlider : HSliderInactive));
  1391. else
  1392. {
  1393. bool right = (( const TQSlider * ) widget )->tickmarks() == TQSlider::NoMarks || (( const TQSlider * ) widget )->tickmarks() == TQSlider::Right;
  1394. (widget && widget->width() < 17) ? p->drawPixmap( r.x()+2, r.y(), *getPixmap( flags & Style_Enabled ? RadioOffHover : RadioOff)) : p->drawPixmap( (optionHandler->style() == Milk) ? r.x() : right ? r.x()+5 : r.x()-3, r.y(), *getPixmap( flags & Style_Enabled ? (right ? VSlider : VSliderAbove) : (right ? VSliderInactive : VSliderAboveInactive)));
  1395. }
  1396. break;
  1397. }
  1398. case KPE_ListViewExpander:
  1399. {
  1400. p->fillRect(r,TQt::green);
  1401. // int radius = ( r.width() - 4 ) / 2;
  1402. // int centerx = r.x() + r.width() / 2;
  1403. // int centery = r.y() + r.height() / 2;
  1404. //
  1405. // int red, green, blue;
  1406. // red = ( cg.dark().red() >> 1 ) + ( cg.base().red() >> 1 );
  1407. // green = ( cg.dark().green() >> 1 ) + ( cg.base().green() >> 1 );
  1408. // blue = ( cg.dark().blue() >> 1 ) + ( cg.base().blue() >> 1 );
  1409. // TQColor blendColor( red, green, blue );
  1410. //
  1411. // p->setPen( cg.dark() );
  1412. // p->drawLine( r.x() + 1, r.y(), r.right() - 1, r.y() );
  1413. // p->drawLine( r.x() + 1, r.bottom(), r.right() - 1, r.bottom() );
  1414. // p->drawLine( r.x(), r.y() + 1, r.x(), r.bottom() - 1 );
  1415. // p->drawLine( r.right(), r.y() + 1, r.right(), r.bottom() - 1 );
  1416. // p->setPen( blendColor );
  1417. // p->drawPoint( r.x(), r.y() );
  1418. // p->drawPoint( r.right(), r.y() );
  1419. // p->drawPoint( r.x(), r.bottom() );
  1420. // p->drawPoint( r.right(), r.bottom() );
  1421. // p->setPen( cg.light() );
  1422. // p->drawRect( r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2 );
  1423. // p->fillRect( r.x() + 2, r.y() + 2, r.width() - 4, r.height() - 4,
  1424. // cg.background() );
  1425. // p->setPen( cg.text() );
  1426. // p->drawLine( centerx - radius, centery, centerx + radius, centery );
  1427. // if ( flags & Style_On )
  1428. // p->drawLine( centerx, centery - radius, centerx, centery + radius );
  1429. break;
  1430. }
  1431. default:
  1432. TDEStyle::drawTDEStylePrimitive( kpe, p, ceData, elementFlags, r, cg, flags, opt, widget );
  1433. }
  1434. }
  1435. void LiquidStyle::drawControl( ControlElement element,
  1436. TQPainter *p,
  1437. const TQStyleControlElementData &ceData,
  1438. ControlElementFlags elementFlags,
  1439. const TQRect &r,
  1440. const TQColorGroup &cg,
  1441. SFlags flags,
  1442. const TQStyleOption &opt,
  1443. const TQWidget *widget ) const
  1444. {
  1445. switch ( element )
  1446. {
  1447. case CE_ProgressBarGroove:
  1448. {
  1449. p->setPen(cg.background().dark(160));
  1450. p->drawRect(r);
  1451. drawCombo( p, cg, cg.background(), r.x()+1, r.y()+1, r.width()-2, r.height()+1, false, false, false, center );
  1452. break;
  1453. }
  1454. case CE_ProgressBarContents:
  1455. {
  1456. // tqWarning("%s - %s,%s : %s,%s",tqApp->argv()[0],widget->className(),widget->name(),widget->parentWidget()->className(),widget->parentWidget()->name());
  1457. const TQProgressBar *progress = ( const TQProgressBar * ) widget;
  1458. TQRect contentsR( subRect( SR_ProgressBarContents, ceData, elementFlags, widget ) );
  1459. double val = progress->progress();
  1460. bool reverse = TQApplication::reverseLayout();
  1461. val = val / progress->totalSteps();
  1462. if ( val > 0.0 )
  1463. {
  1464. int w = TQMIN( contentsR.width(), ( int ) (val * contentsR.width() ) );
  1465. if ( w > 1 )
  1466. {
  1467. int x = contentsR.x();
  1468. int y = contentsR.y();
  1469. TQRect progressRect;
  1470. if (reverse)
  1471. progressRect = TQRect(x+(contentsR.width()-w), y, w, contentsR.height()+1);
  1472. else
  1473. progressRect = TQRect(x, y, w, contentsR.height()+1);
  1474. if (optionHandler->ProgressBar() == liquid)
  1475. {
  1476. int x2 = x + w - 1;
  1477. int y2 = contentsR.bottom();
  1478. //Clip to the old rectangle
  1479. p->setClipRect(progressRect, TQPainter::CoordPainter);
  1480. //Expand
  1481. progressRect.setLeft(progressRect.x() - progAnimShift);
  1482. p->setPen(cg.button().dark(120));
  1483. p->drawLine(x, y, x2, y);
  1484. p->drawLine(x, y, x, y2);
  1485. p->drawLine(x+1, y2+1, x2-1, y2+1);
  1486. p->setPen(cg.button().dark(110));
  1487. p->drawLine(x2, y, x2, y2);
  1488. p->drawLine(x, y2, x2, y2);
  1489. TQPixmap * pix = getPixmap( Progress );
  1490. p->drawTiledPixmap(/*x+1, y+1, w-2, contentsR.height()-2*/progressRect, *pix);
  1491. }
  1492. else if (optionHandler->ProgressBar() == baghira)
  1493. {
  1494. drawCombo( p, cg, cg.button(), r.x()-1, r.y()-1, w, contentsR.height()+5, false, false, false, center);
  1495. }
  1496. else
  1497. {
  1498. ButtonTile *progress2Tile = progress2Dict.find( cg.button().rgb() );
  1499. if ( !progress2Tile )
  1500. {
  1501. TQPixmap *pix = getPixmap(progress2);
  1502. progress2Tile = separateTiles( pix, 0, 15, 38, 1, 0, true);
  1503. if ( !progress2Tile )
  1504. {
  1505. tqWarning( "Progress tile is NULL!" );
  1506. return ;
  1507. }
  1508. else
  1509. {
  1510. LiquidStyle *ptr = const_cast<LiquidStyle*>( this );
  1511. ptr->progress2Dict.insert( cg.button().rgb(), progress2Tile );
  1512. }
  1513. }
  1514. //Clip to the old rectangle
  1515. p->setClipRect(progressRect, TQPainter::CoordPainter);
  1516. //Expand
  1517. progressRect.setLeft(progressRect.x() - 38 + prog2AnimShift);
  1518. int h; /*x, y, w;*/
  1519. progressRect.rect(&x, &y, &w, &h);
  1520. bool tooSmall = h < 32;
  1521. int mid = h/2;
  1522. p->drawTiledPixmap(x,tooSmall ? mid + 1 : progressRect.bottom()-15,w,16, *progress2Tile->pixmap(TileBtm));
  1523. p->drawTiledPixmap(x,tooSmall ? mid : y+15,w,tooSmall ? 1 : h-31, *progress2Tile->pixmap(TileMiddle));
  1524. p->drawTiledPixmap(x,tooSmall ? mid - 15 : y,w,15, *progress2Tile->pixmap(TileTop));
  1525. }
  1526. }
  1527. }
  1528. break;
  1529. }/*
  1530. case CE_ToolButtonLabel:
  1531. {
  1532. const TQToolButton *toolbutton = (const TQToolButton *) widget;
  1533. TQRect rect = r;
  1534. TQt::ArrowType arrowType = opt.isDefault()
  1535. ? TQt::DownArrow : opt.arrowType();
  1536. int shiftX = 0;
  1537. int shiftY = 0;
  1538. if (flags & (Style_Down | Style_On)) {
  1539. shiftX = pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget);
  1540. shiftY = pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget);
  1541. }
  1542. if (!opt.isDefault())
  1543. {
  1544. PrimitiveElement pe;
  1545. switch (arrowType)
  1546. {
  1547. case TQt::LeftArrow: pe = PE_ArrowLeft; break;
  1548. case TQt::RightArrow: pe = PE_ArrowRight; break;
  1549. case TQt::UpArrow: pe = PE_ArrowUp; break;
  1550. default:
  1551. case TQt::DownArrow: pe = PE_ArrowDown; break;
  1552. }
  1553. rect.moveBy(shiftX, shiftY);
  1554. drawPrimitive(pe, p, ceData, elementFlags, rect, cg, flags, opt);
  1555. }
  1556. else
  1557. {
  1558. TQColor btext = TQt::black;//(flags & (Style_Down | Style_On)) ? tqApp->palette().color(TQPalette::Active,TQColorGroup::ButtonText) : toolbutton->paletteForegroundColor();
  1559. if (toolbutton->iconSet().isNull() &&
  1560. ! toolbutton->text().isNull() &&
  1561. ! toolbutton->usesTextLabel()) {
  1562. int alignment = AlignCenter | ShowPrefix;
  1563. if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget))
  1564. alignment |= NoAccel;
  1565. rect.moveBy(shiftX, shiftY);
  1566. drawItem(p, rect, alignment, cg,
  1567. flags & Style_Enabled, 0, toolbutton->text(),
  1568. toolbutton->text().length(), &btext);
  1569. } else {
  1570. TQPixmap pm;
  1571. TQIconSet::Size size =
  1572. toolbutton->usesBigPixmap() ? TQIconSet::Large : TQIconSet::Small;
  1573. TQIconSet::State state =
  1574. toolbutton->isOn() ? TQIconSet::On : TQIconSet::Off;
  1575. TQIconSet::Mode mode;
  1576. if (! toolbutton->isEnabled())
  1577. mode = TQIconSet::Disabled;
  1578. else if (flags & (Style_Down | Style_On) ||
  1579. (flags & Style_Raised) && (flags & Style_AutoRaise))
  1580. mode = TQIconSet::Active;
  1581. else
  1582. mode = TQIconSet::Normal;
  1583. pm = toolbutton->iconSet().pixmap( size, mode, state );
  1584. if ( toolbutton->usesTextLabel() )
  1585. {
  1586. p->setFont( toolbutton->font() );
  1587. TQRect pr = rect, tr = rect;
  1588. int alignment = ShowPrefix;
  1589. if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget))
  1590. alignment |= NoAccel;
  1591. if ( toolbutton->textPosition() == TQToolButton::Under )
  1592. {
  1593. int fh = p->fontMetrics().height();
  1594. pr.addCoords( 0, 1, 0, -fh-3 );
  1595. tr.addCoords( 0, pr.bottom(), 0, -3 );
  1596. pr.moveBy(shiftX, shiftY);
  1597. drawItem( p, pr, AlignCenter, cg, TRUE, &pm, TQString::null );
  1598. alignment |= AlignCenter;
  1599. }
  1600. else
  1601. {
  1602. pr.setWidth( pm.width() + 8 );
  1603. tr.addCoords( pr.right(), 0, 0, 0 );
  1604. pr.moveBy(shiftX, shiftY);
  1605. drawItem( p, pr, AlignCenter, cg, TRUE, &pm, TQString::null );
  1606. alignment |= AlignLeft | AlignVCenter;
  1607. }
  1608. tr.moveBy(shiftX, shiftY);
  1609. drawItem( p, tr, alignment, cg,
  1610. flags & Style_Enabled, 0, toolbutton->textLabel(),
  1611. toolbutton->textLabel().length(), &btext);
  1612. }
  1613. else
  1614. {
  1615. rect.moveBy(shiftX, shiftY);
  1616. drawItem( p, rect, AlignCenter, cg, TRUE, &pm, TQString::null );
  1617. }
  1618. }
  1619. }
  1620. break;
  1621. }*/
  1622. /*
  1623. case CE_HeaderLabel:
  1624. {
  1625. TQRect rect = r;
  1626. const TQHeader* header = (const TQHeader *) widget;
  1627. int section = opt.headerSection();
  1628. TQIconSet* icon = header->iconSet( section );
  1629. if ( icon ) {
  1630. TQPixmap pixmap = icon->pixmap( TQIconSet::Small,
  1631. flags & Style_Enabled ?
  1632. TQIconSet::Normal : TQIconSet::Disabled );
  1633. int pixw = pixmap.width();
  1634. int pixh = pixmap.height();
  1635. // "pixh - 1" because of tricky integer division
  1636. TQRect pixRect = rect;
  1637. pixRect.setY( rect.center().y() - (pixh - 1) / 2 );
  1638. drawItem ( p, pixRect, AlignVCenter, cg, flags & Style_Enabled,
  1639. &pixmap, TQString::null );
  1640. rect.setLeft( rect.left() + pixw + 2 );
  1641. }
  1642. drawItem ( p, rect, AlignVCenter, cg, flags & Style_Enabled,
  1643. 0, header->label( section ), -1, (isTaskContainer && (flags & Style_MouseOver)) ? &(tqApp->palette().color(TQPalette::Active,TQColorGroup::ButtonText)) : &(cg.buttonText()) );
  1644. break;
  1645. }*/
  1646. case CE_ProgressBarLabel:
  1647. {
  1648. if (optionHandler->DrawProgressLabel())
  1649. {
  1650. TQRect contentsR( subRect( SR_ProgressBarContents, ceData, elementFlags, widget ) );
  1651. if ( !contentsR.isValid() )
  1652. return ;
  1653. TQFont font( p->font() );
  1654. font.setBold( true );
  1655. p->setFont( font );
  1656. p->setPen( widget->colorGroup().buttonText() );
  1657. p->setClipRect(r, TQPainter::CoordPainter);
  1658. p->drawText( contentsR, AlignCenter, ( ( const TQProgressBar * ) widget ) ->progressString() );
  1659. }
  1660. break;
  1661. }
  1662. case CE_TabBarTab:
  1663. { // new style with tiled pixmaps
  1664. if ( !widget || !widget->parentWidget(true) )
  1665. break;
  1666. const TQTabBar *tabBar = ( const TQTabBar * ) widget;
  1667. bool selected = flags & Style_Selected;
  1668. bool hover = currentTabBar && currentTabBar == tabBar && tabBar->indexOf(opt.tab()->identifier()) == hoveredTabIndex;
  1669. myPosition pos;
  1670. if (tabBar->count() == 1)
  1671. pos = full;
  1672. else if ((tabBar->indexOf(opt.tab()->identifier()) == 0))
  1673. pos = left;
  1674. else if (tabBar->indexOf(opt.tab()->identifier()) == tabBar->count() - 1)
  1675. pos = right;
  1676. else
  1677. pos = center;
  1678. TQColor c;
  1679. if (hover || selected)
  1680. {
  1681. if (optionHandler->useCustomColors())
  1682. c = optionHandler->customColor(CustomTabOn);
  1683. else
  1684. c = optionHandler->buttonColor();
  1685. }
  1686. else
  1687. {
  1688. if (optionHandler->useCustomColors())
  1689. c = optionHandler->customColor(CustomTabOff);
  1690. else
  1691. c = optionHandler->InactiveButtonColor();
  1692. }
  1693. bool isDialog = optionHandler->TabStyle() == Clever && widget->topLevelWidget()->inherits("TQDialog");
  1694. if (isDialog || optionHandler->TabStyle() == Chooser)
  1695. drawCombo( p, cg, c, r.x(), r.y(), r.width(), r.height(), false, false, false, pos );
  1696. else
  1697. {
  1698. LiquidStyle *ptr = const_cast<LiquidStyle*>( this );
  1699. bool above = tabBar->shape() == TQTabBar::RoundedAbove || tabBar->shape() == TQTabBar::TriangularAbove;
  1700. TQPixmap *pix;
  1701. if (above)
  1702. pix = selected ? getPixmap( TabDown ) : getPixmap( Tab );
  1703. else
  1704. pix = selected ? getPixmap( belowTabDown ) : getPixmap( belowTab );
  1705. ButtonTile *tabTile = above ? tabDict.find( c.rgb() ) : inverseTabDict.find(c.rgb());
  1706. if ( !tabTile )
  1707. tabTile = separateTiles( pix, 9, 15, 67, 1, 0, false);
  1708. if ( !tabTile )
  1709. {
  1710. tqWarning( "Tab tile is NULL!" );
  1711. return ;
  1712. }
  1713. else
  1714. above ? ptr->tabDict.insert( c.rgb(), tabTile ) : ptr->inverseTabDict.insert( c.rgb(), tabTile );
  1715. int offset;
  1716. selected ? offset = 0 : offset = 2;
  1717. if ( r.width() > 18 )
  1718. {
  1719. p->drawTiledPixmap( r.x() + 9, r.y() + offset, r.width() - 18, 15, *tabTile->pixmap( TileTop ) );
  1720. p->drawTiledPixmap( r.x() + 9, r.height() - 11, r.width() - 18, 11, *tabTile->pixmap( TileBtm ) );
  1721. }
  1722. if ( r.height() + offset > 26 )
  1723. {
  1724. p->drawTiledPixmap( r.x() + 0, r.y() + 15 + offset, 9, r.height() - 26 - offset, *tabTile->pixmap( TileLeft ) );
  1725. p->drawTiledPixmap( r.right() - 8, r.y() + 15 + offset, 9, r.height() - 26 - offset, *tabTile->pixmap( TileRight ) );
  1726. }
  1727. if ( r.width() > 18 && r.height() + offset > 22 )
  1728. p->drawTiledPixmap( r.x() + 9, r.y() + 15 + offset, r.width() - 18, r.height() - 26 - offset, *tabTile->pixmap( TileMiddle ) );
  1729. p->drawPixmap( r.x() + 0, r.y() + offset, *tabTile->pixmap( TileTopLeft ) );
  1730. p->drawPixmap( r.right() - 8, r.y() + offset, *tabTile->pixmap( TileTopRight ) );
  1731. p->drawPixmap( r.x() + 0, r.height() - 11, *tabTile->pixmap( TileBtmLeft ) );
  1732. p->drawPixmap( r.right() - 8, r.height() - 11, *tabTile->pixmap( TileBtmRight ) );
  1733. p->setPen( optionHandler->buttonColor());
  1734. bool drawPoint = optionHandler->CenterTabs() || pos == center || pos == right;
  1735. if ( selected )
  1736. {
  1737. if (drawPoint) p->drawPoint(r.x(), above ? r.bottom() : r.y());
  1738. p->drawPoint(r.right(), above ? r.bottom() : r.y());
  1739. }
  1740. else
  1741. {
  1742. p->drawLine( r.x() + drawPoint ? 0 : 1, above ? r.bottom() : r.y(), r.right(), above ? r.bottom() : r.y() );
  1743. p->setPen( optionHandler->buttonColor().dark( 158 ));
  1744. p->drawLine( r.x() + drawPoint ? 0 : 1, above ? r.bottom()-1 : r.y()+1, r.right(), above ? r.bottom()-1 : r.y() + 1 );
  1745. }
  1746. }
  1747. break;
  1748. }
  1749. case CE_TabBarLabel:
  1750. {
  1751. if ( opt.isDefault() )
  1752. return ;
  1753. TQTab *t = opt.tab();
  1754. const TQTabBar * tb = ( const TQTabBar * ) widget;
  1755. if ( ( tb->currentTab() != t->identifier() ))
  1756. {
  1757. if (optionHandler->TabStyle() == TrueTab ||
  1758. (optionHandler->TabStyle() == Clever && !(widget->topLevelWidget()->inherits("TQDialog"))))
  1759. {
  1760. drawItem( p, TQRect( r.x(), r.y() + 1, r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ );
  1761. break;
  1762. }
  1763. drawItem( p, TQRect( r.x(), r.y(), r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ );
  1764. break;
  1765. }
  1766. drawItem( p, TQRect( r.x(), r.y(), r.width(), r.height() ), AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text(), -1/*, &cg.text()*/ );
  1767. break;
  1768. }
  1769. case CE_PushButton:
  1770. {
  1771. // if (_htmlWidgetWId == widget->winId())
  1772. // return;
  1773. TQPushButton *btn = ( TQPushButton* ) widget;
  1774. const_cast<LiquidStyle*>( this ) ->isHTMLButton = isHTMLWidget( btn );
  1775. ButtonFadeInfo *bfi_ = bfi[btn->winId()];
  1776. if ( widget == highlightWidget || (bfi_ && !bfi_->fadeIn) )
  1777. flags |= Style_MouseOver;
  1778. if (btn->isDefault())
  1779. flags |= Style_HasFocus;
  1780. // TQt messes this up with WindowOrigin, so we do it ourselves :P
  1781. if ( !isPlain() && !btn->autoMask() )
  1782. const_cast<LiquidStyle*>( this ) ->btnOffset = btn->backgroundOffset();
  1783. const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<TQWidget*>( widget );
  1784. drawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags, TQStyleOption( btn ));
  1785. const_cast<LiquidStyle*>( this ) ->paintWidget = 0L;
  1786. const_cast<LiquidStyle*>( this ) ->isHTMLButton = false;
  1787. break;
  1788. }
  1789. case CE_PushButtonLabel:
  1790. {
  1791. // if (_htmlWidgetWId == widget->winId())
  1792. // return;
  1793. const TQPushButton *btn = ( const TQPushButton* ) widget;
  1794. int x, y, w, h;
  1795. r.rect( &x, &y, &w, &h );
  1796. if ( btn->isOn() || btn->isDown() )
  1797. flags |= Style_Sunken;
  1798. int xoff = x;
  1799. if ( btn->iconSet() && !btn->iconSet() ->isNull() )
  1800. {
  1801. TQIconSet::Mode mode = btn->isEnabled() ? TQIconSet::Normal : TQIconSet::Disabled;
  1802. if ( mode == TQIconSet::Normal && btn->hasFocus() )
  1803. mode = TQIconSet::Active;
  1804. TQIconSet::State state = TQIconSet::Off;
  1805. if ( btn->isToggleButton() && btn->isOn() )
  1806. state = TQIconSet::On;
  1807. TQPixmap pix( btn->iconSet() ->pixmap( TQIconSet::Small, mode, state ) );
  1808. xoff += (x<6?8:2);
  1809. if (btn->text().isEmpty() && !btn->pixmap())
  1810. p->drawPixmap( x + w/2 - pix.width()/2, y + h / 2 - pix.height() / 2, pix );
  1811. else
  1812. p->drawPixmap( x<6?6:x, y + ( h - pix.height() ) / 2, pix );
  1813. }
  1814. if ( btn->isMenuButton() )
  1815. {
  1816. drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, TQRect( w-14, (int)(h/2), 7, 7 ) , cg, flags, opt );
  1817. w -= 14;
  1818. }
  1819. TQColor tmp;
  1820. tmp = btn->isDown() && !optionHandler->IcyButtons() ? btn->colorGroup().highlightedText() : btn->colorGroup().buttonText();
  1821. drawItem( p, TQRect( xoff, optionHandler->style() == Milk ? y-1 : y, w, h ), AlignCenter | ShowPrefix, cg, btn->isEnabled(), btn->pixmap(), btn->text(), -1, &tmp );
  1822. break;
  1823. }
  1824. case CE_MenuBarItem:
  1825. {
  1826. TQMenuItem *mi = opt.menuItem();
  1827. bool active = flags & Style_Active;
  1828. bool focused = flags & Style_HasFocus;
  1829. if ( active && focused )
  1830. {
  1831. optionHandler->glossyMenus() ?
  1832. drawCombo( p, cg, cg.highlight(), r.x(), r.y()-1, r.width(), r.height() + 5, false, false, false, center ) :
  1833. p->fillRect(r,cg.highlight());
  1834. }
  1835. // TQColor tmpColor( cg.background().dark( 120 ) );
  1836. if ( optionHandler->useShadowText() && !( active && focused ))
  1837. {
  1838. p->setPen(cg.background().dark( 120 ));
  1839. p->drawText(r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, mi->text());
  1840. }
  1841. // drawItem( p, TQRect( r.x() + 1, r.y() + 1, r.width(), r.height() ), AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, &tmpColor );
  1842. // drawItem( p, r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, active && focused ? &(cg.highlightedText()) : &(cg.text()) );
  1843. p->setPen(active && focused ? cg.highlightedText() : cg.text());
  1844. p->drawText(r, AlignCenter | AlignVCenter | ShowPrefix | DontClip | SingleLine, mi->text());
  1845. break;
  1846. }
  1847. case CE_PopupMenuItem:
  1848. {
  1849. int x,y,w, h;
  1850. r.rect( &x, &y, &w, &h );
  1851. const TQPopupMenu *popupmenu = ( const TQPopupMenu * ) widget;
  1852. TQMenuItem *mi = opt.menuItem();
  1853. int tab = opt.tabWidth();
  1854. int maxpmw = opt.maxIconWidth();
  1855. bool dis = mi && !mi->isEnabled();
  1856. bool checkable = popupmenu->isCheckable();
  1857. bool act = flags & Style_Active;
  1858. bool enabled = flags & Style_Enabled;
  1859. int checkcol = maxpmw;
  1860. TQColor menuBgColor( optionHandler->UseCustomMenuColor() ? optionHandler->Color() : optionHandler->bgColor() );
  1861. if ( checkable )
  1862. checkcol = TQMAX( maxpmw, 20 );
  1863. if ( mi && mi->isSeparator() )
  1864. {
  1865. p->setPen( menuBgColor.dark( 130 ) );
  1866. p->drawLine( x + 1, y, x + w - 1, y );
  1867. p->setPen( menuBgColor.light( 120 ) );
  1868. p->drawLine( x+1, y + 1, x + w - 1 , y + 1 );
  1869. return ;
  1870. }
  1871. if ( act && mi && enabled)
  1872. {
  1873. optionHandler->glossyMenus() ?
  1874. drawCombo( p, cg, cg.highlight(), r.x(), r.y(), r.width(), r.height() + 2, false/*sunken*/, false/*hover*/, false, center ) :
  1875. p->fillRect(x,y,w,h,cg.highlight());
  1876. }
  1877. else
  1878. {
  1879. if (popupBack.isNull())
  1880. p->fillRect( x, y, w, h, popupmenu->backgroundBrush() );
  1881. else
  1882. p->drawTiledPixmap( x, y, w, h, popupBack );
  1883. if (act)
  1884. {
  1885. p->setPen(cg.highlight());
  1886. p->drawRect(x,y,w,h);
  1887. }
  1888. }
  1889. if ( !mi )
  1890. return ;
  1891. // Menu contents drawing code based on TQt's styles. TQt is property of
  1892. // TrollTech: www.trolltech.com. Used with permission.
  1893. int xpos = x;
  1894. TQRect vrect = visualRect( TQRect( xpos, y, checkcol, h ), r );
  1895. int xvis = vrect.x();
  1896. // icon
  1897. if (optionHandler->drawMenuStripe())
  1898. p->fillRect(x,y,h,h, optionHandler->menuStripeColor());
  1899. if ( mi->iconSet() )
  1900. {
  1901. TQIconSet::Mode mode = dis ? TQIconSet::Disabled : TQIconSet::Normal;
  1902. if ( act && !dis )
  1903. mode = TQIconSet::Active;
  1904. TQPixmap pixmap;
  1905. if ( checkable && mi->isChecked() )
  1906. pixmap = mi->iconSet() ->pixmap( TQIconSet::Small, mode, TQIconSet::On );
  1907. else
  1908. pixmap = mi->iconSet() ->pixmap( TQIconSet::Small, mode );
  1909. int pixw = pixmap.width();
  1910. int pixh = pixmap.height();
  1911. TQRect pmr( 0, 0, pixw, pixh );
  1912. pmr.moveCenter( vrect.center() );
  1913. p->setPen( cg.text() );
  1914. p->drawPixmap( pmr.topLeft(), pixmap );
  1915. }
  1916. else if ( checkable )
  1917. {
  1918. if ( mi->isChecked() )
  1919. {
  1920. int xp = xpos + windowsItemFrame;
  1921. SFlags cflags = Style_Default;
  1922. if ( !dis )
  1923. cflags |= Style_Enabled;
  1924. if ( act )
  1925. cflags |= Style_On;
  1926. drawPrimitive( PE_CheckMark, p, ceData, elementFlags, visualRect( TQRect( xp, y + windowsItemFrame, checkcol - 2 * windowsItemFrame, h - 2 * windowsItemFrame ), r ), cg, cflags );
  1927. }
  1928. }
  1929. TQColor discol;
  1930. if ( dis )
  1931. {
  1932. discol = cg.text();
  1933. p->setPen( discol );
  1934. }
  1935. int xm = windowsItemFrame + checkcol + windowsItemHMargin;
  1936. xpos += xm;
  1937. vrect = visualRect( TQRect( xpos, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin ), r );
  1938. xvis = vrect.x();
  1939. if ( mi->custom() )
  1940. {
  1941. p->save();
  1942. if ( dis && !act )
  1943. {
  1944. p->setPen( cg.light() );
  1945. mi->custom() ->paint( p, cg, act, !dis, xvis + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin );
  1946. p->setPen( discol );
  1947. }
  1948. mi->custom() ->paint( p, cg, act, !dis, xvis, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin );
  1949. p->restore();
  1950. }
  1951. // Text
  1952. TQString s = mi->text();
  1953. if ( !s.isNull() )
  1954. {
  1955. TQColor textColor, shadowColor;
  1956. shadowColor = optionHandler->bgColor().dark( 130 );
  1957. if ( dis )
  1958. textColor = shadowColor.light( 115 );
  1959. else if (/*!optionHandler->glossyMenus() && */act && mi)
  1960. textColor = cg.highlightedText();
  1961. else if ( optionHandler->UseCustomMenuColor())
  1962. textColor = optionHandler->textColor();
  1963. else
  1964. textColor = cg.text();
  1965. int t = s.find( '\t' );
  1966. int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
  1967. text_flags |= ( TQApplication::reverseLayout() ? AlignRight : AlignLeft );
  1968. if ( t >= 0 )
  1969. { // draw tab text
  1970. int xp;
  1971. xp = x + w - tab - 20 - windowsItemHMargin - windowsItemFrame + 1;
  1972. TQString tabStr( s.right( s.length() - t - 1 ) );
  1973. if ( !tabStr.isEmpty() )
  1974. {
  1975. if ( optionHandler->useShadowText() )
  1976. {
  1977. p->setPen( shadowColor );
  1978. p->drawText( xp + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, tabStr );
  1979. }
  1980. p->setPen( textColor );
  1981. p->drawText( xp, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, tabStr );
  1982. }
  1983. s = s.left( t );
  1984. }
  1985. if ( optionHandler->useShadowText() && !(act && mi) )
  1986. {
  1987. p->setPen( shadowColor );
  1988. p->drawText( xvis + 1, y + windowsItemVMargin + 1, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, s, t );
  1989. }
  1990. p->setPen( textColor );
  1991. p->drawText( xvis, y + windowsItemVMargin, w - xm - tab + 1, h - 2 * windowsItemVMargin, text_flags, s, t );
  1992. }
  1993. else if ( mi->pixmap() )
  1994. // draw pixmap
  1995. {
  1996. TQPixmap * pixmap = mi->pixmap();
  1997. if ( pixmap->depth() == 1 )
  1998. p->setBackgroundMode( OpaqueMode );
  1999. p->drawPixmap( xvis, y + windowsItemFrame, *pixmap );
  2000. if ( pixmap->depth() == 1 )
  2001. p->setBackgroundMode( TransparentMode );
  2002. }
  2003. // Child menu
  2004. if ( mi->popup() )
  2005. {
  2006. int dim = (int)((float)( h - 2 * windowsItemFrame ) / 2);
  2007. PrimitiveElement arrow;
  2008. arrow = ( TQApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight );
  2009. xpos = x + w - windowsArrowHMargin - windowsItemFrame/* - dim*/-8;
  2010. vrect = visualRect( TQRect( xpos, y + h / 2 - dim / 2, /*dim*/8, dim ), r );
  2011. if ( act )
  2012. {
  2013. if ( !dis )
  2014. discol = cg.highlightedText();
  2015. TQColorGroup g2( discol, cg.highlight(), white, white, dis ? discol : white, discol, white );
  2016. drawPrimitive( arrow, p, ceData, elementFlags, vrect, g2, Style_Enabled );
  2017. }
  2018. else
  2019. {
  2020. if ( !dis )
  2021. discol = optionHandler->textColor();
  2022. TQColorGroup g2( discol, cg.background(), white, white, dis ? discol : white, discol, white );
  2023. drawPrimitive( arrow, p, ceData, elementFlags, vrect, g2, mi->isEnabled() ? Style_Enabled : Style_Default );
  2024. }
  2025. }
  2026. break;
  2027. }
  2028. /*
  2029. case CE_ToolBoxTab:
  2030. {
  2031. break;
  2032. }*/
  2033. default:
  2034. TDEStyle::drawControl( element, p, ceData, elementFlags, r, cg, flags, opt, widget );
  2035. }
  2036. }
  2037. // void LiquidStyle::drawControlMask( ControlElement element, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption& opt ) const {
  2038. // switch ( element ) {
  2039. // case CE_PushButton: {
  2040. // p->fillRect( r, TQt::color1 );
  2041. // break;
  2042. // }
  2043. // default:
  2044. // TDEStyle::drawControlMask( element, p, widget, r, opt );
  2045. // break;
  2046. // }
  2047. // }
  2048. // void LiquidStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption &opt ) const {
  2049. // // switch ( control ) {
  2050. // // case CC_ComboBox: {
  2051. // // drawControlMask( CE_PushButton, p, widget, r, opt );
  2052. // // break;
  2053. // // }
  2054. // // default:
  2055. // TDEStyle::drawComplexControlMask( control, p, widget, r, opt );
  2056. // // }
  2057. // }
  2058. void LiquidStyle::drawComplexControl( ComplexControl control,
  2059. TQPainter *p,
  2060. const TQStyleControlElementData &ceData,
  2061. ControlElementFlags elementFlags,
  2062. const TQRect &r,
  2063. const TQColorGroup &cg,
  2064. SFlags flags,
  2065. SCFlags controls,
  2066. SCFlags active,
  2067. const TQStyleOption &opt,
  2068. const TQWidget *widget ) const
  2069. {
  2070. switch ( control )
  2071. {
  2072. case CC_ComboBox:
  2073. {
  2074. bool sunken = (active & SC_ComboBoxArrow);// || (flags & Style_Active) || (flags & Style_Sunken) || (active & SC_ComboBoxListBoxPopup);
  2075. bool hovered = (widget == highlightWidget) || (flags & Style_HasFocus);
  2076. // bool isHtml = isHTMLWidget( widget );
  2077. const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<TQWidget*>( widget );
  2078. TQPen oldPen( p->pen() );
  2079. if ( controls & SC_ComboBoxArrow )
  2080. {
  2081. if ( controls & SC_ComboBoxEditField && ( ( const TQComboBox * ) widget ) ->editable())
  2082. { // editable?
  2083. #if 0
  2084. if ( optionHandler->buttonStyle() == Brushed )
  2085. { // rectangular?
  2086. drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full/*, isHtml*/);
  2087. p->fillRect( r.x() + 6, r.y() +2, r.width()-32, r.height() - 7, cg.background());
  2088. p->setPen( oldPen );
  2089. return ;
  2090. }
  2091. else
  2092. #endif
  2093. { // round frame
  2094. drawRoundFrame( p, r, cg, (flags & Style_HasFocus) || sunken , widget->backgroundOffset());
  2095. p->setPen(cg.mid());
  2096. p->drawPixmap(r.right() - 16, r.height()/2 - 2, *sbDown);
  2097. p->setPen( oldPen );
  2098. // return;
  2099. }
  2100. #if 0
  2101. else
  2102. { // default!
  2103. drawCombo( p, cg, active == SC_ComboBoxArrow ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full );
  2104. p->fillRect( r.x() + 6, r.y() +2, r.width()-32, r.height() - 7, cg.background());
  2105. p->setPen( oldPen );
  2106. return;
  2107. }
  2108. #endif
  2109. }
  2110. else
  2111. { // end editable - default handling
  2112. if ( optionHandler->buttonStyle() == Brushed )
  2113. { // retangular?
  2114. drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full, isHTMLWidget( widget ));
  2115. // p->setPen( oldPen );
  2116. // return ;
  2117. }
  2118. else
  2119. { //default plain good old combobox... ;)
  2120. drawCombo( p, cg, active == SC_ComboBoxArrow ? cg.button().light( 110 ) : cg.button(), r.x(), r.y(), r.width(), r.height(), sunken, hovered, true, full, isHTMLWidget( widget ) );
  2121. // p->setPen( oldPen );
  2122. // return;
  2123. }
  2124. }
  2125. }
  2126. const_cast<LiquidStyle*>( this ) ->paintWidget = 0L;
  2127. break;
  2128. }
  2129. case CC_ToolButton:
  2130. {
  2131. const TQToolButton *toolbutton = ( const TQToolButton * ) widget;
  2132. const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<TQWidget*>( widget );
  2133. const KAccessToolBarButton *toolbutton2 = 0L;
  2134. TQRect button, menuarea;
  2135. button = querySubControlMetrics( control, ceData, elementFlags, SC_ToolButton, opt, widget );
  2136. menuarea = querySubControlMetrics( control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget );
  2137. if (::tqt_cast<TDEToolBarButton*>(toolbutton))
  2138. {
  2139. toolbutton2 = (const KAccessToolBarButton*)toolbutton;
  2140. #if GCC_VERSION < 40000
  2141. if (toolbutton2->iconTextMode() == 3)
  2142. button.setBottom(button.bottom() - p->fontMetrics().height() - 1);
  2143. #endif
  2144. }
  2145. else if (toolbutton->usesTextLabel() && toolbutton->textPosition() == TQToolButton::BelowIcon)
  2146. button.setBottom(button.bottom() - p->fontMetrics().height());
  2147. menuarea.setX(menuarea.x() - 1);
  2148. SFlags bflags = flags, mflags = flags;
  2149. if ( active & SC_ToolButton )
  2150. bflags |= Style_Down;
  2151. if ( active & SC_ToolButtonMenu )
  2152. mflags |= Style_Down;
  2153. if ( widget == highlightWidget )
  2154. bflags |= Style_MouseOver;
  2155. if ( controls & SC_ToolButton )
  2156. {
  2157. bool sunken = mflags & ( Style_Down /*| Style_On*/ );
  2158. bool hover = bflags & (Style_MouseOver | Style_On );
  2159. if ( !optionHandler->useToolButtonFrame())// || !(toolbutton->parentWidget() && ( ::tqt_cast<TQToolBar*>(toolbutton->parentWidget()) || toolbutton->parentWidget()->inherits("KonqFrameTabs"))))
  2160. {
  2161. if ((!(hover || sunken) || (toolbutton->usesTextLabel() && toolbutton->textPosition() == TQToolButton::BelowIcon)) && toolbutton->parentWidget() && !::tqt_cast<TQToolBar*>(toolbutton->parent()) && toolbutton->parentWidget()->paletteBackgroundPixmap() && !toolbutton->parentWidget()->paletteBackgroundPixmap()->isNull())
  2162. {
  2163. TQPixmap pixmap = *(toolbutton->parentWidget()->paletteBackgroundPixmap());
  2164. if (hover || sunken)
  2165. p->drawTiledPixmap( r.x(), button.bottom()+1, r.width(), p->fontMetrics().height(), pixmap, toolbutton->x(), toolbutton->y()+button.height() );
  2166. else
  2167. p->drawTiledPixmap( r, pixmap, toolbutton->pos() );
  2168. }
  2169. if (hover || sunken)
  2170. {
  2171. const_cast<LiquidStyle*>( this ) ->paintWidget = const_cast<TQWidget*>( widget );
  2172. if (optionHandler->toolbuttonStyle() != Brushed)
  2173. drawCombo( p, cg, sunken ? cg.button().light( 110 ) :
  2174. (hover || (cg.button() != tqApp->palette().active().button())) ? cg.button() :
  2175. optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(),
  2176. button.height(), sunken, hover, false, full );
  2177. else
  2178. drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : cg.button(),
  2179. button.x(), button.y(), button.width(), button.height(),
  2180. sunken, hover, false);
  2181. const_cast<LiquidStyle*>( this ) ->paintWidget = 0L;
  2182. }
  2183. }
  2184. else
  2185. {
  2186. myPosition pos = full;
  2187. TDEToolBar *bar = NULL;
  2188. if (toolbutton2 && toolbutton2->parentWidget() && ::tqt_cast<TDEToolBar*>(toolbutton2->parentWidget()) )
  2189. { //position calculation - would be nice if tdetoolbarbutton provided this as flag
  2190. bar = (TDEToolBar*)toolbutton2->parentWidget();
  2191. int buttonId = toolbutton2->id();
  2192. int buttonIndex = bar->itemIndex(buttonId);
  2193. // ok, this is a very hackish heck of a hack...
  2194. // kbookmarkbar (e.g. used by konqueror) accesses the iterator of the toolbar
  2195. // this confuses the iterator of the toolbar a bit, as it is used from the bookmark stuff and my function at the same time (seems, as if kbookmarkbar acts on shown toolbars)
  2196. // unfortunately, there's no way to figure out if it does for this specific toolbar
  2197. // so i check for the toolbars name, knowing this will work for current konqueror - but may fail on further versions
  2198. // even worse - the stuff is hardcoded (assuming first item to be left aligned, last one right and the rest centered)
  2199. // this is crap at all - so if the best thing would be to patch qtoolbutton to provide conjuncted buttons - i'll ask them (maybe qt4)
  2200. if (bar && ( qstrcmp( bar->name(), "bookmarkToolBar" ) == 0 ))
  2201. {
  2202. return;
  2203. buttonIndex == 0 ?
  2204. pos = left :
  2205. buttonIndex == bar->count() - 1 ?
  2206. pos = right :
  2207. pos = center;
  2208. }
  2209. else if (bar->orientation() == TQt::Horizontal)
  2210. {
  2211. if (buttonIndex == 0)
  2212. {
  2213. TDEToolBarButton *tmpButton = bar->getButton(bar->idAt(buttonIndex+1));
  2214. (tmpButton && tmpButton->x() == toolbutton2->x()+toolbutton2->width()) ? pos = left : pos = full;
  2215. }
  2216. else if (buttonIndex == bar->count() - 1)
  2217. {
  2218. TDEToolBarButton *tmpButton = NULL;
  2219. tmpButton = bar->getButton(bar->idAt(buttonIndex-1));
  2220. (tmpButton && tmpButton->x() + tmpButton->width() == toolbutton2->x()) ? pos = right : pos = full;
  2221. }
  2222. else
  2223. {
  2224. TDEToolBarButton *tmpButton1 = bar->getButton(bar->idAt(buttonIndex-1));
  2225. TDEToolBarButton *tmpButton2 = bar->getButton(bar->idAt(buttonIndex+1));
  2226. tmpButton1 && tmpButton1->x() + tmpButton1->width() == toolbutton2->x() ?
  2227. pos = center : pos = left;
  2228. if (!(tmpButton2 && tmpButton2->x() == toolbutton2->x()+toolbutton2->width()))
  2229. pos == left ? pos = full : pos = right;
  2230. }
  2231. }
  2232. else
  2233. {
  2234. if (buttonIndex == 0)
  2235. {
  2236. TDEToolBarButton *tmpButton = bar->getButton(bar->idAt(buttonIndex+1));
  2237. (tmpButton && tmpButton->y() == toolbutton2->y()+toolbutton2->height()) ?
  2238. pos = left : pos = full;
  2239. }
  2240. else if (buttonIndex == bar->count() - 1)
  2241. {
  2242. TDEToolBarButton *tmpButton = NULL;
  2243. tmpButton = bar->getButton(bar->idAt(buttonIndex-1));
  2244. (tmpButton && tmpButton->y() + tmpButton->height() == toolbutton2->y()) ?
  2245. pos = right : pos = full;
  2246. }
  2247. else
  2248. {
  2249. TDEToolBarButton *tmpButton1 = bar->getButton(bar->idAt(buttonIndex-1));
  2250. TDEToolBarButton *tmpButton2 = bar->getButton(bar->idAt(buttonIndex+1));
  2251. tmpButton1 && tmpButton1->y() + tmpButton1->height() == toolbutton2->y() ?
  2252. pos = center : pos = left;
  2253. if (!(tmpButton2 && tmpButton2->y() == toolbutton2->y()+toolbutton2->height()))
  2254. pos == left ? pos = full : pos = right;
  2255. }
  2256. }
  2257. }
  2258. if (optionHandler->toolbuttonStyle() != Brushed)
  2259. {
  2260. (bar && bar->orientation() == TQt::Vertical) ?
  2261. drawCombo( p, cg, sunken ? cg.button().light( 110 ) : (hover || (cg.button() != tqApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), (pos == full || pos == left) ? button.y() : button.y() - 7, button.width(), (pos == full) ? button.height()+2 : (pos == center) ? button.height()+16 : button.height()+9, sunken, hover, false, center ) :
  2262. drawCombo( p, cg, sunken ? cg.button().light( 110 ) : (hover || (cg.button() != tqApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(), button.height()/*+2*/, sunken, hover, false, pos );
  2263. }
  2264. else
  2265. {
  2266. (bar && bar->orientation() == TQt::Vertical) ?
  2267. drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : (hover || (cg.button() != tqApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), (pos == full || pos == left) ? button.y() : button.y()-4, button.width(), (pos == full) ? button.height() : (pos == center) ? button.height()+8 : button.height()+4, sunken, hover, false) :
  2268. drawRectangularButton( p, cg, sunken ? cg.button().light( 110 ) : (hover || (cg.button() != tqApp->palette().active().button())) ? cg.button() : optionHandler->InactiveButtonColor(), button.x(), button.y(), button.width(), button.height(), sunken, hover, false, pos);
  2269. }
  2270. }
  2271. }
  2272. // Draw a toolbutton menu indicator if required
  2273. if ( controls & SC_ToolButtonMenu )
  2274. {
  2275. if ( mflags & ( Style_Down | Style_On | Style_Raised ) )
  2276. drawPrimitive( PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, opt );
  2277. drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, menuarea, cg, mflags, opt );
  2278. }
  2279. #if 0
  2280. if ( toolbutton->hasFocus() && !toolbutton->focusProxy() )
  2281. {
  2282. TQRect fr = toolbutton->rect();
  2283. fr.addCoords( 3, 3, -3, -3 );
  2284. drawPrimitive( PE_FocusRect, p, ceData, elementFlags, fr, cg );
  2285. }
  2286. #endif
  2287. const_cast<LiquidStyle*>( this ) ->paintWidget = 0L;
  2288. break;
  2289. }
  2290. case CC_ScrollBar:
  2291. {
  2292. const_cast<LiquidStyle*>( this ) ->currentScrollBar = ( TQScrollBar * ) widget;
  2293. TDEStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, controls, active, opt, widget );
  2294. break;
  2295. }
  2296. case CC_SpinWidget: {
  2297. const TQSpinWidget * sw = (const TQSpinWidget *) widget;
  2298. SFlags flags;
  2299. PrimitiveElement pe;
  2300. if ( controls & SC_SpinWidgetFrame )
  2301. drawEditFrame( p, r, cg, false, sw->hasFocus());
  2302. if ( controls & SC_SpinWidgetUp ) {
  2303. flags = Style_Default | Style_Enabled;
  2304. if (active == SC_SpinWidgetUp ) {
  2305. flags |= Style_On;
  2306. flags |= Style_Sunken;
  2307. } else
  2308. flags |= Style_Raised;
  2309. pe = PE_SpinWidgetUp;
  2310. TQRect re = sw->upRect();
  2311. TQColorGroup ucg = sw->isUpEnabled() ? cg : sw->palette().disabled();
  2312. p->fillRect(re, ucg.base());
  2313. drawPrimitive(pe, p, ceData, elementFlags, re, ucg, flags);
  2314. }
  2315. if ( controls & SC_SpinWidgetDown ) {
  2316. flags = Style_Default | Style_Enabled;
  2317. if (active == SC_SpinWidgetDown ) {
  2318. flags |= Style_On;
  2319. flags |= Style_Sunken;
  2320. } else
  2321. flags |= Style_Raised;
  2322. pe = PE_SpinWidgetDown;
  2323. TQRect re = sw->downRect();
  2324. TQColorGroup dcg = sw->isDownEnabled() ? cg : sw->palette().disabled();
  2325. p->fillRect(re, dcg.base());
  2326. drawPrimitive(pe, p, ceData, elementFlags, re, dcg, flags);
  2327. }
  2328. break; }
  2329. // SLIDER - KDE code for double buffering
  2330. // -------------------------------------------------------------------
  2331. case CC_Slider: {
  2332. const TQSlider* slider = (const TQSlider*)widget;
  2333. TQRect groove = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderGroove, opt, widget);
  2334. TQRect handle = querySubControlMetrics(CC_Slider, ceData, elementFlags, SC_SliderHandle, opt, widget);
  2335. // Double-buffer slider for no flicker
  2336. TQPixmap pix(widget->size());
  2337. TQPainter p2;
  2338. p2.begin(&pix);
  2339. if ( slider->parentWidget() &&
  2340. (slider->parentWidget()->paletteBackgroundPixmap() && !slider->parentWidget()->paletteBackgroundPixmap()->isNull() )) {
  2341. TQPixmap pixmap = *(slider->parentWidget()->backgroundPixmap());
  2342. if (TQWidget *topDaddy = slider->topLevelWidget()){
  2343. TQPoint zero = TQPoint(0,0);
  2344. #if 0
  2345. zero = slider->mapTo(topDaddy, zero);
  2346. int zxmpw = zero.x()%pixmap.width();
  2347. int zymph;
  2348. #endif
  2349. // probably due to argb mismatches in drawpixmap, this fails on kompmgr startups
  2350. p2.drawTiledPixmap(r, pixmap, slider->mapTo(topDaddy, zero));
  2351. #if 0
  2352. for (int dx = 0; dx < pix.width(); dx += pixmap.width())
  2353. {
  2354. zymph = zero.y()%pixmap.height();
  2355. for (int dy = 0; dy < pix.height(); dy += pixmap.height())
  2356. {
  2357. copyBlt (&pix, dx, dy, &pixmap,
  2358. zxmpw, zymph,
  2359. pix.width()-dx>pixmap.width()-zxmpw?pixmap.width()-zxmpw:pix.width()-dx, pix.height()-dy>pixmap.height()-zymph?pixmap.height()-zymph:pix.height()-dy);
  2360. zymph=0;
  2361. }
  2362. zxmpw=0;
  2363. }
  2364. #endif
  2365. } else
  2366. {
  2367. // probably due to argb mismatches in drawpixmap, this fails on kompmgr startups
  2368. p2.drawTiledPixmap(r, pixmap, slider->pos());
  2369. #if 0
  2370. for (int dx = 0; dx < pix.width(); dx += pixmap.width())
  2371. for (int dy = 0; dy < pix.height(); dy += pixmap.height())
  2372. copyBlt (&pix, dx, dy, &pixmap, 0, 0,
  2373. pix.width()-dx>pixmap.width()?pixmap.width():pix.width()-dx, pix.height()-dy>pixmap.height()?pixmap.height():pix.height()-dy);
  2374. #endif
  2375. }
  2376. // p2.begin(&pix);
  2377. } else{
  2378. // p2.begin(&pix);
  2379. pix.fill(cg.background());
  2380. }
  2381. // Draw slider groove
  2382. if ((controls & SC_SliderGroove) && groove.isValid()) {
  2383. drawTDEStylePrimitive( KPE_SliderGroove, &p2, ceData, elementFlags, groove, cg, flags, opt, widget );
  2384. // Draw the focus rect around the groove
  2385. /* if (slider->hasFocus())
  2386. drawPrimitive(PE_FocusRect, &p2, ceData, elementFlags, groove, cg);*/
  2387. }
  2388. // Draw the tickmarks
  2389. if (controls & SC_SliderTickmarks)
  2390. TQCommonStyle::drawComplexControl(control, &p2, ceData, elementFlags,
  2391. r, cg, flags, SC_SliderTickmarks, active, opt, widget);
  2392. // Draw the slider handle
  2393. if ((controls & SC_SliderHandle) && handle.isValid()) {
  2394. if (active == SC_SliderHandle)
  2395. flags |= Style_Active;
  2396. drawTDEStylePrimitive( KPE_SliderHandle, &p2, ceData, elementFlags, handle, cg, flags, opt, widget );
  2397. }
  2398. p2.end();
  2399. bitBlt((TQWidget*)widget, r.x(), r.y(), &pix);
  2400. break;
  2401. }
  2402. #ifndef TQT_NO_LISTVIEW
  2403. case CC_ListView: {
  2404. if ( controls & SC_ListView ) {
  2405. TQCommonStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, controls, active, opt, widget );
  2406. }
  2407. if ( controls & ( SC_ListViewBranch | SC_ListViewExpand ) ) {
  2408. if ( opt.isDefault() )
  2409. break;
  2410. TQListViewItem *item = opt.listViewItem();
  2411. TQListViewItem *child = item->firstChild();
  2412. TQListView* v = item->listView();
  2413. bool drawDotlines = optionHandler->DrawDotlines();
  2414. static TQBitmap *verticalLine = 0, *horizontalLine = 0;
  2415. static TQCleanupHandler<TQBitmap> qlv_cleanup_bitmap;
  2416. int dotoffset = 0;
  2417. if (drawDotlines && (optionHandler->DotlineStyle() == Dots)){
  2418. if ( !verticalLine ) {
  2419. // make 128*1 and 1*128 bitmaps that can be used for
  2420. // drawing the right sort of lines.
  2421. verticalLine = new TQBitmap( 1, 128, TRUE );
  2422. horizontalLine = new TQBitmap( 128, 1, TRUE );
  2423. TQPointArray a( 64 );
  2424. TQPainter p;
  2425. p.begin( verticalLine );
  2426. int i;
  2427. for( i=0; i<64; i++ )
  2428. a.setPoint( i, 0, i*2+1 );
  2429. p.setPen( optionHandler->DotlineColor() );
  2430. p.drawPoints( a );
  2431. p.end();
  2432. TQApplication::flushX();
  2433. verticalLine->setMask( *verticalLine );
  2434. p.begin( horizontalLine );
  2435. for( i=0; i<64; i++ )
  2436. a.setPoint( i, i*2+1, 0 );
  2437. p.setPen( optionHandler->DotlineColor() );
  2438. p.drawPoints( a );
  2439. p.end();
  2440. TQApplication::flushX();
  2441. horizontalLine->setMask( *horizontalLine );
  2442. qlv_cleanup_bitmap.add( &verticalLine );
  2443. qlv_cleanup_bitmap.add( &horizontalLine );
  2444. }
  2445. }
  2446. int y = r.y();
  2447. int c;
  2448. TQPointArray dotlines;
  2449. if ( drawDotlines && active == SC_All && controls == SC_ListViewExpand ) {
  2450. c = 2;
  2451. dotlines.resize( 2 );
  2452. dotlines[ 0 ] = TQPoint( r.right(), r.top() );
  2453. dotlines[ 1 ] = TQPoint( r.right(), r.bottom() );
  2454. }
  2455. else {
  2456. int linetop = 0, linebot = 0;
  2457. // each branch needs at most two lines, ie. four end points
  2458. dotoffset = (item->itemPos() + item->height() - y) %2;
  2459. dotlines.resize( item->childCount() * 4 );
  2460. c = 0;
  2461. // skip the stuff above the exposed rectangle
  2462. while ( child && y + child->height() <= 0 ) {
  2463. y += child->totalHeight();
  2464. child = child->nextSibling();
  2465. }
  2466. int bx = r.width() / 2;
  2467. // paint stuff in the magical area
  2468. while ( child && y < r.height() ) {
  2469. int lh;
  2470. if ( !item->multiLinesEnabled() )
  2471. lh = child ? child->height() : 0;
  2472. else
  2473. lh = p->fontMetrics().height() + 2 * v->itemMargin();
  2474. lh = TQMAX( lh, TQApplication::globalStrut().height() );
  2475. if ( lh % 2 > 0 )
  2476. lh++;
  2477. linebot = y + lh / 2;
  2478. if ( ( child->isExpandable() || child->childCount() ) && ( child->height() > 0 ) ) {
  2479. if ( optionHandler->ExpanderStyle() == MS ) { // f****** M$ +/- style :-(
  2480. // needs a box
  2481. p->setPen( optionHandler->DotlineColor() );
  2482. p->drawRect( bx - 4, linebot - 4, 9, 9 );
  2483. // plus or minus
  2484. p->setPen( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() );
  2485. p->drawLine( bx - 2, linebot, bx + 2, linebot );
  2486. if ( !child->isOpen() )
  2487. p->drawLine( bx, linebot - 2, bx, linebot + 2 );
  2488. } else { // ultracool triangles ;-)
  2489. TQPointArray a;
  2490. p->setPen( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() );
  2491. if ( child->isOpen() ) {
  2492. a.setPoints( 3, bx - 4, linebot - 2,
  2493. bx, linebot + 2,
  2494. bx + 4, linebot - 2 );
  2495. } //DownArrow
  2496. else {
  2497. a.setPoints( 3, bx - 2, linebot - 4,
  2498. bx + 2, linebot,
  2499. bx - 2, linebot + 4 );
  2500. } //RightArrow
  2501. p->setBrush( optionHandler->UseCustomExpanderColor() ? optionHandler->CustomExpanderColor() : cg.text() );
  2502. p->drawPolygon( a );
  2503. p->setBrush( NoBrush );
  2504. }
  2505. // dotlinery
  2506. if ( drawDotlines ) {
  2507. dotlines[ c++ ] = TQPoint( bx, linetop );
  2508. dotlines[ c++ ] = TQPoint( bx, linebot - (/* optionHandler->plusMinus() ? 4 : */5 ) );
  2509. dotlines[ c++ ] = TQPoint( bx + 5, linebot );
  2510. dotlines[ c++ ] = TQPoint( r.width(), linebot );
  2511. linetop = linebot + 5;
  2512. }
  2513. } else {
  2514. // just dotlinery
  2515. if ( drawDotlines ) {
  2516. dotlines[ c++ ] = TQPoint( bx + 2, linebot );
  2517. dotlines[ c++ ] = TQPoint( r.width(), linebot );
  2518. }
  2519. }
  2520. y += child->totalHeight();
  2521. child = child->nextSibling();
  2522. }
  2523. // Expand line height to edge of rectangle if there's a
  2524. // child, and it's visible
  2525. if ( child && ( child->height() > 0 ) ) {
  2526. linebot = r.height();
  2527. }
  2528. if ( drawDotlines ) {
  2529. if ( linetop < linebot ) {
  2530. dotlines[ c++ ] = TQPoint( bx, linetop );
  2531. dotlines[ c++ ] = TQPoint( bx, linebot );
  2532. }
  2533. }
  2534. }
  2535. if ( drawDotlines && optionHandler->DotlineStyle() == Line) {
  2536. int line; // index into dotlines
  2537. p->setPen( optionHandler->DotlineColor() );
  2538. if ( controls & SC_ListViewBranch )
  2539. for ( line = 0; line < c; line += 2 ) {
  2540. p->drawLine( dotlines[ line ].x(), dotlines[ line ].y(),
  2541. dotlines[ line + 1 ].x(), dotlines[ line + 1 ].y() );
  2542. }
  2543. }
  2544. else if (drawDotlines && (optionHandler->DotlineStyle() == Dots)) {
  2545. int line; // index into dotlines
  2546. if ( controls & SC_ListViewBranch ){
  2547. p->setPen( optionHandler->DotlineColor() );
  2548. for( line = 0; line < c; line += 2 ) {
  2549. // assumptions here: lines are horizontal or vertical.
  2550. // lines always start with the numerically lowest
  2551. // coordinate.
  2552. // point ... relevant coordinate of current point
  2553. // end ..... same coordinate of the end of the current line
  2554. // other ... the other coordinate of the current point/line
  2555. if ( dotlines[line].y() == dotlines[line+1].y() ) {
  2556. int end = dotlines[line+1].x();
  2557. int point = dotlines[line].x();
  2558. int other = dotlines[line].y();
  2559. while( point < end ) {
  2560. int i = 128;
  2561. if ( i+point > end )
  2562. i = end-point;
  2563. p->drawPixmap( point, other, *horizontalLine, 0, 0, i, 1 );
  2564. point += i;
  2565. }
  2566. }
  2567. else {
  2568. int end = dotlines[line+1].y();
  2569. int point = dotlines[line].y();
  2570. int other = dotlines[line].x();
  2571. int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0;
  2572. while( point < end ) {
  2573. int i = 128;
  2574. if ( i+point > end )
  2575. i = end-point;
  2576. p->drawPixmap( other, point, *verticalLine, 0, pixmapoffset, 1, i );
  2577. point += i;
  2578. }
  2579. }
  2580. }
  2581. }
  2582. }
  2583. }
  2584. break;
  2585. }
  2586. #endif // TQT_NO_LISTVIEW
  2587. #ifndef TQT_NO_TITLEBAR
  2588. case CC_TitleBar:
  2589. {
  2590. switch (optionHandler->style())
  2591. {
  2592. case Jaguar:
  2593. if (!widget->isActiveWindow()) p->drawTiledPixmap(r, *getPixmap( TitleBar ));
  2594. p->setPen(optionHandler->titleColor(1).dark(180));
  2595. p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
  2596. break;
  2597. case Panther:
  2598. case Tiger:
  2599. case Milk:
  2600. {
  2601. if (widget->isActiveWindow()) p->drawTiledPixmap(r, *getPixmap( TitleBar ));
  2602. p->setPen(optionHandler->titleColor(1).dark(180));
  2603. p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
  2604. break;
  2605. }
  2606. case Brushed:
  2607. break;
  2608. }
  2609. if ( controls & SC_TitleBarLabel )
  2610. {
  2611. TQRect ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarLabel, TQStyleOption::Default, widget ), widget );
  2612. p->setPen( cg.text() );
  2613. p->drawText(ir.x()+2, ir.y(), ir.width()-2, ir.height(), AlignCenter | AlignVCenter | SingleLine, widget->caption() );
  2614. }
  2615. TQRect ir;
  2616. bool down = FALSE;
  2617. TQPixmap pm;
  2618. if ( controls & SC_TitleBarCloseButton )
  2619. {
  2620. ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarCloseButton, TQStyleOption::Default, widget ), widget );
  2621. down = active & SC_TitleBarCloseButton;
  2622. if (optionHandler->buttonStyle() == Brushed)
  2623. drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(0).dark(120) : optionHandler->titleButtonColor(0), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
  2624. else
  2625. drawCombo( p, cg, down ? optionHandler->titleButtonColor(0).dark(120) : optionHandler->titleButtonColor(0), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
  2626. }
  2627. if ( controls & SC_TitleBarSysMenu )
  2628. {
  2629. ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarSysMenu, TQStyleOption::Default, widget ), widget );
  2630. down = active & SC_TitleBarSysMenu;
  2631. if (optionHandler->buttonStyle() == Brushed)
  2632. drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
  2633. else
  2634. drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
  2635. }
  2636. if ( controls & SC_TitleBarMaxButton )
  2637. {
  2638. ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarMaxButton, TQStyleOption::Default, widget ), widget );
  2639. down = active & SC_TitleBarMaxButton;
  2640. if (optionHandler->buttonStyle() == Brushed)
  2641. drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(2).dark(120) : optionHandler->titleButtonColor(2), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
  2642. else
  2643. drawCombo( p, cg, down ? optionHandler->titleButtonColor(2).dark(120) : optionHandler->titleButtonColor(2), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
  2644. }
  2645. if ( controls & SC_TitleBarMinButton )
  2646. {
  2647. ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarMinButton, TQStyleOption::Default, widget ), widget );
  2648. down = active & SC_TitleBarMinButton;
  2649. if (optionHandler->buttonStyle() == Brushed)
  2650. drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
  2651. else
  2652. drawCombo( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
  2653. }
  2654. if ( controls & SC_TitleBarNormalButton )
  2655. {
  2656. ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarNormalButton, TQStyleOption::Default, widget ), widget );
  2657. down = active & SC_TitleBarNormalButton;
  2658. if (optionHandler->buttonStyle() == Brushed)
  2659. drawRectangularButton( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
  2660. else
  2661. drawCombo( p, cg, down ? optionHandler->titleButtonColor(1).dark(120) : optionHandler->titleButtonColor(1), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
  2662. }
  2663. if ( controls & SC_TitleBarShadeButton )
  2664. {
  2665. ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarShadeButton, TQStyleOption::Default, widget ), widget );
  2666. down = active & SC_TitleBarShadeButton;
  2667. if (optionHandler->buttonStyle() == Brushed)
  2668. drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
  2669. else
  2670. drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
  2671. }
  2672. if ( controls & SC_TitleBarUnshadeButton )
  2673. {
  2674. ir = visualRect( querySubControlMetrics( CC_TitleBar, ceData, elementFlags, SC_TitleBarUnshadeButton, TQStyleOption::Default, widget ), widget );
  2675. down = active & SC_TitleBarUnshadeButton;
  2676. if (optionHandler->buttonStyle() == Brushed)
  2677. drawRectangularButton( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height(), down, false, false, full);
  2678. else
  2679. drawCombo( p, cg, down ? cg.button().dark(120) : cg.button(), ir.x(), ir.y(), ir.width(), ir.height()+2, down, false, false, full );
  2680. }
  2681. break;
  2682. }
  2683. #endif //TQT_NO_TITLEBAR
  2684. default:
  2685. TDEStyle::drawComplexControl( control, p, ceData, elementFlags,
  2686. r, cg, flags, controls, active, opt, widget );
  2687. break;
  2688. }
  2689. }
  2690. int LiquidStyle::styleHint(StyleHint sh,
  2691. const TQStyleControlElementData &ceData,
  2692. ControlElementFlags elementFlags,
  2693. const TQStyleOption & opt,
  2694. TQStyleHintReturn * shr,
  2695. const TQWidget * w) const
  2696. {
  2697. switch (sh)
  2698. {
  2699. case TQStyle::SH_GUIStyle:
  2700. // if (w && ::tqt_cast<TQMenuBar*>(w))
  2701. // return WindowsStyle;
  2702. return MacStyle;
  2703. case TQStyle::SH_TabBar_Alignment:
  2704. if (optionHandler->CenterTabs() && !TQApplication::reverseLayout())
  2705. return AlignHCenter;
  2706. else
  2707. return TDEStyle::styleHint(sh, ceData, elementFlags, opt, shr, w);
  2708. default:
  2709. return TDEStyle::styleHint(sh, ceData, elementFlags, opt, shr, w);
  2710. }
  2711. }
  2712. TQRect LiquidStyle::subRect( SubRect r,
  2713. const TQStyleControlElementData &ceData,
  2714. ControlElementFlags elementFlags,
  2715. const TQWidget *widget ) const {
  2716. if (r == SR_ComboBoxFocusRect){
  2717. return querySubControlMetrics( CC_ComboBox, ceData, elementFlags, SC_ComboBoxEditField, TQStyleOption::Default, widget );
  2718. }
  2719. return ( TDEStyle::subRect( r, ceData, elementFlags, widget ) );
  2720. }
  2721. int LiquidStyle::pixelMetric( PixelMetric m,
  2722. const TQStyleControlElementData &ceData,
  2723. ControlElementFlags elementFlags,
  2724. const TQWidget *widget ) const
  2725. {
  2726. switch ( m )
  2727. {
  2728. case PM_ButtonMargin:
  2729. return ( 5 );
  2730. case PM_ButtonDefaultIndicator:
  2731. return ( 0 );
  2732. case PM_ExclusiveIndicatorWidth:
  2733. case PM_ExclusiveIndicatorHeight:
  2734. return ( 16 );
  2735. case PM_IndicatorWidth:
  2736. case PM_IndicatorHeight:
  2737. return ( 16 );
  2738. case PM_ScrollBarExtent:
  2739. return ( 15 );
  2740. case PM_ScrollBarSliderMin:
  2741. if (isOOO) return 10; return ( 40 );
  2742. case PM_SplitterWidth:
  2743. return 6;
  2744. case PM_SliderControlThickness:
  2745. return(15);
  2746. case PM_SliderThickness:
  2747. return ( 22 );
  2748. /* if (widget && (widget->width() < widget->height() && widget->width() < 17) || (widget->width() > widget->height() && widget->height() < 17))
  2749. return (16);*/
  2750. case PM_SliderLength:
  2751. return ( optionHandler->style() == Milk ? 15 : 13 );
  2752. case PM_TabBarTabOverlap:
  2753. return 0;
  2754. case PM_DefaultFrameWidth:
  2755. {
  2756. /*
  2757. if (widget && ::tqt_cast<TQFrame*>(widget) && ((TQFrame*)widget)->frameShape() == TQFrame::LineEditPanel)
  2758. return 6;*/
  2759. if (widget && widget->parentWidget() && ::tqt_cast<TQTabWidget*>(widget->parentWidget()) && widget->parentWidget()->parentWidget() && (widget->parentWidget()->parentWidget()->inherits("KonqMainWindow") || widget->parentWidget()->parentWidget()->inherits("KonqFrameContainer"))) //for the konqueror statusbar offset, thanks konqueror team... ... ... f***f***f***!!!
  2760. return 0;
  2761. return 2;
  2762. }
  2763. case PM_TabBarBaseOverlap:
  2764. case PM_TabBarBaseHeight:
  2765. {
  2766. if (!widget || !::tqt_cast<TQTabWidget*>(widget) || !widget->children())
  2767. return 0;
  2768. TQObjectListIt it( *widget->children() ); // iterate over the buttons
  2769. TQObject *obj;
  2770. TQTabBar *tabBar = 0L;
  2771. while ( (obj = it.current()) != 0 )
  2772. {
  2773. ++it;
  2774. if (::tqt_cast<TQTabBar*>(obj))
  2775. {
  2776. tabBar = (TQTabBar*)obj;
  2777. break;
  2778. }
  2779. }
  2780. if (!tabBar || !tabBar->isVisible())
  2781. return 0;
  2782. if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("TQDialog")))
  2783. return 12;
  2784. if (m == PM_TabBarBaseOverlap)
  2785. return 2;
  2786. return 7;
  2787. }
  2788. case PM_TabBarTabHSpace:
  2789. if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("TQDialog"))) return 18;
  2790. return 24;
  2791. case PM_TabBarTabVSpace:
  2792. {
  2793. if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("TQDialog"))) return 6;
  2794. return 10;
  2795. }
  2796. case PM_TabBarTabShiftHorizontal:
  2797. return 0;
  2798. case PM_TabBarTabShiftVertical:
  2799. if (optionHandler->TabStyle() == Chooser || (optionHandler->TabStyle() == Clever && widget && widget->topLevelWidget()->inherits("TQDialog"))) return 0;
  2800. return 2;
  2801. case PM_ButtonShiftHorizontal:
  2802. return 0;
  2803. case PM_ButtonShiftVertical:
  2804. return 0;
  2805. default:
  2806. return TDEStyle::pixelMetric( m, ceData, elementFlags, widget );
  2807. }
  2808. }
  2809. TQSize LiquidStyle::sizeFromContents( ContentsType contents,
  2810. const TQStyleControlElementData &ceData,
  2811. ControlElementFlags elementFlags,
  2812. const TQSize &contentSize,
  2813. const TQStyleOption& opt,
  2814. const TQWidget *widget ) const {
  2815. switch ( contents ) {
  2816. case CT_PushButton: {
  2817. // this is a little funky - we give values not based on pixelMetric
  2818. // because we want a custom width/height and we can only give one
  2819. // value in pixelMetric (used in sizeHint). Odd but works well
  2820. const TQPushButton * button = ( const TQPushButton* ) widget;
  2821. int w = contentSize.width() + 26 > 80 ? contentSize.width() + 26 : 80;
  2822. int h = contentSize.height() > 24 ? contentSize.height() : 25;
  2823. if ( button->text().isEmpty() )
  2824. return ( TQSize( contentSize.width() + 2 * pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ), h ) );
  2825. return ( TQSize( w, h ) );
  2826. }
  2827. case CT_ToolButton: {
  2828. if (widget->parentWidget() && ::tqt_cast<TQTabWidget*>(widget->parentWidget())){
  2829. return TQSize(contentSize.width() + 6, contentSize.height() + 5);
  2830. }
  2831. else{
  2832. int w = contentSize.width() + 6;
  2833. int sh = contentSize.height() + 5;
  2834. int sw = (int)(1.3*sh);
  2835. if (w < sw)
  2836. return TQSize(sw, sh);
  2837. else
  2838. return TQSize(w, sh);
  2839. }
  2840. }
  2841. case CT_Slider: {
  2842. int h = contentSize.height() > 24 ? contentSize.height() : 24;
  2843. return ( TQSize( contentSize.width(), h ) );
  2844. }
  2845. case CT_ComboBox: {
  2846. // TQSize sz = TDEStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget );
  2847. // return ( TQSize( sz.width()+3, sz.height() > 25 ? sz.height() : 25 ) );
  2848. if ( ::tqt_cast<const TQComboBox *>(widget) && ((const TQComboBox *)widget)->editable())
  2849. return ( TQSize( contentSize.width()+27, contentSize.height() + 4 > 22 ? contentSize.height() + 4 : 26 ) );
  2850. else
  2851. return ( TQSize( contentSize.width()+27, contentSize.height() + 2 > 24 ? contentSize.height() + 2 : 24 ) );
  2852. }
  2853. case CT_PopupMenuItem: {
  2854. if ( ! widget || opt.isDefault() )
  2855. break;
  2856. const TQPopupMenu *popup = ( const TQPopupMenu * ) widget;
  2857. bool checkable = popup->isCheckable();
  2858. TQMenuItem *mi = opt.menuItem();
  2859. int maxpmw = opt.maxIconWidth();
  2860. int w = contentSize.width();
  2861. int h = contentSize.height();
  2862. if ( mi->custom() ) {
  2863. w = mi->custom() ->sizeHint().width();
  2864. h = mi->custom() ->sizeHint().height();
  2865. if ( !mi->custom() ->fullSpan() )
  2866. h += 2 * windowsItemVMargin + 2 * windowsItemFrame;
  2867. } else if ( mi->widget() ) {}
  2868. else if ( mi->isSeparator() ) {
  2869. w = 10;
  2870. h = windowsSepHeight;
  2871. } else {
  2872. if ( mi->pixmap() )
  2873. h = TQMAX( h, mi->pixmap() ->height() + 2 * windowsItemFrame );
  2874. else if ( ! mi->text().isNull() )
  2875. h = TQMAX( h, popup->fontMetrics().height() + 2 * windowsItemVMargin +
  2876. 2 * windowsItemFrame );
  2877. if ( mi->iconSet() != 0 )
  2878. h = TQMAX( h, mi->iconSet() ->pixmap( TQIconSet::Small,
  2879. TQIconSet::Normal ).height() +
  2880. 2 * windowsItemFrame );
  2881. }
  2882. if ( !mi->text().isNull() && mi->text().find( '\t' ) >= 0 )
  2883. w += windowsTabSpacing;
  2884. else if ( mi->popup() )
  2885. w += 2 * windowsArrowHMargin;
  2886. if ( checkable && maxpmw < 20 )
  2887. w += 20 - maxpmw;
  2888. if ( maxpmw )
  2889. w += maxpmw + 6;
  2890. if ( checkable || maxpmw > 0 )
  2891. w += windowsCheckMarkHMargin;
  2892. w += 20;
  2893. return ( TQSize( w, h ) );
  2894. }
  2895. default:
  2896. break;
  2897. }
  2898. return TDEStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget );
  2899. }
  2900. TQPixmap LiquidStyle::stylePixmap( StylePixmap stylepixmap,
  2901. const TQStyleControlElementData &ceData,
  2902. ControlElementFlags elementFlags,
  2903. const TQStyleOption& opt,
  2904. const TQWidget* widget ) const {
  2905. return TDEStyle::stylePixmap( stylepixmap, ceData, elementFlags, opt, widget );
  2906. }
  2907. #include "eventfilter.cpp"
  2908. TQRect LiquidStyle::querySubControlMetrics( ComplexControl control,
  2909. const TQStyleControlElementData &ceData,
  2910. ControlElementFlags elementFlags,
  2911. SubControl subcontrol,
  2912. const TQStyleOption &opt,
  2913. const TQWidget *widget ) const
  2914. {
  2915. if ( control == CC_ComboBox && subcontrol == SC_ComboBoxEditField )
  2916. return TQRect( 8, 3, widget->width() - 32, widget->height() - 7 );
  2917. if (control == CC_TitleBar)
  2918. {
  2919. switch (subcontrol)
  2920. {
  2921. case SC_TitleBarSysMenu:
  2922. return TQRect( widget->width() - 24, 1, 16, 16 );
  2923. case SC_TitleBarMinButton:
  2924. return TQRect( 26, 1, 16, 16 );
  2925. case SC_TitleBarMaxButton:
  2926. return TQRect( 47, 1, 16, 16 );
  2927. case SC_TitleBarCloseButton:
  2928. return TQRect( 5, 1, 16, 16 );
  2929. case SC_TitleBarLabel:
  2930. return TQRect( 68, 1, widget->width() - 107, 16 );
  2931. case SC_TitleBarNormalButton:
  2932. return TQRect( 26, 1, 16, 16 );
  2933. case SC_TitleBarShadeButton:
  2934. return TQRect( widget->width() - 29, 1, 24, 16 );
  2935. case SC_TitleBarUnshadeButton:
  2936. return TQRect( widget->width() - 29, 1, 24, 16 );
  2937. default:
  2938. return ( TDEStyle::querySubControlMetrics( control, ceData, elementFlags, subcontrol, opt, widget ) );
  2939. }
  2940. }
  2941. else
  2942. return ( TDEStyle::querySubControlMetrics( control, ceData, elementFlags, subcontrol, opt, widget ) );
  2943. }
  2944. TQImage LiquidStyle::fetchImage( const char *name ){
  2945. return uic_findImage( name );
  2946. }
  2947. TQColor LiquidStyle::mapFadeColor(TQColor &color, int index) const
  2948. {
  2949. TQRgb **rgb = fadeColorMap.find(color.rgb());
  2950. if (rgb)
  2951. return TQColor((*rgb)[index]);
  2952. // no color map found, create one and return the queried value
  2953. rgb = new TQRgb*;
  2954. *rgb = new TQRgb[10];
  2955. int iRed = optionHandler->InactiveButtonColor().red();
  2956. int iGreen = optionHandler->InactiveButtonColor().green();
  2957. int iBlue = optionHandler->InactiveButtonColor().blue();
  2958. int cRed = color.red();
  2959. int cGreen = color.green();
  2960. int cBlue = color.blue();
  2961. for (int i = 10; i < 20; i++)
  2962. {
  2963. (*rgb)[i-10] = tqRgb( iRed + (cRed-iRed)*(i)/20, iGreen + (cGreen-iGreen)*(i)/20, iBlue + (cBlue-iBlue)*(i)/20);
  2964. }
  2965. LiquidStyle *ptr = const_cast<LiquidStyle*>( this );
  2966. ptr->fadeColorMap.insert(color.rgb(), rgb);
  2967. return TQColor((*rgb)[index]);
  2968. }
  2969. TQPixmap* LiquidStyle::processEmbedded( const char *label, const TQColor &c, bool blend, const TQColor *bg ) const {
  2970. TQImage img( uic_findImage( label ) );
  2971. img.detach();
  2972. if ( img.isNull() ) { // shouldn't happen, been tested
  2973. tqWarning( "Invalid embedded label %s", label );
  2974. return ( NULL );
  2975. }
  2976. return ( adjustHSV( img, c, bg ) );
  2977. }
  2978. TQPixmap* LiquidStyle::getPixmap( BitmapData item ) const
  2979. {
  2980. if ( pixmaps[ item ] )
  2981. return ( pixmaps[ item ] );
  2982. TQColor bgColor( optionHandler->InactiveButtonColor() );
  2983. TQColor btnColor( isOOO ? optionHandler->CustomButtonColor() : tqApp->palette().active().button() );
  2984. TQColor btnHoverColor( isOOO ? optionHandler->CustomButtonColor().light(120) : btnColor.light( 120 ) );
  2985. TQColor sbGrooveColor( optionHandler->useCustomColors() ?
  2986. optionHandler->customColor( CustomSBGroove ) : bgColor );
  2987. TQColor sbSliderColor( optionHandler->useCustomColors() ?
  2988. optionHandler->customColor( CustomSBSlider ) : bgColor );
  2989. TQColor sbSliderHoverColor( optionHandler->useCustomColors() ?
  2990. optionHandler->customColor( CustomSBSliderHover ) : isOOO?optionHandler->CustomButtonColor():btnColor );
  2991. TQColor sbSliderPressedColor( optionHandler->useCustomColors() ?
  2992. optionHandler->customColor( CustomSBSliderPressed ) : btnColor.dark(110) );
  2993. LiquidStyle *ptr = const_cast<LiquidStyle*>( this );
  2994. switch ( item )
  2995. {
  2996. case RadioOn:
  2997. ptr->pixmaps[ RadioOn ] = processEmbedded( (optionHandler->style() == Milk) ? "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ) : btnColor, true );
  2998. break;
  2999. case RadioOff:
  3000. ptr->pixmaps[ RadioOff ] = processEmbedded( (optionHandler->style() == Milk) ? "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOff ) : bgColor, true );
  3001. break;
  3002. case RadioOnHover:
  3003. ptr->pixmaps[ RadioOnHover ] = processEmbedded( (optionHandler->style() == Milk) ? "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).light( 110 ) : btnHoverColor, true );
  3004. break;
  3005. case RadioOffHover:
  3006. ptr->pixmaps[ RadioOffHover ] = processEmbedded( (optionHandler->style() == Milk) ? "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ) : btnColor, true );
  3007. case RadioOnPressed:
  3008. ptr->pixmaps[ RadioOnPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "radio_down-milk" : "radio_down", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true );
  3009. break;
  3010. case RadioOffPressed:
  3011. ptr->pixmaps[ RadioOffPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "radio-milk" : "radio", optionHandler->useCustomColors() ? optionHandler->customColor( CustomRadioOn ).dark( 120 ) : btnColor.dark( 120 ), true );
  3012. break;
  3013. case Tab:
  3014. ptr->pixmaps[ Tab ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOff ) : optionHandler->InactiveButtonColor(), true );
  3015. break;
  3016. case belowTab:
  3017. ptr->pixmaps[ belowTab ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOff ) : optionHandler->InactiveButtonColor(), true );
  3018. *ptr->pixmaps[ belowTab ] = ptr->pixmaps[ belowTab ] ->xForm( iMatrix );
  3019. break;
  3020. case TabDown:
  3021. ptr->pixmaps[ TabDown ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ) : btnColor, true );
  3022. break;
  3023. case belowTabDown:
  3024. ptr->pixmaps[ belowTabDown ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ) : btnColor, true );
  3025. *ptr->pixmaps[ belowTabDown ] = ptr->pixmaps[ belowTabDown ] ->xForm( iMatrix );
  3026. break;
  3027. case TabFocus:
  3028. ptr->pixmaps[ TabFocus ] = processEmbedded( (optionHandler->style() == Jaguar) ? "tab-jaguar" : (optionHandler->style() == Milk) ? "tab-milk" : "tab", optionHandler->useCustomColors() ? optionHandler->customColor( CustomTabOn ).light( 120 ) : btnHoverColor, true );
  3029. break;
  3030. case CB:
  3031. ptr->pixmaps[ CB ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOff ) : bgColor, true );
  3032. break;
  3033. case CBDown:
  3034. ptr->pixmaps[ CBDown ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true );
  3035. break;
  3036. case CBDownHover:
  3037. ptr->pixmaps[ CBDownHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).light( 110 ) : btnHoverColor, true );
  3038. break;
  3039. case CBTri:
  3040. ptr->pixmaps[ CBTri ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true );
  3041. *ptr->pixmaps[ CBTri ] = ptr->pixmaps[ CBTri ] ->xForm( mMatrix );
  3042. break;
  3043. case CBTriHover:
  3044. ptr->pixmaps[ CBTriHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).light( 110 ) : btnHoverColor, true );
  3045. *ptr->pixmaps[ CBTriHover ] = ptr->pixmaps[ CBTriHover ] ->xForm( mMatrix );
  3046. break;
  3047. case CBHover:
  3048. ptr->pixmaps[ CBHover ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ) : btnColor, true );
  3049. break;
  3050. case CBDownPressed:
  3051. ptr->pixmaps[ CBDownPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true );
  3052. break;
  3053. case CBTriPressed:
  3054. ptr->pixmaps[ CBTriPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkboxdown-milk" : "checkboxdown", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnHoverColor.dark( 120 ), true );
  3055. *ptr->pixmaps[ CBTriPressed ] = ptr->pixmaps[ CBTriPressed ] ->xForm( mMatrix );
  3056. break;
  3057. case CBPressed:
  3058. ptr->pixmaps[ CBPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "checkbox-milk" : "checkbox", optionHandler->useCustomColors() ? optionHandler->customColor( CustomCBOn ).dark( 120 ) : btnColor.dark( 120 ), true );
  3059. break;
  3060. case HSlider:
  3061. ptr->pixmaps[ HSlider ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true );
  3062. break;
  3063. case VSlider:
  3064. ptr->pixmaps[ VSlider ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true );
  3065. *ptr->pixmaps[ VSlider ] = ptr->pixmaps[ VSlider ] ->xForm( lMatrix );
  3066. break;
  3067. case VSliderAbove:
  3068. ptr->pixmaps[ VSliderAbove ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", btnColor, true );
  3069. *ptr->pixmaps[ VSliderAbove ] = ptr->pixmaps[ VSliderAbove ] ->xForm( rMatrix );
  3070. break;
  3071. case HSliderInactive:
  3072. ptr->pixmaps[ HSliderInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true );
  3073. break;
  3074. case VSliderInactive:
  3075. ptr->pixmaps[ VSliderInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true );
  3076. *ptr->pixmaps[ VSliderInactive ] = ptr->pixmaps[ VSliderInactive ] ->xForm( lMatrix );
  3077. break;
  3078. case VSliderAboveInactive:
  3079. ptr->pixmaps[ VSliderAboveInactive ] = processEmbedded( (optionHandler->style() == Milk) ? "sliderarrow-milk" : "sliderarrow", bgColor, true );
  3080. *ptr->pixmaps[ VSliderAboveInactive ] = ptr->pixmaps[ VSliderAboveInactive ] ->xForm( rMatrix );
  3081. break;
  3082. case VSBSliderTop:
  3083. ptr->pixmaps[ VSBSliderTop ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderColor, true, &sbGrooveColor );
  3084. break;
  3085. case VSBSliderBtm:
  3086. ptr->pixmaps[ VSBSliderBtm ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderColor, true, &sbGrooveColor );
  3087. break;
  3088. case VSBSliderMid:
  3089. ptr->pixmaps[ VSBSliderMid ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbIslider_mid", sbSliderColor, &sbGrooveColor );
  3090. break;
  3091. case VSBSliderTopActive:
  3092. ptr->pixmaps[ VSBSliderTopActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderHoverColor, true, &sbGrooveColor );
  3093. break;
  3094. case VSBSliderBtmActive:
  3095. ptr->pixmaps[ VSBSliderBtmActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderHoverColor, true, &sbGrooveColor );
  3096. break;
  3097. case VSBSliderMidActive:
  3098. ptr->pixmaps[ VSBSliderMidActive ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderHoverColor, false, &sbGrooveColor );
  3099. break;
  3100. case VSBSliderTopPressed:
  3101. ptr->pixmaps[ VSBSliderTopPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderPressedColor, true, &sbGrooveColor );
  3102. *ptr->pixmaps[ VSBSliderTopPressed ] = ptr->pixmaps[ VSBSliderTopPressed ] ->xForm( mMatrix );
  3103. break;
  3104. case VSBSliderBtmPressed:
  3105. ptr->pixmaps[ VSBSliderBtmPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderPressedColor, true, &sbGrooveColor );
  3106. *ptr->pixmaps[ VSBSliderBtmPressed ] = ptr->pixmaps[ VSBSliderBtmPressed ] ->xForm( mMatrix );
  3107. break;
  3108. case VSBSliderMidPressed:
  3109. ptr->pixmaps[ VSBSliderMidPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderPressedColor, false, &sbGrooveColor );
  3110. if (optionHandler->style() == Milk)
  3111. *ptr->pixmaps[ VSBSliderMidPressed ] = ptr->pixmaps[ VSBSliderMidPressed ] ->xForm( iMatrix );
  3112. break;
  3113. case HSBSliderTop:
  3114. ptr->pixmaps[ HSBSliderTop ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderColor, true, &sbGrooveColor );
  3115. *ptr->pixmaps[ HSBSliderTop ] = ptr->pixmaps[ HSBSliderTop ]->xForm( rMatrix );
  3116. break;
  3117. case HSBSliderBtm:
  3118. ptr->pixmaps[ HSBSliderBtm ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderColor, true, &sbGrooveColor );
  3119. *ptr->pixmaps[ HSBSliderBtm ] = ptr->pixmaps[ HSBSliderBtm ] ->xForm( rMatrix );
  3120. break;
  3121. case HSBSliderMid:
  3122. ptr->pixmaps[ HSBSliderMid ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbIslider_mid", sbSliderColor, false, &sbGrooveColor );
  3123. *ptr->pixmaps[ HSBSliderMid ] = ptr->pixmaps[ HSBSliderMid ]->xForm( rMatrix );
  3124. break;
  3125. case HSBSliderTopActive:
  3126. ptr->pixmaps[ HSBSliderTopActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), true) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderHoverColor, true, &sbGrooveColor );
  3127. *ptr->pixmaps[ HSBSliderTopActive ] = ptr->pixmaps[ HSBSliderTopActive ] ->xForm( rMatrix );
  3128. break;
  3129. case HSBSliderBtmActive:
  3130. ptr->pixmaps[ HSBSliderBtmActive ] = optionHandler->shadowSbSlider() ? createSliderEnd( sbSliderHoverColor, sbGrooveColor.dark( 120 ), false) : processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderHoverColor, true, &sbGrooveColor );
  3131. *ptr->pixmaps[ HSBSliderBtmActive ] = ptr->pixmaps[ HSBSliderBtmActive ] ->xForm( rMatrix );
  3132. break;
  3133. case HSBSliderMidActive:
  3134. ptr->pixmaps[ HSBSliderMidActive ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderHoverColor, false, &sbGrooveColor );
  3135. *ptr->pixmaps[ HSBSliderMidActive ] = ptr->pixmaps[ HSBSliderMidActive ] ->xForm( rMatrix );
  3136. break;
  3137. case HSBSliderTopPressed:
  3138. ptr->pixmaps[ HSBSliderTopPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_top-milk" : "sbslider_top", sbSliderPressedColor, true, &sbGrooveColor );
  3139. *ptr->pixmaps[ HSBSliderTopPressed ] = ptr->pixmaps[ HSBSliderTopPressed ] ->xForm( mMatrix );
  3140. *ptr->pixmaps[ HSBSliderTopPressed ] = ptr->pixmaps[ HSBSliderTopPressed ] ->xForm( rMatrix );
  3141. break;
  3142. case HSBSliderBtmPressed:
  3143. ptr->pixmaps[ HSBSliderBtmPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_btm-milk" : "sbslider_btm", sbSliderPressedColor, true, &sbGrooveColor );
  3144. *ptr->pixmaps[ HSBSliderBtmPressed ] = ptr->pixmaps[ HSBSliderBtmPressed ] ->xForm( mMatrix );
  3145. *ptr->pixmaps[ HSBSliderBtmPressed ] = ptr->pixmaps[ HSBSliderBtmPressed ] ->xForm( rMatrix );
  3146. break;
  3147. case HSBSliderMidPressed:
  3148. ptr->pixmaps[ HSBSliderMidPressed ] = processEmbedded( (optionHandler->style() == Milk) ? "sbslider_mid-milk" : "sbslider_mid", sbSliderPressedColor, false, &sbGrooveColor );
  3149. if (optionHandler->style() == Milk)
  3150. *ptr->pixmaps[ HSBSliderMidPressed ] = ptr->pixmaps[ HSBSliderMidPressed ] ->xForm( lMatrix );
  3151. else
  3152. *ptr->pixmaps[ HSBSliderMidPressed ] = ptr->pixmaps[ HSBSliderMidPressed ] ->xForm( rMatrix );
  3153. break;
  3154. case VSBSliderTopBg:
  3155. ptr->pixmaps[ VSBSliderTopBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_top-milk" : "sbgroove_top", sbGrooveColor, true, &sbGrooveColor );
  3156. break;
  3157. case VSBSliderBtmBg:
  3158. ptr->pixmaps[ VSBSliderBtmBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_btm-milk" : "sbgroove_btm", sbGrooveColor, true, &sbGrooveColor );
  3159. break;
  3160. case VSBSliderMidBg:
  3161. ptr->pixmaps[ VSBSliderMidBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_mid-milk" : "sbgroove_mid", sbGrooveColor, false, &sbGrooveColor );
  3162. break;
  3163. case VSBSliderMidBgI:
  3164. ptr->pixmaps[ VSBSliderMidBgI ] = processEmbedded( (optionHandler->style() == Milk) ? "sb_subadd-milk" : "sb_subadd", sbGrooveColor, false, &sbGrooveColor );
  3165. break;
  3166. case HSBSliderTopBg:
  3167. ptr->pixmaps[ HSBSliderTopBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_top-milk" : "sbgroove_top", sbGrooveColor, true, &sbGrooveColor );
  3168. *ptr->pixmaps[ HSBSliderTopBg ] = ptr->pixmaps[ HSBSliderTopBg ] ->xForm( rMatrix );
  3169. break;
  3170. case HSBSliderBtmBg:
  3171. ptr->pixmaps[ HSBSliderBtmBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_btm-milk" : "sbgroove_btm", sbGrooveColor, true, &sbGrooveColor );
  3172. *ptr->pixmaps[ HSBSliderBtmBg ] = ptr->pixmaps[ HSBSliderBtmBg ] ->xForm( rMatrix );
  3173. break;
  3174. case HSBSliderMidBg:
  3175. ptr->pixmaps[ HSBSliderMidBg ] = processEmbedded( (optionHandler->style() == Milk) ? "sbgroove_mid-milk" : "sbgroove_mid", sbGrooveColor, false, &sbGrooveColor );
  3176. *ptr->pixmaps[ HSBSliderMidBg ] = ptr->pixmaps[ HSBSliderMidBg ] ->xForm( rMatrix );
  3177. break;
  3178. case HSBSliderMidBgI:
  3179. ptr->pixmaps[ HSBSliderMidBgI ] = processEmbedded( (optionHandler->style() == Milk) ? "sb_subadd-milk" : "sb_subadd", sbGrooveColor, false, &sbGrooveColor );
  3180. *ptr->pixmaps[ HSBSliderMidBgI ] = ptr->pixmaps[ HSBSliderMidBgI ] ->xForm( rMatrix );
  3181. break;
  3182. case Progress:
  3183. ptr->pixmaps[ Progress ] = processEmbedded( "progress", btnColor );
  3184. break;
  3185. case progress2:
  3186. ptr->pixmaps[ progress2 ] = processEmbedded( "progress2", btnColor );
  3187. break;
  3188. case TitleBar:
  3189. {
  3190. if (optionHandler->style() == Jaguar)
  3191. {
  3192. ptr->pixmaps[ TitleBar ] = new TQPixmap(32,22);
  3193. ptr->pixmaps[ TitleBar ]->fill( optionHandler->titleColor(0) );
  3194. TQPainter p;
  3195. p.begin( ptr->pixmaps[ TitleBar ] );
  3196. p.setPen( TQColor(
  3197. (optionHandler->titleColor(0).red()+optionHandler->titleColor(1).red())/2,
  3198. (optionHandler->titleColor(0).green()+optionHandler->titleColor(1).green())/2,
  3199. (optionHandler->titleColor(0).blue()+optionHandler->titleColor(1).blue())/2 ));
  3200. for ( int i = 1; i < 22; i += 4 )
  3201. {
  3202. p.drawLine( 0, i, 31, i );
  3203. p.drawLine( 0, i+2, 31, i+2 );
  3204. }
  3205. p.setPen( optionHandler->titleColor(1));
  3206. for ( int i = 2; i < 22; i += 4 )
  3207. p.drawLine( 0, i, 31, i );
  3208. p.end();
  3209. }
  3210. else
  3211. ptr->pixmaps[ TitleBar ] = &KPixmapEffect::gradient (*((KPixmap*)(new TQPixmap(32,22))), optionHandler->titleColor(0), optionHandler->titleColor(1), KPixmapEffect::VerticalGradient, 22);
  3212. break;
  3213. }
  3214. default:
  3215. break;
  3216. }
  3217. return ( pixmaps[ item ] );
  3218. }
  3219. #include "baghira.moc"