|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.trolltech.qt.internal.QSignalEmitterInternal
com.trolltech.qt.QSignalEmitter
com.trolltech.qt.QtJambiObject
com.trolltech.qt.gui.QPalette
public class QPalette
The QPalette class contains color groups for each widget state. A palette consists of three color groups: Active, Disabled, and Inactive. All widgets in Qt contain a palette and use their palette to draw themselves. This makes the user interface easily configurable and easier to keep consistent.
If you create a new widget we strongly recommend that you use the colors in the palette rather than hard-coding specific colors.
The color groups:
In most styles, Active and Inactive look the same.
Colors and brushes can be set for particular roles in any of a palette's color groups with setColor()
and setBrush()
. A color group contains a group of colors used by widgets for drawing themselves. We recommend that widgets use color group roles from the palette such as "foreground" and "base" rather than literal colors like "red" or "turquoise". The color roles are enumerated and defined in the ColorRole
documentation.
We strongly recommend that you use the default palette of the current style (returned by QApplication::palette()
) and modify that as necessary. This is done by Qt's widgets when they are drawn.
To modify a color group you call the functions setColor()
and setBrush()
, depending on whether you want a pure color or a pixmap pattern.
There are also corresponding color()
and brush()
getters, and a commonly used convenience function to get the ColorRole
for the current ColorGroup
: window()
, windowText()
, base()
, etc.
You can copy a palette using the copy constructor and test to see if two palettes are identical using isCopyOf()
.
QPalette is optimized by the use of implicit sharing, so it is very efficient to pass QPalette objects as arguments.
Warning: Some styles do not use the palette for all drawing, for instance, if they make use of native theme engines. This is the case for both the Windows XP, Windows Vista, and the Mac OS X styles.
QApplication::setPalette()
, QWidget::setPalette()
, and QColor
.
Nested Class Summary | |
---|---|
static class |
QPalette.ColorGroup
|
static class |
QPalette.ColorRole
See the description for details. |
Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter |
---|
QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9 |
Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal |
Field Summary |
---|
Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
currentSender |
Constructor Summary | |
---|---|
QPalette()
Constructs a palette object that uses the application's default palette. |
|
QPalette(QBrush windowText,
QBrush button,
QBrush light,
QBrush dark,
QBrush mid,
QBrush text,
QBrush bright_text,
QBrush base,
QBrush window)
Constructs a palette. |
|
QPalette(QColor button)
Constructs a palette from the button color. |
|
QPalette(QColor button,
QColor window)
Constructs a palette from a button color and a window. |
|
QPalette(QPalette palette)
Constructs a copy of p. |
|
QPalette(Qt.GlobalColor button)
Constructs a palette from the button color. |
Method Summary | |
---|---|
QBrush |
alternateBase()
Returns the alternate base brush of the current color group. |
QBrush |
base()
Returns the base brush of the current color group. |
QBrush |
brightText()
Returns the bright text foreground brush of the current color group. |
QBrush |
brush(QPalette.ColorGroup cg,
QPalette.ColorRole cr)
Returns the brush in the specified color group, used for the given color role. |
QBrush |
brush(QPalette.ColorRole cr)
Returns the brush that has been set for the given color role in the current ColorGroup . |
QBrush |
button()
Returns the button brush of the current color group. |
QBrush |
buttonText()
Returns the button text foreground brush of the current color group. |
long |
cacheKey()
Returns a number that identifies the contents of this QPalette object. |
QPalette |
clone()
This method is reimplemented for internal reasons |
QColor |
color(QPalette.ColorGroup cg,
QPalette.ColorRole cr)
Returns the color in the specified color group, used for the given color role. |
QColor |
color(QPalette.ColorRole cr)
Returns the color that has been set for the given color role in the current ColorGroup . |
QPalette.ColorGroup |
currentColorGroup()
Returns the palette's current color group. |
QBrush |
dark()
Returns the dark brush of the current color group. |
QBrush |
highlight()
Returns the highlight brush of the current color group. |
QBrush |
highlightedText()
Returns the highlighted text brush of the current color group. |
boolean |
isBrushSet(QPalette.ColorGroup cg,
QPalette.ColorRole cr)
Returns true if the ColorGroup cg and ColorRole cr has been set previously on this palette; otherwise returns false. |
boolean |
isCopyOf(QPalette p)
Returns true if this palette and p are copies of each other, i.e. |
boolean |
isEqual(QPalette.ColorGroup cr1,
QPalette.ColorGroup cr2)
Returns true (usually quickly) if color group cg1 is equal to cg2; otherwise returns false. |
QBrush |
light()
Returns the light brush of the current color group. |
QBrush |
link()
Returns the unvisited link text brush of the current color group. |
QBrush |
linkVisited()
Returns the visited link text brush of the current color group. |
QBrush |
mid()
Returns the mid brush of the current color group. |
QBrush |
midlight()
Returns the midlight brush of the current color group. |
void |
readFrom(QDataStream ds)
|
QPalette |
resolve(QPalette arg__1)
Returns a new QPalette that has attributes copied from other. |
void |
setBrush(QPalette.ColorGroup cg,
QPalette.ColorRole cr,
QBrush brush)
Sets the brush in the specified color group, used for the given color role, to brush. |
void |
setBrush(QPalette.ColorRole cr,
QBrush brush)
Sets the brush for the given color role to the specified brush for all groups in the palette. |
void |
setColor(QPalette.ColorGroup cg,
QPalette.ColorRole cr,
QColor color)
Sets the brush in the specified color group, used for the given color role, to the specified solid color. |
void |
setColor(QPalette.ColorRole cr,
QColor color)
Sets the color used for the given color role, in all color groups, to the specified solid color. |
void |
setColorGroup(QPalette.ColorGroup cr,
QBrush windowText,
QBrush button,
QBrush light,
QBrush dark,
QBrush mid,
QBrush text,
QBrush bright_text,
QBrush base,
QBrush window)
Sets a the group at cg. |
void |
setCurrentColorGroup(QPalette.ColorGroup cg)
Set the palette's current color group to cg. |
QBrush |
shadow()
Returns the shadow brush of the current color group. |
QBrush |
text()
Returns the text foreground brush of the current color group. |
QBrush |
toolTipBase()
Returns the tool tip base brush of the current color group. |
QBrush |
toolTipText()
Returns the tool tip text brush of the current color group. |
QBrush |
window()
Returns the window (general background) brush of the current color group. |
QBrush |
windowText()
Returns the window text (general foreground) brush of the current color group. |
void |
writeTo(QDataStream ds)
|
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal |
---|
__qt_signalInitialization |
Methods inherited from class java.lang.Object |
---|
getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.trolltech.qt.QtJambiInterface |
---|
disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership |
Constructor Detail |
---|
public QPalette()
QApplication::setPalette()
, and QApplication::palette()
.
public QPalette(Qt.GlobalColor button)
public QPalette(QBrush windowText, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush window)
QBrush
.
public QPalette(QColor button)
public QPalette(QColor button, QColor window)
public QPalette(QPalette palette)
This constructor is fast thanks to implicit sharing.
Method Detail |
---|
public final QBrush alternateBase()
ColorRole
, and brush()
.
public final QBrush base()
ColorRole
, and brush()
.
public final QBrush brightText()
ColorRole
, and brush()
.
public final QBrush brush(QPalette.ColorGroup cg, QPalette.ColorRole cr)
color()
, setBrush()
, and ColorRole
.
public final QBrush brush(QPalette.ColorRole cr)
ColorGroup
. color()
, setBrush()
, and ColorRole
.
public final QBrush button()
ColorRole
, and brush()
.
public final QBrush buttonText()
ColorRole
, and brush()
.
public final long cacheKey()
The cacheKey()
will change when the palette is altered.
public final QColor color(QPalette.ColorGroup cg, QPalette.ColorRole cr)
brush()
, setColor()
, and ColorRole
.
public final QColor color(QPalette.ColorRole cr)
ColorGroup
. brush()
, and ColorRole
.
public final QPalette.ColorGroup currentColorGroup()
setCurrentColorGroup()
.
public final QBrush dark()
ColorRole
, and brush()
.
public final QBrush highlight()
ColorRole
, and brush()
.
public final QBrush highlightedText()
ColorRole
, and brush()
.
public final boolean isBrushSet(QPalette.ColorGroup cg, QPalette.ColorRole cr)
ColorGroup
cg and ColorRole
cr has been set previously on this palette; otherwise returns false. setBrush()
.
public final boolean isCopyOf(QPalette p)
public final boolean isEqual(QPalette.ColorGroup cr1, QPalette.ColorGroup cr2)
public final QBrush light()
ColorRole
, and brush()
.
public final QBrush link()
ColorRole
, and brush()
.
public final QBrush linkVisited()
ColorRole
, and brush()
.
public final QBrush mid()
ColorRole
, and brush()
.
public final QBrush midlight()
ColorRole
, and brush()
.
public final void writeTo(QDataStream ds)
public final void readFrom(QDataStream ds)
public final QPalette resolve(QPalette arg__1)
public final void setBrush(QPalette.ColorGroup cg, QPalette.ColorRole cr, QBrush brush)
brush()
, setColor()
, and ColorRole
.
public final void setBrush(QPalette.ColorRole cr, QBrush brush)
brush()
, setColor()
, and ColorRole
.
public final void setColor(QPalette.ColorGroup cg, QPalette.ColorRole cr, QColor color)
setBrush()
, color()
, and ColorRole
.
public final void setColor(QPalette.ColorRole cr, QColor color)
brush()
, setColor()
, and ColorRole
.
public final void setColorGroup(QPalette.ColorGroup cr, QBrush windowText, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush window)
QBrush
.
public final void setCurrentColorGroup(QPalette.ColorGroup cg)
currentColorGroup()
.
public final QBrush shadow()
ColorRole
, and brush()
.
public final QBrush text()
ColorRole
, and brush()
.
public final QBrush toolTipBase()
QToolTip
and QWhatsThis
. Note: Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.
ColorRole
, and brush()
.
public final QBrush toolTipText()
QToolTip
and QWhatsThis
. Note: Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.
ColorRole
, and brush()
.
public final QBrush window()
ColorRole
, and brush()
.
public final QBrush windowText()
ColorRole
, and brush()
.
public QPalette clone()
clone
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |