]> git.lyx.org Git - features.git/blob - src/frontends/kde/paradlg.h
cfe8e152ede7827a11cb07557e244d73487305c3
[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 // to connect apply() and close()
33 #include "FormParagraph.h"
34
35 class ParaDialog : public QTabDialog  {
36    Q_OBJECT
37 public:
38         ParaDialog(FormParagraph *form, QWidget *parent=0, const char *name=0,
39                             bool modal=false, WFlags f=0);
40         ~ParaDialog();
41
42         void setReadOnly(bool);
43         void setLabelWidth(const char *);
44         void setAlign(int);
45         void setChecks(bool, bool, bool, bool, bool);
46         void setSpace(VSpace::vspace_kind, VSpace::vspace_kind, bool, bool);
47         void setAboveLength(float, float, float, LyXGlueLength::UNIT, LyXGlueLength::UNIT, LyXGlueLength::UNIT);
48         void setBelowLength(float, float, float, LyXGlueLength::UNIT, LyXGlueLength::UNIT, LyXGlueLength::UNIT);
49         void setExtra(float, LyXGlueLength::UNIT, const string, int, bool, bool, LyXParagraph::PEXTRA_TYPE);
50
51         const char *getLabelWidth() const {
52                 return generalpage->labelwidth->text();
53         }
54
55         LyXAlignment getAlign() const {
56                 if (generalpage->right->isChecked())
57                         return LYX_ALIGN_RIGHT;
58                 else if (generalpage->left->isChecked())
59                         return LYX_ALIGN_LEFT;
60                 else if (generalpage->center->isChecked())
61                         return LYX_ALIGN_CENTER;
62                 else
63                         return LYX_ALIGN_BLOCK;
64         }
65
66         bool getLineAbove() const {
67                 return generalpage->lineabove->isChecked();
68         }
69  
70         bool getLineBelow() const {
71                 return generalpage->linebelow->isChecked();
72         }
73
74         bool getPagebreakAbove() const {
75                 return generalpage->pagebreakabove->isChecked();
76         }
77
78         bool getPagebreakBelow() const {
79                 return generalpage->pagebreakbelow->isChecked();
80         }
81
82         bool getNoIndent() const {
83                 return generalpage->noindent->isChecked();
84         }
85
86         VSpace::vspace_kind getSpaceAboveKind() const {
87                 return getSpaceKind(generalpage->spaceabove->currentItem());
88         }
89         
90         VSpace::vspace_kind getSpaceBelowKind() const {
91                 return getSpaceKind(generalpage->spacebelow->currentItem());
92         }
93         
94         bool getSpaceAboveKeep() const {
95                 // FIXME
96                 return true;
97         }
98
99         bool getSpaceBelowKeep() const {
100                 // FIXME
101                 return true;
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         void apply_adaptor(void) {
170                 form_->apply();
171                 form_->close();
172                 hide();
173         }
174
175         void close_adaptor(void) {
176                 form_->close();
177                 hide();
178         }
179
180         void restore(void);
181 };
182
183 #endif