Eneboo - Documentación para desarrolladores
|
#include <qtc_kstyle.h>
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.
typedef uint QtCKStyle::KStyleFlags |
QtCKStyle Flags:
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.
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.
QtCKStyle::QtCKStyle | ( | KStyleFlags | flags = QtCKStyle::Default , |
KStyleScrollBarType | sbtype = QtCKStyle::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.
flags | the style to be applied |
sbtype | the scroll bar type |
QtCKStyle::~QtCKStyle | ( | ) |
Destructs the QtCKStyle object.
QString QtCKStyle::defaultStyle | ( | ) | [static] |
Returns the default widget style depending on color depth.
void QtCKStyle::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 & | opt = QStyleOption::Default |
||
) | const [virtual] |
Reimplementado de QCommonStyle.
void QtCKStyle::drawControl | ( | ControlElement | element, |
QPainter * | p, | ||
const QWidget * | widget, | ||
const QRect & | r, | ||
const QColorGroup & | cg, | ||
SFlags | flags = Style_Default , |
||
const QStyleOption & | opt = QStyleOption::Default |
||
) | const [virtual] |
Reimplementado de QCommonStyle.
void QtCKStyle::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.
void QtCKStyle::drawPrimitive | ( | PrimitiveElement | pe, |
QPainter * | p, | ||
const QRect & | r, | ||
const QColorGroup & | cg, | ||
SFlags | flags = Style_Default , |
||
const QStyleOption & | opt = QStyleOption::Default |
||
) | const [virtual] |
Reimplementado de QCommonStyle.
Filters events if this object has been installed as an event filter for the watched object.
In your reimplementation of this function, if you want to filter the event e, out, i.e. stop it being handled further, return TRUE; otherwise return FALSE.
Example:
class MyMainWindow : public QMainWindow { public: MyMainWindow( QWidget *parent = 0, const char *name = 0 ); protected: bool eventFilter( QObject *obj, QEvent *ev ); private: QTextEdit *textEdit; }; MyMainWindow::MyMainWindow( QWidget *parent, const char *name ) : QMainWindow( parent, name ) { textEdit = new QTextEdit( this ); setCentralWidget( textEdit ); textEdit->installEventFilter( this ); } bool MyMainWindow::eventFilter( QObject *obj, QEvent *ev ) { if ( obj == textEdit ) { if ( e->type() == QEvent::KeyPress ) { QKeyEvent *k = (QKeyEvent*)ev; qDebug( "Ate key press %d", k->key() ); return TRUE; } else { return FALSE; } } else { // pass the event on to the parent class return QMainWindow::eventFilter( obj, ev ); } }
Notice in the example above that unhandled events are passed to the base class's eventFilter() function, since the base class might have reimplemented eventFilter() for its own internal purposes.
Reimplementado de QObject.
int QtCKStyle::kPixelMetric | ( | KStylePixelMetric | kpm, |
const QWidget * | widget = 0 |
||
) | const |
int QtCKStyle::pixelMetric | ( | PixelMetric | m, |
const QWidget * | widget = 0 |
||
) | const [virtual] |
Reimplementado de QCommonStyle.
void QtCKStyle::polish | ( | QWidget * | ) | [virtual] |
Initializes the appearance of a widget.
This function is called for every widget at some point after it has been fully created but just before it is shown the very first time.
Reasonable actions in this function might be to call QWidget::setBackgroundMode() for the widget. An example of highly unreasonable use would be setting the geometry! Reimplementing this function gives you a back-door through which you can change the appearance of a widget. With Qt 3.0's style engine you will rarely need to write your own polish(); instead reimplement drawItem(), drawPrimitive(), etc.
The QWidget::inherits() function may provide enough information to allow class-specific customizations. But be careful not to hard-code things too much because new QStyle subclasses are expected to work reasonably with all current and future widgets.
Reimplementado de QStyle.
void QtCKStyle::polishPopupMenu | ( | QPopupMenu * | ) | [virtual] |
Polishes the popup menu according to the GUI style. This usually means setting the mouse tracking ({QPopupMenu::setMouseTracking()}) and whether the menu is checkable by default ({QPopupMenu::setCheckable()}).
Implementa QStyle.
QStyle::SubControl QtCKStyle::querySubControl | ( | ComplexControl | control, |
const QWidget * | widget, | ||
const QPoint & | pos, | ||
const QStyleOption & | opt = QStyleOption::Default |
||
) | const [virtual] |
Reimplementado de QCommonStyle.
QRect QtCKStyle::querySubControlMetrics | ( | ComplexControl | control, |
const QWidget * | widget, | ||
SubControl | sc, | ||
const QStyleOption & | opt = QStyleOption::Default |
||
) | const [virtual] |
Reimplementado de QCommonStyle.
void QtCKStyle::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 QtCKStyle constructor should suffice.
sbtype | the scroll bar type |
QtCKStyle::KStyleFlags QtCKStyle::styleFlags | ( | ) | const |
Returns the KStyle flags used to initialize the style.
This is used solely for the kcmstyle module, and hence is internal.
int QtCKStyle::styleHint | ( | StyleHint | sh, |
const QWidget * | w = 0 , |
||
const QStyleOption & | = QStyleOption::Default , |
||
QStyleHintReturn * | = 0 |
||
) | const [virtual] |
Reimplementado de QCommonStyle.
QPixmap QtCKStyle::stylePixmap | ( | StylePixmap | sp, |
const QWidget * | widget = 0 , |
||
const QStyleOption & | = QStyleOption::Default |
||
) | const [virtual] |
Reimplementado de QCommonStyle.
Reimplementado de QCommonStyle.
void QtCKStyle::unPolish | ( | QWidget * | ) | [virtual] |
Undoes the initialization of a widget's appearance.
This function is the counterpart to polish. It is called for every polished widget when the style is dynamically changed. The former style has to unpolish its settings before the new style can polish them again.
Reimplementado de QStyle.
void QtCKStyle::virtual_hook | ( | int | id, |
void * | data | ||
) | [protected, virtual] |