|
|
||||||||||
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.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:
Both active and inactive windows can contain disabled widgets. (Disabled widgets are often called inaccessible or grayed out.)
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.
Nested Class Summary | |
---|---|
static class |
QPalette.ColorGroup
Press link for info on QPalette.ColorGroup |
static class |
QPalette.ColorRole
|
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 | |
---|---|
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 palette. |
|
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 cg, used for the given color cr. |
QBrush |
brush(QPalette.ColorRole cr)
Returns the brush that has been set for the given color cr 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. |
QColor |
color(QPalette.ColorGroup cg,
QPalette.ColorRole cr)
Returns the color in the specified color cg, used for the given color cr. |
QColor |
color(QPalette.ColorRole cr)
Returns the color that has been set for the given color cr 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. |
boolean |
equals(java.lang.Object other)
|
static QPalette |
fromNativePointer(QNativePointer nativePointer)
This function returns the QPalette instance pointed to by nativePointer |
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. one of them was created as a copy of the other and neither was subsequently modified; otherwise returns false. |
boolean |
isEqual(QPalette.ColorGroup cr1,
QPalette.ColorGroup cr2)
Returns true (usually quickly) if color group cr1 is equal to cr2; 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. |
static QNativePointer |
nativePointerArray(QPalette[] array)
This function returns a QNativePointer that is pointing to the specified QPalette array. |
void |
readFrom(QDataStream ds)
Reads a QPalette from ds. |
int |
resolve()
|
void |
resolve(int mask)
|
QPalette |
resolve(QPalette arg__1)
Returns a new QPalette that has attributes copied from arg__1. |
void |
setBrush(QPalette.ColorGroup cg,
QPalette.ColorRole cr,
QBrush brush)
Sets the brush in the specified color cg, used for the given color cr, to brush. |
void |
setBrush(QPalette.ColorRole cr,
QBrush brush)
Sets the brush for the given color cr 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 cg, used for the given color cr, to the specified solid color. |
void |
setColor(QPalette.ColorRole cr,
QColor color)
Sets the color used for the given color cr, 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 cr. |
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 |
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)
Writes thisQPalette to ds. |
Methods inherited from class com.trolltech.qt.QtJambiObject |
---|
dispose, disposed, finalize, reassignNativeResources, tr, tr, tr |
Methods inherited from class com.trolltech.qt.QSignalEmitter |
---|
blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread |
Methods inherited from class java.lang.Object |
---|
clone, 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(QPalette palette)
Constructs a copy of palette.
This constructor is fast thanks to implicit sharing.
public QPalette(QColor button)
Constructs a palette from the button color. The other colors are automatically calculated, based on this color. Window will be the button color as well.
public QPalette(QBrush windowText, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush base, QBrush window)
Constructs a palette. You can pass either brushes, pixmaps or plain colors for windowText, button, light, dark, mid, text, bright_text, base and window.
public QPalette(Qt.GlobalColor button)
Constructs a palette from the button color. The other colors are automatically calculated, based on this color. Window will be the button color as well.
public QPalette()
Constructs a palette object that uses the application's default palette.
public QPalette(QColor button, QColor window)
Constructs a palette from a button color and a window. The other colors are automatically calculated, based on these colors.
Method Detail |
---|
public final QBrush alternateBase()
Returns the alternate base brush of the current color group.
public final QBrush base()
Returns the base brush of the current color group.
public final QBrush brightText()
Returns the bright text foreground brush of the current color group.
public final QBrush brush(QPalette.ColorRole cr)
Returns the brush that has been set for the given color cr in the current ColorGroup.
public final QBrush brush(QPalette.ColorGroup cg, QPalette.ColorRole cr)
Returns the brush in the specified color cg, used for the given color cr.
public final QBrush button()
Returns the button brush of the current color group.
public final QBrush buttonText()
Returns the button text foreground brush of the current color group.
public final long cacheKey()
Returns a number that identifies the contents of this QPalette object. Distinct QPalette objects can have the same key if they refer to the same contents.
The cacheKey will change when the palette is altered.
public final QColor color(QPalette.ColorRole cr)
Returns the color that has been set for the given color cr in the current ColorGroup.
public final QColor color(QPalette.ColorGroup cg, QPalette.ColorRole cr)
Returns the color in the specified color cg, used for the given color cr.
public final QPalette.ColorGroup currentColorGroup()
Returns the palette's current color group.
public final QBrush dark()
Returns the dark brush of the current color group.
public final QBrush highlight()
Returns the highlight brush of the current color group.
public final QBrush highlightedText()
Returns the highlighted text brush of the current color group.
public final 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.
public final boolean isCopyOf(QPalette p)
Returns true if this palette and p are copies of each other, i.e. one of them was created as a copy of the other and neither was subsequently modified; otherwise returns false. This is much stricter than equality.
public final boolean isEqual(QPalette.ColorGroup cr1, QPalette.ColorGroup cr2)
Returns true (usually quickly) if color group cr1 is equal to cr2; otherwise returns false.
public final QBrush light()
Returns the light brush of the current color group.
public final QBrush link()
Returns the unvisited link text brush of the current color group.
public final QBrush linkVisited()
Returns the visited link text brush of the current color group.
public final QBrush mid()
Returns the mid brush of the current color group.
public final QBrush midlight()
Returns the midlight brush of the current color group.
public final void writeTo(QDataStream ds)
public final void readFrom(QDataStream ds)
public final int resolve()
public final QPalette resolve(QPalette arg__1)
Returns a new QPalette that has attributes copied from arg__1.
public final void resolve(int mask)
public final void setBrush(QPalette.ColorGroup cg, QPalette.ColorRole cr, QBrush brush)
Sets the brush in the specified color cg, used for the given color cr, to brush.
public final void setBrush(QPalette.ColorRole cr, QBrush brush)
Sets the brush for the given color cr to the specified brush for all groups in the palette.
public final void setColor(QPalette.ColorGroup cg, QPalette.ColorRole cr, QColor color)
Sets the brush in the specified color cg, used for the given color cr, to the specified solid color.
public final void setColor(QPalette.ColorRole cr, QColor color)
Sets the color used for the given color cr, in all color groups, to the specified solid color.
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)
Sets a the group at cr. You can pass either brushes, pixmaps or plain colors for windowText, button, light, dark, mid, text, bright_text, base and window.
public final void setCurrentColorGroup(QPalette.ColorGroup cg)
Set the palette's current color group to cg.
public final QBrush shadow()
Returns the shadow brush of the current color group.
public final QBrush text()
Returns the text foreground brush of the current color group.
public final QBrush window()
Returns the window (general background) brush of the current color group.
public final QBrush windowText()
Returns the window text (general foreground) brush of the current color group.
public static QPalette fromNativePointer(QNativePointer nativePointer)
nativePointer
- the QNativePointer of which object should be returned.public static QNativePointer nativePointerArray(QPalette[] array)
array
- the array that the returned pointer will point to.
public boolean equals(java.lang.Object other)
equals
in class java.lang.Object
|
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |