~ubuntu-branches/ubuntu/breezy/koffice/breezy

« back to all changes in this revision

Viewing changes to lib/kofficeui/koUnitWidgets.h

  • Committer: Bazaar Package Importer
  • Author(s): Ben Burton
  • Date: 2004-05-09 11:33:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20040509113300-vfrdadqsvjfuhn3b
Tags: 1:1.3.1-1
* New upstream bugfix release.
* Built against newer imagemagick (closes: #246623).
* Made koffice-libs/kformula recommend/depend on latex-xft-fonts, which
  provides mathematical fonts that the formula editor can use.  Also
  patched the kformula part to make these fonts the default.
* Changed kword menu hint from "WordProcessors" to "Word processors"
  (closes: #246209).
* Spellchecker configuration is now fixed (closes: #221256, #227568).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of the KDE project
 
2
   Copyright (C) 2002, Rob Buis(buis@kde.org)
 
3
 
 
4
   This library is free software; you can redistribute it and/or
 
5
   modify it under the terms of the GNU Library General Public
 
6
   License as published by the Free Software Foundation; either
 
7
   version 2 of the License, or (at your option) any later version.
 
8
 
 
9
   This library 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 GNU
 
12
   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 library; see the file COPYING.LIB.  If not, write to
 
16
   the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 
17
   Boston, MA 02111-1307, USA.
 
18
*/
 
19
 
 
20
#ifndef __KOUNITWIDGETS_H__
 
21
#define __KOUNITWIDGETS_H__
 
22
 
 
23
#include <knuminput.h>
 
24
#include <knumvalidator.h>
 
25
#include <klineedit.h>
 
26
#include <kcombobox.h>
 
27
#include <koUnit.h>
 
28
 
 
29
class KoUnitDoubleBase;
 
30
 
 
31
class KoUnitDoubleValidator : public KDoubleValidator
 
32
{
 
33
public:
 
34
        KoUnitDoubleValidator( KoUnitDoubleBase *base, QObject *parent, const char *name = 0 );
 
35
 
 
36
        virtual QValidator::State validate( QString &, int & ) const;
 
37
 
 
38
private:
 
39
        KoUnitDoubleBase        *m_base;
 
40
};
 
41
 
 
42
class KoUnitDoubleBase
 
43
{
 
44
public:
 
45
        KoUnitDoubleBase( KoUnit::Unit unit, unsigned int precision ) : m_unit( unit ), m_precision( precision ) {}
 
46
        virtual ~KoUnitDoubleBase() {}
 
47
 
 
48
        virtual void changeValue( double ) = 0;
 
49
        virtual void setUnit( KoUnit::Unit = KoUnit::U_PT ) = 0;
 
50
 
 
51
        void setValueInUnit( double value, KoUnit::Unit unit )
 
52
        {
 
53
                changeValue( KoUnit::ptToUnit( KoUnit::ptFromUnit( value, unit ), m_unit ) );
 
54
        }
 
55
 
 
56
        void setPrecision( unsigned int precision ) { m_precision = precision; };
 
57
 
 
58
protected:
 
59
        friend class KoUnitDoubleValidator;
 
60
        KoUnitDoubleValidator   *m_validator;
 
61
        KoUnit::Unit                    m_unit;
 
62
        unsigned int                    m_precision;
 
63
};
 
64
 
 
65
class KoUnitDoubleSpinBox : public KDoubleSpinBox, public KoUnitDoubleBase
 
66
{
 
67
public:
 
68
        KoUnitDoubleSpinBox( QWidget *parent, double lower, double upper, double step, double value = 0.0,
 
69
                                        KoUnit::Unit unit = KoUnit::U_PT, unsigned int precision = 2, const char *name = 0 );
 
70
 
 
71
        virtual void changeValue( double );
 
72
        virtual void setUnit( KoUnit::Unit = KoUnit::U_PT );
 
73
};
 
74
 
 
75
class KoUnitDoubleLineEdit : public KLineEdit, public KoUnitDoubleBase
 
76
{
 
77
public:
 
78
        KoUnitDoubleLineEdit( QWidget *parent, double lower, double upper, double value = 0.0, KoUnit::Unit unit = KoUnit::U_PT, unsigned int precision = 2, const char *name = 0 );
 
79
 
 
80
        virtual void changeValue( double );
 
81
        virtual void setUnit( KoUnit::Unit = KoUnit::U_PT );
 
82
 
 
83
        double value() const { return m_value; }
 
84
 
 
85
protected:
 
86
         bool eventFilter( QObject* obj, QEvent* ev );
 
87
 
 
88
private:
 
89
        double m_value;
 
90
        double m_lower;
 
91
        double m_upper;
 
92
};
 
93
 
 
94
class KoUnitDoubleComboBox : public KComboBox, public KoUnitDoubleBase
 
95
{
 
96
Q_OBJECT
 
97
public:
 
98
        KoUnitDoubleComboBox( QWidget *parent, double lower, double upper, double value = 0.0, KoUnit::Unit unit = KoUnit::U_PT, unsigned int precision = 2, const char *name = 0 );
 
99
 
 
100
        virtual void changeValue( double );
 
101
        void updateValue( double );
 
102
        virtual void setUnit( KoUnit::Unit = KoUnit::U_PT );
 
103
 
 
104
        double value() const { return m_value; }
 
105
        void insertItem( double, int index = -1 );
 
106
 
 
107
protected:
 
108
         bool eventFilter( QObject* obj, QEvent* ev );
 
109
 
 
110
signals:
 
111
         void valueChanged(double);
 
112
 
 
113
private slots:
 
114
        void slotActivated( int );
 
115
 
 
116
protected:
 
117
        double m_value;
 
118
        double m_lower;
 
119
        double m_upper;
 
120
};
 
121
 
 
122
class KoUnitDoubleSpinComboBox : public QWidget
 
123
{
 
124
Q_OBJECT
 
125
public:
 
126
        KoUnitDoubleSpinComboBox( QWidget *parent, double lower, double upper, double step, double value = 0.0, KoUnit::Unit unit = KoUnit::U_PT, unsigned int precision = 2, const char *name = 0 );
 
127
 
 
128
        void insertItem( double, int index = -1 );
 
129
        void updateValue( double );
 
130
        double value() const;
 
131
 
 
132
signals:
 
133
         void valueChanged(double);
 
134
 
 
135
private slots:
 
136
        void slotUpClicked();
 
137
        void slotDownClicked();
 
138
 
 
139
private:
 
140
        KoUnitDoubleComboBox *m_combo;
 
141
        double m_step;
 
142
};
 
143
 
 
144
#endif
 
145