summaryrefslogtreecommitdiffstats
path: root/kword/KWTableStyleManager.h
blob: 3b601eb83c3a5dcd1b8a8ab453063427bfb0d928 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
/* This file is part of the KDE project
   Copyright (C) 2002 Nash Hoogwater <nrhoogwater@wanadoo.nl>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License as published by the Free Software Foundation; using
   version 2 of the License.

   This library is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301, USA.
*/

#ifndef kwtablestylemanager_h
#define kwtablestylemanager_h

#include "KWFrameStyle.h"
#include "KWTableStyle.h"

#include <kdialogbase.h>
#include <tqgroupbox.h>
#include <tqptrlist.h>


class TQGridLayout;
class TQLineEdit;
class TQListBox;
class TQPushButton;
class TQWidget;
class TQFrame;
class TQComboBox;

class KWDocument;
class KoParagStyle;

class KoTextDocument;

/******************************************************************/
/* Class: KWTableStylePreview                                     */
/******************************************************************/

class KWTableStylePreview : public TQGroupBox
{
    Q_OBJECT
  

public:
    KWTableStylePreview(const TQString &title, const TQString &text, TQWidget *parent, const char* name = 0);
    virtual ~KWTableStylePreview();

    void setTableStyle(KWTableStyle *_tableStyle);

protected:
    void drawContents( TQPainter *p );

    KWTableStyle *tableStyle;

    KoTextDocument *m_textdoc;
    KoTextZoomHandler *m_zoomHandler;
};

class KWTableStyleListItem
{
  public:
    KWTableStyleListItem() {}
    ~KWTableStyleListItem();
    KWTableStyleListItem(KWTableStyle *orig, KWTableStyle *changed) {
        m_origTableStyle = orig;
        m_changedTableStyle = changed;
    }

    KWTableStyle *origTableStyle()const { return m_origTableStyle; }
    KWTableStyle *changedTableStyle()const { return m_changedTableStyle; }
    void setOrigTableStyle( KWTableStyle *_orig ) { m_origTableStyle = _orig; }
    void setChangedTableStyle( KWTableStyle *_changed ) { m_changedTableStyle = _changed; }
    void deleteOrigTableStyle() { delete m_changedTableStyle; }
    void deleteChangedTableStyle() { delete m_changedTableStyle; }

    void switchStyle();
    void deleteStyle( KWTableStyle *current );
    void apply();

  protected:
    KWTableStyle *m_origTableStyle;
    KWTableStyle *m_changedTableStyle;
};

/******************************************************************/
/* Class: KWTableStyleManager                                     */
/******************************************************************/
class KWTableStyleManager : public KDialogBase
{
    Q_OBJECT
  

public:
    KWTableStyleManager( TQWidget *_parent, KWDocument *_doc );
    ~KWTableStyleManager();

private:
    void setupWidget();
    void addGeneralTab();
    void apply();
    void updateGUI();
    void updatePreview();
    void save();
    int tableStyleIndex( int pos );

    void addStyles(const TQPtrList<KWTableStyle> &listStyle );

    TQListBox *m_stylesList;
    TQLineEdit *m_nameString;
    TQPushButton *m_deleteButton;
    TQPushButton *m_newButton;
    TQPushButton *m_moveUpButton;
    TQPushButton *m_moveDownButton;
    TQComboBox *m_frameStyle;
    TQComboBox *m_style;
    TQPushButton *m_changeFrameStyleButton;
    TQPushButton *m_changeStyleButton;
    TQStringList m_styleOrder;
    TQGroupBox *previewBox;
    KWTableStylePreview *preview;

    TQWidget *main;

    KWTableStyle *m_currentTableStyle;
    TQPtrList<KWTableStyleListItem> m_tableStyles;
    int numTableStyles;
    bool noSignals;

    KWDocument *m_doc;

protected slots:
    virtual void slotOk();
    virtual void slotApply();
    void updateAllStyleCombos();
    void changeFrameStyle();
    void changeStyle();
    void selectFrameStyle(int);
    void selectStyle(int);
    void switchStyle();
    void addStyle();
    void deleteStyle();
    void moveUpStyle();
    void moveDownStyle();
    void renameStyle(const TQString &);
    void setupMain();
    void importFromFile();
};

#endif