Main Page | Namespace List | Class Hierarchy | Compound List | File List | Compound Members | File Members | Related Pages

KStyle Class Reference

#include <kstyle.h>

Inheritance diagram for KStyle:

PlastikStyle List of all members.

Public Types

typedef uint KStyleFlags
enum  KStyleOption { Default = 0x00000000, AllowMenuTransparency = 0x00000001, FilledFrameWorkaround = 0x00000002 }
enum  KStyleScrollBarType { WindowsStyleScrollBar = 0x00000000, PlatinumStyleScrollBar = 0x00000001, ThreeButtonScrollBar = 0x00000002, NextStyleScrollBar = 0x00000004 }
enum  KStylePrimitive {
  KPE_DockWindowHandle, KPE_ToolBarHandle, KPE_GeneralHandle, KPE_SliderGroove,
  KPE_SliderHandle, KPE_ListViewExpander, KPE_ListViewBranch
}
enum  KStylePixelMetric {
  KPM_MenuItemSeparatorHeight = 0x00000001, KPM_MenuItemHMargin = 0x00000002, KPM_MenuItemVMargin = 0x00000004, KPM_MenuItemHFrame = 0x00000008,
  KPM_MenuItemVFrame = 0x00000010, KPM_MenuItemCheckMarkHMargin = 0x00000020, KPM_MenuItemArrowHMargin = 0x00000040, KPM_MenuItemTabSpacing = 0x00000080,
  KPM_ListViewBranchThickness = 0x00000100
}

Public Member Functions

 KStyle (KStyleFlags flags=KStyle::Default, KStyleScrollBarType sbtype=KStyle::WindowsStyleScrollBar)
 ~KStyle ()
void setScrollBarType (KStyleScrollBarType sbtype)
KStyleFlags styleFlags () const
virtual void renderMenuBlendPixmap (KPixmap &pix, const QColorGroup &cg, const QPopupMenu *popup) const
virtual void drawKStylePrimitive (KStylePrimitive kpe, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags=Style_Default, const QStyleOption &=QStyleOption::Default) const
int kPixelMetric (KStylePixelMetric kpm, const QWidget *widget=0) const
void polish (QWidget *widget)
void unPolish (QWidget *widget)
void polishPopupMenu (QPopupMenu *)
void drawPrimitive (PrimitiveElement pe, QPainter *p, const QRect &r, const QColorGroup &cg, SFlags flags=Style_Default, const QStyleOption &=QStyleOption::Default) const
void drawControl (ControlElement element, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags=Style_Default, const QStyleOption &=QStyleOption::Default) const
void drawComplexControl (ComplexControl control, QPainter *p, const QWidget *widget, const QRect &r, const QColorGroup &cg, SFlags flags=Style_Default, SCFlags controls=SC_All, SCFlags active=SC_None, const QStyleOption &=QStyleOption::Default) const
SubControl querySubControl (ComplexControl control, const QWidget *widget, const QPoint &pos, const QStyleOption &=QStyleOption::Default) const
QRect querySubControlMetrics (ComplexControl control, const QWidget *widget, SubControl sc, const QStyleOption &=QStyleOption::Default) const
int pixelMetric (PixelMetric m, const QWidget *widget=0) const
QRect subRect (SubRect r, const QWidget *widget) const
QPixmap stylePixmap (StylePixmap stylepixmap, const QWidget *widget=0, const QStyleOption &=QStyleOption::Default) const
int styleHint (StyleHint sh, const QWidget *w=0, const QStyleOption &opt=QStyleOption::Default, QStyleHintReturn *shr=0) const

Static Public Member Functions

QString defaultStyle ()

Protected Member Functions

bool eventFilter (QObject *object, QEvent *event)
virtual void virtual_hook (int id, void *data)

Private Member Functions

 KStyle (const KStyle &)
KStyleoperator= (const KStyle &)

Private Attributes

KStylePrivated

Detailed Description

Simplifies and extends the QStyle API to make style coding easier.

The KStyle class provides a simple internal menu transparency engine which attempts to use XRender for accelerated blending where requested, or falls back to fast internal software tinting/blending routines. It also simplifies more complex portions of the QStyle API, such as the PopupMenuItems, ScrollBars and Sliders by providing extra "primitive elements" which are simple to implement by the style writer.

Author:
Karol Szwed (gallium@kde.org)
See also:
QStyle::QStyle

QCommonStyle::QCommonStyle

Version:
Id
kstyle.h,v 1.11 2002/10/26 08:59:39 gallium Exp


Member Typedef Documentation

typedef uint KStyle::KStyleFlags
 

KStyle Flags:

  • Default - Default style setting, where menu transparency and the FilledFrameWorkaround are disabled.
  • AllowMenuTransparency - Enable this flag to use KStyle's internal menu transparency engine.
  • FilledFrameWorkaround - Enable this flag to facilitate proper repaints of QMenuBars and QToolBars when the style chooses to paint the interior of a QFrame. The style primitives in question are PE_PanelMenuBar and PE_PanelDockWindow. The HighColor style uses this workaround to enable painting of gradients in menubars and toolbars.


Member Enumeration Documentation

enum KStyle::KStyleOption
 

Enumeration values:
Default 
AllowMenuTransparency 
FilledFrameWorkaround 

enum KStyle::KStylePixelMetric
 

Enumeration values:
KPM_MenuItemSeparatorHeight 
KPM_MenuItemHMargin 
KPM_MenuItemVMargin 
KPM_MenuItemHFrame 
KPM_MenuItemVFrame 
KPM_MenuItemCheckMarkHMargin 
KPM_MenuItemArrowHMargin 
KPM_MenuItemTabSpacing 
KPM_ListViewBranchThickness 

enum KStyle::KStylePrimitive
 

KStyle Primitive Elements:

The KStyle class extends the Qt's Style API by providing certain simplifications for parts of QStyle. To do this, the KStylePrimitive elements were defined, which are very similar to Qt's PrimitiveElement.

The first three Handle primitives simplify and extend PE_DockWindowHandle, so do not reimplement PE_DockWindowHandle if you want the KStyle handle simplifications to be operable. Similarly do not reimplement CC_Slider, SC_SliderGroove and SC_SliderHandle when using the KStyle slider primitives. KStyle automatically double-buffers slider painting when they are drawn via these KStyle primitives to avoid flicker.

  • KPE_DockWindowHandle - This primitive is already implemented in KStyle, and paints a bevelled rect with the DockWindow caption text. Re-implement this primitive to perform other more fancy effects when drawing the dock window handle.
  • KPE_ToolBarHandle - This primitive must be reimplemented. It currently only paints a filled rectangle as default behaviour. This primitive is used to render QToolBar handles.
  • KPE_GeneralHandle - This primitive must be reimplemented. It is used to render general handles that are not part of a QToolBar or QDockWindow, such as the applet handles used in Kicker. The default implementation paints a filled rect of arbitrary color.
  • KPE_SliderGroove - This primitive must be reimplemented. It is used to paint the slider groove. The default implementation paints a filled rect of arbitrary color.
  • KPE_SliderHandle - This primitive must be reimplemented. It is used to paint the slider handle. The default implementation paints a filled rect of arbitrary color.
  • KPE_ListViewExpander - This primitive is already implemented in KStyle. It is used to draw the Expand/Collapse element in QListViews. To indicate the expanded state, the style flags are set to Style_Off, while Style_On implies collapsed.
  • KPE_ListViewBranch - This primitive is already implemented in KStyle. It is used to draw the ListView branches where necessary.
Enumeration values:
KPE_DockWindowHandle 
KPE_ToolBarHandle 
KPE_GeneralHandle 
KPE_SliderGroove 
KPE_SliderHandle 
KPE_ListViewExpander 
KPE_ListViewBranch 

enum KStyle::KStyleScrollBarType
 

KStyle ScrollBarType:

Allows the style writer to easily select what type of scrollbar should be used without having to duplicate large amounts of source code by implementing the complex control CC_ScrollBar.

  • WindowsStyleScrollBar - Two button scrollbar with the previous button at the top/left, and the next button at the bottom/right.
  • PlatinumStyleSrollBar - Two button scrollbar with both the previous and next buttons at the bottom/right.
  • ThreeButtonScrollBar - KDE style three button scrollbar with two previous buttons, and one next button. The next button is always at the bottom/right, whilst the two previous buttons are on either end of the scrollbar.
  • NextStyleScrollBar - Similar to the PlatinumStyle scroll bar, but with the buttons grouped on the opposite end of the scrollbar.
Enumeration values:
WindowsStyleScrollBar 
PlatinumStyleScrollBar 
ThreeButtonScrollBar 
NextStyleScrollBar 


Constructor & Destructor Documentation

KStyle::KStyle KStyleFlags  flags = KStyle::Default,
KStyleScrollBarType  sbtype = KStyle::WindowsStyleScrollBar
 

Constructs a KStyle object.

Select the appropriate KStyle flags and scrollbar type for your style. The user's style preferences selected in KControl are read by using QSettings and are automatically applied to the style. As a fallback, KStyle paints progressbars and tabbars. It inherits from QCommonStyle for speed, so don't expect much to be implemented.

It is advisable to use a currently implemented style such as the HighColor style as a foundation for any new KStyle, so the limited number of drawing fallbacks should not prove problematic.

See also:
KStyle::KStyleFlags

KStyle::KStyleScrollBarType

Author:
Karol Szwed (gallium@kde.org)

KStyle::~KStyle  ) 
 

Destructs the KStyle object.

KStyle::KStyle const KStyle  )  [private]
 


Member Function Documentation

QString KStyle::defaultStyle  )  [static]
 

Returns the default widget style depending on color depth.

void KStyle::drawComplexControl ComplexControl  control,
QPainter *  p,
const QWidget *  widget,
const QRect &  r,
const QColorGroup &  cg,
SFlags  flags = Style_Default,
SCFlags  controls = SC_All,
SCFlags  active = SC_None,
const QStyleOption &  = QStyleOption::Default
const
 

Reimplemented in PlastikStyle.

void KStyle::drawControl ControlElement  element,
QPainter *  p,
const QWidget *  widget,
const QRect &  r,
const QColorGroup &  cg,
SFlags  flags = Style_Default,
const QStyleOption &  = QStyleOption::Default
const
 

Reimplemented in PlastikStyle.

void KStyle::drawKStylePrimitive KStylePrimitive  kpe,
QPainter *  p,
const QWidget *  widget,
const QRect &  r,
const QColorGroup &  cg,
SFlags  flags = Style_Default,
const QStyleOption &  = QStyleOption::Default
const [virtual]
 

This function is identical to Qt's QStyle::drawPrimitive(), except that it adds one further parameter, 'widget', that can be used to determine the widget state of the KStylePrimitive in question.

See also:
KStyle::KStylePrimitive

QStyle::drawPrimitive

QStyle::drawComplexControl

Reimplemented in PlastikStyle.

void KStyle::drawPrimitive PrimitiveElement  pe,
QPainter *  p,
const QRect &  r,
const QColorGroup &  cg,
SFlags  flags = Style_Default,
const QStyleOption &  = QStyleOption::Default
const
 

Reimplemented in PlastikStyle.

bool KStyle::eventFilter QObject *  object,
QEvent *  event
[protected]
 

Reimplemented in PlastikStyle.

int KStyle::kPixelMetric KStylePixelMetric  kpm,
const QWidget *  widget = 0
const
 

KStyle& KStyle::operator= const KStyle  )  [private]
 

int KStyle::pixelMetric PixelMetric  m,
const QWidget *  widget = 0
const
 

Reimplemented in PlastikStyle.

void KStyle::polish QWidget *  widget  ) 
 

Reimplemented in PlastikStyle.

void KStyle::polishPopupMenu QPopupMenu *   ) 
 

QStyle::SubControl KStyle::querySubControl ComplexControl  control,
const QWidget *  widget,
const QPoint &  pos,
const QStyleOption &  = QStyleOption::Default
const
 

QRect KStyle::querySubControlMetrics ComplexControl  control,
const QWidget *  widget,
SubControl  sc,
const QStyleOption &  = QStyleOption::Default
const
 

Reimplemented in PlastikStyle.

void KStyle::renderMenuBlendPixmap KPixmap pix,
const QColorGroup &  cg,
const QPopupMenu *  popup
const [virtual]
 

This virtual function defines the pixmap used to blend between the popup menu and the background to create different menu transparency effects. For example, you can fill the pixmap "pix" with a gradient based on the popup's colorGroup, a texture, or some other fancy painting routine. KStyle will then internally blend this pixmap with a snapshot of the background behind the popupMenu to create the illusion of transparency.

This virtual is never called if XRender/Software blending is disabled by the user in KDE's style control module.

void KStyle::setScrollBarType KStyleScrollBarType  sbtype  ) 
 

Modifies the scrollbar type used by the style.

This function is only provided for convenience. It allows you to make a late decision about what scrollbar type to use for the style after performing some processing in your style's constructor. In most situations however, setting the scrollbar type via the KStyle constructor should suffice.

KStyle::KStyleFlags KStyle::styleFlags  )  const
 

Returns the KStyle flags used to initialise the style.

This is used solely for the kcmstyle module, and hence is internal.

int KStyle::styleHint StyleHint  sh,
const QWidget *  w = 0,
const QStyleOption &  opt = QStyleOption::Default,
QStyleHintReturn *  shr = 0
const
 

QPixmap KStyle::stylePixmap StylePixmap  stylepixmap,
const QWidget *  widget = 0,
const QStyleOption &  = QStyleOption::Default
const
 

QRect KStyle::subRect SubRect  r,
const QWidget *  widget
const
 

Reimplemented in PlastikStyle.

void KStyle::unPolish QWidget *  widget  ) 
 

Reimplemented in PlastikStyle.

void KStyle::virtual_hook int  id,
void *  data
[protected, virtual]
 


Member Data Documentation

KStylePrivate* KStyle::d [private]
 


The documentation for this class was generated from the following files:
Generated on Fri Feb 27 12:01:41 2004 for Glitch by doxygen 1.3.2