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
@@ -1,281 +1,285 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "launchertab.h"
#include <qapplication.h>
LauncherTabBar::LauncherTabBar( QWidget *parent, const char *name )
: QTabBar( parent, name )
{
setFocusPolicy( NoFocus );
connect( this, SIGNAL( selected(int) ), this, SLOT( layoutTabs() ) );
}
LauncherTabBar::~LauncherTabBar()
{
}
void LauncherTabBar::insertTab( LauncherTab *t, int index )
{
if ( index < 0 )
items.append( t );
else
items.insert( (uint)index, t );
tabs.insert( t->type, t );
QTabBar::insertTab( t, index );
}
void LauncherTabBar::removeTab( QTab *tab )
{
LauncherTab *t = (LauncherTab *)tab;
tabs.remove( t->type );
items.remove( t );
QTabBar::removeTab( t );
}
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,178 +1,178 @@
/*
-                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;
cfg. writeEntry ( "LauncherTabs", m_menutabs-> isChecked ( ));
}
if ( m_menusubpopup-> isChecked ( ) != cfg. readBoolEntry ( "LauncherSubPopup", true )) {
apps_changed = true;
cfg. writeEntry ( "LauncherSubPopup", m_menusubpopup-> isChecked ( ));
}
cfg. write ( );
if ( m_applets_changed ) {
QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
m_applets_changed = false;
}
if ( apps_changed ) {
// currently use reloadApplets() since reloadApps is now used exclusive for server
// to refresh the tabs. But what we want here is also a refresh of the startmenu entries
QCopEnvelope ( "QPE/TaskBar", "reloadApps()" );
QCopEnvelope ( "QPE/TaskBar", "reloadApplets()" );
}
}
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
-
-              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
{
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,86 +1,86 @@
/*
-                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>
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.
* @param has_focus Boolean value not used, retained for compatibility reasons.
*/
void paintLabel( QPainter *, const QRect &, QTab *, bool ) const;
private:
class Private;
Private *d;
};
}
}
#endif
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,229 +1,228 @@
/*
                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();
}
void OTabWidget::addTab( QWidget *child, const QString &icon, const QString &label )
{
int tabid = -1;
if ( m_usingTabs )
{
// Create new tab in tab bar
QTab *tab = new QTab();
// Set label (and icon if necessary)
if ( m_tabBarStyle == IconTab )
{
tab->label = QString::null;
tab->iconset = new QIconSet( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ) );
}
else
tab->label = label;
tabid = m_tabBar->addTab( tab );
}
else
{
// Insert entry (with icon if necessary) into drop down list
if ( m_tabBarStyle == IconList )
m_tabList->insertItem( Opie::Core::OResource::loadPixmap( icon, Opie::Core::OResource::SmallIcon ), label, -1 );
else
m_tabList->insertItem( label );
}
// Add widget to stack
m_widgetStack->addWidget( child, tabid );
m_widgetStack->raiseWidget( child );
m_widgetStack->setFrameStyle( QFrame::StyledPanel | QFrame::Raised );
// Keep track of tab information
OTabInfo *tabinfo = new OTabInfo( tabid, child, icon, label );
m_tabs.append( tabinfo );
// Make newly added tab the current one displayed
selectTab( tabinfo );
}
void OTabWidget::removePage( QWidget *childwidget )
{
if ( childwidget )
{
// Find tab information for desired widget
OTabInfo *tab = m_tabs.first();
while ( tab && tab->control() != childwidget )
tab = m_tabs.next();
if ( tab && tab->control() == childwidget )
{
if ( m_usingTabs )
{
// Remove tab from tab bar
m_tabBar->setTabEnabled( tab->id(), false );
m_tabBar->removeTab( m_tabBar->tab( tab->id() ) );
}
else
{
// Remove entry from drop down list
int i = 0;
while ( i < m_tabList->count() && m_tabList->text( i ) != tab->label() )
i++;
if ( m_tabList->text( i ) == tab->label() )
m_tabList->removeItem( i );
}
// Remove widget from stack
m_widgetStack->removeWidget( childwidget );
// Get rid of tab information
m_tabs.remove( tab );
delete tab;
// Reset current tab
m_currTab = m_tabs.current();
if ( !m_currTab )
m_widgetStack->setFrameStyle( QFrame::NoFrame );
// Redraw widget
setUpLayout();
}
}
}
void OTabWidget::changeTab( QWidget *widget, const QString &iconset, const QString &label)
{
// Find tab information for desired widget
OTabInfo *currtab = m_tabs.first();
while ( currtab && currtab->control() != widget )
currtab = m_tabs.next();
if ( currtab && currtab->control() == widget )
{
QPixmap icon( Opie::Core::OResource::loadPixmap( iconset, Opie::Core::OResource::SmallIcon ) );
if ( m_usingTabs )
{
// Update tab label and icon (if necessary)
QTab *tab = m_tabBar->tab( currtab->id() );
tab->setText( label );
if ( m_tabBarStyle == IconTab )
tab->setIconSet( icon );
}
else
{
// Update entry label and icon (if necessary)
int i = 0;
while ( i < m_tabList->count() && m_tabList->text( i ) != currtab->label() )
i++;
if ( i < m_tabList->count() && m_tabList->text( i ) == currtab->label() )
{
if ( m_tabBarStyle == IconList )
m_tabList->changeItem( icon, label, i );
else
m_tabList->changeItem( label, i );
}
}
// Update tab information
currtab->setLabel( label );
currtab->setIcon( iconset );
// Redraw widget
setUpLayout();
}
}
void OTabWidget::setCurrentTab( QWidget *childwidget )
{
OTabInfo *currtab = m_tabs.first();
while ( currtab && currtab->control() != childwidget )
{
currtab = m_tabs.next();
}
if ( currtab && currtab->control() == childwidget )
{
selectTab( currtab );
}
}
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
@@ -184,404 +184,404 @@ void FlatStyle::drawItem( QPainter *p, int x, int y, int w, int h,
if ( revItem ) {
pc = cg.button();
revItem = FALSE;
}
QWindowsStyle::drawItem( p, x, y, w, h, flags, cg, enabled, pixmap, text, len, &pc );
}
void FlatStyle::drawPanel ( QPainter * p, int x, int y, int w, int h,
const QColorGroup &g, bool /*sunken*/, int lineWidth, const QBrush * fill )
{
if ( fill )
p->setBrush( *fill );
p->setPen( QPen(g.foreground(), lineWidth) );
p->drawRect( x, y, w, h );
}
void FlatStyle::drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &cg, bool /*sunken*/, const QBrush* fill )
{
QPen oldPen = p->pen();
int x2 = x+w-1;
int y2 = y+h-1;
if ( fillBtnBorder && btnBg != cg.color(QColorGroup::Button) ) {
p->setPen( btnBg );
p->drawLine( x, y, x2, y );
p->drawLine( x, y2, x2, y2 );
p->drawLine( x, y+1, x, y2-1 );
p->drawLine( x2, y+1, x2, y2-1 );
p->fillRect( x+1, y+1, 3, 3, btnBg );
p->fillRect( x+1, y2-3, 3, 3, btnBg );
p->fillRect( x2-3, y2-3, 3, 3, btnBg );
p->fillRect( x2-3, y+1, 3, 3, btnBg );
p->fillRect( x+2, y+2, w-4, h-4, fill?(*fill):cg.brush(QColorGroup::Button) );
} else {
p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):cg.brush(QColorGroup::Button) );
}
if ( h >= 10 ) {
x++; y++;
x2--; y2--;
w -= 2; h -= 2;
}
p->setPen( cg.foreground() );
if ( h < 10 ) {
p->setBrush( NoBrush );
p->drawRect( x, y, w, h );
} else {
p->drawLine( x+3, y, x2-3, y );
p->drawLine( x+3, y2, x2-3, y2 );
p->drawLine( x, y+3, x, y2-3 );
p->drawLine( x2, y+3, x2, y2-3 );
p->drawLine( x+1, y+1, x+2, y+1 );
p->drawPoint( x+1, y+2 );
p->drawLine( x2-2, y+1, x2-1, y+1 );
p->drawPoint( x2-1, y+2 );
p->drawLine( x+1, y2-1, x+2, y2-1 );
p->drawPoint( x+1, y2-2 );
p->drawLine( x2-2, y2-1, x2-1, y2-1 );
p->drawPoint( x2-1, y2-2 );
}
p->setPen( oldPen );
}
void FlatStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h )
{
x++; y++;
x-=2; y-=2;
p->fillRect( x, y, w, h, color1 );
}
void FlatStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool /*sunken*/, const QBrush* fill )
{
p->fillRect( x+1, y+1, w-2, h-2, fill?(*fill):g.brush(QColorGroup::Button) );
p->setPen( g.foreground() );
p->setBrush( NoBrush );
p->drawRect( x, y, w, h );
}
void FlatStyle::drawToolButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, const QBrush* fill )
{
if ( p->device()->devType() == QInternal::Widget ) {
QWidget *w = (QWidget *)p->device();
if ( w->isA("QToolButton") ) {
QToolButton *btn = (QToolButton *)w;
if ( btn->parentWidget() ) {
btnBg = btn->parentWidget()->backgroundColor();
fillBtnBorder = TRUE;
}
}
}
QBrush fb( fill ? *fill : g.button() );
if ( sunken && fb == g.brush( QColorGroup::Button ) ) {
fb = g.buttonText();
revItem = TRUE; // ugh
}
drawButton( p, x, y, w, h, g, sunken, &fb );
fillBtnBorder = FALSE;
}
void FlatStyle::drawPushButton( QPushButton *btn, QPainter *p )
{
QColorGroup g = btn->colorGroup();
int x1, y1, x2, y2;
btn->rect().coords( &x1, &y1, &x2, &y2 ); // get coordinates
p->setPen( g.foreground() );
p->setBrush( QBrush(g.button(),NoBrush) );
// int diw = buttonDefaultIndicatorWidth();
/*
if ( btn->isDefault() || btn->autoDefault() ) {
if ( btn->isDefault() ) {
p->setPen( g.shadow() );
p->drawRect( x1, y1, x2-x1+1, y2-y1+1 );
}
x1 += diw;
y1 += diw;
x2 -= diw;
y2 -= diw;
}
*/
if ( btn->parentWidget() ) {
btnBg = btn->parentWidget()->backgroundColor();
fillBtnBorder = TRUE;
}
bool clearButton = TRUE;
if ( btn->isDown() ) {
drawButton( p, x1, y1, x2-x1+1, y2-y1+1, g, TRUE,
&g.brush( QColorGroup::Text ) );
} else {
if ( btn->isToggleButton() && btn->isOn() && btn->isEnabled() ) {
QBrush fill(g.light(), Dense4Pattern );
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 ) );
}
void FlatStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w,
int h, const QColorGroup &cg, bool on, bool down, bool enabled )
{
static const QCOORD pts1[] = { // dark lines
1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
static const QCOORD pts4[] = { // white lines
2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
11,4, 10,3, 10,2 };
static const QCOORD pts5[] = { // inner fill
4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
p->eraseRect( x, y, w, h );
QPointArray a( QCOORDARRLEN(pts1), pts4 );
a.translate( x, y );
p->setPen( cg.foreground() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts4), pts1 );
a.translate( x, y );
p->setPen( cg.foreground() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts5), pts5 );
a.translate( x, y );
QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
p->setPen( fillColor );
p->setBrush( fillColor ) ;
p->drawPolygon( a );
if ( on ) {
p->setPen( NoPen );
p->setBrush( cg.text() );
p->drawRect( x+5, y+4, 2, 4 );
p->drawRect( x+4, y+5, 4, 2 );
}
}
void FlatStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h,
const QColorGroup &cg, int state, bool down, bool enabled )
{
QColorGroup mycg( cg );
mycg.setBrush( QColorGroup::Button, QBrush() );
QBrush fill;
drawButton( p, x, y, w, h, mycg, TRUE, 0 );
if ( down )
fill = cg.brush( QColorGroup::Button );
else
fill = cg.brush( enabled ? QColorGroup::Base : QColorGroup::Background );
mycg.setBrush( QColorGroup::Button, fill );
p->fillRect( x+1, y+1, w-2, h-2, fill );
if ( state != QButton::Off ) {
QPointArray a( 7*2 );
int i, xx, yy;
xx = x+3;
yy = y+5;
for ( i=0; i<3; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=3; i<7; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
if ( state == QButton::NoChange ) {
p->setPen( mycg.dark() );
} else {
p->setPen( mycg.text() );
}
p->drawLineSegments( a );
}
}
#define HORIZONTAL (sb->orientation() == QScrollBar::Horizontal)
#define VERTICAL !HORIZONTAL
#define MOTIF_BORDER 2
#define SLIDER_MIN 9 // ### motif says 6 but that's too small
/*! \reimp */
void FlatStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim )
{
int maxLength;
int length = HORIZONTAL ? sb->width() : sb->height();
int extent = HORIZONTAL ? sb->height() : sb->width();
if ( length > (extent - 1)*2 )
buttonDim = extent;
else
buttonDim = length/2 - 1;
sliderMin = 0;
maxLength = length - buttonDim*2 + 2;
if ( sb->maxValue() == sb->minValue() ) {
sliderLength = maxLength;
} else {
sliderLength = (sb->pageStep()*maxLength)/
(sb->maxValue()-sb->minValue()+sb->pageStep());
uint range = sb->maxValue()-sb->minValue();
if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 )
sliderLength = SLIDER_MIN;
if ( sliderLength > maxLength )
sliderLength = maxLength;
}
sliderMax = sliderMin + maxLength - sliderLength;
}
/*!\reimp
*/
QStyle::ScrollControl FlatStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p )
{
if ( !sb->rect().contains( p ) )
return NoScroll;
int sliderMin, sliderMax, sliderLength, buttonDim, pos;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if (sb->orientation() == QScrollBar::Horizontal)
pos = p.x();
else
pos = p.y();
if (pos < sliderStart)
return SubPage;
if (pos < sliderStart + sliderLength)
return Slider;
if (pos < sliderMax + sliderLength)
return AddPage;
if (pos < sliderMax + sliderLength + buttonDim)
return SubLine;
return AddLine;
}
/*! \reimp */
void FlatStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl )
{
#define ADD_LINE_ACTIVE ( activeControl == AddLine )
#define SUB_LINE_ACTIVE ( activeControl == SubLine )
QColorGroup g = sb->colorGroup();
int sliderMin, sliderMax, sliderLength, buttonDim;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) ) {
p->setPen( g.foreground() );
p->setBrush( g.brush( QColorGroup::Mid ) );
p->drawRect( 0, 0, sb->width(), sb->height() );
}
if (sliderStart > sliderMax) { // sanity check
sliderStart = sliderMax;
}
int dimB = buttonDim;
QRect addB;
QRect subB;
QRect addPageR;
QRect subPageR;
QRect sliderR;
int addX, addY, subX, subY;
@@ -703,400 +703,404 @@ void FlatStyle::drawRiffles( QPainter* p, int x, int y, int w, int h,
int mx = x+w/2-4;
int i ;
p->setPen(g.buttonText());
for (i=0; i<n; i++) {
p->drawLine(mx+3*i, y+4, mx + 3*i, y+h-5);
}
}
}
}
int FlatStyle::sliderLength() const
{
return 12;
}
void FlatStyle::drawSlider( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow )
{
int a = tickAbove ? 3 : 0;
int b = tickBelow ? 3 : 0;
p->setPen( g.foreground() );
p->setBrush( g.button() );
if ( o == Horizontal ) {
p->drawRect( x, y+a, w, h-a-b );
int xp = x + w/2;
p->drawLine( xp-1, y+a+3, xp-1, y+h-b-4 );
p->drawLine( xp, y+a+3, xp, y+h-b-4 );
} else {
p->drawRect( x+a, y, w-a-b, h );
int yp = y + h/2;
p->drawLine( x+a+3, yp-1, x+w-b-4, yp-1 );
p->drawLine( x+a+3, yp, x+w-b-4, yp );
}
}
void FlatStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h,
Orientation o, bool tickAbove, bool tickBelow )
{
int a = tickAbove ? 3 : 0;
int b = tickBelow ? 3 : 0;
if ( o == Horizontal )
p->fillRect( x, y+a, w, h-a-b, color1 );
else
p->fillRect( x+a, y, w-a-b, h, color1 );
}
/*!\reimp
*/
void FlatStyle::drawSliderGrooveMask( QPainter *p,
int x, int y, int w, int h,
const QColorGroup& , QCOORD c,
Orientation orient )
{
if ( orient == Horizontal )
p->fillRect( x, y + c - 2, w, 4, color1 );
else
p->fillRect( x + c - 2, y, 4, h, color1 );
}
void FlatStyle::drawSliderGroove( QPainter *p, int x, int y, int w, int h, const QColorGroup &g, QCOORD c, Orientation orient )
{
if ( orient == Horizontal )
p->fillRect( x, y + c - 2, w, 4, g.foreground() );
else
p->fillRect( x + c - 2, y, 4, h, g.foreground() );
}
void FlatStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected )
{
QRect r( t->rect() );
if ( tb->shape() == QTabBar::RoundedAbove ) {
p->setPen( tb->colorGroup().foreground() );
p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
if ( r.left() == 0 )
p->drawPoint( tb->rect().bottomLeft() );
else
p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
if ( selected ) {
p->setPen( tb->colorGroup().background() );
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()-2),
tb->colorGroup().brush( QColorGroup::Background ));
} else {
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 ));
}
p->setPen( tb->colorGroup().foreground() );
p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );
p->drawPoint( r.left()+1, r.top() + 1 );
p->drawLine( r.left()+2, r.top(),
r.right() - 2, r.top() );
p->drawPoint( r.right() - 1, r.top() + 1 );
p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
} else if ( tb->shape() == QTabBar::RoundedBelow ) {
if ( selected ) {
p->setPen( tb->colorGroup().background() );
p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
tb->palette().normal().brush( QColorGroup::Background ));
} else {
p->setPen( tb->colorGroup().foreground() );
p->drawLine( r.left(), r.top(),
r.right(), r.top() );
r.setRect( r.left() + 2, r.top(),
r.width() - 4, r.height() - 2 );
p->setPen( tb->colorGroup().button() );
p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
tb->palette().normal().brush( QColorGroup::Button ));
}
p->setPen( tb->colorGroup().foreground() );
p->drawLine( r.right(), r.top(),
r.right(), r.bottom() - 2 );
p->drawPoint( r.right() - 1, r.bottom() - 1 );
p->drawLine( r.right() - 2, r.bottom(),
r.left() + 2, r.bottom() );
p->drawLine( r.left(), r.top()+1,
r.left(), r.bottom() - 2 );
p->drawPoint( r.left() + 1, r.bottom() - 1 );
if ( r.left() == 0 )
p->drawPoint( tb->rect().topLeft() );
} else {
QCommonStyle::drawTab( p, tb, t, selected );
}
}
static const int motifItemFrame = 0; // menu item frame width
static const int motifSepHeight = 2; // separator item height
static const int motifItemHMargin = 1; // menu item hor text margin
static const int motifItemVMargin = 2; // menu item ver text margin
static const int motifArrowHMargin = 0; // arrow horizontal margin
static const int motifTabSpacing = 12; // space between text and tab
static const int motifCheckMarkHMargin = 1; // horiz. margins of check mark
static const int windowsRightBorder = 8; // right border on windows
static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
void FlatStyle::polishPopupMenu ( QPopupMenu *m )
{
QWindowsStyle::polishPopupMenu( m );
m->setLineWidth( 1 );
}
/*! \reimp
*/
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
+#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;
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();
if ( !s.isNull() ) { // draw text
int t = s.find( '\t' );
int m = motifItemVMargin;
const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
if ( t >= 0 ) { // draw tab text
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( discol );
p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
} else if ( mi->pixmap() ) { // draw 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() ) { // draw sub menu arrow
int dim = (h-2*motifItemFrame) / 2;
if ( act ) {
if ( !dis )
discol = white;
QColorGroup g2( discol, g.highlight(),
white, white,
dis ? discol : white,
discol, white );
drawArrow( p, RightArrow, FALSE,
x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
dim, dim, g2, TRUE );
} else {
drawArrow( p, RightArrow,
FALSE,
x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
dim, dim, g, mi->isEnabled() );
}
}
#endif
}
void FlatStyle::getButtonShift( int &x, int &y )
{
x = 0; y = 0;
}
//===========================================================================
FlatStyleImpl::FlatStyleImpl()
: flat(0)
{
}
FlatStyleImpl::~FlatStyleImpl()
{
// We do not delete the style because Qt does that when a new style
// is set.
}
QStyle *FlatStyleImpl::style()
{
if ( !flat )
flat = new FlatStyle();
return flat;
}
QString FlatStyleImpl::name() const
{
return qApp->translate("FlatStyle", "Flat", "Name of the style Flat");
}
QRESULT FlatStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_Style )
*iface = this;
else
return QS_FALSE;
(*iface)->addRef();
return QS_OK;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( FlatStyleImpl )
}
#include "flat.moc"
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
@@ -1,848 +1,852 @@
/**********************************************************************
** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
**
** This file is part of the Qtopia Environment.
**
** This file may be distributed and/or modified under the terms of the
** GNU General Public License version 2 as published by the Free Software
** Foundation and appearing in the file LICENSE.GPL included in the
** packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.trolltech.com/gpl/ for GPL licensing information.
**
** Contact info@trolltech.com if any conditions of this licensing are
** not clear to you.
**
**********************************************************************/
#include "fresh.h"
#include <qpe/qpeapplication.h>
#include <qpushbutton.h>
#include <qpainter.h>
#include <qfontmetrics.h>
#include <qpalette.h>
#include <qdrawutil.h>
#include <qscrollbar.h>
#include <qbutton.h>
#include <qframe.h>
#include <qtabbar.h>
#define INCLUDE_MENUITEM_DEF
#include <qmenudata.h>
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
FreshStyle::FreshStyle()
{
setButtonMargin(2);
setScrollBarExtent(13,13);
}
FreshStyle::~FreshStyle()
{
}
int FreshStyle::buttonMargin() const
{
return 2;
}
QSize FreshStyle::scrollBarExtent() const
{
return QSize(13,13);
}
void FreshStyle::polish ( QPalette & )
{
}
void FreshStyle::polish( QWidget *w )
{
if ( w->inherits( "QListBox" ) ||
w->inherits( "QListView" ) ||
w->inherits( "QPopupMenu" ) ||
w->inherits( "QSpinBox" ) ) {
QFrame *f = (QFrame *)w;
f->setFrameShape( QFrame::StyledPanel );
f->setLineWidth( 1 );
}
}
void FreshStyle::unPolish( QWidget *w )
{
if ( w->inherits( "QListBox" ) ||
w->inherits( "QListView" ) ||
w->inherits( "QPopupMenu" ) ||
w->inherits( "QSpinBox" ) ) {
QFrame *f = (QFrame *)w;
f->setFrameShape( QFrame::StyledPanel );
f->setLineWidth( 2 );
}
}
int FreshStyle::defaultFrameWidth() const
{
return 1;
}
void FreshStyle::drawPanel ( QPainter * p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, int lineWidth, const QBrush * fill )
{
qDrawShadePanel( p, QRect(x, y, w, h), g, sunken, lineWidth, fill );
}
void FreshStyle::drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &cg, bool sunken, const QBrush* fill )
{
QPen oldPen = p->pen();
int off = sunken ? 1 : 0;
p->fillRect( x+1+off, y+1+off, w-3, h-3, fill?(*fill):cg.brush(QColorGroup::Button) );
int x2 = x+w-1;
int y2 = y+h-1;
if ( sunken )
p->setPen( cg.dark() );
else
p->setPen( cg.light() );
p->drawLine( x, y, x, y2-1 );
p->drawLine( x, y, x2, y );
if ( sunken ) {
p->setPen( white );
p->drawLine( x+1, y+1, x+1, y2-2 );
p->drawLine( x+1, y+1, x2-2, y+1 );
}
if ( sunken )
p->setPen( cg.light() );
else
p->setPen( cg.dark() );
p->drawLine( x2, y+1, x2, y2 );
p->drawLine( x, y2, x2, y2 );
if ( !sunken ) {
p->setPen( white );
p->drawLine( x2-1, y+1, x2-1, y2-1 );
p->drawLine( x+1, y2-1, x2-1, y2-1 );
}
p->setPen( oldPen );
}
void FreshStyle::drawButtonMask ( QPainter * p, int x, int y, int w, int h )
{
p->fillRect( x, y, w, h, color1 );
}
void FreshStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, const QBrush* fill )
{
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*/,
bool enabled,
const QBrush *fill )
{
drawBevelButton( p, x, y, w, h, g, FALSE, fill );
drawBevelButton( p, x+w-14, y, 14, h, g, sunken, fill );
drawArrow( p, QStyle::DownArrow, sunken,
x+w-14+ 2, y+ 2, 14- 4, h- 4, g, enabled,
&g.brush( QColorGroup::Button ) );
}
void FreshStyle::drawExclusiveIndicator ( QPainter * p, int x, int y, int w,
int h, const QColorGroup &cg, bool on, bool down, bool enabled )
{
static const QCOORD pts1[] = { // dark lines
1,9, 1,8, 0,7, 0,4, 1,3, 1,2, 2,1, 3,1, 4,0, 7,0, 8,1, 9,1 };
static const QCOORD pts4[] = { // white lines
2,10, 3,10, 4,11, 7,11, 8,10, 9,10, 10,9, 10,8, 11,7,
11,4, 10,3, 10,2 };
static const QCOORD pts5[] = { // inner fill
4,2, 7,2, 9,4, 9,7, 7,9, 4,9, 2,7, 2,4 };
p->eraseRect( x, y, w, h );
QPointArray a( QCOORDARRLEN(pts1), pts4 );
a.translate( x, y );
p->setPen( cg.dark() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts4), pts1 );
a.translate( x, y );
p->setPen( cg.light() );
p->drawPolyline( a );
a.setPoints( QCOORDARRLEN(pts5), pts5 );
a.translate( x, y );
QColor fillColor = ( down || !enabled ) ? cg.button() : cg.base();
p->setPen( fillColor );
p->setBrush( fillColor ) ;
p->drawPolygon( a );
if ( on ) {
p->setPen( NoPen );
p->setBrush( cg.text() );
p->drawRect( x+5, y+4, 2, 4 );
p->drawRect( x+4, y+5, 4, 2 );
}
}
void FreshStyle::drawIndicator ( QPainter * p, int x, int y, int w, int h,
const QColorGroup &cg, int state, bool down, bool enabled )
{
QColorGroup mycg( cg );
mycg.setBrush( QColorGroup::Button, QBrush() );
QBrush fill;
drawButton( p, x, y, w, h, mycg, TRUE, 0 );
if ( down )
fill = cg.brush( QColorGroup::Button );
else
fill = cg.brush( enabled ? QColorGroup::Base : QColorGroup::Background );
mycg.setBrush( QColorGroup::Button, fill );
p->fillRect( x+1, y+1, w-2, h-2, fill );
if ( state != QButton::Off ) {
QPointArray a( 7*2 );
int i, xx, yy;
xx = x+3;
yy = y+5;
for ( i=0; i<3; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy++;
}
yy -= 2;
for ( i=3; i<7; i++ ) {
a.setPoint( 2*i, xx, yy );
a.setPoint( 2*i+1, xx, yy+2 );
xx++; yy--;
}
if ( state == QButton::NoChange ) {
p->setPen( mycg.dark() );
} else {
p->setPen( mycg.text() );
}
p->drawLineSegments( a );
}
}
#define HORIZONTAL (sb->orientation() == QScrollBar::Horizontal)
#define VERTICAL !HORIZONTAL
#define MOTIF_BORDER 2
#define SLIDER_MIN 9 // ### motif says 6 but that's too small
/*! \reimp */
void FreshStyle::scrollBarMetrics( const QScrollBar* sb, int &sliderMin, int &sliderMax, int &sliderLength, int& buttonDim )
{
int maxLength;
int length = HORIZONTAL ? sb->width() : sb->height();
int extent = HORIZONTAL ? sb->height() : sb->width();
if ( length > (extent - 1)*2 )
buttonDim = extent;
else
buttonDim = length/2 - 1;
sliderMin = 0;
maxLength = length - buttonDim*2;
if ( sb->maxValue() == sb->minValue() ) {
sliderLength = maxLength;
} else {
sliderLength = (sb->pageStep()*maxLength)/
(sb->maxValue()-sb->minValue()+sb->pageStep());
uint range = sb->maxValue()-sb->minValue();
if ( sliderLength < SLIDER_MIN || range > INT_MAX/2 )
sliderLength = SLIDER_MIN;
if ( sliderLength > maxLength )
sliderLength = maxLength;
}
sliderMax = sliderMin + maxLength - sliderLength;
}
/*!\reimp
*/
QStyle::ScrollControl FreshStyle::scrollBarPointOver( const QScrollBar* sb, int sliderStart, const QPoint& p )
{
if ( !sb->rect().contains( p ) )
return NoScroll;
int sliderMin, sliderMax, sliderLength, buttonDim, pos;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if (sb->orientation() == QScrollBar::Horizontal)
pos = p.x();
else
pos = p.y();
if (pos < sliderStart)
return SubPage;
if (pos < sliderStart + sliderLength)
return Slider;
if (pos < sliderMax + sliderLength)
return AddPage;
if (pos < sliderMax + sliderLength + buttonDim)
return SubLine;
return AddLine;
}
/*! \reimp */
void FreshStyle::drawScrollBarControls( QPainter* p, const QScrollBar* sb, int sliderStart, uint controls, uint activeControl )
{
#define ADD_LINE_ACTIVE ( activeControl == AddLine )
#define SUB_LINE_ACTIVE ( activeControl == SubLine )
QColorGroup g = sb->colorGroup();
int sliderMin, sliderMax, sliderLength, buttonDim;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if ( controls == (AddLine | SubLine | AddPage | SubPage | Slider | First | Last ) )
p->fillRect( 0, 0, sb->width(), sb->height(), g.brush( QColorGroup::Mid ));
if (sliderStart > sliderMax) { // sanity check
sliderStart = sliderMax;
}
int dimB = buttonDim;
QRect addB;
QRect subB;
QRect addPageR;
QRect subPageR;
QRect sliderR;
int addX, addY, subX, subY;
int length = HORIZONTAL ? sb->width() : sb->height();
int extent = HORIZONTAL ? sb->height() : sb->width();
if ( HORIZONTAL ) {
subY = addY = ( extent - dimB ) / 2;
subX = length - dimB - dimB;
addX = length - dimB;
} else {
subX = addX = ( extent - dimB ) / 2;
subY = length - dimB - dimB;
addY = length - dimB;
}
int sliderEnd = sliderStart + sliderLength;
int sliderW = extent;
if ( HORIZONTAL ) {
subB.setRect( subX,subY+1,dimB,dimB-1 );
addB.setRect( addX,addY+1,dimB,dimB-1 );
subPageR.setRect( 0, 0,
sliderStart+1, sliderW );
addPageR.setRect( sliderEnd-1, 0, subX - sliderEnd+1, sliderW );
sliderR .setRect( sliderStart, 1, sliderLength, sliderW-1 );
} else {
subB.setRect( subX+1,subY,dimB-1,dimB );
addB.setRect( addX+1,addY,dimB-1,dimB );
subPageR.setRect( 0, 0, sliderW,
sliderStart+1 );
addPageR.setRect( 0, sliderEnd-1, sliderW, subY - sliderEnd+1 );
sliderR .setRect( 1, sliderStart, sliderW-1, sliderLength );
}
bool maxedOut = (sb->maxValue() == sb->minValue());
if ( controls & AddLine ) {
drawBevelButton( p, addB.x(), addB.y(),
addB.width(), addB.height(), g,
ADD_LINE_ACTIVE);
p->setPen(g.shadow());
drawArrow( p, VERTICAL ? DownArrow : RightArrow,
FALSE, addB.x()+2, addB.y()+2,
addB.width()-4, addB.height()-4, g, !maxedOut,
&g.brush( QColorGroup::Button ));
}
if ( controls & SubLine ) {
drawBevelButton( p, subB.x(), subB.y(),
subB.width(), subB.height(), g,
SUB_LINE_ACTIVE );
p->setPen(g.shadow());
drawArrow( p, VERTICAL ? UpArrow : LeftArrow,
FALSE, subB.x()+2, subB.y()+2,
subB.width()-4, subB.height()-4, g, !maxedOut,
&g.brush( QColorGroup::Button ));
}
if ( controls & SubPage )
p->fillRect( subPageR.x(), subPageR.y(), subPageR.width(),
subPageR.height(), g.brush( QColorGroup::Mid ));
if ( controls & AddPage )
p->fillRect( addPageR.x(), addPageR.y(), addPageR.width(),
addPageR.height(), g.brush( QColorGroup::Mid ));
if ( controls & Slider ) {
QPoint bo = p->brushOrigin();
p->setBrushOrigin(sliderR.topLeft());
drawBevelButton( p, sliderR.x(), sliderR.y(),
sliderR.width(), sliderR.height(), g,
FALSE, &g.brush( QColorGroup::Button ) );
p->setBrushOrigin(bo);
drawRiffles( p, sliderR.x(), sliderR.y(),
sliderR.width(), sliderR.height(), g, HORIZONTAL );
}
// ### perhaps this should not be able to accept focus if maxedOut?
if ( sb->hasFocus() && (controls & Slider) )
p->drawWinFocusRect( sliderR.x()+2, sliderR.y()+2,
sliderR.width()-5, sliderR.height()-5,
sb->backgroundColor() );
}
void FreshStyle::drawRiffles( QPainter* p, int x, int y, int w, int h,
const QColorGroup &g, bool horizontal )
{
return;
if (!horizontal) {
if (h > 20) {
y += (h-20)/2 ;
h = 20;
}
if (h > 12) {
int n = 3;
int my = y+h/2-4;
int i ;
p->setPen(g.light());
for (i=0; i<n; i++) {
p->drawLine(x+2, my+3*i, x+w-4, my+3*i);
}
p->setPen(g.dark());
my++;
for (i=0; i<n; i++) {
p->drawLine(x+2, my+3*i, x+w-4, my+3*i);
}
}
}
else {
if (w > 20) {
x += (w-20)/2 ;
w = 20;
}
if (w > 12) {
int n = 3;
int mx = x+w/2-4;
int i ;
p->setPen(g.light());
for (i=0; i<n; i++) {
p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4);
}
p->setPen(g.dark());
mx++;
for (i=0; i<n; i++) {
p->drawLine(mx+3*i, y+2, mx + 3*i, y+h-4);
}
}
}
}
int FreshStyle::sliderLength() const
{
return 12;
}
void FreshStyle::drawSlider( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, Orientation o, bool tickAbove, bool tickBelow )
{
int a = tickAbove ? 3 : 0;
int b = tickBelow ? 3 : 0;
if ( o == Horizontal ) {
drawBevelButton( p, x, y+a, w, h-a-b, g, FALSE, &g.brush( QColorGroup::Button ) );
int xp = x + w/2;
qDrawShadeLine( p, xp, y+a+2, xp, y+h-b-3, g );
} else {
drawBevelButton( p, x+a, y, w-a-b, h, g, FALSE, &g.brush( QColorGroup::Button ) );
int yp = y + h/2;
qDrawShadeLine( p, x+a+2, yp, x+w-b-3, yp, g );
}
}
void FreshStyle::drawSliderMask ( QPainter * p, int x, int y, int w, int h,
Orientation o, bool tickAbove, bool tickBelow )
{
int a = tickAbove ? 3 : 0;
int b = tickBelow ? 3 : 0;
if ( o == Horizontal )
p->fillRect( x, y+a, w, h-a-b, color1 );
else
p->fillRect( x+a, y, w-a-b, h, color1 );
}
/*!\reimp
*/
void FreshStyle::drawSliderGrooveMask( QPainter *p,
int x, int y, int w, int h,
const QColorGroup& , QCOORD c,
Orientation orient )
{
if ( orient == Horizontal )
p->fillRect( x, y + c - 2, w, 4, color1 );
else
p->fillRect( x + c - 2, y, 4, h, color1 );
}
void FreshStyle::drawTab( QPainter *p, const QTabBar *tb, QTab *t, bool selected )
{
QRect r( t->rect() );
if ( tb->shape() == QTabBar::RoundedAbove ) {
p->setPen( tb->colorGroup().light() );
p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
if ( r.left() == 0 )
p->drawPoint( tb->rect().bottomLeft() );
else {
p->setPen( tb->colorGroup().light() );
p->drawLine( r.left(), r.bottom(), r.right(), r.bottom() );
}
if ( selected ) {
p->setPen( tb->colorGroup().background() );
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()-2),
tb->colorGroup().brush( QColorGroup::Background ));
} else {
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;
int x1 = r.left()+1;
int x2 = r.right()-1;
p->drawLine( x1, y, x2, y );
}
}
p->setPen( tb->colorGroup().light() );
p->drawLine( r.left(), r.bottom()-1, r.left(), r.top() + 2 );
p->drawPoint( r.left()+1, r.top() + 1 );
p->drawLine( r.left()+2, r.top(),
r.right() - 2, r.top() );
p->setPen( tb->colorGroup().dark() );
p->drawPoint( r.right() - 1, r.top() + 1 );
p->drawLine( r.right(), r.top() + 2, r.right(), r.bottom() - 1);
} else if ( tb->shape() == QTabBar::RoundedBelow ) {
if ( selected ) {
p->setPen( tb->colorGroup().background() );
p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
p->fillRect( QRect( r.left()+1, r.top(), r.width()-2, r.height()-2),
tb->palette().normal().brush( QColorGroup::Background ));
} else {
p->setPen( tb->colorGroup().dark() );
p->drawLine( r.left(), r.top(),
r.right(), r.top() );
r.setRect( r.left() + 2, r.top(),
r.width() - 4, r.height() - 2 );
p->setPen( tb->colorGroup().button() );
p->drawLine( r.left()+2, r.bottom()-1, r.right()-2, r.bottom()-1 );
p->fillRect( QRect( r.left()+1, r.top()+1, r.width()-2, r.height()-3),
tb->palette().normal().brush( QColorGroup::Button ));
}
p->setPen( tb->colorGroup().dark() );
p->drawLine( r.right(), r.top(),
r.right(), r.bottom() - 2 );
p->drawPoint( r.right() - 1, r.bottom() - 1 );
p->drawLine( r.right() - 2, r.bottom(),
r.left() + 2, r.bottom() );
p->setPen( tb->colorGroup().light() );
p->drawLine( r.left(), r.top()+1,
r.left(), r.bottom() - 2 );
p->drawPoint( r.left() + 1, r.bottom() - 1 );
if ( r.left() == 0 )
p->drawPoint( tb->rect().topLeft() );
} else {
QCommonStyle::drawTab( p, tb, t, selected );
}
}
static const int motifItemFrame = 0; // menu item frame width
static const int motifSepHeight = 2; // separator item height
static const int motifItemHMargin = 1; // menu item hor text margin
static const int motifItemVMargin = 2; // menu item ver text margin
static const int motifArrowHMargin = 0; // arrow horizontal margin
static const int motifTabSpacing = 12; // space between text and tab
static const int motifCheckMarkHMargin = 1; // horiz. margins of check mark
static const int windowsRightBorder = 8; // right border on windows
static const int windowsCheckMarkWidth = 2; // checkmarks width on windows
/*! \reimp
*/
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
+#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;
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();
if ( !s.isNull() ) { // draw text
int t = s.find( '\t' );
int m = motifItemVMargin;
const int text_flags = AlignVCenter|ShowPrefix | DontClip | SingleLine;
if ( t >= 0 ) { // draw tab text
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 );
}
p->drawText( x+xm, y+m, w-xm-tab+1, h-2*m, text_flags, s, t );
} else if ( mi->pixmap() ) { // draw 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() ) { // draw sub menu arrow
int dim = (h-2*motifItemFrame) / 2;
if ( act ) {
if ( !dis )
discol = white;
QColorGroup g2( discol, g.highlight(),
white, white,
dis ? discol : white,
discol, white );
drawArrow( p, RightArrow, FALSE,
x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
dim, dim, g2, TRUE );
} else {
drawArrow( p, RightArrow,
FALSE,
x+w - motifArrowHMargin - motifItemFrame - dim, y+h/2-dim/2,
dim, dim, g, mi->isEnabled() );
}
}
#endif
}
//===========================================================================
FreshStyleImpl::FreshStyleImpl()
: fresh(0)
{
}
FreshStyleImpl::~FreshStyleImpl()
{
// We do not delete the style because Qt does that when a new style
// is set.
}
QStyle *FreshStyleImpl::style()
{
if ( !fresh )
fresh = new FreshStyle();
return fresh;
}
QString FreshStyleImpl::name() const
{
return QString("Fresh");
}
QRESULT FreshStyleImpl::queryInterface( const QUuid &uuid, QUnknownInterface **iface )
{
*iface = 0;
if ( uuid == IID_QUnknown )
*iface = this;
else if ( uuid == IID_Style )
*iface = this;
else
return QS_FALSE;
if ( *iface )
(*iface)->addRef();
return QS_OK;
}
Q_EXPORT_INTERFACE()
{
Q_CREATE_INSTANCE( FreshStyleImpl )
}
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,2613 +1,2620 @@
/*-
* Copyright (C)QPL 2001 Daniel M. Duley. All rights reserved.
*/
//
-// (c) 2002 Robert 'sandman' Griebl
+// (c) 2002 Robert 'sandman' Griebl
//
#ifndef INCLUDE_MENUITEM_DEF
#define INCLUDE_MENUITEM_DEF
#endif
#include "liquid.h"
-#include "effects.h"
+#include "effects.h"
#include "htmlmasks.h"
#include "embeddata.h"
/* OPIE */
#include <opie2/odebug.h>
#include <qpe/config.h>
using namespace Opie::Core;
/* QT */
#include <qmenudata.h>
#include <qapplication.h>
#include <qpalette.h>
#include <qbitmap.h>
#include <qtabbar.h>
#include <qpopupmenu.h>
#include <qobjectlist.h>
#include <qimage.h>
#include <qtimer.h>
#include <qpixmapcache.h>
#include <qradiobutton.h>
#include <qcombobox.h>
#include <qdrawutil.h>
#include <qwidgetlist.h>
#include <qtoolbutton.h>
#include <qheader.h>
#include <qmenubar.h>
#include <qprogressbar.h>
#include <qlineedit.h>
#include <qlistbox.h>
/* STD */
#include <unistd.h>
#include <stdio.h>
typedef void (QStyle::*QDrawMenuBarItemImpl) (QPainter *, int, int, int, int, QMenuItem *,
QColorGroup &, bool, bool);
QDrawMenuBarItemImpl qt_set_draw_menu_bar_impl(QDrawMenuBarItemImpl impl);
void TransMenuHandler::stripePixmap(QPixmap &pix, const QColor &color)
{
QImage img(pix.convertToImage());
QImageEffect::fade(img, 0.9, color);
int x, y;
int r, g, b;
for(y=0; y < img.height(); y+=3){
unsigned int *data = (unsigned int *) img.scanLine(y);
for(x=0; x < img.width(); ++x){
r = qRed(data[x]);
g = qGreen(data[x]);
b = qBlue(data[x]);
if(r-10)
r-=10;
if(g-10)
g-=10;
if(b-10)
b-=10;
data[x] = qRgb(r, g, b);
}
}
pix.convertFromImage(img);
}
TransMenuHandler::TransMenuHandler(QObject *parent)
: QObject(parent)
{
pixDict.setAutoDelete(true);
reloadSettings();
}
void TransMenuHandler::reloadSettings()
{
pixDict.clear();
Config config ( "qpe" );
config. setGroup ( "Liquid-Style" );
type = config. readNumEntry("Type", TransStippleBg);
color = QColor ( config. readEntry("Color", QApplication::palette().active().button().name()));
fgColor = QColor ( config. readEntry("TextColor", QApplication::palette().active().text().name()));
opacity = config. readNumEntry("Opacity", 10);
if ( opacity < -20 )
opacity = 20;
else if ( opacity > 20 )
opacity = 20;
-
+
shadowText = config. readBoolEntry("ShadowText", true);
}
bool TransMenuHandler::eventFilter(QObject *obj, QEvent *ev)
{
QWidget *p = (QWidget *)obj;
if(ev->type() == QEvent::Show){
if(type == TransStippleBg || type == TransStippleBtn ||
type == Custom){
QApplication::syncX();
QPixmap *pix = new QPixmap;
if(p->testWFlags(Qt::WType_Popup)){
QRect r(p->x(), p->y(), p->width(), p->height());
QRect deskR = QApplication::desktop()->rect();
if(r.right() > deskR.right() || r.bottom() > deskR.bottom()){
r.setBottom(deskR.bottom());
r.setRight(deskR.right());
}
*pix = QPixmap::grabWindow(QApplication::desktop()-> winId(), r.x(), r.y(),
r.width(), r.height());
}
else{ // tear off menu
pix->resize(p->width(), p->height());
pix->fill(Qt::black.rgb());
}
if(type == TransStippleBg){
stripePixmap(*pix, p->colorGroup().background());
}
else if(type == TransStippleBtn){
stripePixmap(*pix, p->colorGroup().button());
}
else{
QPixmapEffect::fade(*pix, (((float)opacity)+80)*0.01, color);
}
pixDict.insert(p->winId(), pix);
-
- if ( !p->inherits("QPopupMenu"))
+
+ if ( !p->inherits("QPopupMenu"))
p->setBackgroundPixmap(*pix);
-
+
QObjectList *ol = p-> queryList("QWidget");
for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
QWidget *wid = (QWidget *) it.current ( );
-
+
wid-> setBackgroundPixmap(*pix);
- wid-> setBackgroundOrigin(QWidget::ParentOrigin);
+ wid-> setBackgroundOrigin(QWidget::ParentOrigin);
}
delete ol;
}
}
else if(ev->type() == QEvent::Hide){
if(type == TransStippleBg || type == TransStippleBtn ||
type == Custom){
-// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl;
+// owarn << "Deleting menu pixmap, width " << pixDict.find(p->winId())->width() << "" << oendl;
pixDict.remove(p->winId());
- if ( !p->inherits("QPopupMenu"))
+ if ( !p->inherits("QPopupMenu"))
p->setBackgroundMode(QWidget::PaletteBackground);
QObjectList *ol = p-> queryList("QWidget");
for ( QObjectListIt it( *ol ); it. current ( ); ++it ) {
QWidget *wid = (QWidget *) it.current ( );
-
+
wid-> setBackgroundMode( QWidget::PaletteBackground );
}
delete ol;
}
}
return(false);
}
-
+
LiquidStyle::LiquidStyle()
:QWindowsStyle()
{
setName ( "LiquidStyle" );
flatTBButtons = false;
currentHeader = 0;
btnMaskBmp = QBitmap(37, 26, buttonmask_bits, true);
btnMaskBmp.setMask(btnMaskBmp);
htmlBtnMaskBmp = QBitmap(37, 26, htmlbuttonmask_bits, true);
htmlBtnMaskBmp.setMask(htmlBtnMaskBmp);
headerHoverID = -1;
highlightWidget = NULL;
setButtonDefaultIndicatorWidth(0);
btnDict.setAutoDelete(true);
bevelFillDict.setAutoDelete(true);
smallBevelFillDict.setAutoDelete(true);
rMatrix.rotate(270.0);
btnBorderPix = new QPixmap;
btnBorderPix->convertFromImage(qembed_findImage("buttonfill"));
btnBlendPix = new QPixmap;
btnBlendPix->convertFromImage(qembed_findImage("buttonborder"));
bevelFillPix = new QPixmap;
bevelFillPix->convertFromImage(qembed_findImage("clear_fill_large"));
smallBevelFillPix = new QPixmap;
smallBevelFillPix->convertFromImage(qembed_findImage("clear_fill_small"));
// new stuff
vsbSliderFillPix = menuPix = NULL;
menuHandler = new TransMenuHandler(this);
setScrollBarExtent(15, 15);
int i;
for(i=0; i < BITMAP_ITEMS; ++i){
pixmaps[i] = NULL;
}
oldSliderThickness = sliderThickness();
setSliderThickness(11);
}
LiquidStyle::~LiquidStyle()
{
if(btnBorderPix)
delete btnBorderPix;
if(btnBlendPix)
delete btnBlendPix;
if(bevelFillPix)
delete bevelFillPix;
if(smallBevelFillPix)
delete smallBevelFillPix;
if(vsbSliderFillPix)
delete vsbSliderFillPix;
if(menuPix)
delete menuPix;
setScrollBarExtent(16, 16);
setSliderThickness(oldSliderThickness);
int i;
for(i=0; i < BITMAP_ITEMS; ++i){
if(pixmaps[i])
delete pixmaps[i];
}
}
void LiquidStyle::drawClearBevel(QPainter *p, int x, int y, int w, int h,
const QColor &c, const QColor &bg)
{
QPen oldPen = p->pen(); // headers need this
int x2 = x+w-1;
int y2 = y+h-1;
// outer dark rect
p->setPen(c.dark(130));
p->drawLine(x, y+2, x, y2-2); // l
p->drawLine(x2, y+2, x2, y2-2); // r
p->drawLine(x+2, y, x2-2, y); // t
p->drawLine(x+2, y2, x2-2, y2); // b
p->drawPoint(x+1, y+1); // tl
p->drawPoint(x2-1, y+1); // tr
p->drawPoint(x+1, y2-1); // bl
p->drawPoint(x2-1, y2-1); // br
// inner top light lines
p->setPen(c.light(105));
p->drawLine(x+2, y+1, x2-2, y+1);
p->drawLine(x+1, y+2, x2-1, y+2);
p->drawLine(x+1, y+3, x+2, y+3);
p->drawLine(x2-2, y+3, x2-1, y+3);
p->drawPoint(x+1, y+4);
p->drawPoint(x2-1, y+4);
// inner bottom light lines
p->setPen(c.light(110));
p->drawLine(x+2, y2-1, x2-2, y2-1);
p->drawLine(x+1, y2-2, x2-1, y2-2);
p->drawLine(x+1, y2-3, x+2, y2-3);
p->drawLine(x2-2, y2-3, x2-1, y2-3);
p->drawPoint(x+1, y2-4);
p->drawPoint(x2-1, y2-4);
// inner left mid lines
//p->setPen(c.light(105));
p->setPen(c);
p->drawLine(x+1, y+5, x+1, y2-5);
p->drawLine(x+2, y+4, x+2, y2-4);
// inner right mid lines
p->drawLine(x2-1, y+5, x2-1, y2-5);
p->drawLine(x2-2, y+4, x2-2, y2-4);
// fill
QPixmap *pix;
if(h >= 32){
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);
}
}
else{
pix = smallBevelFillDict.find(c.rgb());
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*smallBevelFillPix);
adjustHSV(*pix, h, s, v);
smallBevelFillDict.insert(c.rgb(), pix);
}
}
p->drawTiledPixmap(x+3, y+3, w-6, h-6, *pix);
// blend
int red, green, blue;
QColor btnColor(c.dark(130));
red = (btnColor.red() >> 1) + (bg.red() >> 1);
green = (btnColor.green() >> 1) + (bg.green() >> 1);
blue = (btnColor.blue() >> 1) + (bg.blue() >> 1);
btnColor.setRgb(red, green, blue);
p->setPen(btnColor);
p->drawPoint(x+1, y);
p->drawPoint(x, y+1);
p->drawPoint(x+1, y2);
p->drawPoint(x, y2-1);
p->drawPoint(x2-1, y);
p->drawPoint(x2, y+1);
p->drawPoint(x2-1, y2);
p->drawPoint(x2, y2-1);
p->setPen(oldPen);
}
void LiquidStyle::drawRoundButton(QPainter *painter, const QColor &c,
const QColor &back, int x, int y, int w, int h,
bool supportPushDown, bool pushedDown,
bool autoDefault, bool isMasked)
{
if(w < 21 || h < 21){
drawClearBevel(painter, x, y, w, h, c, back);
return;
}
if(supportPushDown){
--w, --h;
}
/* We don't make the round buttons smaller, since they don't look as good
if(autoDefault){
w = w-buttonDefaultIndicatorWidth()*2;
h = h-buttonDefaultIndicatorWidth()*2;
}*/
QPixmap *pix = btnDict.find(c.rgb());
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*btnBorderPix);
adjustHSV(*pix, h, s, v);
btnDict.insert(c.rgb(), pix);
}
int x2 = x+w-1;
int y2 = y+h-1;
int bx2 = pix->width()-1;
int by2 = pix->height()-1;
QPixmap tmpPix(w, h);
QPixmap tilePix;
QPainter p;
p.begin(&tmpPix);
// do the fill
p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
// edges
tilePix.resize(pix->width()-20, 10);
// top
bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
// bottom
bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
// left
tilePix.resize(10, pix->height()-20);
bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
// right
bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
// middle
tilePix.resize(pix->width()-20, pix->height()-20);
bitBlt(&tilePix, 0, 0, pix, 10, 10, pix->width()-20, pix->height()-20);
p.drawTiledPixmap(10, 10, w-20, h-20, tilePix);
// do the blend
QBitmap blendMask;
if(!isMasked){
//QRgb bgRgb = back.rgb();
//QRgb fgRgb = c.rgb();
//int r, g, b;
//r = (int)(qRed(bgRgb)*0.75 + qRed(fgRgb)*0.25);
//g = (int)(qGreen(bgRgb)*0.75 + qGreen(fgRgb)*0.25);
//b = (int)(qBlue(bgRgb)*0.75 + qBlue(fgRgb)*0.25);
//QColor blendColor(r, g, b);
int hue, sat, v1, v2;
QColor blendColor(autoDefault ? c : back);
back.hsv(&hue, &sat, &v1);
blendColor.hsv(&hue, &sat, &v2);
if(v2 > v1)
blendColor.setHsv(hue, sat, (int)(v1*0.75 + v2*0.25));
pix = btnBorderDict.find(blendColor.rgb());
if(!pix){
int h, s, v;
blendColor.hsv(&h, &s, &v);
pix = new QPixmap(*btnBlendPix);
adjustHSV(*pix, h, s, v);
btnBorderDict.insert(blendColor.rgb(), pix);
}
}
else{
pix = pushedDown ? getPixmap(HTMLBtnBorderDown) :
getPixmap(HTMLBtnBorder);
}
p.drawPixmap(0, 0, *pix, 0, 0, 10, 10); // tl
p.drawPixmap(x2-9, 0, *pix, bx2-9, 0, 10, 10); // tr
p.drawPixmap(0, y2-9, *pix, 0, by2-9, 10, 10); // bl
p.drawPixmap(x2-9, y2-9, *pix, bx2-9, by2-9, 10, 10); // br
// edges
tilePix.resize(pix->width()-20, 10);
blendMask.resize(pix->width()-20, 10);
// top
bitBlt(&tilePix, 0, 0, pix, 10, 0, pix->width()-20, 10);
bitBlt(&blendMask, 0, 0, pix->mask(), 10, 0, pix->width()-20, 10);
tilePix.setMask(blendMask);
p.drawTiledPixmap(10, 0, w-20, 10, tilePix);
// bottom
bitBlt(&tilePix, 0, 0, pix, 10, by2-9, pix->width()-20, 20);
bitBlt(&blendMask, 0, 0, pix->mask(), 10, by2-9, pix->width()-20, 20);
tilePix.setMask(blendMask);
p.drawTiledPixmap(10, y2-9, w-20, 10, tilePix);
// left
tilePix.resize(10, pix->height()-20);
blendMask.resize(10, pix->height()-20);
bitBlt(&tilePix, 0, 0, pix, 0, 10, 10, pix->height()-20);
bitBlt(&blendMask, 0, 0, pix->mask(), 0, 10, 10, pix->height()-20);
tilePix.setMask(blendMask);
p.drawTiledPixmap(0, 10, 10, h-20, tilePix);
// right
bitBlt(&tilePix, 0, 0, pix, bx2-9, 10, 10, pix->height()-20);
bitBlt(&blendMask, 0, 0, pix->mask(), bx2-9, 10, 10, pix->height()-20);
tilePix.setMask(blendMask);
p.drawTiledPixmap(x2-9, 10, 10, h-20, tilePix);
p.end();
// do the button mask - we don't automask buttons
QBitmap btnMask(w, h);
QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
p.begin(&btnMask);
p.fillRect(0, 0, w, h, Qt::color0);
p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
// fills
p.fillRect(10, 0, w-20, 10, Qt::color1); // top
p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
p.fillRect(0, 10, w, h-20, Qt::color1); // middle
p.end();
tmpPix.setMask(btnMask);
/*if(autoDefault){
if(supportPushDown && pushedDown){
painter->drawPixmap(x+3, y+3, tmpPix);
}
else{
painter->drawPixmap(x+2, y+2, tmpPix);
}
}
else */if(supportPushDown && pushedDown)
painter->drawPixmap(x+1, y+1, tmpPix);
else
painter->drawPixmap(x, y, tmpPix);
}
QPixmap* LiquidStyle::processEmbedded(const char *label, int h, int s, int v,
bool blend)
{
QImage img(qembed_findImage(label));
img.detach();
if(img.isNull()){ // shouldn't happen, been tested
- owarn << "Invalid embedded label " << label << "" << oendl;
+ owarn << "Invalid embedded label " << label << "" << oendl;
return(NULL);
}
if(img.depth() != 32)
img = img.convertDepth(32);
unsigned int *data = (unsigned int *)img.bits();
int total = img.width()*img.height();
int current;
QColor c;
int oldH, oldS, oldV;
int alpha;
if(v < 235)
v += 20;
else
v = 255;
float intensity = v/255.0;
for(current=0; current<total; ++current){
alpha = qAlpha(data[current]);
c.setRgb(data[current]);
c.hsv(&oldH, &oldS, &oldV);
oldV = (int)(oldV*intensity);
c.setHsv(h, s, oldV);
if(blend && alpha != 255 && alpha != 0){
float srcPercent = ((float)alpha)/255.0;
float destPercent = 1.0-srcPercent;
oldH = (int)((srcPercent*h) + (destPercent*bH));
oldS = (int)((srcPercent*s) + (destPercent*bS));
oldV = (int)((srcPercent*oldV) + (destPercent*bV));
c.setHsv(oldH, oldS, oldV);
alpha = 255;
}
data[current] = qRgba(c.red(), c.green(), c.blue(), alpha);
}
QPixmap *pix = new QPixmap;
pix->convertFromImage(img);
return(pix);
}
QPixmap* LiquidStyle::getPixmap(BitmapData item)
{
if(pixmaps[item])
return(pixmaps[item]);
switch(item){
case HTMLBtnBorder:
pixmaps[HTMLBtnBorder] = processEmbedded("htmlbtnborder", btnH, btnS, btnV);
break;
case HTMLBtnBorderDown:
pixmaps[HTMLBtnBorderDown] = processEmbedded("htmlbtnborder", btnHoverH, btnHoverS, btnHoverV);
break;
case HTMLCB:
pixmaps[HTMLCB] = processEmbedded("htmlcheckbox", bH, bS, bV);
break;
case HTMLCBHover:
pixmaps[HTMLCBHover] = processEmbedded("htmlcheckbox", btnHoverH, btnHoverS, btnHoverV);
break;
case HTMLCBDown:
pixmaps[HTMLCBDown] = processEmbedded("htmlcheckboxdown", btnH, btnS, btnV);
break;
case HTMLCBDownHover:
pixmaps[HTMLCBDownHover] = processEmbedded("htmlcheckboxdown", btnHoverH, btnHoverS, btnHoverV);
break;
case HTMLRadio:
pixmaps[HTMLRadio] = processEmbedded("htmlradio", bH, bS, bV);
break;
case HTMLRadioHover:
pixmaps[HTMLRadioHover] = processEmbedded("htmlradio", btnHoverH, btnHoverS, btnHoverV);
break;
case HTMLRadioDown:
pixmaps[HTMLRadioDown] = processEmbedded("htmlradiodown", btnH, btnS, btnV);
break;
case HTMLRadioDownHover:
pixmaps[HTMLRadioDownHover] = processEmbedded("htmlradiodown", btnHoverH, btnHoverS, btnHoverV);
break;
case RadioOff:
pixmaps[RadioOff] = processEmbedded("radio", bH, bS, bV /*, true*/);
break;
case RadioOffHover:
pixmaps[RadioOffHover] = processEmbedded("radio", btnHoverH, btnHoverS, btnHoverV /*, true*/);
break;
case RadioOn:
pixmaps[RadioOn] = processEmbedded("radio_down", btnH, btnS, btnV /*, true*/);
break;
case RadioOnHover:
pixmaps[RadioOnHover] = processEmbedded("radio_down", btnHoverH, btnHoverS, btnHoverV /*, true*/);
break;
case Tab:
pixmaps[Tab] = processEmbedded("tab", bH, bS, bV /*, true*/);
break;
case TabDown:
pixmaps[TabDown] = processEmbedded("tab", btnH, btnS, btnV /*, true*/);
- break;
+ break;
case TabFocus:
pixmaps[TabFocus] = processEmbedded("tab", btnHoverH, btnHoverS, btnHoverV /*, true*/);
- break;
+ break;
case CB:
pixmaps[CB] = processEmbedded("checkbox", bH, bS, bV /*, true*/);
break;
case CBHover:
pixmaps[CBHover] = processEmbedded("checkbox", btnHoverH, btnHoverS, btnHoverV /*, true*/);
break;
case CBDown:
pixmaps[CBDown] = processEmbedded("checkboxdown", btnH, btnS, btnV /*, true*/);
break;
case CBDownHover:
pixmaps[CBDownHover] = processEmbedded("checkboxdown", btnHoverH, btnHoverS, btnHoverV /*, true*/);
break;
case VSlider:
pixmaps[VSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV, true );
*pixmaps[VSlider] = pixmaps[VSlider]->xForm(rMatrix);
break;
case VSBSliderTop:
case VSBSliderTopHover:
pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV /*, true*/);
break;
case VSBSliderBtm:
case VSBSliderBtmHover:
pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV /*, true*/);
break;
case VSBSliderMid:
case VSBSliderMidHover:
pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
break;
case VSBSliderTopBg:
pixmaps[VSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV /*, true*/);
break;
case VSBSliderBtmBg:
pixmaps[VSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV /*, true*/);
break;
case VSBSliderMidBg:
pixmaps[VSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
break;
case HSlider:
pixmaps[HSlider] = processEmbedded("sliderarrow", btnH, btnS, btnV /*, true*/);
break;
case HSBSliderTop:
case HSBSliderTopHover:
pixmaps[item] = processEmbedded("sbslider_top", btnH, btnS, btnV, true );
*pixmaps[item] = pixmaps[item]->xForm(rMatrix);
break;
case HSBSliderBtm:
case HSBSliderBtmHover:
pixmaps[item] = processEmbedded("sbslider_btm", btnH, btnS, btnV, true );
*pixmaps[item] = pixmaps[item]->xForm(rMatrix);
break;
case HSBSliderMid:
case HSBSliderMidHover:
pixmaps[item] = processEmbedded("sbslider_mid", btnH, btnS, btnV);
*pixmaps[item] = pixmaps[item]->xForm(rMatrix);
break;
case HSBSliderTopBg:
pixmaps[HSBSliderTopBg] = processEmbedded("sbslider_top", bH, bS, bV, true );
*pixmaps[HSBSliderTopBg] = pixmaps[HSBSliderTopBg]->xForm(rMatrix);
break;
case HSBSliderBtmBg:
pixmaps[HSBSliderBtmBg] = processEmbedded("sbslider_btm", bH, bS, bV, true );
*pixmaps[HSBSliderBtmBg] = pixmaps[HSBSliderBtmBg]->xForm(rMatrix);
break;
case HSBSliderMidBg:
pixmaps[HSBSliderMidBg] = processEmbedded("sbslider_mid", bH, bS, bV);
*pixmaps[HSBSliderMidBg] = pixmaps[HSBSliderMidBg]->xForm(rMatrix);
break;
default:
break;
}
return(pixmaps[item]);
}
void LiquidStyle::polish(QPalette &appPal)
{
int i;
for(i=0; i < BITMAP_ITEMS; ++i){
if(pixmaps[i]){
delete pixmaps[i];
pixmaps[i] = NULL;
}
}
lowLightVal = 100 + (2* /*KGlobalSettings::contrast()*/ 3 +4)*10;
btnDict.clear();
btnBorderDict.clear();
bevelFillDict.clear();
smallBevelFillDict.clear();
Config config ( "qpe" );
config. setGroup ( "Liquid-Style" );
int contrast = config. readNumEntry ( "StippleContrast", 5 );
if ( contrast < 0 )
contrast = 0;
else if ( contrast > 10 )
contrast = 10;
// QPalette pal = QApplication::palette();
// button color stuff
config. setGroup ( "Appearance" );
QColor c = appPal. color ( QPalette::Active, QColorGroup::Button );
if ( c == appPal. color ( QPalette::Active, QColorGroup::Background )) {
// force button color to be different from background
QBrush btnBrush(QColor(200, 202, 228));
appPal.setBrush(QColorGroup::Button, btnBrush);
}
c.hsv(&btnH, &btnS, &btnV);
c.light(120).hsv(&btnHoverH, &btnHoverS, &btnHoverV);
// menu pixmap
if(!menuPix){
menuPix = new QPixmap;
menuPix->resize(64, 64);
}
QPainter painter;
menuPix->fill(c.rgb());
painter.begin(menuPix);
painter.setPen(c.dark(105));
for(i=0; i < 63; i+=4){
painter.drawLine(0, i, 63, i);
painter.drawLine(0, i+1, 63, i+1);
};
painter.end();
menuBrush.setColor(c);
menuBrush.setPixmap(*menuPix);
// pager brush
c = c.dark(120);
QPixmap *pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*smallBevelFillPix);
adjustHSV(*pix, h, s, v);
smallBevelFillDict.insert(c.rgb(), pix);
}
// pagerHoverBrush.setColor(c);
// pagerHoverBrush.setPixmap(*pix);
c = c.dark(120);
pix = smallBevelFillDict.find(c.rgb()); // better be NULL ;-)
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*smallBevelFillPix);
adjustHSV(*pix, h, s, v);
smallBevelFillDict.insert(c.rgb(), pix);
}
// pagerBrush.setColor(c);
// pagerBrush.setPixmap(*pix);
// background color stuff
c = appPal. color ( QPalette::Active, QColorGroup::Background );
c.hsv(&bH, &bS, &bV);
c.light(120).hsv(&bHoverH, &bHoverS, &bHoverV);
// FIXME?
if(vsbSliderFillPix)
delete vsbSliderFillPix;
vsbSliderFillPix = new QPixmap(bevelFillPix->xForm(rMatrix));
adjustHSV(*vsbSliderFillPix, bH, bS, bV);
// background brush
QPixmap wallPaper(32, 32);
wallPaper.fill(c.rgb());
painter.begin(&wallPaper);
for(i=0; i < 32; i+=4){
painter.setPen(c.dark(100 + contrast));
painter.drawLine(0, i, 32, i);
painter.setPen(c.dark(100 + 3 * contrast / 5 ) );
painter.drawLine(0, i+1, 32, i+1);
};
painter.end();
bgBrush.setColor(c);
bgBrush.setPixmap(wallPaper);
appPal.setBrush(QColorGroup::Background, bgBrush);
}
void LiquidStyle::polish(QWidget *w)
{
if(w->inherits("QMenuBar")){
//((QFrame*)w)->setLineWidth(0);
w->setBackgroundMode(QWidget::PaletteBackground);
w->setBackgroundOrigin(QWidget::ParentOrigin);
return;
}
if(w->inherits("QToolBar")){
w->installEventFilter(this);
w->setBackgroundMode(QWidget::PaletteBackground);
w->setBackgroundOrigin(QWidget::WidgetOrigin);
return;
}
if(w->inherits("QPopupMenu"))
w->setBackgroundMode(QWidget::NoBackground);
- else if(w-> testWFlags(Qt::WType_Popup) &&
- !w->inherits("QListBox") &&
+ else if(w-> testWFlags(Qt::WType_Popup) &&
+ !w->inherits("QListBox") &&
( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
w->installEventFilter(menuHandler);
}
-
+
if(w->isTopLevel()){
return;
}
-
+
if(w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
w->installEventFilter(this);
}
if(w->inherits("QButton") || w-> inherits("QComboBox")){
w-> setBackgroundMode ( QWidget::PaletteBackground );
w->setBackgroundOrigin ( QWidget::ParentOrigin);
}
bool isViewport = qstrcmp(w->name(), "qt_viewport") == 0 ||
qstrcmp(w->name(), "qt_clipped_viewport") == 0;
bool isViewportChild = w->parent() &&
((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
(qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
if(isViewport && w->parent() && qstrcmp(w->parent()->name(), "proxyview") == 0){
w->setBackgroundMode(QWidget::X11ParentRelative);
return;
}
if(isViewportChild){
if(w->inherits("QButton") || w->inherits("QComboBox")){
if(w->parent()){ // heh, only way to test for KHTML children ;-)
if(w->parent()->parent()){
if(w->parent()->parent()->parent() &&
w->parent()->parent()->parent()->inherits("KHTMLView")){
w->setAutoMask(true);
w->setBackgroundMode(QWidget::NoBackground);
}
}
}
return;
}
}
if(w->inherits("QHeader")){
w->setMouseTracking(true);
w->installEventFilter(this);
}
if(w-> inherits("QToolButton")) {
if (w->parent()->inherits("QToolBar")) {
((QToolButton*)w)->setAutoRaise (flatTBButtons);
if ( flatTBButtons )
w->setBackgroundOrigin(QWidget::ParentOrigin);
}
w-> installEventFilter ( this );
}
if(w-> inherits("QToolBarSeparator")&&w->parent()->inherits("QToolBar")) {
((QFrame *) w)-> setFrameShape ( QFrame::NoFrame );
}
if(w->ownPalette() && !w->inherits("QButton") && !w->inherits("QComboBox")){
return;
}
if(w->parent() && w->parent()->isWidgetType() && !((QWidget*)w->parent())->
palette().active().brush(QColorGroup::Background).pixmap()){
- owarn << "No parent pixmap for child widget " << w->className() << "" << oendl;
+ owarn << "No parent pixmap for child widget " << w->className() << "" << oendl;
return;
}
if(!isViewport && !isViewportChild && !w->testWFlags(WType_Popup) &&
!( !w-> inherits("QLineEdit") && w-> parent() && w-> parent()-> isWidgetType ( ) && w-> parent()-> inherits ( "QMultiLineEdit" ))) {
if(w->backgroundMode() == QWidget::PaletteBackground ||
w->backgroundMode() == QWidget::PaletteButton){
w->setBackgroundMode(w->parentWidget()->backgroundMode( )/*QWidget::X11ParentRelative*/);
w->setBackgroundOrigin(QWidget::ParentOrigin);
// w->setBackgroundMode(QWidget::NoBackground);
}
}
if ( !w-> inherits("QFrame") || (((QFrame*) w)-> frameShape () == QFrame::NoFrame ))
- w-> setBackgroundOrigin ( QWidget::ParentOrigin );
+ w-> setBackgroundOrigin ( QWidget::ParentOrigin );
else if ( w-> inherits("QFrame") )
w->setBackgroundOrigin ( QWidget::WidgetOrigin );
if ( w->parentWidget()->inherits ( "QWidgetStack" )) {
w->setBackgroundOrigin ( QWidget::WidgetOrigin );
}
}
void LiquidStyle::unPolish(QWidget *w)
{
if(w->inherits("QMenuBar")){
((QFrame *)w)->setLineWidth(1);
w->setBackgroundMode(QWidget::PaletteBackground);
return;
}
if(w->inherits("QPopupMenu"))
w->setBackgroundMode(QWidget::PaletteButton);
- else if(w-> testWFlags(Qt::WType_Popup) &&
+ else if(w-> testWFlags(Qt::WType_Popup) &&
!w->inherits("QListBox") &&
( qstrcmp ( w-> name(), "automatic what's this? widget" ) != 0 )) {
w->removeEventFilter(menuHandler);
}
if(w->isTopLevel())
return;
// for viewport children, don't just check for NoBackground....
bool isViewportChild = w->parent() &&
((qstrcmp(w->parent()->name(), "qt_viewport") == 0) ||
(qstrcmp(w->parent()->name(), "qt_clipped_viewport") == 0));
w->unsetPalette();
if(w->backgroundMode() == QWidget::X11ParentRelative || isViewportChild){
if(w->inherits("QPushButton"))
w->setBackgroundMode(QWidget::PaletteButton);
else
w->setBackgroundMode(QWidget::PaletteBackground);
}
if(isViewportChild)
w->setAutoMask(false);
/*
if(w->inherits("QPushButton") || w-> inherits("QComboBox")){
w-> setBackgroundMode ( PaletteBackground );
}
*/
if( w->inherits("QRadioButton") || w->inherits("QCheckBox") || w->inherits("QProgressBar")) {
w->removeEventFilter(this);
}
if(w->inherits("QButton") || w->inherits("QComboBox")){
if(w->parent() && w->parent()->inherits("KHTMLPart")){
w->setAutoMask(false);
}
}
if(w-> inherits("QToolButton")) {
w-> removeEventFilter ( this );
}
if(w->inherits("QToolBar")){
w->removeEventFilter(this);
w->setBackgroundMode(QWidget::PaletteBackground);
return;
}
if(w->inherits("QHeader")){
w->setMouseTracking(false);
w->removeEventFilter(this);
}
}
void LiquidStyle::polish(QApplication *app)
{
QWindowsStyle::polish(app);
menuAni = app->isEffectEnabled(UI_AnimateMenu);
menuFade = app->isEffectEnabled(UI_FadeMenu);
if(menuAni)
app->setEffectEnabled(UI_AnimateMenu, false);
if(menuFade)
app->setEffectEnabled(UI_FadeMenu, false);
-
+
qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl) &LiquidStyle::drawMenuBarItem);
-
+
Config config ( "qpe" );
config. setGroup ( "Liquid-Style" );
-
-// if ( config. readBoolEntry ( "WinDecoration", true ))
+
+// if ( config. readBoolEntry ( "WinDecoration", true ))
// QApplication::qwsSetDecoration ( new LiquidDecoration ( ));
-
+
flatTBButtons = config. readBoolEntry ( "FlatToolButtons", false );
}
void LiquidStyle::unPolish(QApplication *app)
{
QWindowsStyle::unPolish(app);
app->setEffectEnabled(UI_AnimateMenu, menuAni);
app->setEffectEnabled(UI_FadeMenu, menuFade);
qt_set_draw_menu_bar_impl ( 0 );
-
+
// QApplication::qwsSetDecoration ( new QPEDecoration ( ));
}
/* !! HACK !! Beware
- *
+ *
* TT forgot to make the QProgressBar widget styleable in Qt 2.x
- * So the only way to customize the drawing, is to intercept the
+ * So the only way to customize the drawing, is to intercept the
* paint event - since we have to use protected functions, we need
* to derive a "hack" class from QProgressBar and do the painting
* in there.
- *
+ *
* - sandman
*/
class HackProgressBar : public QProgressBar {
public:
HackProgressBar ( );
-
+
void paint ( QPaintEvent *event, const QColorGroup &g, QPixmap *pix )
{
QPainter p( this );
if ( !contentsRect().contains( event->rect() ) ) {
p.save();
p.setClipRegion( event->region().intersect(frameRect()) );
drawFrame( &p);
p.restore();
}
if ( event->rect().intersects( contentsRect() )) {
p.setClipRegion( event->region().intersect( contentsRect() ) );
int x, y, w, h;
contentsRect ( ). rect ( &x, &y, &w, &h );
int prog = progress ( );
int total = totalSteps ( );
if ( prog < 0 )
prog = 0;
if ( total <= 0 )
total = 1;
int bw = w * prog / total;
if ( bw > w )
bw = w;
p.setPen(g.button().dark(130));
p.drawRect(x, y, bw, h);
p.setPen(g.button().light(120));
p.drawRect(x+1, y+1, bw-2, h-2);
if(bw >= 4 && h >= 4 && pix)
p.drawTiledPixmap(x+2, y+2, bw-4, h-4, *pix);
-
- if ( progress ( )>= 0 && totalSteps ( ) > 0 ) {
+
+ if ( progress ( )>= 0 && totalSteps ( ) > 0 ) {
QString pstr;
pstr. sprintf ( "%d%%", 100 * progress()/totalSteps ());
p. setPen ( g.text());//g.highlightedText ( ));
p. drawText (x,y,w-1,h-1,AlignCenter,pstr);
}
}
}
};
/*
* The same for QToolButton:
* TT hardcoded the drawing of the focus rect ...
*
* - sandman
*/
class HackToolButton : public QToolButton {
public:
HackToolButton ( );
-
+
void paint ( QPaintEvent *ev )
{
erase ( ev-> region ( ));
QPainter p ( this );
style ( ). drawToolButton ( this, &p );
drawButtonLabel ( &p );
}
};
/*
* This is a fun method ;-) Here's an overview. KToolBar grabs resize to
* force everything to erase and repaint on resize. This is going away, I'm
* trying to get shaped widgets to work right without masking. QPushButton,
* QComboBox, and Panel applet handles capture mouse enter and leaves in order
* to set the highlightwidget and repaint for mouse hovers. CheckBoxes and
* RadioButtons need to do this differently. Qt buffers these in pixmaps and
* caches them in QPixmapCache, which is bad for doing things like hover
* because the style methods aren't called in paintEvents if everything
* is cached. We use our own Paint event handler instead. Taskbuttons and
* pager buttons draw into a pixmap buffer, so we handle those with palette
* modifications. For QHeader, different header items are actually one widget
* that draws multiple items, so we need to check which ID is hightlighted
* and draw it. Finally, we also check enter and leave events for QLineEdit,
* since if it's inside a combobox we want to highlight the combobox during
* hovering in the edit.
*/
bool LiquidStyle::eventFilter(QObject *obj, QEvent *ev)
{
if(obj->inherits("QToolBar")){
if(ev->type() == QEvent::Resize){
const QObjectList *tbChildList = obj->children();
QObjectListIt it(*tbChildList);
QObject *child;
while((child = it.current()) != NULL){
++it;
if(child->isWidgetType())
((QWidget *)child)->repaint(true);
}
}
}
else if(obj->inherits("QToolButton")){
QToolButton *btn = (QToolButton *)obj;
- if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
+ if(ev->type() == QEvent::FocusIn ){ // && !btn-> autoRaise ()
if(btn->isEnabled()){
highlightWidget = btn;
btn->repaint(false);
}
}
else if(ev->type() == QEvent::FocusOut ){
if(btn == highlightWidget){
highlightWidget = NULL;
btn->repaint(false);
}
}
else if(ev->type() == QEvent::Paint) {
(( HackToolButton *) btn )-> paint ((QPaintEvent *) ev );
return true;
}
}
else if(obj->inherits("QRadioButton") || obj->inherits("QCheckBox")){
QButton *btn = (QButton *)obj;
bool isRadio = obj->inherits("QRadioButton");
if(ev->type() == QEvent::Paint){
//if(btn->autoMask())
btn->erase();
QPainter p;
p.begin(btn);
QFontMetrics fm = btn->fontMetrics();
QSize lsz = fm.size(ShowPrefix, btn->text());
QSize sz = isRadio ? exclusiveIndicatorSize()
: indicatorSize();
/*
if(btn->hasFocus()){
QRect r = QRect(0, 0, btn->width(), btn->height());
p.setPen(btn->colorGroup().button().dark(140));
p.drawLine(r.x()+1, r.y(), r.right()-1, r.y());
p.drawLine(r.x(), r.y()+1, r.x(), r.bottom()-1);
p.drawLine(r.right(), r.y()+1, r.right(), r.bottom()-1);
p.drawLine(r.x()+1, r.bottom(), r.right()-1, r.bottom());
}
*/
- int x = 0;
+ int x = 0;
int y = (btn->height()-lsz.height()+fm.height()-sz.height())/2;
if(isRadio)
drawExclusiveIndicator(&p, x, y, sz.width(), sz.height(),
btn->colorGroup(), btn->isOn(),
btn->isDown(), btn->isEnabled());
else
drawIndicator(&p, x, y, sz.width(), sz.height(),
btn->colorGroup(), btn->state(), btn->isDown(),
btn->isEnabled());
x = sz.width() + 6;
y = 0;
drawItem(&p, sz.width()+6+1, 0, btn->width()-(sz.width()+6+1),
btn->height(), AlignLeft|AlignVCenter|ShowPrefix,
btn->colorGroup(), btn->isEnabled(),
btn->pixmap(), btn->text());
p.end();
return(true);
}
}
else if(obj->inherits("QHeader")){
QHeader *hw = (QHeader *)obj;
if(ev->type() == QEvent::Enter){
currentHeader = hw;
headerHoverID = -1;
}
else if(ev->type() == QEvent::Leave){
currentHeader = NULL;
if(headerHoverID != -1){
hw->repaint(hw->sectionPos(headerHoverID), 0,
hw->sectionSize(headerHoverID), hw->height());
}
headerHoverID = -1;
}
else if(ev->type() == QEvent::MouseMove){
QMouseEvent *me = (QMouseEvent *)ev;
int oldHeader = headerHoverID;
headerHoverID = hw->sectionAt(me->x());
if(oldHeader != headerHoverID){
// reset old header
if(oldHeader != -1){
hw->repaint(hw->sectionPos(oldHeader), 0,
hw->sectionSize(oldHeader), hw->height());
}
if(headerHoverID != -1){
hw->repaint(hw->sectionPos(headerHoverID), 0,
hw->sectionSize(headerHoverID), hw->height());
}
}
}
}
else if (obj-> inherits( "QProgressBar" )) {
if ( ev->type() == QEvent::Paint ) {
HackProgressBar *p = (HackProgressBar *) obj;
const QColorGroup &g = p-> colorGroup ( );
-
+
QPixmap *pix = bevelFillDict.find(g.button().dark(120).rgb());
if(!pix){
int h, s, v;
g.button().dark(120).hsv(&h, &s, &v);
pix = new QPixmap(*bevelFillPix);
adjustHSV(*pix, h, s, v);
bevelFillDict.insert(g.button().dark(120).rgb(), pix);
}
p-> paint ((QPaintEvent *) ev, g, pix );
- return true;
+ return true;
}
- }
+ }
return false ;
}
void LiquidStyle::drawButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush *)
{
drawRoundButton(p, sunken ? g.background() : g.button(), g.background(),
x, y, w, h);
}
void LiquidStyle::drawToolButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush *)
{
if(p->device()->devType() != QInternal::Widget){
// drawing into a temp pixmap, don't use mask
QColor c = sunken ? g.button() : g.background();
p->setPen(c.dark(130));
p->drawRect(x, y, w, h);
p->setPen(c.light(105));
p->drawRect(x+1, y+1, w-2, h-2);
// fill
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->drawTiledPixmap(x+2, y+2, w-4, h-4, *pix);
}
else{
drawClearBevel(p, x, y, w, h, sunken ? g.button() :
highlightWidget == p->device() ? g.button().light(110) :
g.background(), g.background());
}
}
void LiquidStyle::drawPushButton(QPushButton *btn, QPainter *p)
{
QRect r = btn->rect();
bool sunken = btn->isOn() || btn->isDown();
QColorGroup g = btn->colorGroup();
//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
p->drawLine(x+2, y, x2-2, y); // t
p->drawLine(x+2, y2, x2-2, y2); // b
p->drawLine(x+1, y+1, x2-1, y+1); // top second line
p->drawLine(x+1, y2-1, x2-1, y2-1); // bottom second line
p->fillRect(x+1, y+2, w-2, h-4, Qt::color1);
}
else{
int x2 = x+w-1;
int y2 = y+h-1;
int bx2 = htmlBtnMaskBmp.width()-1;
int by2 = htmlBtnMaskBmp.height()-1;
p->drawPixmap(0, 0, htmlBtnMaskBmp, 0, 0, 10, 10); // tl
p->drawPixmap(x2-9, 0, htmlBtnMaskBmp, bx2-9, 0, 10, 10); // tr
p->drawPixmap(0, y2-9, htmlBtnMaskBmp, 0, by2-9, 10, 10); // bl
p->drawPixmap(x2-9, y2-9, htmlBtnMaskBmp, bx2-9, by2-9, 10, 10); // br
// fills
p->fillRect(10, 0, w-20, 10, Qt::color1); // top
p->fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
p->fillRect(0, 10, w, h-20, Qt::color1); // middle
}
}
void LiquidStyle::drawBevelButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush */*fill*/)
{
if(currentHeader && p->device() == currentHeader){
int id = currentHeader->sectionAt(x);
bool isHeaderHover = id != -1 && id == headerHoverID;
drawClearBevel(p, x, y, w, h, sunken ?
g.button() : isHeaderHover ? g.button().light(110) :
g.background(), g.background());
}
else
drawClearBevel(p, x, y, w, h, sunken ? g.button() : g.background(),
g.background());
}
QRect LiquidStyle::buttonRect(int x, int y, int w, int h)
{
return(QRect(x+5, y+5, w-10, h-10));
}
void LiquidStyle::drawComboButton(QPainter *painter, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
bool edit, bool, const QBrush *)
{
bool isActive = false;
if (( painter->device()->devType() == QInternal::Widget ) &&
(
( qApp-> focusWidget ( ) == painter-> device ( )) ||
(
edit &&
- ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
+ ((QWidget *) painter-> device ( ))-> inherits ( "QComboBox" ) &&
( qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->lineEdit ( ) ||
qApp-> focusWidget ( ) == ((QComboBox *) painter->device())->listBox ( ))
)
)
) {
isActive = true;
}
-
+
bool isMasked = false;
if(painter->device()->devType() == QInternal::Widget)
isMasked = ((QWidget*)painter->device())->autoMask();
- // TODO: Do custom code, don't just call drawRoundButton into a pixmap
+ // TODO: Do custom code, don't just call drawRoundButton into a pixmap
QPixmap tmpPix(w, h);
QPainter p(&tmpPix);
drawRoundButton(&p, g.button(), g.background(), 0, 0, w, h, false,
sunken, false, isMasked);
if(!isActive){
p.setClipRect(0, 0, w-17, h);
drawRoundButton(&p, g.background(), g.background(), 0, 0, w, h, false,
sunken, false, isMasked);
}
p.end();
int x2 = x+w-1;
int y2 = y+h-1;
int bx2 = btnMaskBmp.width()-1;
int by2 = btnMaskBmp.height()-1;
QBitmap btnMask(w, h);
QBitmap *mask = isMasked ? &htmlBtnMaskBmp : &btnMaskBmp;
p.begin(&btnMask);
p.fillRect(0, 0, w, h, Qt::color0);
p.drawPixmap(0, 0, *mask, 0, 0, 10, 10); // tl
p.drawPixmap(x2-9, 0, *mask, bx2-9, 0, 10, 10); // tr
p.drawPixmap(0, y2-9, *mask, 0, by2-9, 10, 10); // bl
p.drawPixmap(x2-9, y2-9, *mask, bx2-9, by2-9, 10, 10); // br
// fills
p.fillRect(10, 0, w-20, 10, Qt::color1); // top
p.fillRect(10, y2-9, w-20, 10, Qt::color1); // bottom
p.fillRect(0, 10, w, h-20, Qt::color1); // middle
p.end();
tmpPix.setMask(btnMask);
painter->drawPixmap(x, y, tmpPix);
painter->setPen(g.button().dark(120));
painter->drawLine(x2-16, y+1, x2-16, y2-1);
if(edit){
painter->setPen(g.mid());
painter->drawRect(x+8, y+2, w-25, h-4);
}
int arrow_h = h / 3;
int arrow_w = arrow_h;
int arrow_x = w - arrow_w - 6;
int arrow_y = (h - arrow_h) / 2;
drawArrow(painter, DownArrow, false, arrow_x, arrow_y, arrow_w, arrow_h, g, true);
}
void LiquidStyle::drawComboButtonMask(QPainter *p, int x, int y, int w, int h)
{
drawButtonMask(p, x, y, w, h);
}
QRect LiquidStyle::comboButtonRect(int x, int y, int w, int h)
{
//return(QRect(x+3, y+3, w - (h / 3) - 13, h-6));
return(QRect(x+9, y+3, w - (h / 3) - 20, h-6));
}
QRect LiquidStyle::comboButtonFocusRect(int /*x*/, int /*y*/, int /*w*/, int /*h*/)
{
return QRect ( );
-
+
// return(QRect(x+5, y+3, w-(h/3)-13, h-5));
}
void LiquidStyle::drawScrollBarControls(QPainter *p, const QScrollBar *sb,
int sliderStart, uint controls,
uint activeControl)
{
int sliderMin, sliderMax, sliderLength, buttonDim;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
if (sliderStart > sliderMax)
sliderStart = sliderMax;
bool horiz = sb->orientation() == QScrollBar::Horizontal;
QColorGroup g = sb->colorGroup();
QRect addB, subHC, subB;
QRect addPageR, subPageR, sliderR;
int addX, addY, subX, subY;
int len = horiz ? sb->width() : sb->height();
int extent = horiz ? sb->height() : sb->width();
// a few apps (ie: KSpread), are broken and use a hardcoded scrollbar
// extent of 16. Luckily, most apps (ie: Kate), seem fixed by now.
bool brokenApp;
if(extent == 16)
brokenApp = true;
else
brokenApp = false;
if (horiz) {
subY = addY = ( extent - buttonDim ) / 2;
subX = 0;
addX = len - buttonDim;
if(sbBuffer.size() != sb->size())
sbBuffer.resize(sb->size());
}
else {
subX = addX = ( extent - buttonDim ) / 2;
subY = 0;
addY = len - buttonDim;
if(sbBuffer.size() != sb->size())
sbBuffer.resize(sb->size());
}
subB.setRect( subX,subY,0,0); // buttonDim,buttonDim );
addB.setRect( addX,addY,buttonDim,buttonDim );
if(horiz)
subHC.setRect(addX-buttonDim,addY,buttonDim,buttonDim );
else
subHC.setRect(addX,addY-buttonDim,buttonDim,buttonDim );
int sliderEnd = sliderStart + sliderLength;
int sliderW = extent;
if (horiz) {
subPageR.setRect( subB.right() + 1, 0,
sliderStart - subB.right() - 1 , sliderW );
addPageR.setRect( sliderEnd, 0, addX - sliderEnd - buttonDim, sliderW );
sliderR .setRect( sliderStart, 0, sliderLength, sliderW );
}
else {
subPageR.setRect( 0, subB.bottom() + 1, sliderW,
sliderStart - subB.bottom() - 1 );
addPageR.setRect( 0, sliderEnd, sliderW, addY - buttonDim - sliderEnd);
sliderR .setRect( 0, sliderStart, sliderW, sliderLength );
}
bool maxed = sb->maxValue() == sb->minValue();
QPainter painter;
if(!horiz){
painter.begin(&sbBuffer);
QRect bgR(0, subB.bottom()+1, sb->width(), (len-(buttonDim*2))+1);
if(sliderR.height() >= 8){
painter.drawPixmap(bgR.x()+1, bgR.y(), *vsbSliderFillPix, 0, 0,
13, 8);
painter.drawPixmap(bgR.x()+1, bgR.y(), *getPixmap(VSBSliderTopBg));
painter.drawTiledPixmap(bgR.x()+1, bgR.y()+8, 13,
bgR.height()-16, *getPixmap(VSBSliderMidBg));
painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *vsbSliderFillPix,
0, 0, 13, 8);
painter.drawPixmap(bgR.x()+1, bgR.bottom()-8, *getPixmap(VSBSliderBtmBg));
}
else{
painter.drawTiledPixmap(bgR.x()+1, bgR.y(), 13, bgR.height(),
*getPixmap(VSBSliderMidBg));
painter.setPen(g.background().dark(210));
painter.drawRect(bgR.x()+1, bgR.y(), 13, bgR.height()-1);
painter.setPen(g.mid());
painter.drawPoint(bgR.x()+1, bgR.y());
painter.drawPoint(bgR.x()+13, bgR.y());
painter.drawPoint(bgR.x()+1, bgR.bottom()-1);
painter.drawPoint(bgR.x()+13, bgR.bottom()-1);
}
if(controls & Slider){
if(sliderR.height() >= 16){
painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop));
painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+8, 13,
sliderR.height()-16, *getPixmap(VSBSliderMid));
painter.drawPixmap(sliderR.x()+1, sliderR.bottom()-8, *getPixmap(VSBSliderBtm));
}
else if(sliderR.height() >= 8){
int m = sliderR.height()/2;
painter.drawPixmap(sliderR.x()+1, sliderR.y(), *getPixmap(VSBSliderTop), 0, 0, 13, m);
painter.drawPixmap(sliderR.x()+1, sliderR.y()+m, *getPixmap(VSBSliderBtm), 0, 8-m, 13, m);
}
else{
painter.setPen(g.button().dark(210));
drawRoundRect(&painter, sliderR.x()+1, sliderR.y(),
13, sliderR.height());
painter.drawTiledPixmap(sliderR.x()+2, sliderR.y()+1,
11, sliderR.height()-2,
*getPixmap(VSBSliderMid), 1, 0);
}
}
painter.setPen(g.mid());
painter.drawLine(bgR.x(), bgR.y(), bgR.x(), bgR.bottom());
painter.drawLine(bgR.right(), bgR.y(), bgR.right(), bgR.bottom());
if(brokenApp && (controls & Slider)){
painter.setPen(g.background());
painter.drawLine(bgR.right()-1, bgR.y(), bgR.right()-1,
bgR.bottom());
}
painter.end();
}
else{
painter.begin(&sbBuffer);
QRect bgR(subB.right()+1, 0, (len-(buttonDim*2))+1, sb->height());
if(sliderR.width() >= 8){
painter.drawPixmap(bgR.x(), bgR.y()+1, *vsbSliderFillPix, 0, 0,
8, 13);
painter.drawPixmap(bgR.x(), bgR.y()+1, *getPixmap(HSBSliderTopBg));
painter.drawTiledPixmap(bgR.x()+8, bgR.y()+1, bgR.width()-16,
13, *getPixmap(HSBSliderMidBg));
painter.drawPixmap(bgR.right()-8, bgR.y()+1, *vsbSliderFillPix,
0, 0, 8, 13);
painter.drawPixmap(bgR.right()-8, bgR.y()+1, *getPixmap(HSBSliderBtmBg));
}
else{
painter.drawTiledPixmap(bgR.x(), bgR.y()+1, bgR.width(), 13,
*getPixmap(HSBSliderMidBg));
painter.setPen(g.background().dark(210));
painter.drawRect(bgR.x(), bgR.y()+1, bgR.width()-1, 13);
painter.setPen(g.mid());
painter.drawPoint(bgR.x(), bgR.y()+1);
painter.drawPoint(bgR.x(), bgR.bottom()-1);
painter.drawPoint(bgR.right()-1, bgR.y()+1);
painter.drawPoint(bgR.right()-1, bgR.bottom()-1);
}
if(controls & Slider){
if(sliderR.width() >= 16){
painter.drawPixmap(sliderR.x(), sliderR.y()+1,
*getPixmap(HSBSliderTop));
painter.drawTiledPixmap(sliderR.x()+8, sliderR.y()+1, sliderR.width()-16,
13, *getPixmap(HSBSliderMid));
- painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
+ painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
*getPixmap(HSBSliderBtm));
}
else if(sliderR.width() >= 8){
int m = sliderR.width()/2;
painter.drawPixmap(sliderR.x(), sliderR.y()+1,
*getPixmap(HSBSliderTop), 0, 0, m, 13);
- painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
+ painter.drawPixmap(sliderR.right()-8, sliderR.y()+1,
*getPixmap(HSBSliderBtm), 8-m, 0, m, 13);
}
else{
painter.setPen(g.button().dark(210));
drawRoundRect(&painter, sliderR.x(), sliderR.y()+1,
sliderR.width(), 13);
painter.drawTiledPixmap(sliderR.x()+1, sliderR.y()+2,
- sliderR.width()-2, 11,
+ sliderR.width()-2, 11,
*getPixmap(HSBSliderMid), 0, 1);
}
}
painter.setPen(g.mid());
painter.drawLine(bgR.x(), bgR.y(), bgR.right(), bgR.y());
painter.drawLine(bgR.x(), bgR.bottom(), bgR.right(), bgR.bottom());
if(brokenApp && (controls & Slider)){
painter.setPen(g.background());
painter.drawLine(bgR.x(), bgR.bottom()-1, bgR.right(),
bgR.bottom()-1);
}
painter.end();
}
if ( controls & AddLine ) {
drawSBButton(p, addB, g, activeControl == AddLine);
drawArrow( p, horiz ? RightArrow : DownArrow,
false, addB.x()+4, addB.y()+4,
addB.width()-8, addB.height()-8, g, !maxed);
}
if ( controls & SubLine ) {
// drawSBButton(p, subB, g, activeControl == SubLine);
// drawArrow( p, horiz ? LeftArrow : UpArrow,
// false, subB.x()+4, subB.y()+4,
// subB.width()-8, subB.height()-8, g, !maxed);
drawSBButton(p, subHC, g, activeControl == SubLine);
drawArrow( p, horiz ? LeftArrow : UpArrow,
false, subHC.x()+4, subHC.y()+4,
subHC.width()-8, subHC.height()-8, g, !maxed);
}
if(controls & AddPage){
if(addPageR.width()){
p->drawPixmap(addPageR.x(), addPageR.y(), sbBuffer,
addPageR.x(), addPageR.y(), addPageR.width(),
addPageR.height());
}
}
if(controls & SubPage){
if(subPageR.height()){
p->drawPixmap(subPageR.x(), subPageR.y(), sbBuffer,
subPageR.x(), subPageR.y(), subPageR.width(),
subPageR.height());
}
}
if ( controls & Slider ) {
p->drawPixmap(sliderR.x(), sliderR.y(), sbBuffer,
sliderR.x(), sliderR.y(), sliderR.width(),
sliderR.height());
}
}
void LiquidStyle::drawSBButton(QPainter *p, const QRect &r, const QColorGroup &g,
bool down, bool /*fast*/)
{
p->setPen(g.mid());
p->drawRect(r);
QColor c(down ? g.button() : 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->drawTiledPixmap(r.x()+1, r.y()+1, r.width()-2, r.height()-2, *pix);
}
void LiquidStyle::drawSBDeco(QPainter *p, const QRect &r, const QColorGroup &g,
bool horiz)
{
if(horiz){
if(r.width() >= 15){
int y = r.y()+3;
int x = r.x() + (r.width()-7)/2;
int y2 = r.bottom()-3;
p->setPen(g.light());
p->drawLine(x, y, x, y2);
p->drawLine(x+3, y, x+3, y2);
p->drawLine(x+6, y, x+6, y2);
p->setPen(g.mid());
p->drawLine(x+1, y, x+1, y2);
p->drawLine(x+4, y, x+4, y2);
p->drawLine(x+7, y, x+7, y2);
}
}
else{
if(r.height() >= 15){
int x = r.x()+3;
int y = r.y() + (r.height()-7)/2;
int x2 = r.right()-3;
p->setPen(g.light());
p->drawLine(x, y, x2, y);
p->drawLine(x, y+3, x2, y+3);
p->drawLine(x, y+6, x2, y+6);
p->setPen(g.mid());
p->drawLine(x, y+1, x2, y+1);
p->drawLine(x, y+4, x2, y+4);
p->drawLine(x, y+7, x2, y+7);
}
}
}
void LiquidStyle::scrollBarMetrics(const QScrollBar *sb, int &sliderMin,
int &sliderMax, int &sliderLength,
int &buttonDim)
{
int maxLength;
int b = 0;
bool horiz = sb->orientation() == QScrollBar::Horizontal;
int length = horiz ? sb->width() : sb->height();
int extent = horiz ? sb->height() : sb->width();
if ( length > ( extent - b*2 - 1 )*2 + b*2 )
buttonDim = extent - b*2;
else
buttonDim = ( length - b*2 )/2 - 1;
sliderMin = b + 0; // buttonDim;
maxLength = length - b*2 - buttonDim*2; // 3;
if ( sb->maxValue() == sb->minValue() ) {
sliderLength = maxLength;
} else {
sliderLength = (sb->pageStep()*maxLength)/
(sb->maxValue()-sb->minValue()+sb->pageStep());
uint range = sb->maxValue()-sb->minValue();
if ( sliderLength < 9 || range > INT_MAX/2 )
sliderLength = 9;
if ( sliderLength > maxLength )
sliderLength = maxLength;
}
sliderMax = sliderMin + maxLength - sliderLength;
}
QStyle::ScrollControl LiquidStyle::scrollBarPointOver(const QScrollBar *sb,
int sliderStart,
const QPoint &p)
{
if ( !sb->rect().contains( p ) )
return NoScroll;
int sliderMin, sliderMax, sliderLength, buttonDim, pos;
scrollBarMetrics( sb, sliderMin, sliderMax, sliderLength, buttonDim );
pos = (sb->orientation() == QScrollBar::Horizontal)? p.x() : p.y();
if ( pos < sliderMin )
return SubLine;
if ( pos < sliderStart )
return SubPage;
if ( pos < sliderStart + sliderLength )
return Slider;
if ( pos < sliderMax + sliderLength)
return AddPage;
if(pos > sliderMax + sliderLength + 16)
return AddLine;
return SubLine;
}
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
QSize LiquidStyle::exclusiveIndicatorSize() const
{
return(QSize(16, 16));
}
void LiquidStyle::drawExclusiveIndicator(QPainter *p, int x, int y, int /*w*/,
int /*h*/, const QColorGroup &/*g*/, bool on,
bool down, bool)
{
bool isActive = ( p->device()->devType() == QInternal::Widget ) && ( qApp-> focusWidget ( ) == p-> device ( ));
bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
&& ((QWidget*)p->device())->autoMask();
if(isMasked){
if(on || down){
p->drawPixmap(x, y, isActive ? *getPixmap(HTMLRadioDownHover) :
*getPixmap(HTMLRadioDown));
}
else
p->drawPixmap(x, y, isActive ? *getPixmap(HTMLRadioHover) :
*getPixmap(HTMLRadio));
}
else{
if(on || down){
p->drawPixmap(x, y, isActive ? *getPixmap(RadioOnHover) :
*getPixmap(RadioOn));
}
else
p->drawPixmap(x, y, isActive ? *getPixmap(RadioOffHover) :
*getPixmap(RadioOff));
}
}
void LiquidStyle::drawExclusiveIndicatorMask(QPainter *p, int x, int y, int w,
int h, bool)
{
p->fillRect(x, y, w, h, Qt::color0);
p->setPen(Qt::color1);
p->drawPixmap(x, y, *getPixmap(RadioOn)->mask());
}
QSize LiquidStyle::indicatorSize() const
{
return(QSize(20, 22));
}
void LiquidStyle::drawIndicator(QPainter *p, int x, int y, int /*w*/, int /*h*/,
const QColorGroup &/*g*/, int state, bool /*down*/, bool)
{
bool isActive = ( p->device()->devType() == QInternal::Widget ) && ( qApp-> focusWidget ( ) == p-> device ( ));
bool isMasked = p->device() && p->device()->devType() == QInternal::Widget
&& ((QWidget*)p->device())->autoMask();
if(isMasked){
if(state != QButton::Off){
p->drawPixmap(x, y, isActive ? *getPixmap(HTMLCBDownHover) :
*getPixmap(HTMLCBDown));
}
else
p->drawPixmap(x, y, isActive ? *getPixmap(HTMLCBHover) :
*getPixmap(HTMLCB));
}
else{
if(state != QButton::Off){
p->drawPixmap(x, y, isActive ? *getPixmap(CBDownHover) :
*getPixmap(CBDown));
/* Todo - tristate
if(state == QButton::On){
p->setPen(Qt::black);
p->drawPixmap(3, 3, xBmp);
}
else{
p->setPen(g.dark());
p->drawRect(x+2, y+2, w-4, h-4);
p->setPen(Qt::black);
p->drawLine(x+3, (y+h)/2-2, x+w-4, (y+h)/2-2);
p->drawLine(x+3, (y+h)/2, x+w-4, (y+h)/2);
p->drawLine(x+3, (y+h)/2+2, x+w-4, (y+h)/2+2);
}*/
}
else
p->drawPixmap(x, y, isActive ? *getPixmap(CBHover) : *getPixmap(CB));
}
}
void LiquidStyle::drawIndicatorMask(QPainter *p, int x, int y, int /*w*/, int /*h*/,
int /*state*/)
{
// needed for some reason by KHtml, even tho it's all filled ;P
p->drawPixmap(x, y, *getPixmap(HTMLCB)->mask());
}
void LiquidStyle::drawSlider(QPainter *p, int x, int y, int w, int h,
const QColorGroup &/*g*/, Orientation orient,
bool, bool)
{
QWidget *parent = (QWidget *)p->device();
p->setBrushOrigin(parent->pos());
parent->erase(x, y, w, h);
p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider) :
*getPixmap(VSlider));
}
void LiquidStyle::drawSliderMask(QPainter *p, int x, int y, int /*w*/, int /*h*/,
Orientation orient, bool, bool)
{
p->drawPixmap(x, y, orient == Qt::Horizontal ? *getPixmap(HSlider)->mask() :
*getPixmap(VSlider)->mask());
}
int LiquidStyle::sliderLength() const
{
return(10);
}
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
void LiquidStyle::drawArrow(QPainter *p, Qt::ArrowType type, bool on, int x,
int y, int w, int h, const QColorGroup &g,
bool enabled, const QBrush *)
{
static const QCOORD u_arrow[]={3,1, 4,1, 2,2, 5,2, 1,3, 6,3, 0,4, 7,4, 0,5, 7,5};
static const QCOORD d_arrow[]={0,2, 7,2, 0,3, 7,3, 1,4, 6,4, 2,5, 5,5, 3,6, 4,6};
static const QCOORD l_arrow[]={1,3, 1,4, 2,2, 2,5, 3,1, 3,6, 4,0, 4,7, 5,0, 5,7};
static const QCOORD r_arrow[]={2,0, 2,7, 3,0, 3,7, 4,1, 4,6, 5,2, 5,5, 6,3, 6,4};
p->setPen(enabled ? on ? g.light() : g.buttonText() : g.mid());
if(w > 8){
x = x + (w-8)/2;
y = y + (h-8)/2;
}
QPointArray a;
switch(type){
case Qt::UpArrow:
a.setPoints(QCOORDARRLEN(u_arrow), u_arrow);
break;
case Qt::DownArrow:
a.setPoints(QCOORDARRLEN(d_arrow), d_arrow);
break;
case Qt::LeftArrow:
a.setPoints(QCOORDARRLEN(l_arrow), l_arrow);
break;
default:
a.setPoints(QCOORDARRLEN(r_arrow), r_arrow);
break;
}
a.translate(x, y);
p->drawLineSegments(a);
}
void LiquidStyle::drawMenuBarItem(QPainter *p, int x, int y, int w, int h,
QMenuItem *mi, QColorGroup &g, bool /*enabled*/, bool active )
-{
+{
if(active){
- x -= 2; // Bug in Qt/E
+ x -= 2; // Bug in Qt/E
y -= 2;
w += 2;
h += 2;
}
-
+
QWidget *parent = (QWidget *)p->device();
p->setBrushOrigin(parent->pos());
parent->erase(x, y, w, h);
-
+
if(menuHandler->useShadowText()){
QColor shadow;
if(p->device() && p->device()->devType() == QInternal::Widget &&
((QWidget *)p->device())->inherits("QMenuBar")){
shadow = ((QMenuBar*)p->device())->isTopLevel() ? g.button().dark(130) :
g.background().dark(130);
}
else
shadow = g.background().dark(130);
QPixmap *dummy = 0;
-
+
if ( mi-> pixmap ( ) && !mi-> pixmap ( )-> isNull ( )) {
dummy = new QPixmap ( mi-> pixmap ( )-> size ( ));
QBitmap dummy_mask ( dummy-> size ( ));
dummy_mask. fill ( color1 );
dummy-> setMask ( dummy_mask );
}
if(active){
drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
QApplication::style().drawItem(p, x+1, y+1, w, h,
AlignCenter|ShowPrefix|DontClip|SingleLine,
g, mi->isEnabled(), dummy, mi->text(),
-1, &shadow);
QApplication::style().drawItem(p, x, y, w, h,
AlignCenter|ShowPrefix|DontClip|SingleLine,
g, mi->isEnabled(), mi-> pixmap ( ), mi->text(),
-1, &g.text());
}
else{
QApplication::style().drawItem(p, x+1, y+1, w, h,
AlignCenter|ShowPrefix|DontClip|SingleLine,
g, mi->isEnabled(), dummy, mi->text(),
-1, &shadow);
QApplication::style().drawItem(p, x, y, w, h,
AlignCenter|ShowPrefix|DontClip|SingleLine,
g, mi->isEnabled(), mi-> pixmap ( ), mi->text(),
-1, &g.text());
}
delete dummy;
}
else{
if(active)
drawClearBevel(p, x+1, y+1, w-1, h-1, g.button(), g.background());
QApplication::style().drawItem(p, x, y, w, h,
AlignCenter|ShowPrefix|DontClip|SingleLine,
g, mi->isEnabled(), mi-> pixmap ( ), mi->text(),
-1, &g.text());
}
}
void LiquidStyle::drawPopupPanel(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, int /*lineWidth*/,
const QBrush * /*fill*/)
{
QColor c;
switch(menuHandler->transType()){
case None:
case StippledBg:
case TransStippleBg:
c = g.background();
break;
case StippledBtn:
case TransStippleBtn:
c = g.button();
break;
default:
c = menuHandler->bgColor();
}
p->setPen(c.dark(140));
p->drawRect(x, y, w, h);
p->setPen(c.light(120));
p->drawRect(x+1, y+1, w-2, h-2);
}
void LiquidStyle::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)
{
static const int motifItemFrame = 2;
static const int motifItemHMargin = 3;
static const int motifItemVMargin = 2;
static const int motifArrowHMargin = 6;
static const int windowsRightBorder = 12;
maxpmw = QMAX( maxpmw, 20 );
bool dis = !enabled;
QColorGroup itemg = dis ? pal.disabled() : pal.active();
int checkcol = maxpmw;
if(act){
// FIXME
drawClearBevel(p, x, y, w, h, itemg.button(), itemg.background());
}
//else if(((QWidget*)p->device())->backgroundPixmap()){
// p->drawPixmap(x, y, *((QWidget*)p->device())->backgroundPixmap(),
// x, y, w, h);
//}
else{
if(menuHandler->transType() == None){
p->fillRect(x, y, w, h, pal.active().background());
}
else if(menuHandler->transType() == StippledBg){
p->fillRect(x, y, w, h, bgBrush);
}
else if(menuHandler->transType() == StippledBtn){
p->fillRect(x, y, w, h, menuBrush);
}
else{
QPixmap *pix = menuHandler->pixmap(((QWidget*)p->device())->winId());
if(pix)
p->drawPixmap(x, y, *pix, x, y, w, h);
}
}
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];
QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab);
p->drawPixmap(r.x(), r.y(), *pix, 0, 0, 9, r.height());
p->drawPixmap(r.right()-9, r.y(), *pix, pix->width()-9, 0, 9, r.height());
tilePix.resize(pix->width()-18, r.height());
bitBlt(&tilePix, 0, 0, pix, 9, 0, pix->width()-18, r.height());
p->drawTiledPixmap(r.x()+9, r.y(), r.width()-18, r.height(), tilePix);
QColor c = tabBar->colorGroup().button();
if(!selected){
p->setPen(c.dark(130));
p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
}
/*
p->setPen(c.light(110));
p->drawLine(r.x(), r.bottom()+1, r.right(), r.bottom()+1);
p->setPen(c);
p->drawLine(r.x(), r.bottom()+2, r.right(), r.bottom()+2);
p->setPen(c.light(110));
p->drawLine(r.x(), r.bottom()+3, r.right(), r.bottom()+3);
p->setPen(c.light(120));
p->drawLine(r.x(), r.bottom()+4, r.right(), r.bottom()+4);
*/
/*
QColor c = tabBar->colorGroup().button();
pix = bevelFillDict.find(c.rgb());
if(!pix){
int h, s, v;
c.hsv(&h, &s, &v);
pix = new QPixmap(*bevelFillPix);
adjustHSV(*pix, h, s);
bevelFillDict.insert(c.rgb(), pix);
}*/
/*
QRect r = tab->rect();
QColorGroup g = tabBar->colorGroup();
if(!selected){
r.setY(r.y()+1);
p->setPen(g.dark());
p->drawLine(r.x(), r.y()+4, r.x(), r.bottom()-2);
p->drawLine(r.x(), r.y()+4, r.x()+4, r.y());
p->drawLine(r.x()+4, r.y(), r.right()-1, r.y());
p->drawLine(r.right(), r.y()+1, r.right(), r.bottom()-2);
p->setPen(g.midlight());
p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom());
p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1);
p->drawLine(r.x()+5, r.y()+1, r.right()-2, r.y()+1);
p->drawLine(r.x(), r.bottom(), r.right(), r.bottom());
p->setPen(g.mid());
p->drawPoint(r.right()-1, r.y()+1);
p->drawLine(r.x()+4, r.y()+2, r.right()-1, r.y()+2);
p->drawLine(r.x()+3, r.y()+3, r.right()-1, r.y()+3);
p->fillRect(r.x()+2, r.y()+4, r.width()-3, r.height()-6,
g.brush(QColorGroup::Mid));
p->setPen(g.light());
p->drawLine(r.x(), r.bottom()-1, r.right(), r.bottom()-1);
}
else{
p->setPen(g.light());
p->drawLine(r.x(), r.y()+4, r.x(), r.bottom());
p->drawLine(r.x(), r.y()+4, r.x()+4, r.y());
p->drawLine(r.x()+4, r.y(), r.right()-1, r.y());
p->setPen(g.dark());
p->drawLine(r.right(), r.y()+1, r.right(), r.bottom());
p->setPen(g.midlight());
p->drawLine(r.x()+1, r.y()+4, r.x()+1, r.bottom());
p->drawLine(r.x()+1, r.y()+4, r.x()+4, r.y()+1);
p->drawLine(r.x()+5, r.y()+1, r.right() - 2, r.y()+1);
p->setPen(g.mid());
p->drawLine(r.right()-1, r.y()+1, r.right()-1, r.bottom());
}*/
}
void LiquidStyle::drawTabMask(QPainter *p, const QTabBar*, QTab *tab,
bool selected)
{
//p->fillRect(tab->rect(), Qt::color1);
QRect r = tab->rect();
QPixmap *pix = selected ? getPixmap(TabDown) : getPixmap(Tab);
p->drawPixmap(r.x(), r.y(), *pix->mask(), 0, 0, 9, r.height());
p->drawPixmap(r.right()-9, r.y(), *pix->mask(), pix->width()-9, 0, 9, r.height());
p->fillRect(r.x()+9, r.y(), r.width()-18, r.height(), Qt::color1);
}
void LiquidStyle::tabbarMetrics(const QTabBar *t, int &hFrame, int &vFrame,
int &overlap)
{
if(t->shape() == QTabBar::RoundedAbove){
overlap = 1;
hFrame = 18; // was 24
vFrame = 8; // was 10
}
else
QWindowsStyle::tabbarMetrics(t, hFrame, vFrame, overlap);
}
void LiquidStyle::drawSplitter(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, Orientation)
{
drawClearBevel(p, x, y, w, h, highlightWidget == p->device() ?
g.button().light(120) : g.button(), g.background());
}
void LiquidStyle::drawPanel(QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
int lineWidth, const QBrush *fill)
{
if(p->device()->devType() == QInternal::Widget &&
((QWidget *)p->device())->inherits("QLineEdit")){
int x2 = x+w-1;
int y2 = y+h-1;
p->setPen(g.dark());
p->drawRect(x, y, w, h);
p->setPen(g.mid());
p->drawLine(x+1, y+1, x2-2, y+1);
p->drawLine(x+1, y+1, x+1, y2-1);
}
else if(lineWidth != 2 || !sunken)
QWindowsStyle::drawPanel(p, x, y, w, h, g, sunken, lineWidth, fill);
else{
QPen oldPen = p->pen();
int x2 = x+w-1;
int y2 = y+h-1;
p->setPen(g.light());
p->drawLine(x, y2, x2, y2);
p->drawLine(x2, y, x2, y2);
p->setPen(g.mid());
p->drawLine(x, y, x2, y);
p->drawLine(x, y, x, y2);
-
+
p->setPen(g.midlight());
p->drawLine(x+1, y2-1, x2-1, y2-1);
p->drawLine(x2-1, y+1, x2-1, y2-1);
p->setPen(g.dark());
p->drawLine(x+1, y+1, x2-1, y+1);
p->drawLine(x+1, y+1, x+1, y2-1);
p->setPen(oldPen);
if(fill){
// I believe here we are only supposed to fill if there is a
// specified fill brush...
p->fillRect(x+2, y+2, w-4, h-4, *fill);
}
}
}
void LiquidStyle::adjustHSV(QPixmap &pix, int h, int s, int v)
{
QBitmap *maskBmp = NULL;
if(pix.mask())
maskBmp = new QBitmap(*pix.mask());
QImage img = pix.convertToImage();
if(img.depth() != 32)
img = img.convertDepth(32);
unsigned int *data = (unsigned int *)img.bits();
int total = img.width()*img.height();
int current;
QColor c;
int oldH, oldS, oldV;
if(v < 235)
v += 20;
else
v = 255;
float intensity = v/255.0;
for(current=0; current<total; ++current){
c.setRgb(data[current]);
c.hsv(&oldH, &oldS, &oldV);
oldV = (int)(oldV*intensity);
c.setHsv(h, s, oldV);
data[current] = c.rgb();
}
pix.convertFromImage(img);
if(maskBmp)
pix.setMask(*maskBmp);
}
void LiquidStyle::intensity(QPixmap &pix, float percent)
{
QImage image = pix.convertToImage();
int i, tmp, r, g, b;
int segColors = image.depth() > 8 ? 256 : image.numColors();
unsigned char *segTbl = new unsigned char[segColors];
int pixels = image.depth() > 8 ? image.width()*image.height() :
image.numColors();
unsigned int *data = image.depth() > 8 ? (unsigned int *)image.bits() :
(unsigned int *)image.colorTable();
-
+
bool brighten = (percent >= 0);
if(percent < 0)
percent = -percent;
-
+
if(brighten){ // keep overflow check out of loops
for(i=0; i < segColors; ++i){
tmp = (int)(i*percent);
if(tmp > 255)
tmp = 255;
segTbl[i] = tmp;
}
}
else{
for(i=0; i < segColors; ++i){
tmp = (int)(i*percent);
if(tmp < 0)
tmp = 0;
segTbl[i] = tmp;
}
}
-
+
if(brighten){ // same here
for(i=0; i < pixels; ++i){
r = qRed(data[i]);
g = qGreen(data[i]);
b = qBlue(data[i]);
r = r + segTbl[r] > 255 ? 255 : r + segTbl[r];
g = g + segTbl[g] > 255 ? 255 : g + segTbl[g];
b = b + segTbl[b] > 255 ? 255 : b + segTbl[b];
data[i] = qRgb(r, g, b);
}
}
else{
for(i=0; i < pixels; ++i){
r = qRed(data[i]);
g = qGreen(data[i]);
b = qBlue(data[i]);
r = r - segTbl[r] < 0 ? 0 : r - segTbl[r];
g = g - segTbl[g] < 0 ? 0 : g - segTbl[g];
b = b - segTbl[b] < 0 ? 0 : b - segTbl[b];
data[i] = qRgb(r, g, b);
}
}
delete [] segTbl;
pix.convertFromImage(image);
}
void LiquidStyle::drawRoundRect(QPainter *p, int x, int y, int w, int h)
{
int x2 = x+w-1;
int y2 = y+h-1;
p->drawLine(x+1, y, x2-1, y);
p->drawLine(x, y+1, x, y2-1);
p->drawLine(x+1, y2, x2-1, y2);
p->drawLine(x2, y+1, x2, y2-1);
}
void LiquidStyle::drawSliderGroove (QPainter * p, int x, int y, int w, int h,
const QColorGroup &g, QCOORD,
Orientation orient)
{
bool isFocus = ((QWidget *)p->device())->hasFocus();
QColor c = isFocus ? g.background().dark(120) : g.background();
if(orient == Qt::Horizontal){
int x2 = x+w-1;
y+=2;
p->setPen(c.dark(130));
p->drawLine(x+1, y, x2-1, y);
p->setPen(c.dark(150));
p->drawLine(x, y+1, x2, y+1);
p->setPen(c.dark(125));
p->drawLine(x, y+2, x2, y+2);
p->setPen(c.dark(130));
p->drawLine(x, y+3, x2, y+3);
p->setPen(c.dark(120));
p->drawLine(x, y+4, x2, y+4);
p->setPen(c.light(110));
p->drawLine(x+1, y+5, x2-1, y+5);
}
else{
int y2 = y+h-1;
x+=2;
p->setPen(c.dark(130));
p->drawLine(x, y+1, x, y2-1);
p->setPen(c.dark(150));
p->drawLine(x+1, y, x+1, y2);
p->setPen(c.dark(125));
p->drawLine(x+2, y, x+2, y2);
p->setPen(c.dark(130));
p->drawLine(x+3, y, x+3, y2);
p->setPen(c.dark(120));
p->drawLine(x+4, y, x+4, y2);
p->setPen(c.light(110));
p->drawLine(x+5, y+1, x+5, y2-1);
}
//QWindowsStyle::drawSliderGroove(p, x, y, w, h, g, c, orient);
}
void LiquidStyle::drawSliderGrooveMask (QPainter * p, int x, int y, int w,
int h, QCOORD, Orientation orient)
{
p->fillRect(x, y, w, h, Qt::color0);
p->setPen(Qt::color1);
if(orient == Qt::Horizontal){
int x2 = x+w-1;
y+=2;
p->drawLine(x+1, y, x2-1, y);
p->fillRect(x, y+1, w, 4, Qt::color1);
p->drawLine(x+1, y+5, x2-1, y+5);
}
else{
int y2 = y+h-1;
x+=2;
p->drawLine(x, y+1, x, y2-1);
p->fillRect(x+1, y, 4, h, Qt::color1);
p->drawLine(x+5, y+1, x+5, y2-1);
}
}
/* vim: set noet sw=8 ts=8: */
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
@@ -201,656 +201,662 @@ void PhaseStyle::drawPanel(QPainter* painter, int x, int y, int w, int h,
painter->save();
if (sunken) {
painter->setPen(group.dark());
painter->drawRect(x+1, y+1, w-2, h-2);
painter->setPen(group.midlight());
painter->drawLine(x+1, y2, x2, y2);
painter->drawLine(x2, y+1, x2, y2-1);
painter->setPen(group.mid());
painter->drawLine(x, y, x, y2-1);
painter->drawLine(x+1, y, x2-1, y);
painter->setPen(group.background());
painter->drawPoint(x, y2);
painter->drawPoint(x2, y);
} else {
painter->setPen(group.dark());
painter->drawRect(x, y, w, h);
painter->setPen(group.midlight());
painter->drawLine(x+1, y+1, x2-2, y+1);
painter->drawLine(x+1, y+2, x+1, y2-2);
painter->setPen(group.mid());
painter->drawLine(x+2, y2-1, x2-1, y2-1);
painter->drawLine(x2-1, y+2, x2-1, y2-2);
painter->setPen(group.background());
painter->drawPoint(x+1, y2-1);
painter->drawPoint(x2-1, y+1);
}
if (fill) {
painter->fillRect(x+2, y+2, w-4, h-4, *fill );
}
painter->restore();
}
void PhaseStyle::drawButton(QPainter *p, int x, int y, int w, int h,
const QColorGroup &group, bool sunken ,
const QBrush *fill ) {
int x2 = x + w - 1;
int y2 = y + h - 1;
p->setPen(group.midlight());
p->drawLine(x+1, y2, x2, y2);
p->drawLine(x2, y+1, x2, y2-1);
p->setPen(group.mid());
p->drawLine(x, y, x2-1, y);
p->drawLine(x, y+1, x, y2-1);
p->setPen(group.button());
p->drawPoint(x, y2);
p->drawPoint(x2, y);
drawBevelButton(p, x+1, y+1, w-2, h-2, group, sunken,
fill);
}
void PhaseStyle::drawButtonMask( QPainter* p, int x, int y,
int w, int h ) {
QRect rect(x, y, w, h );
p->fillRect(rect, Qt::color1);
p->setPen(Qt::color0);
}
void PhaseStyle::drawBevelButton(QPainter* p, int x, int y,
int w, int h, const QColorGroup& group,
bool sunken, const QBrush* fill ) {
int x2 = x + w - 1;
int y2 = y + h - 1;
p->save();
p->setPen(group.dark());
p->drawRect(x, y, w, h);
p->setPen(sunken ? group.mid() : group.midlight());
p->drawLine(x+1, y+1, x2-2, y+1);
p->drawLine(x+1, y+2, x+1, y2-2);
p->setPen(sunken ? group.midlight() : group.mid());
p->drawLine(x+2, y2-1, x2-1, y2-1);
p->drawLine(x2-1, y+2, x2-1, y2-2);
p->setPen(group.button());
p->drawPoint(x+1, y2-1);
p->drawPoint(x2-1, y+1);
QBrush b = fill ? *fill : group.brush( QColorGroup::Button );
if (sunken) {
// sunken bevels don't get gradients
p->fillRect(x+2, y+2, w-4, h-4, b);
} else
drawPhaseGradient(p, QRect(x+2, y+2, w-4, h-4), b.color() );
p->restore();
}
void PhaseStyle::drawPhaseGradient(QPainter* painter,
const QRect& rect,
const QColor& color )const {
painter->fillRect(rect, color);
}
void PhaseStyle::polish( QWidget* widget ) {
QWindowsStyle::polish(widget );
#if 0
if (widget->inherits("QMenuBar") ||
widget->inherits("QPopupMenu" ) ||
widget->inherits("QToolButton") ||
widget->inherits("QHeader" ) ) {
widget->setBackgroundMode(QWidget::NoBackground);
}
// else if (widget->inherits("QFrame") ) {
// widget->installEventFilter(this);
// }
#endif
}
void PhaseStyle::unPolish( QWidget *w )
{
QWindowsStyle::unPolish( w );
}
void PhaseStyle::polish( QPalette &pal ) {
QWindowsStyle::polish( pal );
// lighten up a bit, so the look is not so "crisp"
if (QPixmap::defaultDepth() > 8) { // but not on low color displays
pal.setColor(QPalette::Disabled, QColorGroup::Dark,
pal.color(QPalette::Disabled, QColorGroup::Dark).light(contrast));
pal.setColor(QPalette::Active, QColorGroup::Dark,
pal.color(QPalette::Active, QColorGroup::Dark).light(contrast));
pal.setColor(QPalette::Inactive, QColorGroup::Dark,
pal.color(QPalette::Inactive, QColorGroup::Dark).light(contrast));
}
}
void PhaseStyle::polish( QApplication* app ) {
QWindowsStyle::polish( app );
qt_set_draw_menu_bar_impl((QDrawMenuBarItemImpl)&PhaseStyle::drawMenuBarItem);
}
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 ));
else
painter->drawRect(rect);
painter->setPen(old);
}
void PhaseStyle::drawSeperator( QPainter* painter, int x, int y, int w,
int h, const QColorGroup& group, bool,
int , int ) {
qWarning( "Seperator" );
QRect rect(x, y, w, h);
int x2 = rect.right();
int y2 = rect.bottom();
painter->setPen(group.dark());
if (w < h)
painter->drawLine(w/2, y, w/2, y2);
else
painter->drawLine(x, h/2, x2, h/2);
}
void PhaseStyle::drawMenuBarItem(QPainter* p, int x, int y, int w, int h,
QMenuItem *mi, QColorGroup& g, bool enabled,
bool act ) {
return QWindowsStyle::drawMenuBarItem(p, x, y, w, h, mi, g, enabled, act);
}
void PhaseStyle::drawIndicator(QPainter* painter, int x, int y, int w, int h,
const QColorGroup &group, int state, bool,
bool enabled ) {
drawPanel(painter, x, y, w, h, group, true, 1, enabled ?
&group.brush(QColorGroup::Base) :
&group.brush(QColorGroup::Background));
if (QButton::On == state ) {
painter->setPen(group.dark());
painter->drawRect(x+3, y+3, w-6, h-6);
painter->fillRect(x+4, y+4, w-8, h-8,
group.brush(QColorGroup::Highlight));
}
}
void PhaseStyle::drawExclusiveIndicator(QPainter* painter, int x, int y, int w, int h,
const QColorGroup &group, bool on,
bool /*down*/, bool enabled) {
QRect r(x, y, w, h );
/*
* As Polygon and Polyline are broken in Qt2 lets use
* something not that spectacilur -> ellipse
*/
painter->save();
painter->fillRect(x, y, w, h, group.background());
painter->setBrush(enabled
? group.brush(QColorGroup::Base)
: group.brush(QColorGroup::Background));
painter->setPen(group.dark());
if (0 == w % 2) --w;
if (0 == h % 2) --h;
painter->drawEllipse(x, y, w, h );
if(on) {
painter->setBrush(group.brush(QColorGroup::Highlight));
painter->drawEllipse(x+3,y+3,w-6,h-6);
}
painter->restore();
}
/*
* Does not get called in QWS as it seems
*/
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
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 );
}
}
QRect PhaseStyle::comboButtonRect ( int x, int y, int w, int h ) {
return QRect(x+2, y+2, w-4-17, h-5 );
}
void PhaseStyle::drawComboButton( QPainter * p, int x, int y,
int w, int h,
const QColorGroup & g,
bool sunken,
bool editable,
bool,
const QBrush *) {
drawButton(p, x, y, w, h, g,
sunken, &g.brush(QColorGroup::Button ));
for ( int n = 0; n < 2; ++n )
kColorBitmaps(p, g, w-16+(6*n), y+(h/2)-2,
0, &doodad_mid, &doodad_light, 0, 0, 0 );
if (editable ) {
const int x2 = x+w-1; const int y2 = y+h-1;
p->setPen(g.dark());
p->drawLine(x2+1, y, x2+1, y2);
p->setPen(g.midlight());
p->drawLine(x2+2, y, x2+2, y2-1);
p->setPen(g.button());
p->drawPoint(x2+2, y2);
}
p->setPen(g.buttonText() );
}
void PhaseStyle::tabbarMetrics( const QTabBar* t, int &hframe, int &vframe, int& ov ) {
QCommonStyle::tabbarMetrics( t, hframe, vframe, ov );
hframe -= 2;
vframe += 1;
}
void PhaseStyle::drawTab(QPainter* painter, const QTabBar* bar, QTab* tab,
bool selected ) {
bool edge = false;
int x, y, w, h;
QRect r = tab->rect();
r.rect(&x,&y,&w,&h);
const int x2 = x+w-1;
const int y2 = y+h-1;
const QColorGroup &group = bar->colorGroup();
painter->save();
// what position is the tab?
if ((bar->count() == 1 ))
edge = true;
else
edge = false;
switch (QTabBar::Shape(bar->shape())) {
case QTabBar::RoundedAbove:
case QTabBar::TriangularAbove: {
if (!selected) { // shorten
y += 2; h -= 2;
}
if (selected) {
painter->setPen(Qt::NoPen);
painter->fillRect(x+1, y+1, w-1, h-1,
group.brush(QColorGroup::Background));
} else
drawPhaseGradient(painter, QRect(x+1, y+1, w-1, h-2),
group.background().dark(contrast) );
// draw tab
painter->setPen(group.dark());
painter->drawLine(x, y, x, y2-2);
painter->drawLine(x+1, y, x2, y);
painter->drawLine(x2, y+1, x2, y2-2);
painter->setPen(group.mid());
painter->drawLine(x2-1, y+2, x2-1, y2-2);
painter->setPen(group.midlight());
painter->drawLine(x+1, y+1, x2-2, y+1);
if ((selected) || edge) painter->drawLine(x+1, y+2, x+1, y2-2);
// finish off bottom
if (selected) {
painter->setPen(group.dark());
painter->drawPoint(x, y2-1);
painter->drawPoint(x2, y2-1);
painter->setPen(group.midlight());
painter->drawPoint(x, y2);
painter->drawLine(x+1, y2-1, x+1, y2);
painter->drawPoint(x2, y2);
painter->setPen(group.mid());
painter->drawPoint(x2-1, y2-1);
if (edge) {
painter->setPen(group.dark());
painter->drawLine(x, y2-1, x, y2);
painter->setPen(group.midlight());
painter->drawPoint(x+1, y2);
}
} else {
painter->setPen(group.dark());
painter->drawLine(x, y2-1, x2, y2-1);
painter->setPen(group.midlight());
painter->drawLine(x, y2, x2, y2);
if (edge) {
painter->setPen(group.dark());
painter->drawLine(x, y2-1, x, y2);
}
}
break;
}
case QTabBar::RoundedBelow:
case QTabBar::TriangularBelow: {
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
@@ -1,330 +1,330 @@
/* This file is part of the KDE libraries
Copyright (C) 1999 Daniel M. Duley <mosfet@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License version 2 as published by the Free Software Foundation.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "othemestyle.h"
#include "othemebase.h"
#include <qpe/qpeapplication.h>
#include <qbitmap.h>
#define INCLUDE_MENUITEM_DEF
#include <qmenudata.h>
#include <qpopupmenu.h>
#include <qtabbar.h>
#include <qglobal.h>
#include <qprogressbar.h>
#include <limits.h>
#include <stdio.h>
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);
p.restore();
}
if ( event->rect().intersects( contentsRect() )) {
p.setClipRegion( event->region().intersect( contentsRect() ) );
int x, y, w, h;
contentsRect ( ). rect ( &x, &y, &w, &h );
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);
}
}
}
};
#define QCOORDARRLEN(x) sizeof(x)/(sizeof(QCOORD)*2)
OThemeStyle::OThemeStyle( const QString &configFile )
: OThemeBase( configFile )
{
setScrollBarExtent( getSBExtent(), getSBExtent() );
setButtonDefaultIndicatorWidth( 0 ); // We REALLY should support one, see drawPushButton() below!
}
OThemeStyle::~OThemeStyle()
{}
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 );
}
void OThemeStyle::polish( QWidget *w )
{
if ( !w->isTopLevel() ) {
if ( w->inherits( "QGroupBox" )
|| w->inherits( "QTabWidget" ) ) {
w->setAutoMask( TRUE );
return ;
}
if ( w->inherits( "QLabel" )
|| w->inherits( "QSlider" )
|| w->inherits( "QButton" )
|| w->inherits( "QProgressBar" )
) {
w->setBackgroundOrigin( QWidget::ParentOrigin );
}
}
if ( w->inherits( "QPopupMenu" ) ) {
popupPalette = w->palette();
if ( isColor( MenuItem ) || isColor( MenuItemDown ) ) {
QPalette newPal( w->palette() );
w->setPalettePropagation( QWidget::SamePalette );
if ( isColor( MenuItem ) ) {
newPal.setNormal( *colorGroup( newPal.normal(), MenuItem ) );
newPal.setDisabled( *colorGroup( newPal.normal(), MenuItem ) );
}
if ( isColor( MenuItemDown ) )
newPal.setActive( *colorGroup( newPal.active(), MenuItemDown ) );
w->setPalette( newPal );
}
}
else if ( w->inherits( "QCheckBox" ) ) {
if ( isColor( IndicatorOff ) || isColor( IndicatorOn ) ) {
QPalette newPal( w->palette() );
w->setPalettePropagation( QWidget::SamePalette );
if ( isColor( IndicatorOff ) ) {
newPal.setNormal( *colorGroup( newPal.normal(), IndicatorOff ) );
newPal.setDisabled( *colorGroup( newPal.normal(), IndicatorOff ) );
}
if ( isColor( IndicatorOn ) )
newPal.setActive( *colorGroup( newPal.active(), IndicatorOn ) );
w->setPalette( newPal );
}
}
else if ( w->inherits( "QRadioButton" ) ) {
if ( isColor( ExIndicatorOff ) || isColor( ExIndicatorOn ) ) {
QPalette newPal( w->palette() );
w->setPalettePropagation( QWidget::SamePalette );
if ( isColor( ExIndicatorOff ) ) {
newPal.setNormal( *colorGroup( newPal.normal(), ExIndicatorOff ) );
newPal.setDisabled( *colorGroup( newPal.normal(),
ExIndicatorOff ) );
}
if ( isColor( ExIndicatorOn ) )
newPal.setActive( *colorGroup( newPal.active(), ExIndicatorOn ) );
w->setPalette( newPal );
}
}
else if ( w-> inherits ( "QProgressBar" ) ) {
w-> installEventFilter ( this );
}
}
void OThemeStyle::unPolish( QWidget* w )
{
if ( !w->isTopLevel() ) {
if ( w->inherits( "QGroupBox" )
|| w->inherits( "QTabWidget" ) ) {
w->setAutoMask( FALSE );
return ;
}
if ( w->inherits( "QLabel" )
|| w->inherits( "QSlider" )
|| w->inherits( "QButton" )
|| w->inherits( "QProgressBar" )
) {
w->setBackgroundOrigin( QWidget::WidgetOrigin );
}
}
if ( w->inherits( "QPopupMenu" ) )
w->unsetPalette();
else if ( w->inherits( "QCheckBox" ) )
w->unsetPalette();
else if ( w->inherits( "QRadioButton" ) )
w->unsetPalette();
else if ( w-> inherits ( "QProgressBar" ) )
w-> removeEventFilter ( this );
}
bool OThemeStyle::eventFilter ( QObject *obj, QEvent *ev )
{
// only QProgressBar so far
if ( ev-> type ( ) == QEvent::Paint ) {
HackProgressBar *pb = (HackProgressBar *) obj;
pb-> paint ((QPaintEvent *) ev, this );
return true;
}
return false;
}
void OThemeStyle::drawBaseButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, bool
rounded, WidgetType type, const QBrush * )
{
if ( w <= 0 || h <= 0 )
return;
int offset = borderPixmap( type ) ? 0 : decoWidth( type );
QPen oldPen = p->pen();
// handle reverse bevel here since it uses decowidth differently
if ( gradientHint( type ) == GrReverseBevel ) {
int i;
bitBlt( p->device(), x, y, scalePixmap( w, h, type ), 0, 0, w, h,
Qt::CopyROP, true );
p->setPen( g.text() );
for ( i = 0; i < borderWidth( type ); ++i, ++x, ++y, w -= 2, h -= 2 )
p->drawRect( x, y, w, h );
}
// same with KDE style borders
else if ( !borderPixmap( type ) && shade() == KDE ) {
qDrawWinButton( p, x, y, w, h, g, sunken );
if ( isPixmap( type ) )
p->drawTiledPixmap( x + 4, y + 4, w - 6, h - 6,
*scalePixmap( w - 6, h - 6,
type ) );
else
p->fillRect( x + 4, y + 4, w - 6, h - offset * 6,
g.brush( QColorGroup::Button ) );
}
else {
if ( ( w - offset * 2 ) > 0 && ( h - offset * 2 ) > 0 ) {
if ( isPixmap( type ) )
if ( rounded )
p->drawTiledPixmap( x, y, w, h, *scalePixmap( w, h, type ) );
else
p->drawTiledPixmap( x + offset, y + offset, w - offset * 2,
h - offset * 2,
*scalePixmap( w - offset * 2, h - offset * 2,
type ) );
else
p->fillRect( x + offset, y + offset, w - offset * 2, h - offset * 2,
g.brush( QColorGroup::Button ) );
}
if ( borderPixmap( type ) ) {
bitBlt( p->device(), x, y, scaleBorder( w, h, type ), 0, 0, w, h,
Qt::CopyROP, false );
}
else
drawShade( p, x, y, w, h, g, sunken, rounded,
highlightWidth( type ), borderWidth( type ), shade() );
}
p->setPen( oldPen );
}
void OThemeStyle::drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush *fill )
{
drawBaseButton( p, x, y, w, h, g, sunken, roundButton(), sunken ?
PushButtonDown : PushButton, fill );
}
void OThemeStyle::drawPushButton( QPushButton* btn, QPainter *p )
{
bool sunken = btn->isOn() || btn->isDown();
int diw = buttonDefaultIndicatorWidth();
drawBaseButton( p, diw, diw, btn->width() - 2 * diw, btn->height() - 2 * diw,
*colorGroup( btn->colorGroup(), sunken ? PushButtonDown :
PushButton ), sunken, roundButton(),
sunken ? PushButtonDown : PushButton, NULL );
// TODO if diw, draw fancy default button indicator
}
void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h,
bool round )
{
// round edge fills
static const QCOORD btm_left_fill[] = {
0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4, 1,
1, 2, 2, 2, 3, 2, 4, 2, 2, 3, 3, 3, 4, 3, 3, 4, 4, 4
};
@@ -994,658 +994,661 @@ widget = enabled ? down ? SunkenArrowRight : ArrowRight : DisArrowRight;
case Qt::DownArrow:
a.setPoints( 4, x, y, x2, y, x + w / 2, y2, x, y );
break;
case Qt::LeftArrow:
a.setPoints( 4, x2, y, x2, y2, x, y + h / 2, x2, y );
break;
default:
a.setPoints( 4, x, y, x, y2, x2, y + h / 2, x, y );
break;
}
QBrush oldBrush = p->brush();
QPen oldPen = p->pen();
p->setBrush( cg->brush( QColorGroup::Shadow ) );
p->setPen( cg->shadow() );
p->drawPolygon( a );
p->setBrush( oldBrush );
p->setPen( oldPen );
}
}
/* This is where we draw the borders and highlights. The new round button
* code is a pain in the arse. We don't want to be calculating arcs so
* use a whole lotta QPointArray's ;-) The code is made a lot more complex
* because you can have variable width border and highlights...
* I may want to cache this if round buttons are used, but am concerned
* about excessive cache misses. This is a memory/speed tradeoff that I
* have to test.
*/
void OThemeStyle::drawShade( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken, bool rounded,
int hWidth, int bWidth, ShadeStyle style )
{
int i, sc, bc, x2, y2;
QPen highPen, lowPen;
if ( style == Motif ) {
highPen.setColor( sunken ? g.dark() : g.light() );
lowPen.setColor( sunken ? g.light() : g.dark() );
}
else {
highPen.setColor( sunken ? g.shadow() : g.light() );
lowPen.setColor( sunken ? g.light() : g.shadow() );
}
// Advanced round buttons
if ( rounded && w > 19 && h > 19 ) {
x2 = x + w - 1, y2 = y + h - 1;
QPointArray bPntArray, hPntArray, lPntArray;
QPointArray bLineArray, hLineArray, lLineArray;
// borders
for ( i = 0, bc = 0; i < bWidth; ++i ) {
bPntArray.putPoints( bc, 24, x + 4, y + 1, x + 5, y + 1, x + 3, y + 2, x + 2, y + 3,
x + 1, y + 4, x + 1, y + 5, x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3,
x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2, x2 - 5, y2 - 1,
x2 - 4, y2 - 1, x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5,
x2 - 1, y2 - 4, x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1,
x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 );
bc += 24;
// ellispe edges don't match exactly, so fill in blanks
if ( i < bWidth - 1 || hWidth != 0 ) {
bPntArray.putPoints( bc, 20, x + 6, y + 1, x + 4, y + 2, x + 3, y + 3,
x + 2, y + 4, x + 1, y + 6, x2 - 6, y + 1, x2 - 4, y + 2,
x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6, x2 - 6, y2 - 1,
x2 - 4, y2 - 2, x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6,
x + 6, y2 - 1, x + 4, y2 - 2, x + 3, y2 - 3, x2 - 1, y + 6,
x2 - 2, y + 4 );
bc += 20;
}
bLineArray.putPoints( i * 8, 8, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6,
x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 );
++x, ++y;
--x2, --y2;
}
// highlights
for ( i = 0, sc = 0; i < hWidth; ++i ) {
hPntArray.putPoints( sc, 12, x + 4, y + 1, x + 5, y + 1, // top left
x + 3, y + 2, x + 2, y + 3, x + 1, y + 4, x + 1, y + 5,
x + 1, y2 - 5, x + 1, y2 - 4, x + 2, y2 - 3, // half corners
x2 - 5, y + 1, x2 - 4, y + 1, x2 - 3, y + 2 );
lPntArray.putPoints( sc, 12, x2 - 5, y2 - 1, x2 - 4, y2 - 1, // btm right
x2 - 3, y2 - 2, x2 - 2, y2 - 3, x2 - 1, y2 - 5, x2 - 1, y2 - 4,
x + 3, y2 - 2, x + 4, y2 - 1, x + 5, y2 - 1, //half corners
x2 - 2, y + 3, x2 - 1, y + 4, x2 - 1, y + 5 );
sc += 12;
if ( i < hWidth - 1 ) {
hPntArray.putPoints( sc, 10, x + 6, y + 1, x + 4, y + 2, // top left
x + 3, y + 3, x + 2, y + 4, x + 1, y + 6,
x2 - 6, y + 1, x2 - 4, y + 2, // half corners
x2 - 3, y + 3, x + 2, y2 - 4, x + 1, y2 - 6 );
lPntArray.putPoints( sc, 10, x2 - 6, y2 - 1, x2 - 4, y2 - 2, // btm right
x2 - 3, y2 - 3, x2 - 2, y2 - 4, x2 - 1, y2 - 6,
x + 6, y2 - 1, x + 4, y2 - 2, // half corners
x + 3, y2 - 3, x2 - 1, y + 6, x2 - 2, y + 4 );
sc += 10;
}
hLineArray.putPoints( i * 4, 4, x + 6, y, x2 - 6, y, x, y + 6, x, y2 - 6 );
lLineArray.putPoints( i * 4, 4, x + 6, y2, x2 - 6, y2, x2, y + 6, x2, y2 - 6 );
++x, ++y;
--x2, --y2;
}
p->setPen( Qt::black );
p->drawPoints( bPntArray );
p->drawLineSegments( bLineArray );
p->setPen( highPen );
p->drawPoints( hPntArray );
p->drawLineSegments( hLineArray );
p->setPen( lowPen );
p->drawPoints( lPntArray );
p->drawLineSegments( lLineArray );
}
// Rectangular buttons
else {
QPointArray highShade( hWidth * 4 );
QPointArray lowShade( hWidth * 4 );
p->setPen( g.shadow() );
for ( i = 0; i < bWidth && w > 2 && h > 2; ++i, ++x, ++y, w -= 2, h -= 2 )
p->drawRect( x, y , w, h );
if ( !hWidth )
return ;
x2 = x + w - 1, y2 = y + h - 1;
for ( i = 0; i < hWidth; ++i, ++x, ++y, --x2, --y2 ) {
highShade.putPoints( i * 4, 4, x, y, x2, y, x, y, x, y2 );
lowShade.putPoints( i * 4, 4, x, y2, x2, y2, x2, y, x2, y2 );
}
if ( style == Windows && hWidth > 1 ) {
p->setPen( highPen );
p->drawLineSegments( highShade, 0, 2 );
p->setPen( lowPen );
p->drawLineSegments( lowShade, 0, 2 );
p->setPen( ( sunken ) ? g.dark() : g.mid() );
p->drawLineSegments( highShade, 4 );
p->setPen( ( sunken ) ? g.mid() : g.dark() );
p->drawLineSegments( lowShade, 4 );
}
else {
p->setPen( ( sunken ) ? g.dark() : g.light() );
p->drawLineSegments( highShade );
p->setPen( ( sunken ) ? g.light() : g.dark() );
p->drawLineSegments( lowShade );
}
}
}
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 );
}
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;
if ( act ) {
if ( !dis )
discol = colorGroup( g, MenuItemDown ) ->text();
//discol = white;
QColorGroup g2( discol, g.highlight(),
white, white,
dis ? discol : white,
discol, white );
drawArrow( p, RightArrow, true,
x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2,
dim, dim, g2, TRUE );
}
else {
drawArrow( p, RightArrow,
false,
x + w - motifArrowHMargin - motifItemFrame - dim, y + h / 2 - dim / 2,
dim, dim, g, mi->isEnabled() );
}
}
}
void OThemeStyle::drawFocusRect( QPainter *p, const QRect &r,
const QColorGroup &g, const QColor *c,
bool atBorder )
{
p->setPen( g.dark() );
if ( !is3DFocus() )
QWindowsStyle::drawFocusRect( p, r, g, c, atBorder );
else {
int i = focusOffset();
p->drawLine( r.x() + i, r.y() + 1 + i, r.x() + i, r.bottom() - 1 - i );
p->drawLine( r.x() + 1 + i, r.y() + i, r.right() - 1 - i, r.y() + i );
p->setPen( g.light() );
p->drawLine( r.right() - i, r.y() + 1 + i, r.right() - i, r.bottom() - 1 - i );
p->drawLine( r.x() + 1 + i, r.bottom() - i, r.right() - 1 - i, r.bottom() - i );
}
}
#if 0
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 )
drawBaseButton( p, x, y, w, h, *cg, false, false, MenuBarItem );
//qDrawShadePanel(p, x, y, w, h, *cg, false, 1);
drawItem( p, x, y, w, h, AlignCenter | ShowPrefix | DontClip | SingleLine,
*cg, mi-> isEnabled ( ), mi->pixmap(), mi->text(),
-1, &btext );
}
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 * )
{
drawBaseButton( p, x, y, w, h, *colorGroup( g, ProgressBar ), false, false,
ProgressBar );
}
void OThemeStyle::getKProgressBackground( const QColorGroup &g, QBrush &bg )
{
const QColorGroup * cg = colorGroup( g, ProgressBg );
bg.setColor( cg->color( QColorGroup::Background ) );
if ( isPixmap( ProgressBg ) )
bg.setPixmap( *uncached( ProgressBg ) );
}
#endif
void OThemeStyle::tabbarMetrics( const QTabBar* t, int& hframe, int& vframe, int& overlap )
{
QCommonStyle::tabbarMetrics( t, hframe, vframe, overlap );
}
void OThemeStyle::drawTab( QPainter* p, const QTabBar* tb, QTab* t ,
bool selected )
{
WidgetType widget = selected ? ActiveTab : InactiveTab;
const QColorGroup *cg = colorGroup( tb->colorGroup(), widget );
int i;
int x = t->r.x(), y = t->r.y();
int x2 = t->r.right(), y2 = t->r.bottom();
int bWidth = borderWidth( widget );
int hWidth = highlightWidth( widget );
if ( tb->shape() == QTabBar::RoundedAbove ) {
if ( !selected ) {
p->fillRect( x, y, x2 - x + 1, 2,
tb->palette().normal().brush( QColorGroup::Background ) );
y += 2;
}
p->setPen( cg->text() );
i = 0;
if ( i < bWidth ) {
p->drawLine( x, y + 1, x, y2 );
p->drawLine( x2, y + 1, x2, y2 );
p->drawLine( x + 1, y, x2 - 1, y );
if ( selected ? activeTabLine() : inactiveTabLine() ) {
p->drawLine( x, y2, x2, y2 );
--y2;
}
++i, ++x, ++y, --x2;
}
for ( ; i < bWidth; ++i, ++x, ++y, --x2 ) {
p->drawLine( x, y, x, y2 );
p->drawLine( x2, y, x2, y2 );
p->drawLine( x, y, x2, y );
if ( selected ? activeTabLine() : inactiveTabLine() ) {
p->drawLine( x, y2, x2, y2 );
--y2;
}
}
i = 0;
if ( i < hWidth && bWidth == 0 ) {
p->setPen( cg->light() );
p->drawLine( x, y + 1, x, y2 );
p->drawLine( x + 1, y, x2 - 1, y );
p->setPen( cg->dark() );
p->drawLine( x2, y + 1, x2, y2 );
if ( selected ? activeTabLine() : inactiveTabLine() ) {
p->drawLine( x, y2, x2, y2 );
--y2;
}
++i, ++x, ++y, --x2;
}
for ( ; i < hWidth; ++i, ++x, ++y, --x2 ) {
p->setPen( cg->light() );
p->drawLine( x, y, x, y2 );
p->drawLine( x, y, x2, y );
p->setPen( cg->dark() );
p->drawLine( x2, y + 1, x2, y2 );
if ( selected ? activeTabLine() : inactiveTabLine() ) {
p->drawLine( x, y2, x2, y2 );
--y2;
}
}
if ( isPixmap( widget ) )
p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1,
*scalePixmap( x2 - x + 1, y2 - y + 1, widget ) );
else
p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() );
}
else if ( tb->shape() == QTabBar::RoundedBelow ) {
if ( !selected ) {
p->fillRect( x, y2 - 2, x2 - x + 1, 2,
tb->palette().normal().brush( QColorGroup::Background ) );
y2 -= 2;
}
p->setPen( cg->text() );
i = 0;
if ( i < bWidth ) {
p->drawLine( x, y, x, y2 - 1 );
p->drawLine( x2, y, x2, y2 - 1 );
p->drawLine( x + 1, y2, x2 - 1, y2 );
if ( selected ? activeTabLine() : inactiveTabLine() ) {
p->drawLine( x, y, x2, y );
++y;
}
}
for ( ; i < bWidth; ++i, ++x, --x2, --y2 ) {
p->drawLine( x, y, x, y2 );
p->drawLine( x2, y, x2, y2 );
p->drawLine( x, y2, x2, y2 );
if ( selected ? activeTabLine() : inactiveTabLine() ) {
p->drawLine( x, y, x2, y );
++y;
}
}
i = 0;
if ( i < hWidth && bWidth == 0 ) {
p->setPen( cg->dark() );
p->drawLine( x + 1, y2, x2 - 1, y2 );
p->drawLine( x2, y, x2, y2 - 1 );
p->setPen( cg->light() );
p->drawLine( x, y, x, y2 - 1 );
if ( selected ? activeTabLine() : inactiveTabLine() ) {
p->drawLine( x, y, x2, y );
++y;
}
++i, ++x, --x2, --y2;
}
for ( ; i < hWidth; ++i, ++x, --x2, --y2 ) {
p->setPen( cg->dark() );
p->drawLine( x, y2, x2, y2 );
p->drawLine( x2, y, x2, y2 );
p->setPen( cg->light() );
p->drawLine( x, y, x, y2 );
if ( selected ? activeTabLine() : inactiveTabLine() ) {
p->drawLine( x, y, x2, y );
++y;
}
}
if ( isPixmap( widget ) )
p->drawTiledPixmap( x, y, x2 - x + 1, y2 - y + 1,
*scalePixmap( x2 - x + 1, y2 - y + 1, widget ) );
else
p->fillRect( x, y, x2 - x + 1, y2 - y + 1, cg->background() );
}
else
QCommonStyle::drawTab( p, tb, t, selected );
}
void OThemeStyle::drawTabMask( QPainter* p, const QTabBar* tb, QTab* t,
bool selected )
{
QRect r( t->r );
if ( tb->shape() == QTabBar::RoundedAbove ) {
if ( !selected )
r.setTop( r.top() + 2 );
p->drawLine( r.left() + 1, r.top(), r.right() - 1, r.top() );
QBrush b( color1, SolidPattern );
p->fillRect( r.left(), r.top() + 1, r.width(), r.height() - 1, b );
}
else if ( tb->shape() == QTabBar::RoundedBelow ) {
if ( !selected )
r.setBottom( r.bottom() - 2 );
p->drawLine( r.left() + 1, r.bottom(), r.right() - 1, r.bottom() );
QBrush b( color1, SolidPattern );
p->fillRect( r.left(), r.top(), r.width(), r.height() - 1, b );
}
else
QCommonStyle::drawTabMask( p, tb, t, selected );
}
//#include "kthemestyle.moc"
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,237 +1,246 @@
/*
* 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;
int sliderEnd = sliderStart + sliderLength;
int addX, addY;
int subX, subY;
int subPageX, subPageY, subPageW, subPageH;
int addPageX, addPageY, addPageW, addPageH;
int sliderX, sliderY, sliderW, sliderH;
if (horizontal)
{
subY = 0;
addY = 0;
subX = 0;
addX = buttonDim;
subPageX = buttonDim * 2;
subPageY = 0;
subPageW = sliderStart - 1;
subPageH = extent;
addPageX = sliderEnd;
addPageY = 0;
addPageW = len - sliderEnd;
addPageH = extent;
sliderX = sliderStart;
sliderY = 0;
sliderW = sliderLength;
sliderH = extent;
}
else
{
subX = 0;
addX = 0;
subY = len - buttonDim * 2;
addY = len - buttonDim;
subPageX = 0;
subPageY = 0;
subPageW = extent;
subPageH = sliderStart;
addPageX = 0;
addPageY = sliderEnd;
addPageW = extent;
addPageH = subY - sliderEnd;
sliderX = 0;
sliderY = sliderStart;
sliderW = extent;
sliderH = sliderLength;
}
rSub .setRect( subX, subY, buttonDim, buttonDim);
rAdd .setRect( addX, addY, buttonDim, buttonDim);
rSubPage .setRect(subPageX, subPageY, subPageW, subPageH);
rAddPage .setRect(addPageX, addPageY, addPageW, addPageH);
rSlider .setRect( sliderX, sliderY, sliderW, sliderH);
}
// Rounded rects my way.
static void
drawFunkyRect
(
QPainter * p,
int x,
int y,
int w,
int h,
bool small
)
{
p->translate(x, y);
if (small)
{
p->drawLine( 2, 0, w - 3, 0 );
p->drawLine( w - 1, 2, w - 1, h - 3 );
p->drawLine( w - 3, h - 1, 2, h - 1 );
p->drawLine( 0, h - 3, 0, 2 );
// Use an array of points so that there's only one round-trip with the
// X server.
QCOORD pointList[] =
{
1, 1,
w - 2, 1,
w - 2, h - 2,
1, h - 2
};
p->drawPoints(QPointArray(4, pointList));
}
else
{
p->drawLine( 3, 0, w - 4, 0 );
p->drawLine( w - 1, 3, w - 1, h - 4 );
p->drawLine( w - 4, h - 1, 3, h - 1 );
p->drawLine( 0, h - 4, 0, 3 );
QCOORD pointList[] =
{
1, 2,
2, 1,
w - 3, 1,
w - 2, 2,
w - 2, h - 3,
w - 3, h - 2,
2, h - 2,
1, h - 3
};
p->drawPoints(QPointArray(8, pointList));
}
p->translate(-x, -y);
}
WebStyle::WebStyle()
: QWindowsStyle()
{
setButtonDefaultIndicatorWidth(1);
setScrollBarExtent(_scrollBarExtent, _scrollBarExtent);
setButtonMargin( 3 );
setSliderThickness(_scrollBarExtent );
}
WebStyle::~WebStyle()
{
// Empty.
}
void
WebStyle::polish(QApplication *)
{
// Empty.
}
void
WebStyle::polish(QPalette &)
{
// Empty.
@@ -780,404 +789,515 @@ WebStyle::drawIndicatorMask
int x,
int y,
int w,
int h,
int /* state */
)
{
p->fillRect(x, y, w, h, Qt::color1);
}
void
WebStyle::drawExclusiveIndicatorMask
(
QPainter * p,
int x,
int y,
int w,
int h,
bool /* on */
)
{
if (0 == w % 2)
--w;
if (0 == h % 2)
--h;
p->setPen(Qt::color1);
p->setBrush(Qt::color1);
p->drawEllipse(x, y, w, h);
}
void
WebStyle::drawComboButton
(
QPainter * p,
int x,
int y,
int w,
int h,
const QColorGroup & g,
bool sunken,
bool editable,
bool enabled,
const QBrush * fill
)
{
p->save();
p->setPen(NoPen);
p->setBrush(0 == fill ? g.brush(QColorGroup::Background) : *fill);
p->drawRect(x, y, w, h);
if (enabled)
{
if (sunken)
p->setPen(contrastingForeground(g.highlight(), g.background()));
else
p->setPen(contrastingForeground(g.mid(), g.background()));
}
else
{
p->setPen(contrastingForeground(g.mid(), g.background()));
}
drawFunkyRect(p, x, y, w, h, true);
p->drawPoint(w - 10, h - 6);
p->drawPoint(w - 9, h - 6);
p->drawPoint(w - 8, h - 6);
p->drawPoint(w - 7, h - 6);
p->drawPoint(w - 6, h - 6);
p->drawPoint(w - 9, h - 7);
p->drawPoint(w - 8, h - 7);
p->drawPoint(w - 7, h - 7);
p->drawPoint(w - 6, h - 7);
p->drawPoint(w - 8, h - 8);
p->drawPoint(w - 7, h - 8);
p->drawPoint(w - 6, h - 8);
p->drawPoint(w - 7, h - 9);
p->drawPoint(w - 6, h - 9);
p->drawPoint(w - 6, h - 10);
if (editable)
p->fillRect(comboButtonFocusRect(x, y, w, h), Qt::red);
p->restore();
}
QRect
WebStyle::comboButtonRect(int x, int y, int w, int h)
{
return QRect(x + 2, y + 2, w - 20, h - 4);
}
QRect
WebStyle::comboButtonFocusRect(int x, int y, int w, int h)
{
return QRect(x + 2, y + 2, w - 20, h - 4);
}
int
WebStyle::sliderLength() const
{
return 13;
}
void
WebStyle::drawSliderGroove
(
QPainter * p,
int x,
int y,
int w,
int h,
const QColorGroup & g,
QCOORD /* c */,
Orientation o
)
{
p->save();
p->setPen(QPen(g.dark(), 0, Qt::DotLine));
if( o == Qt::Horizontal )
p->drawLine(x, y + h / 2, w, y + h / 2);
else
if( o == Qt::Vertical )
p->drawLine(x + w / 2, y, x + w / 2, h);
p->restore();
}
void
WebStyle::drawArrow
(
QPainter * p,
Qt::ArrowType type,
bool down,
int x,
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());
p->setBrush(0 == fill ? NoBrush : *fill);
p->drawRect(x, y, w, h);
p->restore();
}
void
WebStyle::drawPopupPanel
(
QPainter * p,
int x,
int y,
int w,
int h,
const QColorGroup & g,
int /* lineWidth */,
const QBrush * fill
)
{
p->save();
p->setPen(g.dark());
p->setBrush(0 == fill ? NoBrush : *fill);
p->drawRect(x, y, w, h);
p->restore();
}
void
WebStyle::drawSeparator
(
QPainter * p,
int x,
int y,
int w,
int h,
const QColorGroup & g,
bool /* sunken */,
int /* lineWidth */,
int /* midLineWidth */
)
{
p->save();
p->setPen(g.dark());
if (w > h)
{
p->drawLine(x, y + h / 2, x + w, y + h / 2);
}
else
{
p->drawLine(x + w / 2, y, x + w / 2, y + h);
}
p->restore();
}
void
WebStyle::drawTab
(
QPainter * p,
const QTabBar * tabBar,
QTab * tab,
bool selected
)
{
QRect r(tab->rect());
QColorGroup g(tabBar->colorGroup());
p->save();
p->setPen(selected ? g.dark() : g.mid());
p->fillRect(r, g.brush(QColorGroup::Background));
switch (tabBar->shape())
{
case QTabBar::RoundedAbove:
case QTabBar::TriangularAbove:
p->drawLine(r.left(), r.top(), r.left(), r.bottom());
p->drawLine(r.left(), r.top(), r.right(), r.top());
p->drawLine(r.right(), r.top(), r.right(), r.bottom());
if (!selected)
{
p->setPen(g.dark());
p->drawLine(r.left(), r.bottom(), r.right(), r.bottom());
}
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
@@ -26,274 +26,274 @@
class QPainter;
class QScrollBar;
class QPushButton;
class QWidget;
class WebStyle : public QWindowsStyle {
public:
WebStyle();
~WebStyle();
void polish(QApplication *);
void unPolish(QWidget *);
void polish(QWidget *);
void polish(QPalette &);
void unPolish(QApplication *);
void drawButton
(
QPainter * p,
int x,
int y,
int w,
int h,
const QColorGroup & g,
bool sunken = false,
const QBrush * fill = 0
);
QRect buttonRect(int x, int y, int w, int h);
void drawBevelButton
(
QPainter *,
int x,
int y,
int w,
int h,
const QColorGroup &,
bool sunken = false,
const QBrush * fill = 0
);
void drawPushButton(QPushButton *, QPainter *);
virtual void drawPushButtonLabel(QPushButton *, QPainter *);
void drawScrollBarControls
(
QPainter *,
const QScrollBar *,
int sliderStart,
uint controls,
uint activeControl
);
QStyle::ScrollControl scrollBarPointOver
(
const QScrollBar *,
int sliderStart,
const QPoint &
);
void scrollBarMetrics
(
const QScrollBar *,
int & sliderMin,
int & sliderMax,
int & sliderLength,
int & buttonDim
);
QSize indicatorSize() const;
void drawIndicator
(
QPainter *,
int x,
int y,
int w,
int h,
const QColorGroup &,
int state,
bool down = false,
bool enabled = true
);
QSize exclusiveIndicatorSize() const;
void drawExclusiveIndicator
(
QPainter *,
int x,
int y,
int w,
int h,
const QColorGroup &,
bool on,
bool down = false,
bool enabled = true
);
void drawIndicatorMask
(
QPainter *,
int x,
int y,
int w,
int h,
int state
);
void drawExclusiveIndicatorMask
(
QPainter *,
int x,
int y,
int w,
int h,
bool on
);
void drawComboButton
(
QPainter *,
int x,
int y,
int w,
int h,
const QColorGroup &,
bool sunken = false,
bool editable = false,
bool enabled = true,
const QBrush * fill = 0
);
QRect comboButtonRect(int x, int y, int w, int h);
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,
int y,
int w,
int h,
const QColorGroup &,
bool sunken = true,
int lineWidth = 1,
int midLineWidth = 0
);
void drawTab
(
QPainter * p,
const QTabBar * tabBar,
QTab * tab,
bool selected
);
void drawTabMask
(
QPainter * p,
const QTabBar *,
QTab * tab,
bool
);
int popupMenuItemHeight(bool, QMenuItem *, const QFontMetrics &);
GUIStyle guiStyle() const { return Qt::MotifStyle; }
bool eventFilter(QObject *, QEvent *);
};
#endif