diff options
-rw-r--r-- | scheck/scheck.cpp | 527 | ||||
-rw-r--r-- | scheck/scheck.h | 54 |
2 files changed, 310 insertions, 271 deletions
diff --git a/scheck/scheck.cpp b/scheck/scheck.cpp index 20b1c8b2..6b09b093 100644 --- a/scheck/scheck.cpp +++ b/scheck/scheck.cpp @@ -934,7 +934,7 @@ void StyleCheckStyle::slotAccelManage() } -void StyleCheckStyle::polish(TQWidget* widget) +void StyleCheckStyle::polish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { /* Having a global view on the widget makes accel easier to catch. However, just intruding on the main window @@ -944,49 +944,55 @@ void StyleCheckStyle::polish(TQWidget* widget) topLevelAccelManageTimer->start(200, true); // - // Put in order of highest occurance to maximise hit rate - if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) { - widget->installEventFilter(this); - } - - if (widget->inherits(TQLABEL_OBJECT_NAME_STRING)) - { - widget->installEventFilter(this); - } + if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { + TQWidget *widget = reinterpret_cast<TQWidget*>(ptr); - if (widget->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) - { - widget->installEventFilter(this); - } - - if (widget->inherits(TQMAINWINDOW_OBJECT_NAME_STRING) || widget->inherits(TQDIALOG_OBJECT_NAME_STRING) ) - { - watcher->addWatched(widget); + // Put in order of highest occurance to maximise hit rate + if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + } + + if (widget->inherits(TQLABEL_OBJECT_NAME_STRING)) + { + installObjectEventHandler(ceData, elementFlags, ptr, this); + } + + if (widget->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) + { + installObjectEventHandler(ceData, elementFlags, ptr, this); + } + + if (widget->inherits(TQMAINWINDOW_OBJECT_NAME_STRING) || widget->inherits(TQDIALOG_OBJECT_NAME_STRING) ) + { + watcher->addWatched(widget); + } } - KStyle::polish( widget ); + KStyle::polish( ceData, elementFlags, ptr ); } -void StyleCheckStyle::unPolish(TQWidget* widget) +void StyleCheckStyle::unPolish(TQStyleControlElementData ceData, ControlElementFlags elementFlags, void *ptr) { - if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) { - widget->removeEventFilter(this); - } - - if (widget->inherits(TQLABEL_OBJECT_NAME_STRING)) - { - widget->removeEventFilter(this); - } + if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { + TQWidget *widget = reinterpret_cast<TQWidget*>(ptr); - if (widget->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) - { - widget->removeEventFilter(this); + if (widget->inherits(TQPUSHBUTTON_OBJECT_NAME_STRING)) { + removeObjectEventHandler(ceData, elementFlags, ptr, this); + } + + if (widget->inherits(TQLABEL_OBJECT_NAME_STRING)) + { + removeObjectEventHandler(ceData, elementFlags, ptr, this); + } + + if (widget->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) + { + removeObjectEventHandler(ceData, elementFlags, ptr, this); + } } - - - KStyle::unPolish( widget ); + KStyle::unPolish( ceData, elementFlags, ptr ); } @@ -994,6 +1000,8 @@ void StyleCheckStyle::unPolish(TQWidget* widget) // This function draws primitive elements as well as their masks. void StyleCheckStyle::drawPrimitive( PrimitiveElement pe, TQPainter *p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, @@ -1161,7 +1169,7 @@ void StyleCheckStyle::drawPrimitive( PrimitiveElement pe, // Small hack to ensure scrollbar gradients are drawn the right way. flags ^= Style_Horizontal; - drawPrimitive(PE_ButtonBevel, p, r, cg, flags | Style_Enabled | Style_Raised); + drawPrimitive(PE_ButtonBevel, p, ceData, elementFlags, r, cg, flags | Style_Enabled | Style_Raised); // Draw a scrollbar riffle (note direction after above changes) // HighColor & Default scrollbar @@ -1225,21 +1233,21 @@ void StyleCheckStyle::drawPrimitive( PrimitiveElement pe, case PE_ScrollBarAddLine: { - drawPrimitive( PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) | + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, r, cg, (flags & Style_Enabled) | ((flags & Style_Down) ? Style_Down : Style_Raised) ); drawPrimitive( ((flags & Style_Horizontal) ? PE_ArrowRight : PE_ArrowDown), - p, r, cg, flags ); + p, ceData, elementFlags, r, cg, flags ); break; } case PE_ScrollBarSubLine: { - drawPrimitive( PE_ButtonBevel, p, r, cg, (flags & Style_Enabled) | + drawPrimitive( PE_ButtonBevel, p, ceData, elementFlags, r, cg, (flags & Style_Enabled) | ((flags & Style_Down) ? Style_Down : Style_Raised) ); drawPrimitive( ((flags & Style_Horizontal) ? PE_ArrowLeft : PE_ArrowUp), - p, r, cg, flags ); + p, ceData, elementFlags, r, cg, flags ); break; } @@ -1392,7 +1400,7 @@ void StyleCheckStyle::drawPrimitive( PrimitiveElement pe, case PE_WindowFrame: case PE_PanelLineEdit: { bool sunken = flags & Style_Sunken; - int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth) + int lw = opt.isDefault() ? pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags) : opt.lineWidth(); if (lw == 2) { @@ -1415,7 +1423,7 @@ void StyleCheckStyle::drawPrimitive( PrimitiveElement pe, p->drawLine(x+1, y+1, x+1, y2-1); p->setPen(oldPen); } else - KStyle::tqdrawPrimitive(pe, p, r, cg, flags, opt); + KStyle::drawPrimitive(pe, p, ceData, elementFlags, r, cg, flags, opt); break; } @@ -1502,8 +1510,8 @@ void StyleCheckStyle::drawPrimitive( PrimitiveElement pe, p->save(); if ( flags & Style_Down ) - p->translate( pixelMetric( PM_ButtonShiftHorizontal ), - pixelMetric( PM_ButtonShiftVertical ) ); + p->translate( pixelMetric( PM_ButtonShiftHorizontal, ceData, elementFlags ), + pixelMetric( PM_ButtonShiftVertical, ceData, elementFlags ) ); if ( flags & Style_Enabled ) { a.translate( r.x() + r.width() / 2, r.y() + r.height() / 2 ); @@ -1520,7 +1528,7 @@ void StyleCheckStyle::drawPrimitive( PrimitiveElement pe, p->restore(); } else - KStyle::tqdrawPrimitive( pe, p, r, cg, flags, opt ); + KStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); } } } @@ -1528,11 +1536,13 @@ void StyleCheckStyle::drawPrimitive( PrimitiveElement pe, void StyleCheckStyle::drawKStylePrimitive( KStylePrimitive kpe, TQPainter* p, - const TQWidget* widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, - const TQStyleOption &opt ) const + const TQStyleOption &opt, + const TQWidget* widget ) const { switch ( kpe ) { @@ -1700,18 +1710,20 @@ void StyleCheckStyle::drawKStylePrimitive( KStylePrimitive kpe, } default: - KStyle::drawKStylePrimitive( kpe, p, widget, r, cg, flags, opt); + KStyle::drawKStylePrimitive( kpe, p, ceData, elementFlags, r, cg, flags, opt, widget); } } void StyleCheckStyle::drawControl( ControlElement element, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { switch (element) { @@ -1727,14 +1739,14 @@ void StyleCheckStyle::drawControl( ControlElement element, if ( btnDefault || button->autoDefault() ) { // Compensate for default indicator - static int di = pixelMetric( PM_ButtonDefaultIndicator ); + static int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags ); br.addCoords( di, di, -di, -di ); } if ( btnDefault ) - drawPrimitive( PE_ButtonDefault, p, r, cg, flags ); + drawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags ); - drawPrimitive( PE_ButtonCommand, p, br, cg, flags ); + drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags ); break; } @@ -1750,15 +1762,15 @@ void StyleCheckStyle::drawControl( ControlElement element, // Shift button contents if pushed. if ( active ) { - x += pixelMetric(PM_ButtonShiftHorizontal, widget); - y += pixelMetric(PM_ButtonShiftVertical, widget); + x += pixelMetric(PM_ButtonShiftHorizontal, ceData, elementFlags, widget); + y += pixelMetric(PM_ButtonShiftVertical, ceData, elementFlags, widget); flags |= Style_Sunken; } // Does the button have a popup menu? if ( button->isMenuButton() ) { - int dx = pixelMetric( PM_MenuButtonIndicator, widget ); - drawPrimitive( PE_ArrowDown, p, TQRect(x + w - dx - 2, y + 2, dx, h - 4), + int dx = pixelMetric( PM_MenuButtonIndicator, ceData, elementFlags, widget ); + drawPrimitive( PE_ArrowDown, p, ceData, elementFlags, TQRect(x + w - dx - 2, y + 2, dx, h - 4), cg, flags, opt ); w -= dx; } @@ -1811,8 +1823,8 @@ void StyleCheckStyle::drawControl( ControlElement element, // Draw a focus rect if the button has focus if ( flags & Style_HasFocus ) - drawPrimitive( PE_FocusRect, p, - TQStyle::visualRect(subRect(SR_PushButtonFocusRect, widget), widget), + drawPrimitive( PE_FocusRect, p, ceData, elementFlags, + TQStyle::visualRect(subRect(SR_PushButtonFocusRect, ceData, elementFlags, widget), ceData, elementFlags), cg, flags ); break; } @@ -1828,7 +1840,7 @@ void StyleCheckStyle::drawControl( ControlElement element, TQRect tr = r; if ( t->identifier() == tb->currentTab() ) tr.setBottom( tr.bottom() - - pixelMetric( TQStyle::PM_DefaultFrameWidth, tb ) ); + pixelMetric( TQStyle::PM_DefaultFrameWidth, ceData, elementFlags, tb ) ); TQValueVector<StyleGuideViolation> violations = checkTitleStyle(t->text(), ShortTitle, HasAccels); renderViolations(violations, p, r, AlignCenter |ShowPrefix, t->text()); @@ -1837,7 +1849,7 @@ void StyleCheckStyle::drawControl( ControlElement element, flags & Style_Enabled, 0, removedXX(stripAccelViolations(t->text())) ); if ( (flags & Style_HasFocus) && !t->text().isEmpty() ) - drawPrimitive( PE_FocusRect, p, r, cg ); + drawPrimitive( PE_FocusRect, p, ceData, elementFlags, r, cg ); break; } @@ -1857,8 +1869,8 @@ void StyleCheckStyle::drawControl( ControlElement element, if (flags & Style_HasFocus) { - TQRect fr = visualRect(subRect(SR_CheckBoxFocusRect, widget), widget); - drawPrimitive(PE_FocusRect, p, fr, cg, flags); + TQRect fr = visualRect(subRect(SR_CheckBoxFocusRect, ceData, elementFlags, widget), ceData, elementFlags); + drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags); } break; } @@ -1878,8 +1890,8 @@ void StyleCheckStyle::drawControl( ControlElement element, if (flags & Style_HasFocus) { - TQRect fr = visualRect(subRect(SR_CheckBoxFocusRect, widget), widget); - drawPrimitive(PE_FocusRect, p, fr, cg, flags); + TQRect fr = visualRect(subRect(SR_CheckBoxFocusRect, ceData, elementFlags, widget), ceData, elementFlags); + drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags); } break; } @@ -1933,7 +1945,7 @@ void StyleCheckStyle::drawControl( ControlElement element, bool enabled = mi->isEnabled(); bool checkable = popupmenu->isCheckable(); bool active = flags & Style_Active; - bool etchtext = styleHint( SH_EtchDisabledText ); + bool etchtext = styleHint( SH_EtchDisabledText, ceData, elementFlags ); bool reverse = TQApplication::reverseLayout(); int x, y, w, h; r.rect( &x, &y, &w, &h ); @@ -1998,7 +2010,7 @@ void StyleCheckStyle::drawControl( ControlElement element, SFlags cflags = Style_Default; cflags |= active ? Style_Enabled : Style_On; - drawPrimitive( PE_CheckMark, p, TQRect( cx + itemFrame, y + itemFrame, + drawPrimitive( PE_CheckMark, p, ceData, elementFlags, TQRect( cx + itemFrame, y + itemFrame, checkcol - itemFrame*2, h - itemFrame*2), cg, cflags ); } @@ -2110,7 +2122,7 @@ void StyleCheckStyle::drawControl( ControlElement element, // Does the menu item have a submenu? if ( mi->popup() ) { PrimitiveElement arrow = reverse ? PE_ArrowLeft : PE_ArrowRight; - int dim = pixelMetric(PM_MenuButtonIndicator); + int dim = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags); TQRect vr = visualRect( TQRect( x + w - arrowHMargin - 2*itemFrame - dim, y + h / 2 - dim / 2, dim, dim), r ); @@ -2122,9 +2134,9 @@ void StyleCheckStyle::drawControl( ControlElement element, TQColorGroup g2( discol, cg.highlight(), white, white, enabled ? white : discol, discol, white ); - drawPrimitive( arrow, p, vr, g2, Style_Enabled ); + drawPrimitive( arrow, p, ceData, elementFlags, vr, g2, Style_Enabled ); } else - drawPrimitive( arrow, p, vr, cg, + drawPrimitive( arrow, p, ceData, elementFlags, vr, cg, enabled ? Style_Enabled : Style_Default ); } break; @@ -2164,16 +2176,18 @@ void StyleCheckStyle::drawControl( ControlElement element, } default: - KStyle::drawControl(element, p, widget, r, cg, flags, opt); + KStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget); } } void StyleCheckStyle::drawControlMask( ControlElement element, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { switch (element) { @@ -2190,20 +2204,22 @@ void StyleCheckStyle::drawControlMask( ControlElement element, } default: - KStyle::drawControlMask(element, p, widget, r, opt); + KStyle::drawControlMask(element, p, ceData, elementFlags, r, opt, widget); } } void StyleCheckStyle::drawComplexControl( ComplexControl control, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags, - SCFlags controls, - SCFlags active, - const TQStyleOption& opt ) const + SCFlags controls, + SCFlags active, + const TQStyleOption& opt, + const TQWidget *widget ) const { switch(control) { @@ -2247,8 +2263,8 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, // Get the button bounding box TQRect ar = TQStyle::visualRect( - querySubControlMetrics(CC_ComboBox, widget, SC_ComboBoxArrow), - widget ); + querySubControlMetrics(CC_ComboBox, ceData, elementFlags, SC_ComboBoxArrow, TQStyleOption::Default, widget), + ceData, elementFlags ); // Are we enabled? if ( widget->isEnabled() ) @@ -2258,7 +2274,7 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, if ( active & Style_Sunken ) flags |= Style_Sunken; - drawPrimitive(PE_ArrowDown, p, ar, cg, flags); + drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, ar, cg, flags); } // Draw an edit field if required @@ -2266,8 +2282,8 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, { const TQComboBox * cb = (const TQComboBox *) widget; TQRect re = TQStyle::visualRect( - querySubControlMetrics( CC_ComboBox, widget, - SC_ComboBoxEditField), widget ); + querySubControlMetrics( CC_ComboBox, ceData, elementFlags, + SC_ComboBoxEditField, TQStyleOption::Default, widget), ceData, elementFlags ); // Draw the indent if (cb->editable()) { @@ -2290,9 +2306,9 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, cg.brush( TQColorGroup::Highlight ) ); TQRect re = TQStyle::visualRect( - subRect(SR_ComboBoxFocusRect, cb), widget); + subRect(SR_ComboBoxFocusRect, ceData, elementFlags, cb), ceData, elementFlags); - drawPrimitive( PE_FocusRect, p, re, cg, + drawPrimitive( PE_FocusRect, p, ceData, elementFlags, re, cg, Style_FocusAtBorder, TQStyleOption(cg.highlight())); } } @@ -2305,8 +2321,8 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, const TQToolButton *toolbutton = (const TQToolButton *) widget; TQRect button, menuarea; - button = querySubControlMetrics(control, widget, SC_ToolButton, opt); - menuarea = querySubControlMetrics(control, widget, SC_ToolButtonMenu, opt); + button = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget); + menuarea = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget); SFlags bflags = flags, mflags = flags; @@ -2320,7 +2336,7 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, { // If we're pressed, on, or raised... if (bflags & (Style_Down | Style_On | Style_Raised)) - drawPrimitive(PE_ButtonTool, p, button, cg, bflags, opt); + drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt); // Check whether to draw a background pixmap else if ( toolbutton->parentWidget() && @@ -2362,14 +2378,14 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, if (controls & SC_ToolButtonMenu) { if (mflags & (Style_Down | Style_On | Style_Raised)) - drawPrimitive(PE_ButtonDropDown, p, menuarea, cg, mflags, opt); - drawPrimitive(PE_ArrowDown, p, menuarea, cg, mflags, opt); + drawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, opt); + drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, menuarea, cg, mflags, opt); } if (toolbutton->hasFocus() && !toolbutton->focusProxy()) { TQRect fr = toolbutton->rect(); fr.addCoords(3, 3, -3, -3); - drawPrimitive(PE_FocusRect, p, fr, cg); + drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg); } break; @@ -2377,8 +2393,8 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, default: - KStyle::drawComplexControl(control, p, widget, - r, cg, flags, controls, active, opt); + KStyle::drawComplexControl(control, p, ceData, elementFlags, + r, cg, flags, controls, active, opt, widget); break; } } @@ -2386,9 +2402,11 @@ void StyleCheckStyle::drawComplexControl( ComplexControl control, void StyleCheckStyle::drawComplexControlMask( ComplexControl control, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData ceData, + const ControlElementFlags elementFlags, const TQRect &r, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget *widget ) const { switch (control) { @@ -2406,12 +2424,12 @@ void StyleCheckStyle::drawComplexControlMask( ComplexControl control, } default: - KStyle::drawComplexControlMask(control, p, widget, r, opt); + KStyle::drawComplexControlMask(control, p, ceData, elementFlags, r, opt, widget); } } -TQRect StyleCheckStyle::subRect(SubRect r, const TQWidget *widget) const +TQRect StyleCheckStyle::subRect(SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const { // We want the focus rect for buttons to be adjusted from // the TQt3 defaults to be similar to TQt 2's defaults. @@ -2422,11 +2440,11 @@ TQRect StyleCheckStyle::subRect(SubRect r, const TQWidget *widget) const int dbw1 = 0, dbw2 = 0; if (button->isDefault() || button->autoDefault()) { - dbw1 = pixelMetric(PM_ButtonDefaultIndicator, widget); + dbw1 = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget); dbw2 = dbw1 * 2; } - int dfw1 = pixelMetric(PM_DefaultFrameWidth, widget) * 2, + int dfw1 = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) * 2, dfw2 = dfw1 * 2; return TQRect(wrect.x() + dfw1 + dbw1 + 1, @@ -2434,11 +2452,11 @@ TQRect StyleCheckStyle::subRect(SubRect r, const TQWidget *widget) const wrect.width() - dfw2 - dbw2 - 1, wrect.height() - dfw2 - dbw2 - 1); } else - return KStyle::subRect(r, widget); + return KStyle::subRect(r, ceData, elementFlags, widget); } -int StyleCheckStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const +int StyleCheckStyle::pixelMetric(PixelMetric m, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget) const { switch(m) { @@ -2465,15 +2483,17 @@ int StyleCheckStyle::pixelMetric(PixelMetric m, const TQWidget *widget) const } default: - return KStyle::pixelMetric(m, widget); + return KStyle::pixelMetric(m, ceData, elementFlags, widget); } } TQSize StyleCheckStyle::sizeFromContents( ContentsType contents, - const TQWidget* widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQSize &contentSize, - const TQStyleOption& opt ) const + const TQStyleOption& opt, + const TQWidget* widget ) const { switch (contents) { @@ -2483,8 +2503,8 @@ TQSize StyleCheckStyle::sizeFromContents( ContentsType contents, const TQPushButton* button = (const TQPushButton*) widget; int w = contentSize.width(); int h = contentSize.height(); - int bm = pixelMetric( PM_ButtonMargin, widget ); - int fw = pixelMetric( PM_DefaultFrameWidth, widget ) * 2; + int bm = pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ) * 2; w += bm + fw + 6; // ### Add 6 to make way for bold font. h += bm + fw; @@ -2495,7 +2515,7 @@ TQSize StyleCheckStyle::sizeFromContents( ContentsType contents, w = 80; // Compensate for default indicator - int di = pixelMetric( PM_ButtonDefaultIndicator ); + int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags ); w += di * 2; h += di * 2; } @@ -2566,15 +2586,17 @@ TQSize StyleCheckStyle::sizeFromContents( ContentsType contents, default: - return KStyle::tqsizeFromContents( contents, widget, contentSize, opt ); + return KStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget ); } } // Fix TQt's wacky image alignment TQPixmap StyleCheckStyle::stylePixmap(StylePixmap stylepixmap, - const TQWidget* widget, - const TQStyleOption& opt) const + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, + const TQStyleOption& opt, + const TQWidget* widget) const { switch (stylepixmap) { case SP_TitleBarMinButton: @@ -2585,166 +2607,169 @@ TQPixmap StyleCheckStyle::stylePixmap(StylePixmap stylepixmap, break; } - return KStyle::stylePixmap(stylepixmap, widget, opt); + return KStyle::stylePixmap(stylepixmap, ceData, elementFlags, opt, widget); } -bool StyleCheckStyle::eventFilter( TQObject *object, TQEvent *event ) +bool StyleCheckStyle::objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *event ) { - if (KStyle::eventFilter( object, event )) + if (KStyle::objectEventHandler( ceData, elementFlags, source, event )) return true; + if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) { + TQObject* object = reinterpret_cast<TQObject*>(source); - // Handle push button hover effects. - TQPushButton* button = dynamic_cast<TQPushButton*>(object); - if ( button ) - { - if ( (event->type() == TQEvent::Enter) && - (button->isEnabled()) ) { - hoverWidget = button; - button->repaint( false ); - } - else if ( (event->type() == TQEvent::Leave) && - (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) ) { - hoverWidget = 0L; - button->repaint( false ); - } - } - - if ( event->type() == TQEvent::Paint && object->inherits(TQLABEL_OBJECT_NAME_STRING) ) - { - TQLabel* lb = static_cast<TQLabel*>(TQT_TQWIDGET(object)); - if (lb->pixmap() || lb->picture() || lb->movie() || (lb->textFormat() == TQt::RichText) || - (lb->textFormat() == TQt::AutoText && TQStyleSheet::mightBeRichText(lb->text())) ) - { - return false; - } - - TQPainter p(lb); - - TQRect cr = lb->contentsRect(); - - int m = lb->indent(); - if ( m < 0 && lb->frameWidth() ) // no indent, but we do have a frame - m = lb->fontMetrics().width('x') / 2 - lb->margin(); - if ( m > 0 ) - { - int hAlign = TQApplication::horizontalAlignment( lb->alignment() ); - if ( hAlign & AlignLeft ) - cr.setLeft( cr.left() + m ); - if ( hAlign & AlignRight ) - cr.setRight( cr.right() - m ); - if ( lb->alignment() & AlignTop ) - cr.setTop( cr.top() + m ); - if ( lb->alignment() & AlignBottom ) - cr.setBottom( cr.bottom() - m ); - } - - TQValueVector<StyleGuideViolation> violations; - - if (TQCString(lb->name()) == "KJanusWidgetTitleLabel" || lb->font().bold()) + // Handle push button hover effects. + TQPushButton* button = dynamic_cast<TQPushButton*>(object); + if ( button ) { - // We're a page title - violations = checkTitleStyle(lb->text(), LongTitle, lb->buddy() ? HasAccels : NoAccels); - } - else - { - // We're probably, maybe, not a page title label - // Further checks might be needed, depending on how often this comes up in the wild - violations = checkSentenceStyle(lb->text(), lb->buddy() ? BuddiedWidget: BuddylessWidget, lb->buddy() ? HasAccels : NoAccels); - } - - if (lb->buddy()) - { - renderViolations(violations, &p, cr,lb->alignment() | ShowPrefix, lb->text() ); - // ordinary text or pixmap label - drawItem( &p, cr, lb->alignment(), lb->colorGroup(), lb->isEnabled(), - 0, removedXX(stripAccelViolations(lb->text())) ); - } - else - { - renderViolations(violations, &p, cr,lb->alignment(), lb->text() ); - - // ordinary text or pixmap label - drawItem( &p, cr, lb->alignment(), lb->colorGroup(), lb->isEnabled(), - 0, removedXX(stripAccelViolations(lb->text())) ); + if ( (event->type() == TQEvent::Enter) && + (button->isEnabled()) ) { + hoverWidget = button; + button->repaint( false ); + } + else if ( (event->type() == TQEvent::Leave) && + (TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget)) ) { + hoverWidget = 0L; + button->repaint( false ); + } } - - p.end(); - - return true; - } - - if ( event->type() == TQEvent::Paint && object->inherits(TQGROUPBOX_OBJECT_NAME_STRING) ) - { - TQPaintEvent * pevent = TQT_TQPAINTEVENT(event); - TQGroupBox* gb = static_cast<TQGroupBox*>(TQT_TQWIDGET(object)); - bool nestedGroupBox = false; - TQString stripped_title = removedXX(stripAccelViolations(gb->title())); - - //Walk parent hierarchy to check whether any are groupboxes too.. - TQObject* parent = TQT_TQOBJECT(gb); - - // GCC suggested parentheses around assignment used as truth value - // I suggested that it could eat me. GCC won. - while ( (parent = parent->parent()) ) + + if ( event->type() == TQEvent::Paint && object->inherits(TQLABEL_OBJECT_NAME_STRING) ) { - if (parent->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) + TQLabel* lb = static_cast<TQLabel*>(TQT_TQWIDGET(object)); + if (lb->pixmap() || lb->picture() || lb->movie() || (lb->textFormat() == TQt::RichText) || + (lb->textFormat() == TQt::AutoText && TQStyleSheet::mightBeRichText(lb->text())) ) { - nestedGroupBox = true; - break; + return false; + } + + TQPainter p(lb); + + TQRect cr = lb->contentsRect(); + + int m = lb->indent(); + if ( m < 0 && lb->frameWidth() ) // no indent, but we do have a frame + m = lb->fontMetrics().width('x') / 2 - lb->margin(); + if ( m > 0 ) + { + int hAlign = TQApplication::horizontalAlignment( lb->alignment() ); + if ( hAlign & AlignLeft ) + cr.setLeft( cr.left() + m ); + if ( hAlign & AlignRight ) + cr.setRight( cr.right() - m ); + if ( lb->alignment() & AlignTop ) + cr.setTop( cr.top() + m ); + if ( lb->alignment() & AlignBottom ) + cr.setBottom( cr.bottom() - m ); + } + + TQValueVector<StyleGuideViolation> violations; + + if (TQCString(lb->name()) == "KJanusWidgetTitleLabel" || lb->font().bold()) + { + // We're a page title + violations = checkTitleStyle(lb->text(), LongTitle, lb->buddy() ? HasAccels : NoAccels); } + else + { + // We're probably, maybe, not a page title label + // Further checks might be needed, depending on how often this comes up in the wild + violations = checkSentenceStyle(lb->text(), lb->buddy() ? BuddiedWidget: BuddylessWidget, lb->buddy() ? HasAccels : NoAccels); + } + + if (lb->buddy()) + { + renderViolations(violations, &p, cr,lb->alignment() | ShowPrefix, lb->text() ); + // ordinary text or pixmap label + drawItem( &p, cr, lb->alignment(), lb->colorGroup(), lb->isEnabled(), + 0, removedXX(stripAccelViolations(lb->text())) ); + } + else + { + renderViolations(violations, &p, cr,lb->alignment(), lb->text() ); + + // ordinary text or pixmap label + drawItem( &p, cr, lb->alignment(), lb->colorGroup(), lb->isEnabled(), + 0, removedXX(stripAccelViolations(lb->text())) ); + } + + p.end(); + + return true; } - - TQPainter paint( gb ); - if ( stripped_title.length() ) + + if ( event->type() == TQEvent::Paint && object->inherits(TQGROUPBOX_OBJECT_NAME_STRING) ) { - // draw title - TQFontMetrics fm = paint.fontMetrics(); - int h = fm.height(); - int tw = fm.width( stripped_title, stripped_title.length() ) + 2*fm.width(TQChar(' ')); - int x; - if ( gb->alignment() & AlignHCenter ) // center alignment - x = gb->frameRect().width()/2 - tw/2; - else if ( gb->alignment() & AlignRight ) // right alignment - x = gb->frameRect().width() - tw - 8; - else if ( gb->alignment() & AlignLeft ) // left alignment - x = 8; - else - { // auto align - if( TQApplication::reverseLayout() ) + TQPaintEvent * pevent = TQT_TQPAINTEVENT(event); + TQGroupBox* gb = static_cast<TQGroupBox*>(TQT_TQWIDGET(object)); + bool nestedGroupBox = false; + TQString stripped_title = removedXX(stripAccelViolations(gb->title())); + + //Walk parent hierarchy to check whether any are groupboxes too.. + TQObject* parent = TQT_TQOBJECT(gb); + + // GCC suggested parentheses around assignment used as truth value + // I suggested that it could eat me. GCC won. + while ( (parent = parent->parent()) ) + { + if (parent->inherits(TQGROUPBOX_OBJECT_NAME_STRING)) + { + nestedGroupBox = true; + break; + } + } + + TQPainter paint( gb ); + if ( stripped_title.length() ) + { + // draw title + TQFontMetrics fm = paint.fontMetrics(); + int h = fm.height(); + int tw = fm.width( stripped_title, stripped_title.length() ) + 2*fm.width(TQChar(' ')); + int x; + if ( gb->alignment() & AlignHCenter ) // center alignment + x = gb->frameRect().width()/2 - tw/2; + else if ( gb->alignment() & AlignRight ) // right alignment x = gb->frameRect().width() - tw - 8; - else + else if ( gb->alignment() & AlignLeft ) // left alignment x = 8; + else + { // auto align + if( TQApplication::reverseLayout() ) + x = gb->frameRect().width() - tw - 8; + else + x = 8; + } + TQRect r( x, 0, tw, h ); + + TQValueVector<StyleGuideViolation> violations = checkTitleStyle( gb->title(), ShortTitle, HasAccels ); + + renderViolations( violations, &paint, r, AlignCenter | ShowPrefix, gb->title() ); + + drawItem(&paint, r, AlignCenter | ShowPrefix, gb->colorGroup(), + gb->isEnabled(), 0, stripped_title ); + + paint.setClipRegion( pevent->region().subtract( r ) ); } - TQRect r( x, 0, tw, h ); - - TQValueVector<StyleGuideViolation> violations = checkTitleStyle( gb->title(), ShortTitle, HasAccels ); - - renderViolations( violations, &paint, r, AlignCenter | ShowPrefix, gb->title() ); - - drawItem(&paint, r, AlignCenter | ShowPrefix, gb->colorGroup(), - gb->isEnabled(), 0, stripped_title ); - - paint.setClipRegion( pevent->region().subtract( r ) ); - } - - if (nestedGroupBox) - { - paint.save(); - TQPen errorPen(TQt::red, 4, TQPen::DashDotDotLine); - paint.setPen(errorPen); - paint.drawRect( gb->frameRect() ); - paint.restore(); - } - else - { - tqdrawPrimitive( TQStyle::PE_GroupBoxFrame, &paint, gb->frameRect(), - gb->colorGroup(), TQStyle::Style_Default, - TQStyleOption(gb->lineWidth(), gb->midLineWidth(), - gb->frameShape(), gb->frameShadow()) ); + + if (nestedGroupBox) + { + paint.save(); + TQPen errorPen(TQt::red, 4, TQPen::DashDotDotLine); + paint.setPen(errorPen); + paint.drawRect( gb->frameRect() ); + paint.restore(); + } + else + { + drawPrimitive( TQStyle::PE_GroupBoxFrame, &paint, ceData, elementFlags, gb->frameRect(), + gb->colorGroup(), TQStyle::Style_Default, + TQStyleOption(gb->lineWidth(), gb->midLineWidth(), + gb->frameShape(), gb->frameShadow()) ); + } + return true; //We already drew the everything } - return true; //We already drew the everything } return false; diff --git a/scheck/scheck.h b/scheck/scheck.h index e4f411ac..ca3e4a76 100644 --- a/scheck/scheck.h +++ b/scheck/scheck.h @@ -8,7 +8,7 @@ * * Based on the KDE3 HighColor Style (version 1.0): * Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org> - * (C) 2001-2002 Fredrik Höglund <fredrik@kde.org> + * (C) 2001-2002 Fredrik H�glund <fredrik@kde.org> * * Drawing routines adapted from the KDE2 HCStyle, * Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> @@ -76,20 +76,24 @@ class StyleCheckStyle : public KStyle StyleCheckStyle( ); virtual ~StyleCheckStyle(); - void polish( TQWidget* widget ); - void unPolish( TQWidget* widget ); + void polish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); + void unPolish( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void * ); void drawKStylePrimitive( KStylePrimitive kpe, TQPainter* p, - const TQWidget* widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget* widget = 0 ) const; void drawPrimitive( PrimitiveElement pe, TQPainter* p, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, @@ -97,52 +101,62 @@ class StyleCheckStyle : public KStyle void drawControl( ControlElement element, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; void drawControlMask( ControlElement element, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; void drawComplexControl( ComplexControl control, TQPainter *p, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, SCFlags controls = SC_All, SCFlags active = SC_None, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; void drawComplexControlMask( ComplexControl control, TQPainter *p, - const TQWidget *widget, + const TQStyleControlElementData ceData, + const ControlElementFlags elementFlags, const TQRect &r, - const TQStyleOption& = TQStyleOption::Default ) const; + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; - int pixelMetric( PixelMetric m, + int pixelMetric( PixelMetric m, TQStyleControlElementData ceData, ControlElementFlags elementFlags, const TQWidget *widget = 0 ) const; TQSize sizeFromContents( ContentsType contents, - const TQWidget *widget, + TQStyleControlElementData ceData, + ControlElementFlags elementFlags, const TQSize &contentSize, - const TQStyleOption& opt ) const; + const TQStyleOption& opt, + const TQWidget *widget = 0 ) const; - TQRect subRect( SubRect r, + TQRect subRect( SubRect r, const TQStyleControlElementData ceData, const ControlElementFlags elementFlags, const TQWidget *widget ) const; // Fix TQt3's wacky image positions TQPixmap stylePixmap( StylePixmap stylepixmap, - const TQWidget *widget = 0, - const TQStyleOption& = TQStyleOption::Default ) const; + TQStyleControlElementData ceData, ControlElementFlags elementFlags, + const TQStyleOption& = TQStyleOption::Default, const TQWidget *widget = 0 ) const; protected: - bool eventFilter( TQObject *object, TQEvent *event ); + virtual bool objectEventHandler( TQStyleControlElementData ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); void renderGradient( TQPainter* p, const TQRect& r, |