kstyle.h
00001 /* 00002 * $Id$ 00003 * 00004 * KStyle 00005 * Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org> 00006 * 00007 * TQWindowsStyle CC_ListView and style images were kindly donated by TrollTech, 00008 * Copyright (C) 1998-2000 TrollTech AS. 00009 * 00010 * Many thanks to Bradley T. Hughes for the 3 button scrollbar code. 00011 * 00012 * This library is free software; you can redistribute it and/or 00013 * modify it under the terms of the GNU Library General Public 00014 * License version 2 as published by the Free Software Foundation. 00015 * 00016 * This library is distributed in the hope that it will be useful, 00017 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00018 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00019 * Library General Public License for more details. 00020 * 00021 * You should have received a copy of the GNU Library General Public License 00022 * along with this library; see the file COPYING.LIB. If not, write to 00023 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00024 * Boston, MA 02110-1301, USA. 00025 */ 00026 00027 #ifndef __KSTYLE_H 00028 #define __KSTYLE_H 00029 00030 // W A R N I N G 00031 // ------------- 00032 // This API is still subject to change. 00033 // I will remove this warning when I feel the API is sufficiently flexible. 00034 00035 #include <tqcommonstyle.h> 00036 00037 #include <kdelibs_export.h> 00038 00039 class KPixmap; 00040 00041 struct KStylePrivate; 00057 class KDEFX_EXPORT KStyle: public TQCommonStyle 00058 { 00059 Q_OBJECT 00060 TQ_OBJECT 00061 00062 public: 00063 00080 typedef uint KStyleFlags; 00081 enum KStyleOption { 00082 Default = 0x00000000, 00083 AllowMenuTransparency = 0x00000001, 00084 FilledFrameWorkaround = 0x00000002 00085 }; 00086 00110 enum KStyleScrollBarType { 00111 WindowsStyleScrollBar = 0x00000000, 00112 PlatinumStyleScrollBar = 0x00000001, 00113 ThreeButtonScrollBar = 0x00000002, 00114 NextStyleScrollBar = 0x00000004 00115 }; 00116 00136 KStyle( KStyleFlags flags = KStyle::Default, 00137 KStyleScrollBarType sbtype = KStyle::WindowsStyleScrollBar ); 00138 00142 ~KStyle(); 00143 00147 static TQString defaultStyle(); 00148 00160 void setScrollBarType(KStyleScrollBarType sbtype); 00161 00167 KStyleFlags styleFlags() const; 00168 00169 // --------------------------------------------------------------------------- 00170 00182 virtual void renderMenuBlendPixmap( KPixmap& pix, const TQColorGroup& cg, 00183 const TQPopupMenu* popup ) const; 00184 00228 enum KStylePrimitive { 00229 KPE_DockWindowHandle, 00230 KPE_ToolBarHandle, 00231 KPE_GeneralHandle, 00232 00233 KPE_SliderGroove, 00234 KPE_SliderHandle, 00235 00236 KPE_ListViewExpander, 00237 KPE_ListViewBranch 00238 }; 00239 00249 virtual void drawKStylePrimitive( KStylePrimitive kpe, 00250 TQPainter* p, 00251 const TQWidget* widget, 00252 const TQRect &r, 00253 const TQColorGroup &cg, 00254 SFlags flags = Style_Default, 00255 const TQStyleOption& = TQStyleOption::SO_Default ) const; 00256 00257 00258 enum KStylePixelMetric { 00259 KPM_MenuItemSeparatorHeight = 0x00000001, 00260 KPM_MenuItemHMargin = 0x00000002, 00261 KPM_MenuItemVMargin = 0x00000004, 00262 KPM_MenuItemHFrame = 0x00000008, 00263 KPM_MenuItemVFrame = 0x00000010, 00264 KPM_MenuItemCheckMarkHMargin = 0x00000020, 00265 KPM_MenuItemArrowHMargin = 0x00000040, 00266 KPM_MenuItemTabSpacing = 0x00000080, 00267 KPM_ListViewBranchThickness = 0x00000100 00268 }; 00269 00270 int kPixelMetric( KStylePixelMetric kpm, const TQWidget* widget = 0 ) const; 00271 00272 // --------------------------------------------------------------------------- 00273 00274 void polish( TQWidget* widget ); 00275 void unPolish( TQWidget* widget ); 00276 void polishPopupMenu( TQPopupMenu* ); 00277 00278 void tqdrawPrimitive( TQ_PrimitiveElement pe, 00279 TQPainter* p, 00280 const TQRect &r, 00281 const TQColorGroup &cg, 00282 SFlags flags = Style_Default, 00283 const TQStyleOption& = TQStyleOption::SO_Default ) const; 00284 00285 // #ifdef USE_QT4 // kdebindings / smoke needs this function declaration available at all times. Furthermore I don't think it would hurt to have the declaration available at all times...so leave these commented out for now 00286 00287 // void tqdrawPrimitive( TQ_ControlElement pe, 00288 // TQPainter* p, 00289 // const TQRect &r, 00290 // const TQColorGroup &cg, 00291 // SFlags flags = Style_Default, 00292 // const TQStyleOption& = TQStyleOption::SO_Default ) const; 00293 00294 // #endif // USE_QT4 00295 00296 void drawControl( TQ_ControlElement element, 00297 TQPainter* p, 00298 const TQWidget* widget, 00299 const TQRect &r, 00300 const TQColorGroup &cg, 00301 SFlags flags = Style_Default, 00302 const TQStyleOption& = TQStyleOption::SO_Default ) const; 00303 00304 void drawComplexControl( TQ_ComplexControl control, 00305 TQPainter *p, 00306 const TQWidget* widget, 00307 const TQRect &r, 00308 const TQColorGroup &cg, 00309 SFlags flags = Style_Default, 00310 SCFlags controls = SC_All, 00311 SCFlags active = SC_None, 00312 const TQStyleOption& = TQStyleOption::SO_Default ) const; 00313 00314 SubControl querySubControl( TQ_ComplexControl control, 00315 const TQWidget* widget, 00316 const TQPoint &pos, 00317 const TQStyleOption& = TQStyleOption::SO_Default ) const; 00318 00319 TQRect querySubControlMetrics( TQ_ComplexControl control, 00320 const TQWidget* widget, 00321 SubControl sc, 00322 const TQStyleOption& = TQStyleOption::SO_Default ) const; 00323 00324 int pixelMetric( PixelMetric m, 00325 const TQWidget* widget = 0 ) const; 00326 00327 TQRect subRect( SubRect r, 00328 const TQWidget* widget ) const; 00329 00330 TQPixmap stylePixmap( StylePixmap stylepixmap, 00331 const TQWidget* widget = 0, 00332 const TQStyleOption& = TQStyleOption::SO_Default ) const; 00333 00334 int styleHint( TQ_StyleHint sh, 00335 const TQWidget* w = 0, 00336 const TQStyleOption &opt = TQStyleOption::SO_Default, 00337 TQStyleHintReturn* shr = 0 ) const; 00338 00339 protected: 00340 bool eventFilter( TQObject* object, TQEvent* event ); 00341 00342 private: 00343 // Disable copy constructor and = operator 00344 KStyle( const KStyle & ); 00345 KStyle& operator=( const KStyle & ); 00346 00347 protected: 00348 virtual void virtual_hook( int id, void* data ); 00349 private: 00350 KStylePrivate *d; 00351 }; 00352 00353 00354 // vim: set noet ts=4 sw=4: 00355 #endif 00356