Updated to the new titlebar button color handling.

svn path=/trunk/kdebase/kwin/; revision=47732
This commit is contained in:
Daniel M. Duley 2000-04-28 10:34:24 +00:00
parent a974abc657
commit dcf3fda8dd
2 changed files with 58 additions and 72 deletions

View file

@ -173,12 +173,15 @@ static void create_pixmaps()
redraw_pixmaps(); redraw_pixmaps();
} }
B2Button::B2Button(KPixmap *pix, KPixmap *pixDown, QWidget *parent, B2Button::B2Button(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
const char *name) KPixmap *iPixDown, Client *parent, const char *name)
: QButton(parent, name) : QButton(parent, name)
{ {
client = parent;
pNorm = pix; pNorm = pix;
pDown = pixDown; pDown = pixDown;
iNorm = iPix;
iDown = iPixDown;
setFixedSize(16, 16); setFixedSize(16, 16);
setFocusPolicy(NoFocus); setFocusPolicy(NoFocus);
resize(16, 16); resize(16, 16);
@ -198,26 +201,38 @@ QSizePolicy B2Button::sizePolicy() const
void B2Button::drawButton(QPainter *p) void B2Button::drawButton(QPainter *p)
{ {
p->fillRect(rect(), bg); p->fillRect(rect(), bg);
// hehe, nasty casts - I'm such a bad boy ;-) if(useMiniIcon && !client->miniIcon().isNull()){
if(useMiniIcon && !(((B2Client*)parent())->miniIcon().isNull())){ QPixmap miniIcon = client->miniIcon();
QPixmap miniIcon = ((B2Client*)parent())->miniIcon();
p->drawPixmap((width()-miniIcon.width())/2, p->drawPixmap((width()-miniIcon.width())/2,
(height()-miniIcon.height())/2, miniIcon); (height()-miniIcon.height())/2, miniIcon);
} }
else{ else{
if(isOn() || isDown()) if(client->isActive()){
p->drawPixmap((width()-pDown->width())/2, if(isOn() || isDown())
(height()-pDown->height())/2, *pDown); p->drawPixmap((width()-pDown->width())/2,
else (height()-pDown->height())/2, *pDown);
p->drawPixmap((width()-pNorm->width())/2, else
(height()-pNorm->height())/2, *pNorm); p->drawPixmap((width()-pNorm->width())/2,
(height()-pNorm->height())/2, *pNorm);
}
else{
if(isOn() || isDown())
p->drawPixmap((width()-pDown->width())/2,
(height()-pDown->height())/2, *iDown);
else
p->drawPixmap((width()-pNorm->width())/2,
(height()-pNorm->height())/2, *iNorm);
}
} }
} }
void B2Button::setPixmaps(KPixmap *pix, KPixmap *pixDown) void B2Button::setPixmaps(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
KPixmap *iPixDown)
{ {
pNorm = pix; pNorm = pix;
pDown = pixDown; pDown = pixDown;
iNorm = iPix;
iDown = iPixDown;
repaint(false); repaint(false);
} }
@ -258,30 +273,24 @@ B2Client::B2Client( Workspace *ws, WId w, QWidget *parent,
if(!providesContextHelp()) if(!providesContextHelp())
button[5]->hide(); button[5]->hide();
if(isActive()){ button[BtnMenu]->setPixmaps(aMenuPix, aMenuPixDown, iMenuPix,
button[BtnMenu]->setPixmaps(aMenuPix, aMenuPixDown); iMenuPixDown);
button[BtnSticky]->setPixmaps(aPinupPix, aPinupPixDown); button[BtnSticky]->setPixmaps(aPinupPix, aPinupPixDown, iPinupPix,
button[BtnIconify]->setPixmaps(aIconifyPix, aIconifyPixDown); iPinupPixDown);
button[BtnClose]->setPixmaps(aClosePix, aClosePixDown); button[BtnIconify]->setPixmaps(aIconifyPix, aIconifyPixDown,
button[BtnHelp]->setPixmaps(aHelpPix, aHelpPixDown); iIconifyPix, iIconifyPixDown);
button[BtnClose]->setPixmaps(aClosePix, aClosePixDown, iClosePix,
iClosePixDown);
button[BtnHelp]->setPixmaps(aHelpPix, aHelpPixDown, iHelpPix,
iHelpPixDown);
if(isMaximized()) if(isMaximized())
button[BtnMax]->setPixmaps(aNormalizePix, aNormalizePixDown); button[BtnMax]->setPixmaps(aNormalizePix, aNormalizePixDown,
else iNormalizePix, iNormalizePixDown);
button[BtnMax]->setPixmaps(aMaxPix, aMaxPixDown); else
} button[BtnMax]->setPixmaps(aMaxPix, aMaxPixDown, iMaxPix,
else{ iMaxPixDown);
button[BtnMenu]->setPixmaps(iMenuPix, iMenuPixDown); // fixme
button[BtnSticky]->setPixmaps(iPinupPix, iPinupPixDown);
button[BtnIconify]->setPixmaps(iIconifyPix, iIconifyPixDown);
button[BtnClose]->setPixmaps(iClosePix, iClosePixDown);
button[BtnHelp]->setPixmaps(iHelpPix, iHelpPixDown);
if(isMaximized())
button[BtnMax]->setPixmaps(iNormalizePix, iNormalizePixDown);
else
button[BtnMax]->setPixmaps(iMaxPix, iMaxPixDown);
}
QColor c = options->colorGroup(Options::TitleBar, isActive()). QColor c = options->colorGroup(Options::TitleBar, isActive()).
color(QColorGroup::Button); color(QColorGroup::Button);
for(i=0; i < 6; ++i) for(i=0; i < 6; ++i)
@ -519,16 +528,12 @@ void B2Client::stickyChange(bool on)
void B2Client::maximizeChange(bool m) void B2Client::maximizeChange(bool m)
{ {
if(m){ if(m){
if(isActive()) button[BtnMax]->setPixmaps(aNormalizePix, aNormalizePixDown,
button[BtnMax]->setPixmaps(aNormalizePix, aNormalizePixDown); iNormalizePix, iNormalizePixDown);
else
button[BtnMax]->setPixmaps(iNormalizePix, iNormalizePixDown);
} }
else{ else{
if(isActive()) button[BtnMax]->setPixmaps(aMaxPix, aMaxPixDown, iMaxPix,
button[BtnMax]->setPixmaps(aMaxPix, aMaxPixDown); iMaxPixDown);
else
button[BtnMax]->setPixmaps(iMaxPix, iMaxPixDown);
} }
button[BtnMax]->repaint(); button[BtnMax]->repaint();
} }
@ -536,36 +541,14 @@ void B2Client::maximizeChange(bool m)
void B2Client::activeChange(bool on) void B2Client::activeChange(bool on)
{ {
if(on){
button[BtnMenu]->setPixmaps(aMenuPix, aMenuPixDown);
button[BtnSticky]->setPixmaps(aPinupPix, aPinupPixDown);
button[BtnIconify]->setPixmaps(aIconifyPix, aIconifyPixDown);
button[BtnClose]->setPixmaps(aClosePix, aClosePixDown);
button[BtnHelp]->setPixmaps(aHelpPix, aHelpPixDown);
if(isMaximized())
button[BtnMax]->setPixmaps(aNormalizePix, aNormalizePixDown);
else
button[BtnMax]->setPixmaps(aMaxPix, aMaxPixDown);
}
else{
button[BtnMenu]->setPixmaps(iMenuPix, iMenuPixDown);
button[BtnSticky]->setPixmaps(iPinupPix, iPinupPixDown);
button[BtnIconify]->setPixmaps(iIconifyPix, iIconifyPixDown);
button[BtnClose]->setPixmaps(iClosePix, iClosePixDown);
button[BtnHelp]->setPixmaps(iHelpPix, iHelpPixDown);
if(isMaximized())
button[BtnMax]->setPixmaps(iNormalizePix, iNormalizePixDown);
else
button[BtnMax]->setPixmaps(iMaxPix, iMaxPixDown);
}
int i; int i;
repaint(false);
QColor c = options->colorGroup(Options::TitleBar, on). QColor c = options->colorGroup(Options::TitleBar, on).
color(QColorGroup::Button); color(QColorGroup::Button);
for(i=0; i < 6; ++i){ for(i=0; i < 6; ++i){
button[i]->setBg(c); button[i]->setBg(c);
button[i]->repaint(); button[i]->repaint();
} }
Client::activeChange(on);
} }
void B2Client::init() void B2Client::init()
@ -595,8 +578,8 @@ void B2Client::slotReset()
static void redraw_pixmaps() static void redraw_pixmaps()
{ {
QColorGroup aGrp = options->colorGroup(Options::ButtonSingleColor, true); QColorGroup aGrp = options->colorGroup(Options::ButtonBg, true);
QColorGroup iGrp = options->colorGroup(Options::ButtonSingleColor, false); QColorGroup iGrp = options->colorGroup(Options::ButtonBg, false);
// close // close
drawB2Rect(aClosePix, aGrp.button(), false); drawB2Rect(aClosePix, aGrp.button(), false);

View file

@ -13,11 +13,13 @@ class QGridLayout;
class B2Button : public QButton class B2Button : public QButton
{ {
public: public:
B2Button(QWidget *parent=0, const char *name=0) B2Button(Client *parent=0, const char *name=0)
: QButton(parent, name){useMiniIcon = false;} : QButton(parent, name){useMiniIcon = false; client = parent;}
B2Button(KPixmap *pix, KPixmap *pixDown, QWidget *parent=0, const char *name=0); B2Button(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix, KPixmap *iPixDown,
Client *parent=0, const char *name=0);
void setBg(const QColor &c){bg = c;} void setBg(const QColor &c){bg = c;}
void setPixmaps(KPixmap *pix, KPixmap *pixDown); void setPixmaps(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
KPixmap *iPixDown);
void setToggle(){setToggleType(Toggle);} void setToggle(){setToggleType(Toggle);}
void setActive(bool on){setOn(on);} void setActive(bool on){setOn(on);}
void setUseMiniIcon(){useMiniIcon = true;} void setUseMiniIcon(){useMiniIcon = true;}
@ -27,8 +29,9 @@ protected:
virtual void drawButton(QPainter *p); virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;} void drawButtonLabel(QPainter *){;}
bool useMiniIcon; bool useMiniIcon;
KPixmap *pNorm, *pDown; KPixmap *pNorm, *pDown, *iNorm, *iDown;
QColor bg; //only use one color (the rest is pixmap) so forget QPalette ;) QColor bg; //only use one color (the rest is pixmap) so forget QPalette ;)
Client *client;
}; };
class B2Client : public Client class B2Client : public Client