summaryrefslogtreecommitdiffstats
path: root/kwin/clients/plastik
diff options
context:
space:
mode:
Diffstat (limited to 'kwin/clients/plastik')
-rw-r--r--kwin/clients/plastik/CMakeLists.txt39
-rw-r--r--kwin/clients/plastik/Makefile.am19
-rw-r--r--kwin/clients/plastik/config/CMakeLists.txt33
-rw-r--r--kwin/clients/plastik/config/Makefile.am14
-rw-r--r--kwin/clients/plastik/config/config.cpp123
-rw-r--r--kwin/clients/plastik/config/config.h53
-rw-r--r--kwin/clients/plastik/config/configdialog.ui119
-rw-r--r--kwin/clients/plastik/misc.cpp85
-rw-r--r--kwin/clients/plastik/misc.h30
-rw-r--r--kwin/clients/plastik/plastik.cpp598
-rw-r--r--kwin/clients/plastik/plastik.desktop37
-rw-r--r--kwin/clients/plastik/plastik.h127
-rw-r--r--kwin/clients/plastik/plastikbutton.cpp629
-rw-r--r--kwin/clients/plastik/plastikbutton.h90
-rw-r--r--kwin/clients/plastik/plastikclient.cpp529
-rw-r--r--kwin/clients/plastik/plastikclient.h73
16 files changed, 0 insertions, 2598 deletions
diff --git a/kwin/clients/plastik/CMakeLists.txt b/kwin/clients/plastik/CMakeLists.txt
deleted file mode 100644
index d782413ce..000000000
--- a/kwin/clients/plastik/CMakeLists.txt
+++ /dev/null
@@ -1,39 +0,0 @@
-#################################################
-#
-# (C) 2010-2011 Serghei Amelian
-# serghei (DOT) amelian (AT) gmail.com
-#
-# Improvements and feedback are welcome
-#
-# This file is released under GPL >= 2
-#
-#################################################
-
-add_subdirectory( config )
-
-add_definitions( -DQT_PLUGIN )
-
-include_directories(
- ${CMAKE_CURRENT_BINARY_DIR}
- ${CMAKE_SOURCE_DIR}/twin/lib
- ${TDE_INCLUDE_DIR}
- ${TQT_INCLUDE_DIRS}
-)
-
-link_directories(
- ${TQT_LIBRARY_DIRS}
-)
-
-
-##### other data ################################
-
-install( FILES plastik.desktop DESTINATION ${DATA_INSTALL_DIR}/twin )
-
-
-##### twin3_plastik (module) ####################
-
-tde_add_kpart( twin3_plastik AUTOMOC
- SOURCES plastik.cpp plastikclient.cpp plastikbutton.cpp misc.cpp
- LINK tdecorations-shared tdeui-shared
- DESTINATION ${PLUGIN_INSTALL_DIR}
-)
diff --git a/kwin/clients/plastik/Makefile.am b/kwin/clients/plastik/Makefile.am
deleted file mode 100644
index c1757891d..000000000
--- a/kwin/clients/plastik/Makefile.am
+++ /dev/null
@@ -1,19 +0,0 @@
-AUTOMAKE_OPTIONS = foreign
-
-SUBDIRS = config
-
-KDE_CXXFLAGS = -DQT_PLUGIN
-
-INCLUDES = -I$(srcdir)/../../lib $(all_includes)
-
-twindir = $(kde_datadir)/twin/
-twin_DATA = plastik.desktop
-
-kde_module_LTLIBRARIES = twin3_plastik.la
-twin3_plastik_la_SOURCES = plastik.cpp plastikclient.cpp plastikbutton.cpp misc.cpp
-twin3_plastik_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
-twin3_plastik_la_LIBADD = $(LIB_TDEUI) ../../lib/libtdecorations.la
-twin3_plastik_la_METASOURCES = AUTO
-
-DISTCLEANFILES = $(twin3_plastik_la_METASOURCES)
-
diff --git a/kwin/clients/plastik/config/CMakeLists.txt b/kwin/clients/plastik/config/CMakeLists.txt
deleted file mode 100644
index 49066000e..000000000
--- a/kwin/clients/plastik/config/CMakeLists.txt
+++ /dev/null
@@ -1,33 +0,0 @@
-#################################################
-#
-# (C) 2010-2011 Serghei Amelian
-# serghei (DOT) amelian (AT) gmail.com
-#
-# Improvements and feedback are welcome
-#
-# This file is released under GPL >= 2
-#
-#################################################
-
-include_directories(
- ${CMAKE_CURRENT_BINARY_DIR}
- ${TDE_INCLUDE_DIR}
- ${TQT_INCLUDE_DIRS}
-)
-
-link_directories(
- ${TQT_LIBRARY_DIRS}
-)
-
-##### other data ################################
-
-install( FILES DESTINATION ${XDG_APPS_INSTALL_DIR} )
-
-
-##### twin_plastik_config (module) ##############
-
-tde_add_kpart( twin_plastik_config AUTOMOC
- SOURCES config.cpp configdialog.ui
- LINK tdeui-shared
- DESTINATION ${PLUGIN_INSTALL_DIR}
-)
diff --git a/kwin/clients/plastik/config/Makefile.am b/kwin/clients/plastik/config/Makefile.am
deleted file mode 100644
index b21a1d26b..000000000
--- a/kwin/clients/plastik/config/Makefile.am
+++ /dev/null
@@ -1,14 +0,0 @@
-INCLUDES = $(all_includes)
-
-kde_module_LTLIBRARIES = twin_plastik_config.la
-
-twin_plastik_config_la_SOURCES = config.cpp configdialog.ui
-twin_plastik_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module
-twin_plastik_config_la_LIBADD = $(LIB_TDEUI)
-
-METASOURCES = AUTO
-noinst_HEADERS = config.h
-DISTCLEANFILES = $(METASOURCES)
-
-lnkdir = $(kde_datadir)/twin
-
diff --git a/kwin/clients/plastik/config/config.cpp b/kwin/clients/plastik/config/config.cpp
deleted file mode 100644
index aa1c7bd0f..000000000
--- a/kwin/clients/plastik/config/config.cpp
+++ /dev/null
@@ -1,123 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 <tqbuttongroup.h>
-#include <tqcheckbox.h>
-#include <tqradiobutton.h>
-#include <tqslider.h>
-#include <tqspinbox.h>
-#include <tqwhatsthis.h>
-
-#include <kconfig.h>
-#include <klocale.h>
-#include <kglobal.h>
-
-#include "config.h"
-#include "configdialog.h"
-
-PlastikConfig::PlastikConfig(KConfig* config, TQWidget* parent)
- : TQObject(parent), m_config(0), m_dialog(0)
-{
- // create the configuration object
- m_config = new KConfig("twinplastikrc");
- KGlobal::locale()->insertCatalogue("twin_clients");
-
- // create and show the configuration dialog
- m_dialog = new ConfigDialog(parent);
- m_dialog->show();
-
- // load the configuration
- load(config);
-
- // setup the connections
- connect(m_dialog->titleAlign, TQT_SIGNAL(clicked(int)),
- this, TQT_SIGNAL(changed()));
- connect(m_dialog->animateButtons, TQT_SIGNAL(toggled(bool)),
- this, TQT_SIGNAL(changed()));
- connect(m_dialog->menuClose, TQT_SIGNAL(toggled(bool)),
- this, TQT_SIGNAL(changed()));
- connect(m_dialog->titleShadow, TQT_SIGNAL(toggled(bool)),
- this, TQT_SIGNAL(changed()));
- connect(m_dialog->coloredBorder, TQT_SIGNAL(toggled(bool)),
- this, TQT_SIGNAL(changed()));
-}
-
-PlastikConfig::~PlastikConfig()
-{
- if (m_dialog) delete m_dialog;
- if (m_config) delete m_config;
-}
-
-void PlastikConfig::load(KConfig*)
-{
- m_config->setGroup("General");
-
-
- TQString value = m_config->readEntry("TitleAlignment", "AlignLeft");
- TQRadioButton *button = (TQRadioButton*)m_dialog->titleAlign->child(value.latin1());
- if (button) button->setChecked(true);
- bool animateButtons = m_config->readBoolEntry("AnimateButtons", true);
- m_dialog->animateButtons->setChecked(animateButtons);
- bool menuClose = m_config->readBoolEntry("CloseOnMenuDoubleClick", true);
- m_dialog->menuClose->setChecked(menuClose);
- bool titleShadow = m_config->readBoolEntry("TitleShadow", true);
- m_dialog->titleShadow->setChecked(titleShadow);
- bool coloredBorder = m_config->readBoolEntry("ColoredBorder", true);
- m_dialog->coloredBorder->setChecked(coloredBorder);
-}
-
-void PlastikConfig::save(KConfig*)
-{
- m_config->setGroup("General");
-
- TQRadioButton *button = (TQRadioButton*)m_dialog->titleAlign->selected();
- if (button) m_config->writeEntry("TitleAlignment", TQString(button->name()));
- m_config->writeEntry("AnimateButtons", m_dialog->animateButtons->isChecked() );
- m_config->writeEntry("CloseOnMenuDoubleClick", m_dialog->menuClose->isChecked() );
- m_config->writeEntry("TitleShadow", m_dialog->titleShadow->isChecked() );
- m_config->writeEntry("ColoredBorder", m_dialog->coloredBorder->isChecked() );
- m_config->sync();
-}
-
-void PlastikConfig::defaults()
-{
- TQRadioButton *button =
- (TQRadioButton*)m_dialog->titleAlign->child("AlignLeft");
- if (button) button->setChecked(true);
- m_dialog->animateButtons->setChecked(true);
- m_dialog->menuClose->setChecked(false);
- m_dialog->titleShadow->setChecked(true);
- m_dialog->coloredBorder->setChecked(true);
-}
-
-//////////////////////////////////////////////////////////////////////////////
-// Plugin Stuff //
-//////////////////////////////////////////////////////////////////////////////
-
-extern "C"
-{
- KDE_EXPORT TQObject* allocate_config(KConfig* config, TQWidget* parent) {
- return (new PlastikConfig(config, parent));
- }
-}
-
-#include "config.moc"
diff --git a/kwin/clients/plastik/config/config.h b/kwin/clients/plastik/config/config.h
deleted file mode 100644
index d06bd30b8..000000000
--- a/kwin/clients/plastik/config/config.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 KNIFTYCONFIG_H
-#define KNIFTYCONFIG_H
-
-#include <tqobject.h>
-
-class TQButtonGroup;
-class TQGroupBox;
-class KConfig;
-class ConfigDialog;
-
-class PlastikConfig : public TQObject
-{
- Q_OBJECT
-public:
- PlastikConfig(KConfig* config, TQWidget* parent);
- ~PlastikConfig();
-
-signals:
- void changed();
-
-public slots:
- void load(KConfig *config);
- void save(KConfig *config);
- void defaults();
-
-private:
- KConfig *m_config;
- ConfigDialog *m_dialog;
-};
-
-#endif // KNIFTYCONFIG_H
diff --git a/kwin/clients/plastik/config/configdialog.ui b/kwin/clients/plastik/config/configdialog.ui
deleted file mode 100644
index f751d8024..000000000
--- a/kwin/clients/plastik/config/configdialog.ui
+++ /dev/null
@@ -1,119 +0,0 @@
-<!DOCTYPE UI><UI version="3.3" stdsetdef="1">
-<class>ConfigDialog</class>
-<widget class="TQWidget">
- <property name="name">
- <cstring>ConfigDialog</cstring>
- </property>
- <property name="geometry">
- <rect>
- <x>0</x>
- <y>0</y>
- <width>541</width>
- <height>170</height>
- </rect>
- </property>
- <property name="caption">
- <string>Config Dialog</string>
- </property>
- <vbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <property name="margin">
- <number>0</number>
- </property>
- <widget class="TQButtonGroup">
- <property name="name">
- <cstring>titleAlign</cstring>
- </property>
- <property name="title">
- <string>Title &amp;Alignment</string>
- </property>
- <hbox>
- <property name="name">
- <cstring>unnamed</cstring>
- </property>
- <widget class="TQRadioButton">
- <property name="name">
- <cstring>AlignLeft</cstring>
- </property>
- <property name="text">
- <string>Left</string>
- </property>
- </widget>
- <widget class="TQRadioButton">
- <property name="name">
- <cstring>AlignHCenter</cstring>
- </property>
- <property name="text">
- <string>Center</string>
- </property>
- </widget>
- <widget class="TQRadioButton">
- <property name="name">
- <cstring>AlignRight</cstring>
- </property>
- <property name="text">
- <string>Right</string>
- </property>
- </widget>
- </hbox>
- </widget>
- <widget class="TQCheckBox">
- <property name="name">
- <cstring>coloredBorder</cstring>
- </property>
- <property name="text">
- <string>Colored window border</string>
- </property>
- <property name="accel">
- <string></string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Check this option if the window border should be painted in the titlebar color. Otherwise it will be painted in the background color.</string>
- </property>
- </widget>
- <widget class="TQCheckBox">
- <property name="name">
- <cstring>titleShadow</cstring>
- </property>
- <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>
- <widget class="TQCheckBox">
- <property name="name">
- <cstring>animateButtons</cstring>
- </property>
- <property name="text">
- <string>Animate buttons</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Check this option if you want the buttons to fade in when the mouse pointer hovers over them and fade out again when it moves away.</string>
- </property>
- </widget>
- <widget class="TQCheckBox">
- <property name="name">
- <cstring>menuClose</cstring>
- </property>
- <property name="text">
- <string>Close windows by double clicking the menu button</string>
- </property>
- <property name="whatsThis" stdset="0">
- <string>Check this option if you want windows to be closed when you double click the menu button, similar to Microsoft Windows.</string>
- </property>
- </widget>
- </vbox>
-</widget>
-<tabstops>
- <tabstop>AlignLeft</tabstop>
- <tabstop>AlignHCenter</tabstop>
- <tabstop>AlignRight</tabstop>
- <tabstop>animateButtons</tabstop>
- <tabstop>titleShadow</tabstop>
-</tabstops>
-<layoutdefaults spacing="6" margin="11"/>
-</UI>
diff --git a/kwin/clients/plastik/misc.cpp b/kwin/clients/plastik/misc.cpp
deleted file mode 100644
index 1b259d383..000000000
--- a/kwin/clients/plastik/misc.cpp
+++ /dev/null
@@ -1,85 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 <kpixmap.h>
-#include <kpixmapeffect.h>
-
-#include <tqcolor.h>
-#include <tqimage.h>
-#include <tqpainter.h>
-
-#include "misc.h"
-
-TQColor hsvRelative(const TQColor& baseColor, int relativeH, int relativeS, int relativeV)
-{
- int h, s, v;
- baseColor.hsv(&h, &s, &v);
-
- h += relativeH;
- s += relativeS;
- v += relativeV;
-
- if(h < 0) { h = 0; }
- else if(h > 359) { h = 359; }
- if(s < 0) { s = 0; }
- else if(s > 255) { s = 255; }
- if(v < 0) { v = 0; }
- else if(v > 255) { v = 255; }
-
- TQColor c;
- c.setHsv( h, s, v );
- return c;
-}
-
-TQColor alphaBlendColors(const TQColor &bgColor, const TQColor &fgColor, const int a)
-{
-
- // normal button...
- QRgb rgb = bgColor.rgb();
- QRgb rgb_b = fgColor.rgb();
- int alpha = a;
- if(alpha>255) alpha = 255;
- if(alpha<0) alpha = 0;
- int inv_alpha = 255 - alpha;
-
- TQColor result = TQColor( tqRgb(tqRed(rgb_b)*inv_alpha/255 + tqRed(rgb)*alpha/255,
- tqGreen(rgb_b)*inv_alpha/255 + tqGreen(rgb)*alpha/255,
- tqBlue(rgb_b)*inv_alpha/255 + tqBlue(rgb)*alpha/255) );
-
- return result;
-}
-
-TQImage recolorImage(TQImage *img, TQColor color) {
- TQImage destImg(img->width(),img->height(),32);
- destImg.setAlphaBuffer(true);
- for (int x = 0; x < img->width(); x++) {
- for (int y = 0; y < img->height(); y++) {
- if(img->pixel(x,y) == tqRgb(0,0,255) ) {
- destImg.setPixel(x,y,color.rgb() ); // set to the new color
- } else {
- destImg.setPixel(x,y,tqRgba(0,0,0,0) ); // set transparent...
- }
- }
- }
-
- return destImg;
-}
diff --git a/kwin/clients/plastik/misc.h b/kwin/clients/plastik/misc.h
deleted file mode 100644
index 985b405e8..000000000
--- a/kwin/clients/plastik/misc.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 MISC_H
-#define MISC_H
-
-TQColor hsvRelative(const TQColor& baseColor, int relativeH, int relativeS = 0, int relativeV = 0);
-TQColor alphaBlendColors(const TQColor &backgroundColor, const TQColor &foregroundColor, const int alpha);
-TQImage recolorImage(TQImage *img, TQColor color);
-
-#endif // MISC_H
diff --git a/kwin/clients/plastik/plastik.cpp b/kwin/clients/plastik/plastik.cpp
deleted file mode 100644
index 9faf73df0..000000000
--- a/kwin/clients/plastik/plastik.cpp
+++ /dev/null
@@ -1,598 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003-2005 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 <tqbitmap.h>
-#include <tqpainter.h>
-#include <tqimage.h>
-
-#include <kconfig.h>
-#include <kpixmap.h>
-#include <kpixmapeffect.h>
-
-#include "misc.h"
-#include "plastik.h"
-#include "plastik.moc"
-#include "plastikclient.h"
-#include "plastikbutton.h"
-
-namespace KWinPlastik
-{
-
-PlastikHandler::PlastikHandler()
-{
- memset(m_pixmaps, 0, sizeof(TQPixmap*)*NumPixmaps*2*2); // set elements to 0
- memset(m_bitmaps, 0, sizeof(TQBitmap*)*NumButtonIcons*2);
-
- reset(0);
-}
-
-PlastikHandler::~PlastikHandler()
-{
- for (int t=0; t < 2; ++t)
- for (int a=0; a < 2; ++a)
- for (int i=0; i < NumPixmaps; ++i)
- delete m_pixmaps[t][a][i];
- for (int t=0; t < 2; ++t)
- for (int i=0; i < NumButtonIcons; ++i)
- delete m_bitmaps[t][i];
-}
-
-bool PlastikHandler::reset(unsigned long changed)
-{
- // we assume the active font to be the same as the inactive font since the control
- // center doesn't offer different settings anyways.
- m_titleFont = KDecoration::options()->font(true, false); // not small
- m_titleFontTool = KDecoration::options()->font(true, true); // small
-
- switch(KDecoration::options()->preferredBorderSize( this )) {
- case BorderTiny:
- m_borderSize = 3;
- break;
- case BorderLarge:
- m_borderSize = 8;
- break;
- case BorderVeryLarge:
- m_borderSize = 12;
- break;
- case BorderHuge:
- m_borderSize = 18;
- break;
- case BorderVeryHuge:
- m_borderSize = 27;
- break;
- case BorderOversized:
- m_borderSize = 40;
- break;
- case BorderNormal:
- default:
- m_borderSize = 4;
- }
-
- // check if we are in reverse layout mode
- m_reverse = TQApplication::reverseLayout();
-
- // read in the configuration
- readConfig();
-
- // pixmaps probably need to be updated, so delete the cache.
- for (int t=0; t < 2; ++t) {
- for (int a=0; a < 2; ++a) {
- for (int i=0; i < NumPixmaps; i++) {
- if (m_pixmaps[t][a][i]) {
- delete m_pixmaps[t][a][i];
- m_pixmaps[t][a][i] = 0;
- }
- }
- }
- }
- for (int t=0; t < 2; ++t) {
- for (int i=0; i < NumButtonIcons; i++) {
- if (m_bitmaps[t][i]) {
- delete m_bitmaps[t][i];
- m_bitmaps[t][i] = 0;
- }
- }
- }
-
- // Do we need to "hit the wooden hammer" ?
- bool needHardReset = true;
- // TODO: besides the Color and Font settings I can maybe handle more changes
- // without a hard reset. I will do this later...
- if (changed & SettingColors || changed & SettingFont)
- {
- needHardReset = false;
- } else if (changed & SettingButtons) {
- // handled by KCommonDecoration
- needHardReset = false;
- }
-
- if (needHardReset) {
- return true;
- } else {
- resetDecorations(changed);
- return false;
- }
-}
-
-KDecoration* PlastikHandler::createDecoration( KDecorationBridge* bridge )
-{
- return new PlastikClient( bridge, this );
-}
-
-bool PlastikHandler::supports( Ability ability )
-{
- switch( ability )
- {
- case AbilityAnnounceButtons:
- case AbilityButtonMenu:
- case AbilityButtonOnAllDesktops:
- case AbilityButtonSpacer:
- case AbilityButtonHelp:
- case AbilityButtonMinimize:
- case AbilityButtonMaximize:
- case AbilityButtonClose:
- case AbilityButtonAboveOthers:
- case AbilityButtonBelowOthers:
- case AbilityButtonShade:
- return true;
- default:
- return false;
- };
-}
-
-void PlastikHandler::readConfig()
-{
- // create a config object
- KConfig config("twinplastikrc");
- config.setGroup("General");
-
- // grab settings
- m_titleShadow = config.readBoolEntry("TitleShadow", true);
-
- TQFontMetrics fm(m_titleFont); // active font = inactive font
- int titleHeightMin = config.readNumEntry("MinTitleHeight", 16);
- // The title should strech with bigger font sizes!
- m_titleHeight = QMAX(titleHeightMin, fm.height() + 4); // 4 px for the shadow etc.
- // have an even title/button size so the button icons are fully centered...
- if ( m_titleHeight%2 == 0)
- m_titleHeight++;
-
- fm = TQFontMetrics(m_titleFontTool); // active font = inactive font
- int titleHeightToolMin = config.readNumEntry("MinTitleHeightTool", 13);
- // The title should strech with bigger font sizes!
- m_titleHeightTool = QMAX(titleHeightToolMin, fm.height() ); // don't care about the shadow etc.
- // have an even title/button size so the button icons are fully centered...
- if ( m_titleHeightTool%2 == 0)
- m_titleHeightTool++;
-
- TQString value = config.readEntry("TitleAlignment", "AlignLeft");
- if (value == "AlignLeft") m_titleAlign = Qt::AlignLeft;
- else if (value == "AlignHCenter") m_titleAlign = Qt::AlignHCenter;
- else if (value == "AlignRight") m_titleAlign = Qt::AlignRight;
-
- m_coloredBorder = config.readBoolEntry("ColoredBorder", true);
- m_animateButtons = config.readBoolEntry("AnimateButtons", true);
- m_menuClose = config.readBoolEntry("CloseOnMenuDoubleClick", true);
-}
-
-TQColor PlastikHandler::getColor(KWinPlastik::ColorType type, const bool active)
-{
- switch (type) {
- case WindowContour:
- return KDecoration::options()->color(ColorTitleBar, active).dark(200);
- case TitleGradient1:
- return hsvRelative(KDecoration::options()->color(ColorTitleBar, active), 0,-10,+10);
- break;
- case TitleGradient2:
- return hsvRelative(KDecoration::options()->color(ColorTitleBar, active), 0,0,-25);
- break;
- case TitleGradient3:
- return KDecoration::options()->color(ColorTitleBar, active);
- break;
- case ShadeTitleLight:
- return alphaBlendColors(KDecoration::options()->color(ColorTitleBar, active),
- Qt::white, active?205:215);
- break;
- case ShadeTitleDark:
- return alphaBlendColors(KDecoration::options()->color(ColorTitleBar, active),
- Qt::black, active?205:215);
- break;
- case Border:
- return KDecoration::options()->color(ColorFrame, active);
- case TitleFont:
- return KDecoration::options()->color(ColorFont, active);
- default:
- return Qt::black;
- }
-}
-
-void PlastikHandler::pretile( TQPixmap *&pix, int size, Qt::Orientation dir ) const
-{
- TQPixmap *newpix;
- TQPainter p;
-
- if ( dir == Qt::Horizontal )
- newpix = new TQPixmap( size, pix->height() );
- else
- newpix = new TQPixmap( pix->width(), size );
-
- p.begin( newpix );
- p.drawTiledPixmap( newpix->rect(), *pix ) ;
- p.end();
-
- delete pix;
- pix = newpix;
-}
-
-const TQPixmap &PlastikHandler::pixmap(Pixmaps type, bool active, bool toolWindow)
-{
- if (m_pixmaps[toolWindow][active][type])
- return *m_pixmaps[toolWindow][active][type];
-
- TQPixmap *pm = 0;
-
- switch (type) {
- case TitleBarTileTop:
- case TitleBarTile:
- {
- const int titleBarTileHeight = (toolWindow ? m_titleHeightTool : m_titleHeight) + 2;
- // gradient used as well in TitleBarTileTop as TitleBarTile
- const int gradientHeight = 2 + titleBarTileHeight-1;
- TQPixmap gradient(1, gradientHeight);
- TQPainter painter(&gradient);
- KPixmap tempPixmap;
- tempPixmap.resize(1, 4);
- KPixmapEffect::gradient(tempPixmap,
- getColor(TitleGradient1, active),
- getColor(TitleGradient2, active),
- KPixmapEffect::VerticalGradient);
- painter.drawPixmap(0,0, tempPixmap);
- tempPixmap.resize(1, gradientHeight-4);
- KPixmapEffect::gradient(tempPixmap,
- getColor(TitleGradient2, active),
- getColor(TitleGradient3, active),
- KPixmapEffect::VerticalGradient);
- painter.drawPixmap(0,4, tempPixmap);
- painter.end();
-
- // actual titlebar tiles
- if (type == TitleBarTileTop) {
- pm = new TQPixmap(1, 4);
- painter.begin(pm);
- // contour
- painter.setPen(getColor(WindowContour, active) );
- painter.drawPoint(0,0);
- // top highlight
- painter.setPen(getColor(ShadeTitleLight, active) );
- painter.drawPoint(0,1);
- // gradient
- painter.drawPixmap(0, 2, gradient);
- painter.end();
- } else {
- pm = new TQPixmap(1, titleBarTileHeight);
- painter.begin(pm);
- painter.tqdrawPixmap(0, 0, gradient, 0,2);
- if (m_coloredBorder) {
- painter.setPen(getColor(TitleGradient3, active).dark(110) );
- } else {
- painter.setPen(getColor(TitleGradient3, active) );
- }
- painter.drawPoint(0,titleBarTileHeight-1);
- painter.end();
- }
-
- pretile(pm, 64, Qt::Horizontal);
-
- break;
- }
-
- case TitleBarLeft:
- {
- const int w = m_borderSize;
- const int h = 4 + (toolWindow ? m_titleHeightTool : m_titleHeight) + 2;
-
- pm = new TQPixmap(w, h);
- TQPainter painter(pm);
-
- painter.drawTiledPixmap(0,0, w, 4, pixmap(TitleBarTileTop, active, toolWindow) );
- painter.drawTiledPixmap(0,4, w, h-4, pixmap(TitleBarTile, active, toolWindow) );
-
- painter.setPen(getColor(WindowContour, active) );
- painter.drawLine(0,0, 0,h);
- painter.drawPoint(1,1);
-
- const TQColor highlightTitleLeft = getColor(ShadeTitleLight, active);
- painter.setPen(highlightTitleLeft);
- painter.drawLine(1,2, 1,h);
-
- if (m_coloredBorder) {
- painter.setPen(getColor(TitleGradient3, active) );
- painter.drawLine(2,h-1, w-1,h-1);
- }
-
- // outside the region normally masked by doShape
- painter.setPen(TQColor(0,0,0) );
- painter.drawLine(0, 0, 1, 0 );
- painter.drawPoint(0, 1);
-
- break;
- }
-
- case TitleBarRight:
- {
- const int w = m_borderSize;
- const int h = 4 + (toolWindow ? m_titleHeightTool : m_titleHeight) + 2;
-
- pm = new TQPixmap(w, h);
- TQPainter painter(pm);
-
- painter.drawTiledPixmap(0,0, w, 4, pixmap(TitleBarTileTop, active, toolWindow) );
- painter.drawTiledPixmap(0,4, w, h-4, pixmap(TitleBarTile, active, toolWindow) );
-
- painter.setPen(getColor(WindowContour, active) );
- painter.drawLine(w-1,0, w-1,h);
- painter.drawPoint(w-2,1);
-
- const TQColor highlightTitleRight = getColor(ShadeTitleDark, active);
- painter.setPen(highlightTitleRight);
- painter.drawLine(w-2,2, w-2,h);
-
- if (m_coloredBorder) {
- painter.setPen(getColor(TitleGradient3, active) );
- painter.drawLine(0,h-1, w-3,h-1);
- }
-
- // outside the region normally masked by doShape
- painter.setPen(TQColor(0,0,0) );
- painter.drawLine(w-2, 0, w-1, 0 );
- painter.drawPoint(w-1, 1);
-
- break;
- }
-
- case BorderLeftTile:
- {
- const int w = m_borderSize;
-
- pm = new TQPixmap(w, 1);
- TQPainter painter(pm);
- if (m_coloredBorder) {
- painter.setPen(getColor(WindowContour, active) );
- painter.drawPoint(0, 0);
- painter.setPen(getColor(ShadeTitleLight, active) );
- painter.drawPoint(1, 0);
- if (w > 3) {
- painter.setPen(getColor(TitleGradient3, active) );
- painter.drawLine(2,0, w-2,0);
- }
- painter.setPen(getColor(TitleGradient3, active).dark(110) );
- painter.drawPoint(w-1,0);
- } else {
- painter.setPen(getColor(WindowContour, active) );
- painter.drawPoint(0, 0);
- painter.setPen(
- alphaBlendColors(getColor(Border, active),
- getColor(ShadeTitleLight, active), 130) );
- painter.drawPoint(1, 0);
- painter.setPen(getColor(Border, active) );
- painter.drawLine(2,0, w-1,0);
- }
-
- painter.end();
-
- pretile(pm, 64, Qt::Vertical);
-
- break;
- }
-
- case BorderRightTile:
- {
- const int w = m_borderSize;
-
- pm = new TQPixmap(w, 1);
- TQPainter painter(pm);
- if (m_coloredBorder) {
- painter.setPen(getColor(TitleGradient3, active).dark(110) );
- painter.drawPoint(0,0);
- if (w > 3) {
- painter.setPen(getColor(TitleGradient3, active) );
- painter.drawLine(1,0, w-3,0);
- }
- painter.setPen(getColor(ShadeTitleDark, active) );
- painter.drawPoint(w-2, 0);
- painter.setPen(getColor(WindowContour, active) );
- painter.drawPoint(w-1, 0);
- } else {
- painter.setPen(getColor(Border, active) );
- painter.drawLine(0,0, w-3,0);
- painter.setPen(
- alphaBlendColors(getColor(Border, active),
- getColor(ShadeTitleDark, active), 130) );
- painter.drawPoint(w-2, 0);
- painter.setPen(getColor(WindowContour, active) );
- painter.drawPoint(w-1, 0);
- }
- painter.end();
-
- pretile(pm, 64, Qt::Vertical);
-
- break;
- }
-
- case BorderBottomLeft:
- {
- const int w = m_borderSize;
- const int h = m_borderSize;
-
- pm = new TQPixmap(w, h);
- TQPainter painter(pm);
- painter.drawTiledPixmap(0,0,w,h, pixmap(BorderBottomTile, active, toolWindow) );
- painter.setPen(getColor(WindowContour, active) );
- painter.drawLine(0,0, 0,h);
- if (m_coloredBorder) {
- if (h > 3) {
- painter.setPen(getColor(ShadeTitleLight, active) );
- painter.drawLine(1,0, 1,h-2);
- }
-
- painter.setPen(getColor(TitleGradient3, active) );
- painter.drawLine(2,0, w-1,0);
- } else {
- painter.setPen(
- alphaBlendColors(getColor(Border, active),
- getColor(ShadeTitleLight, active), 130) );
- painter.drawLine(1,0, 1,h-2);
- }
-
- painter.end();
-
- break;
- }
-
- case BorderBottomRight:
- {
- const int w = m_borderSize;
- const int h = m_borderSize;
-
- pm = new TQPixmap(w, h);
- TQPainter painter(pm);
- painter.drawTiledPixmap(0,0,w,h, pixmap(BorderBottomTile, active, toolWindow) );
- painter.setPen(getColor(WindowContour, active) );
- painter.drawLine(w-1,0, w-1,h);
- if (m_coloredBorder) {
- painter.setPen(getColor(ShadeTitleDark, active) );
- painter.drawLine(w-2,0, w-2,h-2);
-
- painter.setPen(getColor(TitleGradient3, active) );
- painter.drawLine(0,0, w-3,0);
- } else {
- painter.setPen(
- alphaBlendColors(getColor(Border, active),
- getColor(ShadeTitleDark, active), 130) );
- painter.drawLine(w-2,0, w-2,h-2);
- }
-
- painter.end();
-
- break;
- }
-
- case BorderBottomTile:
- default:
- {
- const int h = m_borderSize;
-
- pm = new TQPixmap(1, m_borderSize);
- TQPainter painter(pm);
-
- if (m_coloredBorder) {
- painter.setPen(getColor(TitleGradient3, active).dark(110) );
- painter.drawPoint(0,0);
- painter.setPen(getColor(TitleGradient3, active) );
- painter.drawLine(0,1, 0,h-3);
- painter.setPen(getColor(ShadeTitleDark, active) );
- painter.drawPoint(0, h-2);
- } else {
- painter.setPen(getColor(Border, active) );
- painter.drawLine(0,0, 0,h-3);
- painter.setPen(
- alphaBlendColors(getColor(Border, active),
- getColor(ShadeTitleDark, active), 130) );
- painter.drawPoint(0, h-2);
- }
- painter.setPen(getColor(WindowContour, active) );
- painter.drawPoint(0, h-1);
- painter.end();
-
- pretile(pm, 64, Qt::Horizontal);
-
- break;
- }
- }
-
- m_pixmaps[toolWindow][active][type] = pm;
- return *pm;
-}
-
-const TQBitmap &PlastikHandler::buttonBitmap(ButtonIcon type, const TQSize &size, bool toolWindow)
-{
- int typeIndex = type;
-
- // btn icon size...
- int reduceW = 0, reduceH = 0;
- if(size.width()>14) {
- reduceW = static_cast<int>(2*(size.width()/3.5) );
- }
- else
- reduceW = 6;
- if(size.height()>14)
- reduceH = static_cast<int>(2*(size.height()/3.5) );
- else
- reduceH = 6;
-
- int w = size.width() - reduceW;
- int h = size.height() - reduceH;
-
- if (m_bitmaps[toolWindow][typeIndex] && m_bitmaps[toolWindow][typeIndex]->size()==TQSize(w,h) )
- return *m_bitmaps[toolWindow][typeIndex];
-
- // no matching pixmap found, create a new one...
-
- delete m_bitmaps[toolWindow][typeIndex];
- m_bitmaps[toolWindow][typeIndex] = 0;
-
- TQBitmap bmp = IconEngine::icon(type /*icon*/, QMIN(w,h) );
- TQBitmap *bitmap = new TQBitmap(bmp);
- m_bitmaps[toolWindow][typeIndex] = bitmap;
- return *bitmap;
-}
-
-TQValueList< PlastikHandler::BorderSize >
-PlastikHandler::borderSizes() const
-{
- // the list must be sorted
- return TQValueList< BorderSize >() << BorderTiny << BorderNormal <<
- BorderLarge << BorderVeryLarge << BorderHuge <<
- BorderVeryHuge << BorderOversized;
-}
-
-// make the handler accessible to other classes...
-static PlastikHandler *handler = 0;
-PlastikHandler* Handler()
-{
- return handler;
-}
-
-} // KWinPlastik
-
-//////////////////////////////////////////////////////////////////////////////
-// Plugin Stuff //
-//////////////////////////////////////////////////////////////////////////////
-
-extern "C"
-{
- KDE_EXPORT KDecorationFactory *create_factory()
- {
- KWinPlastik::handler = new KWinPlastik::PlastikHandler();
- return KWinPlastik::handler;
- }
-}
diff --git a/kwin/clients/plastik/plastik.desktop b/kwin/clients/plastik/plastik.desktop
deleted file mode 100644
index 874719191..000000000
--- a/kwin/clients/plastik/plastik.desktop
+++ /dev/null
@@ -1,37 +0,0 @@
-[Desktop Entry]
-Icon=
-Name=Plastik
-Name[af]=Plastiek
-Name[ar]=بلاستيك
-Name[be]=Пластык
-Name[bn]=প্লাস্টিক
-Name[eo]=Plastiko
-Name[fa]=پلاستیک
-Name[fy]=Plastyk
-Name[hi]=प्लास्टिक
-Name[hr]=Plastika
-Name[is]=Plast
-Name[it]=Plastica
-Name[ka]=Пластик
-Name[kk]=Пластик
-Name[km]=ប្ល៉ាស្ទិក
-Name[lt]=Plastikinis
-Name[lv]=Plastika
-Name[mk]=Пластик
-Name[nb]=Plast
-Name[ne]=प्लास्टिक
-Name[nn]=Plast
-Name[pa]=ਪਲਾਸਟਿਕ
-Name[ro]=Plastic
-Name[ru]=Пластик
-Name[se]=Plastihkka
-Name[sr]=Пластика
-Name[sr@Latn]=Plastika
-Name[ta]=திட்டம்
-Name[te]=ప్లాస్టిక్
-Name[th]=พลาสติก
-Name[uk]=Пластик
-Name[uz@cyrillic]=Пластик
-Name[vi]=Chất dẻo
-Name[zh_CN]=塑料
-X-KDE-Library=twin3_plastik
diff --git a/kwin/clients/plastik/plastik.h b/kwin/clients/plastik/plastik.h
deleted file mode 100644
index a4c1bc5b7..000000000
--- a/kwin/clients/plastik/plastik.h
+++ /dev/null
@@ -1,127 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003-2005 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 PLASTIK_H
-#define PLASTIK_H
-
-#include <tqfont.h>
-
-#include <kdecoration.h>
-#include <kdecorationfactory.h>
-
-namespace KWinPlastik {
-
-enum ColorType {
- WindowContour=0,
- TitleGradient1, // top
- TitleGradient2,
- TitleGradient3, // bottom
- ShadeTitleLight,
- ShadeTitleDark,
- Border,
- TitleFont
-};
-
-enum Pixmaps {
- TitleBarTileTop=0,
- TitleBarTile,
- TitleBarLeft,
- TitleBarRight,
- BorderLeftTile,
- BorderRightTile,
- BorderBottomTile,
- BorderBottomLeft,
- BorderBottomRight,
- NumPixmaps
-};
-
-enum ButtonIcon {
- CloseIcon = 0,
- MaxIcon,
- MaxRestoreIcon,
- MinIcon,
- HelpIcon,
- OnAllDesktopsIcon,
- NotOnAllDesktopsIcon,
- KeepAboveIcon,
- NoKeepAboveIcon,
- KeepBelowIcon,
- NoKeepBelowIcon,
- ShadeIcon,
- UnShadeIcon,
- NumButtonIcons
-};
-
-class PlastikHandler: public TQObject, public KDecorationFactory
-{
- Q_OBJECT
-public:
- PlastikHandler();
- ~PlastikHandler();
- virtual bool reset( unsigned long changed );
-
- virtual KDecoration* createDecoration( KDecorationBridge* );
- virtual bool supports( Ability ability );
-
- const TQPixmap &pixmap(Pixmaps type, bool active, bool toolWindow);
- const TQBitmap &buttonBitmap(ButtonIcon type, const TQSize &size, bool toolWindow);
-
- int titleHeight() { return m_titleHeight; }
- int titleHeightTool() { return m_titleHeightTool; }
- const TQFont &titleFont() { return m_titleFont; }
- const TQFont &titleFontTool() { return m_titleFontTool; }
- bool titleShadow() { return m_titleShadow; }
- int borderSize() { return m_borderSize; }
- bool animateButtons() { return m_animateButtons; }
- bool menuClose() { return m_menuClose; }
- TQ_Alignment titleAlign() { return m_titleAlign; }
- bool reverseLayout() { return m_reverse; }
- TQColor getColor(KWinPlastik::ColorType type, const bool active = true);
-
- TQValueList< PlastikHandler::BorderSize > borderSizes() const;
-private:
- void readConfig();
-
- void pretile(TQPixmap *&pix, int size, Qt::Orientation dir) const;
-
- bool m_coloredBorder;
- bool m_titleShadow;
- bool m_animateButtons;
- bool m_menuClose;
- bool m_reverse;
- int m_borderSize;
- int m_titleHeight;
- int m_titleHeightTool;
- TQFont m_titleFont;
- TQFont m_titleFontTool;
- TQ_Alignment m_titleAlign;
-
- // pixmap cache
- TQPixmap *m_pixmaps[2][2][NumPixmaps]; // button pixmaps have normal+pressed state...
- TQBitmap *m_bitmaps[2][NumButtonIcons];
-};
-
-PlastikHandler* Handler();
-
-} // KWinPlastik
-
-#endif // PLASTIK_H
diff --git a/kwin/clients/plastik/plastikbutton.cpp b/kwin/clients/plastik/plastikbutton.cpp
deleted file mode 100644
index 5f81033cb..000000000
--- a/kwin/clients/plastik/plastikbutton.cpp
+++ /dev/null
@@ -1,629 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003-2005 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 <twin/options.h>
-
-#include <tqbitmap.h>
-#include <tqpainter.h>
-#include <tqpixmap.h>
-#include <kpixmap.h>
-#include <kpixmapeffect.h>
-#include <tqtimer.h>
-
-#include "plastikbutton.h"
-#include "plastikbutton.moc"
-#include "plastikclient.h"
-#include "misc.h"
-
-namespace KWinPlastik
-{
-
-static const uint TIMERINTERVAL = 50; // msec
-static const uint ANIMATIONSTEPS = 4;
-
-PlastikButton::PlastikButton(ButtonType type, PlastikClient *parent, const char *name)
- : KCommonDecorationButton(type, parent, name),
- m_client(parent),
- m_iconType(NumButtonIcons),
- hover(false)
-{
- setBackgroundMode(NoBackground);
-
- // no need to reset here as the button will be resetted on first resize.
-
- animTmr = new TQTimer(this);
- connect(animTmr, TQT_SIGNAL(timeout() ), this, TQT_SLOT(animate() ) );
- animProgress = 0;
-}
-
-PlastikButton::~PlastikButton()
-{
-}
-
-void PlastikButton::reset(unsigned long changed)
-{
- if (changed&DecorationReset || changed&ManualReset || changed&SizeChange || changed&StateChange) {
- switch (type() ) {
- case CloseButton:
- m_iconType = CloseIcon;
- break;
- case HelpButton:
- m_iconType = HelpIcon;
- break;
- case MinButton:
- m_iconType = MinIcon;
- break;
- case MaxButton:
- if (isOn()) {
- m_iconType = MaxRestoreIcon;
- } else {
- m_iconType = MaxIcon;
- }
- break;
- case OnAllDesktopsButton:
- if (isOn()) {
- m_iconType = NotOnAllDesktopsIcon;
- } else {
- m_iconType = OnAllDesktopsIcon;
- }
- break;
- case ShadeButton:
- if (isOn()) {
- m_iconType = UnShadeIcon;
- } else {
- m_iconType = ShadeIcon;
- }
- break;
- case AboveButton:
- if (isOn()) {
- m_iconType = NoKeepAboveIcon;
- } else {
- m_iconType = KeepAboveIcon;
- }
- break;
- case BelowButton:
- if (isOn()) {
- m_iconType = NoKeepBelowIcon;
- } else {
- m_iconType = KeepBelowIcon;
- }
- break;
- default:
- m_iconType = NumButtonIcons; // empty...
- break;
- }
-
- this->update();
- }
-}
-
-void PlastikButton::animate()
-{
- animTmr->stop();
-
- if(hover) {
- if(animProgress < ANIMATIONSTEPS) {
- if (Handler()->animateButtons() ) {
- animProgress++;
- } else {
- animProgress = ANIMATIONSTEPS;
- }
- animTmr->start(TIMERINTERVAL, true); // single-shot
- }
- } else {
- if(animProgress > 0) {
- if (Handler()->animateButtons() ) {
- animProgress--;
- } else {
- animProgress = 0;
- }
- animTmr->start(TIMERINTERVAL, true); // single-shot
- }
- }
-
- tqrepaint(false);
-}
-
-void PlastikButton::enterEvent(TQEvent *e)
-{
- TQButton::enterEvent(e);
-
- hover = true;
- animate();
-}
-
-void PlastikButton::leaveEvent(TQEvent *e)
-{
- TQButton::leaveEvent(e);
-
- hover = false;
- animate();
-}
-
-void PlastikButton::drawButton(TQPainter *painter)
-{
- TQRect r(0,0,width(),height());
-
- bool active = m_client->isActive();
- KPixmap tempKPixmap;
-
- TQColor highlightColor;
- if(type() == CloseButton) {
- highlightColor = TQColor(255,64,0);
- } else {
- highlightColor = Qt::white;
- }
-
- TQColor contourTop = alphaBlendColors(Handler()->getColor(TitleGradient2, active),
- Qt::black, 215);
- TQColor contourBottom = alphaBlendColors(Handler()->getColor(TitleGradient3, active),
- Qt::black, 215);
- TQColor sourfaceTop = alphaBlendColors(Handler()->getColor(TitleGradient2, active),
- Qt::white, 210);
- TQColor sourfaceBottom = alphaBlendColors(Handler()->getColor(TitleGradient3, active),
- Qt::white, 210);
-
- int highlightAlpha = static_cast<int>(255-((60/static_cast<double>(ANIMATIONSTEPS))*
- static_cast<double>(animProgress) ) );
- contourTop = alphaBlendColors(contourTop, highlightColor, highlightAlpha );
- contourBottom = alphaBlendColors(contourBottom, highlightColor, highlightAlpha);
- sourfaceTop = alphaBlendColors(sourfaceTop, highlightColor, highlightAlpha);
- sourfaceBottom = alphaBlendColors(sourfaceBottom, highlightColor, highlightAlpha);
-
- if (isDown() ) {
- contourTop = alphaBlendColors(contourTop, Qt::black, 200);
- contourBottom = alphaBlendColors(contourBottom, Qt::black, 200);
- sourfaceTop = alphaBlendColors(sourfaceTop, Qt::black, 200);
- sourfaceBottom = alphaBlendColors(sourfaceBottom, Qt::black, 200);
- }
-
- TQPixmap buffer;
- buffer.resize(width(), height());
- TQPainter bP(&buffer);
-
- // fake the titlebar background
- bP.drawTiledPixmap(0, 0, width(), width(), m_client->getTitleBarTile(active) );
-
- if (type() != MenuButton || hover || animProgress != 0) {
- // contour
- bP.setPen(contourTop);
- bP.drawLine(r.x()+2, r.y(), r.right()-2, r.y() );
- bP.drawPoint(r.x()+1, r.y()+1);
- bP.drawPoint(r.right()-1, r.y()+1);
- bP.setPen(contourBottom);
- bP.drawLine(r.x()+2, r.bottom(), r.right()-2, r.bottom() );
- bP.drawPoint(r.x()+1, r.bottom()-1);
- bP.drawPoint(r.right()-1, r.bottom()-1);
- // sides of the contour
- tempKPixmap.resize(1, r.height()-2*2);
- KPixmapEffect::gradient(tempKPixmap,
- contourTop,
- contourBottom,
- KPixmapEffect::VerticalGradient);
- bP.drawPixmap(r.x(), r.y()+2, tempKPixmap);
- bP.drawPixmap(r.right(), r.y()+2, tempKPixmap);
- // sort of anti-alias for the contour
- bP.setPen(alphaBlendColors(Handler()->getColor(TitleGradient2, active),
- contourTop, 150) );
- bP.drawPoint(r.x()+1, r.y());
- bP.drawPoint(r.right()-1, r.y());
- bP.drawPoint(r.x(), r.y()+1);
- bP.drawPoint(r.right(), r.y()+1);
- bP.setPen(alphaBlendColors(Handler()->getColor(TitleGradient3, active),
- contourBottom, 150) );
- bP.drawPoint(r.x()+1, r.bottom());
- bP.drawPoint(r.right()-1, r.bottom());
- bP.drawPoint(r.x(), r.bottom()-1);
- bP.drawPoint(r.right(), r.bottom()-1);
- // sourface
- // fill top and bottom
- bP.setPen(sourfaceTop);
- bP.drawLine(r.x()+2, r.y()+1, r.right()-2, r.y()+1 );
- bP.setPen(sourfaceBottom);
- bP.drawLine(r.x()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
- // fill the rest! :)
- tempKPixmap.resize(1, r.height()-2*2);
- KPixmapEffect::gradient(tempKPixmap,
- sourfaceTop,
- sourfaceBottom,
- KPixmapEffect::VerticalGradient);
- bP.drawTiledPixmap(r.x()+1, r.y()+2, r.width()-2, r.height()-4, tempKPixmap);
- }
-
- if (type() == MenuButton)
- {
- TQPixmap menuIcon(m_client->icon().pixmap( TQIconSet::Small, TQIconSet::Normal));
- if (width() < menuIcon.width() || height() < menuIcon.height() ) {
- menuIcon.convertFromImage( TQImage(menuIcon.convertToImage()).smoothScale(width(), height()));
- }
- bP.drawPixmap((width()-menuIcon.width())/2, (height()-menuIcon.height())/2, menuIcon);
- }
- else
- {
- int dX,dY;
- const TQBitmap &icon = Handler()->buttonBitmap(m_iconType, size(), decoration()->isToolWindow() );
- dX = r.x()+(r.width()-icon.width())/2;
- dY = r.y()+(r.height()-icon.height())/2;
- if (isDown() ) {
- dY++;
- }
-
- if(!isDown() && Handler()->titleShadow() ) {
- TQColor shadowColor;
- if (tqGray(Handler()->getColor(TitleFont,active).rgb()) < 100)
- shadowColor = TQColor(255, 255, 255);
- else
- shadowColor = TQColor(0,0,0);
- bP.setPen(alphaBlendColors(sourfaceTop, shadowColor, 180) );
- bP.drawPixmap(dX+1, dY+1, icon);
- }
-
- bP.setPen(Handler()->getColor(TitleFont,active) );
- bP.drawPixmap(dX, dY, icon);
- }
-
- bP.end();
- painter->drawPixmap(0, 0, buffer);
-}
-
-TQBitmap IconEngine::icon(ButtonIcon icon, int size)
-{
- if (size%2 == 0)
- --size;
-
- TQBitmap bitmap(size,size);
- bitmap.fill(Qt::color0);
- TQPainter p(&bitmap);
-
- p.setPen(Qt::color1);
-
- TQRect r = bitmap.rect();
-
- // line widths
- int lwTitleBar = 1;
- if (r.width() > 16) {
- lwTitleBar = 4;
- } else if (r.width() > 4) {
- lwTitleBar = 2;
- }
- int lwArrow = 1;
- if (r.width() > 16) {
- lwArrow = 4;
- } else if (r.width() > 7) {
- lwArrow = 2;
- }
-
- switch(icon) {
- case CloseIcon:
- {
- int lineWidth = 1;
- if (r.width() > 16) {
- lineWidth = 3;
- } else if (r.width() > 4) {
- lineWidth = 2;
- }
-
- drawObject(p, DiagonalLine, r.x(), r.y(), r.width(), lineWidth);
- drawObject(p, CrossDiagonalLine, r.x(), r.bottom(), r.width(), lineWidth);
-
- break;
- }
-
- case MaxIcon:
- {
- int lineWidth2 = 1; // frame
- if (r.width() > 16) {
- lineWidth2 = 2;
- } else if (r.width() > 4) {
- lineWidth2 = 1;
- }
-
- drawObject(p, HorizontalLine, r.x(), r.top(), r.width(), lwTitleBar);
- drawObject(p, HorizontalLine, r.x(), r.bottom()-(lineWidth2-1), r.width(), lineWidth2);
- drawObject(p, VerticalLine, r.x(), r.top(), r.height(), lineWidth2);
- drawObject(p, VerticalLine, r.right()-(lineWidth2-1), r.top(), r.height(), lineWidth2);
-
- break;
- }
-
- case MaxRestoreIcon:
- {
- int lineWidth2 = 1; // frame
- if (r.width() > 16) {
- lineWidth2 = 2;
- } else if (r.width() > 4) {
- lineWidth2 = 1;
- }
-
- int margin1, margin2;
- margin1 = margin2 = lineWidth2*2;
- if (r.width() < 8)
- margin1 = 1;
-
- // background window
- drawObject(p, HorizontalLine, r.x()+margin1, r.top(), r.width()-margin1, lineWidth2);
- drawObject(p, HorizontalLine, r.right()-margin2, r.bottom()-(lineWidth2-1)-margin1, margin2, lineWidth2);
- drawObject(p, VerticalLine, r.x()+margin1, r.top(), margin2, lineWidth2);
- drawObject(p, VerticalLine, r.right()-(lineWidth2-1), r.top(), r.height()-margin1, lineWidth2);
-
- // foreground window
- drawObject(p, HorizontalLine, r.x(), r.top()+margin2, r.width()-margin2, lwTitleBar);
- drawObject(p, HorizontalLine, r.x(), r.bottom()-(lineWidth2-1), r.width()-margin2, lineWidth2);
- drawObject(p, VerticalLine, r.x(), r.top()+margin2, r.height(), lineWidth2);
- drawObject(p, VerticalLine, r.right()-(lineWidth2-1)-margin2, r.top()+margin2, r.height(), lineWidth2);
-
- break;
- }
-
- case MinIcon:
- {
- drawObject(p, HorizontalLine, r.x(), r.bottom()-(lwTitleBar-1), r.width(), lwTitleBar);
-
- break;
- }
-
- case HelpIcon:
- {
- int center = r.x()+r.width()/2 -1;
- int side = r.width()/4;
-
- // paint a question mark... code is quite messy, to be cleaned up later...! :o
-
- if (r.width() > 16) {
- int lineWidth = 3;
-
- // top bar
- drawObject(p, HorizontalLine, center-side+3, r.y(), 2*side-3-1, lineWidth);
- // top bar rounding
- drawObject(p, CrossDiagonalLine, center-side-1, r.y()+5, 6, lineWidth);
- drawObject(p, DiagonalLine, center+side-3, r.y(), 5, lineWidth);
- // right bar
- drawObject(p, VerticalLine, center+side+2-lineWidth, r.y()+3, r.height()-(2*lineWidth+side+2+1), lineWidth);
- // bottom bar
- drawObject(p, CrossDiagonalLine, center, r.bottom()-2*lineWidth, side+2, lineWidth);
- drawObject(p, HorizontalLine, center, r.bottom()-3*lineWidth+2, lineWidth, lineWidth);
- // the dot
- drawObject(p, HorizontalLine, center, r.bottom()-(lineWidth-1), lineWidth, lineWidth);
- } else if (r.width() > 8) {
- int lineWidth = 2;
-
- // top bar
- drawObject(p, HorizontalLine, center-(side-1), r.y(), 2*side-1, lineWidth);
- // top bar rounding
- if (r.width() > 9) {
- drawObject(p, CrossDiagonalLine, center-side-1, r.y()+3, 3, lineWidth);
- } else {
- drawObject(p, CrossDiagonalLine, center-side-1, r.y()+2, 3, lineWidth);
- }
- drawObject(p, DiagonalLine, center+side-1, r.y(), 3, lineWidth);
- // right bar
- drawObject(p, VerticalLine, center+side+2-lineWidth, r.y()+2, r.height()-(2*lineWidth+side+1), lineWidth);
- // bottom bar
- drawObject(p, CrossDiagonalLine, center, r.bottom()-2*lineWidth+1, side+2, lineWidth);
- // the dot
- drawObject(p, HorizontalLine, center, r.bottom()-(lineWidth-1), lineWidth, lineWidth);
- } else {
- int lineWidth = 1;
-
- // top bar
- drawObject(p, HorizontalLine, center-(side-1), r.y(), 2*side, lineWidth);
- // top bar rounding
- drawObject(p, CrossDiagonalLine, center-side-1, r.y()+1, 2, lineWidth);
- // right bar
- drawObject(p, VerticalLine, center+side+1, r.y(), r.height()-(side+2+1), lineWidth);
- // bottom bar
- drawObject(p, CrossDiagonalLine, center, r.bottom()-2, side+2, lineWidth);
- // the dot
- drawObject(p, HorizontalLine, center, r.bottom(), 1, 1);
- }
-
- break;
- }
-
- case NotOnAllDesktopsIcon:
- {
- int lwMark = r.width()-lwTitleBar*2-2;
- if (lwMark < 1)
- lwMark = 3;
-
- drawObject(p, HorizontalLine, r.x()+(r.width()-lwMark)/2, r.y()+(r.height()-lwMark)/2, lwMark, lwMark);
-
- // Fall through to OnAllDesktopsIcon intended!
- }
- case OnAllDesktopsIcon:
- {
- // horizontal bars
- drawObject(p, HorizontalLine, r.x()+lwTitleBar, r.y(), r.width()-2*lwTitleBar, lwTitleBar);
- drawObject(p, HorizontalLine, r.x()+lwTitleBar, r.bottom()-(lwTitleBar-1), r.width()-2*lwTitleBar, lwTitleBar);
- // vertical bars
- drawObject(p, VerticalLine, r.x(), r.y()+lwTitleBar, r.height()-2*lwTitleBar, lwTitleBar);
- drawObject(p, VerticalLine, r.right()-(lwTitleBar-1), r.y()+lwTitleBar, r.height()-2*lwTitleBar, lwTitleBar);
-
-
- break;
- }
-
- case NoKeepAboveIcon:
- {
- int center = r.x()+r.width()/2;
-
- // arrow
- drawObject(p, CrossDiagonalLine, r.x(), center+2*lwArrow, center-r.x(), lwArrow);
- drawObject(p, DiagonalLine, r.x()+center, r.y()+1+2*lwArrow, center-r.x(), lwArrow);
- if (lwArrow>1)
- drawObject(p, HorizontalLine, center-(lwArrow-2), r.y()+2*lwArrow, (lwArrow-2)*2, lwArrow);
-
- // Fall through to KeepAboveIcon intended!
- }
- case KeepAboveIcon:
- {
- int center = r.x()+r.width()/2;
-
- // arrow
- drawObject(p, CrossDiagonalLine, r.x(), center, center-r.x(), lwArrow);
- drawObject(p, DiagonalLine, r.x()+center, r.y()+1, center-r.x(), lwArrow);
- if (lwArrow>1)
- drawObject(p, HorizontalLine, center-(lwArrow-2), r.y(), (lwArrow-2)*2, lwArrow);
-
- break;
- }
-
- case NoKeepBelowIcon:
- {
- int center = r.x()+r.width()/2;
-
- // arrow
- drawObject(p, DiagonalLine, r.x(), center-2*lwArrow, center-r.x(), lwArrow);
- drawObject(p, CrossDiagonalLine, r.x()+center, r.bottom()-1-2*lwArrow, center-r.x(), lwArrow);
- if (lwArrow>1)
- drawObject(p, HorizontalLine, center-(lwArrow-2), r.bottom()-(lwArrow-1)-2*lwArrow, (lwArrow-2)*2, lwArrow);
-
- // Fall through to KeepBelowIcon intended!
- }
- case KeepBelowIcon:
- {
- int center = r.x()+r.width()/2;
-
- // arrow
- drawObject(p, DiagonalLine, r.x(), center, center-r.x(), lwArrow);
- drawObject(p, CrossDiagonalLine, r.x()+center, r.bottom()-1, center-r.x(), lwArrow);
- if (lwArrow>1)
- drawObject(p, HorizontalLine, center-(lwArrow-2), r.bottom()-(lwArrow-1), (lwArrow-2)*2, lwArrow);
-
- break;
- }
-
- case ShadeIcon:
- {
- drawObject(p, HorizontalLine, r.x(), r.y(), r.width(), lwTitleBar);
-
- break;
- }
-
- case UnShadeIcon:
- {
- int lw1 = 1;
- int lw2 = 1;
- if (r.width() > 16) {
- lw1 = 4;
- lw2 = 2;
- } else if (r.width() > 7) {
- lw1 = 2;
- lw2 = 1;
- }
-
- int h = QMAX( (r.width()/2), (lw1+2*lw2) );
-
- // horizontal bars
- drawObject(p, HorizontalLine, r.x(), r.y(), r.width(), lw1);
- drawObject(p, HorizontalLine, r.x(), r.x()+h-(lw2-1), r.width(), lw2);
- // vertical bars
- drawObject(p, VerticalLine, r.x(), r.y(), h, lw2);
- drawObject(p, VerticalLine, r.right()-(lw2-1), r.y(), h, lw2);
-
- break;
- }
-
- default:
- break;
- }
-
- p.end();
-
- bitmap.setMask(bitmap);
-
- return bitmap;
-}
-
-void IconEngine::drawObject(TQPainter &p, Object object, int x, int y, int length, int lineWidth)
-{
- switch(object) {
- case DiagonalLine:
- if (lineWidth <= 1) {
- for (int i = 0; i < length; ++i) {
- p.drawPoint(x+i,y+i);
- }
- } else if (lineWidth <= 2) {
- for (int i = 0; i < length; ++i) {
- p.drawPoint(x+i,y+i);
- }
- for (int i = 0; i < (length-1); ++i) {
- p.drawPoint(x+1+i,y+i);
- p.drawPoint(x+i,y+1+i);
- }
- } else {
- for (int i = 1; i < (length-1); ++i) {
- p.drawPoint(x+i,y+i);
- }
- for (int i = 0; i < (length-1); ++i) {
- p.drawPoint(x+1+i,y+i);
- p.drawPoint(x+i,y+1+i);
- }
- for (int i = 0; i < (length-2); ++i) {
- p.drawPoint(x+2+i,y+i);
- p.drawPoint(x+i,y+2+i);
- }
- }
- break;
- case CrossDiagonalLine:
- if (lineWidth <= 1) {
- for (int i = 0; i < length; ++i) {
- p.drawPoint(x+i,y-i);
- }
- } else if (lineWidth <= 2) {
- for (int i = 0; i < length; ++i) {
- p.drawPoint(x+i,y-i);
- }
- for (int i = 0; i < (length-1); ++i) {
- p.drawPoint(x+1+i,y-i);
- p.drawPoint(x+i,y-1-i);
- }
- } else {
- for (int i = 1; i < (length-1); ++i) {
- p.drawPoint(x+i,y-i);
- }
- for (int i = 0; i < (length-1); ++i) {
- p.drawPoint(x+1+i,y-i);
- p.drawPoint(x+i,y-1-i);
- }
- for (int i = 0; i < (length-2); ++i) {
- p.drawPoint(x+2+i,y-i);
- p.drawPoint(x+i,y-2-i);
- }
- }
- break;
- case HorizontalLine:
- for (int i = 0; i < lineWidth; ++i) {
- p.drawLine(x,y+i, x+length-1, y+i);
- }
- break;
- case VerticalLine:
- for (int i = 0; i < lineWidth; ++i) {
- p.drawLine(x+i,y, x+i, y+length-1);
- }
- break;
- default:
- break;
- }
-}
-
-} // KWinPlastik
diff --git a/kwin/clients/plastik/plastikbutton.h b/kwin/clients/plastik/plastikbutton.h
deleted file mode 100644
index dbebcf63f..000000000
--- a/kwin/clients/plastik/plastikbutton.h
+++ /dev/null
@@ -1,90 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003-2005 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 PLASTIKBUTTON_H
-#define PLASTIKBUTTON_H
-
-#include <tqbutton.h>
-#include <tqimage.h>
-#include "plastik.h"
-
-#include <kcommondecoration.h>
-
-class TQTimer;
-
-namespace KWinPlastik {
-
-class PlastikClient;
-
-class PlastikButton : public KCommonDecorationButton
-{
- Q_OBJECT
-public:
- PlastikButton(ButtonType type, PlastikClient *parent, const char *name);
- ~PlastikButton();
-
- void reset(unsigned long changed);
- PlastikClient * client() { return m_client; }
-
-protected slots:
- void animate();
-
-private:
- void enterEvent(TQEvent *e);
- void leaveEvent(TQEvent *e);
- void drawButton(TQPainter *painter);
-
-private:
- PlastikClient *m_client;
- ButtonIcon m_iconType;
- bool hover;
-
- TQTimer *animTmr;
- uint animProgress;
-};
-
-/**
- * This class creates bitmaps which can be used as icons on buttons. The icons
- * are "hardcoded".
- * Over the previous "Gimp->xpm->QImage->recolor->SmoothScale->TQPixmap" solution
- * it has the important advantage that icons are more scalable and at the same
- * time sharp and not blurred.
- */
-class IconEngine
-{
- public:
- static TQBitmap icon(ButtonIcon icon, int size);
-
- private:
- enum Object {
- HorizontalLine,
- VerticalLine,
- DiagonalLine,
- CrossDiagonalLine
- };
-
- static void drawObject(TQPainter &p, Object object, int x, int y, int length, int lineWidth);
-};
-
-} // namespace KWinPlastik
-
-#endif // PLASTIKBUTTON_H
diff --git a/kwin/clients/plastik/plastikclient.cpp b/kwin/clients/plastik/plastikclient.cpp
deleted file mode 100644
index 0e72ff59c..000000000
--- a/kwin/clients/plastik/plastikclient.cpp
+++ /dev/null
@@ -1,529 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003-2005 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 <klocale.h>
-
-#include <tqbitmap.h>
-#include <tqdatetime.h>
-#include <tqfontmetrics.h>
-#include <tqimage.h>
-#include <tqlabel.h>
-#include <tqlayout.h>
-#include <tqpainter.h>
-#include <tqpixmap.h>
-#include <tqdesktopwidget.h>
-
-#include "plastikclient.h"
-#include "plastikbutton.h"
-#include "misc.h"
-
-namespace KWinPlastik
-{
-
-PlastikClient::PlastikClient(KDecorationBridge* bridge, KDecorationFactory* factory)
- : KCommonDecoration (bridge, factory),
- s_titleFont(TQFont() )
-{
- memset(m_captionPixmaps, 0, sizeof(TQPixmap*)*2);
-}
-
-PlastikClient::~PlastikClient()
-{
- clearCaptionPixmaps();
-}
-
-TQString PlastikClient::visibleName() const
-{
- return i18n("Plastik");
-}
-
-TQString PlastikClient::defaultButtonsLeft() const
-{
- return "M";
-}
-
-TQString PlastikClient::defaultButtonsRight() const
-{
- return "HIAX";
-}
-
-bool PlastikClient::decorationBehaviour(DecorationBehaviour behaviour) const
-{
- switch (behaviour) {
- case DB_MenuClose:
- return Handler()->menuClose();
-
- case DB_WindowMask:
- return true;
-
- default:
- return KCommonDecoration::decorationBehaviour(behaviour);
- }
-}
-
-int PlastikClient::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:
- {
- if (respectWindowState && maximized) {
- return 0;
- } else {
- return Handler()->borderSize();
- }
- }
-
- case LM_TitleEdgeTop:
- {
- if (respectWindowState && maximized) {
- return 0;
- } else {
- return 4;
- }
- }
-
- case LM_TitleEdgeBottom:
- {
-// if (respectWindowState && maximized) {
-// return 1;
-// } else {
- return 2;
-// }
- }
-
- case LM_TitleEdgeLeft:
- case LM_TitleEdgeRight:
- {
- if (respectWindowState && maximized) {
- return 0;
- } else {
- return 6;
- }
- }
-
- case LM_TitleBorderLeft:
- case LM_TitleBorderRight:
- return 5;
-
- case LM_ButtonWidth:
- case LM_ButtonHeight:
- case LM_TitleHeight:
- {
- if (respectWindowState && isToolWindow()) {
- return Handler()->titleHeightTool();
- } else {
- return Handler()->titleHeight();
- }
- }
-
- case LM_ButtonSpacing:
- return 1;
-
- case LM_ButtonMarginTop:
- return 0;
-
- case LM_ExplicitButtonSpacer:
- return 3;
-
- default:
- return KCommonDecoration::layoutMetric(lm, respectWindowState, btn);
- }
-}
-
-KCommonDecorationButton *PlastikClient::createButton(ButtonType type)
-{
- switch (type) {
- case MenuButton:
- return new PlastikButton(MenuButton, this, "menu");
-
- case OnAllDesktopsButton:
- return new PlastikButton(OnAllDesktopsButton, this, "on_all_desktops");
-
- case HelpButton:
- return new PlastikButton(HelpButton, this, "help");
-
- case MinButton:
- return new PlastikButton(MinButton, this, "minimize");
-
- case MaxButton:
- return new PlastikButton(MaxButton, this, "maximize");
-
- case CloseButton:
- return new PlastikButton(CloseButton, this, "close");
-
- case AboveButton:
- return new PlastikButton(AboveButton, this, "above");
-
- case BelowButton:
- return new PlastikButton(BelowButton, this, "below");
-
- case ShadeButton:
- return new PlastikButton(ShadeButton, this, "shade");
-
- default:
- return 0;
- }
-}
-
-void PlastikClient::init()
-{
- s_titleFont = isToolWindow() ? Handler()->titleFontTool() : Handler()->titleFont();
-
- clearCaptionPixmaps();
-
- KCommonDecoration::init();
-}
-
-TQRegion PlastikClient::cornerShape(WindowCorner corner)
-{
- int w = widget()->width();
- int h = widget()->height();
-
- switch (corner) {
- case WC_TopLeft:
- if (layoutMetric(LM_TitleEdgeLeft) > 0)
- return TQRegion(0, 0, 1, 2) + TQRegion(1, 0, 1, 1);
- else
- return TQRegion();
-
- case WC_TopRight:
- if (layoutMetric(LM_TitleEdgeRight) > 0)
- return TQRegion(w-1, 0, 1, 2) + TQRegion(w-2, 0, 1, 1);
- else
- return TQRegion();
-
- case WC_BottomLeft:
- if (layoutMetric(LM_BorderBottom) > 0)
- return TQRegion(0, h-1, 1, 1);
- else
- return TQRegion();
-
- case WC_BottomRight:
- if (layoutMetric(LM_BorderBottom) > 0)
- return TQRegion(w-1, h-1, 1, 1);
- else
- return TQRegion();
-
- default:
- return TQRegion();
- }
-
-}
-
-void PlastikClient::paintEvent(TQPaintEvent *e)
-{
- TQRegion region = e->region();
-
- PlastikHandler *handler = Handler();
-
- if (oldCaption != caption() )
- clearCaptionPixmaps();
-
- bool active = isActive();
- bool toolWindow = isToolWindow();
-
- TQPainter painter(widget() );
-
- // often needed coordinates
- TQRect r = widget()->rect();
-
- int r_w = r.width();
-// int r_h = r.height();
- int r_x, r_y, r_x2, r_y2;
- r.coords(&r_x, &r_y, &r_x2, &r_y2);
- const int borderLeft = layoutMetric(LM_BorderLeft);
- const int borderRight = layoutMetric(LM_BorderRight);
- const int borderBottom = layoutMetric(LM_BorderBottom);
- const int titleHeight = layoutMetric(LM_TitleHeight);
- const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
- const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
- const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
- const int titleEdgeRight = layoutMetric(LM_TitleEdgeRight);
-
- const int borderBottomTop = r_y2-borderBottom+1;
- const int borderLeftRight = r_x+borderLeft-1;
- const int borderRightLeft = r_x2-borderRight+1;
- const int titleEdgeBottomBottom = r_y+titleEdgeTop+titleHeight+titleEdgeBottom-1;
-
- const int sideHeight = borderBottomTop-titleEdgeBottomBottom-1;
-
- TQRect Rtitle = TQRect(r_x+titleEdgeLeft+buttonsLeftWidth(), r_y+titleEdgeTop,
- r_x2-titleEdgeRight-buttonsRightWidth()-(r_x+titleEdgeLeft+buttonsLeftWidth()),
- titleEdgeBottomBottom-(r_y+titleEdgeTop) );
-
- TQRect tempRect;
-
- // topSpacer
- if(titleEdgeTop > 0)
- {
- tempRect.setRect(r_x+2, r_y, r_w-2*2, titleEdgeTop );
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(TitleBarTileTop, active, toolWindow) );
- }
- }
-
- // leftTitleSpacer
- int titleMarginLeft = 0;
- int titleMarginRight = 0;
- if(titleEdgeLeft > 0)
- {
- tempRect.setRect(r_x, r_y, borderLeft, titleEdgeTop+titleHeight+titleEdgeBottom);
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(TitleBarLeft, active, toolWindow) );
- titleMarginLeft = borderLeft;
- }
- }
-
- // rightTitleSpacer
- if(titleEdgeRight > 0)
- {
- tempRect.setRect(borderRightLeft, r_y, borderRight, titleEdgeTop+titleHeight+titleEdgeBottom);
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(TitleBarRight, active, toolWindow) );
- titleMarginRight = borderRight;
- }
- }
-
- // titleSpacer
- const TQPixmap &caption = captionPixmap();
- if(Rtitle.width() > 0)
- {
- m_captionRect = captionRect(); // also update m_captionRect!
- if (m_captionRect.isValid() && region.contains(m_captionRect) )
- {
- painter.drawTiledPixmap(m_captionRect, caption);
- }
-
- // left to the title
- tempRect.setRect(r_x+titleMarginLeft, m_captionRect.top(),
- m_captionRect.left() - (r_x+titleMarginLeft), m_captionRect.height() );
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(TitleBarTile, active, toolWindow) );
- }
-
- // right to the title
- tempRect.setRect(m_captionRect.right()+1, m_captionRect.top(),
- (r_x2-titleMarginRight) - m_captionRect.right(), m_captionRect.height() );
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(TitleBarTile, active, toolWindow) );
- }
-
- }
-
- // leftSpacer
- if(borderLeft > 0 && sideHeight > 0)
- {
- tempRect.setCoords(r_x, titleEdgeBottomBottom+1, borderLeftRight, borderBottomTop-1);
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(BorderLeftTile, active, toolWindow) );
- }
- }
-
- // rightSpacer
- if(borderRight > 0 && sideHeight > 0)
- {
- tempRect.setCoords(borderRightLeft, titleEdgeBottomBottom+1, r_x2, borderBottomTop-1);
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(BorderRightTile, active, toolWindow) );
- }
- }
-
- // bottomSpacer
- if(borderBottom > 0)
- {
- int l = r_x;
- int r = r_x2;
-
- tempRect.setRect(r_x, borderBottomTop, borderLeft, borderBottom);
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(BorderBottomLeft, active, toolWindow) );
- l = tempRect.right()+1;
- }
-
- tempRect.setRect(borderRightLeft, borderBottomTop, borderLeft, borderBottom);
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(BorderBottomRight, active, toolWindow) );
- r = tempRect.left()-1;
- }
-
- tempRect.setCoords(l, borderBottomTop, r, r_y2);
- if (tempRect.isValid() && region.contains(tempRect) ) {
- painter.drawTiledPixmap(tempRect, handler->pixmap(BorderBottomTile, active, toolWindow) );
- }
- }
-}
-
-TQRect PlastikClient::captionRect() const
-{
- const TQPixmap &caption = captionPixmap();
- TQRect r = widget()->rect();
-
- const int titleHeight = layoutMetric(LM_TitleHeight);
- const int titleEdgeBottom = layoutMetric(LM_TitleEdgeBottom);
- const int titleEdgeTop = layoutMetric(LM_TitleEdgeTop);
- const int titleEdgeLeft = layoutMetric(LM_TitleEdgeLeft);
- const int marginLeft = layoutMetric(LM_TitleBorderLeft);
- const int marginRight = layoutMetric(LM_TitleBorderRight);
-
- const int titleLeft = r.left() + titleEdgeLeft + buttonsLeftWidth() + marginLeft;
- const int titleWidth = r.width() -
- titleEdgeLeft - layoutMetric(LM_TitleEdgeRight) -
- buttonsLeftWidth() - buttonsRightWidth() -
- marginLeft - marginRight;
-
- TQ_Alignment a = Handler()->titleAlign();
-
- int tX, tW; // position/width of the title buffer
- if (caption.width() > titleWidth) {
- tW = titleWidth;
- } else {
- tW = caption.width();
- }
- if (a == Qt::AlignLeft || (caption.width() > titleWidth) ) {
- // Align left
- tX = titleLeft;
- } else if (a == Qt::AlignHCenter) {
- // Align center
- tX = titleLeft+(titleWidth- caption.width() )/2;
- } else {
- // Align right
- tX = titleLeft+titleWidth-caption.width();
- }
-
- return TQRect(tX, r.top()+titleEdgeTop, tW, titleHeight+titleEdgeBottom);
-}
-
-void PlastikClient::updateCaption()
-{
- TQRect oldCaptionRect = m_captionRect;
-
- if (oldCaption != caption() )
- clearCaptionPixmaps();
-
- m_captionRect = PlastikClient::captionRect();
-
- if (oldCaptionRect.isValid() && m_captionRect.isValid() )
- widget()->update(oldCaptionRect|m_captionRect);
- else
- widget()->update();
-}
-
-void PlastikClient::reset( unsigned long changed )
-{
- if (changed & SettingColors)
- {
- // tqrepaint the whole thing
- clearCaptionPixmaps();
- widget()->update();
- updateButtons();
- } else if (changed & SettingFont) {
- // font has changed -- update title height and font
- s_titleFont = isToolWindow() ? Handler()->titleFontTool() : Handler()->titleFont();
-
- updateLayout();
-
- // then tqrepaint
- clearCaptionPixmaps();
- widget()->update();
- }
-
- KCommonDecoration::reset(changed);
-}
-
-const TQPixmap &PlastikClient::getTitleBarTile(bool active) const
-{
- return Handler()->pixmap(TitleBarTile, active, isToolWindow() );
-}
-
-const TQPixmap &PlastikClient::captionPixmap() const
-{
- bool active = isActive();
-
- if (m_captionPixmaps[active]) {
- return *m_captionPixmaps[active];
- }
-
- // not found, create new pixmap...
-
- const uint maxCaptionLength = 300; // truncate captions longer than this!
- TQString c(caption() );
- if (c.length() > maxCaptionLength) {
- c.truncate(maxCaptionLength);
- c.append(" [...]");
- }
-
- TQFontMetrics fm(s_titleFont);
- int captionWidth = fm.width(c);
- int captionHeight = fm.height();
-
- const int th = layoutMetric(LM_TitleHeight, false) + layoutMetric(LM_TitleEdgeBottom, false);
-
- TQPainter painter;
-
- const int thickness = 2;
-
- TQPixmap *captionPixmap = new TQPixmap(captionWidth+2*thickness, th);
-
- painter.begin(captionPixmap);
- painter.drawTiledPixmap(captionPixmap->rect(),
- Handler()->pixmap(TitleBarTile, active, isToolWindow()) );
-
- painter.setFont(s_titleFont);
- TQPoint tp(1, captionHeight-1);
- if(Handler()->titleShadow())
- {
- TQColor shadowColor;
- if (tqGray(Handler()->getColor(TitleFont,active).rgb()) < 100)
- shadowColor = TQColor(255, 255, 255);
- else
- shadowColor = TQColor(0,0,0);
-
- painter.setPen(alphaBlendColors(options()->color(ColorTitleBar, active), shadowColor, 205) );
- painter.drawText(tp+TQPoint(1,2), c);
- painter.setPen(alphaBlendColors(options()->color(ColorTitleBar, active), shadowColor, 225) );
- painter.drawText(tp+TQPoint(2,2), c);
- painter.setPen(alphaBlendColors(options()->color(ColorTitleBar, active), shadowColor, 165) );
- painter.drawText(tp+TQPoint(1,1), c);
- }
- painter.setPen(Handler()->getColor(TitleFont,active) );
- painter.drawText(tp, c );
- painter.end();
-
- m_captionPixmaps[active] = captionPixmap;
- return *captionPixmap;
-}
-
-void PlastikClient::clearCaptionPixmaps()
-{
- for (int i = 0; i < 2; ++i) {
- delete m_captionPixmaps[i];
- m_captionPixmaps[i] = 0;
- }
-
- oldCaption = caption();
-}
-
-} // KWinPlastik
diff --git a/kwin/clients/plastik/plastikclient.h b/kwin/clients/plastik/plastikclient.h
deleted file mode 100644
index e83bf75a5..000000000
--- a/kwin/clients/plastik/plastikclient.h
+++ /dev/null
@@ -1,73 +0,0 @@
-/* Plastik KWin window decoration
- Copyright (C) 2003-2005 Sandro Giessl <[email protected]>
-
- based on the window decoration "Web":
- Copyright (C) 2001 Rik Hemsley (rikkus) <[email protected]>
-
- 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 PLASTIKCLIENT_H
-#define PLASTIKCLIENT_H
-
-#include <kcommondecoration.h>
-
-#include "plastik.h"
-
-namespace KWinPlastik {
-
-class PlastikButton;
-
-class PlastikClient : public KCommonDecoration
-{
-public:
- PlastikClient(KDecorationBridge* bridge, KDecorationFactory* factory);
- ~PlastikClient();
-
- virtual TQString visibleName() const;
- virtual TQString defaultButtonsLeft() const;
- virtual TQString defaultButtonsRight() const;
- virtual bool decorationBehaviour(DecorationBehaviour behaviour) const;
- virtual int layoutMetric(LayoutMetric lm, bool respectWindowState = true, const KCommonDecorationButton * = 0) const;
- virtual TQRegion cornerShape(WindowCorner corner);
- virtual KCommonDecorationButton *createButton(ButtonType type);
-
- virtual void init();
- virtual void reset( unsigned long changed );
-
- virtual void paintEvent(TQPaintEvent *e);
- virtual void updateCaption();
-
- const TQPixmap &getTitleBarTile(bool active) const;
-
-private:
- TQRect captionRect() const;
-
- const TQPixmap &captionPixmap() const;
- void clearCaptionPixmaps();
-
- mutable TQPixmap *m_captionPixmaps[2];
-
- TQRect m_captionRect;
- TQString oldCaption;
-
- // settings...
- TQFont s_titleFont;
-};
-
-} // KWinPlastik
-
-#endif // PLASTIKCLIENT_H