/* $Id: klearlook.cpp,v 1.25 2006/04/26 18:55:41 jck Exp $ Klearlook (C) Joerg C. Koenig, 2005 jck@gmx.org ---- Based upon TQtCurve (C) Craig Drummond, 2003 Craig.Drummond@lycos.co.uk Bernhard Rosenkr�zer Preston Brown Than Ngo Released under the GNU General Public License (GPL) v2. ---- B???Curve is based on the KDE Light style, 2nd revision: Copyright(c)2000-2001 Trolltech AS (info@trolltech.com) Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "klearlook.h" #include #if KDE_VERSION >= 0x30200 #include #include #endif // Uncomment the following to enable gradients in toolbars and menubars // NOTE: Not yet complete!!! //#define TQTC_GRADIENT_TOOLBARS_AND_MENUBARS //static int HIGH_LIGHT_FACTORS[]={ 100, 100, 100, 101, 102, 103, 104, 105 /*def*/, 106, 107, 108 }; //#define HIGHLIGHT_FACTOR(X) (X<0||X>10) ? 105 : HIGH_LIGHT_FACTORS[X] #define TQTC_HIGHLIGHT_FACTOR 105 #define TQTC_BORDERED_FRAME_WIDTH 2 #define TQTC_DEF_FRAME_WIDTH 1 //#define TQTC_MIN_BTN_SIZE 10 #define TQTC_NO_SECT -1 #define MENU_POPUP_ITEM_HIGH_HI 7 #define MENU_POPUP_ITEM_HIGH_LO 5 //#define MENU_POPUP_SHADOW #define POS_DIV(a, b) ( (a)/(b) + ( ( (a) % (b) >= (b)/2 ) ? 1 : 0 ) ) static const int itemHMargin = 6; static const int itemFrame = 2; static const int arrowHMargin = 6; static const int rightBorder = 12; #if KDE_VERSION >= 0x30200 // Try to read $KDEHOME/share/config/kickerrc to find out if kicker is transparent... static TQString readEnvPath( const char *env ) { TQCString path = getenv( env ); return path.isEmpty() ? TQString() : TQFile::decodeName( path ); } static bool kickerIsTrans() { TQString kdeHome( readEnvPath( getuid() ? "KDEHOME" : "KDEROOTHOME" ) ), cfgFileName; bool trans = false; if ( kdeHome.isEmpty() ) cfgFileName = TQDir::homeDirPath() + "/.kde/share/config/kickerrc"; else cfgFileName = TQString( kdeHome ) + "/share/config/kickerrc"; TQFile cfgFile( cfgFileName ); if ( cfgFile.open( IO_ReadOnly ) ) { TQTextStream stream( &cfgFile ); TQString line; bool stop = false, inGen = false; while ( !stream.atEnd() && !stop ) { line = stream.readLine(); if ( inGen ) { if ( 0 == line.tqfind( "Transparent=" ) ) // Found it! { if ( -1 != line.tqfind( "true" ) ) trans = true; stop = true; } else if ( line[ 0 ] == TQChar( '[' ) ) // Then wasn't in General section... stop = true; } else if ( 0 == line.tqfind( "[General]" ) ) inGen = true; } cfgFile.close(); } return trans; } #endif inline int limit( double c ) { return c < 0.0 ? 0 : c > 255.0 ? 255 : ( int ) c; } inline TQColor midColor( const TQColor &a, const TQColor &b, double factor = 1.0 ) { return TQColor( ( a.red() + limit( b.red() * factor ) ) >> 1, ( a.green() + limit( b.green() * factor ) ) >> 1, ( a.blue() + limit( b.blue() * factor ) ) >> 1 ); } // Copied from Keramik... static bool isFormWidget( const TQWidget *widget ) { //Form widgets are in the KHTMLView, but that has 2 further inner levels //of widgets - TQClipperWidget, and outside of that, TQViewportWidget TQWidget * potentialClipPort = widget->parentWidget(); if ( !potentialClipPort || potentialClipPort->isTopLevel() ) return false; TQWidget *potentialViewPort = potentialClipPort->parentWidget(); if ( !potentialViewPort || potentialViewPort->isTopLevel() || qstrcmp( potentialViewPort->name(), "qt_viewport" ) ) return false; TQWidget *potentialKHTML = potentialViewPort->parentWidget(); if ( !potentialKHTML || potentialKHTML->isTopLevel() || qstrcmp( potentialKHTML->className(), "KHTMLView" ) ) return false; return true; } static void rgb2hls( double *r, double *g, double *b ) { double min; double max; double red; double green; double blue; double h, l, s; double delta; red = *r; green = *g; blue = *b; if (red > green) { if (red > blue) max = red; else max = blue; if (green < blue) min = green; else min = blue; } else { if (green > blue) max = green; else max = blue; if (red < blue) min = red; else min = blue; } l = (max + min) / 2; s = 0; h = 0; if (max != min) { if (l <= 0.5) s = (max - min) / (max + min); else s = (max - min) / (2 - max - min); delta = max -min; if (red == max) h = (green - blue) / delta; else if (green == max) h = 2 + (blue - red) / delta; else if (blue == max) h = 4 + (red - green) / delta; h *= 60; if (h < 0.0) h += 360; } *r = h; *g = l; *b = s; } static void hls2rgb( double *h, double *l, double *s ) { double hue; double lightness; double saturation; double m1, m2; double r, g, b; lightness = *l; saturation = *s; if (lightness <= 0.5) m2 = lightness * (1 + saturation); else m2 = lightness + saturation - lightness * saturation; m1 = 2 * lightness - m2; if (saturation == 0) { *h = lightness; *l = lightness; *s = lightness; } else { hue = *h + 120; while (hue > 360) hue -= 360; while (hue < 0) hue += 360; if (hue < 60) r = m1 + (m2 - m1) * hue / 60; else if (hue < 180) r = m2; else if (hue < 240) r = m1 + (m2 - m1) * (240 - hue) / 60; else r = m1; hue = *h; while (hue > 360) hue -= 360; while (hue < 0) hue += 360; if (hue < 60) g = m1 + (m2 - m1) * hue / 60; else if (hue < 180) g = m2; else if (hue < 240) g = m1 + (m2 - m1) * (240 - hue) / 60; else g = m1; hue = *h - 120; while (hue > 360) hue -= 360; while (hue < 0) hue += 360; if (hue < 60) b = m1 + (m2 - m1) * hue / 60; else if (hue < 180) b = m2; else if (hue < 240) b = m1 + (m2 - m1) * (240 - hue) / 60; else b = m1; *h = r; *l = g; *s = b; } } static bool equal( double d1, double d2 ) { return ( fabs( d1 - d2 ) < 0.0001 ); } static void shade( const TQColor &a, TQColor *b, float k ) { if ( equal( k, 1.0 ) ) * b = a; else { double red = a.red() / 256.0, green = a.green() / 256.0, blue = a.blue() / 256.0; rgb2hls( &red, &green, &blue ); green *= k; if ( green > 1.0 ) green = 1.0; else if ( green < 0.0 ) green = 0.0; blue *= k; if ( blue > 1.0 ) blue = 1.0; else if ( blue < 0.0 ) blue = 0.0; hls2rgb( &red, &green, &blue ); b->setRgb( limit( red * 256 ), limit( green * 256 ), limit( blue * 256 ) ); } } static void shadeGradient( const TQColor &base, TQColor *vals ) { vals[ KlearlookStyle::GRADIENT_BASE ] = base; shade( vals[ KlearlookStyle::GRADIENT_BASE ], &( vals[ KlearlookStyle::GRADIENT_TOP ] ), SHADE_GRADIENT_TOP ); shade( vals[ KlearlookStyle::GRADIENT_BASE ], &( vals[ KlearlookStyle::GRADIENT_BOTTOM ] ), SHADE_GRADIENT_BOTTOM ); shade( vals[ KlearlookStyle::GRADIENT_BASE ], &( vals[ KlearlookStyle::GRADIENT_LIGHT ] ), SHADE_GRADIENT_LIGHT ); shade( vals[ KlearlookStyle::GRADIENT_BASE ], &( vals[ KlearlookStyle::GRADIENT_DARK ] ), SHADE_GRADIENT_DARK ); } static void drawLines( TQPainter *p, const TQRect &r, bool horiz, int nLines, int offset, const TQColor *cols, int startOffset, bool etched, bool lightGradient ) { int space = ( nLines * 2 ) + ( nLines - 1 ), x = horiz ? r.x() : r.x() + ( ( r.width() - space ) >> 1 ), y = horiz ? r.y() + ( ( r.height() - space ) >> 1 ) : r.y(), x2 = r.x() + r.width() - 1, y2 = r.y() + r.height() - 1, i, displacement = etched ? 1 : 0; if ( horiz ) { if ( startOffset && y + startOffset > 0 ) y += startOffset; p->setPen( cols[ etched ? lightGradient ? 3 : 4 : 0 ] ); for ( i = 0; i < space; i += 3 ) p->drawLine( x + offset, y + i, x2 - ( offset + displacement ), y + i ); p->setPen( cols[ etched ? 0 : lightGradient ? 3 : 4 ] ); for ( i = 1; i < space; i += 3 ) p->drawLine( x + offset + displacement, y + i - 2, x2 - offset, y + i - 2); } else { if ( startOffset && x + startOffset > 0 ) x += startOffset; p->setPen( cols[ etched ? lightGradient ? 3 : 4 : 0 ] ); for ( i = 0; i < space; i += 3 ) p->drawLine( x + i, y + offset, x + i, y2 - ( offset + displacement ) ); p->setPen( cols[ etched ? 0 : lightGradient ? 3 : 4 ] ); for ( i = 1; i < space; i += 3 ) p->drawLine( x + i -2, y + offset + displacement, x + i -2, y2 - offset ); } } inline TQColor getFill( TQStyle::SFlags flags, const TQColor *use ) { return !( flags & TQStyle::Style_Enabled ) ? use[ 1 ] : flags & TQStyle::Style_Down ? use[ 3 ] : flags & TQStyle::Style_MouseOver ? flags & ( TQStyle::Style_On | TQStyle::Style_Sunken ) ? TQColor(use[ 3 ].light( TQTC_HIGHLIGHT_FACTOR )) : TQColor(use[ NUM_SHADES ].light( TQTC_HIGHLIGHT_FACTOR )) : flags & ( TQStyle::Style_On | TQStyle::Style_Sunken ) ? use[ 3 ] : use[ NUM_SHADES ]; } #ifdef USE_SINGLE_STYLE KlearlookStyle::KlearlookStyle() #else KlearlookStyle::KlearlookStyle( bool gpm, bool bb, bool bf, bool round, EGroove st, h, bool ge, bool va, bool bdt, bool crlh, EDefBtnIndicator dbi, ETBarBorder tbb, ELvExpander lve, ELvLines lvl, bool lvd, bool ico, int popuplvl ) ) #endif : KStyle( AllowMenuTransparency, WindowsStyleScrollBar ), themedApp( APP_OTHER ), #ifndef USE_SINGLE_STYLE borderButton( bb ), borderFrame( bf ), rounded( round ), etchedSlider( etched ), appearance( ge ? APPEARANCE_GRADIENT : APPEARANCE_FLAT ), pmProfile( PROFILE_SUNKEN ), vArrow( va ), boldDefText( bdt ), crLabelHighlight( crlh ), lvDark( lvd ), defBtnIndicator( dbi ), sliderThumbs( st ), handles( h ), toolbarBorders( tbb ), lvExpander( lve ), lvLines( lvl ), menuIcons( ico ), borderSplitter( true ), popupmenuHighlightLevel(popuplvl) #endif #if KDE_VERSION >= 0x30200 isTransKicker( false ), #endif hover( HOVER_NONE ), oldCursor( -1, -1 ), formMode( false ), hoverWidget( NULL ), hoverSect( TQTC_NO_SECT ) { TQSettings s; contrast = s.readNumEntry( "/TQt/KDE/contrast", 7 ); if ( contrast < 0 || contrast > 10 ) contrast = 7; #ifdef USE_SINGLE_STYLE borderButton = borderFrame = s.readBoolEntry( "/klearlookstyle/Settings/border", true ); rounded = borderButton ? s.readBoolEntry( "/klearlookstyle/Settings/round", true ) : false; menuIcons = s.readBoolEntry( "/klearlookstyle/Settings/icons", true ); darkMenubar = s.readBoolEntry( "/klearlookstyle/Settings/darkMenubar", true ); popupmenuHighlightLevel = s.readNumEntry( "/klearlookstyle/Settings/popupmenuHighlightLevel", 3); TQString tmp = s.readEntry( "/klearlookstyle/Settings/toolbarBorders", TQString() ); toolbarBorders = tmp.isEmpty() ? TB_LIGHT : qtc_to_tbar_border( tmp.latin1() ); bool etched = s.readBoolEntry( "/klearlookstyle/Settings/etched", true ); tmp = s.readEntry( "/klearlookstyle/Settings/sliderThumbs", TQString() ); sliderThumbs = tmp.isEmpty() ? etched ? GROOVE_SUNKEN : GROOVE_RAISED : qtc_to_groove( tmp.latin1() ); tmp = s.readEntry( "/klearlookstyle/Settings/lvExpander", TQString() ); lvExpander = tmp.isEmpty() ? LV_EXP_ARR : qtc_to_lv_expander( tmp.latin1() ); tmp = s.readEntry( "/klearlookstyle/Settings/lvLines", TQString() ); lvLines = tmp.isEmpty() ? LV_LINES_SOLID : qtc_to_lv_lines( tmp.latin1() ); lvDark = s.readBoolEntry( "/klearlookstyle/Settings/lvDark", false ); handles = qtc_to_groove( s.readEntry( "/klearlookstyle/Settings/sliderThumbs", DEF_HANDLE_STR ).latin1() ); if ( GROOVE_NONE == handles ) handles = GROOVE_RAISED; appearance = qtc_to_appearance( s.readEntry( "/klearlookstyle/Settings/appearance", DEF_APPEARANCE_STR ).latin1() ); pmProfile = qtc_to_profile( s.readEntry( "/klearlookstyle/Settings/pm", DEF_PROFILE_STR ).latin1() ); vArrow = s.readBoolEntry( "/klearlookstyle/Settings/vArrow", false ); boldDefText = s.readBoolEntry( "/klearlookstyle/Settings/embolden", false ); crLabelHighlight = s.readBoolEntry( "/klearlookstyle/Settings/crLabelHighlight", false ); defBtnIndicator = qtc_to_ind( s.readEntry( "/klearlookstyle/Settings/defBtnIndicator", DEF_IND_STR ).latin1() ); //if(!boldDefText && IND_NONE==defBtnIndicator) // defBtnIndicator=IND_CORNER; borderSplitter = s.readBoolEntry( "/klearlookstyle/Settings/borderSplitter", false ); #endif if ( PROFILE_RAISED != pmProfile ) shadeColors( tqApp->tqpalette().active().highlight(), menuPbar ); else shadeGradient( tqApp->tqpalette().active().highlight(), menuPbar ); shadeColors( tqApp->tqpalette().active().background(), gray ); shadeColors( tqApp->tqpalette().active().button(), button ); } void KlearlookStyle::polish( TQApplication *app ) { if ( !qstrcmp( app->argv() [ 0 ], "kicker" ) || !qstrcmp( app->argv() [ 0 ], "appletproxy" ) ) { themedApp = APP_KICKER; #if KDE_VERSION >= 0x30200 isTransKicker = rounded && kickerIsTrans(); #endif } else if ( !qstrcmp( app->argv() [ 0 ], "korn" ) ) { themedApp = APP_KORN; #if KDE_VERSION >= 0x30200 isTransKicker = rounded && kickerIsTrans(); #endif } else themedApp = qstrcmp( tqApp->argv() [ 0 ], "soffice.bin" ) ? APP_OTHER : APP_OPENOFFICE; } void KlearlookStyle::polish( TQPalette &pal ) { int c = TQSettings().readNumEntry( "/TQt/KDE/contrast", 7 ); bool newContrast = false; if ( c < 0 || c > 10 ) c = 7; if ( c != contrast ) { contrast = c; newContrast = true; } if ( newContrast || gray[ NUM_SHADES ] != tqApp->tqpalette().active().background() ) shadeColors( tqApp->tqpalette().active().background(), gray ); if ( newContrast || button[ NUM_SHADES ] != tqApp->tqpalette().active().button() ) shadeColors( tqApp->tqpalette().active().button(), button ); if ( PROFILE_RAISED == pmProfile ) { if ( newContrast || menuPbar[ NUM_SHADES ] != tqApp->tqpalette().active().highlight() ) shadeColors( tqApp->tqpalette().active().highlight(), menuPbar ); } else if ( tqApp->tqpalette().active().highlight() != menuPbar[ GRADIENT_BASE ] ) shadeGradient( tqApp->tqpalette().active().highlight(), menuPbar ); const TQColorGroup &actGroup = pal.active(), &inactGroup = pal.inactive(); const TQColor *use = backgroundColors( actGroup ); TQColorGroup newAct( actGroup.foreground(), actGroup.button(), use[ 0 ], use[ 5 ], actGroup.mid(), actGroup.text(), actGroup.brightText(), actGroup.base(), actGroup.background() ); newAct.setColor( TQColorGroup::Highlight, actGroup.color( TQColorGroup::Highlight ) ); pal.setActive( newAct ); use = backgroundColors( inactGroup ); TQColorGroup newInact( inactGroup.foreground(), inactGroup.button(), use[ 0 ], use[ 5 ], inactGroup.mid(), inactGroup.text(), inactGroup.brightText(), inactGroup.base(), inactGroup.background() ); newInact.setColor( TQColorGroup::Highlight, inactGroup.color( TQColorGroup::Highlight ) ); pal.setInactive( newInact ); } static const char * kdeToolbarWidget = "kde toolbar widget"; void KlearlookStyle::polish( TQWidget *widget ) { if ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || widget->inherits( TQSPLITTERHANDLE_OBJECT_NAME_STRING ) ) { widget->setMouseTracking( true ); widget->installEventFilter( this ); } else if ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || widget->inherits( "TQToolBarExtensionWidget" ) ) { widget->setBackgroundMode( TQWidget::PaletteBackground ); widget->installEventFilter( this ); } else if ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || ::tqqt_cast( widget ) ) widget->setBackgroundMode( TQWidget::PaletteBackground ); else if ( widget->inherits( "KToolBarSeparator" ) ) { widget->setBackgroundMode( TQWidget::NoBackground ); widget->installEventFilter( this ); } else if ( ::tqqt_cast( widget ) ) { widget->setMouseTracking( true ); widget->installEventFilter( this ); widget->setBackgroundMode( TQWidget::NoBackground ); } else if ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) ) { widget->setMouseTracking( true ); widget->installEventFilter( this ); } else if ( 0 == qstrcmp( widget->name(), kdeToolbarWidget ) ) { widget->installEventFilter( this ); widget->setBackgroundMode( TQWidget::NoBackground ); // We paint the whole background. } KStyle::polish( widget ); } void KlearlookStyle::unPolish( TQWidget *widget ) { if ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || widget->inherits( TQSPLITTERHANDLE_OBJECT_NAME_STRING ) ) { widget->setMouseTracking( false ); widget->removeEventFilter( this ); } else if ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || widget->inherits( "TQToolBarExtensionWidget" ) ) { widget->setBackgroundMode( TQWidget::PaletteButton ); widget->removeEventFilter( this ); } else if ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || ::tqqt_cast( widget ) ) widget->setBackgroundMode( TQWidget::PaletteBackground ); else if ( widget->inherits( "KToolBarSeparator" ) ) { widget->setBackgroundMode( PaletteBackground ); widget->removeEventFilter( this ); } else if ( ::tqqt_cast( widget ) ) { widget->setMouseTracking( false ); widget->removeEventFilter( this ); widget->setBackgroundMode( TQWidget::PaletteButton ); } else if ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) ) { widget->setMouseTracking( false ); widget->removeEventFilter( this ); } else if ( 0 == qstrcmp( widget->name(), kdeToolbarWidget ) ) { widget->removeEventFilter( this ); widget->setBackgroundMode( PaletteBackground ); } KStyle::unPolish( widget ); } bool KlearlookStyle::eventFilter( TQObject *object, TQEvent *event ) { if ( object->tqparent() && 0 == qstrcmp( object->name(), kdeToolbarWidget ) ) { // Draw background for custom widgets in the toolbar that have specified a "kde toolbar widget" name. if ( TQEvent::Paint == event->type() ) { TQWidget * widget = TQT_TQWIDGET( object ), *tqparent = TQT_TQWIDGET( object->tqparent() ); #ifdef TQTC_GRADIENT_TOOLBARS_AND_MENUBARS // Find the top-level toolbar of this widget, since it may be nested in other // widgets that are on the toolbar. int x_offset = widget->x(), y_offset = widget->y(); while ( tqparent && tqparent->tqparent() && !qstrcmp( tqparent->name(), kdeToolbarWidget ) ) { x_offset += tqparent->x(); y_offset += tqparent->y(); tqparent = TQT_TQWIDGET( tqparent->tqparent() ); } TQRect pr( tqparent->rect() ); bool horiz_grad = pr.width() < pr.height(); // Check if the tqparent is a TQToolbar, and use its orientation, else guess. TQToolBar *toolbar = dynamic_cast( tqparent ); if ( toolbar ) horiz_grad = toolbar->orientation() == TQt::Vertical; drawBevelGradient( tqparent->tqcolorGroup().background(), true, 1, &TQPainter( widget ), TQRect( x_offset, y_offset, pr.width(), pr.height() ), horiz_grad, SHADE_BAR_LIGHT, SHADE_BAR_DARK ); #else TQPainter( widget ).fillRect( widget->rect(), tqparent->tqcolorGroup().background() ); #endif return false; // Now draw the contents } } else if ( object->inherits( "KToolBarSeparator" ) && TQEvent::Paint == event->type() ) { TQFrame * frame = dynamic_cast( object ); if ( frame && TQFrame::NoFrame != frame->frameShape() ) { TQPainter painter( frame ); if ( TQFrame::VLine == frame->frameShape() ) tqdrawPrimitive( PE_DockWindowSeparator, &painter, frame->rect(), frame->tqcolorGroup(), Style_Horizontal ); else if ( TQFrame::HLine == frame->frameShape() ) tqdrawPrimitive( PE_DockWindowSeparator, &painter, frame->rect(), frame->tqcolorGroup() ); else return false; return true; // been drawn! } } switch ( event->type() ) { case TQEvent::Enter: if ( object->isWidgetType() ) { hoverWidget = ( TQWidget * ) object; if ( hoverWidget && hoverWidget->isEnabled() ) { if ( redrawHoverWidget() ) { hoverWidget->tqrepaint( false ); if ( APP_KICKER == themedApp ) hover = HOVER_NONE; } oldCursor = TQCursor::pos(); } else hoverWidget = NULL; } break; case TQEvent::Leave: if ( hoverWidget && TQT_BASE_OBJECT(object) == TQT_BASE_OBJECT(hoverWidget) ) { oldCursor.setX( -1 ); oldCursor.setY( -1 ); hoverWidget = NULL; ( ( TQWidget * ) object ) ->tqrepaint( false ); } break; case TQEvent::MouseMove: if ( hoverWidget && object->isWidgetType() ) { if ( redrawHoverWidget() ) { hoverWidget->tqrepaint( false ); if ( APP_KICKER == themedApp ) hover = HOVER_NONE; } oldCursor = TQCursor::pos(); } break; default: break; } return KStyle::eventFilter( object, event ); } void KlearlookStyle::drawLightBevelButton( TQPainter *p, const TQRect &r, const TQColorGroup &cg, TQStyle::SFlags flags, bool useGrad, ERound round, const TQColor &fill, const TQColor *custom, bool light ) const { TQRect br( r ); bool sunken = ( flags & ( TQStyle::Style_Down | TQStyle::Style_On | TQStyle::Style_Sunken ) ); int dark = borderButton ? 4 : 5, c1 = sunken ? dark : light ? 6 : 0; p->save(); if ( !borderButton ) br.addCoords( -1, -1, 1, 1 ); if ( ( sunken && !borderButton ) || ( !sunken && flags & TQStyle::Style_Raised ) ) { p->setPen( custom ? custom[ c1 ] : gray[ c1 ] ); if ( APPEARANCE_LIGHT_GRADIENT != appearance ) { int c2 = sunken ? 0 : dark; p->drawLine( br.x() + 1, br.y() + 2, br.x() + 1, br.y() + br.height() - 3 ); // left p->drawLine( br.x() + 1, br.y() + 1, br.x() + br.width() - 2, br.y() + 1 ); // top p->setPen( custom ? custom[ c2 ] : gray[ c2 ] ); p->drawLine( br.x() + br.width() - 2, br.y() + 1, br.x() + br.width() - 2, br.y() + br.height() - 3 ); // right p->drawLine( br.x() + 1, br.y() + br.height() - 2, br.x() + br.width() - 2, br.y() + br.height() - 2 ); // bottom br.addCoords( 2, 2, -2, -2 ); } else { p->drawLine( br.x() + 1, br.y() + 2, br.x() + 1, br.y() + br.height() - 2 ); // left p->drawLine( br.x() + 1, br.y() + 1, br.x() + br.width() - 2, br.y() + 1 ); // top br.addCoords( 2, 2, -1, -1 ); } } else br.addCoords( 1, 1, -1, -1 ); // fill if ( useGrad && APPEARANCE_FLAT != appearance ) { drawBevelGradient( fill.dark( 100 ), !sunken, 0, p, TQRect( br.left() - 1, br.top() - 1, br.width() + 2, br.height() + 2 ), flags & Style_Horizontal, sunken ? SHADE_BEVEL_BUTTON_GRAD_LIGHT( appearance ) : SHADE_BEVEL_BUTTON_GRAD_LIGHT( appearance ), sunken ? SHADE_BEVEL_BUTTON_GRAD_DARK( appearance ) : SHADE_BEVEL_BUTTON_GRAD_DARK( appearance ) ); } else p->fillRect( br, fill ); if ( borderButton ) if ( rounded && ROUNDED_NONE != round ) { bool wide = r.width() >= TQTC_MIN_BTN_SIZE, tall = r.height() >= TQTC_MIN_BTN_SIZE; TQColor border( flags & Style_ButtonDefault && IND_FONT_COLOUR == defBtnIndicator & flags & Style_Enabled ? cg.text() : custom ? custom[ 5 ] : gray[ 5 ] ); p->setPen( border.light(80) ); switch ( round ) { case ROUNDED_ALL: p->drawLine( r.x() + 2, r.y(), r.x() + r.width() - 3, r.y() ); p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 3 ); p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( tall && wide ) { p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !( tall && wide ) ) { p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } if ( !formMode ) { if ( tall && wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x() + r.width() - 1, r.y() ); p->drawPoint( r.x(), r.y() + r.height() - 1 ); p->drawPoint( r.x() + r.width() - 1, r.y() + r.height() - 1 ); } break; case ROUNDED_TOP: p->drawLine( r.x() + 2, r.y(), r.x() + r.width() - 3, r.y() ); p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 1 ); if ( wide ) { p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !wide ) { p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); } if ( !formMode ) { if ( wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x() + r.width() - 1, r.y() ); } break; case ROUNDED_BOTTOM: p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 2, r.y() ); p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y(), r.x(), r.y() + r.height() - 3 ); p->drawLine( r.x() + r.width() - 1, r.y(), r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( wide ) { p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !wide ) { p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } if ( !formMode ) { if ( wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() + r.height() - 1 ); p->drawPoint( r.x() + r.width() - 1, r.y() + r.height() - 1 ); } break; case ROUNDED_LEFT: p->drawLine( r.x() + 2, r.y(), r.x() + r.width() - 2, r.y() ); p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 3 ); p->drawLine( r.x() + r.width() - 1, r.y(), r.x() + r.width() - 1, r.y() + r.height() - 1 ); if ( tall ) { p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !tall ) { p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); } if ( !formMode ) { if ( tall ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x(), r.y() + r.height() - 1 ); } break; case ROUNDED_RIGHT: p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 3, r.y() ); p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y(), r.x(), r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( tall ) { p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !tall ) { p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } if ( !formMode ) { if ( tall ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x() + r.width() - 1, r.y() ); p->drawPoint( r.x() + r.width() - 1, r.y() + r.height() - 1 ); } break; default: break; } } else { p->setPen( flags & Style_ButtonDefault && IND_FONT_COLOUR == defBtnIndicator ? cg.text() : custom ? custom[ 5 ] : gray[ 5 ] ); p->setBrush( NoBrush ); p->drawRect( r ); } p->restore(); } void KlearlookStyle::drawLightBevel( TQPainter *p, const TQRect &r, const TQColorGroup &cg, TQStyle::SFlags flags, bool useGrad, ERound round, const TQColor &fill, const TQColor *custom, bool light ) const { TQRect br( r ); bool sunken = ( flags & ( TQStyle::Style_Down | TQStyle::Style_On | TQStyle::Style_Sunken ) ); int dark = borderButton ? 4 : 5, c1 = sunken ? dark : light ? 6 : 0; p->save(); if ( !borderButton ) br.addCoords( -1, -1, 1, 1 ); if ( ( sunken && !borderButton ) || ( !sunken && flags & TQStyle::Style_Raised ) ) { p->setPen( custom ? custom[ c1 ] : gray[ c1 ] ); if ( APPEARANCE_LIGHT_GRADIENT != appearance ) { int c2 = sunken ? 0 : dark; p->drawLine( br.x() + 1, br.y() + 2, br.x() + 1, br.y() + br.height() - 3 ); // left p->drawLine( br.x() + 1, br.y() + 1, br.x() + br.width() - 2, br.y() + 1 ); // top p->setPen( custom ? custom[ c2 ] : gray[ c2 ] ); p->drawLine( br.x() + br.width() - 2, br.y() + 1, br.x() + br.width() - 2, br.y() + br.height() - 3 ); // right p->drawLine( br.x() + 1, br.y() + br.height() - 2, br.x() + br.width() - 2, br.y() + br.height() - 2 ); // bottom br.addCoords( 2, 2, -2, -2 ); } else { p->drawLine( br.x() + 1, br.y() + 2, br.x() + 1, br.y() + br.height() - 2 ); // left p->drawLine( br.x() + 1, br.y() + 1, br.x() + br.width() - 2, br.y() + 1 ); // top br.addCoords( 2, 2, -1, -1 ); } } else br.addCoords( 1, 1, -1, -1 ); // fill if ( useGrad && APPEARANCE_FLAT != appearance ) { drawBevelGradient( fill, !sunken, 0, p, TQRect( br.left() - 1, br.top() - 1, br.width() + 2, br.height() + 2 ), flags & Style_Horizontal, sunken ? SHADE_BEVEL_GRAD_SEL_LIGHT( appearance ) : SHADE_BEVEL_GRAD_LIGHT( appearance ), sunken ? SHADE_BEVEL_GRAD_SEL_DARK( appearance ) : SHADE_BEVEL_GRAD_DARK( appearance ) ); } else { p->fillRect( br, fill ); } if ( borderButton ) if ( rounded && ROUNDED_NONE != round ) { bool wide = r.width() >= TQTC_MIN_BTN_SIZE, tall = r.height() >= TQTC_MIN_BTN_SIZE; TQColor border = menuPbar[ GRADIENT_BASE ].dark( 130 ); p->setPen( border ); switch ( round ) { case ROUNDED_ALL: p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 2, r.y() ); // top p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); // bottom p->drawLine( r.x(),r.y() + 1, r.x(),r.y() + r.height() - 2 ); // left p->drawLine( r.x() + r.width() - 1, r.y() + 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); // right //p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); //p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 3 ); //p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( tall && wide ) { //p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); //p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); //p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); //p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !( tall && wide ) ) { //p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); //p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); //p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); //p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } if ( !formMode ) { if ( tall && wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); //p->drawPoint( r.x(), r.y() ); //p->drawPoint( r.x() + r.width() - 1, r.y() ); //p->drawPoint( r.x(), r.y() + r.height() - 1 ); //p->drawPoint( r.x() + r.width() - 1, r.y() + r.height() - 1 ); } break; case ROUNDED_TOP: p->drawLine( r.x() + 2, r.y(), r.x() + r.width() - 3, r.y() ); p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 1 ); if ( wide ) { p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !wide ) { p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); } if ( !formMode ) { if ( wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x() + r.width() - 1, r.y() ); } break; case ROUNDED_BOTTOM: p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 2, r.y() ); p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y(), r.x(), r.y() + r.height() - 3 ); p->drawLine( r.x() + r.width() - 1, r.y(), r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( wide ) { p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !wide ) { p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } if ( !formMode ) { if ( wide ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() + r.height() - 1 ); p->drawPoint( r.x() + r.width() - 1, r.y() + r.height() - 1 ); } break; case ROUNDED_LEFT: p->drawLine( r.x() + 2, r.y(), r.x() + r.width() - 2, r.y() ); p->drawLine( r.x() + 2, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 2, r.x(), r.y() + r.height() - 3 ); p->drawLine( r.x() + r.width() - 1, r.y(), r.x() + r.width() - 1, r.y() + r.height() - 1 ); if ( tall ) { p->drawPoint( r.x() + 1, r.y() + r.height() - 2 ); p->drawPoint( r.x() + 1, r.y() + 1 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !tall ) { p->drawLine( r.x(), r.y() + 1, r.x() + 1, r.y() ); p->drawLine( r.x(), r.y() + r.height() - 2, r.x() + 1, r.y() + r.height() - 1 ); } if ( !formMode ) { if ( tall ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x(), r.y() + r.height() - 1 ); } break; case ROUNDED_RIGHT: p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 3, r.y() ); p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 3, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y(), r.x(), r.y() + r.height() - 1 ); p->drawLine( r.x() + r.width() - 1, r.y() + 2, r.x() + r.width() - 1, r.y() + r.height() - 3 ); if ( tall ) { p->drawPoint( r.x() + r.width() - 2, r.y() + 1 ); p->drawPoint( r.x() + r.width() - 2, r.y() + r.height() - 2 ); p->setPen( midColor( border, cg.background() ) ); } if ( !formMode || !tall ) { p->drawLine( r.x() + r.width() - 2, r.y(), r.x() + r.width() - 1, r.y() + 1 ); p->drawLine( r.x() + r.width() - 2, r.y() + r.height() - 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } if ( !formMode ) { if ( tall ) p->setPen( cg.background() ); else p->setPen( midColor( custom ? custom[ 3 ] : gray[ 3 ], cg.background() ) ); p->drawPoint( r.x() + r.width() - 1, r.y() ); p->drawPoint( r.x() + r.width() - 1, r.y() + r.height() - 1 ); } break; default: break; } } else { p->setPen( flags & Style_ButtonDefault && IND_FONT_COLOUR == defBtnIndicator ? cg.text() : custom ? custom[ 5 ] : gray[ 5 ] ); p->setBrush( NoBrush ); p->drawRect( r ); } p->restore(); } void KlearlookStyle::drawArrow( TQPainter *p, const TQRect &r, const TQColorGroup &cg, TQStyle::SFlags flags, TQStyle::TQ_PrimitiveElement pe, bool small, bool checkActive ) const { TQPointArray a; const TQColor &col = flags & Style_Enabled ? checkActive && flags & Style_Active ? cg.highlightedText() : cg.text() : cg.mid(); if ( vArrow ) if ( small ) switch ( pe ) { case TQStyle::PE_ArrowUp: a.setPoints( 7, 2, 1, 2, 0, 0, -2, -2, 0, -2, 1, -2, 0, 2, 0 ); break; case TQStyle::PE_ArrowDown: a.setPoints( 7, 2, -1, 2, 0, 0, 2, -2, 0, -2, -1, -2, 0, 2, 0 ); break; case TQStyle::PE_ArrowRight: a.setPoints( 7, 1, -2, 0, -2, -2, 0, 0, 2, 1, 2, 0, 2, 0, -2 ); break; case TQStyle::PE_ArrowLeft: a.setPoints( 7, -1, -2, 0, -2, 2, 0, 0, 2, -1, 2, 0, 2, 0, -2 ); break; default: return ; } else switch ( pe ) { case TQStyle::PE_ArrowUp: a.setPoints( 7, 3, 1, 0, -2, -3, 1, -2, 2, -1, 1, 1, 1, 2, 2 ); break; case TQStyle::PE_ArrowDown: a.setPoints( 7, 3, -1, 0, 2, -3, -1, -2, -2, -1, -1, 1, -1, 2, -2 ); break; case TQStyle::PE_ArrowRight: a.setPoints( 7, -1, -3, 2, 0, -1, 3, -2, 2, -1, 1, -1, -1, -2, -2 ); break; case TQStyle::PE_ArrowLeft: a.setPoints( 7, 1, -3, -2, 0, 1, 3, 2, 2, 1, 1, 1, -1, 2, -2 ); break; default: return ; } else if ( small ) switch ( pe ) { case TQStyle::PE_ArrowUp: a.setPoints( 4, 2, 0, 0, -2, -2, 0, 2, 0 ); break; case TQStyle::PE_ArrowDown: a.setPoints( 4, 2, 0, 0, 2, -2, 0, 2, 0 ); break; case TQStyle::PE_ArrowRight: a.setPoints( 4, 0, -2, -2, 0, 0, 2, 0, -2 ); break; case TQStyle::PE_ArrowLeft: a.setPoints( 4, 0, -2, 2, 0, 0, 2, 0, -2 ); break; default: return ; } else switch ( pe ) { case TQStyle::PE_ArrowUp: a.setPoints( 4, 3, 1, 0, -2, -3, 1, 3, 1 ); break; case TQStyle::PE_ArrowDown: a.setPoints( 4, 3, -1, 0, 2, -3, -1, 3, -1 ); break; case TQStyle::PE_ArrowRight: a.setPoints( 4, -1, -3, 2, 0, -1, 3, -1, -3 ); break; case TQStyle::PE_ArrowLeft: a.setPoints( 4, 1, -3, -2, 0, 1, 3, 1, -3 ); break; default: return ; } if ( a.isNull() ) return ; p->save(); a.translate( ( r.x() + ( r.width() >> 1 ) ), ( r.y() + ( r.height() >> 1 ) ) ); p->setBrush( col ); p->setPen( col ); p->drawPolygon( a ); p->restore(); } void KlearlookStyle::tqdrawPrimitiveMenu( TQ_PrimitiveElement pe, TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption &data ) const { switch ( pe ) { case PE_CheckMark: if ( flags & Style_On || !( flags & Style_Off ) ) // !(flags&Style_Off) is for tri-state { TQPointArray check; int x = r.center().x() - 3, y = r.center().y() - 3; check.setPoints( 6, x, y + 2, x + 2, y + 4, x + 6, y, x + 6, y + 2, x + 2, y + 6, x, y + 4 ); if ( flags & Style_On ) { if ( flags & Style_Active ) { p->setBrush( cg.highlightedText() ); p->setPen( cg.highlightedText() ); } else { p->setBrush( cg.text() ); p->setPen( cg.text() ); } } else { p->setBrush( cg.text() ); p->setPen( cg.text() ); } p->drawPolygon( check ); } break; default: KStyle::tqdrawPrimitive( pe, p, r, cg, flags, data ); } } void KlearlookStyle::tqdrawPrimitive( TQ_PrimitiveElement pe, TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption &data ) const { int x, y, w, h; r.rect(&x, &y, &w, &h); switch ( pe ) { case PE_HeaderSection: { const TQColor * use = buttonColors( cg ); if ( APP_KICKER == themedApp ) { if ( flags & Style_Down ) flags = ( ( flags | Style_Down ) ^ Style_Down ) | Style_Sunken; flags |= Style_Enabled; #if KDE_VERSION >= 0x30200 #if KDE_VERSION >= 0x30400 if ( HOVER_KICKER == hover && hoverWidget ) // && hoverWidget==p->device()) flags |= Style_MouseOver; #endif formMode = isTransKicker; #endif drawLightBevelButton( p, r, cg, flags | Style_Horizontal, true, ROUNDED_ALL, getFill( flags, use ), use ); #if KDE_VERSION >= 0x30200 formMode = false; #endif } else { flags = ( ( flags | Style_Sunken ) ^ Style_Sunken ) | Style_Raised; if ( TQTC_NO_SECT != hoverSect && HOVER_HEADER == hover && hoverWidget ) { TQHeader * hd = dynamic_cast( hoverWidget ); if ( hd && hd->isClickEnabled( hoverSect ) && r == hd->sectionRect( hoverSect ) ) flags |= Style_MouseOver; } drawLightBevelButton( p, r, cg, flags | Style_Horizontal, true, ROUNDED_NONE, getFill( flags, use ), use ); } break; } case PE_HeaderArrow: drawArrow( p, r, cg, flags, flags & Style_Up ? PE_ArrowUp : PE_ArrowDown ); break; case PE_ButtonCommand: case PE_ButtonBevel: case PE_ButtonTool: case PE_ButtonDropDown: { const TQColor *use = buttonColors( cg ); if ( !( flags & TQStyle::Style_Sunken ) ) // If its not sunken, its raised-don't want flat buttons. flags |= TQStyle::Style_Raised; drawLightBevelButton( p, r, cg, flags | Style_Horizontal, true, r.width() < 16 || r.height() < 16 #if KDE_VERSION >= 0x30200 || ( APP_KORN == themedApp && isTransKicker && PE_ButtonTool == pe ) #endif ? ROUNDED_NONE : ROUNDED_ALL, getFill( flags, use ), use ); break; } case PE_ButtonDefault: switch ( defBtnIndicator ) { case IND_BORDER: p->setBrush( NoBrush ); if ( rounded ) // borderButton) CPD Only use color[4] for rounded def buttons! { const TQColor * use = buttonColors( cg ); p->setPen( use[ 4 ] ); int offset = r.width() >= TQTC_MIN_BTN_SIZE && r.height() >= TQTC_MIN_BTN_SIZE ? 4 : 3; p->drawLine( r.x() + offset, r.y(), r.x() + r.width() - ( 1 + offset ), r.y() ); p->drawLine( r.x() + offset, r.y() + r.height() - 1, r.x() + r.width() - ( 1 + offset ), r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + offset, r.x(), r.y() + r.height() - ( 1 + offset ) ); p->drawLine( r.x() + r.width() - 1, r.y() + offset, r.x() + r.width() - 1, r.y() + r.height() - ( 1 + offset ) ); } else { p->setPen( cg.text() ); p->drawRect( r ); } break; case IND_CORNER: { const TQColor *use = buttonColors( cg ); TQPointArray points; bool sunken = flags & Style_Down || flags & TQStyle::Style_Sunken; int offset = sunken ? 4 : 3; points.setPoints( 3, r.x() + offset, r.y() + offset, r.x() + offset + 6, r.y() + offset, r.x() + offset, r.y() + offset + 6 ); p->setBrush( use[ sunken ? 0 : borderButton ? 4 : 5 ] ); p->setPen( use[ sunken ? 0 : borderButton ? 4 : 5 ] ); p->drawPolygon( points ); break; } default: break; } break; case PE_IndicatorMask: if ( rounded ) { p->fillRect( r, color0 ); p->fillRect( r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2, color1 ); p->setPen( color1 ); p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 2, r.y() ); p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 1, r.x(), r.y() + r.height() - 2 ); p->drawLine( r.x() + r.width() - 1, r.y() + 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); } else p->fillRect( r, color1 ); break; case PE_CheckMark: if ( flags & Style_On || !( flags & Style_Off ) ) // !(flags&Style_Off) is for tri-state { TQPointArray check; int x = r.center().x() - 3, y = r.center().y() - 3; check.setPoints( 6, x, y + 2, x + 2, y + 4, x + 6, y, x + 6, y + 2, x + 2, y + 6, x, y + 4 ); p->setBrush( flags & Style_On ? flags & Style_Enabled ? flags & Style_Selected ? cg.highlightedText() : cg.text() : cg.mid() : cg.light() ); p->setPen( flags & Style_Enabled ? flags & Style_Selected ? cg.highlightedText() : cg.text() : cg.mid() ); p->drawPolygon( check ); } break; case PE_CheckListController: { TQCheckListItem *item = data.checkListItem(); if ( item ) { TQListView * lv = item->listView(); int x = r.x(), y = r.y(), w = r.width(), h = r.height(), marg = lv->itemMargin(); p->setPen( TQPen( flags & Style_Enabled ? cg.text() : lv->tqpalette().color( TQPalette::Disabled, TQColorGroup::Text ) ) ); if ( flags & Style_Selected && !lv->rootIsDecorated() && !( ( item->tqparent() && 1 == item->tqparent() ->rtti() && TQCheckListItem::Controller == ( ( TQCheckListItem* ) item->tqparent() ) ->type() ) )) { p->fillRect( 0, 0, x + marg + w + 4, item->height(), cg.brush( TQColorGroup::Highlight ) ); if ( item->isEnabled() ) p->setPen( TQPen( cg.highlightedText() ) ); } if ( flags & Style_NoChange ) p->setBrush( cg.brush( TQColorGroup::Button ) ); p->drawRect( x + marg + 2, y + 4 + 2, w - 7, h - 8 ); p->drawRect( x + marg, y + 4, w - 7, h - 8 ); } break; } case PE_CheckListIndicator: { TQCheckListItem *item = data.checkListItem(); if ( item ) { TQListView * lv = item->listView(); p->setPen( TQPen( flags & Style_Enabled ? cg.text() : lv->tqpalette().color( TQPalette::Disabled, TQColorGroup::Text ), 2 ) ); if ( flags & Style_Selected ) { flags -= Style_Selected; if ( !lv->rootIsDecorated() && !( ( item->tqparent() && 1 == item->tqparent() ->rtti() && TQCheckListItem::Controller == ( ( TQCheckListItem* ) item->tqparent() ) ->type() ) ) ) { p->fillRect( 0, 0, r.x() + lv->itemMargin() + r.width() + 4, item->height(), cg.brush( TQColorGroup::Highlight ) ); if ( item->isEnabled() ) { p->setPen( TQPen( cg.highlightedText(), 2 ) ); flags += Style_Selected; } } } if ( flags & Style_NoChange ) p->setBrush( cg.brush( TQColorGroup::Button ) ); p->drawRect( r.x() + lv->itemMargin(), r.y() + 2, r.width() - 4, r.width() - 4 ); if ( flags & TQStyle::Style_On || !( flags & Style_Off ) ) tqdrawPrimitive( PE_CheckMark, p, TQRect( r.x() + lv->itemMargin(), r.y() + 2, r.width() - 4, r.width() - 4 ), cg, flags ); } break; } case PE_Indicator: { const TQColor *use = buttonColors( cg ); bool on = flags & TQStyle::Style_On || !( flags & Style_Off ); if ( APPEARANCE_FLAT != appearance ) tqdrawPrimitive( PE_ButtonTool, p, r, cg, flags ); else { p->fillRect( r.x() + 1, r.y() + 2, TQTC_CHECK_SIZE - 2, TQTC_CHECK_SIZE - 2, flags & Style_Enabled ? cg.base() : cg.background() ); p->setPen( use[ 4 ] ); p->drawLine( r.x() + 1, r.y() + TQTC_CHECK_SIZE - 1, r.x() + 1, r.y() + 1 ); p->drawLine( r.x() + 1, r.y() + 1, r.x() + TQTC_CHECK_SIZE - 2, r.y() + 1 ); } p->setPen( use[ 5 ] ); p->setBrush( NoBrush ); if ( rounded ) { p->drawLine( r.x() + 1, r.y(), r.x() + r.width() - 2, r.y() ); p->drawLine( r.x() + 1, r.y() + r.height() - 1, r.x() + r.width() - 2, r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + 1, r.x(), r.y() + r.height() - 2 ); p->drawLine( r.x() + r.width() - 1, r.y() + 1, r.x() + r.width() - 1, r.y() + r.height() - 2 ); p->setPen( midColor( use[ 3 ], cg.background() ) ); p->drawPoint( r.x(), r.y() ); p->drawPoint( r.x(), r.y() + r.width() - 1 ); p->drawPoint( r.x() + r.height() - 1, r.y() ); p->drawPoint( r.x() + r.height() - 1, r.y() + r.width() - 1 ); } else if ( APPEARANCE_FLAT == appearance || borderButton ) p->drawRect( r.x(), r.y(), TQTC_CHECK_SIZE, TQTC_CHECK_SIZE ); if ( on ) tqdrawPrimitive( PE_CheckMark, p, r, cg, flags ); break; } case PE_CheckListExclusiveIndicator: { TQCheckListItem *item = data.checkListItem(); if ( item ) { const TQColor & bgnd = cg.background(), &on = flags & Style_Enabled ? cg.text() : cg.mid(); bool set = flags & TQStyle::Style_On; TQPointArray outer, inner, aa; int x = r.x(), y = r.y() + 2; outer.setPoints( 24, x, y + 8, x, y + 4, x + 1, y + 3, x + 1, y + 2, x + 2, y + 1, x + 3, y + 1, x + 4, y, x + 8, y, x + 9, y + 1, x + 10, y + 1, x + 11, y + 2, x + 11, y + 3, x + 12, y + 4, x + 12, y + 8, x + 11, y + 9, x + 11, y + 10, x + 10, y + 11, x + 9, y + 11, x + 8, y + 12, x + 4, y + 12, x + 3, y + 11, x + 2, y + 11, x + 1, y + 10, x + 1, y + 9 ); inner.setPoints( 20, x + 1, y + 8, x + 1, y + 4, x + 2, y + 3, x + 2, y + 2, x + 3, y + 2, x + 4, y + 1, x + 8, y + 1, x + 9, y + 2, x + 10, y + 2, x + 10, y + 3, x + 11, y + 4, x + 11, y + 8, x + 10, y + 9, x + 10, y + 10, x + 9, y + 10, x + 8, y + 11, x + 4, y + 11, x + 3, y + 10, x + 2, y + 10, x + 2, y + 9 ); aa.setPoints( 16, x + 2, y + 4, x + 4, y + 2, x + 8, y + 2, x + 10, y + 4, x + 10, y + 8, x + 8, y + 10, x + 4, y + 10, x + 2, y + 8, x, y + 3, x + 3, y, x + 9, y, x + 12, y + 3, x + 12, y + 9, x + 9, y + 12, x + 3, y + 12, x, y + 9 ); p->setBrush( on ); p->drawPolyline( outer ); p->drawPolyline( inner ); p->setPen( midColor( on, bgnd, 1.5 ) ); p->drawPoints( aa ); if ( set ) { p->setPen( midColor( on, bgnd ) ); p->drawLine( x + 5, y + 4, x + 7, y + 4 ); p->drawLine( x + 5, y + 8, x + 7, y + 8 ); p->drawLine( x + 4, y + 5, x + 4, y + 7 ); p->drawLine( x + 8, y + 5, x + 8, y + 7 ); p->setBrush( on ); p->setPen( NoPen ); p->drawRect( x + 5, y + 5, 3, 3 ); } } break; } case PE_ExclusiveIndicator: case PE_ExclusiveIndicatorMask: { int x = r.x(), y = r.y(); TQPointArray outer; outer.setPoints( 24, x, y + 8, x, y + 4, x + 1, y + 3, x + 1, y + 2, x + 2, y + 1, x + 3, y + 1, x + 4, y, x + 8, y, x + 9, y + 1, x + 10, y + 1, x + 11, y + 2, x + 11, y + 3, x + 12, y + 4, x + 12, y + 8, x + 11, y + 9, x + 11, y + 10, x + 10, y + 11, x + 9, y + 11, x + 8, y + 12, x + 4, y + 12, x + 3, y + 11, x + 2, y + 11, x + 1, y + 10, x + 1, y + 9 ); if ( PE_ExclusiveIndicatorMask == pe ) { p->fillRect( r, color0 ); p->setPen( TQt::color1 ); p->setBrush( TQt::color1 ); p->drawPolygon( outer ); } else { TQPointArray shadow; const TQColor &bgnd = flags & Style_Enabled ? cg.base() : cg.background(), &on = flags & Style_Enabled ? flags & Style_Selected ? cg.highlightedText() : cg.text() : cg.mid(); TQColor indBgnd = bgnd; const TQColor *use = buttonColors( cg ); TQColor leftShadowColor, rightShadowColor, outerLeftColor, outerRightColor; bool set = flags & TQStyle::Style_On; if ( APPEARANCE_FLAT != appearance && !borderButton ) shadow.setPoints( 14, x + 1, y + 10, x + 1, y + 9, x, y + 8, x, y + 4, x + 1, y + 3, x + 1, y + 2, x + 2, y + 1, x + 3, y + 1, x + 4, y, x + 8, y, x + 9, y + 1, x + 10, y + 1, x + 11, y + 2, x + 11, y + 3 ); else shadow.setPoints( 9, x + 2, y + 11, x + 2, y + 9, x + 1, y + 8, x + 1, y + 4, x + 2, y + 3, x + 2, y + 2, x + 3, y + 2, x + 4, y + 1, x + 8, y + 1 ); p->fillRect( r, crLabelHighlight && flags & Style_MouseOver ? TQColor(cg.background().light( TQTC_HIGHLIGHT_FACTOR )) : cg.background() ); if ( APPEARANCE_FLAT != appearance ) { indBgnd = getFill( flags, use ); p->setClipRegion( TQRegion( outer ) ); drawBevelGradient( indBgnd, !set, 0, p, TQRect( x + 1, y + 1, r.width() - 2, r.height() - 2 ), true, set ? SHADE_BEVEL_GRAD_SEL_LIGHT( appearance ) : SHADE_BEVEL_GRAD_LIGHT( appearance ), set ? SHADE_BEVEL_GRAD_SEL_DARK( appearance ) : SHADE_BEVEL_GRAD_DARK( appearance ) ); p->setClipping( false ); if ( ( !set && !( flags & Style_Down ) ) || !borderButton ) { leftShadowColor = set ? !borderButton ? use[ 5 ] : use[ 4 ] : use[ 0 ]; p->setPen( leftShadowColor ); p->drawPolyline( shadow ); if ( APPEARANCE_LIGHT_GRADIENT == appearance ) rightShadowColor = indBgnd; else { if ( !borderButton ) shadow.setPoints( 10, x + 12, y + 4, x + 12, y + 8, x + 11, y + 9, x + 11, y + 10, x + 10, y + 11, x + 9, y + 11, x + 8, y + 12, x + 4, y + 12, x + 3, y + 11, x + 2, y + 11 ); else shadow.setPoints( 9, x + 10, y + 2, x + 10, y + 3, x + 11, y + 4, x + 11, y + 8, x + 10, y + 9, x + 10, y + 10, x + 9, y + 10, x + 8, y + 11, x + 4, y + 11 ); rightShadowColor = set ? use[ 0 ] : !borderButton ? use[ 5 ] : use[ 4 ]; p->setPen( rightShadowColor ); p->drawPolyline( shadow ); } } else leftShadowColor = rightShadowColor = indBgnd; } else { rightShadowColor = bgnd; p->setBrush( bgnd ); p->setPen( bgnd ); p->drawEllipse( x, y, TQTC_RADIO_SIZE, TQTC_RADIO_SIZE ); p->setPen( use[ 4 ] ); leftShadowColor = use[ 4 ]; p->drawPolyline( shadow ); } if ( APPEARANCE_FLAT == appearance || borderButton ) { p->setPen( use[ 5 ] ); p->drawPolyline( outer ); shade( use[ 5 ], &outerRightColor, 1.1 ); } else { shade( leftShadowColor, &outerLeftColor, 1.1 ); shade( rightShadowColor, &outerRightColor, 1.1 ); } if ( set ) { p->setPen( midColor( on, indBgnd ) ); p->drawLine( x + 5, y + 4, x + 7, y + 4 ); p->drawLine( x + 5, y + 8, x + 7, y + 8 ); p->drawLine( x + 4, y + 5, x + 4, y + 7 ); p->drawLine( x + 8, y + 5, x + 8, y + 7 ); p->setBrush( on ); p->setPen( NoPen ); p->drawRect( x + 5, y + 5, 3, 3 ); } if ( !formMode ) { TQPointArray outerAaLeft, outerAaRight; outerAaLeft.setPoints( 8, x, y + 3, x + 1, y + 1, x + 3, y, x + 9, y, x + 11, y + 1, x + 12, y + 3, x + 1, y + 11, x, y + 9 ); outerAaRight.setPoints( 4, x + 12, y + 9, x + 11, y + 11, x + 9, y + 12, x + 3, y + 12 ); p->setPen( midColor( outerRightColor, cg.background() ) ); p->drawPoints( outerAaRight ); if ( APPEARANCE_FLAT != appearance && !borderButton ) p->setPen( midColor( outerLeftColor, cg.background() ) ); p->drawPoints( outerAaLeft ); if ( APPEARANCE_LIGHT_GRADIENT == appearance ) p->setPen( midColor( indBgnd, use[ 5 ], 1.75 ) ); else p->setPen( midColor( use[ 5 ], indBgnd, 1.5 ) ); if ( APPEARANCE_FLAT != appearance ) { TQPointArray innerAa; if ( !set && !( flags & Style_Down ) ) { if ( borderButton ) { innerAa.setPoints( 3, x + 1, y + 4, x + 2, y + 2, x + 4, y + 1 ); p->drawPoints( innerAa ); p->setPen( midColor( outerRightColor, cg.background() ) ); p->drawPoint( x + 2, y + 10 ); } else { innerAa.setPoints( 4, x + 4, y + 11, x + 8, y + 11, x + 10, y + 10, x + 11, y + 8 ); p->drawPoints( innerAa ); } } } else { TQPointArray innerAa; innerAa.setPoints( 6, x + 4, y + 11, x + 8, y + 11, x + 10, y + 10, x + 11, y + 8, x + 11, y + 4, x + 10, y + 2 ); p->drawPoints( innerAa ); } } } break; } case PE_DockWindowSeparator: { TQPoint p1, p2; //const TQColor *use=backgroundColors(cg); if ( flags & Style_Horizontal ) { int offset = r.height() > 18 ? 6 : r.height() > 12 ? 4 : r.height() > 6 ? 2 : 0; p1 = TQPoint( r.width() >> 1, 0 + offset ); p2 = TQPoint( p1.x(), r.height() - offset ); } else { int offset = r.width() > 18 ? 6 : r.width() > 12 ? 4 : r.width() > 6 ? 2 : 0; p1 = TQPoint( 0 + offset, r.height() >> 1 ); p2 = TQPoint( r.width() - offset, p1.y() ); } p->fillRect( r, cg.background() ); p->setPen( cg.background().dark( 111 ) ); p->drawLine( p1, p2 ); break; } case PE_Splitter: { const TQColor *use = buttonColors( cg ); if ( hoverWidget && hoverWidget == p->device() ) flags |= Style_MouseOver; if ( borderSplitter ) drawLightBevelButton( p, r, cg, TQStyle::Style_Raised, false, ROUNDED_NONE, getFill( flags, use ), use ); else { p->fillRect( r, TQColor( flags & Style_MouseOver ? TQColor(cg.background().light( TQTC_HIGHLIGHT_FACTOR )) : cg.background() ) ); drawLines( p, r, flags & Style_Horizontal, 70, 1, use, 0, TRUE, APPEARANCE_LIGHT_GRADIENT == appearance ); } break; } case PE_DockWindowResizeHandle: p->fillRect( r, cg.background() ); if ( flags & Style_Horizontal ) { p->setPen( cg.highlight().light() ); p->drawLine( r.left() + 1, r.top() + 1, r.right() - 1, r.top() + 1 ); p->setPen( cg.highlight() ); p->drawLine( r.left() + 1, r.top() + 2, r.right() - 1, r.top() + 2 ); p->setPen( cg.highlight().dark() ); p->drawLine( r.left() + 1, r.top() + 3, r.right() - 1, r.top() + 3 ); } else { p->setPen( cg.highlight().light() ); p->drawLine( r.left() + 1, r.top() + 1, r.left() + 1, r.bottom() - 1 ); p->setPen( cg.highlight() ); p->drawLine( r.left() + 2, r.top() + 1, r.left() + 2, r.bottom() - 1 ); p->setPen( cg.highlight().dark() ); p->drawLine( r.left() + 3, r.top() + 1, r.left() + 3, r.bottom() - 1 ); } break; case PE_StatusBarSection: { p->setPen( cg.background().dark(120) ); p->drawRect(x-2, y-2, r.width()+3, r.height()+3); break; } case PE_PanelLineEdit: { const TQColor *use = backgroundColors( cg ); p->setPen( use[ 4 ].light(80) ); p->drawRect( r ); break; } case PE_PanelPopup: { const TQColor *use = backgroundColors( cg ); if ( borderFrame && ( data.isDefault() || data.lineWidth() > 1 ) ) { p->setPen( use[ 4 ].light(70) ); p->setBrush( NoBrush ); drawPopupRect (p, r, cg); //p->drawRect( r ); #ifdef MENU_POPUP_SHADOW qDrawShadePanel( p, r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2, TQColorGroup( use[ 4 ], use[ NUM_SHADES ], use[ 0 ], use[ 4 ], use[ 2 ], cg.text(), use[ NUM_SHADES ] ), flags & Style_Sunken, data.isDefault() ? TQTC_BORDERED_FRAME_WIDTH - 1 : data.lineWidth() - 1 ); #endif } else qDrawShadePanel( p, r, TQColorGroup( use[ 5 ], use[ NUM_SHADES ], use[ 0 ], use[ 5 ], use[ 2 ], cg.text(), use[ NUM_SHADES ] ), flags & Style_Sunken, data.isDefault() ? TQTC_DEF_FRAME_WIDTH : data.lineWidth() ); break; } case PE_PanelTabWidget: { const TQColor *use = backgroundColors( cg ); if ( borderFrame && ( data.isDefault() || data.lineWidth() > 1 ) ) { p->setPen( use[ 4 ] ); p->setBrush( NoBrush ); p->drawRect( r ); #ifdef MENU_POPUP_SHADOW qDrawShadePanel( p, r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2, TQColorGroup( use[ 4 ], use[ NUM_SHADES ], use[ 0 ], use[ 4 ], use[ 2 ], cg.text(), use[ NUM_SHADES ] ), flags & Style_Sunken, data.isDefault() ? TQTC_BORDERED_FRAME_WIDTH - 1 : data.lineWidth() - 1 ); #endif } else qDrawShadePanel( p, r, TQColorGroup( use[ 5 ], use[ NUM_SHADES ], use[ 0 ], use[ 5 ], use[ 2 ], cg.text(), use[ NUM_SHADES ] ), flags & Style_Sunken, data.isDefault() ? TQTC_DEF_FRAME_WIDTH : data.lineWidth() ); break; } case PE_PanelDockWindow: case PE_PanelMenuBar: { const TQColor *use = backgroundColors( cg ); switch ( toolbarBorders ) { case TB_DARK: qDrawShadePanel( p, r.x(), r.y(), r.width(), r.height(), TQColorGroup( use[ 5 ].dark( 120 ), use[ NUM_SHADES ], use[ 0 ], use[ 5 ].dark( 120 ), use[ 2 ], cg.text(), use[ NUM_SHADES ] ), flags & Style_Sunken, 1 ); #ifdef TQTC_GRADIENT_TOOLBARS_AND_MENUBARS if ( APPEARANCE_FLAT != appearance ) drawBevelGradient( use[ NUM_SHADES ], true, 1, p, r, true, SHADE_BAR_LIGHT, SHADE_BAR_DARK ); #endif break; case TB_LIGHT: qDrawShadePanel( p, r.x(), r.y(), r.width(), r.height(), TQColorGroup( use[ 3 ], use[ NUM_SHADES ], use[ 0 ], use[ 3 ], use[ 2 ], cg.text(), use[ NUM_SHADES ] ), flags & Style_Sunken, 1 ); #ifdef TQTC_GRADIENT_TOOLBARS_AND_MENUBARS if ( APPEARANCE_FLAT != appearance ) drawBevelGradient( use[ NUM_SHADES ], true, 1, p, r, true, SHADE_BAR_LIGHT, SHADE_BAR_DARK ); #endif break; case TB_NONE: break; } /* switch */ break; } case PE_ScrollBarAddLine: case PE_ScrollBarSubLine: { bool down = ( flags & ( TQStyle::Style_Down | TQStyle::Style_On | TQStyle::Style_Sunken ) ); const TQColor *use = buttonColors( cg ); pe = flags & Style_Horizontal ? PE_ScrollBarAddLine == pe ? PE_ArrowRight : PE_ArrowLeft : PE_ScrollBarAddLine == pe ? PE_ArrowDown : PE_ArrowUp; drawLightBevelButton( p, r, cg, down ? flags : flags | ( ( ( flags & Style_Enabled ) ? Style_Raised : Style_Default ) ), true, PE_ArrowRight == pe ? ROUNDED_RIGHT : PE_ArrowLeft == pe ? ROUNDED_LEFT : PE_ArrowDown == pe ? ROUNDED_BOTTOM : PE_ArrowUp == pe ? ROUNDED_TOP : ROUNDED_NONE, getFill( flags, use ), use ); tqdrawPrimitive( pe, p, r, cg, flags ); break; } case PE_ScrollBarSubPage: case PE_ScrollBarAddPage: { const TQColor *use = backgroundColors( cg ); if ( borderButton ) { if ( flags & Style_Horizontal ) { p->fillRect( r.x(), r.y() + 1, r.width(), r.height() - 2, use[ 2 ] ); p->setPen( use[ 5 ] ); p->drawLine( r.left(), r.top(), r.right(), r.top() ); p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() ); } else { p->fillRect( r.x() + 1, r.y(), r.width() - 2, r.height(), use[ 2 ] ); p->setPen( use[ 5 ] ); p->drawLine( r.left(), r.top(), r.left(), r.bottom() ); p->drawLine( r.right(), r.top(), r.right(), r.bottom() ); } } else p->fillRect( r.x(), r.y(), r.width(), r.height(), use[ 2 ] ); break; } case PE_ScrollBarSlider: { const TQColor *use = buttonColors( cg ); if ( flags & Style_Down ) flags -= Style_Down; flags |= flags & Style_Enabled ? Style_Raised : Style_Default; drawLightBevelButton( p, r, cg, flags, true, ROUNDED_NONE, getFill( flags, use ), use ); if ( GROOVE_NONE != sliderThumbs && ( ( flags & Style_Horizontal && r.width() >= 20 ) || r.height() >= 20 ) ) drawLines( p, r, !( flags & Style_Horizontal ), 3, 4, use, 0, GROOVE_SUNKEN == sliderThumbs, APPEARANCE_LIGHT_GRADIENT == appearance ); break; } case PE_FocusRect: { p->drawWinFocusRect( r, cg.background() ); break; } case PE_ArrowUp: case PE_ArrowDown: case PE_ArrowRight: case PE_ArrowLeft: drawArrow( p, r, cg, flags, pe ); break; case PE_SpinWidgetUp: case PE_SpinWidgetDown: { TQRect sr( r ); const TQColor *use = buttonColors( cg ); drawLightBevelButton( p, sr, cg, flags | Style_Horizontal, true, PE_SpinWidgetDown == pe ? ROUNDED_BOTTOM : ROUNDED_TOP, getFill( flags, use ), use ); if ( vArrow ) { if ( PE_SpinWidgetDown == pe ) sr.setY( sr.y() - 1 ); } else sr.setY( sr.y() + ( PE_SpinWidgetDown == pe ? -2 : 1 ) ); drawArrow( p, sr, cg, flags, pe == PE_SpinWidgetUp ? PE_ArrowUp : PE_ArrowDown, true ); break; } default: KStyle::tqdrawPrimitive( pe, p, r, cg, flags, data ); } } void KlearlookStyle::drawKStylePrimitive( KStylePrimitive kpe, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption &opt ) const { switch ( kpe ) { case KPE_ToolBarHandle: case KPE_GeneralHandle: drawLines( p, r, !( flags & Style_Horizontal ), 2, APP_KICKER == themedApp ? 1 : KPE_ToolBarHandle == kpe ? 4 : 2, gray, APP_KICKER == themedApp ? 1 : KPE_ToolBarHandle == kpe ? -2 : 0, GROOVE_SUNKEN == handles, APPEARANCE_LIGHT_GRADIENT == appearance ); break; case KPE_SliderGroove: drawSliderGroove( p, r, flags, widget ); break; case KPE_SliderHandle: drawSliderHandle( p, r, cg, flags ); break; case KPE_ListViewExpander: { int lvSize = TQTC_LV_SIZE( lvExpander ); TQRect ar( r.x() + ( ( r.width() - ( lvSize + 4 ) ) >> 1 ), r.y() + ( ( r.height() - ( lvSize + 4 ) ) >> 1 ), lvSize + 4, lvSize + 4 ); p->setPen( /*lvDark ? cg.text() : */cg.mid() ); if ( LV_LINES_NONE != lvLines ) { int lo = rounded ? 2 : 0; p->drawLine( ar.x() + lo, ar.y(), ( ar.x() + ar.width() - 1 ) - lo, ar.y() ); p->drawLine( ar.x() + lo, ar.y() + ar.height() - 1, ( ar.x() + ar.width() - 1 ) - lo, ar.y() + ar.height() - 1 ); p->drawLine( ar.x(), ar.y() + lo, ar.x(), ( ar.y() + ar.height() - 1 ) - lo ); p->drawLine( ar.x() + ar.width() - 1, ar.y() + lo, ar.x() + ar.width() - 1, ( ar.y() + ar.height() - 1 ) - lo ); if ( rounded ) { p->drawPoint( ar.x() + 1, ar.y() + 1 ); p->drawPoint( ar.x() + 1, ar.y() + ar.height() - 2 ); p->drawPoint( ar.x() + ar.width() - 2, ar.y() + 1 ); p->drawPoint( ar.x() + ar.width() - 2, ar.y() + ar.height() - 2 ); p->setPen( midColor( /*lvDark ? cg.text() : */cg.mid(), cg.background() ) ); p->drawLine( ar.x(), ar.y() + 1, ar.x() + 1, ar.y() ); p->drawLine( ar.x() + ar.width() - 2, ar.y(), ar.x() + ar.width() - 1, ar.y() + 1 ); p->drawLine( ar.x(), ar.y() + ar.height() - 2, ar.x() + 1, ar.y() + ar.height() - 1 ); p->drawLine( ar.x() + ar.width() - 2, ar.y() + ar.height() - 1, ar.x() + ar.width() - 1, ar.y() + ar.height() - 2 ); } } if ( LV_EXP_ARR == lvExpander ) drawArrow( p, ar, cg, flags | Style_Enabled, flags & Style_On // Collapsed = On ? TQApplication::reverseLayout() ? PE_ArrowLeft : PE_ArrowRight : PE_ArrowDown ); else { int xo = ( ar.width() - lvSize ) >> 1, yo = ( ar.height() - lvSize ) >> 1; int mid = lvSize >> 1; p->setPen( cg.text() ); p->drawLine( ar.x() + xo + ( mid - 2 ), ar.y() + yo + mid, ar.x() + xo + lvSize - ( mid - 1 ), ar.y() + yo + mid ); if ( flags & Style_On ) // Collapsed = On p->drawLine( ar.x() + xo + mid, ar.y() + yo + ( mid - 2 ), ar.x() + xo + mid, ar.y() + yo + lvSize - ( mid - 1 ) ); } break; } case KPE_ListViewBranch: switch ( lvLines ) { case LV_LINES_NONE: break; case LV_LINES_DOTTED: // Taken and modified (colour wise) from kstyle.cpp - which in turn comes from // qwindowsstyl.cpp { static TQBitmap *verticalLine = 0, *horizontalLine = 0; static TQCleanupHandler lvCleanupBitmap; // Create the dotline pixmaps if not already created if ( !verticalLine ) { // make 128*1 and 1*128 bitmaps that can be used for drawing the right sort of lines. verticalLine = new TQBitmap( 1, 129, true ); horizontalLine = new TQBitmap( 128, 1, true ); TQPointArray a( 64 ); TQPainter p2; p2.begin( verticalLine ); int i; for ( i = 0; i < 64; i++ ) a.setPoint( i, 0, i * 2 + 1 ); p2.setPen( color1 ); p2.drawPoints( a ); p2.end(); TQApplication::flushX(); verticalLine->setMask( *verticalLine ); p2.begin( horizontalLine ); for ( i = 0; i < 64; i++ ) a.setPoint( i, i * 2 + 1, 0 ); p2.setPen( color1 ); p2.drawPoints( a ); p2.end(); TQApplication::flushX(); horizontalLine->setMask( *horizontalLine ); lvCleanupBitmap.add( &verticalLine ); lvCleanupBitmap.add( &horizontalLine ); } p->setPen( lvDark ? cg.text() : cg.mid() ); // Wow, my big modification... if ( flags & Style_Horizontal ) { int point = r.x(), other = r.y(), end = r.x() + r.width(), thickness = r.height(); while ( point < end ) { int i = 128; if ( i + point > end ) i = end - point; p->drawPixmap( point, other, *horizontalLine, 0, 0, i, thickness ); point += i; } } else { int point = r.y(), other = r.x(), end = r.y() + r.height(), thickness = r.width(), pixmapoffset = ( flags & Style_NoChange ) ? 0 : 1; // ### Hackish while ( point < end ) { int i = 128; if ( i + point > end ) i = end - point; p->drawPixmap( other, point, *verticalLine, 0, pixmapoffset, thickness, i ); point += i; } } break; } case LV_LINES_SOLID: p->setPen( cg.mid() ); p->drawLine( r.x(), r.y(), r.x() + r.width() - 1, r.y() + r.height() - 1 ); break; } break; default: KStyle::drawKStylePrimitive( kpe, p, widget, r, cg, flags, opt ); } } void KlearlookStyle::tqdrawControl( ControlElement control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQColorGroup &cg, SFlags flags, const TQStyleOption &data ) const { if ( widget == hoverWidget ) flags |= Style_MouseOver; switch ( control ) { case CE_TabBarTab: { const TQTabBar * tb = ( const TQTabBar * ) widget; bool cornerWidget = false, firstTab = 0 == tb->indexOf( data.tab() ->identifier() ); if ( ::tqqt_cast( tb->tqparent() ) ) { const TQTabWidget * tw = ( const TQTabWidget* ) tb->tqparent(); // is there a corner widget in the (top) left edge? if ( tw->cornerWidget( TQt::TopLeft ) ) cornerWidget = true; } if ( borderFrame ) { TQRect tr( r ), fr( r ); int offset = rounded ? 2 : 0; switch ( tb->tqshape() ) { case TQTabBar::TriangularAbove: case TQTabBar::RoundedAbove: if ( flags & Style_Selected ) { tr.addCoords( 0, 0, 0, -1 ); fr.addCoords( 2, 2, -2, -2 ); p->setPen( gray[ 5 ] ); p->drawLine( tr.left(), firstTab && !cornerWidget ? tr.bottom() + 1 : tr.bottom(), tr.left(), tr.top() + offset ); p->drawLine( tr.left() + offset, tr.top(), tr.right() - offset, tr.top() ); p->drawLine( tr.right(), tr.top() + 1, tr.right(), tr.bottom() ); p->setPen( gray[ 0 ] ); p->drawLine( tr.left() + 1, tr.bottom() + 1, tr.left() + 1, tr.top() + 2 ); p->drawLine( tr.left() + 1, tr.top() + 1, tr.right() - 1, tr.top() + 1 ); p->drawLine( tr.right() - 1, tr.bottom() + 1, tr.right(), tr.bottom() + 1 ); if ( cornerWidget ) p->drawPoint( tr.left(), tr.bottom() + 1 ); p->setPen( gray[ 4 ] ); p->drawLine( tr.right() - 1, tr.top() + 1, tr.right() - 1, tr.bottom() ); if ( rounded ) { p->setPen( gray[ 5 ] ); p->drawPoint( tr.x() + 1, tr.y() + 1 ); p->drawPoint( tr.x() + tr.width() - 2, tr.y() + 1 ); p->setPen( gray[ 4 ] ); p->drawLine( tr.x(), tr.y() + 1, tr.x() + 1, tr.y() ); p->drawLine( tr.x() + tr.width() - 2, tr.y(), tr.x() + tr.width() - 1, tr.y() + 1 ); } } else { tr.addCoords( 0, 2, 0, -1 ); fr.addCoords( 2, 4, -2, -2 ); p->setPen( gray[ 5 ] ); p->drawLine( tr.left(), firstTab && !cornerWidget ? tr.bottom() + 1 : tr.bottom(), tr.left(), tr.top() + 1 ); p->drawLine( rounded ? tr.left() + 1 : tr.left(), tr.top(), rounded ? tr.right() - 1 : tr.right(), tr.top() ); p->drawLine( tr.right(), tr.top() + 1, tr.right(), tr.bottom() ); p->drawLine( tr.left(), tr.bottom(), tr.right(), tr.bottom() ); p->setPen( gray[ 0 ] ); p->drawLine( tr.left() + 1, tr.top() + 1, tr.right() - 1, tr.top() + 1 ); if ( cornerWidget ) p->drawPoint( tr.left(), tr.bottom() + 1 ); if ( !firstTab ) p->setPen( gray[ 2 ] ); p->drawLine( tr.left() + 1, tr.bottom() - 1, tr.left() + 1, tr.top() + 2 ); p->setPen( gray[ 0 ] ); p->drawLine( tr.left() + 1, tr.bottom() + 1, tr.right(), tr.bottom() + 1 ); p->setPen( gray[ 4 ] ); p->drawLine( tr.right() - 1, tr.top() + 1, tr.right() - 1, tr.bottom() - 1 ); } if ( APPEARANCE_FLAT != appearance ) { if ( flags & Style_Selected ) { drawBevelGradient( cg.background(), true, 0, p, fr, true, SHADE_TAB_SEL_LIGHT( appearance ), SHADE_TAB_SEL_DARK( appearance ) ); p->setPen(menuPbar[ GRADIENT_BASE ]); p->drawLine( fr.left()-1, fr.top()-1, fr.right()+1, fr.top()-1); p->drawLine( fr.left()-1, fr.top(), fr.right()+1, fr.top()); p->setPen(menuPbar[ GRADIENT_DARK ].dark(118)); p->drawLine( fr.left(), fr.top()-2, fr.right(), fr.top()-2); p->drawPoint( tr.x() + 1, tr.y() + 1 ); p->drawPoint( tr.x(), tr.y() + 2 ); p->drawPoint( tr.x() + tr.width() - 2, tr.y() + 1 ); p->drawPoint( tr.x() + tr.width() - 1, tr.y() + 2 ); } else drawBevelGradient( gray[ 2 ], true, 0, p, fr, true, SHADE_TAB_LIGHT( appearance ), SHADE_TAB_DARK( appearance ) ); } else p->fillRect( fr, flags & Style_Selected ? cg.background() : gray[ 2 ] ); break; case TQTabBar::TriangularBelow: case TQTabBar::RoundedBelow: if ( flags & Style_Selected ) { fr.addCoords( 3, 2, -3, -3 ); p->setPen( gray[ 5 ] ); p->drawLine( tr.left(), tr.bottom() - offset, tr.left(), firstTab && !cornerWidget ? tr.top() : tr.top() + 1 ); p->drawLine( rounded ? tr.left() + 1 : tr.left(), tr.bottom(), tr.right() - offset, tr.bottom() ); p->drawLine( tr.right(), tr.top() + 1, tr.right(), tr.bottom() - 1 ); p->setPen( gray[ 0 ] ); p->drawLine( tr.left() + 1, tr.bottom() - 2, tr.left() + 1, firstTab && !cornerWidget ? tr.top() : tr.top() - 1 ); p->setPen( gray[ 4 ] ); p->drawLine( tr.left() + 1, tr.bottom() - 1, tr.right() - 1, tr.bottom() - 1 ); p->drawLine( tr.right() - 1, tr.bottom() - 2, tr.right() - 1, tr.top() - 1 ); p->drawPoint( tr.right(), tr.top() ); if ( cornerWidget ) p->drawPoint( tr.left(), tr.top() ); if ( rounded ) { p->setPen( gray[ 5 ] ); p->drawPoint( tr.x() + 1, tr.y() + tr.height() - 2 ); p->drawPoint( tr.x() + tr.width() - 2, tr.y() + tr.height() - 2 ); p->setPen( gray[ 4 ] ); p->drawLine( tr.x(), tr.y() + tr.height() - 2, tr.x() + 1, tr.y() + tr.height() - 1 ); p->drawLine( tr.x() + tr.width() - 2, tr.y() + tr.height() - 1, tr.x() + tr.width() - 1, tr.y() + tr.height() - 2 ); } } else { tr.addCoords( 0, 1, 0, -2 ); fr.addCoords( 1, 2, -2, -4 ); p->setPen( gray[ 5 ] ); p->drawLine( tr.left(), tr.bottom() - 1, tr.left(), firstTab && !cornerWidget ? tr.top() : tr.top() + 1 ); p->drawLine( rounded ? tr.left() + 1 : tr.left(), tr.bottom(), rounded ? tr.right() - 1 : tr.right(), tr.bottom() ); p->drawLine( tr.right(), tr.top() + 1, tr.right(), tr.bottom() - 1 ); p->drawLine( tr.right(), tr.top(), tr.left(), tr.top() ); p->setPen( gray[ 4 ] ); p->drawLine( tr.left(), tr.top() - 1, tr.right(), tr.top() - 1 ); p->drawLine( tr.left() + 1, tr.bottom() - 1, tr.right() - 1, tr.bottom() - 1 ); p->drawLine( tr.right() - 1, tr.bottom() - 2, tr.right() - 1, tr.top() + 1 ); } if ( APPEARANCE_FLAT != appearance ) if ( flags & Style_Selected ) drawBevelGradient( cg.background(), false, -1, p, fr, true, SHADE_BOTTOM_TAB_SEL_DARK( appearance ), SHADE_BOTTOM_TAB_SEL_LIGHT( appearance ) ); else drawBevelGradient( gray[ 2 ], false, 0, p, fr, true, SHADE_BOTTOM_TAB_DARK( appearance ), SHADE_BOTTOM_TAB_LIGHT( appearance ) ); else p->fillRect( fr, flags & Style_Selected ? cg.background() : gray[ 2 ] ); break; default: KStyle::tqdrawControl( control, p, widget, r, cg, flags, data ); } } else { TQRect br( r ); switch ( tb->tqshape() ) { case TQTabBar::TriangularAbove: case TQTabBar::RoundedAbove: if ( flags & Style_Selected ) { p->setPen( cg.background() ); p->drawLine( br.bottomLeft(), br.bottomRight() ); p->setPen( gray[ 0 ] ); p->drawPoint( br.bottomLeft() ); p->setPen( gray[ 5 ] ); p->drawPoint( br.bottomRight() ); br.addCoords( 0, 0, 0, -1 ); } else { p->setPen( gray[ 0 ] ); p->drawLine( br.left(), br.bottom(), br.right(), br.bottom() ); br.addCoords( 0, 1, -1, -1 ); } p->setPen( gray[ 0 == r.left() || flags & Style_Selected ? 0 : 5 ] ); p->drawLine( br.bottomLeft(), br.topLeft() ); p->setPen( gray[ 0 ] ); p->drawLine( br.left() + 1, br.top(), br.right() - 1, br.top() ); p->setPen( gray[ 5 ] ); p->drawLine( br.right(), br.top(), br.right(), br.bottom() ); br.addCoords( 1, 1, -1, 0 ); if ( APPEARANCE_FLAT != appearance ) if ( flags & Style_Selected ) drawBevelGradient( cg.background(), true, 0, p, br, true, SHADE_TAB_SEL_LIGHT( appearance ), SHADE_TAB_SEL_DARK( appearance ) ); else drawBevelGradient( gray[ 2 ], true, 0, p, br, true, SHADE_TAB_LIGHT( appearance ), SHADE_TAB_DARK( appearance ) ); else p->fillRect( br, flags & Style_Selected ? cg.background() : gray[ 2 ] ); break; case TQTabBar::TriangularBelow: case TQTabBar::RoundedBelow: if ( flags & Style_Selected ) { p->setPen( cg.background() ); p->drawLine( br.topLeft(), br.topRight() ); p->setPen( gray[ 0 ] ); p->drawPoint( br.topLeft() ); p->setPen( gray[ 5 ] ); p->drawPoint( br.topRight() ); br.addCoords( 0, 1, 0, 0 ); } else { p->setPen( gray[ 5 ] ); p->drawLine( br.left(), br.top(), br.right(), br.top() ); br.addCoords( 0, 1, -1, -1 ); } if ( 0 == r.left() || flags & Style_Selected ) { p->setPen( gray[ 0 ] ); p->drawLine( br.bottomLeft(), br.topLeft() ); } p->setPen( gray[ 5 ] ); p->drawLine( br.bottomLeft(), br.bottomRight() ); p->drawLine( br.right(), br.top(), br.right(), br.bottom() ); br.addCoords( 1, 0, -1, -1 ); if ( APPEARANCE_FLAT != appearance ) if ( flags & Style_Selected ) drawBevelGradient( cg.background(), false, 0, p, br, true, SHADE_BOTTOM_TAB_SEL_DARK( appearance ), SHADE_BOTTOM_TAB_SEL_LIGHT( appearance ) ); else drawBevelGradient( gray[ 2 ], false, 0, p, br, true, SHADE_BOTTOM_TAB_DARK( appearance ), SHADE_BOTTOM_TAB_LIGHT( appearance ) ); else p->fillRect( br, flags & Style_Selected ? cg.background() : gray[ 2 ] ); } } break; } case CE_TabBarLabel: { if ( data.isDefault() ) break; const TQTabBar *tb = ( const TQTabBar * ) widget; TQTab *t = data.tab(); TQRect tr = r; if ( t->identifier() == tb->currentTab() ) { if ( TQTabBar::RoundedAbove == tb->tqshape() || TQTabBar::TriangularAbove == tb->tqshape() ) tr.setBottom( tr.bottom() - tqpixelMetric( TQStyle::PM_TabBarTabShiftVertical, tb ) ); } else if ( TQTabBar::RoundedBelow == tb->tqshape() || TQTabBar::TriangularBelow == tb->tqshape() ) tr.setTop( tr.top() + tqpixelMetric( TQStyle::PM_TabBarTabShiftVertical, tb ) ); drawItem( p, tr, AlignCenter | ShowPrefix, cg, flags & Style_Enabled, 0, t->text() ); if ( ( flags & Style_HasFocus ) && !t->text().isEmpty() ) tqdrawPrimitive( PE_FocusRect, p, r, cg ); break; } case CE_PushButtonLabel: // Taken from Highcolour and Plastik... { int x, y, w, h; r.rect( &x, &y, &w, &h ); const TQPushButton *button = static_cast( widget ); bool active = button->isOn() || button->isDown(), cornArrow = false; // Shift button contents if pushed. if ( active ) { x += tqpixelMetric( PM_ButtonShiftHorizontal, widget ); y += tqpixelMetric( PM_ButtonShiftVertical, widget ); flags |= Style_Sunken; } // Does the button have a popup menu? if ( button->isMenuButton() ) { int dx = tqpixelMetric( PM_MenuButtonIndicator, widget ), margin = tqpixelMetric( PM_ButtonMargin, widget ); if ( button->iconSet() && !button->iconSet() ->isNull() && ( dx + button->iconSet() ->pixmap ( TQIconSet::Small, TQIconSet::Normal, TQIconSet::Off ).width() ) >= w ) cornArrow = true; //To little room. Draw the arrow in the corner, don't adjust the widget else { tqdrawPrimitive( PE_ArrowDown, p, tqvisualRect( TQRect( ( x + w ) - ( dx + margin ), y, dx, h ), r ), cg, flags, data ); w -= dx; } } // Draw the icon if there is one if ( button->iconSet() && !button->iconSet() ->isNull() ) { TQIconSet::Mode mode = TQIconSet::Disabled; TQIconSet::State state = TQIconSet::Off; if ( button->isEnabled() ) mode = button->hasFocus() ? TQIconSet::Active : TQIconSet::Normal; if ( button->isToggleButton() && button->isOn() ) state = TQIconSet::On; TQPixmap pixmap = button->iconSet() ->pixmap( TQIconSet::Small, mode, state ); static const int constSpace = 2; int xo = 0, pw = pixmap.width(), iw = 0; if ( button->text().isEmpty() && !button->pixmap() ) p->drawPixmap( x + ( w >> 1 ) - ( pixmap.width() >> 1 ), y + ( h >> 1 ) - ( pixmap.height() >> 1 ), pixmap ); else { iw = button->pixmap() ? button->pixmap() ->width() : widget->fontMetrics().size( TQt::ShowPrefix, button->text() ).width(); int cw = iw + pw + constSpace; xo = cw < w ? ( w - cw ) >> 1 : constSpace; p->drawPixmap( x + xo, y + ( h >> 1 ) - ( pixmap.height() >> 1 ), pixmap ); xo += pw; } if ( cornArrow ) //Draw over the icon tqdrawPrimitive( PE_ArrowDown, p, tqvisualRect( TQRect( x + w - 6, x + h - 6, 7, 7 ), r ), cg, flags, data ); if ( xo && iw ) { x += xo + constSpace; w = iw; } else { x += pw + constSpace; w -= pw + constSpace; } } // Make the label indicate if the button is a default button or not int i, j = boldDefText && button->isDefault() ? 2 : 1; for ( i = 0; i < j; i++ ) drawItem( p, TQRect( x + i, y, w, h ), AlignCenter | ShowPrefix, button->tqcolorGroup(), button->isEnabled(), button->pixmap(), button->text(), -1, &button->tqcolorGroup().buttonText() ); //Draw a focus rect if the button has focus if ( flags & Style_HasFocus ) tqdrawPrimitive( PE_FocusRect, p, TQStyle::tqvisualRect( subRect( SR_PushButtonFocusRect, widget ), widget ), cg, flags ); break; } case CE_PopupMenuItem: { if ( !widget || data.isDefault() ) break; const TQPopupMenu *popupmenu = ( const TQPopupMenu * ) widget; TQMenuItem *mi = data.menuItem(); int tab = data.tabWidth(), maxpmw = data.maxIconWidth(), x, y, w, h; r.rect( &x, &y, &w, &h ); if ( ( flags & Style_Active ) && ( flags & Style_Enabled ) ) { drawPBarOrMenu( p, r, true, cg, true ); } else if ( widget->erasePixmap() && !widget->erasePixmap() ->isNull() ) p->drawPixmap( x, y, *widget->erasePixmap(), x, y, w, h ); else { // lighter background in popup menu p->fillRect( r, cg.background().light( 100 + popupmenuHighlightLevel ) ); } if ( !mi ) break; if ( mi->isSeparator() ) { const TQColor * use = backgroundColors( cg ); p->setPen( cg.background().dark(105) ); p->drawLine( r.left() + 5, r.top() + 3, r.right() - 5, r.top() + 3 ); break; } maxpmw = TQMAX( maxpmw, 16 ); TQRect cr, ir, tr, sr; if (menuIcons) { // check column cr.setRect( r.left(), r.top(), maxpmw, r.height() ); // submenu indicator column sr.setCoords( r.right() - maxpmw, r.top(), r.right(), r.bottom() ); // tab/accelerator column tr.setCoords( sr.left() - tab - 4, r.top(), sr.left(), r.bottom() ); // item column ir.setCoords( cr.right() + 2, r.top(), tr.right() - 4, r.bottom() ); } else { // item column ir.setCoords( r.left() + 4, r.top(), r.width() , r.bottom() ); // check column cr.setCoords( r.right() - maxpmw, r.top(), r.right(), r.bottom() ); // submenu indicator column sr.setCoords( r.right() - maxpmw, r.top(), r.right(), r.bottom() ); // tab/accelerator column tr.setCoords( sr.left() - tab - 4, r.top(), sr.left(), r.bottom() ); } bool reverse = TQApplication::reverseLayout(); if ( reverse ) { cr = tqvisualRect( cr, r ); sr = tqvisualRect( sr, r ); tr = tqvisualRect( tr, r ); ir = tqvisualRect( ir, r ); } if ( mi->iconSet() && menuIcons ) { // Select the correct icon from the iconset TQIconSet::Mode mode = flags & Style_Active ? ( mi->isEnabled() ? TQIconSet::Active : TQIconSet::Disabled ) : ( mi->isEnabled() ? TQIconSet::Normal : TQIconSet::Disabled ); cr = tqvisualRect( TQRect( x, y, maxpmw, h ), r ); // Do we have an icon and are checked at the same time? // Then draw a "pressed" background behind the icon if ( popupmenu->isCheckable() && mi->isChecked() ) { TQBrush brush( gray[ 3 ] ); qDrawShadePanel( p, cr.x() + 1, cr.y() + 2, cr.width() - 2, cr.height() - 4, TQColorGroup( gray[ 5 ], gray[ NUM_SHADES ], gray[ 0 ], gray[ 5 ], gray[ 2 ], cg.text(), gray[ NUM_SHADES ] ), true, 1, &brush ); } // Draw the icon TQPixmap pixmap = mi->iconSet() ->pixmap( TQIconSet::Small, mode ); TQRect pmr( 0, 0, pixmap.width(), pixmap.height() ); pmr.moveCenter( cr.center() ); p->drawPixmap( pmr.topLeft(), pixmap ); } else if ( popupmenu->isCheckable() && mi->isChecked() ) { // check column cr.setRect( r.left(), r.top(), maxpmw, r.height() ); // submenu indicator column sr.setCoords( r.right() - maxpmw, r.top(), r.right(), r.bottom() ); // tab/accelerator column tr.setCoords( sr.left() - tab - 4, r.top(), sr.left(), r.bottom() ); // item column ir.setCoords( cr.right() + 2, r.top(), tr.right() - 4, r.bottom() ); TQBrush brush( mi->isEnabled() ? cg.highlightedText() : cg.background() ); tqdrawPrimitiveMenu( PE_CheckMark, p, cr, cg, ( flags & ( Style_Enabled | Style_Active ) ) | Style_On ); } TQColor textcolor, embosscolor; if ( flags & Style_Active ) { if ( !( flags & Style_Enabled ) ) { textcolor = cg.text(); embosscolor = cg.light(); } else { textcolor = cg.highlightedText(); embosscolor = cg.midlight().light(); } } else if ( !( flags & Style_Enabled ) ) { textcolor = cg.text(); embosscolor = cg.light(); } else textcolor = embosscolor = cg.buttonText(); p->setPen( textcolor ); if ( mi->custom() ) { p->save(); if ( !( flags & Style_Enabled ) ) { p->setPen( cg.light() ); mi->custom() ->paint( p, cg, ( flags & Style_Enabled ) ? ( flags & Style_Active ) : 0, flags & Style_Enabled, ir.x() + 1, ir.y() + 1, ir.width() - 1, ir.height() - 1 ); p->setPen( textcolor ); } mi->custom() ->paint( p, cg, ( flags & Style_Enabled ) ? ( flags & Style_Active ) : 0, flags & Style_Enabled, ir.x(), ir.y(), ir.width(), ir.height() ); p->restore(); } TQString text = mi->text(); if ( !text.isNull() ) { int t = text.tqfind( '\t' ); // draw accelerator/tab-text if ( t >= 0 ) { int alignFlag = AlignVCenter | ShowPrefix | DontClip | SingleLine; alignFlag |= ( reverse ? AlignLeft : AlignRight ); if ( !( flags & Style_Enabled ) ) { p->setPen( embosscolor ); tr.moveBy( 1, 1 ); p->drawText( tr, alignFlag, text.mid( t + 1 ) ); tr.moveBy( -1, -1 ); p->setPen( textcolor ); } p->drawText( tr, alignFlag, text.mid( t + 1 ) ); } int alignFlag = AlignVCenter | ShowPrefix | DontClip | SingleLine; alignFlag |= ( reverse ? AlignRight : AlignLeft ); if ( !( flags & Style_Enabled ) ) { p->setPen( embosscolor ); ir.moveBy( 1, 1 ); p->drawText( ir, alignFlag, text, t ); ir.moveBy( -1, -1 ); p->setPen( textcolor ); } p->drawText( ir, alignFlag, text, t ); } else if ( mi->pixmap() ) { TQPixmap pixmap = *mi->pixmap(); if ( 1 == pixmap.depth() ) p->setBackgroundMode( Qt::OpaqueMode ); p->drawPixmap( ir.x(), ( ir.height() - pixmap.height() ) >> 1, pixmap ); if ( pixmap.depth() == 1 ) p->setBackgroundMode( Qt::TransparentMode ); } if ( mi->popup() ) drawArrow( p, sr, cg, flags, reverse ? PE_ArrowLeft : PE_ArrowRight, false, true ); break; } case CE_MenuBarItem: { if ( ( flags & Style_Enabled ) && ( flags & Style_Active ) && ( flags & Style_Down ) ) { drawPBarOrMenu2( p, TQRect(r.x(), r.y(), r.width(), r.height()), true, cg, true ); } else #ifdef TQTC_GRADIENT_TOOLBARS_AND_MENUBARS if ( APPEARANCE_FLAT != appearance ) drawBevelGradient( cg.background(), true, 0, p, r, true, SHADE_BAR_LIGHT, SHADE_BAR_DARK ); else #endif if (darkMenubar) { drawBevelGradient( cg.background(), true, 1, p, TQRect(r.x()-1, r.y()-1, r.width()+2, r.height()+2), true, SHADE_BEVEL_MENU_GRAD_LIGHT( appearance ), SHADE_BEVEL_MENU_GRAD_DARK( appearance )); } else p->fillRect( r, cg.background() ); if ( data.isDefault() ) break; TQMenuItem *mi = data.menuItem(); if ( flags & Style_Active && ( flags & Style_Down ) ) drawItem( p, r, AlignCenter | ShowPrefix | DontClip | SingleLine, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, &cg.highlightedText() ); else drawItem( p, r, AlignCenter | ShowPrefix | DontClip | SingleLine, cg, flags & Style_Enabled, mi->pixmap(), mi->text(), -1, &cg.buttonText() ); break; } case CE_MenuBarEmptyArea: if (darkMenubar) { //p->fillRect( r, cg.background().dark( 106 ) ); TQColor b; b.setRgb(cg.background().red(), cg.background().green(), cg.background().blue()); drawBevelGradient( b, true, 1, p, TQRect(r.x()-1, r.y()-1, r.width()+2, r.height()+2 ), true, SHADE_BEVEL_MENU_GRAD_LIGHT( appearance ), SHADE_BEVEL_MENU_GRAD_DARK( appearance )); } else p->fillRect( r, cg.background() ); break; case CE_DockWindowEmptyArea: #ifdef TQTC_GRADIENT_TOOLBARS_AND_MENUBARS if ( APPEARANCE_FLAT != appearance ) drawBevelGradient( cg.background(), true, 1, p, r, true, SHADE_BAR_LIGHT, SHADE_BAR_DARK ); else #endif p->fillRect( r, cg.background() ); break; case CE_ProgressBarGroove: p->setBrush( gray[ NUM_SHADES ] ); p->drawRect( r ); qDrawShadePanel( p, r, TQColorGroup( gray[ 5 ], gray[ NUM_SHADES ], gray[ 0 ], gray[ 5 ], gray[ 2 ], cg.text(), gray[ NUM_SHADES ] ), true, 1 ); break; case CE_ProgressBarContents: { // ### Take into account totalSteps()for busy indicator const TQProgressBar *pb = ( const TQProgressBar* ) widget; TQRect cr = subRect( SR_ProgressBarContents, widget ); double progress = pb->progress(); bool reverse = TQApplication::reverseLayout(); int steps = pb->totalSteps(); if ( cr.isValid() && ( progress > 0 || steps == 0 ) ) { double pg = ( steps == 0 ) ? 0.1 : progress / steps; int width = TQMIN( cr.width(), ( int ) ( pg * cr.width() ) ); if ( 0 == steps ) //Busy indicator { if ( width < 1 ) width = 1; //A busy indicator with width 0 is kind of useless int remWidth = cr.width() - width; //Never disappear completely if ( remWidth <= 0 ) remWidth = 1; //Do something non-crashy when too small... int pstep = int( progress ) % ( 2 * remWidth ); if ( pstep > remWidth ) { //Bounce about.. We're remWidth +some delta, we want to be remWidth-delta... //-((remWidth +some delta)-2* remWidth)=-(some deleta-remWidth)=remWidth-some delta.. pstep = -( pstep - 2 * remWidth ); } if ( reverse ) drawPBarOrMenu( p, TQRect( cr.x() + cr.width() - width - pstep, cr.y(), width, cr.height() ), true, cg ); else drawPBarOrMenu( p, TQRect( cr.x() + pstep, cr.y(), width, cr.height() ), true, cg ); } else if ( reverse ) drawPBarOrMenu( p, TQRect( cr.x() + ( cr.width() - width ), cr.y(), width, cr.height() ), true, cg ); else drawPBarOrMenu( p, TQRect( cr.x(), cr.y(), width, cr.height() ), true, cg ); } break; } case CE_PushButton: { const TQPushButton *button = static_cast( widget ); TQRect br( r ); int dbi = tqpixelMetric( PM_ButtonDefaultIndicator, widget ); if ( rounded && isFormWidget( widget ) ) formMode = true; if ( widget == hoverWidget ) flags |= Style_MouseOver; if ( IND_BORDER == defBtnIndicator ) br.setCoords( br.left() + dbi, br.top() + dbi, br.right() - dbi, br.bottom() - dbi ); else if ( IND_FONT_COLOUR == defBtnIndicator && button->isDefault() ) flags |= Style_ButtonDefault; p->save(); p->setBrushOrigin( -widget->backgroundOffset().x(), -widget->backgroundOffset().y() ); // draw button tqdrawPrimitive( PE_ButtonCommand, p, br, cg, flags ); if ( button->isDefault() && IND_FONT_COLOUR != defBtnIndicator ) tqdrawPrimitive( PE_ButtonDefault, p, r, cg, flags ); p->restore(); formMode = false; break; } case CE_CheckBox: tqdrawPrimitive( PE_Indicator, p, r, cg, flags, data ); break; case CE_CheckBoxLabel: if ( crLabelHighlight ) { const TQCheckBox * checkbox = ( const TQCheckBox * ) widget; if ( flags & Style_MouseOver && HOVER_CHECK == hover && hoverWidget == widget && !isFormWidget( widget ) ) { TQRect cr( checkbox->rect() ); TQRegion r( TQRect( cr.x(), cr.y(), tqvisualRect( subRect( SR_CheckBoxFocusRect, widget ), widget ).width() + tqpixelMetric( PM_IndicatorWidth ) + 4, cr.height() ) ); r -= tqvisualRect( subRect( SR_CheckBoxIndicator, widget ), widget ); p->setClipRegion( r ); p->fillRect( checkbox->rect(), cg.background().light( TQTC_HIGHLIGHT_FACTOR ) ); p->setClipping( false ); } int tqalignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft; drawItem( p, r, tqalignment | AlignVCenter | ShowPrefix, cg, flags & Style_Enabled, checkbox->pixmap(), checkbox->text() ); if ( checkbox->hasFocus() ) tqdrawPrimitive( PE_FocusRect, p, tqvisualRect( subRect( SR_CheckBoxFocusRect, widget ), widget ), cg, flags ); } else KStyle::tqdrawControl( control, p, widget, r, cg, flags, data ); break; case CE_RadioButton: formMode = isFormWidget( widget ); tqdrawPrimitive( PE_ExclusiveIndicator, p, r, cg, flags, data ); formMode = false; break; case CE_RadioButtonLabel: if ( crLabelHighlight ) { const TQRadioButton * radiobutton = ( const TQRadioButton * ) widget; if ( flags & Style_MouseOver && HOVER_RADIO == hover && hoverWidget == widget && !isFormWidget( widget ) ) { TQRect rb( radiobutton->rect() ); TQRegion r( TQRect( rb.x(), rb.y(), tqvisualRect( subRect( SR_RadioButtonFocusRect, widget ), widget ).width() + tqpixelMetric( PM_ExclusiveIndicatorWidth ) + 4, rb.height() ) ); r -= tqvisualRect( subRect( SR_RadioButtonIndicator, widget ), widget ); p->setClipRegion( r ); p->fillRect( radiobutton->rect(), cg.background().light( TQTC_HIGHLIGHT_FACTOR ) ); p->setClipping( false ); } int tqalignment = TQApplication::reverseLayout() ? AlignRight : AlignLeft; drawItem( p, r, tqalignment | AlignVCenter | ShowPrefix, cg, flags & Style_Enabled, radiobutton->pixmap(), radiobutton->text() ); if ( radiobutton->hasFocus() ) tqdrawPrimitive( PE_FocusRect, p, tqvisualRect( subRect( SR_RadioButtonFocusRect, widget ), widget ), cg, flags ); break; } default: KStyle::tqdrawControl( control, p, widget, r, cg, flags, data ); } } void KlearlookStyle::tqdrawControlMask( ControlElement control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption &data ) const { switch ( control ) { case CE_PushButton: if ( rounded ) { int offset = r.width() < TQTC_MIN_BTN_SIZE || r.height() < TQTC_MIN_BTN_SIZE ? 1 : 2; p->fillRect( r, color0 ); p->fillRect( r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2, color1 ); p->setPen( color1 ); p->drawLine( r.x() + offset, r.y(), r.x() + r.width() - ( offset + 1 ), r.y() ); p->drawLine( r.x() + offset, r.y() + r.height() - 1, r.x() + r.width() - ( offset + 1 ), r.y() + r.height() - 1 ); p->drawLine( r.x(), r.y() + offset, r.x(), r.y() + r.height() - ( offset + 1 ) ); p->drawLine( r.x() + r.width() - 1, r.y() + offset, r.x() + r.width() - 1, r.y() + r.height() - ( offset + 1 ) ); } else p->fillRect( r, color1 ); break; default: KStyle::tqdrawControlMask( control, p, widget, r, data ); } } void KlearlookStyle::tqdrawComplexControlMask( ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption &data ) const { switch ( control ) { case CC_ToolButton: case CC_ComboBox: tqdrawControlMask( CE_PushButton, p, widget, r, data ); break; default: KStyle::tqdrawComplexControlMask( control, p, widget, r, data ); } } TQRect KlearlookStyle::subRect( SubRect subrect, const TQWidget *widget ) const { TQRect rect, wrect( widget->rect() ); switch ( subrect ) { case SR_PushButtonFocusRect: { // const TQPushButton *button=(const TQPushButton *)widget; int dbw1 = 0, dbw2 = 0; // if(button->isDefault() || button->autoDefault()) // { dbw1 = tqpixelMetric( PM_ButtonDefaultIndicator, widget ); dbw2 = dbw1 * 2; // } rect.setRect( wrect.x() + 3 + dbw1, wrect.y() +3 + dbw1, wrect.width() - 6 - dbw2, wrect.height() - 6 - dbw2 ); break; } case SR_CheckBoxIndicator: { int h = tqpixelMetric( PM_IndicatorHeight ); rect.setRect( ( widget->rect().height() - h ) >> 1, ( widget->rect().height() - h ) >> 1, tqpixelMetric( PM_IndicatorWidth ), h ); break; } case SR_RadioButtonIndicator: { int h = tqpixelMetric( PM_ExclusiveIndicatorHeight ); rect.setRect( ( widget->rect().height() - h ) >> 1, ( widget->rect().height() - h ) >> 1, tqpixelMetric( PM_ExclusiveIndicatorWidth ), h ); break; } case SR_ProgressBarContents: rect = TQRect( wrect.x() + 1, wrect.y() + 1, wrect.width() - 2, wrect.height() - 2 ); break; default: rect = KStyle::subRect( subrect, widget ); } return rect; } void KlearlookStyle::tqdrawComplexControl( ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQColorGroup &cg, SFlags flags, SCFlags controls, SCFlags active, const TQStyleOption &data ) const { if ( widget == hoverWidget ) flags |= Style_MouseOver; switch ( control ) { case CC_ToolButton: { const TQToolButton * toolbutton = ( const TQToolButton * ) widget; TQRect button ( querySubControlMetrics( control, widget, SC_ToolButton, data ) ), menuarea( querySubControlMetrics( control, widget, SC_ToolButtonMenu, data ) ); SFlags bflags = flags, mflags = flags; if ( APP_KORN == themedApp ) { tqdrawPrimitive( PE_ButtonTool, p, button, cg, bflags, data ); break; } bool onControlButtons = false, onToolbar = widget->parentWidget() && ::tqqt_cast( widget->parentWidget() ), onExtender = !onToolbar && widget->parentWidget() && widget->parentWidget() ->inherits( "TQToolBarExtensionWidget" ) && ::tqqt_cast( widget->parentWidget() ->parentWidget() ); if ( !onToolbar && !onExtender && widget->parentWidget() && !qstrcmp( widget->parentWidget() ->name(), "qt_maxcontrols" ) ) onControlButtons = true; if ( active & SC_ToolButton ) bflags |= Style_Down; if ( active & SC_ToolButtonMenu ) mflags |= Style_Down; if ( controls & SC_ToolButton ) { // If we're pressed, on, or raised... #if KDE_VERSION >= 0x30200 if ( bflags & ( Style_Down | Style_On | Style_Raised ) || onControlButtons ) #else // CPD: Style_MouseOver obove is *needed* for KDE's KToggleActions... if ( bflags & ( Style_Down | Style_On | Style_Raised | Style_MouseOver ) || onControlButtons ) #endif { //Make sure the standalone toolbuttons have a gradient in the right direction if ( !onToolbar && !onControlButtons ) bflags |= Style_Horizontal; tqdrawPrimitive( PE_ButtonTool, p, button, cg, bflags, data ); } // Check whether to draw a background pixmap else if ( toolbutton->parentWidget() && toolbutton->parentWidget() ->backgroundPixmap() && !toolbutton->parentWidget() ->backgroundPixmap() ->isNull() ) { p->drawTiledPixmap( r, *( toolbutton->parentWidget() ->backgroundPixmap() ), toolbutton->pos() ); } else if ( widget->tqparent() ) { if ( ::tqqt_cast( widget->tqparent() ) ) { TQToolBar * tqparent = ( TQToolBar* ) widget->tqparent(); #ifdef TQTC_GRADIENT_TOOLBARS_AND_MENUBARS if ( APPEARANCE_FLAT != appearance ) drawBevelGradient( cg.background(), true, 0, p, tqparent->rect(), true, SHADE_BAR_LIGHT, SHADE_BAR_DARK ); else #endif p->fillRect( tqparent->rect(), cg.background() ); } else if ( widget->tqparent() ->inherits( "TQToolBarExtensionWidget" ) ) { TQWidget * tqparent = ( TQWidget* ) widget->tqparent(); TQToolBar *toolbar = ( TQToolBar* ) tqparent->tqparent(); #ifdef TQTC_GRADIENT_TOOLBARS_AND_MENUBARS if ( APPEARANCE_FLAT != appearance ) drawBevelGradient( cg.background(), true, 0, p, toolbar->rect(), true, SHADE_BAR_LIGHT, SHADE_BAR_DARK ); else #endif p->fillRect( toolbar->rect(), cg.background() ); } } } if ( controls & SC_ToolButtonMenu ) { if ( mflags & ( Style_Down | Style_On | Style_Raised ) ) tqdrawPrimitive( PE_ButtonDropDown, p, menuarea, cg, mflags, data ); tqdrawPrimitive( PE_ArrowDown, p, menuarea, cg, mflags, data ); } if ( toolbutton->hasFocus() && !toolbutton->focusProxy() ) { TQRect fr = toolbutton->rect(); fr.addCoords( 3, 3, -3, -3 ); tqdrawPrimitive( PE_FocusRect, p, fr, cg ); } break; } case CC_ComboBox: { const TQComboBox *combobox = ( const TQComboBox * ) widget; TQRect frame( TQStyle::tqvisualRect( querySubControlMetrics( CC_ComboBox, widget,SC_ComboBoxFrame,data ),widget ) ), arrow( TQStyle::tqvisualRect( querySubControlMetrics( CC_ComboBox, widget,SC_ComboBoxArrow,data),widget)), field( TQStyle::tqvisualRect( querySubControlMetrics(CC_ComboBox, widget,SC_ComboBoxEditField,data),widget)); const TQColor *use = buttonColors( cg ); if ( rounded && isFormWidget( widget ) ) formMode = true; if ( controls & SC_ComboBoxFrame && frame.isValid() ) { if ( controls & SC_ComboBoxEditField && field.isValid() && combobox->editable() ) { TQRect f2( field ); TQRegion reg( r ); f2.addCoords( -1, -1, 1, 1 ); reg -= f2; p->setClipRegion( reg ); } drawLightBevelButton( p, r, cg, flags | Style_Raised | Style_Horizontal, true, ROUNDED_ALL, getFill( flags, use ), use ); p->setClipping( false ); } if ( controls & SC_ComboBoxArrow && arrow.isValid() ) { tqdrawPrimitive( PE_ArrowDown, p, arrow, cg, flags & ~Style_MouseOver ); p->setPen( use[ 4 ].light(70) ); arrow.addCoords( -1, -1, -1, 1 ); p->drawLine( arrow.left(), arrow.top(), arrow.left(), arrow.bottom() ); } if ( controls & SC_ComboBoxEditField && field.isValid() ) { if ( ( flags & Style_HasFocus ) && ( ! combobox->editable() ) ) { TQRect fr = TQStyle::tqvisualRect( subRect( SR_ComboBoxFocusRect, widget ), widget ); fr.addCoords( 0, 0, -2, 0 ); tqdrawPrimitive( PE_FocusRect, p, fr, cg, flags | Style_FocusAtBorder, TQStyleOption( cg.highlight() ) ); } } p->setPen( flags & Style_Enabled ? cg.buttonText() : cg.mid() ); formMode = false; break; } case CC_SpinWidget: { const TQSpinWidget *spinwidget = ( const TQSpinWidget * ) widget; TQRect frame( querySubControlMetrics( CC_SpinWidget, widget, SC_SpinWidgetFrame, data ) ), up( spinwidget->upRect() ), down( spinwidget->downRect() ); if ( hoverWidget && spinwidget == hoverWidget ) flags |= Style_MouseOver; if ( ( controls & SC_SpinWidgetFrame ) && frame.isValid() ) qDrawShadePanel( p, r, TQColorGroup( gray[ 5 ], gray[ NUM_SHADES ], gray[ 0 ], gray[ 5 ], gray[ 2 ], cg.text(), gray[ NUM_SHADES ] ), true, tqpixelMetric( PM_SpinBoxFrameWidth ) ); if ( ( controls & SC_SpinWidgetUp ) && up.isValid() ) { TQ_PrimitiveElement pe = PE_SpinWidgetUp; SFlags upflags = flags; if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) pe = PE_SpinWidgetPlus; if ( !spinwidget->isUpEnabled() ) upflags ^= Style_Enabled; tqdrawPrimitive( pe, p, up, cg, upflags | ( ( active == SC_SpinWidgetUp ) ? Style_On | Style_Sunken : Style_Raised ) ); } if ( ( controls & SC_SpinWidgetDown ) && down.isValid() ) { TQ_PrimitiveElement pe = PE_SpinWidgetDown; SFlags downflags = flags; if ( spinwidget->buttonSymbols() == TQSpinWidget::PlusMinus ) pe = PE_SpinWidgetMinus; if ( !spinwidget->isDownEnabled() ) downflags ^= Style_Enabled; tqdrawPrimitive( pe, p, down, cg, downflags | ( ( active == SC_SpinWidgetDown ) ? Style_On | Style_Sunken : Style_Raised ) ); } const TQColor *use = backgroundColors( cg ); p->setPen( use[ 4 ].light(80) ); p->drawRect( r ); break; } case CC_ScrollBar: { const TQScrollBar *scrollbar = ( const TQScrollBar * ) widget; bool hw = hoverWidget == scrollbar; TQRect subline( querySubControlMetrics( control, widget, SC_ScrollBarSubLine, data ) ), addline( querySubControlMetrics( control, widget, SC_ScrollBarAddLine, data ) ), subpage( querySubControlMetrics( control, widget, SC_ScrollBarSubPage, data ) ), addpage( querySubControlMetrics( control, widget, SC_ScrollBarAddPage, data ) ), slider( querySubControlMetrics( control, widget, SC_ScrollBarSlider, data ) ), first( querySubControlMetrics( control, widget, SC_ScrollBarFirst, data ) ), last( querySubControlMetrics( control, widget, SC_ScrollBarLast, data ) ); if ( ( controls & SC_ScrollBarSubLine ) && subline.isValid() ) tqdrawPrimitive( PE_ScrollBarSubLine, p, subline, cg, ( hw && HOVER_SB_SUB == hover ? Style_MouseOver : Style_Default ) | Style_Enabled | ( ( active == SC_ScrollBarSubLine ) ? Style_Down : Style_Default ) | ( ( scrollbar->orientation() == Qt::Horizontal ) ? Style_Horizontal : Style_Default ) ); if ( ( controls & SC_ScrollBarAddLine ) && addline.isValid() ) tqdrawPrimitive( PE_ScrollBarAddLine, p, addline, cg, ( hw && HOVER_SB_ADD == hover ? Style_MouseOver : Style_Default ) | Style_Enabled | ( ( active == SC_ScrollBarAddLine ) ? Style_Down : Style_Default ) | ( ( scrollbar->orientation() == Qt::Horizontal ) ? Style_Horizontal : Style_Default ) ); if ( ( controls & SC_ScrollBarSubPage ) && subpage.isValid() ) tqdrawPrimitive( PE_ScrollBarSubPage, p, subpage, cg, Style_Enabled | ( ( active == SC_ScrollBarSubPage ) ? Style_Down : Style_Default ) | ( ( scrollbar->orientation() == Qt::Horizontal ) ? Style_Horizontal : Style_Default ) ); if ( ( controls & SC_ScrollBarAddPage ) && addpage.isValid() ) tqdrawPrimitive( PE_ScrollBarAddPage, p, addpage, cg, ( ( scrollbar->minValue() == scrollbar->maxValue() ) ? Style_Default : Style_Enabled ) | ( ( active == SC_ScrollBarAddPage ) ? Style_Down : Style_Default ) | ( ( scrollbar->orientation() == Qt::Horizontal ) ? Style_Horizontal : Style_Default ) ); if ( ( controls & SC_ScrollBarFirst ) && first.isValid() ) tqdrawPrimitive( PE_ScrollBarFirst, p, first, cg, Style_Enabled | ( ( active == SC_ScrollBarFirst ) ? Style_Down : Style_Default ) | ( ( scrollbar->orientation() == Qt::Horizontal ) ? Style_Horizontal : Style_Default ) ); if ( ( controls & SC_ScrollBarLast ) && last.isValid() ) tqdrawPrimitive( PE_ScrollBarLast, p, last, cg, Style_Enabled | ( ( active == SC_ScrollBarLast ) ? Style_Down : Style_Default ) | ( ( scrollbar->orientation() == Qt::Horizontal ) ? Style_Horizontal : Style_Default ) ); if ( ( controls & SC_ScrollBarSlider ) && slider.isValid() ) { tqdrawPrimitive( PE_ScrollBarSlider, p, slider, cg, ( hw && HOVER_SB_SLIDER == hover ? Style_MouseOver : Style_Default ) | Style_Enabled | ( ( active == SC_ScrollBarSlider ) ? Style_Down : Style_Default ) | ( ( scrollbar->orientation() == Qt::Horizontal ) ? Style_Horizontal : Style_Default ) ); // ### perhaps this should not be able to accept focus if maxedOut? if ( scrollbar->hasFocus() ) tqdrawPrimitive( PE_FocusRect, p, TQRect( slider.x() + 2, slider.y() + 2, slider.width() - 5, slider.height() - 5 ), cg, Style_Default ); } break; } case CC_Slider: { TQRect groove = querySubControlMetrics( CC_Slider, widget, SC_SliderGroove, data ), handle = querySubControlMetrics( CC_Slider, widget, SC_SliderHandle, data ); if ( ( controls & SC_SliderGroove ) && groove.isValid() ) drawSliderGroove( p, groove, flags, widget ); if ( ( controls & SC_SliderHandle ) && handle.isValid() ) drawSliderHandle( p, handle, cg, flags ); if ( controls & SC_SliderTickmarks ) TQCommonStyle::tqdrawComplexControl( control, p, widget, r, cg, flags, SC_SliderTickmarks, active, data ); break; } default: KStyle::tqdrawComplexControl( control, p, widget, r, cg, flags, controls, active, data ); } } TQRect KlearlookStyle::querySubControlMetrics( TQ_ComplexControl control, const TQWidget *widget, SubControl sc, const TQStyleOption &data ) const { switch ( control ) { case CC_SpinWidget: { if ( !widget ) return TQRect(); int fw = tqpixelMetric( PM_SpinBoxFrameWidth, 0 ); TQSize bs; bs.setHeight( widget->height() >> 1 ); if ( bs.height() < 8 ) bs.setHeight( 8 ); bs.setWidth( TQMIN( bs.height() * 8 / 6, widget->width() / 4 ) ); bs = bs.expandedTo( TQApplication::globalStrut() ); if ( !( bs.width() % 2 ) ) bs.setWidth( bs.width() + 1 ); int extra = bs.height() * 2 == widget->height() ? 0 : 1; int y = 0, x = widget->width() - y - bs.width(), lx = fw, rx = x - fw * 2; switch ( sc ) { case SC_SpinWidgetUp: return TQRect( x, y, bs.width(), bs.height() ); case SC_SpinWidgetDown: return TQRect( x, y + bs.height(), bs.width(), bs.height() + extra ); case SC_SpinWidgetButtonField: return TQRect( x, y, bs.width(), widget->height() - 2 * fw ); case SC_SpinWidgetEditField: return TQRect( lx, fw, rx, widget->height() - 2 * fw ); case SC_SpinWidgetFrame: return TQRect( widget->x(), widget->y(), widget->width() - bs.width(), widget->height() ); } } default: return KStyle::querySubControlMetrics( control, widget, sc, data ); } } int KlearlookStyle::tqpixelMetric( PixelMetric metric, const TQWidget *widget ) const { switch ( metric ) { case PM_MenuButtonIndicator: return 7; case PM_MenuBarItemSpacing: { return 5; } case PM_ButtonMargin: return 5; case PM_TabBarTabShiftVertical: { const TQTabBar *tb = ::tqqt_cast( widget ); return TQTabBar::RoundedAbove == tb->tqshape() || TQTabBar::TriangularAbove == tb->tqshape() ? 1 : -1; } case PM_TabBarTabShiftHorizontal: return 0; case PM_TabBarTabVSpace: { const TQTabBar * tb = ( const TQTabBar * ) widget; if ( tb->tqshape() == TQTabBar::RoundedAbove || tb->tqshape() == TQTabBar::RoundedBelow ) return 12; else return 4; } case PM_ButtonShiftHorizontal: case PM_ButtonShiftVertical: return 1; case PM_ButtonDefaultIndicator: return IND_BORDER == defBtnIndicator ? 1 : 0; case PM_DefaultFrameWidth: return borderFrame && widget && ( ::tqqt_cast( widget ) || ::tqqt_cast( widget ) || ::tqqt_cast( widget ) ) ? 2 : TQTC_DEF_FRAME_WIDTH; case PM_SpinBoxFrameWidth: return 1; case PM_MenuBarFrameWidth: return 1; case PM_IndicatorWidth: case PM_IndicatorHeight: return TQTC_CHECK_SIZE; case PM_ExclusiveIndicatorWidth: case PM_ExclusiveIndicatorHeight: return TQTC_RADIO_SIZE; case PM_TabBarTabOverlap: return 1; case PM_ProgressBarChunkWidth: return 2; case PM_DockWindowSeparatorExtent: return 4; case PM_DockWindowHandleExtent: return 10; case PM_SplitterWidth: return 4; case PM_ScrollBarSliderMin: return 16; case PM_ScrollBarExtent: case PM_SliderControlThickness: case PM_SliderThickness: return 15; case PM_SliderLength: return 24; case PM_MaximumDragDistance: return -1; default: return KStyle::tqpixelMetric( metric, widget ); } } int KlearlookStyle::kPixelMetric( KStylePixelMetric kpm, const TQWidget *widget ) const { switch ( kpm ) { case KPM_MenuItemSeparatorHeight: return 4; default: return KStyle::kPixelMetric( kpm, widget ); } } TQSize KlearlookStyle::tqsizeFromContents( ContentsType t, const TQWidget *widget, const TQSize &s, const TQStyleOption &opt ) const { switch ( t ) { case CT_PopupMenuItem: { if ( !widget || opt.isDefault() ) return s; const TQPopupMenu *popup = dynamic_cast( widget ); TQMenuItem *mi = opt.menuItem(); int maxpmw = opt.maxIconWidth(); int w = s.width(), h = s.height(); bool checkable = popup->isCheckable(); if ( mi->custom() ) { w = mi->custom() ->tqsizeHint().width(); h = mi->custom() ->tqsizeHint().height(); if ( !mi->custom() ->fullSpan() ) h += 4; } else if ( mi->widget() ) { // don't change the size in this case. } else if ( mi->isSeparator() ) { w = 20; h = 8; } else { if ( mi->pixmap() ) { h = TQMAX( h, mi->pixmap() ->height() + 2 ); } else { h = TQMAX( h, 21 ); TQSettings s; if ( menuIcons ) h = TQMAX( h, popup->fontMetrics().height() + MENU_POPUP_ITEM_HIGH_HI ); else h = TQMAX( h, popup->fontMetrics().height() + MENU_POPUP_ITEM_HIGH_LO ); } if ( mi->iconSet() ) { h = TQMAX( h, mi->iconSet() ->pixmap( TQIconSet::Small, TQIconSet::Normal ).height() + 2 ); } } if ( !mi->text().isNull() && ( mi->text().tqfind( '\t' ) >= 0 ) ) { w += itemHMargin + itemFrame * 2 + 7; } else if ( mi->popup() ) { w += 2 * arrowHMargin; } if ( maxpmw ) { w += maxpmw + 6; } if ( checkable && maxpmw < 20 ) { w += 20 - maxpmw; } if ( checkable || maxpmw > 0 ) { w += 12; } w += rightBorder; return TQSize( w-25, h ); } case CT_PushButton: { const TQPushButton* btn = static_cast( widget ); int w = s.width() + 2 * tqpixelMetric( PM_ButtonMargin, widget ); int h = s.height() + 2 * tqpixelMetric( PM_ButtonMargin, widget ); if ( btn->text().isEmpty() && s.width() < 32 ) return TQSize( w, h ); // return button size return TQSize( w + 25, h + 3 ); } case CT_ToolButton: { if ( widget->tqparent() && ::tqqt_cast( widget->tqparent() ) ) return TQSize( s.width() + 2 * 4, s.height() + 2 * 4 ); else { return KStyle::tqsizeFromContents ( t, widget, s, opt ); } } default: return KStyle::tqsizeFromContents ( t, widget, s, opt ); } return KStyle::tqsizeFromContents ( t, widget, s, opt ); } int KlearlookStyle::tqstyleHint( StyleHint stylehint, const TQWidget *widget, const TQStyleOption &option, TQStyleHintReturn *returnData ) const { switch ( stylehint ) { case SH_EtchDisabledText: case SH_Slider_SnapToValue: case SH_PrintDialog_RightAlignButtons: case SH_FontDialog_SelectAssociatedText: case SH_MenuBar_AltKeyNavigation: case SH_MenuBar_MouseTracking: case SH_PopupMenu_MouseTracking: case SH_PopupMenu_SpaceActivatesItem: case SH_ComboBox_ListMouseTracking: case SH_ScrollBar_MiddleClickAbsolutePosition: return 1; case SH_MainWindow_SpaceBelowMenuBar: return 0; case SH_ComboBox_Popup: return 0; case SH_PopupMenu_SubMenuPopupDelay: return 300; case SH_PopupMenu_AllowActiveAndDisabled: return 0; default: return KStyle::tqstyleHint( stylehint, widget, option, returnData ); } } void KlearlookStyle::drawPBarOrMenu( TQPainter *p, TQRect const &r, bool horiz, const TQColorGroup &cg, bool menu ) const { switch ( pmProfile ) { case PROFILE_SUNKEN: drawGradientWithBorder( p, r, horiz ); break; case PROFILE_RAISED: { int flags = TQStyle::Style_Raised; if ( horiz ) flags |= Style_Horizontal; drawLightBevel( p, r, cg, flags, true, menu ? ROUNDED_ALL : ROUNDED_NONE, getFill( flags, menuPbar ), menuPbar, true ); break; } default: p->fillRect( r, menuPbar[ GRADIENT_BASE ] ); break; } } void KlearlookStyle::drawPBarOrMenu2( TQPainter *p, TQRect const &r, bool horiz, const TQColorGroup &cg, bool menu ) const { switch ( pmProfile ) { case PROFILE_SUNKEN: drawGradientWithBorder( p, r, horiz ); break; case PROFILE_RAISED: { int flags = TQStyle::Style_Raised; if ( horiz ) flags |= Style_Horizontal; drawLightBevel( p, r, cg, flags, true, menu ? ROUNDED_TOP : ROUNDED_NONE, getFill( flags, menuPbar ), menuPbar, true ); break; } default: p->fillRect( r, menuPbar[ GRADIENT_BASE ] ); break; } } void KlearlookStyle::drawGradientWithBorder( TQPainter *p, TQRect const &r, bool horiz ) const { TQRect r2( r ); drawGradient( menuPbar[ GRADIENT_TOP ], menuPbar[ GRADIENT_BOTTOM ], true, borderFrame ? 2 : 1, p, r, horiz ); // 3d border effect... if ( borderFrame ) { p->setPen( menuPbar[ GRADIENT_BASE ] ); p->setBrush( NoBrush ); p->drawRect( r ); } else r2.addCoords( -1, -1, 1, 1 ); p->setPen( menuPbar[ GRADIENT_LIGHT ] ); p->drawLine( r2.left() + 1, r2.top() + 1, r2.right() - 1, r2.top() + 1 ); p->drawLine( r2.left() + 1, r2.top() + 1, r2.left() + 1, r2.bottom() - 1 ); p->setPen( menuPbar[ GRADIENT_DARK ] ); p->drawLine( r2.left() + 1, r2.bottom() - 1, r2.right() - 1, r2.bottom() - 1 ); p->drawLine( r2.right() - 1, r2.bottom() - 1, r2.right() - 1, r2.top() + 1 ); } void KlearlookStyle::drawBevelGradient( const TQColor &base, bool increase, int border, TQPainter *p, TQRect const &r, bool horiz, double shadeTop, double shadeBot ) const { //CPD TODO: Store last settings to make faster! TQColor top, bot; if ( equal( 1.0, shadeTop ) ) top = base; else shade( base, &top, shadeTop ); if ( equal( 1.0, shadeBot ) ) bot = base; else shade( base, &bot, shadeBot ); drawGradient( top, bot, increase, border, p, r, horiz ); } void KlearlookStyle::drawGradient( const TQColor &top, const TQColor &bot, bool increase, int border, TQPainter *p, TQRect const &r, bool horiz ) const { if ( r.width() > 0 && r.height() > 0 ) { TQRect grad( r.left() + border, r.top() + border, r.width() - ( border * 2 ), r.height() - ( border * 2 ) ); if ( top == bot ) p->fillRect( grad, top ); else { TQRect grad( r.left() + border, r.top() + border, r.width() - ( border * 2 ), r.height() - ( border * 2 ) ); int i, s = horiz ? grad.top() : grad.left(), e = horiz ? grad.bottom() : grad.right(); double amt = ( horiz ? grad.height() : grad.width() ) , dr = ( ( double ) ( bot.red() - top.red() ) ) / amt , dg = ( ( double ) ( bot.green() - top.green() ) ) / amt , db = ( ( double ) ( bot.blue() - top.blue() ) ) / amt, rc = 0, gc = 0, bc = 0; if ( increase ) for ( i = s; i <= e ; i++ ) { p->setPen( TQColor( limit( top.red() + rc ), limit( top.green() + gc ), limit( top.blue() + bc ) )); if ( horiz ) p->drawLine( grad.left(), i, grad.right(), i ); else p->drawLine( i, grad.top(), i, grad.bottom() ); rc += dr; gc += dg; bc += db; } else for ( i = e; i >= s; i-- ) { p->setPen( TQColor( limit( top.red() + rc ), limit( top.green() + gc ), limit( top.blue() + bc ) ) ); if ( horiz ) p->drawLine( grad.left(), i, grad.right(), i ); else p->drawLine( i, grad.top(), i, grad.bottom() ); rc += dr; gc += dg; bc += db; } } } } void KlearlookStyle::drawPopupRect( TQPainter *p, const TQRect &r, const TQColorGroup &cg ) const { const TQColor *use = backgroundColors( cg ); p->setPen( use[ 4 ].light(70) ); p->setBrush( NoBrush ); p->drawRect( r ); } void KlearlookStyle::drawSliderHandle( TQPainter *p, const TQRect &r, const TQColorGroup &cg, TQStyle::SFlags flags ) const { const TQColor * use = buttonColors( cg ); if ( r.width() > r.height() ) flags |= Style_Horizontal; flags |= Style_Raised; drawLightBevelButton( p, r, cg, flags, true, ROUNDED_ALL, getFill( flags, use ), use ); if ( GROOVE_NONE != sliderThumbs && ( ( flags & Style_Horizontal && r.width() >= 14 ) || r.height() >= 14 ) ) drawLines( p, r, r.width() < r.height(), 4, 3, use, 0, GROOVE_SUNKEN == sliderThumbs, APPEARANCE_LIGHT_GRADIENT == appearance ); } void KlearlookStyle::drawSliderGroove ( TQPainter *p, const TQRect &r, TQStyle::SFlags flags, const TQWidget *widget ) const { const TQSlider * slider = ( const TQSlider * ) widget; TQRect groove( r ); if ( flags & Style_HasFocus ) { TQRect fr( groove ); fr.addCoords( -1, -1, 1, 1 ); tqdrawPrimitive( PE_FocusRect, p, fr, TQColorGroup() ); } if ( Qt::Horizontal == slider->orientation() ) { int dh = ( groove.height() - 5 ) >> 1; groove.addCoords( 0, dh, 0, -dh ); } else { int dw = ( groove.width() - 5 ) >> 1; groove.addCoords( dw, 0, -dw, 0 ); } p->setBrush( gray[ 2 ] ); p->setPen( gray[ 5 ] ); p->drawRect( groove ); p->setPen( gray[ 4 ] ); p->drawLine( groove.x() + 1, groove.y() + 1, groove.x() + groove.width() - 2, groove.y() + 1 ); p->drawLine( groove.x() + 1, groove.y() + 1, groove.x() + 1, groove.y() + groove.height() - 2 ); } void KlearlookStyle::shadeColors( const TQColor &base, TQColor *vals ) const { TQTC_SHADES int i; for ( i = 0; i < NUM_SHADES; ++i ) shade( base, &vals[ i ], TQTC_SHADE( appearance, contrast, i ) ); vals[ NUM_SHADES ] = base; } const TQColor * KlearlookStyle::buttonColors( const TQColorGroup &cg ) const { if ( cg.button() != button[ NUM_SHADES ] ) { shadeColors( cg.button(), buttonColoured ); return buttonColoured; } return button; } const TQColor * KlearlookStyle::backgroundColors( const TQColorGroup &cg ) const { if ( cg.background() != gray[ NUM_SHADES ] ) { shadeColors( cg.background(), backgroundColoured ); return backgroundColoured; } return gray; } bool KlearlookStyle::redrawHoverWidget() { if ( !hoverWidget ) return false; TQPoint cursor( TQCursor::pos() ), widgetZero( hoverWidget->mapToGlobal( TQPoint( 0, 0 ) ) ); // // TQt>=3.2 sets the sensitive part of a check/radio to the image + label -> anything else // is not sensitive. But, // the widget can ocupy a larger area - and this whole are will react to mouse over. // This needs to be coounteracted // so that it looks as if only the sensitive area mouse-overs... TQRadioButton *rb = dynamic_cast( hoverWidget ); if ( rb ) { TQRect rect( widgetZero.x(), widgetZero.y(), tqvisualRect( subRect( SR_RadioButtonFocusRect, rb ), rb ).width() + tqpixelMetric( PM_ExclusiveIndicatorWidth ) + 4, hoverWidget->height() ); hover = rect.tqcontains( cursor ) ? HOVER_RADIO : HOVER_NONE; return ( HOVER_NONE != hover && !rect.tqcontains( oldCursor ) ) || ( HOVER_NONE == hover && rect.tqcontains( oldCursor ) ); } else { TQCheckBox *cb = dynamic_cast( hoverWidget ); if ( cb ) { TQRect rect( widgetZero.x(), widgetZero.y(), tqvisualRect( subRect( SR_CheckBoxFocusRect, cb ), cb ).width() + tqpixelMetric( PM_IndicatorWidth ) + 4, hoverWidget->height() ); hover = rect.tqcontains( cursor ) ? HOVER_CHECK : HOVER_NONE; return ( HOVER_NONE != hover && !rect.tqcontains( oldCursor ) ) || ( HOVER_NONE == hover && rect.tqcontains( oldCursor ) ); } else { TQScrollBar *sb = dynamic_cast( hoverWidget ); if ( sb ) // So, are we over add button, sub button, slider, or none? { TQRect subline( querySubControlMetrics( CC_ScrollBar, hoverWidget, SC_ScrollBarSubLine ) ), addline( querySubControlMetrics( CC_ScrollBar, hoverWidget, SC_ScrollBarAddLine ) ), slider( querySubControlMetrics( CC_ScrollBar, hoverWidget, SC_ScrollBarSlider ) ); subline.moveLeft( subline.x() + widgetZero.x() ); subline.moveTop( subline.y() + widgetZero.y() ); addline.moveLeft( addline.x() + widgetZero.x() ); addline.moveTop( addline.y() + widgetZero.y() ); slider.moveLeft( slider.x() + widgetZero.x() ); slider.moveTop( slider.y() + widgetZero.y() ); if ( slider.tqcontains( cursor ) ) hover = HOVER_SB_SLIDER; else if ( subline.tqcontains( cursor ) ) hover = HOVER_SB_SUB; else if ( addline.tqcontains( cursor ) ) hover = HOVER_SB_ADD; else hover = HOVER_NONE; return ( HOVER_SB_SLIDER == hover && !slider.tqcontains( oldCursor ) ) || ( HOVER_SB_SLIDER != hover && slider.tqcontains( oldCursor ) ) || ( HOVER_SB_SUB == hover && !subline.tqcontains( oldCursor ) ) || ( HOVER_SB_SUB != hover && subline.tqcontains( oldCursor ) ) || ( HOVER_SB_ADD == hover && !addline.tqcontains( oldCursor ) ) || ( HOVER_SB_ADD != hover && addline.tqcontains( oldCursor ) ); } else { #if KDE_VERSION >= 0x30400 TQToolButton *tb = dynamic_cast( hoverWidget ); if ( tb ) { hover = APP_KICKER == themedApp ? HOVER_KICKER : HOVER_NONE; return HOVER_KICKER == hover; } else { #endif TQHeader *hd = dynamic_cast( hoverWidget ); if ( hd ) { // Hmm... this ones tricky, as there's only 1 widget - but it has different sections... // and the ones that aren't clickable should not highlight on mouse over! TQRect rect( widgetZero.x(), widgetZero.y(), hoverWidget->width(), hoverWidget->height() ); int s = 0; bool redraw = false; hover = rect.tqcontains( cursor ) ? HOVER_HEADER : HOVER_NONE; hoverSect = TQTC_NO_SECT; for ( s = 0; s < hd->count() && ( TQTC_NO_SECT == hoverSect || !redraw ); ++s ) { TQRect r( hd->sectionRect( s ) ); r.moveLeft( r.x() + widgetZero.x() ); r.moveTop( r.y() + widgetZero.y() ); bool hasNew = r.tqcontains( cursor ); if ( hasNew ) hoverSect = s; if ( !redraw ) { bool hasOld = r.tqcontains( oldCursor ); if ( ( hasNew && !hasOld ) || ( !hasNew && hasOld ) ) redraw = true; } } return redraw; } else return oldCursor == TQPoint( -1, -1 ); #if KDE_VERSION >= 0x30400 } #endif } } } return false; } #define gdouble double EDefBtnIndicator qtc_to_ind( const char *str ) { if ( 0 == memcmp( str, "fontcolour", 10 ) ) return IND_FONT_COLOUR; if ( 0 == memcmp( str, "border", 6 ) ) return IND_BORDER; if ( 0 == memcmp( str, "none", 4 ) ) return IND_NONE; return IND_CORNER; } EGroove qtc_to_groove( const char *str ) { if ( 0 == memcmp( str, "raised", 6 ) ) return GROOVE_RAISED; if ( 0 == memcmp( str, "none", 4 ) ) return GROOVE_NONE; return GROOVE_SUNKEN; } ETBarBorder qtc_to_tbar_border( const char *str ) { if ( 0 == memcmp( str, "dark", 4 ) ) return TB_DARK; if ( 0 == memcmp( str, "none", 4 ) ) return TB_NONE; if ( 0 == memcmp( str, "light", 5 ) ) return TB_LIGHT; return TB_LIGHT; } ELvExpander qtc_to_lv_expander( const char *str ) { return 0 == memcmp( str, "arrow", 5 ) ? LV_EXP_ARR : LV_EXP_PM; } ELvLines qtc_to_lv_lines( const char *str ) { if ( 0 == memcmp( str, "none", 4 ) ) return LV_LINES_NONE; if ( 0 == memcmp( str, "dotted", 6 ) ) return LV_LINES_DOTTED; return LV_LINES_SOLID; } EProfile qtc_to_profile( const char *str ) { if ( 0 == memcmp( str, "flat", 4 ) ) return PROFILE_FLAT; if ( 0 == memcmp( str, "raised", 6 ) ) return PROFILE_RAISED; return PROFILE_SUNKEN; } EAppearance qtc_to_appearance( const char *str ) { if ( 0 == memcmp( str, "flat", 4 ) ) return APPEARANCE_FLAT; if ( 0 == memcmp( str, "gradient", 8 ) ) return APPEARANCE_GRADIENT; return APPEARANCE_LIGHT_GRADIENT; } #include "klearlook.moc"