lib Library API Documentation

koStylist.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., 59 Temple Place - Suite 330,
00017    Boston, MA 02111-1307, 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 <koUnit.h>
00028 #include <qptrlist.h>
00029 #include <kostyle.h>
00030 
00031 class KoFontChooser;
00032 class KoParagStyle;
00033 class KoStyleEditor;
00034 class KoStyleManagerTab;
00035 class QCheckBox;
00036 class QComboBox;
00037 class QGridLayout;
00038 class QLineEdit;
00039 class QListBox;
00040 class QPushButton;
00041 class QTabWidget;
00042 class QWidget;
00043 class KoTextDocument;
00044 class KoStyleManagerPrivate;
00045 
00046 /******************************************************************/
00047 /* Class: KoStyleManager                                          */
00048 /******************************************************************/
00049 class KOTEXT_EXPORT KoStyleManager : public KDialogBase
00050 {
00051     Q_OBJECT
00052 
00053 public:
00054     enum { ShowIncludeInToc = 1 }; // bitfield for flags
00055     KoStyleManager( QWidget *_parent, KoUnit::Unit unit,
00056                     const QPtrList<KoParagStyle> & style, const QString & activeStyleName,
00057                     int flags = 0 );
00058     virtual ~KoStyleManager();
00059 
00060     virtual KoParagStyle* addStyleTemplate(KoParagStyle *style)=0;
00061     //virtual void applyStyleChange( KoParagStyle * changedStyle, int paragLayoutChanged, int formatChanged )=0;
00062     virtual void applyStyleChange( KoStyleChangeDefMap changed )=0;
00063 
00064     virtual void removeStyleTemplate( KoParagStyle *style )=0;
00065     virtual void updateAllStyleLists()=0;
00066     virtual void updateStyleListOrder( const QStringList & list)=0;
00067 
00068 protected:
00069     void updateFollowingStyle( KoParagStyle *s );
00070     void updateInheritStyle( KoParagStyle *s );
00071     void setupWidget(const QPtrList<KoParagStyle> & style);
00072     void addGeneralTab( int flags );
00073     void apply();
00074     void updateGUI();
00075     void updatePreview();
00076     void save();
00077     int styleIndex( int pos );
00078 
00079 private:
00080     QTabWidget *m_tabs;
00081     QListBox *m_stylesList;
00082     QLineEdit *m_nameString;
00083     QComboBox *m_styleCombo;
00084     QPushButton *m_deleteButton;
00085     QPushButton *m_newButton;
00086     QPushButton *m_moveUpButton;
00087     QPushButton *m_moveDownButton;
00088     QComboBox *m_inheritCombo;
00089     KoStyleManagerPrivate *d;
00090 
00091     KoParagStyle *m_currentStyle;
00092     QPtrList<KoParagStyle> m_origStyles;      // internal list of orig styles we have modified
00093     QPtrList<KoParagStyle> m_changedStyles;   // internal list of changed styles.
00094     QPtrList<KoStyleManagerTab> m_tabsList;
00095     QStringList m_styleOrder;
00096     int numStyles;
00097     bool noSignals;
00098 
00099 protected slots:
00100     virtual void slotOk();
00101     virtual void slotApply();
00102     void switchStyle();
00103     void switchTabs();
00104     void addStyle();
00105     void deleteStyle();
00106     void moveUpStyle();
00107     void moveDownStyle();
00108     void renameStyle(const QString &);
00109 protected:
00110     KoParagStyle * style( const QString & _name );
00111     void addTab( KoStyleManagerTab * tab );
00112     QString generateUniqueName();
00113 };
00114 
00115 class KOTEXT_EXPORT KoStyleManagerTab : public QWidget {
00116     Q_OBJECT
00117 public:
00118     KoStyleManagerTab(QWidget *parent) : QWidget(parent) {};
00119 
00121     void setStyle(KoParagStyle *style) { m_style = style; }
00123     virtual void update() = 0;
00125     virtual QString tabName() = 0;
00127     virtual void save() = 0;
00128 protected:
00129     KoParagStyle *m_style;
00130 };
00131 
00132 // A tab to edit parts of the parag-layout of the style
00133 // Acts as a wrapper around KoParagLayoutWidget [which doesn't know about styles].
00134 class KOTEXT_EXPORT KoStyleParagTab : public KoStyleManagerTab
00135 {
00136     Q_OBJECT
00137 public:
00138     KoStyleParagTab( QWidget * parent );
00139 
00140     // not a constructor parameter since 'this' is the parent of the widget
00141     void setWidget( KoParagLayoutWidget * widget );
00142 
00143     virtual void update();
00144     virtual void save();
00145     virtual QString tabName() { return m_widget->tabName(); }
00146 protected:
00147     virtual void resizeEvent( QResizeEvent *e );
00148 private:
00149     KoParagLayoutWidget * m_widget;
00150 };
00151 
00152 // The "font" tab. Maybe we should put the text color at the bottom ?
00153 class KOTEXT_EXPORT KoStyleFontTab : public KoStyleManagerTab
00154 {
00155     Q_OBJECT
00156 public:
00157     KoStyleFontTab( QWidget * parent );
00158     ~KoStyleFontTab();
00159     virtual void update();
00160     virtual QString tabName();
00161     virtual void save();
00162 protected:
00163     virtual void resizeEvent( QResizeEvent *e );
00164 private:
00165     KoFontChooser* m_chooser;
00166     KoZoomHandler* m_zoomHandler;
00167 };
00168 
00169 /*
00170 Font            simple font dia
00171 Color           simple color dia
00172 Spacing and Indents     paragraph spacing dia (KWParagDia)
00173 alignments      KoParagDia alignment tab
00174 borders         KoParagDia  borders tab
00175 numbering       KoParagDia  tab numbering
00176 tabulators      KoParagDia  tab tabs */
00177 
00178 #endif
KDE Logo
This file is part of the documentation for lib Library Version 1.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Mon Feb 13 09:40:08 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003