kword
KWTableStyleManager.h
00001 /* This file is part of the KDE project 00002 Copyright (C) 2002 Nash Hoogwater <nrhoogwater@wanadoo.nl> 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; using 00007 version 2 of the License. 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 kwtablestylemanager_h 00021 #define kwtablestylemanager_h 00022 00023 #include "KWFrameStyle.h" 00024 #include "KWTableStyle.h" 00025 00026 #include <kdialogbase.h> 00027 #include <qgroupbox.h> 00028 #include <qptrlist.h> 00029 00030 00031 class QGridLayout; 00032 class QLineEdit; 00033 class QListBox; 00034 class QPushButton; 00035 class QWidget; 00036 class QFrame; 00037 class QComboBox; 00038 00039 class KWDocument; 00040 class KoParagStyle; 00041 00042 class KoTextDocument; 00043 00044 /******************************************************************/ 00045 /* Class: KWTableStylePreview */ 00046 /******************************************************************/ 00047 00048 class KWTableStylePreview : public QGroupBox 00049 { 00050 Q_OBJECT 00051 00052 public: 00053 KWTableStylePreview(const QString &title, const QString &text, QWidget *parent, const char* name = 0); 00054 virtual ~KWTableStylePreview(); 00055 00056 void setTableStyle(KWTableStyle *_tableStyle); 00057 00058 protected: 00059 void drawContents( QPainter *p ); 00060 00061 KWTableStyle *tableStyle; 00062 00063 KoTextDocument *m_textdoc; 00064 KoTextZoomHandler *m_zoomHandler; 00065 }; 00066 00067 class KWTableStyleListItem 00068 { 00069 public: 00070 KWTableStyleListItem() {} 00071 ~KWTableStyleListItem(); 00072 KWTableStyleListItem(KWTableStyle *orig, KWTableStyle *changed) { 00073 m_origTableStyle = orig; 00074 m_changedTableStyle = changed; 00075 } 00076 00077 KWTableStyle *origTableStyle()const { return m_origTableStyle; } 00078 KWTableStyle *changedTableStyle()const { return m_changedTableStyle; } 00079 void setOrigTableStyle( KWTableStyle *_orig ) { m_origTableStyle = _orig; } 00080 void setChangedTableStyle( KWTableStyle *_changed ) { m_changedTableStyle = _changed; } 00081 void deleteOrigTableStyle() { delete m_changedTableStyle; } 00082 void deleteChangedTableStyle() { delete m_changedTableStyle; } 00083 00084 void switchStyle(); 00085 void deleteStyle( KWTableStyle *current ); 00086 void apply(); 00087 00088 protected: 00089 KWTableStyle *m_origTableStyle; 00090 KWTableStyle *m_changedTableStyle; 00091 }; 00092 00093 /******************************************************************/ 00094 /* Class: KWTableStyleManager */ 00095 /******************************************************************/ 00096 class KWTableStyleManager : public KDialogBase 00097 { 00098 Q_OBJECT 00099 00100 public: 00101 KWTableStyleManager( QWidget *_parent, KWDocument *_doc ); 00102 ~KWTableStyleManager(); 00103 00104 private: 00105 void setupWidget(); 00106 void addGeneralTab(); 00107 void apply(); 00108 void updateGUI(); 00109 void updatePreview(); 00110 void save(); 00111 int tableStyleIndex( int pos ); 00112 00113 void addStyles(const QPtrList<KWTableStyle> &listStyle ); 00114 00115 QListBox *m_stylesList; 00116 QLineEdit *m_nameString; 00117 QPushButton *m_deleteButton; 00118 QPushButton *m_newButton; 00119 QPushButton *m_moveUpButton; 00120 QPushButton *m_moveDownButton; 00121 QComboBox *m_frameStyle; 00122 QComboBox *m_style; 00123 QPushButton *m_changeFrameStyleButton; 00124 QPushButton *m_changeStyleButton; 00125 QStringList m_styleOrder; 00126 QGroupBox *previewBox; 00127 KWTableStylePreview *preview; 00128 00129 QWidget *main; 00130 00131 KWTableStyle *m_currentTableStyle; 00132 QPtrList<KWTableStyleListItem> m_tableStyles; 00133 int numTableStyles; 00134 bool noSignals; 00135 00136 KWDocument *m_doc; 00137 00138 protected slots: 00139 virtual void slotOk(); 00140 virtual void slotApply(); 00141 void updateAllStyleCombos(); 00142 void changeFrameStyle(); 00143 void changeStyle(); 00144 void selectFrameStyle(int); 00145 void selectStyle(int); 00146 void switchStyle(); 00147 void addStyle(); 00148 void deleteStyle(); 00149 void moveUpStyle(); 00150 void moveDownStyle(); 00151 void renameStyle(const QString &); 00152 void setupMain(); 00153 void importFromFile(); 00154 }; 00155 00156 #endif