A few fixes, moved colorgroups to the Options class (much nicer there), and

started on a fixed system style. If you try it out make sure to read the new
README, as it requires some gradient settings.

svn path=/trunk/kdebase/kwin/; revision=30585
This commit is contained in:
Daniel M. Duley 1999-10-11 02:00:06 +00:00
parent b844f223e2
commit 37b09be6f3
9 changed files with 79 additions and 91 deletions

View file

@ -4,8 +4,8 @@ LDFLAGS = $(all_libraries) $(KDE_RPATH)
bin_PROGRAMS = kwin bin_PROGRAMS = kwin
kwin_SOURCES = atoms.cpp beclient.cpp client.cpp main.cpp stdclient.cpp workspace.cpp tabbox.cpp options.cpp kwin_SOURCES = atoms.cpp beclient.cpp client.cpp main.cpp stdclient.cpp workspace.cpp tabbox.cpp options.cpp systemclient.cpp
kwin_LDADD = $(LIB_KDECORE) kwin_LDADD = $(LIB_KDECORE) $(LIB_KDEUI)
METASOURCES = AUTO METASOURCES = AUTO

View file

@ -38,12 +38,6 @@ static const char * size_xpm[] = {
static QPixmap* size_pix = 0; static QPixmap* size_pix = 0;
static bool pixmaps_created = FALSE; 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() static void create_pixmaps()
{ {
if ( pixmaps_created ) if ( pixmaps_created )
@ -52,26 +46,10 @@ static void create_pixmaps()
size_pix = new QPixmap( size_xpm ); 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 ) BeClient::BeClient( Workspace *ws, WId w, QWidget *parent, const char *name )
: Client( ws, w, parent, name, WResizeNoErase ) : Client( ws, w, parent, name, WResizeNoErase )
{ {
create_pixmaps(); create_pixmaps();
create_colorgroups();
QGridLayout* g = new QGridLayout( this, 0, 0, 2 ); QGridLayout* g = new QGridLayout( this, 0, 0, 2 );
g->addRowSpacing(1, 2); g->addRowSpacing(1, 2);
g->setRowStretch( 2, 10 ); g->setRowStretch( 2, 10 );
@ -129,17 +107,18 @@ void BeClient::paintEvent( QPaintEvent* )
QRect bar ( 0, 0, titlebar->geometry().right()+1, QRect bar ( 0, 0, titlebar->geometry().right()+1,
titlebar->geometry().bottom() ); titlebar->geometry().bottom() );
qDrawWinPanel( &p, 0, bar.bottom()+2, width(), height() - bar.bottom()-2, qDrawWinPanel( &p, 0, bar.bottom()+2, width(), height() - bar.bottom()-2,
isActive() ? *aFrameGrp : *iFrameGrp, FALSE ); options->colorGroup(Options::Frame, false));
qDrawWinPanel( &p, 2, bar.bottom()+4, width()-4, height() - bar.bottom()-6, qDrawWinPanel( &p, 2, bar.bottom()+4, width()-4, height() - bar.bottom()-6,
isActive() ? *aFrameGrp : *iFrameGrp, TRUE ); options->colorGroup(Options::Frame, true));
QRect t = titlebar->geometry(); QRect t = titlebar->geometry();
bar.setBottom( bar.bottom() + 3 ); bar.setBottom( bar.bottom() + 3 );
p.setClipRect( bar ); p.setClipRect( bar );
bar.setBottom( bar.bottom() + 2 ); bar.setBottom( bar.bottom() + 2 );
qDrawWinPanel( &p, bar, isActive() ? *aTitleGrp : *iTitleGrp, FALSE, qDrawWinPanel( &p, bar, options->colorGroup(Options::TitleBar, isActive()),
isActive() ? &aTitleGrp->brush(QColorGroup::Background) : FALSE, &options->colorGroup(Options::TitleBar, isActive()).
&iTitleGrp->brush(QColorGroup::Background)); brush(QColorGroup::Background));
p.setClipping( FALSE ); p.setClipping( FALSE );
p.drawPixmap( t.right() - 20, t.center().y()-8, *size_pix ); p.drawPixmap( t.right() - 20, t.center().y()-8, *size_pix );
@ -229,9 +208,3 @@ void BeClient::mouseDoubleClickEvent( QMouseEvent * e )
workspace()->requestFocus( this ); workspace()->requestFocus( this );
} }
QColorGroup* BeClient::makeColorGroup(const QColor &bg, const QColor &fg)
{
return(new QColorGroup( fg, bg, bg.light(150), bg.dark(),
bg.dark(120), fg,
QApplication::palette().normal().base()));
}

View file

@ -12,9 +12,6 @@ class BeClient : public Client
public: public:
BeClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 ); BeClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~BeClient(); ~BeClient();
static QColorGroup* makeColorGroup(const QColor &bg,
const QColor &fg=Qt::white);
protected: protected:
void resizeEvent( QResizeEvent* ); void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* ); void paintEvent( QPaintEvent* );

View file

@ -80,6 +80,7 @@ Application::~Application()
for ( WorkspaceList::Iterator it = workspaces.begin(); it != workspaces.end(); ++it) { for ( WorkspaceList::Iterator it = workspaces.begin(); it != workspaces.end(); ++it) {
delete (*it); delete (*it);
} }
delete options;
} }
bool Application::x11EventFilter( XEvent *e ) bool Application::x11EventFilter( XEvent *e )

View file

@ -4,12 +4,24 @@
#include <kconfig.h> #include <kconfig.h>
#include <kglobal.h> #include <kglobal.h>
// increment this when you add a color type (mosfet) Options::Options()
#define KWINCOLORS 8 {
Options::Options(){ int i;
for(i=0; i < KWINCOLORS*2; ++i)
cg[i] = NULL;
reload(); reload();
} }
Options::~Options(){
int i;
for(i=0; i < KWINCOLORS*2; ++i){
if(cg[i]){
delete cg[i];
cg[i] = NULL;
}
}
}
const QColor& Options::color(ColorType type, bool active) const QColor& Options::color(ColorType type, bool active)
{ {
return(colors[type + (active ? 0 : KWINCOLORS)]); return(colors[type + (active ? 0 : KWINCOLORS)]);
@ -20,6 +32,17 @@ const QFont& Options::font(bool active)
return(active ? activeFont : inactiveFont); return(active ? activeFont : inactiveFont);
} }
const QColorGroup& Options::colorGroup(ColorType type, bool active)
{
int idx = type + (active ? 0 : KWINCOLORS);
if(cg[idx])
return(*cg[idx]);
cg[idx] = new QColorGroup(Qt::black, colors[idx], colors[idx].light(150),
colors[idx].dark(), colors[idx].dark(120),
Qt::black, QApplication::palette().normal().
base());
return(*cg[idx]);
}
void Options::reload() void Options::reload()
{ {
@ -35,9 +58,9 @@ void Options::reload()
colors[Frame] = Qt::lightGray; colors[Frame] = Qt::lightGray;
colors[Frame] = config->readColorEntry("frame", &colors[Frame]); colors[Frame] = config->readColorEntry("frame", &colors[Frame]);
colors[Handle] = config->readColorEntry("handle", &colors[Frame]); colors[Handle] = config->readColorEntry("handle", &colors[Frame]);
colors[ButtonBg] = config->readColorEntry("buttonBackground", colors[ButtonBg] = config->readColorEntry("buttonBackgroundDown",
&colors[Frame]); &colors[Frame]);
colors[ButtonBlend] = config->readColorEntry("buttonBlend", colors[ButtonBlend] = config->readColorEntry("buttonBlendDown",
&colors[ButtonBg]); &colors[ButtonBg]);
colors[TitleBar] = Qt::darkBlue; colors[TitleBar] = Qt::darkBlue;
colors[TitleBar] = config->readColorEntry("activeBackground", colors[TitleBar] = config->readColorEntry("activeBackground",
@ -48,34 +71,42 @@ void Options::reload()
colors[Font] = Qt::white; colors[Font] = Qt::white;
colors[Font] = config->readColorEntry("activeForeground", &colors[Font]); colors[Font] = config->readColorEntry("activeForeground", &colors[Font]);
colors[ButtonFg] = Qt::lightGray; colors[ButtonFg] = Qt::lightGray;
colors[ButtonFg] = config->readColorEntry("buttonForeground", colors[ButtonFg] = config->readColorEntry("buttonForegroundDown",
&colors[ButtonFg]); &colors[ButtonFg]);
// inactive // inactive
colors[Frame+KWINCOLORS] = colors[Frame];
colors[Frame+KWINCOLORS] = colors[Frame+KWINCOLORS] =
config->readColorEntry("inactiveFrame", &colors[Frame+KWINCOLORS]); config->readColorEntry("inactiveFrame", &colors[Frame]);
colors[Handle+KWINCOLORS] =
config->readColorEntry("inactiveHandle", &colors[Frame+KWINCOLORS]);
colors[TitleBar+KWINCOLORS] = Qt::darkGray; colors[TitleBar+KWINCOLORS] = Qt::darkGray;
colors[TitleBar+KWINCOLORS] = config-> colors[TitleBar+KWINCOLORS] = config->
readColorEntry("inactiveBackground", &colors[TitleBar+KWINCOLORS]); readColorEntry("inactiveBackground", &colors[TitleBar+KWINCOLORS]);
colors[TitleBlend+KWINCOLORS] = colors[TitleBlend+KWINCOLORS] =
config->readColorEntry("inactiveBlend", &colors[TitleBar+KWINCOLORS]); config->readColorEntry("inactiveBlend", &colors[TitleBar+KWINCOLORS]);
colors[ButtonBg+KWINCOLORS] = colors[ButtonBg+KWINCOLORS] =
config->readColorEntry("inactiveButtonBackground", config->readColorEntry("buttonBackground",
&colors[Frame+KWINCOLORS]); &colors[ButtonBg]);
colors[ButtonBlend+KWINCOLORS] = colors[ButtonBlend+KWINCOLORS] =
config->readColorEntry("inactiveButtonBlend", config->readColorEntry("buttonBlend",
&colors[ButtonBg+KWINCOLORS]); &colors[ButtonBlend]);
colors[ButtonFg+KWINCOLORS] = config->
readColorEntry("buttonForeground", &colors[ButtonFg]);
colors[Handle+KWINCOLORS] =
config->readColorEntry("inactiveHandle", &colors[Handle]);
colors[Font+KWINCOLORS] = Qt::lightGray; colors[Font+KWINCOLORS] = Qt::lightGray;
colors[Font+KWINCOLORS] = config->readColorEntry("inactiveForeground", colors[Font+KWINCOLORS] = config->readColorEntry("inactiveForeground",
&colors[Font+KWINCOLORS]); &colors[Font+KWINCOLORS]);
colors[ButtonFg+KWINCOLORS] = config->
readColorEntry("inactiveButtonForeground", &colors[ButtonFg]);
activeFont = QFont("Helvetica", 12, QFont::Bold); activeFont = QFont("Helvetica", 12, QFont::Bold);
activeFont = config->readFontEntry("activeFont", &activeFont); activeFont = config->readFontEntry("activeFont", &activeFont);
inactiveFont = config->readFontEntry("inactiveFont", &activeFont); inactiveFont = config->readFontEntry("inactiveFont", &activeFont);
int i;
for(i=0; i < KWINCOLORS*2; ++i){
if(cg[i]){
delete cg[i];
cg[i] = NULL;
}
}
} }

View file

@ -2,7 +2,10 @@
#define OPTIONS_H #define OPTIONS_H
#include <qfont.h> #include <qfont.h>
#include <qcolor.h> #include <qpalette.h>
// increment this when you add a color type (mosfet)
#define KWINCOLORS 8
class Options { class Options {
public: public:
@ -41,7 +44,7 @@ public:
* Not all styles have to implement all the colors, but for the ones that * Not all styles have to implement all the colors, but for the ones that
* are implemented you should retrieve them here. * are implemented you should retrieve them here.
*/ */
// increment KWINCOLORS in options.cpp if you add something (mosfet) // increment KWINCOLORS if you add something (mosfet)
enum ColorType{TitleBar=0, TitleBlend, Font, ButtonFg, ButtonBg, enum ColorType{TitleBar=0, TitleBlend, Font, ButtonFg, ButtonBg,
ButtonBlend, Frame, Handle}; ButtonBlend, Frame, Handle};
@ -56,6 +59,10 @@ public:
* Return the color for the given decoration. * Return the color for the given decoration.
*/ */
const QColor& color(ColorType type, bool active=true); const QColor& color(ColorType type, bool active=true);
/**
* Return a colorgroup using the given decoration color as the background
*/
const QColorGroup& colorGroup(ColorType type, bool active=true);
/** /**
* Return the active or inactive decoration font. * Return the active or inactive decoration font.
*/ */
@ -64,9 +71,11 @@ public:
void reload(); void reload();
Options(); Options();
~Options();
protected: protected:
QFont activeFont, inactiveFont; QFont activeFont, inactiveFont;
QColor colors[16]; QColor colors[KWINCOLORS*2];
QColorGroup *cg[KWINCOLORS*2];
}; };
extern Options* options; extern Options* options;

View file

@ -172,27 +172,6 @@ static QPixmap* pinup_pix = 0;
static QPixmap* pindown_pix = 0; static QPixmap* pindown_pix = 0;
static bool pixmaps_created = FALSE; 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() static void create_pixmaps()
{ {
if ( pixmaps_created ) if ( pixmaps_created )
@ -212,8 +191,6 @@ StdClient::StdClient( Workspace *ws, WId w, QWidget *parent, const char *name )
: Client( ws, w, parent, name, WResizeNoErase ) : Client( ws, w, parent, name, WResizeNoErase )
{ {
create_pixmaps(); create_pixmaps();
create_colorgroups();
QGridLayout* g = new QGridLayout( this, 0, 0, 2 ); QGridLayout* g = new QGridLayout( this, 0, 0, 2 );
g->setRowStretch( 1, 10 ); g->setRowStretch( 1, 10 );
@ -318,11 +295,11 @@ void StdClient::paintEvent( QPaintEvent* )
QRegion r = rect(); QRegion r = rect();
r = r.subtract( t ); r = r.subtract( t );
p.setClipRegion( r ); p.setClipRegion( r );
qDrawWinPanel( &p, rect(), isActive()? *aFrameGrp : *iFrameGrp ); qDrawWinPanel( &p, rect(), options->colorGroup(Options::Frame, isActive()));
p.setClipping( FALSE ); p.setClipping( FALSE );
p.fillRect( t, options->color(Options::TitleBar, isActive())); p.fillRect( t, options->color(Options::TitleBar, isActive()));
qDrawShadePanel( &p, t.x(), t.y(), t.width(), t.height(), qDrawShadePanel( &p, t.x(), t.y(), t.width(), t.height(),
isActive() ? *aTitleGrp : *iTitleGrp, TRUE ); options->colorGroup(Options::TitleBar, isActive()), true);
t.setTop( 2 ); t.setTop( 2 );
t.setLeft( t.left() + 4 ); t.setLeft( t.left() + 4 );
@ -355,9 +332,3 @@ void StdClient::iconChange()
button[0]->repaint( FALSE ); button[0]->repaint( FALSE );
} }
QColorGroup* StdClient::makeColorGroup(const QColor &bg, const QColor &fg)
{
return(new QColorGroup( fg, bg, bg.light(150), bg.dark(),
bg.dark(120), fg,
QApplication::palette().normal().base()));
}

View file

@ -11,8 +11,6 @@ class StdClient : public Client
public: public:
StdClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 ); StdClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~StdClient(); ~StdClient();
static QColorGroup* makeColorGroup(const QColor &bg,
const QColor &fg=Qt::white);
protected: protected:
void resizeEvent( QResizeEvent* ); void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* ); void paintEvent( QPaintEvent* );

View file

@ -2,6 +2,7 @@
#include "client.h" #include "client.h"
#include "stdclient.h" #include "stdclient.h"
#include "beclient.h" #include "beclient.h"
#include "systemclient.h"
#include "tabbox.h" #include "tabbox.h"
#include "atoms.h" #include "atoms.h"
#include <X11/X.h> #include <X11/X.h>
@ -657,6 +658,7 @@ void Workspace::showPopup( const QPoint& pos, Client* c)
QPopupMenu* deco = new QPopupMenu( popup ); QPopupMenu* deco = new QPopupMenu( popup );
deco->insertItem("KDE Classic", 100 ); deco->insertItem("KDE Classic", 100 );
deco->insertItem("Be-like style", 101 ); deco->insertItem("Be-like style", 101 );
deco->insertItem("System style", 102 );
popup->insertItem("Decoration", deco ); popup->insertItem("Decoration", deco );
} }
@ -671,6 +673,9 @@ void Workspace::showPopup( const QPoint& pos, Client* c)
case 101: case 101:
setDecoration( 1 ); setDecoration( 1 );
break; break;
case 102:
setDecoration( 2 );
break;
default: default:
break; break;
} }
@ -855,7 +860,10 @@ void Workspace::setDecoration( int deco )
switch ( deco ) { switch ( deco ) {
case 1: case 1:
c = new BeClient( this, w); c = new BeClient( this, w);
break; break;
case 2:
c = new SystemClient(this, w);
break;
default: default:
c = new StdClient( this, w ); c = new StdClient( this, w );
} }