2
* Copyright (C) 1997 Michael Roth <mroth@wirlweb.de>
4
* This program is free software; you can redistribute it and/or modify
5
* it under the terms of the GNU Library General Public License as published by
6
* the Free Software Foundation; either version 2 of the License, or
7
* (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU Library General Public License for more details.
14
* You should have received a copy of the GNU Library General Public License
15
* along with this program; if not, write to the Free Software
16
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19
#include "kseparator.h"
21
#include <QtGui/QStyle>
22
#include <QtGui/QStyleOption>
24
KSeparator::KSeparator( QWidget* parent, Qt::WFlags f )
29
setOrientation( HLine );
34
KSeparator::KSeparator( int orientation, QWidget* parent, Qt::WFlags f )
39
setOrientation( orientation );
44
void KSeparator::setOrientation( int orientation )
46
switch ( orientation )
50
setFrameStyle( QFrame::VLine | QFrame::Sunken );
51
setMinimumSize( 2, 0 );
55
qDebug( "KSeparator::setOrientation(): invalid orientation, using default orientation HLine" );
59
setFrameStyle( QFrame::HLine | QFrame::Sunken );
60
setMinimumSize( 0, 2 );
67
int KSeparator::orientation() const
69
if ( frameStyle() & VLine )
72
if ( frameStyle() & HLine )
78
void KSeparator::drawFrame( QPainter *p )
81
QRect r = frameRect();
83
if ( frameStyle() & HLine )
85
p1 = QPoint( r.x(), r.height() / 2 );
86
p2 = QPoint( r.x() + r.width(), p1.y() );
90
p1 = QPoint( r.x() + r.width() / 2, 0 );
91
p2 = QPoint( p1.x(), r.height() );
94
QStyleOption opt( lineWidth(), midLineWidth() );
95
opt.state = QStyle::State_Sunken;
96
style()->drawPrimitive( QStyle::PE_IndicatorToolBarSeparator, &opt, p );
100
QSize KSeparator::sizeHint() const
102
if ( frameStyle() & VLine )
103
return QSize( 2, 0 );
105
if ( frameStyle() & HLine )
106
return QSize( 0, 2 );
108
return QSize( -1, -1 );
111
void KSeparator::virtual_hook( int, void* )
112
{ /*BASE::virtual_hook( id, data );*/ }