summaryrefslogtreecommitdiff
authorleseb <leseb>2002-07-02 21:23:40 (UTC)
committer leseb <leseb>2002-07-02 21:23:40 (UTC)
commitd83f58a1a4a314a3ef8b25dd78432488922a9e31 (patch) (side-by-side diff)
tree353b815ff13bb34594fa8db4d15233ed6b8c27e4
parent2481ac4013794f95c53580f99b4b761142e4ee8f (diff)
downloadopie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.zip
opie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.tar.gz
opie-d83f58a1a4a314a3ef8b25dd78432488922a9e31.tar.bz2
Fix QToolButton drawing
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--noncore/styles/theme/othemestyle.cpp8
-rw-r--r--noncore/styles/theme/othemestyle.h6
2 files changed, 14 insertions, 0 deletions
diff --git a/noncore/styles/theme/othemestyle.cpp b/noncore/styles/theme/othemestyle.cpp
index 61127b8..d97b026 100644
--- a/noncore/styles/theme/othemestyle.cpp
+++ b/noncore/styles/theme/othemestyle.cpp
@@ -248,128 +248,136 @@ void OThemeStyle::drawBaseMask( QPainter *p, int x, int y, int w, int h,
static const QCOORD btm_right_fill[] = {
0, 0, 1, 0, 2, 0, 3, 0, 4, 0, 0, 1, 1, 1, 2, 1, 3, 1, 4,
1, 0, 2, 1, 2, 2, 2, 3, 2, 0, 3, 1, 3, 2, 3, 0, 4, 1, 4
};
static const QCOORD top_left_fill[] = {
3, 0, 4, 0, 2, 1, 3, 1, 4, 1, 1, 2, 2, 2, 3, 2, 4, 2, 0, 3,
1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4
};
static const QCOORD top_right_fill[] = {
0, 0, 1, 0, 0, 1, 1, 1, 2, 1, 0, 2, 1, 2, 2, 2, 3, 2, 0,
3, 1, 3, 2, 3, 3, 3, 4, 3, 0, 4, 1, 4, 2, 4, 3, 4, 4, 4
};
QBrush fillBrush( color1, SolidPattern );
p->setPen( color1 );
if ( round && w > 19 && h > 19 ) {
int x2 = x + w - 1;
int y2 = y + h - 1;
QPointArray a( QCOORDARRLEN( top_left_fill ), top_left_fill );
a.translate( 1, 1 );
p->drawPoints( a );
a.setPoints( QCOORDARRLEN( btm_left_fill ), btm_left_fill );
a.translate( 1, h - 6 );
p->drawPoints( a );
a.setPoints( QCOORDARRLEN( top_right_fill ), top_right_fill );
a.translate( w - 6, 1 );
p->drawPoints( a );
a.setPoints( QCOORDARRLEN( btm_right_fill ), btm_right_fill );
a.translate( w - 6, h - 6 );
p->drawPoints( a );
p->fillRect( x + 6, y, w - 12, h, fillBrush );
p->fillRect( x, y + 6, x + 6, h - 12, fillBrush );
p->fillRect( x2 - 6, y + 6, x2, h - 12, fillBrush );
p->drawLine( x + 6, y, x2 - 6, y );
p->drawLine( x + 6, y2, x2 - 6, y2 );
p->drawLine( x, y + 6, x, y2 - 6 );
p->drawLine( x2, y + 6, x2, y2 - 6 );
}
else
p->fillRect( x, y, w, h, fillBrush );
}
void OThemeStyle::drawButtonMask( QPainter *p, int x, int y, int w, int h )
{
drawBaseMask( p, x, y, w, h, roundButton() );
}
void OThemeStyle::drawComboButtonMask( QPainter *p, int x, int y, int w, int h )
{
drawBaseMask( p, x, y, w, h, roundComboBox() );
}
void OThemeStyle::drawBevelButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
const QBrush * )
{
WidgetType type = sunken ? BevelDown : Bevel;
drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type );
}
+void OThemeStyle::drawToolButton( QPainter *p, int x, int y, int w, int h,
+ const QColorGroup &g, bool sunken,
+ const QBrush * )
+{
+ WidgetType type = sunken ? ToolButtonDown : ToolButton;
+ drawBaseButton( p, x, y, w, h, *colorGroup( g, type ), sunken, false, type );
+}
+
#if 0
void OThemeStyle::drawKToolBarButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken,
bool raised, bool enabled, bool popup,
KToolButtonType type, const QString &btext,
const QPixmap *pixmap, QFont *font,
QWidget * )
{
QFont tmp_font( QString::fromLatin1( "Helvetica" ), 10 );
if ( font )
tmp_font = *font;
QFontMetrics fm( tmp_font );
WidgetType widget = sunken ? ToolButtonDown : ToolButton;
drawBaseButton( p, x, y, w, h, *colorGroup( g, widget ), sunken, false,
widget );
int dx, dy;
if ( type == Icon ) { // icon only
if ( pixmap ) {
dx = ( w - pixmap->width() ) / 2;
dy = ( h - pixmap->height() ) / 2;
if ( sunken ) {
++dx;
++dy;
}
p->drawPixmap( x + dx, y + dy, *pixmap );
}
}
else if ( type == IconTextRight ) { // icon and text (if any)
if ( pixmap ) {
dx = 4;
dy = ( h - pixmap->height() ) / 2;
if ( sunken ) {
++dx;
++dy;
}
p->drawPixmap( x + dx, y + dy, *pixmap );
}
if ( !btext.isNull() ) {
int tf = AlignVCenter | AlignLeft;
if ( pixmap )
dx = 4 + pixmap->width() + 2;
else
dx = 4;
dy = 0;
if ( sunken ) {
++dx;
++dy;
}
if ( font )
p->setFont( *font );
if ( raised )
p->setPen( KGlobalSettings::toolBarHighlightColor() );
p->drawText( x + dx, y + dy, w - dx, h, tf, btext );
}
}
else if ( type == Text ) { // only text, even if there is a icon
if ( !btext.isNull() ) {
int tf = AlignTop | AlignLeft;
if ( !enabled )
p->setPen( g.dark() );
dx = ( w - fm.width( btext ) ) / 2;
dy = ( h - fm.lineSpacing() ) / 2;
if ( sunken ) {
diff --git a/noncore/styles/theme/othemestyle.h b/noncore/styles/theme/othemestyle.h
index 02bec78..52445c4 100644
--- a/noncore/styles/theme/othemestyle.h
+++ b/noncore/styles/theme/othemestyle.h
@@ -48,128 +48,134 @@ public:
* @param configFile A KConfig file to use as the theme configuration.
* Defaults to ~/.kderc.
*/
OThemeStyle( const QString &configFile = QString::null );
~OThemeStyle();
virtual void polish( QWidget* );
virtual void unPolish( QWidget* );
/**
* By default this just sets the background brushes to the pixmapped
* background.
*/
virtual void polish( QApplication *app );
virtual void unPolish( QApplication* );
/// @internal
// to make it possible for derived classes to overload this function
virtual void polish( QPalette& pal );
/**
* This is a convenience method for drawing widgets with
* borders, highlights, pixmaps, colors, etc...
* You specify the widget type and it will draw it according to the
* config file settings.
*
* @param p The QPainter to draw on.
* @param g The color group to use.
* @param rounded @p true if the widget is rounded, @p false if rectangular.
* @param type The widget type to paint.
* @param fill An optional fill brush. Currently ignored (the config file
* is used instead).
*/
virtual void drawBaseButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken = FALSE,
bool rounded = FALSE, WidgetType type = Bevel,
const QBrush *fill = 0 );
/**
* Draw a mask with for widgets that may be rounded.
*
*Currently used
* by pushbuttons and comboboxes.
*
* @param p The QPainter to draw on.
* @param rounded @p true if the widget is rounded, @p false if rectangular.
*/
virtual void drawBaseMask( QPainter *p, int x, int y, int w, int h,
bool rounded );
/**
* Draw a pushbutton.
*
* This calls @ref drawBaseButton() with @p PushButton as the
* widget type.
*/
virtual void drawButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken = FALSE,
const QBrush *fill = 0 );
/**
* Draw a bevel button.
*
* This calls @ref drawBaseButton() with Bevel as the
* widget type.
*/
virtual void drawBevelButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken = FALSE,
const QBrush *fill = 0 );
+ /**
+ * Draw a toolbar button.
+ */
+ virtual void drawToolButton ( QPainter *p, int x, int y, int w, int h,
+ const QColorGroup &g, bool sunken = FALSE,
+ const QBrush *fill = 0 );
#if 0
/**
* Draw a toolbar button.
*/
virtual void drawKToolBarButton( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, bool sunken = false,
bool raised = true, bool enabled = true,
bool popup = false, KToolButtonType type = Icon,
const QString &btext = QString::null,
const QPixmap *icon = NULL,
QFont *font = NULL, QWidget *btn = NULL );
/**
* Draw the handle used in toolbars.
*/
void drawKBarHandle( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g,
KToolBarPos type, QBrush *fill = NULL );
/**
* Draw a toolbar.
*/
void drawKToolBar( QPainter *p, int x, int y, int w, int h,
const QColorGroup &g, KToolBarPos type,
QBrush *fill = NULL );
#endif
/**
* Return the space available in a pushbutton, taking configurable
* borders and highlights into account.
*/
virtual QRect buttonRect( int x, int y, int w, int h );
/**
* Draw an arrow in the style specified by the config file.
*/
virtual void drawArrow( QPainter *p, Qt::ArrowType type, bool down,
int x, int y, int w, int h, const QColorGroup &g,
bool enabled = true, const QBrush *fill = 0 );
/**
* Return the size of the exclusive indicator pixmap if one is specified
* in the config file, otherwise it uses the base style's size.
*/
virtual QSize exclusiveIndicatorSize() const;
/**
* Draw an exclusive indicator widget.
*
* If a pixmap is specified in the
* config file that is used, otherwise the base style's widget is drawn.
*/
virtual void drawExclusiveIndicator( QPainter* p, int x, int y, int w,
int h, const QColorGroup &g, bool on,
bool down = FALSE,
bool enabled = TRUE );
/**
* Set the mask of an exclusive indicator widget.
*
* If a pixmap is specified
* it is masked according to it's transparent pixels, otherwise the
* base style's mask is used.
*/
virtual void drawExclusiveIndicatorMask( QPainter *p, int x, int y, int w,
int h, bool on );
/**
* Set the mask of an indicator widget.
*
* If a pixmap is specified