• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEUI

KStyle Class Reference

#include <kstyle.h>

Inheritance diagram for KStyle:

Inheritance graph
[legend]

List of all members.


Detailed Description

Makes style coding more convenient.

Todo:
and allows to style KDE specific widgets.
KStyle strives to ease style development by implementing various QStyle methods. These implementations are based on
  1. the concept of Layout Properties. These properties can be set using setWidgetLayoutProp(). KStyle uses this information to respect various metrics (like space between primitives or margins around widget contents) or turn specific features on or off.
  2. the concept of KStyle Primitives. These can be implemented by overriding drawKStylePrimitive() and providing drawing methods for specific primitives. Often, the drawing of more complex widgets consists of several primitives.

In the following modules, information about related members is collected:

  • KStyle option representation
  • KStyle widget representation

Author:
Maksim Orlovich (maksim@kde.org)

Sandro Giessl (giessl@kde.org)

See also:
KStyleFactory for how to implement the style plugin interface.

Definition at line 84 of file kstyle.h.


Public Member Functions

 KStyle ()
 ~KStyle ()
QStyle Methods
These are methods reimplemented from QStyle.

Usually it's not necessary to reimplement them yourself.

Some of them are there for binary compatibility reasons only; all they do is to call the implementation from QCommonStyle.

void drawComplexControl (ComplexControl cc, const QStyleOptionComplex *opt, QPainter *p, const QWidget *w) const
void drawControl (ControlElement elem, const QStyleOption *opt, QPainter *p, const QWidget *w) const
void drawItemPixmap (QPainter *painter, const QRect &rect, int alignment, const QPixmap &pixmap) const
void drawItemText (QPainter *painter, const QRect &rect, int flags, const QPalette &pal, bool enabled, const QString &text, QPalette::ColorRole textRole=QPalette::NoRole) const
void drawPrimitive (PrimitiveElement elem, const QStyleOption *opt, QPainter *p, const QWidget *w) const
bool eventFilter (QObject *, QEvent *)
QPixmap generatedIconPixmap (QIcon::Mode iconMode, const QPixmap &pixmap, const QStyleOption *opt) const
SubControl hitTestComplexControl (ComplexControl cc, const QStyleOptionComplex *opt, const QPoint &pt, const QWidget *w) const
QRect itemPixmapRect (const QRect &r, int flags, const QPixmap &pixmap) const
QRect itemTextRect (const QFontMetrics &fm, const QRect &r, int flags, bool enabled, const QString &text) const
int pixelMetric (PixelMetric metric, const QStyleOption *opt=0, const QWidget *w=0) const
void polish (QPalette &)
void polish (QApplication *)
void polish (QWidget *)
QSize sizeFromContents (ContentsType type, const QStyleOption *opt, const QSize &contentsSize, const QWidget *w) const
QPalette standardPalette () const
QPixmap standardPixmap (StandardPixmap standardPixmap, const QStyleOption *opt, const QWidget *widget=0) const
int styleHint (StyleHint hint, const QStyleOption *opt, const QWidget *w, QStyleHintReturn *returnData) const
QRect subControlRect (ComplexControl control, const QStyleOptionComplex *opt, SubControl subControl, const QWidget *w) const
QRect subElementRect (SubElement subRect, const QStyleOption *opt, const QWidget *w) const
void unpolish (QApplication *)
void unpolish (QWidget *)

Static Public Member Functions

static QString defaultStyle ()

Protected Types

enum  MarginOffsets {
  MainMargin, Top, Bot, Left,
  Right, MarginInc
}
enum  WidgetType {
  WT_Generic, WT_PushButton, WT_Splitter, WT_CheckBox,
  WT_RadioButton, WT_DockWidget, WT_ProgressBar, WT_MenuBar,
  WT_MenuBarItem, WT_Menu, WT_MenuItem, WT_ScrollBar,
  WT_TabBar, WT_TabWidget, WT_Slider, WT_Tree,
  WT_SpinBox, WT_ComboBox, WT_Header, WT_LineEdit,
  WT_GroupBox, WT_StatusBar, WT_ToolBar, WT_ToolButton,
  WT_ToolBoxTab, WT_Window, WT_Limit = 0xFFFF
}

Protected Member Functions

virtual void drawKStylePrimitive (WidgetType widgetType, int primitive, const QStyleOption *opt, const QRect &r, const QPalette &pal, State flags, QPainter *p, const QWidget *widget=0, Option *kOpt=0) const
void setWidgetLayoutProp (WidgetType widget, int metric, int value)
virtual int widgetLayoutProp (WidgetType widgetType, int metric, const QStyleOption *opt=0, const QWidget *w=0) const
Helper Methods
These are methods helping with QRect handling, for example.

QRect centerRect (const QRect &in, const QSize &size) const
QRect centerRect (const QRect &in, int w, int h) const
void drawInsideRect (QPainter *p, const QRect &r) const

Static Protected Member Functions

template<typename T>
static T extractOption (Option *option)

Classes

struct  CheckBox
 Describes widgets like QCheckBox. More...
class  ColorMode
 A representation for colors for use as a widget layout property. More...
struct  ColorOption
 Option representing the color of the thing to draw. More...
struct  ComboBox
 Describes a widget like QComboBox. More...
struct  DockWidget
 Describes the title of a dock widget. More...
struct  DoubleButtonOption
 Option for drawing double scrollbar buttons, indicating whether a button should be drawn active or not. More...
struct  Generic
 Basic primitive drawing operations. More...
struct  GroupBox
 Describes something like QGroupBox. More...
struct  Header
 Describes a list header, like in QListView. More...
struct  IconOption
 Option for drawing icons: represents whether the icon should be active or not. More...
struct  LineEdit
 Describes a text edit widget like QLineEdit. More...
struct  Menu
 Describes a menu. More...
struct  MenuBar
 Describes widgets like QMenuBar. More...
struct  MenuBarItem
 Describes MenuBar items. More...
struct  MenuItem
 Describes an item in a menu. More...
struct  Option
 Base for our own option classes. More...
struct  OptionBase
 Intermediatary base that helps implement subtypes of Option that properly handle defaults. More...
struct  ProgressBar
 Describes widgets like QProgressBar. More...
struct  PushButton
 Describes widgets like QPushButton. More...
struct  RadioButton
 Describes widgets like QRadioButton. More...
struct  ScrollBar
 Describes widgets like QScrollBar. More...
struct  Slider
 Describes a slider, like QSlider. More...
struct  SpinBox
 Describes a widget like QSpinBox. More...
struct  Splitter
 Describes widgets like QSplitter. More...
struct  StatusBar
 Describes a status bar section. More...
struct  TabBar
 Describes a tab bar. More...
struct  TabWidget
 Describes a tab widget (frame). More...
struct  TextOption
 Option representing text drawing info. For Generic::Text. More...
struct  TitleButtonOption
 Option for drawing WT_Window titlebar buttons, indicating whether the button is pressed, and containing the window icon. More...
struct  ToolBar
 Describes a tool bar. More...
struct  ToolBoxTab
 Describes a tab for a tool box, like QToolBox. More...
struct  ToolButton
 Describes widgets like QToolButton (usually inside a QToolBar). More...
struct  Tree
 Describes an expandable tree, e.g. More...
struct  Window
 Describes windows, like in QWorkspace. More...

Constructor & Destructor Documentation

KStyle::KStyle (  ) 

Definition at line 132 of file kstyle.cpp.

KStyle::~KStyle (  ) 

Definition at line 261 of file kstyle.cpp.


Member Function Documentation

QRect KStyle::centerRect ( const QRect &  in,
const QSize &  size 
) const [protected]

Return a size-dimension QRect centered inside the 'in' rectangle.

Definition at line 359 of file kstyle.cpp.

QRect KStyle::centerRect ( const QRect &  in,
int  w,
int  h 
) const [protected]

Returns a w x h QRect center inside the 'in' rectangle.

Definition at line 354 of file kstyle.cpp.

QString KStyle::defaultStyle (  )  [static]

Returns the default widget style.

Definition at line 274 of file kstyle.cpp.

void KStyle::drawComplexControl ( ComplexControl  cc,
const QStyleOptionComplex *  opt,
QPainter *  p,
const QWidget *  w 
) const

Definition at line 2763 of file kstyle.cpp.

void KStyle::drawControl ( ControlElement  elem,
const QStyleOption *  opt,
QPainter *  p,
const QWidget *  w 
) const

Definition at line 1070 of file kstyle.cpp.

void KStyle::drawInsideRect ( QPainter *  p,
const QRect &  r 
) const [protected]

Draws inside the rectangle using a thinkness 0 pen.

This is what drawRect in Qt3 used to do.

Definition at line 349 of file kstyle.cpp.

void KStyle::drawItemPixmap ( QPainter *  painter,
const QRect &  rect,
int  alignment,
const QPixmap &  pixmap 
) const

Definition at line 329 of file kstyle.cpp.

void KStyle::drawItemText ( QPainter *  painter,
const QRect &  rect,
int  flags,
const QPalette &  pal,
bool  enabled,
const QString &  text,
QPalette::ColorRole  textRole = QPalette::NoRole 
) const

Definition at line 322 of file kstyle.cpp.

void KStyle::drawKStylePrimitive ( WidgetType  widgetType,
int  primitive,
const QStyleOption *  opt,
const QRect &  r,
const QPalette &  pal,
State  flags,
QPainter *  p,
const QWidget *  widget = 0,
KStyle::Option *  kOpt = 0 
) const [protected, virtual]

Draws primitives which are used inside KStyle.

KStyle implements various elements of QStyle::ComplexControl and QStyle::ControlElement for convenience. Usually complex drawing is split into smaller pieces, which can be text, icons, or other KStyle primitives. These are painted by this method.

Common Qt option parameters are unpacked for convenience, and information from KStyle are passed as a KStyleOption.

Note:
This method is not meant to be accessible from outside KStyle.

You should make sure to use the r parameter for the rectangle, since the QStyleOption is generally unaltered from the original request, even if layout indicates a different painting rectangle.

Parameters:
widgetType the widget context in which this call is happening in
primitive the primitive which should be called. Primitives from the Generic struct are not directly coupled to the widgetType , other primitives are usually defined in the struct corresponding to the widget type.
opt Qt option parameters
r parameter for the rectangle
pal the palette extracted from opt for convenience
flags state flags extracted from opt for convenience
p used to draw the primitive
widget the widget which is painted on
kOpt information passed from KStyle

Definition at line 366 of file kstyle.cpp.

void KStyle::drawPrimitive ( PrimitiveElement  elem,
const QStyleOption *  opt,
QPainter *  p,
const QWidget *  w 
) const

Definition at line 727 of file kstyle.cpp.

bool KStyle::eventFilter ( QObject *  obj,
QEvent *  ev 
)

Definition at line 3984 of file kstyle.cpp.

QPixmap KStyle::generatedIconPixmap ( QIcon::Mode  iconMode,
const QPixmap &  pixmap,
const QStyleOption *  opt 
) const

Definition at line 343 of file kstyle.cpp.

QStyle::SubControl KStyle::hitTestComplexControl ( ComplexControl  cc,
const QStyleOptionComplex *  opt,
const QPoint &  pt,
const QWidget *  w 
) const

Definition at line 3653 of file kstyle.cpp.

QRect KStyle::itemPixmapRect ( const QRect &  r,
int  flags,
const QPixmap &  pixmap 
) const

Definition at line 318 of file kstyle.cpp.

QRect KStyle::itemTextRect ( const QFontMetrics &  fm,
const QRect &  r,
int  flags,
bool  enabled,
const QString &  text 
) const

Definition at line 312 of file kstyle.cpp.

int KStyle::pixelMetric ( PixelMetric  metric,
const QStyleOption *  opt = 0,
const QWidget *  w = 0 
) const

Definition at line 2287 of file kstyle.cpp.

void KStyle::polish ( QPalette &  pal  ) 

Definition at line 308 of file kstyle.cpp.

void KStyle::polish ( QApplication *  a  ) 

Definition at line 300 of file kstyle.cpp.

void KStyle::polish ( QWidget *  w  ) 

Definition at line 279 of file kstyle.cpp.

void KStyle::setWidgetLayoutProp ( WidgetType  widget,
int  metric,
int  value 
) [protected]

Interface for the style to configure various metrics that KStyle has customizable.

Definition at line 650 of file kstyle.cpp.

QSize KStyle::sizeFromContents ( ContentsType  type,
const QStyleOption *  opt,
const QSize &  contentsSize,
const QWidget *  w 
) const

Definition at line 3706 of file kstyle.cpp.

QPalette KStyle::standardPalette (  )  const

Definition at line 334 of file kstyle.cpp.

QPixmap KStyle::standardPixmap ( StandardPixmap  standardPixmap,
const QStyleOption *  opt,
const QWidget *  widget = 0 
) const

Definition at line 338 of file kstyle.cpp.

int KStyle::styleHint ( StyleHint  hint,
const QStyleOption *  opt,
const QWidget *  w,
QStyleHintReturn *  returnData 
) const

Definition at line 2243 of file kstyle.cpp.

QRect KStyle::subControlRect ( ComplexControl  control,
const QStyleOptionComplex *  opt,
SubControl  subControl,
const QWidget *  w 
) const

Definition at line 3264 of file kstyle.cpp.

QRect KStyle::subElementRect ( SubElement  subRect,
const QStyleOption *  opt,
const QWidget *  w 
) const

Definition at line 2606 of file kstyle.cpp.

void KStyle::unpolish ( QApplication *  a  ) 

Definition at line 304 of file kstyle.cpp.

void KStyle::unpolish ( QWidget *  w  ) 

Definition at line 292 of file kstyle.cpp.

int KStyle::widgetLayoutProp ( WidgetType  widgetType,
int  metric,
const QStyleOption *  opt = 0,
const QWidget *  w = 0 
) const [protected, virtual]

Used to obtain information about KStyle layout properties and metrics.

The default implementation returns values which are set using setWidgetLayoutProp(), so normally it's not necessary to implement it yourself.

Note:
This method is not meant to be accessible from outside KStyle.
Parameters:
widgetType the widget type context where the metric property belongs to
metric the value of this property is requested
opt Qt option parameters
w the actual widget this call is related to

Definition at line 662 of file kstyle.cpp.


The documentation for this class was generated from the following files:
  • kstyle.h
  • kstyle.cpp

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal