]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.h
HTML output for InsetMathCancel.
[lyx.git] / src / frontends / qt4 / GuiDocument.h
1 // -*- C++ -*-
2 /**
3  * \file GuiDocument.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  * \author Richard Heck (modules)
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef GUIDOCUMENT_H
14 #define GUIDOCUMENT_H
15
16 #include <QDialog>
17
18 #include "BufferParams.h"
19 #include "BulletsModule.h"
20 #include "GuiDialog.h"
21 #include "GuiIdListModel.h"
22
23 #include "ui_BiblioUi.h"
24 #include "ui_ColorUi.h"
25 #include "ui_DocumentUi.h"
26 #include "ui_FontUi.h"
27 #include "ui_LanguageUi.h"
28 #include "ui_LaTeXUi.h"
29 #include "ui_ListingsSettingsUi.h"
30 #include "ui_LocalLayoutUi.h"
31 #include "ui_MarginsUi.h"
32 #include "ui_MasterChildUi.h"
33 #include "ui_MathsUi.h"
34 #include "ui_ModulesUi.h"
35 #include "ui_NumberingUi.h"
36 #include "ui_OutputUi.h"
37 #include "ui_PageLayoutUi.h"
38 #include "ui_PDFSupportUi.h"
39 #include "ui_PreambleUi.h"
40 #include "ui_TextLayoutUi.h"
41
42 namespace lyx {
43
44 class BufferParams;
45 class LayoutModuleList;
46 class TextClass;
47
48 namespace frontend {
49
50 class FloatPlacement;
51 class GuiBranches;
52 class GuiIndices;
53 class ModuleSelectionManager;
54 class PreambleModule;
55 class LocalLayout;
56
57 ///
58 typedef void const * BufferId;
59
60 template<class UI>
61 class UiWidget : public QWidget, public UI
62 {
63 public:
64         UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
65 };
66
67
68 class GuiDocument : public GuiDialog, public Ui::DocumentUi
69 {
70         Q_OBJECT
71 public:
72         GuiDocument(GuiView & lv);
73
74         void paramsToDialog();
75         void updateFontsize(std::string const &, std::string const &);
76         void updateFontlist();
77         void updateDefaultFormat();
78         void updatePagestyle(std::string const &, std::string const &);
79         bool isChildIncluded(std::string const &);
80
81         ///
82         BufferParams const & params() const { return bp_; }
83
84 private Q_SLOTS:
85         void updateNumbering();
86         void change_adaptor();
87         void includeonlyClicked(QTreeWidgetItem * item, int);
88         void setListingsMessage();
89         void saveDefaultClicked();
90         void useDefaultsClicked();
91         void setLSpacing(int);
92         void setMargins();
93         void papersizeChanged(int);
94         void setColSep();
95         void setCustomMargins(bool);
96         void fontencChanged(int);
97         void romanChanged(int);
98         void sansChanged(int);
99         void ttChanged(int);
100         void setIndent(int);
101         void enableIndent(bool);
102         void setSkip(int);
103         void enableSkip(bool);
104         void browseLayout();
105         void browseMaster();
106         void classChanged();
107         void languagePackageChanged(int);
108         void biblioChanged();
109         void bibtexChanged(int);
110         void setAuthorYear(bool);
111         void setNumerical(bool);
112         void updateModuleInfo();
113         void modulesChanged();
114         void changeBackgroundColor();
115         void deleteBackgroundColor();
116         void changeFontColor();
117         void deleteFontColor();
118         void changeNoteFontColor();
119         void deleteNoteFontColor();
120         void changeBoxBackgroundColor();
121         void deleteBoxBackgroundColor();
122         void osFontsChanged(bool);
123         void branchesRename(docstring const &, docstring const &);
124 private:
125         /// validate listings parameters and return an error message, if any
126         QString validateListingsParameters();
127
128         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
129         UiWidget<Ui::MasterChildUi> *masterChildModule;
130         UiWidget<Ui::FontUi> *fontModule;
131         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
132         UiWidget<Ui::MarginsUi> *marginsModule;
133         UiWidget<Ui::LanguageUi> *langModule;
134         UiWidget<Ui::ColorUi> *colorModule;
135         UiWidget<Ui::NumberingUi> *numberingModule;
136         UiWidget<Ui::BiblioUi> *biblioModule;
137         UiWidget<Ui::MathsUi> *mathsModule;
138         UiWidget<Ui::LaTeXUi> *latexModule;
139         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
140         UiWidget<Ui::ModulesUi> *modulesModule;
141         UiWidget<Ui::OutputUi> *outputModule;
142         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
143         PreambleModule * preambleModule;
144         LocalLayout * localLayout;
145
146         GuiBranches * branchesModule;
147         GuiIndices * indicesModule;
148
149         BulletsModule * bulletsModule;
150         FloatPlacement * floatModule;
151
152         ModuleSelectionManager * selectionManager;
153
154         /// Available modules
155         GuiIdListModel * availableModel() { return &modules_av_model_; }
156         /// Selected modules
157         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
158
159         /// Apply changes
160         void applyView();
161         /// update
162         void updateContents();
163         ///
164         void updateAvailableModules();
165         ///
166         void updateSelectedModules();
167         ///
168         void updateIncludeonlys();
169         /// save as default template
170         void saveDocDefault();
171         /// reset to default params
172         void useClassDefaults();
173         ///
174         void setLayoutComboByIDString(std::string const & idString);
175
176         /// available classes
177         GuiIdListModel classes_model_;
178         /// available modules
179         GuiIdListModel modules_av_model_;
180         /// selected modules
181         GuiIdListModel modules_sel_model_;
182         /// current buffer
183         BufferId current_id_;
184
185         /// return false if validate_listings_params returns error
186         bool isValid();
187
188         /// font family names for BufferParams::fonts_default_family
189         static char const * const fontfamilies[5];
190         /// GUI names corresponding fontfamilies
191         static char const * fontfamilies_gui[5];
192         ///
193         bool initialiseParams(std::string const & data);
194         ///
195         void clearParams();
196         ///
197         void dispatchParams();
198         ///
199         void modulesToParams(BufferParams &);
200         ///
201         bool isBufferDependent() const { return true; }
202         /// always true since we don't manipulate document contents
203         bool canApply() const { return true; }
204         ///
205         DocumentClass const & documentClass() const;
206         ///
207         BufferParams & params() { return bp_; }
208         ///
209         BufferId id() const;
210         ///
211         struct modInfoStruct {
212                 QString name;
213                 std::string id;
214                 QString description;
215         };
216         /// List of available modules
217         std::list<modInfoStruct> const & getModuleInfo();
218         /// Modules in use in current buffer
219         std::list<modInfoStruct> const getSelectedModules();
220         ///
221         std::list<modInfoStruct> const getProvidedModules();
222         ///
223         std::list<modInfoStruct> const
224                         makeModuleInfo(LayoutModuleList const & mods);
225         ///
226         void setLanguage() const;
227         ///
228         void saveAsDefault() const;
229         ///
230         bool isFontAvailable(std::string const & font) const;
231         /// does this font provide Old Style figures?
232         bool providesOSF(std::string const & font) const;
233         /// does this font provide true Small Caps?
234         bool providesSC(std::string const & font) const;
235         /// does this font provide size adjustment?
236         bool providesScale(std::string const & font) const;
237         ///
238         void executeBranchRenaming() const;
239         ///
240         void setCustomPapersize(bool custom);
241 private:
242         ///
243         void loadModuleInfo();
244         ///
245         void updateUnknownBranches();
246         ///
247         BufferParams bp_;
248         /// List of names of available modules
249         std::list<modInfoStruct> moduleNames_;
250         ///
251         std::map<docstring, docstring> changedBranches_;
252         ///
253         std::list<std::string> includeonlys_;
254         ///
255         bool biblioChanged_;
256 };
257
258
259 class PreambleModule : public UiWidget<Ui::PreambleUi>
260 {
261         Q_OBJECT
262 public:
263         PreambleModule();
264         void update(BufferParams const & params, BufferId id);
265         void apply(BufferParams & params);
266
267 Q_SIGNALS:
268         /// signal that something's changed in the Widget.
269         void changed();
270
271 private:
272         void closeEvent(QCloseEvent *);
273         void on_preambleTE_textChanged() { changed(); }
274
275 private:
276         typedef std::map<BufferId, std::pair<int,int> > Coords;
277         Coords preamble_coords_;
278         BufferId current_id_;
279 };
280
281
282 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
283 {
284         Q_OBJECT
285 public:
286         LocalLayout();
287         void update(BufferParams const & params, BufferId id);
288         void apply(BufferParams & params);
289         bool isValid() const { return is_valid_; }
290
291 Q_SIGNALS:
292         /// signal that something's changed in the Widget.
293         void changed();
294
295 private:
296         void validate();
297         void convert();
298 private Q_SLOTS:
299         void textChanged();
300         void validatePressed();
301         void convertPressed();
302
303 private:
304         BufferId current_id_;
305         bool is_valid_;
306 };
307
308
309 } // namespace frontend
310 } // namespace lyx
311
312 #endif // GUIDOCUMENT_H