kword

KWFrameStyleManager.h
1/* This file is part of the KDE project
2 Copyright (C) 2002 Nash Hoogwater <nrhoogwater@wanadoo.nl>
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; using
7 version 2 of the License.
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 kwframestylemanager_h
21#define kwframestylemanager_h
22
23#include "KWFrameStyle.h"
24
25#include <kdialogbase.h>
26#include <tqptrlist.h>
27
28
29class TQGroupBox;
30class TQGridLayout;
31class TQLineEdit;
32class TQListBox;
33class TQPushButton;
34class TQTabWidget;
35class TQWidget;
36class KWDocument;
37class KWFrameStyleManagerTab;
38class KoParagLayoutWidget;
39class KoParagLayout;
40class KColorButton;
41class KWBrushStylePreview;
42
43/******************************************************************/
44/* Class: KWFrameStylePreview */
45/******************************************************************/
46
47class KWFrameStylePreview : public TQWidget
48{
49 TQ_OBJECT
50
51
52public:
53 KWFrameStylePreview( TQWidget *parent )
54 : TQWidget( parent ), frameStyle( 0 ) {
55 setBackgroundColor( white );
56 }
57
58 void setFrameStyle(KWFrameStyle *_frameStyle);
59
60protected:
61 void paintEvent( TQPaintEvent *e );
62
63 void setTopBorder(KoBorder _bTop) { frameStyle->setTopBorder( _bTop ); repaint( true ); }
64 void setBottomBorder(KoBorder _bBottom) { frameStyle->setBottomBorder( _bBottom ); repaint( true ); }
65 void setRightBorder(KoBorder _bRight) { frameStyle->setRightBorder( _bRight ); repaint( true ); }
66 void setLeftBorder(KoBorder _bLeft) { frameStyle->setLeftBorder( _bLeft ); repaint( true ); }
67 void setBackground( const TQColor & col ) { frameStyle->setBackgroundColor( col ); repaint( true ); }
68
69 KWFrameStyle *frameStyle;
70};
71
72
73class KWFrameStyleListItem
74{
75 public:
76 KWFrameStyleListItem() {}
77 ~KWFrameStyleListItem();
78 KWFrameStyleListItem(KWFrameStyle *orig, KWFrameStyle *changed) {
79 m_origFrameStyle = orig;
80 m_changedFrameStyle = changed;
81 }
82
83 KWFrameStyle *origFrameStyle()const { return m_origFrameStyle; }
84 KWFrameStyle *changedFrameStyle()const { return m_changedFrameStyle; }
85 void setOrigFrameStyle( KWFrameStyle *_orig ) { m_origFrameStyle = _orig; }
86 void setChangedFrameStyle( KWFrameStyle *_changed ) { m_changedFrameStyle = _changed; }
87 void deleteOrigFrameStyle() { delete m_changedFrameStyle; }
88 void deleteChangedFrameStyle() { delete m_changedFrameStyle; }
89
90 void switchStyle();
91 void deleteStyle( KWFrameStyle *current );
92 void apply();
93
94 protected:
95 KWFrameStyle *m_origFrameStyle;
96 KWFrameStyle *m_changedFrameStyle;
97};
98
99/******************************************************************/
100/* Class: KWFrameStyleManager */
101/******************************************************************/
102class KWFrameStyleManager : public KDialogBase
103{
104 TQ_OBJECT
105
106
107public:
108 KWFrameStyleManager( TQWidget *_parent, KWDocument *_doc,
109 const TQString & activeStyleName );
110 ~KWFrameStyleManager();
111
112protected:
113 void addStyles(const TQPtrList<KWFrameStyle> & style );
114 void setupWidget();
115 void addGeneralTab();
116 void apply();
117 void updateGUI();
118 void updatePreview();
119 void save();
120 int frameStyleIndex( int pos );
121
122 TQTabWidget *m_tabs;
123 TQListBox *m_stylesList;
124 TQLineEdit *m_nameString;
125 TQPushButton *m_deleteButton;
126 TQPushButton *m_newButton;
127 TQPushButton *m_moveUpButton;
128 TQPushButton *m_moveDownButton;
129
130 TQGroupBox *previewBox;
131 KWFrameStylePreview *preview;
132
133 KWFrameStyle *m_currentFrameStyle;
134 TQStringList m_styleOrder;
135 TQPtrList<KWFrameStyleListItem> m_frameStyles;
136 TQPtrList<KWFrameStyleManagerTab> m_tabsList;
137 int numFrameStyles;
138 bool noSignals;
139
140 KWDocument *m_doc;
141
142protected slots:
143 virtual void slotOk();
144 virtual void slotApply();
145 void switchStyle();
146 void switchTabs();
147 void addStyle();
148 void deleteStyle();
149 void moveUpStyle();
150 void moveDownStyle();
151 void renameStyle(const TQString &);
152 void importFromFile();
153protected:
154 void addTab( KWFrameStyleManagerTab * tab );
155};
156
157class KWFrameStyleManagerTab : public TQWidget {
158 TQ_OBJECT
159
160public:
161 KWFrameStyleManagerTab(TQWidget *parent) : TQWidget(parent) {};
162
164 void setStyle(KWFrameStyle *style) { m_style = style; }
166 virtual void update() = 0;
168 virtual TQString tabName() = 0;
170 virtual void save() = 0;
171protected:
172 KWFrameStyle *m_style;
173};
174
175class KWFrameStyleBackgroundTab : public KWFrameStyleManagerTab
176{
177 TQ_OBJECT
178
179public:
180 KWFrameStyleBackgroundTab( TQWidget * parent );
181
182 virtual void update();
183 virtual void save();
184 virtual TQString tabName();
185protected slots:
186 void updateBrushConfiguration( const TQColor & );
187protected:
188 TQBrush m_backgroundColor;
189 TQWidget *bgwidget;
190 TQGridLayout *grid;
191 KColorButton *brushColor;
192 KWBrushStylePreview *brushPreview;
193};
194
195class KWFrameStyleBordersTab : public KWFrameStyleManagerTab
196{
197 TQ_OBJECT
198
199public:
200 KWFrameStyleBordersTab( TQWidget * parent );
201 ~KWFrameStyleBordersTab();
202 void setWidget( KoParagLayoutWidget * widget );
203
204 virtual void update();
205 virtual void save();
206 virtual TQString tabName();
207protected:
208 virtual void resizeEvent( TQResizeEvent *e );
209
210 KoParagLayoutWidget * m_widget;
211 KoParagLayout *m_borders; // Pity that I'm using such an overdosis for just borders :-(
212};
213
214#endif
The user-visible style for frames (borders and background)