~ubuntu-branches/ubuntu/maverick/uim/maverick

« back to all changes in this revision

Viewing changes to qt4/chardict/kseparator.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Fabrice Coutadeur
  • Date: 2010-01-22 17:44:19 UTC
  • mfrom: (1.1.12 upstream) (7.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20100122174419-jvzfjkrbwv21kv0x
Tags: 1:1.5.7-2ubuntu1
* Merge from debian/unstable. No remaining changes.
* debian/control: added build dependency on libgnomeui-dev. This is mandatory
  to build the Gnome applet and fixes a FTBFS

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
*   Copyright (C) 1997  Michael Roth <mroth@wirlweb.de>
 
3
*
 
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.
 
8
*
 
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.
 
13
*
 
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.
 
17
*
 
18
*/
 
19
#include "kseparator.h"
 
20
 
 
21
#include <QtGui/QStyle>
 
22
#include <QtGui/QStyleOption>
 
23
 
 
24
KSeparator::KSeparator( QWidget* parent, Qt::WFlags f )
 
25
        : QFrame( parent, f )
 
26
{
 
27
    setLineWidth( 1 );
 
28
    setMidLineWidth( 0 );
 
29
    setOrientation( HLine );
 
30
}
 
31
 
 
32
 
 
33
 
 
34
KSeparator::KSeparator( int orientation, QWidget* parent, Qt::WFlags f )
 
35
        : QFrame( parent, f )
 
36
{
 
37
    setLineWidth( 1 );
 
38
    setMidLineWidth( 0 );
 
39
    setOrientation( orientation );
 
40
}
 
41
 
 
42
 
 
43
 
 
44
void KSeparator::setOrientation( int orientation )
 
45
{
 
46
    switch ( orientation )
 
47
    {
 
48
    case Qt::Vertical:
 
49
    case VLine:
 
50
        setFrameStyle( QFrame::VLine | QFrame::Sunken );
 
51
        setMinimumSize( 2, 0 );
 
52
        break;
 
53
 
 
54
    default:
 
55
        qDebug( "KSeparator::setOrientation(): invalid orientation, using default orientation HLine" );
 
56
 
 
57
    case Qt::Horizontal:
 
58
    case HLine:
 
59
        setFrameStyle( QFrame::HLine | QFrame::Sunken );
 
60
        setMinimumSize( 0, 2 );
 
61
        break;
 
62
    }
 
63
}
 
64
 
 
65
 
 
66
 
 
67
int KSeparator::orientation() const
 
68
{
 
69
    if ( frameStyle() & VLine )
 
70
        return VLine;
 
71
 
 
72
    if ( frameStyle() & HLine )
 
73
        return HLine;
 
74
 
 
75
    return 0;
 
76
}
 
77
 
 
78
void KSeparator::drawFrame( QPainter *p )
 
79
{
 
80
    QPoint p1, p2;
 
81
    QRect r = frameRect();
 
82
 
 
83
    if ( frameStyle() & HLine )
 
84
    {
 
85
        p1 = QPoint( r.x(), r.height() / 2 );
 
86
        p2 = QPoint( r.x() + r.width(), p1.y() );
 
87
    }
 
88
    else
 
89
    {
 
90
        p1 = QPoint( r.x() + r.width() / 2, 0 );
 
91
        p2 = QPoint( p1.x(), r.height() );
 
92
    }
 
93
 
 
94
    QStyleOption opt( lineWidth(), midLineWidth() );
 
95
    opt.state = QStyle::State_Sunken;
 
96
    style()->drawPrimitive( QStyle::PE_IndicatorToolBarSeparator, &opt, p );
 
97
}
 
98
 
 
99
 
 
100
QSize KSeparator::sizeHint() const
 
101
{
 
102
    if ( frameStyle() & VLine )
 
103
        return QSize( 2, 0 );
 
104
 
 
105
    if ( frameStyle() & HLine )
 
106
        return QSize( 0, 2 );
 
107
 
 
108
    return QSize( -1, -1 );
 
109
}
 
110
 
 
111
void KSeparator::virtual_hook( int, void* )
 
112
{ /*BASE::virtual_hook( id, data );*/ }