libopie API Documentation

otabbar.cpp

00001 /*
00002                             This file is part of the Opie Project
00003 
00004                              Copyright (c)  2002 Dan Williams <williamsdr@acm.org>
00005               =.
00006             .=l.
00007            .>+-=
00008  _;:,     .>    :=|.         This program is free software; you can
00009 .> <`_,   >  .   <=          redistribute it and/or  modify it under
00010 :`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
00011 .="- .-=="i,     .._         License as published by the Free Software
00012  - .   .-<_>     .<>         Foundation; either version 2 of the License,
00013      ._= =}       :          or (at your option) any later version.
00014     .%`+i>       _;_.
00015     .i_,=:_.      -<s.       This program is distributed in the hope that
00016      +  .  -:.       =       it will be useful,  but WITHOUT ANY WARRANTY;
00017     : ..    .:,     . . .    without even the implied warranty of
00018     =_        +     =;=|`    MERCHANTABILITY or FITNESS FOR A
00019   _.=:.       :    :=>`:     PARTICULAR PURPOSE. See the GNU
00020 ..}^=.=       =       ;      Library General Public License for more
00021 ++=   -.     .`     .:       details.
00022  :     =  ...= . :.=-
00023  -.   .:....=;==+<;          You should have received a copy of the GNU
00024   -_. . .   )=.  =           Library General Public License along with
00025     --        :-=`           this library; see the file COPYING.LIB.
00026                              If not, write to the Free Software Foundation,
00027                              Inc., 59 Temple Place - Suite 330,
00028                              Boston, MA 02111-1307, USA.
00029 
00030 */
00031 
00032 #include "otabbar.h"
00033 
00034 OTabBar::OTabBar( QWidget *parent , const char *name  )
00035      : QTabBar( parent, name )
00036 {
00037 }
00038 
00039 void OTabBar::paintLabel( QPainter* p, const QRect& br, QTab* t, bool has_focus ) const
00040 {
00041 
00042     QRect r = br;
00043     if ( t->iconset)
00044     {
00045         QIconSet::Mode mode = (t->enabled && isEnabled()) ? QIconSet::Normal : QIconSet::Disabled;
00046         if ( mode == QIconSet::Normal && has_focus ) {
00047             mode = QIconSet::Active;
00048         }
00049         QPixmap pixmap = t->iconset->pixmap( QIconSet::Small, mode );
00050         int pixw = pixmap.width();
00051         int pixh = pixmap.height();
00052         r.setLeft( r.left() + pixw + 2 );
00053         p->drawPixmap( br.left()+2, br.center().y()-pixh/2, pixmap );
00054     }
00055 
00056     QRect tr = r;
00057     if ( t->id == currentTab() )
00058     {
00059         tr.setBottom( tr.bottom() - style().defaultFrameWidth() );
00060     }
00061 
00062     if ( t->enabled && isEnabled()  )
00063     {
00064         p->setPen( colorGroup().foreground() );
00065         p->drawText( tr, AlignCenter | ShowPrefix, t->label );
00066     }
00067     else if ( style() == MotifStyle )
00068     {
00069         p->setPen( palette().disabled().foreground() );
00070         p->drawText( tr, AlignCenter | ShowPrefix, t->label );
00071     }
00072     else
00073     {
00074         p->setPen( colorGroup().light() );
00075         QRect wr = tr;
00076         wr.moveBy( 1, 1 );
00077         p->drawText( wr, AlignCenter | ShowPrefix, t->label );
00078         p->setPen( palette().disabled().foreground() );
00079         p->drawText( tr, AlignCenter | ShowPrefix, t->label );
00080     }
00081 }
KDE Logo
This file is part of the documentation for OPIE Version 1.1.
Documentation copyright © 1997-2003 the KDE developers. 2003 OPIE developers
Generated on Tue Feb 10 20:24:45 2004 by doxygen 1.3.5 written by Dimitri van Heesch, © 1997-2001