~ubuntu-branches/ubuntu/precise/koffice/precise

« back to all changes in this revision

Viewing changes to lib/kotext/koStylist.h

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2006-04-20 21:38:53 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20060420213853-j5lxluqvymxt2zny
Tags: 1:1.5.0-0ubuntu2
UbuntuĀ uploadĀ 

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* This file is part of the KDE project
2
 
   Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@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 kostylist_h
21
 
#define kostylist_h
22
 
 
23
 
#include <kdialogbase.h>
24
 
#include <qstringlist.h>
25
 
 
26
 
#include <koParagDia.h>
27
 
#include <koUnit.h>
28
 
#include <qptrlist.h>
29
 
#include <kostyle.h>
30
 
 
31
 
class KoFontChooser;
32
 
class KoParagStyle;
33
 
class KoStyleEditor;
34
 
class KoStyleManagerTab;
35
 
class QCheckBox;
36
 
class QComboBox;
37
 
class QGridLayout;
38
 
class QLineEdit;
39
 
class QListBox;
40
 
class QPushButton;
41
 
class QTabWidget;
42
 
class QWidget;
43
 
class KoTextDocument;
44
 
class KoStyleManagerPrivate;
45
 
 
46
 
/******************************************************************/
47
 
/* Class: KoStyleManager                                          */
48
 
/******************************************************************/
49
 
class KOTEXT_EXPORT KoStyleManager : public KDialogBase
50
 
{
51
 
    Q_OBJECT
52
 
 
53
 
public:
54
 
    enum { ShowIncludeInToc = 1 }; // bitfield for flags
55
 
    KoStyleManager( QWidget *_parent, KoUnit::Unit unit,
56
 
                    const QPtrList<KoParagStyle> & style, const QString & activeStyleName,
57
 
                    int flags = 0 );
58
 
    virtual ~KoStyleManager();
59
 
 
60
 
    virtual KoParagStyle* addStyleTemplate(KoParagStyle *style)=0;
61
 
    //virtual void applyStyleChange( KoParagStyle * changedStyle, int paragLayoutChanged, int formatChanged )=0;
62
 
    virtual void applyStyleChange( KoStyleChangeDefMap changed )=0;
63
 
 
64
 
    virtual void removeStyleTemplate( KoParagStyle *style )=0;
65
 
    virtual void updateAllStyleLists()=0;
66
 
    virtual void updateStyleListOrder( const QStringList & list)=0;
67
 
 
68
 
protected:
69
 
    void updateFollowingStyle( KoParagStyle *s );
70
 
    void updateInheritStyle( KoParagStyle *s );
71
 
    void setupWidget(const QPtrList<KoParagStyle> & style);
72
 
    void addGeneralTab( int flags );
73
 
    void apply();
74
 
    void updateGUI();
75
 
    void updatePreview();
76
 
    void save();
77
 
    int styleIndex( int pos );
78
 
 
79
 
private:
80
 
    QTabWidget *m_tabs;
81
 
    QListBox *m_stylesList;
82
 
    QLineEdit *m_nameString;
83
 
    QComboBox *m_styleCombo;
84
 
    QPushButton *m_deleteButton;
85
 
    QPushButton *m_newButton;
86
 
    QPushButton *m_moveUpButton;
87
 
    QPushButton *m_moveDownButton;
88
 
    QComboBox *m_inheritCombo;
89
 
    KoStyleManagerPrivate *d;
90
 
 
91
 
    KoParagStyle *m_currentStyle;
92
 
    QPtrList<KoParagStyle> m_origStyles;      // internal list of orig styles we have modified
93
 
    QPtrList<KoParagStyle> m_changedStyles;   // internal list of changed styles.
94
 
    QPtrList<KoStyleManagerTab> m_tabsList;
95
 
    QStringList m_styleOrder;
96
 
    int numStyles;
97
 
    bool noSignals;
98
 
 
99
 
protected slots:
100
 
    virtual void slotOk();
101
 
    virtual void slotApply();
102
 
    void switchStyle();
103
 
    void switchTabs();
104
 
    void addStyle();
105
 
    void deleteStyle();
106
 
    void moveUpStyle();
107
 
    void moveDownStyle();
108
 
    void renameStyle(const QString &);
109
 
protected:
110
 
    KoParagStyle * style( const QString & _name );
111
 
    void addTab( KoStyleManagerTab * tab );
112
 
    QString generateUniqueName();
113
 
};
114
 
 
115
 
class KOTEXT_EXPORT KoStyleManagerTab : public QWidget {
116
 
    Q_OBJECT
117
 
public:
118
 
    KoStyleManagerTab(QWidget *parent) : QWidget(parent) {};
119
 
 
120
 
    /** the new style which is to be displayed */
121
 
    void setStyle(KoParagStyle *style) { m_style = style; }
122
 
    /**  update the GUI from the current Style*/
123
 
    virtual void update() = 0;
124
 
    /**  return the (i18n-ed) name of the tab */
125
 
    virtual QString tabName() = 0;
126
 
    /** save the GUI to the style */
127
 
    virtual void save() = 0;
128
 
protected:
129
 
    KoParagStyle *m_style;
130
 
};
131
 
 
132
 
// A tab to edit parts of the parag-layout of the style
133
 
// Acts as a wrapper around KoParagLayoutWidget [which doesn't know about styles].
134
 
class KOTEXT_EXPORT KoStyleParagTab : public KoStyleManagerTab
135
 
{
136
 
    Q_OBJECT
137
 
public:
138
 
    KoStyleParagTab( QWidget * parent );
139
 
 
140
 
    // not a constructor parameter since 'this' is the parent of the widget
141
 
    void setWidget( KoParagLayoutWidget * widget );
142
 
 
143
 
    virtual void update();
144
 
    virtual void save();
145
 
    virtual QString tabName() { return m_widget->tabName(); }
146
 
protected:
147
 
    virtual void resizeEvent( QResizeEvent *e );
148
 
private:
149
 
    KoParagLayoutWidget * m_widget;
150
 
};
151
 
 
152
 
// The "font" tab. Maybe we should put the text color at the bottom ?
153
 
class KOTEXT_EXPORT KoStyleFontTab : public KoStyleManagerTab
154
 
{
155
 
    Q_OBJECT
156
 
public:
157
 
    KoStyleFontTab( QWidget * parent );
158
 
    ~KoStyleFontTab();
159
 
    virtual void update();
160
 
    virtual QString tabName();
161
 
    virtual void save();
162
 
protected:
163
 
    virtual void resizeEvent( QResizeEvent *e );
164
 
private:
165
 
    KoFontChooser* m_chooser;
166
 
    KoZoomHandler* m_zoomHandler;
167
 
};
168
 
 
169
 
/*
170
 
Font            simple font dia
171
 
Color           simple color dia
172
 
Spacing and Indents     paragraph spacing dia (KWParagDia)
173
 
alignments      KoParagDia alignment tab
174
 
borders         KoParagDia  borders tab
175
 
numbering       KoParagDia  tab numbering
176
 
tabulators      KoParagDia  tab tabs */
177
 
 
178
 
#endif