lib

KoStyleManager.h

00001 /* This file is part of the KDE project
00002    Copyright (C) 1998, 1999 Reginald Stadlbauer <reggie@kde.org>
00003 
00004    This library is free software; you can redistribute it and/or
00005    modify it under the terms of the GNU Library General Public
00006    License as published by the Free Software Foundation; either
00007    version 2 of the License, or (at your option) any later version.
00008 
00009    This library 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 GNU
00012    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 library; see the file COPYING.LIB.  If not, write to
00016    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018 */
00019 
00020 #ifndef kostylist_h
00021 #define kostylist_h
00022 
00023 #include <kdialogbase.h>
00024 #include <qstringlist.h>
00025 
00026 #include <KoParagDia.h>
00027 #include <KoFontTab.h>
00028 #include <KoDecorationTab.h>
00029 #include <KoHighlightingTab.h>
00030 #include <KoLayoutTab.h>
00031 #include <KoLanguageTab.h>
00032 #include <KoUnit.h>
00033 #include <qptrlist.h>
00034 #include <KoStyleCollection.h>
00035 
00036 //class KoFontChooser;
00037 class KoParagStyle;
00038 class KoStyleEditor;
00039 class KoStyleManagerTab;
00040 class QCheckBox;
00041 class QComboBox;
00042 class QGridLayout;
00043 class QLineEdit;
00044 class QListBox;
00045 class QPushButton;
00046 class QTabWidget;
00047 class QWidget;
00048 class KoTextDocument;
00049 class KoStyleManagerPrivate;
00050 
00054 class KOTEXT_EXPORT KoStyleManager : public KDialogBase
00055 {
00056     Q_OBJECT
00057 
00058 public:
00059     enum { ShowIncludeInToc = 1 }; // bitfield for flags
00060     KoStyleManager( QWidget *_parent, KoUnit::Unit unit,
00061                     const KoStyleCollection& styleCollection,
00062                     const QString & activeStyleName,
00063                     int flags = 0 );
00064     virtual ~KoStyleManager();
00065 
00066     virtual KoParagStyle* addStyleTemplate(KoParagStyle *style)=0;
00067     //virtual void applyStyleChange( KoParagStyle * changedStyle, int paragLayoutChanged, int formatChanged )=0;
00068     virtual void applyStyleChange( KoStyleChangeDefMap changed )=0;
00069 
00070     virtual void removeStyleTemplate( KoParagStyle *style )=0;
00071     virtual void updateAllStyleLists()=0;
00072     virtual void updateStyleListOrder( const QStringList & list)=0;
00073 
00074 protected:
00075     void updateFollowingStyle( KoParagStyle *s );
00076     void updateInheritStyle( KoParagStyle *s );
00077     void setupWidget(const KoStyleCollection & styleCollection);
00078     void addGeneralTab( int flags );
00079     void apply();
00080     void updateGUI();
00081     void updatePreview();
00082     void save();
00083     int styleIndex( int pos );
00084 
00085 private:
00086     QTabWidget *m_tabs;
00087     QListBox *m_stylesList;
00088     QLineEdit *m_nameString;
00089     QComboBox *m_styleCombo;
00090     QPushButton *m_deleteButton;
00091     QPushButton *m_newButton;
00092     QPushButton *m_moveUpButton;
00093     QPushButton *m_moveDownButton;
00094     QComboBox *m_inheritCombo;
00095     KoStyleManagerPrivate *d;
00096 
00097     KoParagStyle *m_currentStyle;
00098     QPtrList<KoParagStyle> m_origStyles;      // internal list of orig styles we have modified
00099     QPtrList<KoParagStyle> m_changedStyles;   // internal list of changed styles.
00100     QPtrList<KoStyleManagerTab> m_tabsList;
00101     QStringList m_styleOrder;
00102     int numStyles;
00103     bool noSignals;
00104 
00105 protected slots:
00106     virtual void slotOk();
00107     virtual void slotApply();
00108     void switchStyle();
00109     void switchTabs();
00110     void addStyle();
00111     void deleteStyle();
00112     void moveUpStyle();
00113     void moveDownStyle();
00114     void renameStyle(const QString &);
00115 protected:
00116     KoParagStyle * style( const QString & _name );
00117     void addTab( KoStyleManagerTab * tab );
00118     QString generateUniqueName();
00119 };
00120 
00121 class KOTEXT_EXPORT KoStyleManagerTab : public QWidget {
00122     Q_OBJECT
00123 public:
00124     KoStyleManagerTab(QWidget *parent) : QWidget(parent) {};
00125 
00127     void setStyle(KoParagStyle *style) { m_style = style; }
00129     virtual void update() = 0;
00131     virtual QString tabName() = 0;
00133     virtual void save() = 0;
00134 protected:
00135     KoParagStyle *m_style;
00136 };
00137 
00138 // A tab to edit parts of the parag-layout of the style
00139 // Acts as a wrapper around KoParagLayoutWidget [which doesn't know about styles].
00140 class KOTEXT_EXPORT KoStyleParagTab : public KoStyleManagerTab
00141 {
00142     Q_OBJECT
00143 public:
00144     KoStyleParagTab( QWidget * parent );
00145 
00146     // not a constructor parameter since 'this' is the parent of the widget
00147     void setWidget( KoParagLayoutWidget * widget );
00148 
00149     virtual void update();
00150     virtual void save();
00151     virtual QString tabName() { return m_widget->tabName(); }
00152 protected:
00153     virtual void resizeEvent( QResizeEvent *e );
00154 private:
00155     KoParagLayoutWidget * m_widget;
00156 };
00157 
00158 // The "font" tab. Maybe we should put the text color at the bottom ?
00159 class KOTEXT_EXPORT KoStyleFontTab : public KoStyleManagerTab
00160 {
00161     Q_OBJECT
00162 public:
00163     KoStyleFontTab( QWidget * parent );
00164     ~KoStyleFontTab();
00165     virtual void update();
00166     virtual QString tabName();
00167     virtual void save();
00168 private:
00169     KoFontTab *m_fontTab;
00170     KoDecorationTab *m_decorationTab;
00171     KoHighlightingTab *m_highlightingTab;
00172     KoLayoutTab *m_layoutTab;
00173     KoLanguageTab *m_languageTab;
00174 };
00175 
00176 /*
00177 Font            simple font dia
00178 Color           simple color dia
00179 Spacing and Indents     paragraph spacing dia (KWParagDia)
00180 alignments      KoParagDia alignment tab
00181 borders         KoParagDia  borders tab
00182 numbering       KoParagDia  tab numbering
00183 tabulators      KoParagDia  tab tabs */
00184 
00185 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys