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.
tde-style-lipstik/style/lipstik.cpp

4102 lines
167 KiB

/* Lipstik widget style for TDE
Copyright (C) 2004-2007 Patrice Tremblay <poplixos@gmail.com>
http://www.poplix.info/lipstik
based on Plastik:
Copyright (C) 2003 Sandro Giessl <ceebx@users.sourceforge.net>
based on the TDE style "dotNET":
Copyright (C) 2001-2002, Chris Lee <clee@kde.org>
Carsten Pfeiffer <pfeiffer@kde.org>
Karol Szwed <gallium@kde.org>
Drawing routines completely reimplemented from KDE3 HighColor, which was
originally based on some stuff from the KDE2 HighColor.
based on drawing routines of the style "Keramik":
Copyright (c) 2002 Malte Starostik <malte@kde.org>
(c) 2002,2003 Maksim Orlovich <mo002j@mail.rochester.edu>
based on the TDE HighColor Style
Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org>
(C) 2001-2002 Fredrik H<>glund <fredrik@kde.org>
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>
Progressbar code based on TDEStyle,
Copyright (C) 2001-2002 Karol Szwed <gallium@kde.org>
...also based on plastikq, krisp, comix, motifplus, polyester, qtcurve...
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 <tqimage.h>
#include <tqstylefactory.h>
#include <tqpointarray.h>
#include <tqpainter.h>
#include <tqtabbar.h>
#include <tqprogressbar.h>
#include <tqcheckbox.h>
#include <tqcombobox.h>
#include <tqcleanuphandler.h>
#include <tqheader.h>
#include <tqlineedit.h>
#include <tqlistbox.h>
#include <tqscrollbar.h>
#include <tqstyleplugin.h>
#include <tqpushbutton.h>
#include <tqtabwidget.h>
#include <tqtimer.h>
#include <tqtoolbutton.h>
#include <tqtoolbar.h>
#include <tqmenubar.h>
#include <tqpopupmenu.h>
#include <tqdrawutil.h>
#include <tqapplication.h>
#include <tqvariant.h>
#include <tqradiobutton.h>
#include <tqregion.h>
#include <tqslider.h>
#include <tqsettings.h>
#include <kpixmap.h>
#include "lipstik.h"
#include "lipstik.moc"
#include "misc.h"
// some bitmaps for the radio button so it's easier to handle the circle stuff...
// 13x13
static const unsigned char radiobutton_mask_bits[] = {
0xf8, 0x03, 0xfc, 0x07, 0xfe, 0x0f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f,
0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xff, 0x1f, 0xfe, 0x0f, 0xfc, 0x07,
0xf8, 0x03};
static const unsigned char radiobutton_contour_bits[] = {
0xf0, 0x01, 0x0c, 0x06, 0x02, 0x08, 0x02, 0x08, 0x01, 0x10, 0x01, 0x10,
0x01, 0x10, 0x01, 0x10, 0x01, 0x10, 0x02, 0x08, 0x02, 0x08, 0x0c, 0x06,
0xf0, 0x01};
static const unsigned char radiobutton_aa_inside_bits[] = {
0x00, 0x00, 0x10, 0x01, 0x04, 0x04, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x02, 0x08, 0x00, 0x00, 0x04, 0x04, 0x10, 0x01,
0x00, 0x00};
static const unsigned char radiobutton_aa_outside_bits[] = {
0x08, 0x02, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x10, 0x00, 0x00, 0x00, 0x00,
0x08, 0x02};
static const unsigned char radiobutton_highlight1_bits[] = {
0x00, 0x00, 0xf0, 0x01, 0x1c, 0x07, 0x04, 0x04, 0x06, 0x0c, 0x02, 0x08,
0x02, 0x08, 0x02, 0x08, 0x06, 0x0c, 0x04, 0x04, 0x1c, 0x07, 0xf0, 0x01,
0x00, 0x00};
static const unsigned char radiobutton_highlight2_bits[] = {
0x00, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x18, 0x03, 0x08, 0x02, 0x04, 0x04,
0x04, 0x04, 0x04, 0x04, 0x08, 0x02, 0x18, 0x03, 0xe0, 0x00, 0x00, 0x00,
0x00, 0x00};
// check mark
const uint CHECKMARKSIZE = 9; // 9x9
static const unsigned char checkmark_aa_bits[] = {
0x45, 0x01, 0x28, 0x00, 0x11, 0x01, 0x82, 0x00, 0x44, 0x00, 0x82, 0x00,
0x11, 0x01, 0x28, 0x00, 0x45, 0x01};
static const unsigned char checkmark_dark_bits[] = {
0x82, 0x00, 0x45, 0x01, 0xaa, 0x00, 0x54, 0x00, 0x28, 0x00, 0x74, 0x00,
0xea, 0x00, 0xc5, 0x01, 0x82, 0x00};
static const unsigned char checkmark_light_bits[] = {
0x00, 0xfe, 0x82, 0xfe, 0x44, 0xfe, 0x28, 0xfe, 0x10, 0xfe, 0x08, 0xfe,
0x04, 0xfe, 0x02, 0xfe, 0x00, 0xfe};
static const unsigned char checkmark_tristate_bits[] = {
0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0xff, 0x01, 0x00, 0x00, 0xff, 0x01,
0x00, 0x00, 0xff, 0x01, 0x00, 0x00};
// radio mark
const uint RADIOMARKSIZE = 9; // 9x9
static const unsigned char radiomark_aa_bits[] = {
0x00, 0x00, 0x44, 0x00, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x82, 0x00, 0x44, 0x00, 0x00, 0x00};
static const unsigned char radiomark_dark_bits[] = {
0x00, 0x00, 0x38, 0x00, 0x44, 0x00, 0xf2, 0x00, 0xfa, 0x00, 0xfa, 0x00,
0x7c, 0x00, 0x38, 0x00, 0x00, 0x00};
static const unsigned char radiomark_light_bits[] = {
0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x0c, 0x00, 0x04, 0x00, 0x04, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
// popupmenu item constants...
static const int itemHMargin = 6;
static const int itemFrame = 2;
static const int arrowHMargin = 6;
static const int rightBorder = 12;
// -- Style Plugin Interface -------------------------
class LipstikStylePlugin : public TQStylePlugin
{
public:
LipstikStylePlugin() {}
~LipstikStylePlugin() {}
TQStringList keys() const {
return TQStringList() << "Lipstik";
}
TQStyle* create( const TQString& key ) {
if (key.lower() == "lipstik")
return new LipstikStyle;
return 0;
}
};
TQ_EXPORT_PLUGIN( LipstikStylePlugin )
// -- end --
LipstikStyle::LipstikStyle() : TDEStyle( AllowMenuTransparency, ThreeButtonScrollBar),
kickerMode(false),
kornMode(false),
flatMode(false)
{
horizontalDots = 0;
verticalDots = 0;
horizontalLine = 0;
verticalLine = 0;
TQSettings settings;
_contrast = settings.readNumEntry("/TQt/KDE/contrast", 6);
_defaultMenuStripeColor.setNamedColor( settings.readEntry("/TQt/KWinPalette/activeBackground", "black") );
settings.beginGroup("/lipstikstyle/Settings");
_animateProgressBar = settings.readBoolEntry("/animateProgressBar", false);
_drawToolBarSeparator = settings.readBoolEntry("/drawToolBarSeparator", true);
_drawToolBarGradient = settings.readBoolEntry("/drawToolBarGradient", false);
_invertBarGrad = settings.readBoolEntry("/invertBarGrad", true);
_drawToolBarItemSeparator = settings.readBoolEntry("/drawToolBarItemSeparator", true);
_drawFocusRect = settings.readBoolEntry("/drawFocusRect", true);
_drawTriangularExpander = settings.readBoolEntry("/drawTriangularExpander", false);
_inputFocusHighlight = settings.readBoolEntry("/inputFocusHighlight", true);
_customOverHighlightColor = settings.readBoolEntry("/customOverHighlightColor", false);
_overHighlightColor.setNamedColor( settings.readEntry("/overHighlightColor", "black") );
_customFocusHighlightColor = settings.readBoolEntry("/customFocusHighlightColor", false);
_focusHighlightColor.setNamedColor( settings.readEntry("/focusHighlightColor", "black") );
_customCheckMarkColor = settings.readBoolEntry("/customCheckMarkColor", false);
_checkMarkColor.setNamedColor( settings.readEntry("/checkMarkColor", "black") );
_customTabHighlightColor = settings.readBoolEntry("/customTabHighlightColor", false);
_tabHighlightColor.setNamedColor( settings.readEntry("/tabHighlightColor", "black") );
_menuSpacing = settings.readNumEntry("/menuSpacing", 5);
_toolBarSpacing = settings.readNumEntry("/toolBarSpacing", 0);
_drawStatusBarFrame = settings.readBoolEntry("/drawStatusBarFrame", false);
_scrollBarStyle = settings.readEntry("/scrollBarStyle", "WindowsStyleScrollBar");
_scrollBarWidth = settings.readEntry("/scrollBarWidth", "Small");
_paintGroove = settings.readBoolEntry("/paintGroove", true);
_flatHeaders = settings.readBoolEntry("/flatHeaders", true);
_sliderStyle = settings.readEntry("/sliderStyle", "sliderLipstikStyle");
_reverseGradients = settings.readBoolEntry("/reverseGradients", false);
_drawTabHighlight = settings.readBoolEntry("/drawTabHighlight", true);
_drawToolBarHandle = settings.readBoolEntry("/drawToolBarHandle", true);
_coloredMenuBar = settings.readBoolEntry("/coloredMenuBar", false);
_menuLeftSideBar = settings.readBoolEntry("/menuLeftSideBar", true);
_flatStripe = settings.readBoolEntry("/flatStripe", false);
_customMenuStripeColor = settings.readBoolEntry("/customMenuStripeColor", false);
_menuStripeColor.setNamedColor( settings.readEntry("/menuStripeColor", "black") );
_alterMenuGradients = settings.readBoolEntry("/alterMenuGradients", true);
_sharperMenuGradient = settings.readBoolEntry("/sharperMenuGradient", false);
_comboboxColored = settings.readBoolEntry("/comboboxColored", false);
_tickCheckMark = settings.readBoolEntry("/tickCheckMark", true);
//(Keep the following around for later, I cant make it work now.)
//_customArrowColor = settings.readBoolEntry("/customArrowColor", false);
//_arrowColor.setNamedColor( settings.readEntry("/arrowColor", "black") );
settings.endGroup();
if( !strcmp(_scrollBarStyle,"WindowsStyleScrollBar" ) )
this->setScrollBarType(TDEStyle::WindowsStyleScrollBar);
else if( !strcmp(_scrollBarStyle,"PlatinumStyleScrollBar" ) )
this->setScrollBarType(TDEStyle::PlatinumStyleScrollBar);
else if( !strcmp(_scrollBarStyle,"NextStyleScrollBar" ) )
this->setScrollBarType(TDEStyle::NextStyleScrollBar);
// setup pixmap cache...
pixmapCache = new TQIntCache<CacheEntry>(150000, 499);
pixmapCache->setAutoDelete(true);
if ( _animateProgressBar )
{
animationTimer = new TQTimer( this );
connect( animationTimer, TQT_SIGNAL(timeout()), this, TQT_SLOT(updateProgressPos()) );
}
}
void LipstikStyle::updateProgressPos()
{
TQProgressBar* pb;
//Update the registered progressbars.
TQMap<TQWidget*, int>::iterator iter;
bool visible = false;
for (iter = progAnimWidgets.begin(); iter != progAnimWidgets.end(); ++iter)
{
if ( !::tqqt_cast<TQProgressBar*>(iter.key()) )
continue;
pb = dynamic_cast<TQProgressBar*>(iter.key());
if ( iter.key() -> isEnabled() &&
pb -> progress() != pb->totalSteps() )
{
// update animation Offset of the current Widget
iter.data() = (iter.data() + 1) % 20;
iter.key()->update();
}
if (iter.key()->isVisible())
visible = true;
}
if (!visible)
animationTimer->stop();
}
LipstikStyle::~LipstikStyle()
{
delete pixmapCache;
delete horizontalDots;
delete verticalDots;
delete horizontalLine;
delete verticalLine;
}
void LipstikStyle::applicationPolish(const TQStyleControlElementData &ceData, ControlElementFlags, void *ptr)
{
if (ceData.widgetObjectTypes.contains(TQAPPLICATION_OBJECT_NAME_STRING)) {
TQApplication *app = reinterpret_cast<TQApplication*>(ptr);
if (!qstrcmp(app->argv()[0], "kicker"))
kickerMode = true;
else if (!qstrcmp(app->argv()[0], "korn"))
kornMode = true;
}
}
void LipstikStyle::polish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr)
{
if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
if( !strcmp(widget->name(), "__tdehtml") ) { // is it a tdehtml widget...?
tdehtmlWidgets[widget] = true;
connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(tdehtmlWidgetDestroyed(TQObject*)));
}
// use tqt_cast where possible to check if the widget inheits one of the classes. might improve
// performance compared to TQObject::inherits()
if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ||
::tqqt_cast<TQSpinWidget*>(widget) || ::tqqt_cast<TQSlider*>(widget) ||
::tqqt_cast<TQCheckBox*>(widget) || ::tqqt_cast<TQRadioButton*>(widget) ||
::tqqt_cast<TQToolButton*>(widget)
)
{
installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (::tqqt_cast<TQTabBar*>(widget)) {
widget->setMouseTracking(true);
installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (::tqqt_cast<TQPopupMenu*>(widget)) {
widget->setBackgroundMode( NoBackground );
} else if(::tqqt_cast<TQScrollBar*>(widget)) {
widget->setMouseTracking(true);
installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) || widget->inherits(TQDOCKWINDOWHANDLE_OBJECT_NAME_STRING) ) {
installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (::tqqt_cast<TQLineEdit*>(widget)) {
installObjectEventHandler(ceData, elementFlags, ptr, this);
} else if ( !qstrcmp(widget->name(), "tde toolbar widget") ) {
installObjectEventHandler(ceData, elementFlags, ptr, this);
}
if( _animateProgressBar && ::tqqt_cast<TQProgressBar*>(widget) ) {
installObjectEventHandler(ceData, elementFlags, ptr, this);
progAnimWidgets[widget] = 0;
connect(widget, TQT_SIGNAL(destroyed(TQObject*)), this, TQT_SLOT(progressBarDestroyed(TQObject*)));
if (!animationTimer->isActive())
animationTimer->start( 50, false );
} else if( !qstrcmp(widget->className(), "KonqFrameStatusBar") ) {
// This disables the white background of the KonquerorFrameStatusBar.
// When the green led is shown the background is set to
// applications cg.midlight() so we override it to standard background.
// Thanks Comix! (because this was ugly from day one!)
// NOTE: Check if we can set it earlier (before painting), cause
// on slow machines we can see the repainting of the bar (from white to background...)
TQPalette kPalette = TQApplication::palette();
kPalette.setColor( TQColorGroup::Midlight,kPalette.active().background() );
TQApplication::setPalette( kPalette );
}
}
TDEStyle::polish(ceData, elementFlags, ptr);
}
void LipstikStyle::unPolish(const TQStyleControlElementData &ceData, ControlElementFlags elementFlags, void *ptr)
{
if (ceData.widgetObjectTypes.contains(TQWIDGET_OBJECT_NAME_STRING)) {
TQWidget *widget = reinterpret_cast<TQWidget*>(ptr);
if( !strcmp(widget->name(), "__tdehtml") ) { // is it a tdehtml widget...?
tdehtmlWidgets.remove(widget);
}
// use tqt_cast to check if the widget inheits one of the classes.
if ( ::tqqt_cast<TQPushButton*>(widget) || ::tqqt_cast<TQComboBox*>(widget) ||
::tqqt_cast<TQSpinWidget*>(widget) || ::tqqt_cast<TQSlider*>(widget) ||
::tqqt_cast<TQCheckBox*>(widget) || ::tqqt_cast<TQRadioButton*>(widget) ||
::tqqt_cast<TQToolButton*>(widget) || ::tqqt_cast<TQLineEdit*>(widget) ||
widget->inherits(TQSPLITTERHANDLE_OBJECT_NAME_STRING) )
{
removeObjectEventHandler(ceData, elementFlags, ptr, this);
}
else if (::tqqt_cast<TQTabBar*>(widget)) {
widget->setMouseTracking(false);
removeObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (::tqqt_cast<TQScrollBar*>(widget)) {
widget->setMouseTracking(false);
removeObjectEventHandler(ceData, elementFlags, ptr, this);
} else if (::tqqt_cast<TQPopupMenu*>(widget)) {
widget->setBackgroundMode( PaletteBackground );
} else if ( !qstrcmp(widget->name(), "tde toolbar widget") ) {
removeObjectEventHandler(ceData, elementFlags, ptr, this);
}
if ( ::tqqt_cast<TQProgressBar*>(widget) ) {
progAnimWidgets.remove(widget);
} else if( widget->inherits("KonqFrameStatusBar") ) {
removeObjectEventHandler(ceData, elementFlags, ptr, this);
}
}
TDEStyle::unPolish(ceData, elementFlags, ptr);
}
void LipstikStyle::tdehtmlWidgetDestroyed(TQObject* obj)
{
tdehtmlWidgets.remove(TQT_TQWIDGET(obj));
}
void LipstikStyle::progressBarDestroyed(TQObject* obj)
{
progAnimWidgets.remove(TQT_TQWIDGET(obj));
}
void LipstikStyle::renderContour(TQPainter *p,
const TQRect &r,
const TQColor &backgroundColor,
const TQColor &contour,
const uint flags) const
{
if((r.width() <= 0)||(r.height() <= 0))
return;
const bool drawLeft = flags&Draw_Left;
const bool drawRight = flags&Draw_Right;
const bool drawTop = flags&Draw_Top;
const bool drawBottom = flags&Draw_Bottom;
const bool disabled = flags&Is_Disabled;
const bool alphaBlend = flags&Draw_AlphaBlend;
TQColor contourColor;
if (disabled) {
contourColor = backgroundColor.dark(150);
} else {
contourColor = contour;
}
// sides
p->setPen( alphaBlendColors(backgroundColor, contourColor, 50) );
if(drawLeft)
p->drawLine(r.left(), drawTop?r.top()+2:r.top(), r.left(), drawBottom?r.bottom()-2:r.bottom());
if(drawRight)
p->drawLine(r.right(), drawTop?r.top()+2:r.top(), r.right(), drawBottom?r.bottom()-2:r.bottom());
if(drawTop)
p->drawLine(drawLeft?r.left()+2:r.left(), r.top(), drawRight?r.right()-2:r.right(), r.top());
if(drawBottom)
p->drawLine(drawLeft?r.left()+2:r.left(), r.bottom(), drawRight?r.right()-2:r.right(), r.bottom());
// edges
const int alphaAA = 110; // the alpha value for anti-aliasing...
// first part...
p->setPen(alphaBlendColors(backgroundColor, contourColor, 50) );
if(drawLeft && drawTop) {
switch(flags&Round_UpperLeft) {
case false:
p->drawPoint(r.left()+1, r.top());
p->drawPoint(r.left(), r.top()+1);
break;
default:
p->drawPoint(r.left()+1, r.top()+1);
}
}
if(drawLeft && drawBottom) {
switch(flags&Round_BottomLeft) {
case false:
p->drawPoint(r.left()+1, r.bottom());
p->drawPoint(r.left(), r.bottom()-1);
break;
default:
p->drawPoint(r.left()+1, r.bottom()-1);
}
}
if(drawRight && drawTop) {
switch(flags&Round_UpperRight) {
case false:
p->drawPoint(r.right()-1, r.top());
p->drawPoint(r.right(), r.top()+1);
break;
default:
p->drawPoint(r.right()-1, r.top()+1);
}
}
if(drawRight && drawBottom) {
switch(flags&Round_BottomRight) {
case false:
p->drawPoint(r.right()-1, r.bottom());
p->drawPoint(r.right(), r.bottom()-1);
break;
default:
p->drawPoint(r.right()-1, r.bottom()-1);
}
}
// second part... fill edges in case we don't paint alpha-blended
p->setPen( backgroundColor );
if (!alphaBlend) {
if(flags&Round_UpperLeft && drawLeft && drawTop) {
p->drawPoint( r.x(), r.y() );
}
if(flags&Round_BottomLeft && drawLeft && drawBottom) {
p->drawPoint( r.x(), r.bottom() );
}
if(flags&Round_UpperRight && drawRight && drawTop) {
p->drawPoint( r.right(), r.y() );
}
if(flags&Round_BottomRight && drawRight && drawBottom) {
p->drawPoint( r.right(), r.bottom() );
}
}
// third part... anti-aliasing...
if(drawLeft && drawTop) {
switch(flags&Round_UpperLeft) {
case false:
renderPixel(p,TQPoint(r.left(),r.top()),alphaAA,contourColor,backgroundColor,alphaBlend);
break;
default:
renderPixel(p,TQPoint(r.left()+1,r.top()),alphaAA,contourColor,backgroundColor,alphaBlend);
renderPixel(p,TQPoint(r.left(),r.top()+1),alphaAA,contourColor,backgroundColor,alphaBlend);
}
}
if(drawLeft && drawBottom) {
switch(flags&Round_BottomLeft) {
case false:
renderPixel(p,TQPoint(r.left(),r.bottom()),alphaAA,contourColor,backgroundColor,alphaBlend);
break;
default:
renderPixel(p,TQPoint(r.left()+1,r.bottom()),alphaAA,contourColor,backgroundColor,alphaBlend);
renderPixel(p,TQPoint(r.left(),r.bottom()-1),alphaAA,contourColor,backgroundColor,alphaBlend);
}
}
if(drawRight && drawTop) {
switch(flags&Round_UpperRight) {
case false:
renderPixel(p,TQPoint(r.right(),r.top()),alphaAA,contourColor,backgroundColor,alphaBlend);
break;
default:
renderPixel(p,TQPoint(r.right()-1,r.top()),alphaAA,contourColor,backgroundColor,alphaBlend);
renderPixel(p,TQPoint(r.right(),r.top()+1),alphaAA,contourColor,backgroundColor,alphaBlend);
}
}
if(drawRight && drawBottom) {
switch(flags&Round_BottomRight) {
case false:
renderPixel(p,TQPoint(r.right(),r.bottom()),alphaAA,contourColor,backgroundColor,alphaBlend);
break;
default:
renderPixel(p,TQPoint(r.right()-1,r.bottom()),alphaAA,contourColor,backgroundColor,alphaBlend);
renderPixel(p,TQPoint(r.right(),r.bottom()-1),alphaAA,contourColor,backgroundColor,alphaBlend);
}
}
}
void LipstikStyle::renderMask(TQPainter *p,
const TQRect &r,
const TQColor &color,
const uint flags) const
{
if((r.width() <= 0)||(r.height() <= 0))
return;
const bool roundUpperLeft = flags&Round_UpperLeft;
const bool roundUpperRight = flags&Round_UpperRight;
const bool roundBottomLeft = flags&Round_BottomLeft;
const bool roundBottomRight = flags&Round_BottomRight;
p->fillRect (TQRect(r.x()+1, r.y()+1, r.width()-2, r.height()-2) , color);
p->setPen(color);
// sides
p->drawLine(roundUpperLeft?r.x()+1:r.x(), r.y(),
roundUpperRight?r.right()-1:r.right(), r.y() );
p->drawLine(roundBottomLeft?r.x()+1:r.x(), r.bottom(),
roundBottomRight?r.right()-1:r.right(), r.bottom() );
p->drawLine(r.x(), roundUpperLeft?r.y()+1:r.y(),
r.x(), roundBottomLeft?r.bottom()-1:r.bottom() );
p->drawLine(r.right(), roundUpperLeft?r.y()+1:r.y(),
r.right(), roundBottomLeft?r.bottom()-1:r.bottom() );
}
void LipstikStyle::renderSurface(TQPainter *p,
const TQRect &r,
const TQColor &backgroundColor,
const TQColor &buttonColor,
const TQColor &highlightColor,
int intensity,
const uint flags) const
{
if((r.width() <= 0)||(r.height() <= 0))
return;
const bool disabled = flags&Is_Disabled;
const bool drawLeft = flags&Draw_Left;
const bool drawRight = flags&Draw_Right;
const bool drawTop = flags&Draw_Top;
const bool drawBottom = flags&Draw_Bottom;
const bool roundUpperLeft = flags&Round_UpperLeft;
const bool roundUpperRight = flags&Round_UpperRight;
const bool roundBottomLeft = flags&Round_BottomLeft;
const bool roundBottomRight = flags&Round_BottomRight;
const bool sunken = flags&Is_Sunken;
const bool horizontal = flags&Is_Horizontal;
bool highlight = false,
highlightLeft = false,
highlightRight = false,
highlightTop = false,
highlightBottom = false;
// only highlight if not sunken & not disabled...
if(!sunken && !disabled) {
highlight = (flags&Is_Highlight);
highlightLeft = (flags&Highlight_Left);
highlightRight = (flags&Highlight_Right);
highlightTop = (flags&Highlight_Top);
highlightBottom = (flags&Highlight_Bottom);
}
TQColor baseColor = alphaBlendColors(backgroundColor, disabled?backgroundColor:buttonColor, 10);
if (disabled) {
intensity = 2;
} else if (highlight) {
// blend this _slightly_ with the background
baseColor = alphaBlendColors(baseColor, highlightColor, 240);
} else if (sunken) {
// enforce a common sunken-style...
baseColor = baseColor.dark(110+intensity);
intensity = _contrast/2;
}
// some often needed colors...
// 1 more intensive than 2 and 3.
const TQColor colorTop1 = alphaBlendColors(baseColor,
sunken?baseColor.dark(100+intensity*2):baseColor.light(100+intensity*2), 80);
const TQColor colorTop2 = alphaBlendColors(baseColor,
sunken?baseColor.dark(100+intensity):baseColor.light(100+intensity), 80);
const TQColor colorBottom1 = alphaBlendColors(baseColor,
sunken?baseColor.light(100+intensity*2):baseColor.dark(100+intensity*2), 80);
const TQColor colorBottom2 = alphaBlendColors(baseColor,
sunken?baseColor.light(100+intensity):baseColor.dark(100+intensity), 80);
// sides
if (drawLeft) {
if (horizontal) {
int height = r.height();
if (roundUpperLeft || !drawTop) height--;
if (roundBottomLeft || !drawBottom) height--;
renderGradient(p, TQRect(r.left(), (roundUpperLeft&&drawTop)?r.top()+1:r.top(), 1, height),
colorTop1, baseColor);
} else {
p->setPen(colorTop1 );
p->drawLine(r.left(), (roundUpperLeft&&drawTop)?r.top()+1:r.top(),
r.left(), (roundBottomLeft&&drawBottom)?r.bottom()-1:r.bottom() );
}
}
if (drawRight) {
if (horizontal) {
int height = r.height();
// TODO: there's still a bogus in it: when edge4 is Thick
// and we don't whant to draw the Top, we have a unpainted area
if (roundUpperRight || !drawTop) height--;
if (roundBottomRight || !drawBottom) height--;
renderGradient(p, TQRect(r.right(), (roundUpperRight&&drawTop)?r.top()+1:r.top(), 1, height),
baseColor, colorBottom1);
} else {
p->setPen(colorBottom1 );
p->drawLine(r.right(), (roundUpperRight&&drawTop)?r.top()+1:r.top(),
r.right(), (roundBottomRight&&drawBottom)?r.bottom()-1:r.bottom() );
}
}
if (drawTop) {
if (horizontal) {
p->setPen(colorTop1 );
p->drawLine((roundUpperLeft&&drawLeft)?r.left()+1:r.left(), r.top(),
(roundUpperRight&&drawRight)?r.right()-1:r.right(), r.top() );
} else {
int width = r.width();
if (roundUpperLeft || !drawLeft) width--;
if (roundUpperRight || !drawRight) width--;
renderGradient(p, TQRect((roundUpperLeft&&drawLeft)?r.left()+1:r.left(), r.top(), width, 1),
colorTop1, colorTop2);
}
}
if (drawBottom) {
if (horizontal) {
p->setPen(colorBottom1 );
p->drawLine((roundBottomLeft&&drawLeft)?r.left()+1:r.left(), r.bottom(),
(roundBottomRight&&drawRight)?r.right()-1:r.right(), r.bottom() );
} else {
int width = r.width();
if (roundBottomLeft || !drawLeft) width--;
if (roundBottomRight || !drawRight) width--;
renderGradient(p, TQRect((roundBottomLeft&&drawLeft)?r.left()+1:r.left(), r.bottom(), width, 1),
colorBottom2, colorBottom1);
}
}
// button area...
int width = r.width();
int height = r.height();
if (drawLeft) width--;
if (drawRight) width--;
if (drawTop) height--;
if (drawBottom) height--;
renderGradient(p, TQRect(drawLeft?r.left()+1:r.left(), drawTop?r.top()+1:r.top(), width, height),
colorTop2, colorBottom2, horizontal);
// highlighting...
if(highlightTop) {
p->setPen(alphaBlendColors(colorTop1 , highlightColor, 80) );
p->drawLine((roundUpperLeft&&drawLeft)?r.left()+1:r.left(), r.top(),
(roundUpperRight&&drawRight)?r.right()-1:r.right(), r.top() );
p->setPen(alphaBlendColors(colorTop2 , highlightColor, 150) );
p->drawLine(highlightLeft?r.left()+1:r.left(), r.top()+1,
highlightRight?r.right()-1:r.right(), r.top()+1 );
}
if(highlightBottom) {
p->setPen(alphaBlendColors(colorBottom1 , highlightColor, 80) );
p->drawLine((roundBottomLeft&&drawLeft)?r.left()+1:r.left(), r.bottom(),
(roundBottomRight&&drawRight)?r.right()-1:r.right(), r.bottom() );
p->setPen(alphaBlendColors(colorBottom2 , highlightColor, 150) );
p->drawLine(highlightLeft?r.left()+1:r.left(), r.bottom()-1,
highlightRight?r.right()-1:r.right(), r.bottom()-1 );
}
if(highlightLeft) {
p->setPen(alphaBlendColors(colorTop1 , highlightColor, 80) );
p->drawLine(r.left(), (roundUpperLeft&&drawTop)?r.top()+1:r.top(),
r.left(), (roundBottomLeft&&drawBottom)?r.bottom()-1:r.bottom() );
p->setPen(alphaBlendColors(colorTop2 , highlightColor, 150) );
p->drawLine(r.left()+1, highlightTop?r.top()+1:r.top(),
r.left()+1, highlightBottom?r.bottom()-1:r.bottom() );
}
if(highlightRight) {
p->setPen(alphaBlendColors(colorBottom1 , highlightColor, 80) );
p->drawLine(r.right(), (roundUpperRight&&drawTop)?r.top()+1:r.top(),
r.right(), (roundBottomRight&&drawBottom)?r.bottom()-1:r.bottom() );
p->setPen(alphaBlendColors(colorBottom2 , highlightColor, 150) );
p->drawLine(r.right()-1, highlightTop?r.top()+1:r.top(),
r.right()-1, highlightBottom?r.bottom()-1:r.bottom() );
}
}
void LipstikStyle::renderPixel(TQPainter *p,
const TQPoint &pos,
const int alpha,
const TQColor &color,
const TQColor &background,
bool fullAlphaBlend) const
{
if(fullAlphaBlend)
// full alpha blend: paint into an image with alpha buffer and convert to a pixmap ...
{
TQRgb rgb = color.rgb();
// generate a quite unique key -- use the unused width field to store the alpha value.
CacheEntry search(cAlphaDot, alpha, 0, rgb);
int key = search.key();
CacheEntry *cacheEntry;
if( (cacheEntry = pixmapCache->find(key)) ) {
if( search == *cacheEntry ) { // match! we can draw now...
if(cacheEntry->pixmap)
p->drawPixmap(pos, *(cacheEntry->pixmap) );
return;
} else { //Remove old entry in case of a conflict!
pixmapCache->remove( key );
}
}
TQImage aImg(1,1,32); // 1x1
aImg.setAlphaBuffer(true);
aImg.setPixel(0,0,tqRgba(tqRed(rgb),tqGreen(rgb),tqBlue(rgb),alpha));
TQPixmap *result = new TQPixmap(aImg);
p->drawPixmap(pos, *result);
// add to the cache...
CacheEntry *toAdd = new CacheEntry(search);
toAdd->pixmap = result;
bool insertOk = pixmapCache->insert( key, toAdd, result->depth()/8);
if(!insertOk)
delete result;
} else
// don't use an alpha buffer: calculate the resulting color from the alpha value, the fg- and the bg-color.
{
TQRgb rgb_a = color.rgb();
TQRgb rgb_b = background.rgb();
int a = alpha;
if(a>255) a = 255;
if(a<0) a = 0;
int a_inv = 255 - a;
TQColor res = TQColor( tqRgb(tqRed(rgb_b)*a_inv/255 + tqRed(rgb_a)*a/255,
tqGreen(rgb_b)*a_inv/255 + tqGreen(rgb_a)*a/255,
tqBlue(rgb_b)*a_inv/255 + tqBlue(rgb_a)*a/255) );
p->setPen(res);
p->drawPoint(pos);
}
}
void LipstikStyle::renderButton(TQPainter *p,
const TQRect &r,
const TQColorGroup &g,
bool sunken,
bool mouseOver,
bool horizontal,
bool enabled,
bool tdehtmlMode) const
{
// small fix for the kicker buttons...
if(kickerMode) enabled = true;
const TQPen oldPen( p->pen() );
uint contourFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom;
if(!enabled) contourFlags|=Is_Disabled;
if(tdehtmlMode) contourFlags|=Draw_AlphaBlend;
uint surfaceFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom;
if(horizontal) surfaceFlags|=Is_Horizontal;
if(!enabled) surfaceFlags|=Is_Disabled;
else {
if(sunken) surfaceFlags|=Is_Sunken;
else {
if(mouseOver) {
surfaceFlags|=Is_Highlight;
surfaceFlags|=Highlight_Top;
surfaceFlags|=Highlight_Bottom;
surfaceFlags|=Highlight_Right;
surfaceFlags|=Highlight_Left;
}
}
}
if (!flatMode) {
contourFlags |= Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight;
surfaceFlags |= Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight;
renderContour(p, r, g.background(), getColor(g,ButtonContour),
contourFlags);
renderSurface(p, TQRect(r.left()+1, r.top()+1, r.width()-2, r.height()-2),
g.background(), g.button(), getColor(g,MouseOverHighlight), _contrast, surfaceFlags);
} else {
renderContour(p, r, g.background(), g.button().dark(105+_contrast*3),
contourFlags);
renderSurface(p, TQRect(r.left()+1, r.top()+1, r.width()-2, r.height()-2),
g.background(), g.button(), getColor(g,MouseOverHighlight), _contrast/2, surfaceFlags);
flatMode = false;
}
p->setPen(oldPen);
}
void LipstikStyle::renderDot(TQPainter *p,
const TQPoint &point,
const TQColor &baseColor,
const bool thick,
const bool sunken) const
{
const TQColor topColor = alphaBlendColors(baseColor, sunken?baseColor.dark(130):baseColor.light(150), 70);
const TQColor bottomColor = alphaBlendColors(baseColor, sunken?baseColor.light(150):baseColor.dark(130), 70);
p->setPen(topColor );
p->drawLine(point.x(), point.y(), point.x()+1, point.y());
p->drawPoint(point.x(), point.y()+1);
p->setPen(bottomColor );
if(thick) {
p->drawLine(point.x()+1, point.y()+2, point.x()+2, point.y()+2);
p->drawPoint(point.x()+2, point.y()+1);
} else {
p->drawPoint(point.x()+1, point.y()+1);
}
}
void LipstikStyle::renderGradient(TQPainter *painter,
const TQRect &rect,
const TQColor &c1,
const TQColor &c2,
bool horizontal) const
{
if((rect.width() <= 0)||(rect.height() <= 0))
return;
// generate a quite unique key for this surface.
CacheEntry search(cGradientTile,
horizontal ? 0 : rect.width(),
horizontal ? rect.height() : 0,
c1.rgb(), c2.rgb(), horizontal );
int key = search.key();
CacheEntry *cacheEntry;
if( (cacheEntry = pixmapCache->find(key)) ) {
if( search == *cacheEntry ) { // match! we can draw now...
if(cacheEntry->pixmap) {
painter->drawTiledPixmap(rect, *(cacheEntry->pixmap) );
}
return;
} else {
// Remove old entry in case of a conflict!
// This shouldn't happen very often, see comment in CacheEntry.
pixmapCache->remove(key);
}
}
// there wasn't anything matching in the cache, create the pixmap now...
TQPixmap *result = new TQPixmap(horizontal ? 10 : rect.width(),
horizontal ? rect.height() : 10);
TQPainter p(result);
int r_w = result->rect().width();
int r_h = result->rect().height();
int r_x, r_y, r_x2, r_y2;
TQT_TQRECT_OBJECT(result->rect()).coords(&r_x, &r_y, &r_x2, &r_y2);
int rDiff, gDiff, bDiff;
int rc, gc, bc;
register int x, y;
if( _reverseGradients ) {
rDiff = ( c2.red()) - (rc = c1.red());
gDiff = ( c2.green()) - (gc = c1.green());
bDiff = ( c2.blue()) - (bc = c1.blue());
} else {
rDiff = ( c1.red()) - (rc = c2.red());
gDiff = ( c1.green()) - (gc = c2.green());
bDiff = ( c1.blue()) - (bc = c2.blue());
}
register int rl = rc << 16;
register int gl = gc << 16;
register int bl = bc << 16;
int rdelta = ((1<<16) / (horizontal ? r_h : r_w)) * rDiff;
int gdelta = ((1<<16) / (horizontal ? r_h : r_w)) * gDiff;
int bdelta = ((1<<16) / (horizontal ? r_h : r_w)) * bDiff;
// these for-loops could be merged, but the if's in the inner loop
// would make it slow
if(horizontal) {
for ( y = 0; y < r_h; y++ ) {
rl += rdelta;
gl += gdelta;
bl += bdelta;
p.setPen(TQColor(rl>>16, gl>>16, bl>>16));
p.drawLine(r_x, r_y+y, r_x2, r_y+y);
}
} else {
for( x = 0; x < r_w; x++) {
rl += rdelta;
gl += gdelta;
bl += bdelta;
p.setPen(TQColor(rl>>16, gl>>16, bl>>16));
p.drawLine(r_x+x, r_y, r_x+x, r_y2);
}
}
p.end();
// draw the result...
painter->drawTiledPixmap(rect, *result);
// insert into cache using the previously created key.
CacheEntry *toAdd = new CacheEntry(search);
toAdd->pixmap = result;
bool insertOk = pixmapCache->insert( key, toAdd, result->width()*result->height()*result->depth()/8 );
if(!insertOk)
delete result;
}
void LipstikStyle::renderPanel(TQPainter *p,
const TQRect &r,
const TQColorGroup &g,
const bool pseudo3d,
const bool sunken) const
{
int x, x2, y, y2, w, h;
r.rect(&x,&y,&w,&h);
r.coords(&x, &y, &x2, &y2);
if (kickerMode &&
p->device() && p->device()->devType() == TQInternal::Widget &&
TQCString(TQT_TQWIDGET(static_cast<QWidget*>(p->device()))->className()) == "FittsLawFrame") {
// Stolen wholesale from Keramik. I don't like it, but oh well.
if (sunken) {
const TQCOORD corners[] = { x2, y, x2, y2, x, y2, x, y };
p->setPen(g.mid());
p->drawConvexPolygon(TQPointArray(4, corners));
p->setPen(g.mid());
p->drawPolyline(TQPointArray(4, corners), 0, 3);
} else {
const TQCOORD corners[] = { x, y2, x, y, x2, y, x2, y2 };
p->setPen(g.background().dark());
p->drawPolygon(TQPointArray(4, corners));
p->setPen(g.background().light());
p->drawPolyline(TQPointArray(4, corners), 0, 3);
}
} else {
renderContour(p, r, g.background(), getColor(g, PanelContour) );
if(pseudo3d) {
if (sunken) {
p->setPen(getColor(g, PanelDark) );
} else {
p->setPen(getColor(g, PanelLight) );
}
p->drawLine(r.left()+2, r.top()+1, r.right()-2, r.top()+1);
p->drawLine(r.left()+1, r.top()+2, r.left()+1, r.bottom()-2);
if (sunken) {
p->setPen(getColor(g, PanelLight) );
} else {
p->setPen(getColor(g, PanelDark) );
}
p->drawLine(r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1);
p->drawLine(r.right()-1, r.top()+2, r.right()-1, r.bottom()-2);
}
}
}
void LipstikStyle::renderMenuBlendPixmap( KPixmap &pix, const TQColorGroup &cg,
const TQPopupMenu* /* popup */ ) const
{
pix.fill( cg.background().light(105) );
}
void LipstikStyle::renderTab(TQPainter *p,
const TQRect &r,
const TQColorGroup &g,
bool mouseOver,
const bool selected,
const bool bottom,
const TabPosition pos,
const bool triangular,
const bool cornerWidget) const
{
const bool reverseLayout = TQApplication::reverseLayout();
const bool isFirst = (pos == First) || (pos == Single);
const bool isLast = (pos == Last);
const bool isSingle = (pos == Single);
if (selected) {
// is selected
// the top part of the tab which is nearly the same for all positions
TQRect Rc; // contour
if (!bottom) {
if (isFirst && !cornerWidget && !reverseLayout) {
Rc = TQRect(r.x(), r.y(), r.width()-1, r.height()-3);
} else if (isFirst && !cornerWidget && reverseLayout) {
Rc = TQRect(r.x()+1, r.y(), r.width()-1, r.height()-3);
} else {
Rc = TQRect(r.x()+1, r.y(), r.width()-2, r.height()-3);
}
} else {
if (isFirst && !cornerWidget && !reverseLayout) {
Rc = TQRect(r.x(), r.y()+3, r.width()-1, r.height()-3);
} else if (isFirst && !cornerWidget && reverseLayout) {
Rc = TQRect(r.x()+1, r.y()+3, r.width()-1, r.height()-3);
} else {
Rc = TQRect(r.x()+1, r.y()+3, r.width()-2, r.height()-3);
}
}
const TQRect Rs(Rc.x()+1, bottom?Rc.y():Rc.y()+1, Rc.width()-2, Rc.height()-1); // the resulting surface
// the area where the fake border shoudl appear
const TQRect Rb(r.x(), bottom?r.top():Rc.bottom()+1, r.width(), r.height()-Rc.height() );
uint contourFlags = Draw_Left|Draw_Right;
if(!bottom) {
contourFlags |= Draw_Top|Round_UpperLeft|Round_UpperRight;
} else {
contourFlags |= Draw_Bottom|Round_BottomLeft|Round_BottomRight;
}
renderContour(p, Rc,
g.background(), getColor(g,PanelContour),
contourFlags);
// surface
if(!bottom) {
p->setPen(getColor(g,PanelLight) );
p->drawLine(Rs.x()+1, Rs.y(), Rs.right()-1, Rs.y() );
renderGradient(p, TQRect(Rs.x(), Rs.y()+1, 1, Rs.height()-1),
getColor(g,PanelLight), getColor(g,PanelLight2));
renderGradient(p, TQRect(Rs.right(), Rs.y()+1, 1, Rs.height()-1),
getColor(g,PanelDark), getColor(g,PanelDark2));
if(_drawTabHighlight) {
if(_customTabHighlightColor) {
p->setPen( alphaBlendColors(getColor(g,TabHighlight), getColor(g,PanelLight), 180) );
p->drawLine( Rs.x()+1, Rs.y(), Rs.right()-1, Rs.y() );
p->setPen( alphaBlendColors(getColor(g,TabHighlight), getColor(g,PanelLight), 110) );
p->drawLine( Rs.x(), Rs.y()+1, Rs.right(), Rs.y()+1 );
} else {
p->setPen( alphaBlendColors(g.highlight(), getColor(g,PanelLight), 180) );
p->drawLine( Rs.x()+1, Rs.y(), Rs.right()-1, Rs.y() );
p->setPen( alphaBlendColors(g.highlight(), getColor(g,PanelLight), 110) );
p->drawLine( Rs.x(), Rs.y()+1, Rs.right(), Rs.y()+1 );
}
}
} else {
p->setPen(alphaBlendColors(g.background(), g.background().dark(160), 100) );
p->drawLine(Rs.x()+1, Rs.bottom(), Rs.right()-1, Rs.bottom() );
renderGradient(p, TQRect(Rs.x(), Rs.y(), 1, Rs.height()-1),
getColor(g,PanelLight), getColor(g,PanelLight2));
renderGradient(p, TQRect(Rs.right(), Rs.y(), 1, Rs.height()-1),
getColor(g,PanelDark), getColor(g,PanelDark2));
if(_drawTabHighlight) {
p->setPen( alphaBlendColors(g.highlight(), getColor(g,PanelLight), 180) );
//p->setPen(getColor(g,MouseOverHighlight) );
p->drawLine( Rs.x()+1, Rs.bottom(), Rs.right()-1, Rs.bottom() );
p->setPen( alphaBlendColors(g.highlight(), getColor(g,PanelLight), 110) );
p->drawLine( Rs.x(), Rs.bottom()-1, Rs.right(), Rs.bottom()-1 );
}
}
// some "position specific" paintings...
// draw parts of the inactive tabs around...
if(!isSingle) {
p->setPen(alphaBlendColors(g.background(), getColor(g, ButtonContour), 50) );
if( (!isFirst&&!reverseLayout) || (!isLast&&reverseLayout) ) {
p->drawPoint(r.left(), bottom?(triangular?r.bottom()-2:r.bottom()-3):(triangular?r.top()+2:r.top()+3) );
renderSurface(p, TQRect(r.left(), bottom?r.top()+3:(triangular?r.top()+3:r.top()+4), 1, (triangular?r.height()-6:r.height()-7) ),
g.background(), g.button(), getColor(g,MouseOverHighlight), _contrast,
Draw_Top|Draw_Bottom|Is_Horizontal);
}
if( (!isLast&&!reverseLayout) || (!isFirst&&reverseLayout) ) {
p->drawPoint(r.right(), bottom?(triangular?r.bottom()-2:r.bottom()-3):(triangular?r.top()+2:r.top()+3) );
renderSurface(p, TQRect(r.right(), bottom?r.top()+3:(triangular?r.top()+3:r.top()+4), 1, (triangular?r.height()-6:r.height()-7) ),
g.background(), g.button(), getColor(g,MouseOverHighlight), _contrast,
Draw_Top|Draw_Bottom|Is_Horizontal);
}
}
// left connection from the panel border to the tab. :)
if(isFirst && !reverseLayout && !cornerWidget) {
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawLine(Rb.x(), Rb.y(), Rb.x(), Rb.bottom() );
p->setPen(getColor(g,PanelLight) );
p->drawLine(Rb.x()+1, Rb.y(), Rb.x()+1, Rb.bottom() );
} else if(isFirst && reverseLayout && !cornerWidget) {
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawLine(Rb.right(), Rb.y(), Rb.right(), Rb.bottom() );
p->setPen(getColor(g,PanelDark) );
p->drawLine(Rb.right()-1, Rb.y(), Rb.right()-1, Rb.bottom() );
}
// rounded connections to the panel...
if(!bottom) {
// left
if( (!isFirst && !reverseLayout) || (reverseLayout) || (isFirst && !reverseLayout && cornerWidget) ) {
p->setPen( alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawPoint(Rb.x(), Rb.y());
p->setPen( alphaBlendColors(g.background(), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.x(), Rb.y()+1);
p->drawPoint(Rb.x()+1, Rb.y());
}
// right
if( (!reverseLayout) || (!isFirst && reverseLayout) || (isFirst && reverseLayout && cornerWidget) ) {
p->setPen( alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawPoint(Rb.right(), Rb.y());
p->setPen( alphaBlendColors(g.background(), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.right(), Rb.y()+1);
p->drawPoint(Rb.right()-1, Rb.y());
}
} else {
// left
if( (!isFirst && !reverseLayout) || (reverseLayout) || (isFirst && !reverseLayout && cornerWidget) ) {
p->setPen( alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawPoint(Rb.x(), Rb.bottom());
p->setPen( alphaBlendColors(g.background(), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.x(), Rb.bottom()-1);
p->drawPoint(Rb.x()+1, Rb.bottom());
}
// right
if( (!reverseLayout) || (!isFirst && reverseLayout) || (isFirst && reverseLayout && cornerWidget) ) {
p->setPen( alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawPoint(Rb.right(), Rb.bottom());
p->setPen( alphaBlendColors(g.background(), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.right(), Rb.bottom()-1);
p->drawPoint(Rb.right()-1, Rb.bottom());
}
}
} else {
// inactive tabs
// the top part of the tab which is nearly the same for all positions
TQRect Rc; // contour
if (isFirst&&reverseLayout ) {
Rc = TQRect(r.x()+1, (bottom?r.y()+2:(triangular?r.y()+2:r.y()+3)), r.width()-2, (triangular?r.height()-4:r.height()-5) );
} else {
Rc = TQRect(r.x()+1, (bottom?r.y()+2:(triangular?r.y()+2:r.y()+3)), r.width()-1, (triangular?r.height()-4:r.height()-5) );
}
TQRect Rs; // the resulting surface
if ( (isFirst&&!reverseLayout) || (isLast&&reverseLayout) ) {
Rs = TQRect(Rc.x()+1, bottom?Rc.y():Rc.y()+1, Rc.width()-2, Rc.height()-1);
} else {
Rs = TQRect(Rc.x(), bottom?Rc.y():Rc.y()+1, Rc.width()-1, Rc.height()-1);
}
// the area where the fake border shoudl appear
const TQRect Rb(r.x(), bottom?r.y():Rc.bottom()+1, r.width(), 2 );
uint contourFlags;
if(!bottom) {
if ( (isFirst&&!reverseLayout) || (isLast&&reverseLayout) ) {
contourFlags = Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft;
} else if ( (isLast&&!reverseLayout) || (isFirst&&reverseLayout) ) {
contourFlags = Draw_Right|Draw_Top|Round_UpperRight;
} else {
contourFlags = Draw_Right|Draw_Top;
}
} else {
if ( (isFirst&&!reverseLayout) || (isLast&&reverseLayout) ) {
contourFlags = Draw_Left|Draw_Right|Draw_Bottom|Round_BottomLeft;
} else if ( (isLast&&!reverseLayout) || (isFirst&&reverseLayout) ) {
contourFlags = Draw_Right|Draw_Bottom|Round_BottomRight;
} else {
contourFlags = Draw_Right|Draw_Bottom;
}
}
renderContour(p, Rc,
g.background(), getColor(g, ButtonContour),
contourFlags);
uint surfaceFlags = Is_Horizontal;
if(mouseOver) {
surfaceFlags |= (bottom?Highlight_Bottom:Highlight_Top);
surfaceFlags |= Is_Highlight;
}
if ( (isFirst&&!reverseLayout) || (isLast&&reverseLayout) ) {
if(!bottom)
surfaceFlags |= Draw_Left|Draw_Top|Draw_Bottom|Round_UpperLeft;
else
surfaceFlags |= Draw_Left|Draw_Top|Draw_Bottom|Round_BottomLeft;
} else if ( (isLast&&!reverseLayout) || (isFirst&&reverseLayout) ) {
if(!bottom)
surfaceFlags |= Draw_Right|Draw_Top|Draw_Bottom|Round_UpperRight;
else
surfaceFlags |= Draw_Right|Draw_Top|Draw_Bottom|Round_BottomRight;
} else {
surfaceFlags |= Draw_Top|Draw_Bottom;
}
renderSurface(p, Rs,
g.background(), g.button(), getColor(g,MouseOverHighlight), _contrast,
surfaceFlags);
// some "position specific" paintings...
// fake parts of the panel border
if(!bottom) {
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawLine(Rb.x(), Rb.y(), ((isLast&&!reverseLayout)||(isFirst&&reverseLayout&&cornerWidget))?Rb.right():Rb.right()-1, Rb.y());
p->setPen(getColor(g,PanelLight) );
p->drawLine(Rb.x(), Rb.y()+1, ((isLast&&!reverseLayout)||(isFirst&&reverseLayout&&cornerWidget))?Rb.right():Rb.right()-1, Rb.y()+1 );
} else {
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawLine(Rb.x(), Rb.bottom(), ((isLast&&!reverseLayout)||(isFirst&&reverseLayout&&cornerWidget))?Rb.right():Rb.right()-1, Rb.bottom());
p->setPen(getColor(g,PanelDark) );
p->drawLine(Rb.x(), Rb.bottom()-1, ((isLast&&!reverseLayout)||(isFirst&&reverseLayout&&cornerWidget))?Rb.right():Rb.right()-1, Rb.bottom()-1 );
}
// fake the panel border edge for tabs which are aligned left-most
// (i.e. only if there is no widget in the corner of the tabwidget!)
if(isFirst&&!reverseLayout&&!cornerWidget)
// normal layout
{
if (!bottom) {
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawPoint(Rb.x()+1, Rb.y()+1 );
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.x(), Rb.y()+1 );
p->setPen(g.background() );
p->drawPoint(Rb.x(), Rb.y() );
p->setPen(alphaBlendColors( alphaBlendColors(g.background(), getColor(g, ButtonContour), 50), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.x()+1, Rb.y() );
} else {
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawPoint(Rb.x()+1, Rb.bottom()-1 );
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.x(), Rb.bottom()-1 );
p->setPen(g.background() );
p->drawPoint(Rb.x(), Rb.bottom() );
p->setPen(alphaBlendColors( alphaBlendColors(g.background(), getColor(g, ButtonContour), 50), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.x()+1, Rb.bottom() );
}
} else if(isFirst&&reverseLayout&&!cornerWidget)
// reverse layout
{
if (!bottom) {
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawPoint(Rb.right()-1, Rb.y()+1 );
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.right(), Rb.y()+1 );
p->setPen(g.background() );
p->drawPoint(Rb.right(), Rb.y() );
p->setPen(alphaBlendColors( alphaBlendColors(g.background(), getColor(g, ButtonContour), 50), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.right()-1, Rb.y() );
} else {
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 50) );
p->drawPoint(Rb.right()-1, Rb.bottom()-1 );
p->setPen(alphaBlendColors(g.background(), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.right(), Rb.bottom()-1 );
p->setPen(g.background() );
p->drawPoint(Rb.right(), Rb.bottom() );
p->setPen(alphaBlendColors( alphaBlendColors(g.background(), getColor(g, ButtonContour), 50), getColor(g,PanelContour), 150) );
p->drawPoint(Rb.right()-1, Rb.bottom() );
}
}
}
}
void LipstikStyle::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
{
// some "global" vars...
const bool enabled = (flags & Style_Enabled);
// SLIDER
// ------
switch( kpe ) {
case KPE_SliderGroove: {
bool horizontal = ceData.orientation == TQt::Horizontal;
if (horizontal) {
int center = r.y()+r.height()/2;
renderContour(p, TQRect(r.left(), center-2, r.width(), 4),
cg.background(), cg.background().dark(enabled?150:130),
Draw_Left|Draw_Right|Draw_Top|Draw_Bottom);
} else {
int center = r.x()+r.width()/2;
renderContour(p, TQRect(center-2, r.top(), 4, r.height()),
cg.background(), cg.background().dark(enabled?150:130),
Draw_Left|Draw_Right|Draw_Top|Draw_Bottom);
}
break;
}
case KPE_SliderHandle: {
bool horizontal = ceData.orientation == TQt::Horizontal;
const bool pressed = (flags&Style_Active);
const WidgetState s = enabled?(pressed?IsPressed:IsEnabled):IsDisabled;
const TQColor contour = getColor(cg,DragButtonContour,s),
surface = getColor(cg,DragButtonSurface,s);
int xcenter = (r.left()+r.right()) / 2;
int ycenter = (r.top()+r.bottom()) / 2;
if (_sliderStyle == "sliderLipstikStyle") {
if (horizontal) {
renderContour(p, TQRect(xcenter-9, ycenter-7, 20, 15), cg.background(), contour,
Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft|Round_UpperRight|
Draw_Bottom|Round_BottomLeft|Round_BottomRight);
TQRegion mask(xcenter-8, ycenter-6, 18, 13);
p->setClipRegion(mask);
uint surfaceFlags = Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft|Round_UpperRight|
Is_Horizontal;
if(!enabled)
surfaceFlags |= Is_Disabled;
else if(flags & Style_MouseOver) {
surfaceFlags |= Highlight_Right|Highlight_Left;
}
renderSurface(p, TQRect(xcenter-8, ycenter-6, 18, 13),
cg.background(), surface, getColor(cg,MouseOverHighlight),
_contrast+3, surfaceFlags);
renderDot(p, TQPoint(xcenter-2, ycenter), surface, true, true );
renderDot(p, TQPoint(xcenter+2, ycenter), surface, true, true );
p->setClipping(false);
} else {
renderContour(p, TQRect(xcenter-7, ycenter-9, 16, 20), cg.background(), contour,
Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft|Round_UpperRight|
Draw_Bottom|Round_BottomLeft|Round_BottomRight);
TQRegion mask(xcenter-6, ycenter-8, 13, 18);
p->setClipRegion(mask);
uint surfaceFlags = Draw_Left|Draw_Top|Draw_Bottom|Round_UpperLeft|Round_BottomLeft|
Round_UpperRight|Is_Horizontal;
if(!enabled)
surfaceFlags |= Is_Disabled;
else if(flags & Style_MouseOver)
surfaceFlags |= Highlight_Top|Highlight_Bottom;
renderSurface(p, TQRect(xcenter-6, ycenter-8, 13, 18),
cg.background(), surface, getColor(cg,MouseOverHighlight),
_contrast+3, surfaceFlags);
renderDot(p, TQPoint(xcenter, ycenter-2), surface, true, true );
renderDot(p, TQPoint(xcenter, ycenter+2), surface, true, true );
p->setClipping(false);
}
} else if (_sliderStyle == "sliderPlastikStyle") {
if (horizontal) {
renderContour(p, TQRect(xcenter-5, ycenter-6, 11, 10),
cg.background(), contour,
Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft|Round_UpperRight);
// manual contour: vertex
p->setPen(alphaBlendColors(cg.background(), contour, 50) );
p->drawPoint(xcenter-5+1, ycenter+4);
p->drawPoint(xcenter+5-1, ycenter+4);
p->drawPoint(xcenter-5+2, ycenter+5);
p->drawPoint(xcenter+5-2, ycenter+5);
p->drawPoint(xcenter-5+3, ycenter+6);
p->drawPoint(xcenter+5-3, ycenter+6);
p->drawPoint(xcenter-5+4, ycenter+7);
p->drawPoint(xcenter+5-4, ycenter+7);
// anti-aliasing of the contour... sort of. :)
p->setPen(alphaBlendColors(cg.background(), contour, 80) );
p->drawPoint(xcenter, ycenter+8);
p->setPen(alphaBlendColors(cg.background(), contour, 150) );
p->drawPoint(xcenter-5, ycenter+4);
p->drawPoint(xcenter+5, ycenter+4);
p->drawPoint(xcenter-5+1, ycenter+5);
p->drawPoint(xcenter+5-1, ycenter+5);
p->drawPoint(xcenter-5+2, ycenter+6);
p->drawPoint(xcenter+5-2, ycenter+6);
p->drawPoint(xcenter-5+3, ycenter+7);
p->drawPoint(xcenter+5-3, ycenter+7);
p->setPen(alphaBlendColors(cg.background(), contour, 190) );
p->drawPoint(xcenter-5+4, ycenter+8);
p->drawPoint(xcenter+5-4, ycenter+8);
TQRegion mask(xcenter-4, ycenter-5, 9, 13);
mask -= TQRegion(xcenter-4, ycenter+4, 1, 4);
mask -= TQRegion(xcenter-3, ycenter+5, 1, 3);
mask -= TQRegion(xcenter-2, ycenter+6, 1, 2);
mask -= TQRegion(xcenter-1, ycenter+7, 1, 1);
mask -= TQRegion(xcenter+1, ycenter+7, 1, 1);
mask -= TQRegion(xcenter+2, ycenter+6, 1, 2);
mask -= TQRegion(xcenter+3, ycenter+5, 1, 3);
mask -= TQRegion(xcenter+4, ycenter+4, 1, 4);
p->setClipRegion(mask);
uint surfaceFlags = Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft|Round_UpperRight|Is_Horizontal;
if(!enabled)
surfaceFlags |= Is_Disabled;
renderSurface(p, TQRect(xcenter-4, ycenter-5, 9, 13),
cg.background(), surface, getColor(cg,MouseOverHighlight),
_contrast+3, surfaceFlags);
renderDot(p, TQPoint(xcenter-3, ycenter-3), surface, false, true );
renderDot(p, TQPoint(xcenter+2, ycenter-3), surface, false, true );
p->setClipping(false);
} else {
renderContour(p, TQRect(xcenter-6, ycenter-5, 10, 11),
cg.background(), contour,
Draw_Left|Draw_Top|Draw_Bottom|Round_UpperLeft|Round_BottomLeft);
// manual contour: vertex
p->setPen(alphaBlendColors(cg.background(), contour, 50) );
p->drawPoint(xcenter+4, ycenter-5+1);
p->drawPoint(xcenter+4, ycenter+5-1);
p->drawPoint(xcenter+5, ycenter-5+2);
p->drawPoint(xcenter+5, ycenter+5-2);
p->drawPoint(xcenter+6, ycenter-5+3);
p->drawPoint(xcenter+6, ycenter+5-3);
p->drawPoint(xcenter+7, ycenter-5+4);
p->drawPoint(xcenter+7, ycenter+5-4);
// anti-aliasing. ...sort of :)
p->setPen(alphaBlendColors(cg.background(), contour, 80) );
p->drawPoint(xcenter+8, ycenter);
p->setPen(alphaBlendColors(cg.background(), contour, 150) );
p->drawPoint(xcenter+4, ycenter-5);
p->drawPoint(xcenter+4, ycenter+5);
p->drawPoint(xcenter+5, ycenter-5+1);
p->drawPoint(xcenter+5, ycenter+5-1);
p->drawPoint(xcenter+6, ycenter-5+2);
p->drawPoint(xcenter+6, ycenter+5-2);
p->drawPoint(xcenter+7, ycenter-5+3);
p->drawPoint(xcenter+7, ycenter+5-3);
p->setPen(alphaBlendColors(cg.background(), contour, 190) );
p->drawPoint(xcenter+8, ycenter-5+4);
p->drawPoint(xcenter+8, ycenter+5-4);
TQRegion mask(xcenter-5, ycenter-4, 13, 9);
mask -= TQRegion(xcenter+4, ycenter-4, 4, 1);
mask -= TQRegion(xcenter+5, ycenter-3, 3, 1);
mask -= TQRegion(xcenter+6, ycenter-2, 2, 1);
mask -= TQRegion(xcenter+7, ycenter-1, 1, 1);
mask -= TQRegion(xcenter+7, ycenter+1, 1, 1);
mask -= TQRegion(xcenter+6, ycenter+2, 2, 1);
mask -= TQRegion(xcenter+5, ycenter+3, 3, 1);
mask -= TQRegion(xcenter+4, ycenter+4, 4, 1);
p->setClipRegion(mask);
uint surfaceFlags = Draw_Left|Draw_Top|Draw_Bottom|Round_UpperLeft|Round_BottomLeft|
Round_UpperRight|Is_Horizontal;
if(!enabled)
surfaceFlags |= Is_Disabled;
renderSurface(p, TQRect(xcenter-5, ycenter-4, 13, 9),
cg.background(), surface, getColor(cg,MouseOverHighlight),
_contrast+3, surfaceFlags);
renderDot(p, TQPoint(xcenter-3, ycenter-3), surface, false, true );
renderDot(p, TQPoint(xcenter-3, ycenter+2), surface, false, true );
p->setClipping(false);
}
} else {
if (horizontal) {
renderContour(p, TQRect(xcenter-16, ycenter-7, 33, 15), cg.background(), contour,
Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft|Round_UpperRight|
Draw_Bottom|Round_BottomLeft|Round_BottomRight);
TQRegion mask(xcenter-15, ycenter-6, 31, 13);
p->setClipRegion(mask);
uint surfaceFlags = Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft|Round_UpperRight|
Is_Horizontal;
if(!enabled)
surfaceFlags |= Is_Disabled;
else if(flags & Style_MouseOver) {
surfaceFlags |= Highlight_Right|Highlight_Left;
}
renderSurface(p, TQRect(xcenter-15, ycenter-6, 31, 13),
cg.background(), surface, getColor(cg,MouseOverHighlight),
_contrast+3, surfaceFlags);
renderDot(p, TQPoint(xcenter-4, ycenter), surface, true, true );
renderDot(p, TQPoint(xcenter, ycenter), surface, true, true );
renderDot(p, TQPoint(xcenter+4, ycenter), surface, true, true );
p->setClipping(false);
} else {
renderContour(p, TQRect(xcenter-7, ycenter-16, 16, 33), cg.background(), contour,
Draw_Left|Draw_Right|Draw_Top|Round_UpperLeft|Round_UpperRight|Draw_Bottom|Round_BottomLeft|Round_BottomRight);
TQRegion mask(xcenter-6, ycenter-15, 13, 31);
p->setClipRegion(mask);
uint surfaceFlags = Draw_Left|Draw_Top|Draw_Bottom|Round_UpperLeft|Round_BottomLeft|
Round_UpperRight|Is_Horizontal;
if(!enabled)
surfaceFlags |= Is_Disabled;
else if(flags & Style_MouseOver)
surfaceFlags |= Highlight_Top|Highlight_Bottom;
renderSurface(p, TQRect(xcenter-6, ycenter-15, 13, 31),
cg.background(), surface, getColor(cg,MouseOverHighlight),
_contrast+3, surfaceFlags);
renderDot(p, TQPoint(xcenter, ycenter-4), surface, true, true );
renderDot(p, TQPoint(xcenter, ycenter), surface, true, true );
renderDot(p, TQPoint(xcenter, ycenter+4), surface, true, true );
p->setClipping(false);
}
}
break;
}
case KPE_ListViewExpander: {
int radius = (r.width() - 4) / 2;
int centerx = r.x() + r.width()/2;
int centery = r.y() + r.height()/2;
renderContour(p, r, cg.base(), cg.dark(), Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight );
p->setPen( cg.text() );
if(!_drawTriangularExpander)
{
// plus or minus
p->drawLine( centerx - radius, centery, centerx + radius, centery );
if ( flags & Style_On ) // Collapsed = On
p->drawLine( centerx, centery - radius, centerx, centery + radius );
} else if(_drawTriangularExpander) {
if( flags & Style_On )
drawPrimitive(PE_ArrowRight, p, ceData, elementFlags, TQRect(r.x()+1,r.y()+1,r.width(),r.height()), cg,ButtonContour, flags);
if( flags & Style_Off )
drawPrimitive(PE_ArrowDown, p, ceData, elementFlags, TQRect(r.x()+1,r.y()+1,r.width(),r.height()), cg,ButtonContour, flags);
}
break;
}
// copied and slightly modified from TDEStyle.
case KPE_ListViewBranch: {
// Typical Windows style listview branch element (dotted line).
// Create the dotline pixmaps if not already created
if ( !verticalLine )
{
// make 128*1 and 1*128 bitmaps that can be used for
// drawing the right sort of lines.
verticalLine = new TQBitmap( 1, 129, true );
horizontalLine = new TQBitmap( 128, 1, true );
TQPointArray a( 64 );
TQPainter p2;
p2.begin( verticalLine );
int i;
for( i=0; i < 64; i++ )
a.setPoint( i, 0, i*2+1 );
p2.setPen( color1 );
p2.drawPoints( a );
p2.end();
TQApplication::flushX();
verticalLine->setMask( *verticalLine );
p2.begin( horizontalLine );
for( i=0; i < 64; i++ )
a.setPoint( i, i*2+1, 0 );
p2.setPen( color1 );
p2.drawPoints( a );
p2.end();
TQApplication::flushX();
horizontalLine->setMask( *horizontalLine );
}
p->setPen( cg.mid() );
if (flags & Style_Horizontal)
{
int point = r.x();
int other = r.y();
int end = r.x()+r.width();
int thickness = r.height();
while( point < end )
{
int i = 128;
if ( i+point > end )
i = end-point;
p->drawPixmap( point, other, *horizontalLine, 0, 0, i, thickness );
point += i;
}
} else {
int point = r.y();
int other = r.x();
int end = r.y()+r.height();
int thickness = r.width();
int pixmapoffset = (flags & Style_NoChange) ? 0 : 1; // ### Hackish
while( point < end )
{
int i = 128;
if ( i+point > end )
i = end-point;
p->drawPixmap( other, point, *verticalLine, 0, pixmapoffset, thickness, i );
point += i;
}
}
break;
}
default:
TDEStyle::drawTDEStylePrimitive(kpe, p, ceData, elementFlags, r, cg, flags, opt, widget);
}
}
void LipstikStyle::drawPrimitive(PrimitiveElement pe,
TQPainter *p,
const TQStyleControlElementData &ceData,
ControlElementFlags elementFlags,
const TQRect &r,
const TQColorGroup &cg,
SFlags flags,
const TQStyleOption &opt ) const
{
bool down = flags & Style_Down;
bool on = flags & Style_On;
bool sunken = flags & Style_Sunken;
bool horiz = flags & Style_Horizontal;
const bool enabled = flags & Style_Enabled;
const bool mouseOver = flags & Style_MouseOver;
bool hasFocus = flags & Style_HasFocus;
int x = r.x();
int y = r.y();
int w = r.width();
int h = r.height();
int x2, y2;
r.coords(&x, &y, &x2, &y2);
switch(pe) {
// BUTTONS
// -------
case PE_FocusRect: {
if(_drawFocusRect)
{
TQPen old = p->pen();
p->setPen( alphaBlendColors(cg.highlight(), getColor(cg,PanelLight), 120) );
p->drawRect( TQRect(r.topLeft(), r.bottomRight()));
p->setPen(old);
}
else
{
p->drawWinFocusRect( r );
}
break;
}
case PE_HeaderSectionMenu:
case PE_HeaderSection: {
// the taskbar buttons seems to be painted with PE_HeaderSection but I
// want them look like normal buttons (at least for now. :) )
if(!kickerMode) {
// Pat: Here I add another header painting method to
// optionnally give headers a "flat" look.
if(_flatHeaders) {
p->fillRect( r.left(), r.top(), r.width(), r.height(), cg.background() );
p->setPen( cg.background().dark(110) );
p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
p->drawLine( r.right(), r.bottom(), r.right(), r.top() );
break;
} else {
// detect if this is the left most header item
bool isFirst = false;
TQHeader *header = dynamic_cast<TQHeader*>(p->device() );
if (header) {
isFirst = header->mapToIndex(header->sectionAt(r.x() ) ) == 0;
}
uint contourFlags = Draw_Right|Draw_Top|Draw_Bottom;
if (isFirst)
contourFlags |= Draw_Left;
if(!enabled) contourFlags|=Is_Disabled;
renderContour(p, r, cg.background(), getColor(cg,ButtonContour),
contourFlags);
uint surfaceFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|Is_Horizontal;
if(!enabled) surfaceFlags|=Is_Disabled;
else {
if(on||down) surfaceFlags|=Is_Sunken;
else {
if(mouseOver) {
surfaceFlags|=Is_Highlight|Highlight_Top|Highlight_Bottom;
}
}
}
renderSurface(p, TQRect(isFirst?r.left()+1:r.left(), r.top()+1, isFirst?r.width()-2:r.width()-1, r.height()-2),
cg.background(), cg.button(), getColor(cg,MouseOverHighlight), _contrast,
surfaceFlags);
break;
}
}
}
case PE_ButtonBevel:
case PE_ButtonTool:
case PE_ButtonDropDown:
case PE_ButtonCommand: {
bool tdehtmlMode = opt.isDefault() ? false : tdehtmlWidgets.contains(opt.widget());
renderButton(p, r, cg, (on||down), mouseOver, true, enabled, tdehtmlMode );
break;
}
case PE_ButtonDefault: {
uint contourFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|
Round_UpperLeft|Round_UpperRight|Round_BottomLeft|Round_BottomRight;
if(!enabled) contourFlags|=Is_Disabled;
renderContour(p, r, cg.background(), cg.highlight(), contourFlags);
break;
}
case PE_SpinWidgetPlus:
case PE_SpinWidgetMinus: {
p->setPen( cg.buttonText() );
int l = TQMIN( w-2, h-2 );
// make the length even so that we get a nice symmetric plus...
if(l%2 != 0)
--l;
TQPoint c = r.center();
p->drawLine( c.x()-l/2, c.y(), c.x()+l/2, c.y() );
if ( pe == PE_SpinWidgetPlus ) {
p->drawLine( c.x(), c.y()-l/2, c.x(), c.y()+l/2 );
}
break;
}
case PE_ScrollBarSlider: {
const WidgetState s = enabled?(down?IsPressed:IsEnabled):IsDisabled;
const TQColor surface = getColor(cg, DragButtonSurface, s);
bool scrollbarHighlighted = false;
uint contourFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom;
if(!enabled) contourFlags|=Is_Disabled;
renderContour(p, r, cg.background(), getColor(cg, DragButtonContour, s),
contourFlags);
uint surfaceFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom|Is_Horizontal;
if(flags & Style_MouseOver)
{
scrollbarHighlighted = true;
if(horiz)
surfaceFlags |= Highlight_Right|Highlight_Left;
else
surfaceFlags |= Highlight_Top|Highlight_Bottom;
}
if(!enabled) surfaceFlags|=Is_Disabled;
if(r.height() >= 4)
renderSurface(p, TQRect(r.left()+1, r.top()+1, r.width()-2, r.height()-2),
cg.background(), surface, scrollbarHighlighted?cg.highlight():cg.background(),
_contrast+3, surfaceFlags);
//Now draw the dots.
p->setPen(alphaBlendColors(cg.background(), surface.dark(enabled?140:120), 50) );
int xPos = r.center().x();
int yPos = r.center().y();
if(horiz)
{
renderDot(p, TQPoint(xPos-6, yPos), surface, true, true );
renderDot(p, TQPoint(xPos-2, yPos), surface, true, true );
renderDot(p, TQPoint(xPos+2, yPos), surface, true, true );
renderDot(p, TQPoint(xPos+6, yPos), surface, true, true );
}
else
{
//--xPos;
renderDot(p, TQPoint(xPos, yPos-6), surface, true, true );
renderDot(p, TQPoint(xPos, yPos-2), surface, true, true );
renderDot(p, TQPoint(xPos, yPos+2), surface, true, true );
renderDot(p, TQPoint(xPos, yPos+6), surface, true, true );
}
break;
}
case PE_ScrollBarAddPage:
case PE_ScrollBarSubPage: {
// draw double buffered to avoid flicker...
TQPixmap buffer;
if(flags & Style_Horizontal) {
buffer.resize(2, r.height() );
} else {
buffer.resize(r.width(), 2 );
}
TQRect br(buffer.rect() );
TQPainter bp(&buffer);
if (on || down) {
bp.fillRect(br, TQBrush(cg.mid().dark()));
} else {
if(flags & Style_Horizontal) {
bp.setPen(cg.background().dark(106));
bp.drawLine(br.left(), br.top(), br.right(), br.top());
bp.setPen(cg.background().light(106));
bp.drawLine(br.left(), br.bottom(), br.right(), br.bottom());
bp.fillRect(br.left(), br.top()+1, br.width(), br.height()-2,cg.background());
} else {
bp.setPen(cg.background().dark(106));
bp.drawLine(br.left(), br.top(), br.left(), br.bottom());
bp.setPen(cg.background().light(106));
bp.drawLine(br.right(), br.top(), br.right(), br.bottom());
bp.fillRect(br.left()+1, br.top(), br.width()-2, br.height(),cg.background());
}
}
bp.fillRect(br, TQBrush(cg.background().light(), _paintGroove?Dense4Pattern:SolidPattern));
bp.end();
p->drawTiledPixmap(r, buffer, TQPoint(0, r.top()%2) );
break;
}
// SCROLLBAR BUTTONS
// -----------------
case PE_ScrollBarSubLine: {
uint contourFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom;
uint surfaceFlags = Draw_Left|Draw_Right|Draw_Top|Draw_Bottom;
if(down) surfaceFlags|=Is_Sunken;
if(!enabled) {
contourFlags|=Is_Disabled;
surfaceFlags|=Is_Disabled;
}
if(horiz) {
contourFlags |= Round_UpperLeft|Round_BottomLeft|Is_Horizontal;
surfaceFlags |= Round_UpperLeft|Round_BottomLeft|Is_Horizontal;
} else {
contourFlags |= Round_UpperLeft|Round_UpperRight|Is_Horizontal;
surfaceFlags |= Round_UpperLeft|Round_UpperRight|Is_Horizontal;
}
renderContour(p, r, cg.background(), getColor(cg, ButtonContour),
contourFlags);
renderSurface(p, TQRect(r.left()+1, r.top()+1, r.width()-2, r.height()-2),
cg.background(), cg.button(), getColor(cg,MouseOverHighlight), _contrast+3,
surfaceFlags);
p->setPen(cg.foreground());
drawPrimitive((horiz ? PE_ArrowLeft : PE_ArrowUp), p, ceData, elementFlags, r, cg, flags);