Qyoto
4.0.5
Qyoto is a C# language binding for Qt
|
The QStyleOption class stores the parameters used by QStyle functions. More...
Public Types | |
enum | OptionType { SO_Button = 2, SO_ComboBox = 983044, SO_Complex = 983040, SO_ComplexCustomBase = 251658240, SO_CustomBase = 3840, SO_Default = 0, SO_DockWidget = 10, SO_FocusRect = 1, SO_Frame = 5, SO_GraphicsItem = 17, SO_GroupBox = 983047, SO_Header = 8, SO_MenuItem = 4, SO_ProgressBar = 6, SO_Q3DockWindow = 9, SO_Q3ListView = 983045, SO_Q3ListViewItem = 11, SO_RubberBand = 15, SO_SizeGrip = 983048, SO_Slider = 983041, SO_SpinBox = 983042, SO_Tab = 3, SO_TabBarBase = 14, SO_TabWidgetFrame = 13, SO_TitleBar = 983046, SO_ToolBar = 16, SO_ToolBox = 7, SO_ToolButton = 983043, SO_ViewItem = 12 } |
More... | |
enum | StyleOptionType { Type = 0 } |
More... | |
enum | StyleOptionVersion { Version = 1 } |
More... | |
Public Member Functions | |
QStyleOption (QStyleOption other) | |
| |
QStyleOption (int version=(int) QStyleOption.StyleOptionVersion.Version, int type=(int) QStyleOption.OptionType.SO_Default) | |
| |
virtual void | CreateProxy () |
new void | Init (QWidget w) |
| |
new void | InitFrom (QWidget w) |
| |
new void | Dispose () |
Protected Member Functions | |
QStyleOption (System.Type dummy) | |
Protected Attributes | |
SmokeInvocation | interceptor |
Properties | |
virtual System.IntPtr | SmokeObject [get, set] |
new Qt.LayoutDirection | Direction [get, set] |
| |
new QFontMetrics | FontMetrics [get, set] |
| |
new QPalette | Palette [get, set] |
| |
new QRect | Rect [get, set] |
| |
new QStyle.StateFlag | State [get, set] |
| |
new int | Type [get, set] |
| |
new int | Version [get, set] |
| |
The QStyleOption class stores the parameters used by QStyle functions.
QStyleOption and its subclasses contain all the information that QStyle functions need to draw a graphical element.
For performance reasons, there are few member functions and the access to the member variables is direct (i.e., using the . or -> operator). This low-level feel makes the structures straightforward to use and emphasizes that these are simply parameters used by the style functions.
The caller of a QStyle function usually creates QStyleOption objects on the stack. This combined with Qt's extensive use of implicit sharing for types such as QString, QPalette, and QColor ensures that no memory allocation needlessly takes place.
The following code snippet shows how to use a specific QStyleOption subclass to paint a push button:
void MyPushButton::paintEvent(QPaintEvent *)
{
QStyleOptionButton option;
option.initFrom(this);
option.state = isDown() ? QStyle::State_Sunken : QStyle::State_Raised;
if (isDefault())
option.features |= QStyleOptionButton::DefaultButton;
option.text = text();
option.icon = icon();
style()->drawControl(QStyle::CE_PushButton, &option, &painter, this);
}
In our example, the control is a QStyle::CE_PushButton, and according to the QStyle::drawControl() documentation the corresponding class is QStyleOptionButton.
When reimplementing QStyle functions that take a QStyleOption parameter, you often need to cast the QStyleOption to a subclass. For safety, you can use qstyleoption_cast() to ensure that the pointer type is correct. For example:
void MyStyle::drawPrimitive(PrimitiveElement element,
const QStyleOption *option,
QPainter *painter,
const QWidget *widget)
{
if (element == PE_FrameFocusRect) {
const QStyleOptionFocusRect *focusRectOption =
qstyleoption_cast<const QStyleOptionFocusRect *>(option);
if (focusRectOption) {
// ...
}
}
// ...
}
The qstyleoption_cast() function will return 0 if the object to which option points is not of the correct type.
For an example demonstrating how style options can be used, see the Styles example.
See also QStyle and QStylePainter.
This enum is used internally by QStyleOption, its subclasses, and qstyleoption_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles.
The following values are used for custom controls:
Some style options are defined for various Qt3Support controls:
See also type.
SO_Button | |
SO_ComboBox | |
SO_Complex | |
SO_ComplexCustomBase |
Reserved for custom QStyleOptions; all custom complex controls values must be above this value |
SO_CustomBase |
Reserved for custom QStyleOptions; all custom controls values must be above this value |
SO_Default | |
SO_DockWidget | |
SO_FocusRect | |
SO_Frame | |
SO_GraphicsItem | |
SO_GroupBox | |
SO_Header | |
SO_MenuItem | |
SO_ProgressBar | |
SO_Q3DockWindow |
QStyleOptionQ3DockWindow |
SO_Q3ListView |
QStyleOptionQ3ListView |
SO_Q3ListViewItem |
QStyleOptionQ3ListViewItem |
SO_RubberBand | |
SO_SizeGrip | |
SO_Slider | |
SO_SpinBox | |
SO_Tab | |
SO_TabBarBase | |
SO_TabWidgetFrame | |
SO_TitleBar | |
SO_ToolBar | |
SO_ToolBox | |
SO_ToolButton | |
SO_ViewItem |
QStyleOptionViewItem (used in Interviews) |
This enum is used to hold information about the type of the style option, and is defined for each QStyleOption subclass.
The type is used internally by QStyleOption, its subclasses, and qstyleoption_cast() to determine the type of style option. In general you do not need to worry about this unless you want to create your own QStyleOption subclass and your own styles.
See also StyleOptionVersion.
This enum is used to hold information about the version of the style option, and is defined for each QStyleOption subclass.
The version is used by QStyleOption subclasses to implement extensions without breaking compatibility. If you use qstyleoption_cast(), you normally do not need to check it.
See also StyleOptionType.
|
protected |
QtGui.QStyleOption.QStyleOption | ( | QStyleOption | other | ) |
Constructs a copy of other.
QtGui.QStyleOption.QStyleOption | ( | int | version = (int) QStyleOption.StyleOptionVersion.Version , |
int | type = (int) QStyleOption.OptionType.SO_Default |
||
) |
Constructs a QStyleOption with the specified version and type.
The version has no special meaning for QStyleOption; it can be used by subclasses to distinguish between different version of the same option type.
The state member variable is initialized to QStyle::State_None.
See also version and type.
|
virtual |
Reimplemented in QtGui.QStyleOptionViewItemV4, QtGui.QStyleOptionViewItemV3, QtGui.QStyleOptionViewItemV2, QtGui.QStyleOptionViewItem, QtGui.QStyleOptionToolButton, QtGui.QStyleOptionToolBoxV2, QtGui.QStyleOptionToolBox, QtGui.QStyleOptionToolBar, QtGui.QStyleOptionTitleBar, QtGui.QStyleOptionTabWidgetFrameV2, QtGui.QStyleOptionTabWidgetFrame, QtGui.QStyleOptionTabV3, QtGui.QStyleOptionTabV2, QtGui.QStyleOptionTabBarBaseV2, QtGui.QStyleOptionTabBarBase, QtGui.QStyleOptionTab, QtGui.QStyleOptionSpinBox, QtGui.QStyleOptionSlider, QtGui.QStyleOptionSizeGrip, QtGui.QStyleOptionRubberBand, QtGui.QStyleOptionProgressBarV2, QtGui.QStyleOptionProgressBar, QtGui.QStyleOptionMenuItem, QtGui.QStyleOptionHeader, QtGui.QStyleOptionGroupBox, QtGui.QStyleOptionGraphicsItem, QtGui.QStyleOptionFrameV3, QtGui.QStyleOptionFrameV2, QtGui.QStyleOptionFrame, QtGui.QStyleOptionFocusRect, QtGui.QStyleOptionDockWidgetV2, QtGui.QStyleOptionDockWidget, QtGui.QStyleOptionComplex, QtGui.QStyleOptionComboBox, and QtGui.QStyleOptionButton.
new void QtGui.QStyleOption.Dispose | ( | ) |
new void QtGui.QStyleOption.Init | ( | QWidget | w | ) |
Use initFrom(widget) instead.
new void QtGui.QStyleOption.InitFrom | ( | QWidget | w | ) |
Initializes the state, direction, rect, palette, and fontMetrics member variables based on the specified widget.
This is a convenience function; the member variables can also be initialized manually.
This function was introduced in Qt 4.1.
See also QWidget::layoutDirection(), QWidget::rect(), QWidget::palette(), and QWidget::fontMetrics().
|
protected |
|
getset |
This variable holds the text layout direction that should be used when drawing text in the control.
By default, the layout direction is Qt::LeftToRight.
See also initFrom().
|
getset |
This variable holds the font metrics that should be used when drawing text in the control.
By default, the application's default font is used.
See also initFrom().
|
getset |
This variable holds the palette that should be used when painting the control.
By default, the application's default palette is used.
See also initFrom().
|
getset |
This variable holds the area that should be used for various calculations and painting.
This can have different meanings for different types of elements. For example, for a QStyle::CE_PushButton element it would be the rectangle for the entire button, while for a QStyle::CE_PushButtonLabel element it would be just the area for the push button label.
The default value is a null rectangle, i.e. a rectangle with both the width and the height set to 0.
See also initFrom().
|
getset |
|
getset |
This variable holds the style flags that are used when drawing the control.
The default value is QStyle::State_None.
See also initFrom(), QStyle::drawPrimitive(), QStyle::drawControl(), QStyle::drawComplexControl(), and QStyle::State.
|
getset |
This variable holds the option type of the style option.
The default value is SO_Default.
See also OptionType.
|
getset |
This variable holds the version of the style option.
This value can be used by subclasses to implement extensions without breaking compatibility. If you use the qstyleoption_cast() function, you normally do not need to check it.
The default value is 1.