Qt Jambi Home

com.trolltech.qt.gui
Class QPalette

java.lang.Object
  extended by com.trolltech.qt.QSignalEmitter
      extended by com.trolltech.qt.QtJambiObject
          extended by com.trolltech.qt.gui.QPalette
All Implemented Interfaces:
QtJambiInterface

public class QPalette
extends QtJambiObject

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.

See Also:
QApplication::setPalette, QWidget::setPalette, QColor

Nested Class Summary
static class QPalette.ColorGroup
          Press link for info on QPalette.ColorGroup
static class QPalette.ColorRole
          

Color Roles

 
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

QPalette

public QPalette(QPalette palette)

Constructs a copy of palette.

This constructor is fast thanks to implicit sharing.


QPalette

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.


QPalette

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.

See Also:
QBrush

QPalette

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.


QPalette

public QPalette()

Constructs a palette object that uses the application's default palette.

See Also:
QApplication::setPalette, QApplication::palette

QPalette

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

alternateBase

public final QBrush alternateBase()

Returns the alternate base brush of the current color group.

See Also:
ColorRole, brush

base

public final QBrush base()

Returns the base brush of the current color group.

See Also:
ColorRole, brush

brightText

public final QBrush brightText()

Returns the bright text foreground brush of the current color group.

See Also:
ColorRole, brush

brush

public final QBrush brush(QPalette.ColorRole cr)

Returns the brush that has been set for the given color cr in the current ColorGroup.

See Also:
color, setBrush, ColorRole

brush

public final QBrush brush(QPalette.ColorGroup cg,
                          QPalette.ColorRole cr)

Returns the brush in the specified color cg, used for the given color cr.

See Also:
color, setBrush, ColorRole

button

public final QBrush button()

Returns the button brush of the current color group.

See Also:
ColorRole, brush

buttonText

public final QBrush buttonText()

Returns the button text foreground brush of the current color group.

See Also:
ColorRole, brush

cacheKey

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.


color

public final QColor color(QPalette.ColorRole cr)

Returns the color that has been set for the given color cr in the current ColorGroup.

See Also:
brush, ColorRole

color

public final QColor color(QPalette.ColorGroup cg,
                          QPalette.ColorRole cr)

Returns the color in the specified color cg, used for the given color cr.

See Also:
brush, setColor, ColorRole

currentColorGroup

public final QPalette.ColorGroup currentColorGroup()

Returns the palette's current color group.

See Also:
setCurrentColorGroup

dark

public final QBrush dark()

Returns the dark brush of the current color group.

See Also:
ColorRole, brush

highlight

public final QBrush highlight()

Returns the highlight brush of the current color group.

See Also:
ColorRole, brush

highlightedText

public final QBrush highlightedText()

Returns the highlighted text brush of the current color group.

See Also:
ColorRole, brush

isBrushSet

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.

See Also:
setBrush

isCopyOf

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.

See Also:
operator=, operator==

isEqual

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.


light

public final QBrush light()

Returns the light brush of the current color group.

See Also:
ColorRole, brush

link

public final QBrush link()

Returns the unvisited link text brush of the current color group.

See Also:
ColorRole, brush

linkVisited

public final QBrush linkVisited()

Returns the visited link text brush of the current color group.

See Also:
ColorRole, brush

mid

public final QBrush mid()

Returns the mid brush of the current color group.

See Also:
ColorRole, brush

midlight

public final QBrush midlight()

Returns the midlight brush of the current color group.

See Also:
ColorRole, brush

writeTo

public final void writeTo(QDataStream ds)
Writes thisQPalette to ds.


readFrom

public final void readFrom(QDataStream ds)
Reads a QPalette from ds.


resolve

public final int resolve()


resolve

public final QPalette resolve(QPalette arg__1)

Returns a new QPalette that has attributes copied from arg__1.


resolve

public final void resolve(int mask)


setBrush

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.

See Also:
brush, setColor, ColorRole

setBrush

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.

See Also:
brush, setColor, ColorRole

setColor

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.

See Also:
setBrush, color, ColorRole

setColor

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.

See Also:
color, brush, setColor, ColorRole

setColorGroup

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.

See Also:
QBrush

setCurrentColorGroup

public final void setCurrentColorGroup(QPalette.ColorGroup cg)

Set the palette's current color group to cg.

See Also:
currentColorGroup

shadow

public final QBrush shadow()

Returns the shadow brush of the current color group.

See Also:
ColorRole, brush

text

public final QBrush text()

Returns the text foreground brush of the current color group.

See Also:
ColorRole, brush

window

public final QBrush window()

Returns the window (general background) brush of the current color group.

See Also:
ColorRole, brush

windowText

public final QBrush windowText()

Returns the window text (general foreground) brush of the current color group.

See Also:
ColorRole, brush

fromNativePointer

public static QPalette fromNativePointer(QNativePointer nativePointer)
This function returns the QPalette instance pointed to by nativePointer

Parameters:
nativePointer - the QNativePointer of which object should be returned.

nativePointerArray

public static QNativePointer nativePointerArray(QPalette[] array)
This function returns a QNativePointer that is pointing to the specified QPalette array.

Parameters:
array - the array that the returned pointer will point to.
Returns:
a QNativePointer that is pointing to the specified array.

equals

public boolean equals(java.lang.Object other)

Overrides:
equals in class java.lang.Object

Qt Jambi Home