readded modernsystem style as that is needed by kpersonalizer. Gallium

takes over maintenance and there are several additions and changes from
Melchior Franz anyway

svn path=/trunk/kdebase/kwin/; revision=103041
icc-effect-5.14.5
Ralf Nolden 2001-06-19 15:26:48 +00:00
parent ab5b07786a
commit 5781bbadac
9 changed files with 1004 additions and 0 deletions

View File

@ -0,0 +1,20 @@
# $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

@ -0,0 +1,93 @@
/* 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

@ -0,0 +1,42 @@
/* 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

@ -0,0 +1,15 @@
# $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

@ -0,0 +1,77 @@
// $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

@ -0,0 +1,38 @@
// $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

@ -0,0 +1,646 @@
// $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

@ -0,0 +1,70 @@
// $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

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