summaryrefslogtreecommitdiff
path: root/noncore/styles/liquid/liquid.cpp
Side-by-side diff
Diffstat (limited to 'noncore/styles/liquid/liquid.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/styles/liquid/liquid.cpp129
1 files changed, 68 insertions, 61 deletions
diff --git a/noncore/styles/liquid/liquid.cpp b/noncore/styles/liquid/liquid.cpp
index 51814e7..77cf198 100644
--- a/noncore/styles/liquid/liquid.cpp
+++ b/noncore/styles/liquid/liquid.cpp
@@ -1,27 +1,27 @@
/*-
* Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
*/
//
-// (c) 2002 Robert 'sandman' Griebl
+// (c) 2002 Robert 'sandman' Griebl
//
#ifndef INCLUDE_MENUITEM_DEF
#define INCLUDE_MENUITEM_DEF
#endif
#include "liquid.h"
-#include "effects.h"
+#include "effects.h"
#include "htmlmasks.h"
#include "embeddata.h"
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/config.h>
using namespace Opie::Core;
/* QT */
#include <qmenudata.h>
#include <qapplication.h>
#include <qpalette.h>
@@ -90,25 +90,25 @@ void TransMenuHandler::reloadSettings()
Config config ( "qpe" );
config. setGroup ( "Liquid-Style" );
type = config. readNumEntry("Type", TransStippleBg);
color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
opacity = config. readNumEntry("Opacity", 10);
if ( opacity < -20 )
opacity = 20;
else if ( opacity > 20 )
opacity = 20;
-
+
shadowText = config. readBoolEntry("ShadowText", true);
}
bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
{
QWidget *p = (QWidget *)obj;
if(ev->type() == QEvent::Show){
if(type == TransStippleBg || type == TransStippleBtn ||
type == Custom){
QApplication::syncX();
QPixmap *pix = new QPixmap;
@@ -128,61 +128,61 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
}
if(type == TransStippleBg){
stripePixmap(*pix, p->colorGroup().background());
}
else if(type == TransStippleBtn){
stripePixmap(*pix, p->colorGroup().button());
}
else{
QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
}
pixDict.insert(p->winId(), pix);
-
- if ( !p->inherits("QPopupMenu"))
+
+ if ( !p->inherits("QPopupMenu"))
p->setBackgroundPixmap(*pix);
-
+
QObjectList *ol = p-> queryList("QWidget");
for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
QWidget *wid = (QWidget *) it.current ( );
-
+
wid-> setBackgroundPixmap(*pix);
- wid-> setBackgroundOrigin(QWidget::ParentOrigin);
+ wid-> setBackgroundOrigin(QWidget::ParentOrigin);
}
delete ol;
}
}
else if(ev->type() == QEvent::Hide){
if(type == TransStippleBg || type == TransStippleBtn ||
type == Custom){
-// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl;
+// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl;
pixDict.remove(p->winId());
- if ( !p->inherits("QPopupMenu"))
+ if ( !p->inherits("QPopupMenu"))
p->setBackgroundMode(QWidget::PaletteBackground);
QObjectList *ol = p-> queryList("QWidget");
for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
QWidget *wid = (QWidget *) it.current ( );
-
+
wid-> setBackgroundMode( QWidget::PaletteBackground );
}
delete ol;
}
}
return(false);
}
-
+
LiquidStyle::LiquidStyle()
:QWindowsStyle()
{
setName ( "LiquidStyle" );
flatTBButtons = false;
currentHeader = 0;
btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
btnMaskBmp.setMask(btnMaskBmp);
htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
@@ -490,25 +490,25 @@ void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
}
QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v,
bool blend)
{
QImage img(qembed_findImage(label));
img.detach();
if(img.isNull()){ // shouldn't happen, been tested
- owarn << "Invalid embedded label " << label << "" << oendl;
+ owarn << "Invalid embedded label " << label << "" << oendl;
return(NULL);
}
if(img.depth() != 32)
img = img.convertDepth(32);
unsigned int *data = (unsigned int *)img.bits();
int total = img.width()*img.height();
int current;
QColor c;
int oldH, oldS, oldV;
int alpha;
if(v < 235)
v += 20;
@@ -590,28 +590,28 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
case RadioOn:
pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/);
break;
case RadioOnHover:
pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/);
break;
case Tab:
pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/);
break;
case TabDown:
pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/);
- break;
+ break;
case TabFocus:
pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/);
- break;
+ break;
case CB:
pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/);
break;
case CBHover:
pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/);
break;
case CBDown:
pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/);
break;
case CBDownHover:
pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/);
@@ -792,34 +792,34 @@ void LiquidStyle::polish(QWidget *w)
w->setBackgroundMode(QWidget::PaletteBackground);
w->setBackgroundOrigin(QWidget::ParentOrigin);
return;
}
if(w->inherits("QToolBar")){
w->installEventFilter(this);
w->setBackgroundMode(QWidget::PaletteBackground);
w->setBackgroundOrigin(QWidget::WidgetOrigin);
return;
}
if(w->inherits("QPopupMenu"))
w->setBackgroundMode(QWidget::NoBackground);
- else if(w-> testWFlags(Qt::WType_Popup) &&
- !w->inherits("QListBox") &&
+ else if(w-> testWFlags(Qt::WType_Popup) &&
+ !w->inherits("QListBox") &&
( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
w->installEventFilter(menuHandler);
}
-
+
if(w->isTopLevel()){
return;
}
-
+
if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
w->installEventFilter(this);
}
if(w->inherits("QButton") || w-> inherits("QComboBox")){
w-> setBackgroundMode ( QWidget::PaletteBackground );
w->setBackgroundOrigin ( QWidget::ParentOrigin);
}
bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
qstrcmp(w->name(), "qt_clipped_viewport") == 0;
bool isViewportChild = w->parent() &&
@@ -856,57 +856,57 @@ void LiquidStyle::polish(QWidget *w)
}
w-> installEventFilter ( this );
}
if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) {
((QFrame *) w)-> setFrameShape ( QFrame::NoFrame );
}
if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
return;
}
if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
palette().active().brush(QColorGroup::Background).pixmap()){
- owarn << "No parent pixmap for child widget " << w->className() << "" << oendl;
+ owarn << "No parent pixmap for child widget " << w->className() << "" << oendl;
return;
}
if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
!( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
if(w->backgroundMode() == QWidget::PaletteBackground ||
w->backgroundMode() == QWidget::PaletteButton){
w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/);
w->setBackgroundOrigin(QWidget::ParentOrigin);
// w->setBackgroundMode(QWidget::NoBackground);
}
}
if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame ))
- w-> setBackgroundOrigin ( QWidget::ParentOrigin );
+ w-> setBackgroundOrigin ( QWidget::ParentOrigin );
else if ( w-> inherits("QFrame") )
w->setBackgroundOrigin ( QWidget::WidgetOrigin );
if ( w->parentWidget()->inherits ( "QWidgetStack" )) {
w->setBackgroundOrigin ( QWidget::WidgetOrigin );
}
}
void LiquidStyle::unPolish(QWidget *w)
{
if(w->inherits("QMenuBar")){
((QFrame *)w)->setLineWidth(1);
w->setBackgroundMode(QWidget::PaletteBackground);
return;
}
if(w->inherits("QPopupMenu"))
w->setBackgroundMode(QWidget::PaletteButton);
- else if(w-> testWFlags(Qt::WType_Popup) &&
+ else if(w-> testWFlags(Qt::WType_Popup) &&
!w->inherits("QListBox") &&
( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
w->removeEventFilter(menuHandler);
}
if(w->isTopLevel())
return;
// for viewport children, don't just check for NoBackground....
bool isViewportChild = w->parent() &&
((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
(qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
@@ -950,63 +950,63 @@ void LiquidStyle::unPolish(QWidget *w)
}
void LiquidStyle::polish(QApplication *app)
{
QWindowsStyle::polish(app);
menuAni = app->isEffectEnabled(UI_AnimateMenu);
menuFade = app->isEffectEnabled(UI_FadeMenu);
if(menuAni)
app->setEffectEnabled(UI_AnimateMenu, false);
if(menuFade)
app->setEffectEnabled(UI_FadeMenu, false);
-
+
qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
-
+
Config config ( "qpe" );
config. setGroup ( "Liquid-Style" );
-
-// if ( config. readBoolEntry ( "WinDecoration", true ))
+
+// if ( config. readBoolEntry ( "WinDecoration", true ))
// QApplication::qwsSetDecoration ( new LiquidDecoration ( ));
-
+
flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false );
}
void LiquidStyle::unPolish(QApplication *app)
{
QWindowsStyle::unPolish(app);
app->setEffectEnabled(UI_AnimateMenu, menuAni);
app->setEffectEnabled(UI_FadeMenu, menuFade);
qt_set_draw_menu_bar_impl ( 0 );
-
+
// QApplication::qwsSetDecoration ( new QPEDecoration ( ));
}
/* !! HACK !! Beware
- *
+ *
* TT forgot to make the QProgressBar widget styleable in Qt 2.x
- * So the only way to customize the drawing, is to intercept the
+ * So the only way to customize the drawing, is to intercept the
* paint event - since we have to use protected functions, we need
* to derive a "hack" class from QProgressBar and do the painting
* in there.
- *
+ *
* - sandman
*/
class HackProgressBar : public QProgressBar {
public:
HackProgressBar ( );
-
+
void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix )
{
QPainter p( this );
if ( !contentsRect().contains( event->rect() ) ) {
p.save();
p.setClipRegion( event->region().intersect(frameRect()) );
drawFrame( &p);
p.restore();
}
if ( event->rect().intersects( contentsRect() )) {
p.setClipRegion( event->region().intersect( contentsRect() ) );
@@ -1022,48 +1022,48 @@ public:
total = 1;
int bw = w * prog / total;
if ( bw > w )
bw = w;
p.setPen(g.button().dark(130));
p.drawRect(x, y, bw, h);
p.setPen(g.button().light(120));
p.drawRect(x+1, y+1, bw-2, h-2);
if(bw >= 4 && h >= 4 && pix)
p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix);
-
- if ( progress ( )>= 0 && totalSteps ( ) > 0 ) {
+
+ if ( progress ( )>= 0 && totalSteps ( ) > 0 ) {
QString pstr;
pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
p. setPen ( g.text());//g.highlightedText ( ));
p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
}
}
}
};
/*
* The same for QToolButton:
* TT hardcoded the drawing of the focus rect ...
*
* - sandman
*/
class HackToolButton : public QToolButton {
public:
HackToolButton ( );
-
+
void paint ( QPaintEvent *ev )
{
erase ( ev-> region ( ));
QPainter p ( this );
style ( ). drawToolButton ( this, &p );
drawButtonLabel ( &p );
}
};
/*
* This is a fun method ;-) Here's an overview. KToolBar grabs resize to
* force everything to erase and repaint on resize. This is going away, I'm
@@ -1089,25 +1089,25 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
QObjectListIt it(*tbChildList);
QObject *child;
while((child = it.current()) != NULL){
++it;
if(child->isWidgetType())
((QWidget *)child)->repaint(true);
}
}
}
else if(obj->inherits("QToolButton")){
QToolButton *btn = (QToolButton *)obj;
- if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
+ if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
if(btn->isEnabled()){
highlightWidget = btn;
btn->repaint(false);
}
}
else if(ev->type() == QEvent::FocusOut ){
if(btn == highlightWidget){
highlightWidget = NULL;
btn->repaint(false);
}
}
else if(ev->type() == QEvent::Paint) {
@@ -1129,25 +1129,25 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
: indicatorSize();
/*
if(btn->hasFocus()){
QRect r = QRect(0, 0, btn->width(), btn->height());
p.setPen(btn->colorGroup().button().dark(140));
p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
}
*/
- int x = 0;
+ int x = 0;
int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
if(isRadio)
drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
btn->colorGroup(), btn->isOn(),
btn->isDown(), btn->isEnabled());
else
drawIndicator(&p, x, y, sz.width(), sz.height(),
btn->colorGroup(), btn->state(), btn->isDown(),
btn->isEnabled());
x = sz.width() + 6;
y = 0;
drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1),
@@ -1184,37 +1184,37 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
}
if(headerHoverID != -1){
hw->repaint(hw->sectionPos(headerHoverID), 0,
hw->sectionSize(headerHoverID), hw->height());
}
}
}
}
else if (obj-> inherits( "QProgressBar" )) {
if ( ev->type() == QEvent::Paint ) {
HackProgressBar *p = (HackProgressBar *) obj;
const QColorGroup &g = p-> colorGroup ( );
-
+
QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb());
if(!pix){
int h, s, v;
g.button().dark(120).hsv(&h, &s, &v);
pix = new QPixmap(*bevelFillPix);
adjustHSV(*pix, h, s, v);
bevelFillDict.insert(g.button().dark(120).rgb(), pix);
}
p-> paint ((QPaintEvent *) ev, g, pix );
- return true;
+ return true;
}
- }
+ }
return false ;
}
void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush *)
{
drawRoundButton(p, sunken ? g.background() : g.button(), g.background(),
x, y, w, h);
}
void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
@@ -1294,33 +1294,37 @@ void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
bool act = btn->isOn() || btn->isDown();
if(act){
++x1, ++y1;
}
// Draw iconset first, if any
if ( btn->iconSet() && !btn->iconSet()->isNull() )
{
QIconSet::Mode mode = btn->isEnabled()
? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && btn->hasFocus() )
mode = QIconSet::Active;
- QPixmap pixmap = btn->iconSet()->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = btn->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = btn->iconSet()->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x1+6, y1+h/2-pixh/2, pixmap );
x1 += pixw + 8;
w -= pixw + 8;
}
-
+
if(act){
QFont font = btn->font();
font.setBold(true);
p->setFont(font);
QColor shadow(btn->colorGroup().button().dark(130));
drawItem( p, x1+1, y1+1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&shadow);
drawItem( p, x1, y1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
@@ -1396,37 +1400,37 @@ QRect LiquidStyle::buttonRect(int x, int y, int w, int h)
}
void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
bool edit, bool, const QBrush *)
{
bool isActive = false;
if (( painter->device()->devType() == QInternal::Widget ) &&
(
( qApp-> focusWidget ( ) == painter-> device ( )) ||
(
edit &&
- ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
+ ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) ||
qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( ))
)
)
) {
isActive = true;
}
-
+
bool isMasked = false;
if(painter->device()->devType() == QInternal::Widget)
isMasked = ((QWidget*)painter->device())->autoMask();
- // TODO: Do custom code, don't just call drawRoundButton into a pixmap
+ // TODO: Do custom code, don't just call drawRoundButton into a pixmap
QPixmap tmpPix(w, h);
QPainter p(&tmpPix);
drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false,
sunken, false, isMasked);
if(!isActive){
p.setClipRect(0, 0, w-17, h);
drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false,
sunken, false, isMasked);
}
p.end();
int x2 = x+w-1;
@@ -1469,25 +1473,25 @@ void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h)
drawButtonMask(p, x, y, w, h);
}
QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
{
//return(QRect(x+3, y+3, w - (h / 3) - 13, h-6));
return(QRect(x+9, y+3, w - (h / 3) - 20, h-6));
}
QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/)
{
return QRect ( );
-
+
// return(QRect(x+5, y+3, w-(h/3)-13, h-5));
}
void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
int sliderStart, uint controls,
uint activeControl)
{
int sliderMin, sliderMax, sliderLength, buttonDim;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if (sliderStart > sliderMax)
sliderStart = sliderMax;
@@ -1624,40 +1628,40 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
painter.setPen(g.mid());
painter.drawPoint(bgR.x(), bgR.y()+1);
painter.drawPoint(bgR.x(), bgR.bottom()-1);
painter.drawPoint(bgR.right()-1, bgR.y()+1);
painter.drawPoint(bgR.right()-1, bgR.bottom()-1);
}
if(controls & Slider){
if(sliderR.width() >= 16){
painter.drawPixmap(sliderR.x(), sliderR.y()+1,
*getPixmap(HSBSliderTop));
painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16,
13, *getPixmap(HSBSliderMid));
- painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
+ painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
*getPixmap(HSBSliderBtm));
}
else if(sliderR.width() >= 8){
int m = sliderR.width()/2;
painter.drawPixmap(sliderR.x(), sliderR.y()+1,
*getPixmap(HSBSliderTop), 0, 0, m, 13);
- painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
+ painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
*getPixmap(HSBSliderBtm), 8-m, 0, m, 13);
}
else{
painter.setPen(g.button().dark(210));
drawRoundRect(&painter, sliderR.x(), sliderR.y()+1,
sliderR.width(), 13);
painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
- sliderR.width()-2, 11,
+ sliderR.width()-2, 11,
*getPixmap(HSBSliderMid), 0, 1);
}
}
painter.setPen(g.mid());
painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y());
painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
if(brokenApp && (controls & Slider)){
painter.setPen(g.background());
painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(),
bgR.bottom()-1);
}
painter.end();
@@ -1967,48 +1971,48 @@ void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x,
default:
a.setPoints(QCOORDARRLEN(r_arrow), r_arrow);
break;
}
a.translate(x, y);
p->drawLineSegments(a);
}
void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h,
QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active )
-{
+{
if(active){
- x -= 2; // Bug in Qt/E
+ x -= 2; // Bug in Qt/E
y -= 2;
w += 2;
h += 2;
}
-
+
QWidget *parent = (QWidget *)p->device();
p->setBrushOrigin(parent->pos());
parent->erase(x, y, w, h);
-
+
if(menuHandler->useShadowText()){
QColor shadow;
if(p->device() && p->device()->devType() == QInternal::Widget &&
((QWidget *)p->device())->inherits("QMenuBar")){
shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) :
g.background().dark(130);
}
else
shadow = g.background().dark(130);
QPixmap *dummy = 0;
-
+
if ( mi-> pixmap ( ) && !mi-> pixmap ( )-> isNull ( )) {
dummy = new QPixmap ( mi-> pixmap ( )-> size ( ));
QBitmap dummy_mask ( dummy-> size ( ));
dummy_mask. fill ( color1 );
dummy-> setMask ( dummy_mask );
}
if(active){
drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
QApplication::style().drawItem(p, x+1, y+1, w, h,
AlignCenter|ShowPrefix|DontClip|SingleLine,
g, mi->isEnabled(), dummy, mi->text(),
@@ -2146,25 +2150,29 @@ static const int windowsRightBorder = 12;
c = menuHandler->bgColor();
}
p->setPen(c.dark(140));
p->drawLine(x, y, x+w, y );
p->setPen(c.light(115));
p->drawLine(x, y+1, x+w, y+1 );
return;
}
if(mi->iconSet()) {
QIconSet::Mode mode = dis? QIconSet::Disabled : QIconSet::Normal;
if (!dis)
mode = QIconSet::Active;
- QPixmap pixmap = mi->iconSet()->pixmap(QIconSet::Small, mode);
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = mi->iconSet()->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
QRect cr(x, y, checkcol, h);
QRect pmr(0, 0, pixw, pixh);
pmr.moveCenter( cr.center() );
p->setPen(itemg.highlightedText());
p->drawPixmap(pmr.topLeft(), pixmap );
}
else if(checkable) {
int mw = checkcol + motifItemFrame;
int mh = h - 2*motifItemFrame;
@@ -2227,26 +2235,25 @@ static const int windowsRightBorder = 12;
int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi,
const QFontMetrics &fm)
{
if (mi->isSeparator())
return 2;
int h = 0;
if (mi->pixmap())
h = mi->pixmap()->height();
if (mi->iconSet())
- h = QMAX(mi->iconSet()->
- pixmap(QIconSet::Small, QIconSet::Normal).height(), h);
+ h = QMAX(mi->iconSet()->pixmap().height(), h);
h = QMAX(fm.height() + 4, h);
// we want a minimum size of 18
h = QMAX(h, 18);
return h;
}
void LiquidStyle::drawFocusRect(QPainter *p, const QRect &r,
const QColorGroup &g, const QColor *c,
@@ -2421,25 +2428,25 @@ void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
else if(lineWidth != 2 || !sunken)
QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill);
else{
QPen oldPen = p->pen();
int x2 = x+w-1;
int y2 = y+h-1;
p->setPen(g.light());
p->drawLine(x, y2, x2, y2);
p->drawLine(x2, y, x2, y2);
p->setPen(g.mid());
p->drawLine(x, y, x2, y);
p->drawLine(x, y, x, y2);
-
+
p->setPen(g.midlight());
p->drawLine(x+1, y2-1, x2-1, y2-1);
p->drawLine(x2-1, y+1, x2-1, y2-1);
p->setPen(g.dark());
p->drawLine(x+1, y+1, x2-1, y+1);
p->drawLine(x+1, y+1, x+1, y2-1);
p->setPen(oldPen);
if(fill){
// I believe here we are only supposed to fill if there is a
// specified fill brush...
p->fillRect(x+2, y+2, w-4, h-4, *fill);
}
@@ -2479,46 +2486,46 @@ void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v)
}
void LiquidStyle::intensity(QPixmap &pix, float percent)
{
QImage image = pix.convertToImage();
int i, tmp, r, g, b;
int segColors = image.depth() > 8 ? 256 : image.numColors();
unsigned char *segTbl = new unsigned char[segColors];
int pixels = image.depth() > 8 ? image.width()*image.height() :
image.numColors();
unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() :
(unsigned int *)image.colorTable();
-
+
bool brighten = (percent >= 0);
if(percent < 0)
percent = -percent;
-
+
if(brighten){ // keep overflow check out of loops
for(i=0; i < segColors; ++i){
tmp = (int)(i*percent);
if(tmp > 255)
tmp = 255;
segTbl[i] = tmp;
}
}
else{
for(i=0; i < segColors; ++i){
tmp = (int)(i*percent);
if(tmp < 0)
tmp = 0;
segTbl[i] = tmp;
}
}
-
+
if(brighten){ // same here
for(i=0; i < pixels; ++i){
r = qRed(data[i]);
g = qGreen(data[i]);
b = qBlue(data[i]);
r = r + segTbl[r] > 255 ? 255 : r + segTbl[r];
g = g + segTbl[g] > 255 ? 255 : g + segTbl[g];
b = b + segTbl[b] > 255 ? 255 : b + segTbl[b];
data[i] = qRgb(r, g, b);
}
}
else{