summaryrefslogtreecommitdiff
authordrw <drw>2005-04-14 18:30:23 (UTC)
committer drw <drw>2005-04-14 18:30:23 (UTC)
commit5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf (patch) (side-by-side diff)
treed4ba8a948d876db9bbff10cbd282fd16aab91feb
parent7a3b813cc3bfbb2f7c31f347c35405851e82aecf (diff)
downloadopie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.zip
opie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.tar.gz
opie-5fd266a3a5a6d9a1acb9c38e4802ff06ba38beaf.tar.bz2
More icon sizing updates
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/launchertab.cpp24
-rw-r--r--core/settings/launcher/menusettings.cpp44
-rw-r--r--libopie2/opieui/otabbar.cpp50
-rw-r--r--libopie2/opieui/otabbar.h46
-rw-r--r--libopie2/opieui/otabwidget.cpp1
-rw-r--r--noncore/styles/flat/flat.cpp18
-rw-r--r--noncore/styles/fresh/fresh.cpp18
-rw-r--r--noncore/styles/liquid/liquid.cpp129
-rw-r--r--noncore/styles/phase/phasestyle.cpp14
-rw-r--r--noncore/styles/theme/othemestyle.cpp53
-rw-r--r--noncore/styles/web/webstyle.cpp126
-rw-r--r--noncore/styles/web/webstyle.h2
12 files changed, 338 insertions, 187 deletions
diff --git a/core/launcher/launchertab.cpp b/core/launcher/launchertab.cpp
index 710f259..72ebf59 100644
--- a/core/launcher/launchertab.cpp
+++ b/core/launcher/launchertab.cpp
@@ -92,69 +92,69 @@ void LauncherTabBar::layoutTabs()
for (it.toFirst(); it.current(); ++it ) {
t = it.current();
if ( !t )
continue;
int iw = fm.width( t->text() ) + hframe - overlap;
if ( t != current ) {
available -= hiddenTabWidth + hframe - overlap;
if ( t->iconSet() != 0 )
- available -= t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
+ available -= t->iconSet()->pixmap().width();
}
if ( t->iconSet() != 0 )
- iw += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
+ iw += t->iconSet()->pixmap().width();
required += iw;
// As space gets tight, packed looks better than even. "10" must be at least 0.
if ( iw >= eventabwidth-10 )
mode = Pack;
}
if ( mode == Pack && required > width()-1 )
mode = HideBackText;
for ( it.toFirst(); it.current(); ++it ) {
t = it.current();
if ( !t )
continue;
if ( mode != HideBackText ) {
int w = fm.width( t->text() );
int ih = 0;
if ( t->iconSet() != 0 ) {
- w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
- ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
+ w += t->iconSet()->pixmap().width();
+ ih = t->iconSet()->pixmap().height();
}
int h = QMAX( fm.height(), ih );
h = QMAX( h, QApplication::globalStrut().height() );
h += vframe;
w += hframe;
QRect totr(x, 0,
mode == Even ? eventabwidth : w * (width()-1)/required, h);
t->setRect(totr);
x += totr.width() - overlap;
r = r.unite(totr);
} else if ( t != current ) {
int w = hiddenTabWidth;
int ih = 0;
if ( t->iconSet() != 0 ) {
- w += t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width();
- ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
+ w += t->iconSet()->pixmap().width();
+ ih = t->iconSet()->pixmap().height();
}
int h = QMAX( fm.height(), ih );
h = QMAX( h, QApplication::globalStrut().height() );
h += vframe;
w += hframe;
t->setRect( QRect(x, 0, w, h) );
x += t->rect().width() - overlap;
r = r.unite( t->rect() );
} else {
int ih = 0;
if ( t->iconSet() != 0 ) {
- ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
+ ih = t->iconSet()->pixmap().height();
}
int h = QMAX( fm.height(), ih );
h = QMAX( h, QApplication::globalStrut().height() );
h += vframe;
t->setRect( QRect(x, 0, available, h) );
x += t->rect().width() - overlap;
@@ -215,18 +215,18 @@ void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const
pal.setColor( QPalette::Inactive, QColorGroup::Foreground, ct->fgColor );
that->setUpdatesEnabled( FALSE );
that->setPalette( pal );
setPal = TRUE;
}
int iw = 0;
int ih = 0;
if ( t->iconSet() != 0 ) {
- iw = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).width() + 2;
- ih = t->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height();
+ iw = t->iconSet()->pixmap().width() + 2;
+ ih = t->iconSet()->pixmap().height();
}
int w = iw + p->fontMetrics().width( t->text() ) + 4;
int h = QMAX(p->fontMetrics().height() + 4, ih );
paintLabel( p, QRect( r.left() + (r.width()-w)/2 - 3,
r.top() + (r.height()-h)/2, w, h ), t,
#if QT_VERSION >= 0x030000
t->identifier() == keyboardFocusTab()
#else
@@ -246,17 +246,21 @@ void LauncherTabBar::paintLabel( QPainter* p, const QRect&,
// if ( t->id != currentTab() )
//r.moveBy( 1, 1 );
//
if ( t->iconSet() ) {
// the tab has an iconset, draw it in the right mode
QIconSet::Mode mode = (t->isEnabled() && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && has_focus )
mode = QIconSet::Active;
- QPixmap pixmap = t->iconSet()->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = t->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = t->iconSet()->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( r.left() + 6, r.center().y() - pixh / 2 + 1, pixmap );
r.setLeft( r.left() + pixw + 5 );
}
QRect tr = r;
diff --git a/core/settings/launcher/menusettings.cpp b/core/settings/launcher/menusettings.cpp
index 55bf358..29ce841 100644
--- a/core/settings/launcher/menusettings.cpp
+++ b/core/settings/launcher/menusettings.cpp
@@ -1,31 +1,31 @@
/*
-                This file is part of the OPIE Project
+ This file is part of the OPIE Project
=. Copyright (c) 2002 Trolltech AS <info@trolltech.com>
-             .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
-           .>+-=
- _;:,     .>    :=|. This file is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This file 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 General
-..}^=.=       =       ; Public License for more details.
-++=   -.     .`     .:
- :     =  ...= . :.=- You should have received a copy of the GNU
- -.   .:....=;==+<; General Public License along with this file;
-  -_. . .   )=.  = see the file COPYING. If not, write to the
-    --        :-=` Free Software Foundation, Inc.,
+ .=l. Copyright (c) 2002 Robert Griebl <sandman@handhelds.org>
+ .>+-=
+_;:, .> :=|. This file is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU General Public
+.="- .-=="i, .._ License as published by the Free Software
+- . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This file 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 General
+..}^=.= = ; Public License for more details.
+++= -. .` .:
+: = ...= . :.=- You should have received a copy of the GNU
+-. .:....=;==+<; General Public License along with this file;
+ -_. . . )=. = see the file COPYING. If not, write to the
+ -- :-=` Free Software Foundation, Inc.,
59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "menusettings.h"
#include <qpe/config.h>
@@ -100,17 +100,17 @@ void MenuSettings::init ( )
QTranslator *trans = new QTranslator ( qApp );
QString type = (*it). left ((*it). find ("."));
QString tfn = QPEApplication::qpeDir ( ) + "i18n/" + lang + "/" + type + ".qm";
if ( trans-> load ( tfn ))
qApp-> installTranslator ( trans );
else
delete trans;
name = iface-> name ( );
- icon = iface-> icon ( ). pixmap ( QIconSet::Small, QIconSet::Normal );
+ icon = iface-> icon ( ). pixmap ();
iface-> release ( );
lib-> unload ( );
QCheckListItem *item;
item = new QCheckListItem ( m_list, name, QCheckListItem::CheckBox );
if ( !icon. isNull ( ))
item-> setPixmap ( 0, icon );
item-> setOn ( exclude. find ( *it ) == exclude. end ( ));
diff --git a/libopie2/opieui/otabbar.cpp b/libopie2/opieui/otabbar.cpp
index a62e18b..dc5df42 100644
--- a/libopie2/opieui/otabbar.cpp
+++ b/libopie2/opieui/otabbar.cpp
@@ -1,41 +1,45 @@
/*
-                This file is part of the Opie Project
-
-              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
+ This file is part of the Opie Project
+
+ Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
=.
.=l.
-           .>+-=
- _;:,     .>    :=|. This program is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This program 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.
+ .>+-=
+_;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+- . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include <opie2/otabbar.h>
+#include <qpe/applnk.h>
+
+#include <stdio.h>
+
using namespace Opie::Ui;
OTabBar::OTabBar( QWidget *parent , const char *name )
:QTabBar( parent, name )
{}
void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const
{
@@ -43,17 +47,17 @@ void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus
QRect r = br;
if ( t->iconset)
{
QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
if ( mode == QIconSet::Normal && has_focus )
{
mode = QIconSet::Active;
}
- QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode );
+ QPixmap pixmap = t->iconset->pixmap();
int pixw = pixmap.width();
int pixh = pixmap.height();
r.setLeft( r.left() + pixw + 2 );
p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap );
}
QRect tr = r;
if ( t->id == currentTab() )
diff --git a/libopie2/opieui/otabbar.h b/libopie2/opieui/otabbar.h
index 925ae96..1044bdd 100644
--- a/libopie2/opieui/otabbar.h
+++ b/libopie2/opieui/otabbar.h
@@ -1,37 +1,37 @@
/*
-                This file is part of the Opie Project
-
-              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
+ This file is part of the Opie Project
+
+ Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
=.
.=l.
-           .>+-=
- _;:,     .>    :=|. This program is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This program 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.
+ .>+-=
+_;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+- . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program 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., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
-
+
*/
#ifndef OTABBAR_H
#define OTABBAR_H
/* QT */
#include <qtabbar.h>
diff --git a/libopie2/opieui/otabwidget.cpp b/libopie2/opieui/otabwidget.cpp
index 7333f5e..d617a9c 100644
--- a/libopie2/opieui/otabwidget.cpp
+++ b/libopie2/opieui/otabwidget.cpp
@@ -29,17 +29,16 @@
*/
#include <opie2/otabwidget.h>
/* OPIE */
#include <opie2/oresource.h>
#include <opie2/otabbar.h>
-#include <qpe/applnk.h>
#include <qpe/config.h>
/* QT */
#include <qcombobox.h>
#include <qwidgetstack.h>
using namespace Opie::Ui;
diff --git a/noncore/styles/flat/flat.cpp b/noncore/styles/flat/flat.cpp
index f3bacf9..c164ecc 100644
--- a/noncore/styles/flat/flat.cpp
+++ b/noncore/styles/flat/flat.cpp
@@ -368,17 +368,17 @@ void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
w -= dx;
}
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 = btn->iconSet()->pixmap( QIconSet::Automatic, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x+2, y+h/2-pixh/2, pixmap );
x += pixw + 4;
w -= pixw + 4;
}
drawItem( p, x, y, w, h,
AlignCenter | ShowPrefix,
@@ -386,18 +386,18 @@ void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
btn->pixmap(), btn->text(), -1, &cg.buttonText() );
}
QRect FlatStyle::comboButtonRect( int x, int y, int w, int h)
{
return QRect(x+2, y+2, w-4-13, h-4);
}
-
-
+
+
QRect FlatStyle::comboButtonFocusRect( int x, int y, int w, int h)
{
return QRect(x+2, y+2, w-4-14, h-4);
}
void FlatStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
bool /*editable*/,
@@ -887,39 +887,39 @@ int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* m
return w;
#endif
}
/*! \reimp
*/
int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
{
-#ifndef QT_NO_MENUDATA
+#ifndef QT_NO_MENUDATA
int h = 0;
if ( mi->isSeparator() ) // separator height
h = motifSepHeight;
else if ( mi->pixmap() ) // pixmap height
h = mi->pixmap()->height() + 2*motifItemFrame;
else // text height
h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
- h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame );
+ h = QMAX( h, mi->iconSet()->pixmap().height() + 2*motifItemFrame );
}
if ( mi->custom() )
h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
return h;
#endif
}
void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
const QPalette& pal,
bool act, bool enabled, int x, int y, int w, int h)
{
-#ifndef QT_NO_MENUDATA
+#ifndef QT_NO_MENUDATA
const QColorGroup & g = pal.active();
bool dis = !enabled;
QColorGroup itemg = dis ? pal.disabled() : pal.active();
if ( checkable )
maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
int checkcol = maxpmw;
@@ -949,17 +949,21 @@ void FlatStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int
p->fillRect(x, y, checkcol , h,
g.brush( QColorGroup::Button ));
}
if ( mi->iconSet() ) { // draw iconset
QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
if (act && !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();
if ( act && !dis ) {
if ( !mi->isChecked() )
qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
}
QRect cr( x, y, checkcol, h );
QRect pmr( 0, 0, pixw, pixh );
diff --git a/noncore/styles/fresh/fresh.cpp b/noncore/styles/fresh/fresh.cpp
index 831b620..856f68b 100644
--- a/noncore/styles/fresh/fresh.cpp
+++ b/noncore/styles/fresh/fresh.cpp
@@ -142,18 +142,18 @@ void FreshStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
{
drawButton( p, x, y, w, h, g, sunken, fill );
}
QRect FreshStyle::comboButtonRect( int x, int y, int w, int h)
{
return QRect(x+1, y+1, w-2-14, h-2);
}
-
-
+
+
QRect FreshStyle::comboButtonFocusRect( int x, int y, int w, int h)
{
return QRect(x+2, y+2, w-4-14, h-4);
}
void FreshStyle::drawComboButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
bool /*editable*/,
@@ -523,17 +523,17 @@ void FreshStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected
r.setRect( r.left() + 2, r.top() + 2,
r.width() - 4, r.height() - 2 );
p->setPen( tb->colorGroup().button() );
p->drawLine( r.left()+2, r.top()+1, r.right()-2, r.top()+1 );
p->fillRect( QRect( r.left()+1, r.top()+2, r.width()-2, r.height()-3),
tb->colorGroup().brush( QColorGroup::Button ));
//do shading; will not work for pixmap brushes
- QColor bg = tb->colorGroup().button();
+ QColor bg = tb->colorGroup().button();
// int h,s,v;
// bg.hsv( &h, &s, &v );
int n = r.height()/2;
int dark = 100;
for ( int i = 1; i < n; i++ ) {
dark = (dark * (100+(i*15)/n) )/100;
p->setPen( bg.dark( dark ) );
int y = r.bottom()-n+i;
@@ -633,39 +633,39 @@ int FreshStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem*
return w;
#endif
}
/*! \reimp
*/
int FreshStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
{
-#ifndef QT_NO_MENUDATA
+#ifndef QT_NO_MENUDATA
int h = 0;
if ( mi->isSeparator() ) // separator height
h = motifSepHeight;
else if ( mi->pixmap() ) // pixmap height
h = mi->pixmap()->height() + 2*motifItemFrame;
else // text height
h = fm.height() + 2*motifItemVMargin + 2*motifItemFrame - 1;
if ( !mi->isSeparator() && mi->iconSet() != 0 ) {
- h = QMAX( h, mi->iconSet()->pixmap( QIconSet::Small, QIconSet::Normal ).height() + 2*motifItemFrame );
+ h = QMAX( h, mi->iconSet()->pixmap().height() + 2*motifItemFrame );
}
if ( mi->custom() )
h = QMAX( h, mi->custom()->sizeHint().height() + 2*motifItemVMargin + 2*motifItemFrame ) - 1;
return h;
#endif
}
void FreshStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int tab, QMenuItem* mi,
const QPalette& pal,
bool act, bool enabled, int x, int y, int w, int h)
{
-#ifndef QT_NO_MENUDATA
+#ifndef QT_NO_MENUDATA
const QColorGroup & g = pal.active();
bool dis = !enabled;
QColorGroup itemg = dis ? pal.disabled() : pal.active();
if ( checkable )
maxpmw = QMAX( maxpmw, 8 ); // space for the checkmarks
int checkcol = maxpmw;
@@ -697,17 +697,21 @@ void FreshStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw, int
p->fillRect(x, y, checkcol , h,
g.brush( QColorGroup::Button ));
}
if ( mi->iconSet() ) { // draw iconset
QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
if (act && !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();
if ( act && !dis ) {
if ( !mi->isChecked() )
qDrawShadePanel( p, x, y, checkcol, h, g, FALSE, 1, &g.brush( QColorGroup::Button ) );
}
QRect cr( x, y, checkcol, h );
QRect pmr( 0, 0, pixw, pixh );
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,23 +1,23 @@
/*-
* 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;
@@ -94,17 +94,17 @@ void TransMenuHandler::reloadSettings()
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){
@@ -132,53 +132,53 @@ bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
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;
@@ -494,17 +494,17 @@ 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;
@@ -594,20 +594,20 @@ QPixmap* LiquidStyle::getPixmap(BitmapData item)
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:
@@ -796,26 +796,26 @@ void LiquidStyle::polish(QWidget *w)
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);
}
@@ -860,30 +860,30 @@ void LiquidStyle::polish(QWidget *w)
((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 );
}
}
@@ -892,17 +892,17 @@ 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;
@@ -954,55 +954,55 @@ 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);
@@ -1026,18 +1026,18 @@ public:
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);
}
}
}
};
@@ -1049,17 +1049,17 @@ public:
*
* - sandman
*/
class HackToolButton : public QToolButton {
public:
HackToolButton ( );
-
+
void paint ( QPaintEvent *ev )
{
erase ( ev-> region ( ));
QPainter p ( this );
style ( ). drawToolButton ( this, &p );
drawButtonLabel ( &p );
}
};
@@ -1093,17 +1093,17 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
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;
@@ -1133,17 +1133,17 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
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(),
@@ -1188,29 +1188,29 @@ bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
}
}
}
}
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(),
@@ -1298,25 +1298,29 @@ void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
// 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,
@@ -1400,29 +1404,29 @@ void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
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,
@@ -1473,17 +1477,17 @@ 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;
@@ -1628,32 +1632,32 @@ void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
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());
@@ -1971,40 +1975,40 @@ void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x,
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){
@@ -2150,17 +2154,21 @@ static const int windowsRightBorder = 12;
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 );
@@ -2231,18 +2239,17 @@ int LiquidStyle::popupMenuItemHeight(bool /*checkable*/, QMenuItem *mi,
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;
}
@@ -2425,17 +2432,17 @@ void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
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){
@@ -2483,38 +2490,38 @@ 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];
diff --git a/noncore/styles/phase/phasestyle.cpp b/noncore/styles/phase/phasestyle.cpp
index 746354e..c2b9de8 100644
--- a/noncore/styles/phase/phasestyle.cpp
+++ b/noncore/styles/phase/phasestyle.cpp
@@ -385,17 +385,20 @@ void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) {
#if 0
if (button->isToggleButton() && button->isOn()) {
state = true;
} else {
state = false;
}
#endif
- pixmap = button->iconSet()->pixmap(QIconSet::Small, mode);
+ if ( mode == QIconSet::Disabled )
+ pixmap = button->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = button->iconSet()->pixmap();
if (button->text().isEmpty() && !button->pixmap()) {
painter->drawPixmap(x+w/2 - pixmap.width()/2,
y+h/2 - pixmap.height()/2, pixmap);
} else {
painter->drawPixmap(x+4, y+h/2 - pixmap.height()/2, pixmap);
}
x += pixmap.width() + 4;
w -= pixmap.width() + 4;
@@ -564,18 +567,17 @@ int PhaseStyle::popupMenuItemHeight ( bool ,
if ( mi->pixmap() ) {
h = QMAX(h, mi->pixmap()->height() + ITEMFRAME*2);
}else {
h = QMAX(h, MINICONSIZE+ITEMFRAME*2 );
h = QMAX(h, fm.height()
+ ITEMVMARGIN*2 + ITEMFRAME*2 );
}
if ( mi->iconSet() )
- h = QMAX(h, mi->iconSet()->
- pixmap(QIconSet::Small, QIconSet::Normal ).height()
+ h = QMAX(h, mi->iconSet()->pixmap().height()
+ ITEMFRAME*2 );
}
return h;
}
int PhaseStyle::extraPopupMenuItemWidth(bool checkable, int maxpmw,
@@ -656,17 +658,21 @@ void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable,
// draw icon
QIconSet::Mode mode;
if ( mi->iconSet() && !mi->isChecked() ) {
if ( act )
mode = enabled ? QIconSet::Active : QIconSet::Disabled;
else
mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
- 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();
QRect pmrect(0, 0, pixmap.width(), pixmap.height() );
QRect cr(x, y, maxpmw, h );
pmrect.moveCenter( cr.center() );
p->drawPixmap(pmrect.topLeft(), pixmap);
}
// draw check
if(mi->isChecked() ) {
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp
index 98e7253..106d206 100644
--- a/noncore/styles/theme/othemestyle.cpp
+++ b/noncore/styles/theme/othemestyle.cpp
@@ -32,30 +32,30 @@
typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
QColorGroup &, bool, bool);
QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
/* !! 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, OThemeStyle *style )
{
QPainter p( this );
if ( !contentsRect().contains( event->rect() ) ) {
p.save();
p.setClipRegion( event->region().intersect(frameRect()) );
drawFrame( &p);
@@ -70,19 +70,19 @@ public:
int prog = progress ( );
int total = totalSteps ( );
if ( prog < 0 )
prog = 0;
if ( total <= 0 )
total = 1;
int perc = prog * 100 / total;
- style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc );
+ style-> drawProgressBar ( &p, x, y, w, h, colorGroup ( ), perc );
- if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) {
+ if ( progress ( ) >= 0 && totalSteps ( ) > 0 ) {
QString pstr;
pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
p. setPen ( colorGroup().text());//g.highlightedText ( ));
p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
}
}
}
};
@@ -104,43 +104,43 @@ void OThemeStyle::polish( QApplication * /*app*/ )
{
qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &OThemeStyle::drawMenuBarItem);
}
void OThemeStyle::polish( QPalette &p )
{
oldPalette = p;
-
+
QColor bg = oldPalette. color ( QPalette::Normal, QColorGroup::Background );
if ( bgcolor. isValid ( ))
bg = bgcolor;
- if ( isColor ( Background ))
+ if ( isColor ( Background ))
bg = colorGroup ( oldPalette. active ( ), Background )-> background ( );
p = QPalette ( bg, bg );
if ( isPixmap( Background ) )
p. setBrush ( QColorGroup::Background, QBrush ( bg, *uncached ( Background )));
if ( fgcolor. isValid ( )) {
- p. setColor ( QColorGroup::Foreground, fgcolor );
+ p. setColor ( QColorGroup::Foreground, fgcolor );
p. setColor ( QColorGroup::ButtonText, fgcolor );
}
if ( selfgcolor. isValid ( ))
- p. setColor ( QColorGroup::HighlightedText, selfgcolor );
+ p. setColor ( QColorGroup::HighlightedText, selfgcolor );
if ( selbgcolor. isValid ( ))
- p. setColor ( QColorGroup::Highlight, selbgcolor );
- if ( winfgcolor. isValid ( ))
- p. setColor ( QColorGroup::Text, winfgcolor );
+ p. setColor ( QColorGroup::Highlight, selbgcolor );
+ if ( winfgcolor. isValid ( ))
+ p. setColor ( QColorGroup::Text, winfgcolor );
if ( winbgcolor. isValid ( ))
- p. setColor ( QColorGroup::Base, winbgcolor );
-
+ p. setColor ( QColorGroup::Base, winbgcolor );
+
}
void OThemeStyle::unPolish( QApplication *app )
{
qt_set_draw_menu_bar_impl ( 0 );
app->setPalette( oldPalette, true );
}
@@ -1178,17 +1178,17 @@ void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
}
// Next, draw iconset, 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 = btn->iconSet() ->pixmap( QIconSet::Automatic, mode );
int pixw = pixmap.width();
int pixh = pixmap.height();
p->drawPixmap( x + 6, y + h / 2 - pixh / 2, pixmap );
x += pixw + 8;
w -= pixw + 8;
}
@@ -1241,18 +1241,17 @@ int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi,
if ( mi->isChecked() )
h = isPixmap( CheckMark ) ? uncached( CheckMark ) ->height() + offset :
offset + 16;
if ( mi->pixmap() ) {
h2 = mi->pixmap() ->height() + offset;
h = h2 > h ? h2 : h;
}
if ( mi->iconSet() ) {
- h2 = mi->iconSet() ->
- pixmap( QIconSet::Small, QIconSet::Normal ).height() + offset;
+ h2 = mi->iconSet() ->pixmap().height() + offset;
h = h2 > h ? h2 : h;
}
h2 = fm.height() + offset;
h = h2 > h ? h2 : h;
return ( h );
}
void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
@@ -1320,17 +1319,21 @@ void OThemeStyle::drawPopupMenuItem( QPainter* p, bool checkable, int maxpmw,
}
}
if ( !mi )
return ;
if ( mi->iconSet() ) {
QIconSet::Mode mode = dis ? QIconSet::Disabled : QIconSet::Normal;
if ( act && !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.text() );
p->drawPixmap( pmr.topLeft(), pixmap );
@@ -1429,21 +1432,21 @@ void OThemeStyle::drawKMenuBar( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool, QBrush * )
{
drawBaseButton( p, x, y, w, h, *colorGroup( g, MenuBar ), false, false,
MenuBar );
}
#endif
void OThemeStyle::drawMenuBarItem( QPainter *p, int x, int y, int w, int h,
- QMenuItem *mi, const QColorGroup &g,
+ QMenuItem *mi, const 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;
}
const QColorGroup * cg = colorGroup( g, active ? MenuBarItem : MenuBar );
QColor btext = cg->buttonText();
if ( active )
@@ -1459,21 +1462,21 @@ void OThemeStyle::drawMenuBarItem( QPainter *p, int x, int y, int w, int h,
void OThemeStyle::drawProgressBar ( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, int percent )
{
const QColorGroup * cg = colorGroup( g, ProgressBg );
QBrush bg;
bg.setColor( cg->color( QColorGroup::Background ) );
if ( isPixmap( ProgressBg ) )
bg.setPixmap( *uncached( ProgressBg ) );
-
+
int pw = w * percent / 100;
-
- p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO
-
+
+ p-> fillRect ( x + pw, y, w - pw, h, bg ); // ### TODO
+
drawBaseButton( p, x, y, pw, h, *cg, false, false, ProgressBar );
}
#if 0
void OThemeStyle::drawKProgressBlock( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, QBrush * )
{
diff --git a/noncore/styles/web/webstyle.cpp b/noncore/styles/web/webstyle.cpp
index cd3cf08..7b58d89 100644
--- a/noncore/styles/web/webstyle.cpp
+++ b/noncore/styles/web/webstyle.cpp
@@ -38,16 +38,25 @@ static const int _indicatorSize = 9;
static QButton * _highlightedButton = 0;
static const int _scrollBarExtent = 12;
static QFrame * _currentFrame = 0;
static int _savedFrameLineWidth;
static int _savedFrameMidLineWidth;
static ulong _savedFrameStyle;
+static const int ITEMFRAME = 1; // menu stuff
+static const int ITEMHMARGIN = 3;
+static const int ITEMVMARGIN = 0;
+
+static const int ARROWMARGIN = 6;
+static const int RIGHTBORDER = 10;
+static const int MINICONSIZE = 12;
+
+
static QColor contrastingForeground(const QColor & fg, const QColor & bg)
{
int h, s, vbg, vfg;
bg.hsv(&h, &s, &vbg);
fg.hsv(&h, &s, &vfg);
int diff(vbg - vfg);
@@ -964,29 +973,140 @@ WebStyle::drawSlider
}
void
WebStyle::drawPopupMenuItem
(
QPainter * p,
bool checkable,
int maxpmw,
- int tab,
+ int tabwidth,
QMenuItem * mi,
const QPalette & pal,
bool act,
bool enabled,
int x,
int y,
int w,
int h
)
{
// TODO
- QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h);
+ //QWindowsStyle::drawPopupMenuItem(p, checkable, maxpmw, tab, mi, pal, act, enabled, x, y, w, h);
+ if ( !mi )
+ return;
+
+ QRect rect(x, y, w, h );
+ int x2, y2;
+ x2 = rect.right();
+ y2 = rect.bottom();
+ const QColorGroup& g = pal.active();
+ QColorGroup itemg = !enabled ? pal.disabled() : pal.active();
+
+ if ( checkable || maxpmw ) maxpmw = QMAX(maxpmw, 20);
+
+ if (act && enabled )
+ p->fillRect(x, y, w, h, g.highlight() );
+ else
+ p->fillRect(x, y, w, h, g.background() );
+
+ // draw seperator
+ if (mi->isSeparator() ) {
+ p->setPen( g.dark() );
+ p->drawLine( x+8, y+1, x+w-8, y+1 );
+
+ p->setPen( g.mid() );
+ p->drawLine( x+8, y, x+w-8, y );
+ p->drawPoint(x+w,y+1);
+
+ p->setPen( g.midlight() );
+ p->drawLine( x+8, y-1, x+w-8, y-1 );
+ p->drawPoint(x+8, y );
+ return;
+ }
+
+ // draw icon
+ QIconSet::Mode mode;
+ if ( mi->iconSet() && !mi->isChecked() ) {
+ if ( act )
+ mode = enabled ? QIconSet::Active : QIconSet::Disabled;
+ else
+ mode = enabled ? QIconSet::Normal : QIconSet::Disabled;
+ QPixmap pixmap;
+ if ( mode == QIconSet::Disabled )
+ pixmap = mi->iconSet()->pixmap( QIconSet::Automatic, mode );
+ else
+ pixmap = mi->iconSet()->pixmap();
+ QRect pmrect(0, 0, pixmap.width(), pixmap.height() );
+ QRect cr(x, y, maxpmw, h );
+ pmrect.moveCenter( cr.center() );
+ p->drawPixmap(pmrect.topLeft(), pixmap);
+ }
+
+ // draw check
+ if(mi->isChecked() ) {
+ drawCheckMark(p, x, y, maxpmw, h, itemg, act, !enabled );
+ }
+
+
+ // draw text
+ int xm = maxpmw + 2;
+ int xp = x + xm;
+ int tw = w -xm - 2;
+
+ p->setPen( enabled ? ( act ? g.highlightedText() : g.buttonText() ) :
+ g.mid() );
+
+
+ if ( mi->custom() ) {
+ p->save();
+ mi->custom()->paint(p, g, act, enabled,
+ xp, y+1, tw, h-2 );
+ p->restore();
+ }else { // draw label
+ QString text = mi->text();
+ if (!text.isNull() ) {
+ int t = text.find('\t');
+ const int tflags = AlignVCenter | DontClip |
+ ShowPrefix | SingleLine |
+ AlignLeft;
+
+ if (t >= 0) {
+ int tabx = x + w - tabwidth - RIGHTBORDER -
+ ITEMHMARGIN - ITEMFRAME;
+ p->drawText(tabx, y+ITEMVMARGIN, tabwidth,
+ h-2*ITEMVMARGIN, tflags,
+ text.mid(t+1) );
+ text = text.left(t );
+ }
+
+ // draw left label
+ p->drawText(xp, y+ITEMVMARGIN,
+ tw, h-2*ITEMVMARGIN,
+ tflags, text, t);
+ }else if ( mi->pixmap() ) { // pixmap as label
+ QPixmap pixmap = *mi->pixmap();
+ if ( pixmap.depth() == 1 )
+ p->setBackgroundMode( OpaqueMode );
+
+ int dx = ((w-pixmap.width() ) /2 ) +
+ ((w - pixmap.width()) %2 );
+ p->drawPixmap(x+dx, y+ITEMFRAME, pixmap );
+
+ if ( pixmap.depth() == 1 )
+ p->setBackgroundMode( TransparentMode );
+ }
+ }
+
+ if ( mi->popup() ) { // draw submenu arrow
+ int dim = (h-2*ITEMFRAME) / 2;
+ drawArrow( p, RightArrow, false,
+ x+w-ARROWMARGIN-ITEMFRAME-dim,
+ y+h/2-dim/2, dim, dim, g, enabled );
+ }
}
void
WebStyle::drawFocusRect
(
QPainter * p,
const QRect & r,
const QColorGroup & g,
@@ -1163,17 +1283,17 @@ WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm)
{
h = i->pixmap()->height();
}
if (0 != i->iconSet())
{
h = QMAX
(
- i->iconSet()->pixmap(QIconSet::Small, QIconSet::Normal).height(),
+ i->iconSet()->pixmap().height(),
h
);
}
h = QMAX(fm.height() + 4, h);
h = QMAX(18, h);
diff --git a/noncore/styles/web/webstyle.h b/noncore/styles/web/webstyle.h
index 83ab784..d6f153b 100644
--- a/noncore/styles/web/webstyle.h
+++ b/noncore/styles/web/webstyle.h
@@ -210,17 +210,17 @@ class WebStyle : public QWindowsStyle {
bool tickBelow
);
void drawPopupMenuItem
(
QPainter *,
bool checkable,
int maxpmw,
- int tab,
+ int tabwidth,
QMenuItem *,
const QPalette &,
bool act,
bool enabled,
int x,
int y,
int w,
int h