Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

oseparator.cpp

Go to the documentation of this file.
00001 /*
00002                              This file is part of the Opie Project
00003                              Copyright (C) 2003 Michael 'Mickey' Lauer <mickey@tm.informatik.uni-frankfurt.de>
00004                              Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
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 /* OPIE */
00033 
00034 #include <opie2/odebug.h>
00035 #include <opie2/oseparator.h>
00036 
00037 /* QT */
00038 
00039 using namespace Opie::Core;
00040 using namespace Opie::Ui;
00041 
00042 OSeparator::OSeparator(QWidget* parent, const char* name, WFlags f)
00043    : QFrame(parent, name, f)
00044 {
00045    setLineWidth(1);
00046    setMidLineWidth(0);
00047    setOrientation( HLine );
00048 }
00049 
00050 
00051 
00052 OSeparator::OSeparator(int orientation, QWidget* parent, const char* name, WFlags f)
00053    : QFrame(parent, name, f)
00054 {
00055    setLineWidth(1);
00056    setMidLineWidth(0);
00057    setOrientation( orientation );
00058 }
00059 
00060 
00061 
00062 void OSeparator::setOrientation(int orientation)
00063 {
00064    switch(orientation)
00065    {
00066       case Vertical:
00067       case VLine:
00068          setFrameStyle( QFrame::VLine | QFrame::Sunken );
00069          setMinimumSize(2, 0);
00070          break;
00071       
00072       default:
00073          owarn << "OSeparator::setOrientation(): invalid orientation, using default orientation HLine" << oendl;
00074          
00075       case Horizontal:
00076       case HLine:
00077          setFrameStyle( QFrame::HLine | QFrame::Sunken );
00078          setMinimumSize(0, 2);
00079          break;
00080    }
00081 }
00082 
00083 
00084 
00085 int OSeparator::orientation() const
00086 {
00087    if ( frameStyle() & VLine )
00088       return VLine;
00089    
00090    if ( frameStyle() & HLine )
00091       return HLine;
00092    
00093    return 0;
00094 }
00095 
00096 void OSeparator::drawFrame(QPainter *p)
00097 {
00098    QPoint       p1, p2;
00099    QRect        r     = frameRect();
00100    const QColorGroup & g = colorGroup();
00101 
00102    if ( frameStyle() & HLine ) {
00103       p1 = QPoint( r.x(), r.height()/2 );
00104       p2 = QPoint( r.x()+r.width(), p1.y() );
00105    }
00106    else {
00107       p1 = QPoint( r.x()+r.width()/2, 0 );
00108       p2 = QPoint( p1.x(), r.height() );
00109    }
00110 
00111 #if QT_VERSION < 0x030000
00112    style().drawSeparator( p, p1.x(), p1.y(), p2.x(), p2.y(), g, true, 1, midLineWidth() );
00113 #else
00114    QStyleOption opt( lineWidth(), midLineWidth() );
00115    style().drawPrimitive( QStyle::PE_Separator, p, QRect( p1, p2 ), g, QStyle::Style_Sunken, opt );
00116 #endif
00117 }
00118 
00119 
00120 QSize OSeparator::sizeHint() const
00121 {
00122    if ( frameStyle() & VLine )
00123       return QSize(2, 0);
00124    
00125    if ( frameStyle() & HLine )
00126       return QSize(0, 2);
00127    
00128    return QSize(-1, -1);
00129 }

Generated on Sat Nov 5 16:16:27 2005 for OPIE by  doxygen 1.4.2