From 714ac1f0c4ca9bcb352aa90ab11c0bd294b20c2f Mon Sep 17 00:00:00 2001 From: Vincent Reher Date: Thu, 21 Jan 2021 12:51:58 -0800 Subject: Introduce new TDE widget style that scales with font DPI. Style is based on the 'phase' style which according to its author David Johnson, is "abandonware" (per 2020-09-24 email to Author). This initial commit is based on code developed <= 2020-07-20 and has been tested and actively used on Author's systems to date. Signed-off-by: Vincent Reher --- styles/CMakeLists.txt | 1 + styles/Makefile.am | 2 +- styles/phase2/CMakeL10n.txt | 3 + styles/phase2/CMakeLists.txt | 49 + styles/phase2/Makefile.am | 22 + styles/phase2/bitmaps.h | 67 + styles/phase2/config/CMakeL10n.txt | 3 + styles/phase2/config/CMakeLists.txt | 36 + styles/phase2/config/Makefile.am | 12 + styles/phase2/config/phase2styleconfig.cpp | 111 ++ styles/phase2/config/phase2styleconfig.h | 57 + styles/phase2/config/styledialog.ui | 70 + styles/phase2/phase2.themerc | 86 + styles/phase2/phase2style.cpp | 2985 ++++++++++++++++++++++++++++ styles/phase2/phase2style.h | 280 +++ styles/phase2/scaling.h | 139 ++ styles/phase2/shapes.h | 400 ++++ 17 files changed, 4322 insertions(+), 1 deletion(-) create mode 100644 styles/phase2/CMakeL10n.txt create mode 100644 styles/phase2/CMakeLists.txt create mode 100644 styles/phase2/Makefile.am create mode 100644 styles/phase2/bitmaps.h create mode 100644 styles/phase2/config/CMakeL10n.txt create mode 100644 styles/phase2/config/CMakeLists.txt create mode 100644 styles/phase2/config/Makefile.am create mode 100644 styles/phase2/config/phase2styleconfig.cpp create mode 100644 styles/phase2/config/phase2styleconfig.h create mode 100644 styles/phase2/config/styledialog.ui create mode 100644 styles/phase2/phase2.themerc create mode 100644 styles/phase2/phase2style.cpp create mode 100644 styles/phase2/phase2style.h create mode 100644 styles/phase2/scaling.h create mode 100644 styles/phase2/shapes.h diff --git a/styles/CMakeLists.txt b/styles/CMakeLists.txt index ca32bd4b..6b953156 100644 --- a/styles/CMakeLists.txt +++ b/styles/CMakeLists.txt @@ -11,3 +11,4 @@ add_subdirectory( dotnet ) add_subdirectory( phase ) +add_subdirectory( phase2 ) diff --git a/styles/Makefile.am b/styles/Makefile.am index 8518ce8b..2be426e4 100644 --- a/styles/Makefile.am +++ b/styles/Makefile.am @@ -1 +1 @@ -SUBDIRS = dotnet phase +SUBDIRS = dotnet phase phase2 diff --git a/styles/phase2/CMakeL10n.txt b/styles/phase2/CMakeL10n.txt new file mode 100644 index 00000000..b585ce4a --- /dev/null +++ b/styles/phase2/CMakeL10n.txt @@ -0,0 +1,3 @@ +##### create translation templates ############## + +tde_l10n_auto_add_subdirectories( ) diff --git a/styles/phase2/CMakeLists.txt b/styles/phase2/CMakeLists.txt new file mode 100644 index 00000000..e2110ceb --- /dev/null +++ b/styles/phase2/CMakeLists.txt @@ -0,0 +1,49 @@ +################################################# +# +# (C) 2021 Vincent Reher +# tde (AT) 4reher.org +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_definitions( + -DQT_PLUGIN +) + +include_directories( + ${TQT_INCLUDE_DIRS} + ${TDE_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} +) + + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +add_subdirectory( config ) + +##### other data ################################ + +tde_create_translated_desktop( + SOURCE phase2.themerc + DESTINATION ${DATA_INSTALL_DIR}/tdestyle/themes + PO_DIR style-themes +) + +##### phase2style ################################# + +set( target phase2style ) + +set( ${target}_SRCS + phase2style.cpp phase2style.h shapes.h scaling.h +) + +tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK tdefx-shared + DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/styles +) diff --git a/styles/phase2/Makefile.am b/styles/phase2/Makefile.am new file mode 100644 index 00000000..f6d420e4 --- /dev/null +++ b/styles/phase2/Makefile.am @@ -0,0 +1,22 @@ +AUTOMAKE_OPTIONS = foreign + +SUBDIRS = config + +KDE_CXXFLAGS = -DQT_PLUGIN + +INCLUDES = $(all_includes) + +styledir = $(kde_datadir)/tdestyle/themes +style_DATA = phase2.themerc + +EXTRA_DIST = $(style_DATA) + +noinst_HEADERS = phase2style.h bitmaps.h shapes.h arrows.h + +kde_style_LTLIBRARIES = phase2style.la +phase2style_la_SOURCES = phase2style.cpp +phase2style_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx +phase2style_la_LIBADD = -ltdefx -ltdecore +phase2style_la_METASOURCES = AUTO + +DISTCLEANFILES = $(phase2style_la_METASOURCES) diff --git a/styles/phase2/bitmaps.h b/styles/phase2/bitmaps.h new file mode 100644 index 00000000..1163e103 --- /dev/null +++ b/styles/phase2/bitmaps.h @@ -0,0 +1,67 @@ +////////////////////////////////////////////////////////////////////////////// +// bitmaps.h +// ------------------- +// Bitmaps for Phase style +// ------------------- +// Copyright (c) 2004 David Johnson +// Please see the phasestyle.h file for copyright and license information. +////////////////////////////////////////////////////////////////////////////// + +// Note: the "light" bits are drawn with midlight color + +// Arrows (6x6) + +static TQBitmap uarrow; +static const unsigned char uarrow_bits[] = { + 0x00, 0x0c, 0x1e, 0x3f, 0x3f, 0x00}; + +static TQBitmap darrow; +static const unsigned char darrow_bits[] = { + 0x00, 0x3f, 0x3f, 0x1e, 0x0c, 0x00}; + +static TQBitmap larrow; +static const unsigned char larrow_bits[] = { + 0x18, 0x1c, 0x1e, 0x1e, 0x1c, 0x18}; + +static TQBitmap rarrow; +static const unsigned char rarrow_bits[] = { + 0x06, 0x0e, 0x1e, 0x1e, 0x0e, 0x06}; + +// plus/minus "arrows" + +static TQBitmap bplus; +static const unsigned char bplus_bits[] = { + 0x0c, 0x0c, 0x3f, 0x3f, 0x0c, 0x0c}; + +static TQBitmap bminus; +static const unsigned char bminus_bits[] = { + 0x00, 0x00, 0x3f, 0x3f, 0x00, 0x00}; + +// checkmark (9x9) + +static TQBitmap bcheck; +static const unsigned char bcheck_bits[] = { + 0x00, 0x00, 0x80, 0x01, 0xc0, 0x01, 0xe0, 0x00, 0x73, 0x00, 0x3f, 0x00, + 0x1e, 0x00, 0x0c, 0x00, 0x00, 0x00}; + +// expander arrows (9x9) + +static TQBitmap dexpand; +static const unsigned char dexpand_bits[] = { + 0x00, 0x00, 0x00, 0x00, 0xff, 0x01, 0xfe, 0x00, 0x7c, 0x00, 0x38, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00}; + +static TQBitmap rexpand; +static const unsigned char rexpand_bits[] = { + 0x04, 0x00, 0x0c, 0x00, 0x1c, 0x00, 0x3c, 0x00, 0x7c, 0x00, 0x3c, 0x00, + 0x1c, 0x00, 0x0c, 0x00, 0x04, 0x00}; + +// scrollbar doodads (4x4) + +static TQBitmap doodad_mid; +static const unsigned char doodad_mid_bits[] = { + 0x07, 0x01, 0x01, 0x00}; + +static TQBitmap doodad_light; +static const unsigned char doodad_light_bits[] = { + 0x00, 0x08, 0x08, 0x0e}; diff --git a/styles/phase2/config/CMakeL10n.txt b/styles/phase2/config/CMakeL10n.txt new file mode 100644 index 00000000..514740a4 --- /dev/null +++ b/styles/phase2/config/CMakeL10n.txt @@ -0,0 +1,3 @@ +##### create translation templates ############## + +tde_l10n_create_template( "tdestyle_phase_config" ) diff --git a/styles/phase2/config/CMakeLists.txt b/styles/phase2/config/CMakeLists.txt new file mode 100644 index 00000000..7a6d2aa6 --- /dev/null +++ b/styles/phase2/config/CMakeLists.txt @@ -0,0 +1,36 @@ +################################################# +# +# (C) 2021 Vincent Reher +# tde (AT) 4reher.org +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${TQT_INCLUDE_DIRS} + ${TDE_INCLUDE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + +##### tdestyle_phase_config ######################## + +set( target tdestyle_phase2_config ) + +set( ${target}_SRCS + phase2styleconfig.h + phase2styleconfig.cpp + styledialog.ui +) + +tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK tdeui-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/styles/phase2/config/Makefile.am b/styles/phase2/config/Makefile.am new file mode 100644 index 00000000..ff5b16b1 --- /dev/null +++ b/styles/phase2/config/Makefile.am @@ -0,0 +1,12 @@ +INCLUDES = $(all_includes) + +noinst_HEADERS = phase2styleconfig.h + +kde_module_LTLIBRARIES = tdestyle_phase2_config.la +tdestyle_phase_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module $(LIB_QT) $(LIB_TDECORE) $(LIB_TDEUI) -ltdefx +tdestyle_phase_config_la_LIBADD = $(LIB_TDEUI) +tdestyle_phase_config_la_SOURCES = phases2tyleconfig.cpp styledialog.ui +tdestyle_phase_config_la_METASOURCES = AUTO + +messages: rc.cpp + $(XGETTEXT) *.cpp *.h -o $(podir)/tdestyle_phase2_config.pot diff --git a/styles/phase2/config/phase2styleconfig.cpp b/styles/phase2/config/phase2styleconfig.cpp new file mode 100644 index 00000000..4528f47a --- /dev/null +++ b/styles/phase2/config/phase2styleconfig.cpp @@ -0,0 +1,111 @@ +////////////////////////////////////////////////////////////////////////////// +// phasestyleconfig.cpp +// ------------------- +// Config dialog for Phase widget style +// ------------------- +// Copyright (c) 2004 David Johnson +// Please see the header file for copyright and license information. +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include +#include +#include +#include + +#include "phase2styleconfig.h" +#include "styledialog.h" + +////////////////////////////////////////////////////////////////////////////// +// PhaseStyleConfig Class // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// PhaseStyleConfig() +// ---------------- +// Constructor + +PhaseStyleConfig::PhaseStyleConfig(TQWidget* parent) : StyleDialog(parent) +{ + TDEGlobal::locale()->insertCatalogue("tdestyle_phase_config"); + + TQSettings settings; + oldgradients = + settings.readBoolEntry("/phasestyle/Settings/gradients", true); + gradients->setChecked(oldgradients); + oldhighlights = + settings.readBoolEntry("/phasestyle/Settings/highlights", true); + highlights->setChecked(oldhighlights); + + // connections + connect(gradients, TQT_SIGNAL(toggled(bool)), + this, TQT_SLOT(updateChanged())); + connect(highlights, TQT_SIGNAL(toggled(bool)), + this, TQT_SLOT(updateChanged())); +} + +////////////////////////////////////////////////////////////////////////////// +// ~PhaseStyleConfig() +// ----------------- +// Destructor + +PhaseStyleConfig::~PhaseStyleConfig() +{ + TDEGlobal::locale()->removeCatalogue("tdestyle_phase_config"); +} + +////////////////////////////////////////////////////////////////////////////// +// selectionChanged() +// ------------------ +// Selection has changed + +void PhaseStyleConfig::updateChanged() +{ + bool update = false; + + if ((gradients->isChecked() != oldgradients) || + (highlights->isChecked() != oldhighlights)) { + update = true; + } + + emit changed(update); +} + +////////////////////////////////////////////////////////////////////////////// +// save() +// ------ +// Save the settings + +void PhaseStyleConfig::save() +{ + TQSettings settings; + settings.writeEntry("/phasestyle/Settings/gradients", + gradients->isChecked()); + settings.writeEntry("/phasestyle/Settings/highlights", + highlights->isChecked()); +} + +////////////////////////////////////////////////////////////////////////////// +// defaults() +// ---------- +// Set to the defaults + +void PhaseStyleConfig::defaults() +{ + gradients->setChecked(true); + highlights->setChecked(true); +} + +////////////////////////////////////////////////////////////////////////////// +// Plugin Stuff // +////////////////////////////////////////////////////////////////////////////// + +extern "C" +{ + KDE_EXPORT TQObject* allocate_tdestyle_config(TQWidget* parent) { + return(TQT_TQOBJECT(new PhaseStyleConfig(parent))); + } +} + +#include "phase2styleconfig.moc" diff --git a/styles/phase2/config/phase2styleconfig.h b/styles/phase2/config/phase2styleconfig.h new file mode 100644 index 00000000..0c29a52c --- /dev/null +++ b/styles/phase2/config/phase2styleconfig.h @@ -0,0 +1,57 @@ +////////////////////////////////////////////////////////////////////////////// +// phasestyleconfig.h +// ------------------- +// Config dialog for Phase widget style +// ------------------- +// Copyright (c) 2004 David Johnson +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +////////////////////////////////////////////////////////////////////////////// + +#ifndef PHASESTYLECONFIG_H +#define PHASESTYLECONFIG_H + +#include "styledialog.h" + +class TDEConfig; + +class PhaseStyleConfig : public StyleDialog +{ + Q_OBJECT + +public: + PhaseStyleConfig(TQWidget* parent); + ~PhaseStyleConfig(); + +signals: + void changed(bool); + +public slots: + void save(); + void defaults(); + +protected slots: + void updateChanged(); + +private: + bool oldgradients; + bool oldhighlights; +}; + +#endif // PHASESTYLECONFIG_H diff --git a/styles/phase2/config/styledialog.ui b/styles/phase2/config/styledialog.ui new file mode 100644 index 00000000..484de58a --- /dev/null +++ b/styles/phase2/config/styledialog.ui @@ -0,0 +1,70 @@ + +StyleDialog + + + StyleDialog + + + + 0 + 0 + 217 + 103 + + + + Style Dialog + + + + unnamed + + + + stylebox + + + GroupBoxPanel + + + Sunken + + + Style Settings + + + + unnamed + + + + gradients + + + Use &gradients + + + This option will draw buttons and several other widgets using a gradient texture + + + + + highlights + + + Highlight on &mouse hover + + + This option will highlight buttons and several other widgets when the mouse cursor is over them + + + + + + + + gradients + highlights + + + diff --git a/styles/phase2/phase2.themerc b/styles/phase2/phase2.themerc new file mode 100644 index 00000000..ef0e65cf --- /dev/null +++ b/styles/phase2/phase2.themerc @@ -0,0 +1,86 @@ +[Misc] +Name=Phase2 +Name[br]=Prantadoù +Name[ca]=Fase +Name[el]=Φάση +Name[eo]=Fazo +Name[es]=Fase +Name[et]=Faas +Name[eu]=Fasea +Name[fa]=گام +Name[fi]=Vaihe +Name[fy]=Faze +Name[ga]=Pas +Name[he]=קרני לייזר +Name[hi]=फेज़ +Name[is]=Fasi +Name[it]=Fase +Name[ja]=位相 +Name[ka]=ფაზა +Name[mk]=Фаза +Name[ms]=Fasa +Name[nb]=Fase +Name[nds]=Phaas +Name[ne]=चरण +Name[nn]=Fase +Name[pa]=ਪੜਾਅ +Name[pl]=Faza +Name[ru]=Фаза +Name[sl]=Faza +Name[sr]=Фаза +Name[sr@Latn]=Faza +Name[sv]=Fas +Name[ta]=பகுதி +Name[tr]=Faz +Name[uk]=Фаза +Name[vi]=Pha +Name[zh_TW]=相 +ConfigPage=tdestyle_phase2_config +Comment=Clean classical look that scales with current widget font +Comment[bg]=Семпъл и изчистен стил +Comment[bs]=Jednostavan klasični stil +Comment[ca]=Un estil clàssic i net +Comment[cs]=Klasický čistý vzhled +Comment[da]=Rent klassisk udseende +Comment[de]=Ein einfaches und klares Aussehen +Comment[el]=Ένα απλό και κλασσικό στυλ +Comment[es]=Un estilo clásico y claro +Comment[et]=Lihtne klassikaline välimus +Comment[eu]=Itxura garbi klasikoa +Comment[fa]=ظاهر کلاسیک واضح +Comment[fi]=Puhdas perinteinen tyyli +Comment[fr]=Un style simple et propre +Comment[fy]=In klassyk en moai uterlik +Comment[gl]=Apariencia sinxela e clásica +Comment[he]=סגנון פשוט ונקי +Comment[hi]=साफ शास्त्रीय रूप +Comment[hu]=Tiszta, egyszerű stílus +Comment[is]=Einfaldur og hreinlegur stíll +Comment[it]=Orologio classico +Comment[ja]=単純で清潔なスタイル +Comment[ka]=სადა და კლასიკური სტილი +Comment[mk]=Чист класичен изглед +Comment[ms]=Rupa klasik bersih +Comment[nb]=Enkelt klassisk utseende +Comment[nds]=Oprüümt klass'sch Utsehn +Comment[ne]=सफा उत्कृष्ट ढाँचा +Comment[nl]=Een klassiek en schoon uiterlijk +Comment[nn]=Enkel og klassisk utsjånad +Comment[pa]=ਸਾਫ਼ ਟਕਸਾਲੀ ਦਿੱਖ +Comment[pl]=Czysty, klasyczny wygląd +Comment[pt]=Um estilo clássico limpo +Comment[pt_BR]=Uma aprência clássica limpa +Comment[ru]=Простой классический стиль +Comment[sk]=Jednoduchý klasický vzhľad +Comment[sl]=Čist klasičen izgled +Comment[sr]=Чист класичан изглед +Comment[sr@Latn]=Čist klasičan izgled +Comment[sv]=Ren och klassisk stil +Comment[ta]=விசேஷ பார்வையைத் துடை +Comment[tr]=Temiz ve klasik bir görünüm +Comment[uk]=Акуратний, класичний стиль +Comment[vi]=Sạch, kiểu dáng truyền thống +Comment[zh_CN]=简洁经典的外观 +Comment[zh_TW]=乾淨的傳統外觀 +[KDE] +WidgetStyle=Phase2 diff --git a/styles/phase2/phase2style.cpp b/styles/phase2/phase2style.cpp new file mode 100644 index 00000000..73d23599 --- /dev/null +++ b/styles/phase2/phase2style.cpp @@ -0,0 +1,2985 @@ +////////////////////////////////////////////////////////////////////////////// +// phase2style.cpp +// ------------------- +// TQt/TDE widget style +// ------------------- +// Copyright (c) 2004 David Johnson +// Please see the header file for copyright and license information. +////////////////////////////////////////////////////////////////////////////// +// +// Some miscellaneous notes +// +// Reimplemented scrollbar metric and drawing routines from TDEStyle to allow +// better placement of subcontrols. This is because the subcontrols slightly +// overlap to share part of their border. +// +// Menu and toolbars are painted with the background color by default. This +// differs from the TQt default of giving them PaletteButton backgrounds. +// Menubars have normal gradients, toolbars have reverse. +// +// Some toolbars are not part of a TQMainWindows, such as in a TDE file dialog. +// In these cases we treat the toolbar as "floating" and paint it flat. +// +////////////////////////////////////////////////////////////////////////////// + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "phase2style.h" + +static const char* TQSPLITTERHANDLE = TQSPLITTERHANDLE_OBJECT_NAME_STRING; +static const char* TQTOOLBAREXTENSION = "TQToolBarExtensionWidget"; +static const char* KTOOLBARWIDGET = "tde toolbar widget"; + +// some convenient constants +static const int ITEMFRAME = 1; // menu stuff +static const int ITEMHMARGIN = 3; +static const int ITEMVMARGIN = 0; +//OBE: static const int ARROWMARGIN = 6; +static const int RIGHTBORDER = 6; +static const int MINICONSIZE = 16; +static const int CHECKSIZE = 9; +static const int MAXGRADIENTSIZE = 64; + +static unsigned contrast = 110; + +#include "scaling.h" +#include "shapes.h" + +/**************************** TO-DO ********************************** +* (1) The above "constants" should be re-scaled by the scaling.h +* function Generate_Scaling_Metrics() +* (2) Should the same function pre-draw other basic shapes in sizes +* relative to FONT_Scale? +*********************************************************************/ + +//#include "plastik-excerpt.cpp" + +////////////////////////////////////////////////////////////////////////////// +// Construction, Destruction, Initialization // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// Phase2Style() +// ----------- +// Constructor + +Phase2Style::Phase2Style() + : TDEStyle(FilledFrameWorkaround | AllowMenuTransparency, + ThreeButtonScrollBar), + gradients_(TQPixmap::defaultDepth() > 8), kicker_(false) +{ + TQSettings settings; + + Set_QT3SCALE() ; + Generate_Scaling_Metrics(0) ; + Initialize_Shapes() ; + + if (gradients_) { // don't bother setting if already false + gradients_ = + settings.readBoolEntry("/phasestyle/Settings/gradients", true); + contrast = 100 + settings.readNumEntry("/TQt/TDE/contrast", 5); + } + highlights_ = + settings.readBoolEntry("/phasestyle/Settings/highlights", true); + + gradients = new TQMap >; + + reverse_ = TQApplication::reverseLayout(); + +} + +Phase2Style::~Phase2Style() +{ + delete gradients; + gradients = 0; + if (KPE_ListViewExpander_ArrowLeft) { + delete KPE_ListViewExpander_ArrowLeft ; + KPE_ListViewExpander_ArrowLeft = 0 ; + } + if (KPE_ListViewExpander_ArrowRight) { + delete KPE_ListViewExpander_ArrowRight ; + KPE_ListViewExpander_ArrowLeft = 0 ; + } +} + +////////////////////////////////////////////////////////////////////////////// +// Polishing // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// polish() +// -------- +// Initialize application specific + +void Phase2Style::applicationPolish(const TQStyleControlElementData &ceData, ControlElementFlags, void *ptr) +{ + if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) { + TQApplication *app = reinterpret_cast(ptr); + if (!qstrcmp(app->argv()[0], "kicker")) kicker_ = true; + } +} + +////////////////////////////////////////////////////////////////////////////// +// polish() +// -------- +// Initialize the appearance of a widget + +void Phase2Style::polish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr) +{ + if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { + TQWidget *widget = reinterpret_cast(ptr); + + if (::tqqt_cast(widget) || + ::tqqt_cast(widget)) { + // anti-flicker optimization + widget->setBackgroundMode(NoBackground); + } else if (::tqqt_cast(widget) || + widget->inherits(TQTOOLBAREXTENSION) || + (!qstrcmp(widget->name(), KTOOLBARWIDGET))) { + // needs special handling on paint events + installObjectEventHandler(ceData, elementFlags, ptr, this); + } else if (highlights_ && + (::tqqt_cast(widget) || + ::tqqt_cast(widget) || + ::tqqt_cast(widget) || + ::tqqt_cast(widget) || + ::tqqt_cast(widget) || + ::tqqt_cast(widget) || + widget->inherits(TQSPLITTERHANDLE))) { + // mouseover highlighting + installObjectEventHandler(ceData, elementFlags, ptr, this); + } else if (highlights_ && ::tqqt_cast(widget)) { + // highlighting needing mouse tracking + widget->setMouseTracking(true); + installObjectEventHandler(ceData, elementFlags, ptr, this); + } + } + + TDEStyle::polish(ceData, elementFlags, ptr); +} + +////////////////////////////////////////////////////////////////////////////// +// polish() +// -------- +// Initialize the palette + +void Phase2Style::polish(TQPalette &pal) +{ + // clear out gradients on a color change + gradients->clear(); + + // lighten up a bit, so the look is not so "crisp" + if (TQPixmap::defaultDepth() > 8) { // but not on low color displays + pal.setColor(TQPalette::Disabled, TQColorGroup::Dark, + pal.color(TQPalette::Disabled, TQColorGroup::Dark).light(contrast)); + pal.setColor(TQPalette::Active, TQColorGroup::Dark, + pal.color(TQPalette::Active, TQColorGroup::Dark).light(contrast)); + pal.setColor(TQPalette::Inactive, TQColorGroup::Dark, + pal.color(TQPalette::Inactive, TQColorGroup::Dark).light(contrast)); + } + + TQStyle::polish(pal); +} + +////////////////////////////////////////////////////////////////////////////// +// unPolish() +// ---------- +// Undo the initialization of a widget's appearance + +void Phase2Style::unPolish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr) +{ + if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { + TQWidget *widget = reinterpret_cast(ptr); + + if (::tqqt_cast(widget) || + ::tqqt_cast(widget)) { + widget->setBackgroundMode(PaletteBackground); + } else if (::tqqt_cast(widget) || + widget->inherits(TQTOOLBAREXTENSION) || + (!qstrcmp(widget->name(), KTOOLBARWIDGET))) { + removeObjectEventHandler(ceData, elementFlags, ptr, this); + } else if (highlights_ && // highlighting + (::tqqt_cast(widget) || + ::tqqt_cast(widget) || + ::tqqt_cast(widget) || + ::tqqt_cast(widget) || + ::tqqt_cast(widget) || + ::tqqt_cast(widget) || + widget->inherits(TQSPLITTERHANDLE))) { + removeObjectEventHandler(ceData, elementFlags, ptr, this); + } else if (highlights_ && ::tqqt_cast(widget)) { + widget->setMouseTracking(false); + removeObjectEventHandler(ceData, elementFlags, ptr, this); + } + } + + TDEStyle::unPolish(ceData, elementFlags, ptr); +} + +////////////////////////////////////////////////////////////////////////////// +// Drawing // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// drawPhaseGradient() +// ------------------ +// Draw gradient + +void Phase2Style::drawPhaseGradient(TQPainter *painter, + const TQRect &rect, + TQColor color, + bool horizontal, + int px, int py, + int pw, int ph, + bool reverse) const +{ + if (!gradients_) { + painter->fillRect(rect, color); + return; + } + + // px, py, pw, ph used for parent-relative pixmaps + int size; + if (horizontal) + size = (pw > 0) ? pw : rect.width(); + else + size = (ph > 0) ? ph : rect.height(); + + if (size > MAXGRADIENTSIZE) { // keep it sensible + painter->fillRect(rect, color); + } else { + // lazy allocation + GradientSet *set = (*gradients)[color.rgb()][size]; + if (!set) { + set = new GradientSet(color, size); + (*gradients)[color.rgb()].setAutoDelete(true); + (*gradients)[color.rgb()].insert(size, set); + } + painter->drawTiledPixmap(rect, *set->gradient(horizontal, reverse), + TQPoint(px, py)); + } +} + +////////////////////////////////////////////////////////////////////////////// +// drawPhaseBevel() +// ---------------- +// Draw the basic Phase bevel + +void Phase2Style::drawPhaseBevel(TQPainter *painter, + int x, int y, int w, int h, + const TQColorGroup &group, + const TQColor &fill, + bool sunken, + bool horizontal, + bool reverse) const +{ + int x2 = x + w - 1; + int y2 = y + h - 1; + painter->save(); + + painter->setPen(group.dark()); + painter->drawRect(x, y, w, h); + + painter->setPen(sunken ? group.mid() : group.midlight()); + painter->drawLine(x+1, y+1, x2-2, y+1); + painter->drawLine(x+1, y+2, x+1, y2-2); + + painter->setPen(sunken ? group.midlight() : group.mid()); + painter->drawLine(x+2, y2-1, x2-1, y2-1); + painter->drawLine(x2-1, y+2, x2-1, y2-2); + + painter->setPen(group.button()); + painter->drawPoint(x+1, y2-1); + painter->drawPoint(x2-1, y+1); + + if (sunken) { + // sunken bevels don't get gradients + painter->fillRect(x+2, y+2, w-4, h-4, fill); + } else { + drawPhaseGradient(painter, TQRect(x+2, y+2, w-4, h-4), fill, + horizontal, 0, 0, w-4, h-4, reverse); + } + painter->restore(); +} + +////////////////////////////////////////////////////////////////////////////// +// drawPhaseButton() +// ---------------- +// Draw the basic Phase button + +void Phase2Style::drawPhaseButton(TQPainter *painter, + int x, int y, int w, int h, + const TQColorGroup &group, + const TQColor &fill, + bool sunken) const +{ + int x2 = x + w - 1; + int y2 = y + h - 1; + + painter->setPen(group.midlight()); + painter->drawLine(x+1, y2, x2, y2); + painter->drawLine(x2, y+1, x2, y2-1); + + painter->setPen(group.mid()); + painter->drawLine(x, y, x2-1, y); + painter->drawLine(x, y+1, x, y2-1); + + painter->setPen(group.button()); + painter->drawPoint(x, y2); + painter->drawPoint(x2, y); + + drawPhaseBevel(painter, x+1, y+1, w-2, h-2, group, fill, + sunken, false, false); +} + +////////////////////////////////////////////////////////////////////////////// +// drawPhasePanel() +// ---------------- +// Draw the basic Phase panel + +void Phase2Style::drawPhasePanel(TQPainter *painter, + int x, int y, int w, int h, + const TQColorGroup &group, + bool sunken, + const TQBrush *fill) const +{ + int x2 = x + w - 1; + int y2 = y + h - 1; + painter->save(); + + if (sunken) { + painter->setPen(group.dark()); + painter->drawRect(x+1, y+1, w-2, h-2); + painter->setPen(group.midlight()); + painter->drawLine(x+1, y2, x2, y2); + painter->drawLine(x2, y+1, x2, y2-1); + painter->setPen(group.mid()); + painter->drawLine(x, y, x, y2-1); + painter->drawLine(x+1, y, x2-1, y); + painter->setPen(group.background()); + painter->drawPoint(x, y2); + painter->drawPoint(x2, y); + } else { + painter->setPen(group.dark()); + painter->drawRect(x, y, w, h); + painter->setPen(group.midlight()); + painter->drawLine(x+1, y+1, x2-2, y+1); + painter->drawLine(x+1, y+2, x+1, y2-2); + painter->setPen(group.mid()); + painter->drawLine(x+2, y2-1, x2-1, y2-1); + painter->drawLine(x2-1, y+2, x2-1, y2-2); + painter->setPen(group.background()); + painter->drawPoint(x+1, y2-1); + painter->drawPoint(x2-1, y+1); + } + + if (fill) { + painter->fillRect(x+2, y+2, w-4, h-4, fill->color()); + } + painter->restore(); +} + +////////////////////////////////////////////////////////////////////////////// +// drawPhaseTab() +// ------------- +// Draw a Phase style tab + +void Phase2Style::drawPhaseTab(TQPainter *painter, + int x, int y, int w, int h, + const TQColorGroup &group, + const TQStyleControlElementData &ceData, + ControlElementFlags /*elementFlags*/, + const TQStyleOption &option, + SFlags flags) const +{ + bool selected = (flags & Style_Selected); + bool edge; // tab is at edge of bar + const int x2 = x + w - 1; + const int y2 = y + h - 1; + + painter->save(); + + // what position is the tab? + if ((ceData.tabBarData.tabCount == 1) + || (ceData.tabBarData.identIndexMap[option.tab()->identifier()] == 0)) { + edge = true; + } else { + edge = false; + } + + switch (TQTabBar::Shape(ceData.tabBarData.shape)) { + case TQTabBar::RoundedAbove: + case TQTabBar::TriangularAbove: { + // is there a corner widget? + if (!ceData.tabBarData.cornerWidgets[reverse_ ? TQStyleControlElementTabBarData::CWL_TopRight : TQStyleControlElementTabBarData::CWL_TopLeft].widgetObjectTypes.isEmpty()) { + edge = false; + } + + if (!selected) { // shorten + y += 2; h -= 2; + } + if (selected) { + painter->setPen(TQt::NoPen); + painter->fillRect(x+1, y+1, w-1, h-1, + group.brush(TQColorGroup::Background)); + } else { + drawPhaseGradient(painter, TQRect(x+1, y+1, w-1, h-2), + (flags & Style_MouseOver) + ? group.background() + : TQColor(group.background().dark(contrast)), + false, 0, 0, 0, h*2, false); + } + + // draw tab + painter->setPen(group.dark()); + painter->drawLine(x, y, x, y2-2); + painter->drawLine(x+1, y, x2, y); + painter->drawLine(x2, y+1, x2, y2-2); + + painter->setPen(group.mid()); + painter->drawLine(x2-1, y+2, x2-1, y2-2); + + painter->setPen(group.midlight()); + painter->drawLine(x+1, y+1, x2-2, y+1); + if ((selected) || edge) painter->drawLine(x+1, y+2, x+1, y2-2); + + // finish off bottom + if (selected) { + painter->setPen(group.dark()); + painter->drawPoint(x, y2-1); + painter->drawPoint(x2, y2-1); + + painter->setPen(group.midlight()); + painter->drawPoint(x, y2); + painter->drawLine(x+1, y2-1, x+1, y2); + painter->drawPoint(x2, y2); + + painter->setPen(group.mid()); + painter->drawPoint(x2-1, y2-1); + + if (!reverse_ && edge) { + painter->setPen(group.dark()); + painter->drawLine(x, y2-1, x, y2); + painter->setPen(group.midlight()); + painter->drawPoint(x+1, y2); + } + } else { + painter->setPen(group.dark()); + painter->drawLine(x, y2-1, x2, y2-1); + + painter->setPen(group.midlight()); + painter->drawLine(x, y2, x2, y2); + + if (!reverse_ && edge) { + painter->setPen(group.dark()); + painter->drawLine(x, y2-1, x, y2); + } + } + if (reverse_ && edge) { + painter->setPen(group.dark()); + painter->drawPoint(x2, y2); + painter->setPen(selected ? group.mid() : group.background()); + painter->drawPoint(x2-1, y2); + } + break; + } + + case TQTabBar::RoundedBelow: + case TQTabBar::TriangularBelow: { + // is there a corner widget? + if (!ceData.tabBarData.cornerWidgets[reverse_ ? TQStyleControlElementTabBarData::CWL_BottomRight : TQStyleControlElementTabBarData::CWL_BottomLeft].widgetObjectTypes.isEmpty()) { + edge = false; + } + + painter->setBrush((selected || (flags & Style_MouseOver)) + ? group.background() + : TQColor(group.background().dark(contrast))); + painter->setPen(TQt::NoPen); + painter->fillRect(x+1, y+1, w-1, h-1, painter->brush()); + + // draw tab + painter->setPen(group.dark()); + painter->drawLine(x, y+1, x, y2); + painter->drawLine(x+1, y2, x2, y2); + painter->drawLine(x2, y+1, x2, y2-1); + + painter->setPen(group.mid()); + painter->drawLine(x2-1, y+1, x2-1, y2-1); + painter->drawLine(x+2, y2-1, x2-1, y2-1); + painter->drawPoint(x, y); + painter->drawPoint(x2, y); + + if ((selected) || edge) { + painter->setPen(group.midlight()); + painter->drawLine(x+1, y+1, x+1, y2-2); + } + + // finish off top + if (selected) { + if (!reverse_ && edge) { + painter->setPen(group.dark()); + painter->drawPoint(x, y); + painter->setPen(group.midlight()); + painter->drawPoint(x+1, y); + } + } else { + painter->setPen(group.dark()); + painter->drawLine(x, y+1, x2, y+1); + + painter->setPen(group.mid()); + painter->drawLine(x, y, x2, y); + + if (!reverse_ && edge) { + painter->setPen(group.dark()); + painter->drawPoint(x, y); + } + } + if (reverse_ && edge) { + painter->setPen(group.dark()); + painter->drawPoint(x2, y); + painter->setPen(group.mid()); + painter->drawPoint(x2-1, y); + } + break; + } + } + painter->restore(); +} + +////////////////////////////////////////////////////////////////////////////// +// drawPrimitive() +// --------------- +// Draw the primitive element + +void Phase2Style::drawPrimitive(TQ_PrimitiveElement element, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQColorGroup &group, + SFlags flags, + const TQStyleOption &option) const +{ + // common locals + bool down = flags & Style_Down; + bool on = flags & Style_On; + bool depress = (down || on); + bool enabled = flags & Style_Enabled; + bool horiz = flags & Style_Horizontal; + bool active = flags & Style_Active; + bool mouseover = highlights_ && (flags & Style_MouseOver); + int x, y, w, h, x2, y2, n, cx, cy; + TQPointArray parray; + TQWidget* widget; + + rect.rect(&x, &y, &w, &h); + x2 = rect.right(); + y2 = rect.bottom(); + + switch(element) { + case PE_ButtonBevel: + case PE_ButtonDefault: + case PE_ButtonDropDown: + case PE_ButtonTool: + drawPhaseBevel(painter, x,y,w,h, group, group.button(), + depress, false, false); + break; + + case PE_ButtonCommand: + drawPhaseButton(painter, x, y, w, h, group, + mouseover ? + TQColor(group.button().light(contrast)) : + group.button(), depress); + break; + + case PE_FocusRect: { + TQPen old = painter->pen(); + painter->setPen(group.highlight().dark(contrast)); + + painter->drawRect(rect); + + painter->setPen(old); + break; + } + + case PE_HeaderSection: { + // covers kicker taskbar buttons and menu titles + TQHeader* header = dynamic_cast(painter->device()); + widget =dynamic_cast(painter->device()); + + if (header) { + horiz = (header->orientation() ==Qt::Horizontal); + } else { + horiz = true; + } + + if ((ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING)) || + (ceData.widgetObjectTypes.contains("TDEPopupTitle"))) { + // kicker/kdesktop menu titles + drawPhaseBevel(painter, x,y,w,h, + group, group.background(), depress, !horiz); + } else if (kicker_) { + // taskbar buttons (assuming no normal headers used in kicker) + if (depress) { + painter->setPen(group.dark()); + painter->setBrush(group.brush(TQColorGroup::Mid)); + painter->drawRect(x-1, y-1, w+1, h+1); + } + else { + drawPhaseBevel(painter, x-1, y-1, w+1, h+1, + group, group.button(), false, !horiz, true); + } + } else { + // other headers + if (depress) { + painter->setPen(group.dark()); + painter->setBrush(group.brush(TQColorGroup::Mid)); + painter->drawRect(x-1, y-1, w+1, h+1); + } + else { + drawPhaseBevel(painter, x-1, y-1, w+1, h+1, group, + group.background(), false, !horiz, true); + } + } + break; + } + + case PE_HeaderArrow: { + + //--- Determine arrow size & position + int arrowSize = ARROW_Size2 ; + int arrowScaling = 0 ; + int vdelta = ( h - arrowSize ) ; + int hdelta = ( w - arrowSize ) ; + int voffset = y + vdelta / 2 ; // vertical alignment: centered + int hoffset = x + hdelta / 2 ; // horizontal alignment: centered + TQRect frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + + //--- Determine arrow direction + TQStyle::PrimitiveElement arrow = PE_ArrowDown ; + if (flags & Style_Up) arrow = PE_ArrowUp ; + + //--- Determine arrow color + if (enabled) painter->setPen( + (flags & Style_Sunken) ? group.midlight() : darkBlue ); + // ? group.midlight() : group.dark()); + else painter->setPen( group.mid() ); + + //--- Draw arrow + drawArrow(painter, frame, arrow, arrowScaling ); + + break ; + + //-------------------------------------------------------------------- + /* Previous code: * / + //-------------------------------------------------------------------- + if (flags & Style_Up) + drawArrow(painter, TQRect(x,y,h,w), PE_ArrowUp, 0) ; + //drawPrimitive(PE_ArrowUp, painter, ceData, elementFlags, rect, group, Style_Enabled); + else + drawArrow(painter, TQRect(x,y,h,w), PE_ArrowDown, 0) ; + //drawPrimitive(PE_ArrowDown, painter, ceData, elementFlags, rect, group, Style_Enabled); + break ; /* End of previous code */ + } + + case PE_ScrollBarAddPage: + case PE_ScrollBarSubPage: + if (h) { // has a height, thus visible + painter->fillRect(rect, group.mid()); + painter->setPen(group.dark()); + if (horiz) { // vertical + painter->drawLine(x, y, x2, y); + painter->drawLine(x, y2, x2, y2); + } else { // horizontal + painter->drawLine(x, y, x, y2); + painter->drawLine(x2, y, x2, y2); + } + } + break; + + case PE_ScrollBarAddLine: + case PE_ScrollBarSubLine: { + drawPhaseBevel(painter, x, y, w, h, + group, group.button(), down, !horiz, true); + + //--- Determine arrow direction + TQ_PrimitiveElement arrow = ((horiz) ? + ((element == PE_ScrollBarAddLine) ? + PE_ArrowRight : PE_ArrowLeft) : + ((element == PE_ScrollBarAddLine) ? + PE_ArrowDown : PE_ArrowUp)); + + if (down) { // shift arrow + switch (arrow) { + case PE_ArrowRight: x++; break; + case PE_ArrowLeft: x--; break; + case PE_ArrowDown: y++; break; + case PE_ArrowUp: y--; break; + default: break; + } + } + + //--- Determine arrow size & position + int arrowSize = ARROW_Size2 ; + int arrowScaling = 0 ; + int vdelta = ( h - arrowSize ) ; + int hdelta = ( w - arrowSize ) ; + int voffset = y + vdelta / 2 ; // vertical alignment: centered + int hoffset = x + hdelta / 2 ; // horizontal alignment: centered + TQRect frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + + //--- Determine arrow color + if (enabled) painter->setPen( + (flags & Style_Sunken) ? group.midlight() : darkBlue ); + // ? group.midlight() : group.dark()); + else painter->setPen( group.mid() ); + + //--- Draw arrow + drawArrow(painter, frame, arrow, arrowScaling ); + + break; + + //-------------------------------------------------------------------- + /* Previous code: * / + //-------------------------------------------------------------------- + + //drawPrimitive(arrow, painter, ceData, elementFlags, TQRect(x,y,h,w), group, flags); + drawArrow(painter, TQRect(x,y,h,w), arrow, 4) ; + break ; /* End of previous code */ + } + + case PE_ScrollBarSlider: + drawPhaseBevel(painter, x, y, w, h, group, group.button(), + false, !horiz, true); + // draw doodads + cx = x + w/2 - 2; cy = y + h/2 - 2; + if (horiz && (w >=20)) { + for (n = -5; n <= 5; n += 5) { + kColorBitmaps(painter, group, cx+n, cy, + 0, &doodad_mid, &doodad_light, 0, 0, 0); + } + } else if (!horiz && (h >= 20)) { + for (n = -5; n <= 5; n += 5) { + kColorBitmaps(painter, group, cx, cy+n, + 0, &doodad_mid, &doodad_light, 0, 0, 0); + } + } + break; + + case PE_Indicator: + drawPhasePanel(painter, x+1, y+1, w-2, h-2, group, true, enabled ? + &group.brush(TQColorGroup::Base) : + &group.brush(TQColorGroup::Background)); + + if (on) { + painter->setPen(mouseover + ? TQColor(group.highlight().dark(contrast)) + : group.dark()); + painter->drawRect(x+4, y+4, w-8, h-8); + painter->fillRect(x+5, y+5, w-10, h-10, + group.brush(TQColorGroup::Highlight)); + } else if (mouseover) { + painter->setPen(TQColor(group.highlight().dark(contrast))); + painter->drawRect(x+4, y+4, w-8, h-8); + } + break; + + case PE_IndicatorMask: + painter->fillRect(x+1, y+1, w-2, h-2, TQt::color1); + painter->setPen(TQt::color0); + break; + + case PE_ExclusiveIndicator: { + // note that this requires an even size from pixelMetric + cx = (x + x2) / 2; + cy = (y + y2) / 2; + + painter->setBrush(enabled + ? group.brush(TQColorGroup::Base) + : group.brush(TQColorGroup::Background)); + + painter->setPen(group.dark()); + parray.putPoints(0, 8, + x+1,cy+1, x+1,cy, cx,y+1, cx+1,y+1, + x2-1,cy, x2-1,cy+1, cx+1,y2-1, cx,y2-1); + painter->drawConvexPolygon(parray, 0, 8); + + painter->setPen(group.mid()); + parray.putPoints(0, 4, x,cy, cx,y, cx+1,y, x2,cy); + painter->drawPolyline(parray, 0, 4); + painter->setPen(group.midlight()); + parray.putPoints(0, 4, x2,cy+1, cx+1,y2, cx,y2, x,cy+1); + painter->drawPolyline(parray, 0, 4); + + if (on) { + painter->setBrush(group.brush(TQColorGroup::Highlight)); + painter->setPen(mouseover + ? TQColor(group.highlight().dark(contrast)) + : group.dark()); + parray.putPoints(0, 8, + x+4,cy+1, x+4,cy, cx,y+4, cx+1,y+4, + x2-4,cy, x2-4,cy+1, cx+1,y2-4, cx,y2-4); + painter->drawConvexPolygon(parray, 0, 8); + } else if (mouseover) { + painter->setPen(TQColor(group.highlight().dark(contrast))); + parray.putPoints(0, 9, + x+4,cy+1, x+4,cy, cx,y+4, cx+1,y+4, + x2-4,cy, x2-4,cy+1, cx+1,y2-4, cx,y2-4, + x+4,cy+1); + painter->drawPolyline(parray, 0, 9); + } + break; + } + + case PE_ExclusiveIndicatorMask: + cx = (x + x2) / 2; + cy = (y + y2) / 2; + painter->setBrush(TQt::color1); + painter->setPen(TQt::color1); + parray.putPoints(0, 8, + x,cy+1, x,cy, cx,y, cx+1,y, + x2,cy, x2,cy+1, cx+1,y2, cx,y2); + painter->drawConvexPolygon(parray, 0, 8); + painter->setPen(TQt::color0); + break; + + case PE_DockWindowResizeHandle: + drawPhasePanel(painter, x, y, w, h, group, false, + &group.brush(TQColorGroup::Background)); + break; + + case PE_Splitter: + cx = x + w/2 - 2; cy = y + h/2 - 2; + painter->fillRect(rect, + (flags & Style_MouseOver) + ? TQColor(group.background().light(contrast)) + : group.background()); + + if (!horiz && (w >=20)) { + for (n = -5; n <= 5; n += 5) { + kColorBitmaps(painter, group, cx+n, cy, + 0, &doodad_mid, &doodad_light, 0, 0, 0); + } + } else if (horiz && (h >= 20)) { + for (n = -5; n <= 5; n += 5) { + kColorBitmaps(painter, group, cx, cy+n, + 0, &doodad_mid, &doodad_light, 0, 0, 0); + } + } + break; + + case PE_Panel: + case PE_PanelLineEdit: + case PE_PanelTabWidget: + case PE_TabBarBase: + drawPhasePanel(painter, x, y, w, h, group, flags & Style_Sunken); + break; + + case PE_PanelPopup: + case PE_WindowFrame: + drawPhasePanel(painter, x, y, w, h, group, false); + break; + + case PE_GroupBoxFrame: + case PE_PanelGroupBox: + painter->setPen(group.dark()); + painter->drawRect(rect); + break; + + case PE_Separator: + painter->setPen(group.dark()); + if (w < h) + painter->drawLine(w/2, y, w/2, y2); + else + painter->drawLine(x, h/2, x2, h/2); + break; + + case PE_StatusBarSection: + painter->setPen(group.mid()); + painter->drawLine(x, y, x2-1, y); + painter->drawLine(x, y+1, x, y2-1); + painter->setPen(group.midlight()); + painter->drawLine(x+1, y2, x2, y2); + painter->drawLine(x2, y+1, x2, y2-1); + break; + + case PE_PanelMenuBar: + case PE_PanelDockWindow: + if (kicker_ && (w == 2)) { // kicker handle separator + painter->setPen(group.mid()); + painter->drawLine(x, y, x, y2); + painter->setPen(group.midlight()); + painter->drawLine(x+1, y, x+1, y2); + } else if (kicker_ && (h == 2)) { // kicker handle separator + painter->setPen(group.mid()); + painter->drawLine(x, y, x2, y); + painter->setPen(group.midlight()); + painter->drawLine(x, y+1, x2, y+1); + } else { + --x; --y; ++w; ++h; // adjust rect so we can use bevel + drawPhaseBevel(painter, x, y, w, h, + group, group.background(), false, (w < h), + (element==PE_PanelDockWindow) ? true : false); + } + break; + + case PE_DockWindowSeparator: { + widget = dynamic_cast(painter->device()); + bool flat = true; + + if (ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING)) { + TQToolBar *toolbar = ::tqqt_cast(widget->parent()); + if (toolbar) { + // toolbar not floating or in a TQMainWindow + flat = flatToolbar(ceData, elementFlags, toolbar); + } + } + + if (flat) + painter->fillRect(rect, group.background()); + else + drawPhaseGradient(painter, rect, group.background(), + !(horiz), 0, 0, -1, -1, true); + + if (horiz) { + int cx = w/2 - 1; + painter->setPen(group.mid()); + painter->drawLine(cx, 0, cx, h-2); + if (!flat) painter->drawLine(0, h-1, w-1, h-1); + + painter->setPen(group.midlight()); + painter->drawLine(cx+1, 0, cx+1, h-2); + } else { + int cy = h/2 - 1; + painter->setPen(group.mid()); + painter->drawLine(0, cy, w-2, cy); + if (!flat) painter->drawLine(w-1, 0, w-1, h-1); + + painter->setPen(group.midlight()); + painter->drawLine(0, cy+1, w-2, cy+1); + } + break; + } + + case PE_SizeGrip: { + int sw = TQMIN(h, w) - 1; + y = y2 - sw; + + if (reverse_) { + x2 = x + sw; + for (int n = 0; n < 4; ++n) { + painter->setPen(group.dark()); + painter->drawLine(x, y, x2, y2); + painter->setPen(group.midlight()); + painter->drawLine(x, y+1, x2-1, y2); + y += 3;; + x2 -= 3;; + } + } else { + x = x2 - sw; + for (int n = 0; n < 4; ++n) { + painter->setPen(group.dark()); + painter->drawLine(x, y2, x2, y); + painter->setPen(group.midlight()); + painter->drawLine(x+1, y2, x2, y+1); + x += 3; + y += 3; + } + } + + break; + } + + case PE_CheckMark: + + drawCheckmark(painter, rect, 4 ); + break ; + painter->setPen(group.text()); + painter->drawPixmap(x+w/2-4, y+h/2-4, bcheck); + break; + + case PE_SpinWidgetPlus: + case PE_SpinWidgetMinus: + if (enabled) + painter->setPen((flags & Style_Sunken) + ? group.midlight() : group.dark()); + else + painter->setPen(group.mid()); + painter->drawPixmap(x+w/2-3, y+h/2-3, + (element==PE_SpinWidgetPlus) ? bplus : bminus); + break; + + case PE_SpinWidgetUp: { + + // painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow); break ; + + //--- Determine arrow size & position + //int arrowSize = ARROW_Size4x3 ; + //int arrowScaling = 1 ; + int arrowSize = ARROW_Size2 ; + int arrowScaling = 1 ; + int vdelta = ( h - arrowSize ) ; + int hdelta = ( w - arrowSize ) ; + int voffset = y + vdelta ; // vertical alignment: top + int hoffset = x + hdelta / 2 ; // horizontal alignment: centered + TQRect frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + + //--- Determine arrow direction + TQStyle::PrimitiveElement arrow = PE_ArrowUp ; + + //--- Determine arrow color + if (flags & Style_Enabled) { + painter->setPen((flags & Style_Sunken) + ? group.midlight() : group.dark()); + painter->setPen(darkBlue) ; + } + else { + painter->setPen(group.mid()); + } + + //--- Draw arrow + drawArrow(painter, frame, arrow, arrowScaling ); + + break ; + + //-------------------------------------------------------------------- + /* Previous code: * / + //-------------------------------------------------------------------- + + drawArrow(painter, rect, element, 3) ; + //drawArrow(painter, TQRect(x+w/2,y+h/2+3,h,w), element, 1) ; + //painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow); + //drawArrow(painter, TQRect(x,y,h,w), element, 1) ; + break ; /* End of previous code */ + } + + case PE_SpinWidgetDown: { + + // painter->drawPixmap(x+w/2-3, y+h/2-3, darrow); break ; + + //--- Determine arrow size & position + //int arrowSize = ARROW_Size4x3 ; + //int arrowScaling = 1 ; + int arrowSize = ARROW_Size2 ; + int arrowScaling = 1 ; + int vdelta = ( h - arrowSize ) ; + int hdelta = ( w - arrowSize ) ; + int voffset = y ; ; // vertical alignment: bottom + int hoffset = x + hdelta / 2 ; // horizontal alignment: centered + TQRect frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + + //--- Determine arrow direction + TQStyle::PrimitiveElement arrow = PE_ArrowDown ; + + //--- Determine arrow color + if (flags & Style_Enabled) { + painter->setPen((flags & Style_Sunken) + ? group.midlight() : group.dark()); + painter->setPen(darkBlue) ; + } + else { + painter->setPen(group.mid()); + } + + //--- Draw arrow + drawArrow(painter, frame, arrow, arrowScaling ); + + break ; + + //-------------------------------------------------------------------- + /* Previous code: * / + //-------------------------------------------------------------------- + + if (flags & Style_Enabled) { + painter->setPen((flags & Style_Sunken) + ? group.midlight() : group.dark()); + painter->setPen(blue) ; + } + else { + painter->setPen(group.mid()); + } + drawArrow(painter, rect, element, 3) ; + //drawArrow(painter, TQRect(x+w/2,y+h/2-3,h,w), element, 1) ; + //painter->drawPixmap(x+w/2-3, y+h/2-3, darrow); + //drawArrow(painter, TQRect(x,y,h,w), element, 1) ; + break ; /* End of previous code */ + } + + case PE_ArrowUp: + case PE_ArrowDown: + case PE_ArrowLeft: + case PE_ArrowRight: { + + //--- Determine arrow size & position + int arrowSize = ARROW_Size4 ; + int arrowScaling = -1 ; + int vdelta = ( h - arrowSize ) ; + int hdelta = ( w - arrowSize ) ; + int voffset = y + vdelta / 2 ; // vertical alignment: centered + int hoffset = x + hdelta / 2 ; // horizontal alignment: centered + TQRect frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + + //--- Determine arrow color + if (flags & Style_Enabled) { + painter->setPen((flags & Style_Sunken) + ? group.midlight() : group.dark()); + } + else { + painter->setPen(group.mid()); + } + + //--- Draw arrow + if ( FONT_Scale <= 1.00 ) + //--- Invoke legacy code that relies on hardcoded bitmaps + drawArrowBitmap( painter, frame, element ) ; + else + //--- Invoke new code that relies on dynamic drawing routines + drawArrow(painter, frame, element, arrowScaling ); + + break ; + + //-------------------------------------------------------------------- + /* Previous code: * / + //-------------------------------------------------------------------- + + if (flags & Style_Enabled) { + // painter->setPen((flags & Style_Sunken) + // ? group.midlight() : group.dark()); + painter->setPen(black) ; + } + else { + painter->setPen(group.mid()); + } + drawArrow(painter, rect, element, -1) ; + // painter->drawPixmap(x+w/2-3, y+h/2-3, uarrow); + // painter->drawPixmap(x+w/2-3, y+h/2-3, darrow); + // painter->drawPixmap(x+w/2-3, y+h/2-3, larrow); + // painter->drawPixmap(x+w/2-3, y+h/2-3, rarrow); + break ; /* End of previous code */ + } + + case PE_MenuItemIndicatorFrame: { + // Draw nothing + break; + } + case PE_MenuItemIndicatorIconFrame: { + // Draw nothing + break; + } + case PE_MenuItemIndicatorCheck: { + int checkwidth = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, option, NULL, NULL); + int cx = reverse_ ? x+w - checkwidth : x; + drawPrimitive(PE_CheckMark, painter, ceData, elementFlags, + TQRect(cx + ITEMFRAME, y + ITEMFRAME, + checkwidth - ITEMFRAME*2, h - ITEMFRAME*2), + group, Style_Default | + (active ? Style_Enabled : Style_On)); + break; + } + + default: + TDEStyle::drawPrimitive(element, painter, ceData, elementFlags, rect, group, flags, option); + } +} + +////////////////////////////////////////////////////////////////////////////// +// drawTDEStylePrimitive() +// --------------------- +// Draw the element + +void Phase2Style::drawTDEStylePrimitive(TDEStylePrimitive element, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQColorGroup &group, + SFlags flags, + const TQStyleOption &option, + const TQWidget *widget) const +{ + bool horiz = flags & Style_Horizontal; + int x, y, w, h, x2, y2, n, cx, cy; + + rect.rect(&x, &y, &w, &h); + x2 = rect.right(); + y2 = rect.bottom(); + cx = x + w/2; + cy = y + h/2; + + switch (element) { + case KPE_ToolBarHandle: + cx-=2; cy-=2; + drawPhaseGradient(painter, rect, group.background(), + !horiz, 0, 0, w-1, h-1, true); + if (horiz) { + for (n = -5; n <= 5; n += 5) { + kColorBitmaps(painter, group, cx, cy+n, + 0, &doodad_mid, &doodad_light, 0, 0, 0); + } + painter->setPen(group.mid()); + painter->drawLine(x, y2, x2, y2); + } else { + for (n = -5; n <= 5; n += 5) { + kColorBitmaps(painter, group, cx+n, cy, + 0, &doodad_mid, &doodad_light, 0, 0, 0); + } + painter->setPen(group.mid()); + painter->drawLine(x2, y, x2, y2); + } + break; + + //case KPE_DockWindowHandle: + case KPE_GeneralHandle: + cx-=2; cy-=2; + painter->fillRect(rect, group.brush(TQColorGroup::Background)); + + if (horiz) { + for (n = -5; n <= 5; n += 5) { + kColorBitmaps(painter, group, cx, cy+n, + 0, &doodad_mid, &doodad_light, 0, 0, 0); + } + } else { + for (n = -5; n <= 5; n += 5) { + kColorBitmaps(painter, group, cx+n, cy, + 0, &doodad_mid, &doodad_light, 0, 0, 0); + } + } + break; + + case KPE_ListViewExpander: + { + //-------------------------------------------------------------------- + /* METHOD 0: Let TDE draw the default style / + //-------------------------------------------------------------------- + + TDEStyle::drawTDEStylePrimitive(element, painter, ceData, elementFlags, rect, + group, flags, option, widget); + break ; /* End of METHOD 0 */ + + //--- Determine arrow size & position + int arrowSize = ARROW_Size2 ; + int arrowScaling = 1 ; + int vdelta = ( h - arrowSize ) ; + int hdelta = ( w - arrowSize ) ; + int voffset = y + vdelta / 2 ; // vertical alignment: centered + int hoffset = x + hdelta / 2 ; // horizontal alignment: centered + TQRect frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + + /**************************** FIXME ********************************** + * First tree view suffers from a visible and relatively prolonged + * "rippling" effect that NONE of the methods below seem to address. + * This actually seems to be a problem with most widget styles! + * + * We are still encountering challenges drawing appropriately scaled + * +|- (i.e. scaled relative to FONT_Size). For some reason, the + * rectangle we are passed is *ALWAYS* 9x9 px and we have not been + * able find the reason why. Debugging statements we have used: + + fprintf(stderr, + "Rectangle pos (size): H - %3d + %3d x V - %3d + %3d\n", + x, h, y, w + ); + fprintf(stderr, + "Arrow position (siz): H - %3d + %3d x V - %3d + %3d\n", + hoffset, arrowSize, voffset, arrowSize + ); + fprintf(stderr, + "Pixelmetrics:\n PE_CheckListController='%d'\n PE_CheckListIndicator='%d'\n PE_CheckListExclusiveIndicator='%d'\n\n", + (int)PE_CheckListController, (int)PE_CheckListIndicator, (int)PE_CheckListExclusiveIndicator + ) ; + fprintf(stderr, "Checkbox size = %d \n\n", FONT_Size & 0xfffe); + + *********************************************************************/ + + //-------------------------------------------------------------------- + /* METHOD 1: Directly draw the arrows */ + //-------------------------------------------------------------------- + + //--- Determine arrow direction + TQStyle::PrimitiveElement arrow = PE_ArrowLeft ; + if (flags & Style_On) arrow = PE_ArrowRight ; + + //--- Determine arrow color + painter->setPen(group.mid()); + + //--- Draw arrow vector + drawArrow(painter, frame, arrow, arrowScaling ); + + break ; /* End of METHOD 1 */ + + //-------------------------------------------------------------------- + /* METHOD 2a: Generate reusable arrow pixmaps, then "draw" them * / + //-------------------------------------------------------------------- + + //--- Generate reusable arrow pixmaps + if (! KPE_ListViewExpander_ArrowLeft ) { + KPE_ListViewExpander_ArrowLeft = + Create_Arrow_Pix(PE_ArrowLeft, arrowSize, arrowScaling) ; + } + if (!KPE_ListViewExpander_ArrowRight ) { + KPE_ListViewExpander_ArrowRight = + Create_Arrow_Pix(PE_ArrowRight, arrowSize, arrowScaling) ; + } + + //--- Determine arrow direction + TQPixmap * arrow_pix = KPE_ListViewExpander_ArrowLeft ; + if (flags & Style_On) arrow_pix = KPE_ListViewExpander_ArrowRight ; + + //--- Determine arrow color + painter->setPen(group.mid()); + + //--- Draw arrow pixmap + painter->drawPixmap(frame, *arrow_pix ); + + break ; + /* End of METHOD 2a */ + + //-------------------------------------------------------------------- + /* METHOD 2b: Generate reusable arrow pixmaps, then "bitBlt" them * / + // (inspired by Asteroid CC_Slider code) + //-------------------------------------------------------------------- + + //--- Generate reusable arrow pixmaps + if (! KPE_ListViewExpander_ArrowLeft ) { + KPE_ListViewExpander_ArrowLeft = + Create_Arrow_Pix(PE_ArrowLeft, arrowSize, arrowScaling) ; + } + if (!KPE_ListViewExpander_ArrowRight ) { + KPE_ListViewExpander_ArrowRight = + Create_Arrow_Pix(PE_ArrowRight, arrowSize, arrowScaling) ; + } + + //--- Determine arrow direction + TQPixmap * arrow_pix = KPE_ListViewExpander_ArrowLeft ; + if (flags & Style_On) arrow_pix = KPE_ListViewExpander_ArrowRight ; + + //--- Determine arrow color + painter->setPen(group.mid()); + + //--- BitBlt arrow pixmap (allegedly faster) + bitBlt( + painter->device(), hoffset, voffset, + arrow_pix, 0, 0, arrowSize, arrowSize, + Qt::CopyROP, true + ) ; + // FIXME: draws only black arrows - maybe color needs to aready be in pixmap? + + break ; /* End of METHOD 2b */ + + //-------------------------------------------------------------------- + /* METHOD 3: Generate reusable arrow images, then "draw" them * / + //-------------------------------------------------------------------- + + //--- Generate reusable arrow images + if (! iKPE_ListViewExpander_ArrowLeft ) + iKPE_ListViewExpander_ArrowLeft = + Create_Arrow_Image(PE_ArrowLeft, arrowSize, arrowScaling) ; + if (! iKPE_ListViewExpander_ArrowRight ) + iKPE_ListViewExpander_ArrowRight = + Create_Arrow_Image(PE_ArrowRight, arrowSize, arrowScaling) ; + + //--- Determine arrow direction + TQImage * arrow_img = iKPE_ListViewExpander_ArrowLeft ; + if (flags & Style_On) arrow_img = iKPE_ListViewExpander_ArrowRight ; + + //--- Determine arrow color + painter->setPen(group.mid()); + + //--- Draw arrow image + painter->drawImage(frame, *arrow_img ); + + break /* End of METHOD 3 */ ; + + + //-------------------------------------------------------------------- + /* METHOD 4a: Draw +|- instead of arrows (cribbed from Plastik) * / + //-------------------------------------------------------------------- + + arrowSize = ARROW_Size2 ; + arrowScaling = 0 ; + vdelta = ( h - arrowSize ) ; + hdelta = ( w - arrowSize ) ; + voffset = y + vdelta / 2 ; // vertical alignment: centered + hoffset = x + hdelta / 2 ; // horizontal alignment: centered + frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + + // Typical Windows style expand/collapse element. + int radius = (frame.width() - 4) / 2; + int centerx = rect.x() + rect.width()/2; + int centery = rect.y() + rect.height()/2; + + // Outer box + painter->setPen( group.mid() ); + painter->drawRect( frame ); + + // plus or minus + painter->setPen( group.text() ); + painter->drawLine( centerx - radius, centery, centerx + radius, centery ); + if ( flags & Style_On ) // Collapsed = On + painter->drawLine( centerx, centery - radius, centerx, centery + radius ); + + break ; /* End of METHOD 4a */ + + //-------------------------------------------------------------------- + /* METHOD 4b: Draw +|- instead of arrows (cribbed from Plastik) * / + //-------------------------------------------------------------------- + + TQPen mypen ; mypen.setWidth(1) ; mypen.setColor(black) ; + painter->setPen(mypen) ; + + //frame = TQRect(hoffset-1, voffset-1, arrowSize, arrowSize) ; + + int radius = frame.width() / 2 ; + int centerx = rect.x() + rect.width()/2; + int centery = rect.y() + rect.height()/2 ; + painter->drawRect( frame ); + painter->drawLine( centerx - radius , centery, centerx + radius, centery ); + if (flags & Style_On) + painter->drawLine( centerx, centery - radius, centerx, centery + radius ) ; + break ; /* End of METHOD 4b */ + + //-------------------------------------------------------------------- + /* Previous code: * / + //-------------------------------------------------------------------- + if (flags & Style_On) { + // drawArrow(painter, rect, PE_ArrowRight, -(QT3SCALE-0)) ; + drawArrow(painter, TQRect(x+offset, y+offset, arrowSize, arrowSize), PE_ArrowRight, 1 ); + // painter->drawPixmap(x+w/2-4, y+h/2-4, rexpand); + } else { + drawArrow(painter, rect, PE_ArrowLeft, -(QT3SCALE-0)) ; + // painter->drawPixmap(x+w/2-4, y+h/2-4, dexpand); + } + break ; /* End of previous code */ + } + + case KPE_ListViewBranch: + painter->setPen(group.mid()); + if (flags & Style_Horizontal) { + painter->drawLine(x, cy, x2, cy); + } else { + painter->drawLine(cx, y, cx, y2); + } + break; + + case KPE_SliderGroove: { + if (ceData.orientation == TQt::Horizontal) { + y = cy - 3; + h = 7; + } else { + x = cx - 3; + w = 7; + } + drawPhasePanel(painter, x, y, w, h, group, true, + &group.brush(TQColorGroup::Mid)); + break; + } + + case KPE_SliderHandle: { + TQColor color = (flags & Style_MouseOver) + ? TQColor(group.button().light(contrast)) + : group.button(); + if (ceData.orientation == TQt::Horizontal) { + drawPhaseBevel(painter, cx-5, y, 6, h, group, color, + false, false, false); + drawPhaseBevel(painter, cx, y, 6, h, group, color, + false, false, false); + } else { + drawPhaseBevel(painter, x, cy-5, w, 6, group, color, + false, true, false); + drawPhaseBevel(painter, x, cy, w, 6, group, color, + false, true, false); + } + break; + } + + default: + TDEStyle::drawTDEStylePrimitive(element, painter, ceData, elementFlags, rect, + group, flags, option, widget); + } +} + +////////////////////////////////////////////////////////////////////////////// +// drawControl() +// ------------- +// Draw the control + +void Phase2Style::drawControl(TQ_ControlElement element, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQColorGroup &group, + SFlags flags, + const TQStyleOption &option, + const TQWidget *widget) const +{ + bool active, enabled, depress; + int x, y, w, h, x2, y2, dx; + TQMenuItem *mi; + TQIconSet::Mode mode; + TQIconSet::State state; + TQPixmap pixmap; + + rect.rect(&x, &y, &w, &h); + x2 = rect.right(); + y2 = rect.bottom(); + + switch (element) { + case CE_PushButton: { + depress = flags & (Style_Down | Style_On); + int bd = pixelMetric(PM_ButtonDefaultIndicator, ceData, elementFlags, widget) + 1; + + if ((flags & Style_ButtonDefault) && !depress) { + drawPhasePanel(painter, x, y, w, h, group, true, + &group.brush(TQColorGroup::Mid)); + drawPhaseBevel(painter, x+bd, y+bd, w-bd*2, h-bd*2, group, + (flags & Style_MouseOver) + ? TQColor(group.button().light(contrast)) + : group.button(), + false, false, false); + } else { + drawPhaseButton(painter, x, y, w, h, group, + (flags & Style_MouseOver) + ? TQColor(group.button().light(contrast)) + : group.button(), depress); + } + + if (flags & Style_HasFocus) { // draw focus + drawPrimitive(PE_FocusRect, painter, ceData, elementFlags, + subRect(SR_PushButtonFocusRect, ceData, elementFlags, widget), + group, flags); + } + break; + } + + case CE_PushButtonLabel: { + const TQPushButton* button = ::tqqt_cast(widget); + if (!button) { + TDEStyle::drawControl(element, painter, ceData, elementFlags, rect, group, + flags, option, widget); + return; + } + active = button->isOn() || button->isDown(); + + if (active) { // shift contents + x++; y++; + flags |= Style_Sunken; + } + + if (button->isMenuButton()) { // menu indicator + int dx = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags, widget); + //drawPrimitive(PE_ArrowDown, painter, ceData, elementFlags, + // TQRect(x+w-dx-2, y+2, dx, h-4), + // group, flags, option); + if (flags & Style_Enabled) { + painter->setPen(green) ; + } + else { + painter->setPen(yellow) ; + } + drawArrow(painter, TQRect(x+w-dx-2, y+2, dx, h-4), PE_ArrowDown, 3) ; + w -= dx; + } + /**************************** FIXME ********************************** + *********************************************************************/ + + if (button->iconSet() && !button->iconSet()->isNull()) { // draw icon + if (button->isEnabled()) { + if (button->hasFocus()) { + mode = TQIconSet::Active; + } else { + mode = TQIconSet::Normal; + } + } else { + mode = TQIconSet::Disabled; + } + + if (button->isToggleButton() && button->isOn()) { + state = TQIconSet::On; + } else { + state = TQIconSet::Off; + } + + pixmap = button->iconSet()->pixmap(TQIconSet::Small, mode, state); + if (button->text().isEmpty() && !button->pixmap()) { + painter->drawPixmap(x+w/2 - pixmap.width()/2, + y+h/2 - pixmap.height()/2, pixmap); + } else { + painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap); + } + x += pixmap.width() + 4; + w -= pixmap.width() + 4; + } + + if (active || button->isDefault()) { // default button + for(int n=0; n<2; n++) { + drawItem(painter, TQRect(x+n, y, w, h), + AlignCenter | ShowPrefix, + button->colorGroup(), + button->isEnabled(), + button->pixmap(), + button->text(), -1, + (button->isEnabled()) ? + &button->colorGroup().buttonText() : + &button->colorGroup().mid()); + } + } else { // normal button + drawItem(painter, TQRect(x, y, w, h), + AlignCenter | ShowPrefix, + button->colorGroup(), + button->isEnabled(), + button->pixmap(), + button->text(), -1, + (button->isEnabled()) ? + &button->colorGroup().buttonText() : + &button->colorGroup().mid()); + } + break; + } + + case CE_CheckBoxLabel: + case CE_RadioButtonLabel: { + const TQButton *b = ::tqqt_cast(widget); + if (!b) return; + + int alignment = reverse_ ? AlignRight : AlignLeft; + drawItem(painter, rect, alignment | AlignVCenter | ShowPrefix, + group, flags & Style_Enabled, b->pixmap(), b->text()); + + // only draw focus if content (forms on html won't) + if ((flags & Style_HasFocus) && ((!b->text().isNull()) || b->pixmap())) { + drawPrimitive(PE_FocusRect, painter, ceData, elementFlags, + visualRect(subRect(SR_RadioButtonFocusRect, ceData, elementFlags, + widget), ceData, elementFlags), + group, flags); + } + break; + } + + case CE_DockWindowEmptyArea: { + const TQToolBar *tb = ::tqqt_cast(widget); + if (tb) { + // toolbar not floating or in a TQMainWindow + if (flatToolbar(ceData, elementFlags, tb)) { + if (tb->backgroundMode() == PaletteButton) + // force default button color to background color + painter->fillRect(rect, group.background()); + else + painter->fillRect(rect, tb->paletteBackgroundColor()); + } + } + break; + } + + case CE_MenuBarEmptyArea: + drawPhaseGradient(painter, TQRect(x, y, w, h), group.background(), + (w(widget); + if (!mbar) { + TDEStyle::drawControl(element, painter, ceData, elementFlags, rect, group, + flags, option, widget); + return; + } + mi = option.menuItem(); + TQRect prect = mbar->rect(); + + if ((flags & Style_Active) && (flags & Style_HasFocus)) { + if (flags & Style_Down) { + drawPhasePanel(painter, x, y, w, h, group, true, + &group.brush(TQColorGroup::Background)); + } else { + drawPhaseBevel(painter, x, y, w, h, + group, group.background(), + false, false, false); + } + } else { + drawPhaseGradient(painter, rect, group.background(), false, x, y, + prect.width()-2, prect.height()-2, false); + } + drawItem(painter, rect, + AlignCenter | AlignVCenter | + DontClip | ShowPrefix | SingleLine, + group, flags & Style_Enabled, + mi->pixmap(), mi->text()); + break; + } + + case CE_PopupMenuItem: { + if (!ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING)) { + TDEStyle::drawControl(element, painter, ceData, elementFlags, rect, group, + flags, option, widget); + return; + } + + // We'll need these values for both arrows and text, so define them here + int arrowSize = ARROW_Size2 ; + int arrowRmargin = arrowSize / 2 ; + + mi = option.menuItem(); + if (!mi) { + painter->fillRect(rect, group.button()); + break; + } + + int tabwidth = option.tabWidth(); + int checkwidth = option.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + bool etchtext = styleHint(SH_EtchDisabledText, ceData, elementFlags); + active = flags & Style_Active; + enabled = mi->isEnabled(); + TQRect vrect; + + if (checkable) checkwidth = TQMAX(checkwidth, 20); + + // draw background + if (active && enabled) { + painter->fillRect(x, y, w, h, group.highlight()); + } else if (!ceData.bgPixmap.isNull()) { + painter->drawPixmap(x, y, ceData.bgPixmap, x, y, w, h); + } else { + painter->fillRect(x, y, w, h, group.background()); + } + + // draw separator + if (mi->isSeparator()) { + painter->setPen(group.dark()); + painter->drawLine(x+checkwidth+1, y+1, x2-checkwidth-1, y+1); + painter->setPen(group.mid()); + painter->drawLine(x+checkwidth, y, x2-checkwidth-1, y); + painter->drawPoint(x+checkwidth, y+1); + painter->setPen(group.midlight()); + painter->drawLine(x+checkwidth+1, y2, x2-checkwidth, y2); + painter->drawPoint(x2-checkwidth, y2-1); + break; + } + + // draw icon + if (mi->iconSet() && !mi->isChecked()) { + if (active) + mode = enabled ? TQIconSet::Active : TQIconSet::Disabled; + else + mode = enabled ? TQIconSet::Normal : TQIconSet::Disabled; + + pixmap = mi->iconSet()->pixmap(TQIconSet::Small, mode); + TQRect pmrect(0, 0, pixmap.width(), pixmap.height()); + vrect = visualRect(TQRect(x, y, checkwidth, h), rect); + pmrect.moveCenter(vrect.center()); + painter->drawPixmap(pmrect.topLeft(), pixmap); + } + + // draw check + if (mi->isChecked()) { + drawPrimitive(PE_MenuItemIndicatorCheck, painter, ceData, elementFlags, TQRect(x, y, checkwidth, h), group, flags, option); + } + + // draw text + int xm = ITEMFRAME + checkwidth + ITEMHMARGIN; + int xp = reverse_ ? + x + tabwidth + RIGHTBORDER + ITEMHMARGIN + ITEMFRAME - 1 : + x + xm; + int offset = reverse_ ? -1 : 1; + int tw = w - xm - tabwidth - (arrowSize + arrowRmargin) + - ITEMHMARGIN * 3 - ITEMFRAME + 1 ; + + painter->setPen(enabled ? (active ? group.highlightedText() : + group.buttonText()) : group.mid()); + + if (mi->custom()) { // draws own label + painter->save(); + if (etchtext && !enabled && !active) { + painter->setPen(group.light()); + mi->custom()->paint(painter, group, active, enabled, + xp+offset, y+ITEMVMARGIN+1, + tw, h-2*ITEMVMARGIN); + painter->setPen(group.mid()); + } + mi->custom()->paint(painter, group, active, enabled, + xp, y+ITEMVMARGIN, tw, h-2*ITEMVMARGIN); + painter->restore(); + } + else { // draw label + TQString text = mi->text(); + + if (!text.isNull()) { + int t = text.find('\t'); + int tflags = AlignVCenter | DontClip | + ShowPrefix | SingleLine | + (reverse_ ? AlignRight : AlignLeft); + + if (t >= 0) { + int tabx = reverse_ ? + x + RIGHTBORDER + ITEMHMARGIN + ITEMFRAME : + x + w - tabwidth - RIGHTBORDER - ITEMHMARGIN + - ITEMFRAME; + + // draw right label (accerator) + if (etchtext && !enabled) { // etched + painter->setPen(group.light()); + painter->drawText(tabx+offset, y+ITEMVMARGIN+1, + tabwidth, h-2*ITEMVMARGIN, + tflags, text.mid(t+1)); + painter->setPen(group.mid()); + } + painter->drawText(tabx, y+ITEMVMARGIN, + tabwidth, h-2*ITEMVMARGIN, + tflags, text.mid(t+1)); + text = text.left(t); + } + + // draw left label + if (etchtext && !enabled) { // etched + painter->setPen(group.light()); + painter->drawText(xp+offset, y+ITEMVMARGIN+1, + tw, h-2*ITEMVMARGIN, + tflags, text, t); + painter->setPen(group.mid()); + } + painter->drawText(xp, y+ITEMVMARGIN, + tw, h-2*ITEMVMARGIN, + tflags, text, t); + } + else if (mi->pixmap()) { // pixmap as label + pixmap = *mi->pixmap(); + if (pixmap.depth() == 1) + painter->setBackgroundMode(Qt::OpaqueMode); + + dx = ((w - pixmap.width()) / 2) + ((w - pixmap.width()) % 2); + painter->drawPixmap(x+dx, y+ITEMFRAME, pixmap); + + if (pixmap.depth() == 1) + painter->setBackgroundMode(Qt::TransparentMode); + } + } + + if (mi->popup()) { // draw submenu arrow + TQ_PrimitiveElement arrow = reverse_ ? PE_ArrowLeft : PE_ArrowRight; + // arrowSize & arrowRmargin were defined earlier + int arrowScaling = 1 ; + int vdelta = ( h - arrowSize ) ; + int hdelta = ( w - arrowSize - arrowRmargin ) ; + int voffset = y + vdelta / 2 ; // vertical alignment: centered + int hoffset = x + hdelta ; // horizontal alignment: right + TQRect frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + + /* CUT - Debugging statements + fprintf(stderr, + "Rectangle pos (size): V - %3d + %3d x H - %3d + %3d\n", + x, h, y, w + ); + fprintf(stderr, + "Arrow position (siz): V - %3d + %3d x H- %3d + %3d\n", + voffset, arrowSize, hoffset, arrowSize + ); + //fprintf(stderr, " or at %d (h) x %d (v)\n", vrect.left(), vrect.top()); + CUT */ + + if (flags & Style_Enabled) { + painter->setPen(black) ; + } + else { + painter->setPen(group.mid()); + } + drawArrow(painter, frame, arrow, arrowScaling ); + + //-------------------------------------------------------------------- + /* Previous code: * / + //-------------------------------------------------------------------- + int dim = (h-2*ITEMFRAME) / 2; + vrect = visualRect(TQRect(x + w - ARROWMARGIN - ITEMFRAME - dim, + y + h / 2 - dim / 2, dim, dim), rect); + // drawPrimitive(arrow, painter, ceData, elementFlags, vrect, group, + // enabled ? Style_Enabled : Style_Default); + + if (flags & Style_Enabled) { + painter->setPen(red) ; + } + else { + painter->setPen(group.mid()); + } + drawArrow(painter, vrect, arrow, -3+(QT3SCALE*3)) ; + // drawArrow(painter, vrect, arrow, 3) ; + /* End of previous code */ + } + break; + } + + case CE_TabBarTab: { + if (ceData.widgetObjectTypes.contains(TQTABBAR_OBJECT_NAME_STRING)) { + // this guy can get complicated, we we do it elsewhere + drawPhaseTab(painter, x, y, w, h, group, ceData, elementFlags, option, + flags); + } else { // not a tabbar + TDEStyle::drawControl(element, painter, ceData, elementFlags, rect, group, + flags, option, widget); + return; + } + break; + } + + case CE_ProgressBarGroove: { + drawPhasePanel(painter, x, y, w, h, group, true, + &group.brush(TQColorGroup::Base)); + break; + } + + case CE_ProgressBarContents: { + if (!ceData.widgetObjectTypes.contains(TQPROGRESSBAR_OBJECT_NAME_STRING)) { + TDEStyle::drawControl(element, painter, ceData, elementFlags, rect, group, + flags, option, widget); + return; + } + subRect(SR_ProgressBarContents, ceData, elementFlags, widget).rect(&x, &y, &w, &h); + + painter->setBrush(group.brush(TQColorGroup::Highlight)); + painter->setPen(group.dark()); + + if (!ceData.totalSteps) { + // busy indicator + int bar = pixelMetric(PM_ProgressBarChunkWidth, ceData, elementFlags, widget) + 2; + int progress = ceData.currentStep % ((w-bar) * 2); + if (progress > (w-bar)) progress = 2 * (w-bar) - progress; + painter->drawRect(x+progress+1, y+1, bar-2, h-2); + } else { + double progress = static_cast(ceData.currentStep) / + static_cast(ceData.totalSteps); + dx = static_cast(w * progress); + if (dx < 4) break; + if (reverse_) x += w - dx; + painter->drawRect(x+1, y+1, dx-2, h-2); + } + break; + } + + case CE_ToolBoxTab: { + const TQToolBox *box = ::tqqt_cast(widget); + if (!box) { + TDEStyle::drawControl(element, painter, ceData, elementFlags, rect, group, + flags, option, widget); + return; + } + + const int rx = x2 - 20; + const int cx = rx - h + 1; + + TQPointArray parray(6); + parray.putPoints(0, 6, + x-1,y, cx,y, rx-2,y2-2, x2+1,y2-2, + x2+1,y2+2, x-1,y2+2); + + if (box->currentItem() && (flags & Style_Selected)) { + painter->setPen(group.dark()); + painter->setBrush(box->currentItem()->paletteBackgroundColor()); + painter->drawConvexPolygon(parray, 0, 6); + painter->setBrush(NoBrush); + } else { + painter->setClipRegion(parray, TQPainter::CoordPainter); + drawPhaseGradient(painter, rect, + group.background(), + false, 0, 0, 0, h*2, false); + painter->setClipping(false); + painter->drawPolyline(parray, 0, 4); + } + + parray.putPoints(0, 4, x,y+1, cx,y+1, rx-2,y2-1, x2,y2-1); + painter->setPen(group.midlight()); + painter->drawPolyline(parray, 0, 4); + + break; + } + + default: + TDEStyle::drawControl(element, painter, ceData, elementFlags, rect, group, + flags, option, widget); + } +} + +////////////////////////////////////////////////////////////////////////////// +// drawControlMask() +// ----------------- +// Draw a bitmask for the element + +void Phase2Style::drawControlMask(TQ_ControlElement element, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQStyleOption &option, + const TQWidget *widget) const +{ + switch (element) { + case CE_PushButton: + painter->fillRect(rect, TQt::color1); + painter->setPen(TQt::color0); + break; + + default: + TDEStyle::drawControlMask(element, painter, ceData, elementFlags, rect, option, widget); + } +} + +////////////////////////////////////////////////////////////////////////////// +// drawComplexControl() +// -------------------- +// Draw a complex control + +void Phase2Style::drawComplexControl(TQ_ComplexControl control, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQColorGroup &group, + SFlags flags, + SCFlags controls, + SCFlags active, + const TQStyleOption &option, + const TQWidget *widget) const +{ + bool down = flags & Style_Down; + bool on = flags & Style_On; + bool raised = flags & Style_Raised; + bool sunken = flags & Style_Sunken; + TQRect subrect; + int x, y, w, h, x2, y2; + rect.rect(&x, &y, &w, &h); + + switch (control) { + case CC_ComboBox: { + sunken = (active == SC_ComboBoxArrow); + drawPhaseButton(painter, x, y, w, h, group, + (flags & Style_MouseOver) + ? TQColor(group.button().light(contrast)) + : group.button(), sunken); + + if (controls & SC_ComboBoxArrow) { // draw arrow box + + TQ_PrimitiveElement arrow = PE_ArrowDown; + int arrowSize = ARROW_Size2 ; + int arrowRmargin = arrowSize / 2 ; + int arrowScaling = 0 ; + int vdelta = ( h - arrowSize ) ; + int hdelta = ( w - arrowSize - arrowRmargin ) ; + int voffset = y + vdelta / 2 ; // vertical alignment: centered + int hoffset = x + hdelta ; // horizontal alignment: right + TQRect frame = TQRect(hoffset, voffset, arrowSize, arrowSize) ; + painter->setPen(darkBlue); + drawArrow(painter, frame, arrow, arrowScaling ); + + //-------------------------------------------------------------------- + /* Previous code: * / + //-------------------------------------------------------------------- + subrect = visualRect(querySubControlMetrics(CC_ComboBox, ceData, elementFlags, + SC_ComboBoxArrow, TQStyleOption::Default, widget), ceData, elementFlags); + + subrect.rect(&x, &y, &w, &h); + int slot = TQMAX(h/4, 6) + (h % 2); + + drawPhasePanel(painter, x+3, y+(h/2)-(slot/2), w-6, + slot, group, true, + sunken ? &group.brush(TQColorGroup::Midlight) + : &group.brush(TQColorGroup::Mid)); + /* End of previous code */ + } + + if (controls & SC_ComboBoxEditField) { // draw edit box + if (elementFlags & CEF_IsEditable) { // editable box + subrect = visualRect(querySubControlMetrics(CC_ComboBox, + ceData, elementFlags, SC_ComboBoxEditField, TQStyleOption::Default, widget), ceData, elementFlags); + x2 = subrect.right(); y2 = subrect.bottom(); + painter->setPen(group.dark()); + painter->drawLine(x2+1, y, x2+1, y2); + painter->setPen(group.midlight()); + painter->drawLine(x2+2, y, x2+2, y2-1); + painter->setPen(group.button()); + painter->drawPoint(x2+2, y2); + } else if (elementFlags & CEF_HasFocus) { // non editable box + subrect = visualRect(subRect(SR_ComboBoxFocusRect, ceData, elementFlags, + widget), ceData, elementFlags); + drawPrimitive(PE_FocusRect, painter, ceData, elementFlags, subrect, group, + Style_FocusAtBorder, + TQStyleOption(group.highlight())); + } + } + + painter->setPen(group.buttonText()); // for subsequent text + break; + } + + case CC_ScrollBar: { + // always a three button scrollbar + TQRect srect; + bool horizontal = (ceData.orientation == TQt::Horizontal); + SFlags scrollflags = (horizontal ? Style_Horizontal : Style_Default); + + if (ceData.minSteps == ceData.maxSteps) scrollflags |= Style_Default; + else scrollflags |= Style_Enabled; + + // addline + if (controls & SC_ScrollBarAddLine) { + srect = querySubControlMetrics(control, ceData, elementFlags, + SC_ScrollBarAddLine, option, widget); + if (srect.isValid()) + drawPrimitive(PE_ScrollBarAddLine, painter, ceData, elementFlags, srect, group, + scrollflags | ((active == SC_ScrollBarAddLine) + ? Style_Down : Style_Default)); + } + + // subline (two of them) + if (controls & SC_ScrollBarSubLine) { + // top/left subline + srect = querySubControlMetrics(control, ceData, elementFlags, + SC_ScrollBarSubLine, option, widget); + if (srect.isValid()) + drawPrimitive(PE_ScrollBarSubLine, painter, ceData, elementFlags, srect, group, + scrollflags | ((active == SC_ScrollBarSubLine) + ? Style_Down : Style_Default)); + // bottom/right subline + srect = querySubControlMetrics(control, ceData, elementFlags, + SC_ScrollBarAddLine, option, widget); + if (srect.isValid()) { + if (horizontal) srect.moveBy(-srect.width()+1, 0); + else srect.moveBy(0, -srect.height()+1); + drawPrimitive(PE_ScrollBarSubLine, painter, ceData, elementFlags, srect, group, + scrollflags | ((active == SC_ScrollBarSubLine) + ? Style_Down : Style_Default)); + } + } + + // addpage + if (controls & SC_ScrollBarAddPage) { + srect = querySubControlMetrics(control, ceData, elementFlags, + SC_ScrollBarAddPage, option, widget); + if (srect.isValid()) { + if (horizontal) srect.addCoords(1, 0, 1, 0); + else srect.addCoords(0, 1, 0, 1); + drawPrimitive(PE_ScrollBarAddPage, painter, ceData, elementFlags, srect, group, + scrollflags | ((active == SC_ScrollBarAddPage) + ? Style_Down : Style_Default)); + } + } + + // subpage + if (controls & SC_ScrollBarSubPage) { + srect = querySubControlMetrics(control, ceData, elementFlags, + SC_ScrollBarSubPage, option, widget); + if (srect.isValid()) { + drawPrimitive(PE_ScrollBarSubPage, painter, ceData, elementFlags, srect, group, + scrollflags | ((active == SC_ScrollBarSubPage) + ? Style_Down : Style_Default)); + } + } + + // slider + if (controls & SC_ScrollBarSlider) { + if (ceData.minSteps == ceData.maxSteps) { + // maxed out + srect = querySubControlMetrics(control, ceData, elementFlags, + SC_ScrollBarGroove, option, widget); + } else { + srect = querySubControlMetrics(control, ceData, elementFlags, + SC_ScrollBarSlider, option, widget); + } + if (srect.isValid()) { + if (horizontal) srect.addCoords(0, 0, 1, 0); + else srect.addCoords(0, 0, 0, 1); + drawPrimitive(PE_ScrollBarSlider, painter, ceData, elementFlags, srect, group, + scrollflags | ((active == SC_ScrollBarSlider) + ? Style_Down : Style_Default)); + // focus + if (elementFlags & CEF_HasFocus) { + srect.addCoords(2, 2, -2, -2); + drawPrimitive(PE_FocusRect, painter, ceData, elementFlags, srect, group, + Style_Default); + } + } + } + break; + } + + case CC_SpinWidget: { + //-Former experiment: #include "plastik-CC_SpinWidget.cpp" + const TQSpinWidget *spin = ::tqqt_cast(widget); + if (!spin) { + TDEStyle::drawComplexControl(control, painter, ceData, elementFlags, rect, group, + flags, controls, active, option, widget); + return; + } + + TQ_PrimitiveElement element; + + // draw frame + if (controls & SC_SpinWidgetFrame) { + drawPhasePanel(painter, x, y, w, h, group, true, NULL); + } + + // draw button field + if (controls & SC_SpinWidgetButtonField) { + subrect = querySubControlMetrics(CC_SpinWidget, ceData, elementFlags, + SC_SpinWidgetButtonField, + option, widget); + if (reverse_) subrect.moveLeft(spin->upRect().left()); + drawPhaseBevel(painter, subrect.x(), subrect.y(), + subrect.width(), subrect.height(), group, + (flags & Style_MouseOver) + ? TQColor(group.button().light(contrast)) + : group.button(), false, false, false); + } + + // draw up arrow + if (controls & SC_SpinWidgetUp) { + subrect = spin->upRect(); + + sunken = (active == SC_SpinWidgetUp); + if (spin->buttonSymbols() == TQSpinWidget::PlusMinus) + element = PE_SpinWidgetPlus; + else + element = PE_SpinWidgetUp; + + drawPrimitive(element, painter, ceData, elementFlags, subrect, group, flags + | ((active == SC_SpinWidgetUp) + ? Style_On | Style_Sunken : Style_Raised)); + } + + // draw down button + if (controls & SC_SpinWidgetDown) { + subrect = spin->downRect(); + + sunken = (active == SC_SpinWidgetDown); + if (spin->buttonSymbols() == TQSpinWidget::PlusMinus) + element = PE_SpinWidgetMinus; + else + element = PE_SpinWidgetDown; + + drawPrimitive(element, painter, ceData, elementFlags, subrect, group, flags + | ((active == SC_SpinWidgetDown) + ? Style_On | Style_Sunken : Style_Raised)); + } + break; + } + + case CC_ToolButton: { + const TQToolButton *btn = ::tqqt_cast(widget); + + TQToolBar *toolbar; + bool horiz = true; + bool normal = !(down || on || raised); // normal button state + + x2 = rect.right(); + y2 = rect.bottom(); + + // check for TQToolBar parent + if (ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAR_OBJECT_NAME_STRING)) { + toolbar = (btn)?::tqqt_cast(btn->parent()):NULL; + horiz = (ceData.toolBarData.orientation == TQt::Horizontal); + if (normal) { // draw background + if (toolbar && flatToolbar(ceData, elementFlags, toolbar)) { + // toolbar not floating or in a TQMainWindow + painter->fillRect(rect, group.background()); + } else { + drawPhaseGradient(painter, rect, group.background(), + !horiz, 0, 0, + ceData.parentWidgetData.rect.width()-3, + ceData.parentWidgetData.rect.height()-3, true); + painter->setPen(group.mid()); + if (horiz) { + painter->drawLine(x, y2, x2, y2); + } else { + painter->drawLine(x2, y, x2, y2); + } + } + } + } + // check for TQToolBarExtensionWidget parent + else if (btn && ceData.parentWidgetData.widgetObjectTypes.contains(TQTOOLBAREXTENSION)) { + TQWidget *extension; + if ((extension = ::tqqt_cast(btn->parent()))) { + toolbar = ::tqqt_cast(extension->parent()); + if (toolbar) { + horiz = (toolbar->orientation() == Qt::Horizontal); + if (normal) { // draw background + drawPhaseGradient(painter, rect, group.background(), + !horiz, 0, 0, toolbar->width()-3, + toolbar->height()-3, true); + } + } + } + } + // check for background pixmap + else if (normal && + !ceData.parentWidgetData.bgPixmap.isNull()) { + TQPixmap pixmap = ceData.parentWidgetData.bgPixmap; + painter->drawTiledPixmap(rect, pixmap, ceData.pos); + } + // everything else + else if (normal) { + // toolbutton not on a toolbar + painter->fillRect(rect, group.background()); + } + + // now draw active buttons + if (down || on) { + drawPhasePanel(painter, x, y, w, h, group, true, + &group.brush(TQColorGroup::Button)); + } else if (raised) { + drawPhaseBevel(painter, x, y, w, h, group, group.button(), + false, !horiz, true); + } + + painter->setPen(group.text()); + break; + } + + default: + TDEStyle::drawComplexControl(control, painter, ceData, elementFlags, rect, group, + flags, controls, active, option, widget); + break; + } +} + +////////////////////////////////////////////////////////////////////////////// +// drawComplexControlMask() +// ------------------------ +// Draw a bitmask for the control + +void Phase2Style::drawComplexControlMask(TQ_ComplexControl control, + TQPainter *painter, + const TQStyleControlElementData &ceData, + const ControlElementFlags elementFlags, + const TQRect &rect, + const TQStyleOption &option, + const TQWidget *widget) const +{ + switch (control) { + case CC_ComboBox: + case CC_ToolButton: { + painter->fillRect(rect, TQt::color1); + painter->setPen(TQt::color0); + break; + } + + default: + TDEStyle::drawComplexControlMask(control,painter,ceData,elementFlags,rect,option,widget); + } +} + +////////////////////////////////////////////////////////////////////////////// +// pixelMetric() +// ------------- +// Get the pixel metric for metric + +int Phase2Style::pixelMetric(PixelMetric metric, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQWidget *widget) const +{ + // not using widget's font, so that all metrics are uniform + int em = FONT_Size ; + //-Instead of: int em = TQMAX(TQApplication::fontMetrics().strikeOutPos() * 3, 17); + + switch (metric) { + + case PM_DefaultFrameWidth: + return 2; //*QT3SCALE; + + case PM_ButtonDefaultIndicator: // size of default indicator + return 2*FONT_Scale; + + case PM_ButtonMargin: // Space betweeen frame and label + return 3*FONT_Scale; + + case PM_TabBarTabOverlap: // Amount of tab overlap + return 1*FONT_Scale; + + case PM_TabBarTabHSpace: // extra tab spacing + return 24*FONT_Scale; + + case PM_TabBarTabVSpace: + if (ceData.widgetObjectTypes.contains(TQTABBAR_OBJECT_NAME_STRING)) { + if (ceData.tabBarData.shape == TQTabBar::RoundedAbove) { + return 10*FONT_Scale; + } else { + return 6*FONT_Scale; + } + } + return 0; + + case PM_ExclusiveIndicatorWidth: // radiobutton size + case PM_ExclusiveIndicatorHeight: + case PM_IndicatorWidth: // checkbox size + case PM_IndicatorHeight: + case PM_CheckListButtonSize: // checkbox size in qlistview items + case PM_ScrollBarExtent: // base width of a vertical scrollbar + return em & 0xfffe; + + case PM_SplitterWidth: // width of spitter + return (em / 3) & 0xfffe; + + case PM_ScrollBarSliderMin: // minimum length of slider + return em * 2; + + case PM_SliderThickness: // slider thickness + case PM_SliderControlThickness: + return em; + + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return ITEMFRAME*FONT_Scale; + default: + return TDEStyle::pixelMetric(metric, ceData, elementFlags, widget)*FONT_Scale; + } +} + +////////////////////////////////////////////////////////////////////////////// +// subRect() +// --------- +// Return subrect for the widget in logical coordinates + +TQRect Phase2Style::subRect(SubRect rect, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget *widget) const +{ + switch (rect) { + case SR_ComboBoxFocusRect: { + TQRect r = querySubControlMetrics(CC_ComboBox, ceData, elementFlags, + SC_ComboBoxEditField, TQStyleOption::Default, widget); + r.addCoords(1, 1,-1,-1); + return r; + } + + default: + return TDEStyle::subRect(rect, ceData, elementFlags, widget); + } +} + +////////////////////////////////////////////////////////////////////////////// +// querySubControlMetrics() +// ------------------------ +// Get metrics for subcontrols of complex controls + +TQRect Phase2Style::querySubControlMetrics(TQ_ComplexControl control, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + SubControl subcontrol, + const TQStyleOption &option, + const TQWidget *widget) const +{ + TQRect rect; + + const int fw = pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget); + int w = ceData.rect.width(), h = ceData.rect.height(); + int xc; + + switch (control) { + + case CC_ComboBox: { + xc = h; // position between edit and arrow + + switch (subcontrol) { + case SC_ComboBoxFrame: // total combobox area + rect = ceData.rect; + break; + + case SC_ComboBoxArrow: // the right side + rect.setRect(w-xc, fw, xc-fw, h-(fw*2)); + break; + + case SC_ComboBoxEditField: // the left side + rect.setRect(fw, fw, w*FONT_Scale-xc-fw-1, h-(fw*2)); + break; + + case SC_ComboBoxListBoxPopup: // the list popup box + rect = option.rect(); + break; + + default: + break; + } + break; + } + + case CC_ScrollBar: { + bool horizontal = (ceData.orientation == TQt::Horizontal); + rect = TDEStyle::querySubControlMetrics(control, ceData, elementFlags, + subcontrol, option, widget); + + // adjust the standard metrics so controls can "overlap" + if (subcontrol == SC_ScrollBarGroove) { + if (horizontal) rect.addCoords(-1, 0, 1, 0); + else rect.addCoords(0, -1, 0, 1); + } + break; + } + +#if 0 + /**************************** FIXME ********************************** + The SpinWidgets were formerly clickable only around the base of the + triangular arrow image, both of which exist near the center line + of the enclosing rectangle. The problem appears to be resolved + by removing the code below and falling back to the QT3 defaults. + See also the corresponding draw* (PE|CC)_SpinWidget* code above. + *********************************************************************/ + + case CC_SpinWidget: { + + /* + fw = 2; + + const bool heightDividable = ((rect.height()%2) == 0); + + TQSize bs; + if(heightDividable) + bs.setHeight(TQMAX(8, (rect.height()-2)/2)); + else + bs.setHeight(TQMAX(8, (rect.height()-2-1)/2)); + bs.setWidth(15); + const int buttonsLeft = rect.right()-bs.width(); + */ + + bool odd = ceData.rect.height() % 2; + xc = (h * 3 / 4) + odd; // position between edit and arrows + + switch (subcontrol) { + case SC_SpinWidgetButtonField: + //rect.setRect(w-xc, 1, xc-1, h-2); + rect.setRect(buttonsLeft, rect.top()+1, bs.width(), rect.height()-2); + break; + + case SC_SpinWidgetEditField: + rect.setRect(fw, fw, w-xc-fw, h-(fw*2)); + /* + rect.setRect(rect.left()+fw, rect.top()+fw, + rect.width()-(bs.width()+1+2*fw), rect.height()-2*fw); + */ + break; + + case SC_SpinWidgetFrame: + rect = ceData.rect; + break; + + case SC_SpinWidgetUp: + rect.setRect(w-xc, (h/2)-(odd ? 6 : 7), xc-1, 6); + /* + rect.setRect(buttonsLeft, rect.top()+1, bs.width(), bs.height() ); + */ + break; + + case SC_SpinWidgetDown: + rect.setRect(w-xc, (h/2)+1, xc-1, odd ? 7 : 6); + /* + if(heightDividable) + rect.setRect(buttonsLeft, rect.top()+1+bs.height(), + bs.width(), rect.height()-(bs.height()+2) ); + else + rect.setRect(buttonsLeft, rect.top()+1+bs.height()+1, + bs.width(), rect.height()-(bs.height()+2+1) ); + */ + break; + + default: + break; + + } + break; + } +#endif + + default: + rect = TDEStyle::querySubControlMetrics(control, ceData, elementFlags, subcontrol, + option, widget); + } + + return rect; +} + +////////////////////////////////////////////////////////////////////////////// +// sizeFromContents() +// ------------------ +// Returns the size of widget based on the contentsize + +TQSize Phase2Style::sizeFromContents(ContentsType contents, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQSize &contentsize, + const TQStyleOption &option, + const TQWidget* widget ) const +{ + int w = contentsize.width(); + int h = contentsize.height(); + + switch (contents) { + case CT_PushButton: { + const TQPushButton* button = ::tqqt_cast(widget); + if (!button) { + return TDEStyle::sizeFromContents(contents, ceData, elementFlags, contentsize, + option, widget); + } + int margin = pixelMetric(PM_ButtonMargin, ceData, elementFlags, widget) + + pixelMetric(PM_DefaultFrameWidth, ceData, elementFlags, widget) + 4; + + w += margin + 6; // add room for bold font + h += margin; + + // standard width and heights + if (button->isDefault() || button->autoDefault()) { + if (w < 80 && !button->pixmap()) w = 80; + } + if (h < 22) h = 22; + return TQSize(w, h); + } + + case CT_PopupMenuItem: { + if (!widget || option.isDefault()) return contentsize; + if (!ceData.widgetObjectTypes.contains(TQPOPUPMENU_OBJECT_NAME_STRING)) { + return TDEStyle::sizeFromContents(contents, ceData, elementFlags, contentsize, + option, widget); + } + TQMenuItem *item = option.menuItem(); + + if (item->custom()) { + w = item->custom()->sizeHint().width(); + h = item->custom()->sizeHint().height(); + if (!item->custom()->fullSpan()) + h += ITEMVMARGIN*2 + ITEMFRAME*2; + } else if (item->widget()) { // a menu item that is a widget + w = contentsize.width(); + h = contentsize.height(); + } else if (item->isSeparator()) { + w = h = 3; + } else { + if (item->pixmap()) { + h = TQMAX(h, item->pixmap()->height() + ITEMFRAME*2); + } else { + h = TQMAX(h, MINICONSIZE + ITEMFRAME*2); + h = TQMAX(h, TQFontMetrics(ceData.font).height() + + ITEMVMARGIN*2 + ITEMFRAME*2); + } + if (item->iconSet()) + h = TQMAX(h, item->iconSet()-> + pixmap(TQIconSet::Small, TQIconSet::Normal).height() + + ITEMFRAME*2); + } + + if (!item->text().isNull() && item->text().find('\t') >= 0) + w += 12; + else if (item->popup()) + w += 2 * + ARROW_Size1 ; + + if (option.maxIconWidth() || (elementFlags & CEF_IsCheckable)) { + w += TQMAX(option.maxIconWidth(), + TQIconSet::iconSize(TQIconSet::Small).width()) + + ITEMHMARGIN*2; + } + w += RIGHTBORDER; + return TQSize(w, h); + } + + default: + return TDEStyle::sizeFromContents(contents, ceData, elementFlags, contentsize, + option, widget); + } +} + +////////////////////////////////////////////////////////////////////////////// +// Miscellaneous // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// flatToolbar() +// ------------- +// Is the toolbar "flat" + +bool Phase2Style::flatToolbar(const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQToolBar *toolbar) const +{ + if (!toolbar) return true; // not on a toolbar + if (!toolbar->isMovingEnabled()) return true; // immobile toolbars are flat + if (!toolbar->area()) return true; // not docked + if (toolbar->place() == TQDockWindow::OutsideDock) return true; // ditto + if (!toolbar->mainWindow()) return true; // not in a main window + return false; +} + +int Phase2Style::styleHint(StyleHint sh, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQStyleOption &opt, TQStyleHintReturn *returnData, const TQWidget *w) const +{ + int ret; + + switch (sh) { + case SH_MenuIndicatorColumnWidth: + { + int checkwidth = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if (checkable) checkwidth = TQMAX(checkwidth, 20); + + ret = checkwidth; + } + break; + default: + ret = TDEStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + +////////////////////////////////////////////////////////////////////////////// +// eventFilter() +// ------------- +// Grab events we are interested in. Most of this routine is to handle the +// exceptions to the normal styling rules. + +bool Phase2Style::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *event ) +{ + if (ceData.widgetObjectTypes.contains(TQOBJECT_OBJECT_NAME_STRING)) { + TQObject* object = reinterpret_cast(source); + + if (TDEStyle::objectEventHandler(ceData, elementFlags, source, event)) return true; + if (!object->isWidgetType()) return false; + + bool horiz; + int x, y, w, h; + TQFrame *frame; + TQToolBar *toolbar; + TQWidget *widget; + + // painting events + if (event->type() == TQEvent::Paint) { + // make sure we do the most specific stuff first + + // TDE Toolbar Widget + // patch by Daniel Brownlees + if (object->parent() && !qstrcmp(object->name(), KTOOLBARWIDGET)) { + if (0 == (widget = ::tqqt_cast(object))) return false; + TQWidget *parent = ::tqqt_cast(object->parent()); + int px = ceData.rect.x(), py = ceData.rect.y(); + // find the toolbar + while (parent && parent->parent() + && !::tqqt_cast(parent)) { + px += parent->x(); + py += parent->y(); + parent = ::tqqt_cast(parent->parent()); + } + if (!parent) return false; + TQT_TQRECT_OBJECT(ceData.rect).rect(&x, &y, &w, &h); + TQRect prect = parent->rect(); + + toolbar = ::tqqt_cast(parent); + horiz = (toolbar) ? (toolbar->orientation() == Qt::Horizontal) + : (prect.height() < prect.width()); + TQPainter painter(widget); + if (flatToolbar(ceData, elementFlags, toolbar)) { + painter.fillRect(ceData.rect, + parent->colorGroup().background()); + } else { + drawPhaseGradient(&painter, ceData.rect, + parent->colorGroup().background(), + !horiz, px, py, + prect.width(), prect.height(), true); + if (horiz && (h==prect.height()-2)) { + painter.setPen(parent->colorGroup().mid()); + painter.drawLine(x, h-1, w-1, h-1); + } else if (!horiz && (w==prect.width()-2)) { + painter.setPen(parent->colorGroup().mid()); + painter.drawLine(w-1, y, w-1, h-1); + } + } + } + + // TQToolBarExtensionWidget + else if (object && object->isWidgetType() && object->parent() && + (toolbar = ::tqqt_cast(object->parent()))) { + if (0 == (widget = ::tqqt_cast(object))) return false; + horiz = (toolbar->orientation() == Qt::Horizontal); + TQPainter painter(widget); + TQT_TQRECT_OBJECT(ceData.rect).rect(&x, &y, &w, &h); + // draw the extension + drawPhaseGradient(&painter, ceData.rect, + toolbar->colorGroup().background(), + !horiz, x, y, w-1, h-1, true); + if (horiz) { + painter.setPen(toolbar->colorGroup().dark()); + painter.drawLine(w-1, 0, w-1, h-1); + painter.setPen(toolbar->colorGroup().mid()); + painter.drawLine(w-2, 0, w-2, h-2); + painter.drawLine(x, h-1, w-2, h-1); + painter.drawLine(x, y, x, h-2); + painter.setPen(toolbar->colorGroup().midlight()); + painter.drawLine(x+1, y, x+1, h-2); + } else { + painter.setPen(toolbar->colorGroup().dark()); + painter.drawLine(0, h-1, w-1, h-1); + painter.setPen(toolbar->colorGroup().mid()); + painter.drawLine(0, h-2, w-2, h-2); + painter.drawLine(w-1, y, w-1, h-2); + painter.drawLine(x, y, w-2, y); + painter.setPen(toolbar->colorGroup().midlight()); + painter.drawLine(x, y+1, w-2, y+1); + } + } + + // TQFrame lines (do this guy last) + else if (0 != (frame = ::tqqt_cast(object))) { + TQFrame::Shape shape = frame->frameShape(); + switch (shape) { + case TQFrame::HLine: + case TQFrame::VLine: { + // NOTE: assuming lines have no content + TQPainter painter(frame); + TQT_TQRECT_OBJECT(frame->rect()).rect(&x, &y, &w, &h); + painter.setPen(frame->colorGroup().dark()); + if (shape == TQFrame::HLine) { + painter.drawLine(0, h/2, w, h/2); + } else if (shape == TQFrame::VLine) { + painter.drawLine(w/2, 0, w/2, h); + } + return true; + } + default: + break; + } + } + + } + } + + return false; +} + +////////////////////////////////////////////////////////////////////////////// +// GradientSet // +////////////////////////////////////////////////////////////////////////////// + +////////////////////////////////////////////////////////////////////////////// +// GradientSet() +// ------------- +// Constructor + +GradientSet::GradientSet(const TQColor &color, int size) + : color_(color), size_(size) +{ + for (int n=0; nresize(size_, 16); + KPixmapEffect::gradient(*set[type], + color_.light(contrast), + color_.dark(contrast), + KPixmapEffect::HorizontalGradient); + break; + + case HorizontalReverse: + set[type]->resize(size_, 16); + KPixmapEffect::gradient(*set[type], + color_.dark(contrast), + color_.light(contrast), + KPixmapEffect::HorizontalGradient); + break; + + case Vertical: + set[type]->resize(16, size_); + KPixmapEffect::gradient(*set[type], + color_.light(contrast), + color_.dark(contrast), + KPixmapEffect::VerticalGradient); + break; + + case VerticalReverse: + set[type]->resize(16, size_); + KPixmapEffect::gradient(*set[type], + color_.dark(contrast), + color_.light(contrast), + KPixmapEffect::VerticalGradient); + break; + + default: + break; + } + } + return (set[type]); +} + +////////////////////////////////////////////////////////////////////////////// +// Plugin Stuff // +////////////////////////////////////////////////////////////////////////////// + +class Phase2StylePlugin : public TQStylePlugin +{ + public: + Phase2StylePlugin(); + TQStringList keys() const; + TQStyle *create(const TQString &key); +}; + +Phase2StylePlugin::Phase2StylePlugin() : TQStylePlugin() { ; } + +TQStringList Phase2StylePlugin::keys() const +{ + return TQStringList() << "Phase2"; +} + +TQStyle* Phase2StylePlugin::create(const TQString& key) +{ + if (key.lower() == "phase2") + return new Phase2Style(); + return 0; +} + +KDE_Q_EXPORT_PLUGIN(Phase2StylePlugin) + +#include "phase2style.moc" diff --git a/styles/phase2/phase2style.h b/styles/phase2/phase2style.h new file mode 100644 index 00000000..a45f7fe9 --- /dev/null +++ b/styles/phase2/phase2style.h @@ -0,0 +1,280 @@ +////////////////////////////////////////////////////////////////////////////// +// phase2style.h +// ------------------- +// TQt/TDE widget style +// ------------------- +// Copyright (c) 2004 David Johnson +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to +// deal in the Software without restriction, including without limitation the +// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +// sell copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +// IN THE SOFTWARE. +////////////////////////////////////////////////////////////////////////////// + +#ifndef PHASE2STYLE_H +#define PHASE2STYLE_H + +#include +#include +#include + +class KPixmap; + +class GradientSet +{ + public: + enum GradientType { + Horizontal, + Vertical, + HorizontalReverse, + VerticalReverse, + GradientTypeCount + }; + + GradientSet(const TQColor &color, int size); + ~GradientSet(); + + KPixmap* gradient(bool horizontal, bool reverse); + + private: + KPixmap *set[GradientTypeCount]; + TQColor color_; + int size_; +}; + +class Phase2Style : public TDEStyle +{ + Q_OBJECT + + public: + Phase2Style(); + virtual ~Phase2Style(); + + void applicationPolish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *); + void polish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *); + void polish(TQPalette &pal); + void unPolish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *); + + void drawPrimitive(TQ_PrimitiveElement element, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQColorGroup &group, + SFlags flags = Style_Default, + const TQStyleOption &option = TQStyleOption::Default) const; + + void drawTDEStylePrimitive(TDEStylePrimitive element, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQColorGroup &group, + SFlags flags = Style_Default, + const TQStyleOption &option = TQStyleOption::Default, + const TQWidget *widget = 0) const; + + void drawControl(TQ_ControlElement element, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQColorGroup &group, + SFlags flags = Style_Default, + const TQStyleOption &option = TQStyleOption::Default, + const TQWidget *widget = 0) const; + + void drawControlMask(TQ_ControlElement element, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQStyleOption &option = TQStyleOption::Default, + const TQWidget *widget = 0) const; + + void drawComplexControl(TQ_ComplexControl control, + TQPainter *painter, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &rect, + const TQColorGroup &group, + SFlags flags = Style_Default, + SCFlags controls = SC_All, + SCFlags active = SC_None, + const TQStyleOption &option = TQStyleOption::Default, + const TQWidget *widget = 0) const; + + void drawComplexControlMask(TQ_ComplexControl control, + TQPainter *painter, + const TQStyleControlElementData &ceData, + const ControlElementFlags elementFlags, + const TQRect &rect, + const TQStyleOption &option = TQStyleOption::Default, + const TQWidget *widget = 0) const; + + int pixelMetric(PixelMetric metric, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, + const TQWidget *widget = 0) const; + + TQRect subRect(SubRect rect, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget *widget = 0) const; + + TQRect querySubControlMetrics(TQ_ComplexControl control, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + SubControl subcontrol, + const TQStyleOption &option = TQStyleOption::Default, + const TQWidget *widget = 0) const; + + TQSize sizeFromContents(ContentsType contents, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQSize &contentsize, + const TQStyleOption& option = TQStyleOption::Default, + const TQWidget *widget = 0) const; + + int styleHint(TQ_StyleHint, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, + const TQStyleOption & = TQStyleOption::Default, + TQStyleHintReturn * = 0, const TQWidget * = 0 ) const; + +//#include "plastik-excerpt.h" + + private: + //Phase2Style(const Phase2Style &); + //Phase2Style& operator=(const Phase2Style &); + + void drawPhaseBevel(TQPainter *painter, + int x, int y, int w, int h, + const TQColorGroup &group, + const TQColor &fill, + bool sunken=false, + bool horizontal=true, + bool reverse=false) const; + + void drawPhaseButton(TQPainter *painter, + int x, int y, int w, int h, + const TQColorGroup &group, + const TQColor &fill, + bool sunken=false) const; + + void drawPhasePanel(TQPainter *painter, + int x, int y, int w, int h, + const TQColorGroup &group, + bool sunken=false, + const TQBrush *fill=NULL) const; + + void drawPhaseTab(TQPainter *painter, + int x, int y, int w, int h, + const TQColorGroup &group, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQStyleOption &option, + const SFlags flags) const; + + void drawPhaseGradient(TQPainter *painter, + const TQRect &rect, + TQColor color, + bool horizontal, + int px=0, int py=0, + int pw=-1, int ph=-1, + bool reverse=false) const; + + bool flatToolbar( + const TQStyleControlElementData &ceData, + const ControlElementFlags elementFlags, + const TQToolBar* toolbar + ) const; + + bool objectEventHandler( + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + void* source, + TQEvent* e + ); + + //-------------------------------------------------------------------------- + // Low-level image drawing functions + //-------------------------------------------------------------------------- + + //--- Taken from Highcontrast style: + + void drawRect( + TQPainter* painter, + TQRect rect, + int offset = 0, + bool filled = true + ) const; + + void drawRoundRect( + TQPainter* painter, + TQRect rect, + int offset = 0, + bool filled = true + ) const; + + void drawEllipse( + TQPainter* painter, + TQRect rect, + int offset = 0, + bool filled = true + ) const; + + void drawArrow( + TQPainter* painter, + TQRect rect, + TQ_PrimitiveElement arrow, + int offset = 0 + ) const; + + //--- Taken from legacy code: + + void drawArrowBitmap( + TQPainter* painter, + TQRect rect, + TQ_PrimitiveElement arrow + ) const; + + //--- New code: + + void drawCheckmark( + TQPainter* painter, + TQRect rect, + int offset = 0 + ) const; + + //-------------------------------------------------------------------------- + // Image generation functions + //-------------------------------------------------------------------------- + + TQPixmap * Create_Arrow_Pix( + TQ_PrimitiveElement shape, + int size, + int scaling + ) const ; + + TQImage * Create_Arrow_Image( + TQ_PrimitiveElement shape, + int size, + int scaling + ) const ; + + private: + TQMap > * gradients; + bool gradients_; + bool highlights_; + bool reverse_; + bool kicker_; +}; + +#endif // PHASE2STYLE_H diff --git a/styles/phase2/scaling.h b/styles/phase2/scaling.h new file mode 100644 index 00000000..bb478c0f --- /dev/null +++ b/styles/phase2/scaling.h @@ -0,0 +1,139 @@ +#ifndef __SCALING_H__ +#define __SCALING_H__ + +#include +#include + +static int QT3SCALE_MAX = 3 ; +static int QT3SCALE = 1 ; + +#define QT3SCALE_TAG_BUFFSIZE 3 +static char QT3SCALE_TAG[QT3SCALE_TAG_BUFFSIZE] = { '1', 0, 0 } ; + +//--- Information about current application font + +const static TQFont CurrentFont = TQApplication::font() ; +const static TQFontInfo CurrentFontInfo(CurrentFont) ; +const static TQFontMetrics CurrentFontMetrics(CurrentFont) ; + + +static int FONT_Size = 16 ; // Sans 12 pixel size +static double FONT_Scale = 1.00 ; // 96 DPI + +//------------------------------------------------------------------------------ +// Functions called during style initialization +//------------------------------------------------------------------------------ + +static void +Generate_Scaling_Metrics(const QWidget * w = 0) +{ + //--- FONT_Size is an important metric for scaling widget elements + + FONT_Size = CurrentFontMetrics.ascent() + CurrentFontMetrics.descent() ; + /* Alternative methods for initial computing FONT_Size + with exmplary values displayed for Sans 10/12 fonts: + CurrentFontMetrics.strikeOutPos() * 3 ; // 12/15 + CurrentFontInfo.pixelSize() ; // 13/16 + CurrentFontMetrics.overlinePos() ; // 13/16 + CurrentFontMetrics.ascent() + CurrentFontMetrics.descent() ; // 14/18 + CurrentFontMetrics.height() ; // 15/19 + */ + if (FONT_Size % 2 != 0) FONT_Size++ ; + + //--- FONT_scale is also an important metric for scaling widget elements + + double Pixels_96dpi = 4 * CurrentFontInfo.pointSize() / 3 ; + // Calculate font size relative to 96dpi + FONT_Scale = (double)(int)((double)( FONT_Size / Pixels_96dpi )*4)/4 ; + // Calculate font scaling relative to 96dpi in increments of 0.25 + +//fprintf(stderr, +// "At the current %.2f scaling, a %d-point font is %d (%d) pixels high\n", +// FONT_scale, FONT_points, FONT_size, FONT_height +//) ; +} + +//------------------------------------------------------------------------------ + +void Set_QT3SCALE() +{ + QT3SCALE = 1 ; + const char *QT3SCALE_env = getenv("QT3SCALE"); + if ( QT3SCALE_env != NULL ) { + int QT3SCALE_int = atoi(QT3SCALE_env) ; + if ( QT3SCALE_int > 1 && QT3SCALE_int <= QT3SCALE_MAX ) + QT3SCALE = QT3SCALE_int ; + } + snprintf(QT3SCALE_TAG, QT3SCALE_TAG_BUFFSIZE, "%d", QT3SCALE) ; +} + +//------------------------------------------------------------------------------ + +/* + QStyle::PE_ButtonCommand - button used to initiate an action, for example, a QPushButton. + QStyle::PE_ButtonDefault - this button is the default button, e.g. in a dialog. + QStyle::PE_ButtonBevel - generic button bevel. + QStyle::PE_ButtonTool - tool button, for example, a QToolButton. + QStyle::PE_ButtonDropDown - drop down button, for example, a tool button that displays a popup menu, for example, QPopupMenu. + + QStyle::PE_FocusRect - generic focus indicator. + + QStyle::PE_ArrowUp - up arrow. + QStyle::PE_ArrowDown - down arrow. + QStyle::PE_ArrowRight - right arrow. + QStyle::PE_ArrowLeft - left arrow. + + QStyle::PE_SpinWidgetUp - up symbol for a spin widget, for example a QSpinBox. + QStyle::PE_SpinWidgetDown - down symbol for a spin widget. + QStyle::PE_SpinWidgetPlus - increase symbol for a spin widget. + QStyle::PE_SpinWidgetMinus - decrease symbol for a spin widget. + + QStyle::PE_Indicator - on/off indicator, for example, a QCheckBox. + QStyle::PE_IndicatorMask - bitmap mask for an indicator. + QStyle::PE_ExclusiveIndicator - exclusive on/off indicator, for example, a QRadioButton. + QStyle::PE_ExclusiveIndicatorMask - bitmap mask for an exclusive indicator. + + QStyle::PE_DockWindowHandle - tear off handle for dock windows and toolbars, for example QDockWindows and QToolBars. + QStyle::PE_DockWindowSeparator - item separator for dock window and toolbar contents. + QStyle::PE_DockWindowResizeHandle - resize handle for dock windows. + QStyle::PE_Splitter - splitter handle; see also QSplitter. + + QStyle::PE_Panel - generic panel frame; see also QFrame. + QStyle::PE_PanelPopup - panel frame for popup windows/menus; see also QPopupMenu. + QStyle::PE_PanelMenuBar - panel frame for menu bars. + QStyle::PE_PanelDockWindow - panel frame for dock windows and toolbars. + QStyle::PE_PanelTabWidget - panel frame for tab widgets. + QStyle::PE_PanelLineEdit - panel frame for line edits. + QStyle::PE_PanelGroupBox - panel frame for group boxes. + QStyle::PE_TabBarBase - area below tabs in a tab widget, for example, QTab. + + QStyle::PE_HeaderSection - section of a list or table header; see also QHeader. + QStyle::PE_HeaderArrow - arrow used to indicate sorting on a list or table header + QStyle::PE_StatusBarSection - section of a status bar; see also QStatusBar. + + QStyle::PE_GroupBoxFrame - frame around a group box; see also QGroupBox. + QStyle::PE_WindowFrame - frame around a MDI window or a docking window + + QStyle::PE_Separator - generic separator. + + QStyle::PE_SizeGrip - window resize handle; see also QSizeGrip. + + QStyle::PE_CheckMark - generic check mark; see also QCheckBox. + + QStyle::PE_ScrollBarAddLine - scrollbar line increase indicator (i.e. scroll down); see also QScrollBar. + QStyle::PE_ScrollBarSubLine - scrollbar line decrease indicator (i.e. scroll up). + QStyle::PE_ScrollBarAddPage - scolllbar page increase indicator (i.e. page down). + QStyle::PE_ScrollBarSubPage - scrollbar page decrease indicator (i.e. page up). + QStyle::PE_ScrollBarSlider - scrollbar slider + QStyle::PE_ScrollBarFirst - scrollbar first line indicator (i.e. home). + QStyle::PE_ScrollBarLast - scrollbar last line indicator (i.e. end). + + QStyle::PE_ProgressBarChunk - section of a progress bar indicator; see also QProgressBar. + QStyle::PE_CheckListController - controller part of a listview item + QStyle::PE_CheckListIndicator - checkbox part of a listview item + QStyle::PE_CheckListExclusiveIndicator - radiobutton part of a listview item + QStyle::PE_RubberBand - rubber band used in such things as iconview + QStyle::PE_CustomBase - base value for custom PrimitiveElements. All values above this are reserved for custom use. Custom values must be greater than this value. + */ + +#endif diff --git a/styles/phase2/shapes.h b/styles/phase2/shapes.h new file mode 100644 index 00000000..b7715564 --- /dev/null +++ b/styles/phase2/shapes.h @@ -0,0 +1,400 @@ +#ifndef __SHAPES_H__ +#define __SHAPES_H__ + +#include +#include +#include +#include "bitmaps.h" + +/* + Symbols supported by Liberation Sans: + + 0x2713 - Unicode checkmark - regular + 0x2714 - Unicode checkmark = bold + + 0x2206 - Unicode math operator triangle "up" + 0x2207 - Unicode math operator triangle "down" + + 0x25B2 - Unicode geometric shape triangle solid "up" + 0x25BA - Unicode geometric shape triangle solid "right" + 0x25BC - Unicode geometric shape triangle solid "down" + + Symbols NOT supported by Liberation Sans: + + 0x22B2 - Unicode mathematical operator triangle "left" + 0x22B3 - Unicode mathematical operator triangle "right" + + 0x25C2 - Unicode geometric shape solid "left" triangle +*/ + +//--- Checkmark unicode characters + +#define UNICODE_CHECKMARK_REGULAR 0x2713 +#define UNICODE_CHECKMARK_BOLD 0x2714 +#define UNICODE_CHECKMARK_BALLOT_BOX 0x2611 + +static TQChar Checkmark = 0 ; + +//--- Arrow unicode characters + +#define UNICODE_TRIANGLE_OTHER 0x25BC + +//--- Arrow sizes (drawn) + +static int ARROW_Size1 = 16 ; // FONT_size / 2 +static int ARROW_Size2 = 8 ; // FONT_size / 2 +static int ARROW_Size3 = 6 ; // FONT_size / 3, made even +static int ARROW_Size4 = 4 ; // FONT_size / 4 +static int ARROW_Size4x3 = 12 ; // FONT_size * (3/4) + +//--- Arrow images (pre-drawn) + +static TQPixmap * KPE_ListViewExpander_ArrowLeft = 0 ; +static TQPixmap * KPE_ListViewExpander_ArrowRight = 0 ; +static TQImage * iKPE_ListViewExpander_ArrowLeft = 0 ; +static TQImage * iKPE_ListViewExpander_ArrowRight = 0 ; + +//------------------------------------------------------------------------------ +// Initialization +//------------------------------------------------------------------------------ + +void +Initialize_Shapes() +{ + //--- Determine checkmark + + TQChar checkmark = UNICODE_CHECKMARK_BOLD ; + if (! CurrentFontMetrics.inFont( checkmark ) ) + checkmark = 'x' ; + Checkmark = checkmark ; + + //--- Determine drawn arrow sizes, in terms of fractions of FONT_size + + ARROW_Size1 = FONT_Size ; if (ARROW_Size1 % 2 != 0) ARROW_Size1++ ; + ARROW_Size1 = FONT_Size + FONT_Size % 2 ; + ARROW_Size2 = ARROW_Size1 / 2 ; + ARROW_Size3 = ARROW_Size1 / 3 + ARROW_Size1 % 3 ; + ARROW_Size4 = ARROW_Size1 / 4 + ARROW_Size1 % 4 ; + ARROW_Size4x3 = ARROW_Size4 * 3 ; + + //--- Create bitmaps used in legacy code: + + uarrow = TQBitmap(6, 6, uarrow_bits, true); + uarrow.setMask(uarrow); + darrow = TQBitmap(6, 6, darrow_bits, true); + darrow.setMask(darrow); + larrow = TQBitmap(6, 6, larrow_bits, true); + larrow.setMask(larrow); + rarrow = TQBitmap(6, 6, rarrow_bits, true); + rarrow.setMask(rarrow); + bplus = TQBitmap(6, 6, bplus_bits, true); + bplus.setMask(bplus); + bminus = TQBitmap(6, 6, bminus_bits, true); + bminus.setMask(bminus); + bcheck = TQBitmap(9, 9, bcheck_bits, true); + bcheck.setMask(bcheck); + dexpand = TQBitmap(9, 9, dexpand_bits, true); + dexpand.setMask(dexpand); + rexpand = TQBitmap(9, 9, rexpand_bits, true); + rexpand.setMask(rexpand); + doodad_mid = TQBitmap(4, 4, doodad_mid_bits, true); + doodad_light = TQBitmap(4, 4, doodad_light_bits, true); +} + +//------------------------------------------------------------------------------ +// Low-level image drawing functions +//------------------------------------------------------------------------------ + +//--- Taken from Highcontrast style: + +void +addOffset( + TQRect* r, + int offset, + int lineWidth = 0 +) +{ + int offset1 = offset; + int offset2 = offset; + + *r = r->normalize(); + + if (lineWidth > 0) + { + offset1 += lineWidth/2; + offset2 += lineWidth - lineWidth/2 - 1; + } + + if (offset1 + offset2 > r->width()) + r->addCoords (r->width()/2, 0, - (r->width() - r->width()/2), 0); + else + r->addCoords (offset1, 0, -offset2, 0); + + if (offset1 + offset2 > r->height()) + r->addCoords (0, r->height()/2, 0, - (r->height() - r->height()/2)); + else + r->addCoords (0, offset1, 0, -offset2); +} + +//------------------------------------------------------------------------------ + +void +Phase2Style::drawRect( + TQPainter* p, + TQRect r, + int offset, + bool filled +) const +{ + addOffset (&r, offset, p->pen().width()); + if (filled) + p->fillRect (r, p->backgroundColor()); + + p->drawRect (r); +} + +void +Phase2Style::drawRoundRect( + TQPainter* p, + TQRect r, + int offset, + bool filled +) const +{ + int lineWidth = p->pen().width(); + if ((r.width() >= 5*lineWidth + 2*offset) && (r.height() >= 5*lineWidth + 2*offset)) + { + TQRect r2 (r); + addOffset (&r2, offset, lineWidth); + + addOffset (&r, offset); + TQRect r3 (r); + addOffset (&r3, lineWidth); + + p->save(); + p->setPen (Qt::NoPen); + if (filled) + p->fillRect (r3, p->backgroundColor()); + p->drawRect (r3); + p->restore(); + + p->drawLine (r.left()+lineWidth, r2.top(), r.right()+1-lineWidth, r2.top()); + p->fillRect (r.left()+1, r.top()+1, lineWidth, lineWidth, p->pen().color()); + p->drawLine (r2.left(), r.top()+lineWidth, r2.left(), r.bottom()+1-lineWidth); + p->fillRect (r.left()+1, r.bottom()-lineWidth, lineWidth, lineWidth, p->pen().color()); + p->drawLine (r.left()+lineWidth, r2.bottom(), r.right()+1-lineWidth, r2.bottom()); + p->fillRect (r.right()-lineWidth, r.bottom()-lineWidth, lineWidth, lineWidth, p->pen().color()); + p->drawLine (r2.right(), r.top()+lineWidth, r2.right(), r.bottom()+1-lineWidth); + p->fillRect (r.right()-lineWidth, r.top()+1, lineWidth, lineWidth, p->pen().color()); + } + else + drawRect (p, r, offset, filled); +} + +void +Phase2Style::drawEllipse( + TQPainter* p, + TQRect r, + int offset, + bool filled +) const +{ + addOffset (&r, offset, p->pen().width()); + + if (filled) { + p->save(); + p->setBrush (p->backgroundColor()); + p->drawRoundRect (r, 99, 99); + p->restore(); + } + + p->drawRoundRect (r, 99, 99); +} + +//------------------------------------------------------------------------------ + +void +Phase2Style::drawArrow( + TQPainter* p, + TQRect r, + TQ_PrimitiveElement arrow, + int offset +) const +{ + p->save(); + addOffset (&r, offset); + + TQPoint center = r.center(); + if (r.height() < r.width()) + r.setWidth (r.height()); + if (r.width() % 2 != 0) + r.setWidth (r.width() - 1); + r.setHeight (r.width()); + r.moveCenter (center); + + TQPointArray points (3); + switch (arrow) { + case PE_ArrowUp: + case PE_SpinWidgetUp: + case PE_SpinWidgetPlus: { + points.setPoint (0, r.bottomLeft()); + points.setPoint (1, r.bottomRight()); + points.setPoint (2, r.center().x(), r.top() + r.height()/7); + break; + } + case PE_ArrowDown: + case PE_SpinWidgetDown: + case PE_SpinWidgetMinus: { + points.setPoint (0, r.topLeft()); + points.setPoint (1, r.topRight()); + points.setPoint (2, r.center().x(), r.bottom() - r.height()/7); + break; + } + case PE_ArrowLeft: { + points.setPoint (0, r.topRight()); + points.setPoint (1, r.bottomRight()); + points.setPoint (2, r.left() + r.width()/7, r.center().y()); + break; + } + default: { + points.setPoint (0, r.topLeft()); + points.setPoint (1, r.bottomLeft()); + points.setPoint (2, r.right() - r.width()/7, r.center().y()); + } + } + + p->setPen (p->pen().color()); + p->setBrush (p->pen().color()); + p->drawPolygon (points); + p->restore(); +} + +/* + * Called from phasestyle.cpp: + * drawPrimitive() + * PE_HeaderArrow ARROW_Size2 (scaling = 0) + * PE_ScrollBar(Add,Sub)Line ARROW_Size2 (scaling = 0) + * PE_SpinWidget(Up,Down) ARROW_Size2 (scaling = 1) + * PE_Arrow(Up,Down,Left,Right) ARROW_Size4 (scaling = -1) + * drawTDEStylePrimitive() + * KPE_ListViewExpander ARROW_Size2 (scaling = 1) + * drawControl() + * CE_PopupMenuItem ARROW_Size2 (offset=0) + * CE_PushButtonLabel drawArrow called directly, offset 3 # FIXME + * + */ + +//------------------------------------------------------------------------------ + + +//--- Taken from legacy code: + +void +Phase2Style::drawArrowBitmap( + TQPainter* painter, + TQRect rect, + TQ_PrimitiveElement arrow +) const +{ + int x, y, w, h, x2, y2 ; + rect.rect(&x, &y, &w, &h) ; + + TQBitmap arrowBitmap ; + switch (arrow) { + case PE_ArrowUp: { arrowBitmap = uarrow ; break ; } + case PE_ArrowDown: { arrowBitmap = darrow ; break ; } + case PE_ArrowLeft: { arrowBitmap = larrow ; break ; } + case PE_ArrowRight: { arrowBitmap = rarrow ; break ; } + } + + painter->drawPixmap(x+w/2-3, y+h/2-3, arrowBitmap); +} + +//--- New code: + +void +Phase2Style::drawCheckmark( + TQPainter* p, + TQRect r, + int offset +) const +{ + p->save(); + p->setPen( p->pen().black ); + + if ( ! Checkmark.isNull() ) + //--- "Draw" the unicode checkmark character + p->drawText( r, TQt::AlignCenter, Checkmark ); + + else { + + //--- Draw a crude-looking checkmark + + p->setPen( p->pen().SolidLine ); + + TQPen pen = p->pen(); + pen.setWidth( 2 ); + p->setPen( pen ); + + addOffset (&r, 2); + + TQPoint center = r.center(); + if (r.height() < r.width()) + r.setWidth (r.height()); + if (r.width() % 2 != 0) + r.setWidth (r.width() - 1); + r.setHeight (r.width()); + + TQPointArray points (3); + points.setPoint (0, r.topRight()); + points.setPoint (1, r.center().x(), r.bottom() - r.height()/7); + points.setPoint (2, r.left() + r.width()/7, r.center().y()); + + p->drawPolyline (points); + } + + p->restore(); +} + +//------------------------------------------------------------------------------ +// Image generation functions +//------------------------------------------------------------------------------ + +TQPixmap * +Phase2Style::Create_Arrow_Pix( + TQ_PrimitiveElement shape, + int size, + int scaling +) const +{ + TQRect frame = TQRect(0, 0, size, size) ; + TQPainter canvas ; + TQPixmap * picture = new TQPixmap(size, size, 1) ; + canvas.begin(picture) ; + canvas.fillRect(frame, color0) ; + drawArrow( &canvas, frame, shape, scaling ) ; + canvas.end() ; + + // TQImage image = picture->convertToImage() ; + + // TQImage * image = new TQImage() ; + // *image = picture->convertToImage() ; + + return picture; +} + +TQImage * +Phase2Style::Create_Arrow_Image( + TQ_PrimitiveElement shape, + int size, + int scaling +) const +{ + TQPixmap * pixmap = Create_Arrow_Pix( shape, size, scaling) ; + if (! pixmap ) return NULL ; + TQImage * image = new TQImage() ; + *image = pixmap->convertToImage() ; + return image ; +} + +#endif -- cgit v1.2.1