# kdeui Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Namespaces | Source Files

# kseparator.cpp

    00001 /*
    00002  *   Copyright (C) 1997  Michael Roth <mroth@wirlweb.de>
    00003  *
    00004  *   This program is free software; you can redistribute it and/or modify
    00005  *   it under the terms of the GNU Library General Public License as published by
    00006  *   the Free Software Foundation; either version 2 of the License, or
    00007  *   (at your option) any later version.
    00008  *
    00009  *   This program is distributed in the hope that it will be useful,
    00010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
    00011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    00012  *   GNU Library General Public License for more details.
    00013  *
    00014  *   You should have received a copy of the GNU Library General Public License
    00015  *   along with this program; if not, write to the Free Software
    00016  *   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
    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 { /*BASE::virtual_hook( id, data );*/ }
    00116

This file is part of the documentation for kdeui Library Version 3.4.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sat Jun 11 20:20:22 2005 by doxygen 1.4.1 written by Dimitri van Heesch, © 1997-2003