![]() |
CopperSpice API
2.0.0
|
The built-in widgets use the QStyle class to perform nearly all of their drawing. QStyle is an abstract base class that encapsulates the look and feel of a GUI, and can be used to make the widgets look exactly like the equivalent native widgets or to give the widgets a custom look.
CopperSpice provides a set of QStyle subclasses that emulate the native look of the different platforms supported by CopperSpice (QWindowsStyle, QMacStyle, QMotifStyle, etc.). These styles are built into the CsGui library, other styles can be made available using the CopperSpice plugin mechanism.
Most methods for drawing style elements take four arguments.
The style gets all the information it needs to render the graphical element from the QStyleOption class. The widget is passed as the last argument in case the style needs it to perform special effects (such as animated default buttons on Mac OS X), but it is not mandatory. In fact, QStyle can be used to draw on any paint device (not just widgets), in which case the widget argument is a zero pointer.
The paint system also provides the QStylePainter class which inherits from QPainter. QStylePainter is a class used for drawing QStyle elements inside a widget and extends QPainter with a high level drawing methods implemented on top of the QStyle API. The advantage of using QStylePainter is the parameter lists are considerably shorter.
![]() | QIconThe QIcon class provides scalable icons in different modes and states. QIcon can generate pixmaps reflecting an icon's state, mode and size. These pixmaps are generated from the set of pixmaps made available to the icon, and are used by CopperSpice widgets to show an icon representing a particular action. The rendering of a QIcon object is handled by the QIconEngine class. Each icon has a corresponding icon engine that is responsible for drawing the icon with a requested size, mode and state. |
For more information about widget styling and appearance, see the Styles and Style Aware Widgets.