diff options
Diffstat (limited to 'twin/clients/modernsystem')
-rw-r--r-- | twin/clients/modernsystem/CMakeLists.txt | 36 | ||||
-rw-r--r-- | twin/clients/modernsystem/Makefile.am | 19 | ||||
-rw-r--r-- | twin/clients/modernsystem/btnhighcolor.h | 93 | ||||
-rw-r--r-- | twin/clients/modernsystem/buttondata.h | 42 | ||||
-rw-r--r-- | twin/clients/modernsystem/config/CMakeLists.txt | 30 | ||||
-rw-r--r-- | twin/clients/modernsystem/config/Makefile.am | 14 | ||||
-rw-r--r-- | twin/clients/modernsystem/config/config.cpp | 130 | ||||
-rw-r--r-- | twin/clients/modernsystem/config/config.h | 50 | ||||
-rw-r--r-- | twin/clients/modernsystem/modernsys.cpp | 739 | ||||
-rw-r--r-- | twin/clients/modernsystem/modernsys.h | 72 | ||||
-rw-r--r-- | twin/clients/modernsystem/modernsystem.desktop | 69 |
11 files changed, 1294 insertions, 0 deletions
diff --git a/twin/clients/modernsystem/CMakeLists.txt b/twin/clients/modernsystem/CMakeLists.txt new file mode 100644 index 000000000..62c2d766c --- /dev/null +++ b/twin/clients/modernsystem/CMakeLists.txt @@ -0,0 +1,36 @@ +################################################# +# +# (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 ) + +include_directories( + ${CMAKE_SOURCE_DIR}/twin/lib + ${TDE_INCLUDE_DIR} + ${TQT_INCLUDE_DIRS} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES modernsystem.desktop DESTINATION ${DATA_INSTALL_DIR}/twin ) + + +##### twin3_modernsys (module) ################## + +tde_add_kpart( twin3_modernsys + SOURCES modernsys.cpp + LINK tdecorations-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/twin/clients/modernsystem/Makefile.am b/twin/clients/modernsystem/Makefile.am new file mode 100644 index 000000000..e4c21d7a3 --- /dev/null +++ b/twin/clients/modernsystem/Makefile.am @@ -0,0 +1,19 @@ + +INCLUDES = -I$(srcdir)/../../lib $(all_includes) + +SUBDIRS = config + +kde_module_LTLIBRARIES = twin3_modernsys.la + +twin3_modernsys_la_SOURCES = modernsys.cpp +twin3_modernsys_la_LIBADD = ../../lib/libtdecorations.la +twin3_modernsys_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module + +METASOURCES = AUTO +noinst_HEADERS = modernsys.h + +lnkdir = $(kde_datadir)/twin/ +lnk_DATA = modernsystem.desktop + +EXTRA_DIST = $(lnk_DATA) + diff --git a/twin/clients/modernsystem/btnhighcolor.h b/twin/clients/modernsystem/btnhighcolor.h new file mode 100644 index 000000000..fa323b9eb --- /dev/null +++ b/twin/clients/modernsystem/btnhighcolor.h @@ -0,0 +1,93 @@ +/* XPM */ +static const char * btnhighcolor_xpm[] = { +"14 15 75 1", +" c None", +". c #6E6E6E", +"+ c #757575", +"@ c #878787", +"# c #7D7D7D", +"$ c #9E9E9E", +"% c #B9B9B9", +"& c #C6C6C6", +"* c #BABABA", +"= c #A5A5A5", +"- c #7F7F7F", +"; c #848484", +"> c #A7A7A7", +", c #BFBFBF", +"' c #D1D1D1", +") c #D7D7D7", +"! c #DADADA", +"~ c #CBCBCB", +"{ c #ABABAB", +"] c #B3B3B3", +"^ c #C2C2C2", +"/ c #CACACA", +"( c #C9C9C9", +"_ c #B6B6B6", +": c #9A9A9A", +"< c #999999", +"[ c #B0B0B0", +"} c #C4C4C4", +"| c #C3C3C3", +"1 c #C0C0C0", +"2 c #AEAEAE", +"3 c #969696", +"4 c #C1C1C1", +"5 c #CCCCCC", +"6 c #C5C5C5", +"7 c #BEBEBE", +"8 c #AAAAAA", +"9 c #CECECE", +"0 c #D4D4D4", +"a c #DBDBDB", +"b c #DEDEDE", +"c c #D5D5D5", +"d c #D3D3D3", +"e c #BCBCBC", +"f c #CDCDCD", +"g c #E0E0E0", +"h c #E4E4E4", +"i c #E8E8E8", +"j c #EBEBEB", +"k c #E9E9E9", +"l c #E6E6E6", +"m c #DDDDDD", +"n c #E1E1E1", +"o c #EDEDED", +"p c #F1F1F1", +"q c #F5F5F5", +"r c #F8F8F8", +"s c #F6F6F6", +"t c #F3F3F3", +"u c #EEEEEE", +"v c #E5E5E5", +"w c #DCDCDC", +"x c #B7B7B7", +"y c #E2E2E2", +"z c #FDFDFD", +"A c #FFFFFF", +"B c #FCFCFC", +"C c #F7F7F7", +"D c #B5B5B5", +"E c #F2F2F2", +"F c #FAFAFA", +"G c #9B9B9B", +"H c #FBFBFB", +"I c #A9A9A9", +"J c #747474", +" .... ", +" ..+@@+.. ", +" .#$%&&*=-. ", +" .;>,')!)~{#. ", +" .$]^///(&_:. ", +".<[*^}||11*23.", +".[4&5555~(678.", +".,90!aba)cd~e.", +".faghijklhm06.", +".'nopqrstuvw/.", +".xyprzAzBCunD.", +" .'EzAAAAFpf. ", +" .GcHAAAAF0<. ", +" ..I5kk5I.. ", +" J..... "}; diff --git a/twin/clients/modernsystem/buttondata.h b/twin/clients/modernsystem/buttondata.h new file mode 100644 index 000000000..1af5fb8dd --- /dev/null +++ b/twin/clients/modernsystem/buttondata.h @@ -0,0 +1,42 @@ +/* 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 }; + diff --git a/twin/clients/modernsystem/config/CMakeLists.txt b/twin/clients/modernsystem/config/CMakeLists.txt new file mode 100644 index 000000000..8a6d6db43 --- /dev/null +++ b/twin/clients/modernsystem/config/CMakeLists.txt @@ -0,0 +1,30 @@ +################################################# +# +# (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} +) + + +##### twin_modernsys_config (module) ############ + +tde_add_kpart( twin_modernsys_config AUTOMOC + SOURCES config.cpp + LINK tdeui-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) + diff --git a/twin/clients/modernsystem/config/Makefile.am b/twin/clients/modernsystem/config/Makefile.am new file mode 100644 index 000000000..aaae38b2a --- /dev/null +++ b/twin/clients/modernsystem/config/Makefile.am @@ -0,0 +1,14 @@ + +INCLUDES = $(all_includes) + +kde_module_LTLIBRARIES = twin_modernsys_config.la + +twin_modernsys_config_la_SOURCES = config.cpp +twin_modernsys_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module +twin_modernsys_config_la_LIBADD = $(LIB_TDEUI) + +METASOURCES = AUTO +noinst_HEADERS = config.h + +lnkdir = $(kde_datadir)/twin/ + diff --git a/twin/clients/modernsystem/config/config.cpp b/twin/clients/modernsystem/config/config.cpp new file mode 100644 index 000000000..136ff3492 --- /dev/null +++ b/twin/clients/modernsystem/config/config.cpp @@ -0,0 +1,130 @@ +// Melchior FRANZ <mfranz@kde.org> -- 2001-04-22 + +#include <kapplication.h> +#include <kconfig.h> +#include <kdialog.h> +#include <klocale.h> +#include <kglobal.h> +#include <tqlayout.h> +#include <tqwhatsthis.h> +#include "config.h" + + +extern "C" +{ + KDE_EXPORT TQObject* allocate_config(KConfig* conf, TQWidget* parent) + { + return(new ModernSysConfig(conf, parent)); + } +} + + +// 'conf' is a pointer to the twindecoration modules open twin config, +// and is by default set to the "Style" group. +// +// 'parent' is the parent of the TQObject, which is a VBox inside the +// Configure tab in twindecoration + +ModernSysConfig::ModernSysConfig(KConfig* conf, TQWidget* parent) : TQObject(parent) +{ + clientrc = new KConfig("twinmodernsysrc"); + KGlobal::locale()->insertCatalogue("twin_clients"); + mainw = new TQWidget(parent); + vbox = new TQVBoxLayout(mainw); + vbox->setSpacing(6); + vbox->setMargin(0); + + handleBox = new TQWidget(mainw); + TQGridLayout* layout = new TQGridLayout(handleBox, 0, KDialog::spacingHint()); + + cbShowHandle = new TQCheckBox(i18n("&Show window resize handle"), handleBox); + TQWhatsThis::add(cbShowHandle, + 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->addMultiCellWidget(cbShowHandle, 0, 0, 0, 1); + connect(cbShowHandle, TQT_SIGNAL(clicked()), this, TQT_SLOT(slotSelectionChanged())); + + sliderBox = new TQVBox(handleBox); + handleSizeSlider = new TQSlider(0, 4, 1, 0, Qt::Horizontal, sliderBox); + TQWhatsThis::add(handleSizeSlider, + i18n("Here you can change the size of the resize handle.")); + handleSizeSlider->setTickInterval(1); + handleSizeSlider->setTickmarks(TQSlider::Below); + connect(handleSizeSlider, TQT_SIGNAL(valueChanged(int)), this, TQT_SLOT(slotSelectionChanged())); + + hbox = new TQHBox(sliderBox); + hbox->setSpacing(6); + + bool rtl = kapp->reverseLayout(); + label1 = new TQLabel(i18n("Small"), hbox); + label1->tqsetAlignment(rtl ? AlignRight : AlignLeft); + label2 = new TQLabel(i18n("Medium"), hbox); + label2->tqsetAlignment(AlignHCenter); + label3 = new TQLabel(i18n("Large"), hbox); + label3->tqsetAlignment(rtl ? AlignLeft : AlignRight); + + vbox->addWidget(handleBox); + vbox->addStretch(1); + +// layout->setColSpacing(0, 30); + layout->addItem(new TQSpacerItem(30, 10, TQSizePolicy::Fixed, TQSizePolicy::Fixed), 1, 0); + layout->addWidget(sliderBox, 1, 1); + + load(conf); + 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(KConfig* /*conf*/) +{ + clientrc->setGroup("General"); + bool i = clientrc->readBoolEntry("ShowHandle", true ); + cbShowHandle->setChecked(i); + hbox->setEnabled(i); + handleSizeSlider->setEnabled(i); + handleWidth = clientrc->readUnsignedNumEntry("HandleWidth", 6); + handleSize = clientrc->readUnsignedNumEntry("HandleSize", 30); + handleSizeSlider->setValue(TQMIN((handleWidth - 6) / 2, 4)); + +} + + +void ModernSysConfig::save(KConfig* /*conf*/) +{ + clientrc->setGroup("General"); + clientrc->writeEntry("ShowHandle", cbShowHandle->isChecked()); + clientrc->writeEntry("HandleWidth", 6 + 2 * handleSizeSlider->value()); + clientrc->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" diff --git a/twin/clients/modernsystem/config/config.h b/twin/clients/modernsystem/config/config.h new file mode 100644 index 000000000..3a04573cf --- /dev/null +++ b/twin/clients/modernsystem/config/config.h @@ -0,0 +1,50 @@ +#ifndef __KDE_MODSYSTEMCONFIG_H +#define __KDE_MODSYSTEMCONFIG_H + +#include <tqcheckbox.h> +#include <tqgroupbox.h> +#include <tqlayout.h> +#include <tqvbox.h> +#include <tqslider.h> +#include <tqlabel.h> + +class ModernSysConfig : public TQObject +{ + Q_OBJECT + + public: + ModernSysConfig(KConfig* conf, TQWidget* parent); + ~ModernSysConfig(); + + // These public signals/slots work similar to KCM modules + signals: + void changed(); + + public slots: + void load(KConfig* conf); + void save(KConfig* conf); + void defaults(); + + protected slots: + void slotSelectionChanged(); // Internal use + + private: + KConfig *clientrc; + TQWidget *mainw; + TQVBoxLayout *vbox; + TQWidget *handleBox; + TQCheckBox *cbShowHandle; + TQVBox *sliderBox; + TQSlider *handleSizeSlider; + TQHBox *hbox; + TQLabel *label1; + TQLabel *label2; + TQLabel *label3; + + unsigned handleWidth; + unsigned handleSize; + +}; + + +#endif diff --git a/twin/clients/modernsystem/modernsys.cpp b/twin/clients/modernsystem/modernsys.cpp new file mode 100644 index 000000000..b6e7cda01 --- /dev/null +++ b/twin/clients/modernsystem/modernsys.cpp @@ -0,0 +1,739 @@ +// Daniel M. DULEY <mosfet@kde.org> original work +// Melchior FRANZ <a8603365@unet.univie.ac.at> configuration options + +#include <kconfig.h> +#include <kglobal.h> +#include <klocale.h> +#include <tqlayout.h> +#include <tqdrawutil.h> +#include <kpixmapeffect.h> +#include <kdrawutil.h> +#include <tqbitmap.h> +#include <tqtooltip.h> +#include <tqapplication.h> +#include <tqlabel.h> +#include "modernsys.h" + +#include "buttondata.h" +#include "btnhighcolor.h" +#include <tqimage.h> + +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 KPixmap *aUpperGradient=0; +static KPixmap *iUpperGradient=0; +static TQPixmap *buttonPix=0; +static TQPixmap *buttonPixDown=0; +static TQPixmap *iButtonPix=0; +static TQPixmap *iButtonPixDown=0; + +static TQColor *buttonFg; +static bool pixmaps_created = false; + +static TQBitmap *lcDark1; +static TQBitmap *lcDark2; +static TQBitmap *lcDark3; +static TQBitmap *lcLight1; +static TQImage *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 TQColorGroup &g, TQPixmap *pix, bool light=false) +{ + pix->fill(g.background()); + TQPainter p(pix); + + if(TQPixmap::defaultDepth() > 8){ + int i, destH, destS, destV, srcH, srcS, srcV; + TQColor btnColor = g.background(); + + if(btnSource->depth() < 32) + *btnSource = btnSource->convertDepth(32); + if(light) + btnColor = btnColor.light(120); + btnColor.hsv(&destH, &destS, &destV); + TQImage btnDest(14, 15, 32); + + unsigned int *srcData = (unsigned int *)btnSource->bits(); + unsigned int *destData = (unsigned int *)btnDest.bits(); + TQColor srcColor; + for(i=0; i < btnSource->width()*btnSource->height(); ++i){ + srcColor.setRgb(srcData[i]); + srcColor.hsv(&srcH, &srcS, &srcV); + srcColor.setHsv(destH, destS, srcV); + destData[i] = srcColor.rgb(); + } + pix->convertFromImage(btnDest); + + } + else{ + if(!lcDark1->mask()){ + lcDark1->setMask(*lcDark1); + lcDark2->setMask(*lcDark2); + lcDark3->setMask(*lcDark3); + lcLight1->setMask(*lcLight1); + } + p.setPen(g.dark()); + p.drawPixmap(0, 0, *lcDark2); + p.drawPixmap(0, 0, *lcDark1); + p.setPen(g.mid()); + p.drawPixmap(0, 0, *lcDark3); + p.setPen(g.light()); + p.drawPixmap(0, 0, *lcLight1); + } +} + + +static void create_pixmaps() +{ + if(pixmaps_created) + return; + pixmaps_created = true; + + lcDark1 = new TQBitmap(14, 15, lowcolor_6a696a_bits, true); + lcDark2 = new TQBitmap(14, 15, lowcolor_949194_bits, true); + lcDark3 = new TQBitmap(14, 15, lowcolor_b4b6b4_bits, true); + lcLight1 = new TQBitmap(14, 15, lowcolor_e6e6e6_bits, true); + btnSource = new TQImage(btnhighcolor_xpm); + + if(TQPixmap::defaultDepth() > 8){ + aUpperGradient = new KPixmap; + aUpperGradient->resize(32, title_height+2); + iUpperGradient = new KPixmap; + iUpperGradient->resize(32, title_height+2); + KPixmapEffect::gradient(*aUpperGradient, + options()->color(KDecoration::ColorTitleBar, true).light(130), + options()->color(KDecoration::ColorTitleBlend, true), + KPixmapEffect::VerticalGradient); + KPixmapEffect::gradient(*iUpperGradient, + options()->color(KDecoration::ColorTitleBar, false).light(130), + options()->color(KDecoration::ColorTitleBlend, false), + KPixmapEffect::VerticalGradient); + } + // buttons + TQColorGroup btnColor(options()->tqcolorGroup(KDecoration::ColorButtonBg, true)); + buttonPix = new TQPixmap(14, 15); + make_button_fx(btnColor, buttonPix); + buttonPixDown = new TQPixmap(14, 15); + make_button_fx(btnColor, buttonPixDown, true); + + btnColor = options()->tqcolorGroup(KDecoration::ColorButtonBg, false); + iButtonPix = new TQPixmap(14, 15); + make_button_fx(btnColor, iButtonPix); + iButtonPixDown = new TQPixmap(14, 15); + make_button_fx(btnColor, iButtonPixDown, true); + + + if(tqGray(btnColor.background().rgb()) < 150) + buttonFg = new TQColor(Qt::white); + else + buttonFg = new TQColor(Qt::black); + + delete lcDark1; + delete lcDark2; + delete lcDark3; + delete lcLight1; + delete btnSource; +} + +static void delete_pixmaps() +{ + if(aUpperGradient){ + delete aUpperGradient; + delete iUpperGradient; + } + delete buttonPix; + delete buttonPixDown; + delete iButtonPix; + delete iButtonPixDown; + + delete buttonFg; + + pixmaps_created = false; +} + +void ModernSysFactory::read_config() +{ + bool showh; + int hsize, hwidth, bwidth, theight; + + KConfig c("twinmodernsysrc"); + c.setGroup("General"); + showh = c.readBoolEntry("ShowHandle", true); + + hwidth = c.readUnsignedNumEntry("HandleWidth", 6); + hsize = c.readUnsignedNumEntry("HandleSize", 30); + if (!(showh && hsize && hwidth)) { + showh = false; + hwidth = hsize = 0; + } + + 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 = TQFontMetrics(options()->font(true)).height() + 2; + 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; +} + +TQValueList< ModernSysFactory::BorderSize > ModernSysFactory::borderSizes() const +{ // the list must be sorted + return TQValueList< 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, name) +{ + setBackgroundMode( NoBackground ); + + TQBitmap mask(14, 15, TQPixmap::defaultDepth() > 8 ? + btnhighcolor_mask_bits : lowcolor_mask_bits, true); + 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( isOn() ? (isLeft()?l_minmax_bits:r_minmax_bits) : maximize_bits ); + break; + case OnAllDesktopsButton: + setBitmap( isOn() ? unsticky_bits : sticky_bits ); + break; + case ShadeButton: + setBitmap( isOn() ? shade_on_bits : shade_off_bits ); + break; + case AboveButton: + setBitmap( isOn() ? above_on_bits : above_off_bits ); + break; + case BelowButton: + setBitmap( isOn() ? 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 = TQBitmap(8, 8, bitmap, true); + else { + deco = TQBitmap(8,8); + deco.fill(Qt::color0); + } + deco.setMask(deco); +} + +void ModernButton::drawButton(TQPainter *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()){ + p->setPen(*buttonFg); + p->drawPixmap(isDown() ? 4 : 3, isDown() ? 5 : 4, deco); + } +} + +void ModernSys::reset( unsigned long changed) +{ + KCommonDecoration::reset(changed); + + titleBuffer.resize(0, 0); + recalcTitleBuffer(); + resetButtons(); + widget()->update(); +} + +ModernSys::ModernSys( KDecorationBridge* b, KDecorationFactory* f ) + : KCommonDecoration( b, f ) +{ +} + +TQString ModernSys::visibleName() const +{ + return i18n("Modern System"); +} + +TQString ModernSys::defaultButtonsLeft() const +{ + return "X"; +} + +TQString 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; + + case LM_ExplicitButtonSpacer: + return 3; + + 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 = TQApplication::reverseLayout(); + + KCommonDecoration::init(); + + recalcTitleBuffer(); +} + +void ModernSys::recalcTitleBuffer() +{ + if(oldTitle == caption() && width() == titleBuffer.width()) + return; + + TQFontMetrics fm(options()->font(true)); + titleBuffer.resize(width(), title_height+2); + TQPainter p; + p.begin(&titleBuffer); + if(aUpperGradient) + p.drawTiledPixmap(0, 0, width(), title_height+2, *aUpperGradient); + else + p.fillRect(0, 0, width(), title_height+2, + options()->tqcolorGroup(ColorTitleBar, true). + brush(TQColorGroup::Button)); + + TQRect t = titleRect(); // titlebar->geometry(); + t.setTop( 2 ); + t.setLeft( t.left() ); + t.setRight( t.right() - 2 ); + + TQRegion r(t.x(), 0, t.width(), title_height+2); + r -= TQRect(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, AlignCenter, caption()); + p.setClipping(false); + p.end(); + oldTitle = caption(); +} + +void ModernSys::updateCaption() +{ + widget()->update(titleRect() ); +} + +void ModernSys::drawRoundFrame(TQPainter &p, int x, int y, int w, int h) +{ + kDrawRoundButton(&p, x, y, w, h, + options()->tqcolorGroup(ColorFrame, isActive()), false); + +} + +void ModernSys::paintEvent( TQPaintEvent* ) +{ + // update title buffer... + if (oldTitle != caption() || width() != titleBuffer.width() ) + recalcTitleBuffer(); + + int hs = handle_size; + int hw = handle_width; + + TQPainter p( widget() ); + TQRect t = titleRect(); // titlebar->geometry(); + + TQBrush fillBrush(widget()->tqcolorGroup().tqbrush(TQColorGroup::Background).pixmap() ? + widget()->tqcolorGroup().brush(TQColorGroup::Background) : + options()->tqcolorGroup(ColorFrame, isActive()). + brush(TQColorGroup::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 + TQColorGroup g = options()->tqcolorGroup(ColorTitleBar, isActive()); + 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, AlignCenter, caption() ); + } + + // titlebar highlight + p.setPen(g.light()); + p.drawLine(1, 1, 1, title_height+3); + p.drawLine(1, 1, w-3, 1); + p.setPen(g.dark()); + p.drawLine(w-2, 1, w-2, title_height+3); + p.drawLine(0, title_height+2, w-2, title_height+2); + + // frame + g = options()->tqcolorGroup(ColorFrame, isActive()); + p.setPen(g.light()); + p.drawLine(1, title_height+3, 1, h-2); + p.setPen(g.dark()); + 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()); + p.drawLine(width()-3, height()-hs-1, width()-3, height()-3); + p.drawLine(width()-hs-1, height()-3, width()-3, height()-3); + + p.setPen(g.light()); + p.drawLine(width()-hw, height()-hs-1, width()-hw, height()-hw); + p.drawLine(width()-hs-1, height()-hw, width()-hw, height()-hw); + p.drawLine(width()-hw, height()-hs-1, width()-4, height()-hs-1); + p.drawLine(width()-hs-1, height()-hw, width()-hs-1, height()-4); + + p.setPen(Qt::black); + p.drawRect(0, 0, w, h); + + // handle outline + p.drawLine(width()-hw, height()-hs, width(), height()-hs); + p.drawLine(width()-2, height()-hs, width()-2, height()-2); + p.drawLine(width()-hs, height()-2, width()-2, height()-2); + p.drawLine(width()-hs, height()-hw, width()-hs, height()-2); + } else { + p.setPen(Qt::black); + p.drawRect(0, 0, w, h); + } +} + +void ModernSys::updateWindowShape() +{ + int hs = handle_size; + int hw = handle_width; + TQRegion mask; + mask += TQRect(0, 0, width()-hw, height()-hw); + //single points + mask -= TQRect(0, 0, 1, 1); + mask -= TQRect(width()-hw-1, 0, 1, 1); + mask -= TQRect(0, height()-hw-1, 1, 1); + + if (show_handle) { + mask += TQRect(width()-hs, height()-hs, hs-1, hs-1); + mask -= TQRect(width()-2, height()-2, 1, 1); + mask -= TQRect(width()-2, height()-hs, 1, 1); + mask -= TQRect(width()-hs, height()-2, 1, 1); + } else + mask -= TQRect(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)); +} + +bool ModernSysFactory::reset( unsigned long changed ) +{ + read_config(); + + bool needHardReset = true; + if( changed & (SettingColors | SettingBorder | SettingFont) ) + { + delete_pixmaps(); + create_pixmaps(); + needHardReset = false; + } else if (changed & SettingButtons) { + // handled by KCommonDecoration + needHardReset = false; + } + + if( needHardReset ) + return true; + else + { + resetDecorations( changed ); + return false; // no recreating of decorations + } +} + +bool ModernSysFactory::supports( Ability ability ) +{ + switch( ability ) + { + case AbilityAnnounceButtons: + case AbilityButtonOnAllDesktops: + case AbilityButtonSpacer: + case AbilityButtonHelp: + case AbilityButtonMinimize: + case AbilityButtonMaximize: + case AbilityButtonClose: + case AbilityButtonAboveOthers: + case AbilityButtonBelowOthers: + case AbilityButtonShade: + case AbilityButtonMenu: + 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 diff --git a/twin/clients/modernsystem/modernsys.h b/twin/clients/modernsystem/modernsys.h new file mode 100644 index 000000000..3e0cf02fd --- /dev/null +++ b/twin/clients/modernsystem/modernsys.h @@ -0,0 +1,72 @@ +#ifndef __MODSYSTEMCLIENT_H +#define __MODSYSTEMCLIENT_H + +#include <tqbitmap.h> +#include <kpixmap.h> +#include <kcommondecoration.h> +#include <kdecorationfactory.h> + +class TQLabel; +class TQSpacerItem; + +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: + + virtual void drawButton(TQPainter *p); + void drawButtonLabel(TQPainter *){;} + TQBitmap deco; +}; + +class ModernSys : public KCommonDecoration +{ +public: + ModernSys( KDecorationBridge* b, KDecorationFactory* f ); + ~ModernSys(){;} + + 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 KCommonDecorationButton *createButton(ButtonType type); + + virtual void updateWindowShape(); + virtual void updateCaption(); + + void init(); +protected: + void drawRoundFrame(TQPainter &p, int x, int y, int w, int h); + void paintEvent( TQPaintEvent* ); + void recalcTitleBuffer(); + void reset( unsigned long ); +private: + TQPixmap titleBuffer; + TQString oldTitle; + bool reverse; +}; + +class ModernSysFactory : public TQObject, public KDecorationFactory +{ +public: + ModernSysFactory(); + virtual ~ModernSysFactory(); + virtual KDecoration* createDecoration( KDecorationBridge* ); + virtual bool reset( unsigned long changed ); + virtual bool supports( Ability ability ); + TQValueList< BorderSize > borderSizes() const; +private: + void read_config(); +}; + +} + +#endif diff --git a/twin/clients/modernsystem/modernsystem.desktop b/twin/clients/modernsystem/modernsystem.desktop new file mode 100644 index 000000000..994fd2860 --- /dev/null +++ b/twin/clients/modernsystem/modernsystem.desktop @@ -0,0 +1,69 @@ +[Desktop Entry] +Name=Modern System +Name[af]=Moderne Stelsel +Name[ar]=نظام معاصر +Name[az]=Modern Sistem +Name[be]=Сучасная сістэма +Name[bn]=মডার্ন সিস্টেম +Name[br]=Reizhiad Nevez +Name[ca]=Sistema modern +Name[cs]=Moderní systém +Name[csb]=Mòdernô systema +Name[cy]=Cysawd Cyfoes +Name[da]=Moderne system +Name[el]=Μοντέρνο σύστημα +Name[eo]=Moderna Sistemo +Name[es]=Sistema moderno +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[hi]=आधुनिक तंत्र +Name[hr]=Suvremeni sustav +Name[is]=Nútímaleg vél +Name[it]=Sistema Moderno +Name[ja]=モダンシステム +Name[ka]=თანამედროვე სისტემა +Name[kk]=Заманауи жүйе +Name[km]=ប្រព័ន្ធទំនើប +Name[ko]=모던 시스템 +Name[lt]=Moderni sistema +Name[lv]=Moderna sistēma +Name[mk]=Модерен систем +Name[ms]=Sistem Moden +Name[mt]=Sistema Moderna +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 moderm +Name[ru]=Современная система +Name[rw]=Sisitemu Igezweho +Name[se]=Áigeguovdilis vuogádat +Name[sk]=Moderný systém +Name[sl]=Moderni sistem +Name[sr]=Модерни систем +Name[sr@Latn]=Moderni sistem +Name[sv]=Modernt system +Name[ta]=நவீன அமைப்பு +Name[te]=ఆధునిక వ్యవస్థ +Name[tg]=Системаи навтарин +Name[th]=แบบ Moden System +Name[tr]=Modern Sistem +Name[tt]=Zamança Sistem +Name[uk]=Сучасна система +Name[uz]=Zamonaviy tizim +Name[uz@cyrillic]=Замонавий тизим +Name[vi]=Hệ thống Hiện đại +Name[wa]=Sistinme modiene +Name[zh_CN]=现代系统 +Name[zh_TW]=現代系統 +X-KDE-Library=twin3_modernsys |