You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1868 lines
54 KiB
1868 lines
54 KiB
15 years ago
|
/*
|
||
|
* 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.
|
||
|
*/
|
||
|
|
||
15 years ago
|
#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>
|
||
15 years ago
|
|
||
14 years ago
|
#include <tqimage.h>
|
||
|
#include <tqapplication.h>
|
||
|
|
||
15 years ago
|
#include <kdrawutil.h>
|
||
|
#include <kpixmapeffect.h>
|
||
|
|
||
|
#include "highcontrast.h"
|
||
|
#include "highcontrast.moc"
|
||
|
|
||
|
// -- Style Plugin Interface -------------------------
|
||
14 years ago
|
class HighContrastStylePlugin : public TQStylePlugin
|
||
15 years ago
|
{
|
||
|
public:
|
||
|
HighContrastStylePlugin() {}
|
||
|
~HighContrastStylePlugin() {}
|
||
|
|
||
15 years ago
|
TQStringList keys() const
|
||
15 years ago
|
{
|
||
15 years ago
|
return TQStringList() << "HighContrast";
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
TQStyle* create( const TQString& key )
|
||
15 years ago
|
{
|
||
|
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;
|
||
|
|
||
|
|
||
15 years ago
|
void addOffset (TQRect* r, int offset, int lineWidth = 0)
|
||
15 years ago
|
{
|
||
|
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()
|
||
12 years ago
|
: TDEStyle( 0, ThreeButtonScrollBar )
|
||
15 years ago
|
{
|
||
15 years ago
|
TQSettings settings;
|
||
15 years ago
|
settings.beginGroup("/highcontraststyle/Settings/");
|
||
|
bool useWideLines = settings.readBoolEntry("wideLines", false);
|
||
|
basicLineWidth = useWideLines ? 4 : 2;
|
||
|
}
|
||
|
|
||
|
|
||
|
HighContrastStyle::~HighContrastStyle()
|
||
|
{
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
void HighContrastStyle::polish( TQPalette& pal )
|
||
15 years ago
|
{
|
||
|
//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
|
||
15 years ago
|
for (int c = 0; c < TQColorGroup::NColorRoles; ++c)
|
||
15 years ago
|
switch (c)
|
||
|
{
|
||
15 years ago
|
case TQColorGroup::Button:
|
||
|
case TQColorGroup::Base:
|
||
|
case TQColorGroup::Highlight:
|
||
|
pal.setColor(TQPalette::Disabled, TQColorGroup::ColorRole(c), pal.color(TQPalette::Active, TQColorGroup::Background));
|
||
15 years ago
|
break;
|
||
15 years ago
|
case TQColorGroup::ButtonText:
|
||
|
case TQColorGroup::Text:
|
||
|
case TQColorGroup::HighlightedText:
|
||
|
pal.setColor(TQPalette::Disabled, TQColorGroup::ColorRole(c), pal.color(TQPalette::Active, TQColorGroup::Foreground));
|
||
15 years ago
|
break;
|
||
|
default:
|
||
15 years ago
|
pal.setColor(TQPalette::Disabled, TQColorGroup::ColorRole(c), pal.color(TQPalette::Active, TQColorGroup::ColorRole(c)));
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void HighContrastStyle::polish (const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr)
|
||
15 years ago
|
{
|
||
12 years ago
|
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);
|
||
|
}
|
||
|
}
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
TDEStyle::polish (ceData, elementFlags, ptr);
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void HighContrastStyle::unPolish (const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr)
|
||
15 years ago
|
{
|
||
12 years ago
|
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);
|
||
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
TDEStyle::unPolish (ceData, elementFlags, ptr);
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::setColorsNormal (TQPainter* p, const TQColorGroup& cg, int flags, int highlight) const
|
||
15 years ago
|
{
|
||
|
setColorsByState (p, cg, cg.foreground(), cg.background(), flags, highlight);
|
||
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::setColorsButton (TQPainter* p, const TQColorGroup& cg, int flags, int highlight) const
|
||
15 years ago
|
{
|
||
|
setColorsByState (p, cg, cg.buttonText(), cg.button(), flags, highlight);
|
||
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::setColorsText (TQPainter* p, const TQColorGroup& cg, int flags, int highlight) const
|
||
15 years ago
|
{
|
||
|
setColorsByState (p, cg, cg.text(), cg.base(), flags, highlight);
|
||
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::setColorsHighlight (TQPainter* p, const TQColorGroup& cg, int flags) const
|
||
15 years ago
|
{
|
||
|
setColorsByState (p, cg, cg.highlightedText(), cg.highlight(), flags, 0);
|
||
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::setColorsByState (TQPainter* p, const TQColorGroup& cg, const TQColor& fg, const TQColor& bg, int flags, int highlight) const
|
||
15 years ago
|
{
|
||
15 years ago
|
TQFont font = p->font();
|
||
15 years ago
|
font.setStrikeOut (! (flags & Style_Enabled));
|
||
|
p->setFont (font);
|
||
|
|
||
|
if ((flags & Style_Enabled) && (flags & highlight))
|
||
|
{
|
||
15 years ago
|
p->setPen (TQPen (cg.highlightedText(), basicLineWidth, flags & Style_Enabled ? Qt::SolidLine : Qt::DotLine));
|
||
15 years ago
|
p->setBackgroundColor (cg.highlight());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
15 years ago
|
p->setPen (TQPen (fg, basicLineWidth, flags & Style_Enabled ? Qt::SolidLine : Qt::DotLine));
|
||
15 years ago
|
p->setBackgroundColor (bg);
|
||
|
}
|
||
|
|
||
15 years ago
|
p->setBrush (TQBrush ());
|
||
15 years ago
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::drawRect (TQPainter* p, TQRect r, int offset, bool filled) const
|
||
15 years ago
|
{
|
||
|
addOffset (&r, offset, p->pen().width());
|
||
|
if (filled)
|
||
|
p->fillRect (r, p->backgroundColor());
|
||
|
|
||
|
p->drawRect (r);
|
||
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::drawRoundRect (TQPainter* p, TQRect r, int offset, bool filled) const
|
||
15 years ago
|
{
|
||
|
int lineWidth = p->pen().width();
|
||
|
if ((r.width() >= 5*lineWidth + 2*offset) && (r.height() >= 5*lineWidth + 2*offset))
|
||
|
{
|
||
15 years ago
|
TQRect r2 (r);
|
||
15 years ago
|
addOffset (&r2, offset, lineWidth);
|
||
|
|
||
|
addOffset (&r, offset);
|
||
15 years ago
|
TQRect r3 (r);
|
||
15 years ago
|
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);
|
||
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::drawEllipse (TQPainter* p, TQRect r, int offset, bool filled) const
|
||
15 years ago
|
{
|
||
|
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);
|
||
|
}
|
||
|
|
||
14 years ago
|
void HighContrastStyle::drawArrow (TQPainter* p, TQRect r, TQ_PrimitiveElement arrow, int offset) const
|
||
15 years ago
|
{
|
||
|
p->save();
|
||
|
addOffset (&r, offset);
|
||
|
|
||
15 years ago
|
TQPoint center = r.center();
|
||
15 years ago
|
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);
|
||
|
|
||
15 years ago
|
TQPointArray points (3);
|
||
15 years ago
|
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
|
||
12 years ago
|
void HighContrastStyle::drawPrimitive (TQ_PrimitiveElement pe,
|
||
15 years ago
|
TQPainter *p,
|
||
12 years ago
|
const TQStyleControlElementData &ceData,
|
||
12 years ago
|
ControlElementFlags elementFlags,
|
||
15 years ago
|
const TQRect &r,
|
||
|
const TQColorGroup &cg,
|
||
15 years ago
|
SFlags flags,
|
||
15 years ago
|
const TQStyleOption& opt ) const
|
||
15 years ago
|
{
|
||
|
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();
|
||
15 years ago
|
p->setBrush (TQBrush ());
|
||
|
p->setPen (TQPen (cg.highlight(), basicLineWidth, Qt::SolidLine));
|
||
15 years ago
|
drawRoundRect (p, r, basicLineWidth, false);
|
||
15 years ago
|
p->setPen (TQPen (cg.highlightedText(), basicLineWidth, Qt::DashLine));
|
||
15 years ago
|
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
|
||
|
// -------------------------------------------------------------------
|
||
13 years ago
|
case PE_HeaderSectionMenu:
|
||
15 years ago
|
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) {
|
||
15 years ago
|
TQRect r2 (r);
|
||
15 years ago
|
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());
|
||
|
|
||
15 years ago
|
TQRect r2 (r);
|
||
15 years ago
|
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);
|
||
15 years ago
|
TQPen pen = p->pen();
|
||
15 years ago
|
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))
|
||
|
{
|
||
15 years ago
|
TQRect r2 (r);
|
||
15 years ago
|
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);
|
||
|
}
|
||
15 years ago
|
TQPen pen = p->pen();
|
||
15 years ago
|
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());
|
||
|
|
||
15 years ago
|
p->setPen (TQPen (p->pen().color(), 1, Qt::DashLine));
|
||
15 years ago
|
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())
|
||
|
{
|
||
15 years ago
|
TQPen pen = p->pen();
|
||
15 years ago
|
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))
|
||
12 years ago
|
drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
|
||
15 years ago
|
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;
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
case PE_MenuItemIndicatorFrame:
|
||
|
{
|
||
|
// Draw nothing
|
||
|
break;
|
||
|
}
|
||
|
break;
|
||
|
case PE_MenuItemIndicatorIconFrame:
|
||
|
{
|
||
|
int x, y, w, h;
|
||
|
r.rect( &x, &y, &w, &h );
|
||
12 years ago
|
int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL);
|
||
|
TQRect cr = visualRect( TQRect(x, y, checkcol, h), r );
|
||
12 years ago
|
drawRect (p, cr, 0, false);
|
||
|
break;
|
||
|
}
|
||
|
case PE_MenuItemIndicatorCheck:
|
||
|
{
|
||
|
int x, y, w, h;
|
||
|
r.rect( &x, &y, &w, &h );
|
||
12 years ago
|
int checkcol = styleHint(SH_MenuIndicatorColumnWidth, ceData, elementFlags, opt, NULL, NULL);
|
||
12 years ago
|
|
||
12 years ago
|
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);
|
||
12 years ago
|
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;
|
||
|
}
|
||
|
|
||
|
|
||
15 years ago
|
// 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: {
|
||
12 years ago
|
TDEStyle::drawPrimitive( pe, p, ceData, elementFlags, r, cg, flags, opt );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
12 years ago
|
void HighContrastStyle::drawTDEStylePrimitive (TDEStylePrimitive kpe,
|
||
15 years ago
|
TQPainter* p,
|
||
12 years ago
|
const TQStyleControlElementData &ceData,
|
||
12 years ago
|
ControlElementFlags elementFlags,
|
||
15 years ago
|
const TQRect &r,
|
||
|
const TQColorGroup &cg,
|
||
15 years ago
|
SFlags flags,
|
||
12 years ago
|
const TQStyleOption &opt,
|
||
|
const TQWidget* widget ) const
|
||
15 years ago
|
{
|
||
|
switch ( kpe )
|
||
|
{
|
||
|
// TOOLBAR HANDLE
|
||
|
// -------------------------------------------------------------------
|
||
|
case KPE_ToolBarHandle:
|
||
|
case KPE_DockWindowHandle:
|
||
|
case KPE_GeneralHandle:
|
||
|
{
|
||
|
setColorsButton (p, cg);
|
||
|
p->fillRect (r, p->backgroundColor());
|
||
15 years ago
|
p->setBrush (TQBrush (p->pen().color(), Qt::BDiagPattern));
|
||
15 years ago
|
drawRoundRect (p, r);
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
|
||
|
// SLIDER GROOVE
|
||
|
// -------------------------------------------------------------------
|
||
|
case KPE_SliderGroove: {
|
||
|
setColorsText (p, cg, flags);
|
||
15 years ago
|
TQRect r2 (r);
|
||
12 years ago
|
if (ceData.widgetObjectTypes.contains(TQSLIDER_OBJECT_NAME_STRING))
|
||
15 years ago
|
{
|
||
12 years ago
|
if (ceData.orientation == TQt::Horizontal)
|
||
15 years ago
|
{
|
||
|
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: {
|
||
13 years ago
|
// TODO There is no pixelMetric associated with the
|
||
12 years ago
|
// ListViewExpander in TDEStyle.
|
||
15 years ago
|
// To have a properly large expander, the CC_ListView case of
|
||
13 years ago
|
// drawComplexControl should be handled.
|
||
15 years ago
|
// Probably it would be better to add a KPM_ListViewExpander metric
|
||
12 years ago
|
// to the TDEStyle TDEStylePixelMetric enum, and have the TDEStyle
|
||
13 years ago
|
// drawComplexControl handle it.
|
||
14 years ago
|
TQ_PrimitiveElement direction;
|
||
15 years ago
|
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:
|
||
12 years ago
|
// TODO Draw (thick) dotted line. Check tdestyle.cpp
|
||
15 years ago
|
// Fall down for now
|
||
|
default:
|
||
12 years ago
|
TDEStyle::drawTDEStylePrimitive( kpe, p, ceData, elementFlags, r, cg, flags, opt, widget);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
|
||
13 years ago
|
void HighContrastStyle::drawControl (TQ_ControlElement element,
|
||
15 years ago
|
TQPainter *p,
|
||
12 years ago
|
const TQStyleControlElementData &ceData,
|
||
12 years ago
|
ControlElementFlags elementFlags,
|
||
15 years ago
|
const TQRect &r,
|
||
|
const TQColorGroup &cg,
|
||
15 years ago
|
SFlags flags,
|
||
12 years ago
|
const TQStyleOption& opt,
|
||
|
const TQWidget *widget ) const
|
||
15 years ago
|
{
|
||
|
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);
|
||
|
|
||
12 years ago
|
TQTabBar::Shape shape = ceData.tabBarData.shape;
|
||
13 years ago
|
if (shape == TQTabBar::TriangularBelow ||
|
||
|
shape == TQTabBar::RoundedBelow) {
|
||
15 years ago
|
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: {
|
||
15 years ago
|
TQPushButton *button = (TQPushButton*) widget;
|
||
|
TQRect br = r;
|
||
12 years ago
|
bool btnDefault = (elementFlags & CEF_IsDefault);
|
||
15 years ago
|
|
||
12 years ago
|
if (( btnDefault || (elementFlags & CEF_AutoDefault) ) && (elementFlags & CEF_IsEnabled)) {
|
||
15 years ago
|
// Compensate for default indicator
|
||
12 years ago
|
static int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags );
|
||
15 years ago
|
addOffset (&br, di);
|
||
|
}
|
||
|
|
||
12 years ago
|
if ( btnDefault && (elementFlags & CEF_IsEnabled))
|
||
12 years ago
|
drawPrimitive( PE_ButtonDefault, p, ceData, elementFlags, r, cg, flags );
|
||
15 years ago
|
|
||
12 years ago
|
drawPrimitive( PE_ButtonCommand, p, ceData, elementFlags, br, cg, flags );
|
||
15 years ago
|
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
|
||
|
// LABEL
|
||
|
// -------------------------------------------------------------------
|
||
|
case CE_ProgressBarLabel:
|
||
|
case CE_TabBarLabel:
|
||
|
case CE_RadioButtonLabel:
|
||
|
case CE_CheckBoxLabel:
|
||
|
case CE_ToolButtonLabel:
|
||
|
case CE_PushButtonLabel: {
|
||
15 years ago
|
const TQPixmap* pixmap = 0;
|
||
|
TQPixmap icon;
|
||
|
TQString text;
|
||
15 years ago
|
bool popup = false;
|
||
|
|
||
15 years ago
|
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;
|
||
15 years ago
|
|
||
|
int x, y, w, h;
|
||
|
r.rect( &x, &y, &w, &h );
|
||
|
|
||
|
if (element == CE_ProgressBarLabel) {
|
||
12 years ago
|
text = ceData.progressText;
|
||
15 years ago
|
setColorsNormal (p, cg, flags);
|
||
|
}
|
||
|
else if (element == CE_TabBarLabel) {
|
||
|
if (!opt.isDefault()) {
|
||
15 years ago
|
TQTab* tab = opt.tab();
|
||
15 years ago
|
text = tab->text();
|
||
|
}
|
||
|
setColorsNormal (p, cg, flags, Style_Selected);
|
||
|
}
|
||
|
else if (element == CE_ToolButtonLabel) {
|
||
12 years ago
|
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);
|
||
15 years ago
|
setColorsButton (p, cg, flags);
|
||
|
}
|
||
|
else if (element == CE_PushButtonLabel) {
|
||
12 years ago
|
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);
|
||
15 years ago
|
setColorsButton (p, cg, flags);
|
||
|
}
|
||
|
else {
|
||
12 years ago
|
pixmap = (ceData.fgPixmap.isNull())?NULL:&ceData.fgPixmap;
|
||
|
text = ceData.text;
|
||
15 years ago
|
setColorsNormal (p, cg);
|
||
|
}
|
||
|
|
||
|
// Does the button have a popup menu?
|
||
|
if (popup) {
|
||
12 years ago
|
int dx = pixelMetric (PM_MenuButtonIndicator, ceData, elementFlags, widget);
|
||
15 years ago
|
drawArrow (p, TQRect(x + w - dx - 2, y + 2, dx, h - 4), PE_ArrowDown);
|
||
15 years ago
|
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)
|
||
12 years ago
|
drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
|
||
15 years ago
|
|
||
|
// Draw the label itself
|
||
15 years ago
|
TQColor color = p->pen().color();
|
||
|
drawItem (p, TQRect(x, y, w, h),
|
||
15 years ago
|
(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()) {
|
||
15 years ago
|
TQMenuItem *mi = opt.menuItem();
|
||
15 years ago
|
|
||
15 years ago
|
TQColor color = p->pen().color();
|
||
15 years ago
|
drawItem (p, r, AlignCenter | AlignVCenter | ShowPrefix
|
||
|
| DontClip | SingleLine, cg, flags,
|
||
|
mi->pixmap(), mi->text(), -1, &color);
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
// CHECKBOX
|
||
|
// -------------------------------------------------------------------
|
||
|
case CE_CheckBox: {
|
||
12 years ago
|
drawPrimitive (PE_Indicator, p, ceData, elementFlags, r, cg, flags);
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
|
||
|
// RADIOBUTTON
|
||
|
// -------------------------------------------------------------------
|
||
|
case CE_RadioButton: {
|
||
12 years ago
|
drawPrimitive (PE_ExclusiveIndicator, p, ceData, elementFlags, r, cg, flags);
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
|
||
|
// PROGRESSBAR
|
||
|
// -------------------------------------------------------------------
|
||
|
case CE_ProgressBarGroove: {
|
||
|
setColorsText (p, cg, flags);
|
||
12 years ago
|
TQRect r2 (r);
|
||
|
r2.setLeft (p->boundingRect (r, AlignVCenter|AlignLeft|ShowPrefix, ceData.progressText).right()
|
||
|
+ 4*basicLineWidth);
|
||
|
drawRoundRect (p, r2);
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
case CE_ProgressBarContents: {
|
||
12 years ago
|
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)
|
||
15 years ago
|
{
|
||
12 years ago
|
r2.setWidth (progress / ceData.totalSteps);
|
||
15 years ago
|
}
|
||
12 years ago
|
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);
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
|
||
|
// POPUPMENU ITEM
|
||
|
// -------------------------------------------------------------------
|
||
|
case CE_PopupMenuItem: {
|
||
|
setColorsNormal (p, cg, flags, Style_Active|Style_MouseOver);
|
||
|
p->fillRect (r, p->backgroundColor ());
|
||
|
|
||
15 years ago
|
TQMenuItem *mi = opt.menuItem();
|
||
15 years ago
|
if (!mi)
|
||
|
break;
|
||
|
|
||
|
int tab = opt.tabWidth();
|
||
|
int checkcol = opt.maxIconWidth();
|
||
12 years ago
|
bool checkable = (elementFlags & CEF_IsCheckable);
|
||
15 years ago
|
bool reverse = TQApplication::reverseLayout();
|
||
15 years ago
|
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() ) {
|
||
15 years ago
|
TQIconSet::Mode mode;
|
||
13 years ago
|
TQRect cr = visualRect( TQRect(x, y, checkcol, h), r );
|
||
15 years ago
|
|
||
|
// Select the correct icon from the iconset
|
||
|
if (!(flags & Style_Enabled))
|
||
15 years ago
|
mode = TQIconSet::Disabled;
|
||
15 years ago
|
else if (flags & Style_Active)
|
||
15 years ago
|
mode = TQIconSet::Active;
|
||
15 years ago
|
else
|
||
15 years ago
|
mode = TQIconSet::Normal;
|
||
15 years ago
|
|
||
|
// Draw the icon
|
||
15 years ago
|
TQPixmap pixmap = mi->iconSet()->pixmap( TQIconSet::Small, mode );
|
||
|
TQRect pmr( 0, 0, pixmap.width(), pixmap.height() );
|
||
15 years ago
|
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() )
|
||
|
{
|
||
12 years ago
|
drawPrimitive(PE_MenuItemIndicatorIconFrame, p, ceData, elementFlags, r, cg, flags, opt);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// Are we checked? (This time without an icon)
|
||
|
else if ( checkable && mi->isChecked() ) {
|
||
12 years ago
|
drawPrimitive(PE_MenuItemIndicatorCheck, p, ceData, elementFlags, r, cg, flags, opt);
|
||
15 years ago
|
}
|
||
|
|
||
|
// 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
|
||
15 years ago
|
TQString s = mi->text();
|
||
15 years ago
|
|
||
|
// Does the menu item have a text label?
|
||
|
if ( !s.isNull() ) {
|
||
13 years ago
|
int t = s.find( '\t' );
|
||
15 years ago
|
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() ) {
|
||
15 years ago
|
TQPixmap *pixmap = mi->pixmap();
|
||
15 years ago
|
|
||
|
// Draw the pixmap
|
||
|
if ( pixmap->depth() == 1 )
|
||
14 years ago
|
p->setBackgroundMode( Qt::OpaqueMode );
|
||
15 years ago
|
|
||
|
int diffw = ( ( w - pixmap->width() ) / 2 )
|
||
|
+ ( ( w - pixmap->width() ) % 2 );
|
||
|
p->drawPixmap( x+diffw, y+itemFrame, *pixmap );
|
||
|
|
||
|
if ( pixmap->depth() == 1 )
|
||
14 years ago
|
p->setBackgroundMode( Qt::TransparentMode );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// Does the menu item have a submenu?
|
||
|
if ( mi->popup() ) {
|
||
14 years ago
|
TQ_PrimitiveElement arrow = reverse ? PE_ArrowLeft : PE_ArrowRight;
|
||
12 years ago
|
int dim = pixelMetric(PM_MenuButtonIndicator, ceData, elementFlags);
|
||
13 years ago
|
TQRect vr = visualRect( TQRect( x + w - arrowHMargin - 2*itemFrame - dim,
|
||
15 years ago
|
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:
|
||
12 years ago
|
TDEStyle::drawControl(element, p, ceData, elementFlags, r, cg, flags, opt, widget);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
void HighContrastStyle::drawControlMask (TQ_ControlElement element,
|
||
15 years ago
|
TQPainter *p,
|
||
12 years ago
|
const TQStyleControlElementData &ceData,
|
||
12 years ago
|
ControlElementFlags elementFlags,
|
||
15 years ago
|
const TQRect &r,
|
||
12 years ago
|
const TQStyleOption &opt,
|
||
|
const TQWidget *w) const
|
||
15 years ago
|
{
|
||
|
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: {
|
||
12 years ago
|
TDEStyle::drawControlMask (element, p, ceData, elementFlags, r, opt, w);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
14 years ago
|
// Helper to find the next sibling that's not hidden
|
||
12 years ago
|
// Lifted from tdestyle.cpp
|
||
15 years ago
|
static TQListViewItem* nextVisibleSibling(TQListViewItem* item)
|
||
15 years ago
|
{
|
||
15 years ago
|
TQListViewItem* sibling = item;
|
||
15 years ago
|
do
|
||
|
{
|
||
|
sibling = sibling->nextSibling();
|
||
|
}
|
||
|
while (sibling && !sibling->isVisible());
|
||
|
|
||
|
return sibling;
|
||
|
}
|
||
|
|
||
13 years ago
|
void HighContrastStyle::drawComplexControl (TQ_ComplexControl control,
|
||
15 years ago
|
TQPainter *p,
|
||
12 years ago
|
const TQStyleControlElementData &ceData,
|
||
12 years ago
|
ControlElementFlags elementFlags,
|
||
15 years ago
|
const TQRect &r,
|
||
|
const TQColorGroup &cg,
|
||
15 years ago
|
SFlags flags,
|
||
|
SCFlags controls,
|
||
|
SCFlags active,
|
||
12 years ago
|
const TQStyleOption& opt,
|
||
|
const TQWidget *widget ) const
|
||
15 years ago
|
{
|
||
|
switch(control)
|
||
|
{
|
||
|
// COMBOBOX
|
||
|
// -------------------------------------------------------------------
|
||
|
case CC_ComboBox: {
|
||
|
setColorsText (p, cg, flags);
|
||
|
drawRoundRect (p, r);
|
||
|
|
||
12 years ago
|
TQRect r2 = TQStyle::visualRect (querySubControlMetrics (CC_ComboBox, ceData, elementFlags, SC_ComboBoxArrow, TQStyleOption::Default, widget), ceData, elementFlags);
|
||
15 years ago
|
if (flags & Style_HasFocus) {
|
||
15 years ago
|
TQRect r3 (r);
|
||
15 years ago
|
if (r2.left() > 0)
|
||
|
r3.setRight (r2.left()+basicLineWidth-1);
|
||
|
else
|
||
|
r3.setLeft (r2.right()-basicLineWidth+1);
|
||
|
|
||
12 years ago
|
drawPrimitive (PE_FocusRect, p, ceData, elementFlags, r3, cg, flags, TQStyleOption (p->backgroundColor()));
|
||
15 years ago
|
}
|
||
|
|
||
|
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)
|
||
12 years ago
|
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, r, cg, flags, TQStyleOption (p->backgroundColor()));
|
||
15 years ago
|
}
|
||
|
|
||
|
setColorsButton (p, cg, flags);
|
||
|
// Draw arrows if required
|
||
|
if (controls & SC_SpinWidgetDown) {
|
||
12 years ago
|
TQRect r2 = TQStyle::visualRect (querySubControlMetrics ((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags, SC_SpinWidgetDown, TQStyleOption::Default, widget), ceData, elementFlags);
|
||
15 years ago
|
drawRoundRect (p, r2);
|
||
|
drawArrow (p, r2, PE_SpinWidgetDown, 2*basicLineWidth);
|
||
|
}
|
||
|
if (controls & SC_SpinWidgetUp) {
|
||
12 years ago
|
TQRect r2 = TQStyle::visualRect (querySubControlMetrics ((TQ_ComplexControl)CC_SpinWidget, ceData, elementFlags, SC_SpinWidgetUp, TQStyleOption::Default, widget), ceData, elementFlags);
|
||
15 years ago
|
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 ());
|
||
|
|
||
15 years ago
|
TQRect button, menuarea;
|
||
12 years ago
|
button = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButton, opt, widget);
|
||
|
menuarea = querySubControlMetrics(control, ceData, elementFlags, SC_ToolButtonMenu, opt, widget);
|
||
15 years ago
|
|
||
|
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))
|
||
12 years ago
|
drawPrimitive(PE_ButtonTool, p, ceData, elementFlags, button, cg, bflags, opt);
|
||
15 years ago
|
|
||
|
// Check whether to draw a background pixmap
|
||
12 years ago
|
else if ( !ceData.parentWidgetData.bgPixmap.isNull() )
|
||
15 years ago
|
{
|
||
12 years ago
|
TQPixmap pixmap = ceData.parentWidgetData.bgPixmap;
|
||
|
p->drawTiledPixmap( r, pixmap, ceData.pos );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// Draw a toolbutton menu indicator if required
|
||
|
if (controls & SC_ToolButtonMenu)
|
||
|
{
|
||
|
if (mflags & (Style_Down | Style_On | Style_Raised))
|
||
12 years ago
|
drawPrimitive(PE_ButtonDropDown, p, ceData, elementFlags, menuarea, cg, mflags, opt);
|
||
15 years ago
|
drawArrow (p, menuarea, PE_ArrowDown);
|
||
|
}
|
||
|
|
||
12 years ago
|
if ((elementFlags & CEF_HasFocus) && !(elementFlags & CEF_HasFocusProxy)) {
|
||
|
TQRect fr = ceData.rect;
|
||
15 years ago
|
addOffset (&fr, 3);
|
||
12 years ago
|
drawPrimitive(PE_FocusRect, p, ceData, elementFlags, fr, cg, flags, TQStyleOption (p->backgroundColor()));
|
||
15 years ago
|
}
|
||
|
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
// LISTVIEW
|
||
|
// -------------------------------------------------------------------
|
||
|
case CC_ListView: {
|
||
|
/*
|
||
12 years ago
|
* Sigh... Lifted and modified from tdestyle.cpp
|
||
15 years ago
|
*/
|
||
|
/*
|
||
15 years ago
|
* Many thanks to TrollTech AS for donating CC_ListView from TQWindowsStyle.
|
||
15 years ago
|
* CC_ListView code is Copyright (C) 1998-2000 TrollTech AS.
|
||
|
*/
|
||
|
|
||
|
// Paint the icon and text.
|
||
|
if ( controls & SC_ListView )
|
||
12 years ago
|
TQCommonStyle::drawComplexControl( control, p, ceData, elementFlags, r, cg, flags, controls, active, opt, widget );
|
||
15 years ago
|
|
||
|
// 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;
|
||
|
|
||
15 years ago
|
TQListViewItem *item = opt.listViewItem();
|
||
|
TQListViewItem *child = item->firstChild();
|
||
15 years ago
|
|
||
|
int y = r.y();
|
||
|
int c; // dotline vertice count
|
||
|
int dotoffset = 0;
|
||
15 years ago
|
TQPointArray dotlines;
|
||
15 years ago
|
|
||
|
if ( active == SC_All && controls == SC_ListViewExpand ) {
|
||
|
// We only need to draw a vertical line
|
||
|
c = 2;
|
||
|
dotlines.resize(2);
|
||
15 years ago
|
dotlines[0] = TQPoint( r.right(), r.top() );
|
||
|
dotlines[1] = TQPoint( r.right(), r.bottom() );
|
||
15 years ago
|
|
||
|
} 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
|
||
15 years ago
|
TQListView* v = item->listView();
|
||
15 years ago
|
int lh = QMAX( p->fontMetrics().height() + 2 * v->itemMargin(),
|
||
15 years ago
|
TQApplication::globalStrut().height() );
|
||
15 years ago
|
if ( lh % 2 > 0 )
|
||
|
lh++;
|
||
|
|
||
|
// Draw all the expand/close boxes...
|
||
15 years ago
|
TQRect boxrect;
|
||
|
TQStyle::StyleFlags boxflags;
|
||
15 years ago
|
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.
|
||
15 years ago
|
boxrect = TQRect( bx-h/2, linebot-h/2, h, h );
|
||
|
boxflags = child->isOpen() ? TQStyle::Style_Off : TQStyle::Style_On;
|
||
15 years ago
|
|
||
12 years ago
|
// TDEStyle extension: Draw the box and expand/collapse indicator
|
||
|
drawTDEStylePrimitive( KPE_ListViewExpander, p, ceData, elementFlags, boxrect, cg, boxflags, opt, NULL );
|
||
15 years ago
|
|
||
|
// dotlinery
|
||
|
p->setPen( cg.mid() );
|
||
15 years ago
|
dotlines[c++] = TQPoint( bx, linetop );
|
||
|
dotlines[c++] = TQPoint( bx, linebot - 5 );
|
||
|
dotlines[c++] = TQPoint( bx + 5, linebot );
|
||
|
dotlines[c++] = TQPoint( r.width(), linebot );
|
||
15 years ago
|
linetop = linebot + 5;
|
||
|
} else {
|
||
|
// just dotlinery
|
||
15 years ago
|
dotlines[c++] = TQPoint( bx+1, linebot );
|
||
|
dotlines[c++] = TQPoint( r.width(), linebot );
|
||
15 years ago
|
}
|
||
|
|
||
|
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 )
|
||
|
{
|
||
15 years ago
|
dotlines[c++] = TQPoint( bx, linetop );
|
||
|
dotlines[c++] = TQPoint( bx, linebot );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
|
// Draw all the branches...
|
||
12 years ago
|
static int thickness = kPixelMetric( KPM_ListViewBranchThickness, ceData, elementFlags );
|
||
15 years ago
|
int line; // index into dotlines
|
||
15 years ago
|
TQRect branchrect;
|
||
|
TQStyle::StyleFlags branchflags;
|
||
15 years ago
|
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();
|
||
|
|
||
15 years ago
|
branchrect = TQRect( point, other-(thickness/2), end-point, thickness );
|
||
|
branchflags = TQStyle::Style_Horizontal;
|
||
15 years ago
|
|
||
12 years ago
|
// TDEStyle extension: Draw the horizontal branch
|
||
|
drawTDEStylePrimitive( KPE_ListViewBranch, p, ceData, elementFlags, branchrect, cg, branchflags, opt, NULL );
|
||
15 years ago
|
|
||
|
} 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;
|
||
|
|
||
15 years ago
|
branchrect = TQRect( other-(thickness/2), point, thickness, end-point );
|
||
15 years ago
|
if (!pixmapoffset) // ### Hackish - used to hint the offset
|
||
15 years ago
|
branchflags = TQStyle::Style_NoChange;
|
||
15 years ago
|
else
|
||
15 years ago
|
branchflags = TQStyle::Style_Default;
|
||
15 years ago
|
|
||
12 years ago
|
// TDEStyle extension: Draw the vertical branch
|
||
|
drawTDEStylePrimitive( KPE_ListViewBranch, p, ceData, elementFlags, branchrect, cg, branchflags, opt, NULL );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
default:
|
||
12 years ago
|
TDEStyle::drawComplexControl(control, p, ceData, elementFlags,
|
||
12 years ago
|
r, cg, flags, controls, active, opt, widget);
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
}
|
||
|
|
||
13 years ago
|
void HighContrastStyle::drawComplexControlMask(TQ_ComplexControl c,
|
||
15 years ago
|
TQPainter *p,
|
||
12 years ago
|
const TQStyleControlElementData &ceData,
|
||
12 years ago
|
const ControlElementFlags elementFlags,
|
||
15 years ago
|
const TQRect &r,
|
||
12 years ago
|
const TQStyleOption &o,
|
||
|
const TQWidget *w) const
|
||
15 years ago
|
{
|
||
|
switch (c) {
|
||
|
case CC_SpinWidget:
|
||
|
case CC_ToolButton:
|
||
|
case CC_ComboBox: {
|
||
|
p->fillRect (r, color0);
|
||
|
break;
|
||
|
}
|
||
|
default: {
|
||
12 years ago
|
TDEStyle::drawComplexControlMask (c, p, ceData, elementFlags, r, o, w);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
15 years ago
|
void HighContrastStyle::drawItem( TQPainter *p,
|
||
|
const TQRect &r,
|
||
15 years ago
|
int flags,
|
||
15 years ago
|
const TQColorGroup &cg,
|
||
15 years ago
|
bool enabled,
|
||
15 years ago
|
const TQPixmap *pixmap,
|
||
|
const TQString &text,
|
||
15 years ago
|
int len,
|
||
15 years ago
|
const TQColor *penColor ) const
|
||
15 years ago
|
{
|
||
|
p->save();
|
||
|
|
||
|
// make the disabled things use the cross-line
|
||
15 years ago
|
TQFont font = p->font();
|
||
15 years ago
|
font.setStrikeOut (!enabled);
|
||
|
p->setFont (font);
|
||
|
|
||
|
enabled = true; //do not ghost it in Qt
|
||
|
|
||
12 years ago
|
TDEStyle::drawItem (p, r, flags, cg, enabled, pixmap, text, len, penColor);
|
||
15 years ago
|
|
||
|
p->restore();
|
||
|
}
|
||
|
|
||
14 years ago
|
TQRect HighContrastStyle::querySubControlMetrics( TQ_ComplexControl control,
|
||
12 years ago
|
const TQStyleControlElementData &ceData,
|
||
12 years ago
|
ControlElementFlags elementFlags,
|
||
15 years ago
|
SubControl subcontrol,
|
||
12 years ago
|
const TQStyleOption& opt,
|
||
|
const TQWidget* widget ) const
|
||
15 years ago
|
{
|
||
|
switch (control)
|
||
|
{
|
||
|
case CC_ComboBox : {
|
||
12 years ago
|
int arrow = pixelMetric (PM_ScrollBarExtent, ceData, elementFlags, widget);
|
||
15 years ago
|
switch (subcontrol)
|
||
|
{
|
||
|
case SC_ComboBoxFrame:
|
||
12 years ago
|
return TQRect (0, 0, ceData.rect.width(), ceData.rect.height());
|
||
15 years ago
|
case SC_ComboBoxArrow:
|
||
12 years ago
|
return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height());
|
||
15 years ago
|
case SC_ComboBoxEditField:
|
||
15 years ago
|
return TQRect (2*basicLineWidth, 2*basicLineWidth,
|
||
12 years ago
|
ceData.rect.width() - arrow - 3*basicLineWidth, ceData.rect.height() - 4*basicLineWidth);
|
||
15 years ago
|
|
||
|
default: break;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
case CC_SpinWidget : {
|
||
12 years ago
|
int arrow = pixelMetric (PM_ScrollBarExtent, ceData, elementFlags, 0);
|
||
15 years ago
|
switch (subcontrol)
|
||
|
{
|
||
|
case SC_SpinWidgetFrame:
|
||
12 years ago
|
return TQRect (0, 0, ceData.rect.width(), ceData.rect.height());
|
||
15 years ago
|
case SC_SpinWidgetButtonField:
|
||
12 years ago
|
return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height());
|
||
15 years ago
|
case SC_SpinWidgetUp:
|
||
12 years ago
|
return TQRect (ceData.rect.width() - arrow, 0, arrow, ceData.rect.height()/2);
|
||
15 years ago
|
case SC_SpinWidgetDown:
|
||
12 years ago
|
return TQRect (ceData.rect.width() - arrow, ceData.rect.height()/2,
|
||
|
arrow, ceData.rect.height()-ceData.rect.height()/2);
|
||
15 years ago
|
case SC_SpinWidgetEditField:
|
||
15 years ago
|
return TQRect (2*basicLineWidth, 2*basicLineWidth,
|
||
12 years ago
|
ceData.rect.width() - arrow - 3*basicLineWidth, ceData.rect.height() - 4*basicLineWidth);
|
||
15 years ago
|
|
||
|
default: break;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
default: break;
|
||
|
}
|
||
|
|
||
12 years ago
|
return TDEStyle::querySubControlMetrics (control, ceData, elementFlags, subcontrol, opt, widget);
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
12 years ago
|
int HighContrastStyle::pixelMetric(PixelMetric m, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQWidget *widget) const
|
||
15 years ago
|
{
|
||
|
//### 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: {
|
||
12 years ago
|
if ((widget != 0) && !(elementFlags & CEF_IsEnabled))
|
||
15 years ago
|
return 0;
|
||
|
else
|
||
|
return 2*basicLineWidth;
|
||
|
}
|
||
|
|
||
|
case PM_ButtonShiftHorizontal:
|
||
|
case PM_ButtonShiftVertical:
|
||
|
return 0;
|
||
|
|
||
|
case PM_ScrollBarExtent: {
|
||
|
int h = 0;
|
||
|
if (widget != 0)
|
||
12 years ago
|
h = (2*TQFontMetrics(ceData.font).lineSpacing())/3;
|
||
15 years ago
|
|
||
|
if (h > 9*basicLineWidth+4)
|
||
|
return h;
|
||
|
else
|
||
|
return 9*basicLineWidth+4;
|
||
|
}
|
||
|
|
||
|
case PM_DefaultFrameWidth: {
|
||
12 years ago
|
if (widget && (ceData.widgetObjectTypes.contains (TQLINEEDIT_OBJECT_NAME_STRING) || ceData.widgetObjectTypes.contains (TQTEXTEDIT_OBJECT_NAME_STRING)))
|
||
15 years ago
|
return 2*basicLineWidth;
|
||
|
else
|
||
|
return basicLineWidth;
|
||
|
}
|
||
|
|
||
|
case PM_SpinBoxFrameWidth: {
|
||
|
return 2*basicLineWidth;
|
||
|
}
|
||
|
|
||
|
case PM_MenuButtonIndicator: { // Arrow width
|
||
|
int h = 0;
|
||
|
if (widget != 0)
|
||
12 years ago
|
h = TQFontMetrics(ceData.font).lineSpacing()/2;
|
||
15 years ago
|
|
||
|
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)
|
||
12 years ago
|
h = TQFontMetrics(ceData.font).lineSpacing()-2*basicLineWidth;
|
||
15 years ago
|
|
||
|
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)
|
||
12 years ago
|
w = TQFontMetrics(ceData.font).lineSpacing()/4;
|
||
15 years ago
|
if (w > 5*basicLineWidth)
|
||
|
return w;
|
||
|
else
|
||
|
return 5*basicLineWidth;
|
||
|
}
|
||
|
|
||
12 years ago
|
case PM_MenuIndicatorFrameHBorder:
|
||
|
case PM_MenuIndicatorFrameVBorder:
|
||
|
case PM_MenuIconIndicatorFrameHBorder:
|
||
|
case PM_MenuIconIndicatorFrameVBorder:
|
||
|
return 0;
|
||
|
|
||
15 years ago
|
default:
|
||
12 years ago
|
return TDEStyle::pixelMetric(m, ceData, elementFlags, widget);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
int HighContrastStyle::kPixelMetric( TDEStylePixelMetric kpm, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQWidget *widget ) const
|
||
15 years ago
|
{
|
||
|
switch (kpm) {
|
||
|
case KPM_ListViewBranchThickness:
|
||
|
// XXX Proper support of thick branches requires reimplementation of
|
||
12 years ago
|
// the drawTDEStylePrimitive KPE_ListViewBranch case.
|
||
15 years ago
|
return basicLineWidth;
|
||
|
default:
|
||
12 years ago
|
return TDEStyle::kPixelMetric(kpm, ceData, elementFlags, widget);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
TQSize HighContrastStyle::sizeFromContents( ContentsType contents,
|
||
12 years ago
|
const TQStyleControlElementData &ceData,
|
||
12 years ago
|
ControlElementFlags elementFlags,
|
||
15 years ago
|
const TQSize &contentSize,
|
||
12 years ago
|
const TQStyleOption& opt,
|
||
|
const TQWidget* widget ) const
|
||
15 years ago
|
{
|
||
|
switch (contents)
|
||
|
{
|
||
|
// PUSHBUTTON SIZE
|
||
|
// ------------------------------------------------------------------
|
||
|
case CT_PushButton: {
|
||
15 years ago
|
const TQPushButton* button = (const TQPushButton*) widget;
|
||
15 years ago
|
int w = contentSize.width();
|
||
|
int h = contentSize.height();
|
||
12 years ago
|
int bm = pixelMetric( PM_ButtonMargin, ceData, elementFlags, widget );
|
||
|
int fw = pixelMetric( PM_DefaultFrameWidth, ceData, elementFlags, widget ) * 2;
|
||
15 years ago
|
|
||
|
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
|
||
12 years ago
|
int di = pixelMetric( PM_ButtonDefaultIndicator, ceData, elementFlags );
|
||
15 years ago
|
w += di * 2;
|
||
|
h += di * 2;
|
||
|
}
|
||
|
|
||
|
if ( h < 22 )
|
||
|
h = 22;
|
||
|
|
||
15 years ago
|
return TQSize( w + basicLineWidth*2, h + basicLineWidth*2 );
|
||
15 years ago
|
}
|
||
|
|
||
|
// TOOLBUTTON SIZE
|
||
|
// -----------------------------------------------------------------
|
||
|
case CT_ToolButton: {
|
||
|
int w = contentSize.width();
|
||
|
int h = contentSize.height();
|
||
15 years ago
|
return TQSize(w + basicLineWidth*2 + 6, h + basicLineWidth*2 + 5);
|
||
15 years ago
|
break;
|
||
|
}
|
||
|
|
||
|
// COMBOBOX SIZE
|
||
|
// -----------------------------------------------------------------
|
||
|
case CT_ComboBox: {
|
||
15 years ago
|
const TQComboBox *cb = static_cast< const TQComboBox* > (widget);
|
||
15 years ago
|
int borderSize = (cb->editable() ? 4 : 2) * basicLineWidth;
|
||
12 years ago
|
int arrowSize = pixelMetric (PM_ScrollBarExtent, ceData, elementFlags, cb);
|
||
15 years ago
|
return TQSize(borderSize + basicLineWidth + arrowSize, borderSize) + contentSize;
|
||
15 years ago
|
}
|
||
|
|
||
|
// POPUPMENU ITEM SIZE
|
||
|
// -----------------------------------------------------------------
|
||
|
case CT_PopupMenuItem: {
|
||
|
if ( ! widget || opt.isDefault() )
|
||
|
return contentSize;
|
||
|
|
||
15 years ago
|
const TQPopupMenu *popup = (const TQPopupMenu *) widget;
|
||
15 years ago
|
bool checkable = popup->isCheckable();
|
||
15 years ago
|
TQMenuItem *mi = opt.menuItem();
|
||
15 years ago
|
int maxpmw = opt.maxIconWidth();
|
||
|
int w = contentSize.width(), h = contentSize.height();
|
||
|
|
||
|
if ( mi->custom() ) {
|
||
13 years ago
|
w = mi->custom()->sizeHint().width();
|
||
|
h = mi->custom()->sizeHint().height();
|
||
15 years ago
|
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(
|
||
15 years ago
|
TQIconSet::Small, TQIconSet::Normal).height() +
|
||
15 years ago
|
2 * itemFrame );
|
||
|
}
|
||
|
|
||
13 years ago
|
if ( ! mi->text().isNull() && mi->text().find('\t') >= 0 )
|
||
15 years ago
|
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;
|
||
|
|
||
15 years ago
|
return TQSize( w, h );
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
// LINEDIT SIZE
|
||
|
// -----------------------------------------------------------------
|
||
|
case CT_LineEdit: {
|
||
15 years ago
|
return contentSize + TQSize (4*basicLineWidth, 4*basicLineWidth);
|
||
15 years ago
|
}
|
||
|
|
||
|
|
||
|
default:
|
||
12 years ago
|
return TDEStyle::sizeFromContents( contents, ceData, elementFlags, contentSize, opt, widget );
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
TQRect HighContrastStyle::subRect (SubRect subrect, const TQStyleControlElementData &ceData, const ControlElementFlags elementFlags, const TQWidget * widget) const
|
||
15 years ago
|
{
|
||
|
switch (subrect) {
|
||
|
case SR_ProgressBarGroove:
|
||
|
case SR_ProgressBarContents:
|
||
|
case SR_ProgressBarLabel:
|
||
12 years ago
|
return ceData.rect;
|
||
15 years ago
|
default:
|
||
12 years ago
|
return TDEStyle::subRect (subrect, ceData, elementFlags, widget);
|
||
15 years ago
|
}
|
||
|
}
|
||
|
|
||
12 years ago
|
bool HighContrastStyle::objectEventHandler( const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void* source, TQEvent *event )
|
||
15 years ago
|
{
|
||
12 years ago
|
return TDEStyle::objectEventHandler (ceData, elementFlags, source, event);
|
||
15 years ago
|
}
|
||
|
|
||
12 years ago
|
/*! \reimp */
|
||
12 years ago
|
int HighContrastStyle::styleHint(StyleHint sh, const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, const TQStyleOption &opt, TQStyleHintReturn *returnData, const TQWidget *w) const
|
||
12 years ago
|
{
|
||
|
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:
|
||
12 years ago
|
ret = TDEStyle::styleHint(sh, ceData, elementFlags, opt, returnData, w);
|
||
12 years ago
|
break;
|
||
|
}
|
||
|
|
||
|
return ret;
|
||
|
}
|
||
|
|
||
15 years ago
|
// vim: set noet ts=4 sw=4:
|
||
14 years ago
|
// kate: indent-width 4; replace-tabs off; smart-indent on; tab-width 4;
|