Qyoto  4.0.5
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Properties
QtGui.QStyleOption Class Reference

The QStyleOption class stores the parameters used by QStyle functions. More...

Inheritance diagram for QtGui.QStyleOption:
Collaboration diagram for QtGui.QStyleOption:

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]
 
 

Detailed Description

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();

QPainter painter(this);

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.

Member Enumeration Documentation

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.

Enumerator:
SO_Button 

QStyleOptionButton

SO_ComboBox 

QStyleOptionComboBox

SO_Complex 

QStyleOptionComplex

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 

QStyleOption

SO_DockWidget 

QStyleOptionDockWidget

SO_FocusRect 

QStyleOptionFocusRect

SO_Frame 

QStyleOptionFrame QStyleOptionFrameV2

SO_GraphicsItem 

QStyleOptionGraphicsItem

SO_GroupBox 

QStyleOptionGroupBox

SO_Header 

QStyleOptionHeader

SO_MenuItem 

QStyleOptionMenuItem

SO_ProgressBar 

QStyleOptionProgressBar QStyleOptionProgressBarV2

SO_Q3DockWindow 

QStyleOptionQ3DockWindow

SO_Q3ListView 

QStyleOptionQ3ListView

SO_Q3ListViewItem 

QStyleOptionQ3ListViewItem

SO_RubberBand 

QStyleOptionRubberBand

SO_SizeGrip 

QStyleOptionSizeGrip

SO_Slider 

QStyleOptionSlider

SO_SpinBox 

QStyleOptionSpinBox

SO_Tab 

QStyleOptionTab

SO_TabBarBase 

QStyleOptionTabBarBase

SO_TabWidgetFrame 

QStyleOptionTabWidgetFrame

SO_TitleBar 

QStyleOptionTitleBar

SO_ToolBar 

QStyleOptionToolBar

SO_ToolBox 

QStyleOptionToolBox

SO_ToolButton 

QStyleOptionToolButton

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.

Enumerator:
Type 

The type of style option provided (SO_Default for this class).

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.

Enumerator:
Version 

1

Constructor & Destructor Documentation

QtGui.QStyleOption.QStyleOption ( System.Type  dummy)
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.

Member Function Documentation

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().

Member Data Documentation

SmokeInvocation QtGui.QStyleOption.interceptor
protected

Property Documentation

new Qt.LayoutDirection QtGui.QStyleOption.Direction
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().

new QFontMetrics QtGui.QStyleOption.FontMetrics
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().

new QPalette QtGui.QStyleOption.Palette
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().

new QRect QtGui.QStyleOption.Rect
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().

virtual System.IntPtr QtGui.QStyleOption.SmokeObject
getset
new QStyle.StateFlag QtGui.QStyleOption.State
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.

new int QtGui.QStyleOption.Type
getset

This variable holds the option type of the style option.

The default value is SO_Default.

See also OptionType.

new int QtGui.QStyleOption.Version
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.