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) (show whitespace changes)
-rw-r--r--core/launcher/launchertab.cpp24
-rw-r--r--core/settings/launcher/menusettings.cpp44
-rw-r--r--libopie2/opieui/otabbar.cpp48
-rw-r--r--libopie2/opieui/otabbar.h42
-rw-r--r--libopie2/opieui/otabwidget.cpp1
-rw-r--r--noncore/styles/flat/flat.cpp10
-rw-r--r--noncore/styles/fresh/fresh.cpp8
-rw-r--r--noncore/styles/liquid/liquid.cpp15
-rw-r--r--noncore/styles/phase/phasestyle.cpp14
-rw-r--r--noncore/styles/theme/othemestyle.cpp11
-rw-r--r--noncore/styles/web/webstyle.cpp126
-rw-r--r--noncore/styles/web/webstyle.h2
12 files changed, 248 insertions, 97 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
@@ -52,230 +52,234 @@ void LauncherTabBar::removeTab( QTab *tab )
void LauncherTabBar::prevTab()
{
int n = count();
int tab = currentTab();
if ( tab >= 0 )
setCurrentTab( (tab - 1 + n)%n );
}
void LauncherTabBar::nextTab()
{
int n = count();
int tab = currentTab();
setCurrentTab( (tab + 1)%n );
}
void LauncherTabBar::showTab( const QString& id )
{
setCurrentTab( tabs[id] );
}
void LauncherTabBar::layoutTabs()
{
if ( !count() )
return;
int available = width()-1;
QFontMetrics fm = fontMetrics();
int hiddenTabWidth = -12;
LauncherTab *current = currentLauncherTab();
int hframe, vframe, overlap;
style().tabbarMetrics( this, hframe, vframe, overlap );
int x = 0;
QRect r;
LauncherTab *t;
QListIterator< LauncherTab > it( items );
int required = 0;
int eventabwidth = (width()-1)/count();
enum Mode { HideBackText, Pack, Even } mode=Even;
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;
r = r.unite( t->rect() );
}
}
t = it.toLast();
if (t) {
QRect rr = t->rect();
rr.setRight(width()-1);
t->setRect( rr );
}
for (it.toFirst(); it.current(); ++it ) {
t = it.current();
QRect tr = t->rect();
tr.setHeight( r.height() );
t->setRect( tr );
}
update();
}
void LauncherTabBar::paint( QPainter * p, QTab * t, bool selected ) const
{
LauncherTabBar *that = (LauncherTabBar *) this;
LauncherTab *ct = (LauncherTab *)t;
QPalette pal = palette();
bool setPal = FALSE;
if ( ct->bgColor.isValid() ) {
pal.setColor( QPalette::Active, QColorGroup::Background, ct->bgColor );
pal.setColor( QPalette::Active, QColorGroup::Button, ct->bgColor );
pal.setColor( QPalette::Inactive, QColorGroup::Background, ct->bgColor );
pal.setColor( QPalette::Inactive, QColorGroup::Button, ct->bgColor );
that->setUpdatesEnabled( FALSE );
that->setPalette( pal );
setPal = TRUE;
}
#if QT_VERSION >= 0x030000
QStyle::SFlags flags = QStyle::Style_Default;
if ( selected )
flags |= QStyle::Style_Selected;
style().drawControl( QStyle::CE_TabBarTab, p, this, t->rect(),
colorGroup(), flags, QStyleOption(t) );
#else
style().drawTab( p, this, t, selected );
#endif
QRect r( t->rect() );
QFont f( font() );
if ( selected )
f.setBold( TRUE );
p->setFont( f );
if ( ct->fgColor.isValid() ) {
pal.setColor( QPalette::Active, QColorGroup::Foreground, ct->fgColor );
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
t->identitifer() == keyboardFocusTab()
#endif
);
if ( setPal ) {
that->unsetPalette();
that->setUpdatesEnabled( TRUE );
}
}
void LauncherTabBar::paintLabel( QPainter* p, const QRect&,
QTab* t, bool has_focus ) const
{
QRect r = t->rect();
// 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;
if ( r.width() < 20 )
return;
if ( t->isEnabled() && isEnabled() ) {
#if defined(_WS_WIN32_)
if ( colorGroup().brush( QColorGroup::Button ) == colorGroup().brush( QColorGroup::Background ) )
p->setPen( colorGroup().buttonText() );
else
p->setPen( colorGroup().foreground() );
#else
p->setPen( colorGroup().foreground() );
#endif
p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
} else {
p->setPen( palette().disabled().foreground() );
p->drawText( tr, AlignCenter | AlignVCenter | ShowPrefix, t->text() );
}
}
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,156 +1,156 @@
/*
-                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>
#include <qpe/qlibrary.h>
#include <qpe/qpeapplication.h>
#include <qpe/menuappletinterface.h>
#include <qpe/qcopenvelope_qws.h>
#include <qdir.h>
#include <qlistview.h>
#include <qcheckbox.h>
#include <qheader.h>
#include <qlayout.h>
#include <qlabel.h>
#include <qwhatsthis.h>
#include <stdlib.h>
MenuSettings::MenuSettings ( QWidget *parent, const char *name )
: QWidget ( parent, name )
{
m_applets_changed = false;
QBoxLayout *lay = new QVBoxLayout ( this, 4, 4 );
QLabel *l = new QLabel ( tr( "Load applets in O-Menu:" ), this );
lay-> addWidget ( l );
m_list = new QListView ( this );
m_list-> addColumn ( "foobar" );
m_list-> header ( )-> hide ( );
lay-> addWidget ( m_list );
m_menutabs = new QCheckBox ( tr( "Show Launcher tabs in O-Menu" ), this );
lay-> addWidget ( m_menutabs );
m_menusubpopup = new QCheckBox ( tr( "Show Applications in Subpopups" ), this );
lay-> addWidget ( m_menusubpopup );
QWhatsThis::add ( m_list, tr( "Check the applets that you want to have included in the O-Menu." ));
QWhatsThis::add ( m_menutabs, tr( "Adds the contents of the Launcher Tabs as menus in the O-Menu." ));
connect ( m_list, SIGNAL( clicked(QListViewItem*)), this, SLOT( appletChanged()));
init ( );
}
void MenuSettings::init ( )
{
Config cfg ( "StartMenu" );
cfg. setGroup ( "Applets" );
QStringList exclude = cfg. readListEntry ( "ExcludeApplets", ',' );
QString path = QPEApplication::qpeDir ( ) + "plugins/applets";
#ifdef Q_OS_MACX
QStringList list = QDir ( path, "lib*.dylib" ). entryList ( );
#else
QStringList list = QDir ( path, "lib*.so" ). entryList ( );
#endif /* Q_OS_MACX */
for ( QStringList::Iterator it = list. begin ( ); it != list. end ( ); ++it ) {
QString name;
QPixmap icon;
MenuAppletInterface *iface = 0;
QLibrary *lib = new QLibrary ( path + "/" + *it );
lib-> queryInterface ( IID_MenuApplet, (QUnknownInterface**) &iface );
if ( iface ) {
QString lang = getenv( "LANG" );
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 ( ));
m_applets [*it] = item;
} else {
delete lib;
}
}
cfg. setGroup ( "Menu" );
m_menutabs->setChecked( cfg.readBoolEntry( "LauncherTabs", true ) );
m_menusubpopup->setChecked( cfg.readBoolEntry( "LauncherSubPopup", true ) );
m_menusubpopup->setEnabled( m_menutabs->isChecked() );
connect( m_menutabs, SIGNAL( stateChanged(int) ), m_menusubpopup, SLOT( setEnabled(bool) ) );
}
void MenuSettings::appletChanged()
{
m_applets_changed = true;
}
void MenuSettings::accept ( )
{
bool apps_changed = false;
Config cfg ( "StartMenu" );
cfg. setGroup ( "Applets" );
if ( m_applets_changed ) {
QStringList exclude;
QMap <QString, QCheckListItem *>::Iterator it;
for ( it = m_applets. begin ( ); it != m_applets. end ( ); ++it ) {
if ( !(*it)-> isOn ( ))
exclude << it. key ( );
}
cfg. writeEntry ( "ExcludeApplets", exclude, ',' );
}
cfg. writeEntry ( "SafeMode", false );
cfg. setGroup ( "Menu" );
if ( m_menutabs-> isChecked ( ) != cfg. readBoolEntry ( "LauncherTabs", true )) {
apps_changed = true;
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,83 +1,87 @@
/*
-                This file is part of the Opie Project
+ This file is part of the Opie Project
-              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
+ 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
{
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() )
{
tr.setBottom( tr.bottom() - style().defaultFrameWidth() );
}
if ( t->enabled && isEnabled() )
{
p->setPen( colorGroup().foreground() );
p->drawText( tr, AlignCenter | ShowPrefix, t->label );
}
else if ( style() == MotifStyle )
{
p->setPen( palette().disabled().foreground() );
p->drawText( tr, AlignCenter | ShowPrefix, t->label );
}
else
{
p->setPen( colorGroup().light() );
QRect wr = tr;
wr.moveBy( 1, 1 );
p->drawText( wr, AlignCenter | ShowPrefix, t->label );
p->setPen( palette().disabled().foreground() );
p->drawText( tr, AlignCenter | ShowPrefix, t->label );
}
}
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,73 +1,73 @@
/*
-                This file is part of the Opie Project
+ This file is part of the Opie Project
-              Copyright (c) 2002 Dan Williams <williamsdr@acm.org>
+ 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>
namespace Opie {
namespace Ui {
/**
* @class OTabBar
* @brief The OTabBar class is a derivative of QTabBar.
*
* OTabBar is a derivation of TrollTech's QTabBar which provides
* a row of tabs for selection. The only difference between this
* class and QTabBar is that there is no dotted line box around
* the label of the tab with the current focus.
*/
class OTabBar : public QTabBar
{
Q_OBJECT
public:
/**
* @fn OTabBar( QWidget *parent = 0, const char *name = 0 )
* @brief Object constructor.
*
* @param parent Pointer to parent of this control.
* @param name Name of control.
*
* Constructs a new OTabBar control with parent and name.
*/
OTabBar( QWidget * = 0, const char * = 0 );
protected:
/**
* @fn paintLabel( QPainter* p, const QRect& br , QTab* t, bool has_focus)const
* @brief Internal function to draw a tab's label.
*
* @param p Pointer to QPainter used for drawing.
* @param br QRect providing region to draw label in.
* @param t Tab to draw label for.
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
@@ -1,85 +1,84 @@
/*
                This file is part of the Opie Project
Copyright (C) 2002, 2005 Dan Williams <drw@handhelds.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.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#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;
OTabWidget::OTabWidget( QWidget *parent, const char *name, TabStyle s, TabPosition p )
: QWidget( parent, name )
, m_currTab( 0l )
, m_tabBarStyle( Global )
, m_tabBarPosition( Top )
, m_usingTabs( true )
, m_tabBar( 0l )
, m_tabList( 0l )
{
if ( s == Global )
{
// Read Opie global settings for style and position
Config config( "qpe" );
config.setGroup( "Appearance" );
// Style
s = ( TabStyle ) config.readNumEntry( "TabStyle", (int) IconTab );
if ( s <= Global || s > IconList)
s = IconTab;
// Position
( config.readEntry( "TabPosition", "Top" ) == "Bottom" ) ? p = Bottom
: p = Top;
}
// Initialize widget stack for tab widgets
m_widgetStack = new QWidgetStack( this );
m_widgetStack->setFrameStyle( QFrame::NoFrame );
m_widgetStack->setLineWidth( style().defaultFrameWidth() );
// Set initial selector control style and position
setTabStyle( s );
setTabPosition( p );
}
OTabWidget::~OTabWidget()
{
m_tabs.setAutoDelete( true );
m_tabs.clear();
}
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
@@ -328,97 +328,97 @@ void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p )
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE, &fill );
clearButton = FALSE;
} else {
if ( !btn->isFlat() )
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, btn->isOn(),
&g.brush( QColorGroup::Button ) );
}
}
/*
if ( clearButton ) {
if (btn->isDown())
p->setBrushOrigin(p->brushOrigin() + QPoint(1,1));
p->fillRect( x1+2, y1+2, x2-x1-3, y2-y1-3,
g.brush( QColorGroup::Button ) );
if (btn->isDown())
p->setBrushOrigin(p->brushOrigin() - QPoint(1,1));
}
*/
fillBtnBorder = FALSE;
if ( p->brush().style() != NoBrush )
p->setBrush( NoBrush );
}
void FlatStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
{
QRect r = pushButtonContentsRect( btn );
int x, y, w, h;
r.rect( &x, &y, &w, &h );
QColorGroup cg = btn->colorGroup();
if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() && !btn->isDown() )
cg.setColor( QColorGroup::ButtonText, btn->colorGroup().text() );
else if ( btn->isDown() || btn->isOn() )
cg.setColor( QColorGroup::ButtonText, btn->colorGroup().button() );
if ( btn->isMenuButton() ) {
int dx = menuButtonIndicatorWidth( btn->height() );
drawArrow( p, DownArrow, FALSE,
x+w-dx, y+2, dx-4, h-4,
cg,
btn->isEnabled() );
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,
cg, btn->isEnabled(),
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*/,
bool enabled,
const QBrush * /*fill*/ )
{
x++; y++;
w-=2; h-=2;
p->setPen( g.foreground() );
p->setBrush( QBrush(NoBrush) );
p->drawRect( x, y, w, h );
p->setPen( g.background() );
p->drawRect( x+1, y+1, w-14, h-2 );
p->fillRect( x+2, y+2, w-16, h-4, g.brush( QColorGroup::Base ) );
QColorGroup cg( g );
if ( sunken ) {
cg.setColor( QColorGroup::ButtonText, g.button() );
cg.setColor( QColorGroup::Button, g.buttonText() );
}
drawArrow( p, QStyle::DownArrow, FALSE,
x+w-13, y+1, 12, h-2, cg, enabled,
&cg.brush( QColorGroup::Button ) );
}
@@ -857,149 +857,153 @@ void FlatStyle::polishPopupMenu ( QPopupMenu *m )
*/
int FlatStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
{
#ifndef QT_NO_MENUDATA
int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
if ( mi->isSeparator() )
return 10; // arbitrary
else if ( mi->pixmap() )
w += mi->pixmap()->width(); // pixmap only
if ( !mi->text().isNull() ) {
if ( mi->text().find('\t') >= 0 ) // string contains tab
w += motifTabSpacing;
}
if ( maxpmw ) { // we have iconsets
w += maxpmw;
w += 6; // add a little extra border around the iconset
}
if ( checkable && maxpmw < windowsCheckMarkWidth ) {
w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
}
if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
w += motifCheckMarkHMargin; // add space to separate the columns
w += windowsRightBorder; // windows has a strange wide border on the right side
return w;
#endif
}
/*! \reimp
*/
int FlatStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
{
#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
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;
if ( mi && mi->isSeparator() ) { // draw separator
p->setPen( g.dark() );
p->drawLine( x, y, x+w, y );
return;
}
QBrush fill = act? g.brush( QColorGroup::Highlight ) :
g.brush( QColorGroup::Button );
p->fillRect( x, y, w, h, fill);
if ( !mi )
return;
if ( mi->isChecked() ) {
if ( act && !dis ) {
qDrawShadePanel( p, x, y, checkcol, h,
g, TRUE, 1, &g.brush( QColorGroup::Button ) );
} else {
qDrawShadePanel( p, x, y, checkcol, h,
g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
}
} else if ( !act ) {
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 );
pmr.moveCenter( cr.center() );
p->setPen( itemg.text() );
p->drawPixmap( pmr.topLeft(), pixmap );
QBrush fill = act? g.brush( QColorGroup::Highlight ) :
g.brush( QColorGroup::Button );
p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
} else if ( checkable ) { // just "checking"...
int mw = checkcol + motifItemFrame;
int mh = h - 2*motifItemFrame;
if ( mi->isChecked() ) {
drawCheckMark( p, x + motifItemFrame + 2,
y+motifItemFrame, mw, mh, itemg, act, dis );
}
}
p->setPen( act ? g.highlightedText() : g.buttonText() );
QColor discol;
if ( dis ) {
discol = itemg.text();
p->setPen( discol );
}
int xm = motifItemFrame + checkcol + motifItemHMargin;
if ( mi->custom() ) {
int m = motifItemVMargin;
p->save();
if ( dis && !act ) {
p->setPen( g.light() );
mi->custom()->paint( p, itemg, act, enabled,
x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
p->setPen( discol );
}
mi->custom()->paint( p, itemg, act, enabled,
x+xm, y+m, w-xm-tab+1, h-2*m );
p->restore();
}
QString s = mi->text();
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
@@ -603,151 +603,155 @@ static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
*/
int FreshStyle::extraPopupMenuItemWidth( bool checkable, int maxpmw, QMenuItem* mi, const QFontMetrics& /*fm*/ )
{
#ifndef QT_NO_MENUDATA
int w = 2*motifItemHMargin + 2*motifItemFrame; // a little bit of border can never harm
if ( mi->isSeparator() )
return 10; // arbitrary
else if ( mi->pixmap() )
w += mi->pixmap()->width(); // pixmap only
if ( !mi->text().isNull() ) {
if ( mi->text().find('\t') >= 0 ) // string contains tab
w += motifTabSpacing;
}
if ( maxpmw ) { // we have iconsets
w += maxpmw;
w += 6; // add a little extra border around the iconset
}
if ( checkable && maxpmw < windowsCheckMarkWidth ) {
w += windowsCheckMarkWidth - maxpmw; // space for the checkmarks
}
if ( maxpmw > 0 || checkable ) // we have a check-column ( iconsets or checkmarks)
w += motifCheckMarkHMargin; // add space to separate the columns
w += windowsRightBorder; // windows has a strange wide border on the right side
return w;
#endif
}
/*! \reimp
*/
int FreshStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem* mi, const QFontMetrics& fm )
{
#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
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;
if ( mi && mi->isSeparator() ) { // draw separator
p->setPen( g.dark() );
p->drawLine( x, y, x+w, y );
p->setPen( g.light() );
p->drawLine( x, y+1, x+w, y+1 );
return;
}
QBrush fill = act? g.brush( QColorGroup::Highlight ) :
g.brush( QColorGroup::Button );
p->fillRect( x, y, w, h, fill);
if ( !mi )
return;
if ( mi->isChecked() ) {
if ( act && !dis ) {
qDrawShadePanel( p, x, y, checkcol, h,
g, TRUE, 1, &g.brush( QColorGroup::Button ) );
} else {
qDrawShadePanel( p, x, y, checkcol, h,
g, TRUE, 1, &g.brush( QColorGroup::Midlight ) );
}
} else if ( !act ) {
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 );
pmr.moveCenter( cr.center() );
p->setPen( itemg.text() );
p->drawPixmap( pmr.topLeft(), pixmap );
QBrush fill = act? g.brush( QColorGroup::Highlight ) :
g.brush( QColorGroup::Button );
p->fillRect( x+checkcol + 1, y, w - checkcol - 1, h, fill);
} else if ( checkable ) { // just "checking"...
int mw = checkcol + motifItemFrame;
int mh = h - 2*motifItemFrame;
if ( mi->isChecked() ) {
drawCheckMark( p, x + motifItemFrame + 2,
y+motifItemFrame, mw, mh, itemg, act, dis );
}
}
p->setPen( act ? g.highlightedText() : g.buttonText() );
QColor discol;
if ( dis ) {
discol = itemg.text();
p->setPen( discol );
}
int xm = motifItemFrame + checkcol + motifItemHMargin;
if ( mi->custom() ) {
int m = motifItemVMargin;
p->save();
if ( dis && !act ) {
p->setPen( g.light() );
mi->custom()->paint( p, itemg, act, enabled,
x+xm+1, y+m+1, w-xm-tab+1, h-2*m );
p->setPen( discol );
}
mi->custom()->paint( p, itemg, act, enabled,
x+xm, y+m, w-xm-tab+1, h-2*m );
p->restore();
}
QString s = mi->text();
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
@@ -1258,97 +1258,101 @@ void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p)
//int dw = buttonDefaultIndicatorWidth();
if(btn->hasFocus() || btn->isDefault()){
QColor c = btn->hasFocus() ? g.button().light(110) : g.background();
QPixmap *pix = bevelFillDict.find(c.rgb());
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*bevelFillPix);
adjustHSV(*pix, h, s, v);
bevelFillDict.insert(c.rgb(), pix);
}
p->setPen(c.dark(150));
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());
p->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
}
QColor newColor = btn == highlightWidget || sunken ?
g.button().light(120) : g.button();
drawRoundButton(p, newColor, g.background(),
r.x(), r.y(), r.width(), r.height(), !btn->autoMask(),
sunken, btn->isDefault() || btn->autoDefault() || btn->hasFocus(),
btn->autoMask());
}
void LiquidStyle::drawPushButtonLabel(QPushButton *btn, QPainter *p)
{
int x1, y1, x2, y2, w, h;
btn->rect().coords(&x1, &y1, &x2, &y2);
w = btn->width();
h = btn->height();
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(),
btn->pixmap(), btn->text(), -1, &btn->colorGroup().light());
}
else{
/* Too blurry
drawItem( p, x1+1, y1+1, w, h,
AlignCenter | ShowPrefix, btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&btn->colorGroup().button().dark(115));
*/
drawItem( p, x1, y1, w, h,
AlignCenter | ShowPrefix,
btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text(), -1,
&btn->colorGroup().buttonText());
}
}
void LiquidStyle::drawButtonMask(QPainter *p, int x, int y, int w, int h)
{
int x2 = x+w-1;
int y2 = y+h-1;
p->setPen(Qt::color1);
p->fillRect(x, y, w, h, Qt::color0);
if(w < 21 || h < 21){
// outer rect
p->drawLine(x, y+2, x, y2-2); // l
p->drawLine(x2, y+2, x2, y2-2); // r
@@ -2110,179 +2114,182 @@ static const int windowsRightBorder = 12;
if(!mi)
return;
QColor discol;
if (dis) {
discol = itemg.mid();
p->setPen(discol);
}
QColorGroup cg2(itemg);
if(menuHandler->transType() == Custom){
cg2.setColor(QColorGroup::Foreground, menuHandler->textColor());
cg2.setColor(QColorGroup::Text, menuHandler->textColor());
cg2.setColor(QColorGroup::Light, menuHandler->textColor().light(120));
cg2.setColor(QColorGroup::Mid, menuHandler->textColor().dark(120));
}
else{
cg2 = QColorGroup(discol, itemg.highlight(), black, black,
dis ? discol : black, discol, black);
}
if(mi->isSeparator()){
QColor c;
switch(menuHandler->transType()){
case None:
case StippledBg:
case TransStippleBg:
c = QApplication::palette().active().background();
break;
case StippledBtn:
case TransStippleBtn:
c = QApplication::palette().active().button();
break;
default:
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;
if (mi->isChecked()){
drawCheckMark( p, x + motifItemFrame,
y+motifItemFrame, mw, mh, cg2, act, dis );
}
}
if(menuHandler->transType() == Custom)
p->setPen(menuHandler->textColor());
else
p->setPen(itemg.text());
int xm = motifItemFrame + checkcol + motifItemHMargin;
QString s = mi->text();
if (!s.isNull()) {
int t = s.find( '\t' );
int m = motifItemVMargin;
const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
QPen oldPen = p->pen();
if(menuHandler->useShadowText()){
if(menuHandler->transType() == Custom)
p->setPen(menuHandler->bgColor().dark(130));
else if(menuHandler->transType() == StippledBtn ||
menuHandler->transType() == TransStippleBtn)
p->setPen(itemg.button().dark(130));
else
p->setPen(bgBrush.color().dark(130));
if (t >= 0) {
p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+2,
y+m+2, tab-1, h-2*m-1, text_flags, s.mid( t+1 ));
}
p->drawText(x+xm+1, y+m+1, w-xm-tab, h-2*m-1, text_flags, s, t);
}
p->setPen(oldPen);
if (t >= 0) {
p->drawText(x+w-tab-windowsRightBorder-motifItemHMargin-motifItemFrame+1,
y+m+1, tab, h-2*m, text_flags, s.mid( t+1 ));
}
p->drawText(x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t);
}
else if (mi->pixmap()) {
QPixmap *pixmap = mi->pixmap();
if (pixmap->depth() == 1)
p->setBackgroundMode(OpaqueMode);
p->drawPixmap( x+xm, y+motifItemFrame, *pixmap);
if (pixmap->depth() == 1)
p->setBackgroundMode(TransparentMode);
}
if (mi->popup()) {
int dim = (h-2*motifItemFrame) / 2;
drawArrow(p, RightArrow, true,
x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
dim, dim, cg2, TRUE);
}
}
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,
bool atBorder)
{
// are we painting a widget?
if(p->device()->devType() == QInternal::Widget){
// if so does it use a special focus rectangle?
QWidget *w = (QWidget *)p->device();
if(w->inherits("QPushButton") || w->inherits("QSlider") || w->inherits("QComboBox") || w->inherits("QToolButton" )){
return;
}
else{
QWindowsStyle::drawFocusRect(p, r, g, c, atBorder);
}
}
else
QWindowsStyle::drawFocusRect(p, r, g, c, atBorder);
}
void LiquidStyle::polishPopupMenu(QPopupMenu *mnu)
{
mnu->installEventFilter(menuHandler);
QWindowsStyle::polishPopupMenu(mnu);
}
void LiquidStyle::drawTab(QPainter *p, const QTabBar *tabBar, QTab *tab,
bool selected)
{
if(tabBar->shape() != QTabBar::RoundedAbove){
QWindowsStyle::drawTab(p, tabBar, tab, selected);
return;
}
QPixmap tilePix;
QRect r = tab->rect();
//QPixmap *pix = selected ? tabBar->hasFocus() ? pixmaps[TabFocus] :
// pixmaps[TabDown] : pixmaps[Tab];
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
@@ -345,97 +345,100 @@ void PhaseStyle::polish( QApplication* app ) {
void PhaseStyle::unPolish( QApplication* app ) {
QWindowsStyle::unPolish(app);
qt_set_draw_menu_bar_impl ( 0 );
}
void PhaseStyle::drawPushButtonLabel (QPushButton *button, QPainter *painter) {
bool active = button->isOn() || button->isDown();
QRect r = pushButtonContentsRect( button );
QColorGroup group = button->colorGroup();
int x, y, w, h;
r.rect( &x, &y, &w, &h );
bool sunken = false;
QIconSet::Mode mode;
QPixmap pixmap;
if (active) {// shift contents
x++; y++;
sunken = true;
}
if (button->isMenuButton()) { // draw the indicator
//dx = pixelMetric(PM_MenuButtonIndicator, widget);
int dx = menuButtonIndicatorWidth( button->height() );
drawArrow(painter, Qt::DownArrow, active,
x+w-dx, y+2, dx-4, h-4, group,button->isEnabled() );
w -= dx;
}
if (button->iconSet() && !button->iconSet()->isNull()) { // draw icon
if (button->isEnabled()) {
if (button->hasFocus()) {
mode = QIconSet::Active;
} else {
mode = QIconSet::Normal;
}
} else {
mode = QIconSet::Disabled;
}
#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;
}
if (active || button->isDefault()) { // default button
for(int n=0; n<2; n++) {
drawItem(painter, x+n, y, w, h,
AlignCenter | ShowPrefix,
button->colorGroup(),
button->isEnabled(),
button->pixmap(),
button->text(), -1,
(button->isEnabled()) ?
&button->colorGroup().buttonText() :
&button->colorGroup().mid());
}
} else { // normal button
drawItem(painter, x, y, w, h,
AlignCenter | ShowPrefix,
button->colorGroup(),
button->isEnabled(),
button->pixmap(),
button->text(), -1,
(button->isEnabled()) ?
&button->colorGroup().buttonText() :
&button->colorGroup().mid());
}
}
void PhaseStyle::drawFocusRect(QPainter *painter, const QRect &rect,
const QColorGroup &group,
const QColor *, bool atBorder) {
QPen old = painter->pen();
painter->setPen(group.highlight().dark(contrast));
painter->setBrush(NoBrush);
if ( atBorder )
painter->drawRect(QRect(rect.x()+1, rect.y()+1,
rect.width()-2, rect.height()-2 ));
@@ -524,189 +527,192 @@ void PhaseStyle::drawExclusiveIndicator(QPainter* painter, int x, int y, int w,
void PhaseStyle::drawExclusiveIndicatorMask(QPainter *painter, int x, int y, int w,
int h, bool /*on*/ ) {
return;
if (0 != w%2) --w;
if (0 != h%2) --h;
QRect r(x, y, w, h );
int x2 = r.right();
int y2 = r.bottom();
int cx = (x + x2) / 2;
int cy = (y + y2) / 2;
QPointArray parray;
painter->setBrush(Qt::color1);
painter->setPen(Qt::color1);
parray.putPoints(0, 8,
x,cy+1, x,cy, cx,y, cx+1,y,
x2,cy, x2,cy+1, cx+1,y2, cx,y2);
painter->drawPolygon(parray, 0, 8);
}
int PhaseStyle::defaultFrameWidth()const {
return 1;
}
int PhaseStyle::popupMenuItemHeight ( bool ,
QMenuItem * mi,
const QFontMetrics & fm ) {
int h = 0;
if (mi->custom() ) {
h = mi->custom()->sizeHint().height();
if (!mi->custom()->fullSpan() )
h += ITEMVMARGIN*2 + ITEMFRAME*2;
}else if (mi->isSeparator() ) {
h = 1;
}else {
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,
QMenuItem* mi, const QFontMetrics& ) {
int w = 0;
if (mi->isSeparator() )
return 3;
else if ( mi->pixmap() )
w = mi->pixmap()->width();
if (!mi->text().isNull() &&
mi->text().find('\t' ) >= 0 )
w += 12;
else if ( mi->popup() )
w += 2*ARROWMARGIN;
if ( maxpmw )
w += maxpmw +4;
if ( maxpmw > 0 || checkable )
w += ITEMHMARGIN*2+8;
w += RIGHTBORDER;
return w;
}
QSize PhaseStyle::indicatorSize()const {
return QSize( 11, 11 );
}
QSize PhaseStyle::exclusiveIndicatorSize()const {
return QSize( 11, 11 );
}
void PhaseStyle::getButtonShift( int &x, int &y ) {
x++;
y++;
}
void PhaseStyle::drawPopupMenuItem ( QPainter * p, bool checkable,
int maxpmw,int tabwidth,
QMenuItem * mi, const QPalette & pal,
bool act, bool enabled, int x,
int y, int w, int 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 = 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() ) {
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
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
@@ -1138,239 +1138,242 @@ void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h,
}
}
void OThemeStyle::drawPushButtonLabel( QPushButton *btn, QPainter *p )
{
WidgetType widget = btn->isDown() || btn->isOn() ? PushButtonDown :
PushButton;
const QColorGroup *cg = colorGroup( btn->colorGroup(), widget );
int x, y, w, h;
QRect r = btn->rect();
r.rect( &x, &y, &w, &h );
x += decoWidth( widget );
y += decoWidth( widget );
w -= decoWidth( widget ) * 2;
h -= decoWidth( widget ) * 2;
bool act = btn->isOn() || btn->isDown();
// If this is a button with an associated popup menu, draw an arrow first
if ( btn->popup() ) {
int dx = menuButtonIndicatorWidth( btn->height() );
QColorGroup g( btn->colorGroup() );
int xx = x + w - dx - 4;
int yy = y - 3;
int hh = h + 6;
if ( !act ) {
p->setPen( g.light() );
p->drawLine( xx, yy + 3, xx, yy + hh - 4 );
}
else {
p->setPen( g.button() );
p->drawLine( xx, yy + 4, xx, yy + hh - 4 );
}
drawArrow( p, DownArrow, FALSE,
x + w - dx - 2, y + 2, dx, h - 4,
btn->colorGroup(),
btn->isEnabled() );
w -= dx;
}
// 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;
}
if ( widget == PushButtonDown ) {
drawItem( p, x + buttonXShift(), y + buttonYShift(),
w, h, AlignCenter | ShowPrefix, *cg, btn->isEnabled(),
btn->pixmap(), btn->text(), -1, &cg->buttonText() );
}
else {
drawItem( p, x, y, w, h, AlignCenter | ShowPrefix, *cg,
btn->isEnabled(), btn->pixmap(), btn->text(), -1,
&cg->buttonText() );
}
}
int OThemeStyle::splitterWidth() const
{
return ( splitWidth() );
}
void OThemeStyle::drawSplitter( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, Orientation )
{
drawBaseButton( p, x, y, w, h, *colorGroup( g, Splitter ), false, false,
Splitter );
}
void OThemeStyle::drawCheckMark( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool act, bool dis )
{
if ( isPixmap( CheckMark ) ) {
if ( !dis )
p->drawPixmap( x + ( w - uncached( CheckMark ) ->width() ) / 2,
y + ( h - uncached( CheckMark ) ->height() ) / 2,
*uncached( CheckMark ) );
}
else
QWindowsStyle::drawCheckMark( p, x, y, w, h, *colorGroup( g, CheckMark ),
act, dis );
}
int OThemeStyle::popupMenuItemHeight( bool /*checkable*/, QMenuItem *mi,
const QFontMetrics &fm )
{
int h2, h = 0;
int offset = QMAX( decoWidth( MenuItemDown ), decoWidth( MenuItem ) ) + 4;
if ( mi->isSeparator() )
return ( 2 );
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,
int tab, QMenuItem* mi,
const QPalette& pal, bool act,
bool enabled, int x, int y, int w, int h )
{
// I changed the following method to be based from Qt's instead of my own
// wacky code. Works much better now :P (mosfet)
static const int motifItemFrame = 2; // menu item frame width
static const int motifItemHMargin = 5; // menu item hor text margin
static const int motifItemVMargin = 4; // menu item ver text margin
static const int motifArrowHMargin = 6; // arrow horizontal margin
static const int windowsRightBorder = 12; // right border on windowsstatic const int windowsCheckMarkWidth = 12; // checkmarks width on windows
bool dis = !enabled;
const QColorGroup &g = dis ? *colorGroup( pal.normal(), MenuItem ) :
*colorGroup( pal.normal(), MenuItemDown );
QColorGroup itemg = dis ? *colorGroup( pal.disabled(), MenuItem )
: act ? *colorGroup( pal.active(), MenuItemDown )
: *colorGroup( pal.normal(), MenuItem );
maxpmw = QMAX( maxpmw, 20 );
int checkcol = maxpmw;
if ( mi && mi->isSeparator() ) {
p->setPen( g.dark() );
p->drawLine( x, y, x + w, y );
p->setPen( g.light() );
p->drawLine( x, y + 1, x + w, y + 1 );
return ;
}
if ( act ) {
drawBaseButton( p, x, y, w, h, g, true, false, MenuItemDown );
}
else {
drawShade( p, x, y, w, h, *colorGroup( g, MenuItem ), false, false,
highlightWidth( MenuItem ), borderWidth( MenuItem ),
shade() );
int dw = decoWidth( MenuItem );
if ( !isPixmap( MenuItem ) ) {
p->fillRect( x + dw, y + dw, w - dw * 2, h - dw * 2,
colorGroup( g, MenuItem ) ->
brush( QColorGroup::Background ) );
}
else {
// process inactive item pixmaps as one large item
p->drawTiledPixmap( x + dw, y + dw, w - dw * 2, h - dw * 2, *scalePixmap
(w, ((QWidget *)p->device())->height(), MenuItem),
//( w, p->clipRegion().boundingRect().height(), MenuItem ), // cliping does not work in Qt/E
x, y );
}
if ( checkable && mi && mi->isChecked() ) {
// draw 'pressed' border around checkable items
// This is extremely important for items that have an iconset
// because the checkmark isn't drawn in that case
// An alternative would be superimposing the checkmark over
// the iconset instead or not drawing the iconset at all.
int mw = checkcol + motifItemFrame;
drawShade( p, x, y, mw, h, g, true, false,
highlightWidth( MenuItemDown ),
borderWidth( MenuItemDown ), shade() );
}
}
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 );
}
else if ( checkable ) {
int mw = checkcol + motifItemFrame;
int mh = h - 2 * motifItemFrame;
if ( mi->isChecked() ) {
drawCheckMark( p, x + motifItemFrame,
y + motifItemFrame, mw, mh, itemg, act, dis );
}
}
p->setPen( colorGroup( g, act ? MenuItemDown : MenuItem ) ->text() );
QColor discol;
if ( dis ) {
discol = itemg.text();
p->setPen( discol );
}
int xm = motifItemFrame + checkcol + motifItemHMargin;
QString s = mi->text();
if ( !s.isNull() ) {
int t = s.find( '\t' );
int m = motifItemVMargin;
const int text_flags = AlignVCenter | ShowPrefix | DontClip | SingleLine;
if ( t >= 0 ) {
if ( dis && !act ) {
p->setPen( g.light() );
p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame + 1,
y + m + 1, tab, h - 2 * m, text_flags, s.mid( t + 1 ) );
p->setPen( discol );
}
p->drawText( x + w - tab - windowsRightBorder - motifItemHMargin - motifItemFrame,
y + m, tab, h - 2 * m, text_flags, s.mid( t + 1 ) );
}
if ( dis && !act ) {
p->setPen( g.light() );
p->drawText( x + xm + 1, y + m + 1, w - xm + 1, h - 2 * m, text_flags, s, t );
p->setPen( discol );
}
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
@@ -1,93 +1,102 @@
/*
* Copyright (C) 2001 Rik Hemsley (rikkus) <rik@kde.org>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU 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 INCLUDE_MENUITEM_DEF
#define INCLUDE_MENUITEM_DEF
#endif
#include <qmenudata.h>
#include <qpalette.h>
#include <qbitmap.h>
#include <qtabbar.h>
#include <qpointarray.h>
#include <qscrollbar.h>
#include <qframe.h>
#include <qpushbutton.h>
#include <qdrawutil.h>
#include <qpainter.h>
#include "webstyle.h"
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);
if ((diff > -72) && (diff < 72))
{
return (vbg < 128) ? Qt::white : Qt::black;
}
else
{
return fg;
}
}
// Gotta keep it separated.
static void
scrollBarControlsMetrics
(
const QScrollBar * sb,
int sliderStart,
int /* sliderMin */,
int sliderMax,
int sliderLength,
int buttonDim,
QRect & rSub,
QRect & rAdd,
QRect & rSubPage,
QRect & rAddPage,
QRect & rSlider
)
{
bool horizontal = sb->orientation() == QScrollBar::Horizontal;
int len = horizontal ? sb->width() : sb->height();
int extent = horizontal ? sb->height() : sb->width();
QColorGroup g = sb->colorGroup();
if (sliderStart > sliderMax)
sliderStart = sliderMax;
@@ -924,109 +933,220 @@ WebStyle::drawArrow
int y,
int w,
int h,
const QColorGroup & g,
bool enabled,
const QBrush * fill
)
{
QWindowsStyle::drawArrow(p, type, down, x, y, w, h, g, enabled, fill);
}
void
WebStyle::drawSlider
(
QPainter * p,
int x,
int y,
int w,
int h,
const QColorGroup & g,
Orientation o,
bool /* tickAbove */,
bool /* tickBelow */
)
{
p->save();
p->fillRect(x + 1, y + 1, w - 2, h - 2, g.background());
p->setPen(g.dark());
p->setBrush(g.light());
int sl = sliderLength();
if( o == Qt::Horizontal )
p->drawEllipse(x, y + h / 2 - sl / 2, sl, sl);
else
if( o == Qt::Vertical )
p->drawEllipse(x + w / 2 - sl / 2, y, sl, sl);
p->restore();
}
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,
const QColor * pen,
bool atBorder
)
{
p->save();
if (0 != pen)
p->setPen(0 == pen ? g.foreground() : *pen);
p->setBrush(NoBrush);
if (atBorder)
{
p->drawRect(QRect(r.x() + 1, r.y() + 1, r.width() - 2, r.height() - 2));
}
else
{
p->drawRect(r);
}
p->restore();
}
void
WebStyle::drawPanel
(
QPainter * p,
int x,
int y,
int w,
int h,
const QColorGroup & g,
bool /* sunken */,
int /* lineWidth */,
const QBrush * fill
)
{
p->save();
p->setPen(g.dark());
@@ -1123,61 +1243,61 @@ WebStyle::drawTab
}
break;
case QTabBar::RoundedBelow:
case QTabBar::TriangularBelow:
if (!selected)
{
p->setPen(g.dark());
p->drawLine(r.left(), r.top(), r.right(), r.top());
}
p->drawLine(r.left(), r.top(), r.left(), r.bottom());
p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
p->drawLine(r.right(), r.top(), r.right(), r.bottom());
break;
}
p->restore();
}
void
WebStyle::drawTabMask
(
QPainter * p,
const QTabBar *,
QTab * tab,
bool
)
{
p->fillRect(tab->rect(), Qt::color1);
}
int
WebStyle::popupMenuItemHeight(bool, QMenuItem * i, const QFontMetrics & fm)
{
if (i->isSeparator())
return 1;
int h = 0;
if (0 != i->pixmap())
{
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);
return 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
@@ -170,97 +170,97 @@ class WebStyle : public QWindowsStyle {
QRect comboButtonFocusRect(int x, int y, int w, int h);
int sliderLength() const;
void drawSliderGroove
(
QPainter *,
int x,
int y,
int w,
int h,
const QColorGroup &,
QCOORD,
Orientation
);
void drawArrow
(
QPainter *,
Qt::ArrowType,
bool down,
int x,
int y,
int w,
int h,
const QColorGroup &,
bool enabled = true,
const QBrush * fill = 0
);
void drawSlider
(
QPainter *,
int x,
int y,
int w,
int h,
const QColorGroup &,
Orientation,
bool tickAbove,
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
);
void drawFocusRect
(
QPainter *,
const QRect &,
const QColorGroup &,
const QColor * pen,
bool atBorder
);
void drawPanel
(
QPainter *,
int x,
int y,
int w,
int h,
const QColorGroup &,
bool sunken,
int lineWidth = 1,
const QBrush * = 0
);
void drawPopupPanel
(
QPainter *,
int x,
int y,
int w,
int h,
const QColorGroup &,
int lineWidth = 2,
const QBrush * = 0
);
void drawSeparator
(
QPainter *,
int x,