]> git.lyx.org Git - features.git/blob - src/frontends/kde/paradlg.h
The big KDE reorg + fi l10n update
[features.git] / src / frontends / kde / paradlg.h
1 /*
2  * paradlg.h
3  * (C) 2000 LyX Team
4  * John Levon, moz@compsoc.man.ac.uk
5  */
6
7 /***************************************************************************
8  *                                                                         *
9  *   This program is free software; you can redistribute it and/or modify  *
10  *   it under the terms of the GNU General Public License as published by  *
11  *   the Free Software Foundation; either version 2 of the License, or     *
12  *   (at your option) any later version.                                   *
13  *                                                                         *
14  ***************************************************************************/
15
16 #ifndef PARADLG_H
17 #define PARADLG_H
18
19 #include <config.h>
20 #include <gettext.h>
21 #include <string>
22
23 #include  "parageneraldlg.h"
24 #include  "paraextradlg.h"
25  
26 //#include <qtabdialog.h>
27  
28 #include "vspace.h" 
29 #include "lyxparagraph.h"
30 #include "debug.h" 
31
32 #include "dlg/paradlgdata.h"
33
34 // to connect apply() and close()
35 #include "FormParagraph.h"
36
37 class ParaDialog : public ParaDialogData  {
38    Q_OBJECT
39 public:
40         ParaDialog(FormParagraph *form, QWidget *parent=0, const char *name=0,
41                             bool modal=false, WFlags f=0);
42         ~ParaDialog();
43
44         void setReadOnly(bool);
45         void setLabelWidth(const char *);
46         void setAlign(int);
47         void setChecks(bool, bool, bool, bool, bool);
48         void setSpace(VSpace::vspace_kind, VSpace::vspace_kind, bool, bool);
49         void setAboveLength(float, float, float, LyXGlueLength::UNIT, LyXGlueLength::UNIT, LyXGlueLength::UNIT);
50         void setBelowLength(float, float, float, LyXGlueLength::UNIT, LyXGlueLength::UNIT, LyXGlueLength::UNIT);
51         void setExtra(float, LyXGlueLength::UNIT, const string, int, bool, bool, LyXParagraph::PEXTRA_TYPE);
52
53         const char *getLabelWidth() const {
54                 return generalpage->labelwidth->text();
55         }
56
57         LyXAlignment getAlign() const {
58                 if (generalpage->right->isChecked())
59                         return LYX_ALIGN_RIGHT;
60                 else if (generalpage->left->isChecked())
61                         return LYX_ALIGN_LEFT;
62                 else if (generalpage->center->isChecked())
63                         return LYX_ALIGN_CENTER;
64                 else
65                         return LYX_ALIGN_BLOCK;
66         }
67
68         bool getAboveKeep() const {
69                 return generalpage->abovepage->keepabove->isChecked();
70         }
71
72         bool getBelowKeep() const {
73                 return generalpage->belowpage->keepbelow->isChecked();
74         }
75
76         bool getLineAbove() const {
77                 return generalpage->lineabove->isChecked();
78         }
79  
80         bool getLineBelow() const {
81                 return generalpage->linebelow->isChecked();
82         }
83
84         bool getPagebreakAbove() const {
85                 return generalpage->abovepage->pagebreakabove->isChecked();
86         }
87
88         bool getPagebreakBelow() const {
89                 return generalpage->belowpage->pagebreakbelow->isChecked();
90         }
91
92         bool getNoIndent() const {
93                 return generalpage->noindent->isChecked();
94         }
95
96         VSpace::vspace_kind getSpaceAboveKind() const {
97                 return getSpaceKind(generalpage->abovepage->spaceabove->currentItem());
98         }
99         
100         VSpace::vspace_kind getSpaceBelowKind() const {
101                 return getSpaceKind(generalpage->belowpage->spacebelow->currentItem());
102         }
103         
104         LyXGlueLength getAboveLength() const;
105
106         LyXGlueLength getBelowLength() const;
107
108         LyXLength getExtraWidth() const;
109
110         string getExtraWidthPercent() const;
111
112         LyXParagraph::PEXTRA_TYPE getExtraType() const {
113                 switch (extrapage->type->currentItem()) {
114                         case 0: return LyXParagraph::PEXTRA_NONE;
115                         case 1: return LyXParagraph::PEXTRA_INDENT;
116                         case 2: return LyXParagraph::PEXTRA_MINIPAGE;
117                         case 3: return LyXParagraph::PEXTRA_FLOATFLT;
118                 }
119                 return LyXParagraph::PEXTRA_NONE;
120         }
121
122         LyXParagraph::MINIPAGE_ALIGNMENT getExtraAlign() const {
123                 if (extrapage->top->isChecked())
124                         return LyXParagraph::MINIPAGE_ALIGN_TOP;
125                 if (extrapage->middle->isChecked())
126                         return LyXParagraph::MINIPAGE_ALIGN_MIDDLE;
127                 return LyXParagraph::MINIPAGE_ALIGN_BOTTOM;
128         }
129
130         bool getHfillBetween() const {
131                 return extrapage->hfillbetween->isChecked();
132         }
133
134         bool getStartNewMinipage() const {
135                 return extrapage->startnewminipage->isChecked();
136         }
137
138 protected:
139         void closeEvent(QCloseEvent *e);
140  
141 private:
142         FormParagraph *form_;
143
144         /// the general tab page
145         ParaGeneralDialog *generalpage;
146         /// the extra options tab page
147         ParaExtraDialog *extrapage;
148
149         VSpace::vspace_kind getSpaceKind(int val) const {
150                 switch (val) {
151                         case 0: return VSpace::NONE;
152                         case 1: return VSpace::DEFSKIP;
153                         case 2: return VSpace::SMALLSKIP;
154                         case 3: return VSpace::MEDSKIP;
155                         case 4: return VSpace::BIGSKIP;
156                         case 5: return VSpace::VFILL;
157                         case 6: return VSpace::LENGTH;
158                         default:
159                                 lyxerr[Debug::GUI] << "Unknown kind combo entry " << val << std::endl;
160                 }
161                 return VSpace::NONE;
162         }
163
164         void setUnits(QComboBox *box, LyXGlueLength::UNIT unit);
165
166         LyXLength::UNIT getUnits(QComboBox *box) const;
167
168 private slots:
169
170         void ok_adaptor(void) {
171                 apply_adaptor();
172                 form_->close();
173                 hide();
174         }
175
176         void apply_adaptor(void) {
177                 form_->apply();
178         }
179
180         void restore_adaptor(void) {
181                 // this will reset to known values
182                 form_->update();
183         }
184         
185         void cancel_adaptor(void) {
186                 form_->close();
187                 hide();
188         }
189
190 };
191
192 #endif