diff options
author | Darrell Anderson <humanreadable@yahoo.com> | 2013-08-18 10:14:48 -0500 |
---|---|---|
committer | Darrell Anderson <humanreadable@yahoo.com> | 2013-08-18 10:14:48 -0500 |
commit | dad42352f4ad47d34caf50040367dc2a95772baa (patch) | |
tree | 6d2887d13f9b1403b8ce15be48a6ea7cec32fd96 /tdestyles/highcontrast | |
parent | 365f03061337a81bcffb4a45c4ad637edad27019 (diff) | |
download | tdelibs-dad42352f4ad47d34caf50040367dc2a95772baa.tar.gz tdelibs-dad42352f4ad47d34caf50040367dc2a95772baa.zip |
Rename KStyle to TDEStyle to avoid conflicts with KDE4.
Diffstat (limited to 'tdestyles/highcontrast')
-rw-r--r-- | tdestyles/highcontrast/CMakeLists.txt | 49 | ||||
-rw-r--r-- | tdestyles/highcontrast/Makefile.am | 41 | ||||
-rw-r--r-- | tdestyles/highcontrast/TODO | 5 | ||||
-rw-r--r-- | tdestyles/highcontrast/config/CMakeLists.txt | 37 | ||||
-rw-r--r-- | tdestyles/highcontrast/config/Makefile.am | 12 | ||||
-rw-r--r-- | tdestyles/highcontrast/config/highcontrastconfig.cpp | 94 | ||||
-rw-r--r-- | tdestyles/highcontrast/config/highcontrastconfig.h | 61 | ||||
-rw-r--r-- | tdestyles/highcontrast/highcontrast.cpp | 1867 | ||||
-rw-r--r-- | tdestyles/highcontrast/highcontrast.h | 180 | ||||
-rw-r--r-- | tdestyles/highcontrast/highcontrast.themerc | 127 |
10 files changed, 2473 insertions, 0 deletions
diff --git a/tdestyles/highcontrast/CMakeLists.txt b/tdestyles/highcontrast/CMakeLists.txt new file mode 100644 index 000000000..b68dc34e1 --- /dev/null +++ b/tdestyles/highcontrast/CMakeLists.txt @@ -0,0 +1,49 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +add_subdirectory( config ) + + +add_definitions( + -DQT_PLUGIN +) + +include_directories( + ${TQT_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdefx + ${CMAKE_SOURCE_DIR}/tdecore +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### other data ################################ + +install( FILES highcontrast.themerc DESTINATION ${DATA_INSTALL_DIR}/tdestyle/themes ) + + +##### highcontrast ############################## + +set( target highcontrast ) + +set( ${target}_SRCS + highcontrast.cpp +) + +tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK tdefx-shared + DESTINATION ${PLUGIN_INSTALL_DIR}/plugins/styles +) diff --git a/tdestyles/highcontrast/Makefile.am b/tdestyles/highcontrast/Makefile.am new file mode 100644 index 000000000..8c7d11320 --- /dev/null +++ b/tdestyles/highcontrast/Makefile.am @@ -0,0 +1,41 @@ + +# This file is part of the KDE libraries +# Copyright (C) 2005 Olaf Schmidt (ojschmidt@kde.org) + +# This library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Library General Public +# License as published by the Free Software Foundation; either +# version 2 of the License, or (at your option) any later version. + +# This library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Library General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this library; see the file COPYING. If not, write to +# the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +# Boston, MA 02110-1301, USA. + +AUTOMAKE_OPTIONS = foreign + +SUBDIRS = config + +KDE_CXXFLAGS = -DQT_PLUGIN + +INCLUDES = $(all_includes) + +stylercdir = $(kde_datadir)/tdestyle/themes +stylerc_DATA = highcontrast.themerc + +EXTRA_DIST = $(stylerc_DATA) + +noinst_HEADERS = highcontrast.h + +kde_style_LTLIBRARIES = highcontrast.la +highcontrast_la_SOURCES = highcontrast.cpp +highcontrast_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module +highcontrast_la_LIBADD = ../../tdefx/libtdefx.la $(LIB_QT) +highcontrast_la_METASOURCES = AUTO + +DISTCLEANFILES = $(highcontrast_la_METASOURCES) diff --git a/tdestyles/highcontrast/TODO b/tdestyles/highcontrast/TODO new file mode 100644 index 000000000..a7795bab8 --- /dev/null +++ b/tdestyles/highcontrast/TODO @@ -0,0 +1,5 @@ +- QLineEdit are much taller than the other widgets. Check why. +- The QLineEdits background seem to bleed on the outside. +- Use a thicker dotted line (or a solid line?) for the TreView 'branches' + +- ListViewExpanders should get their size from the item text height. (done) diff --git a/tdestyles/highcontrast/config/CMakeLists.txt b/tdestyles/highcontrast/config/CMakeLists.txt new file mode 100644 index 000000000..1305f8163 --- /dev/null +++ b/tdestyles/highcontrast/config/CMakeLists.txt @@ -0,0 +1,37 @@ +################################################# +# +# (C) 2010 Serghei Amelian +# serghei (DOT) amelian (AT) gmail.com +# +# Improvements and feedback are welcome +# +# This file is released under GPL >= 2 +# +################################################# + +include_directories( + ${TQT_INCLUDE_DIRS} + ${CMAKE_CURRENT_BINARY_DIR} + ${CMAKE_BINARY_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdecore + ${CMAKE_SOURCE_DIR}/tdeui +) + +link_directories( + ${TQT_LIBRARY_DIRS} +) + + +##### tdestyle_highcontrast_config ################ + +set( target tdestyle_highcontrast_config ) + +set( ${target}_SRCS + highcontrastconfig.cpp +) + +tde_add_kpart( ${target} AUTOMOC + SOURCES ${${target}_SRCS} + LINK tdecore-shared + DESTINATION ${PLUGIN_INSTALL_DIR} +) diff --git a/tdestyles/highcontrast/config/Makefile.am b/tdestyles/highcontrast/config/Makefile.am new file mode 100644 index 000000000..31592f288 --- /dev/null +++ b/tdestyles/highcontrast/config/Makefile.am @@ -0,0 +1,12 @@ +INCLUDES = $(all_includes) + +noinst_HEADERS = highcontrastconfig.h +kde_module_LTLIBRARIES = tdestyle_highcontrast_config.la +tdestyle_highcontrast_config_la_LDFLAGS = $(all_libraries) $(KDE_PLUGIN) -module +tdestyle_highcontrast_config_la_LIBADD = $(LIB_QT) $(LIB_TDECORE) +tdestyle_highcontrast_config_la_SOURCES = highcontrastconfig.cpp +tdestyle_highcontrast_config_la_METASOURCES = AUTO + + +messages: + $(XGETTEXT) *.cpp *.h -o $(podir)/tdestyle_highcontrast_config.pot diff --git a/tdestyles/highcontrast/config/highcontrastconfig.cpp b/tdestyles/highcontrast/config/highcontrastconfig.cpp new file mode 100644 index 000000000..8d8df0e79 --- /dev/null +++ b/tdestyles/highcontrast/config/highcontrastconfig.cpp @@ -0,0 +1,94 @@ +/* +Copyright (c) 2005 Luciano Montanaro <mikelima@cirulla.net> + +based on the Keramick configuration dialog +Copyright (c) 2003 Maksim Orlovich <maksim.orlovich@kdemail.net> + +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. + +*/ + +#include <tqcheckbox.h> +#include <tqlayout.h> +#include <tqsettings.h> +#include <kdialog.h> +#include <tdeglobal.h> +#include <tdelocale.h> + +#include "highcontrastconfig.h" + +extern "C" KDE_EXPORT TQWidget* +allocate_tdestyle_config(TQWidget* parent) +{ + return new HighContrastStyleConfig(parent); +} + +HighContrastStyleConfig::HighContrastStyleConfig( + TQWidget* parent): TQWidget(parent) +{ + // Should have no margins here, the dialog provides them + TQVBoxLayout* layout = new TQVBoxLayout(this, 0, 0); + TDEGlobal::locale()->insertCatalogue("tdestyle_highcontrast_config"); + + wideLinesBox = new TQCheckBox(i18n("Use wider lines"), this); + + layout->add(wideLinesBox); + layout->addStretch(1); + + TQSettings s; + + originalWideLinesState = s.readBoolEntry( + "/highcontraststyle/Settings/wideLines", false); + wideLinesBox->setChecked(originalWideLinesState); + + connect(wideLinesBox, TQT_SIGNAL(toggled(bool)), TQT_SLOT(updateChanged())); +} + +HighContrastStyleConfig::~HighContrastStyleConfig() +{ + TDEGlobal::locale()->removeCatalogue("tdestyle_keramik_config"); +} + + +void +HighContrastStyleConfig::save() +{ + TQSettings s; + s.writeEntry("/highcontraststyle/Settings/wideLines", + wideLinesBox->isChecked()); +} + +void +HighContrastStyleConfig::defaults() +{ + wideLinesBox->setChecked(false); + // updateChanged would be done by setChecked already +} + +void +HighContrastStyleConfig::updateChanged() +{ + if ((wideLinesBox->isChecked() == originalWideLinesState)) { + emit changed(false); + } else { + emit changed(true); + } +} + +#include "highcontrastconfig.moc" diff --git a/tdestyles/highcontrast/config/highcontrastconfig.h b/tdestyles/highcontrast/config/highcontrastconfig.h new file mode 100644 index 000000000..d52a22b47 --- /dev/null +++ b/tdestyles/highcontrast/config/highcontrastconfig.h @@ -0,0 +1,61 @@ +/* +Copyright (c) 2005 Luciano Montanaro <mikelima@cirulla.net> + +based on the Keramick configuration dialog +Copyright (c) 2003 Maksim Orlovich <maksim.orlovich@kdemail.net> + +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 HIGHCONTRAST_CONF_H +#define HIGHCONTRAST_CONF_H + +class TQCheckBox; + +class HighContrastStyleConfig: public TQWidget +{ + Q_OBJECT +public: + HighContrastStyleConfig(TQWidget* parent); + ~HighContrastStyleConfig(); + + // This signal and the next two slots are the plugin + // page interface +signals: + void changed(bool); + +public slots: + void save(); + void defaults(); + + // Everything below this is internal. +protected slots: + void updateChanged(); + +protected: + // We store settings directly in widgets to + // avoid the hassle of sync'ing things + TQCheckBox* wideLinesBox; + + // Original settings, for accurate dirtiness tracking + bool originalWideLinesState; +}; + +#endif // HIGHCONTRAST_CONF_H diff --git a/tdestyles/highcontrast/highcontrast.cpp b/tdestyles/highcontrast/highcontrast.cpp new file mode 100644 index 000000000..af021a91a --- /dev/null +++ b/tdestyles/highcontrast/highcontrast.cpp @@ -0,0 +1,1867 @@ +/* + * High Contrast Style (version 1.0) + * Copyright (C) 2004 Olaf Schmidt <ojschmidt@kde.org> + * + * Derived from Axes Style + * Copyright (C) 2003 Maksim Orlovich <orlovich@cs.rochester.edu> + * + * Axes Style based on KDE 3 HighColor Style, + * Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org> + * (C) 2001-2002 Fredrik Höglund <fredrik@kde.org> + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#include <tqdrawutil.h> +#include <tqpainter.h> +#include <tqpointarray.h> +#include <tqstyleplugin.h> + +#include <tqfont.h> +#include <tqcombobox.h> +#include <tqheader.h> +#include <tqmenubar.h> +#include <tqpushbutton.h> +#include <tqscrollbar.h> +#include <tqslider.h> +#include <tqtabbar.h> +#include <tqtoolbutton.h> +#include <tqtoolbar.h> +#include <tqpopupmenu.h> +#include <tqprogressbar.h> +#include <tqlistview.h> +#include <tqsettings.h> + +#include <tqimage.h> +#include <tqapplication.h> + +#include <kdrawutil.h> +#include <kpixmapeffect.h> + +#include "highcontrast.h" +#include "highcontrast.moc" + +// -- Style Plugin Interface ------------------------- +class HighContrastStylePlugin : public TQStylePlugin +{ + public: + HighContrastStylePlugin() {} + ~HighContrastStylePlugin() {} + + TQStringList keys() const + { + return TQStringList() << "HighContrast"; + } + + TQStyle* create( const TQString& key ) + { + if ( key == "highcontrast" ) + return new HighContrastStyle(); + return 0; + } +}; + +KDE_Q_EXPORT_PLUGIN (HighContrastStylePlugin) +// --------------------------------------------------- + + + +static const int itemFrame = 1; +static const int itemHMargin = 3; +static const int itemVMargin = 0; +static const int arrowHMargin = 6; +static const int rightBorder = 12; + + +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); +} + + +// --------------------------------------------------------------------------- + +HighContrastStyle::HighContrastStyle() + : TDEStyle( 0, ThreeButtonScrollBar ) +{ + TQSettings settings; + settings.beginGroup("/highcontraststyle/Settings/"); + bool useWideLines = settings.readBoolEntry("wideLines", false); + basicLineWidth = useWideLines ? 4 : 2; +} + + +HighContrastStyle::~HighContrastStyle() +{ +} + + +void HighContrastStyle::polish( TQPalette& pal ) +{ + //We do not want the disabled widgets to be greyed out, + //as that may be hard indeed (and since we use crossed-out text instead), + //so we make disabled colors be the same as active foreground and + //background colour + for (int c = 0; c < TQColorGroup::NColorRoles; ++c) + switch (c) + { + case TQColorGroup::Button: + case TQColorGroup::Base: + case TQColorGroup::Highlight: + pal.setColor(TQPalette::Disabled, TQColorGroup::ColorRole(c), pal.color(TQPalette::Active, TQColorGroup::Background)); + break; + case TQColorGroup::ButtonText: + case TQColorGroup::Text: + case TQColorGroup::HighlightedText: + pal.setColor(TQPalette::Disabled, TQColorGroup::ColorRole(c), pal.color(TQPalette::Active, TQColorGroup::Foreground)); + break; + default: + pal.setColor(TQPalette::Disabled, TQColorGroup::ColorRole(c), pal.color(TQPalette::Active, TQColorGroup::ColorRole(c))); + } +} + + +void HighContrastStyle::polish (const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr) +{ + if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { + TQWidget *widget = reinterpret_cast<TQWidget*>(ptr); + + if (widget->inherits (TQBUTTON_OBJECT_NAME_STRING) + || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING) + || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING) + || widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING) + || widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING)) + { + installObjectEventHandler(ceData, elementFlags, ptr, this); + + TQSpinWidget* spinwidget = dynamic_cast<TQSpinWidget*>(widget); + if (spinwidget && spinwidget->editWidget()) { + TQWidget* spinEditWidget = spinwidget->editWidget(); + TQStyleControlElementData swCeData = populateControlElementDataFromWidget(spinEditWidget, TQStyleOption()); + ControlElementFlags swElementFlags = getControlElementFlagsForObject(spinEditWidget, swCeData.widgetObjectTypes, TQStyleOption()); + installObjectEventHandler(swCeData, swElementFlags, spinEditWidget, this); + } + } + } + + TDEStyle::polish (ceData, elementFlags, ptr); +} + + +void HighContrastStyle::unPolish (const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr) +{ + if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) { + TQWidget *widget = reinterpret_cast<TQWidget*>(ptr); + if (widget->inherits (TQWIDGET_OBJECT_NAME_STRING) || widget->inherits (TQCOMBOBOX_OBJECT_NAME_STRING) || widget->inherits (TQSPINWIDGET_OBJECT_NAME_STRING) || widget->inherits (TQLINEEDIT_OBJECT_NAME_STRING) || widget->inherits (TQTEXTEDIT_OBJECT_NAME_STRING)) { + installObjectEventHandler(ceData, elementFlags, ptr, this); + } + } + + TDEStyle::unPolish (ceData, elementFlags, ptr); +} + +void HighContrastStyle::setColorsNormal (TQPainter* p, const TQColorGroup& cg, int flags, int highlight) const +{ + setColorsByState (p, cg, cg.foreground(), cg.background(), flags, highlight); +} + +void HighContrastStyle::setColorsButton (TQPainter* p, const TQColorGroup& cg, int flags, int highlight) const +{ + setColorsByState (p, cg, cg.buttonText(), cg.button(), flags, highlight); +} + +void HighContrastStyle::setColorsText (TQPainter* p, const TQColorGroup& cg, int flags, int highlight) const +{ + setColorsByState (p, cg, cg.text(), cg.base(), flags, highlight); +} + +void HighContrastStyle::setColorsHighlight (TQPainter* p, const TQColorGroup& cg, int flags) const +{ + setColorsByState (p, cg, cg.highlightedText(), cg.highlight(), flags, 0); +} + +void HighContrastStyle::setColorsByState (TQPainter* p, const TQColorGroup& cg, const TQColor& fg, const TQColor& bg, int flags, int highlight) const +{ + TQFont font = p->font(); + font.setStrikeOut (! (flags & Style_Enabled)); + p->setFont (font); + + if ((flags & Style_Enabled) && (flags & highlight)) + { + p->setPen (TQPen (cg.highlightedText(), basicLineWidth, flags & Style_Enabled ? Qt::SolidLine : Qt::DotLine)); + p->setBackgroundColor (cg.highlight()); + } + else + { + p->setPen (TQPen (fg, basicLineWidth, flags & Style_Enabled ? Qt::SolidLine : Qt::DotLine)); + p->setBackgroundColor (bg); + } + + p->setBrush (TQBrush ()); +} + +void HighContrastStyle::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 HighContrastStyle::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 HighContrastStyle::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 HighContrastStyle::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(); +} + +// This function draws primitive elements +void HighContrastStyle::drawPrimitive (TQ_PrimitiveElement pe, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + const TQStyleOption& opt ) const +{ + switch(pe) + { + case PE_StatusBarSection: { + //### TODO: Not everything uses this! + setColorsNormal (p, cg, Style_Enabled); + drawRect (p, r); + break; + } + // BUTTONS + // ------------------------------------------------------------------- + case PE_ButtonDefault: + case PE_ButtonDropDown: + case PE_ButtonCommand: + case PE_ButtonTool: + case PE_ButtonBevel: { + setColorsButton (p, cg, flags, Style_On|Style_MouseOver|Style_Down); + drawRoundRect (p, r, 0, false); + break; + } + + // FOCUS RECT + // ------------------------------------------------------------------- + case PE_FocusRect: { + p->save(); + p->setBrush (TQBrush ()); + p->setPen (TQPen (cg.highlight(), basicLineWidth, Qt::SolidLine)); + drawRoundRect (p, r, basicLineWidth, false); + p->setPen (TQPen (cg.highlightedText(), basicLineWidth, Qt::DashLine)); + drawRoundRect (p, r, basicLineWidth, false); + p->restore(); + break; + } + + case PE_HeaderArrow: { + setColorsButton (p, cg, flags, 0); + drawArrow (p, r, flags & Style_Down ? PE_ArrowDown : PE_ArrowUp, 2*basicLineWidth); + break; + } + // HEADER SECTION + // ------------------------------------------------------------------- + case PE_HeaderSectionMenu: + case PE_HeaderSection: { + setColorsButton (p, cg, flags, 0); + drawRect (p, r); + break; + } + + + // SCROLLBAR + // ------------------------------------------------------------------- + case PE_ScrollBarSlider: { + setColorsNormal (p, cg); + p->fillRect (r, p->backgroundColor()); + + if (flags & Style_Enabled) { + setColorsHighlight (p, cg, flags); + drawRoundRect (p, r); + + if (r.width() >= 7*basicLineWidth && r.height() >= 7*basicLineWidth) { + TQRect r2 (r); + r2.setWidth (4*basicLineWidth); + r2.setHeight (4*basicLineWidth); + r2.moveCenter (r.center()); + drawRect (p, r2, 0, false); + } + } + break; + } + + case PE_ScrollBarAddPage: + case PE_ScrollBarSubPage: { + setColorsNormal (p, cg); + p->fillRect (r, p->backgroundColor()); + + TQRect r2 (r); + if (flags & Style_Horizontal) + { + if (r2.height() > 5*basicLineWidth) + { + r2.setHeight (5*basicLineWidth); + r2.moveCenter (r.center()); + } + } + else + { + if (r2.width() > 5*basicLineWidth) + { + r2.setWidth (5*basicLineWidth); + r2.moveCenter (r.center()); + } + } + setColorsText (p, cg, flags); + drawRect (p, r2); + + if (flags & Style_Horizontal) + r2.addCoords (0, basicLineWidth, 0, -basicLineWidth); + else + r2.addCoords (basicLineWidth, 0, -basicLineWidth, 0); + TQPen pen = p->pen(); + pen.setColor (p->backgroundColor()); + p->setPen (pen); + drawRect (p, r2); + + break; + } + + case PE_ScrollBarAddLine: + case PE_ScrollBarSubLine: + case PE_ScrollBarFirst: + case PE_ScrollBarLast: { + setColorsNormal (p, cg); + p->fillRect (r, p->backgroundColor()); + + if (flags & Style_Enabled) { + setColorsButton (p, cg, flags); + drawRoundRect (p, r); + if (pe == PE_ScrollBarAddLine) + drawArrow (p, r, flags & Style_Horizontal ? PE_ArrowRight : PE_ArrowDown, r.height()/3); + else if (pe == PE_ScrollBarSubLine) + drawArrow (p, r, flags & Style_Horizontal ? PE_ArrowLeft : PE_ArrowUp, r.height()/3); + } + break; + } + + + case PE_ProgressBarChunk: { + p->fillRect (r, Qt::color1); + break; + } + + + // CHECKBOX + // ------------------------------------------------------------------- + case PE_Indicator: { + setColorsText (p, cg, flags); + + //Draw the outer rect + drawRect (p, r); + + if (!(flags & Style_Off)) + { + TQRect r2 (r); + addOffset (&r2, basicLineWidth); + if (flags & Style_On) + { + p->drawLine (r2.topLeft(), r2.bottomRight()); + p->drawLine (r2.bottomLeft(), r2.topRight()); + } + else + { // Tristate + p->drawLine (r2.left(), r2.top()+r2.width()/2, r2.right(), r2.top()+r2.width()/2); + } + TQPen pen = p->pen(); + pen.setColor (p->backgroundColor()); + p->setPen (pen); + drawRect (p, r2, 0, false); + } + break; + } + case PE_IndicatorMask: { + p->fillRect (r, Qt::color1); + break; + } + case PE_CheckMark: { + setColorsText (p, cg, flags); + + if (flags & Style_On) + { + p->drawLine (r.topLeft(), r.bottomRight()); + p->drawLine (r.bottomLeft(), r.topRight()); + } + break; + } + + // RADIOBUTTON (exclusive indicator) + // ------------------------------------------------------------------- + case PE_ExclusiveIndicator: { + setColorsText (p, cg, flags); + drawEllipse (p, r); + + // Indicator "dot" + if (flags & Style_On) { + p->setBackgroundColor (p->pen().color()); + drawEllipse (p, r, 2*p->pen().width()); + } + + break; + } + case PE_ExclusiveIndicatorMask: { + p->fillRect (r, Qt::color0); + p->setBackgroundColor (Qt::color1); + p->setPen (Qt::NoPen); + p->setBrush (Qt::color1); + p->drawEllipse (r); + break; + } + + + // SPLITTER/DOCKWINDOW HANDLES + // ------------------------------------------------------------------- + case PE_DockWindowResizeHandle: + case PE_Splitter: { + setColorsButton (p, cg, flags); + p->fillRect (r, p->backgroundColor()); + + p->setPen (TQPen (p->pen().color(), 1, Qt::DashLine)); + if (flags & Style_Horizontal) + p->drawLine (r.center().x(), r.top(), r.center().x(), r.bottom()); + else + p->drawLine (r.left(), r.center().y(), r.right(), r.center().y()); + break; + } + + + // GENERAL PANELS + // ------------------------------------------------------------------- + case PE_Panel: + case PE_GroupBoxFrame: + case PE_PanelPopup: { + setColorsNormal (p, cg, flags, 0); + if (!opt.isDefault()) + { + TQPen pen = p->pen(); + pen.setWidth (opt.lineWidth()); + p->setPen (pen); + } + if (pe == PE_PanelPopup) + drawRect (p, r, 0, false); + else + drawRoundRect (p, r, 0, false); + break; + } + case PE_WindowFrame: + case PE_TabBarBase: { + setColorsNormal (p, cg, flags, 0); + drawRect (p, r, 0, false); + break; + } + case PE_PanelLineEdit: { + setColorsText (p, cg, flags, 0); + drawRoundRect (p, r); + if (flags & (Style_HasFocus | Style_Active)) + drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor())); + break; + } + case PE_PanelTabWidget: + case PE_PanelGroupBox: { + setColorsNormal (p, cg, flags, 0); + drawRoundRect (p, r); + break; + } + case PE_PanelMenuBar: { // Menu + p->fillRect (r, cg.background()); + break; + } + case PE_PanelDockWindow: { // Toolbar + p->fillRect (r, cg.button()); + break; + } + + + + // SEPARATORS + // ------------------------------------------------------------------- + case PE_Separator: { + setColorsNormal (p, cg); + p->fillRect (r, p->backgroundColor()); + p->setPen (p->pen().color()); + if (flags & Style_Horizontal) + p->drawLine (r.center().x(), r.top()+basicLineWidth, r.center().x(), r.bottom()-basicLineWidth + 1); + else + p->drawLine (r.left()+basicLineWidth, r.center().y(), r.right()-basicLineWidth + 1, r.center().y()); + break; + } + case PE_DockWindowSeparator: { + setColorsButton (p, cg); + p->fillRect (r, p->backgroundColor()); + p->setPen (p->pen().color()); + if (flags & Style_Horizontal) + p->drawLine (r.center().x(), r.top()+basicLineWidth, r.center().x(), r.bottom()-basicLineWidth); + else + p->drawLine (r.left()+basicLineWidth, r.center().y(), r.right()-basicLineWidth, r.center().y()); + break; + } + + + case PE_MenuItemIndicatorFrame: + { + // Draw nothing + break; + } + break; + case PE_MenuItemIndicatorIconFrame: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + TQRect cr = visualRect( TQRect(x, y, checkcol, h), r ); + drawRect (p, cr, 0, false); + break; + } + case PE_MenuItemIndicatorCheck: + { + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL); + + TQRect cr = visualRect( TQRect(x, y, checkcol, h), r ); + bool reverse = TQApplication::reverseLayout(); + int cx = reverse ? x+w - checkcol : x; + TQRect rc (cx, y, checkcol, h); + addOffset (&rc, 2*basicLineWidth); + TQPoint center = rc.center(); + if (rc.width() > rc.height()) + rc.setWidth (rc.height()); + else + rc.setHeight (rc.width()); + rc.moveCenter (center); + + p->drawLine (rc.topLeft(), rc.bottomRight()); + p->drawLine (rc.topRight(), rc.bottomLeft()); + break; + } + + + // ARROWS + // ------------------------------------------------------------------- + case PE_ArrowUp: + case PE_ArrowDown: + case PE_ArrowRight: + case PE_ArrowLeft: + case PE_SpinWidgetPlus: + case PE_SpinWidgetUp: + case PE_SpinWidgetMinus: + case PE_SpinWidgetDown: { + setColorsNormal (p, cg, flags); + drawArrow (p, r, pe); + break; + } + + default: { + TDEStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt ); + } + } +} + + +void HighContrastStyle::drawTDEStylePrimitive (TDEStylePrimitive kpe, + TQPainter* p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + const TQStyleOption &opt, + const TQWidget* widget ) const +{ + switch ( kpe ) + { + // TOOLBAR HANDLE + // ------------------------------------------------------------------- + case KPE_ToolBarHandle: + case KPE_DockWindowHandle: + case KPE_GeneralHandle: + { + setColorsButton (p, cg); + p->fillRect (r, p->backgroundColor()); + p->setBrush (TQBrush (p->pen().color(), Qt::BDiagPattern)); + drawRoundRect (p, r); + break; + } + + + // SLIDER GROOVE + // ------------------------------------------------------------------- + case KPE_SliderGroove: { + setColorsText (p, cg, flags); + TQRect r2 (r); + if (ceData.widgetObjectTypes.contains(TQSLIDER_OBJECT_NAME_STRING)) + { + if (ceData.orientation == TQt::Horizontal) + { + if (r2.height() > 5*basicLineWidth) + { + r2.setHeight (5*basicLineWidth); + r2.moveCenter (r.center()); + } + } + else + { + if (r2.width() > 5*basicLineWidth) + { + r2.setWidth (5*basicLineWidth); + r2.moveCenter (r.center()); + } + } + } + + drawRoundRect (p, r2); + break; + } + + // SLIDER HANDLE + // ------------------------------------------------------------------- + case KPE_SliderHandle: { + setColorsHighlight (p, cg, flags); + drawRoundRect (p, r); + break; + } + + case KPE_ListViewExpander: { + // TODO There is no pixelMetric associated with the + // ListViewExpander in TDEStyle. + // To have a properly large expander, the CC_ListView case of + // drawComplexControl should be handled. + // Probably it would be better to add a KPM_ListViewExpander metric + // to the TDEStyle TDEStylePixelMetric enum, and have the TDEStyle + // drawComplexControl handle it. + TQ_PrimitiveElement direction; + if (flags & Style_On) { // Collapsed = On + direction = PE_ArrowRight; + + } else { + direction = PE_ArrowDown; + } + setColorsText (p, cg, flags); + drawArrow (p, r, direction); + break; + } + case KPE_ListViewBranch: + // TODO Draw (thick) dotted line. Check tdestyle.cpp + // Fall down for now + default: + TDEStyle::drawTDEStylePrimitive( kpe, p, ceData, elementFlags, r, cg, flags, opt, widget); + } +} + + +void HighContrastStyle::drawControl (TQ_ControlElement element, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + const TQStyleOption& opt, + const TQWidget *widget ) const +{ + switch (element) + { + // TABS + // ------------------------------------------------------------------- + case CE_ToolBoxTab: { + setColorsNormal (p, cg, flags, Style_Selected); + drawRoundRect (p, r); + break; + } + + case CE_TabBarTab: { + setColorsNormal (p, cg, flags, Style_Selected); + drawRoundRect (p, r); + + TQTabBar::Shape shape = ceData.tabBarData.shape; + if (shape == TQTabBar::TriangularBelow || + shape == TQTabBar::RoundedBelow) { + p->fillRect (r.left(), r.top(), + r.width(), 2*basicLineWidth, + p->pen().color()); + p->fillRect (r.left()+basicLineWidth, + flags & Style_Selected ? basicLineWidth : 2*basicLineWidth, + r.width()-2*basicLineWidth, + basicLineWidth, + p->backgroundColor()); + } else { + p->fillRect (r.left(), r.bottom()-2*basicLineWidth+1, + r.width(), 2*basicLineWidth, + p->pen().color()); + p->fillRect (r.left()+basicLineWidth, + r.bottom()-2*basicLineWidth+1, + r.width()-2*basicLineWidth, + flags & Style_Selected ? 2*basicLineWidth : basicLineWidth, + p->backgroundColor()); + } + break; + } + + + // PUSHBUTTON + // ------------------------------------------------------------------- + case CE_PushButton: { + TQPushButton *button = (TQPushButton*) widget; + TQRect br = r; + bool btnDefault = (elementFlags & CEF_IsDefault); + + if (( btnDefault || (elementFlags & CEF_AutoDefault) ) && (elementFlags & CEF_IsEnabled)) { + // Compensate for default indicator + static int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags ); + addOffset (&br, di); + } + + if ( btnDefault && (elementFlags & CEF_IsEnabled)) + drawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags ); + + drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags ); + + break; + } + + + // LABEL + // ------------------------------------------------------------------- + case CE_ProgressBarLabel: + case CE_TabBarLabel: + case CE_RadioButtonLabel: + case CE_CheckBoxLabel: + case CE_ToolButtonLabel: + case CE_PushButtonLabel: { + const TQPixmap* pixmap = 0; + TQPixmap icon; + TQString text; + bool popup = false; + + TQIconSet::Mode mode = flags & Style_Enabled ? ((flags & Style_HasFocus) ? TQIconSet::Active : TQIconSet::Normal) : TQIconSet::Disabled; + TQIconSet::State state = flags & Style_On ? TQIconSet::On : TQIconSet::Off; + + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + if (element == CE_ProgressBarLabel) { + text = ceData.progressText; + setColorsNormal (p, cg, flags); + } + else if (element == CE_TabBarLabel) { + if (!opt.isDefault()) { + TQTab* tab = opt.tab(); + text = tab->text(); + } + setColorsNormal (p, cg, flags, Style_Selected); + } + else if (element == CE_ToolButtonLabel) { + text = ceData.text; + pixmap = (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap; + if (!ceData.iconSet.isNull()) + icon = ceData.iconSet.pixmap (TQIconSet::Small, mode, state); + popup = (elementFlags & CEF_HasPopupMenu); + setColorsButton (p, cg, flags); + } + else if (element == CE_PushButtonLabel) { + text = ceData.text; + pixmap = (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap; + if (!ceData.iconSet.isNull()) + icon = ceData.iconSet.pixmap (TQIconSet::Small, mode, state); + popup = (elementFlags & CEF_HasPopupMenu); + setColorsButton (p, cg, flags); + } + else { + pixmap = (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap; + text = ceData.text; + setColorsNormal (p, cg); + } + + // Does the button have a popup menu? + if (popup) { + int dx = pixelMetric (PM_MenuButtonIndicator, ceData, elementFlags, widget); + drawArrow (p, TQRect(x + w - dx - 2, y + 2, dx, h - 4), PE_ArrowDown); + w -= dx; + } + + // Draw the icon if there is one + if (!icon.isNull()) + { + // Center the iconset if there's no text or pixmap + if (text.isEmpty() && ((pixmap == 0) || pixmap->isNull())) + p->drawPixmap (x + (w - icon.width()) / 2, + y + (h - icon.height()) / 2, icon); + else + p->drawPixmap (x + 4, y + (h - icon.height()) / 2, icon); + + int pw = icon.width(); + x += pw + 4; + w -= pw + 4; + } + + // Draw a focus rect if the button has focus + if (flags & Style_HasFocus) + drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor())); + + // Draw the label itself + TQColor color = p->pen().color(); + drawItem (p, TQRect(x, y, w, h), + (element == CE_RadioButtonLabel || element == CE_CheckBoxLabel || element == CE_ProgressBarLabel) ? AlignVCenter|AlignLeft|ShowPrefix : AlignCenter|ShowPrefix, + cg, flags & Style_Enabled, pixmap, text, -1, &color); + break; + } + + // MENUBAR BACKGROUND + // ------------------------------------------------------------------- + case CE_MenuBarEmptyArea: + { + p->fillRect (r, cg.background()); + break; + } + + // DOCKWINDOW BACKGROUND + // ------------------------------------------------------------------- + case CE_DockWindowEmptyArea: + { + p->fillRect (r, cg.button()); + break; + } + + // MENUBAR ITEM + // ------------------------------------------------------------------- + case CE_MenuBarItem: { + setColorsNormal (p, cg, flags, Style_Active|Style_MouseOver); + p->fillRect (r, p->backgroundColor ()); + if (!opt.isDefault()) { + TQMenuItem *mi = opt.menuItem(); + + TQColor color = p->pen().color(); + drawItem (p, r, AlignCenter | AlignVCenter | ShowPrefix + | DontClip | SingleLine, cg, flags, + mi->pixmap(), mi->text(), -1, &color); + } + break; + } + + // CHECKBOX + // ------------------------------------------------------------------- + case CE_CheckBox: { + drawPrimitive (PE_Indicator, p, ceData, elementFlags, r, cg, flags); + break; + } + + // RADIOBUTTON + // ------------------------------------------------------------------- + case CE_RadioButton: { + drawPrimitive (PE_ExclusiveIndicator, p, ceData, elementFlags, r, cg, flags); + break; + } + + // PROGRESSBAR + // ------------------------------------------------------------------- + case CE_ProgressBarGroove: { + setColorsText (p, cg, flags); + TQRect r2 (r); + r2.setLeft (p->boundingRect (r, AlignVCenter|AlignLeft|ShowPrefix, ceData.progressText).right() + + 4*basicLineWidth); + drawRoundRect (p, r2); + break; + } + case CE_ProgressBarContents: { + TQRect r2 (r); + r2.setLeft (p->boundingRect (r, AlignVCenter|AlignLeft|ShowPrefix, ceData.progressText).right() + + 4*basicLineWidth); + long progress = r2.width() * ceData.currentStep; + if (ceData.totalSteps > 0) + { + r2.setWidth (progress / ceData.totalSteps); + } + else + { + int width = r2.width() / 5; + int left = ceData.currentStep % (2*(r2.width() - width)); + if (left > r2.width() - width) + left = 2*(r2.width() - width) - left; + r2.setLeft (r2.left() + left); + r2.setWidth (width); + } + setColorsHighlight (p, cg, flags); + if (r2.width() > 0) + drawRoundRect (p, r2); + break; + } + + // POPUPMENU ITEM + // ------------------------------------------------------------------- + case CE_PopupMenuItem: { + setColorsNormal (p, cg, flags, Style_Active|Style_MouseOver); + p->fillRect (r, p->backgroundColor ()); + + TQMenuItem *mi = opt.menuItem(); + if (!mi) + break; + + int tab = opt.tabWidth(); + int checkcol = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + bool reverse = TQApplication::reverseLayout(); + int x, y, w, h; + r.rect( &x, &y, &w, &h ); + + if ( checkable ) + checkcol = QMAX( checkcol, 20 ); + + // Are we a menu item separator? + if ( mi->isSeparator() ) { + p->drawLine (r.left() + 1, r.center().y(), r.right(), r.center().y()); + break; + } + + // Do we have an icon? + if ( mi->iconSet() && !mi->iconSet()->isNull() ) { + TQIconSet::Mode mode; + TQRect cr = visualRect( TQRect(x, y, checkcol, h), r ); + + // Select the correct icon from the iconset + if (!(flags & Style_Enabled)) + mode = TQIconSet::Disabled; + else if (flags & Style_Active) + mode = TQIconSet::Active; + else + mode = TQIconSet::Normal; + + // Draw the icon + TQPixmap pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode ); + TQRect pmr( 0, 0, pixmap.width(), pixmap.height() ); + pmr.moveCenter( cr.center() ); + p->drawPixmap( pmr.topLeft(), pixmap ); + + // Do we have an icon and are checked at the same time? + // Then draw a square border around the icon + if ( checkable && mi->isChecked() ) + { + drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt); + } + } + + // Are we checked? (This time without an icon) + else if ( checkable && mi->isChecked() ) { + drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt); + } + + // Time to draw the menu item label... + int xm = itemFrame + checkcol + itemHMargin; // X position margin + + int xp = reverse ? // X position + x + tab + rightBorder + itemHMargin + itemFrame - 1 : + x + xm; + + // Label width (minus the width of the accelerator portion) + int tw = w - xm - tab - arrowHMargin - itemHMargin * 3 - itemFrame + 1; + + // Does the menu item draw it's own label? + if ( mi->custom() ) { + int m = itemVMargin; + // Save the painter state in case the custom + // paint method changes it in some way + p->save(); + mi->custom()->paint( p, cg, flags & Style_Active, flags & Style_Enabled, xp, y+m, tw, h-2*m ); + p->restore(); + } + else { + // The menu item doesn't draw it's own label + TQString s = mi->text(); + + // Does the menu item have a text label? + if ( !s.isNull() ) { + int t = s.find( '\t' ); + int m = itemVMargin; + int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine; + text_flags |= reverse ? AlignRight : AlignLeft; + + // Does the menu item have a tabstop? (for the accelerator text) + if ( t >= 0 ) { + int tabx = reverse ? x + rightBorder + itemHMargin + itemFrame : + x + w - tab - rightBorder - itemHMargin - itemFrame; + + // Draw the right part of the label (accelerator text) + p->drawText( tabx, y+m, tab, h-2*m, text_flags, s.mid( t+1 ) ); + s = s.left( t ); + } + + // Draw the left part of the label (or the whole label + // if there's no accelerator) + + p->drawText( xp, y+m, tw, h-2*m, text_flags, s, t ); + + } + + // The menu item doesn't have a text label + // Check if it has a pixmap instead + else if ( mi->pixmap() ) { + TQPixmap *pixmap = mi->pixmap(); + + // Draw the pixmap + if ( pixmap->depth() == 1 ) + p->setBackgroundMode( Qt::OpaqueMode ); + + int diffw = ( ( w - pixmap->width() ) / 2 ) + + ( ( w - pixmap->width() ) % 2 ); + p->drawPixmap( x+diffw, y+itemFrame, *pixmap ); + + if ( pixmap->depth() == 1 ) + p->setBackgroundMode( Qt::TransparentMode ); + } + } + + // Does the menu item have a submenu? + if ( mi->popup() ) { + TQ_PrimitiveElement arrow = reverse ? PE_ArrowLeft : PE_ArrowRight; + int dim = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags); + TQRect vr = visualRect( TQRect( x + w - arrowHMargin - 2*itemFrame - dim, + y + h / 2 - dim / 2, dim, dim), r ); + + // Draw an arrow at the far end of the menu item + drawArrow (p, vr, arrow); + } + break; + } + + default: + TDEStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget); + } +} + +void HighContrastStyle::drawControlMask (TQ_ControlElement element, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQStyleOption &opt, + const TQWidget *w) const +{ + switch (element) { + case CE_PushButton: + case CE_ToolBoxTab: + case CE_TabBarTab: + case CE_ProgressBarLabel: + case CE_TabBarLabel: + case CE_RadioButtonLabel: + case CE_CheckBoxLabel: + case CE_ToolButtonLabel: + case CE_PushButtonLabel: + case CE_MenuBarEmptyArea: + case CE_MenuBarItem: + case CE_PopupMenuItem: { + p->fillRect (r, color0); + break; + } + + default: { + TDEStyle::drawControlMask (element, p, ceData, elementFlags, r, opt, w); + } + } +} + +// Helper to find the next sibling that's not hidden +// Lifted from tdestyle.cpp +static TQListViewItem* nextVisibleSibling(TQListViewItem* item) +{ + TQListViewItem* sibling = item; + do + { + sibling = sibling->nextSibling(); + } + while (sibling && !sibling->isVisible()); + + return sibling; +} + +void HighContrastStyle::drawComplexControl (TQ_ComplexControl control, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags, + SCFlags controls, + SCFlags active, + const TQStyleOption& opt, + const TQWidget *widget ) const +{ + switch(control) + { + // COMBOBOX + // ------------------------------------------------------------------- + case CC_ComboBox: { + setColorsText (p, cg, flags); + drawRoundRect (p, r); + + TQRect r2 = TQStyle::visualRect (querySubControlMetrics (CC_ComboBox, ceData, elementFlags, SC_ComboBoxArrow, TQStyleOption::Default, widget), ceData, elementFlags); + if (flags & Style_HasFocus) { + TQRect r3 (r); + if (r2.left() > 0) + r3.setRight (r2.left()+basicLineWidth-1); + else + r3.setLeft (r2.right()-basicLineWidth+1); + + drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r3, cg, flags, TQStyleOption (p->backgroundColor())); + } + + setColorsButton (p, cg, flags); + // Draw arrow if required + if (controls & SC_ComboBoxArrow) { + drawRoundRect (p, r2); + drawArrow (p, r2, PE_ArrowDown, 2*basicLineWidth); + } + + setColorsText (p, cg, flags); + break; + } + + // SPINWIDGET + // ------------------------------------------------------------------- + case CC_SpinWidget: { + if (controls & SC_SpinWidgetFrame) { + setColorsText (p, cg, flags); + drawRoundRect (p, r); + if (flags & Style_HasFocus) + drawPrimitive(PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor())); + } + + setColorsButton (p, cg, flags); + // Draw arrows if required + if (controls & SC_SpinWidgetDown) { + TQRect r2 = TQStyle::visualRect (querySubControlMetrics ((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags, SC_SpinWidgetDown, TQStyleOption::Default, widget), ceData, elementFlags); + drawRoundRect (p, r2); + drawArrow (p, r2, PE_SpinWidgetDown, 2*basicLineWidth); + } + if (controls & SC_SpinWidgetUp) { + TQRect r2 = TQStyle::visualRect (querySubControlMetrics ((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags, SC_SpinWidgetUp, TQStyleOption::Default, widget), ceData, elementFlags); + drawRoundRect (p, r2); + drawArrow (p, r2, PE_SpinWidgetUp, 2*basicLineWidth); + } + + setColorsText (p, cg, flags); + break; + } + + // TOOLBUTTON + // ------------------------------------------------------------------- + case CC_ToolButton: { + setColorsButton (p, cg, flags); + p->fillRect (r, p->backgroundColor ()); + + TQRect button, menuarea; + button = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget); + menuarea = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget); + + SFlags bflags = flags, + mflags = flags; + + if (active & SC_ToolButton) + bflags |= Style_Down; + if (active & SC_ToolButtonMenu) + mflags |= Style_Down; + + if (controls & SC_ToolButton) + { + // If we're pressed, on, or raised... + if (bflags & (Style_Down | Style_On | Style_Raised)) + drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt); + + // Check whether to draw a background pixmap + else if ( !ceData.parentWidgetData.bgPixmap.isNull() ) + { + TQPixmap pixmap = ceData.parentWidgetData.bgPixmap; + p->drawTiledPixmap( r, pixmap, ceData.pos ); + } + } + + // Draw a toolbutton menu indicator if required + if (controls & SC_ToolButtonMenu) + { + if (mflags & (Style_Down | Style_On | Style_Raised)) + drawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, opt); + drawArrow (p, menuarea, PE_ArrowDown); + } + + if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) { + TQRect fr = ceData.rect; + addOffset (&fr, 3); + drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags, TQStyleOption (p->backgroundColor())); + } + + break; + } + + // LISTVIEW + // ------------------------------------------------------------------- + case CC_ListView: { + /* + * Sigh... Lifted and modified from tdestyle.cpp + */ + /* + * Many thanks to TrollTech AS for donating CC_ListView from TQWindowsStyle. + * CC_ListView code is Copyright (C) 1998-2000 TrollTech AS. + */ + + // Paint the icon and text. + if ( controls & SC_ListView ) + TQCommonStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, controls, active, opt, widget ); + + // If we're have a branch or are expanded... + if ( controls & (SC_ListViewBranch | SC_ListViewExpand) ) + { + // If no list view item was supplied, break + if (opt.isDefault()) + break; + + TQListViewItem *item = opt.listViewItem(); + TQListViewItem *child = item->firstChild(); + + int y = r.y(); + int c; // dotline vertice count + int dotoffset = 0; + TQPointArray dotlines; + + if ( active == SC_All && controls == SC_ListViewExpand ) { + // We only need to draw a vertical line + c = 2; + dotlines.resize(2); + dotlines[0] = TQPoint( r.right(), r.top() ); + dotlines[1] = TQPoint( r.right(), r.bottom() ); + + } else { + + int linetop = 0, linebot = 0; + // each branch needs at most two lines, ie. four end points + dotoffset = (item->itemPos() + item->height() - y) % 2; + dotlines.resize( item->childCount() * 4 ); + c = 0; + + // skip the stuff above the exposed rectangle + while ( child && y + child->height() <= 0 ) + { + y += child->totalHeight(); + child = nextVisibleSibling(child); + } + + int bx = r.width() / 2; + + // paint stuff in the magical area + TQListView* v = item->listView(); + int lh = QMAX( p->fontMetrics().height() + 2 * v->itemMargin(), + TQApplication::globalStrut().height() ); + if ( lh % 2 > 0 ) + lh++; + + // Draw all the expand/close boxes... + TQRect boxrect; + TQStyle::StyleFlags boxflags; + while ( child && y < r.height() ) + { + linebot = y + lh/2; + if ( (child->isExpandable() || child->childCount()) && + (child->height() > 0) ) + { + int h = QMIN(lh, 24) - 4*basicLineWidth; + if (h < 10) + h = 10; + else + h &= ~1; // Force an even number of pixels + + // The primitive requires a rect. + boxrect = TQRect( bx-h/2, linebot-h/2, h, h ); + boxflags = child->isOpen() ? TQStyle::Style_Off : TQStyle::Style_On; + + // TDEStyle extension: Draw the box and expand/collapse indicator + drawTDEStylePrimitive( KPE_ListViewExpander, p, ceData, elementFlags, boxrect, cg, boxflags, opt, NULL ); + + // dotlinery + p->setPen( cg.mid() ); + dotlines[c++] = TQPoint( bx, linetop ); + dotlines[c++] = TQPoint( bx, linebot - 5 ); + dotlines[c++] = TQPoint( bx + 5, linebot ); + dotlines[c++] = TQPoint( r.width(), linebot ); + linetop = linebot + 5; + } else { + // just dotlinery + dotlines[c++] = TQPoint( bx+1, linebot ); + dotlines[c++] = TQPoint( r.width(), linebot ); + } + + y += child->totalHeight(); + child = nextVisibleSibling(child); + } + + if ( child ) // there's a child to draw, so move linebot to edge of rectangle + linebot = r.height(); + + if ( linetop < linebot ) + { + dotlines[c++] = TQPoint( bx, linetop ); + dotlines[c++] = TQPoint( bx, linebot ); + } + } + + // Draw all the branches... + static int thickness = kPixelMetric( KPM_ListViewBranchThickness, ceData, elementFlags ); + int line; // index into dotlines + TQRect branchrect; + TQStyle::StyleFlags branchflags; + for( line = 0; line < c; line += 2 ) + { + // assumptions here: lines are horizontal or vertical. + // lines always start with the numerically lowest + // coordinate. + + // point ... relevant coordinate of current point + // end ..... same coordinate of the end of the current line + // other ... the other coordinate of the current point/line + if ( dotlines[line].y() == dotlines[line+1].y() ) + { + // Horizontal branch + int end = dotlines[line+1].x(); + int point = dotlines[line].x(); + int other = dotlines[line].y(); + + branchrect = TQRect( point, other-(thickness/2), end-point, thickness ); + branchflags = TQStyle::Style_Horizontal; + + // TDEStyle extension: Draw the horizontal branch + drawTDEStylePrimitive( KPE_ListViewBranch, p, ceData, elementFlags, branchrect, cg, branchflags, opt, NULL ); + + } else { + // Vertical branch + int end = dotlines[line+1].y(); + int point = dotlines[line].y(); + int other = dotlines[line].x(); + int pixmapoffset = ((point & 1) != dotoffset ) ? 1 : 0; + + branchrect = TQRect( other-(thickness/2), point, thickness, end-point ); + if (!pixmapoffset) // ### Hackish - used to hint the offset + branchflags = TQStyle::Style_NoChange; + else + branchflags = TQStyle::Style_Default; + + // TDEStyle extension: Draw the vertical branch + drawTDEStylePrimitive( KPE_ListViewBranch, p, ceData, elementFlags, branchrect, cg, branchflags, opt, NULL ); + } + } + } + break; + } + + default: + TDEStyle::drawComplexControl(control, p, ceData, elementFlags, + r, cg, flags, controls, active, opt, widget); + break; + } +} + +void HighContrastStyle::drawComplexControlMask(TQ_ComplexControl c, + TQPainter *p, + const TQStyleControlElementData &ceData, + const ControlElementFlags elementFlags, + const TQRect &r, + const TQStyleOption &o, + const TQWidget *w) const +{ + switch (c) { + case CC_SpinWidget: + case CC_ToolButton: + case CC_ComboBox: { + p->fillRect (r, color0); + break; + } + default: { + TDEStyle::drawComplexControlMask (c, p, ceData, elementFlags, r, o, w); + } + } +} + +void HighContrastStyle::drawItem( TQPainter *p, + const TQRect &r, + int flags, + const TQColorGroup &cg, + bool enabled, + const TQPixmap *pixmap, + const TQString &text, + int len, + const TQColor *penColor ) const +{ + p->save(); + + // make the disabled things use the cross-line + TQFont font = p->font(); + font.setStrikeOut (!enabled); + p->setFont (font); + + enabled = true; //do not ghost it in Qt + + TDEStyle::drawItem (p, r, flags, cg, enabled, pixmap, text, len, penColor); + + p->restore(); +} + +TQRect HighContrastStyle::querySubControlMetrics( TQ_ComplexControl control, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + SubControl subcontrol, + const TQStyleOption& opt, + const TQWidget* widget ) const +{ + switch (control) + { + case CC_ComboBox : { + int arrow = pixelMetric (PM_ScrollBarExtent, ceData, elementFlags, widget); + switch (subcontrol) + { + case SC_ComboBoxFrame: + return TQRect (0, 0, ceData.rect.width(), ceData.rect.height()); + case SC_ComboBoxArrow: + return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height()); + case SC_ComboBoxEditField: + return TQRect (2*basicLineWidth, 2*basicLineWidth, + ceData.rect.width() - arrow - 3*basicLineWidth, ceData.rect.height() - 4*basicLineWidth); + + default: break; + } + break; + } + case CC_SpinWidget : { + int arrow = pixelMetric (PM_ScrollBarExtent, ceData, elementFlags, 0); + switch (subcontrol) + { + case SC_SpinWidgetFrame: + return TQRect (0, 0, ceData.rect.width(), ceData.rect.height()); + case SC_SpinWidgetButtonField: + return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height()); + case SC_SpinWidgetUp: + return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height()/2); + case SC_SpinWidgetDown: + return TQRect (ceData.rect.width() - arrow, ceData.rect.height()/2, + arrow, ceData.rect.height()-ceData.rect.height()/2); + case SC_SpinWidgetEditField: + return TQRect (2*basicLineWidth, 2*basicLineWidth, + ceData.rect.width() - arrow - 3*basicLineWidth, ceData.rect.height() - 4*basicLineWidth); + + default: break; + } + break; + } + + default: break; + } + + return TDEStyle::querySubControlMetrics (control, ceData, elementFlags, subcontrol, opt, widget); +} + + +int HighContrastStyle::pixelMetric(PixelMetric m, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQWidget *widget) const +{ + //### TODO: Use the tab metrics changes from Ker. + switch(m) + { + // BUTTONS + // ------------------------------------------------------------------- + case PM_ButtonMargin: // Space btw. frame and label + return 2*basicLineWidth; + + case PM_ButtonDefaultIndicator: { + if ((widget != 0) && !(elementFlags & CEF_IsEnabled)) + return 0; + else + return 2*basicLineWidth; + } + + case PM_ButtonShiftHorizontal: + case PM_ButtonShiftVertical: + return 0; + + case PM_ScrollBarExtent: { + int h = 0; + if (widget != 0) + h = (2*TQFontMetrics(ceData.font).lineSpacing())/3; + + if (h > 9*basicLineWidth+4) + return h; + else + return 9*basicLineWidth+4; + } + + case PM_DefaultFrameWidth: { + if (widget && (ceData.widgetObjectTypes.contains (TQLINEEDIT_OBJECT_NAME_STRING) || ceData.widgetObjectTypes.contains (TQTEXTEDIT_OBJECT_NAME_STRING))) + return 2*basicLineWidth; + else + return basicLineWidth; + } + + case PM_SpinBoxFrameWidth: { + return 2*basicLineWidth; + } + + case PM_MenuButtonIndicator: { // Arrow width + int h = 0; + if (widget != 0) + h = TQFontMetrics(ceData.font).lineSpacing()/2; + + if (h > 3*basicLineWidth) + return h; + else + return 3*basicLineWidth; + } + + // CHECKBOXES / RADIO BUTTONS + // ------------------------------------------------------------------- + case PM_ExclusiveIndicatorWidth: // Radiobutton size + case PM_ExclusiveIndicatorHeight: + case PM_IndicatorWidth: // Checkbox size + case PM_IndicatorHeight: { + int h = 0; + if (widget != 0) + h = TQFontMetrics(ceData.font).lineSpacing()-2*basicLineWidth; + + if (h > 6*basicLineWidth) + return h; + else + return 6*basicLineWidth; + } + + case PM_DockWindowSeparatorExtent: { + return 2*basicLineWidth + 1; + } + case PM_DockWindowHandleExtent: { + int w = 0; + if (widget != 0) + w = TQFontMetrics(ceData.font).lineSpacing()/4; + if (w > 5*basicLineWidth) + return w; + else + return 5*basicLineWidth; + } + + case PM_MenuIndicatorFrameHBorder: + case PM_MenuIndicatorFrameVBorder: + case PM_MenuIconIndicatorFrameHBorder: + case PM_MenuIconIndicatorFrameVBorder: + return 0; + + default: + return TDEStyle::pixelMetric(m, ceData, elementFlags, widget); + } +} + +int HighContrastStyle::kPixelMetric( TDEStylePixelMetric kpm, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQWidget *widget ) const +{ + switch (kpm) { + case KPM_ListViewBranchThickness: + // XXX Proper support of thick branches requires reimplementation of + // the drawTDEStylePrimitive KPE_ListViewBranch case. + return basicLineWidth; + default: + return TDEStyle::kPixelMetric(kpm, ceData, elementFlags, widget); + } +} + +TQSize HighContrastStyle::sizeFromContents( ContentsType contents, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQSize &contentSize, + const TQStyleOption& opt, + const TQWidget* widget ) const +{ + switch (contents) + { + // PUSHBUTTON SIZE + // ------------------------------------------------------------------ + case CT_PushButton: { + const TQPushButton* button = (const TQPushButton*) widget; + int w = contentSize.width(); + int h = contentSize.height(); + int bm = pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget ); + int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ) * 2; + + w += bm + fw + 6; // ### Add 6 to make way for bold font. + h += bm + fw; + + // Ensure we stick to standard width and heights. + if (( button->isDefault() || button->autoDefault() ) && (button->isEnabled())) { + if ( w < 80 && !button->text().isEmpty() ) + w = 80; + + // Compensate for default indicator + int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags ); + w += di * 2; + h += di * 2; + } + + if ( h < 22 ) + h = 22; + + return TQSize( w + basicLineWidth*2, h + basicLineWidth*2 ); + } + + // TOOLBUTTON SIZE + // ----------------------------------------------------------------- + case CT_ToolButton: { + int w = contentSize.width(); + int h = contentSize.height(); + return TQSize(w + basicLineWidth*2 + 6, h + basicLineWidth*2 + 5); + break; + } + + // COMBOBOX SIZE + // ----------------------------------------------------------------- + case CT_ComboBox: { + const TQComboBox *cb = static_cast< const TQComboBox* > (widget); + int borderSize = (cb->editable() ? 4 : 2) * basicLineWidth; + int arrowSize = pixelMetric (PM_ScrollBarExtent, ceData, elementFlags, cb); + return TQSize(borderSize + basicLineWidth + arrowSize, borderSize) + contentSize; + } + + // POPUPMENU ITEM SIZE + // ----------------------------------------------------------------- + case CT_PopupMenuItem: { + if ( ! widget || opt.isDefault() ) + return contentSize; + + const TQPopupMenu *popup = (const TQPopupMenu *) widget; + bool checkable = popup->isCheckable(); + TQMenuItem *mi = opt.menuItem(); + int maxpmw = opt.maxIconWidth(); + int w = contentSize.width(), h = contentSize.height(); + + if ( mi->custom() ) { + w = mi->custom()->sizeHint().width(); + h = mi->custom()->sizeHint().height(); + if ( ! mi->custom()->fullSpan() ) + h += 2*itemVMargin + 2*itemFrame; + } + else if ( mi->widget() ) { + } else if ( mi->isSeparator() ) { + w = 10; // Arbitrary + h = 4; + } + else { + if ( mi->pixmap() ) + h = QMAX( h, mi->pixmap()->height() + 2*itemFrame ); + else { + // Ensure that the minimum height for text-only menu items + // is the same as the icon size used by KDE. + h = QMAX( h, 16 + 2*itemFrame ); + h = QMAX( h, popup->fontMetrics().height() + + 2*itemVMargin + 2*itemFrame ); + } + + if ( mi->iconSet() && ! mi->iconSet()->isNull() ) + h = QMAX( h, mi->iconSet()->pixmap( + TQIconSet::Small, TQIconSet::Normal).height() + + 2 * itemFrame ); + } + + if ( ! mi->text().isNull() && mi->text().find('\t') >= 0 ) + w += 12; + else if ( mi->popup() ) + w += 2 * arrowHMargin; + + if ( maxpmw ) + w += maxpmw + 6; + if ( checkable && maxpmw < 20 ) + w += 20 - maxpmw; + if ( checkable || maxpmw > 0 ) + w += 12; + + w += rightBorder; + + return TQSize( w, h ); + } + + + // LINEDIT SIZE + // ----------------------------------------------------------------- + case CT_LineEdit: { + return contentSize + TQSize (4*basicLineWidth, 4*basicLineWidth); + } + + + default: + return TDEStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget ); + } +} + +TQRect HighContrastStyle::subRect (SubRect subrect, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget * widget) const +{ + switch (subrect) { + case SR_ProgressBarGroove: + case SR_ProgressBarContents: + case SR_ProgressBarLabel: + return ceData.rect; + default: + return TDEStyle::subRect (subrect, ceData, elementFlags, widget); + } +} + +bool HighContrastStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *event ) +{ + return TDEStyle::objectEventHandler (ceData, elementFlags, source, event); +} + +/*! \reimp */ +int HighContrastStyle::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 checkcol = opt.maxIconWidth(); + bool checkable = (elementFlags & CEF_IsCheckable); + + if ( checkable ) + checkcol = QMAX( checkcol, 20 ); + + ret = checkcol; + } + break; + default: + ret = TDEStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w); + break; + } + + return ret; +} + +// vim: set noet ts=4 sw=4: +// kate: indent-width 4; replace-tabs off; smart-indent on; tab-width 4; diff --git a/tdestyles/highcontrast/highcontrast.h b/tdestyles/highcontrast/highcontrast.h new file mode 100644 index 000000000..552526254 --- /dev/null +++ b/tdestyles/highcontrast/highcontrast.h @@ -0,0 +1,180 @@ +/* + * High Contrast Style (version 1.0) + * Copyright (C) 2004 Olaf Schmidt <ojschmidt@kde.org> + * + * Derived from Axes Style + * Copyright (C) 2003 Maksim Orlovich <orlovich@cs.rochester.edu> + * + * Axes Style based on KDE 3 HighColor Style, + * Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org> + * (C) 2001-2002 Fredrik Höglund <fredrik@kde.org> + * + * KDE 3 HighColor Style drawing routines adapted from the KDE2 HCStyle, + * Copyright (C) 2000 Daniel M. Duley <mosfet@kde.org> + * (C) 2000 Dirk Mueller <mueller@kde.org> + * (C) 2001 Martijn Klingens <klingens@kde.org> + * + * Includes portions from TDEStyle, + * Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org> + * + * Many thanks to Bradley T. Hughes for the 3 button scrollbar code. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License version 2 as published by the Free Software Foundation. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public License + * along with this library; see the file COPYING.LIB. If not, write to + * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifndef __HIGHCONTRAST_H +#define __HIGHCONTRAST_H + +#include <tqbitmap.h> +#include <tqintdict.h> +#include <kdrawutil.h> +#include <kpixmap.h> +#include <tdestyle.h> + + +class TQPopupMenu; + +class HighContrastStyle : public TDEStyle +{ + Q_OBJECT + + public: + HighContrastStyle(); + virtual ~HighContrastStyle(); + + void polish( TQPalette& pal ); + + void polish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + void unPolish( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void * ); + + void drawTDEStylePrimitive( TDEStylePrimitive kpe, + TQPainter* p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags = Style_Default, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget* widget = 0 ) const; + + void drawPrimitive( TQ_PrimitiveElement pe, + TQPainter* p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags = Style_Default, + const TQStyleOption& = TQStyleOption::Default ) const; + + void drawControl( TQ_ControlElement element, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags = Style_Default, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; + + void drawControlMask( TQ_ControlElement element, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; + + void drawComplexControl( TQ_ComplexControl control, + TQPainter *p, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQRect &r, + const TQColorGroup &cg, + SFlags flags = Style_Default, + SCFlags controls = SC_All, + SCFlags active = SC_None, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; + + void drawComplexControlMask( TQ_ComplexControl control, + TQPainter *p, + const TQStyleControlElementData &ceData, + const ControlElementFlags elementFlags, + const TQRect &r, + const TQStyleOption& = TQStyleOption::Default, + const TQWidget *widget = 0 ) const; + + TQRect querySubControlMetrics( TQ_ComplexControl control, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + SubControl subcontrol, + const TQStyleOption& opt = TQStyleOption::Default, + const TQWidget* widget = 0 ) const; + + + void drawItem( TQPainter *p, + const TQRect &r, + int flags, + const TQColorGroup &cg, + bool enabled, + const TQPixmap *pixmap, + const TQString &text, + int len = -1, + const TQColor *penColor = 0 ) const; + + int pixelMetric( PixelMetric m, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, + const TQWidget *widget = 0 ) const; + + int kPixelMetric( TDEStylePixelMetric m, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, + const TQWidget *widget = 0 ) const; + + TQSize sizeFromContents( ContentsType contents, + const TQStyleControlElementData &ceData, + ControlElementFlags elementFlags, + const TQSize &contentSize, + const TQStyleOption& opt, + const TQWidget *widget = 0 ) const; + + TQRect subRect (SubRect subrect, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget * widget) const; + + int styleHint(TQ_StyleHint, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, + const TQStyleOption & = TQStyleOption::Default, + TQStyleHintReturn * = 0, const TQWidget * = 0 ) const; + + protected: + virtual bool objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *e ); + + private: + void setColorsNormal (TQPainter* p, const TQColorGroup& cg, int flags = Style_Enabled, int highlight = Style_Down|Style_MouseOver) const; + void setColorsButton (TQPainter* p, const TQColorGroup& cg, int flags = Style_Enabled, int highlight = Style_Down|Style_MouseOver) const; + void setColorsText (TQPainter* p, const TQColorGroup& cg, int flags = Style_Enabled, int highlight = Style_Down|Style_MouseOver) const; + void setColorsHighlight (TQPainter* p, const TQColorGroup& cg, int flags = Style_Enabled) const; + void setColorsByState (TQPainter* p, const TQColorGroup& cg, const TQColor& fg, const TQColor& bg, int flags, int highlight) const; + + void drawRect (TQPainter* p, TQRect r, int offset = 0, bool filled = true) const; + void drawRoundRect (TQPainter* p, TQRect r, int offset = 0, bool filled = true) const; + void drawEllipse (TQPainter* p, TQRect r, int offset = 0, bool filled = true) const; + void drawArrow (TQPainter* p, TQRect r, TQ_PrimitiveElement arrow, int offset = 0) const; + + int basicLineWidth; + // Disable copy constructor and = operator + HighContrastStyle( const HighContrastStyle & ); + HighContrastStyle& operator=( const HighContrastStyle & ); +}; + +// vim: set noet ts=4 sw=4: +// kate: indent-width 4; replace-tabs off; smart-indent on; tab-width 4; + +#endif diff --git a/tdestyles/highcontrast/highcontrast.themerc b/tdestyles/highcontrast/highcontrast.themerc new file mode 100644 index 000000000..c3b8445d4 --- /dev/null +++ b/tdestyles/highcontrast/highcontrast.themerc @@ -0,0 +1,127 @@ +[Misc] +Name=HighContrast +Name[af]=Hoë kontras +Name[be]=Высокі кантраст +Name[bn]=হাই কনট্রাস্ট +Name[br]=Dargemm uhel +Name[ca]=Contrast alt +Name[cs]=Vysoký kontrast +Name[csb]=Wësoczi kòntrast +Name[da]=Høj kontrast +Name[de]=Hoher Kontrast +Name[el]=Υψηλή φωτεινότητα +Name[eo]=Granda kontrasto +Name[es]=ContrasteAlto +Name[et]=Tugev kontrast +Name[eu]=Kontraste handia +Name[fa]=سایه روشن بالا +Name[fi]=KorkeaKontrasti +Name[fr]=Contraste fort +Name[fy]=Heechkontrast +Name[he]=ניגודיות גבוהה +Name[hr]=Visoki kontrast +Name[hu]=Erősen kontrasztos +Name[is]=Há birtuskil +Name[it]=Contrasto elevato +Name[ja]=高コントラスト +Name[ka]=კონტრასტი +Name[kk]=Жоғары контрасты +Name[km]=កម្រិតពណ៌ខ្ពស់ +Name[lb]=HéichKontrast +Name[lt]=Didelis kontrastas +Name[lv]=Augsts kontrasts +Name[mk]=Висок контраст +Name[ms]=Kontras Tinggi +Name[nb]=HøyKontrast +Name[nds]=HoochKontrast +Name[ne]=उच्च व्यतिरेक +Name[nl]=Hoogcontrast +Name[nn]=Høg kontrast +Name[pa]=ਗੂੜਾ +Name[pl]=Wysoki kontrast +Name[pt]=Alto Contraste +Name[pt_BR]=Alto Contraste +Name[ro]=Contrast mare +Name[ru]=Контраст +Name[rw]=InyuranyamigaragarireRihebuje +Name[se]=AllaVuostálasvuohta +Name[sl]=VisokKontrast +Name[sr]=Високи контраст +Name[sr@Latn]=Visoki kontrast +Name[sv]=Hög kontrast +Name[ta]=அதிக மாறுபாடு +Name[te]=ఎక్కువ వ్యత్యాసం +Name[tg]=БаландАкс +Name[th]=คอนทราสต์สูง +Name[tr]=Yüksek Kontrast +Name[tt]=KiskenTösle +Name[uk]=Висока контрастність +Name[vi]=Độ tương phản cao +Name[zh_CN]=高对比度 +Name[zh_HK]=高反差 +ConfigPage=tdestyle_highcontrast_config +Comment=A style that works well with high contrast color schemes +Comment[af]=´n Styl wat goed werk met hoë kontras kleur skemas +Comment[be]=Стыль, які створаны для працы з высокакантрастнымі колернымі схемамі +Comment[bg]=Стил за схеми с висок контраст +Comment[bs]=Stil koji izgleda dobro sa šemama boja visokog kontrasta +Comment[ca]=Un estil que funciona bé amb esquemes de color de contrast alt +Comment[cs]=Styl vhodný pro barevná schémata s vysokým kontrastem +Comment[csb]=Sztél, jaczi dzejô pòprôwno z témama farwów ò wësoczim kòntrasce +Comment[da]=En stil der virker godt med farvesammensætninger med høj kontrast +Comment[de]=Ein Stil, der gut zu kontrastreichen Farbschemas passt +Comment[el]=Ένα στυλ που δουλεύει καλά με σχήματα υψηλής φωτεινότητας +Comment[en_GB]=A style that works well with high contrast colour schemes +Comment[eo]=Stilo kiu konvenas al kolor-etosoj kiuj havas grandajn kontrastojn +Comment[es]=Un estilo que funciona con esquemas de color de contraste alto +Comment[et]=Stiil, mis sobib hästi tugeva kontrastiga värviskeemidele +Comment[eu]=Kontraste handiko gaiekin ongi moldatzen den estiloa +Comment[fa]=سبکی که به خوبی با طرحهای رنگ، با سایه روشن بالا کار میکند +Comment[fi]=Tyyli joka toimii hyvin korkeakontrastisien väriteemojen kanssa +Comment[fr]=Un style se combinant bien avec les modèles de couleurs à fort contraste +Comment[fy]=In styl dy goed wurket mei hege kontrast kleureskema’s +Comment[gl]=Un estilo que traballa ben con esquemas de cor de alto contraste +Comment[hr]=Stil koji dobro fukcionira s shemama bojanja u visokom kontrastu +Comment[hu]=Erősen kontrasztos színsémákhoz jól illeszkedő stílus +Comment[id]=Gaya yang sesuai untuk skema warna kontras tinggi +Comment[is]=Stíll sem passar vel við litaskemu sem nota há birtuskil +Comment[it]=Uno stile che funziona bene con combinazioni di colori ad alto contrasto +Comment[ja]=高コントラストの色スキームにふさわしいスタイル +Comment[ka]=ფერების მაღალ კონტრასტული სქემების სტილი +Comment[kk]=Контрастығы жоғары түстер сұлбалы стиль +Comment[km]=រចនាប័ទ្មដែលធ្វើការយ៉ាងល្អជាមួយគ្រោងពណ៌កម្រិតខ្ពស់ +Comment[lb]=E Stil, dee gutt bei Faarfschemaë mat engem héiche Kontrast passt +Comment[lt]=Stilius, kuris labai tinka didelio kontrasto spalvų schemoms +Comment[mk]=Стил што добро работи со шеми на бои со висок контраст +Comment[ms]=Gaya yang berfungsi baik dengan skema warna kontras tinggi +Comment[nb]=En stil som passer bra sammen med temaer med høy kontrast +Comment[nds]=En Stil, de goot för Klöörschemas mit hogen Kontrast passt. +Comment[ne]=उच्च व्यतिरेक रङ स्कीमासँग राम्रो कार्य गर्ने शैली +Comment[nl]=Een stijl die goed werkt met hoog contrast kleurenschema's +Comment[nn]=Ein stil som fungerer bra når fargeoppsettet har høg kontrast +Comment[pa]= ਇੱਕ ਸ਼ੈਲੀ, ਜੋ ਕਿ ਗੂੜੀ ਰੰਗ ਸਕੀਮ ਨਾਲ ਵਧੀਆ ਕੰਮ ਕਰਦੀ ਹੈ +Comment[pl]=Styl, który działa dobrze z motywami kolorów o wysokim kontraście +Comment[pt]=Um estilo que funciona bem com esquemas de cores de alto contraste +Comment[pt_BR]=Um estilo que funciona bem com esquemas de cor de alto contraste +Comment[ro]=Un stil care se potriveşte cu schemele de culori cu contrast mare +Comment[ru]=Стиль с контрастными цветовыми схемами +Comment[rw]=Imisusire ikorana neza n'ibishushanyombonera by'ibara inyuranyamigaragarire yo hejuru +Comment[se]=Stiila mii doaibmá bures ovttas ivdnečoahkádusaiguin mas leat alla vuostálasvuohta +Comment[sk]=Štýl, ktorý funguje dobre pri schémach s vysokým kontrastom +Comment[sl]=Slog, ki se dobro obnese z visokokontrastnimi shemami +Comment[sr]=Стил који ради са високо контрастним шемама боја +Comment[sr@Latn]=Stil koji radi sa visoko kontrastnim šemama boja +Comment[sv]=En stil som fungerar bra med färgscheman för hög kontrast +Comment[ta]=அதிக மாறுபாட்டு வண்ண அமைப்புகளில் சரியாக இயங்கும் ஒரு பாணி +Comment[te]=ఎక్కువ వ్యత్యాసాల రంగుల పద్దతులతొ బాగా పనిచేయు ఒక శైలి +Comment[tg]=Услуб, ки бо истифодаи нақшаҳо бо рангҳои баландакс соз кор мекунад +Comment[th]=รูปแบบที่ทำงานได้ดีกับชุดสีคอนทราสต์สูง +Comment[tr]=Yüksek kontrast renk şemalarına uygun bir stil +Comment[tt]=Bu tışlaw bik kisken tösle köyläwlärgä yaxşı kileşä +Comment[uk]=Стиль, який підходить до схем кольорів з високою контрастністю +Comment[vi]=Kiểu dáng thích hợp với lược đồ màu có độ tương phản cao. +Comment[zh_CN]=在高对比度配色方案中适用的样式 +Comment[zh_HK]=適用於高反差色彩的佈景 +Comment[zh_TW]=在高彩度下可以使用的風格 +[KDE] +WidgetStyle=HighContrast |