00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
#include <qstyle.h>
00021
00022
#include <kdebug.h>
00023
#include <kapplication.h>
00024
00025
#include "kseparator.moc"
00026
00027
00028 KSeparator::KSeparator(
QWidget* parent,
const char* name, WFlags f)
00029 :
QFrame(parent, name, f)
00030 {
00031 setLineWidth(1);
00032 setMidLineWidth(0);
00033
setOrientation( HLine );
00034 }
00035
00036
00037
00038 KSeparator::KSeparator(
int orientation,
QWidget* parent,
const char* name, WFlags f)
00039 :
QFrame(parent, name, f)
00040 {
00041 setLineWidth(1);
00042 setMidLineWidth(0);
00043
setOrientation( orientation );
00044 }
00045
00046
00047
00048 void KSeparator::setOrientation(
int orientation)
00049 {
00050
switch(orientation)
00051 {
00052
case Vertical:
00053
case VLine:
00054 setFrameStyle( QFrame::VLine | QFrame::Sunken );
00055 setMinimumSize(2, 0);
00056
break;
00057
00058
default:
00059
kdWarning() <<
"KSeparator::setOrientation(): invalid orientation, using default orientation HLine" <<
endl;
00060
00061
case Horizontal:
00062
case HLine:
00063 setFrameStyle( QFrame::HLine | QFrame::Sunken );
00064 setMinimumSize(0, 2);
00065
break;
00066 }
00067 }
00068
00069
00070
00071
int KSeparator::orientation()
const
00072
{
00073
if ( frameStyle() & VLine )
00074
return VLine;
00075
00076
if ( frameStyle() & HLine )
00077
return HLine;
00078
00079
return 0;
00080 }
00081
00082 void KSeparator::drawFrame(
QPainter *p)
00083 {
00084
QPoint p1, p2;
00085
QRect r = frameRect();
00086
const QColorGroup & g = colorGroup();
00087
00088
if ( frameStyle() & HLine ) {
00089 p1 =
QPoint( r.x(), r.height()/2 );
00090 p2 =
QPoint( r.x()+r.width(), p1.y() );
00091 }
00092
else {
00093 p1 =
QPoint( r.x()+r.width()/2, 0 );
00094 p2 =
QPoint( p1.x(), r.height() );
00095 }
00096
00097
QStyleOption opt( lineWidth(), midLineWidth() );
00098 style().drawPrimitive( QStyle::PE_Separator, p,
QRect( p1, p2 ), g,
00099 QStyle::Style_Sunken, opt );
00100 }
00101
00102
00103 QSize KSeparator::sizeHint()
const
00104
{
00105
if ( frameStyle() & VLine )
00106
return QSize(2, 0);
00107
00108
if ( frameStyle() & HLine )
00109
return QSize(0, 2);
00110
00111
return QSize(-1, -1);
00112 }
00113
00114
void KSeparator::virtual_hook(
int,
void* )
00115 { }
00116