A large number of GUI elements are common to many widgets. The TQStyle class allows the look of these elements to be modified across all widgets that use the TQStyle functions. It also provides two feel options: Motif and Windows.
Although it is not possible to fully enumerate the look of graphical elements and the feel of widgets in a GUI, TQStyle provides a considerable amount of control and customisability.
In TQt 1.x the look and feel option for widgets was specified by a single value: the GUIStyle. Starting with TQt 2.0, this notion was expanded to allow the look to be specified by virtual drawing functions.
Derived classes may reimplement some or all of the drawing functions to modify the look of all widgets that use those functions.
.PP
Languages written from right to left (such as Arabic and Hebrew) usually also mirror the whole layout of widgets. If you design a style, you should take special care when drawing asymmetric elements to make sure that they also look correct in a mirrored layout. You can start your application with \fC-reverse\fR to check the mirrored layout. Also notice, that for a reversed layout, the light usually comes from top right instead of top left.
The actual reverse layout is performed automatically when possible. However, for the sake of flexibility, the translation cannot be performed everywhere. The documentation for each function in the TQStyle API states whether the function expects/returns logical or screen coordinates. Using logical coordinates (in ComplexControls, for example) provides great flexibility in controlling the look of a widget. Use visualRect() when necessary to translate logical coordinates into screen coordinates for drawing.
In TQt versions prior to 3.0, if you wanted a low level route into changing the appearance of a widget, you would reimplement polish(). With the new 3.0 style engine the recommended approach is to reimplement the draw functions, for example drawItem(), drawPrimitive(), drawControl(), drawControlMask(), drawComplexControl() and drawComplexControlMask(). Each of these functions is called with a range of parameters that provide information that you can use to determine how to draw them, e.g. style flags, rectangle, color group, etc.
This enum represents a ComplexControl. ComplexControls have different behaviour depending upon where the user clicks on them or which keys are pressed.
\fCTQStyle::CC_CustomBase\fR - base value for custom ControlElements. All values above this are reserved for custom use. Therefore, custom values must be greater than this value.
\fCTQStyle::CT_CustomBase\fR - base value for custom ControlElements. All values above this are reserved for custom use. Custom values must be greater than this value.
\fCTQStyle::CE_CustomBase\fR - base value for custom ControlElements. All values above this are reserved for custom use. Therefore, custom values must be greater than this value.
\fCTQStyle::PM_MaximumDragDistance\fR - Some feels require the scrollbar or other sliders to jump back to the original position when the mouse pointer is too far away while dragging. A value of -1 disables this behavior.
\fCTQStyle::PM_DockWindowSeparatorExtent\fR - width of a separator in a horiztonal dock window and the height of a separator in a vertical dock window.
\fCTQStyle::PM_CustomBase\fR - base value for custom ControlElements. All values above this are reserved for custom use. Therefore, custom values must be greater than this value.
\fCTQStyle::PE_CustomBase\fR - base value for custom PrimitiveElements. All values above this are reserved for custom use. Custom values must be greater than this value.
This enum represents flags for drawing PrimitiveElements. Not all primitives use all of these flags. Note that these flags may mean different things to different primitives. For an explanation of the relationship between primitives and their flags, as well as the different meanings of the flags, see the Style overview.
\fCTQStyle::SH_ScrollBar_MiddleClickAbsolutePosition\fR - a boolean value. If TRUE, middle clicking on a scrollbar causes the slider to jump to that position. If FALSE, the middle clicking is ignored.
\fCTQStyle::SH_ScrollBar_LeftClickAbsolutePosition\fR - a boolean value. If TRUE, left clicking on a scrollbar causes the slider to jump to that position. If FALSE, the left clicking will behave as appropriate for each control.
\fCTQStyle::SH_ScrollBar_ScrollWhenPointerLeavesControl\fR - a boolean value. If TRUE, when clicking a scrollbar SubControl, holding the mouse button down and moving the pointer outside the SubControl, the scrollbar continues to scroll. If FALSE, the scollbar stops scrolling when the pointer leaves the SubControl.
\fCTQStyle::SH_Header_ArrowAlignment\fR - the placement of the sorting indicator may appear in list or table headers. Possible values are TQt::Left or TQt::Right.
\fCTQStyle::SH_ProgressDialog_TextLabelAlignment\fR - TQt::AlignmentFlags -- text label alignment in progress dialogs; Center on windows, Auto|VCenter otherwise.
\fCTQStyle::SH_FontDialog_SelectAssociatedText\fR - select the text in the line edit, or when selecting an item from the listbox, or when the line edit receives focus, like Windows.
\fCTQStyle::SH_ScrollView_FrameOnlyAroundContents\fR - whether scrollviews draw their frame only around contents (like Motif), or around contents, scrollbars and corner widgets (like Windows).
\fCTQStyle::SH_MenuBar_AltKeyNavigation\fR - menubars items are navigable by pressing Alt, followed by using the arrow keys to select the desired item.
\fCTQStyle::SH_CustomBase\fR - base value for custom ControlElements. All values above this are reserved for custom use. Therefore, custom values must be greater than this value.
\fCTQStyle::SP_CustomBase\fR - base value for custom ControlElements. All values above this are reserved for custom use. Therefore, custom values must be greater than this value.
\fCTQStyle::SR_CustomBase\fR - base value for custom ControlElements. All values above this are reserved for custom use. Therefore, custom values must be greater than this value.
Draws the ComplexControl \fIcontrol\fR using the painter \fIp\fR in the area \fIr\fR. Colors are used from the color group \fIcg\fR. The \fIsub\fR argument specifies which SubControls to draw. Multiple SubControls can be OR'ed together. The \fIsubActive\fR argument specifies which SubControl is active.
.PP
The rect \fIr\fR should be in logical coordinates. Reimplementations of this function should use visualRect() to change the logical coordinates into screen coordinates when using drawPrimitive() and drawControl().
.PP
The \fIhow\fR argument is used to control how the ComplexControl is drawn. Multiple flags can OR'ed together. See the table below for an explanation of which flags are used with the various ComplexControls.
The \fIwidget\fR argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \fIcontrol\fR. The \fIopt\fR argument can be used to pass extra information required when drawing the ComplexControl. Note that \fIopt\fR may be the default value even for ComplexControls that can make use of the extra options. See the table below for the appropriate \fIwidget\fR and \fIopt\fR usage:
& Widget Cast Style Flags Notes Options Notes CC_SpinWidget(const QSpinWidget *) Style_Enabled Set if the spinwidget is enabled. Unused. Style_HasFocus Set if the spinwidget has input focus. CC_ComboBox(const QComboBox *) Style_Enabled Set if the combobox is enabled. Unused. Style_HasFocus Set if the combobox has input focus. CC_ScrollBar(const QScrollBar *) Style_Enabled Set if the scrollbar is enabled. Unused. Style_HasFocus Set if the scrollbar has input focus. CC_Slider(const QSlider *) Style_Enabled Set if the slider is enabled. Unused. Style_HasFocus Set if the slider has input focus. CC_ToolButton(const TQToolButton *) Style_Enabled Set if the toolbutton is enabled. TQStyleOption ( ArrowType t )
opt.arrowType() When the tool button only contains an arrow, \fIt\fR is the arrow's type. Style_HasFocus Set if the toolbutton has input focus. Style_Down Set if the toolbutton is down (ie. mouse button or space pressed). Style_On Set if the toolbutton is a toggle button and is toggled on. Style_AutoRaise Set if the toolbutton has auto-raise enabled. Style_Raised Set if the button is not down, not on and doesn't contain the mouse when auto-raise is enabled. CC_TitleBar(const TQWidget *) Style_Enabled Set if the titlebar is enabled. Unused. CC_ListView(const QListView *) Style_Enabled Set if the titlebar is enabled. TQStyleOption ( QListViewItem *item )
Draw a bitmask for the ComplexControl \fIcontrol\fR using the painter \fIp\fR in the area \fIr\fR. See drawComplexControl() for an explanation of the use of the \fIwidget\fR and \fIopt\fR arguments.
.PP
The rect \fIr\fR should be in logical coordinates. Reimplementations of this function should use visualRect() to change the logical corrdinates into screen coordinates when using drawPrimitive() and drawControl().
Draws the ControlElement \fIelement\fR using the painter \fIp\fR in the area \fIr\fR. Colors are used from the color group \fIcg\fR.
.PP
The rect \fIr\fR should be in screen coordinates.
.PP
The \fIhow\fR argument is used to control how the ControlElement is drawn. Multiple flags can be OR'ed together. See the table below for an explanation of which flags are used with the various ControlElements.
The \fIwidget\fR argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \fIelement\fR. The \fIopt\fR argument can be used to pass extra information required when drawing the ControlElement. Note that \fIopt\fR may be the default value even for ControlElements that can make use of the extra options. See the table below for the appropriate \fIwidget\fR and \fIopt\fR usage:
CE_PushButtonLabel(const QPushButton *) Style_Enabled Set if the button is enabled. Unused. Style_HasFocus Set if the button has input focus. Style_Raised Set if the button is not down, not on and not flat. Style_On Set if the button is a toggle button and toggled on. Style_Down Set if the button is down (i.e., the mouse button or space bar is pressed on the button). Style_ButtonDefault Set if the button is a default button. CE_CheckBox(const QCheckBox *)
.PP
and
.PP
CE_CheckBoxLabel(const QCheckBox *)
.PP Style_Enabled Set if the checkbox is enabled. Unused.
Style_HasFocus Set if the checkbox has input focus. Style_On Set if the checkbox is checked. Style_Off Set if the checkbox is not checked. Style_NoChange Set if the checkbox is in the NoChange state. Style_Down Set if the checkbox is down (i.e., the mouse button or space bar is pressed on the button). CE_RadioButton(const QRadioButton *)
.PP
and
.PP
CE_RadioButtonLabel(const QRadioButton *) Style_Enabled Set if the radiobutton is enabled. Unused. Style_HasFocus Set if the radiobutton has input focus. Style_On Set if the radiobutton is checked. Style_Off Set if the radiobutton is not checked. Style_Down Set if the radiobutton is down (i.e., the mouse button or space bar is pressed on the radiobutton). CE_TabBarTab(const QTabBar *)
Style_HasFocus Set if the progressbar has input focus. CE_PopupMenuItem(const TQPopupMenu *) Style_Enabled Set if the menuitem is enabled. TQStyleOption ( TQMenuItem *mi, int tabwidth, int maxpmwidth )
opt.maxIconWidth() \fImi\fR is the menu item being drawn. TQMenuItem is currently an internal class. Style_Active Set if the menuitem is the current item. \fItabwidth\fR is the width of the tab column where key accelerators are drawn. Style_Down Set if the menuitem is down (i.e., the mouse button or space bar is pressed). \fImaxpmwidth\fR is the maximum width of the check column where checkmarks and iconsets are drawn. CE_MenuBarItem(const TQMenuBar *) Style_Enabled Set if the menuitem is enabled TQStyleOption ( TQMenuItem *mi )
opt.menuItem() \fImi\fR is the menu item being drawn. Style_Active Set if the menuitem is the current item. Style_Down Set if the menuitem is down (i.e., a mouse button or the space bar is pressed). Style_HasFocus Set if the menubar has input focus. CE_ToolButtonLabel(const TQToolButton *) Style_Enabled Set if the toolbutton is enabled. TQStyleOption ( ArrowType t )
opt.arrowType() When the tool button only contains an arrow, \fIt\fR is the arrow's type. Style_HasFocus Set if the toolbutton has input focus. Style_Down Set if the toolbutton is down (i.e., a mouse button or the space is pressed). Style_On Set if the toolbutton is a toggle button and is toggled on. Style_AutoRaise Set if the toolbutton has auto-raise enabled. Style_MouseOver Set if the mouse pointer is over the toolbutton. Style_Raised
Draw a bitmask for the ControlElement \fIelement\fR using the painter \fIp\fR in the area \fIr\fR. See drawControl() for an explanation of the use of the \fIwidget\fR and \fIopt\fR arguments.
Draws the \fItext\fR or \fIpixmap\fR in rectangle \fIr\fR using painter \fIp\fR and color group \fIg\fR. The pen color is specified with \fIpenColor\fR. The \fIenabled\fR bool indicates whether or not the item is enabled; when reimplementing this bool should influence how the item is drawn. If \fIlen\fR is -1 (the default) all the \fItext\fR is drawn; otherwise only the first \fIlen\fR characters of \fItext\fR are drawn. The text is aligned and wrapped according to the alignment \fIflags\fR (see TQt::AlignmentFlags).
Draws the style PrimitiveElement \fIpe\fR using the painter \fIp\fR in the area \fIr\fR. Colors are used from the color group \fIcg\fR.
.PP
The rect \fIr\fR should be in screen coordinates.
.PP
The \fIflags\fR argument is used to control how the PrimitiveElement is drawn. Multiple flags can be OR'ed together.
.PP
For example, a pressed button would be drawn with the flags Style_Enabled and Style_Down.
.PP
The \fIopt\fR argument can be used to control how various PrimitiveElements are drawn. Note that \fIopt\fR may be the default value even for PrimitiveElements that make use of extra options. When \fIopt\fR is non-default, it is used as follows:
opt.midLineWidth() \fIlinewidth\fR is the line width for drawing the panel. \fImidlinewidth\fR is the mid-line width for drawing the panel. PE_PanelPopup TQStyleOption ( int linewidth, int midlinewidth )
opt.midLineWidth() \fIlinewidth\fR is the line width for drawing the panel. \fImidlinewidth\fR is the mid-line width for drawing the panel. PE_PanelMenuBar TQStyleOption ( int linewidth, int midlinewidth )
opt.midLineWidth() \fIlinewidth\fR is the line width for drawing the panel. \fImidlinewidth\fR is the mid-line width for drawing the panel. PE_PanelDockWindow TQStyleOption ( int linewidth, int midlinewidth )
opt.midLineWidth() \fIlinewidth\fR is the line width for drawing the panel. \fImidlinewidth\fR is the mid-line width for drawing the panel. PE_GroupBoxFrame TQStyleOption ( int linewidth, int midlinewidth, int shape, int shadow )
opt.frameShadow() \fIlinewidth\fR is the line width for the group box. \fImidlinewidth\fR is the mid-line width for the group box. \fIshape\fR is the frame shape for the group box.
.TE
.fi
</center>
.PP
For all other PrimitiveElements, \fIopt\fR is unused.
Returns the appropriate area (see below) within rectangle \fIr\fR in which to draw the \fItext\fR or \fIpixmap\fR using painter \fIp\fR. If \fIlen\fR is -1 (the default) all the \fItext\fR is drawn; otherwise only the first \fIlen\fR characters of \fItext\fR are drawn. The text is aligned in accordance with the alignment \fIflags\fR (see TQt::AlignmentFlags). The \fIenabled\fR bool indicates whether or not the item is enabled.
If \fIr\fR is larger than the area needed to render the \fItext\fR the rectangle that is returned will be offset within \fIr\fR in accordance with the alignment \fIflags\fR. For example if \fIflags\fR is AlignCenter the returned rectangle will be centered within \fIr\fR. If \fIr\fR is smaller than the area needed the rectangle that is returned will be \fIlarger\fR than \fIr\fR (the smallest rectangle large enough to render the \fItext\fR or \fIpixmap\fR).
.PP
By default, if both the text and the pixmap are not null, the pixmap is drawn and the text is ignored.
Returns the pixel metric for \fImetric\fR. The \fIwidget\fR argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \fImetric\fR. Note that \fIwidget\fR may be zero even for PixelMetrics that can make use of \fIwidget\fR. See the table below for the appropriate \fIwidget\fR casts:
Reasonable actions in this function might be to call TQWidget::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 TQt 3.0's style engine you will rarely need to write your own polish(); instead reimplement drawItem(), drawPrimitive(), etc.
The TQWidget::inherits() function may provide enough information to allow class-specific customizations. But be careful not to hard-code things too much because new TQStyle subclasses are expected to work reasonably with all current and \fIfuture\fR widgets.
Polishes the popup menu according to the GUI style. This usually means setting the mouse tracking (TQPopupMenu::setMouseTracking()) and whether the menu is checkable by default (TQPopupMenu::setCheckable()).
Returns the SubControl for \fIwidget\fR at the point \fIpos\fR. The \fIwidget\fR argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \fIcontrol\fR. The \fIopt\fR argument can be used to pass extra information required when drawing the ComplexControl. Note that \fIopt\fR may be the default value even for ComplexControls that can make use of the extra options. See drawComplexControl() for an explanation of the \fIwidget\fR and \fIopt\fR arguments.
Note that \fIpos\fR is passed in screen coordinates. When using querySubControlMetrics() to check for hits and misses, use visualRect() to change the logical coordinates into screen coordinates.
.PP
See also drawComplexControl(), ComplexControl, SubControl, and querySubControlMetrics().
The \fIwidget\fR argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \fIcontrol\fR. The \fIopt\fR argument can be used to pass extra information required when drawing the ComplexControl. Note that \fIopt\fR may be the default value even for ComplexControls that can make use of the extra options. See drawComplexControl() for an explanation of the \fIwidget\fR and \fIopt\fR arguments.
The \fIwidget\fR argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \fIcontents\fR. The \fIopt\fR argument can be used to pass extra information required when calculating the size. Note that \fIopt\fR may be the default value even for ContentsTypes that can make use of the extra options. See the table below for the appropriate \fIwidget\fR and \fIopt\fR usage:
Returns the style hint \fIstylehint\fR for \fIwidget\fR. Currently, \fIwidget\fR, \fIopt\fR, and \fIreturnData\fR are unused; they're included to allow for future enhancements.
.PP
For an explanation of the return value see StyleHint.
The \fIopt\fR argument can be used to pass extra information required when drawing the ControlElement. Note that \fIopt\fR may be the default value even for StylePixmaps that can make use of the extra options. Currently, the \fIopt\fR argument is unused.
The \fIwidget\fR argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \fIstylepixmap\fR. See the table below for the appropriate \fIwidget\fR casts:
The \fIwidget\fR argument is a pointer to a TQWidget or one of its subclasses. The widget can be cast to the appropriate type based on the value of \fIsubrect\fR. See the table below for the appropriate \fIwidget\fR casts:
Undoes the initialization of a widget's appearance.
.PP
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.
Returns the rect \fIlogical\fR in screen coordinates. The bounding rect for widget \fIw\fR is used to perform the translation. This function is provided to aid style implementors in supporting right-to-left mode.
This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
.PP
Returns the rect \fIlogical\fR in screen coordinates. The rect \fIbounding\fR is used to perform the translation. This function is provided to aid style implementors in supporting right-to-left mode.