Qyoto  4.0.7
Qyoto is a C# language binding for Qt
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Properties
QtGui.QPalette Class Reference

The QPalette class contains color groups for each widget state. More...

Inheritance diagram for QtGui.QPalette:
Collaboration diagram for QtGui.QPalette:

Public Types

enum  ColorGroup {
  Active = 0, All = 5, Current = 4, Disabled = 1,
  Inactive = 2, NColorGroups = 3, Normal = 0
}
 
enum  ColorRole {
  AlternateBase = 16, Background = 10, Base = 9, BrightText = 7,
  Button = 1, ButtonText = 8, Dark = 4, Foreground = 0,
  Highlight = 12, HighlightedText = 13, Light = 2, Link = 14,
  LinkVisited = 15, Mid = 5, Midlight = 3, NColorRoles = 20,
  NoRole = 17, Shadow = 11, Text = 6, ToolTipBase = 18,
  ToolTipText = 19, Window = 10, WindowText = 0
}
  More...
 

Public Member Functions

override bool Equals (object o)
 
override int GetHashCode ()
 
 QPalette ()
  More...
 
 QPalette (QColor button)
  More...
 
 QPalette (QPalette palette)
  More...
 
 QPalette (QColor button, QColor window)
  More...
 
 QPalette (QColor windowText, QColor window, QColor light, QColor dark, QColor mid, QColor text, QColor @base)
  More...
 
 QPalette (QBrush windowText, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush @base, QBrush window)
  More...
 
 QPalette (Qt.GlobalColor button)
  More...
 
virtual void CreateProxy ()
 
new QBrush Brush (QPalette.ColorRole cr)
  More...
 
new QBrush Brush (QPalette.ColorGroup cg, QPalette.ColorRole cr)
  More...
 
new QColor Color (QPalette.ColorRole cr)
  More...
 
new QColor Color (QPalette.ColorGroup cg, QPalette.ColorRole cr)
  More...
 
new bool IsBrushSet (QPalette.ColorGroup cg, QPalette.ColorRole cr)
  More...
 
new bool IsCopyOf (QPalette p)
  More...
 
new bool IsEqual (QPalette.ColorGroup cr1, QPalette.ColorGroup cr2)
  More...
 
new uint Resolve ()
 
new QPalette Resolve (QPalette other)
  More...
 
new void Resolve (uint mask)
 
new void SetBrush (QPalette.ColorRole cr, QBrush brush)
  More...
 
new void SetBrush (QPalette.ColorGroup cg, QPalette.ColorRole cr, QBrush brush)
  More...
 
new void SetColor (QPalette.ColorRole cr, QColor color)
  More...
 
new void SetColor (QPalette.ColorGroup cg, QPalette.ColorRole cr, QColor color)
  More...
 
new void SetColorGroup (QPalette.ColorGroup cr, QBrush windowText, QBrush button, QBrush light, QBrush dark, QBrush mid, QBrush text, QBrush bright_text, QBrush @base, QBrush window)
  More...
 
new void Dispose ()
 

Static Public Member Functions

static bool operator!= (QPalette one, QPalette p)
  More...
 
static bool operator== (QPalette one, QPalette p)
  More...
 

Protected Member Functions

 QPalette (System.Type dummy)
 

Protected Attributes

SmokeInvocation interceptor
 

Properties

QPalette.ColorGroup CurrentColorGroup [get, set]
  More...
 
QBrush AlternateBase [get]
  More...
 
QBrush Background [get]
  More...
 
QBrush Base [get]
  More...
 
QBrush BrightText [get]
  More...
 
QBrush Button [get]
  More...
 
QBrush ButtonText [get]
  More...
 
long CacheKey [get]
  More...
 
QBrush Dark [get]
  More...
 
QBrush Foreground [get]
  More...
 
QBrush Highlight [get]
  More...
 
QBrush HighlightedText [get]
  More...
 
QBrush Light [get]
  More...
 
QBrush Link [get]
  More...
 
QBrush LinkVisited [get]
  More...
 
QBrush Mid [get]
  More...
 
QBrush Midlight [get]
  More...
 
int SerialNumber [get]
  More...
 
QBrush Shadow [get]
  More...
 
QBrush Text [get]
  More...
 
QBrush ToolTipBase [get]
  More...
 
QBrush ToolTipText [get]
  More...
 
QBrush Window [get]
  More...
 
QBrush WindowText [get]
  More...
 
virtual System.IntPtr SmokeObject [get, set]
 
static new QMetaObject StaticMetaObject [get]
 

Detailed Description

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:

The Active group is used for the window that has keyboard focus.

The Inactive group is used for other windows.

The Disabled group is used for widgets (not windows) that are disabled for some reason.

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.

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.

See also QApplication::setPalette(), QWidget::setPalette(), and QColor.

Member Enumeration Documentation

Enumerator
Active 
All 
Current 
Disabled 
Inactive 
NColorGroups 
Normal 

Synonym for Active

The ColorRole enum defines the different symbolic color roles used in current GUIs.

The central roles are:

There are some color roles used mostly for 3D bevel and shadow effects. All of these are normally derived from Window, and used in ways that depend on that relationship. For example, buttons depend on it to make the bevels look attractive, and Motif scroll bars depend on Mid to be slightly different from Window.

Selected (marked) items have two roles:

There are two color roles related to hyperlinks:

Note that we do not use the Link and LinkVisited roles when rendering rich text in Qt, and that we recommend that you use CSS and the QTextDocument::setDefaultStyleSheet() function to alter the appearance of links. For example:

QTextBrowser browser;

QColor linkColor(Qt::red);

QString sheet = QString::fromLatin1("a { text-decoration: underline; color: %1 }").arg(linkColor.name());

browser.document()->setDefaultStyleSheet(sheet);

Enumerator
AlternateBase 

Used as the alternate background color in views with alternating row colors (see QAbstractItemView::setAlternatingRowColors()).

Background 

This value is obsolete. Use Window instead.

Base 

Used mostly as the background color for text entry widgets, but can also be used for other painting - such as the background of combobox drop down lists and toolbar handles. It is usually white or another light color.

BrightText 

A text color that is very different from WindowText, and contrasts well with e.g. Dark. Typically used for text that needs to be drawn where Text or WindowText would give poor contrast, such as on pressed push buttons. Note that text colors can be used for things other than just words; text colors are usually used for text, but it's quite common to use the text color roles for lines, icons, etc.

Button 

The general button background color. This background can be different from Window as some styles require a different background color for buttons.

ButtonText 

A foreground color used with the Button color.

Dark 

Darker than Button.

Foreground 

This value is obsolete. Use WindowText instead.

Highlight 

A color to indicate a selected item or the current item. By default, the highlight color is Qt::darkBlue.

HighlightedText 

A text color that contrasts with Highlight. By default, the highlighted text color is Qt::white.

Light 

Lighter than Button color.

Link 

A text color used for unvisited hyperlinks. By default, the link color is Qt::blue.

LinkVisited 

A text color used for already visited hyperlinks. By default, the linkvisited color is Qt::magenta.

Mid 

Between Button and Dark.

Midlight 

Between Button and Light.

NColorRoles 
NoRole 

No role; this special role is often used to indicate that a role has not been assigned.

Shadow 

A very dark color. By default, the shadow color is Qt::black.

Text 

The foreground color used with Base. This is usually the same as the WindowText, in which case it must provide good contrast with Window and Base.

ToolTipBase 

Used as the background color for QToolTip and QWhatsThis. Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.

ToolTipText 

Used as the foreground color for QToolTip and QWhatsThis. Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.

Window 

A general background color.

WindowText 

A general foreground color.

Constructor & Destructor Documentation

QtGui.QPalette.QPalette ( System.Type  dummy)
protected
QtGui.QPalette.QPalette ( )

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

See also QApplication::setPalette() and QApplication::palette().

Here is the call graph for this function:

Here is the caller graph for this function:

QtGui.QPalette.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.

Here is the call graph for this function:

QtGui.QPalette.QPalette ( QPalette  palette)

Constructs a copy of p.

This constructor is fast thanks to implicit sharing.

Here is the call graph for this function:

QtGui.QPalette.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.

Here is the call graph for this function:

QtGui.QPalette.QPalette ( QColor  windowText,
QColor  window,
QColor  light,
QColor  dark,
QColor  mid,
QColor  text,
QColor base 
)

Constructs a palette with the specified windowText, window, light, dark, mid, text, and base colors. The button color will be set to the window color.

Here is the call graph for this function:

QtGui.QPalette.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.

Here is the call graph for this function:

QtGui.QPalette.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.

Here is the call graph for this function:

Member Function Documentation

new QBrush QtGui.QPalette.Brush ( QPalette.ColorRole  cr)

This is an overloaded function.

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

See also color(), setBrush(), and ColorRole.

new QBrush QtGui.QPalette.Brush ( QPalette.ColorGroup  cg,
QPalette.ColorRole  cr 
)

Returns the brush in the specified color group, used for the given color role.

See also color(), setBrush(), and ColorRole.

new QColor QtGui.QPalette.Color ( QPalette.ColorRole  cr)

This is an overloaded function.

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

See also brush() and ColorRole.

new QColor QtGui.QPalette.Color ( QPalette.ColorGroup  cg,
QPalette.ColorRole  cr 
)

Returns the color in the specified color group, used for the given color role.

See also brush(), setColor(), and ColorRole.

virtual void QtGui.QPalette.CreateProxy ( )
virtual

Here is the caller graph for this function:

new void QtGui.QPalette.Dispose ( )
override bool QtGui.QPalette.Equals ( object  o)

Here is the call graph for this function:

override int QtGui.QPalette.GetHashCode ( )
new bool QtGui.QPalette.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.

This function was introduced in Qt 4.2.

See also setBrush().

new bool QtGui.QPalette.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=() and operator==().

new bool QtGui.QPalette.IsEqual ( QPalette.ColorGroup  cr1,
QPalette.ColorGroup  cr2 
)

Returns true (usually quickly) if color group cg1 is equal to cg2; otherwise returns false.

static bool QtGui.QPalette.operator!= ( QPalette  one,
QPalette  p 
)
static

Returns true (slowly) if this palette is different from p; otherwise returns false (usually quickly).

Note: The current ColorGroup is not taken into account when comparing palettes

See also operator==().

static bool QtGui.QPalette.operator== ( QPalette  one,
QPalette  p 
)
static

Returns true (usually quickly) if this palette is equal to p; otherwise returns false (slowly).

Note: The current ColorGroup is not taken into account when comparing palettes

See also operator!=().

new uint QtGui.QPalette.Resolve ( )
new QPalette QtGui.QPalette.Resolve ( QPalette  other)

Returns a new QPalette that has attributes copied from other.

new void QtGui.QPalette.Resolve ( uint  mask)
new void QtGui.QPalette.SetBrush ( QPalette.ColorRole  cr,
QBrush  brush 
)

Sets the brush for the given color role to the specified brush for all groups in the palette.

See also brush(), setColor(), and ColorRole.

new void QtGui.QPalette.SetBrush ( QPalette.ColorGroup  cg,
QPalette.ColorRole  cr,
QBrush  brush 
)

This is an overloaded function.

Sets the brush in the specified color group, used for the given color role, to brush.

See also brush(), setColor(), and ColorRole.

new void QtGui.QPalette.SetColor ( QPalette.ColorRole  cr,
QColor  color 
)

This is an overloaded function.

Sets the color used for the given color role, in all color groups, to the specified solid color.

See also brush(), setColor(), and ColorRole.

new void QtGui.QPalette.SetColor ( QPalette.ColorGroup  cg,
QPalette.ColorRole  cr,
QColor  color 
)

Sets the color in the specified color group, used for the given color role, to the specified solid color.

See also setBrush(), color(), and ColorRole.

new void QtGui.QPalette.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. You can pass either brushes, pixmaps or plain colors for windowText, button, light, dark, mid, text, bright_text, base and window.

See also QBrush.

Member Data Documentation

SmokeInvocation QtGui.QPalette.interceptor
protected

Property Documentation

QBrush QtGui.QPalette.AlternateBase
get

Returns the alternate base brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.Background
get

Use window() instead.

QBrush QtGui.QPalette.Base
get

Returns the base brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.BrightText
get

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

See also ColorRole and brush().

QBrush QtGui.QPalette.Button
get

Returns the button brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.ButtonText
get

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

See also ColorRole and brush().

long QtGui.QPalette.CacheKey
get

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.

QPalette.ColorGroup QtGui.QPalette.CurrentColorGroup
getset

Returns the palette's current color group.

Set the palette's current color group to cg.

QBrush QtGui.QPalette.Dark
get

Returns the dark brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.Foreground
get

Use windowText() instead.

QBrush QtGui.QPalette.Highlight
get

Returns the highlight brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.HighlightedText
get

Returns the highlighted text brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.Light
get

Returns the light brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.Link
get

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

See also ColorRole and brush().

QBrush QtGui.QPalette.LinkVisited
get

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

See also ColorRole and brush().

QBrush QtGui.QPalette.Mid
get

Returns the mid brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.Midlight
get

Returns the midlight brush of the current color group.

See also ColorRole and brush().

int QtGui.QPalette.SerialNumber
get

Returns a number that identifies the contents of this QPalette object. Distinct QPalette objects can only have the same serial number if they refer to the same contents (but they don't have to). Also, the serial number of a QPalette may change during the lifetime of the object.

Use cacheKey() instead.

Warning: The serial number doesn't necessarily change when the palette is altered. This means that it may be dangerous to use it as a cache key.

See also operator==().

QBrush QtGui.QPalette.Shadow
get

Returns the shadow brush of the current color group.

See also ColorRole and brush().

virtual System.IntPtr QtGui.QPalette.SmokeObject
getset
new QMetaObject QtGui.QPalette.StaticMetaObject
staticget
QBrush QtGui.QPalette.Text
get

Returns the text foreground brush of the current color group.

See also ColorRole and brush().

QBrush QtGui.QPalette.ToolTipBase
get

Returns the tool tip base brush of the current color group. This brush is used by QToolTip and QWhatsThis.

Note: Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.

This function was introduced in Qt 4.4.

See also ColorRole and brush().

QBrush QtGui.QPalette.ToolTipText
get

Returns the tool tip text brush of the current color group. This brush is used by QToolTip and QWhatsThis.

Note: Tool tips use the Inactive color group of QPalette, because tool tips are not active windows.

This function was introduced in Qt 4.4.

See also ColorRole and brush().

QBrush QtGui.QPalette.Window
get

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

See also ColorRole and brush().

QBrush QtGui.QPalette.WindowText
get

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

See also ColorRole and brush().