/* This file is part of the KDE project Copyright (C) 2006 Jaroslaw Staniek This program is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this program; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * Boston, MA 02110-1301, USA. */ #ifndef KEXIUTILS_STYLEPROXY_H #define KEXIUTILS_STYLEPROXY_H #include #include #include #include "kexiutils_export.h" namespace KexiUtils { //! @short a TQStyle proxy allowing to customizing the currently used style /*! All you need is to reimplement one or more of the methods. For example, you can reimpelmente drawPrimitive() and temporary change the color in color group. You can change even the smallest part of the style for a selected widget using the following code: \code class MyStyle : public KexiUtils::StyleProxy { //reimplement method(s) here... }; TQWidget *w = ..... w->setStyle( new MyStyle(&w->style(), w) ); //this will alter w's style a bit \endcode More info at http://doc.trolltech.com/qq/qq09-q-and-a.html#style */ class KEXIUTILS_EXPORT StyleProxy : public TQStyle { public: /*! Creates a new style proxy object. \a parentStyle pointer will not be kept (because it's most likely owned by the application: a new TQStyle instance for this name will be created internally. */ StyleProxy(TQStyle* parentStyle); virtual ~StyleProxy(); TQStyle* parentStyle() const; void setParentStyle(TQStyle* style); virtual void polish( TQWidget *w ) { m_style->polish(w); } virtual void unPolish( TQWidget *w ) { m_style->unPolish(w); } virtual void polish( TQApplication *a ) { m_style->polish(a); } virtual void unPolish( TQApplication *a ) { m_style->unPolish(a); } virtual void polish( TQPalette &p ) { m_style->polish(p); }; virtual void polishPopupMenu( TQPopupMenu* p ) { m_style->polishPopupMenu(p); } virtual TQRect tqitemRect( TQPainter *p, const TQRect &r, int flags, bool enabled, const TQPixmap *pixmap, const TQString &text, int len = -1 ) const { return m_style->tqitemRect( p, r, flags, enabled, pixmap, text, len ); } virtual void drawItem( TQPainter *p, const TQRect &r, int flags, const TQColorGroup &g, bool enabled, const TQPixmap *pixmap, const TQString &text, int len = -1, const TQColor *penColor = 0 ) const { m_style->drawItem( p, r, flags, g, enabled, pixmap, text, len, penColor ); } virtual void tqdrawPrimitive( TQ_PrimitiveElement pe, TQPainter *p, const TQRect &r, const TQColorGroup &cg, SFlags flags = Style_Default, const TQStyleOption& option = TQStyleOption::Default ) const { m_style->tqdrawPrimitive( pe, p, r, cg, flags, option ); } virtual void tqdrawControl( TQ_ControlElement element, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQColorGroup &cg, SFlags how = Style_Default, const TQStyleOption& option = TQStyleOption::Default ) const { m_style->tqdrawControl( element, p, widget, r, cg, how, option ); } virtual void tqdrawControlMask( TQ_ControlElement element, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption& option = TQStyleOption::Default ) const { m_style->tqdrawControlMask( element, p, widget, r, option ); } virtual TQRect subRect( SubRect r, const TQWidget *widget ) const { return m_style->subRect( r, widget ); } virtual void tqdrawComplexControl( TQ_ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQColorGroup &cg, SFlags how = Style_Default, #ifdef TQ_TQDOC SCFlags sub = SC_All, #else SCFlags sub = (uint)SC_All, #endif SCFlags subActive = SC_None, const TQStyleOption& option = TQStyleOption::Default ) const { tqdrawComplexControl( control, p, widget, r, cg, how, sub, subActive, option ); } virtual void tqdrawComplexControlMask( TQ_ComplexControl control, TQPainter *p, const TQWidget *widget, const TQRect &r, const TQStyleOption& option = TQStyleOption::Default ) const { m_style->tqdrawComplexControlMask( control, p, widget, r, option ); } virtual TQRect querySubControlMetrics( TQ_ComplexControl control, const TQWidget *widget, SubControl sc, const TQStyleOption& option = TQStyleOption::Default ) const { return m_style->querySubControlMetrics( control, widget, sc, option ); } virtual SubControl querySubControl( TQ_ComplexControl control, const TQWidget *widget, const TQPoint &pos, const TQStyleOption& option = TQStyleOption::Default ) const { return m_style->querySubControl( control, widget, pos, option ); } virtual int tqpixelMetric( PixelMetric metric, const TQWidget *widget = 0 ) const { return m_style->tqpixelMetric( metric, widget ); } virtual TQSize tqsizeFromContents( ContentsType contents, const TQWidget *widget, const TQSize &contentsSize, const TQStyleOption& option = TQStyleOption::Default ) const { return m_style->tqsizeFromContents( contents, widget, contentsSize, option ); } virtual int tqstyleHint( TQ_StyleHint stylehint, const TQWidget *widget = 0, const TQStyleOption& option = TQStyleOption::Default, TQStyleHintReturn* returnData = 0 ) const { return m_style->tqstyleHint( stylehint, widget, option, returnData ); } virtual TQPixmap stylePixmap( StylePixmap stylepixmap, const TQWidget *widget = 0, const TQStyleOption& option = TQStyleOption::Default ) const { return m_style->stylePixmap( stylepixmap, widget, option ); } protected: TQStyle *m_style; }; } #endif