Browse Source

Do not use direct widget access when drawing tabs and popup menus

tags/r14.0.0
Timothy Pearson 6 years ago
parent
commit
dc6c9f70cf
1 changed files with 19 additions and 28 deletions
  1. 19
    28
      style/qtcurve.cpp

+ 19
- 28
style/qtcurve.cpp View File

@@ -4525,22 +4525,21 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
4525 4525
     {
4526 4526
         case CE_TabBarTab:
4527 4527
         {
4528
-            const TQTabBar *tb((const TQTabBar *)widget);
4529
-            int           tabIndex(tb->indexOf(data.tab()->identifier())),
4528
+            int           tabIndex(ceData.tabBarData.identIndexMap[data.tab()->identifier()]),
4530 4529
                           dark(APPEARANCE_FLAT==opts.appearance ? ORIGINAL_SHADE : FRAME_DARK_SHADOW),
4531 4530
                           moOffset(ROUNDED_NONE==opts.round || TAB_MO_TOP!=opts.tabMouseOver ? 1 : opts.round);
4532 4531
             bool          cornerWidget(false),
4533 4532
                           bottomCornerWidget(false),
4534 4533
                           reverse(TQApplication::reverseLayout()),
4535 4534
                           firstTab(0==tabIndex),
4536
-                          lastTab((tb->count()-1)==tabIndex),
4535
+                          lastTab((ceData.tabBarData.tabCount-1)==tabIndex),
4537 4536
 //                           isFirstKTabCtlTab(firstTab && widget->parent()
4538 4537
 //                                          ? 0==qstrcmp("KTabCtl", widget->parent()->className())
4539 4538
 //                                          : false),
4540 4539
                           active(flags & Style_Selected),
4541 4540
                           itsHover(itsHoverTab && itsHoverTab->isEnabled() && data.tab()==itsHoverTab &&
4542 4541
                                           !(flags&Style_Selected) &&
4543
-                                          tb->currentTab()!=tabIndex),
4542
+                                          ceData.tabBarData.currentTabIndex!=tabIndex),
4544 4543
                           glowMo(!active && itsHover && opts.coloredMouseOver && TAB_MO_GLOW==opts.tabMouseOver);
4545 4544
             int           sizeAdjust(!active && TAB_MO_GLOW==opts.tabMouseOver ? 1 : 0);
4546 4545
             const TQColor  &fill(getTabFill(flags&Style_Selected, itsHover, itsBackgroundCols));
@@ -4560,19 +4559,15 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
4560 4559
                 firstTab=oldLast;
4561 4560
             }
4562 4561
 
4563
-            if(::tqqt_cast<const TQTabWidget *>(tb->parent()))
4564
-            {
4565
-                const TQTabWidget *tw((const TQTabWidget*)tb->parent());
4566
-
4567
-                // is there a corner widget in the (top) left edge?
4568
-                if(tw->cornerWidget(TQt::TopLeft))
4569
-                    cornerWidget=true;
4570
-                if(tw->cornerWidget(TQt::BottomLeft))
4571
-                    bottomCornerWidget=true;
4562
+            if (!ceData.tabBarData.cornerWidgets[TQStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes.isEmpty()) {
4563
+                cornerWidget=true;
4564
+            }
4565
+            if (!ceData.tabBarData.cornerWidgets[TQStyleControlElementTabBarData::CWL_BottomLeft].widgetObjectTypes.isEmpty()) {
4566
+                bottomCornerWidget=true;
4572 4567
             }
4573 4568
 
4574 4569
             TQRect tr(r);
4575
-            bool  top(TQTabBar::TriangularAbove==tb->shape() || TQTabBar::RoundedAbove==tb->shape());
4570
+            bool  top(TQTabBar::TriangularAbove==ceData.tabBarData.shape || TQTabBar::RoundedAbove==ceData.tabBarData.shape);
4576 4571
 
4577 4572
             if(active && opts.tabBgnd)
4578 4573
             {
@@ -4773,13 +4768,13 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
4773 4768
             TQRect         tr(r);
4774 4769
             int           shift(pixelMetric(PM_TabBarTabShiftVertical, ceData, elementFlags, tb));
4775 4770
 
4776
-            if (t->identifier() == tb->currentTab())
4771
+            if (t->identifier() == ceData.tabBarData.currentTabIndex)
4777 4772
             {
4778
-                if(TQTabBar::RoundedAbove==tb->shape() || TQTabBar::TriangularAbove==tb->shape())
4773
+                if(TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape)
4779 4774
                     tr.addCoords(0, -shift, 0, -shift);
4780 4775
             }
4781 4776
             else
4782
-                if(TQTabBar::RoundedBelow==tb->shape() || TQTabBar::TriangularBelow==tb->shape())
4777
+                if(TQTabBar::RoundedBelow==ceData.tabBarData.shape || TQTabBar::TriangularBelow==ceData.tabBarData.shape)
4783 4778
                     tr.addCoords(0, shift, 0, shift);
4784 4779
 
4785 4780
             if(APP_MACTOR==itsThemedApp)
@@ -4788,7 +4783,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
4788 4783
 
4789 4784
                 if(t->iconSet())
4790 4785
                 {
4791
-                    TQIconSet::Mode mode((t->isEnabled() && tb->isEnabled())
4786
+                    TQIconSet::Mode mode((t->isEnabled() && (elementFlags & CEF_IsEnabled))
4792 4787
                                             ? TQIconSet::Normal : TQIconSet::Disabled);
4793 4788
 
4794 4789
                     if (mode == TQIconSet::Normal && (flags&Style_HasFocus))
@@ -4815,7 +4810,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
4815 4810
             {
4816 4811
                 TQRect fr(r);
4817 4812
 
4818
-                if(TQTabBar::RoundedAbove==tb->shape() || TQTabBar::TriangularAbove==tb->shape())
4813
+                if(TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape)
4819 4814
                     fr.addCoords(0, 1, 0, -1);
4820 4815
                 else
4821 4816
                     fr.addCoords(0, 0, 0, -1);
@@ -4942,7 +4937,6 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
4942 4937
             if(!widget || data.isDefault())
4943 4938
                 break;
4944 4939
 
4945
-            const TQPopupMenu *popupmenu((const TQPopupMenu *)widget);
4946 4940
             TQMenuItem        *mi(data.menuItem());
4947 4941
             int              tab(data.tabWidth()),
4948 4942
                              maxpmw(data.maxIconWidth()),
@@ -5015,7 +5009,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
5015 5009
 
5016 5010
                 // Do we have an icon and are checked at the same time?
5017 5011
                 // Then draw a "pressed" background behind the icon
5018
-                if(popupmenu->isCheckable() && mi->isChecked())
5012
+                if((elementFlags & CEF_IsCheckable) && mi->isChecked())
5019 5013
                     drawLightBevel((flags & Style_Active)&&(flags & Style_Enabled)
5020 5014
                                     ? itsHighlightCols[ORIGINAL_SHADE]
5021 5015
                                     : cg.background(), p, TQRect(cr.x()+1, cr.y()+2, cr.width()-2, cr.height()-4),
@@ -5030,7 +5024,7 @@ void QtCurveStyle::drawControl(ControlElement control, TQPainter *p, TQStyleCont
5030 5024
                 pmr.moveCenter(cr.center());
5031 5025
                 p->drawPixmap(pmr.topLeft(), pixmap);
5032 5026
             }
5033
-            else if(popupmenu->isCheckable() && mi->isChecked())
5027
+            else if((elementFlags & CEF_IsCheckable) && mi->isChecked())
5034 5028
                 drawPrimitive(PE_CheckMark, p, ceData, elementFlags, cr, cg,
5035 5029
                               (flags &(Style_Enabled|(opts.useHighlightForMenu ? Style_Active : 0)))| Style_On|MENU_ITEM);
5036 5030
 
@@ -6832,10 +6826,8 @@ int QtCurveStyle::pixelMetric(PixelMetric metric, TQStyleControlElementData ceDa
6832 6826
 #if 0x039999 >= 0x030200
6833 6827
         case PM_TabBarTabShiftVertical:
6834 6828
         {
6835
-            const TQTabBar *tb=widget ? ::tqqt_cast<const TQTabBar *>(widget) : 0;
6836
-
6837
-            return tb
6838
-                    ? TQTabBar::RoundedAbove==tb->shape() || TQTabBar::TriangularAbove==tb->shape()
6829
+            return (ceData.widgetObjectTypes.contains(TQTABBAR_OBJECT_NAME_STRING))
6830
+                    ? TQTabBar::RoundedAbove==ceData.tabBarData.shape || TQTabBar::TriangularAbove==ceData.tabBarData.shape
6839 6831
                        ? 1
6840 6832
                        : -1
6841 6833
                     : BASE_STYLE::pixelMetric(metric, ceData, elementFlags, widget);
@@ -6966,7 +6958,6 @@ TQSize QtCurveStyle::sizeFromContents(ContentsType contents, TQStyleControlEleme
6966 6958
             const int        constMinH(opts.thinnerMenuItems ? 25 : 27);
6967 6959
 
6968 6960
             TQMenuItem        *mi(data.menuItem());
6969
-            const TQPopupMenu *popupmenu(static_cast<const TQPopupMenu *>(widget));
6970 6961
             int              maxpmw(data.maxIconWidth()),
6971 6962
                              w(contentsSize.width()), h(contentsSize.height());
6972 6963
 
@@ -6993,7 +6984,7 @@ TQSize QtCurveStyle::sizeFromContents(ContentsType contents, TQStyleControlEleme
6993 6984
                 if (mi->pixmap())
6994 6985
                     h = TQMAX(h, mi->pixmap()->height());
6995 6986
                 else if (!mi->text().isNull())
6996
-                    h = TQMAX(h, popupmenu->fontMetrics().height() + 2);
6987
+                    h = TQMAX(h, TQFontMetrics(ceData.font).height() + 2);
6997 6988
                 if (mi->iconSet()!= 0)
6998 6989
                     h = TQMAX(h, mi->iconSet()->pixmap(TQIconSet::Small, TQIconSet::Normal).height());
6999 6990
                 h+=(opts.thinnerMenuItems ? 2 : 4);

Loading…
Cancel
Save