diff options
Diffstat (limited to 'styles/phase')
-rw-r--r-- | styles/phase/phasestyle.cpp | 117 | ||||
-rw-r--r-- | styles/phase/phasestyle.h | 7 |
2 files changed, 31 insertions, 93 deletions
diff --git a/styles/phase/phasestyle.cpp b/styles/phase/phasestyle.cpp index 78f423cc..3b73ebfb 100644 --- a/styles/phase/phasestyle.cpp +++ b/styles/phase/phasestyle.cpp @@ -82,7 +82,7 @@ static unsigned contrast = 110; PhaseStyle::PhaseStyle() : KStyle(FilledFrameWorkaround | AllowMenuTransparency, - ThreeButtonScrollBar), hover_(0), hovertab_(0), + ThreeButtonScrollBar), gradients_(TQPixmap::defaultDepth() > 8), kicker_(false) { TQSettings settings; @@ -412,11 +412,11 @@ void PhaseStyle::drawPhasePanel(TQPainter *painter, void PhaseStyle::drawPhaseTab(TQPainter *painter, int x, int y, int w, int h, const TQColorGroup &group, - const TQTabBar *bar, + TQStyleControlElementData ceData, + ControlElementFlags /*elementFlags*/, const TQStyleOption &option, SFlags flags) const { - const TQTabWidget *tabwidget; bool selected = (flags & Style_Selected); bool edge; // tab is at edge of bar const int x2 = x + w - 1; @@ -425,21 +425,18 @@ void PhaseStyle::drawPhaseTab(TQPainter *painter, painter->save(); // what position is the tab? - if ((bar->count() == 1) - || (bar->indexOf(option.tab()->identifier()) == 0)) { + if ((ceData.tabBarData.tabCount == 1) + || (ceData.tabBarData.identIndexMap[option.tab()->identifier()] == 0)) { edge = true; } else { edge = false; } - switch (TQTabBar::Shape(bar->shape())) { + switch (TQTabBar::Shape(ceData.tabBarData.shape)) { case TQTabBar::RoundedAbove: case TQTabBar::TriangularAbove: { // is there a corner widget? - tabwidget = ::tqqt_cast<TQTabWidget*>(bar->parent()); - if (edge && tabwidget - && tabwidget->cornerWidget(reverse_ ? - TQt::TopRight : TQt::TopLeft)) { + if (!ceData.tabBarData.cornerWidgets[reverse_ ? TQStyleControlElementTabBarData::CWL_TopRight : TQStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes.isEmpty()) { edge = false; } @@ -515,10 +512,7 @@ void PhaseStyle::drawPhaseTab(TQPainter *painter, case TQTabBar::RoundedBelow: case TQTabBar::TriangularBelow: { // is there a corner widget? - tabwidget = ::tqqt_cast<TQTabWidget*>(bar->parent()); - if (edge && tabwidget - && tabwidget->cornerWidget(reverse_ ? - TQt::BottomRight : TQt::BottomLeft)) { + if (!ceData.tabBarData.cornerWidgets[reverse_ ? TQStyleControlElementTabBarData::CWL_BottomRight : TQStyleControlElementTabBarData::CWL_BottomLeft].widgetObjectTypes.isEmpty()) { edge = false; } @@ -823,7 +817,7 @@ void PhaseStyle::drawPrimitive(TQ_PrimitiveElement element, case PE_Splitter: cx = x + w/2 - 2; cy = y + h/2 - 2; painter->fillRect(rect, - (hover_ == painter->device()) + (flags & Style_MouseOver) ? TQColor(group.background().light(contrast)) : group.background()); @@ -1117,7 +1111,7 @@ void PhaseStyle::drawKStylePrimitive(KStylePrimitive element, case KPE_SliderHandle: { const TQSlider* slider = ::tqqt_cast<const TQSlider*>(widget); if (slider) { - TQColor color = (widget==hover_) + TQColor color = (flags & Style_MouseOver) ? TQColor(group.button().light(contrast)) : group.button(); if (slider->orientation() ==Qt::Horizontal) { @@ -1176,13 +1170,13 @@ void PhaseStyle::drawControl(TQ_ControlElement element, drawPhasePanel(painter, x, y, w, h, group, true, &group.brush(TQColorGroup::Mid)); drawPhaseBevel(painter, x+bd, y+bd, w-bd*2, h-bd*2, group, - (widget==hover_) + (flags & Style_MouseOver) ? TQColor(group.button().light(contrast)) : group.button(), false, false, false); } else { drawPhaseButton(painter, x, y, w, h, group, - (widget==hover_) + (flags & Style_MouseOver) ? TQColor(group.button().light(contrast)) : group.button(), depress); } @@ -1342,8 +1336,7 @@ void PhaseStyle::drawControl(TQ_ControlElement element, } case CE_PopupMenuItem: { - const TQPopupMenu *popup = ::tqqt_cast<const TQPopupMenu*>(widget); - if (!popup) { + if (!ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING)) { KStyle::drawControl(element, painter, ceData, elementFlags, rect, group, flags, option, widget); return; @@ -1357,7 +1350,7 @@ void PhaseStyle::drawControl(TQ_ControlElement element, int tabwidth = option.tabWidth(); int checkwidth = option.maxIconWidth(); - bool checkable = popup->isCheckable(); + bool checkable = (elementFlags & CEF_IsCheckable); bool etchtext = styleHint(SH_EtchDisabledText, ceData, elementFlags); active = flags & Style_Active; enabled = mi->isEnabled(); @@ -1503,13 +1496,9 @@ void PhaseStyle::drawControl(TQ_ControlElement element, } case CE_TabBarTab: { - const TQTabBar* tab = ::tqqt_cast<const TQTabBar*>(widget); - if (tab) { - if ((widget == hover_) && (option.tab() == hovertab_)) { - flags |= Style_MouseOver; - } + if (ceData.widgetObjectTypes.contains(TQTABBAR_OBJECT_NAME_STRING)) { // this guy can get complicated, we we do it elsewhere - drawPhaseTab(painter, x, y, w, h, group, tab, option, + drawPhaseTab(painter, x, y, w, h, group, ceData, elementFlags, option, flags); } else { // not a tabbar KStyle::drawControl(element, painter, ceData, elementFlags, rect, group, @@ -1526,8 +1515,7 @@ void PhaseStyle::drawControl(TQ_ControlElement element, } case CE_ProgressBarContents: { - const TQProgressBar* pbar = ::tqqt_cast<const TQProgressBar*>(widget); - if (!pbar) { + if (!ceData.widgetObjectTypes.contains(TQPROGRESSBAR_OBJECT_NAME_STRING)) { KStyle::drawControl(element, painter, ceData, elementFlags, rect, group, flags, option, widget); return; @@ -1537,15 +1525,15 @@ void PhaseStyle::drawControl(TQ_ControlElement element, painter->setBrush(group.brush(TQColorGroup::Highlight)); painter->setPen(group.dark()); - if (!pbar->totalSteps()) { + if (!ceData.totalSteps) { // busy indicator int bar = pixelMetric(PM_ProgressBarChunkWidth, ceData, elementFlags, widget) + 2; - int progress = pbar->progress() % ((w-bar) * 2); + int progress = ceData.currentStep % ((w-bar) * 2); if (progress > (w-bar)) progress = 2 * (w-bar) - progress; painter->drawRect(x+progress+1, y+1, bar-2, h-2); } else { - double progress = static_cast<double>(pbar->progress()) / - static_cast<double>(pbar->totalSteps()); + double progress = static_cast<double>(ceData.currentStep) / + static_cast<double>(ceData.totalSteps); dx = static_cast<int>(w * progress); if (dx < 4) break; if (reverse_) x += w - dx; @@ -1657,7 +1645,7 @@ void PhaseStyle::drawComplexControl(TQ_ComplexControl control, sunken = (active == SC_ComboBoxArrow); drawPhaseButton(painter, x, y, w, h, group, - (widget==hover_) + (flags & Style_MouseOver) ? TQColor(group.button().light(contrast)) : group.button(), sunken); @@ -1818,7 +1806,7 @@ void PhaseStyle::drawComplexControl(TQ_ComplexControl control, if (reverse_) subrect.moveLeft(spin->upRect().left()); drawPhaseBevel(painter, subrect.x(), subrect.y(), subrect.width(), subrect.height(), group, - (widget==hover_) + (flags & Style_MouseOver) ? TQColor(group.button().light(contrast)) : group.button(), false, false, false); } @@ -1995,8 +1983,8 @@ int PhaseStyle::pixelMetric(PixelMetric metric, TQStyleControlElementData ceData return 24; case PM_TabBarTabVSpace: - if (const TQTabBar *tb = ::tqqt_cast<const TQTabBar*>(widget)) { - if (tb->shape() == TQTabBar::RoundedAbove) { + if (ceData.widgetObjectTypes.contains(TQTABBAR_OBJECT_NAME_STRING)) { + if (ceData.tabBarData.shape == TQTabBar::RoundedAbove) { return 10; } else { return 6; @@ -2186,8 +2174,7 @@ TQSize PhaseStyle::sizeFromContents(ContentsType contents, case CT_PopupMenuItem: { if (!widget || option.isDefault()) return contentsize; - const TQPopupMenu *popup = ::tqqt_cast<const TQPopupMenu*>(widget); - if (!popup) { + if (!ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING)) { return KStyle::sizeFromContents(contents, ceData, elementFlags, contentsize, option, widget); } @@ -2208,7 +2195,7 @@ TQSize PhaseStyle::sizeFromContents(ContentsType contents, h = TQMAX(h, item->pixmap()->height() + ITEMFRAME*2); } else { h = TQMAX(h, MINICONSIZE + ITEMFRAME*2); - h = TQMAX(h, popup->fontMetrics().height() + h = TQMAX(h, TQFontMetrics(ceData.font).height() + ITEMVMARGIN*2 + ITEMFRAME*2); } if (item->iconSet()) @@ -2222,7 +2209,7 @@ TQSize PhaseStyle::sizeFromContents(ContentsType contents, else if (item->popup()) w += 2 * ARROWMARGIN; - if (option.maxIconWidth() || popup->isCheckable()) { + if (option.maxIconWidth() || (elementFlags & CEF_IsCheckable)) { w += TQMAX(option.maxIconWidth(), TQIconSet::iconSize(TQIconSet::Small).width()) + ITEMHMARGIN*2; @@ -2373,54 +2360,6 @@ bool PhaseStyle::objectEventHandler( TQStyleControlElementData ceData, ControlEl } } - } else if (highlights_) { // "mouseover" events - if (::tqqt_cast<TQPushButton*>(object) || - ::tqqt_cast<TQComboBox*>(object) || - ::tqqt_cast<TQSpinWidget*>(object) || - ::tqqt_cast<TQCheckBox*>(object) || - ::tqqt_cast<TQRadioButton*>(object) || - ::tqqt_cast<TQSlider*>(object) || - object->inherits(TQSPLITTERHANDLE)) { - if (event->type() == TQEvent::Enter) { - if (0 != (widget = ::tqqt_cast<TQWidget*>(object)) && - widget->isEnabled()) { - hover_ = widget; - widget->repaint(false); - } - } else if (event->type() == TQEvent::Leave) { - if (0 != (widget = ::tqqt_cast<TQWidget*>(object))) { - hover_ = 0; - widget->repaint(false); - } - } - } else if (::tqqt_cast<TQTabBar*>(object)) { // special case for qtabbar - if (event->type() == TQEvent::Enter) { - if (0 != (widget = ::tqqt_cast<TQWidget*>(object)) && - widget->isEnabled()) { - hover_ = widget; - hovertab_ = 0;; - widget->repaint(false); - } - } else if (event->type() == TQEvent::Leave) { - if (0 != (widget = ::tqqt_cast<TQWidget*>(object))) { - hover_ = 0; - hovertab_ = 0;; - widget->repaint(false); - } - } else if (event->type() == TQEvent::MouseMove) { - TQTabBar *tabbar; - if (0 != (tabbar = ::tqqt_cast<TQTabBar*>(object))) { - TQMouseEvent *me; - if (0 != (me = dynamic_cast<TQMouseEvent*>(event))) { - TQTab *tab = tabbar->selectTab(me->pos()); - if (hovertab_ != tab) { - hovertab_ = tab; - tabbar->repaint(false); - } - } - } - } - } } } diff --git a/styles/phase/phasestyle.h b/styles/phase/phasestyle.h index be4f3016..61f86470 100644 --- a/styles/phase/phasestyle.h +++ b/styles/phase/phasestyle.h @@ -170,8 +170,9 @@ private: void drawPhaseTab(TQPainter *painter, int x, int y, int w, int h, const TQColorGroup &group, - const TQTabBar *bar, - const TQStyleOption &option, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQStyleOption &option, const SFlags flags) const; void drawPhaseGradient(TQPainter *painter, @@ -187,8 +188,6 @@ private: bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); private: - TQWidget *hover_; - TQTab *hovertab_; TQMap<unsigned int, TQIntDict<GradientSet> > * gradients; bool gradients_; bool highlights_; |