|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.core.QObject
com.trolltech.qt.gui.QStyle
com.trolltech.qt.gui.QCommonStyle
com.trolltech.qt.gui.QWindowsStyle
com.trolltech.qt.gui.QPlastiqueStyle
public class QPlastiqueStyle
The QPlastiqueStyle class provides a widget style similar to the Plastik style available in KDE.
The Plastique style provides a default look and feel for widgets on X11 that closely resembles the Plastik style, introduced by Sandro Giessl in KDE 3.2.
Nested Class Summary |
---|
Nested classes/interfaces inherited from class com.trolltech.qt.gui.QStyle |
---|
QStyle.ComplexControl, QStyle.ContentsType, QStyle.ControlElement, QStyle.PixelMetric, QStyle.PrimitiveElement, QStyle.StandardPixmap, QStyle.State, QStyle.StateFlag, QStyle.StyleHint, QStyle.SubControl, QStyle.SubElement |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I> |
Constructor Summary | |
---|---|
QPlastiqueStyle()
Constructs a QPlastiqueStyle object. |
Method Summary | |
---|---|
void |
drawComplexControl(QStyle.ComplexControl control,
QStyleOptionComplex option,
QPainter painter,
QWidget widget)
Draws the given control using the provided painter with the style options specified by option. |
void |
drawControl(QStyle.ControlElement element,
QStyleOption option,
QPainter painter,
QWidget widget)
Draws the given element with the provided painter with the style options specified by option. |
void |
drawPrimitive(QStyle.PrimitiveElement element,
QStyleOption option,
QPainter painter,
QWidget widget)
Draws the given primitive element with the provided painter using the style options specified by option. |
boolean |
eventFilter(QObject watched,
QEvent event)
Filters events if this object has been installed as an event filter for the arg__1 object. In your reimplementation of this function, if you want to filter the arg__2 out, i.e. stop it being handled further, return true; otherwise return false. Example: class MainWindow : public QMainWindow
{
public:
MainWindow();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private:
QTextEdit *textEdit;
};
MainWindow::MainWindow()
{
textEdit = new QTextEdit;
setCentralWidget(textEdit);
textEdit->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj == textEdit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
qDebug() << "Ate key press" << keyEvent->key();
return true;
} else {
return false;
}
} else {
// pass the event on to the parent class
return QMainWindow::eventFilter(obj, event);
}
}
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. Warning: If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash. |
static QPlastiqueStyle |
fromNativePointer(QNativePointer nativePointer)
This function returns the QPlastiqueStyle instance pointed to by nativePointer |
int |
hitTestComplexControl(QStyle.ComplexControl control,
QStyleOptionComplex option,
QPoint pos,
QWidget widget)
Returns the sub control at the given pos in the given complex control (with the style options specified by option). |
int |
pixelMetric(QStyle.PixelMetric metric,
QStyleOption option,
QWidget widget)
Returns the value of the given pixel metric. |
void |
polish(QApplication app)
Late initialization of the given arg__1 object. |
void |
polish(QPalette pal)
Changes the arg__1 according to style specific requirements for color palettes (if any). |
void |
polish(QWidget widget)
Initializes the appearance of the given arg__1. This function is called for every widget at some point after it has been fully created but just before it is shown for the very first time. Note that the default implementation does nothing. Reasonable actions in this function might be to call the QWidget::setBackgroundMode() function for the widget. Do not use the function to set, for example, the geometry; reimplementing this function do provide a back-door through which the appearance of a widget can be changed, but with Qt 4.0's style engine there is rarely necessary to implement this function; reimplement the drawItemPixmap, drawItemText, drawPrimitive, etc. instead. The QWidget::inherits() function may provide enough information to allow class-specific customizations. But because new QStyle subclasses are expected to work reasonably with all current and future widgets, limited use of hard-coded customization is recommended. |
QSize |
sizeFromContents(QStyle.ContentsType type,
QStyleOption option,
QSize size,
QWidget widget)
Returns the size of the element described by the specified option and type, based on the provided size. |
protected QIcon |
standardIconImplementation(QStyle.StandardPixmap standardIcon,
QStyleOption opt,
QWidget widget)
|
QPalette |
standardPalette()
Returns the style's standard palette. |
int |
styleHint(QStyle.StyleHint hint,
QStyleOption option,
QWidget widget,
QStyleHintReturn returnData)
Returns an integer representing the specified style hint for the given widget described by the provided style option. |
QRect |
subControlRect(QStyle.ComplexControl cc,
QStyleOptionComplex opt,
int sc,
QWidget widget)
Returns the rectangle containing the specified sc of the given complex cc (with the style specified by opt). |
QRect |
subElementRect(QStyle.SubElement element,
QStyleOption option,
QWidget widget)
Returns the sub-area for the given element as described in the provided style option. |
protected void |
timerEvent(QTimerEvent event)
This event handler can be reimplemented in a subclass to receive timer events for the object. QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the arg__1 parameter. |
void |
unpolish(QApplication app)
Uninitialize the given arg__1. |
void |
unpolish(QWidget widget)
Uninitialize the given arg__1's appearance. This function is the counterpart to polish. It is called for every polished widget whenever the style is dynamically changed; the former style has to unpolish its settings before the new style can polish them again. Note that unpolish will only be called if the widget is destroyed. This can cause problems in some cases, e.g, if you remove a widget from the UI, cache it, and then reinsert it after the style has changed; some of Qt's classes cache their widgets. |
Methods inherited from class com.trolltech.qt.gui.QCommonStyle |
---|
generatedIconPixmap |
Methods inherited from class com.trolltech.qt.core.QObject |
---|
blockSignals, childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, property, removeEventFilter, setObjectName, setParent, setProperty, signalsBlocked, startTimer, thread |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
disconnect, disconnect, signalSender |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QPlastiqueStyle()
Constructs a QPlastiqueStyle object.
Method Detail |
---|
protected QIcon standardIconImplementation(QStyle.StandardPixmap standardIcon, QStyleOption opt, QWidget widget)
standardIconImplementation
in class QWindowsStyle
public void drawComplexControl(QStyle.ComplexControl control, QStyleOptionComplex option, QPainter painter, QWidget widget)
Draws the given control using the provided painter with the style options specified by option.
The widget argument is optional and can be used as aid in drawing the control.
The option parameter is a pointer to a QStyleOptionComplex object that can be cast to the correct subclass using the qstyleoption_cast() function. Note that the rect member of the specified option must be in logical coordinates. Reimplementations of this function should use visualRect to change the logical coordinates into screen coordinates before calling the drawPrimitive or drawControl function.
The table below is listing the complex control elements and their associated style option subclass. The style options contain all the parameters required to draw the controls, including QStyleOption::state which holds the style flags that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
Complex Control | QStyleOptionComplex Subclass | Style Flag | Remark |
---|---|---|---|
CC_SpinBox | QStyleOptionSpinBox | State_Enabled | Set if the spin box is enabled. |
State_HasFocus | Set if the spin box has input focus. | ||
CC_ComboBox | QStyleOptionComboBox | State_Enabled | Set if the combobox is enabled. |
State_HasFocus | Set if the combobox has input focus. | ||
CC_ScrollBar | QStyleOptionSlider | State_Enabled | Set if the scroll bar is enabled. |
State_HasFocus | Set if the scroll bar has input focus. | ||
CC_Slider | QStyleOptionSlider | State_Enabled | Set if the slider is enabled. |
State_HasFocus | Set if the slider has input focus. | ||
CC_Dial | QStyleOptionSlider | State_Enabled | Set if the dial is enabled. |
State_HasFocus | Set if the dial has input focus. | ||
CC_ToolButton | QStyleOptionToolButton | State_Enabled | Set if the tool button is enabled. |
State_HasFocus | Set if the tool button has input focus. | ||
State_DownArrow | Set if the tool button is down (i.e., a mouse button or the space bar is pressed). | ||
State_On | Set if the tool button is a toggle button and is toggled on. | ||
State_AutoRaise | Set if the tool button has auto-raise enabled. | ||
State_Raised | Set if the button is not down, not on, and doesn't contain the mouse when auto-raise is enabled. | ||
CC_TitleBar | QStyleOptionTitleBar | State_Enabled | Set if the title bar is enabled. |
CC_Q3ListView | QStyleOptionQ3ListView | State_Enabled | Set if the list view is enabled. |
drawComplexControl
in class QWindowsStyle
public void drawControl(QStyle.ControlElement element, QStyleOption option, QPainter painter, QWidget widget)
Draws the given element with the provided painter with the style options specified by option.
The widget argument is optional and can be used as aid in drawing the control. The option parameter is a pointer to a QStyleOption object that can be cast to the correct subclass using the qstyleoption_cast() function.
The table below is listing the control elements and their associated style option subclass. The style options contain all the parameters required to draw the controls, including QStyleOption::state which holds the style flags that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
Note that if a control element is not listed here, it is because it uses a plain QStyleOption object.
Control Element | QStyleOption Subclass | Style Flag | Remark |
---|---|---|---|
CE_MenuItem, CE_MenuBarItem | QStyleOptionMenuItem | State_Selected | The menu item is currently selected item. |
State_Enabled | The item is enabled. | ||
State_DownArrow | Indicates that a scroll down arrow should be drawn. | ||
State_UpArrow | Indicates that a scroll up arrow should be drawn | ||
State_HasFocus | Set if the menu bar has input focus. | ||
CE_PushButton, CE_PushButtonBevel, CE_PushButtonLabel | QStyleOptionButton | State_Enabled | Set if the button is enabled. |
State_HasFocus | Set if the button has input focus. | ||
State_Raised | Set if the button is not down, not on and not flat. | ||
State_On | Set if the button is a toggle button and is toggled on. | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button). | ||
CE_RadioButton, CE_RadioButtonLabel, CE_CheckBox, CE_CheckBoxLabel | QStyleOptionButton | State_Enabled | Set if the button is enabled. |
State_HasFocus | Set if the button has input focus. | ||
State_On | Set if the button is checked. | ||
State_Off | Set if the button is not checked. | ||
State_NoChange | Set if the button is in the NoChange state. | ||
State_Sunken | Set if the button is down (i.e., the mouse button or the space bar is pressed on the button). | ||
CE_ProgressBarContents, CE_ProgressBarLabel, CE_ProgressBarGroove | QStyleOptionProgressBar | State_Enabled | Set if the progress bar is enabled. |
State_HasFocus | Set if the progress bar has input focus. | ||
CE_Header, CE_HeaderSection, CE_HeaderLabel | QStyleOptionHeader | ||
CE_TabBarTab, CE_TabBarTabShape, CE_TabBarTabLabel | QStyleOptionTab | State_Enabled | Set if the tab bar is enabled. |
State_Selected | The tab bar is the currently selected tab bar. | ||
State_HasFocus | Set if the tab bar tab has input focus. | ||
CE_ToolButtonLabel | QStyleOptionToolButton | State_Enabled | Set if the tool button is enabled. |
State_HasFocus | Set if the tool button has input focus. | ||
State_Sunken | Set if the tool button is down (i.e., a mouse button or the space bar is pressed). | ||
State_On | Set if the tool button is a toggle button and is toggled on. | ||
State_AutoRaise | Set if the tool button has auto-raise enabled. | ||
State_MouseOver | Set if the mouse pointer is over the tool button. | ||
State_Raised | Set if the button is not down and is not on. | ||
CE_ToolBoxTab | QStyleOptionToolBox | State_Selected | The tab is the currently selected tab. |
CE_HeaderSection | QStyleOptionHeader | State_Sunken | Indicates that the section is pressed. |
State_UpArrow | Indicates that the sort indicator should be pointing up. | ||
State_DownArrow | Indicates that the sort indicator should be pointing down. |
drawControl
in class QWindowsStyle
public void drawPrimitive(QStyle.PrimitiveElement element, QStyleOption option, QPainter painter, QWidget widget)
Draws the given primitive element with the provided painter using the style options specified by option.
The widget argument is optional and may contain a widget that may aid in drawing the primitive element.
The table below is listing the primitive elements and their associated style option subclasses. The style options contain all the parameters required to draw the elements, including QStyleOption::state which holds the style flags that are used when drawing. The table also describes which flags that are set when casting the given option to the appropriate subclass.
Note that if a primitive element is not listed here, it is because it uses a plain QStyleOption object.
Primitive Element | QStyleOption Subclass | Style Flag | Remark |
---|---|---|---|
PE_FrameFocusRect | QStyleOptionFocusRect | State_FocusAtBorder | Whether the focus is is at the border or inside the widget. |
PE_IndicatorCheckBox | QStyleOptionButton | State_NoChange | Indicates a "tri-state" checkbox. |
State_On | Indicates the indicator is checked. | ||
PE_IndicatorRadioButton | QStyleOptionButton | State_On | Indicates that a radio button is selected. |
PE_Q3CheckListExclusiveIndicator, PE_Q3CheckListIndicator | QStyleOptionQ3ListView | State_On | Indicates whether or not the controller is selected. |
State_NoChange | Indicates a "tri-state" controller. | ||
State_Enabled | Indicates the controller is enabled. | ||
PE_IndicatorBranch | QStyleOption | State_Children | Indicates that the control for expanding the tree to show child items, should be drawn. |
State_Item | Indicates that a horizontal branch (to show a child item), should be drawn. | ||
State_Open | Indicates that the tree branch is expanded. | ||
State_Sibling | Indicates that a vertical line (to show a sibling item), should be drawn. | ||
PE_IndicatorHeaderArrow | QStyleOptionHeader | State_UpArrow | Indicates that the arrow should be drawn up; otherwise it should be down. |
PE_FrameGroupBox, PE_Frame, PE_FrameLineEdit, PE_FrameMenu, PE_FrameDockWidget | QStyleOptionFrame | State_Sunken | Indicates that the Frame should be sunken. |
PE_IndicatorToolBarHandle | QStyleOption | State_Horizontal | Indicates that the window handle is horizontal instead of vertical. |
PE_Q3DockWindowSeparator | QStyleOption | State_Horizontal | Indicates that the separator is horizontal instead of vertical. |
PE_IndicatorSpinPlus, PE_IndicatorSpinMinus, PE_IndicatorSpinUp, PE_IndicatorSpinDown, | QStyleOptionSpinBox | State_Sunken | Indicates that the button is pressed. |
drawPrimitive
in class QWindowsStyle
public boolean eventFilter(QObject watched, QEvent event)
Filters events if this object has been installed as an event filter for the arg__1 object.
In your reimplementation of this function, if you want to filter the arg__2 out, i.e. stop it being handled further, return true; otherwise return false.
Example:
class MainWindow : public QMainWindow
{
public:
MainWindow();
protected:
bool eventFilter(QObject *obj, QEvent *ev);
private:
QTextEdit *textEdit;
};
MainWindow::MainWindow()
{
textEdit = new QTextEdit;
setCentralWidget(textEdit);
textEdit->installEventFilter(this);
}
bool MainWindow::eventFilter(QObject *obj, QEvent *event)
{
if (obj == textEdit) {
if (event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
qDebug() << "Ate key press" << keyEvent->key();
return true;
} else {
return false;
}
} else {
// pass the event on to the parent class
return QMainWindow::eventFilter(obj, event);
}
}
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.
Warning: If you delete the receiver object in this function, be sure to return true. Otherwise, Qt will forward the event to the deleted object and the program might crash.
eventFilter
in class QWindowsStyle
public int hitTestComplexControl(QStyle.ComplexControl control, QStyleOptionComplex option, QPoint pos, QWidget widget)
Returns the sub control at the given pos in the given complex control (with the style options specified by option).
Note that the pos is expressed in screen coordinates.
The option argument is a pointer to a QStyleOptionComplex object (or one of its subclasses). The object can be cast to the appropriate type using the qstyleoption_cast() function. See drawComplexControl for details. The widget argument is optional and can contain additional information for the function.
hitTestComplexControl
in class QCommonStyle
public int pixelMetric(QStyle.PixelMetric metric, QStyleOption option, QWidget widget)
Returns the value of the given pixel metric.
The specified option and widget can be used for calculating the metric. In general, the widget argument is not used. The option can be cast to the appropriate type using the qstyleoption_cast() function. Note that the option may be zero even for PixelMetrics that can make use of it. See the table below for the appropriate option casts:
Some pixel metrics are called from widgets and some are only called internally by the style. If the metric is not called by a widget, it is the discretion of the style author to make use of it. For some styles, this may not be appropriate.
pixelMetric
in class QWindowsStyle
public void polish(QWidget widget)
Initializes the appearance of the given arg__1.
This function is called for every widget at some point after it has been fully created but just before it is shown for the very first time.
Note that the default implementation does nothing. Reasonable actions in this function might be to call the QWidget::setBackgroundMode() function for the widget. Do not use the function to set, for example, the geometry; reimplementing this function do provide a back-door through which the appearance of a widget can be changed, but with Qt 4.0's style engine there is rarely necessary to implement this function; reimplement the drawItemPixmap, drawItemText, drawPrimitive, etc. instead.
The QWidget::inherits() function may provide enough information to allow class-specific customizations. But because new QStyle subclasses are expected to work reasonably with all current and future widgets, limited use of hard-coded customization is recommended.
polish
in class QWindowsStyle
public void polish(QPalette pal)
Changes the arg__1 according to style specific requirements for color palettes (if any).
polish
in class QWindowsStyle
public void polish(QApplication app)
Late initialization of the given arg__1 object.
polish
in class QWindowsStyle
public QSize sizeFromContents(QStyle.ContentsType type, QStyleOption option, QSize size, QWidget widget)
Returns the size of the element described by the specified option and type, based on the provided size.
The option argument is a pointer to a QStyleOption or one of its subclasses. The option can be cast to the appropriate type using the qstyleoption_cast() function. The widget is an optional argument and can contain extra information used for calculating the size.
See the table below for the appropriate option casts:
sizeFromContents
in class QWindowsStyle
public QPalette standardPalette()
Returns the style's standard palette.
Note that on systems that support system colors, the style's standard palette is not used.
standardPalette
in class QStyle
public int styleHint(QStyle.StyleHint hint, QStyleOption option, QWidget widget, QStyleHintReturn returnData)
Returns an integer representing the specified style hint for the given widget described by the provided style option.
Note that currently, the returnData and widget parameters are not used; they are provided for future enhancement. In addition, the option parameter is used only in case of the SH_ComboBox_Popup, SH_ComboBox_LayoutDirection, and SH_GroupBox_TextLabelColor style hints.
styleHint
in class QWindowsStyle
public QRect subControlRect(QStyle.ComplexControl cc, QStyleOptionComplex opt, int sc, QWidget widget)
Returns the rectangle containing the specified sc of the given complex cc (with the style specified by opt). The rectangle is defined in screen coordinates.
The opt argument is a pointer to QStyleOptionComplex or one of its subclasses, and can be cast to the appropriate type using the qstyleoption_cast() function. See drawComplexControl for details. The widget is optional and can contain additional information for the function.
subControlRect
in class QCommonStyle
public QRect subElementRect(QStyle.SubElement element, QStyleOption option, QWidget widget)
Returns the sub-area for the given element as described in the provided style option. The returned rectangle is defined in screen coordinates.
The widget argument is optional and can be used to aid determining the area. The QStyleOption object can be cast to the appropriate type using the qstyleoption_cast() function. See the table below for the appropriate option casts:
subElementRect
in class QWindowsStyle
protected void timerEvent(QTimerEvent event)
This event handler can be reimplemented in a subclass to receive timer events for the object.
QTimer provides a higher-level interface to the timer functionality, and also more general information about timers. The timer event is passed in the arg__1 parameter.
timerEvent
in class QWindowsStyle
public void unpolish(QWidget widget)
Uninitialize the given arg__1's appearance.
This function is the counterpart to polish. It is called for every polished widget whenever the style is dynamically changed; the former style has to unpolish its settings before the new style can polish them again.
Note that unpolish will only be called if the widget is destroyed. This can cause problems in some cases, e.g, if you remove a widget from the UI, cache it, and then reinsert it after the style has changed; some of Qt's classes cache their widgets.
unpolish
in class QWindowsStyle
public void unpolish(QApplication app)
Uninitialize the given arg__1.
unpolish
in class QWindowsStyle
public static QPlastiqueStyle fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |