#include <qpalette.h>
Collaboration diagram for QPalette:

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 a system-supplied color group and modify that as necessary.
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: background(), foreground(), 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.
Definition at line 41 of file qpalette.h.
Public Types | |
| enum | ColorGroup |
| enum | ColorRole |
Public Member Functions | |
| QPalette () | |
| QPalette (const QColor &button) | |
| QPalette (Qt::GlobalColor button) | |
| QPalette (const QColor &button, const QColor &window) | |
| QPalette (const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &window) | |
| QPalette (const QColor &windowText, const QColor &window, const QColor &light, const QColor &dark, const QColor &mid, const QColor &text, const QColor &base) | |
| QPalette (const QPalette &palette) | |
| ~QPalette () | |
| QPalette & | operator= (const QPalette &palette) |
| operator QVariant () const | |
| ColorGroup | currentColorGroup () const |
| void | setCurrentColorGroup (ColorGroup cg) |
| const QColor & | color (ColorGroup cg, ColorRole cr) const |
| const QBrush & | brush (ColorGroup cg, ColorRole cr) const |
| void | setColor (ColorGroup cg, ColorRole cr, const QColor &color) |
| void | setColor (ColorRole cr, const QColor &color) |
| void | setBrush (ColorRole cr, const QBrush &brush) |
| bool | isBrushSet (ColorGroup cg, ColorRole cr) const |
| void | setBrush (ColorGroup cg, ColorRole cr, const QBrush &brush) |
| void | setColorGroup (ColorGroup cr, const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &window) |
| bool | isEqual (ColorGroup cr1, ColorGroup cr2) const |
| const QColor & | color (ColorRole cr) const |
| const QBrush & | brush (ColorRole cr) const |
| const QBrush & | foreground () const |
| const QBrush & | windowText () const |
| const QBrush & | button () const |
| const QBrush & | light () const |
| const QBrush & | dark () const |
| const QBrush & | mid () const |
| const QBrush & | text () const |
| const QBrush & | base () const |
| const QBrush & | alternateBase () const |
| const QBrush & | background () const |
| const QBrush & | window () const |
| const QBrush & | midlight () const |
| const QBrush & | brightText () const |
| const QBrush & | buttonText () const |
| const QBrush & | shadow () const |
| const QBrush & | highlight () const |
| const QBrush & | highlightedText () const |
| const QBrush & | link () const |
| const QBrush & | linkVisited () const |
| bool | operator== (const QPalette &p) const |
| bool | operator!= (const QPalette &p) const |
| bool | isCopyOf (const QPalette &p) const |
| int | serialNumber () const |
| QPalette | resolve (const QPalette &) const |
| uint | resolve () const |
| void | resolve (uint mask) |
Private Member Functions | |
| void | setColorGroup (ColorGroup cr, const QBrush &windowText, const QBrush &button, const QBrush &light, const QBrush &dark, const QBrush &mid, const QBrush &text, const QBrush &bright_text, const QBrush &base, const QBrush &alternate_base, const QBrush &window, const QBrush &midlight, const QBrush &button_text, const QBrush &shadow, const QBrush &highlight, const QBrush &highlighted_text, const QBrush &link, const QBrush &link_visited) |
| void | init () |
| void | detach () |
Private Attributes | |
| QPalettePrivate * | d |
| uint | current_group: 4 |
| uint | resolve_mask: 28 |
Friends | |
| Q_GUI_EXPORT QDataStream & | operator<< (QDataStream &s, const QPalette &p) |
Related Functions | |
| (Note that these are not member functions.) | |
| QDataStream & | operator>> (QDataStream &s, QPalette &p) |
| enum QPalette::ColorGroup |
Disabled Active Inactive Normal synonym for Active
All NColorGroups Current
Definition at line 64 of file qpalette.h.
| enum QPalette::ColorRole |
palette.png Color Roles
The ColorRole enum defines the different symbolic color roles used in current GUIs.
The central roles are:
Window A general background color.
Background This value is obsolete. Use Window instead.
WindowText A general foreground color.
Foreground This value is obsolete. Use WindowText instead.
Base Used as the background color for text entry widgets; usually white or another light color.
AlternateBase Used as the alternate background color in views with alternating row colors (see QAbstractItemView::setAlternatingRowColors()).
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.
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.
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.
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.
Light Lighter than Button color.
Midlight Between Button and Light.
Dark Darker than Button.
Mid Between Button and Dark.
Shadow A very dark color. By default, the shadow color is Qt::black.
Selected (marked) items have two roles:
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.
There are two color roles related to hyperlinks:
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.
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:
doc/src/snippets/textdocument-css/main.cpp QTextBrowser browser.document
NColorRoles NoRole
Definition at line 65 of file qpalette.h.
00065 { WindowText, Button, Light, Midlight, Dark, Mid, 00066 Text, BrightText, ButtonText, Base, Window, Shadow, 00067 Highlight, HighlightedText, 00068 Link, LinkVisited, // ### Qt 5: remove 00069 AlternateBase, NoRole, NColorRoles = NoRole, 00070 Foreground = WindowText, Background = Window // ### Qt 5: remove 00071 };
| QPalette::QPalette | ( | ) |
Constructs a palette object that uses the application's default palette.
Definition at line 509 of file qpalette.cpp.
References d, QPalettePrivate::ref, and QBasicAtomic::ref().
00510 : d(QApplication::palette().d), 00511 current_group(Active), 00512 resolve_mask(0) 00513 { 00514 d->ref.ref(); 00515 }
Here is the call graph for this function:

| QPalette::QPalette | ( | const 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.
Definition at line 549 of file qpalette.cpp.
References button(), init(), and qt_palette_from_color().
00550 { 00551 init(); 00552 qt_palette_from_color(*this, button); 00553 }
Here is the call graph for this function:

| 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.
Definition at line 560 of file qpalette.cpp.
References init(), and qt_palette_from_color().
00561 { 00562 init(); 00563 qt_palette_from_color(*this, button); 00564 }
Here is the call graph for this function:

Constructs a palette from a button color and a window. The other colors are automatically calculated, based on these colors.
Definition at line 606 of file qpalette.cpp.
References Active, Qt::black, button(), Qt::darkGray, Disabled, QColor::getHsv(), h, Inactive, init(), s, setColorGroup(), Qt::white, and window().
00607 { 00608 init(); 00609 QColor bg = window, btn = button, fg, base, disfg; 00610 int h, s, v; 00611 bg.getHsv(&h, &s, &v); 00612 if(v > 128) { 00613 fg = Qt::black; 00614 base = Qt::white; 00615 disfg = Qt::darkGray; 00616 } else { 00617 fg = Qt::white; 00618 base = Qt::black; 00619 disfg = Qt::darkGray; 00620 } 00621 //inactive and active are identical 00622 setColorGroup(Inactive, QBrush(fg), QBrush(btn), QBrush(btn.light(150)), QBrush(btn.dark()), 00623 QBrush(btn.dark(150)), QBrush(fg), QBrush(Qt::white), QBrush(base), 00624 QBrush(bg)); 00625 setColorGroup(Active, QBrush(fg), QBrush(btn), QBrush(btn.light(150)), QBrush(btn.dark()), 00626 QBrush(btn.dark(150)), QBrush(fg), QBrush(Qt::white), QBrush(base), 00627 QBrush(bg)); 00628 setColorGroup(Disabled, QBrush(disfg), QBrush(btn), QBrush(btn.light(150)), 00629 QBrush(btn.dark()), QBrush(btn.dark(150)), QBrush(disfg), 00630 QBrush(Qt::white), QBrush(base), QBrush(bg)); 00631 }
Here is the call graph for this function:

| QPalette::QPalette | ( | const QBrush & | windowText, | |
| const QBrush & | button, | |||
| const QBrush & | light, | |||
| const QBrush & | dark, | |||
| const QBrush & | mid, | |||
| const QBrush & | text, | |||
| const QBrush & | bright_text, | |||
| const QBrush & | base, | |||
| const 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.
Definition at line 573 of file qpalette.cpp.
References All, base(), button(), dark(), init(), light(), mid(), setColorGroup(), text(), window(), and windowText().
00578 { 00579 init(); 00580 setColorGroup(All, windowText, button, light, dark, mid, text, bright_text, 00581 base, window); 00582 }
Here is the call graph for this function:

| QPalette::QPalette | ( | const QColor & | windowText, | |
| const QColor & | window, | |||
| const QColor & | light, | |||
| const QColor & | dark, | |||
| const QColor & | mid, | |||
| const QColor & | text, | |||
| const 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.
Definition at line 591 of file qpalette.cpp.
References All, base(), dark(), init(), light(), mid(), setColorGroup(), text(), window(), and windowText().
00594 { 00595 init(); 00596 setColorGroup(All, QBrush(windowText), QBrush(window), QBrush(light), 00597 QBrush(dark), QBrush(mid), QBrush(text), QBrush(light), 00598 QBrush(base), QBrush(window)); 00599 }
Here is the call graph for this function:

| QPalette::QPalette | ( | const QPalette & | p | ) |
Constructs a copy of p.
This constructor is fast thanks to {implicit sharing}.
Definition at line 638 of file qpalette.cpp.
References current_group, d, p, QPalettePrivate::ref, QBasicAtomic::ref(), and resolve_mask.
00639 { 00640 d = p.d; 00641 d->ref.ref(); 00642 resolve_mask = p.resolve_mask; 00643 current_group = p.current_group; 00644 }
Here is the call graph for this function:

| QPalette::~QPalette | ( | ) |
Destroys the palette.
Definition at line 649 of file qpalette.cpp.
References d, QBasicAtomic::deref(), and QPalettePrivate::ref.
Here is the call graph for this function:

Assigns p to this palette and returns a reference to this palette.
This operation is fast thanks to {implicit sharing}.
Definition at line 668 of file qpalette.cpp.
References current_group, d, p, qAtomicSetPtr(), resolve_mask, and x.
00669 { 00670 QPalettePrivate *x = p.d; 00671 x->ref.ref(); 00672 resolve_mask = p.resolve_mask; 00673 current_group = p.current_group; 00674 x = qAtomicSetPtr(&d, x); 00675 if(!x->ref.deref()) 00676 delete x; 00677 return *this; 00678 }
Here is the call graph for this function:

| QPalette::operator QVariant | ( | ) | const |
Returns the palette as a QVariant
Definition at line 683 of file qpalette.cpp.
References QVariant::Palette.
00684 { 00685 return QVariant(QVariant::Palette, this); 00686 }
| ColorGroup QPalette::currentColorGroup | ( | ) | const [inline] |
Returns the palette's current color group.
Definition at line 73 of file qpalette.h.
Referenced by Q3TextHorizontalLine::draw(), and NorwegianWoodStyle::drawControl().
00073 { return static_cast<ColorGroup>(current_group); }
| void QPalette::setCurrentColorGroup | ( | ColorGroup | cg | ) | [inline] |
Set the palette's current color group to cg.
Definition at line 74 of file qpalette.h.
Referenced by QTableViewPrivate::drawCell(), QCommonStyle::drawComplexControl(), QMotifStyle::drawComplexControl(), Q3IconView::drawContents(), Q3ListView::drawContentsOffset(), QTreeView::drawRow(), QMenuBarPrivate::getStyleOption(), QMenuPrivate::getStyleOption(), Q3ListBox::paintCell(), Q3TitleBar::paintEvent(), QWorkspaceTitleBar::paintEvent(), QTableView::paintEvent(), and QListView::paintEvent().
00074 { current_group = cg; }
| const QColor & QPalette::color | ( | ColorGroup | gr, | |
| ColorRole | r | |||
| ) | const [inline] |
Returns the color in color group gr, used for color role r.
Definition at line 76 of file qpalette.h.
Referenced by QMessageBox::aboutQt(), MainWindow::buildActiveEffect(), PaletteEditorAdvanced::buildActiveEffect(), MainWindow::buildPalette(), QTextDocumentLayoutPrivate::drawBlock(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QTextControl::drawContents(), QPlastiqueStyle::drawControl(), QItemDelegate::drawDisplay(), QItemDelegate::drawFocus(), QTextDocumentLayoutPrivate::drawFrame(), QCleanlooksStyle::drawItemText(), QStyle::drawItemText(), QPlastiqueStyle::drawPrimitive(), QTreeView::drawRow(), QLCDNumberPrivate::drawSegment(), Calculator::eventFilter(), MainWindow::fileSave(), QCommonStyle::generatedIconPixmap(), TabbedBrowser::init(), PaletteEditorAdvanced::onCentral(), PaletteEditorAdvanced::onEffect(), Q3TextParagraph::paint(), BookDelegate::paint(), qdesigner_internal::QPropertyEditorDelegate::paint(), ArthurFrame::paintEvent(), qdesigner_internal::QtColorLinePrivate::paintEvent(), QLabel::paintEvent(), PieView::paintEvent(), QMotifStyle::polish(), qDrawShadeLine(), qt_plastique_draw_handle(), qt_plastique_drawFrame(), Q3TitleBarPrivate::readColors(), QWorkspaceTitleBarPrivate::readColors(), RegExpDialog::refresh(), Q3TextParagraph::setColorForSelection(), Q3SyntaxHighlighter::setFormat(), QApplicationPrivate::setSystemPalette(), QInputContext::standardFormat(), QMotifStyle::standardPixmap(), QCommonStyle::styleHint(), MainWindow::updateColorButtons(), and PaletteEditorAdvanced::updateColorButtons().
| const QBrush & QPalette::brush | ( | ColorGroup | gr, | |
| ColorRole | cr | |||
| ) | const |
Returns the brush in color group gr, used for color role cr.
Definition at line 700 of file qpalette.cpp.
References Active, QPalettePrivate::br, Current, current_group, d, NColorGroups, NColorRoles, and qWarning().
Referenced by Q3TextParagraph::backgroundBrush(), QGLDrawable::backgroundColor(), qdesigner_internal::PaletteModel::data(), Q3TextDocument::draw(), QItemDelegate::drawBackground(), QTableViewPrivate::drawCell(), QCommonStyle::drawComplexControl(), QWindowsStyle::drawComplexControl(), QWindowsXPStyle::drawComplexControl(), QTextControl::drawContents(), QCDEStyle::drawControl(), QMotifStyle::drawControl(), QItemDelegate::drawDisplay(), Q3TextParagraph::drawLabel(), QTextDocumentLayoutPrivate::drawListItem(), QCommonStyle::drawPrimitive(), QCDEStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QTreeView::drawRow(), QTreeView::drawTree(), Q3Canvas::drawViewArea(), QCalendarModel::formatForCell(), QPainter::initFrom(), QWidgetPrivate::isBackgroundInherited(), QWidgetPrivate::isOpaque(), Q3CheckTableItem::paint(), Q3ListBox::paintCell(), Q3CheckListItem::paintCell(), Q3Table::paintCell(), QLineEdit::paintEvent(), ArthurFrame::paintEvent(), Q3DateTimeEditor::paintEvent(), QDesignerDialog::paintEvent(), QTableView::paintEvent(), QHideDock::paintEvent(), QListView::paintEvent(), QGraphicsView::paintEvent(), paintGrid(), QMotifStyle::polish(), RegExpDialog::RegExpDialog(), qdesigner_internal::PaletteModel::setData(), qdesigner_internal::PaletteEditor::setPalette(), and qdesigner_internal::PaletteEditor::updatePreviewPalette().
00701 { 00702 Q_ASSERT(cr < NColorRoles); 00703 if(gr >= (int)NColorGroups) { 00704 if(gr == Current) { 00705 gr = (ColorGroup)current_group; 00706 } else { 00707 qWarning("QPalette::brush: Unknown ColorGroup: %d", (int)gr); 00708 gr = Active; 00709 } 00710 } 00711 return d->br[gr][cr]; 00712 }
Here is the call graph for this function:

| void QPalette::setColor | ( | ColorGroup | gr, | |
| ColorRole | r, | |||
| const QColor & | c | |||
| ) | [inline] |
Sets the brush in color group gr, used for color role r, to the solid color c.
Definition at line 158 of file qpalette.h.
References setBrush().
Referenced by MainWindow::buildPalette(), Button::Button(), Q3TextHorizontalLine::draw(), QStyleSheetStyle::drawComplexControl(), QWindowsStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), QWindowsXPStyle::drawControl(), QCommonStyle::drawControl(), QWindowsStyle::drawPrimitive(), EditorPage::EditorPage(), Calculator::eventFilter(), QTabBarPrivate::getStyleOption(), TabbedBrowser::init(), MessageEditor::MessageEditor(), MessagesTreeView::MessagesTreeView(), Oubliette::Oubliette(), Q3ComboTableItem::paint(), qdesigner_internal::QPropertyEditorDelegate::paint(), QLabel::paintEvent(), PreviewView::paintPage(), QMotifStyle::polish(), ArthurStyle::polish(), printPage(), QBalloonTip::QBalloonTip(), Q3TitleBarPrivate::readColors(), QWorkspaceTitleBarPrivate::readColors(), readV1ColorGroup(), RegExpDialog::refresh(), setColor(), QGraphicsTextItem::setDefaultTextColor(), Q3TextEdit::setPaper(), QApplicationPrivate::setSystemPalette(), and TrPreviewTool::TrPreviewTool().
Here is the call graph for this function:

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the color used for color role r in all color groups to a solid color c.
Definition at line 161 of file qpalette.h.
References All, and setColor().
Here is the call graph for this function:

Sets the brush for color role cr to brush brush for all groups in the palette.
Definition at line 163 of file qpalette.h.
References All.
Referenced by CursorWindow::CursorWindow(), Q3TextTableCell::draw(), Q3SimpleRichText::draw(), QCleanlooksStyle::drawComplexControl(), NorwegianWoodStyle::drawControl(), QStyleSheetStyle::drawControl(), qdesigner_internal::PaletteEditor::getPalette(), PaletteEditorAdvanced::mapToActivePixmapRole(), PaletteEditorAdvanced::mapToDisabledPixmapRole(), PaletteEditorAdvanced::mapToInactivePixmapRole(), PageCurl::PageCurl(), Q3CheckTableItem::paint(), Q3ComboTableItem::paint(), ArthurFrame::paintDescription(), Q3TextEdit::paintDocument(), QHeaderView::paintSection(), QPlastiqueStyle::polish(), QCleanlooksStyle::polish(), QWindowsXPStyle::polish(), RegExpDialog::RegExpDialog(), setColor(), setColorGroup(), qdesigner_internal::PaletteModel::setData(), QItemDelegate::setOptions(), qdesigner_internal::PaletteEditor::setPalette(), ShadeWidget::ShadeWidget(), and qdesigner_internal::PaletteEditor::updatePreviewPalette().
| bool QPalette::isBrushSet | ( | ColorGroup | cg, | |
| ColorRole | cr | |||
| ) | const |
Definition at line 759 of file qpalette.cpp.
References resolve_mask.
00760 { 00761 Q_UNUSED(cg); 00762 return (resolve_mask & (1<<cr)); 00763 }
| void QPalette::setBrush | ( | ColorGroup | cg, | |
| ColorRole | cr, | |||
| const QBrush & | b | |||
| ) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Sets the brush in color group cg, used for color role cr, to b.
Definition at line 730 of file qpalette.cpp.
References Active, All, b, QPalettePrivate::br, Current, current_group, d, detach(), i, int, NColorGroups, NColorRoles, qWarning(), and resolve_mask.
00731 { 00732 Q_ASSERT(cr < NColorRoles); 00733 detach(); 00734 if(cg >= (int)NColorGroups) { 00735 if(cg == All) { 00736 for(int i = 0; i < (int)NColorGroups; i++) 00737 d->br[i][cr] = b; 00738 resolve_mask |= (1<<cr); 00739 return; 00740 } else if(cg == Current) { 00741 cg = (ColorGroup)current_group; 00742 } else { 00743 qWarning("QPalette::setBrush: Unknown ColorGroup: %d", (int)cg); 00744 cg = Active; 00745 } 00746 } 00747 d->br[cg][cr] = b; 00748 resolve_mask |= (1<<cr); 00749 }
Here is the call graph for this function:

| void QPalette::setColorGroup | ( | ColorGroup | cg, | |
| const QBrush & | windowText, | |||
| const QBrush & | button, | |||
| const QBrush & | light, | |||
| const QBrush & | dark, | |||
| const QBrush & | mid, | |||
| const QBrush & | text, | |||
| const QBrush & | bright_text, | |||
| const QBrush & | base, | |||
| const 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.
Definition at line 1015 of file qpalette.cpp.
References base(), Qt::black, Qt::blue, button(), QBrush::color(), dark(), Qt::darkBlue, Highlight, HighlightedText, light(), Link, LinkVisited, Qt::magenta, mid(), qt_mix_colors(), resolve_mask, text(), Qt::white, window(), and windowText().
Referenced by QPalette(), and qt_palette_from_color().
01019 { 01020 QBrush alt_base = QBrush(qt_mix_colors(base.color(), button.color())); 01021 QBrush mid_light = QBrush(qt_mix_colors(button.color(), light.color())); 01022 setColorGroup(cg, windowText, button, light, dark, mid, text, bright_text, base, 01023 alt_base, window, mid_light, text, 01024 QBrush(Qt::black), QBrush(Qt::darkBlue), QBrush(Qt::white), 01025 QBrush(Qt::blue), QBrush(Qt::magenta)); 01026 01027 resolve_mask &= ~(1 << Highlight); 01028 resolve_mask &= ~(1 << HighlightedText); 01029 resolve_mask &= ~(1 << LinkVisited); 01030 resolve_mask &= ~(1 << Link); 01031 }
Here is the call graph for this function:

| bool QPalette::isEqual | ( | QPalette::ColorGroup | group1, | |
| QPalette::ColorGroup | group2 | |||
| ) | const |
Returns true (usually quickly) if color group cg1 is equal to cg2; otherwise returns false.
Definition at line 833 of file qpalette.cpp.
References Active, QPalettePrivate::br, Current, current_group, d, int, NColorGroups, NColorRoles, and qWarning().
00834 { 00835 if(group1 >= (int)NColorGroups) { 00836 if(group1 == Current) { 00837 group1 = (ColorGroup)current_group; 00838 } else { 00839 qWarning("QPalette::brush: Unknown ColorGroup(1): %d", (int)group1); 00840 group1 = Active; 00841 } 00842 } 00843 if(group2 >= (int)NColorGroups) { 00844 if(group2 == Current) { 00845 group2 = (ColorGroup)current_group; 00846 } else { 00847 qWarning("QPalette::brush: Unknown ColorGroup(2): %d", (int)group2); 00848 group2 = Active; 00849 } 00850 } 00851 if(group1 == group2) 00852 return true; 00853 for(int role = 0; role < (int)NColorRoles; role++) { 00854 if(d->br[group1][role] != d->br[group2][role]) 00855 return false; 00856 } 00857 return true; 00858 }
Here is the call graph for this function:

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the color that has been set for color role r in the current ColorGroup.
Definition at line 90 of file qpalette.h.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. Returns the brush that has been set for color role r in the current ColorGroup.
Definition at line 91 of file qpalette.h.
| const QBrush & QPalette::foreground | ( | ) | const [inline] |
Use windowText() instead.
Definition at line 92 of file qpalette.h.
Referenced by QCommonStyle::drawComplexControl(), QFrame::drawFrame(), QCommonStyle::drawPrimitive(), QCDEStyle::drawPrimitive(), NorwegianWoodStyle::drawPrimitive(), and setColorGroup().
00092 { return brush(WindowText); }
| const QBrush & QPalette::windowText | ( | ) | const [inline] |
Returns the window text (general foreground) brush of the current color group.
Definition at line 93 of file qpalette.h.
Referenced by QPalette(), and setColorGroup().
00093 { return brush(WindowText); }
| const QBrush & QPalette::button | ( | ) | const [inline] |
Returns the button brush of the current color group.
Definition at line 94 of file qpalette.h.
Referenced by Q3TextTable::draw(), QCommonStyle::drawComplexControl(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QCleanlooksStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), NorwegianWoodStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), qDrawWinButton(), QPalette(), qt_cleanlooks_draw_mdibutton(), qt_plastique_drawFrame(), qt_plastique_drawShadedPanel(), and setColorGroup().
| const QBrush & QPalette::light | ( | ) | const [inline] |
Returns the light brush of the current color group.
Definition at line 95 of file qpalette.h.
Referenced by QCommonStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QStyle::drawItemText(), QCDEStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QLCDNumberPrivate::drawSegment(), QLabel::paintEvent(), qDrawShadeLine(), qDrawShadePanel(), qDrawShadeRect(), qDrawWinButton(), qDrawWinPanel(), QPalette(), and setColorGroup().
| const QBrush & QPalette::dark | ( | ) | const [inline] |
Returns the dark brush of the current color group.
Definition at line 96 of file qpalette.h.
Referenced by QWorkspace::background(), Q3TextImage::draw(), qdesigner_internal::QPropertyEditor::drawBranches(), QCommonStyle::drawComplexControl(), QCDEStyle::drawControl(), QCommonStyle::drawPrimitive(), QCDEStyle::drawPrimitive(), QWindowsStyle::drawPrimitive(), QLCDNumberPrivate::drawSegment(), qdesigner_internal::QPropertyEditorDelegate::paint(), paintGrid(), QWindowsStyle::polish(), qDrawShadeLine(), qDrawShadePanel(), qDrawShadeRect(), qDrawWinButton(), qDrawWinPanel(), QPalette(), and setColorGroup().
| const QBrush & QPalette::mid | ( | ) | const [inline] |
Returns the mid brush of the current color group.
Definition at line 97 of file qpalette.h.
Referenced by NorwegianWoodStyle::drawPrimitive(), Q3Table::paintCell(), qDrawShadeLine(), qDrawShadeRect(), QPalette(), and setColorGroup().
| const QBrush & QPalette::text | ( | ) | const [inline] |
Returns the text foreground brush of the current color group.
Definition at line 98 of file qpalette.h.
Referenced by Q3TextHorizontalLine::draw(), Q3TextTable::draw(), Q3TextDocument::draw(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QTextDocumentLayoutPrivate::drawListItem(), QPlastiqueStyle::drawPrimitive(), Q3TextParagraph::drawString(), QGraphicsPathItem::paint(), Q3DateTimeEditorPrivate::paint(), Q3CheckTableItem::paint(), QGraphicsLineItem::paint(), QGraphicsEllipseItem::paint(), QGraphicsPolygonItem::paint(), QGraphicsRectItem::paint(), QLineEdit::paintEvent(), QPalette(), setColorGroup(), QInputContext::standardFormat(), and Q3ListBox::viewportPaintEvent().
| const QBrush & QPalette::base | ( | ) | const [inline] |
Returns the base brush of the current color group.
Definition at line 99 of file qpalette.h.
References Base.
Referenced by QPlastiqueStyle::drawControl(), QPlastiqueStyle::drawPrimitive(), Q3IconView::eventFilter(), Q3DateTimeEditorPrivate::paint(), Q3ListBox::paintCell(), Q3TextEdit::paintDocument(), PieView::paintEvent(), Q3ListViewItem::paintFocus(), Q3Table::paintFocus(), QPlastiqueStyle::polish(), QWindowsXPStyle::polish(), QPalette(), qt_plastique_draw_handle(), setColorGroup(), and SpreadSheet::updateColor().
| const QBrush & QPalette::alternateBase | ( | ) | const [inline] |
Returns the alternate base brush of the current color group.
Definition at line 100 of file qpalette.h.
00100 { return brush(AlternateBase); }
| const QBrush & QPalette::background | ( | ) | const [inline] |
Use window() instead.
Definition at line 101 of file qpalette.h.
Referenced by QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), QCommonStyle::drawControl(), QCleanlooksStyle::drawPrimitive(), QCDEStyle::drawPrimitive(), QPlastiqueStyle::drawPrimitive(), NorwegianWoodStyle::drawPrimitive(), QHeaderView::paintEvent(), QWindowsStyle::polish(), qt_cleanlooks_draw_mdibutton(), qt_plastique_draw_handle(), qt_plastique_drawFrame(), qt_plastique_drawShadedPanel(), setColorGroup(), QSplashScreen::setPixmap(), QInputContext::standardFormat(), and QCleanlooksStyle::styleHint().
| const QBrush & QPalette::window | ( | ) | const [inline] |
Returns the window (general background) brush of the current color group.
Definition at line 102 of file qpalette.h.
Referenced by QPalette(), and setColorGroup().
| const QBrush & QPalette::midlight | ( | ) | const [inline] |
Returns the midlight brush of the current color group.
Definition at line 103 of file qpalette.h.
Referenced by qDrawShadePanel(), qDrawWinPanel(), and setColorGroup().
| const QBrush & QPalette::brightText | ( | ) | const [inline] |
Returns the bright text foreground brush of the current color group.
Definition at line 104 of file qpalette.h.
Referenced by NorwegianWoodStyle::drawControl().
00104 { return brush(BrightText); }
| const QBrush & QPalette::buttonText | ( | ) | const [inline] |
Returns the button text foreground brush of the current color group.
Definition at line 105 of file qpalette.h.
00105 { return brush(ButtonText); }
| const QBrush & QPalette::shadow | ( | ) | const [inline] |
Returns the shadow brush of the current color group.
Definition at line 106 of file qpalette.h.
Referenced by qDrawShadePanel(), qDrawWinButton(), qDrawWinPanel(), qt_plastique_draw_frame(), and setColorGroup().
| const QBrush & QPalette::highlight | ( | ) | const [inline] |
Returns the highlight brush of the current color group.
Definition at line 107 of file qpalette.h.
Referenced by Q3TextHorizontalLine::draw(), Q3TextImage::draw(), QCleanlooksStyle::drawComplexControl(), QPlastiqueStyle::drawComplexControl(), QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QMotifStyle::drawControl(), QWindowsStyle::drawControl(), QCommonStyle::drawControl(), QPlastiqueStyle::drawPrimitive(), qdesigner_internal::ActionGroupDelegate::paint(), QFontFamilyDelegate::paint(), PixelDelegate::paint(), Q3ListBox::paintCell(), Q3ListViewItem::paintFocus(), Q3Table::paintFocus(), QCleanlooksStyle::polish(), QWindowsStyle::polish(), qt_cleanlooks_draw_mdibutton(), qt_plastique_draw_frame(), and setColorGroup().
| const QBrush & QPalette::highlightedText | ( | ) | const [inline] |
Returns the highlighted text brush of the current color group.
Definition at line 108 of file qpalette.h.
Referenced by QPlastiqueStyle::drawControl(), QCleanlooksStyle::drawControl(), QWindowsStyle::drawControl(), QWindowsXPStyle::drawControl(), Q3CheckTableItem::paint(), QFontFamilyDelegate::paint(), PixelDelegate::paint(), Q3ListBox::paintCell(), and QCleanlooksStyle::polish().
00108 { return brush(HighlightedText); }
| const QBrush & QPalette::link | ( | ) | const [inline] |
Returns the unvisited link text brush of the current color group.
Definition at line 109 of file qpalette.h.
Referenced by Q3TextParagraph::drawString(), and setColorGroup().
| const QBrush & QPalette::linkVisited | ( | ) | const [inline] |
Returns the visited link text brush of the current color group.
Definition at line 110 of file qpalette.h.
00110 { return brush(LinkVisited); }
| bool QPalette::operator== | ( | const QPalette & | p | ) | const |
Returns true (usually quickly) if this palette is equal to p; otherwise returns false (slowly).
Definition at line 793 of file qpalette.cpp.
References QPalettePrivate::br, d, int, isCopyOf(), NColorGroups, NColorRoles, and p.
00794 { 00795 if (isCopyOf(p)) 00796 return true; 00797 for(int grp = 0; grp < (int)NColorGroups; grp++) { 00798 for(int role = 0; role < (int)NColorRoles; role++) { 00799 if(d->br[grp][role] != p.d->br[grp][role]) 00800 return false; 00801 } 00802 } 00803 return true; 00804 }
Here is the call graph for this function:

| bool QPalette::operator!= | ( | const QPalette & | p | ) | const [inline] |
Returns true (slowly) if this palette is different from p; otherwise returns false (usually quickly).
Definition at line 126 of file qpalette.h.
References operator==(), and p.
00126 { return !(operator==(p)); }
Here is the call graph for this function:

| bool QPalette::isCopyOf | ( | const QPalette & | p | ) | const |
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.
Definition at line 1002 of file qpalette.cpp.
Referenced by operator==(), qt_naturalWidgetPalette(), and QApplicationPrivate::setPalette_helper().
| int QPalette::serialNumber | ( | ) | const |
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.
Definition at line 873 of file qpalette.cpp.
References d, and QPalettePrivate::ser_no.
Referenced by uniqueName().
Returns a new QPalette that has attributes copied from other.
Definition at line 881 of file qpalette.cpp.
References QPalettePrivate::br, d, int, NColorGroups, NColorRoles, o, palette, and resolve_mask.
Referenced by qdesigner_internal::PaletteModel::data(), qt_naturalWidgetPalette(), QWidgetPrivate::resolvePalette(), qdesigner_internal::PaletteModel::setData(), qdesigner_internal::PaletteEditor::setPalette(), QWidget::setPalette(), QWidgetPrivate::setPalette_helper(), qdesigner_internal::PaletteProperty::setValue(), and qdesigner_internal::PaletteProperty::updateValue().
00882 { 00883 if (*this == other && resolve_mask == other.resolve_mask 00884 || resolve_mask == 0) { 00885 QPalette o = other; 00886 o.resolve_mask = resolve_mask; 00887 return o; 00888 } 00889 00890 QPalette palette(*this); 00891 palette.detach(); 00892 00893 for(int role = 0; role < (int)NColorRoles; role++) 00894 if (!(resolve_mask & (1<<role))) 00895 for(int grp = 0; grp < (int)NColorGroups; grp++) 00896 palette.d->br[grp][role] = other.d->br[grp][role]; 00897 00898 return palette; 00899 }
| uint QPalette::resolve | ( | ) | const [inline] |
| void QPalette::resolve | ( | uint | mask | ) | [inline] |
| void QPalette::setColorGroup | ( | ColorGroup | cr, | |
| const QBrush & | windowText, | |||
| const QBrush & | button, | |||
| const QBrush & | light, | |||
| const QBrush & | dark, | |||
| const QBrush & | mid, | |||
| const QBrush & | text, | |||
| const QBrush & | bright_text, | |||
| const QBrush & | base, | |||
| const QBrush & | alternate_base, | |||
| const QBrush & | window, | |||
| const QBrush & | midlight, | |||
| const QBrush & | button_text, | |||
| const QBrush & | shadow, | |||
| const QBrush & | highlight, | |||
| const QBrush & | highlighted_text, | |||
| const QBrush & | link, | |||
| const QBrush & | link_visited | |||
| ) | [private] |
Definition at line 1036 of file qpalette.cpp.
References AlternateBase, background(), base(), Base, BrightText, button(), ButtonText, Dark, dark(), detach(), foreground(), highlight(), Highlight, HighlightedText, Light, light(), Link, link(), LinkVisited, Mid, mid(), midlight(), Midlight, setBrush(), shadow(), Shadow, text(), Text, and WindowText.
01044 { 01045 detach(); 01046 setBrush(cg, WindowText, foreground); 01047 setBrush(cg, Button, button); 01048 setBrush(cg, Light, light); 01049 setBrush(cg, Dark, dark); 01050 setBrush(cg, Mid, mid); 01051 setBrush(cg, Text, text); 01052 setBrush(cg, BrightText, bright_text); 01053 setBrush(cg, Base, base); 01054 setBrush(cg, AlternateBase, alternate_base); 01055 setBrush(cg, Window, background); 01056 setBrush(cg, Midlight, midlight); 01057 setBrush(cg, ButtonText, button_text); 01058 setBrush(cg, Shadow, shadow); 01059 setBrush(cg, Highlight, highlight); 01060 setBrush(cg, HighlightedText, highlighted_text); 01061 setBrush(cg, Link, link); 01062 setBrush(cg, LinkVisited, link_visited); 01063 }
Here is the call graph for this function:

| void QPalette::init | ( | ) | [private] |
Definition at line 656 of file qpalette.cpp.
References Active, current_group, d, and resolve_mask.
Referenced by QPalette().
00656 { 00657 d = new QPalettePrivate; 00658 resolve_mask = 0; 00659 current_group = Active; //as a default.. 00660 }
| void QPalette::detach | ( | ) | [private] |
Definition at line 768 of file qpalette.cpp.
References QPalettePrivate::br, d, int, NColorGroups, NColorRoles, qAtomicSetPtr(), QPalettePrivate::ref, and x.
Referenced by setBrush(), and setColorGroup().
00769 { 00770 if (d->ref != 1) { 00771 QPalettePrivate *x = new QPalettePrivate; 00772 for(int grp = 0; grp < (int)NColorGroups; grp++) { 00773 for(int role = 0; role < (int)NColorRoles; role++) 00774 x->br[grp][role] = d->br[grp][role]; 00775 } 00776 x = qAtomicSetPtr(&d, x); 00777 if(!x->ref.deref()) 00778 delete x; 00779 } 00780 }
Here is the call graph for this function:

| QDataStream & operator<< | ( | QDataStream & | s, | |
| const QPalette & | p | |||
| ) | [friend] |
Writes the palette, p to the stream s and returns a reference to the stream.
Definition at line 931 of file qpalette.cpp.
00932 { 00933 for (int grp = 0; grp < (int)QPalette::NColorGroups; grp++) { 00934 if (s.version() == 1) { 00935 // Qt 1.x 00936 for (int i = 0; i < NumOldRoles; ++i) 00937 s << p.d->br[grp][oldRoles[i]].color(); 00938 } else { 00939 int max = QPalette::NColorRoles; 00940 if (s.version() <= 3) // Qt 2.x 00941 max = 14; 00942 for (int r = 0; r < max; r++) 00943 s << p.d->br[grp][r]; 00944 } 00945 } 00946 return s; 00947 }
| QDataStream & operator>> | ( | QDataStream & | s, | |
| QPalette & | p | |||
| ) | [related] |
Reads a palette from the stream, s into the palette p, and returns a reference to the stream.
Definition at line 967 of file qpalette.cpp.
References Active, Disabled, Inactive, int, NColorGroups, NColorRoles, p, readV1ColorGroup(), and s.
00968 { 00969 if(s.version() == 1) { 00970 p = QPalette(); 00971 readV1ColorGroup(s, p, QPalette::Active); 00972 readV1ColorGroup(s, p, QPalette::Disabled); 00973 readV1ColorGroup(s, p, QPalette::Inactive); 00974 } else { 00975 int max = QPalette::NColorRoles; 00976 if (s.version() <= 3) { // Qt 2.x 00977 p = QPalette(); 00978 max = 14; 00979 } 00980 00981 QBrush tmp; 00982 for(int grp = 0; grp < (int)QPalette::NColorGroups; ++grp) { 00983 for(int role = 0; role < max; ++role) { 00984 s >> tmp; 00985 p.setBrush((QPalette::ColorGroup)grp, (QPalette::ColorRole)role, tmp); 00986 } 00987 } 00988 } 00989 return s; 00990 }
Here is the call graph for this function:

QPalettePrivate* QPalette::d [private] |
Definition at line 152 of file qpalette.h.
Referenced by brush(), detach(), init(), isCopyOf(), isEqual(), operator=(), operator==(), QPalette(), resolve(), serialNumber(), setBrush(), and ~QPalette().
uint QPalette::current_group [private] |
Definition at line 153 of file qpalette.h.
Referenced by brush(), init(), isEqual(), operator=(), QPalette(), and setBrush().
uint QPalette::resolve_mask [private] |
Definition at line 154 of file qpalette.h.
Referenced by init(), isBrushSet(), operator=(), QPalette(), resolve(), setBrush(), and setColorGroup().
1.5.1