diff options
Diffstat (limited to 'src/styles')
-rw-r--r-- | src/styles/ntqcommonstyle.h | 9 | ||||
-rw-r--r-- | src/styles/ntqmotifplusstyle.h | 11 | ||||
-rw-r--r-- | src/styles/ntqmotifstyle.h | 4 | ||||
-rw-r--r-- | src/styles/ntqsgistyle.h | 11 | ||||
-rw-r--r-- | src/styles/ntqwindowsstyle.h | 9 | ||||
-rw-r--r-- | src/styles/qcommonstyle.cpp | 47 | ||||
-rw-r--r-- | src/styles/qmotifplusstyle.cpp | 78 | ||||
-rw-r--r-- | src/styles/qmotifstyle.cpp | 8 | ||||
-rw-r--r-- | src/styles/qsgistyle.cpp | 124 | ||||
-rw-r--r-- | src/styles/qwindowsstyle.cpp | 104 |
10 files changed, 195 insertions, 210 deletions
diff --git a/src/styles/ntqcommonstyle.h b/src/styles/ntqcommonstyle.h index fd1e0f459..ce7e12334 100644 --- a/src/styles/ntqcommonstyle.h +++ b/src/styles/ntqcommonstyle.h @@ -38,6 +38,11 @@ ** **********************************************************************/ +// RAJA FIXME +// QMotifPlusStyle +// QSGIStyle +// QWindowsStyle + #ifndef TQCOMMONSTYLE_H #define TQCOMMONSTYLE_H @@ -241,7 +246,6 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; - private: // Disabled copy constructor and operator= #if defined(TQ_DISABLE_COPY) @@ -250,9 +254,6 @@ private: #endif }; -Q_EXPORT TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* widget, const TQStyleOption& opt, bool populateReliantFields=true); -Q_EXPORT TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* object, TQStringList objectTypeList, const TQStyleOption& opt); - #endif // QT_NO_STYLE #endif // TQCOMMONSTYLE_H diff --git a/src/styles/ntqmotifplusstyle.h b/src/styles/ntqmotifplusstyle.h index 10703a0cf..8027b9339 100644 --- a/src/styles/ntqmotifplusstyle.h +++ b/src/styles/ntqmotifplusstyle.h @@ -63,11 +63,11 @@ public: virtual ~TQMotifPlusStyle(); void polish(TQPalette &pal); - void polish(TQWidget *widget); - void unPolish(TQWidget*widget); + void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); + void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); - void polish(TQApplication *app); - void unPolish(TQApplication *app); + void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); + void applicationUnPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); void drawPrimitive( PrimitiveElement pe, TQPainter *p, @@ -118,8 +118,7 @@ public: int styleHint(StyleHint sh, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQStyleOption & = TQStyleOption::Default, TQStyleHintReturn* = 0, const TQWidget * = 0) const; -protected: - bool eventFilter(TQObject *, TQEvent *); + bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); private: diff --git a/src/styles/ntqmotifstyle.h b/src/styles/ntqmotifstyle.h index 882705c3d..9b9d3650d 100644 --- a/src/styles/ntqmotifstyle.h +++ b/src/styles/ntqmotifstyle.h @@ -67,8 +67,8 @@ public: bool useHighlightColors() const; void polish( TQPalette& ); - void polish( TQWidget* ); - void polish( TQApplication* ); + void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); void polishPopupMenu( TQPopupMenu* ); diff --git a/src/styles/ntqsgistyle.h b/src/styles/ntqsgistyle.h index 38294e44c..73be2ae84 100644 --- a/src/styles/ntqsgistyle.h +++ b/src/styles/ntqsgistyle.h @@ -67,10 +67,10 @@ public: #if !defined(Q_NO_USING_KEYWORD) using TQMotifStyle::polish; #endif - void polish( TQWidget* ); - void unPolish( TQWidget* ); - void polish( TQApplication* ); - void unPolish( TQApplication* ); + void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void applicationUnPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); void drawPrimitive( PrimitiveElement pe, TQPainter *p, @@ -124,8 +124,7 @@ public: const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; -protected: - bool eventFilter( TQObject*, TQEvent*); + bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); private: TQSGIStylePrivate *d; diff --git a/src/styles/ntqwindowsstyle.h b/src/styles/ntqwindowsstyle.h index 79934934d..d626c3e3c 100644 --- a/src/styles/ntqwindowsstyle.h +++ b/src/styles/ntqwindowsstyle.h @@ -61,11 +61,11 @@ public: TQWindowsStyle(); ~TQWindowsStyle(); - void polish(TQApplication*); - void unPolish(TQApplication*); + void applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); + void applicationUnPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); - void polish(TQWidget*); - void unPolish(TQWidget*); + void polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); + void unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *); void polish( TQPalette & ); @@ -130,6 +130,7 @@ public: TQRect subRect( SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const; + bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); private: class Private; diff --git a/src/styles/qcommonstyle.cpp b/src/styles/qcommonstyle.cpp index 45b1ba857..20c6c9993 100644 --- a/src/styles/qcommonstyle.cpp +++ b/src/styles/qcommonstyle.cpp @@ -156,7 +156,7 @@ TQStringList getObjectTypeListForObject(const TQObject* object) { return objectTypes; } -TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* object, TQStringList objectTypeList, const TQStyleOption& opt) { +TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* object, TQStringList objectTypeList, const TQStyleOption& opt, bool populateReliantFields) { TQStyle::ControlElementFlags cef = (TQStyle::ControlElementFlags)0; if (object) { @@ -226,6 +226,11 @@ TQStyle::ControlElementFlags getControlElementFlagsForObject(const TQObject* obj if (widget->parentWidget()) cef = cef | TQStyle::CEF_HasParentWidget; if (widget->focusProxy()) cef = cef | TQStyle::CEF_HasFocusProxy; if (widget->hasFocus()) cef = cef | TQStyle::CEF_HasFocus; + if (populateReliantFields) { + if (widget->isActiveWindow()) cef = cef | TQStyle::CEF_IsActiveWindow; + if (widget->isTopLevel()) cef = cef | TQStyle::CEF_IsTopLevel; + if (widget->isVisible()) cef = cef | TQStyle::CEF_IsVisible; + } } } else { @@ -240,6 +245,7 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w if (widget) { ceData.widgetObjectTypes = getObjectTypeListForObject(widget); + ceData.allDataPopulated = populateReliantFields; const TQPixmap* erasePixmap = widget->backgroundPixmap(); if (erasePixmap) { ceData.bgPixmap = *erasePixmap; @@ -373,8 +379,11 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w ceData.maxSteps = sb->maxValue(); ceData.currentStep = sb->value(); ceData.startStep = sb->sliderStart(); + ceData.lineStep = sb->lineStep(); ceData.pageStep = sb->pageStep(); - + if (populateReliantFields) { + ceData.sliderRect = sb->sliderRect(); + } } } if (ceData.widgetObjectTypes.contains("TQSlider")) { @@ -387,6 +396,9 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w ceData.startStep = sl->sliderStart(); ceData.lineStep = sl->lineStep(); ceData.pageStep = sl->pageStep(); + if (populateReliantFields) { + ceData.sliderRect = sl->sliderRect(); + } } } if (ceData.widgetObjectTypes.contains("TQDialogButtons")) { @@ -434,6 +446,7 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w TQWidget* viewport = lv->viewport(); if (viewport) { ceData.viewportData.widgetObjectTypes = getObjectTypeListForObject(viewport); + ceData.viewportData.allDataPopulated = populateReliantFields; const TQPixmap* erasePixmap = viewport->backgroundPixmap(); if (erasePixmap) { ceData.viewportData.bgPixmap = *erasePixmap; @@ -470,10 +483,17 @@ TQStyleControlElementData populateControlElementDataFromWidget(const TQWidget* w } } } + if (ceData.widgetObjectTypes.contains("TQFrame")) { + const TQFrame *frame = dynamic_cast<const TQFrame*>(widget); + if (frame) { + ceData.frameStyle = frame->frameStyle(); + } + } const TQWidget* parentWidget = widget->parentWidget(); if (parentWidget) { ceData.parentWidgetData.widgetObjectTypes = getObjectTypeListForObject(parentWidget); + ceData.parentWidgetData.allDataPopulated = populateReliantFields; const TQPixmap* erasePixmap = parentWidget->backgroundPixmap(); if (erasePixmap) { ceData.parentWidgetData.bgPixmap = *erasePixmap; @@ -1111,7 +1131,7 @@ void TQCommonStyle::drawControl( ControlElement element, } int tf=AlignVCenter | ShowPrefix; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) tf |= NoAccel; #ifndef QT_NO_ICONSET @@ -1164,7 +1184,7 @@ void TQCommonStyle::drawControl( ControlElement element, { #ifndef QT_NO_CHECKBOX int alignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg, @@ -1186,7 +1206,7 @@ void TQCommonStyle::drawControl( ControlElement element, { #ifndef QT_NO_RADIOBUTTON int alignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; drawItem(p, r, alignment | AlignVCenter | ShowPrefix, cg, flags & Style_Enabled, (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap, ceData.text); @@ -1253,7 +1273,7 @@ void TQCommonStyle::drawControl( ControlElement element, pixelMetric( TQStyle::PM_DefaultFrameWidth, ceData, elementFlags, widget ) ); int alignment = AlignCenter | ShowPrefix; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; drawItem( p, tr, alignment, cg, flags & Style_Enabled, 0, t->text() ); @@ -1386,7 +1406,7 @@ void TQCommonStyle::drawControl( ControlElement element, TQMenuItem *mi = opt.menuItem(); int alignment = AlignCenter|ShowPrefix|DontClip|SingleLine; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; drawItem( p, r, alignment, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, @@ -1428,7 +1448,7 @@ void TQCommonStyle::drawControl( ControlElement element, ! ceData.text.isNull() && ! (elementFlags & CEF_UsesTextLabel)) { int alignment = AlignCenter | ShowPrefix; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; rect.moveBy(shiftX, shiftY); @@ -1455,7 +1475,7 @@ void TQCommonStyle::drawControl( ControlElement element, p->setFont( ceData.font ); TQRect pr = rect, tr = rect; int alignment = ShowPrefix; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) alignment |= NoAccel; if ( ceData.toolButtonTextPosition == TQToolButton::Under ) { @@ -2379,7 +2399,7 @@ TQRect TQCommonStyle::querySubControlMetrics( ComplexControl control, } #endif - TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption()); + TQStyleControlElementData ceData = populateControlElementDataFromWidget(widget, TQStyleOption(), false); return querySubControlMetrics(control, ceData, getControlElementFlagsForObject(widget, ceData.widgetObjectTypes, TQStyleOption()), sc, opt, widget); } @@ -3126,7 +3146,7 @@ TQSize TQCommonStyle::sizeFromContents(ContentsType contents, int TQCommonStyle::styleHint(StyleHint sh, const TQWidget * w, const TQStyleOption &so, TQStyleHintReturn *shr) const { TQStyleControlElementData ceData = populateControlElementDataFromWidget(w, TQStyleOption(), false); - return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, TQStyleOption()), so, shr, w); + return styleHint(sh, ceData, getControlElementFlagsForObject(w, ceData.widgetObjectTypes, TQStyleOption(), false), so, shr, w); } /*! \reimp */ @@ -3200,6 +3220,10 @@ int TQCommonStyle::styleHint(StyleHint sh, TQStyleControlElementData ceData, Con ret = 1; break; + case SH_HideUnderlineAcceleratorWhenAltUp: + ret = 0; + break; + default: ret = 0; break; @@ -3221,5 +3245,4 @@ TQPixmap TQCommonStyle::stylePixmap(StylePixmap, TQStyleControlElementData, Cont return TQPixmap(); } - #endif // QT_NO_STYLE diff --git a/src/styles/qmotifplusstyle.cpp b/src/styles/qmotifplusstyle.cpp index 129f0a2d2..2ad7e7f5a 100644 --- a/src/styles/qmotifplusstyle.cpp +++ b/src/styles/qmotifplusstyle.cpp @@ -69,7 +69,9 @@ struct TQMotifPlusStylePrivate scrollbarElement(0), lastElement(0), ref(1) { ; } - TQGuardedPtr<TQWidget> hoverWidget; + void* hoverWidget; + TQStyleControlElementData hoverWidgetData; + TQStyle::ControlElementFlags hoverWidgetFlags; bool hovering, sliderActive, mousePressed; int scrollbarElement, lastElement, ref; TQPoint mousePos; @@ -176,52 +178,58 @@ void TQMotifPlusStyle::polish(TQPalette &) /*! \reimp */ -void TQMotifPlusStyle::polish(TQWidget *widget) +void TQMotifPlusStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { + if (ceData.widgetObjectTypes.contains("TQWidget")) { #ifndef QT_NO_FRAME - if (::tqt_cast<TQFrame*>(widget) && ((TQFrame *) widget)->frameStyle() == TQFrame::Panel) - ((TQFrame *) widget)->setFrameStyle(TQFrame::WinPanel); + if ((ceData.widgetObjectTypes.contains("TQFrame")) && (ceData.frameStyle == TQFrame::Panel)) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, TQStyleWidgetActionRequestData(TQFrame::WinPanel)); + } #endif #ifndef QT_NO_MENUBAR - if (::tqt_cast<TQMenuBar*>(widget) && ((TQMenuBar *) widget)->frameStyle() != TQFrame::NoFrame) - ((TQMenuBar *) widget)->setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised); + if ((ceData.widgetObjectTypes.contains("TQMenuBar")) && (ceData.frameStyle != TQFrame::NoFrame)) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, TQStyleWidgetActionRequestData(TQFrame::StyledPanel | TQFrame::Raised)); + } #endif #ifndef QT_NO_TOOLBAR - if (::tqt_cast<TQToolBar*>(widget)) - widget->layout()->setMargin(2); + if (ceData.widgetObjectTypes.contains("TQToolBar")) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetLayoutMargin, TQStyleWidgetActionRequestData(2)); + } #endif + } if (useHoveringHighlight) { - if (::tqt_cast<TQButton*>(widget) || ::tqt_cast<TQComboBox*>(widget)) - widget->installEventFilter(this); + if ((ceData.widgetObjectTypes.contains("TQButton")) || (ceData.widgetObjectTypes.contains("TQComboBox"))) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + } - if (::tqt_cast<TQScrollBar*>(widget) || ::tqt_cast<TQSlider*>(widget)) { - widget->setMouseTracking(TRUE); - widget->installEventFilter(this); + if ((ceData.widgetObjectTypes.contains("TQScrollBar")) || (ceData.widgetObjectTypes.contains("TQSlider"))) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_EnableMouseTracking); + installObjectEventHandler(ceData, elementFlags, ptr, this); } } - TQMotifStyle::polish(widget); + TQMotifStyle::polish(ceData, elementFlags, ptr); } /*! \reimp */ -void TQMotifPlusStyle::unPolish(TQWidget *widget) +void TQMotifPlusStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { - widget->removeEventFilter(this); - TQMotifStyle::unPolish(widget); + removeObjectEventHandler(ceData, elementFlags, ptr, this); + TQMotifStyle::unPolish(ceData, elementFlags, ptr); } /*! \reimp */ -void TQMotifPlusStyle::polish(TQApplication *) +void TQMotifPlusStyle::applicationPolish(TQStyleControlElementData, ControlElementFlags, void *) { } /*! \reimp */ -void TQMotifPlusStyle::unPolish(TQApplication *) +void TQMotifPlusStyle::applicationUnPolish(TQStyleControlElementData, ControlElementFlags, void *) { } @@ -1477,14 +1485,14 @@ TQRect TQMotifPlusStyle::querySubControlMetrics(ComplexControl control, /*! \reimp */ -bool TQMotifPlusStyle::eventFilter(TQObject *object, TQEvent *event) +bool TQMotifPlusStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event ) { switch(event->type()) { case TQEvent::MouseButtonPress: { singleton->mousePressed = TRUE; - if (!::tqt_cast<TQSlider*>(object)) + if (!ceData.widgetObjectTypes.contains("TQSlider")) break; singleton->sliderActive = TRUE; @@ -1495,50 +1503,52 @@ bool TQMotifPlusStyle::eventFilter(TQObject *object, TQEvent *event) { singleton->mousePressed = FALSE; - if (!::tqt_cast<TQSlider*>(object)) + if (!ceData.widgetObjectTypes.contains("TQSlider")) break; singleton->sliderActive = FALSE; - ((TQWidget *) object)->repaint(FALSE); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; } case TQEvent::Enter: { - if (! object->isWidgetType()) + if (!ceData.widgetObjectTypes.contains("TQWidget")) break; - singleton->hoverWidget = (TQWidget *) object; - if (! singleton->hoverWidget->isEnabled()) { + singleton->hoverWidget = source; + singleton->hoverWidgetData = ceData; + singleton->hoverWidgetFlags = elementFlags; + if (!(singleton->hoverWidgetFlags & CEF_IsEnabled)) { singleton->hoverWidget = 0; break; } - singleton->hoverWidget->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, singleton->hoverWidget, WAR_Repaint); break; } case TQEvent::Leave: { - if (object != singleton->hoverWidget) + if (source != singleton->hoverWidget) break; - TQWidget *w = singleton->hoverWidget; + void *w = singleton->hoverWidget; singleton->hoverWidget = 0; - w->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, w, WAR_Repaint); break; } case TQEvent::MouseMove: { - if (! object->isWidgetType() || object != singleton->hoverWidget) + if ((!ceData.widgetObjectTypes.contains("TQWidget")) || source != singleton->hoverWidget) break; - if (!::tqt_cast<TQScrollBar*>(object) && ! ::tqt_cast<TQSlider*>(object)) + if ((!ceData.widgetObjectTypes.contains("TQScrollBar")) && (!ceData.widgetObjectTypes.contains("TQSlider"))) break; singleton->mousePos = ((TQMouseEvent *) event)->pos(); if (! singleton->mousePressed) { singleton->hovering = TRUE; - singleton->hoverWidget->repaint(FALSE); + widgetActionRequest(singleton->hoverWidgetData, singleton->hoverWidgetFlags, singleton->hoverWidget, WAR_Repaint); singleton->hovering = FALSE; } @@ -1549,7 +1559,7 @@ bool TQMotifPlusStyle::eventFilter(TQObject *object, TQEvent *event) break; } - return TQMotifStyle::eventFilter(object, event); + return TQMotifStyle::objectEventHandler(ceData, elementFlags, source, event); } diff --git a/src/styles/qmotifstyle.cpp b/src/styles/qmotifstyle.cpp index 1dfa385da..37a5a34cf 100644 --- a/src/styles/qmotifstyle.cpp +++ b/src/styles/qmotifstyle.cpp @@ -171,9 +171,9 @@ void TQMotifStyle::polish( TQPalette& pal ) \internal Keep TQStyle::polish() visible. */ -void TQMotifStyle::polish( TQWidget* w ) +void TQMotifStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - TQStyle::polish(w); + TQStyle::polish(ceData, elementFlags, ptr); } /*! @@ -181,9 +181,9 @@ void TQMotifStyle::polish( TQWidget* w ) \internal Keep TQStyle::polish() visible. */ -void TQMotifStyle::polish( TQApplication* a ) +void TQMotifStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - TQStyle::polish(a); + TQStyle::applicationPolish(ceData, elementFlags, ptr); } static void rot(TQPointArray& a, int n) diff --git a/src/styles/qsgistyle.cpp b/src/styles/qsgistyle.cpp index e6daeec18..930a34d09 100644 --- a/src/styles/qsgistyle.cpp +++ b/src/styles/qsgistyle.cpp @@ -65,7 +65,7 @@ struct SliderLastPosition { SliderLastPosition() : rect(0,-1,0,-1), slider(0) {} TQRect rect; - const TQSlider* slider; + const void* slider; }; #endif @@ -74,7 +74,7 @@ struct ScrollbarLastPosition { ScrollbarLastPosition() : rect( 0,-1, 0,-1 ), scrollbar(0) {} TQRect rect; - const TQScrollBar *scrollbar; + const void* scrollbar; }; #endif @@ -86,7 +86,7 @@ public: { } - const TQWidget *hotWidget; + const void* hotWidget; TQPoint mousePos; #ifndef QT_NO_SCROLLBAR ScrollbarLastPosition lastScrollbarRect; @@ -136,10 +136,10 @@ TQSGIStyle::~TQSGIStyle() bold italic font for menu options. */ void -TQSGIStyle::polish( TQApplication* app) +TQSGIStyle::applicationPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { isApplicationStyle = 1; - TQMotifStyle::polish( app ); + TQMotifStyle::polish( ceData, elementFlags, ptr ); TQPalette pal = TQApplication::palette(); // check this on SGI-Boxes @@ -181,7 +181,7 @@ TQSGIStyle::polish( TQApplication* app) /*! \reimp */ void -TQSGIStyle::unPolish( TQApplication* /* app */ ) +TQSGIStyle::applicationUnPolish( TQStyleControlElementData, ControlElementFlags, void * ) { TQFont f = TQApplication::font(); TQApplication::setFont( f, TRUE ); // get rid of the special fonts for special widget classes @@ -194,9 +194,9 @@ TQSGIStyle::unPolish( TQApplication* /* app */ ) hovering. */ void -TQSGIStyle::polish( TQWidget* w ) +TQSGIStyle::polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - TQMotifStyle::polish(w); + TQMotifStyle::polish(ceData, elementFlags, ptr); if ( !isApplicationStyle ) { TQPalette sgiPal = TQApplication::palette(); @@ -214,7 +214,7 @@ TQSGIStyle::polish( TQWidget* w ) sgiPal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, sgiPal.disabled().base() ); } - if ( ::tqt_cast<TQLineEdit*>(w) || ::tqt_cast<TQTextEdit*>(w) ) { + if ( (ceData.widgetObjectTypes.contains("TQLineEdit")) || (ceData.widgetObjectTypes.contains("TQTextEdit")) ) { // different basecolor and highlighting in Q(Multi)LineEdit sgiPal.setColor( TQColorGroup::Base, TQColor(211,181,181) ); sgiPal.setColor( TQPalette::Active, TQColorGroup::Highlight, sgiPal.active().midlight() ); @@ -224,89 +224,89 @@ TQSGIStyle::polish( TQWidget* w ) sgiPal.setColor( TQPalette::Disabled, TQColorGroup::Highlight, sgiPal.disabled().midlight() ); sgiPal.setColor( TQPalette::Disabled, TQColorGroup::HighlightedText, sgiPal.disabled().text() ); - } else if ( ::tqt_cast<TQMenuBar*>(w) || ::tqt_cast<TQToolBar*>(w) ) { + } else if ( (ceData.widgetObjectTypes.contains("TQMenuBar")) || (ceData.widgetObjectTypes.contains("TQToolBar")) ) { sgiPal.setColor( TQColorGroup::Button, sgiPal.active().midlight() ); } - w->setPalette( sgiPal ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetPalette, TQStyleWidgetActionRequestData(sgiPal)); } - if ( ::tqt_cast<TQButton*>(w) || ::tqt_cast<TQSlider*>(w) || ::tqt_cast<TQScrollBar*>(w) ) { - w->installEventFilter( this ); - w->setMouseTracking( TRUE ); + if ( (ceData.widgetObjectTypes.contains("TQButton")) || (ceData.widgetObjectTypes.contains("TQSlider")) || (ceData.widgetObjectTypes.contains("TQScrollBar")) ) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + widgetActionRequest(ceData, elementFlags, ptr, WAR_EnableMouseTracking); #ifndef QT_NO_SCROLLBAR - if ( ::tqt_cast<TQScrollBar*>(w) ) - w->setBackgroundMode( TQWidget::NoBackground ); + if ( ceData.widgetObjectTypes.contains("TQScrollBar") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, TQStyleWidgetActionRequestData(TQWidget::NoBackground)); + } #endif - } else if ( ::tqt_cast<TQComboBox*>(w) ) { + } else if ( ceData.widgetObjectTypes.contains("TQComboBox") ) { TQFont f = TQApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(f)); #ifndef QT_NO_MENUBAR - } else if ( ::tqt_cast<TQMenuBar*>(w) ) { - ((TQFrame*) w)->setFrameStyle(TQFrame::StyledPanel | TQFrame::Raised); - w->setBackgroundMode( TQWidget::PaletteBackground ); + } else if ( ceData.widgetObjectTypes.contains("TQMenuBar") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetStyle, TQStyleWidgetActionRequestData(TQFrame::StyledPanel | TQFrame::Raised)); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, TQStyleWidgetActionRequestData(TQWidget::PaletteBackground)); TQFont f = TQApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(f)); #endif #ifndef QT_NO_POPUPMENU - } else if ( ::tqt_cast<TQPopupMenu*>(w) ) { - ((TQFrame*) w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth, TQStyleControlElementData(), CEF_None ) + 1 ); + } else if ( ceData.widgetObjectTypes.contains("TQPopupMenu") ) { + TQStyleWidgetActionRequestData requestData; + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetLineWidth, TQStyleWidgetActionRequestData(pixelMetric( PM_DefaultFrameWidth, TQStyleControlElementData(), CEF_None ) + 1)); TQFont f = TQApplication::font(); f.setBold( TRUE ); f.setItalic( TRUE ); - w->setFont( f ); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(f)); #endif - } else if ( ::tqt_cast<TQToolBar*>(w) || w->inherits("TQToolBarSeparator") ) { - w->setBackgroundMode( TQWidget::PaletteBackground ); + } else if ( (ceData.widgetObjectTypes.contains("TQToolBar")) || (ceData.widgetObjectTypes.contains("TQToolBarSeparator")) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetBackgroundMode, TQStyleWidgetActionRequestData(TQWidget::PaletteBackground)); } } /*! \reimp */ void -TQSGIStyle::unPolish( TQWidget* w ) +TQSGIStyle::unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr ) { - if ( ::tqt_cast<TQButton*>(w) || ::tqt_cast<TQSlider*>(w) || ::tqt_cast<TQScrollBar*>(w) ) { - w->removeEventFilter( this ); + if ( (ceData.widgetObjectTypes.contains("TQButton")) || (ceData.widgetObjectTypes.contains("TQSlider")) || (ceData.widgetObjectTypes.contains("TQScrollBar")) ) { + removeObjectEventHandler(ceData, elementFlags, ptr, this); #ifndef QT_NO_POPUPMENU - } else if ( ::tqt_cast<TQPopupMenu*>(w) ) { - ((TQFrame*)w)->setLineWidth( pixelMetric( PM_DefaultFrameWidth, TQStyleControlElementData(), CEF_None ) ); - w->setFont( TQApplication::font() ); + } else if ( ceData.widgetObjectTypes.contains("TQPopupMenu") ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_FrameSetLineWidth, TQStyleWidgetActionRequestData(pixelMetric( PM_DefaultFrameWidth, TQStyleControlElementData(), CEF_None ))); + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(TQApplication::font())); #endif #if !defined(QT_NO_MENUBAR) || !defined(QT_NO_COMBOBOX) - } else if ( ::tqt_cast<TQMenuBar*>(w) || ::tqt_cast<TQComboBox*>(w) ) { - w->setFont( TQApplication::font() ); + } else if ( (ceData.widgetObjectTypes.contains("TQMenuBar")) || (ceData.widgetObjectTypes.contains("TQComboBox")) ) { + widgetActionRequest(ceData, elementFlags, ptr, WAR_SetFont, TQStyleWidgetActionRequestData(TQApplication::font())); #endif } } /*! \reimp */ -bool TQSGIStyle::eventFilter( TQObject* o, TQEvent* e ) +bool TQSGIStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) { - if ( !o->isWidgetType() || e->type() == TQEvent::Paint ) - return TQMotifStyle::eventFilter( o, e ); - - TQWidget *widget = (TQWidget*)o; + if ( (!(ceData.widgetObjectTypes.contains("TQWidget"))) || (e->type() == TQEvent::Paint) ) + return TQMotifStyle::objectEventHandler( ceData, elementFlags, source, e ); switch ( e->type() ) { case TQEvent::MouseButtonPress: { #ifndef QT_NO_SCROLLBAR - if ( ::tqt_cast<TQScrollBar*>(widget) ) { - d->lastScrollbarRect.rect = ((TQScrollBar*)widget)->sliderRect(); - d->lastScrollbarRect.scrollbar = ((TQScrollBar*)widget); - widget->repaint( FALSE ); + if (ceData.widgetObjectTypes.contains("TQScrollBar")) { + d->lastScrollbarRect.rect = ceData.sliderRect; + d->lastScrollbarRect.scrollbar = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } else #endif { #ifndef QT_NO_SLIDER - if ( ::tqt_cast<TQSlider*>(widget) ) { - d->lastSliderRect.rect = ((TQSlider*)widget)->sliderRect(); - d->lastSliderRect.slider = ((TQSlider*)widget); - widget->repaint( FALSE ); + if (ceData.widgetObjectTypes.contains("TQSlider")) { + d->lastSliderRect.rect = ceData.sliderRect; + d->lastSliderRect.slider = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } #endif } @@ -317,52 +317,52 @@ bool TQSGIStyle::eventFilter( TQObject* o, TQEvent* e ) { if ( 0 ) { #ifndef QT_NO_SCROLLBAR - } else if ( ::tqt_cast<TQScrollBar*>(widget) ) { + } else if (ceData.widgetObjectTypes.contains("TQScrollBar")) { TQRect oldRect = d->lastScrollbarRect.rect; d->lastScrollbarRect.rect = TQRect( 0, -1, 0, -1 ); - widget->repaint( oldRect, FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_RepaintRect, TQStyleWidgetActionRequestData(oldRect)); #endif #ifndef QT_NO_SLIDER - } else if ( ::tqt_cast<TQSlider*>(widget) ) { + } else if (ceData.widgetObjectTypes.contains("TQSlider")) { TQRect oldRect = d->lastSliderRect.rect; d->lastSliderRect.rect = TQRect( 0, -1, 0, -1 ); - widget->repaint( oldRect, FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_RepaintRect, TQStyleWidgetActionRequestData(oldRect)); #endif } } break; case TQEvent::MouseMove: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; if ( ((TQMouseEvent*)e)->button() ) break; - d->hotWidget = widget; + d->hotWidget = source; d->mousePos = ((TQMouseEvent*)e)->pos(); - widget->repaint( FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; case TQEvent::Enter: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; - d->hotWidget = widget; - widget->repaint( FALSE ); + d->hotWidget = source; + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); break; case TQEvent::Leave: - if ( !widget->isActiveWindow() ) + if ( !(elementFlags & CEF_IsActiveWindow) ) break; - if ( widget == d->hotWidget) { + if ( source == d->hotWidget) { d->hotWidget = 0; - widget->repaint( FALSE ); + widgetActionRequest(ceData, elementFlags, source, WAR_Repaint); } break; default: break; } - return TQMotifStyle::eventFilter( o, e ); + return TQMotifStyle::objectEventHandler( ceData, elementFlags, source, e ); } static const int sgiItemFrame = 2; // menu item frame width diff --git a/src/styles/qwindowsstyle.cpp b/src/styles/qwindowsstyle.cpp index 5c5c996e5..5a1289dca 100644 --- a/src/styles/qwindowsstyle.cpp +++ b/src/styles/qwindowsstyle.cpp @@ -95,99 +95,42 @@ class TQWindowsStyle::Private : public TQObject public: Private(TQWindowsStyle *parent); - bool hasSeenAlt(const TQWidget *widget) const; - bool altDown() const { return alt_down; } - -protected: - bool eventFilter(TQObject *o, TQEvent *e); + bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); private: - TQPtrList<TQWidget> seenAlt; - bool alt_down; int menuBarTimer; }; TQWindowsStyle::Private::Private(TQWindowsStyle *parent) -: TQObject(parent, "TQWindowsStylePrivate"), alt_down(FALSE), menuBarTimer(0) +: TQObject(parent, "TQWindowsStylePrivate"), menuBarTimer(0) { } -// Returns true if the toplevel parent of \a widget has seen the Alt-key -bool TQWindowsStyle::Private::hasSeenAlt(const TQWidget *widget) const -{ - widget = widget->topLevelWidget(); - return seenAlt.contains(widget); -} - // Records Alt- and Focus events -bool TQWindowsStyle::Private::eventFilter(TQObject *o, TQEvent *e) +bool TQWindowsStyle::Private::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags, void* source, TQEvent *e ) { - if (!o->isWidgetType()) - return TQObject::eventFilter(o, e); + if (!(ceData.widgetObjectTypes.contains("TQWidget"))) { + return TRUE; + } - TQWidget *widget = ::tqt_cast<TQWidget*>(o); + TQWidget *widget = reinterpret_cast<TQWidget*>(source); switch(e->type()) { - case TQEvent::KeyPress: - if (((TQKeyEvent*)e)->key() == Key_Alt) { - widget = widget->topLevelWidget(); - - // Alt has been pressed - find all widgets that care - TQObjectList *l = widget->queryList("TQWidget"); - TQObjectListIt it( *l ); - TQWidget *w; - while ( (w = (TQWidget*)it.current()) != 0 ) { - ++it; - if (w->isTopLevel() || !w->isVisible() || - w->style().styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, w)) - l->removeRef(w); - } - // Update states before repainting - seenAlt.append(widget); - alt_down = TRUE; - - // Repaint all relevant widgets - it.toFirst(); - while ( (w = (TQWidget*)it.current()) != 0 ) { - ++it; - w->repaint(FALSE); - } - delete l; - } - break; - case TQEvent::KeyRelease: - if (((TQKeyEvent*)e)->key() == Key_Alt) { - widget = widget->topLevelWidget(); - - // Update state - alt_down = FALSE; - // Repaint only menubars - TQObjectList *l = widget->queryList("TQMenuBar"); - TQObjectListIt it( *l ); - TQMenuBar *menuBar; - while ( (menuBar = (TQMenuBar*)it.current()) != 0) { - ++it; - menuBar->repaint(FALSE); - } - } - break; case TQEvent::FocusIn: case TQEvent::FocusOut: { // Menubars toggle based on focus - TQMenuBar *menuBar = ::tqt_cast<TQMenuBar*>(o); + TQMenuBar *menuBar = ::tqt_cast<TQMenuBar*>(widget); if (menuBar && !menuBarTimer) // delayed repaint to avoid flicker menuBarTimer = menuBar->startTimer(0); } break; case TQEvent::Close: // Reset widget when closing - seenAlt.removeRef(widget); - seenAlt.removeRef(widget->topLevelWidget()); break; case TQEvent::Timer: { - TQMenuBar *menuBar = ::tqt_cast<TQMenuBar*>(o); + TQMenuBar *menuBar = ::tqt_cast<TQMenuBar*>(widget); TQTimerEvent *te = (TQTimerEvent*)e; if (menuBar && te->timerId() == menuBarTimer) { menuBar->killTimer(te->timerId()); @@ -201,7 +144,7 @@ bool TQWindowsStyle::Private::eventFilter(TQObject *o, TQEvent *e) break; } - return TQObject::eventFilter(o, e); + return TRUE; } /*! @@ -230,32 +173,40 @@ TQWindowsStyle::~TQWindowsStyle() } /*! \reimp */ -void TQWindowsStyle::polish(TQApplication *app) +bool TQWindowsStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ) { + if (d) { + return d->objectEventHandler(ceData, elementFlags, source, e); + } + return TRUE; +} + +/*! \reimp */ +void TQWindowsStyle::applicationPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { // We only need the overhead when shortcuts are sometimes hidden - if (!styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, 0)) { + if (styleHint(SH_UnderlineAccelerator, TQStyleControlElementData(), CEF_None, 0) && styleHint(SH_HideUnderlineAcceleratorWhenAltUp, TQStyleControlElementData(), CEF_None, 0)) { d = new Private(this); - app->installEventFilter(d); + installObjectEventHandler(ceData, elementFlags, ptr, this); } } /*! \reimp */ -void TQWindowsStyle::unPolish(TQApplication *) +void TQWindowsStyle::applicationUnPolish(TQStyleControlElementData, ControlElementFlags, void *) { delete d; d = 0; } /*! \reimp */ -void TQWindowsStyle::polish(TQWidget *widget) +void TQWindowsStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { - TQCommonStyle::polish(widget); + TQCommonStyle::polish(ceData, elementFlags, ptr); } /*! \reimp */ -void TQWindowsStyle::unPolish(TQWidget *widget) +void TQWindowsStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { - TQCommonStyle::polish(widget); + TQCommonStyle::polish(ceData, elementFlags, ptr); } /*! \reimp */ @@ -946,8 +897,9 @@ void TQWindowsStyle::drawControl( ControlElement element, if ( !s.isNull() ) { // draw text int t = s.find( '\t' ); int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine; - if (!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) + if ((!styleHint(SH_UnderlineAccelerator, ceData, elementFlags, TQStyleOption::Default, 0, widget)) || ((styleHint(SH_HideUnderlineAcceleratorWhenAltUp, ceData, elementFlags, TQStyleOption::Default, 0, widget)) && (!acceleratorsShown()))) { text_flags |= NoAccel; + } text_flags |= (TQApplication::reverseLayout() ? AlignRight : AlignLeft ); if ( t >= 0 ) { // draw tab text int xp = x + w - tab - windowsItemHMargin - windowsItemFrame + 1; |