revert. sorry

svn path=/trunk/KDE/kdebase/workspace/; revision=1154460
icc-effect-5.14.5
Markus Meik Slopianka 2010-07-25 14:19:05 +00:00
parent 8933e3bd32
commit 6374f08355
89 changed files with 10416 additions and 0 deletions

View File

@ -0,0 +1,16 @@
add_subdirectory( config )
########### next target ###############
set(kwin3_kde2_PART_SRCS kde2.cpp)
kde4_add_plugin(kwin3_kde2 ${kwin3_kde2_PART_SRCS})
target_link_libraries(kwin3_kde2 kdecorations ${QT_QTGUI_LIBRARY})
install(TARGETS kwin3_kde2 DESTINATION ${PLUGIN_INSTALL_DIR})
install( FILES kde2.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/ )

View File

@ -0,0 +1,16 @@
########### next target ###############
set(kwin_kde2_config_PART_SRCS config.cpp )
kde4_add_plugin(kwin_kde2_config ${kwin_kde2_config_PART_SRCS})
target_link_libraries(kwin_kde2_config ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY})
install(TARGETS kwin_kde2_config DESTINATION ${PLUGIN_INSTALL_DIR} )

View File

@ -0,0 +1,150 @@
/*********************************************************************
KDE2 Default configuration widget
Copyright (c) 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "config.h"
#include <QWhatsThis>
#include <QPixmap>
#include <kglobal.h>
#include <kdialog.h>
#include <klocale.h>
#include <kvbox.h>
extern "C"
{
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
{
return(new KDE2Config(conf, parent));
}
}
// NOTE:
// '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
KDE2Config::KDE2Config( KConfig* conf, QWidget* parent )
: QObject( parent )
{
Q_UNUSED( conf );
KGlobal::locale()->insertCatalog("kwin_clients");
c = new KConfig("kwinKDE2rc");
highcolor = QPixmap::defaultDepth() > 8;
gb = new KVBox( parent );
gb->setSpacing( KDialog::spacingHint() );
cbShowStipple = new QCheckBox( i18n("Draw titlebar &stipple effect"), gb );
cbShowStipple->setWhatsThis(
i18n("When selected, active titlebars are drawn "
"with a stipple (dotted) effect; otherwise, they are "
"drawn without the stipple."));
cbShowGrabBar = new QCheckBox( i18n("Draw g&rab bar below windows"), gb );
cbShowGrabBar->setWhatsThis(
i18n("When selected, decorations are drawn with a \"grab bar\" "
"below windows; otherwise, no grab bar is drawn."));
// Only show the gradient checkbox for highcolor displays
if (highcolor)
{
cbUseGradients = new QCheckBox( i18n("Draw &gradients"), gb );
cbUseGradients->setWhatsThis(
i18n("When selected, decorations are drawn with gradients "
"for high-color displays; otherwise, no gradients are drawn.") );
}
// Ensure we track user changes properly
connect( cbShowStipple, SIGNAL(clicked()),
this, SLOT(slotSelectionChanged()) );
connect( cbShowGrabBar, SIGNAL(clicked()),
this, SLOT(slotSelectionChanged()) );
if (highcolor)
connect( cbUseGradients, SIGNAL(clicked()),
this, SLOT(slotSelectionChanged()) );
// Load configuration options
load( KConfigGroup() );
// Make the widgets visible in kwindecoration
gb->show();
}
KDE2Config::~KDE2Config()
{
delete gb;
delete c;
}
void KDE2Config::slotSelectionChanged()
{
emit changed();
}
// Loads the configurable options from the kwinrc config file
// It is passed the open config from kwindecoration to improve efficiency
void KDE2Config::load( const KConfigGroup& )
{
KConfigGroup cg(c, "General");
bool override = cg.readEntry( "ShowTitleBarStipple", true);
cbShowStipple->setChecked( override );
override = cg.readEntry( "ShowGrabBar", true);
cbShowGrabBar->setChecked( override );
if (highcolor) {
override = cg.readEntry( "UseGradients", true);
cbUseGradients->setChecked( override );
}
}
// Saves the configurable options to the kwinrc config file
void KDE2Config::save( KConfigGroup& )
{
KConfigGroup cg(c, "General");
cg.writeEntry( "ShowTitleBarStipple", cbShowStipple->isChecked() );
cg.writeEntry( "ShowGrabBar", cbShowGrabBar->isChecked() );
if (highcolor)
cg.writeEntry( "UseGradients", cbUseGradients->isChecked() );
// No need to conf->sync() - kwindecoration will do it for us
}
// Sets UI widget defaults which must correspond to style defaults
void KDE2Config::defaults()
{
cbShowStipple->setChecked( true );
cbShowGrabBar->setChecked( true );
if (highcolor)
cbUseGradients->setChecked( true );
}
#include "config.moc"
// vim: ts=4
// kate: space-indent off; tab-width 4;

View File

@ -0,0 +1,64 @@
/*********************************************************************
KDE2 Default configuration widget
Copyright (c) 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KDE2_CONFIG_H
#define KDE2_CONFIG_H
#include <QCheckBox>
#include <QGroupBox>
#include <QLabel>
#include <kvbox.h>
#include <kconfig.h>
class KDE2Config: public QObject
{
Q_OBJECT
public:
KDE2Config( KConfig* conf, QWidget* parent );
~KDE2Config();
// These public signals/slots work similar to KCM modules
signals:
void changed();
public slots:
void load( const KConfigGroup& conf );
void save( KConfigGroup& conf );
void defaults();
protected slots:
void slotSelectionChanged(); // Internal use
private:
QCheckBox* cbShowStipple;
QCheckBox* cbShowGrabBar;
QCheckBox* cbUseGradients;
KVBox* gb;
KConfig *c;
bool highcolor;
};
#endif
// vim: ts=4
// kate: space-indent off; tab-width 4;

1093
clients/kde2/kde2.cpp Normal file

File diff suppressed because it is too large Load Diff

91
clients/kde2/kde2.desktop Normal file
View File

@ -0,0 +1,91 @@
[Desktop Entry]
Name=KDE 2
Name[af]=KDE 2
Name[ar]=كدي 2
Name[as]=KDE 2
Name[be]=KDE 2
Name[be@latin]=KDE 2
Name[bg]=KDE 2
Name[bn]=কে.ডি.ই. ২
Name[bn_IN]=KDE 2
Name[br]=KDE 2
Name[ca]=KDE 2
Name[ca@valencia]=KDE 2
Name[cs]=KDE 2
Name[csb]=KDE 2
Name[cy]=KDE 2
Name[da]=KDE 2
Name[de]=KDE 2
Name[el]=KDE 2
Name[en_GB]=KDE 2
Name[eo]=KDE 2
Name[es]=KDE 2
Name[et]=KDE 2
Name[eu]=KDE 2
Name[fa]=KDE ۲
Name[fi]=KDE 2
Name[fr]=KDE 2
Name[fy]=KDE 2
Name[ga]=KDE 2
Name[gl]=KDE 2
Name[gu]=KDE ૨
Name[he]=KDE 2
Name[hi]=केडीई 2
Name[hne]=केडीई 2
Name[hr]=KDE 2
Name[hsb]=KDE 2
Name[hu]=KDE 2
Name[ia]=KDE 2
Name[id]=KDE 2
Name[is]=KDE 2
Name[it]=KDE 2
Name[ja]=KDE 2
Name[ka]=KDE 2
Name[kk]=KDE 2
Name[km]=KDE 2
Name[kn]=ಕೆಡಿಇ ೨
Name[ko]=KDE 2
Name[ku]=KDE 2
Name[lt]=KDE 2
Name[lv]=KDE 2
Name[mai]=केडीई 2
Name[mk]=KDE 2
Name[ml]=കെഡിഇ 2
Name[mr]=KDE 2
Name[ms]=KDE 2
Name[nb]=KDE 2
Name[nds]=KDE 2
Name[ne]=केडीई २
Name[nl]=KDE 2
Name[nn]=KDE 2
Name[oc]=KDE 2
Name[pa]=KDE 2
Name[pl]=KDE 2
Name[pt]=KDE 2
Name[pt_BR]=KDE 2
Name[ro]=KDE 2
Name[ru]=KDE 2
Name[se]=KDE 2
Name[si]=KDE 2
Name[sk]=KDE 2
Name[sl]=KDE 2
Name[sr]=КДЕ2
Name[sr@ijekavian]=КДЕ2
Name[sr@ijekavianlatin]=KDE2
Name[sr@latin]=KDE2
Name[sv]=KDE 2
Name[ta]=KDE 2
Name[te]=కెడిఈ 2
Name[tg]=KDE 2
Name[th]=รูปแบบ KDE 2
Name[tr]=KDE 2
Name[uk]=KDE 2
Name[uz]=KDE 2
Name[uz@cyrillic]=KDE 2
Name[vi]=KDE 2
Name[wa]=KDE 2
Name[xh]=KDE 2
Name[x-test]=xxKDE 2xx
Name[zh_CN]=KDE 2
Name[zh_TW]=KDE 2
X-KDE-Library=kwin3_kde2

110
clients/kde2/kde2.h Normal file
View File

@ -0,0 +1,110 @@
/*********************************************************************
KDE2 Default KWin client
Copyright (C) 1999, 2001 Daniel Duley <mosfet@kde.org>
Matthias Ettrich <ettrich@kde.org>
Karol Szwed <gallium@kde.org>
Draws mini titlebars for tool windows.
Many features are now customizable.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KDE2_H
#define KDE2_H
#include <QDateTime>
#include <kcommondecoration.h>
#include <kdecorationfactory.h>
class QPixmap;
class QPainterPath;
namespace KDE2 {
class KDE2Client;
class KDE2Handler: public KDecorationFactory
{
public:
KDE2Handler();
~KDE2Handler();
KDecoration* createDecoration( KDecorationBridge* b );
bool reset( unsigned long changed );
virtual QList< BorderSize > borderSizes() const;
virtual bool supports( Ability ability ) const;
private:
unsigned long readConfig( bool update );
void createPixmaps();
void freePixmaps();
void drawButtonBackground(QPixmap *pix,
const QPalette &g, bool sunken);
};
class KDE2Button : public KCommonDecorationButton
{
public:
KDE2Button(ButtonType type, KDE2Client *parent, const char *name);
~KDE2Button();
void reset(unsigned long changed);
void setBitmap(const unsigned char *bitmap);
protected:
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void paintEvent(QPaintEvent *);
void drawButton(QPainter *p);
void drawButtonLabel(QPainter*) {;}
QPainterPath* deco;
bool large;
bool isMouseOver;
};
class KDE2Client : public KCommonDecoration
{
public:
KDE2Client( KDecorationBridge* b, KDecorationFactory* f );
~KDE2Client() {;}
virtual QString visibleName() const;
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
virtual KCommonDecorationButton *createButton(ButtonType type);
virtual QRegion cornerShape(WindowCorner corner);
void init();
void reset( unsigned long changed );
protected:
void paintEvent( QPaintEvent* );
private:
bool mustDrawHandle() const;
int titleHeight;
};
}
#endif
// vim: ts=4
// kate: space-indent off; tab-width 4;

View File

@ -0,0 +1,15 @@
add_subdirectory( config )
set(kwin3_keramik_PART_SRCS keramik.cpp )
qt4_add_resources(kwin3_keramik_PART_SRCS tiles.qrc )
kde4_add_plugin(kwin3_keramik ${kwin3_keramik_PART_SRCS})
target_link_libraries(kwin3_keramik ${KDE4_KDEUI_LIBS} kdecorations)
install(TARGETS kwin3_keramik DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES keramik.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin )

View File

@ -0,0 +1,18 @@
include_directories( ${KDEBASE_WORKSPACE_SOURCE_DIR}/kwin/lib )
########### next target ###############
set(kwin_keramik_config_PART_SRCS config.cpp )
kde4_add_ui_files(kwin_keramik_config_PART_SRCS keramikconfig.ui )
kde4_add_plugin(kwin_keramik_config ${kwin_keramik_config_PART_SRCS})
target_link_libraries(kwin_keramik_config ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY})
install(TARGETS kwin_keramik_config DESTINATION ${PLUGIN_INSTALL_DIR} )

View File

@ -0,0 +1,112 @@
/*
*
* Keramik KWin client configuration module
*
* Copyright (C) 2002 Fredrik Höglund <fredrik@kde.org>
*
* Based on the Quartz configuration module,
* Copyright (c) 2001 Karol Szwed <gallium@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#include "config.h"
#include <kglobal.h>
#include <klocale.h>
#include <QCheckBox>
#include "config.moc"
extern "C"
{
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
{
return ( new KeramikConfig( conf, parent ) );
}
}
/* NOTE:
* '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
*/
KeramikConfig::KeramikConfig( KConfig* conf, QWidget* parent )
: QObject( parent )
{
Q_UNUSED( conf );
KGlobal::locale()->insertCatalog("kwin_clients");
c = new KConfig( "kwinkeramikrc" );
KConfigGroup cg(c, "General");
ui = new KeramikConfigUI( parent );
connect( ui->showAppIcons, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->smallCaptions, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->largeGrabBars, SIGNAL(clicked()), SIGNAL(changed()) );
connect( ui->useShadowedText, SIGNAL(clicked()), SIGNAL(changed()) );
load( cg );
ui->show();
}
KeramikConfig::~KeramikConfig()
{
delete ui;
delete c;
}
// Loads the configurable options from the kwinrc config file
// It is passed the open config from kwindecoration to improve efficiency
void KeramikConfig::load( const KConfigGroup& )
{
KConfigGroup cg(c, "General");
ui->showAppIcons->setChecked( cg.readEntry("ShowAppIcons", true) );
ui->smallCaptions->setChecked( cg.readEntry("SmallCaptionBubbles", false) );
ui->largeGrabBars->setChecked( cg.readEntry("LargeGrabBars", true) );
ui->useShadowedText->setChecked( cg.readEntry("UseShadowedText", true) );
}
// Saves the configurable options to the kwinrc config file
void KeramikConfig::save( KConfigGroup& )
{
KConfigGroup cg(c, "General");
cg.writeEntry( "ShowAppIcons", ui->showAppIcons->isChecked() );
cg.writeEntry( "SmallCaptionBubbles", ui->smallCaptions->isChecked() );
cg.writeEntry( "LargeGrabBars", ui->largeGrabBars->isChecked() );
cg.writeEntry( "UseShadowedText", ui->useShadowedText->isChecked() );
c->sync();
}
// Sets UI widget defaults which must correspond to style defaults
void KeramikConfig::defaults()
{
ui->showAppIcons->setChecked( true );
ui->smallCaptions->setChecked( false );
ui->largeGrabBars->setChecked( true );
ui->useShadowedText->setChecked( true );
emit changed();
}
// vim: set noet ts=4 sw=4:

View File

@ -0,0 +1,67 @@
/*
* Keramik KWin client configuration module
*
* Copyright (C) 2002 Fredrik Höglund <fredrik@kde.org>
*
* Based on the Quartz configuration module,
* Copyright (c) 2001 Karol Szwed <gallium@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __KWIN_KERAMIK_CONFIG_H
#define __KWIN_KERAMIK_CONFIG_H
#include <kconfig.h>
#include "ui_keramikconfig.h"
class KeramikConfigUI : public QWidget, public Ui::KeramikConfigUI
{
public:
KeramikConfigUI( QWidget *parent ) : QWidget( parent ) {
setupUi( this );
}
};
class KeramikConfig: public QObject
{
Q_OBJECT
public:
KeramikConfig( KConfig* conf, QWidget* parent );
~KeramikConfig();
// These public signals/slots work similar to KCM modules
signals:
void changed();
public slots:
void load( const KConfigGroup& conf );
void save( KConfigGroup& conf );
void defaults();
private:
KeramikConfigUI *ui;
KConfig *c;
};
#endif
// vim: set noet ts=4 sw=4:

View File

@ -0,0 +1,61 @@
<ui version="4.0" stdsetdef="1" >
<class>KeramikConfigUI</class>
<widget class="QWidget" name="KeramikConfigUI" >
<property name="geometry" >
<rect>
<x>0</x>
<y>0</y>
<width>287</width>
<height>102</height>
</rect>
</property>
<property name="windowTitle" >
<string>Keramik</string>
</property>
<layout class="QVBoxLayout" >
<property name="margin" >
<cstring>0</cstring>
</property>
<item>
<widget class="QCheckBox" name="showAppIcons" >
<property name="text" >
<string>Display the window &amp;icon in the caption bubble</string>
</property>
<property name="whatsThis" stdset="0" >
<string>Check this option if you want the window icon to be displayed in the caption bubble next to the titlebar text.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="smallCaptions" >
<property name="text" >
<string>Draw &amp;small caption bubbles on active windows</string>
</property>
<property name="whatsThis" stdset="0" >
<string>Check this option if you want the caption bubble to have the same size on active windows that it has on inactive ones. This option is useful for laptops or low resolution displays where you want maximize the amount of space available to the window contents.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="largeGrabBars" >
<property name="text" >
<string>Draw g&amp;rab bars below windows</string>
</property>
<property name="whatsThis" stdset="0" >
<string>Check this option if you want a grab bar to be drawn below windows. When this option is not selected only a thin border will be drawn in its place.</string>
</property>
</widget>
</item>
<item>
<widget class="QCheckBox" name="useShadowedText" >
<property name="text" >
<string>Use shadowed &amp;text</string>
</property>
<property name="whatsThis" stdset="0" >
<string>Check this option if you want the titlebar text to have a 3D look with a shadow behind it.</string>
</property>
</widget>
</item>
</layout>
</widget>
</ui>

1818
clients/keramik/keramik.cpp Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,91 @@
[Desktop Entry]
Name=Keramik
Name[af]=Keramik
Name[ar]=كيراميك
Name[be]=Keramik
Name[be@latin]=Keramik
Name[bg]=Keramik
Name[bn]=কেরামিক
Name[bn_IN]=Keramik
Name[br]=Keramik
Name[ca]=Keramik
Name[ca@valencia]=Keramik
Name[cs]=Keramika
Name[csb]=Keramik
Name[cy]=Keramik
Name[da]=Keramik
Name[de]=Keramik
Name[el]=Keramik
Name[en_GB]=Keramik
Name[eo]=Keramik
Name[es]=Keramik
Name[et]=Keramik
Name[eu]=Keramik
Name[fa]=کرامیک
Name[fi]=Keramik
Name[fr]=Keramik
Name[fy]=Keramyk
Name[ga]=Keramik
Name[gl]=Keramik
Name[gu]=કેરામિક
Name[he]=Keramik
Name[hi]=केरामिक
Name[hne]=केरामिक
Name[hr]=Keramik
Name[hsb]=Keramik
Name[hu]=Keramik
Name[ia]=Keramik
Name[id]=Keramik
Name[is]=Keramík
Name[it]=Ceramica
Name[ja]=Keramik
Name[ka]=Keramik
Name[kk]=Керамика
Name[km]=Keramik
Name[kn]=ಕೆರಾಮಿಕ್
Name[ko]=Keramik
Name[ku]=Keramik
Name[lt]=Keramik
Name[lv]=Keramik
Name[mai]=केरामिक
Name[mk]=Керамик
Name[ml]=കെരാമിക്
Name[mr]=केरामिक
Name[ms]=Keramik
Name[nb]=Keramik
Name[nds]=Keramik
Name[ne]=केरामिक
Name[nl]=Keramik
Name[nn]=Keramikk
Name[oc]=Keramik
Name[or]=Keramik
Name[pa]=ਕੀਰਾਮਿਕ
Name[pl]=Keramik
Name[pt]=Keramik
Name[pt_BR]=Keramik
Name[ro]=Keramik
Name[ru]=Керамика
Name[se]=Bálseduodji
Name[si]=Keramik
Name[sk]=Keramik
Name[sl]=Keramik
Name[sr]=Керамика
Name[sr@ijekavian]=Керамика
Name[sr@ijekavianlatin]=Keramika
Name[sr@latin]=Keramika
Name[sv]=Keramik
Name[ta]=கெராமிக்
Name[te]=కెరామిక్
Name[tg]=Keramik
Name[th]=รูปแบบเครามิก
Name[tr]=Keramik
Name[uk]=Керамік
Name[uz]=Keramika
Name[uz@cyrillic]=Керамика
Name[vi]=Gốm
Name[wa]=Keramik
Name[xh]=Keramik
Name[x-test]=xxKeramikxx
Name[zh_CN]=Keramik
Name[zh_TW]=Keramik
X-KDE-Library=kwin3_keramik

198
clients/keramik/keramik.h Normal file
View File

@ -0,0 +1,198 @@
/*
*
* Keramik KWin client (version 0.8)
*
* Copyright (C) 2002 Fredrik Höglund <fredrik@kde.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the license, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; see the file COPYING. If not, write to
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
* Boston, MA 02110-1301, USA.
*/
#ifndef __KERAMIK_H
#define __KERAMIK_H
#include <QAbstractButton>
#include <kdecoration.h>
#include <kdecorationfactory.h>
class QSpacerItem;
class QBoxLayout;
namespace Keramik {
enum TilePixmap { TitleLeft=0, TitleCenter, TitleRight,
CaptionSmallLeft, CaptionSmallCenter, CaptionSmallRight,
CaptionLargeLeft, CaptionLargeCenter, CaptionLargeRight,
GrabBarLeft, GrabBarCenter, GrabBarRight,
BorderLeft, BorderRight, NumTiles };
enum Button { MenuButton=0, OnAllDesktopsButton, HelpButton, MinButton,
MaxButton, CloseButton, AboveButton, BelowButton, ShadeButton,
NumButtons };
enum ButtonDeco { Menu=0, OnAllDesktops, NotOnAllDesktops, Help, Minimize, Maximize,
Restore, Close, AboveOn, AboveOff, BelowOn, BelowOff, ShadeOn, ShadeOff,
NumButtonDecos };
struct SettingsCache
{
bool largeGrabBars:1;
bool smallCaptionBubbles:1;
};
class KeramikHandler : public KDecorationFactory
{
public:
KeramikHandler();
~KeramikHandler();
virtual QList< BorderSize > borderSizes() const;
virtual bool reset( unsigned long changed );
virtual KDecoration* createDecoration( KDecorationBridge* );
virtual bool supports( Ability ability ) const;
bool showAppIcons() const { return showIcons; }
bool useShadowedText() const { return shadowedText; }
bool largeCaptionBubbles() const { return !smallCaptionBubbles; }
int titleBarHeight( bool large ) const {
return ( large ? activeTiles[CaptionLargeCenter]->height()
: activeTiles[CaptionSmallCenter]->height() );
}
int grabBarHeight() const
{ return activeTiles[GrabBarCenter]->height(); }
const QPixmap *roundButton() const { return titleButtonRound; }
const QPixmap *squareButton() const { return titleButtonSquare; }
const QBitmap *buttonDeco( ButtonDeco deco ) const
{ return buttonDecos[ deco ]; }
inline const QPixmap *tile( TilePixmap tilePix, bool active ) const;
private:
void readConfig();
void createPixmaps();
void destroyPixmaps();
void addWidth (int width, QPixmap *&pix, bool left, QPixmap *bottomPix);
void addHeight (int height, QPixmap *&pix);
void flip( QPixmap *&, QPixmap *& );
void pretile( QPixmap *&, int, Qt::Orientation );
QPixmap *composite( QImage *, QImage * );
QImage *loadImage( const QString &, const QColor & );
QPixmap *loadPixmap( const QString &, const QColor & );
bool showIcons:1, shadowedText:1,
smallCaptionBubbles:1, largeGrabBars:1;
SettingsCache *settings_cache;
QPixmap *activeTiles[ NumTiles ];
QPixmap *inactiveTiles[ NumTiles ];
QBitmap *buttonDecos[ NumButtonDecos ];
QPixmap *titleButtonRound, *titleButtonSquare;
}; // class KeramikHandler
class KeramikClient;
class KeramikButton : public QAbstractButton
{
public:
KeramikButton( KeramikClient *, Button, const QString &, const int realizeBtns = Qt::LeftButton );
~KeramikButton();
Qt::MouseButtons lastButton() const { return lastbutton; }
private:
void enterEvent( QEvent * );
void leaveEvent( QEvent * );
void mousePressEvent( QMouseEvent * );
void mouseReleaseEvent( QMouseEvent * );
void paintEvent( QPaintEvent * );
private:
KeramikClient *client;
Button button;
bool hover;
Qt::MouseButtons lastbutton;
int realizeButtons;
}; // class KeramikButton
class KeramikClient : public KDecoration
{
Q_OBJECT
public:
KeramikClient( KDecorationBridge* bridge, KDecorationFactory* factory );
~KeramikClient();
virtual void init();
virtual void reset( unsigned long changed );
virtual Position mousePosition( const QPoint& p ) const;
virtual void borders( int& left, int& right, int& top, int& bottom ) const;
virtual void resize( const QSize& s );
virtual QSize minimumSize() const;
virtual bool eventFilter( QObject* o, QEvent* e );
virtual void activeChange();
virtual void captionChange();
virtual void maximizeChange();
virtual void desktopChange();
virtual void shadeChange();
private:
void createLayout();
void addButtons( QBoxLayout*, const QString & );
void updateMask(); // FRAME
void updateCaptionBuffer();
void iconChange();
void resizeEvent( QResizeEvent *); // FRAME
void paintEvent( QPaintEvent *); // FRAME
void mouseDoubleClickEvent( QMouseEvent * ); // FRAME
int width() const { return widget()->width(); }
int height() const { return widget()->height(); }
void calculateCaptionRect();
inline bool maximizedVertical() const {
return ( maximizeMode() & MaximizeVertical );
}
private slots:
void menuButtonPressed();
void slotMaximize();
void slotAbove();
void slotBelow();
void slotShade();
void keepAboveChange( bool );
void keepBelowChange( bool );
private:
QSpacerItem *topSpacer, *titlebar;
KeramikButton *button[ NumButtons ];
QRect captionRect;
QPixmap captionBuffer;
QPixmap *activeIcon, *inactiveIcon;
bool captionBufferDirty:1, maskDirty:1;
bool largeCaption:1, largeTitlebar:1;
}; // class KeramikClient
} // namespace Keramik
#endif // ___KERAMIK_H
// vim: set noet ts=4 sw=4:

Binary file not shown.

After

Width:  |  Height:  |  Size: 126 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 127 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 135 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 171 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 379 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 489 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 173 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 415 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 486 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 166 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 164 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

27
clients/keramik/tiles.qrc Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE RCC><RCC version="1.0">
<qresource>
<file>pics/border-left.png</file>
<file>pics/border-right.png</file>
<file>pics/bottom-center.png</file>
<file>pics/bottom-left.png</file>
<file>pics/bottom-right.png</file>
<file>pics/caption-large-center.png</file>
<file>pics/caption-large-left.png</file>
<file>pics/caption-large-right.png</file>
<file>pics/caption-small-center.png</file>
<file>pics/caption-small-left.png</file>
<file>pics/caption-small-right.png</file>
<file>pics/grabbar-center.png</file>
<file>pics/grabbar-left.png</file>
<file>pics/grabbar-right.png</file>
<file>pics/titlebar-center.png</file>
<file>pics/titlebar-left.png</file>
<file>pics/titlebar-right.png</file>
<file>pics/titlebutton-round-huge.png</file>
<file>pics/titlebutton-round-large.png</file>
<file>pics/titlebutton-round.png</file>
<file>pics/titlebutton-square-huge.png</file>
<file>pics/titlebutton-square-large.png</file>
<file>pics/titlebutton-square.png</file>
</qresource>
</RCC>

View File

@ -0,0 +1,25 @@
add_subdirectory( cli_installer )
add_subdirectory( pics )
########### next target ###############
set(kwin3_kwmtheme_PART_SRCS kwmthemeclient.cpp )
kde4_add_plugin(kwin3_kwmtheme ${kwin3_kwmtheme_PART_SRCS})
target_link_libraries(kwin3_kwmtheme ${KDE4_KDECORE_LIBS} kdecorations )
install(TARGETS kwin3_kwmtheme DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES kwmtheme.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin )

View File

@ -0,0 +1,14 @@
########### next target ###############
set(kwmtheme_SRCS main.cpp )
kde4_add_executable(kwmtheme ${kwmtheme_SRCS})
target_link_libraries(kwmtheme ${KDE4_KDECORE_LIBS} )
install(TARGETS kwmtheme ${INSTALL_TARGETS_DEFAULT_ARGS})

View File

@ -0,0 +1,178 @@
/********************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include <QFile>
#include <QDir>
#include <kapplication.h>
#include <ksimpleconfig.h>
#include <kglobal.h>
#include <kdebug.h>
#include <kstandarddirs.h>
#include <kcmdlineargs.h>
#include <klocale.h>
static const char description[] =
I18N_NOOP("Installs a KWM theme");
void copy(const QString &src, const QString &dest)
{
QFile copyInput(src);
QFile copyOutput(dest);
if(!copyInput.open(QIODevice::ReadOnly)){
kWarning(1212) << "Couldn't open " << src ;
return;
}
if(!copyOutput.open(QIODevice::WriteOnly)){
kWarning(1212) << "Couldn't open " << dest ;
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");
KCmdLineOptions options;
options.add("+[file]", ki18n("Path to a theme config file"));
KCmdLineArgs::addCmdLineOptions( options );
KApplication app(argc, argv);
KCmdLineArgs *args = KCmdLineArgs::parsedArgs();
if(!args->count()){
kWarning(1212) << "You need to specify the path to a theme config file!" ;
return(1);
}
QString srcStr = QString(args->arg(0));
QFile f(srcStr);
QString tmpStr;
if(!f.exists()){
kWarning(1212) << "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.absoluteFilePath());
srcStr = fi.dirPath(true) + '/';
KSharedConfig::Ptr 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, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("shapePixmapBottom");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottom", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("shapePixmapLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_left", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("shapePixmapRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_right", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("shapePixmapTopLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_topleft", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("shapePixmapTopRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_topright", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("shapePixmapBottomLeft");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottomleft", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("shapePixmapBottomRight");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("wm_bottomright", tmpStr, KConfig::Normal|KConfig::Global);
input.setGroup("Window Titlebar");
output->writeEntry("TitleAlignment", input.readEntry("TitleAlignment"), KConfig::Normal|KConfig::Global);
output->writeEntry("PixmapUnderTitleText", input.readEntry("PixmapUnderTitleText"), KConfig::Normal|KConfig::Global);
output->writeEntry("TitleFrameShaded", input.readEntry("TitleFrameShaded"), KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("MenuButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("menu", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("PinUpButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("pinup", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("PinDownButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("pindown", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("CloseButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("close", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("MaximizeButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("maximize", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("MaximizeDownButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("maximizedown", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("MinimizeButton");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("iconify", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("TitlebarPixmapActive");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("TitlebarPixmapActive", tmpStr, KConfig::Normal|KConfig::Global);
tmpStr = input.readEntry("TitlebarPixmapInactive");
if(!tmpStr.isEmpty())
copy(srcStr+tmpStr, localDirStr+tmpStr);
output->writeEntry("TitlebarPixmapInactive", tmpStr, KConfig::Normal|KConfig::Global);
input.setGroup("Window Button Layout");
output->setGroup("Buttons");
output->writeEntry("ButtonA", input.readEntry("ButtonA"), KConfig::Normal|KConfig::Global);
output->writeEntry("ButtonB", input.readEntry("ButtonB"), KConfig::Normal|KConfig::Global);
output->writeEntry("ButtonC", input.readEntry("ButtonC"), KConfig::Normal|KConfig::Global);
output->writeEntry("ButtonD", input.readEntry("ButtonD"), KConfig::Normal|KConfig::Global);
output->writeEntry("ButtonE", input.readEntry("ButtonE"), KConfig::Normal|KConfig::Global);
output->writeEntry("ButtonF", input.readEntry("ButtonF"), KConfig::Normal|KConfig::Global);
output->sync();
return(0);
}

View File

@ -0,0 +1,89 @@
[Desktop Entry]
Name=KWM Theme
Name[af]=KWM Tema
Name[ar]=سمة KWM
Name[be]=Тэма KWM
Name[be@latin]=Matyŭ „KWM”
Name[bg]=Тема KWM
Name[bn]=KWM থীম
Name[bn_IN]=KWM থিম
Name[br]=Gwiskad KWM
Name[ca]=Tema KWM
Name[ca@valencia]=Tema KWM
Name[cs]=Téma KWM
Name[csb]=Témë KWM
Name[cy]=Thema KWM
Name[da]=KWM-tema
Name[de]=KWM-Design
Name[el]=Θέμα KWM
Name[en_GB]=KWM Theme
Name[eo]=KWM-etoso
Name[es]=Tema de KWM
Name[et]=KWM teema
Name[eu]=KWM gaia
Name[fa]=چهره KWM
Name[fi]=KWM-teema
Name[fr]=Thème KWM
Name[fy]=KWM-tema
Name[ga]=Téama KWM
Name[gl]=Tema do KWM
Name[gu]=KWM થીમ
Name[he]=ערכת KWM
Name[hi]=केडबल्यूएम प्रसंग
Name[hne]=केडबल्यूएम प्रसंग
Name[hr]=KWM tema
Name[hsb]=KWM-tema
Name[hu]=KWM téma
Name[ia]=Thema KWM
Name[id]=Tema KWM
Name[is]=KWM þema
Name[it]=Tema KWM
Name[ja]=KWM テーマ
Name[ka]=KWM სტილი
Name[kk]=KWM нақышы
Name[km]=ស្បែក KWM
Name[kn]=KWM ಪರಿಸರವಿನ್ಯಾಸ (ಥೀಮ್)
Name[ko]=KWM 테마
Name[ku]=Dirbê KWM
Name[lt]=KWM tema
Name[lv]=KWM tēma
Name[mai]=केडबल्यूएम प्रसंग
Name[mk]=KWM тема
Name[ml]=കെഡബ്ല്യൂഎം പ്രമേയം
Name[mr]=केडबल्यूएम सुत्रयोजना
Name[ms]=Temas KWM
Name[nb]=KWM-tema
Name[nds]=KWM-Muster
Name[ne]=KWM विषयवस्तु
Name[nl]=KWM-thema
Name[nn]=KWM-tema
Name[pa]=KWM ਥੀਮ
Name[pl]=Motyw KWM
Name[pt]=Tema KWM
Name[pt_BR]=Tema KWM
Name[ro]=Tematică KWM
Name[ru]=Стиль KWM
Name[se]=KWM-fáddá
Name[si]=KWM තේමාව
Name[sk]=Téma KWM
Name[sl]=Tema KWM
Name[sr]=КВМ‑ова тема
Name[sr@ijekavian]=КВМ‑ова тема
Name[sr@ijekavianlatin]=KWMova tema
Name[sr@latin]=KWMova tema
Name[sv]=KWM-tema
Name[ta]=KWM தலைப்பு
Name[te]=KWM థీమ్
Name[tg]=Мавзӯъи KWM
Name[th]=รูปแบบชุดตกแต่ง KWM
Name[tr]=KWM Teması
Name[uk]=Тема KWM
Name[uz]=KWM mavzusi
Name[uz@cyrillic]=KWM мавзуси
Name[vi]=Sắc thái KWM
Name[wa]=Tinme KWM
Name[xh]=Umxholo we KWM
Name[x-test]=xxKWM Themexx
Name[zh_CN]=KWM 主题
Name[zh_TW]=KWM 主題
X-KDE-Library=kwin3_kwmtheme

View File

@ -0,0 +1,951 @@
/********************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "kwmthemeclient.h"
#include <kconfig.h>
#include <kglobal.h>
#include <QLayout>
#include <qdrawutil.h>
#include <QPainter>
#include <kpixmapeffect.h>
#include <kstandarddirs.h>
#include <kdebug.h>
#include <klocale.h>
#include <QBitmap>
#include <QStyle>
#include <QLabel>
namespace KWMTheme {
/* 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;
} */
inline const KDecorationOptions* options() { return KDecoration::options(); }
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 QPixmap *aTitlePix = 0;
static QPixmap *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 * const keys[] = {"wm_top", "wm_bottom", "wm_left", "wm_right",
"wm_topleft", "wm_topright", "wm_bottomleft", "wm_bottomright"};
if(pixmaps_created)
return;
pixmaps_created = true;
KSharedConfig::Ptr _config = KGlobal::config();
KConfigGroup config(_config, "General");
QString tmpStr;
for(int i=0; i < 8; ++i)
{
framePixmaps[i] = new QPixmap(locate("data",
"kwin/pics/"+config.readEntry(keys[i], " ")));
if(framePixmaps[i]->isNull())
kWarning(1212) << "Unable to load frame pixmap for " << 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();
maxExtent++;
menuPix = new QPixmap(locate("data",
"kwin/pics/"+config.readEntry("menu", " ")));
iconifyPix = new QPixmap(locate("data",
"kwin/pics/"+config.readEntry("iconify", " ")));
maxPix = new QPixmap(locate("appdata",
"pics/"+config.readEntry("maximize", " ")));
minmaxPix = new QPixmap(locate("data",
"kwin/pics/"+config.readEntry("maximizedown", " ")));
closePix = new QPixmap(locate("data",
"kwin/pics/"+config.readEntry("close", " ")));
pinupPix = new QPixmap(locate("data",
"kwin/pics/"+config.readEntry("pinup", " ")));
pindownPix = new QPixmap(locate("data",
"kwin/pics/"+config.readEntry("pindown", " ")));
if(menuPix->isNull())
menuPix->load(locate("data", "kwin/pics/menu.png"));
if(iconifyPix->isNull())
iconifyPix->load(locate("data", "kwin/pics/iconify.png"));
if(maxPix->isNull())
maxPix->load(locate("data", "kwin/pics/maximize.png"));
if(minmaxPix->isNull())
minmaxPix->load(locate("data", "kwin/pics/maximizedown.png"));
if(closePix->isNull())
closePix->load(locate("data", "kwin/pics/close.png"));
if(pinupPix->isNull())
pinupPix->load(locate("data", "kwin/pics/pinup.png"));
if(pindownPix->isNull())
pindownPix->load(locate("data", "kwin/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.readEntry("TitleFrameShaded", true );
// titleSunken = true; // is this fixed?
titleTransparent = config.readEntry("PixmapUnderTitleText", true);
tmpStr = config.readEntry("TitlebarLook");
if(tmpStr == "shadedVertical"){
aTitlePix = new QPixmap;
aTitlePix->resize(32, 20);
KPixmapEffect::gradient(*aTitlePix,
options()->color(KDecorationOptions::ColorTitleBar, true),
options()->color(KDecorationOptions::ColorTitleBlend, true),
KPixmapEffect::VerticalGradient);
iTitlePix = new QPixmap;
iTitlePix->resize(32, 20);
KPixmapEffect::gradient(*iTitlePix,
options()->color(KDecorationOptions::ColorTitleBar, false),
options()->color(KDecorationOptions::ColorTitleBlend, 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 QPixmap;
aTitlePix->load(locate("data", "kwin/pics/" + tmpStr));
}
else
aTitlePix = NULL;
tmpStr = config.readEntry("TitlebarPixmapInactive", "");
if(!tmpStr.isEmpty()){
iTitlePix = new QPixmap;
iTitlePix->load(locate("data", "kwin/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 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, QRect( offset, offset, width(), height() ),
AlignCenter, colorGroup(),
true, pixmap(), QString());
}
}
KWMThemeClient::KWMThemeClient( KDecorationBridge* b, KDecorationFactory* f )
: KDecoration( b, f )
{
}
void KWMThemeClient::init()
{
createMainWidget( WResizeNoErase | WStaticContents );
widget()->installEventFilter( this );
stickyBtn = maxBtn = mnuBtn = 0;
layout = new QGridLayout(widget());
layout->addColSpacing(0, maxExtent);
layout->addColSpacing(2, maxExtent);
layout->addRowSpacing(0, maxExtent);
layout->addItem(new QSpacerItem(1, 1, QSizePolicy::Fixed,
QSizePolicy::Expanding));
if( isPreview())
layout->addWidget( new QLabel( i18n( "<center><b>KWMTheme</b></center>" ), widget()), 2, 1);
else
layout->addItem( new QSpacerItem( 0, 0 ), 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->setColumnStretch(1, 10);
QBoxLayout* hb = new QBoxLayout(0, QBoxLayout::LeftToRight, 0, 0, 0);
layout->addLayout( hb, 1, 1 );
KSharedConfig::Ptr _config = KGlobal::config();
KConfigGroup config(_config, "Buttons");
QString val;
MyButton *btn;
int i;
static const char * const 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(widget(), "menu");
mnuBtn->setToolTip( i18n("Menu"));
iconChange();
hb->addWidget(mnuBtn);
mnuBtn->setFixedSize(20, 20);
connect(mnuBtn, SIGNAL(pressed()), this,
SLOT(menuButtonPressed()));
}
else if(val == "Sticky"){
stickyBtn = new MyButton(widget(), "sticky");
stickyBtn->setToolTip( i18n("Sticky"));
if (isOnAllDesktops())
stickyBtn->setPixmap(*pindownPix);
else
stickyBtn->setPixmap(*pinupPix);
connect(stickyBtn, SIGNAL( clicked() ), this, SLOT(toggleOnAllDesktops()));
hb->addWidget(stickyBtn);
stickyBtn->setFixedSize(20, 20);
}
else if((val == "Iconify") && isMinimizable()){
btn = new MyButton(widget(), "iconify");
btn->setToolTip( i18n("Minimize"));
btn->setPixmap(*iconifyPix);
connect(btn, SIGNAL(clicked()), this, SLOT(minimize()));
hb->addWidget(btn);
btn->setFixedSize(20, 20);
}
else if((val == "Maximize") && isMaximizable()){
maxBtn = new MyButton(widget(), "max");
maxBtn->setToolTip( i18n("Maximize"));
maxBtn->setPixmap(*maxPix);
connect(maxBtn, SIGNAL(clicked()), this, SLOT(maximize()));
hb->addWidget(maxBtn);
maxBtn->setFixedSize(20, 20);
}
else if((val == "Close") && isCloseable()){
btn = new MyButton(widget(), "close");
btn->setToolTip( i18n("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()))
kWarning(1212) << "KWin: Unrecognized button value: " << val ;
}
}
if(titleGradient){
aGradient = new QPixmap;
iGradient = new QPixmap;
}
else{
aGradient = 0;
iGradient = 0;
}
widget()->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()->palette(KDecorationOptions::ColorFrame, isActive()).active(),
true, 1, 0);
r.setRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2);
}
QPixmap *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(KDecorationOptions::ColorTitleBar, isActive()),
options()->color(KDecorationOptions::ColorTitleBlend, isActive()),
grType);
}
p.drawTiledPixmap(r, *fill);
}
else{
p.fillRect(r, options()->palette(KDecorationOptions::ColorTitleBar, isActive()).active().
brush(QPalette::Button));
}
p.setFont(options()->font(isActive()));
p.setPen(options()->color(KDecorationOptions::ColorFont, 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* )
{
doShape();
widget()->repaint();
}
void KWMThemeClient::captionChange()
{
widget()->repaint( titlebar->geometry(), false );
}
void KWMThemeClient::paintEvent( QPaintEvent *)
{
QPainter p;
p.begin(widget());
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;
QMatrix 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.transformed(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.transformed(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.transformed(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.transformed(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 = widget()->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;
if (framePixmaps[FrameTopLeft]->mask())
p.drawPixmap(0,0,*framePixmaps[FrameTopLeft]->mask(),
0,0,w1, h1);
else
p.fillRect(0,0,w1,h1,color1);
int w2 = framePixmaps[FrameTopRight]->width();
int h2 = framePixmaps[FrameTopRight]->height();
if (w2 > width()/2) w2 = width()/2;
if (h2 > height()/2) h2 = height()/2;
if (framePixmaps[FrameTopRight]->mask())
p.drawPixmap(width()-w2,0,*framePixmaps[FrameTopRight]->mask(),
framePixmaps[FrameTopRight]->width()-w2,0,w2, h2);
else
p.fillRect(width()-w2,0,w2, h2,color1);
int w3 = framePixmaps[FrameBottomLeft]->width();
int h3 = framePixmaps[FrameBottomLeft]->height();
if (w3 > width()/2) w3 = width()/2;
if (h3 > height()/2) h3 = height()/2;
if (framePixmaps[FrameBottomLeft]->mask())
p.drawPixmap(0,height()-h3,*framePixmaps[FrameBottomLeft]->mask(),
0,framePixmaps[FrameBottomLeft]->height()-h3,w3, h3);
else
p.fillRect(0,height()-h3,w3,h3,color1);
int w4 = framePixmaps[FrameBottomRight]->width();
int h4 = framePixmaps[FrameBottomRight]->height();
if (w4 > width()/2) w4 = width()/2;
if (h4 > height()/2) h4 = height()/2;
if (framePixmaps[FrameBottomRight]->mask())
p.drawPixmap(width()-w4,height()-h4,*framePixmaps[FrameBottomRight]->mask(),
framePixmaps[FrameBottomRight]->width()-w4,
framePixmaps[FrameBottomRight]->height()-h4,
w4, h4);
else
p.fillRect(width()-w4,height()-h4,w4,h4,color1);
QPixmap pm;
QMatrix m;
int n,s,w;
//top
if (framePixmaps[FrameTop]->mask())
{
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.transformed(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
if (framePixmaps[FrameBottom]->mask())
{
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.transformed(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
if (framePixmaps[FrameLeft]->mask())
{
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.transformed(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
if (framePixmaps[FrameRight]->mask())
{
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.transformed(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 *)
{
doShape();
widget()->repaint(false);
}
void KWMThemeClient::mouseDoubleClickEvent( QMouseEvent * e )
{
if (e->button() == LeftButton && titlebar->geometry().contains( e->pos() ) )
titlebarDblClickOperation();
}
void KWMThemeClient::desktopChange()
{
if (stickyBtn) {
bool on = isOnAllDesktops();
stickyBtn->setPixmap(on ? *pindownPix : *pinupPix);
stickyBtn->setToolTip( on ? i18n("Unsticky") : i18n("Sticky") );
}
}
void KWMThemeClient::maximizeChange()
{
if (maxBtn) {
bool m = maximizeMode() == MaximizeFull;
maxBtn->setPixmap(m ? *minmaxPix : *maxPix);
maxBtn->setToolTip( m ? i18n("Restore") : i18n("Maximize"));
}
}
void KWMThemeClient::slotMaximize()
{
maximize( maximizeMode() == MaximizeFull ? MaximizeRestore : MaximizeFull );
}
void KWMThemeClient::activeChange()
{
widget()->update();
}
KDecoration::Position KWMThemeClient::mousePosition(const QPoint &p) const
{
Position m = KDecoration::mousePosition(p);
// corners
if(p.y() < framePixmaps[FrameTop]->height() &&
p.x() < framePixmaps[FrameLeft]->width()){
m = PositionTopLeft;
}
else if(p.y() < framePixmaps[FrameTop]->height() &&
p.x() > width()-framePixmaps[FrameRight]->width()){
m = PositionTopRight;
}
else if(p.y() > height()-framePixmaps[FrameBottom]->height() &&
p.x() < framePixmaps[FrameLeft]->width()){
m = PositionBottomLeft;
}
else if(p.y() > height()-framePixmaps[FrameBottom]->height() &&
p.x() > width()-framePixmaps[FrameRight]->width()){
m = PositionBottomRight;
} // edges
else if(p.y() < framePixmaps[FrameTop]->height())
m = PositionTop;
else if(p.y() > height()-framePixmaps[FrameBottom]->height())
m = PositionBottom;
else if(p.x() < framePixmaps[FrameLeft]->width())
m = PositionLeft;
else if(p.x() > width()-framePixmaps[FrameRight]->width())
m = PositionRight;
return(m);
}
void KWMThemeClient::menuButtonPressed()
{
mnuBtn->setDown(false); // will stay down if I don't do this
QPoint pos = mnuBtn->mapToGlobal(mnuBtn->rect().bottomLeft());
showWindowMenu( pos );
}
void KWMThemeClient::iconChange()
{
if(mnuBtn){
if( icon().pixmap( QIcon::Small, QIcon::Normal ).isNull()){
mnuBtn->setPixmap(*menuPix);
}
else{
mnuBtn->setPixmap(icon().pixmap( QIcon::Small, QIcon::Normal ));
}
}
}
bool KWMThemeClient::eventFilter( QObject* o, QEvent* e )
{
if ( o != widget() )
return false;
switch ( e->type() )
{
case QEvent::Resize:
resizeEvent( static_cast< QResizeEvent* >( e ) );
return true;
case QEvent::Paint:
paintEvent( static_cast< QPaintEvent* >( e ) );
return true;
case QEvent::MouseButtonDblClick:
mouseDoubleClickEvent( static_cast< QMouseEvent* >( e ) );
return true;
case QEvent::MouseButtonPress:
processMousePressEvent( static_cast< QMouseEvent* >( e ) );
return true;
case QEvent::Show:
showEvent( static_cast< QShowEvent* >( e ) );
return true;
default:
return false;
}
}
QSize KWMThemeClient::minimumSize() const
{
return widget()->minimumSize().expandedTo( QSize( 100, 50 ));
}
void KWMThemeClient::resize( const QSize& s )
{
widget()->resize( s );
}
void KWMThemeClient::borders( int& left, int& right, int& top, int& bottom ) const
{
left =
right =
top =
bottom =
TODO
}
KWMThemeFactory::KWMThemeFactory()
{
create_pixmaps();
}
KWMThemeFactory::~KWMThemeFactory()
{
delete_pixmaps();
}
KDecoration* KWMThemeFactory::createDecoration( KDecorationBridge* b )
{
return new KWMThemeClient( b, this );
}
bool KWMThemeFactory::reset( unsigned long mask )
{
bool needHardReset = false;
TODO
// doesn't obey the Border size setting
if( mask & ( SettingFont | SettingButtons ))
needHardReset = true;
if( mask & ( SettingFont | SettingColors )) {
KWMTheme::delete_pixmaps();
KWMTheme::create_pixmaps();
}
if( !needHardReset )
resetDecorations( mask );
return needHardReset;
}
}
extern "C"
{
KDE_EXPORT KDecorationFactory *create_factory()
{
return new KWMTheme::KWMThemeFactory();
}
}
#include "kwmthemeclient.moc"

View File

@ -0,0 +1,88 @@
/********************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef __KWMTHEMECLIENT_H
#define __KWMTHEMECLIENT_H
#include <qbutton.h>
#include <QToolButton>
#include <QPixmap>
#include <kdecoration.h>
#include <kdecorationfactory.h>
class QSpacerItem;
class QGridLayout;
namespace KWMTheme {
class MyButton : public QToolButton
{
public:
explicit MyButton(QWidget *parent=0, const char *name=0)
: QToolButton(parent, name){setAutoRaise(true);setCursor( arrowCursor ); }
protected:
void drawButtonLabel(QPainter *p);
};
class KWMThemeClient : public KDecoration
{
Q_OBJECT
public:
KWMThemeClient( KDecorationBridge* b, KDecorationFactory* f );
~KWMThemeClient(){;}
void init();
void resize( const QSize& s );
QSize minimumSize() const;
void borders( int& left, int& right, int& top, int& bottom ) const;
protected:
void doShape();
void drawTitle(QPainter &p);
void resizeEvent( QResizeEvent* );
void paintEvent( QPaintEvent* );
void showEvent( QShowEvent* );
void mouseDoubleClickEvent( QMouseEvent * );
bool eventFilter( QObject* o, QEvent* e );
void captionChange();
void desktopChange();
void maximizeChange();
void iconChange();
void activeChange();
void shadeChange() {};
Position mousePosition(const QPoint &) const;
protected slots:
//void slotReset();
void menuButtonPressed();
void slotMaximize();
private:
QPixmap buffer;
KPixmap *aGradient, *iGradient;
MyButton *maxBtn, *stickyBtn, *mnuBtn;
QSpacerItem *titlebar;
QGridLayout* layout;
};
class KWMThemeFactory : public KDecorationFactory
{
public:
KWMThemeFactory();
~KWMThemeFactory();
KDecoration* createDecoration( KDecorationBridge* b );
bool reset( unsigned long mask );
};
}
#endif

View File

@ -0,0 +1,3 @@
install( FILES close.png maximize.png maximizedown.png menu.png iconify.png pindown.png pinup.png unknown.png fog.png fog-grey.png bluesun.png greenie.light.png greenie.dim.png DESTINATION ${DATA_INSTALL_DIR}/kwin/pics )

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 285 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 269 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 297 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 454 B

View File

@ -0,0 +1,18 @@
add_subdirectory( config )
########### next target ###############
set(kwin3_modernsys_PART_SRCS modernsys.cpp)
kde4_add_plugin(kwin3_modernsys ${kwin3_modernsys_PART_SRCS})
target_link_libraries(kwin3_modernsys kdecorations ${QT_QTGUI_LIBRARY})
install(TARGETS kwin3_modernsys DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
install( FILES modernsystem.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/ )

View File

@ -0,0 +1,117 @@
/*
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __BTNHIGHCOLOR_H
#define __BTNHIGHCOLOR_H
/* XPM */
static const char * const 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..... "};
#endif // __BTNHIGHCOLOR_H

View File

@ -0,0 +1,65 @@
/*
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __BUTTONDATA_H
#define __BUTTONDATA_H
/* Image bits processed by KPixmap2Bitmaps */
#define lowcolor_mask_width 14
#define lowcolor_mask_height 15
static const 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 const 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 const 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 const 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 const 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 };
#endif // __BUTTONDATA_H

View File

@ -0,0 +1,16 @@
########### next target ###############
set(kwin_modernsys_config_PART_SRCS config.cpp )
kde4_add_plugin(kwin_modernsys_config ${kwin_modernsys_config_PART_SRCS})
target_link_libraries(kwin_modernsys_config ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY})
install(TARGETS kwin_modernsys_config DESTINATION ${PLUGIN_INSTALL_DIR} )

View File

@ -0,0 +1,157 @@
/********************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
// Melchior FRANZ <mfranz@kde.org> -- 2001-04-22
#include "config.h"
#include <kapplication.h>
#include <kconfig.h>
#include <kdialog.h>
#include <klocale.h>
#include <kglobal.h>
#include <QLayout>
//Added by qt3to4:
#include <QLabel>
#include <QVBoxLayout>
#include <QGridLayout>
#include <kvbox.h>
extern "C"
{
KDE_EXPORT 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");
KGlobal::locale()->insertCatalog("kwin_clients");
mainw = new QWidget(parent);
vbox = new QVBoxLayout(mainw);
vbox->setSpacing(6);
vbox->setMargin(0);
handleBox = new QWidget(mainw);
QGridLayout* layout = new QGridLayout(handleBox );
layout->setSpacing( KDialog::spacingHint() );
cbShowHandle = new QCheckBox(i18n("&Show window resize handle"), handleBox);
cbShowHandle->setWhatsThis(
i18n("When selected, all windows are drawn with a resize "
"handle at the lower right corner. This makes window resizing "
"easier, especially for trackballs and other mouse replacements "
"on laptops."));
layout->addWidget(cbShowHandle, 0, 0, 1, 2 );
connect(cbShowHandle, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()));
sliderBox = new KVBox(handleBox);
//handleSizeSlider = new QSlider(0, 4, 1, 0, Qt::Horizontal, sliderBox);
handleSizeSlider = new QSlider(Qt::Horizontal, sliderBox);
handleSizeSlider->setMinimum(0);
handleSizeSlider->setMaximum(4);
handleSizeSlider->setPageStep(1);
handleSizeSlider->setWhatsThis(
i18n("Here you can change the size of the resize handle."));
handleSizeSlider->setTickInterval(1);
handleSizeSlider->setTickPosition(QSlider::TicksBelow);
connect(handleSizeSlider, SIGNAL(valueChanged(int)), this, SLOT(slotSelectionChanged()));
hbox = new KHBox(sliderBox);
hbox->setSpacing(6);
bool rtl = kapp->layoutDirection() == Qt::RightToLeft;
label1 = new QLabel(i18n("Small"), hbox);
label1->setAlignment(rtl ? Qt::AlignRight : Qt::AlignLeft);
label2 = new QLabel(i18n("Medium"), hbox);
label2->setAlignment( Qt::AlignHCenter );
label3 = new QLabel(i18n("Large"), hbox);
label3->setAlignment(rtl ? Qt::AlignLeft : Qt::AlignRight);
vbox->addWidget(handleBox);
vbox->addStretch(1);
// layout->setColumnMinimumWidth(0, 30);
layout->addItem(new QSpacerItem(30, 10, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
layout->addWidget(sliderBox, 1, 1);
KConfigGroup group(conf,"General");
load(group);
mainw->show();
}
ModernSysConfig::~ModernSysConfig()
{
delete mainw;
delete clientrc;
}
void ModernSysConfig::slotSelectionChanged()
{
bool i = cbShowHandle->isChecked();
if (i != hbox->isEnabled()) {
hbox->setEnabled(i);
handleSizeSlider->setEnabled(i);
}
emit changed();
}
void ModernSysConfig::load(const KConfigGroup& /*conf*/)
{
KConfigGroup cg(clientrc, "General");
bool i = cg.readEntry("ShowHandle", true);
cbShowHandle->setChecked(i);
hbox->setEnabled(i);
handleSizeSlider->setEnabled(i);
handleWidth = cg.readEntry("HandleWidth", 6);
handleSize = cg.readEntry("HandleSize", 30);
handleSizeSlider->setValue(qMin((handleWidth - 6) / 2, (uint)4));
}
void ModernSysConfig::save(KConfigGroup& /*conf*/)
{
KConfigGroup cg(clientrc, "General");
cg.writeEntry("ShowHandle", cbShowHandle->isChecked());
cg.writeEntry("HandleWidth", 6 + 2 * handleSizeSlider->value());
cg.writeEntry("HandleSize", 30 + 4 * handleSizeSlider->value());
clientrc->sync();
}
void ModernSysConfig::defaults()
{
cbShowHandle->setChecked(true);
hbox->setEnabled(true);
handleSizeSlider->setEnabled(true);
handleSizeSlider->setValue(0);
}
#include "config.moc"

View File

@ -0,0 +1,70 @@
/********************************************************************
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef __KDE_MODSYSTEMCONFIG_H
#define __KDE_MODSYSTEMCONFIG_H
#include <QCheckBox>
#include <QLayout>
#include <QSlider>
#include <QLabel>
//Added by qt3to4:
#include <QVBoxLayout>
#include <kvbox.h>
class KConfig;
class KConfigGroup;
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(const KConfigGroup& conf);
void save(KConfigGroup& conf);
void defaults();
protected slots:
void slotSelectionChanged(); // Internal use
private:
KConfig *clientrc;
QWidget *mainw;
QVBoxLayout *vbox;
QWidget *handleBox;
QCheckBox *cbShowHandle;
KVBox *sliderBox;
QSlider *handleSizeSlider;
KHBox *hbox;
QLabel *label1;
QLabel *label2;
QLabel *label3;
unsigned handleWidth;
unsigned handleSize;
};
#endif

View File

@ -0,0 +1,821 @@
/*
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
// Daniel M. DULEY <mosfet@kde.org> original work
// Melchior FRANZ <a8603365@unet.univie.ac.at> configuration options
#include "modernsys.h"
#include <kconfiggroup.h>
#include <kglobal.h>
#include <klocale.h>
#include <QLayout>
#include <QtGui/qdrawutil.h>
//Added by qt3to4:
#include <QPixmap>
#include <QPaintEvent>
#include <QPainter>
#include <QBitmap>
#include <QApplication>
#include <QLabel>
#include "buttondata.h"
#include "btnhighcolor.h"
#include <QImage>
namespace ModernSystem {
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 r_minmax_bits[] = {
0x0c, 0x18, 0x33, 0x67, 0xcf, 0x9f, 0x3f, 0x3f};
static unsigned char l_minmax_bits[] = {
0x30, 0x18, 0xcc, 0xe6, 0xf3, 0xf9, 0xfc, 0xfc};
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 above_on_bits[] = {
0x7e, 0x00, 0x7e, 0x3c, 0x18, 0x00, 0x00, 0x00};
static unsigned char above_off_bits[] = {
0x18, 0x3c, 0x7e, 0x00, 0x7e, 0x00, 0x00, 0x00};
static unsigned char below_off_bits[] = {
0x00, 0x00, 0x00, 0x7e, 0x00, 0x7e, 0x3c, 0x18};
static unsigned char below_on_bits[] = {
0x00, 0x00, 0x00, 0x18, 0x3c, 0x7e, 0x00, 0x7e};
static unsigned char shade_off_bits[] = {
0x00, 0x7e, 0x7e, 0x00, 0x00, 0x00, 0x00, 0x00};
static unsigned char shade_on_bits[] = {
0x00, 0x7e, 0x7e, 0x42, 0x42, 0x42, 0x7e, 0x00};
static unsigned char menu_bits[] = {
0xff, 0x81, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff};
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 QPixmap *aUpperGradient=0;
static QPixmap *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 bool show_handle;
static int handle_size;
static int handle_width;
static int border_width;
static int title_height;
static inline const KDecorationOptions* options()
{
return KDecoration::options();
}
static void make_button_fx(const QPalette &g, QPixmap *pix, bool light=false)
{
pix->fill(g.background().color());
if(QPixmap::defaultDepth() > 8){
int i, destH, destS, destV, srcH, srcS, srcV;
QColor btnColor = g.background().color();
// TODO: This seems to have been broken from the port to Qt4
if(btnSource->depth() < 32)
*btnSource = btnSource->convertToFormat(QImage::Format_RGB32);
if(light)
btnColor = btnColor.light(120);
btnColor.getHsv(&destH, &destS, &destV);
QImage btnDest(14, 15, QImage::Format_RGB32);
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.getHsv(&srcH, &srcS, &srcV);
srcColor.setHsv(destH, destS, srcV);
destData[i] = srcColor.rgb();
}
*pix = QPixmap::fromImage(btnDest);
}
else{
QPainter p(pix);
if(!lcDark1.mask()){
lcDark1.setMask(lcDark1);
lcDark2.setMask(lcDark2);
lcDark3.setMask(lcDark3);
lcLight1.setMask(lcLight1);
}
p.setPen(g.dark().color());
p.drawPixmap(0, 0, lcDark2);
p.drawPixmap(0, 0, lcDark1);
p.setPen(g.mid().color());
p.drawPixmap(0, 0, lcDark3);
p.setPen(g.light().color());
p.drawPixmap(0, 0, lcLight1);
}
}
static void gradientFill(QPixmap *pixmap, const QColor &color1, const QColor &color2)
{
QPainter p(pixmap);
QLinearGradient gradient(0, 0, 0, pixmap->height());
gradient.setColorAt(0.0, color1);
gradient.setColorAt(1.0, color2);
QBrush brush(gradient);
p.fillRect(pixmap->rect(), brush);
}
static void create_pixmaps()
{
if(pixmaps_created)
return;
pixmaps_created = true;
lcDark1 = QBitmap::fromData(QSize(14, 15), lowcolor_6a696a_bits, QImage::Format_Mono);
lcDark2 = QBitmap::fromData(QSize(14, 15), lowcolor_949194_bits, QImage::Format_Mono);
lcDark3 = QBitmap::fromData(QSize(14, 15), lowcolor_b4b6b4_bits, QImage::Format_Mono);
lcLight1 = QBitmap::fromData(QSize(14, 15), lowcolor_e6e6e6_bits, QImage::Format_Mono);
btnSource = new QImage(btnhighcolor_xpm);
if(QPixmap::defaultDepth() > 8){
aUpperGradient = new QPixmap( 32, title_height+2 );
iUpperGradient = new QPixmap( 32, title_height+2);;
gradientFill(aUpperGradient,
options()->color(KDecoration::ColorTitleBar, true).light(130),
options()->color(KDecoration::ColorTitleBlend, true));
gradientFill(iUpperGradient,
options()->color(KDecoration::ColorTitleBar, false).light(130),
options()->color(KDecoration::ColorTitleBlend, false));
}
// buttons
QPalette btnColor(options()->palette(KDecoration::ColorButtonBg, true) );
btnColor.setCurrentColorGroup(QPalette::Active);
buttonPix = new QPixmap(14, 15);
make_button_fx(btnColor, buttonPix);
buttonPixDown = new QPixmap(14, 15);
make_button_fx(btnColor, buttonPixDown, true);
btnColor = options()->palette(KDecoration::ColorButtonBg, false);
btnColor.setCurrentColorGroup(QPalette::Active);
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().color().rgb()) < 150)
buttonFg = new QColor(Qt::white);
else
buttonFg = new QColor(Qt::black);
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 void draw_button(QPainter &p, int x, int y, int w, int h, const QPalette &pal)
{
if (w > 16 && h > 16){
int x2 = x+w, y2 = y+h;
QPen oldPen = p.pen();
QPolygon hPntArray, lPntArray;
hPntArray.putPoints(0, 12, x+4,y+1, x+5,y+1, // top left
x+3,y+2, x+2,y+3, x+1,y+4, x+1,y+5,
x+1,y2-5, x+1,y2-4, x+2,y2-3, // half corners
x2-5,y+1, x2-4,y+1, x2-3,y+2);
lPntArray.putPoints(0, 17, x2-5,y2-1, x2-4,y2-1, // btm right
x2-3,y2-2, x2-2,y2-3, x2-1,y2-5, x2-1,y2-4,
x+3,y2-2, x+4,y2-1, x+5,y2-1, //half corners
x2-2,y+3, x2-1,y+4, x2-1,y+5,
x2-5,y2-2, x2-4,y2-2, // testing
x2-3,y2-3,
x2-2,y2-5, x2-2,y2-4);
p.setPen(pal.color(QPalette::Light));
p.drawLine(x+6, y, x2-6, y);
p.drawLine(0, y+6, 0, y2-6);
p.drawPoints(hPntArray);
p.setPen(pal.color(QPalette::Dark));
p.drawLine(x+6, y2, x2-6, y2);
p.drawLine(x+6, y2-1, x2-6, y2-1);
p.drawLine(x2, y+6, x2, y2-6);
p.drawLine(x2-1, y+6, x2-1, y2-6);
p.drawPoints(lPntArray);
p.setPen(oldPen);
}
else
qDrawWinPanel(&p, x, y, w, h, pal, false);
}
void ModernSysFactory::read_config()
{
bool showh;
int hsize, hwidth, bwidth, theight;
KConfig _c( "kwinmodernsysrc" );
KConfigGroup c(&_c, "General");
showh = c.readEntry("ShowHandle", true);
hwidth = c.readEntry("HandleWidth", 6);
hsize = c.readEntry("HandleSize", 30);
if (!(showh && hsize && hwidth)) {
showh = false;
hwidth = hsize = 0;
}
switch(options()->preferredBorderSize( this )) {
case BorderLarge:
bwidth = 8;
hwidth = hwidth * 7/5;
hsize = hsize * 7/5;
break;
case BorderVeryLarge:
bwidth = 12;
hwidth = hwidth * 17/10 + 2;
hsize = hsize * 17/10;
break;
case BorderHuge:
bwidth = 18;
hwidth = hwidth * 2 + 6;
hsize = hsize * 2;
break;
/*
// If we allow these large sizes we need to change the
// correlation between the border width and the handle size.
case BorderVeryHuge:
bwidth = 27;
hwidth = hwidth * 5/2 + 15;
hsize = hsize * 5/2;
break;
case BorderOversized:
bwidth = 40;
hwidth = hwidth * 3 + 22;
hsize = hsize * 3;
break;
*/
case BorderNormal:
default:
bwidth = 4;
}
theight = QFontMetrics(options()->font(true)).height();
if (theight < 16)
theight = 16;
if (theight < bwidth)
theight = bwidth;
show_handle = showh;
handle_width = hwidth;
handle_size = hsize;
border_width = bwidth;
title_height = theight;
}
QList< ModernSysFactory::BorderSize > ModernSysFactory::borderSizes() const
{ // the list must be sorted
return QList< BorderSize >() << BorderNormal << BorderLarge <<
BorderVeryLarge << BorderHuge;
// as long as the buttons don't scale don't offer the largest two sizes.
// BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
}
ModernButton::ModernButton(ButtonType type, ModernSys *parent, const char *name)
: KCommonDecorationButton(type, parent)
{
setObjectName( name );
setAttribute(Qt::WA_NoSystemBackground, true);
QBitmap mask = QBitmap::fromData( QSize(14, 15), QPixmap::defaultDepth() > 8 ? btnhighcolor_mask_bits : lowcolor_mask_bits);
resize(14, 15);
setMask(mask);
}
void ModernButton::reset(unsigned long changed)
{
if (changed&DecorationReset || changed&ManualReset || changed&SizeChange || changed&StateChange) {
switch (type() ) {
case CloseButton:
setBitmap(close_bits);
break;
case HelpButton:
setBitmap(question_bits);
break;
case MinButton:
setBitmap(iconify_bits);
break;
case MaxButton:
setBitmap( isChecked() ? (isLeft()?l_minmax_bits:r_minmax_bits) : maximize_bits );
break;
case OnAllDesktopsButton:
setBitmap( isChecked() ? unsticky_bits : sticky_bits );
break;
case ShadeButton:
setBitmap( isChecked() ? shade_on_bits : shade_off_bits );
break;
case AboveButton:
setBitmap( isChecked() ? above_on_bits : above_off_bits );
break;
case BelowButton:
setBitmap( isChecked() ? below_on_bits : below_off_bits );
break;
case MenuButton:
setBitmap(menu_bits);
break;
default:
setBitmap(0);
break;
}
this->update();
}
}
void ModernButton::setBitmap(const unsigned char *bitmap)
{
if (bitmap)
deco = QBitmap::fromData( QSize(8, 8), bitmap);
else {
deco = QBitmap(8,8);
deco.fill(Qt::color0);
}
deco.setMask(deco);
}
void ModernButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
drawButton(&p);
}
void ModernButton::drawButton(QPainter *p)
{
if(decoration()->isActive()){
if(buttonPix)
p->drawPixmap(0, 0, isDown() ? *buttonPixDown : *buttonPix);
}
else{
if(iButtonPix)
p->drawPixmap(0, 0, isDown() ? *iButtonPixDown : *iButtonPix);
}
if(!deco.isNull()){
QPainterPath path;
path.addRegion( deco );
p->setBrush(*buttonFg);
p->setPen( Qt::NoPen );
p->translate( isDown() ? QPoint( 4, 5 ):QPoint( 3, 4 ) );
p->drawPath( path );
}
}
void ModernSys::reset( unsigned long changed)
{
KCommonDecoration::reset(changed);
titleBuffer = QPixmap();
recalcTitleBuffer();
resetButtons();
widget()->update();
}
ModernSys::ModernSys( KDecorationBridge* b, KDecorationFactory* f )
: KCommonDecoration( b, f )
{
}
QString ModernSys::visibleName() const
{
return i18n("Modern System");
}
QString ModernSys::defaultButtonsLeft() const
{
return "X";
}
QString ModernSys::defaultButtonsRight() const
{
return "HSIA";
}
bool ModernSys::decorationBehaviour(DecorationBehaviour behaviour) const
{
switch (behaviour) {
case DB_MenuClose:
return false;
case DB_WindowMask:
return true;
case DB_ButtonHide:
return true;
default:
return KCommonDecoration::decorationBehaviour(behaviour);
}
}
int ModernSys::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
{
// bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
switch (lm) {
case LM_BorderLeft:
return border_width + (reverse ? handle_width : 0);
case LM_BorderRight:
return border_width + (reverse ? 0 : handle_width);
case LM_BorderBottom:
return border_width + handle_width;
case LM_TitleEdgeLeft:
return layoutMetric(LM_BorderLeft,respectWindowState)+3;
case LM_TitleEdgeRight:
return layoutMetric(LM_BorderRight,respectWindowState)+3;
case LM_TitleEdgeTop:
return 2;
case LM_TitleEdgeBottom:
return 2;
case LM_TitleBorderLeft:
case LM_TitleBorderRight:
return 4;
case LM_TitleHeight:
return title_height;
case LM_ButtonWidth:
return 14;
case LM_ButtonHeight:
return 15;
case LM_ButtonSpacing:
return 1;
default:
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
}
}
KCommonDecorationButton *ModernSys::createButton(ButtonType type)
{
switch (type) {
case MenuButton:
return new ModernButton(MenuButton, this, "menu");
case OnAllDesktopsButton:
return new ModernButton(OnAllDesktopsButton, this, "on_all_desktops");
case HelpButton:
return new ModernButton(HelpButton, this, "help");
case MinButton:
return new ModernButton(MinButton, this, "minimize");
case MaxButton:
return new ModernButton(MaxButton, this, "maximize");
case CloseButton:
return new ModernButton(CloseButton, this, "close");
case AboveButton:
return new ModernButton(AboveButton, this, "above");
case BelowButton:
return new ModernButton(BelowButton, this, "below");
case ShadeButton:
return new ModernButton(ShadeButton, this, "shade");
default:
return 0;
}
}
void ModernSys::init()
{
reverse = QApplication::isRightToLeft();
KCommonDecoration::init();
recalcTitleBuffer();
}
void ModernSys::recalcTitleBuffer()
{
if(oldTitle == caption() && width() == titleBuffer.width())
return;
QFontMetrics fm(options()->font(true));
titleBuffer = QPixmap(width(), title_height+2);
QPainter p;
p.begin(&titleBuffer);
QPalette pt = options()->palette(ColorTitleBar, true);
pt.setCurrentColorGroup( QPalette::Active );
if(aUpperGradient)
p.drawTiledPixmap(0, 0, width(), title_height+2, *aUpperGradient);
else
p.fillRect(0, 0, width(), title_height+2,
pt.brush(QPalette::Button));
QRect t = titleRect(); // titlebar->geometry();
t.setTop( 2 );
t.setLeft( t.left() );
t.setRight( t.right() - 2 );
QRegion r(t.x(), 0, t.width(), title_height+2);
r -= QRect(t.x()+((t.width()-fm.width(caption()))/2)-4,
0, fm.width(caption())+8, title_height+2);
p.setClipRegion(r);
int i, ly;
ly = (title_height % 3 == 0) ? 3 : 4;
for(i=0; i < (title_height-2)/3; ++i, ly+=3){
p.setPen(options()->color(ColorTitleBar, true).light(150));
p.drawLine(0, ly, width()-1, ly);
p.setPen(options()->color(ColorTitleBar, true).dark(120));
p.drawLine(0, ly+1, width()-1, ly+1);
}
p.setClipRect(t);
p.setPen(options()->color(ColorFont, true));
p.setFont(options()->font(true));
p.drawText(t.x()+((t.width()-fm.width(caption()))/2)-4,
0, fm.width(caption())+8, title_height+2, Qt::AlignCenter, caption());
p.setClipping(false);
p.end();
oldTitle = caption();
}
void ModernSys::updateCaption()
{
widget()->update(titleRect() );
}
void ModernSys::drawRoundFrame(QPainter &p, int x, int y, int w, int h)
{
QPalette pt = options()->palette(ColorFrame, isActive());
pt.setCurrentColorGroup( QPalette::Active );
draw_button(p, x, y, w, h, pt);
}
void ModernSys::paintEvent( QPaintEvent* )
{
// update title buffer...
if (oldTitle != caption() || width() != titleBuffer.width() )
recalcTitleBuffer();
int hs = handle_size;
int hw = handle_width;
QPainter p( widget() );
QRect t = titleRect(); // titlebar->geometry();
QPalette pt = options()->palette(ColorFrame, isActive());
pt.setCurrentColorGroup( QPalette::Active );
QBrush fillBrush(!widget()->palette().brush(QPalette::Background).texture().isNull() ?
widget()->palette().brush(QPalette::Background) :
pt.brush(QPalette::Button));
p.fillRect(1, title_height+3, width()-2, height()-(title_height+3), 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
QPalette g = options()->palette(ColorTitleBar, isActive());
g.setCurrentColorGroup( QPalette::Active );
if(isActive()){
p.drawPixmap(1, 1, titleBuffer, 0, 0, w-2, title_height+2);
}
else{
if(iUpperGradient)
p.drawTiledPixmap(1, 1, w-2, title_height+2, *iUpperGradient);
else
p.fillRect(1, 1, w-2, title_height+2, fillBrush);
p.setPen(options()->color(ColorFont, isActive()));
p.setFont(options()->font(isActive()));
p.drawText(t, Qt::AlignCenter, caption() );
}
// titlebar highlight
p.setPen(g.light().color());
p.drawLine(1, 1, 1, title_height+3);
p.drawLine(1, 1, w-3, 1);
p.setPen(g.dark().color());
p.drawLine(w-2, 1, w-2, title_height+3);
p.drawLine(0, title_height+2, w-2, title_height+2);
// frame
g = options()->palette(ColorFrame, isActive());
g.setCurrentColorGroup(QPalette::Active);
p.setPen(g.light().color());
p.drawLine(1, title_height+3, 1, h-2);
p.setPen(g.dark().color());
p.drawLine(2, h-2, w-2, h-2);
p.drawLine(w-2, title_height+3, w-2, h-2);
//p.drawPoint(w-3, title_height+3);
//p.drawPoint(2, title_height+3);
qDrawShadePanel(&p, border_width-1, title_height+3, w-2*border_width+2, h-title_height-border_width-2, g, true);
if (show_handle) {
p.setPen(g.dark().color());
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().color());
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-1, h-1);
// 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-1, h-1);
}
}
void ModernSys::updateWindowShape()
{
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);
}
ModernSysFactory::ModernSysFactory()
{
read_config();
create_pixmaps();
}
ModernSysFactory::~ModernSysFactory()
{
ModernSystem::delete_pixmaps();
}
KDecoration* ModernSysFactory::createDecoration( KDecorationBridge* b )
{
return(new ModernSys(b, this))->decoration();
}
bool ModernSysFactory::reset( unsigned long changed )
{
read_config();
bool needHardReset = true;
if( changed & (SettingColors | SettingBorder | SettingFont) )
{
delete_pixmaps();
create_pixmaps();
}
if( ( changed & ~(SettingColors | SettingBorder | SettingFont | SettingButtons)) == 0 )
needHardReset = false;
if( needHardReset )
return true;
else
{
resetDecorations( changed );
return false; // no recreating of decorations
}
}
bool ModernSysFactory::supports( Ability ability ) const
{
switch( ability )
{
// announce
case AbilityAnnounceButtons:
case AbilityAnnounceColors:
// buttons
case AbilityButtonOnAllDesktops:
case AbilityButtonSpacer:
case AbilityButtonHelp:
case AbilityButtonMinimize:
case AbilityButtonMaximize:
case AbilityButtonClose:
case AbilityButtonAboveOthers:
case AbilityButtonBelowOthers:
case AbilityButtonShade:
case AbilityButtonMenu:
// colors
case AbilityColorTitleBack:
case AbilityColorTitleBlend:
case AbilityColorTitleFore:
return true;
default:
return false;
};
}
}
// KWin extended plugin interface
extern "C" KDE_EXPORT KDecorationFactory* create_factory()
{
return new ModernSystem::ModernSysFactory();
}
// vim:ts=4:sw=4

View File

@ -0,0 +1,89 @@
/*
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef __MODERNSYS_H
#define __MODERNSYS_H
#include <QBitmap>
#include <kcommondecoration.h>
#include <kdecorationfactory.h>
namespace ModernSystem {
class ModernSys;
class ModernButton : public KCommonDecorationButton
{
public:
ModernButton(ButtonType type, ModernSys *parent, const char *name);
void setBitmap(const unsigned char *bitmap);
virtual void reset(unsigned long changed);
protected:
void paintEvent(QPaintEvent *);
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
QBitmap deco;
};
class ModernSys : public KCommonDecoration
{
public:
ModernSys( KDecorationBridge* b, KDecorationFactory* f );
~ModernSys(){;}
virtual QString visibleName() const;
virtual QString defaultButtonsLeft() const;
virtual QString defaultButtonsRight() const;
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
virtual KCommonDecorationButton *createButton(ButtonType type);
virtual void updateWindowShape();
virtual void updateCaption();
void init();
protected:
void drawRoundFrame(QPainter &p, int x, int y, int w, int h);
void paintEvent( QPaintEvent* );
void recalcTitleBuffer();
void reset( unsigned long );
private:
QPixmap titleBuffer;
QString oldTitle;
bool reverse;
};
class ModernSysFactory : public QObject, public KDecorationFactory
{
Q_OBJECT
public:
ModernSysFactory();
virtual ~ModernSysFactory();
virtual KDecoration* createDecoration( KDecorationBridge* );
virtual bool reset( unsigned long changed );
virtual bool supports( Ability ability ) const;
QList< BorderSize > borderSizes() const;
private:
void read_config();
};
}
#endif // __MODERNSYS_H

View File

@ -0,0 +1,88 @@
[Desktop Entry]
Name=Modern System
Name[af]=Moderne Stelsel
Name[ar]=نظام عصري
Name[be]=Сучасная сістэма
Name[be@latin]=Sučasnaja systema
Name[bg]=Модерна система
Name[bn]=মডার্ন সিস্টেম
Name[bn_IN]=আধুনিক সিস্টেম
Name[br]=Reizhiad Nevez
Name[ca]=Sistema modern
Name[ca@valencia]=Sistema modern
Name[cs]=Moderní systém
Name[csb]=Mòdernô systema
Name[cy]=Cysawd Cyfoes
Name[da]=Moderne system
Name[de]=Modern System
Name[el]=Μοντέρνο σύστημα
Name[en_GB]=Modern System
Name[eo]=Moderna sistemo
Name[es]=Sistema moderno
Name[et]=Modern System
Name[eu]=Sistema modernoa
Name[fa]=سیستم نوین
Name[fi]=Moderni järjestelmä
Name[fr]=Système Moderne
Name[fy]=Modern systeem
Name[ga]=Córas Nua-Aimseartha
Name[gl]=Sistema moderno
Name[gu]=મોર્ડન સિસ્ટમ
Name[he]=מערכת מודרנית
Name[hi]=आधुनिक तंत्र
Name[hne]=आधुनिक तंत्र
Name[hr]=Suvremeni sustav
Name[hsb]=Moderny system
Name[hu]=Modern System
Name[ia]=Systema Moderne
Name[id]=Sistem Modern
Name[is]=Nútímalegt kerfi
Name[it]=Sistema moderno
Name[ja]=モダンシステム
Name[ka]=თანამედროვე სისტემა
Name[kk]=Заманауи жүйе
Name[km]=ប្រព័ន្ធ​ទំនើប
Name[kn]=ಆಧುನಿಕ ವ್ಯವಸ್ಥೆ
Name[ko]=모던 시스템
Name[ku]=Modern System
Name[lt]=Moderni sistema
Name[lv]=Moderna sistēma
Name[mai]=आधुनिक तंत्र
Name[mk]=Модерен систем
Name[ml]=മോഡേര്‍ണ്‍ സിസ്റ്റം
Name[mr]=आधुनिक प्रणाली
Name[ms]=Sistem Moden
Name[nb]=Moderne System
Name[nds]=Modeern Systeem
Name[ne]=आधुनिक प्रणाली
Name[nl]=Modern systeem
Name[nn]=Moderne System
Name[pa]=ਮਾਡਰਨ ਸਿਸਟਮ
Name[pl]=Nowoczesny system
Name[pt]=Sistema Moderno
Name[pt_BR]=Sistema moderno
Name[ro]=Sistem modern
Name[ru]=Современная система
Name[se]=Áigeguovdilis vuogádat
Name[si]=නවතම පද්ධති
Name[sk]=Moderný systém
Name[sl]=Moderni sistem
Name[sr]=Модеран систем
Name[sr@ijekavian]=Модеран систем
Name[sr@ijekavianlatin]=Moderan sistem
Name[sr@latin]=Moderan sistem
Name[sv]=Modernt system
Name[ta]=நவீன அமைப்பு
Name[te]=ఆధునిక సిస్టమ్
Name[tg]=Системаи ҳозира
Name[th]=รูปแบบระบบทันสมัย
Name[tr]=Modern Sistem
Name[uk]=Сучасна система
Name[uz]=Zamonaviy tizim
Name[uz@cyrillic]=Замонавий тизим
Name[vi]=Hệ thống Hiện đại
Name[wa]=Sistinme modiene
Name[x-test]=xxModern Systemxx
Name[zh_CN]=现代系统
Name[zh_TW]=現代系統
X-KDE-Library=kwin3_modernsys

View File

@ -0,0 +1,17 @@
add_subdirectory( config )
########### next target ###############
set(kwin3_quartz_PART_SRCS quartz.cpp )
kde4_add_plugin(kwin3_quartz ${kwin3_quartz_PART_SRCS})
target_link_libraries(kwin3_quartz kdecorations)
install(TARGETS kwin3_quartz DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES quartz.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/ )

View File

@ -0,0 +1,16 @@
########### next target ###############
set(kwin_quartz_config_PART_SRCS config.cpp )
kde4_add_plugin(kwin_quartz_config ${kwin_quartz_config_PART_SRCS})
target_link_libraries(kwin_quartz_config ${KDE4_KDEUI_LIBS} ${QT_QTGUI_LIBRARY})
install(TARGETS kwin_quartz_config DESTINATION ${PLUGIN_INSTALL_DIR} )

View File

@ -0,0 +1,120 @@
/********************************************************************
This file contains the quartz configuration widget
Copyright (c) 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "config.h"
#include <kglobal.h>
#include <kconfiggroup.h>
#include <klocale.h>
#include <kvbox.h>
extern "C"
{
KDE_EXPORT QObject* allocate_config( KConfig* conf, QWidget* parent )
{
return(new QuartzConfig(conf, parent));
}
}
/* NOTE:
* '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
*/
QuartzConfig::QuartzConfig( KConfig* conf, QWidget* parent )
: QObject( parent )
{
Q_UNUSED( conf );
quartzConfig = new KConfig("kwinquartzrc");
KConfigGroup cg(quartzConfig, "General");
KGlobal::locale()->insertCatalog("kwin_clients");
gb = new KVBox( parent );
cbColorBorder = new QCheckBox(
i18n("Draw window frames using &titlebar colors"), gb );
cbColorBorder->setWhatsThis(
i18n("When selected, the window decoration borders "
"are drawn using the titlebar colors; otherwise, they are "
"drawn using normal border colors instead.") );
cbExtraSmall = new QCheckBox( i18n("Quartz &extra slim"), gb );
cbExtraSmall->setWhatsThis(
i18n("Quartz window decorations with extra-small title bar.") );
// Load configuration options
load( cg );
// Ensure we track user changes properly
connect( cbColorBorder, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()) );
connect( cbExtraSmall, SIGNAL(clicked()), this, SLOT(slotSelectionChanged()) );
// Make the widgets visible in kwindecoration
gb->show();
}
QuartzConfig::~QuartzConfig()
{
delete gb;
delete quartzConfig;
}
void QuartzConfig::slotSelectionChanged()
{
emit changed();
}
// Loads the configurable options from the kwinrc config file
// It is passed the open config from kwindecoration to improve efficiency
void QuartzConfig::load( const KConfigGroup& /*conf*/ )
{
KConfigGroup cg(quartzConfig, "General");
bool override = cg.readEntry( "UseTitleBarBorderColors", true);
cbColorBorder->setChecked( override );
override = cg.readEntry( "UseQuartzExtraSlim", false);
cbExtraSmall->setChecked( override );
}
// Saves the configurable options to the kwinrc config file
void QuartzConfig::save( KConfigGroup& /*conf*/ )
{
KConfigGroup cg(quartzConfig, "General");
cg.writeEntry( "UseTitleBarBorderColors", cbColorBorder->isChecked() );
cg.writeEntry( "UseQuartzExtraSlim", cbExtraSmall->isChecked() );
// Ensure others trying to read this config get updated
quartzConfig->sync();
}
// Sets UI widget defaults which must correspond to style defaults
void QuartzConfig::defaults()
{
cbColorBorder->setChecked( true );
cbExtraSmall->setChecked( false );
}
#include "config.moc"
// vim: ts=4

View File

@ -0,0 +1,61 @@
/********************************************************************
This file contains the quartz configuration widget
Copyright (c) 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef __KDE_QUARTZCONFIG_H
#define __KDE_QUARTZCONFIG_H
#include <QCheckBox>
#include <kconfig.h>
#include <kvbox.h>
class QuartzConfig: public QObject
{
Q_OBJECT
public:
QuartzConfig( KConfig* conf, QWidget* parent );
~QuartzConfig();
// These public signals/slots work similar to KCM modules
signals:
void changed();
public slots:
void load( const KConfigGroup& conf );
void save( KConfigGroup& conf );
void defaults();
protected slots:
void slotSelectionChanged(); // Internal use
private:
KConfig* quartzConfig;
QCheckBox* cbColorBorder;
QCheckBox* cbExtraSmall;
KVBox* gb;
};
#endif
// vim: ts=4

849
clients/quartz/quartz.cpp Normal file
View File

@ -0,0 +1,849 @@
/********************************************************************
Gallium-Quartz KWin client
Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
Copyright 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
Based on the KDE default client.
Includes mini titlebars for ToolWindow Support.
Button positions are now customizable.
drawColorBitmaps originally from kdefx:
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include <kconfiggroup.h>
#include <kglobal.h>
#include <klocale.h>
#include <QBitmap>
#include <QImage>
#include <QPixmap>
#include <QApplication>
#include <QPaintEvent>
#include <QPainter>
#include "quartz.h"
namespace Quartz {
static const unsigned char iconify_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0xfc, 0x00, 0xfc, 0x00, 0x00, 0x00 };
static const unsigned char close_bits[] = {
0x00, 0x00, 0x86, 0x01, 0xcc, 0x00, 0x78, 0x00, 0x30, 0x00, 0x78, 0x00,
0xcc, 0x00, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00};
static const unsigned char maximize_bits[] = {
0xff, 0x01, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0xff, 0x01, 0x00, 0x00};
static const unsigned char minmax_bits[] = {
0xfc, 0x00, 0xfc, 0x00, 0x84, 0x00, 0xbf, 0x00, 0xbf, 0x00, 0xe1, 0x00,
0x21, 0x00, 0x21, 0x00, 0x3f, 0x00, 0x00, 0x00};
static const unsigned char question_bits[] = {
0x00, 0x00, 0x3c, 0x00, 0x66, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18, 0x00,
0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00};
static const 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 const 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 const 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 const 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 const 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 const 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 const unsigned char above_on_bits[] = {
0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0x30, 0x00, 0xfc, 0x00, 0x78, 0x00,
0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const unsigned char above_off_bits[] = {
0x30, 0x00, 0x78, 0x00, 0xfc, 0x00, 0x30, 0x00, 0xfe, 0x01, 0xfe, 0x01,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static const unsigned char below_on_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x00, 0x78, 0x00, 0xfc, 0x00,
0x30, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0x00, 0x00};
static const unsigned char below_off_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01,
0x30, 0x00, 0xfc, 0x00, 0x78, 0x00, 0x30, 0x00};
static const unsigned char shade_on_bits[] = {
0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0x02, 0x01, 0x02, 0x01,
0x02, 0x01, 0x02, 0x01, 0xfe, 0x01, 0x00, 0x00};
static const unsigned char shade_off_bits[] = {
0x00, 0x00, 0xfe, 0x01, 0xfe, 0x01, 0xfe, 0x01, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void drawColorBitmaps(QPainter *p, const QPalette &pal, int x, int y, int w, int h,
const uchar *lightColor, const uchar *midColor, const uchar *blackColor)
{
const uchar *data[]={lightColor, midColor, blackColor};
QColor colors[]={pal.color(QPalette::Light), pal.color(QPalette::Mid), Qt::black};
int i;
QSize s(w,h);
for(i=0; i < 3; ++i){
QBitmap b = QBitmap::fromData(s, data[i], QImage::Format_MonoLSB );
b.setMask(b);
p->setPen(colors[i]);
p->drawPixmap(x, y, b);
}
}
///////////////////////////////////////////////////////////////////////////
// Titlebar button positions
bool onAllDesktopsButtonOnLeft = true;
bool coloredFrame = true;
bool extraSlim = false;
QPixmap* titleBlocks = NULL;
QPixmap* ititleBlocks = NULL;
QPixmap* pinDownPix = NULL;
QPixmap* pinUpPix = NULL;
QPixmap* ipinDownPix = NULL;
QPixmap* ipinUpPix = NULL;
static int normalTitleHeight;
static int toolTitleHeight;
static int borderWidth;
bool quartz_initialized = false;
QuartzHandler* clientHandler;
///////////////////////////////////////////////////////////////////////////
QuartzHandler::QuartzHandler()
{
quartz_initialized = false;
readConfig();
createPixmaps();
quartz_initialized = true;
}
QuartzHandler::~QuartzHandler()
{
quartz_initialized = false;
freePixmaps();
}
KDecoration* QuartzHandler::createDecoration( KDecorationBridge* bridge )
{
return ( new QuartzClient( bridge, this ))->decoration();
}
bool QuartzHandler::reset(unsigned long changed)
{
quartz_initialized = false;
freePixmaps();
readConfig();
createPixmaps();
quartz_initialized = true;
// Do we need to "hit the wooden hammer" ?
bool needHardReset = true;
if ((changed & ~(SettingColors | SettingButtons)) == 0)
{
needHardReset = false;
}
if (needHardReset) {
return true;
} else {
resetDecorations(changed);
return false;
}
return true;
}
bool QuartzHandler::supports( Ability ability ) const
{
switch( ability )
{
// announce
case AbilityAnnounceButtons:
case AbilityAnnounceColors:
// buttons
case AbilityButtonMenu:
case AbilityButtonOnAllDesktops:
case AbilityButtonHelp:
case AbilityButtonMinimize:
case AbilityButtonMaximize:
case AbilityButtonClose:
case AbilityButtonAboveOthers:
case AbilityButtonBelowOthers:
case AbilityButtonShade:
case AbilityButtonSpacer:
// colors
case AbilityColorTitleBack:
case AbilityColorTitleBlend:
case AbilityColorTitleFore:
case AbilityColorButtonBack:
return true;
default:
return false;
};
}
void QuartzHandler::readConfig()
{
KConfig configFile("kwinquartzrc");
KConfigGroup conf( &configFile, "General");
coloredFrame = conf.readEntry( "UseTitleBarBorderColors", true);
extraSlim = conf.readEntry( "UseQuartzExtraSlim", false);
// A small hack to make the on all desktops button look nicer
onAllDesktopsButtonOnLeft = KDecoration::options()->titleButtonsLeft().contains( 'S' );
if ( QApplication::isRightToLeft() )
onAllDesktopsButtonOnLeft = !onAllDesktopsButtonOnLeft;
switch(options()->preferredBorderSize(this)) {
case BorderLarge:
borderWidth = 8;
break;
case BorderVeryLarge:
borderWidth = 12;
break;
case BorderHuge:
borderWidth = 18;
break;
case BorderVeryHuge:
borderWidth = 27;
break;
case BorderOversized:
borderWidth = 40;
break;
case BorderTiny:
case BorderNormal:
default:
borderWidth = extraSlim?2:4;
}
normalTitleHeight = QFontMetrics(options()->font(true)).height() - 2;
int nTH_limit=extraSlim?14:18;
normalTitleHeight = QFontMetrics(options()->font(true)).height()-(extraSlim?1:0);
if (normalTitleHeight < nTH_limit) normalTitleHeight = nTH_limit;
if (normalTitleHeight < borderWidth) normalTitleHeight = borderWidth;
toolTitleHeight = QFontMetrics(options()->font(true, true)).height() - 2;
if (toolTitleHeight < 12) toolTitleHeight = 12;
if (toolTitleHeight < borderWidth) toolTitleHeight = borderWidth;
}
// This does the colour transition magic. (You say "Oh, is that it?")
// This may be made configurable at a later stage
void QuartzHandler::drawBlocks( QPixmap *pi, QPixmap &p, const QColor &c1, const QColor &c2 )
{
// Draw a background gradient first
QPainter gp;
gp.begin(&p);
QLinearGradient grad(0, 0, p.width(), 0);
grad.setColorAt(0.0, c1);
grad.setColorAt(1.0, c2);
gp.setPen(Qt::NoPen);
gp.setBrush(grad);
gp.drawRect(p.rect());
gp.end();
QPainter px;
px.begin( pi );
int factor = (pi->height()-2)/4;
int square = factor - (factor+2)/4;
int x = pi->width() - 5*factor - square;
int y = (pi->height() - 4*factor)/2;
px.fillRect( x, y, square, square, c1.light(120) );
px.fillRect( x, y+factor, square, square, c1 );
px.fillRect( x, y+2*factor, square, square, c1.light(110) );
px.fillRect( x, y+3*factor, square, square, c1 );
px.fillRect( x+factor, y, square, square, c1.light(110) );
px.fillRect( x+factor, y+factor, square, square, c2.light(110) );
px.fillRect( x+factor, y+2*factor, square, square, c1.light(120) );
px.fillRect( x+factor, y+3*factor, square, square, c2.light(130) );
px.fillRect( x+2*factor, y+factor, square, square, c1.light(110) );
px.fillRect( x+2*factor, y+2*factor, square, square, c2.light(120) );
px.fillRect( x+2*factor, y+3*factor, square, square, c2.light(150) );
px.fillRect( x+3*factor, y, square, square, c1.dark(110) );
px.fillRect( x+3*factor, y+2*factor, square, square, c2.light(120) );
px.fillRect( x+3*factor, y+3*factor, square, square, c1.dark(120) );
px.fillRect( x+4*factor, y+factor, square, square, c1.light(110) );
px.fillRect( x+4*factor, y+3*factor, square, square, c1.dark(110) );
px.fillRect( x+5*factor, y+2*factor, square, square, c2.light(120));
px.fillRect( x+5*factor, y+3*factor, square, square, c2.light(110) );
}
// This paints the button pixmaps upon loading the style.
void QuartzHandler::createPixmaps()
{
// Obtain titlebar blend colours, and create the block stuff on pixmaps.
QPalette g2 = options()->palette(ColorTitleBlend, true);
g2.setCurrentColorGroup( QPalette::Active );
QColor c2 = g2.color( QPalette::Background );
g2 = options()->palette(ColorTitleBar, true );
g2.setCurrentColorGroup( QPalette::Active );
QColor c = g2.color(QPalette::Background).light(130);
titleBlocks = new QPixmap( normalTitleHeight*25/18, normalTitleHeight );
drawBlocks( titleBlocks, *titleBlocks, c, c2 );
g2 = options()->palette(ColorTitleBlend, false);
g2.setCurrentColorGroup( QPalette::Active );
c2 = g2.color( QPalette::Background );
g2 = options()->palette(ColorTitleBar, false );
g2.setCurrentColorGroup( QPalette::Active );
c = g2.color(QPalette::Background).light(130);
ititleBlocks = new QPixmap( normalTitleHeight*25/18, normalTitleHeight );
drawBlocks( ititleBlocks, *ititleBlocks, c, c2 );
// Set the on all desktops pin pixmaps;
QPalette g;
QPainter p;
g = options()->palette( onAllDesktopsButtonOnLeft ? ColorTitleBar : ColorTitleBlend, true );
g.setCurrentColorGroup( QPalette::Active );
c = onAllDesktopsButtonOnLeft ? g.color(QPalette::Background).light(130) : g.color(QPalette::Background);
g2 = options()->palette( ColorButtonBg, true );
g2.setCurrentColorGroup( QPalette::Active );
QImage pinImg = QImage(16, 16, QImage::Format_ARGB32_Premultiplied);
p.begin(&pinImg);
p.fillRect( 0, 0, 16, 16, c);
drawColorBitmaps( &p, g2, 0, 1, 16, 16, pinup_white_bits, pinup_gray_bits, pinup_dgray_bits );
p.end();
pinUpPix = new QPixmap(QPixmap::fromImage(pinImg));
p.begin(&pinImg);
p.fillRect( 0, 0, 16, 16, c);
drawColorBitmaps( &p, g2, 0, 1, 16, 16, pindown_white_bits, pindown_gray_bits, pindown_dgray_bits );
p.end();
pinDownPix = new QPixmap(QPixmap::fromImage(pinImg));
// Inactive pins
g = options()->palette( onAllDesktopsButtonOnLeft ? ColorTitleBar : ColorTitleBlend, false );
g.setCurrentColorGroup( QPalette::Active );
c = onAllDesktopsButtonOnLeft ? g.color(QPalette::Background).light(130) : g.color( QPalette::Background );
g2 = options()->palette( ColorButtonBg, false );
g2.setCurrentColorGroup( QPalette::Active );
p.begin(&pinImg);
p.fillRect( 0, 0, 16, 16, c);
drawColorBitmaps( &p, g2, 0, 1, 16, 16, pinup_white_bits, pinup_gray_bits, pinup_dgray_bits );
p.end();
ipinUpPix = new QPixmap(QPixmap::fromImage(pinImg));
p.begin(&pinImg);
p.fillRect( 0, 0, 16, 16, c);
drawColorBitmaps( &p, g2, 0, 1, 16, 16, pindown_white_bits, pindown_gray_bits, pindown_dgray_bits );
p.end();
ipinDownPix = new QPixmap(QPixmap::fromImage(pinImg));
}
void QuartzHandler::freePixmaps()
{
delete titleBlocks;
delete ititleBlocks;
// On all desktops pin images
delete pinUpPix;
delete ipinUpPix;
delete pinDownPix;
delete ipinDownPix;
}
QList< QuartzHandler::BorderSize > QuartzHandler::borderSizes() const
{ // the list must be sorted
return QList< BorderSize >() << BorderNormal << BorderLarge <<
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
}
QuartzButton::QuartzButton(ButtonType type, QuartzClient *parent, const char *name)
: KCommonDecorationButton(type, parent)
{
setObjectName( name );
// Eliminate any possible background flicker
setAttribute(Qt::WA_NoSystemBackground, false);
deco = 0;
}
QuartzButton::~QuartzButton()
{
delete deco;
}
void QuartzButton::reset(unsigned long changed)
{
if (changed&DecorationReset || changed&ManualReset || changed&SizeChange || changed&StateChange) {
switch (type() ) {
case CloseButton:
setBitmap(close_bits);
break;
case HelpButton:
setBitmap(question_bits);
break;
case MinButton:
setBitmap(iconify_bits);
break;
case MaxButton:
setBitmap( isChecked() ? minmax_bits : maximize_bits );
break;
case OnAllDesktopsButton:
setBitmap(0);
break;
case ShadeButton:
setBitmap( isChecked() ? shade_on_bits : shade_off_bits );
break;
case AboveButton:
setBitmap( isChecked() ? above_on_bits : above_off_bits );
break;
case BelowButton:
setBitmap( isChecked() ? below_on_bits : below_off_bits );
break;
default:
setBitmap(0);
break;
}
this->update();
}
}
void QuartzButton::setBitmap(const unsigned char *bitmap)
{
delete deco;
deco = 0;
if (bitmap) {
deco = new QBitmap(QBitmap::fromData(QSize(10, 10), bitmap));
deco->setMask( *deco );
repaint( );
}
}
void QuartzButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
drawButton(&p);
}
void QuartzButton::drawButton(QPainter *p)
{
// Never paint if the pixmaps have not been created
if (!quartz_initialized)
return;
QColor c;
if (isLeft() )
c = KDecoration::options()->color(KDecoration::ColorTitleBar, decoration()->isActive()).light(130);
else
c = KDecoration::options()->color(KDecoration::ColorTitleBlend, decoration()->isActive());
// Fill the button background with an appropriate color
p->fillRect(0, 0, width(), height(), c );
// If we have a decoration bitmap, then draw that
// otherwise we paint a menu button (with mini icon), or a onAllDesktops button.
if( deco )
{
int xOff = (width()-10)/2;
int yOff = (height()-10)/2;
QPainterPath path;
path.addRegion( *deco );
p->setPen( Qt::NoPen );
p->setBrush( Qt::black );
p->translate( isDown() ? QPoint( xOff+2, yOff+2 ) : QPoint( xOff+1, yOff+1 ) );
p->drawPath( path );
p->setBrush( KDecoration::options()->color(KDecoration::ColorButtonBg, decoration()->isActive()).light(150) );
p->translate( QPoint( -1, -1 ) );
p->drawPath( path );
} else
{
QPixmap btnpix;
int Offset = 0;
if (type() == OnAllDesktopsButton)
{
if (isDown())
Offset = 1;
// Select the right onAllDesktops button to paint
if (decoration()->isActive())
btnpix = isChecked() ? *pinDownPix : *pinUpPix;
else
btnpix = isChecked() ? *ipinDownPix : *ipinUpPix;
} else
btnpix = decoration()->icon().pixmap( QSize(10,10), QIcon::Normal);
// Shrink the miniIcon for tiny titlebars.
if ( height() < 16)
{
// Smooth scale the image
QPixmap tmpPix = btnpix.scaled(height(), height(), Qt::IgnoreAspectRatio,Qt::SmoothTransformation);
p->drawPixmap( 0, 0, tmpPix );
} else {
Offset += (height() - 16)/2;
p->drawPixmap( Offset, Offset, btnpix );
}
}
}
///////////////////////////////////////////////////////////////////////////
QuartzClient::QuartzClient(KDecorationBridge* bridge, KDecorationFactory* factory)
: KCommonDecoration (bridge, factory)
{
}
QString QuartzClient::visibleName() const
{
return i18n("Quartz");
}
QString QuartzClient::defaultButtonsLeft() const
{
return "M";
}
QString QuartzClient::defaultButtonsRight() const
{
return "HIA__X";
}
bool QuartzClient::decorationBehaviour(DecorationBehaviour behaviour) const
{
switch (behaviour) {
case DB_MenuClose:
return false;
case DB_WindowMask:
return false;
case DB_ButtonHide:
return true;
default:
return KCommonDecoration::decorationBehaviour(behaviour);
}
}
int QuartzClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
{
bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
switch (lm) {
case LM_BorderLeft:
case LM_BorderRight:
case LM_BorderBottom:
case LM_TitleEdgeLeft:
case LM_TitleEdgeRight:
{
if (respectWindowState && maximized) {
return 0;
} else {
return borderSize;
}
}
case LM_TitleEdgeTop:
return borderSize-1;
case LM_TitleEdgeBottom:
return 1;
case LM_TitleBorderLeft:
case LM_TitleBorderRight:
return 5;
case LM_TitleHeight:
return titleHeight;
case LM_ButtonWidth:
case LM_ButtonHeight:
return titleHeight-2;
case LM_ButtonSpacing:
return 1;
default:
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
}
}
KCommonDecorationButton *QuartzClient::createButton(ButtonType type)
{
switch (type) {
case MenuButton:
return new QuartzButton(MenuButton, this, "menu");
case OnAllDesktopsButton:
return new QuartzButton(OnAllDesktopsButton, this, "on_all_desktops");
case HelpButton:
return new QuartzButton(HelpButton, this, "help");
case MinButton:
return new QuartzButton(MinButton, this, "minimize");
case MaxButton:
return new QuartzButton(MaxButton, this, "maximize");
case CloseButton:
return new QuartzButton(CloseButton, this, "close");
case AboveButton:
return new QuartzButton(AboveButton, this, "above");
case BelowButton:
return new QuartzButton(BelowButton, this, "below");
case ShadeButton:
return new QuartzButton(ShadeButton, this, "shade");
default:
return 0;
}
}
void QuartzClient::init()
{
// Finally, toolWindows look small
if ( isToolWindow() ) {
titleHeight = toolTitleHeight;
largeButtons = false;
}
else {
titleHeight = normalTitleHeight;
largeButtons = true;
}
borderSize = borderWidth;
KCommonDecoration::init();
}
void QuartzClient::reset( unsigned long changed )
{
if (changed & SettingColors || changed & SettingFont)
{
// repaint the whole thing
widget()->repaint();
}
KCommonDecoration::reset(changed);
}
// Quartz Paint magic goes here.
void QuartzClient::paintEvent( QPaintEvent* )
{
// Never paint if the pixmaps have not been created
if (!quartz_initialized)
return;
const bool maxFull = (maximizeMode()==MaximizeFull) && !options()->moveResizeMaximizedWindows();
QPalette g;
QPainter p(widget());
// Obtain widget bounds.
QRect r(widget()->rect());
int x = r.x();
int y = r.y();
int x2 = r.width() - 1;
int y2 = r.height() - 1;
int w = r.width();
int h = r.height();
// Draw part of the frame that is the title color
if( coloredFrame )
g = options()->palette(ColorTitleBar, isActive());
else
g = options()->palette(ColorFrame, isActive());
g.setCurrentColorGroup( QPalette::Active );
// Draw outer highlights and lowlights
p.setPen( g.color(QPalette::Light).light(120) );
p.drawLine( x, y, x2-1, y );
p.drawLine( x, y+1, x, y2-1 );
p.setPen( g.color(QPalette::Dark).light(120) );
p.drawLine( x2, y, x2, y2 );
p.drawLine( x, y2, x2, y2 );
// Fill out the border edges
QColor frameColor;
if ( coloredFrame)
frameColor = g.color(QPalette::Background).light(130);
else
frameColor = g.color( QPalette::Background );
if (borderSize > 2) {
p.fillRect(x+1, y+1, w-2, borderSize-2, frameColor); // top
if (!maxFull) {
p.fillRect(x+1, y+h-(borderSize), w-2, borderSize-1, frameColor); // bottom
p.fillRect(x+1, y+borderSize-1, borderSize-1, h-2*(borderSize-1), frameColor); // left
p.fillRect(x+w-(borderSize), y+borderSize-1, borderSize-1, h-2*(borderSize-1), frameColor); // right
}
}
// Draw a frame around the wrapped widget.
p.setPen( g.color(QPalette::Background) );
if (maxFull) {
p.drawLine(x+1, y+titleHeight+(borderSize-1), w-2, y+titleHeight+(borderSize-1));
} else {
p.drawRect( x+(borderSize-1), y+titleHeight+(borderSize-1), w-2*(borderSize-1)-1, h-titleHeight-2*(borderSize-1)-1 );
}
// Drawing this extra line removes non-drawn areas when shaded
p.drawLine( x+borderSize, y2-borderSize, x2-borderSize, y2-borderSize);
// Highlight top corner
p.setPen( g.color(QPalette::Light).light(160) );
p.drawPoint( x, y );
p.setPen( g.color(QPalette::Light).light(140) );
p.drawPoint( x+1, y );
p.drawPoint( x, y+1 );
// Draw the title bar.
// ===================
int r_x, r_y, r_x2, r_y2;
widget()->rect().getCoords(&r_x, &r_y, &r_x2, &r_y2);
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
const int ttlHeight = layoutMetric(LM_TitleHeight);
const int titleEdgeBottomBottom = r_y+titleEdgeTop+ttlHeight+titleEdgeBottom-1;
r = QRect(r_x+titleEdgeLeft+buttonsLeftWidth(), r_y+titleEdgeTop,
r_x2-titleEdgeRight-buttonsRightWidth()-(r_x+titleEdgeLeft+buttonsLeftWidth()),
titleEdgeBottomBottom-(r_y+titleEdgeTop) );
// Obtain titlebar blend colours
QColor c1 = options()->color(ColorTitleBar, isActive() ).light(130);
QColor c2 = options()->color(ColorTitleBlend, isActive() );
// Create a disposable pixmap buffer for the titlebar
QPixmap* titleBuffer = new QPixmap( maxFull?w-2:(w-2*(borderSize-1)), titleHeight );
QPainter p2( titleBuffer );
// subtract titleBlocks pixmap width and some
int rightoffset = r.x()+r.width()-titleBlocks->width()-borderSize;
p2.fillRect( 0, 0, w, r.height(), c1 );
p2.fillRect( rightoffset, 0, maxFull?w-rightoffset:w-rightoffset-2*(borderSize-1), r.height(), c2 );
// 8 bit displays will be a bit dithered, but they still look ok.
if ( isActive() )
p2.drawPixmap( rightoffset, 0, *titleBlocks );
else
p2.drawPixmap( rightoffset, 0, *ititleBlocks );
// Draw the title text on the pixmap, and with a smaller font
// for toolwindows than the default.
QFont fnt;
if ( largeButtons ) {
fnt = options()->font(true, false); // font not small
} else {
fnt = options()->font(true, true); // font small
fnt.setWeight( QFont::Normal ); // and disable bold
}
p2.setFont( fnt );
p2.setPen( options()->color(ColorFont, isActive() ));
p2.drawText(r.x()+4-borderSize, 0, r.width()-3, r.height(),
Qt::AlignLeft | Qt::AlignVCenter, caption() );
p2.end();
p.drawPixmap( maxFull?1:borderSize-1, borderSize-1, *titleBuffer );
delete titleBuffer;
}
}
// Extended KWin plugin interface
/////////////////////////////////
extern "C"
{
KDE_EXPORT KDecorationFactory *create_factory()
{
Quartz::clientHandler = new Quartz::QuartzHandler();
return Quartz::clientHandler;
}
}
#include "quartz.moc"
// vim: ts=4
// kate: space-indent off; tab-width 4;

View File

@ -0,0 +1,89 @@
[Desktop Entry]
Name=Quartz
Name[af]=Quartz
Name[ar]=كوارتز
Name[be]=Quartz
Name[be@latin]=Quartz
Name[bg]=Кварц
Name[bn]=কোয়ার্ট্‌জ
Name[bn_IN]=Quartz (কোয়ার্টজ)
Name[br]=Quartz
Name[ca]=Quartz
Name[ca@valencia]=Quartz
Name[cs]=Quartz
Name[csb]=Kwarc
Name[cy]=Cwarts
Name[da]=Quartz
Name[de]=Quartz
Name[el]=Quartz
Name[en_GB]=Quartz
Name[eo]=Quartz
Name[es]=Cuarzo
Name[et]=Quartz
Name[eu]=Kuartzoa
Name[fa]=کوارتز
Name[fi]=Quartz
Name[fr]=Quartz
Name[fy]=Quartz
Name[ga]=Grianchloch
Name[gl]=Quartz
Name[gu]=ક્વાર્ટઝ
Name[he]=Quartz
Name[hi]=क्वार्ट्ज
Name[hne]=क्वार्ट्ज
Name[hr]=Kvarc
Name[hsb]=Quartz
Name[hu]=Quartz
Name[ia]=Quartz
Name[id]=Quartz
Name[is]=Kvartz
Name[it]=Quarzo
Name[ja]=Quartz
Name[ka]=კვარცი
Name[kk]=Кварц
Name[km]=Quartz
Name[kn]=ಕ್ವಾರ್ಟ್ಜ
Name[ko]=수정
Name[ku]=Quartz
Name[lt]=Quartz
Name[lv]=Quartz
Name[mai]=क्वार्ट्ज
Name[mk]=Кварц
Name[ml]=ക്വാര്‍ട്ട്സ്
Name[mr]=क्वार्ट्ज
Name[ms]=Quartz
Name[nb]=Quartz
Name[nds]=Quartz
Name[ne]=क्वार्ज
Name[nl]=Quartz
Name[nn]=Quartz
Name[pa]=Quartz
Name[pl]=Kwarc
Name[pt]=Quartz
Name[pt_BR]=Quartzo
Name[ro]=Cuarț
Name[ru]=Кварц
Name[se]=Quartz
Name[si]=Quartz
Name[sk]=Quartz
Name[sl]=Quartz
Name[sr]=Кварц
Name[sr@ijekavian]=Кварц
Name[sr@ijekavianlatin]=Kvarc
Name[sr@latin]=Kvarc
Name[sv]=Quartz
Name[ta]=குவார்ட்ஸ்
Name[te]=ఖ్వార్‍ట్జ్
Name[tg]=Квартс
Name[th]=รูปแบบควอทซ์
Name[tr]=Kuartz
Name[uk]=Кварц
Name[uz]=Chaqmoqtosh
Name[uz@cyrillic]=Чақмоқтош
Name[vi]=Thạch anh
Name[wa]=Blanc cayô
Name[xh]=Quartz
Name[x-test]=xxQuartzxx
Name[zh_CN]=Quartz
Name[zh_TW]=石英
X-KDE-Library=kwin3_quartz

105
clients/quartz/quartz.h Normal file
View File

@ -0,0 +1,105 @@
/********************************************************************
Gallium-Quartz KWin client
Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
Copyright 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
Based on the KDE default client.
Includes mini titlebars for ToolWindow Support.
Button positions are now customizable.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef __KDEGALLIUM_QUARTZ_H
#define __KDEGALLIUM_QUARTZ_H
#include <QBitmap>
#include "../../lib/kcommondecoration.h"
#include "../../lib/kdecorationfactory.h"
namespace Quartz {
class QuartzClient;
class QuartzHandler: public QObject, public KDecorationFactory
{
Q_OBJECT
public:
QuartzHandler();
~QuartzHandler();
virtual KDecoration* createDecoration( KDecorationBridge* );
virtual bool reset(unsigned long changed);
virtual bool supports( Ability ability ) const;
virtual QList< BorderSize > borderSizes() const;
private:
void readConfig();
void createPixmaps();
void freePixmaps();
void drawBlocks(QPixmap* pi, QPixmap &p, const QColor &c1, const QColor &c2);
};
class QuartzButton : public KCommonDecorationButton
{
public:
QuartzButton(ButtonType type, QuartzClient *parent, const char *name);
~QuartzButton();
void setBitmap(const unsigned char *bitmap);
void reset(unsigned long changed);
protected:
void paintEvent(QPaintEvent *);
void drawButton(QPainter *p);
QBitmap* deco;
};
class QuartzClient : public KCommonDecoration
{
public:
QuartzClient(KDecorationBridge* bridge, KDecorationFactory* factory);
~QuartzClient() {;}
virtual QString visibleName() const;
virtual QString defaultButtonsLeft() const;
virtual QString defaultButtonsRight() const;
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
virtual KCommonDecorationButton *createButton(ButtonType type);
virtual void init();
protected:
virtual void reset( unsigned long changed );
void paintEvent( QPaintEvent* );
private:
int titleHeight, borderSize;
bool largeButtons;
};
}
#endif
// vim: ts=4
// kate: space-indent off; tab-width 4;

View File

@ -0,0 +1,11 @@
set(kwin3_redmond_PART_SRCS redmond.cpp)
kde4_add_plugin(kwin3_redmond ${kwin3_redmond_PART_SRCS})
target_link_libraries(kwin3_redmond kdecorations)
install(TARGETS kwin3_redmond DESTINATION ${PLUGIN_INSTALL_DIR})
########### install files ###############
install( FILES redmond.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin )

711
clients/redmond/redmond.cpp Normal file
View File

@ -0,0 +1,711 @@
/********************************************************************
Redmond KWin client
Copyright 2001
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
Based on the default KWin client.
Updated to support toolwindows 3/2001 (KS)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "redmond.h"
#include <QtGui/qdrawutil.h>
#include <QDateTime>
//Added by qt3to4:
#include <QPixmap>
#include <QPaintEvent>
#include <klocale.h>
#include <QBitmap>
#include <QImage>
#include <QApplication>
#include <QPainter>
namespace Redmond {
static const char * const kdelogo[] = {
/* columns rows colors chars-per-pixel */
"16 16 8 1",
" c None",
". c #000000",
"+ c #A0A0A4",
"@ c #FFFFFF",
"# c #585858",
"$ c #C0C0C0",
"% c #808080",
"& c #DCDCDC",
" ",
" .. .. ",
" .+@. .@#. ",
" .@@@. .@@@# ",
" .@@@..$@@$. ",
" .@@@.@@@$. ",
" .@@@%@@$. ",
" .@@@&@@. ",
" .@@@@@@. ",
" .@@@$@@&. ",
" .@@@.@@@. ",
" .@@@.+@@@. ",
" .@@@..$@@&. ",
" .@@%. .@@@. ",
" .... ... ",
" "};
static unsigned char iconify_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x7e, 0x00, 0x7e, 0x00, 0x00, 0x00};
static unsigned char close_bits[] = {
0x00, 0x00, 0x86, 0x01, 0xcc, 0x00, 0x78, 0x00, 0x30, 0x00, 0x78, 0x00,
0xcc, 0x00, 0x86, 0x01, 0x00, 0x00, 0x00, 0x00};
static unsigned char maximize_bits[] = {
0xff, 0x01, 0xff, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
0x01, 0x01, 0x01, 0x01, 0xff, 0x01, 0x00, 0x00};
static unsigned char minmax_bits[] = {
0xfc, 0x00, 0xfc, 0x00, 0x84, 0x00, 0xbf, 0x00, 0xbf, 0x00, 0xe1, 0x00,
0x21, 0x00, 0x21, 0x00, 0x3f, 0x00, 0x00, 0x00};
static unsigned char question_bits[] = {
0x00, 0x00, 0x3c, 0x00, 0x66, 0x00, 0x60, 0x00, 0x30, 0x00, 0x18, 0x00,
0x00, 0x00, 0x18, 0x00, 0x18, 0x00, 0x00, 0x00};
// Up / Down titlebar button images
static QPixmap *btnPix1;
static QPixmap *iBtnPix1;
static QPixmap *btnDownPix1;
static QPixmap *iBtnDownPix1;
static QPixmap *miniBtnPix1;
static QPixmap *iMiniBtnPix1;
static QPixmap *miniBtnDownPix1;
static QPixmap *iMiniBtnDownPix1;
static QPixmap *defaultMenuPix;
static QColor *btnForeground;
static bool pixmaps_created = false;
static int toolTitleHeight;
static int normalTitleHeight;
static int borderWidth;
static inline const KDecorationOptions *options()
{
return KDecoration::options();
}
static void drawButtonFrame( QPixmap *pix, const QPalette &g, bool sunken )
{
QPainter p;
int x2 = pix->width() - 3;
int y2 = pix->height() - 3;
p.begin(pix);
// titlebar button frame
p.setPen( sunken ? g.color(QPalette::Dark).dark(155) : g.color(QPalette::Light));
p.drawLine(0, 0, x2, 0);
p.drawLine(0, 0, 0, y2);
if (sunken)
{
p.setPen( g.color(QPalette::Mid).dark(135) );
p.drawLine(1, 1, x2-1, 1);
p.drawLine(1, 1, 1, y2-1);
}
p.setPen( sunken ? g.color(QPalette::Light) : g.color(QPalette::Mid).dark(135));
p.drawLine(1, y2-1, x2-1, y2-1);
p.drawLine(x2-1, 1, x2-1, y2-1);
p.setPen( sunken ? g.color(QPalette::Light) : g.color(QPalette::Dark).dark(155));
p.drawLine(0, y2, x2, y2);
p.drawLine(x2, 0, x2, y2);
}
static void gradientFill(QPixmap *pixmap,
const QColor &color1, const QColor &color2, bool horizontal = false)
{
QPainter p(pixmap);
QLinearGradient gradient(0, 0,
horizontal ? pixmap->width() : 0,
horizontal ? 0 : pixmap->height());
gradient.setColorAt(0.0, color1);
gradient.setColorAt(1.0, color2);
QBrush brush(gradient);
p.fillRect(pixmap->rect(), brush);
}
static void create_pixmaps ()
{
if (pixmaps_created)
return;
pixmaps_created = true;
bool highcolor = QPixmap::defaultDepth() > 8;
btnPix1 = new QPixmap;
btnDownPix1 = new QPixmap;
iBtnPix1 = new QPixmap;
iBtnDownPix1 = new QPixmap;
miniBtnPix1 = new QPixmap;
miniBtnDownPix1 = new QPixmap;
iMiniBtnPix1 = new QPixmap;
iMiniBtnDownPix1 = new QPixmap;
defaultMenuPix = new QPixmap(kdelogo);
// buttons (active/inactive, sunken/unsunken)
QPalette g = options()->palette(KDecoration::ColorButtonBg, true);
QColor c = g.button().color();
*btnPix1 = QPixmap(normalTitleHeight, normalTitleHeight-2);
*btnDownPix1 = QPixmap(normalTitleHeight, normalTitleHeight-2);
*iBtnPix1 = QPixmap(normalTitleHeight, normalTitleHeight-2);
*iBtnDownPix1 = QPixmap(normalTitleHeight, normalTitleHeight-2);
*miniBtnPix1 = QPixmap(toolTitleHeight, toolTitleHeight);
*miniBtnDownPix1 = QPixmap(toolTitleHeight, toolTitleHeight);
*iMiniBtnPix1 = QPixmap(toolTitleHeight, toolTitleHeight);
*iMiniBtnDownPix1 = QPixmap(toolTitleHeight, toolTitleHeight);
if (highcolor && false) {
gradientFill(btnPix1, c.light(130), c.dark(130));
gradientFill(btnDownPix1, c.dark(130), c.light(130));
gradientFill(miniBtnPix1, c.light(130), c.dark(130));
gradientFill(miniBtnDownPix1, c.dark(130), c.light(130));
g = options()->palette(KDecoration::ColorButtonBg, false);
c = g.button().color();
gradientFill(iBtnPix1, c.light(130), c.dark(130));
gradientFill(iBtnDownPix1, c.dark(130), c.light(130));
gradientFill(iMiniBtnPix1, c.light(130), c.dark(130));
gradientFill(iMiniBtnDownPix1, c.dark(130), c.light(130));
} else {
btnPix1->fill(c.rgb());
btnDownPix1->fill(c.rgb());
miniBtnPix1->fill(c.rgb());
miniBtnDownPix1->fill(c.rgb());
g = options()->palette(KDecoration::ColorButtonBg, false);
c = g.button().color();
iBtnPix1->fill(c.rgb());
iBtnDownPix1->fill(c.rgb());
iMiniBtnPix1->fill(c.rgb());
iMiniBtnDownPix1->fill(c.rgb());
}
g = options()->palette(KDecoration::ColorButtonBg, true);
drawButtonFrame(btnPix1, g, false);
drawButtonFrame(btnDownPix1, g, true);
drawButtonFrame(miniBtnPix1, g, false);
drawButtonFrame(miniBtnDownPix1, g, true);
g = options()->palette(KDecoration::ColorButtonBg, false);
drawButtonFrame(iBtnPix1, g, false);
drawButtonFrame(iBtnDownPix1, g, true);
drawButtonFrame(iMiniBtnPix1, g, false);
drawButtonFrame(iMiniBtnDownPix1, g, true);
// Make sure button pixmaps contrast with the current colour scheme.
if (qGray(options()->color(KDecoration::ColorButtonBg, true).rgb()) > 127)
btnForeground = new QColor(Qt::black);
else
btnForeground = new QColor(Qt::white);
}
void delete_pixmaps()
{
delete btnPix1;
delete btnDownPix1;
delete iBtnPix1;
delete iBtnDownPix1;
delete miniBtnPix1;
delete miniBtnDownPix1;
delete iMiniBtnPix1;
delete iMiniBtnDownPix1;
delete defaultMenuPix;
delete btnForeground;
pixmaps_created = false;
}
RedmondButton::RedmondButton(ButtonType type, RedmondDeco *parent)
: KCommonDecorationButton(type, parent)
{
// Eliminate background flicker
setAttribute(Qt::WA_NoSystemBackground, true);
miniBtn = decoration()->isToolWindow();
}
void RedmondButton::reset(unsigned long changed)
{
if (changed&DecorationReset || changed&ManualReset || changed&SizeChange || changed&StateChange) {
switch (type() ) {
case CloseButton:
setBitmap(close_bits);
break;
case HelpButton:
setBitmap(question_bits);
break;
case MinButton:
setBitmap(iconify_bits);
break;
case MaxButton:
setBitmap( isChecked() ? minmax_bits : maximize_bits );
break;
case MenuButton:
{
QPixmap miniIcon = decoration()->icon().pixmap(QSize(16, 16), QIcon::Normal, QIcon::On);
if (!miniIcon.isNull()) {
setPixmap(miniIcon);
} else {
setPixmap(*defaultMenuPix);
}
break;
}
default:
setBitmap(0);
break;
}
this->update();
}
}
void RedmondButton::setBitmap(const unsigned char *bitmap)
{
pix = QPixmap();
if (bitmap)
deco = QBitmap::fromData( QSize(10, 10), bitmap);
else {
deco = QBitmap(10,10);
deco.fill(Qt::color0);
}
deco.setMask(deco);
}
void RedmondButton::setPixmap( const QPixmap &p )
{
deco = QPixmap();
pix = p;
repaint();
}
void RedmondButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
drawButton(&p);
}
void RedmondButton::drawButton(QPainter *p)
{
if ( pix.isNull() ) {
if ( decoration()->isActive() ) {
if ( isDown() )
p->drawPixmap(0, 0, miniBtn ? *miniBtnDownPix1 : *btnDownPix1);
else
p->drawPixmap(0, 0, miniBtn ? *miniBtnPix1 : *btnPix1);
} else {
if ( isDown() )
p->drawPixmap(0, 0, miniBtn ? *iMiniBtnDownPix1 : *iBtnDownPix1);
else
p->drawPixmap(0, 0, miniBtn ? *iMiniBtnPix1 : *iBtnPix1);
}
QPainterPath path;
path.addRegion( deco );
p->setPen( Qt::NoPen );
p->setBrush( *btnForeground );
QPoint offset( ( width() - 10 )/2, ( height() - 10 )/2 );
if( isDown() ) offset += QPoint( 1, 1 );
p->translate( offset );
p->drawPath( path );
} else {
if (isLeft() ) {
p->fillRect(0, 0, width(), height(),
options()->color(KDecoration::ColorTitleBar, decoration()->isActive()));
} else {
p->fillRect(0, 0, width(), height(),
options()->color(KDecoration::ColorTitleBlend, decoration()->isActive()));
}
if ( type()==MenuButton && height() < 16) {
// Smooth scale the menu button pixmap
QPixmap tmpPix = QPixmap::fromImage(
pix.toImage().scaled( height(), height(), Qt::IgnoreAspectRatio, Qt::SmoothTransformation ));
p->drawPixmap( 0, 0, tmpPix );
} else {
int xOff = (width() -pix.width() )/2;
int yOff = (height()-pix.height())/2;
p->drawPixmap(xOff, yOff, pix );
}
}
}
RedmondDeco::RedmondDeco(KDecorationBridge *b, KDecorationFactory *f)
: KCommonDecoration(b, f)
{
}
QString RedmondDeco::visibleName() const
{
return i18n("Redmond");
}
QString RedmondDeco::defaultButtonsLeft() const
{
return "M";
}
QString RedmondDeco::defaultButtonsRight() const
{
return "HIA_X";
}
bool RedmondDeco::decorationBehaviour(DecorationBehaviour behaviour) const
{
switch (behaviour) {
case DB_MenuClose:
return true;
case DB_WindowMask:
return false;
case DB_ButtonHide:
return true;
default:
return KCommonDecoration::decorationBehaviour(behaviour);
}
}
int RedmondDeco::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
{
bool border = !(maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows());
switch (lm) {
case LM_BorderLeft:
case LM_BorderRight:
case LM_BorderBottom:
return border ? borderWidth : 0;
case LM_TitleEdgeLeft:
case LM_TitleEdgeRight:
return border ? borderWidth+2 : 0;
case LM_TitleEdgeTop:
return border ? borderWidth+2 : 0;
case LM_TitleEdgeBottom:
return border ? 1 : 0;
case LM_TitleBorderLeft:
case LM_TitleBorderRight:
return border ? 1 : 0;
case LM_TitleHeight:
return titleHeight-2;
case LM_ButtonWidth:
return titleHeight-2;
case LM_ButtonHeight:
if (isToolWindow() || (btn && btn->type()==MenuButton) ) {
return titleHeight-2;
} else {
return titleHeight-2-2;
}
case LM_ButtonSpacing:
return 0;
default:
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
}
}
KCommonDecorationButton *RedmondDeco::createButton(ButtonType type)
{
switch (type) {
case MenuButton:
return new RedmondButton(MenuButton, this);
case HelpButton:
return new RedmondButton(HelpButton, this);
case MinButton:
return new RedmondButton(MinButton, this);
case MaxButton:
return new RedmondButton(MaxButton, this);
case CloseButton:
return new RedmondButton(CloseButton, this);
default:
return 0;
}
}
void RedmondDeco::init()
{
// Finally, toolwindows look small
if ( isToolWindow() ) {
titleHeight = toolTitleHeight;
} else {
titleHeight = normalTitleHeight;
}
KCommonDecoration::init();
}
void RedmondDeco::reset( unsigned long changed )
{
KCommonDecoration::reset(changed);
}
void RedmondDeco::paintEvent( QPaintEvent* )
{
bool hicolor = QPixmap::defaultDepth() > 8;
int fontoffset = 1;
// Modify borderWith used by titlebar to 0, when maximized and not move or resize able
bool border = !(maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows());
int modBorderWidth = border ? borderWidth : 0;
QPainter p(widget());
// Obtain widget bounds.
QRect r(widget()->rect());
int x = r.x();
int y = r.y();
int x2 = r.width()-1;
int y2 = r.height()-1;
int w = r.width();
//int h = r.height();
// Draw part of the frame that is the frame color
// ==============================================
QPalette g = options()->palette(KDecoration::ColorFrame, isActive());
g.setCurrentColorGroup( QPalette::Active );
p.setPen( g.background().color() );
p.drawLine( x, y, x2-1, y );
p.drawLine( x, y, x, y2-1 );
// Draw line under title bar
p.drawLine( x+borderWidth, y+titleHeight+borderWidth, x2-borderWidth, y+titleHeight+borderWidth );
// Draw a hidden line that appears during shading
p.drawLine( x+borderWidth, y2-borderWidth, x2-borderWidth, y2-borderWidth );
// Fill out the border edges
for (int i = 1; i < borderWidth; i++)
p.drawRect( x+i, y+i, x2-2*i, y2-2*i );
// Draw highlights and lowlights
p.setPen(g.color( QPalette::Light ));
for (int i = 1; i <= borderWidth/3; i++) {
p.drawLine( x+i, y+i, x2-i-1, y+i);
p.drawLine( x+i, y+i, x+i, y2-i-1);
}
p.setPen(g.color(QPalette::Dark).dark(135));
for (int i = 1; i <= borderWidth/3; i++) {
p.drawLine( x2-i, y+i+1, x2-i, y2-i);
p.drawLine( x+i+1, y2-i, x2-i, y2-i);
}
// Draw black edges
p.setPen( g.color(QPalette::Dark).dark(155) );
p.drawLine(x2, y, x2, y2);
p.drawLine(x, y2, x2, y2);
// Draw the title bar.
// ===================
r = titleRect();
// QFontMetrics fm(options()->font(true));
// Obtain blend colours.
QColor c1 = options()->color(KDecoration::ColorTitleBar, isActive() );
QColor c2 = options()->color(KDecoration::ColorTitleBlend, isActive() );
QFont fnt = options()->font(true, isToolWindow() );
if (isToolWindow() ) {
fnt.setWeight( QFont::Normal );
fontoffset = 0;
}
// Paint without a buffer if the colours are the same to
// improve performance, and only draw gradients on hicolor displays.
if ((c1 != c2) && hicolor) {
// KS - Add gradient caching if needed at a later stage.
// Create a disposable pixmap buffer for the title blend
QPixmap* titleBuffer = new QPixmap;
*titleBuffer = QPixmap(w-2*modBorderWidth, titleHeight);
if (titleBuffer->depth() > 16) {
gradientFill(titleBuffer, c1, c2, true);
}
QPainter p2( titleBuffer );
// Since drawing the gradient is (relatively) slow, it is best
// to draw the title text on the pixmap.
p2.setFont( fnt );
p2.setPen( options()->color(KDecoration::ColorFont, isActive() ));
p2.drawText( r.x(), fontoffset, r.width()-3, r.height()-1,
Qt::AlignLeft | Qt::AlignVCenter, caption() );
p2.end();
p.drawPixmap( modBorderWidth, modBorderWidth, *titleBuffer );
delete titleBuffer;
} else {
// Assume lower ended hardware, so don't use buffers.
// Don't draw a gradient either.
p.fillRect( modBorderWidth, modBorderWidth, w-2*modBorderWidth, titleHeight, c1 );
// Draw the title text.
p.setFont( fnt );
p.setPen(options()->color(KDecoration::ColorFont, isActive() ));
p.drawText(r.x()+4, r.y()+fontoffset-2, r.width()-3, r.height()-1,
Qt::AlignLeft | Qt::AlignVCenter, caption() );
}
}
void RedmondDecoFactory::readConfig() {
normalTitleHeight = QFontMetrics(options()->font(true)).height();
QFont toolFont = options()->font(true, true);
toolFont.setWeight(QFont::Normal);
toolTitleHeight = QFontMetrics(toolFont).height();
switch(options()->preferredBorderSize(this)) {
case BorderLarge:
borderWidth = 8;
if (normalTitleHeight < 20) normalTitleHeight = 20;
if (toolTitleHeight < 20) toolTitleHeight = 20;
break;
case BorderVeryLarge:
borderWidth = 12;
if (normalTitleHeight < 24) normalTitleHeight = 24;
if (toolTitleHeight < 24) toolTitleHeight = 24;
break;
case BorderHuge:
borderWidth = 18;
if (normalTitleHeight < 28) normalTitleHeight = 28;
if (toolTitleHeight < 28) toolTitleHeight = 28;
break;
case BorderVeryHuge:
borderWidth = 27;
if (normalTitleHeight < 33) normalTitleHeight = 33;
if (toolTitleHeight < 33) toolTitleHeight = 33;
break;
case BorderOversized:
borderWidth = 40;
if (normalTitleHeight < 40) normalTitleHeight = 40;
if (toolTitleHeight < 40) toolTitleHeight = 40;
break;
case BorderTiny:
case BorderNormal:
default:
borderWidth = 4;
if (normalTitleHeight < 16) normalTitleHeight = 16;
if (toolTitleHeight < 16) toolTitleHeight = 16;
}
}
RedmondDecoFactory::RedmondDecoFactory()
{
readConfig();
create_pixmaps();
}
RedmondDecoFactory::~RedmondDecoFactory()
{
Redmond::delete_pixmaps();
}
KDecoration *RedmondDecoFactory::createDecoration( KDecorationBridge *b )
{
return (new RedmondDeco(b, this))->decoration();
}
bool RedmondDecoFactory::reset( unsigned long changed )
{
// SettingButtons is handled by KCommonDecoration
if ( changed & ( SettingFont | SettingBorder | SettingColors | SettingButtons ) ) {
delete_pixmaps();
readConfig();
create_pixmaps();
resetDecorations(changed);
return true;
} else {
resetDecorations(changed);
return false;
}
}
bool RedmondDecoFactory::supports( Ability ability ) const
{
switch( ability )
{
// announce
case AbilityAnnounceButtons:
case AbilityAnnounceColors:
// buttons
case AbilityButtonMenu:
case AbilityButtonHelp:
case AbilityButtonMinimize:
case AbilityButtonMaximize:
case AbilityButtonClose:
case AbilityButtonSpacer:
// colors
case AbilityColorTitleBack:
case AbilityColorTitleBlend:
case AbilityColorTitleFore:
return true;
default:
return false;
}
}
QList< RedmondDecoFactory::BorderSize > RedmondDecoFactory::borderSizes() const
{ // the list must be sorted
return QList< BorderSize >() << BorderNormal << BorderLarge <<
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
}
}
extern "C" KDE_EXPORT KDecorationFactory *create_factory()
{
return new Redmond::RedmondDecoFactory();
}
#include "redmond.moc"
// vim: ts=4 sw=4
// kate: space-indent off; tab-width 4;

View File

@ -0,0 +1,90 @@
[Desktop Entry]
Name=Redmond
Name[af]=Redmond
Name[ar]=ريدموند
Name[be]=Redmond
Name[be@latin]=Redmond
Name[bg]=Редмънд
Name[bn]=রেডমন্ড
Name[bn_IN]=Redmond (রেডমন্ড)
Name[br]=Redmond
Name[ca]=Redmond
Name[ca@valencia]=Redmond
Name[cs]=Redmond
Name[csb]=Redmond
Name[cy]=Redmond
Name[da]=Redmond
Name[de]=Redmond
Name[el]=Redmond
Name[en_GB]=Redmond
Name[eo]=Redmondo
Name[es]=Redmond
Name[et]=Redmond
Name[eu]=Redmond
Name[fa]=ردموند
Name[fi]=Redmond
Name[fr]=Redmond
Name[fy]=Redmond
Name[ga]=Redmond
Name[gl]=Redmond
Name[gu]=રેડમન્ડ
Name[he]=Redmond
Name[hi]=रेडमण्ड
Name[hne]=रेडमन्ड
Name[hr]=Redmond
Name[hsb]=Redmond
Name[hu]=Redmond
Name[ia]=Redmond
Name[id]=Redmond
Name[is]=Redmond
Name[it]=Redmond
Name[ja]=Redmond
Name[ka]=რედმონდი
Name[kk]=Redmond
Name[km]=Redmond
Name[kn]=ರೆಡ್ಮಂಡ್
Name[ko]=레드몬드
Name[ku]=Redmond
Name[lt]=Redmond
Name[lv]=Redmond
Name[mai]=रेडमंड
Name[mk]=Редмонд
Name[ml]=റെഡ്മണ്ട്
Name[mr]=रेडमंड
Name[ms]=Redmond
Name[nb]=Redmond
Name[nds]=Redmond
Name[ne]=रेडमोन्ड
Name[nl]=Redmond
Name[nn]=Redmond
Name[oc]=Redmond
Name[pa]=ਰੀਡਮੋਂਡ
Name[pl]=Redmond
Name[pt]=Redmond
Name[pt_BR]=Redmond
Name[ro]=Redmond
Name[ru]=Редмонд
Name[se]=Redmond
Name[si]=Redmond
Name[sk]=Redmond
Name[sl]=Redmond
Name[sr]=Редмонд
Name[sr@ijekavian]=Редмонд
Name[sr@ijekavianlatin]=Redmond
Name[sr@latin]=Redmond
Name[sv]=Redmond
Name[ta]=ரெட்மான்ட்
Name[te]=రెడ్‌మాండ్
Name[tg]=Редмонд
Name[th]=รูปแบบเรดมอนด์
Name[tr]=Redmond
Name[uk]=Редмонд
Name[uz]=Redmond
Name[uz@cyrillic]=Редмонд
Name[vi]=Redmond
Name[wa]=Redmond
Name[xh]=Redmond
Name[x-test]=xxRedmondxx
Name[zh_CN]=Redmond
Name[zh_TW]=Redmond
X-KDE-Library=kwin3_redmond

103
clients/redmond/redmond.h Normal file
View File

@ -0,0 +1,103 @@
/********************************************************************
Redmond KWin client
Copyright 2001-2003
Ported to kwin_iii by Chris Lee <clee@kde.org>
Karol Szwed <gallium@kde.org>
http://gallium.n3.net/
Based on the default KWin client.
Updated to support the new API 9/2003 (CL)
Updated to emulate More Accurately 9/2003 (CL)
Updated to support toolwindows 3/2001 (KS)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef __KDE_REDMOND_H
#define __KDE_REDMOND_H
#include <QBitmap>
#include <kcommondecoration.h>
#include <kdecorationfactory.h>
namespace Redmond {
class RedmondDeco;
class RedmondButton : public KCommonDecorationButton
{
Q_OBJECT
public:
RedmondButton(ButtonType type, RedmondDeco *parent);
void setBitmap(const unsigned char *bitmap);
void setPixmap(const QPixmap &p);
void reset(unsigned long changed);
protected:
void paintEvent(QPaintEvent *);
virtual void drawButton(QPainter *p);
void drawButtonLabel(QPainter *){;}
QBitmap deco;
QPixmap pix;
bool miniBtn;
};
class RedmondDeco : public KCommonDecoration
{
public:
RedmondDeco(KDecorationBridge *, KDecorationFactory *);
~RedmondDeco() {;}
virtual QString visibleName() const;
virtual QString defaultButtonsLeft() const;
virtual QString defaultButtonsRight() const;
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
virtual KCommonDecorationButton *createButton(ButtonType type);
void init();
protected:
virtual void reset( unsigned long changed );
void paintEvent(QPaintEvent*);
private:
int titleHeight;
};
class RedmondDecoFactory : public QObject, public KDecorationFactory
{
Q_OBJECT
public:
RedmondDecoFactory();
virtual ~RedmondDecoFactory();
virtual KDecoration *createDecoration(KDecorationBridge *);
virtual bool reset(unsigned long);
virtual bool supports( Ability ability ) const;
virtual QList< BorderSize > borderSizes() const;
private:
void readConfig();
};
}
#endif
// vim: ts=4
// kate: space-indent off; tab-width 4;

View File

@ -0,0 +1,21 @@
########### next target ###############
set(kwin3_test_PART_SRCS test.cpp )
kde4_add_plugin(kwin3_test ${kwin3_test_PART_SRCS})
target_link_libraries(kwin3_test ${KDE4_KDEUI_LIBS} kdecorations )
install(TARGETS kwin3_test DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES test.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin )

361
clients/test/test.cpp Normal file
View File

@ -0,0 +1,361 @@
/********************************************************************
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#include "test.h"
#include <kglobal.h>
#include <kdebug.h>
namespace KWinTest
{
Decoration::Decoration( KDecorationBridge* bridge, KDecorationFactory* factory )
: KDecoration( bridge, factory ),
button( NULL )
{
}
void Decoration::init()
{
createMainWidget();
widget()->setEraseColor( red );
widget()->installEventFilter( this );
if( isCloseable())
{
button = new QPushButton( widget());
button->show();
button->setCursor( arrowCursor );
button->move( 0, 0 );
connect( button, SIGNAL( clicked()), SLOT( closeWindow()));
button->setToolTip( "Zelva Mana" );
}
}
Decoration::MousePosition Decoration::mousePosition( const QPoint& p ) const
{
const int range = 16;
const int border = 4;
MousePosition m = Nowhere;
int width = widget()->width();
int height = widget()->height();
if ( ( p.x() > border && p.x() < width - border )
&& ( p.y() > border && p.y() < height - border ) )
return Center;
if ( p.y() <= range && p.x() <= range)
m = TopLeft2;
else if ( p.y() >= height-range && p.x() >= width-range)
m = BottomRight2;
else if ( p.y() >= height-range && p.x() <= range)
m = BottomLeft2;
else if ( p.y() <= range && p.x() >= width-range)
m = TopRight2;
else if ( p.y() <= border )
m = Top;
else if ( p.y() >= height-border )
m = Bottom;
else if ( p.x() <= border )
m = Left;
else if ( p.x() >= width-border )
m = Right;
else
m = Center;
return m;
}
void Decoration::borders( int& left, int& right, int& top, int& bottom ) const
{
if( options()->preferredBorderSize( factory()) == BorderTiny )
{
left = right = bottom = 1;
top = 5;
}
else
{
left = right = options()->preferredBorderSize( factory()) * 5;
top = options()->preferredBorderSize( factory()) * 10;
bottom = options()->preferredBorderSize( factory()) * 2;
}
if( isShade())
bottom = 0;
if( ( maximizeMode() & MaximizeHorizontal ) && !options()->moveResizeMaximizedWindows())
left = right = 0;
if( ( maximizeMode() & MaximizeVertical ) && !options()->moveResizeMaximizedWindows())
bottom = 0;
}
void Decoration::reset( unsigned long )
{
}
void Decoration::resize( const QSize& s )
{
widget()->resize( s );
}
QSize Decoration::minimumSize() const
{
return QSize( 100, 50 );
}
bool Decoration::eventFilter( QObject* o, QEvent* e )
{
if( o == widget())
{
switch( e->type())
{
case QEvent::MouseButtonPress:
{ // FRAME
processMousePressEvent( static_cast< QMouseEvent* >( e ));
return true;
}
case QEvent::Show:
break;
case QEvent::Hide:
break;
default:
break;
}
}
return false;
}
}
#include <QApplication>
#include <QPainter>
#include <X11/Xlib.h>
#include <math.h>
#include <unistd.h>
namespace KWinTest
{
// taken from riscos
bool Decoration::animateMinimize(bool iconify)
{
int style = 1;
switch (style) {
case 1:
{
// Double twisting double back, with pike ;)
if (!iconify) // No animation for restore.
return true;
// Go away quick.
helperShowHide( false );
qApp->syncX();
QRect r = iconGeometry();
if (!r.isValid())
return true;
// Algorithm taken from Window Maker (http://www.windowmaker.org)
int sx = geometry().x();
int sy = geometry().y();
int sw = width();
int sh = height();
int dx = r.x();
int dy = r.y();
int dw = r.width();
int dh = r.height();
double steps = 12;
double xstep = double((dx-sx)/steps);
double ystep = double((dy-sy)/steps);
double wstep = double((dw-sw)/steps);
double hstep = double((dh-sh)/steps);
double cx = sx;
double cy = sy;
double cw = sw;
double ch = sh;
double finalAngle = 3.14159265358979323846;
double delta = finalAngle / steps;
QPainter p( workspaceWidget());
p.setRasterOp(Qt::NotROP);
for (double angle = 0; ; angle += delta) {
if (angle > finalAngle)
angle = finalAngle;
double dx = (cw / 10) - ((cw / 5) * sin(angle));
double dch = (ch / 2) * cos(angle);
double midy = cy + (ch / 2);
QPoint p1(int(cx + dx), int(midy - dch));
QPoint p2(int(cx + cw - dx), p1.y());
QPoint p3(int(cx + dw + dx), int(midy + dch));
QPoint p4(int(cx - dx), p3.y());
grabXServer();
p.drawLine(p1, p2);
p.drawLine(p2, p3);
p.drawLine(p3, p4);
p.drawLine(p4, p1);
p.flush();
usleep(500);
p.drawLine(p1, p2);
p.drawLine(p2, p3);
p.drawLine(p3, p4);
p.drawLine(p4, p1);
ungrabXServer();
// FRAME qApp->processEvents(); // FRAME ???
cx += xstep;
cy += ystep;
cw += wstep;
ch += hstep;
if (angle >= finalAngle)
break;
}
}
break;
case 2:
{
// KVirc style ? Maybe. For qwertz.
if (!iconify) // No animation for restore.
return true;
// Go away quick.
helperShowHide( false );
qApp->syncX();
int stepCount = 12;
QRect r(geometry());
int dx = r.width() / (stepCount * 2);
int dy = r.height() / (stepCount * 2);
QPainter p( workspaceWidget());
p.setRasterOp(Qt::NotROP);
for (int step = 0; step < stepCount; step++) {
r.translate(dx, dy);
r.setWidth(r.width() - 2 * dx);
r.setHeight(r.height() - 2 * dy);
grabXServer();
p.drawRect(r);
p.flush();
usleep(200);
p.drawRect(r);
ungrabXServer();
// FRAME qApp->processEvents();
}
}
break;
default:
{
QRect icongeom = iconGeometry();
if (!icongeom.isValid())
return true;
QRect wingeom = geometry();
QPainter p( workspaceWidget());
p.setRasterOp(Qt::NotROP);
#if 0
if (iconify)
p.setClipRegion(
QRegion( workspaceWidget()->rect()) - wingeom
);
#endif
grabXServer();
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
p.flush();
qApp->syncX();
usleep(30000);
p.drawLine(wingeom.bottomRight(), icongeom.bottomRight());
p.drawLine(wingeom.bottomLeft(), icongeom.bottomLeft());
p.drawLine(wingeom.topLeft(), icongeom.topLeft());
p.drawLine(wingeom.topRight(), icongeom.topRight());
ungrabXServer();
}
break;
}
return true;
}
KDecoration* Factory::createDecoration( KDecorationBridge* bridge )
{
NET::WindowType type = windowType( SUPPORTED_WINDOW_TYPES_MASK, bridge );
if( type == NET::Dialog )
;
return new Decoration( bridge, this );
}
bool Factory::reset( unsigned long changed )
{
resetDecorations( changed );
return false;
}
} // namespace
extern "C"
{
KDE_EXPORT KDecorationFactory *create_factory()
{
return new KWinTest::Factory();
}
}
#include "test.moc"

87
clients/test/test.desktop Normal file
View File

@ -0,0 +1,87 @@
[Desktop Entry]
Name=KWin test
Name[af]=KWin toets
Name[ar]=اختبار كوين
Name[be]=Тэст KWin
Name[be@latin]=Test dla akońnika „KWin”
Name[bg]=Тест KWin
Name[bn]=Kwin পরীক্ষা
Name[bn_IN]=KWin পরীক্ষা
Name[ca]=Test de KWin
Name[ca@valencia]=Test de KWin
Name[cs]=KWin test
Name[csb]=Test KWin
Name[cy]=arbrawf KWin
Name[da]=KWin-test
Name[de]=KWin-Test
Name[el]=KWin τεστ
Name[en_GB]=KWin test
Name[eo]=Testo de KDE-fenestroadministrilo
Name[es]=Prueba de KWin
Name[et]=KWin test
Name[eu]=KWin froga
Name[fa]=آزمون KWin
Name[fi]=KWin-testi
Name[fr]=Test de KWin
Name[fy]=KWin test
Name[ga]=Tástáil KWin
Name[gl]=Proba de KWin
Name[gu]=KWin ચકાસણી
Name[he]=בדיקה של KWin
Name[hi]=के-विन जांच
Name[hne]=के-विन जांच
Name[hr]=KWina proba
Name[hsb]=KWin-test
Name[hu]=KWin-teszt
Name[ia]=prova de KWin
Name[id]=Tes KWIN
Name[is]=KWin prófun
Name[it]=Prova di KWin
Name[ja]=KWin テスト
Name[ka]=KWin შემოწმება
Name[kk]=KWin сынауы
Name[km]=សាកល្បង KWin
Name[kn]=ಕೆವಿನ್ ಪರೀಕ್ಷೆ
Name[ko]=KWin 테스트
Name[ku]=KWin test
Name[lt]=KWin patikrinimas
Name[lv]=KWin tests
Name[mai]=के-विन जांच
Name[mk]=Тест за KWin
Name[ml]=കെവിന്‍ ടെസ്റ്റ്
Name[mr]=केविन जांच
Name[ms]=Ujian KWin
Name[nb]=KWin test
Name[nds]=KWin-Test
Name[ne]=केडीई विन परीक्षण
Name[nl]=KWin test
Name[nn]=KWin-test
Name[pa]=KWin ਟੈਸਟ
Name[pl]=Test KWin
Name[pt]=Teste do KWin
Name[pt_BR]=Teste do KWin
Name[ro]=Test KWin
Name[ru]=Проверка KWin
Name[se]=KWin-geahččaleapmi
Name[si]=KWin පරික්‍ෂණය
Name[sk]=Test KWin
Name[sl]=Preizkus KWin
Name[sr]=Проба К‑вина
Name[sr@ijekavian]=Проба К‑вина
Name[sr@ijekavianlatin]=Proba KWina
Name[sr@latin]=Proba KWina
Name[sv]=Kwin-test
Name[ta]=KWin சோதனை
Name[te]=KWin పరిశీలన
Name[tg]=Санҷиши KWin
Name[th]=ทดสอบ KWin
Name[tr]=KWin testi
Name[uk]=Тест KWin
Name[uz]=KWin sinash
Name[uz@cyrillic]=KWin синаш
Name[vi]=Thử KWin
Name[wa]=Saye KWin
Name[x-test]=xxKWin testxx
Name[zh_CN]=KWin 测试
Name[zh_TW]=KWin 測試
X-KDE-Library=kwin3_test

67
clients/test/test.h Normal file
View File

@ -0,0 +1,67 @@
/********************************************************************
Copyright (C) 2003 Lubos Lunak <l.lunak@kde.org>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*********************************************************************/
#ifndef KWIN_TEST
#define KWIN_TEST
#include <kdecoration.h>
#include <kdecorationfactory.h>
#include <QPushButton>
namespace KWinTest
{
const int SUPPORTED_WINDOW_TYPES_MASK = NET::NormalMask | NET::DesktopMask | NET::DockMask
| NET::ToolbarMask | NET::MenuMask | NET::DialogMask /*| NET::OverrideMask*/ | NET::TopMenuMask
| NET::UtilityMask | NET::SplashMask;
class Decoration
: public KDecoration
{
Q_OBJECT
public:
Decoration( KDecorationBridge* bridge, KDecorationFactory* factory );
virtual void init();
virtual MousePosition mousePosition( const QPoint& p ) const;
virtual void borders( int& left, int& right, int& top, int& bottom ) const;
virtual void resize( const QSize& s );
virtual QSize minimumSize() const;
virtual void activeChange() {};
virtual void captionChange() {};
virtual void maximizeChange() {};
virtual void desktopChange() {};
virtual void shadeChange() {};
virtual void iconChange() {};
virtual bool eventFilter( QObject* o, QEvent* e );
virtual void reset( unsigned long changed );
virtual bool animateMinimize( bool minimize );
private:
QPushButton* button;
};
class Factory
: public KDecorationFactory
{
public:
virtual KDecoration* createDecoration( KDecorationBridge* );
virtual bool reset( unsigned long changed );
};
} // namespace
#endif

View File

@ -0,0 +1,22 @@
########### next target ###############
set(kwin3_web_PART_SRCS Web.cpp WebButton.cpp )
kde4_add_plugin(kwin3_web ${kwin3_web_PART_SRCS})
target_link_libraries(kwin3_web ${KDE4_KDEUI_LIBS} kdecorations )
install(TARGETS kwin3_web DESTINATION ${PLUGIN_INSTALL_DIR} )
########### install files ###############
install( FILES web.desktop DESTINATION ${DATA_INSTALL_DIR}/kwin/ )

402
clients/web/Web.cpp Normal file
View File

@ -0,0 +1,402 @@
/*
'Web' kwin client
Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "Web.h"
#include <QPainter>
//Added by qt3to4:
#include <QPaintEvent>
#include <kconfiggroup.h>
#include "WebButton.h"
extern "C"
{
KDE_EXPORT KDecorationFactory *create_factory()
{
return new Web::WebFactory();
}
}
namespace Web {
WebClient::WebClient(KDecorationBridge* bridge, KDecorationFactory* factory)
: KCommonDecoration(bridge, factory)
{
// Empty.
}
WebClient::~WebClient()
{
// Empty.
}
QString WebClient::visibleName() const
{
return i18n("Web");
}
QString WebClient::defaultButtonsLeft() const
{
return "S";
}
QString WebClient::defaultButtonsRight() const
{
return "HIA__X";
}
bool WebClient::decorationBehaviour(DecorationBehaviour behaviour) const
{
switch (behaviour) {
case DB_MenuClose:
return false;
case DB_WindowMask:
return true;
case DB_ButtonHide:
return true;
default:
return KCommonDecoration::decorationBehaviour(behaviour);
}
}
int WebClient::layoutMetric(LayoutMetric lm, bool respectWindowState, const KCommonDecorationButton *btn) const
{
// bool maximized = maximizeMode()==MaximizeFull && !options()->moveResizeMaximizedWindows();
switch (lm) {
case LM_BorderLeft:
case LM_BorderRight:
case LM_BorderBottom:
return borderSize_;
case LM_TitleEdgeLeft:
case LM_TitleEdgeRight:
case LM_TitleEdgeTop:
case LM_TitleEdgeBottom:
return 0;
case LM_TitleBorderLeft:
case LM_TitleBorderRight:
return 0;
case LM_TitleHeight:
case LM_ButtonWidth:
case LM_ButtonHeight:
return titleHeight_;
case LM_ButtonSpacing:
return 0;
default:
return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
}
}
KCommonDecorationButton *WebClient::createButton(ButtonType type)
{
switch (type) {
case MenuButton:
return new WebButton(MenuButton, this, shape_);
case OnAllDesktopsButton:
return new WebButton(OnAllDesktopsButton, this, shape_);
case HelpButton:
return new WebButton(HelpButton, this, shape_);
case MinButton:
return new WebButton(MinButton, this, shape_);
case MaxButton:
return new WebButton(MaxButton, this, shape_);
case CloseButton:
return new WebButton(CloseButton, this, shape_);
case AboveButton:
return new WebButton(AboveButton, this, shape_);
case BelowButton:
return new WebButton(BelowButton, this, shape_);
case ShadeButton:
return new WebButton(ShadeButton, this, shape_);
default:
return 0;
}
}
void
WebClient::init()
{
// title height
const int textVMargin = 2;
QFontMetrics fm(options()->font(isActive(), isToolWindow()));
// border size
switch(options()->preferredBorderSize( factory())) {
case BorderLarge:
borderSize_ = 8;
break;
case BorderVeryLarge:
borderSize_ = 12;
break;
case BorderHuge:
borderSize_ = 18;
break;
case BorderVeryHuge:
borderSize_ = 27;
break;
case BorderOversized:
borderSize_ = 40;
break;
case BorderNormal:
default:
borderSize_ = 4;
}
titleHeight_ = qMax(qMax(14, fm.height() + textVMargin * 2), borderSize_);
if (0 != titleHeight_ % 2)
titleHeight_ += 1;
KConfig c("kwinwebrc");
shape_ = c.group("General").readEntry("Shape", true);
KCommonDecoration::init();
}
void
WebClient::reset( unsigned long changed )
{
if (changed & SettingColors)
{
// repaint the whole thing
widget()->repaint();
} else if (changed & SettingFont) {
// font has changed -- update title height
// title height
const int textVMargin = 2;
QFontMetrics fm(options()->font(isActive(), isToolWindow()));
titleHeight_ = qMax(qMax(14, fm.height() + textVMargin * 2), borderSize_);
if (0 != titleHeight_ % 2)
titleHeight_ += 1;
widget()->repaint();
}
KCommonDecoration::reset(changed);
}
void
WebClient::paintEvent(QPaintEvent * pe)
{
int r_x, r_y, r_x2, r_y2;
widget()->rect().getCoords(&r_x, &r_y, &r_x2, &r_y2);
const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
const int ttlHeight = layoutMetric(LM_TitleHeight);
const int titleEdgeBottomBottom = r_y+titleEdgeTop+ttlHeight+titleEdgeBottom-1;
QRect titleRect = QRect(r_x+titleEdgeLeft+buttonsLeftWidth()+1, r_y+titleEdgeTop,
r_x2-titleEdgeRight-buttonsRightWidth()-(r_x+titleEdgeLeft+buttonsLeftWidth()+1),
titleEdgeBottomBottom-(r_y+titleEdgeTop) );
titleRect.setTop(1);
QRegion mask( calcMask() );
QPainter p(widget());
p.setPen(Qt::black);
QPalette pal = options()->palette(ColorFrame, isActive());
pal.setCurrentColorGroup( QPalette::Active );
p.setBrush( pal.background() );
p.setClipRegion(pe->region() - titleRect);
if( isPreview() && shape_ ) p.setClipRegion( mask, Qt::IntersectClip );
QRect r(widget()->rect());
r.adjust(0, 0, -1, -1);
p.drawRect(r);
p.setClipRegion(pe->region());
if( isPreview() && shape_ ) p.setClipRegion( mask, Qt::IntersectClip );
p.fillRect(titleRect, options()->color(ColorTitleBar, isActive()));
if (shape_)
{
int r(width());
int b(height());
// Draw edge of top-left corner inside the area removed by the mask.
p.drawPoint(3, 1);
p.drawPoint(4, 1);
p.drawPoint(2, 2);
p.drawPoint(1, 3);
p.drawPoint(1, 4);
// Draw edge of top-right corner inside the area removed by the mask.
p.drawPoint(r - 5, 1);
p.drawPoint(r - 4, 1);
p.drawPoint(r - 3, 2);
p.drawPoint(r - 2, 3);
p.drawPoint(r - 2, 4);
// Draw edge of bottom-left corner inside the area removed by the mask.
p.drawPoint(1, b - 5);
p.drawPoint(1, b - 4);
p.drawPoint(2, b - 3);
p.drawPoint(3, b - 2);
p.drawPoint(4, b - 2);
// Draw edge of bottom-right corner inside the area removed by the mask.
p.drawPoint(r - 2, b - 5);
p.drawPoint(r - 2, b - 4);
p.drawPoint(r - 3, b - 3);
p.drawPoint(r - 4, b - 2);
p.drawPoint(r - 5, b - 2);
}
p.setFont(options()->font(isActive(), isToolWindow()));
p.setPen(options()->color(ColorFont, isActive()));
p.drawText(titleRect, Qt::AlignCenter, caption());
}
QRegion WebClient::calcMask(void) const
{
QRegion mask(0, 0, width(), height());
if (maximizeMode() == MaximizeFull)
return mask;
int r(width());
int b(height());
// Remove top-left corner.
mask -= QRegion(0, 0, 5, 1);
mask -= QRegion(0, 1, 3, 1);
mask -= QRegion(0, 2, 2, 1);
mask -= QRegion(0, 3, 1, 2);
// Remove top-right corner.
mask -= QRegion(r - 5, 0, 5, 1);
mask -= QRegion(r - 3, 1, 3, 1);
mask -= QRegion(r - 2, 2, 2, 1);
mask -= QRegion(r - 1, 3, 1, 2);
// Remove bottom-left corner.
mask -= QRegion(0, b - 5, 1, 3);
mask -= QRegion(0, b - 3, 2, 1);
mask -= QRegion(0, b - 2, 3, 1);
mask -= QRegion(0, b - 1, 5, 1);
// Remove bottom-right corner.
mask -= QRegion(r - 5, b - 1, 5, 1);
mask -= QRegion(r - 3, b - 2, 3, 1);
mask -= QRegion(r - 2, b - 3, 2, 1);
mask -= QRegion(r - 1, b - 5, 1, 2);
return mask;
}
void WebClient::updateWindowShape()
{
if (!shape_)
return;
setMask(calcMask());
}
KDecoration* WebFactory::createDecoration( KDecorationBridge* b )
{
return(new WebClient(b, this))->decoration();
}
bool WebFactory::reset(unsigned long changed)
{
// Do we need to "hit the wooden hammer" ?
bool needHardReset = true;
if ((changed & ~(SettingColors | SettingFont | SettingButtons)) == 0 )
{
needHardReset = false;
}
if (needHardReset) {
return true;
} else {
resetDecorations(changed);
return false;
}
}
bool WebFactory::supports( Ability ability ) const
{
switch( ability )
{
// announce
case AbilityAnnounceButtons:
case AbilityAnnounceColors:
// buttons
case AbilityButtonOnAllDesktops:
case AbilityButtonHelp:
case AbilityButtonMinimize:
case AbilityButtonMaximize:
case AbilityButtonClose:
case AbilityButtonMenu:
case AbilityButtonAboveOthers:
case AbilityButtonBelowOthers:
case AbilityButtonShade:
case AbilityButtonSpacer:
// colors:
case AbilityColorTitleBack:
case AbilityColorTitleFore:
return true;
default:
return false;
};
}
QList< WebFactory::BorderSize > WebFactory::borderSizes() const
{ // the list must be sorted
return QList< BorderSize >() << BorderNormal << BorderLarge <<
BorderVeryLarge << BorderHuge << BorderVeryHuge << BorderOversized;
}
}
#include "Web.moc"
// vim:ts=2:sw=2:tw=78:set et:
// kate: indent-width 2; replace-tabs on; tab-width 2; space-indent on;

84
clients/web/Web.h Normal file
View File

@ -0,0 +1,84 @@
/*
'Web' kwin client
Copyright (C) 2005 Sandro Giessl <sandro@giessl.com>
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KWIN_WEB_H
#define KWIN_WEB_H
#include "../../lib/kcommondecoration.h"
#include "../../lib/kdecorationfactory.h"
namespace Web
{
class WebClient : public KCommonDecoration
{
public:
WebClient(KDecorationBridge* bridge, KDecorationFactory* factory);
~WebClient();
virtual QString visibleName() const;
virtual QString defaultButtonsLeft() const;
virtual QString defaultButtonsRight() const;
virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
virtual KCommonDecorationButton *createButton(ButtonType type);
virtual QRegion calcMask( void ) const;
virtual void updateWindowShape();
virtual void init();
protected:
virtual void reset( unsigned long changed );
virtual void paintEvent(QPaintEvent *);
private:
int titleHeight_, borderSize_;
bool shape_;
QBitmap _buttonBitmap(ButtonType t) const;
};
class WebFactory : public QObject, public KDecorationFactory
{
Q_OBJECT
public:
WebFactory() {}
virtual ~WebFactory() {}
virtual KDecoration* createDecoration( KDecorationBridge* );
virtual bool reset( unsigned long changed );
virtual bool supports( Ability ability ) const;
virtual QList< BorderSize > borderSizes() const;
};
}
#endif
// vim:ts=2:sw=2:tw=78:set et:
// kate: indent-width 2; replace-tabs on; tab-width 2; space-indent on;

303
clients/web/WebButton.cpp Normal file
View File

@ -0,0 +1,303 @@
/*
'Web' kwin client
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "WebButton.h"
#include <QPainter>
//Added by qt3to4:
#include <QEvent>
#include "Web.h"
namespace Web {
static unsigned char close_bits[] = {
0x42, 0xe7, 0x7e, 0x3c, 0x3c, 0x7e, 0xe7, 0x42
};
static unsigned char iconify_bits[] = {
0x00, 0x00, 0x00, 0x7e, 0x7e, 0x3c, 0x18, 0x00
};
static unsigned char maximize_bits[] = {
0xfc, 0xf8, 0xf0, 0xe0, 0xc0, 0x80, 0x00, 0x00
};
static unsigned char unmaximize_bits[] = {
0x00, 0x00, 0x01, 0x03, 0x07, 0x0f, 0x1f, 0x3f
};
static unsigned char sticky_bits[] = {
0x20, 0x70, 0xfa, 0x7e, 0x3c, 0x1c, 0x32, 0x01
};
static unsigned char unsticky_bits[] = {
0x1c, 0x1c, 0x1c, 0x3e, 0x7f, 0x08, 0x08, 0x08
};
static unsigned char help_bits[] = {
0x18, 0x18, 0x00, 0x1c, 0x18, 0x18, 0x18, 0x3c
};
static unsigned char shade_on_bits[] = {
0xff, 0xff, 0x81, 0x81, 0x99, 0xbd, 0x81, 0xff
};
static unsigned char shade_off_bits[] = {
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
};
static unsigned char above_on_bits[] = {
0xff, 0x7e, 0x3c, 0x18, 0x00, 0xff, 0xff, 0x00
};
static unsigned char above_off_bits[] = {
0x18, 0x3c, 0x7e, 0xff, 0x00, 0xff, 0xff, 0x00
};
static unsigned char below_on_bits[] = {
0x00, 0xff, 0xff, 0x00, 0x18, 0x3c, 0x7e, 0xff
};
static unsigned char below_off_bits[] = {
0x00, 0xff, 0xff, 0x00, 0xff, 0x7e, 0x3c, 0x18
};
static unsigned char menu_bits[] = {
0xff, 0x81, 0x81, 0xff, 0x81, 0xff, 0x81, 0xff
};
WebButton::WebButton(ButtonType type, WebClient *parent, bool shape)
: KCommonDecorationButton (type, parent),
mouseOver_ (false),
shape_ (shape),
deco_ (parent)
{
setAttribute(Qt::WA_NoSystemBackground, true);
}
WebButton::~WebButton()
{
// Empty.
}
void WebButton::reset(unsigned long changed)
{
if (changed&DecorationReset || changed&ManualReset || changed&SizeChange || changed&StateChange) {
switch (type() ) {
case CloseButton:
setBitmap(close_bits);
break;
case HelpButton:
setBitmap(help_bits);
break;
case MinButton:
setBitmap(iconify_bits);
break;
case MaxButton:
setBitmap( isChecked() ? unmaximize_bits : maximize_bits );
break;
case OnAllDesktopsButton:
setBitmap( isChecked() ? unsticky_bits : sticky_bits );
break;
case ShadeButton:
setBitmap( isChecked() ? shade_on_bits : shade_off_bits );
break;
case AboveButton:
setBitmap( isChecked() ? above_on_bits : above_off_bits );
break;
case BelowButton:
setBitmap( isChecked() ? below_on_bits : below_off_bits );
break;
case MenuButton:
setBitmap(menu_bits);
break;
default:
setBitmap(0);
break;
}
this->update();
}
}
void
WebButton::enterEvent(QEvent * e)
{
mouseOver_ = true;
repaint();
QAbstractButton::enterEvent(e);
}
void
WebButton::leaveEvent(QEvent * e)
{
mouseOver_ = false;
repaint();
QAbstractButton::leaveEvent(e);
}
void WebButton::paintEvent(QPaintEvent *)
{
QPainter p(this);
drawButton(&p);
}
void
WebButton::drawButton(QPainter *p)
{
QPen highlightPen;
if (isDown() )
highlightPen = QPen( palette().color( QPalette::Light ));
else
{
if (mouseOver_)
highlightPen = QPen( palette().color( QPalette::Highlight ));
else
highlightPen = QPen(Qt::NoPen);
}
p->fillRect(rect(), palette().color( QPalette::Background ) );
Position position_;
if (0 == mapToParent(rect().topLeft() ).x() )
position_ = Left;
else if (deco_->width()-1 == mapToParent(rect().topRight() ).x() )
position_ = Right;
else
position_ = Mid;
if( deco_->isPreview() && shape_ )
{
QRegion mask( deco_->calcMask().translated( -mapToParent(rect().topLeft()) ) );
p->setClipRegion( mask, Qt::IntersectClip );
}
switch ( position_ )
{
case Left:
{
// Draw edge.
p->setPen(Qt::black);
p->drawLine(0, 0, width(), 0);
p->drawLine(0, 1, 0, height() - 1);
if (shape_)
{
p->drawPoint(3, 1);
p->drawPoint(4, 1);
p->drawPoint(2, 2);
p->drawPoint(1, 3);
p->drawPoint(1, 4);
}
// Draw highlight.
p->setBrush(Qt::NoBrush);
p->setPen(highlightPen);
if (shape_)
p->setClipRegion(QRegion(rect()) - QRect(0, 0, 6, 6));
p->drawRect(2, 2, width() - 4, height() - 4);
if (shape_)
{
p->setClipRect(rect());
p->drawPoint(4, 3);
p->drawPoint(5, 3);
p->drawPoint(3, 4);
p->drawPoint(3, 5);
}
}
break;
case Right:
{
// Draw edge.
p->setPen(Qt::black);
p->drawLine(0, 0, width(), 0);
p->drawLine(width() - 1, 1, width() - 1, height() - 1);
if (shape_)
{
p->drawPoint(width() - 5, 1);
p->drawPoint(width() - 4, 1);
p->drawPoint(width() - 3, 2);
p->drawPoint(width() - 2, 3);
p->drawPoint(width() - 2, 4);
}
// Draw highlight.
p->setBrush(Qt::NoBrush);
p->setPen(highlightPen);
if (shape_)
p->setClipRegion(QRegion(rect()) - QRect(width() - 6, 0, 6, 6));
p->drawRect(2, 2, width() - 4, height() - 4);
if (shape_)
{
p->setClipRect(rect());
p->drawPoint(width() - 5, 3);
p->drawPoint(width() - 6, 3);
p->drawPoint(width() - 4, 4);
p->drawPoint(width() - 4, 5);
}
}
break;
case Mid:
default:
{
// Draw edge.
p->setPen(Qt::black);
p->drawLine(0, 0, width(), 0);
// Draw highlight.
p->setBrush(Qt::NoBrush);
p->setPen(highlightPen);
p->drawRect(2, 2, width() - 4, height() - 4);
}
break;
}
// Draw icon.
QPoint center(rect().center());
QPainterPath path;
path.addRegion( bitmap_ );
int bwby2(bitmap_.width() / 2); // Bitmap Width BY 2
int bhby2(bitmap_.height() / 2); // Bitmap Height BY 2
p->setPen( Qt::NoPen );
p->setBrush(Qt::black);
p->translate( center.x() - bwby2 + 1, center.y() - bhby2 + 1 );
p->drawPath( path );
}
void
WebButton::setBitmap(const unsigned char *bitmap)
{
if (bitmap)
bitmap_ = QBitmap::fromData( QSize(8, 8), bitmap);
else
bitmap_ = QBitmap(8,8);
bitmap_.setMask(bitmap_);
}
}
// vim:ts=2:sw=2:tw=78:set et:
// kate: indent-width 2; replace-tabs on; tab-width 2; space-indent on;

71
clients/web/WebButton.h Normal file
View File

@ -0,0 +1,71 @@
/*
'Web' kwin client
Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; see the file COPYING. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef KWIN_WEB_BUTTON_H
#define KWIN_WEB_BUTTON_H
#include <QWidget>
#include <QBitmap>
#include <klocale.h>
#include "../../lib/kcommondecoration.h"
namespace Web
{
class WebClient;
class WebButton : public KCommonDecorationButton
{
public:
enum Position
{
Left, Mid, Right
};
WebButton(ButtonType type, WebClient *parent, bool shape);
virtual ~WebButton();
virtual void reset(unsigned long changed);
protected:
void setBitmap(const unsigned char *bitmap);
void enterEvent(QEvent *);
void leaveEvent(QEvent *);
void paintEvent(QPaintEvent *);
void drawButton(QPainter *p);
private:
QBitmap bitmap_;
bool mouseOver_;
bool shape_;
WebClient* deco_;
};
}
#endif
// vim:ts=2:sw=2:tw=78:set et:
// kate: indent-width 2; replace-tabs on; tab-width 2; space-indent on;

90
clients/web/web.desktop Normal file
View File

@ -0,0 +1,90 @@
[Desktop Entry]
Name=Web
Name[af]=Web
Name[ar]=انترنت
Name[be]=Сеціва
Name[be@latin]=Web
Name[bg]=Уеб
Name[bn]=ওয়েব
Name[bn_IN]=ওয়েব
Name[br]=Gwiad
Name[ca]=Web
Name[ca@valencia]=Web
Name[cs]=Web
Name[csb]=Web
Name[cy]=Gwe
Name[da]=Net
Name[de]=Web
Name[el]=Ιστός
Name[en_GB]=Web
Name[eo]=TTT
Name[es]=Web
Name[et]=Veeb
Name[eu]=Web
Name[fa]=وب
Name[fi]=Web
Name[fr]=Web
Name[fy]=Web
Name[ga]=Gréasán
Name[gl]=Web
Name[gu]=વેબ
Name[he]=רשת
Name[hi]=वेब
Name[hne]=वेब
Name[hr]=Internet
Name[hsb]=Web
Name[hu]=Web
Name[ia]=Web
Name[id]=Web
Name[is]=Vefur
Name[it]=Web
Name[ja]=Web
Name[ka]=Web
Name[kk]=Веб
Name[km]=បណ្ដាញ
Name[kn]=ಜಾಲ
Name[ko]=웹
Name[ku]=Tor
Name[lt]=Žiniatinklis
Name[lv]=Tīmeklis
Name[mai]=वेब
Name[mk]=Веб
Name[ml]=വെബ്
Name[mr]=वेब
Name[ms]=Web
Name[nb]=Nett
Name[nds]=Web
Name[ne]=वेब
Name[nl]=Web
Name[nn]=Vev
Name[oc]=Web
Name[pa]=ਵੈੱਬ
Name[pl]=Sieć
Name[pt]=Web
Name[pt_BR]=Web
Name[ro]=Web
Name[ru]=Веб
Name[se]=Fierpmádat
Name[si]=වෙබ්
Name[sk]=Web
Name[sl]=Splet
Name[sr]=Веб
Name[sr@ijekavian]=Веб
Name[sr@ijekavianlatin]=Web
Name[sr@latin]=Web
Name[sv]=Webb
Name[ta]=வலை
Name[te]=వెబ్
Name[tg]=Интернет
Name[th]=รูปแบบเว็บ
Name[tr]=Web
Name[uk]=Тенета
Name[uz]=Veb
Name[uz@cyrillic]=Веб
Name[vi]=Mạng
Name[wa]=Waibe
Name[xh]=Web
Name[x-test]=xxWebxx
Name[zh_CN]=网页
Name[zh_TW]=網頁
X-KDE-Library=kwin3_web