lib

KoStyleManager.h
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., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA.
18*/
19
20#ifndef kostylist_h
21#define kostylist_h
22
23#include <kdialogbase.h>
24#include <tqstringlist.h>
25
26#include <KoParagDia.h>
27#include <KoFontTab.h>
28#include <KoDecorationTab.h>
29#include <KoHighlightingTab.h>
30#include <KoLayoutTab.h>
31#include <KoLanguageTab.h>
32#include <KoUnit.h>
33#include <tqptrlist.h>
34#include <KoStyleCollection.h>
35
36//class KoFontChooser;
37class KoParagStyle;
38class KoStyleEditor;
39class KoStyleManagerTab;
40class TQCheckBox;
41class TQComboBox;
42class TQGridLayout;
43class TQLineEdit;
44class TQListBox;
45class TQPushButton;
46class TQTabWidget;
47class TQWidget;
48class KoTextDocument;
49class KoStyleManagerPrivate;
50
54class KOTEXT_EXPORT KoStyleManager : public KDialogBase
55{
56 TQ_OBJECT
57
58
59public:
60 enum { ShowIncludeInToc = 1 }; // bitfield for flags
61 KoStyleManager( TQWidget *_parent, KoUnit::Unit unit,
62 const KoStyleCollection& styleCollection,
63 const TQString & activeStyleName,
64 int flags = 0 );
65 virtual ~KoStyleManager();
66
67 virtual KoParagStyle* addStyleTemplate(KoParagStyle *style)=0;
68 //virtual void applyStyleChange( KoParagStyle * changedStyle, int paragLayoutChanged, int formatChanged )=0;
69 virtual void applyStyleChange( KoStyleChangeDefMap changed )=0;
70
71 virtual void removeStyleTemplate( KoParagStyle *style )=0;
72 virtual void updateAllStyleLists()=0;
73 virtual void updateStyleListOrder( const TQStringList & list)=0;
74
75protected:
76 void updateFollowingStyle( KoParagStyle *s );
77 void updateInheritStyle( KoParagStyle *s );
78 void setupWidget(const KoStyleCollection & styleCollection);
79 void addGeneralTab( int flags );
80 void apply();
81 void updateGUI();
82 void updatePreview();
83 void save();
84 int styleIndex( int pos );
85
86private:
87 TQTabWidget *m_tabs;
88 TQListBox *m_stylesList;
89 TQLineEdit *m_nameString;
90 TQComboBox *m_styleCombo;
91 TQPushButton *m_deleteButton;
92 TQPushButton *m_newButton;
93 TQPushButton *m_moveUpButton;
94 TQPushButton *m_moveDownButton;
95 TQComboBox *m_inheritCombo;
96 KoStyleManagerPrivate *d;
97
98 KoParagStyle *m_currentStyle;
99 TQPtrList<KoParagStyle> m_origStyles; // internal list of orig styles we have modified
100 TQPtrList<KoParagStyle> m_changedStyles; // internal list of changed styles.
101 TQPtrList<KoStyleManagerTab> m_tabsList;
102 TQStringList m_styleOrder;
103 int numStyles;
104 bool noSignals;
105
106protected slots:
107 virtual void slotOk();
108 virtual void slotApply();
109 void switchStyle();
110 void switchTabs();
111 void addStyle();
112 void deleteStyle();
113 void moveUpStyle();
114 void moveDownStyle();
115 void renameStyle(const TQString &);
116protected:
117 KoParagStyle * style( const TQString & _name );
118 void addTab( KoStyleManagerTab * tab );
119 TQString generateUniqueName();
120};
121
122class KOTEXT_EXPORT KoStyleManagerTab : public TQWidget {
123 TQ_OBJECT
124
125public:
126 KoStyleManagerTab(TQWidget *parent) : TQWidget(parent) {};
127
129 void setStyle(KoParagStyle *style) { m_style = style; }
131 virtual void update() = 0;
133 virtual TQString tabName() = 0;
135 virtual void save() = 0;
136protected:
137 KoParagStyle *m_style;
138};
139
140// A tab to edit parts of the parag-layout of the style
141// Acts as a wrapper around KoParagLayoutWidget [which doesn't know about styles].
142class KOTEXT_EXPORT KoStyleParagTab : public KoStyleManagerTab
143{
144 TQ_OBJECT
145
146public:
147 KoStyleParagTab( TQWidget * parent );
148
149 // not a constructor parameter since 'this' is the parent of the widget
150 void setWidget( KoParagLayoutWidget * widget );
151
152 virtual void update();
153 virtual void save();
154 virtual TQString tabName() { return m_widget->tabName(); }
155protected:
156 virtual void resizeEvent( TQResizeEvent *e );
157private:
158 KoParagLayoutWidget * m_widget;
159};
160
161// The "font" tab. Maybe we should put the text color at the bottom ?
162class KOTEXT_EXPORT KoStyleFontTab : public KoStyleManagerTab
163{
164 TQ_OBJECT
165
166public:
167 KoStyleFontTab( TQWidget * parent );
168 ~KoStyleFontTab();
169 virtual void update();
170 virtual TQString tabName();
171 virtual void save();
172private:
173 KoFontTab *m_fontTab;
174 KoDecorationTab *m_decorationTab;
175 KoHighlightingTab *m_highlightingTab;
176 KoLayoutTab *m_layoutTab;
177 KoLanguageTab *m_languageTab;
178};
179
180/*
181Font simple font dia
182Color simple color dia
183Spacing and Indents paragraph spacing dia (KWParagDia)
184alignments KoParagDia alignment tab
185borders KoParagDia borders tab
186numbering KoParagDia tab numbering
187tabulators KoParagDia tab tabs */
188
189#endif
virtual void slotApply()
void apply()
KDialogBase(TQWidget *parent=0, const char *name=0, bool modal=true, const TQString &caption=TQString::null, int buttonMask=Ok|Apply|Cancel, ButtonCode defaultButton=Ok, bool separator=false, const KGuiItem &user1=KGuiItem(), const KGuiItem &user2=KGuiItem(), const KGuiItem &user3=KGuiItem())
virtual void slotOk()
A paragraph style is a combination of a character style and paragraph-layout attributes,...
TODO rename to KoParagStyleCollection - or should char styles be part of it too?
Unit
Length units supported by KOffice.
Definition KoUnit.h:63
TDEAction * save(const TQObject *recvr, const char *slot, TDEActionCollection *parent, const char *name=0)