Might as well make colorgroups static too. Also fixed a memleak
(pixmaps_created was never set to true). svn path=/trunk/kdebase/kwin/; revision=30498
This commit is contained in:
parent
92e1e869b1
commit
b844f223e2
4 changed files with 64 additions and 33 deletions
44
beclient.cpp
44
beclient.cpp
|
@ -38,20 +38,40 @@ static const char * size_xpm[] = {
|
|||
static QPixmap* size_pix = 0;
|
||||
static bool pixmaps_created = FALSE;
|
||||
|
||||
static QColorGroup *aFrameGrp = 0;
|
||||
static QColorGroup *iFrameGrp = 0;
|
||||
static QColorGroup *aTitleGrp = 0;
|
||||
static QColorGroup *iTitleGrp = 0;
|
||||
static bool colors_created = FALSE;
|
||||
|
||||
static void create_pixmaps()
|
||||
{
|
||||
if ( pixmaps_created )
|
||||
return;
|
||||
pixmaps_created = true;
|
||||
size_pix = new QPixmap( size_xpm );
|
||||
}
|
||||
|
||||
|
||||
static void create_colorgroups()
|
||||
{
|
||||
if(colors_created)
|
||||
return;
|
||||
colors_created = true;
|
||||
aFrameGrp = BeClient::makeColorGroup(options->
|
||||
color(Options::Frame, true));
|
||||
iFrameGrp = BeClient::makeColorGroup(options->
|
||||
color(Options::Frame, false));
|
||||
aTitleGrp = BeClient::makeColorGroup(options->
|
||||
color(Options::TitleBar, true));
|
||||
iTitleGrp = BeClient::makeColorGroup(options->
|
||||
color(Options::TitleBar, false));
|
||||
}
|
||||
|
||||
BeClient::BeClient( Workspace *ws, WId w, QWidget *parent, const char *name )
|
||||
: Client( ws, w, parent, name, WResizeNoErase )
|
||||
{
|
||||
create_pixmaps();
|
||||
|
||||
create_colorgroups();
|
||||
QGridLayout* g = new QGridLayout( this, 0, 0, 2 );
|
||||
g->addRowSpacing(1, 2);
|
||||
g->setRowStretch( 2, 10 );
|
||||
|
@ -70,12 +90,6 @@ BeClient::BeClient( Workspace *ws, WId w, QWidget *parent, const char *name )
|
|||
hb->addItem( titlebar );
|
||||
|
||||
hb->addStretch();
|
||||
|
||||
aFrameGrp = makeColorGroup(options->color(Options::Frame, true));
|
||||
iFrameGrp = makeColorGroup(options->color(Options::Frame, false));
|
||||
aTitleGrp = makeColorGroup(options->color(Options::TitleBar, true));
|
||||
iTitleGrp = makeColorGroup(options->color(Options::TitleBar, false));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -115,17 +129,17 @@ void BeClient::paintEvent( QPaintEvent* )
|
|||
QRect bar ( 0, 0, titlebar->geometry().right()+1,
|
||||
titlebar->geometry().bottom() );
|
||||
qDrawWinPanel( &p, 0, bar.bottom()+2, width(), height() - bar.bottom()-2,
|
||||
isActive() ? aFrameGrp : iFrameGrp, FALSE );
|
||||
isActive() ? *aFrameGrp : *iFrameGrp, FALSE );
|
||||
qDrawWinPanel( &p, 2, bar.bottom()+4, width()-4, height() - bar.bottom()-6,
|
||||
isActive() ? aFrameGrp : iFrameGrp, TRUE );
|
||||
isActive() ? *aFrameGrp : *iFrameGrp, TRUE );
|
||||
QRect t = titlebar->geometry();
|
||||
|
||||
bar.setBottom( bar.bottom() + 3 );
|
||||
p.setClipRect( bar );
|
||||
bar.setBottom( bar.bottom() + 2 );
|
||||
qDrawWinPanel( &p, bar, isActive() ? aTitleGrp : iTitleGrp, FALSE,
|
||||
isActive() ? &aTitleGrp.brush(QColorGroup::Background) :
|
||||
&iTitleGrp.brush(QColorGroup::Background));
|
||||
qDrawWinPanel( &p, bar, isActive() ? *aTitleGrp : *iTitleGrp, FALSE,
|
||||
isActive() ? &aTitleGrp->brush(QColorGroup::Background) :
|
||||
&iTitleGrp->brush(QColorGroup::Background));
|
||||
p.setClipping( FALSE );
|
||||
|
||||
p.drawPixmap( t.right() - 20, t.center().y()-8, *size_pix );
|
||||
|
@ -215,9 +229,9 @@ void BeClient::mouseDoubleClickEvent( QMouseEvent * e )
|
|||
workspace()->requestFocus( this );
|
||||
}
|
||||
|
||||
QColorGroup BeClient::makeColorGroup(const QColor &bg, const QColor &fg)
|
||||
QColorGroup* BeClient::makeColorGroup(const QColor &bg, const QColor &fg)
|
||||
{
|
||||
return(QColorGroup( fg, bg, bg.light(150), bg.dark(),
|
||||
return(new QColorGroup( fg, bg, bg.light(150), bg.dark(),
|
||||
bg.dark(120), fg,
|
||||
QApplication::palette().normal().base()));
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
#ifndef BECLIENT_H
|
||||
#define BECLIENT_H
|
||||
#include "client.h"
|
||||
#include <qpalette.h>
|
||||
class QToolButton;
|
||||
class QLabel;
|
||||
class QSpacerItem;
|
||||
|
@ -13,9 +12,10 @@ class BeClient : public Client
|
|||
public:
|
||||
BeClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
|
||||
~BeClient();
|
||||
static QColorGroup* makeColorGroup(const QColor &bg,
|
||||
const QColor &fg=Qt::white);
|
||||
|
||||
protected:
|
||||
QColorGroup makeColorGroup(const QColor &bg, const QColor &fg=Qt::white);
|
||||
void resizeEvent( QResizeEvent* );
|
||||
void paintEvent( QPaintEvent* );
|
||||
void mousePressEvent( QMouseEvent * );
|
||||
|
@ -32,7 +32,6 @@ protected:
|
|||
private:
|
||||
QSpacerItem* titlebar;
|
||||
void doShape();
|
||||
QColorGroup aFrameGrp, iFrameGrp, aTitleGrp, iTitleGrp;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -172,10 +172,32 @@ static QPixmap* pinup_pix = 0;
|
|||
static QPixmap* pindown_pix = 0;
|
||||
static bool pixmaps_created = FALSE;
|
||||
|
||||
static QColorGroup *aFrameGrp = 0;
|
||||
static QColorGroup *iFrameGrp = 0;
|
||||
static QColorGroup *aTitleGrp = 0;
|
||||
static QColorGroup *iTitleGrp = 0;
|
||||
static bool colors_created = FALSE;
|
||||
|
||||
static void create_colorgroups()
|
||||
{
|
||||
if(colors_created)
|
||||
return;
|
||||
colors_created = true;
|
||||
aFrameGrp = StdClient::makeColorGroup(options->
|
||||
color(Options::Frame, true));
|
||||
iFrameGrp = StdClient::makeColorGroup(options->
|
||||
color(Options::Frame, false));
|
||||
aTitleGrp = StdClient::makeColorGroup(options->
|
||||
color(Options::TitleBar, true));
|
||||
iTitleGrp = StdClient::makeColorGroup(options->
|
||||
color(Options::TitleBar, false));
|
||||
}
|
||||
|
||||
static void create_pixmaps()
|
||||
{
|
||||
if ( pixmaps_created )
|
||||
return;
|
||||
pixmaps_created = true;
|
||||
close_pix = new QPixmap( close_xpm );
|
||||
maximize_pix = new QPixmap( maximize_xpm );
|
||||
minimize_pix = new QPixmap( minimize_xpm );
|
||||
|
@ -190,6 +212,7 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name )
|
|||
: Client( ws, w, parent, name, WResizeNoErase )
|
||||
{
|
||||
create_pixmaps();
|
||||
create_colorgroups();
|
||||
|
||||
|
||||
QGridLayout* g = new QGridLayout( this, 0, 0, 2 );
|
||||
|
@ -240,10 +263,6 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name )
|
|||
button[5]->setIconSet( *close_pix );
|
||||
connect( button[5], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
|
||||
|
||||
aFrameGrp = makeColorGroup(options->color(Options::Frame, true));
|
||||
iFrameGrp = makeColorGroup(options->color(Options::Frame, false));
|
||||
aTitleGrp = makeColorGroup(options->color(Options::TitleBar, true));
|
||||
iTitleGrp = makeColorGroup(options->color(Options::TitleBar, false));
|
||||
}
|
||||
|
||||
|
||||
|
@ -299,11 +318,11 @@ void StdClient::paintEvent( QPaintEvent* )
|
|||
QRegion r = rect();
|
||||
r = r.subtract( t );
|
||||
p.setClipRegion( r );
|
||||
qDrawWinPanel( &p, rect(), isActive()? aFrameGrp : iFrameGrp );
|
||||
qDrawWinPanel( &p, rect(), isActive()? *aFrameGrp : *iFrameGrp );
|
||||
p.setClipping( FALSE );
|
||||
p.fillRect( t, options->color(Options::TitleBar, isActive()));
|
||||
qDrawShadePanel( &p, t.x(), t.y(), t.width(), t.height(),
|
||||
isActive() ? aTitleGrp : iTitleGrp, TRUE );
|
||||
isActive() ? *aTitleGrp : *iTitleGrp, TRUE );
|
||||
|
||||
t.setTop( 2 );
|
||||
t.setLeft( t.left() + 4 );
|
||||
|
@ -336,9 +355,9 @@ void StdClient::iconChange()
|
|||
button[0]->repaint( FALSE );
|
||||
}
|
||||
|
||||
QColorGroup StdClient::makeColorGroup(const QColor &bg, const QColor &fg)
|
||||
QColorGroup* StdClient::makeColorGroup(const QColor &bg, const QColor &fg)
|
||||
{
|
||||
return(QColorGroup( fg, bg, bg.light(150), bg.dark(),
|
||||
return(new QColorGroup( fg, bg, bg.light(150), bg.dark(),
|
||||
bg.dark(120), fg,
|
||||
QApplication::palette().normal().base()));
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
class QToolButton;
|
||||
class QLabel;
|
||||
class QSpacerItem;
|
||||
class QColorGroup;
|
||||
|
||||
class StdClient : public Client
|
||||
{
|
||||
|
@ -12,13 +11,14 @@ class StdClient : public Client
|
|||
public:
|
||||
StdClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
|
||||
~StdClient();
|
||||
static QColorGroup* makeColorGroup(const QColor &bg,
|
||||
const QColor &fg=Qt::white);
|
||||
protected:
|
||||
void resizeEvent( QResizeEvent* );
|
||||
void paintEvent( QPaintEvent* );
|
||||
|
||||
void mouseDoubleClickEvent( QMouseEvent * );
|
||||
void init();
|
||||
QColorGroup makeColorGroup(const QColor &bg, const QColor &fg=Qt::white);
|
||||
void captionChange( const QString& name );
|
||||
void iconChange();
|
||||
void maximizeChange( bool );
|
||||
|
@ -27,7 +27,6 @@ protected:
|
|||
private:
|
||||
QToolButton* button[6];
|
||||
QSpacerItem* titlebar;
|
||||
QColorGroup aFrameGrp, iFrameGrp, aTitleGrp, iTitleGrp;
|
||||
};
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue