Removing the styles I wrote except the default one, and will be maintaining

them outside of CVS.

svn path=/trunk/kdebase/kwin/; revision=102431
icc-effect-5.14.5
Daniel M. Duley 2001-06-16 00:48:49 +00:00
parent bbee1d9340
commit 29af54215b
33 changed files with 1 additions and 5429 deletions

View File

@ -1 +1 @@
SUBDIRS = default kde1 kstep system b2 laptop riscos modernsystem win2k kwmtheme quartz icewm web mwm
SUBDIRS = default kde1 riscos win2k quartz icewm web mwm

View File

@ -1,21 +0,0 @@
INCLUDES = $(all_includes)
kde_module_LTLIBRARIES = libkwinb2.la
libkwinb2_la_SOURCES = b2client.cpp
libkwinb2_la_LIBADD = ../../kwin.la
libkwinb2_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
METASOURCES = AUTO
noinst_HEADERS = b2client.h
lnkdir = $(kde_datadir)/kwin/
lnk_DATA = b2.desktop
EXTRA_DIST = $(lnk_DATA)
###KMAKE-start (don't edit or delete this block)
###KMAKE-end

View File

@ -1,3 +0,0 @@
[Desktop Entry]
Name=B II
X-KDE-Library=libkwinb2

File diff suppressed because it is too large Load Diff

View File

@ -1,120 +0,0 @@
#ifndef __B2CLIENT_H
#define __B2CLIENT_H
#include <qtoolbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
class QLabel;
//class QSpacerItem;
//class QHBoxLayout;
class QGridLayout;
namespace KWinInternal {
class B2Button : public QButton
{
Q_OBJECT
public:
B2Button(Client *_client=0, QWidget *parent=0, const char *name=0)
: QButton(parent, name){useMiniIcon = false; client = _client;}
B2Button(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix, KPixmap *iPixDown,
Client *_client=0, QWidget *parent=0, const char *name=0);
void setBg(const QColor &c){bg = c;}
void setPixmaps(KPixmap *pix, KPixmap *pixDown, KPixmap *iPix,
KPixmap *iPixDown);
void setToggle(){setToggleType(Toggle);}
void setActive(bool on){setOn(on);}
void setUseMiniIcon(){useMiniIcon = true;}
QSize sizeHint() const;
QSizePolicy sizePolicy() const;
protected:
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
bool useMiniIcon;
KPixmap *pNorm, *pDown, *iNorm, *iDown;
QColor bg; //only use one color (the rest is pixmap) so forget QPalette ;)
Client *client;
void mousePressEvent( QMouseEvent* e );
void mouseReleaseEvent( QMouseEvent* e );
public:
int last_button;
};
class B2Client;
class B2Titlebar : public QWidget
{
Q_OBJECT
public:
B2Titlebar(B2Client *parent);
~B2Titlebar(){;}
bool isFullyObscured() const {return isfullyobscured;}
void recalcBuffer();
protected:
void paintEvent( QPaintEvent* );
bool x11Event(XEvent *e);
void mouseDoubleClickEvent( QMouseEvent * );
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
void mouseMoveEvent(QMouseEvent *);
void init();
void resizeEvent(QResizeEvent *ev);
QString oldTitle;
KPixmap titleBuffer;
bool set_x11mask;
bool isfullyobscured;
bool shift_move;
QPoint moveOffset;
B2Client *client;
};
class B2Client : public KWinInternal::Client
{
Q_OBJECT
friend class B2Titlebar;
public:
B2Client( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~B2Client(){;}
void unobscureTitlebar();
void titleMoveAbs(int new_ofs);
void titleMoveRel(int xdiff);
protected:
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void showEvent( QShowEvent* );
void windowWrapperShowEvent( QShowEvent* );
void init();
void captionChange( const QString& name );
void stickyChange(bool on);
void activeChange(bool on);
void maximizeChange(bool m);
void iconChange();
void doShape();
MousePosition mousePosition( const QPoint& p ) const;
private slots:
void menuButtonPressed();
void slotReset();
void maxButtonClicked();
private:
void positionButtons();
enum ButtonType{BtnMenu=0, BtnSticky, BtnIconify, BtnMax, BtnClose,
BtnHelp};
//B2Button* button[5];
B2Button* button[6];
//QSpacerItem* titlebar;
//QHBoxLayout *tLayout;
QGridLayout *g;
int bar_x_ofs;
B2Titlebar *titlebar;
int in_unobs;
};
};
#endif

View File

@ -1,98 +0,0 @@
#ifndef __STDCLIENT_BITMAPS_H
#define __STDCLIENT_BITMAPS_H
/**
* The standard client has the capability to color it's titlebar buttons
* according to the new color scheme. In order to do this it needs a bitmap
* for each shade which it draws into a pixmap with the appropriate color.
* These are all the bitmaps.
*/
static unsigned char close_white_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x04, 0x10, 0x04, 0x08, 0x08, 0x04, 0x10, 0x02,
0x20, 0x01, 0x40, 0x00, 0x40, 0x00, 0x20, 0x01, 0x10, 0x02, 0x08, 0x04,
0x04, 0x08, 0x04, 0x10, 0x00, 0x00, 0x00, 0x00};
static unsigned char close_dgray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x08, 0x20, 0x18, 0x30, 0x30, 0x18, 0x60, 0x0c,
0xc0, 0x06, 0x80, 0x03, 0x80, 0x03, 0xc0, 0x06, 0x60, 0x0c, 0x30, 0x18,
0x18, 0x30, 0x08, 0x20, 0x00, 0x00, 0x00, 0x00};
static unsigned char menu_white_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfc, 0x3f, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char menu_dgray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x20, 0xf8, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char menu_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0xfc, 0x3f, 0x04, 0x20, 0xfc, 0x3f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pindown_white_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x80, 0x1f, 0xa0, 0x03,
0xb0, 0x01, 0x30, 0x01, 0xf0, 0x00, 0x70, 0x00, 0x20, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pindown_gray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1c,
0x00, 0x0e, 0x00, 0x06, 0x00, 0x00, 0x80, 0x07, 0xc0, 0x03, 0xe0, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pindown_dgray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x10, 0x70, 0x20, 0x50, 0x20,
0x48, 0x30, 0xc8, 0x38, 0x08, 0x1f, 0x08, 0x18, 0x10, 0x1c, 0x10, 0x0e,
0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pindown_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0xc0, 0x1f, 0xf0, 0x3f, 0xf0, 0x3f,
0xf8, 0x3f, 0xf8, 0x3f, 0xf8, 0x1f, 0xf8, 0x1f, 0xf0, 0x1f, 0xf0, 0x0f,
0xe0, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pinup_white_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x00, 0x80, 0x11,
0x3f, 0x15, 0x00, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pinup_gray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x0a, 0xbf, 0x0a, 0x80, 0x15, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pinup_dgray_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0x40, 0x31, 0x40, 0x2e,
0x40, 0x20, 0x40, 0x20, 0x7f, 0x2a, 0x40, 0x3f, 0xc0, 0x31, 0xc0, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char pinup_mask_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x20, 0xc0, 0x31, 0xc0, 0x3f,
0xff, 0x3f, 0xff, 0x3f, 0xff, 0x3f, 0xc0, 0x3f, 0xc0, 0x31, 0xc0, 0x20,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char help_mask_bits[] = {
0x00,0x00,0x00,0x00,0xe0,0x03,0xf0,0x07,0x70,0x0e,0x60,0x0e,0x00,0x0f,0x80,
0x07,0xc0,0x03,0xc0,0x01,0x80,0x01,0xc0,0x00,0xc0,0x01,0x80,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x4c,0x0b,0x08,0x58,0x65,0x09,0x08,0x90,0x00,0x00,
0x00,0x09,0x04,0x00,0x00,0x72,0x6f,0x6f,0x74,0x00,0x24,0x31,0x24,0x47,0x6b,
0x65,0x44,0x78,0x63 };
static unsigned char help_dark_bits[] = {
0x00,0x00,0x00,0x00,0xe0,0x03,0x30,0x06,0x30,0x06,0x00,0x06,0x00,0x03,0x80,
0x01,0xc0,0x00,0xc0,0x00,0x00,0x00,0xc0,0x00,0xc0,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x65,0x64,0x28,0x29,0x00,0x00,0x00,0x00,0x90,0x00,0x00,
0x00,0x21,0x00,0x00,0x00,0x34,0xfe,0x12,0x2b,0x00,0x00,0xff,0xff,0x58,0xc0,
0x01,0x2b,0x45,0xfe };
static unsigned char help_light_bits[] = {
0x00,0x00,0x00,0x00,0x00,0x00,0xc0,0x01,0x40,0x08,0x60,0x08,0x00,0x0c,0x00,
0x06,0x00,0x03,0x00,0x01,0x80,0x01,0x00,0x00,0x00,0x01,0x80,0x01,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x4c,0x0b,0x08,0x58,0x65,0x09,0x08,0x90,0x00,0x00,
0x00,0x09,0x04,0x00,0x00,0x72,0x6f,0x6f,0x74,0x00,0x24,0x31,0x24,0x47,0x6b,
0x65,0x44,0x78,0x63 };
#endif

View File

@ -1,21 +0,0 @@
INCLUDES = $(all_includes)
kde_module_LTLIBRARIES = libkwinkstep.la
libkwinkstep_la_SOURCES = nextclient.cpp
libkwinkstep_la_LIBADD = ../../kwin.la
libkwinkstep_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
METASOURCES = AUTO
noinst_HEADERS = nextclient.h
lnkdir = $(kde_datadir)/kwin/
lnk_DATA = kstep.desktop
EXTRA_DIST = $(lnk_DATA)
###KMAKE-start (don't edit or delete this block)
###KMAKE-end

View File

@ -1,9 +0,0 @@
[Desktop Entry]
Name=KStep
Name[da]=KDE Trin
Name[eo]=Paŝo
Name[mi]=KHïkoi
Name[no]=KSteg
Name[pt]=Step
Name[sk]=Kkrok
X-KDE-Library=libkwinkstep

View File

@ -1,391 +0,0 @@
#include "nextclient.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
using namespace KWinInternal;
static unsigned char close_bits[] = {
0x03, 0x03, 0x87, 0x03, 0xce, 0x01, 0xfc, 0x00, 0x78, 0x00, 0x78, 0x00,
0xfc, 0x00, 0xce, 0x01, 0x87, 0x03, 0x03, 0x03};
static unsigned char iconify_bits[] = {
0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0xff, 0x03, 0x03, 0x03, 0x03, 0x03,
0x03, 0x03, 0x03, 0x03, 0xff, 0x03, 0xff, 0x03};
static unsigned char sticky_bits[] = {
0x00, 0x00, 0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0xfe, 0x01, 0xfe, 0x01,
0x30, 0x00, 0x30, 0x00, 0x30, 0x00, 0x00, 0x00};
static unsigned char unsticky_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static KPixmap *aTitlePix=0;
static KPixmap *iTitlePix=0;
static KPixmap *aFramePix=0;
static KPixmap *iFramePix=0;
static KPixmap *aHandlePix=0;
static KPixmap *iHandlePix=0;
static KPixmap *aBtn=0;
static KPixmap *aBtnDown=0;
static KPixmap *iBtn=0;
static KPixmap *iBtnDown=0;
static bool pixmaps_created = false;
static QColor *btnForeground;
static void create_pixmaps()
{
if(pixmaps_created)
return;
pixmaps_created = true;
aTitlePix = new KPixmap();
aTitlePix->resize(32, 14);
KPixmapEffect::gradient(*aTitlePix,
options->color(Options::TitleBar, true),
options->color(Options::TitleBlend, true),
KPixmapEffect::VerticalGradient);
iTitlePix = new KPixmap();
iTitlePix->resize(32, 14);
KPixmapEffect::gradient(*iTitlePix,
options->color(Options::TitleBar, false),
options->color(Options::TitleBlend, false),
KPixmapEffect::VerticalGradient);
// Bottom frame gradient
aFramePix = new KPixmap();
aFramePix->resize(32, 6);
KPixmapEffect::gradient(*aFramePix,
options->color(Options::Frame, true).light(150),
options->color(Options::Frame, true).dark(120),
KPixmapEffect::VerticalGradient);
iFramePix = new KPixmap();
iFramePix->resize(32, 6);
KPixmapEffect::gradient(*iFramePix,
options->color(Options::Frame, false).light(150),
options->color(Options::Frame, false).dark(120),
KPixmapEffect::VerticalGradient);
// Handle gradient
aHandlePix = new KPixmap();
aHandlePix->resize(32, 6);
KPixmapEffect::gradient(*aHandlePix,
options->color(Options::Handle, true).light(150),
options->color(Options::Handle, true).dark(120),
KPixmapEffect::VerticalGradient);
iHandlePix = new KPixmap();
iHandlePix->resize(32, 6);
KPixmapEffect::gradient(*iHandlePix,
options->color(Options::Handle, false).light(150),
options->color(Options::Handle, false).dark(120),
KPixmapEffect::VerticalGradient);
iBtn = new KPixmap;
iBtn->resize(18, 18);
iBtnDown = new KPixmap;
iBtnDown->resize(18, 18);
aBtn = new KPixmap;
aBtn->resize(18, 18);
aBtnDown = new KPixmap;
aBtnDown->resize(18, 18);
KPixmap internal;
internal.resize(12, 12);
// inactive buttons
QColor c(options->color(Options::ButtonBg, false));
KPixmapEffect::gradient(*iBtn, c.light(120), c.dark(120),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(internal, c.dark(120), c.light(120),
KPixmapEffect::DiagonalGradient);
bitBlt(iBtn, 3, 3, &internal, 0, 0, 12, 12, Qt::CopyROP, true);
KPixmapEffect::gradient(*iBtnDown, c.dark(120), c.light(120),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(internal, c.light(120), c.dark(120),
KPixmapEffect::DiagonalGradient);
bitBlt(iBtnDown, 3, 3, &internal, 0, 0, 12, 12, Qt::CopyROP, true);
// active buttons
c = options->color(Options::ButtonBg, true);
KPixmapEffect::gradient(*aBtn, c.light(120), c.dark(120),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(internal, c.dark(120), c.light(120),
KPixmapEffect::DiagonalGradient);
bitBlt(aBtn, 3, 3, &internal, 0, 0, 12, 12, Qt::CopyROP, true);
KPixmapEffect::gradient(*aBtnDown, c.dark(120), c.light(120),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(internal, c.light(120), c.dark(120),
KPixmapEffect::DiagonalGradient);
bitBlt(aBtnDown, 3, 3, &internal, 0, 0, 12, 12, Qt::CopyROP, true);
QPainter p;
p.begin(aBtn);
p.setPen(Qt::black);
p.drawRect(0, 0, 18, 18);
p.end();
p.begin(iBtn);
p.setPen(Qt::black);
p.drawRect(0, 0, 18, 18);
p.end();
p.begin(aBtnDown);
p.setPen(Qt::black);
p.drawRect(0, 0, 18, 18);
p.end();
p.begin(iBtnDown);
p.setPen(Qt::black);
p.drawRect(0, 0, 18, 18);
p.end();
if(qGray(options->color(Options::ButtonBg, true).rgb()) > 128)
btnForeground = new QColor(Qt::black);
else
btnForeground = new QColor(Qt::white);
}
static void delete_pixmaps()
{
delete aTitlePix;
delete iTitlePix;
delete aFramePix;
delete iFramePix;
delete aHandlePix;
delete iHandlePix;
delete aBtn;
delete iBtn;
delete aBtnDown;
delete iBtnDown;
delete btnForeground;
pixmaps_created = false;
}
void NextClient::slotReset()
{
button[0]->reset();
button[1]->reset();
button[2]->reset();
}
NextButton::NextButton(Client *parent, const char *name,
const unsigned char *bitmap, int bw, int bh)
: QButton(parent, name)
{
setBackgroundMode( NoBackground );
client = parent;
resize(18, 18);
if(bitmap)
setBitmap(bitmap, bw, bh);
}
void NextButton::reset()
{
repaint(false);
}
void NextButton::setBitmap(const unsigned char *bitmap, int w, int h)
{
deco = QBitmap(w, h, bitmap, true);
deco.setMask(deco);
repaint();
}
void NextButton::drawButton(QPainter *p)
{
if(client->isActive())
p->drawPixmap(0, 0, isDown() ? *aBtnDown : *aBtn);
else
p->drawPixmap(0, 0, isDown() ? *iBtnDown : *iBtn);
p->setPen(*btnForeground);
p->drawPixmap(isDown()? 5 : 4, isDown() ? 5 : 4, deco);
}
NextClient::NextClient( Workspace *ws, WId w, QWidget *parent,
const char *name )
: Client( ws, w, parent, name, WResizeNoErase )
{
setBackgroundMode( NoBackground );
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
QVBoxLayout *mainLayout = new QVBoxLayout(this);
QHBoxLayout *titleLayout = new QHBoxLayout();
QHBoxLayout *windowLayout = new QHBoxLayout();
mainLayout->addLayout(titleLayout);
mainLayout->addLayout(windowLayout, 1);
mainLayout->addSpacing(6);
windowLayout->addSpacing(1);
windowLayout->addWidget(windowWrapper(), 1);
windowLayout->addSpacing(1);
button[0] = new NextButton(this, "close", close_bits, 10, 10);
button[1] = new NextButton(this, "sticky");
stickyChange(isSticky());
button[2] = new NextButton(this, "iconify", iconify_bits, 10, 10);
connect( button[0], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
connect( button[1], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
connect( button[2], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) );
titleLayout->addWidget( button[2] );
titlebar = new QSpacerItem(10, 16, QSizePolicy::Expanding,
QSizePolicy::Minimum );
titleLayout->addItem(titlebar);
titleLayout->addWidget( button[1] );
titleLayout->addWidget( button[0] );
for ( int i = 0; i < 3; i++) {
button[i]->setMouseTracking( TRUE );
button[i]->setFixedSize( 18, 18 );
}
}
void NextClient::resizeEvent( QResizeEvent* e)
{
Client::resizeEvent( e );
if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
QPainter p( this );
QRect t = titlebar->geometry();
t.setTop( 0 );
QRegion r = rect();
r = r.subtract( t );
p.setClipRegion( r );
p.eraseRect( rect() );
}
}
void NextClient::captionChange( const QString& )
{
repaint( titlebar->geometry(), false );
}
void NextClient::paintEvent( QPaintEvent* )
{
QPainter p( this );
p.setPen(Qt::black);
p.drawRect(rect());
QRect t = titlebar->geometry();
t.setTop(1);
p.drawTiledPixmap(t.x()+1, t.y()+1, t.width()-2, t.height()-2,
isActive() ? *aTitlePix : *iTitlePix);
qDrawShadePanel(&p, t.x(), t.y(), t.width(), t.height()-1,
options->colorGroup(Options::TitleBar, isActive()));
p.drawLine(t.x(), t.bottom(), t.right(), t.bottom());
QRegion r = rect();
r = r.subtract( t );
p.setClipRegion( r );
p.setClipping( FALSE );
t.setTop( 2 );
t.setHeight(t.height()-4);
t.setLeft( t.left() + 4 );
t.setRight( t.right() - 2 );
p.setPen(options->color(Options::Font, isActive()));
p.setFont(options->font(isActive()));
p.drawText( t, AlignCenter, caption() );
qDrawShadePanel(&p, rect().x()+1, rect().bottom()-6, 24, 6,
options->colorGroup(Options::Handle, isActive()), false);
p.drawTiledPixmap(rect().x()+2, rect().bottom()-5, 22, 4,
isActive() ? *aHandlePix : *iHandlePix);
qDrawShadePanel(&p, rect().x()+25, rect().bottom()-6, rect().width()-50, 6,
options->colorGroup(Options::Frame, isActive()), false);
p.drawTiledPixmap(rect().x()+26, rect().bottom()-5, rect().width()-52, 4,
isActive() ? *aFramePix : *iFramePix);
qDrawShadePanel(&p, rect().right()-24, rect().bottom()-6, 24, 6,
options->colorGroup(Options::Handle, isActive()), false);
p.drawTiledPixmap(rect().right()-23, rect().bottom()-5, 22, 4,
isActive() ? *aHandlePix : *iHandlePix);
}
void NextClient::mouseDoubleClickEvent( QMouseEvent * e )
{
if (titlebar->geometry().contains( e->pos() ) )
workspace()->performWindowOperation( this, options->operationTitlebarDblClick() );
workspace()->requestFocus( this );
}
void NextClient::stickyChange(bool on)
{
if(on)
button[1]->setBitmap(unsticky_bits, 10, 10);
else
button[1]->setBitmap(sticky_bits, 10, 10);
}
void NextClient::init()
{
Client::init();
}
void NextClient::activeChange(bool)
{
repaint(false);
button[0]->reset();
button[1]->reset();
button[2]->reset();
}
Client::MousePosition
NextClient::mousePosition( const QPoint& p ) const
{
MousePosition m = Nowhere;
if (p.y() < (height() - 6))
m = Client::mousePosition(p);
else {
if (p.x() >= (width() - 25))
m = BottomRight;
else if (p.x() <= 25)
m = BottomLeft;
else
m = Bottom;
}
return m;
}
extern "C"
{
Client *allocate(Workspace *ws, WId w, int )
{
return(new NextClient(ws, w));
}
void init()
{
create_pixmaps();
}
void reset()
{
delete_pixmaps();
create_pixmaps();
}
void deinit()
{
delete_pixmaps();
}
}
#include "nextclient.moc"

View File

@ -1,56 +0,0 @@
#ifndef __NEXTCLIENT_H
#define __NEXTCLIENT_H
#include <qbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
class QLabel;
class QSpacerItem;
namespace KWinInternal {
// get rid of autohide :P
class NextButton : public QButton
{
public:
NextButton(Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL, int bw=0, int bh=0);
void setBitmap(const unsigned char *bitmap, int bw, int bh);
void reset();
protected:
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
KPixmap aBackground, iBackground;
QBitmap deco;
Client *client;
};
class NextClient : public KWinInternal::Client
{
Q_OBJECT
public:
NextClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~NextClient(){;}
protected:
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void mouseDoubleClickEvent( QMouseEvent * );
void init();
void captionChange( const QString& name );
void stickyChange(bool on);
void activeChange(bool);
MousePosition mousePosition(const QPoint &) const;
protected slots:
void slotReset();
private:
NextButton* button[3];
QSpacerItem* titlebar;
};
};
#endif

View File

@ -1,11 +0,0 @@
SUBDIRS=cli_installer
INCLUDES = $(all_includes)
kde_module_LTLIBRARIES = libkwinkwmtheme.la
libkwinkwmtheme_la_SOURCES = kwmthemeclient.cpp
libkwinkwmtheme_la_LIBADD = ../../kwin.la
libkwinkwmtheme_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
METASOURCES = AUTO
noinst_HEADERS = kwmthemeclient.h

View File

@ -1,18 +0,0 @@
# set the include path for X, qt and KDE
INCLUDES= $(all_includes)
####### This part is very kwmtheme specific
# you can add here more. This one gets installed
bin_PROGRAMS = kwmtheme
# Which sources should be compiled for kwmtheme.
kwmtheme_SOURCES = main.cpp
# the library search path.
kwmtheme_LDFLAGS = $(all_libraries) $(KDE_RPATH)
# the libraries to link against. Be aware of the order. First the libraries,
# that depend on the following ones.
kwmtheme_LDADD = $(LIB_KDECORE)

View File

@ -1,165 +0,0 @@
#include <qfile.h>
#include <qdir.h>
#include <kapp.h>
#include <ksimpleconfig.h>
#include <kglobal.h>
#include <kstddirs.h>
#include <kcmdlineargs.h>
#include <klocale.h>
static const char *description =
I18N_NOOP("Installs a KWM theme");
static KCmdLineOptions options[] =
{
{ "+[file]", I18N_NOOP("Path to a theme config file"), 0 },
{ 0, 0, 0 }
};
void copy(const QString &src, const QString &dest)
{
QFile copyInput(src);
QFile copyOutput(dest);
if(!copyInput.open(IO_ReadOnly)){
qWarning("Couldn't open %s", src.latin1());
return;
}
if(!copyOutput.open(IO_WriteOnly)){
qWarning("Couldn't open %s", dest.latin1());
copyInput.close();
return;
}
while(!copyInput.atEnd()){
copyOutput.putch(copyInput.getch());
}
copyInput.close();
copyOutput.close();
}
int main(int argc, char **argv)
{
KCmdLineArgs::init(argc, argv, "kwmtheme", description, "0.1");
KCmdLineArgs::addCmdLineOptions( options );
KApplication app(argc, argv);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if(!args->count()){
qWarning("You need to specify the path to a theme config file!");
return(1);
}
QString srcStr = QString(QFile::decodeName(args->arg(0)));
QFile f(srcStr);
QString tmpStr;
if(!f.exists()){
qWarning("Specified theme config file doesn't exist!");
return(2);
}
QStringList appDirs = KGlobal::dirs()->findDirs("data", "kwin");
QString localDirStr = *(appDirs.end());
if(localDirStr.isEmpty()){
localDirStr = KGlobal::dirs()->saveLocation("data", "kwin");
}
localDirStr += "/pics/";
if(!QFile::exists(localDirStr))
QDir().mkdir(localDirStr);
QFileInfo fi(f);
KSimpleConfig input(fi.absFilePath());
srcStr = fi.dirPath(true) + "/";
KConfig *output = KGlobal::config();
input.setGroup("Window Border");
output->setGroup("General");
tmpStr = input.readEntry("shapePixmapTop");
if(!tmpStr.isEmpty()){
copy(srcStr+tmpStr, localDirStr+tmpStr);
}
output->writeEntry("wm_top", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapBottom");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottom", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_left", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_right", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapTopLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_topleft", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapTopRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_topright", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapBottomLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottomleft", tmpStr, true, true);
tmpStr = input.readEntry("shapePixmapBottomRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottomright", tmpStr, true, true);
input.setGroup("Window Titlebar");
output->writeEntry("TitleAlignment", input.readEntry("TitleAlignment"), true, true);
output->writeEntry("PixmapUnderTitleText", input.readEntry("PixmapUnderTitleText"), true, true);
output->writeEntry("TitleFrameShaded", input.readEntry("TitleFrameShaded"), true, true);
tmpStr = input.readEntry("MenuButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("menu", tmpStr, true, true);
tmpStr = input.readEntry("PinUpButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("pinup", tmpStr, true, true);
tmpStr = input.readEntry("PinDownButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("pindown", tmpStr, true, true);
tmpStr = input.readEntry("CloseButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("close", tmpStr, true, true);
tmpStr = input.readEntry("MaximizeButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("maximize", tmpStr, true, true);
tmpStr = input.readEntry("MaximizeDownButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("maximizedown", tmpStr, true, true);
tmpStr = input.readEntry("MinimizeButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("iconify", tmpStr, true, true);
tmpStr = input.readEntry("TitlebarPixmapActive");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("TitlebarPixmapActive", tmpStr, true, true);
tmpStr = input.readEntry("TitlebarPixmapInactive");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("TitlebarPixmapInactive", tmpStr, true, true);
input.setGroup("Window Button Layout");
output->setGroup("Buttons");
output->writeEntry("ButtonA", input.readEntry("ButtonA"), true, true);
output->writeEntry("ButtonB", input.readEntry("ButtonB"), true, true);
output->writeEntry("ButtonC", input.readEntry("ButtonC"), true, true);
output->writeEntry("ButtonD", input.readEntry("ButtonD"), true, true);
output->writeEntry("ButtonE", input.readEntry("ButtonE"), true, true);
output->writeEntry("ButtonF", input.readEntry("ButtonF"), true, true);
output->sync();
return(0);
}

View File

@ -1,41 +0,0 @@
[Desktop Entry]
Name=KWM Theme
Name[ca]=Tema KWM
Name[cs]=Téma KWM
Name[da]=KWM tema
Name[de]=KWM-Design
Name[el]=Θέμα KWM
Name[eo]=KWM-etoso
Name[es]=Tema KWM
Name[et]=KWM teema
Name[fi]=KWM-teema
Name[fr]=Thème KWM
Name[gl]=Tema do KWM
Name[hr]=KWM Tema
Name[hu]=KWM téma
Name[is]=KWM þema
Name[it]=Tema KWM
Name[ja]=KWMテーマ
Name[ko]=KWM 테마
Name[lt]=KWM Tema
Name[lv]=KWM Tēma
Name[mi]=Kaupapa KWM
Name[mk]=KWM тема
Name[nl]=KWM-thema
Name[no]=KWM-tema
Name[no_NY]=KWM-tema
Name[oc]=Tema KWM
Name[pl]=Motyw KWM
Name[pt]=Tema do kwm
Name[pt_BR]=Tema KWM
Name[ro]=Temă KWM
Name[ru]=Стиль KWM
Name[sk]=Témy KWM
Name[sl]=Tema za KWM
Name[sr]=KWM Tema
Name[sv]=KWM-tema
Name[tr]=KWM Teması
Name[uk]=Тема KWM
Name[zh_CN.GB2312]=KWM 主题
Name[zh_TW.Big5]=KWM 佈景
X-KDE-Library=libkwinkwmtheme

View File

@ -1,833 +0,0 @@
#include <kconfig.h>
#include "kwmthemeclient.h"
#include <kglobal.h>
#include <qlayout.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <kstddirs.h>
#include <kglobal.h>
#include <klocale.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
using namespace KWinInternal;
static QPixmap stretchPixmap(QPixmap& src, bool stretchVert){
QPixmap dest;
QBitmap *srcMask, *destMask;
int w, h, w2, h2;
QPainter p;
if (src.isNull()) return src;
w = src.width();
h = src.height();
if (stretchVert){
w2 = w;
for (h2=h; h2<100; h2=h2<<1)
;
}
else{
h2 = h;
for (w2=w; w2<100; w2=w2<<1)
;
}
if (w2==w && h2==h) return src;
dest = src;
dest.resize(w2, h2);
p.begin(&dest);
p.drawTiledPixmap(0, 0, w2, h2, src);
p.end();
srcMask = (QBitmap*)src.mask();
if (srcMask){
destMask = (QBitmap*)dest.mask();
p.begin(destMask);
p.drawTiledPixmap(0, 0, w2, h2, *srcMask);
p.end();
}
return dest;
}
enum FramePixmap{FrameTop=0, FrameBottom, FrameLeft, FrameRight, FrameTopLeft,
FrameTopRight, FrameBottomLeft, FrameBottomRight};
static QPixmap *framePixmaps[8];
static QPixmap *menuPix, *iconifyPix, *closePix, *maxPix, *minmaxPix,
*pinupPix, *pindownPix;
static KPixmap *aTitlePix = 0;
static KPixmap *iTitlePix = 0;
static KPixmapEffect::GradientType grType;
static int maxExtent, titleAlign;
static bool titleGradient = true;
static bool pixmaps_created = false;
static bool titleSunken = false;
static bool titleTransparent;
static void create_pixmaps()
{
const char *keys[] = {"wm_top", "wm_bottom", "wm_left", "wm_right",
"wm_topleft", "wm_topright", "wm_bottomleft", "wm_bottomright"};
if(pixmaps_created)
return;
pixmaps_created = true;
KConfig *config = KGlobal::config();
config->setGroup("General");
QString tmpStr;
for(int i=0; i < 8; ++i)
{
framePixmaps[i] = new QPixmap(locate("appdata",
"pics/"+config->readEntry(keys[i], " ")));
if(framePixmaps[i]->isNull())
qWarning("Unable to load frame pixmap for %s", keys[i]);
}
*framePixmaps[FrameTop] = stretchPixmap(*framePixmaps[FrameTop], false);
*framePixmaps[FrameBottom] = stretchPixmap(*framePixmaps[FrameBottom], false);
*framePixmaps[FrameLeft] = stretchPixmap(*framePixmaps[FrameLeft], true);
*framePixmaps[FrameRight] = stretchPixmap(*framePixmaps[FrameRight], true);
maxExtent = framePixmaps[FrameTop]->height();
if(framePixmaps[FrameBottom]->height() > maxExtent)
maxExtent = framePixmaps[FrameBottom]->height();
if(framePixmaps[FrameLeft]->width() > maxExtent)
maxExtent = framePixmaps[FrameLeft]->width();
if(framePixmaps[FrameRight]->width() > maxExtent)
maxExtent = framePixmaps[FrameRight]->width();
menuPix = new QPixmap(locate("appdata",
"pics/"+config->readEntry("menu", " ")));
iconifyPix = new QPixmap(locate("appdata",
"pics/"+config->readEntry("iconify", " ")));
maxPix = new QPixmap(locate("appdata",
"pics/"+config->readEntry("maximize", " ")));
minmaxPix = new QPixmap(locate("appdata",
"pics/"+config->readEntry("maximizedown", " ")));
closePix = new QPixmap(locate("appdata",
"pics/"+config->readEntry("close", " ")));
pinupPix = new QPixmap(locate("appdata",
"pics/"+config->readEntry("pinup", " ")));
pindownPix = new QPixmap(locate("appdata",
"pics/"+config->readEntry("pindown", " ")));
if(menuPix->isNull())
menuPix->load(locate("appdata", "pics/menu.png"));
if(iconifyPix->isNull())
iconifyPix->load(locate("appdata", "pics/iconify.png"));
if(maxPix->isNull())
maxPix->load(locate("appdata", "pics/maximize.png"));
if(minmaxPix->isNull())
minmaxPix->load(locate("appdata", "pics/maximizedown.png"));
if(closePix->isNull())
closePix->load(locate("appdata", "pics/close.png"));
if(pinupPix->isNull())
pinupPix->load(locate("appdata", "pics/pinup.png"));
if(pindownPix->isNull())
pindownPix->load(locate("appdata", "pics/pindown.png"));
tmpStr = config->readEntry("TitleAlignment");
if(tmpStr == "right")
titleAlign = Qt::AlignRight | Qt::AlignVCenter;
else if(tmpStr == "middle")
titleAlign = Qt::AlignCenter;
else
titleAlign = Qt::AlignLeft | Qt::AlignVCenter;
titleSunken = config->readBoolEntry("TitleFrameShaded", true);
// titleSunken = true; // is this fixed?
titleTransparent = config->readBoolEntry("PixmapUnderTitleText", true);
tmpStr = config->readEntry("TitlebarLook");
if(tmpStr == "shadedVertical"){
aTitlePix = new KPixmap;
aTitlePix->resize(32, 20);
KPixmapEffect::gradient(*aTitlePix,
options->color(Options::TitleBar, true),
options->color(Options::TitleBlend, true),
KPixmapEffect::VerticalGradient);
iTitlePix = new KPixmap;
iTitlePix->resize(32, 20);
KPixmapEffect::gradient(*iTitlePix,
options->color(Options::TitleBar, false),
options->color(Options::TitleBlend, false),
KPixmapEffect::VerticalGradient);
titleGradient = false; // we can just tile this
}
else if(tmpStr == "shadedHorizontal")
grType = KPixmapEffect::HorizontalGradient;
else if(tmpStr == "shadedDiagonal")
grType = KPixmapEffect::DiagonalGradient;
else if(tmpStr == "shadedCrossDiagonal")
grType = KPixmapEffect::CrossDiagonalGradient;
else if(tmpStr == "shadedPyramid")
grType = KPixmapEffect::PyramidGradient;
else if(tmpStr == "shadedRectangle")
grType = KPixmapEffect::RectangleGradient;
else if(tmpStr == "shadedPipeCross")
grType = KPixmapEffect::PipeCrossGradient;
else if(tmpStr == "shadedElliptic")
grType = KPixmapEffect::EllipticGradient;
else{
titleGradient = false;
tmpStr = config->readEntry("TitlebarPixmapActive", "");
if(!tmpStr.isEmpty()){
aTitlePix = new KPixmap;
aTitlePix->load(locate("appdata", "pics/" + tmpStr));
}
else
aTitlePix = NULL;
tmpStr = config->readEntry("TitlebarPixmapInactive", "");
if(!tmpStr.isEmpty()){
iTitlePix = new KPixmap;
iTitlePix->load(locate("appdata", "pics/" + tmpStr));
}
else
iTitlePix = NULL;
}
}
static void delete_pixmaps()
{
for(int i=0; i < 8; ++i)
delete framePixmaps[i];
delete menuPix;
delete iconifyPix;
delete closePix;
delete maxPix;
delete minmaxPix;
delete pinupPix;
delete pindownPix;
delete aTitlePix;
aTitlePix = 0;
delete iTitlePix;
iTitlePix = 0;
titleGradient = true;
pixmaps_created = false;
titleSunken = false;
}
void KWMThemeClient::slotReset()
{
}
void MyButton::drawButtonLabel(QPainter *p)
{
if(pixmap()){
// If we have a theme who's button covers the entire width or
// entire height, we shift down/right by 1 pixel so we have
// some visual notification of button presses. i.e. for MGBriezh
int offset = (isDown() && ((pixmap()->width() >= width()) ||
(pixmap()->height() >= height()))) ? 1 : 0;
style().drawItem(p, offset, offset, width(), height(),
AlignCenter, colorGroup(),
true, pixmap(), QString::null);
}
}
KWMThemeClient::KWMThemeClient( Workspace *ws, WId w, QWidget *parent,
const char *name )
: Client( ws, w, parent, name, WResizeNoErase | WNorthWestGravity)
{
stickyBtn = maxBtn = mnuBtn = 0;
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
layout = new QGridLayout(this);
layout->addColSpacing(0, maxExtent);
layout->addColSpacing(2, maxExtent);
layout->addRowSpacing(0, maxExtent);
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed,
QSizePolicy::Expanding));
layout->addWidget(windowWrapper(), 2, 1);
// Without the next line, shading flickers
layout->addItem( new QSpacerItem(0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding) );
layout->addRowSpacing(3, maxExtent);
layout->setRowStretch(2, 10);
layout->setColStretch(1, 10);
QHBoxLayout* hb = new QHBoxLayout;
layout->addLayout( hb, 1, 1 );
KConfig *config = KGlobal::config();
config->setGroup("Buttons");
QString val;
MyButton *btn;
int i;
static const char *defaultButtons[]={"Menu","Sticky","Off","Iconify",
"Maximize","Close"};
static const char keyOffsets[]={"ABCDEF"};
for(i=0; i < 6; ++i){
if(i == 3){
titlebar = new QSpacerItem(10, 20, QSizePolicy::Expanding,
QSizePolicy::Minimum );
hb->addItem( titlebar );
}
QString key("Button");
key += QChar(keyOffsets[i]);
val = config->readEntry(key, defaultButtons[i]);
if(val == "Menu"){
mnuBtn = new MyButton(this, "menu");
iconChange();
hb->addWidget(mnuBtn);
mnuBtn->setFixedSize(20, 20);
connect(mnuBtn, SIGNAL(pressed()), this,
SLOT(menuButtonPressed()));
}
else if(val == "Sticky"){
stickyBtn = new MyButton(this, "sticky");
if (isSticky())
stickyBtn->setPixmap(*pindownPix);
else
stickyBtn->setPixmap(*pinupPix);
connect(stickyBtn, SIGNAL( clicked() ), this, SLOT(toggleSticky()));
hb->addWidget(stickyBtn);
stickyBtn->setFixedSize(20, 20);
}
else if((val == "Iconify") && isMinimizable()){
btn = new MyButton(this, "iconify");
btn->setPixmap(*iconifyPix);
connect(btn, SIGNAL(clicked()), this, SLOT(iconify()));
hb->addWidget(btn);
btn->setFixedSize(20, 20);
}
else if((val == "Maximize") && isMaximizable()){
maxBtn = new MyButton(this, "max");
maxBtn->setPixmap(*maxPix);
connect(maxBtn, SIGNAL(clicked()), this, SLOT(maximize()));
hb->addWidget(maxBtn);
maxBtn->setFixedSize(20, 20);
}
else if(val == "Close"){
btn = new MyButton(this, "close");
btn->setPixmap(*closePix);
connect(btn, SIGNAL(clicked()), this, SLOT(closeWindow()));
hb->addWidget(btn);
btn->setFixedSize(20, 20);
}
else{
if((val != "Off") &&
((val == "Iconify") && !isMinimizable()) &&
((val == "Maximize") && !isMaximizable()))
qWarning("KWin: Unrecognized button value: %s", val.latin1());
}
}
if(titleGradient){
aGradient = new KPixmap;
iGradient = new KPixmap;
}
else{
aGradient = 0;
iGradient = 0;
}
setBackgroundMode(NoBackground);
}
void KWMThemeClient::drawTitle(QPainter &dest)
{
QRect titleRect = titlebar->geometry();
QRect r(0, 0, titleRect.width(), titleRect.height());
QPixmap buffer;
if(buffer.width() == r.width())
return;
buffer.resize(r.size());
QPainter p;
p.begin(&buffer);
if(titleSunken){
qDrawShadeRect(&p, r, options->colorGroup(Options::Frame, isActive()),
true, 1, 0);
r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
}
KPixmap *fill = isActive() ? aTitlePix : iTitlePix;
if(fill)
p.drawTiledPixmap(r, *fill);
else if(titleGradient){
fill = isActive() ? aGradient : iGradient;
if(fill->width() != r.width()){
fill->resize(r.width(), 20);
KPixmapEffect::gradient(*fill,
options->color(Options::TitleBar, isActive()),
options->color(Options::TitleBlend, isActive()),
grType);
}
p.drawTiledPixmap(r, *fill);
}
else{
p.fillRect(r, options->colorGroup(Options::TitleBar, isActive()).
brush(QColorGroup::Button));
}
p.setFont(options->font(isActive()));
p.setPen(options->color(Options::Font, isActive()));
// Add left & right margin
r.setLeft(r.left()+5);
r.setRight(r.right()-5);
p.drawText(r, titleAlign, caption());
p.end();
dest.drawPixmap(titleRect.x(), titleRect.y(), buffer);
}
void KWMThemeClient::resizeEvent( QResizeEvent* e)
{
Client::resizeEvent( e );
doShape();
repaint();
}
void KWMThemeClient::captionChange( const QString& )
{
repaint( titlebar->geometry(), false );
}
void KWMThemeClient::paintEvent( QPaintEvent *)
{
QPainter p;
p.begin(this);
int x,y;
// first the corners
int w1 = framePixmaps[FrameTopLeft]->width();
int h1 = framePixmaps[FrameTopLeft]->height();
if (w1 > width()/2) w1 = width()/2;
if (h1 > height()/2) h1 = height()/2;
p.drawPixmap(0,0,*framePixmaps[FrameTopLeft],
0,0,w1, h1);
int w2 = framePixmaps[FrameTopRight]->width();
int h2 = framePixmaps[FrameTopRight]->height();
if (w2 > width()/2) w2 = width()/2;
if (h2 > height()/2) h2 = height()/2;
p.drawPixmap(width()-w2,0,*framePixmaps[FrameTopRight],
framePixmaps[FrameTopRight]->width()-w2,0,w2, h2);
int w3 = framePixmaps[FrameBottomLeft]->width();
int h3 = framePixmaps[FrameBottomLeft]->height();
if (w3 > width()/2) w3 = width()/2;
if (h3 > height()/2) h3 = height()/2;
p.drawPixmap(0,height()-h3,*framePixmaps[FrameBottomLeft],
0,framePixmaps[FrameBottomLeft]->height()-h3,w3, h3);
int w4 = framePixmaps[FrameBottomRight]->width();
int h4 = framePixmaps[FrameBottomRight]->height();
if (w4 > width()/2) w4 = width()/2;
if (h4 > height()/2) h4 = height()/2;
p.drawPixmap(width()-w4,height()-h4,*(framePixmaps[FrameBottomRight]),
framePixmaps[FrameBottomRight]->width()-w4,
framePixmaps[FrameBottomRight]->height()-h4,
w4, h4);
QPixmap pm;
QWMatrix m;
int n,s,w;
//top
pm = *framePixmaps[FrameTop];
if (pm.width() > 0){
s = width()-w2-w1;
n = s/pm.width();
w = n>0?s/n:s;
m.reset();
m.scale(w/(float)pm.width(), 1);
pm = pm.xForm(m);
x = w1;
while (1){
if (pm.width() < width()-w2-x){
p.drawPixmap(x,maxExtent-pm.height()-1,
pm);
x += pm.width();
}
else {
p.drawPixmap(x,maxExtent-pm.height()-1,
pm,
0,0,width()-w2-x,pm.height());
break;
}
}
}
//bottom
pm = *framePixmaps[FrameBottom];
if (pm.width() > 0){
s = width()-w4-w3;
n = s/pm.width();
w = n>0?s/n:s;
m.reset();
m.scale(w/(float)pm.width(), 1);
pm = pm.xForm(m);
x = w3;
while (1){
if (pm.width() < width()-w4-x){
p.drawPixmap(x,height()-maxExtent+1,pm);
x += pm.width();
}
else {
p.drawPixmap(x,height()-maxExtent+1,pm,
0,0,width()-w4-x,pm.height());
break;
}
}
}
//left
pm = *framePixmaps[FrameLeft];
if (pm.height() > 0){
s = height()-h3-h1;
n = s/pm.height();
w = n>0?s/n:s;
m.reset();
m.scale(1, w/(float)pm.height());
pm = pm.xForm(m);
y = h1;
while (1){
if (pm.height() < height()-h3-y){
p.drawPixmap(maxExtent-pm.width()-1, y,
pm);
y += pm.height();
}
else {
p.drawPixmap(maxExtent-pm.width()-1, y,
pm,
0,0, pm.width(),
height()-h3-y);
break;
}
}
}
//right
pm = *framePixmaps[FrameRight];
if (pm.height() > 0){
s = height()-h4-h2;
n = s/pm.height();
w = n>0?s/n:s;
m.reset();
m.scale(1, w/(float)pm.height());
pm = pm.xForm(m);
y = h2;
while (1){
if (pm.height() < height()-h4-y){
p.drawPixmap(width()-maxExtent+1, y,
pm);
y += pm.height();
}
else {
p.drawPixmap(width()-maxExtent+1, y,
pm,
0,0, pm.width(),
height()-h4-y);
break;
}
}
}
drawTitle(p);
QColor c = colorGroup().background();
// KWM evidently had a 1 pixel border around the client window. We
// emulate it here, but should be removed at some point in order to
// seamlessly mesh widget themes
p.setPen(c);
p.drawRect(maxExtent-1, maxExtent-1, width()-(maxExtent-1)*2,
height()-(maxExtent-1)*2);
// We fill the area behind the wrapped widget to ensure that
// shading animation is drawn as smoothly as possible
QRect r(layout->cellGeometry(2, 1));
p.fillRect( r.x(), r.y(), r.width(), r.height(), c);
p.end();
}
void KWMThemeClient::doShape()
{
QBitmap shapemask(width(), height());
shapemask.fill(color0);
QPainter p;
p.begin(&shapemask);
p.setBrush(color1);
p.setPen(color1);
int x,y;
// first the corners
int w1 = framePixmaps[FrameTopLeft]->width();
int h1 = framePixmaps[FrameTopLeft]->height();
if (w1 > width()/2) w1 = width()/2;
if (h1 > height()/2) h1 = height()/2;
p.drawPixmap(0,0,*framePixmaps[FrameTopLeft]->mask(),
0,0,w1, h1);
int w2 = framePixmaps[FrameTopRight]->width();
int h2 = framePixmaps[FrameTopRight]->height();
if (w2 > width()/2) w2 = width()/2;
if (h2 > height()/2) h2 = height()/2;
p.drawPixmap(width()-w2,0,*framePixmaps[FrameTopRight]->mask(),
framePixmaps[FrameTopRight]->width()-w2,0,w2, h2);
int w3 = framePixmaps[FrameBottomLeft]->width();
int h3 = framePixmaps[FrameBottomLeft]->height();
if (w3 > width()/2) w3 = width()/2;
if (h3 > height()/2) h3 = height()/2;
p.drawPixmap(0,height()-h3,*framePixmaps[FrameBottomLeft]->mask(),
0,framePixmaps[FrameBottomLeft]->height()-h3,w3, h3);
int w4 = framePixmaps[FrameBottomRight]->width();
int h4 = framePixmaps[FrameBottomRight]->height();
if (w4 > width()/2) w4 = width()/2;
if (h4 > height()/2) h4 = height()/2;
p.drawPixmap(width()-w4,height()-h4,*framePixmaps[FrameBottomRight]->mask(),
framePixmaps[FrameBottomRight]->width()-w4,
framePixmaps[FrameBottomRight]->height()-h4,
w4, h4);
QPixmap pm;
QWMatrix m;
int n,s,w;
//top
pm = *framePixmaps[FrameTop]->mask();
s = width()-w2-w1;
n = s/pm.width();
w = n>0?s/n:s;
m.reset();
m.scale(w/(float)pm.width(), 1);
pm = pm.xForm(m);
x = w1;
while (1){
if (pm.width() < width()-w2-x){
p.drawPixmap(x,maxExtent-pm.height()-1,
pm);
x += pm.width();
}
else {
p.drawPixmap(x,maxExtent-pm.height()-1,
pm,
0,0,width()-w2-x,pm.height());
break;
}
}
//bottom
pm = *framePixmaps[FrameBottom]->mask();
s = width()-w4-w3;
n = s/pm.width();
w = n>0?s/n:s;
m.reset();
m.scale(w/(float)pm.width(), 1);
pm = pm.xForm(m);
x = w3;
while (1){
if (pm.width() < width()-w4-x){
p.drawPixmap(x,height()-maxExtent+1,pm);
x += pm.width();
}
else {
p.drawPixmap(x,height()-maxExtent+1,pm,
0,0,width()-w4-x,pm.height());
break;
}
}
//left
pm = *framePixmaps[FrameLeft]->mask();
s = height()-h3-h1;
n = s/pm.height();
w = n>0?s/n:s;
m.reset();
m.scale(1, w/(float)pm.height());
pm = pm.xForm(m);
y = h1;
while (1){
if (pm.height() < height()-h3-y){
p.drawPixmap(maxExtent-pm.width()-1, y,
pm);
y += pm.height();
}
else {
p.drawPixmap(maxExtent-pm.width()-1, y,
pm,
0,0, pm.width(),
height()-h3-y);
break;
}
}
//right
pm = *framePixmaps[FrameRight]->mask();
s = height()-h4-h2;
n = s/pm.height();
w = n>0?s/n:s;
m.reset();
m.scale(1, w/(float)pm.height());
pm = pm.xForm(m);
y = h2;
while (1){
if (pm.height() < height()-h4-y){
p.drawPixmap(width()-maxExtent+1, y,
pm);
y += pm.height();
}
else {
p.drawPixmap(width()-maxExtent+1, y,
pm,
0,0, pm.width(),
height()-h4-y);
break;
}
}
p.fillRect(maxExtent-1, maxExtent-1, width()-2*maxExtent+2, height()-2*maxExtent+2, color1);
setMask(shapemask);
}
void KWMThemeClient::showEvent(QShowEvent *ev)
{
Client::showEvent(ev);
doShape();
repaint(false);
}
void KWMThemeClient::windowWrapperShowEvent( QShowEvent* )
{
doShape();
}
void KWMThemeClient::mouseDoubleClickEvent( QMouseEvent * e )
{
if (titlebar->geometry().contains( e->pos() ) )
setShade( !isShade() );
workspace()->requestFocus( this );
}
void KWMThemeClient::stickyChange(bool on)
{
if (stickyBtn)
stickyBtn->setPixmap(on ? *pindownPix : *pinupPix);
}
void KWMThemeClient::maximizeChange(bool m)
{
if (maxBtn)
maxBtn->setPixmap(m ? *minmaxPix : *maxPix);
}
Client::MousePosition KWMThemeClient::mousePosition(const QPoint &p) const
{
MousePosition m = Client::mousePosition(p);
// corners
if(p.y() < framePixmaps[FrameTop]->height() &&
p.x() < framePixmaps[FrameLeft]->width()){
m = TopLeft;
}
else if(p.y() < framePixmaps[FrameTop]->height() &&
p.x() > width()-framePixmaps[FrameRight]->width()){
m = TopRight;
}
else if(p.y() > height()-framePixmaps[FrameBottom]->height() &&
p.x() < framePixmaps[FrameLeft]->width()){
m = BottomLeft;
}
else if(p.y() > height()-framePixmaps[FrameBottom]->height() &&
p.x() > width()-framePixmaps[FrameRight]->width()){
m = BottomRight;
} // edges
else if(p.y() < framePixmaps[FrameTop]->height())
m = Top;
else if(p.y() > height()-framePixmaps[FrameBottom]->height())
m = Bottom;
else if(p.x() < framePixmaps[FrameLeft]->width())
m = Left;
else if(p.x() > width()-framePixmaps[FrameRight]->width())
m = Right;
return(m);
}
void KWMThemeClient::menuButtonPressed()
{
static QTime* t = 0;
static KWMThemeClient* tc = 0;
if ( !t )
t = new QTime;
if ( tc != this || t->elapsed() > QApplication::doubleClickInterval() ){
mnuBtn->setDown(false); // will stay down if I don't do this
workspace()->clientPopup(this)->
popup(mnuBtn->mapToGlobal(mnuBtn->rect().bottomLeft()));
}
else {
mnuBtn->setPopup( 0 );
closeWindow();
}
t->start();
tc = this;
}
void KWMThemeClient::iconChange()
{
if(mnuBtn){
if(miniIcon().isNull()){
mnuBtn->setPixmap(*menuPix);
}
else{
mnuBtn->setPixmap(miniIcon());
}
}
}
void KWMThemeClient::init()
{
//
}
extern "C"
{
Client *allocate(Workspace *ws, WId w)
{
return(new KWMThemeClient(ws, w));
}
void init()
{
create_pixmaps();
}
void reset()
{
delete_pixmaps();
create_pixmaps();
}
void deinit()
{
delete_pixmaps();
}
}
#include "kwmthemeclient.moc"

View File

@ -1,58 +0,0 @@
#ifndef __KWMTHEMECLIENT_H
#define __KWMTHEMECLIENT_H
#include <qbutton.h>
#include <qtoolbutton.h>
#include <kpixmap.h>
#include "../../client.h"
class QLabel;
class QSpacerItem;
class QGridLayout;
namespace KWinInternal{
// QToolButton uses a 1 pixel border :P
class MyButton : public QToolButton
{
public:
MyButton(QWidget *parent=0, const char *name=0)
: QToolButton(parent, name){setAutoRaise(true);}
protected:
void drawButtonLabel(QPainter *p);
};
class KWMThemeClient : public KWinInternal::Client
{
Q_OBJECT
public:
KWMThemeClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~KWMThemeClient(){;}
protected:
void doShape();
void drawTitle(QPainter &p);
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void showEvent( QShowEvent* );
void windowWrapperShowEvent( QShowEvent* );
void mouseDoubleClickEvent( QMouseEvent * );
void init();
void captionChange( const QString& name );
void stickyChange(bool on);
void maximizeChange(bool m);
void iconChange();
MousePosition mousePosition(const QPoint &) const;
protected slots:
void slotReset();
void menuButtonPressed();
private:
QPixmap buffer;
KPixmap *aGradient, *iGradient;
MyButton *maxBtn, *stickyBtn, *mnuBtn;
QSpacerItem *titlebar;
QGridLayout* layout;
};
};
#endif

View File

@ -1,21 +0,0 @@
INCLUDES = $(all_includes)
kde_module_LTLIBRARIES = libkwinlaptop.la
libkwinlaptop_la_SOURCES = laptopclient.cpp
libkwinlaptop_la_LIBADD = ../../kwin.la
libkwinlaptop_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
METASOURCES = AUTO
noinst_HEADERS = laptopclient.h
lnkdir = $(kde_datadir)/kwin/
lnk_DATA = laptop.desktop
EXTRA_DIST = $(lnk_DATA)
###KMAKE-start (don't edit or delete this block)
###KMAKE-end

View File

@ -1,28 +0,0 @@
[Desktop Entry]
Name=Laptop
Name[ca]=Portàtil
Name[da]=Bærbar
Name[el]=Φορητό
Name[eo]=Portkomputilo
Name[es]=Portátil
Name[fi]=Kannettava
Name[fr]=Ordinateur portable
Name[gl]=Portátil
Name[is]=Ferðavél
Name[it]=Portatile
Name[ja]=ラップトップ
Name[ko]=랩탑
Name[lv]=Laptops
Name[mk]=Лаптоп
Name[nl]=Schootcomputer
Name[no]=Bærbar
Name[no_NY]=Bærbar
Name[oc]=Portatil
Name[pt]=Portátil
Name[sl]=Prenosnik
Name[sv]=Bärbar dator
Name[tr]=Dizüstü
Name[uk]=Мобільний комп'ютер (лептоп)
Name[zh_CN.GB2312]=膝上计算机
Name[zh_TW.Big5]=膝上型電腦
X-KDE-Library=libkwinlaptop

View File

@ -1,704 +0,0 @@
#include <kconfig.h> // up here to avoid X11 header conflict :P
#include "laptopclient.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <kglobal.h>
#include <kapp.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
using namespace KWinInternal;
static unsigned char iconify_bits[] = {
0xff, 0xff, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18};
static unsigned char close_bits[] = {
0x42, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0x42};
static unsigned char maximize_bits[] = {
0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0xff, 0xff };
static unsigned char minmax_bits[] = {
0x0c, 0x18, 0x33, 0x67, 0xcf, 0x9f, 0x3f, 0x3f};
static unsigned char question_bits[] = {
0x3c, 0x66, 0x60, 0x30, 0x18, 0x00, 0x18, 0x18};
static unsigned char unsticky_bits[] = {
0x3c, 0x42, 0x99, 0xbd, 0xbd, 0x99, 0x42, 0x3c};
static unsigned char sticky_bits[] = {
0x3c, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3c};
static QPixmap *titlePix=0;
static KPixmap *aUpperGradient=0;
static KPixmap *iUpperGradient=0;
// buttons active, inactive, up, down, and 2 sizes :P
static KPixmap *btnPix1=0;
static KPixmap *iBtnPix1=0;
static KPixmap *btnDownPix1=0;
static KPixmap *iBtnDownPix1=0;
static KPixmap *btnPix2=0;
static KPixmap *btnDownPix2=0;
static KPixmap *iBtnPix2=0;
static KPixmap *iBtnDownPix2=0;
static QColor btnForeground;
static bool pixmaps_created = false;
static int titleHeight = 14; // configurable title height not implemented yet
static int btnWidth1 = 17;
static int btnWidth2 = 27;
static void drawButtonFrame(KPixmap *pix, const QColorGroup &g, bool sunken)
{
QPainter p;
int w = pix->width();
int h = pix->height();
int x2 = w-1;
int y2 = h-1;
p.begin(pix);
if(sunken){
qDrawShadePanel(&p, 0, 0, w, h, g, true, 2);
}
else{
p.setPen(g.dark());
p.drawRect(0, 0, w-1, h-1);
p.setPen(g.light());
p.drawLine(x2, 0, x2, y2);
p.drawLine(0, y2, x2, y2);
p.drawLine(1, 1, x2-2, 1);
p.drawLine(1, 1, 1, y2-2);
p.end();
}
}
static void create_pixmaps()
{
if(pixmaps_created)
return;
pixmaps_created = true;
// titlebar
QPainter p;
QPainter maskPainter;
int i, x, y;
titlePix = new QPixmap(33, 12);
QBitmap mask(33, 12);
mask.fill(Qt::color0);
p.begin(titlePix);
maskPainter.begin(&mask);
maskPainter.setPen(Qt::color1);
for(i=0, y=2; i < 3; ++i, y+=4){
for(x=1; x <= 33; x+=3){
p.setPen(options->color(Options::TitleBar, true).light(150));
p.drawPoint(x, y);
maskPainter.drawPoint(x, y);
p.setPen(options->color(Options::TitleBar, true).dark(150));
p.drawPoint(x+1, y+1);
maskPainter.drawPoint(x+1, y+1);
}
}
p.end();
maskPainter.end();
titlePix->setMask(mask);
if(QPixmap::defaultDepth() > 8){
aUpperGradient = new KPixmap;
aUpperGradient->resize(32, titleHeight+2);
iUpperGradient = new KPixmap;
iUpperGradient->resize(32, titleHeight+2);
QColor bgColor = options->color(Options::TitleBar, true);
KPixmapEffect::gradient(*aUpperGradient,
bgColor.light(120),
bgColor.dark(120),
KPixmapEffect::VerticalGradient);
bgColor = options->color(Options::TitleBar, false);
KPixmapEffect::gradient(*iUpperGradient,
bgColor.light(120),
bgColor.dark(120),
KPixmapEffect::VerticalGradient);
}
// buttons (active/inactive, sunken/unsunken, 2 sizes each)
QColorGroup g = options->colorGroup(Options::ButtonBg, true);
QColor c = g.background();
btnPix1 = new KPixmap;
btnPix1->resize(btnWidth1, titleHeight);
btnDownPix1 = new KPixmap;
btnDownPix1->resize(btnWidth1, titleHeight);
btnPix2 = new KPixmap;
btnPix2->resize(btnWidth2, titleHeight);
btnDownPix2 = new KPixmap;
btnDownPix2->resize(btnWidth2, titleHeight);
iBtnPix1 = new KPixmap;
iBtnPix1->resize(btnWidth1, titleHeight);
iBtnDownPix1 = new KPixmap;
iBtnDownPix1->resize(btnWidth1, titleHeight);
iBtnPix2 = new KPixmap;
iBtnPix2->resize(btnWidth2, titleHeight);
iBtnDownPix2 = new KPixmap;
iBtnDownPix2->resize(btnWidth2, titleHeight);
if(QPixmap::defaultDepth() > 8){
KPixmapEffect::gradient(*btnPix1, c.light(120), c.dark(130),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(*btnDownPix1, c.dark(130), c.light(120),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(*btnPix2, c.light(120), c.dark(130),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(*btnDownPix2, c.dark(130), c.light(120),
KPixmapEffect::DiagonalGradient);
g = options->colorGroup(Options::ButtonBg, false);
c = g.background();
KPixmapEffect::gradient(*iBtnPix1, c.light(120), c.dark(130),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(*iBtnDownPix1, c.dark(130), c.light(120),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(*iBtnPix2, c.light(120), c.dark(130),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(*iBtnDownPix2, c.dark(130), c.light(120),
KPixmapEffect::DiagonalGradient);
}
else{
btnPix1->fill(c.rgb());
btnDownPix1->fill(c.rgb());
btnPix2->fill(c.rgb());
btnDownPix2->fill(c.rgb());
g = options->colorGroup(Options::ButtonBg, false);
c = g.background();
iBtnPix1->fill(c.rgb());
iBtnDownPix1->fill(c.rgb());
iBtnPix2->fill(c.rgb());
iBtnDownPix2->fill(c.rgb());
}
g = options->colorGroup(Options::ButtonBg, true);
c = g.background();
drawButtonFrame(btnPix1, g, false);
drawButtonFrame(btnDownPix1, g, true);
drawButtonFrame(btnPix2, g, false);
drawButtonFrame(btnDownPix2, g, true);
g = options->colorGroup(Options::ButtonBg, false);
c = g.background();
drawButtonFrame(iBtnPix1, g, false);
drawButtonFrame(iBtnDownPix1, g, true);
drawButtonFrame(iBtnPix2, g, false);
drawButtonFrame(iBtnDownPix2, g, true);
if(qGray(options->color(Options::ButtonBg, true).rgb()) > 128)
btnForeground = Qt::black;
else
btnForeground = Qt::white;
}
static void delete_pixmaps()
{
delete titlePix;
if(aUpperGradient){
delete aUpperGradient;
delete iUpperGradient;
delete btnPix1;
delete btnDownPix1;
delete iBtnPix1;
delete iBtnDownPix1;
delete btnPix2;
delete btnDownPix2;
delete iBtnPix2;
delete iBtnDownPix2;
}
pixmaps_created = false;
}
LaptopClientButton::LaptopClientButton(int w, int h, Client *parent, const char *name,
const unsigned char *bitmap)
: QButton(parent, name)
{
client = parent;
defaultSize = QSize(w, h);
setFixedHeight(h);
resize(defaultSize);
if(bitmap)
setBitmap(bitmap);
//setBackgroundMode(QWidget::NoBackground);
}
QSize LaptopClientButton::sizeHint() const
{
return(defaultSize);
}
void LaptopClientButton::reset()
{
repaint(false);
}
void LaptopClientButton::setBitmap(const unsigned char *bitmap)
{
deco = QBitmap(8, 8, bitmap, true);
deco.setMask(deco);
repaint();
}
void LaptopClientButton::drawButton(QPainter *p)
{
bool smallBtn = width() == btnWidth1;
if(btnPix1){
if(client->isActive()){
if(isDown())
p->drawPixmap(0, 0, smallBtn ? *btnDownPix1 : *btnDownPix2);
else
p->drawPixmap(0, 0, smallBtn ? *btnPix1 : *btnPix2);
}
else{
if(isDown())
p->drawPixmap(0, 0, smallBtn ? *iBtnDownPix1 : *iBtnDownPix2);
else
p->drawPixmap(0, 0, smallBtn ? *iBtnPix1 : *iBtnPix2);
}
}
else{
QColorGroup g = options->colorGroup(Options::ButtonBg,
client->isActive());
int w = width();
int h = height();
p->fillRect(1, 1, w-2, h-2, isDown() ? g.mid() : g.button());
p->setPen(isDown() ? g.dark() : g.light());
p->drawLine(0, 0, w-1, 0);
p->drawLine(0, 0, 0, w-1);
p->setPen(isDown() ? g.light() : g.dark());
p->drawLine(w-1, 0, w-1, h-1);
p->drawLine(0, h-1, w-1, h-1);
}
p->setPen(btnForeground);
int xOff = (width()-8)/2;
int yOff = (height()-8)/2;
p->drawPixmap(isDown() ? xOff+1: xOff, isDown() ? yOff+1 : yOff, deco);
}
void LaptopClient::slotReset()
{
int i;
for(i=0; i < 5; ++i){
if(button[i])
button[i]->reset();
}
repaint();
}
LaptopClient::LaptopClient( Workspace *ws, WId w, QWidget *parent,
const char *name )
: Client( ws, w, parent, name, WResizeNoErase | WNorthWestGravity )
{
lastButtonWidth = 0;
lastBufferWidth = 0;
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
bool help = providesContextHelp();
QGridLayout* g = new QGridLayout(this, 0, 0, 0);
g->setResizeMode(QLayout::FreeResize);
g->addRowSpacing(0, 3);
g->addRowSpacing(2, 1);
g->addWidget(windowWrapper(), 3, 1);
g->setRowStretch(3, 10);
g->addRowSpacing(4, 8); // bottom handles
g->addColSpacing(0, 4);
g->addColSpacing(2, 4);
int th = titleHeight;
if ( isTool() )
th -= 2;
button[BtnClose] = new LaptopClientButton(27, th, this, "close", close_bits);
button[BtnSticky] = new LaptopClientButton(17, th, this, "sticky");
if(isSticky())
button[BtnSticky]->setBitmap(unsticky_bits);
else
button[BtnSticky]->setBitmap(sticky_bits);
button[BtnIconify] = new LaptopClientButton(27, th, this, "iconify",
iconify_bits);
button[BtnMax] = new LaptopClientButton(27, th, this, "maximize",
maximize_bits);
if(help){
button[BtnHelp] = new LaptopClientButton(17, th, this, "help",
question_bits);
connect(button[BtnHelp], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) );
}
else
button[BtnHelp] = NULL;
connect( button[BtnClose], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
connect( button[BtnSticky], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
connect( button[BtnIconify], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) );
connect( button[BtnMax], SIGNAL( clicked() ), this, ( SLOT( slotMaximize() ) ) );
hb = new QHBoxLayout();
hb->setResizeMode(QLayout::FreeResize);
g->addLayout( hb, 1, 1 );
hb->addWidget( button[BtnClose]);
hb->addSpacing(1);
titlebar = new QSpacerItem(10, th, QSizePolicy::Expanding,
QSizePolicy::Minimum);
hb->addItem(titlebar);
hb->addSpacing(1);
if(help){
hb->addWidget( button[BtnHelp]);
}
hb->addWidget( button[BtnSticky]);
hb->addWidget( button[BtnIconify]);
hb->addWidget( button[BtnMax]);
if ( isTransient() || isTool() )
button[BtnSticky]->hide();
if ( !isMinimizable() )
button[BtnIconify]->hide();
if ( !isMaximizable() )
button[BtnMax]->hide();
hiddenItems = false;
bufferDirty = true;
}
void LaptopClient::slotMaximize()
{
if ( button[BtnMax]->last_button == MidButton )
maximize( MaximizeVertical );
else if ( button[BtnMax]->last_button == RightButton )
maximize( MaximizeHorizontal );
else
maximize();
}
void LaptopClient::resizeEvent( QResizeEvent* e)
{
Client::resizeEvent( e );
doShape();
calcHiddenButtons();
if ( isVisibleToTLW() ) {
int dx = 0;
int dy = 0;
if ( e->oldSize().width() != width() )
dx = 32 + QABS( e->oldSize().width() - width() );
if ( e->oldSize().height() != height() )
dy = 8 + QABS( e->oldSize().height() - height() );
if ( dy )
update( 0, height() - dy + 1, width(), dy );
if ( dx ) {
update( width() - dx + 1, 0, dx, height() );
update( QRect( QPoint(4,4), titlebar->geometry().bottomLeft() - QPoint(1,0) ) );
update( QRect( titlebar->geometry().topRight(), QPoint( width() - 4, titlebar->geometry().bottom() ) ) );
// titlebar needs no background
QApplication::postEvent( this, new QPaintEvent( titlebar->geometry(), FALSE ) );
}
}
}
void LaptopClient::captionChange( const QString& )
{
bufferDirty = true;
repaint( titlebar->geometry(), false );
}
void LaptopClient::paintEvent( QPaintEvent* )
{
QPainter p(this);
QColorGroup g = options->colorGroup(Options::Frame, isActive());
QRect r(rect());
p.setPen(Qt::black);
p.drawRect(r);
// outer frame
p.setPen(g.light());
p.drawLine(r.x()+1, r.y()+1, r.right()-1, r.y()+1);
p.drawLine(r.x()+1, r.y()+1, r.x()+1, r.bottom()-1);
p.setPen(g.dark());
p.drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom()-1);
p.drawLine(r.x()+1, r.bottom()-1, r.right()-1, r.bottom()-1);
int th = titleHeight;
if ( isTool() )
th -= 2;
// inner rect
p.drawRect(r.x()+3, r.y()+th+3, r.width()-6,
r.height()-th-10);
// handles
if(r.width() > 44){
qDrawShadePanel(&p, r.x()+1, r.bottom()-6, 20,
6, g, false, 1, &g.brush(QColorGroup::Mid));
qDrawShadePanel(&p, r.x()+21, r.bottom()-6, r.width()-42, 6,
g, false, 1, isActive() ?
&g.brush(QColorGroup::Background) :
&g.brush(QColorGroup::Mid));
qDrawShadePanel(&p, r.right()-20, r.bottom()-6, 20, 6,
g, false, 1, &g.brush(QColorGroup::Mid));
}
else
qDrawShadePanel(&p, r.x()+1, r.bottom()-6, r.width()-2, 6, g,
false, 1, isActive() ?
&g.brush(QColorGroup::Background) :
&g.brush(QColorGroup::Mid));
r = titlebar->geometry();
r.setRight(r.right()-1);
if(isActive()){
updateActiveBuffer();
p.drawPixmap(r.x(), r.y(), activeBuffer);
}
else{
if(iUpperGradient)
p.drawTiledPixmap(r.x(), r.y(), r.width(), r.height()-1,
*iUpperGradient);
else
p.fillRect(r.x(), r.y(), r.width(), r.height()-1,
options->color(Options::TitleBar, false));
p.setFont(options->font(false, isTool() ));
QFontMetrics fm(options->font(false));
g = options->colorGroup(Options::TitleBar, false);
if(iUpperGradient)
p.drawTiledPixmap(r.x()+((r.width()-fm.width(caption()))/2)-4,
r.y(), fm.width(caption())+8, r.height()-1,
*iUpperGradient);
else
p.fillRect(r.x()+((r.width()-fm.width(caption()))/2)-4, r.y(),
fm.width(caption())+8, r.height()-1,
g.brush(QColorGroup::Background));
p.setPen(g.mid());
p.drawLine(r.x(), r.y(), r.right(), r.y());
p.drawLine(r.x(), r.y(), r.x(), r.bottom());
p.setPen(g.button());
p.drawLine(r.right(), r.y(), r.right(), r.bottom());
p.drawLine(r.x(), r.bottom(), r.right(), r.bottom());
p.setPen(options->color(Options::Font, false));
p.drawText(r.x(), r.y(), r.width(), r.height()-1,
AlignCenter, caption() );
g = options->colorGroup(Options::Frame, true);
p.setPen(g.background());
p.drawPoint(r.x(), r.y());
p.drawPoint(r.right(), r.y());
p.drawLine(r.right()+1, r.y(), r.right()+1, r.bottom());
}
}
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
void LaptopClient::doShape()
{
QRegion mask(QRect(0, 0, width(), height()));
mask -= QRect(0, 0, 1, 1);
mask -= QRect(width()-1, 0, 1, 1);
mask -= QRect(0, height()-1, 1, 1);
mask -= QRect(width()-1, height()-1, 1, 1);
setMask(mask);
}
void LaptopClient::showEvent(QShowEvent *ev)
{
Client::showEvent(ev);
doShape();
repaint();
}
void LaptopClient::windowWrapperShowEvent( QShowEvent* )
{
doShape();
}
void LaptopClient::mouseDoubleClickEvent( QMouseEvent * e )
{
if (titlebar->geometry().contains( e->pos() ) )
workspace()->performWindowOperation( this, options->operationTitlebarDblClick() );
workspace()->requestFocus( this );
}
void LaptopClient::stickyChange(bool on)
{
button[BtnSticky]->setBitmap(on ? unsticky_bits : sticky_bits);
}
void LaptopClient::maximizeChange(bool m)
{
button[BtnMax]->setBitmap(m ? minmax_bits : maximize_bits);
}
void LaptopClient::init()
{
//
}
void LaptopClient::activeChange(bool)
{
repaint(false);
int i;
for(i=0; i < 5; ++i){
if(button[i])
button[i]->reset();
}
}
void LaptopClient::calcHiddenButtons()
{
// order of hiding is help, sticky, maximize, minimize, close;
// buttons can have
int minWidth = 32 + btnWidth2*3 + (providesContextHelp() ? btnWidth1*2 :
btnWidth1);
if(lastButtonWidth > width()){ // shrinking
lastButtonWidth = width();
if(width() < minWidth){
hiddenItems = true;
int i;
for(i=0; i<5; ++i){
if(button[i]){
if( !button[i]->isHidden() ) {
button[i]->hide();
}
minWidth-=button[i]->sizeHint().width();
if(width() >= minWidth)
return;
}
}
}
}
else if(hiddenItems){ // expanding
lastButtonWidth = width();
int i;
int totalSize=32;
for(i=4; i>=0; --i){
if(button[i]){
if(button[i]->sizeHint().width() + totalSize <= width()){
totalSize+=button[i]->sizeHint().width();
if(button[i]->isHidden() &&
( !isTransient() || !isTransient() || i != BtnSticky ) &&
( isMinimizable() || i != BtnIconify ) &&
( isMaximizable() || ( i != BtnIconify && i != BtnSticky && i != BtnMax ) )
) {
button[i]->resize(button[i]->sizeHint());
button[i]->show();
}
}
else
return;
}
}
// all items shown now
hiddenItems = false;
}
else
lastButtonWidth = width();
}
void LaptopClient::updateActiveBuffer( )
{
if( !bufferDirty && (lastBufferWidth == titlebar->geometry().width()))
return;
if ( titlebar->geometry().width() <= 0 || titlebar->geometry().height() <= 0 )
return;
lastBufferWidth = titlebar->geometry().width();
bufferDirty = false;
activeBuffer.resize(titlebar->geometry().width(),
titlebar->geometry().height());
QPainter p;
QRect r(0, 0, activeBuffer.width()-1, activeBuffer.height());
p.begin(&activeBuffer);
if(aUpperGradient){
p.drawTiledPixmap(r, *aUpperGradient);
}
else{
p.fillRect(r, options->color(Options::TitleBar, true));
}
if(titlePix)
p.drawTiledPixmap(r, *titlePix);
p.setFont(options->font(true, isTool() ));
QFontMetrics fm(options->font(true));
QColorGroup g = options->colorGroup(Options::TitleBar, true);
if(aUpperGradient)
p.drawTiledPixmap(r.x()+((r.width()-fm.width(caption()))/2)-4,
r.y(), fm.width(caption())+8, r.height()-1,
*aUpperGradient);
else
p.fillRect(r.x()+((r.width()-fm.width(caption()))/2)-4, 0,
fm.width(caption())+8, r.height(),
g.brush(QColorGroup::Background));
p.setPen(g.mid());
p.drawLine(r.x(), r.y(), r.right(), r.y());
p.drawLine(r.x(), r.y(), r.x(), r.bottom());
p.setPen(g.button());
p.drawLine(r.right(), r.y(), r.right(), r.bottom());
p.drawLine(r.x(), r.bottom(), r.right(), r.bottom());
p.setPen(options->color(Options::Font, true));
p.drawText(r.x(), r.y(), r.width(), r.height()-1,
AlignCenter, caption() );
g = options->colorGroup(Options::Frame, true);
p.setPen(g.background());
p.drawPoint(r.x(), r.y());
p.drawPoint(r.right(), r.y());
p.drawLine(r.right()+1, r.y(), r.right()+1, r.bottom());
p.end();
}
Client::MousePosition
LaptopClient::mousePosition( const QPoint& p ) const
{
MousePosition m = Nowhere;
if (p.y() < (height() - 7))
m = Client::mousePosition(p);
else {
if (p.x() >= (width() - 20))
m = BottomRight;
else if (p.x() <= 20)
m = BottomLeft;
else
m = Bottom;
}
return m;
}
extern "C"
{
Client *allocate(Workspace *ws, WId w, int)
{
return(new LaptopClient(ws, w));
}
void init()
{
create_pixmaps();
}
void reset()
{
delete_pixmaps();
create_pixmaps();
}
void deinit()
{
delete_pixmaps();
}
}
#include "laptopclient.moc"

View File

@ -1,86 +0,0 @@
#ifndef __KDECLIENT_H
#define __KDECLIENT_H
#include <qbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
class QLabel;
class QSpacerItem;
class QHBoxLayout;
namespace KWinInternal {
// get rid of autohide :P
class LaptopClientButton : public QButton
{
public:
LaptopClientButton(int w, int h, Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL);
void setBitmap(const unsigned char *bitmap);
void reset();
QSize sizeHint() const;
int last_button;
protected:
void mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mousePressEvent( &me );
}
void mouseReleaseEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
QSize defaultSize;
QBitmap deco;
Client *client;
};
class LaptopClient : public KWinInternal::Client
{
Q_OBJECT
public:
enum Buttons{BtnHelp=0, BtnSticky, BtnMax, BtnIconify, BtnClose};
LaptopClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~LaptopClient(){;}
protected:
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void showEvent( QShowEvent* );
void windowWrapperShowEvent( QShowEvent* );
void mouseDoubleClickEvent( QMouseEvent * );
void init();
void captionChange( const QString& name );
void stickyChange(bool on);
void maximizeChange(bool m);
void doShape();
void activeChange(bool);
void calcHiddenButtons();
void updateActiveBuffer();
MousePosition mousePosition(const QPoint &) const;
protected slots:
void slotReset();
void slotMaximize();
private:
LaptopClientButton* button[5];
int lastButtonWidth;
QSpacerItem* titlebar;
bool hiddenItems;
QHBoxLayout *hb;
KPixmap activeBuffer;
bool bufferDirty;
int lastBufferWidth;
};
};
#endif

View File

@ -1,20 +0,0 @@
# $Id$
INCLUDES = $(all_includes)
SUBDIRS = config
kde_module_LTLIBRARIES = libkwinmodernsys.la
libkwinmodernsys_la_SOURCES = modernsys.cpp
libkwinmodernsys_la_LIBADD = ../../kwin.la
libkwinmodernsys_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
METASOURCES = AUTO
noinst_HEADERS = modernsys.h
lnkdir = $(kde_datadir)/kwin/
lnk_DATA = modernsystem.desktop
EXTRA_DIST = $(lnk_DATA)

View File

@ -1,93 +0,0 @@
/* XPM */
static const char * btnhighcolor_xpm[] = {
"14 15 75 1",
" c None",
". c #6E6E6E",
"+ c #757575",
"@ c #878787",
"# c #7D7D7D",
"$ c #9E9E9E",
"% c #B9B9B9",
"& c #C6C6C6",
"* c #BABABA",
"= c #A5A5A5",
"- c #7F7F7F",
"; c #848484",
"> c #A7A7A7",
", c #BFBFBF",
"' c #D1D1D1",
") c #D7D7D7",
"! c #DADADA",
"~ c #CBCBCB",
"{ c #ABABAB",
"] c #B3B3B3",
"^ c #C2C2C2",
"/ c #CACACA",
"( c #C9C9C9",
"_ c #B6B6B6",
": c #9A9A9A",
"< c #999999",
"[ c #B0B0B0",
"} c #C4C4C4",
"| c #C3C3C3",
"1 c #C0C0C0",
"2 c #AEAEAE",
"3 c #969696",
"4 c #C1C1C1",
"5 c #CCCCCC",
"6 c #C5C5C5",
"7 c #BEBEBE",
"8 c #AAAAAA",
"9 c #CECECE",
"0 c #D4D4D4",
"a c #DBDBDB",
"b c #DEDEDE",
"c c #D5D5D5",
"d c #D3D3D3",
"e c #BCBCBC",
"f c #CDCDCD",
"g c #E0E0E0",
"h c #E4E4E4",
"i c #E8E8E8",
"j c #EBEBEB",
"k c #E9E9E9",
"l c #E6E6E6",
"m c #DDDDDD",
"n c #E1E1E1",
"o c #EDEDED",
"p c #F1F1F1",
"q c #F5F5F5",
"r c #F8F8F8",
"s c #F6F6F6",
"t c #F3F3F3",
"u c #EEEEEE",
"v c #E5E5E5",
"w c #DCDCDC",
"x c #B7B7B7",
"y c #E2E2E2",
"z c #FDFDFD",
"A c #FFFFFF",
"B c #FCFCFC",
"C c #F7F7F7",
"D c #B5B5B5",
"E c #F2F2F2",
"F c #FAFAFA",
"G c #9B9B9B",
"H c #FBFBFB",
"I c #A9A9A9",
"J c #747474",
" .... ",
" ..+@@+.. ",
" .#$%&&*=-. ",
" .;>,')!)~{#. ",
" .$]^///(&_:. ",
".<[*^}||11*23.",
".[4&5555~(678.",
".,90!aba)cd~e.",
".faghijklhm06.",
".'nopqrstuvw/.",
".xyprzAzBCunD.",
" .'EzAAAAFpf. ",
" .GcHAAAAF0<. ",
" ..I5kk5I.. ",
" J..... "};

View File

@ -1,42 +0,0 @@
/* Image bits processed by KPixmap2Bitmaps */
#define lowcolor_mask_width 14
#define lowcolor_mask_height 15
static unsigned char lowcolor_mask_bits[] = {
0xf0,0x03,0xf8,0x07,0xfc,0xcf,0xfe,0x1f,0xfe,0x1f,0xff,0xff,0xff,0xff,0xff,
0x3f,0xff,0x3f,0xff,0xbf,0xfe,0xdf,0xfe,0x9f,0xfc,0x0f,0xf8,0x07,0xf0,0x03,
0x00,0x40,0x80,0x00,0x00,0x00,0x29,0x00,0x00,0x00,0x7c,0xfe,0x87,0x40,0x00,
0x00,0x64,0x00,0x20,0x00,0x64,0x00,0x86,0xfe,0x87,0x40,0x00,0x00,0x65,0x00 };
#define lowcolor_6a696a_width 14
#define lowcolor_6a696a_height 15
static unsigned char lowcolor_6a696a_bits[] = {
0xf0,0x03,0x18,0x06,0x04,0xcc,0x06,0x18,0x02,0x10,0x00,0xc0,0x00,0xc0,0x00,
0x00,0x00,0x00,0x00,0xc0,0x00,0xc0,0x00,0x80,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x40,0x80,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x03,
0x00,0x00,0x00,0x80,0x24,0x0e,0x08,0x61,0x00,0x00,0x00,0xf0,0xd9,0x0c,0x08 };
#define lowcolor_949194_width 14
#define lowcolor_949194_height 15
static unsigned char lowcolor_949194_bits[] = {
0x00,0x40,0xe0,0x01,0x08,0x02,0x00,0x04,0x04,0x08,0x07,0x78,0x03,0xf0,0x01,
0xe0,0x01,0x60,0x01,0x20,0x00,0xc0,0x02,0x90,0x04,0x08,0x08,0x04,0xf0,0x03,
0x00,0x40,0x80,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0xc8,0x51,0x0c,0x08,0x0e,
0x01,0x00,0x00,0x37,0x00,0x00,0x00,0x58,0x5f,0x49,0x6d,0x61,0x67,0x65,0x54 };
#define lowcolor_b4b6b4_width 14
#define lowcolor_b4b6b4_height 15
static unsigned char lowcolor_b4b6b4_bits[] = {
0x00,0x40,0x00,0x00,0x10,0x00,0x08,0x02,0x18,0x06,0xb8,0x47,0x0c,0xce,0x0e,
0xd8,0x06,0x58,0x02,0x10,0x02,0xd0,0x00,0x80,0x00,0x00,0x10,0x02,0x00,0x00,
0x00,0x40,0x80,0x00,0x00,0x00,0x11,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,
0x00,0x08,0x00,0x02,0x00,0x00,0x00,0x61,0x00,0x00,0x00,0x38,0x5b,0x0c,0x08 };
#define lowcolor_e6e6e6_width 14
#define lowcolor_e6e6e6_height 15
static unsigned char lowcolor_e6e6e6_bits[] = {
0x00,0x40,0x00,0x00,0x00,0x00,0xe0,0x01,0x00,0x00,0x00,0x40,0x00,0xc0,0x00,
0xc0,0x00,0x40,0xe0,0xc0,0xe0,0xc1,0xe0,0x81,0xf0,0x03,0xc0,0x00,0x00,0x00,
0x00,0x40,0x80,0x00,0x00,0x00,0x39,0x00,0x00,0x00,0x08,0x19,0x0d,0x08,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x00,0x00,0x00 };

View File

@ -1,15 +0,0 @@
# $Id$
INCLUDES = $(all_includes)
kde_module_LTLIBRARIES = libkwinmodernsys_config.la
libkwinmodernsys_config_la_SOURCES = config.cpp
libkwinmodernsys_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
libkwinmodernsys_config_la_LIBADD = $(LIB_KDEUI)
METASOURCES = AUTO
noinst_HEADERS = config.h
lnkdir = $(kde_datadir)/kwin/

View File

@ -1,77 +0,0 @@
// $Id$
// Melchior FRANZ <a8603365@unet.univie.ac.at> -- 2001-04-22
#include "config.h"
#include <kconfig.h>
#include <klocale.h>
#include <qwhatsthis.h>
extern "C"
{
QObject* allocate_config( KConfig* conf, QWidget* parent )
{
return(new ModernSysConfig(conf, parent));
}
}
// 'conf' is a pointer to the kwindecoration modules open kwin config,
// and is by default set to the "Style" group.
//
// 'parent' is the parent of the QObject, which is a VBox inside the
// Configure tab in kwindecoration
ModernSysConfig::ModernSysConfig(KConfig* conf, QWidget* parent) : QObject(parent)
{
clientrc = new KConfig("kwinmodernsysrc");
gb = new QGroupBox(1, Qt::Horizontal, i18n("Decoration Settings"), parent);
cbShowHandle = new QCheckBox(i18n("&Show resize handle"), gb);
QWhatsThis::add(cbShowHandle, i18n("When selected, all windows are drawn with a resize "
"handle at the lower right corner."));
connect(cbShowHandle, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()));
load(conf);
gb->show();
}
ModernSysConfig::~ModernSysConfig()
{
delete cbShowHandle;
delete gb;
delete clientrc;
}
void ModernSysConfig::slotSelectionChanged()
{
emit changed();
}
void ModernSysConfig::load(KConfig* /*conf*/)
{
clientrc->setGroup("General");
bool i = clientrc->readBoolEntry("ShowHandle", true );
cbShowHandle->setChecked(i);
handle_width = clientrc->readUnsignedNumEntry("HandleWidth", 6);
handle_size = clientrc->readUnsignedNumEntry("HandleSize", 30);
}
void ModernSysConfig::save(KConfig* /*conf*/)
{
clientrc->setGroup("General");
clientrc->writeEntry("ShowHandle", cbShowHandle->isChecked());
clientrc->writeEntry("HandleWidth", handle_width);
clientrc->writeEntry("HandleSize", handle_size);
clientrc->sync();
}
void ModernSysConfig::defaults()
{
cbShowHandle->setChecked(true);
}
#include "config.moc"

View File

@ -1,38 +0,0 @@
// $Id$
#ifndef __KDE_MODSYSTEMCONFIG_H
#define __KDE_MODSYSTEMCONFIG_H
#include <qcheckbox.h>
#include <qgroupbox.h>
#include <kconfig.h>
class ModernSysConfig : public QObject
{
Q_OBJECT
public:
ModernSysConfig( KConfig* conf, QWidget* parent );
~ModernSysConfig();
// These public signals/slots work similar to KCM modules
signals:
void changed();
public slots:
void load( KConfig* conf );
void save( KConfig* conf );
void defaults();
protected slots:
void slotSelectionChanged(); // Internal use
private:
KConfig *clientrc;
QGroupBox *gb;
QCheckBox *cbShowHandle;
unsigned handle_width;
unsigned handle_size;
};
#endif

View File

@ -1,646 +0,0 @@
// $Id$
// Daniel M. DULEY <mosfet@kde.org> original work
// Melchior FRANZ <a8603365@unet.univie.ac.at> configuration options
#include <kconfig.h>
#include <kglobal.h>
#include <qlayout.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
#include "modernsys.h"
#include "buttondata.h"
#include "btnhighcolor.h"
using namespace KWinInternal;
static unsigned char iconify_bits[] = {
0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00};
static unsigned char close_bits[] = {
0x00, 0x66, 0x7e, 0x3c, 0x3c, 0x7e, 0x66, 0x00};
static unsigned char maximize_bits[] = {
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00};
static unsigned char minmax_bits[] = {
0x0c, 0x18, 0x33, 0x67, 0xcf, 0x9f, 0x3f, 0x3f};
static unsigned char unsticky_bits[] = {
0x3c, 0x42, 0x99, 0xbd, 0xbd, 0x99, 0x42, 0x3c};
static unsigned char sticky_bits[] = {
0x3c, 0x42, 0x81, 0x81, 0x81, 0x81, 0x42, 0x3c};
static unsigned char question_bits[] = {
0x3c, 0x66, 0x60, 0x30, 0x18, 0x00, 0x18, 0x18};
static unsigned char btnhighcolor_mask_bits[] = {
0xe0,0x41,0xf8,0x07,0xfc,0x0f,0xfe,0xdf,0xfe,0x1f,0xff,0x3f,0xff,0xff,0xff,
0x3f,0xff,0x3f,0xff,0xff,0xff,0xff,0xfe,0x9f,0xfe,0x1f,0xfc,0x0f,0xf0,0x03,
0x00,0x40,0x80,0x00,0x00,0x00,0x39,0x00,0x00,0x00,0x20,0x99,0x0f,0x08,0xc4,
0x00,0x00,0x00,0x67,0x00,0x00,0x00,0x58,0x5f,0x43,0x68,0x61,0x6e,0x67,0x65 };
static KPixmap *aUpperGradient=0;
static KPixmap *iUpperGradient=0;
static QPixmap *buttonPix=0;
static QPixmap *buttonPixDown=0;
static QPixmap *iButtonPix=0;
static QPixmap *iButtonPixDown=0;
static QColor *buttonFg;
static bool pixmaps_created = false;
static QBitmap *lcDark1;
static QBitmap *lcDark2;
static QBitmap *lcDark3;
static QBitmap *lcLight1;
static QImage *btnSource;
static QString *button_pattern = NULL;
static bool show_handle;
static int handle_size;
static int handle_width;
static bool config_changed;
static void make_button_fx(const QColorGroup &g, QPixmap *pix, bool light=false)
{
pix->fill(g.background());
QPainter p(pix);
if(QPixmap::defaultDepth() > 8){
int i, destH, destS, destV, srcH, srcS, srcV;
QColor btnColor = g.background();
if(btnSource->depth() < 32)
*btnSource = btnSource->convertDepth(32);
if(light)
btnColor = btnColor.light(120);
btnColor.hsv(&destH, &destS, &destV);
QImage btnDest(14, 15, 32);
unsigned int *srcData = (unsigned int *)btnSource->bits();
unsigned int *destData = (unsigned int *)btnDest.bits();
QColor srcColor;
for(i=0; i < btnSource->width()*btnSource->height(); ++i){
srcColor.setRgb(srcData[i]);
srcColor.hsv(&srcH, &srcS, &srcV);
srcColor.setHsv(destH, destS, srcV);
destData[i] = srcColor.rgb();
}
pix->convertFromImage(btnDest);
}
else{
if(!lcDark1->mask()){
lcDark1->setMask(*lcDark1);
lcDark2->setMask(*lcDark2);
lcDark3->setMask(*lcDark3);
lcLight1->setMask(*lcLight1);
}
p.setPen(g.dark());
p.drawPixmap(0, 0, *lcDark2);
p.drawPixmap(0, 0, *lcDark1);
p.setPen(g.mid());
p.drawPixmap(0, 0, *lcDark3);
p.setPen(g.light());
p.drawPixmap(0, 0, *lcLight1);
}
}
static void create_pixmaps()
{
if(pixmaps_created)
return;
pixmaps_created = true;
lcDark1 = new QBitmap(14, 15, lowcolor_6a696a_bits, true);
lcDark2 = new QBitmap(14, 15, lowcolor_949194_bits, true);
lcDark3 = new QBitmap(14, 15, lowcolor_b4b6b4_bits, true);
lcLight1 = new QBitmap(14, 15, lowcolor_e6e6e6_bits, true);
btnSource = new QImage(btnhighcolor_xpm);
if(QPixmap::defaultDepth() > 8){
aUpperGradient = new KPixmap;
aUpperGradient->resize(32, 18);
iUpperGradient = new KPixmap;
iUpperGradient->resize(32, 18);
KPixmapEffect::gradient(*aUpperGradient,
options->color(Options::TitleBar, true).light(130),
options->color(Options::TitleBlend, true),
KPixmapEffect::VerticalGradient);
KPixmapEffect::gradient(*iUpperGradient,
options->color(Options::TitleBar, false).light(130),
options->color(Options::TitleBlend, false),
KPixmapEffect::VerticalGradient);
}
// buttons
QColorGroup btnColor(options->colorGroup(Options::ButtonBg, true));
buttonPix = new QPixmap(14, 15);
make_button_fx(btnColor, buttonPix);
buttonPixDown = new QPixmap(14, 15);
make_button_fx(btnColor, buttonPixDown, true);
btnColor = options->colorGroup(Options::ButtonBg, false);
iButtonPix = new QPixmap(14, 15);
make_button_fx(btnColor, iButtonPix);
iButtonPixDown = new QPixmap(14, 15);
make_button_fx(btnColor, iButtonPixDown, true);
if(qGray(btnColor.background().rgb()) < 150)
buttonFg = new QColor(Qt::white);
else
buttonFg = new QColor(Qt::black);
delete lcDark1;
delete lcDark2;
delete lcDark3;
delete lcLight1;
delete btnSource;
}
static void delete_pixmaps()
{
if(aUpperGradient){
delete aUpperGradient;
delete iUpperGradient;
}
delete buttonPix;
delete buttonPixDown;
delete iButtonPix;
delete iButtonPixDown;
delete buttonFg;
pixmaps_created = false;
}
static bool read_config()
{
bool showh;
int hsize, hwidth;
QString bpatt;
KConfig c("kwinmodernsysrc");
c.setGroup("General");
showh = c.readBoolEntry("ShowHandle", true);
hwidth = c.readUnsignedNumEntry("HandleWidth", 6);
hsize = c.readUnsignedNumEntry("HandleSize", 30);
if (!(showh && hsize && hwidth)) {
showh = false;
hwidth = hsize = 0;
}
if (options->customButtonPositions()) {
bpatt = "2" + options->titleButtonsLeft() + "3t3"
+ options->titleButtonsRight() + "2";
}
else
bpatt = "2X3t3HSIA2";
if (showh == show_handle && hwidth == handle_width && hsize == handle_size
&& bpatt == *button_pattern)
return false;
show_handle = showh;
handle_width = hwidth;
handle_size = hsize;
*button_pattern = bpatt;
return true;
}
ModernButton::ModernButton(Client *parent, const char *name,
const unsigned char *bitmap)
: QButton(parent, name)
{
setBackgroundMode( NoBackground );
QBitmap mask(14, 15, QPixmap::defaultDepth() > 8 ?
btnhighcolor_mask_bits : lowcolor_mask_bits, true);
resize(14, 15);
if(bitmap)
setBitmap(bitmap);
setMask(mask);
client = parent;
hide();
}
QSize ModernButton::sizeHint() const
{
return(QSize(14, 15));
}
void ModernButton::reset()
{
repaint(false);
}
void ModernButton::setBitmap(const unsigned char *bitmap)
{
deco = QBitmap(8, 8, bitmap, true);
deco.setMask(deco);
repaint();
}
void ModernButton::drawButton(QPainter *p)
{
if(client->isActive()){
if(buttonPix)
p->drawPixmap(0, 0, isDown() ? *buttonPixDown : *buttonPix);
}
else{
if(iButtonPix)
p->drawPixmap(0, 0, isDown() ? *iButtonPixDown : *iButtonPix);
}
if(!deco.isNull()){
p->setPen(*buttonFg);
p->drawPixmap(isDown() ? 4 : 3, isDown() ? 5 : 4, deco);
}
}
void ModernButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mousePressEvent( &me );
}
void ModernButton::mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QButton::mouseReleaseEvent( &me );
}
void ModernSys::slotReset()
{
if (config_changed) {
workspace()->slotResetAllClientsDelayed();
config_changed = false;
}
titleBuffer.resize(0, 0);
recalcTitleBuffer();
for (int i = 0; i < 5; button[i++]->reset());
repaint();
}
ModernSys::ModernSys( Workspace *ws, WId w, QWidget *parent,
const char *name )
: Client( ws, w, parent, name, WResizeNoErase )
{
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
bool help = providesContextHelp();
QGridLayout* g = new QGridLayout(this, 0, 0, 2);
g->addWidget(windowWrapper(), 1, 1 );
g->setRowStretch(1, 10);
g->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) );
g->addColSpacing(0, 2);
g->addColSpacing(2, 2 + handle_width);
g->addRowSpacing(2, 2 + handle_width);
QHBoxLayout* hb = new QHBoxLayout(0);
hb->setResizeMode(QLayout::FreeResize);
titlebar = new QSpacerItem(10, 16, QSizePolicy::Expanding,
QSizePolicy::Minimum);
button[BtnClose] = new ModernButton(this, "close", close_bits);
button[BtnSticky] = new ModernButton(this, "sticky");
button[BtnMinimize] = new ModernButton(this, "iconify", iconify_bits);
button[BtnMaximize] = new ModernButton(this, "maximize", maximize_bits);
button[BtnHelp] = new ModernButton(this, "help", question_bits);
connect( button[BtnClose], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
connect( button[BtnSticky], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
connect( button[BtnMinimize], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) );
connect( button[BtnMaximize], SIGNAL( clicked() ), this, ( SLOT( maxButtonClicked() ) ) );
connect( button[BtnHelp], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) );
for (int i = 0; i < (int)button_pattern->length();) {
QChar c = (*button_pattern)[i++];
if (c == '_')
c = '3';
if (c.isDigit()) {
hb->addSpacing(int(c - '0'));
continue;
}
else if (c == 'X') {
hb->addWidget(button[BtnClose]);
button[BtnClose]->show();
}
else if (c == 'S') {
if(isSticky())
button[BtnSticky]->setBitmap(unsticky_bits);
else
button[BtnSticky]->setBitmap(sticky_bits);
hb->addWidget(button[BtnSticky]);
button[BtnSticky]->show();
}
else if (c == 'I' && isMinimizable()) {
hb->addWidget(button[BtnMinimize]);
button[BtnMinimize]->show();
}
else if (c == 'A' && isMaximizable()) {
hb->addWidget(button[BtnMaximize]);
button[BtnMaximize]->show();
}
else if (help && c == 'H') {
hb->addWidget(button[BtnHelp]);
button[BtnHelp]->show();
}
else if (c == 't')
hb->addItem(titlebar);
if ((*button_pattern)[i] >= 'A' && (*button_pattern)[i] <= 'Z')
hb->addSpacing(1);
}
g->addLayout( hb, 0, 1 );
setBackgroundMode(NoBackground);
recalcTitleBuffer();
}
void ModernSys::maxButtonClicked( )
{
switch ( button[BtnMaximize]->last_button ) {
case MidButton:
maximize( MaximizeVertical );
break;
case RightButton:
maximize( MaximizeHorizontal );
break;
default: //LeftButton:
maximize( MaximizeFull );
break;
}
}
void ModernSys::resizeEvent( QResizeEvent* )
{
recalcTitleBuffer();
doShape();
}
void ModernSys::recalcTitleBuffer()
{
if(oldTitle == caption() && width() == titleBuffer.width())
return;
QFontMetrics fm(options->font(true));
titleBuffer.resize(width(), 18);
QPainter p;
p.begin(&titleBuffer);
if(aUpperGradient)
p.drawTiledPixmap(0, 0, width(), 18, *aUpperGradient);
else
p.fillRect(0, 0, width(), 18,
options->colorGroup(Options::TitleBar, true).
brush(QColorGroup::Button));
QRect t = titlebar->geometry();
t.setTop( 2 );
t.setLeft( t.left() );
t.setRight( t.right() - 2 );
QRegion r(t.x(), 0, t.width(), 18);
r -= QRect(t.x()+((t.width()-fm.width(caption()))/2)-4,
0, fm.width(caption())+8, 18);
p.setClipRegion(r);
int i, ly;
for(i=0, ly=4; i < 4; ++i, ly+=3){
p.setPen(options->color(Options::TitleBar, true).light(150));
p.drawLine(0, ly, width()-1, ly);
p.setPen(options->color(Options::TitleBar, true).dark(120));
p.drawLine(0, ly+1, width()-1, ly+1);
}
p.setClipRect(t);
p.setPen(options->color(Options::Font, true));
p.setFont(options->font(true));
p.drawText(t.x()+((t.width()-fm.width(caption()))/2)-4,
0, fm.width(caption())+8, 18, AlignCenter, caption());
p.setClipping(false);
p.end();
oldTitle = caption();
}
void ModernSys::captionChange( const QString &)
{
recalcTitleBuffer();
repaint( titlebar->geometry(), false );
}
void ModernSys::drawRoundFrame(QPainter &p, int x, int y, int w, int h)
{
kDrawRoundButton(&p, x, y, w, h,
options->colorGroup(Options::Frame, isActive()), false);
}
void ModernSys::paintEvent( QPaintEvent* )
{
int hs = handle_size;
int hw = handle_width;
QPainter p( this );
QRect t = titlebar->geometry();
QBrush fillBrush(colorGroup().brush(QColorGroup::Background).pixmap() ?
colorGroup().brush(QColorGroup::Background) :
options->colorGroup(Options::Frame, isActive()).
brush(QColorGroup::Button));
p.fillRect(1, 16, width()-2, height()-16, fillBrush);
p.fillRect(width()-6, 0, width()-1, height(), fillBrush);
t.setTop( 2 );
t.setLeft( t.left() );
t.setRight( t.right() - 2 );
int w = width() - hw; // exclude handle
int h = height() - hw;
// titlebar
QColorGroup g = options->colorGroup(Options::TitleBar, isActive());
if(isActive()){
p.drawPixmap(1, 1, titleBuffer, 0, 0, w-2, 18);
}
else{
if(iUpperGradient)
p.drawTiledPixmap(1, 1, w-2, 18, *iUpperGradient);
else
p.fillRect(1, 1, w-2, 18, fillBrush);
p.setPen(options->color(Options::Font, isActive()));
p.setFont(options->font(isActive()));
p.drawText(t, AlignCenter, caption() );
}
// titlebar highlight
p.setPen(g.light());
p.drawLine(1, 1, 1, 19);
p.drawLine(1, 1, w-3, 1);
p.setPen(g.dark());
p.drawLine(w-2, 1, w-2, 19);
p.drawLine(0, 18, w-2, 18);
// frame
g = options->colorGroup(Options::Frame, isActive());
p.setPen(g.light());
p.drawLine(1, 19, 1, h-2);
p.setPen(g.dark());
p.drawLine(2, h-2, w-2, h-2);
p.drawLine(w-2, 19, w-2, h-2);
//p.drawPoint(w-3, 19);
//p.drawPoint(2, 19);
qDrawShadePanel(&p, 3, 19, w-6, h-22, g, true);
if (show_handle) {
p.setPen(g.dark());
p.drawLine(width()-3, height()-hs-1, width()-3, height()-3);
p.drawLine(width()-hs-1, height()-3, width()-3, height()-3);
p.setPen(g.light());
p.drawLine(width()-hw, height()-hs-1, width()-hw, height()-hw);
p.drawLine(width()-hs-1, height()-hw, width()-hw, height()-hw);
p.drawLine(width()-hw, height()-hs-1, width()-4, height()-hs-1);
p.drawLine(width()-hs-1, height()-hw, width()-hs-1, height()-4);
p.setPen(Qt::black);
p.drawRect(0, 0, w, h);
// handle outline
p.drawLine(width()-hw, height()-hs, width(), height()-hs);
p.drawLine(width()-2, height()-hs, width()-2, height()-2);
p.drawLine(width()-hs, height()-2, width()-2, height()-2);
p.drawLine(width()-hs, height()-hw, width()-hs, height()-2);
} else {
p.setPen(Qt::black);
p.drawRect(0, 0, w, h);
}
}
void ModernSys::doShape()
{
int hs = handle_size;
int hw = handle_width;
QRegion mask;
mask += QRect(0, 0, width()-hw, height()-hw);
//single points
mask -= QRect(0, 0, 1, 1);
mask -= QRect(width()-hw-1, 0, 1, 1);
mask -= QRect(0, height()-hw-1, 1, 1);
if (show_handle) {
mask += QRect(width()-hs, height()-hs, hs-1, hs-1);
mask -= QRect(width()-2, height()-2, 1, 1);
mask -= QRect(width()-2, height()-hs, 1, 1);
mask -= QRect(width()-hs, height()-2, 1, 1);
} else
mask -= QRect(width()-1, height()-1, 1, 1);
setMask(mask);
}
void ModernSys::showEvent(QShowEvent *ev)
{
Client::showEvent(ev);
doShape();
repaint();
}
void ModernSys::windowWrapperShowEvent( QShowEvent* )
{
doShape();
}
void ModernSys::mouseDoubleClickEvent( QMouseEvent * e )
{
if (titlebar->geometry().contains( e->pos() ) )
workspace()->performWindowOperation( this, options->operationTitlebarDblClick() );
workspace()->requestFocus( this );
}
void ModernSys::stickyChange(bool on)
{
button[BtnSticky]->setBitmap(on ? unsticky_bits : sticky_bits);
}
void ModernSys::maximizeChange(bool m)
{
button[BtnMaximize]->setBitmap(m ? minmax_bits : maximize_bits);
}
void ModernSys::init()
{
//
}
void ModernSys::activeChange(bool)
{
repaint(false);
for (int i = 0; i < 5; button[i++]->reset());
}
Client::MousePosition ModernSys::mousePosition( const QPoint& p) const
{
MousePosition m = Client::mousePosition( p );
if ( show_handle && m == Center ) {
int border = handle_width + 4;
bool hx = (p.x() >= width() - border);
bool hy = (p.y() >= height() - border);
if (hx && hy)
m = BottomRight;
else if (hx)
m = Right;
else if (hy)
m = Bottom;
}
return m;
}
// KWin extended plugin interface
extern "C"
{
Client *allocate(Workspace *ws, WId w, int)
{
return(new ModernSys(ws, w));
}
void init()
{
button_pattern = new QString;
create_pixmaps();
read_config();
config_changed = true;
}
void reset()
{
if (read_config())
config_changed = true;
delete_pixmaps();
create_pixmaps();
}
void deinit()
{
delete_pixmaps();
delete button_pattern;
}
}
#include "modernsys.moc"
// vim:ts=4:sw=4

View File

@ -1,70 +0,0 @@
// $Id$
#ifndef __MODSYSTEMCLIENT_H
#define __MODSYSTEMCLIENT_H
#include <qbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
class QLabel;
class QSpacerItem;
namespace KWinInternal {
// get rid of autohide :P
class ModernButton : public QButton
{
Q_OBJECT
public:
ModernButton(Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL);
void setBitmap(const unsigned char *bitmap);
void reset();
QSize sizeHint() const;
protected:
void mousePressEvent( QMouseEvent* e );
void mouseReleaseEvent( QMouseEvent* e );
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
QBitmap deco;
Client *client;
public:
int last_button;
};
class ModernSys : public KWinInternal::Client
{
Q_OBJECT
public:
ModernSys( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~ModernSys(){;}
protected:
void drawRoundFrame(QPainter &p, int x, int y, int w, int h);
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void showEvent( QShowEvent* );
void windowWrapperShowEvent( QShowEvent* );
void mouseDoubleClickEvent( QMouseEvent * );
void init();
void captionChange( const QString& name );
void stickyChange(bool on);
void maximizeChange(bool m);
void doShape();
void recalcTitleBuffer();
void activeChange(bool);
MousePosition mousePosition( const QPoint& ) const;
protected slots:
void slotReset();
void maxButtonClicked();
private:
enum Buttons{ BtnClose = 0, BtnSticky, BtnMinimize, BtnMaximize, BtnHelp };
ModernButton* button[5];
QSpacerItem* titlebar;
QPixmap titleBuffer;
QString oldTitle;
};
};
#endif

View File

@ -1,3 +0,0 @@
[Desktop Entry]
Name=ModSystem
X-KDE-Library=libkwinmodernsys

View File

@ -1,21 +0,0 @@
INCLUDES = $(all_includes)
kde_module_LTLIBRARIES = libkwinsystem.la
libkwinsystem_la_SOURCES = systemclient.cpp
libkwinsystem_la_LIBADD = ../../kwin.la
libkwinsystem_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN)
METASOURCES = AUTO
noinst_HEADERS = systemclient.h
lnkdir = $(kde_datadir)/kwin/
lnk_DATA = system.desktop
EXTRA_DIST = $(lnk_DATA)
###KMAKE-start (don't edit or delete this block)
###KMAKE-end

View File

@ -1,20 +0,0 @@
[Desktop Entry]
Name=System++
Name[ca]=Sistema++
Name[cs]=Systém++
Name[eo]=Sistemo++
Name[et]=Süsteem++
Name[fi]=Järjestelmä++
Name[fr]=Système++
Name[is]=Kerfi++
Name[ko]=시스템++
Name[lv]=Sistēma++
Name[mk]=Систем++
Name[nl]=Systeem++
Name[oc]=Sistemo++
Name[ro]=Sistem++
Name[sk]=Systém++
Name[sl]=Sistem++
Name[tr]=Sistem++
Name[zh_TW.Big5]=系統++
X-KDE-Library=libkwinsystem

View File

@ -1,555 +0,0 @@
#include "systemclient.h"
#include <qapplication.h>
#include <qcursor.h>
#include <qabstractlayout.h>
#include <qlayout.h>
#include <qtoolbutton.h>
#include <qlabel.h>
#include <qdrawutil.h>
#include <kpixmapeffect.h>
#include <kdrawutil.h>
#include <kapp.h>
#include <qbitmap.h>
#include "../../workspace.h"
#include "../../options.h"
using namespace KWinInternal;
static unsigned char iconify_bits[] = {
0x00, 0x00, 0xff, 0xff, 0x7e, 0x3c, 0x18, 0x00};
static unsigned char maximize_bits[] = {
0x00, 0x18, 0x3c, 0x7e, 0xff, 0xff, 0x00, 0x00};
static unsigned char minmax_bits[] = {
0x0c, 0x18, 0x33, 0x67, 0xcf, 0x9f, 0x3f, 0x3f};
static unsigned char unsticky_bits[] = {
0x00, 0x18, 0x18, 0x7e, 0x7e, 0x18, 0x18, 0x00};
static unsigned char sticky_bits[] = {
0x00, 0x00, 0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00};
static unsigned char question_bits[] = {
0x3c, 0x66, 0x60, 0x30, 0x18, 0x00, 0x18, 0x18};
static KPixmap *aUpperGradient=0;
static KPixmap *iUpperGradient=0;
static KPixmap *btnPix=0;
static KPixmap *btnPixDown=0;
static KPixmap *iBtnPix=0;
static KPixmap *iBtnPixDown=0;
static QColor *btnForeground;
static bool pixmaps_created = false;
static void drawButtonFrame(KPixmap *pix, const QColorGroup &g)
{
QPainter p;
p.begin(pix);
p.setPen(g.mid());
p.drawLine(0, 0, 13, 0);
p.drawLine(0, 0, 0, 13);
p.setPen(g.light());
p.drawLine(13, 0, 13, 13);
p.drawLine(0, 13, 13, 13);
p.setPen(g.dark());
p.drawRect(1, 1, 12, 12);
p.end();
}
static void create_pixmaps()
{
if(pixmaps_created)
return;
pixmaps_created = true;
if(QPixmap::defaultDepth() > 8){
// titlebar
aUpperGradient = new KPixmap;
aUpperGradient->resize(32, 18);
iUpperGradient = new KPixmap;
iUpperGradient->resize(32, 18);
QColor bgColor = kapp->palette().normal().background();
KPixmapEffect::gradient(*aUpperGradient,
options->color(Options::Frame, true).light(130),
bgColor,
KPixmapEffect::VerticalGradient);
KPixmapEffect::gradient(*iUpperGradient,
options->color(Options::Frame, false).light(130),
bgColor,
KPixmapEffect::VerticalGradient);
// buttons
KPixmap aPix;
aPix.resize(12, 12);
KPixmap iPix;
iPix.resize(12, 12);
KPixmap aInternal;
aInternal.resize(8, 8);
KPixmap iInternal;
iInternal.resize(8, 8);
QColor hColor(options->color(Options::ButtonBg, false));
KPixmapEffect::gradient(iInternal,
hColor.dark(120),
hColor.light(120),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(iPix,
hColor.light(150),
hColor.dark(150),
KPixmapEffect::DiagonalGradient);
hColor =options->color(Options::ButtonBg, true);
KPixmapEffect::gradient(aInternal,
hColor.dark(120),
hColor.light(120),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(aPix,
hColor.light(150),
hColor.dark(150),
KPixmapEffect::DiagonalGradient);
bitBlt(&aPix, 1, 1, &aInternal, 0, 0, 8, 8, Qt::CopyROP, true);
bitBlt(&iPix, 1, 1, &iInternal, 0, 0, 8, 8, Qt::CopyROP, true);
// normal buttons
btnPix = new KPixmap;
btnPix->resize(14, 14);
bitBlt(btnPix, 2, 2, &aPix, 0, 0, 10, 10, Qt::CopyROP, true);
drawButtonFrame(btnPix, options->colorGroup(Options::Frame, true));
iBtnPix = new KPixmap;
iBtnPix->resize(14, 14);
bitBlt(iBtnPix, 2, 2, &iPix, 0, 0, 10, 10, Qt::CopyROP, true);
drawButtonFrame(iBtnPix, options->colorGroup(Options::Frame, false));
// pressed buttons
hColor = options->color(Options::ButtonBg, false);
KPixmapEffect::gradient(iInternal,
hColor.light(130),
hColor.dark(130),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(iPix,
hColor.light(150),
hColor.dark(150),
KPixmapEffect::DiagonalGradient);
hColor =options->color(Options::ButtonBg, true);
KPixmapEffect::gradient(aInternal,
hColor.light(130),
hColor.dark(130),
KPixmapEffect::DiagonalGradient);
KPixmapEffect::gradient(aPix,
hColor.light(150),
hColor.dark(150),
KPixmapEffect::DiagonalGradient);
bitBlt(&aPix, 1, 1, &aInternal, 0, 0, 8, 8, Qt::CopyROP, true);
bitBlt(&iPix, 1, 1, &iInternal, 0, 0, 8, 8, Qt::CopyROP, true);
btnPixDown = new KPixmap;
btnPixDown->resize(14, 14);
bitBlt(btnPixDown, 2, 2, &aPix, 0, 0, 10, 10, Qt::CopyROP, true);
drawButtonFrame(btnPixDown, options->colorGroup(Options::Frame,
true));
iBtnPixDown = new KPixmap;
iBtnPixDown->resize(14, 14);
bitBlt(iBtnPixDown, 2, 2, &iPix, 0, 0, 10, 10, Qt::CopyROP, true);
drawButtonFrame(iBtnPixDown, options->colorGroup(Options::Frame,
false));
}
if(qGray(options->color(Options::ButtonBg, true).rgb()) > 128)
btnForeground = new QColor(Qt::black);
else
btnForeground = new QColor(Qt::white);
}
static void delete_pixmaps()
{
if(aUpperGradient){
delete aUpperGradient;
delete iUpperGradient;
delete btnPix;
delete btnPixDown;
delete iBtnPix;
delete iBtnPixDown;
aUpperGradient = 0;
}
delete btnForeground;
pixmaps_created = false;
}
SystemButton::SystemButton(Client *parent, const char *name,
const unsigned char *bitmap)
: QToolButton(parent, name)
{
setBackgroundMode( NoBackground );
resize(14, 14);
connect( this, SIGNAL( clicked() ), this, SLOT( handleClicked() ) );
if(bitmap)
setBitmap(bitmap);
client = parent;
}
QSize SystemButton::sizeHint() const
{
return(QSize(14, 14));
}
void SystemButton::reset()
{
repaint(false);
}
void SystemButton::setBitmap(const unsigned char *bitmap)
{
deco = QBitmap(8, 8, bitmap, true);
deco.setMask(deco);
repaint();
}
void SystemButton::drawButton(QPainter *p)
{
if(btnPixDown){
if(client->isActive())
p->drawPixmap(0, 0, isDown() ? *btnPixDown : *btnPix);
else
p->drawPixmap(0, 0, isDown() ? *iBtnPixDown : *iBtnPix);
}
else{
QColorGroup g = options->colorGroup(Options::Frame,
client->isActive());
int x2 = width()-1;
int y2 = height()-1;
// outer frame
p->setPen(g.mid());
p->drawLine(0, 0, x2, 0);
p->drawLine(0, 0, 0, y2);
p->setPen(g.light());
p->drawLine(x2, 0, x2, y2);
p->drawLine(0, x2, y2, x2);
p->setPen(g.dark());
p->drawRect(1, 1, width()-2, height()-2);
// inner frame
g = options->colorGroup(Options::ButtonBg, client->isActive());
p->fillRect(3, 3, width()-6, height()-6, g.background());
p->setPen(isDown() ? g.mid() : g.light());
p->drawLine(2, 2, x2-2, 2);
p->drawLine(2, 2, 2, y2-2);
p->setPen(isDown() ? g.light() : g.mid());
p->drawLine(x2-2, 2, x2-2, y2-2);
p->drawLine(2, x2-2, y2-2, x2-2);
}
if(!deco.isNull()){
p->setPen(*btnForeground);
p->drawPixmap(isDown() ? 4 : 3, isDown() ? 4 : 3, deco);
}
}
void SystemButton::mousePressEvent( QMouseEvent* e )
{
last_button = e->button();
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QToolButton::mousePressEvent( &me );
}
void SystemButton::mouseReleaseEvent( QMouseEvent* e )
{
QMouseEvent me ( e->type(), e->pos(), e->globalPos(), LeftButton, e->state() );
QToolButton::mouseReleaseEvent( &me );
}
void SystemButton::handleClicked()
{
emit clicked( last_button );
}
void SystemClient::slotReset()
{
titleBuffer.resize(0, 0);
recalcTitleBuffer();
repaint();
button[0]->reset();
button[1]->reset();
button[2]->reset();
button[3]->reset();
if(button[4])
button[4]->reset();
}
void SystemClient::maxButtonClicked( int button )
{
switch ( button ){
case MidButton:
maximize( MaximizeVertical );
break;
case RightButton:
maximize( MaximizeHorizontal );
break;
default: //LeftButton:
maximize( MaximizeFull );
break;
}
}
SystemClient::SystemClient( Workspace *ws, WId w, QWidget *parent,
const char *name )
: Client( ws, w, parent, name, WResizeNoErase )
{
connect(options, SIGNAL(resetClients()), this, SLOT(slotReset()));
bool help = providesContextHelp();
QGridLayout* g = new QGridLayout(this, 0, 0, 2);
g->setRowStretch(1, 10);
g->addWidget(windowWrapper(), 1, 1 );
g->addItem( new QSpacerItem( 0, 0, QSizePolicy::Fixed, QSizePolicy::Expanding ) );
g->addColSpacing(0, 2);
g->addColSpacing(2, 2);
g->addRowSpacing(2, 6);
button[0] = new SystemButton(this, "close"/*, close_bits*/);
button[1] = new SystemButton(this, "sticky");
if(isSticky())
button[1]->setBitmap(unsticky_bits);
else
button[1]->setBitmap(sticky_bits);
button[2] = new SystemButton(this, "iconify", iconify_bits);
button[3] = new SystemButton(this, "maximize", maximize_bits);
if(help){
button[4] = new SystemButton(this, "help", question_bits);
connect( button[4], SIGNAL( clicked() ), this, ( SLOT( contextHelp() ) ) );
}
else
button[4] = NULL;
connect( button[0], SIGNAL( clicked() ), this, ( SLOT( closeWindow() ) ) );
connect( button[1], SIGNAL( clicked() ), this, ( SLOT( toggleSticky() ) ) );
connect( button[2], SIGNAL( clicked() ), this, ( SLOT( iconify() ) ) );
connect( button[3], SIGNAL( clicked(int) ), this, ( SLOT( maxButtonClicked(int) ) ) );
QHBoxLayout* hb = new QHBoxLayout(0);
hb->setResizeMode(QLayout::FreeResize);
g->addLayout( hb, 0, 1 );
hb->addSpacing(3);
hb->addWidget( button[0]);
titlebar = new QSpacerItem(10, 14, QSizePolicy::Expanding,
QSizePolicy::Minimum);
hb->addSpacing(3);
hb->addItem(titlebar);
hb->addSpacing(3);
if(help){
hb->addWidget( button[4]);
hb->addSpacing(1);
}
hb->addWidget( button[1]);
hb->addSpacing(1);
hb->addWidget( button[2]);
hb->addSpacing(1);
hb->addWidget( button[3]);
hb->addSpacing(3);
setBackgroundMode(NoBackground);
recalcTitleBuffer();
}
void SystemClient::resizeEvent( QResizeEvent* )
{
//Client::resizeEvent( e );
recalcTitleBuffer();
doShape();
/*
if ( isVisibleToTLW() && !testWFlags( WNorthWestGravity )) {
QPainter p( this );
QRect t = titlebar->geometry();
t.setTop( 0 );
QRegion r = rect();
r = r.subtract( t );
p.setClipRegion( r );
p.eraseRect( rect() );
}*/
}
void SystemClient::recalcTitleBuffer()
{
if(oldTitle == caption() && width() == titleBuffer.width())
return;
QFontMetrics fm(options->font(true));
titleBuffer.resize(width(), 18);
QPainter p;
p.begin(&titleBuffer);
if(aUpperGradient)
p.drawTiledPixmap(0, 0, width(), 18, *aUpperGradient);
else
p.fillRect(0, 0, width(), 18,
options->colorGroup(Options::Frame, true).
brush(QColorGroup::Button));
QRect t = titlebar->geometry();
t.setTop( 2 );
t.setLeft( t.left() + 4 );
t.setRight( t.right() - 2 );
QRegion r(t.x(), 0, t.width(), 18);
r -= QRect(t.x()+((t.width()-fm.width(caption()))/2)-4,
0, fm.width(caption())+8, 18);
p.setClipRegion(r);
int i, ly;
for(i=0, ly=4; i < 4; ++i, ly+=3){
p.setPen(options->color(Options::TitleBar, true).light(150));
p.drawLine(0, ly, width()-1, ly);
p.setPen(options->color(Options::TitleBar, true).dark(120));
p.drawLine(0, ly+1, width()-1, ly+1);
}
p.setClipRect(t);
p.setPen(options->color(Options::Font, true));
p.setFont(options->font(true));
p.drawText(t.x()+((t.width()-fm.width(caption()))/2)-4,
0, fm.width(caption())+8, 18, AlignCenter, caption());
p.setClipping(false);
p.end();
oldTitle = caption();
}
void SystemClient::captionChange( const QString &)
{
recalcTitleBuffer();
repaint( titlebar->geometry(), false );
}
void SystemClient::drawRoundFrame(QPainter &p, int x, int y, int w, int h)
{
kDrawRoundButton(&p, x, y, w, h,
options->colorGroup(Options::Frame, isActive()), false);
}
void SystemClient::paintEvent( QPaintEvent* )
{
QPainter p( this );
QRect t = titlebar->geometry();
QBrush fillBrush(colorGroup().brush(QColorGroup::Background).pixmap() ?
colorGroup().brush(QColorGroup::Background) :
options->colorGroup(Options::Frame, isActive()).
brush(QColorGroup::Button));
p.fillRect(1, 18, width()-2, height()-19, fillBrush);
t.setTop( 2 );
t.setLeft( t.left() + 4 );
t.setRight( t.right() - 2 );
if(isActive())
p.drawPixmap(0, 0, titleBuffer);
else{
if(iUpperGradient)
p.drawTiledPixmap(0, 0, width(), 18, *iUpperGradient);
else
p.fillRect(0, 0, width(), 18, fillBrush);
p.setPen(options->color(Options::Font, isActive()));
p.setFont(options->font(isActive()));
p.drawText(t, AlignCenter, caption() );
}
p.setPen(options->colorGroup(Options::Frame, isActive()).light());
p.drawLine(width()-20, height()-7, width()-10, height()-7);
p.drawLine(width()-20, height()-5, width()-10, height()-5);
p.setPen(options->colorGroup(Options::Frame, isActive()).dark());
p.drawLine(width()-20, height()-6, width()-10, height()-6);
p.drawLine(width()-20, height()-4, width()-10, height()-4);
drawRoundFrame(p, 0, 0, width(), height());
}
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
void SystemClient::doShape()
{
// using a bunch of QRect lines seems much more efficent than bitmaps or
// point arrays
QRegion mask;
kRoundMaskRegion(mask, 0, 0, width(), height());
setMask(mask);
}
void SystemClient::showEvent(QShowEvent *ev)
{
Client::showEvent(ev);
doShape();
repaint();
}
void SystemClient::windowWrapperShowEvent( QShowEvent* )
{
doShape();
}
void SystemClient::mouseDoubleClickEvent( QMouseEvent * e )
{
if (titlebar->geometry().contains( e->pos() ) )
workspace()->performWindowOperation( this, options->operationTitlebarDblClick() );
workspace()->requestFocus( this );
}
void SystemClient::stickyChange(bool on)
{
button[1]->setBitmap(on ? unsticky_bits : sticky_bits);
}
void SystemClient::maximizeChange(bool m)
{
button[3]->setBitmap(m ? minmax_bits : maximize_bits);
}
void SystemClient::init()
{
//
}
void SystemClient::activeChange(bool)
{
repaint(false);
button[0]->reset();
button[1]->reset();
button[2]->reset();
button[3]->reset();
if(button[4])
button[4]->reset();
}
extern "C"
{
Client *allocate(Workspace *ws, WId w, int)
{
return(new SystemClient(ws, w));
}
void init()
{
create_pixmaps();
}
void reset()
{
delete_pixmaps();
create_pixmaps();
}
void deinit()
{
delete_pixmaps();
}
}
#include "systemclient.moc"

View File

@ -1,79 +0,0 @@
#ifndef __SYSTEMCLIENT_H
#define __SYSTEMCLIENT_H
#include <qbutton.h>
#include <qtoolbutton.h>
#include <qbitmap.h>
#include <kpixmap.h>
#include "../../client.h"
class QLabel;
class QSpacerItem;
namespace KWinInternal {
class SystemButton : public QToolButton
{
Q_OBJECT
public:
SystemButton(Client *parent=0, const char *name=0,
const unsigned char *bitmap=NULL);
void setBitmap(const unsigned char *bitmap);
void reset();
QSize sizeHint() const;
signals:
void clicked( int );
protected:
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
QBitmap deco;
Client *client;
void mousePressEvent( QMouseEvent* e );
void mouseReleaseEvent( QMouseEvent* e );
private slots:
void handleClicked();
private:
int last_button;
};
class SystemClient : public KWinInternal::Client
{
Q_OBJECT
public:
SystemClient( Workspace *ws, WId w, QWidget *parent=0, const char *name=0 );
~SystemClient(){;}
protected:
void drawRoundFrame(QPainter &p, int x, int y, int w, int h);
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void showEvent( QShowEvent* );
void windowWrapperShowEvent( QShowEvent* );
void mouseDoubleClickEvent( QMouseEvent * );
void init();
void captionChange( const QString& name );
void stickyChange(bool on);
void maximizeChange(bool m);
void doShape();
void recalcTitleBuffer();
void activeChange(bool);
protected slots:
void slotReset();
private slots:
void maxButtonClicked( int );
private:
SystemButton* button[5];
QSpacerItem* titlebar;
QPixmap titleBuffer;
QString oldTitle;
};
};
#endif