Qt 4.8
Classes | Functions | Variables
qpalette.cpp File Reference
#include "qpalette.h"
#include "qapplication.h"
#include "qdatastream.h"
#include "qvariant.h"

Go to the source code of this file.

Classes

class  QPalettePrivate
 

Functions

static QColor qt_mix_colors (QColor a, QColor b)
 
static void qt_palette_from_color (QPalette &pal, const QColor &button)
 
static void readV1ColorGroup (QDataStream &s, QPalette &pal, QPalette::ColorGroup grp)
 

Variables

static const int NumOldRoles = 7
 
static const int oldRoles [7]
 
static int qt_palette_count = 1
 

Function Documentation

◆ qt_mix_colors()

static QColor qt_mix_colors ( QColor  a,
QColor  b 
)
static

Definition at line 60 of file qpalette.cpp.

Referenced by QPalette::setColorGroup().

61 {
62  return QColor((a.red() + b.red()) / 2, (a.green() + b.green()) / 2,
63  (a.blue() + b.blue()) / 2, (a.alpha() + b.alpha()) / 2);
64 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
ushort red
Returns the red color component of this color.
Definition: qcolor.h:243
ushort blue
Returns the blue color component of this color.
Definition: qcolor.h:245
ushort alpha
Returns the alpha color component of this color.
Definition: qcolor.h:242
ushort green
Returns the green color component of this color.
Definition: qcolor.h:244

◆ qt_palette_from_color()

static void qt_palette_from_color ( QPalette pal,
const QColor button 
)
static

Definition at line 681 of file qpalette.cpp.

Referenced by QPalette::QPalette().

682 {
683  QColor bg = button,
684  btn = button,
685  fg, base;
686  int h, s, v;
687  bg.getHsv(&h, &s, &v);
688  if(v > 128) {
689  fg = Qt::black;
690  base = Qt::white;
691  } else {
692  fg = Qt::white;
693  base = Qt::black;
694  }
695  //inactive and active are the same..
696  pal.setColorGroup(QPalette::Active, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
697  QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
698  QBrush(base), QBrush(bg));
699  pal.setColorGroup(QPalette::Inactive, QBrush(fg), QBrush(btn), QBrush(btn.lighter(150)),
700  QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(fg), QBrush(Qt::white),
701  QBrush(base), QBrush(bg));
702  pal.setColorGroup(QPalette::Disabled, QBrush(btn.darker()), QBrush(btn), QBrush(btn.lighter(150)),
703  QBrush(btn.darker()), QBrush(btn.darker(150)), QBrush(btn.darker()),
704  QBrush(Qt::white), QBrush(bg), QBrush(bg));
705 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
static const uint base
Definition: qurl.cpp:268
void getHsv(int *h, int *s, int *v, int *a=0) const
Sets the contents pointed to by h, s, v, and a, to the hue, saturation, value, and alpha-channel (tra...
Definition: qcolor.cpp:679
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)
Sets a the group at cg.
Definition: qpalette.cpp:1246
The QBrush class defines the fill pattern of shapes drawn by QPainter.
Definition: qbrush.h:76

◆ readV1ColorGroup()

static void readV1ColorGroup ( QDataStream s,
QPalette pal,
QPalette::ColorGroup  grp 
)
static

Definition at line 1174 of file qpalette.cpp.

Referenced by QPalette::operator>>().

1175 {
1176  for (int i = 0; i < NumOldRoles; ++i) {
1177  QColor col;
1178  s >> col;
1179  pal.setColor(grp, (QPalette::ColorRole)oldRoles[i], col);
1180  }
1181 }
The QColor class provides colors based on RGB, HSV or CMYK values.
Definition: qcolor.h:67
ColorRole
The ColorRole enum defines the different symbolic color roles used in current GUIs.
Definition: qpalette.h:93
static const int NumOldRoles
Definition: qpalette.cpp:1138
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
Definition: qpalette.h:201
static const int oldRoles[7]
Definition: qpalette.cpp:1139

Variable Documentation

◆ NumOldRoles

const int NumOldRoles = 7
static

Definition at line 1138 of file qpalette.cpp.

Referenced by readV1ColorGroup().

◆ oldRoles

const int oldRoles[7]
static

◆ qt_palette_count

int qt_palette_count = 1
static

Definition at line 49 of file qpalette.cpp.