]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.h
Not sure why "notr = 'true'" got in there.
[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 "BufferParams.h"
17 #include "BulletsModule.h"
18 #include "GuiDialog.h"
19 #include "GuiIdListModel.h"
20
21 #include "ui_BiblioUi.h"
22 #include "ui_ColorUi.h"
23 #include "ui_DocumentUi.h"
24 #include "ui_FontUi.h"
25 #include "ui_LanguageUi.h"
26 #include "ui_LaTeXUi.h"
27 #include "ui_ListingsSettingsUi.h"
28 #include "ui_LocalLayoutUi.h"
29 #include "ui_MarginsUi.h"
30 #include "ui_MasterChildUi.h"
31 #include "ui_MathsUi.h"
32 #include "ui_ModulesUi.h"
33 #include "ui_NumberingUi.h"
34 #include "ui_OutputUi.h"
35 #include "ui_PageLayoutUi.h"
36 #include "ui_PDFSupportUi.h"
37 #include "ui_PreambleUi.h"
38 #include "ui_TextLayoutUi.h"
39
40 namespace lyx {
41
42 class BufferParams;
43 class LayoutModuleList;
44 class LyXModule;
45 class TextClass;
46
47 namespace frontend {
48
49 class FloatPlacement;
50 class GuiBranches;
51 class GuiIndices;
52 class ModuleSelectionManager;
53 class PreambleModule;
54 class LocalLayout;
55 class FontModule;
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 updateEngineType(std::string const &, CiteEngineType const &);
79         void updatePagestyle(std::string const &, std::string const &);
80         bool isChildIncluded(std::string const &);
81
82         ///
83         BufferParams const & params() const { return bp_; }
84
85 public Q_SLOTS:
86         void onBufferViewChanged();//override
87
88 private Q_SLOTS:
89         void updateNumbering();
90         void change_adaptor();
91         void includeonlyClicked(QTreeWidgetItem * item, int);
92         void setListingsMessage();
93         void saveDefaultClicked();
94         void useDefaultsClicked();
95         void setLSpacing(int);
96         void setMargins();
97         void papersizeChanged(int);
98         void setColSep();
99         void setCustomMargins(bool);
100         void fontencChanged(int);
101         void romanChanged(int);
102         void sansChanged(int);
103         void ttChanged(int);
104         void fontOsfToggled(bool state);
105         void fontScToggled(bool state);
106         void setIndent(int);
107         void enableIndent(bool);
108         void setSkip(int);
109         void enableSkip(bool);
110         void browseLayout();
111         void browseMaster();
112         void classChanged();
113         void classChanged_adaptor();
114         void languagePackageChanged(int);
115         void biblioChanged();
116         void bibtexChanged(int);
117         void setAuthorYear(bool);
118         void setNumerical(bool);
119         void updateModuleInfo();
120         void modulesChanged();
121         void changeBackgroundColor();
122         void deleteBackgroundColor();
123         void changeFontColor();
124         void deleteFontColor();
125         void changeNoteFontColor();
126         void deleteNoteFontColor();
127         void changeBoxBackgroundColor();
128         void deleteBoxBackgroundColor();
129         void languageChanged(int);
130         void osFontsChanged(bool);
131         void mathFontChanged(int);
132         void branchesRename(docstring const &, docstring const &);
133         void allPackagesAuto();
134         void allPackagesAlways();
135         void allPackagesNot();
136 private:
137         /// validate listings parameters and return an error message, if any
138         QString validateListingsParameters();
139
140         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
141         UiWidget<Ui::MasterChildUi> *masterChildModule;
142         FontModule *fontModule;
143         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
144         UiWidget<Ui::MarginsUi> *marginsModule;
145         UiWidget<Ui::LanguageUi> *langModule;
146         UiWidget<Ui::ColorUi> *colorModule;
147         UiWidget<Ui::NumberingUi> *numberingModule;
148         UiWidget<Ui::BiblioUi> *biblioModule;
149         UiWidget<Ui::MathsUi> *mathsModule;
150         UiWidget<Ui::LaTeXUi> *latexModule;
151         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
152         UiWidget<Ui::ModulesUi> *modulesModule;
153         UiWidget<Ui::OutputUi> *outputModule;
154         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
155         PreambleModule * preambleModule;
156         LocalLayout * localLayout;
157
158         GuiBranches * branchesModule;
159         GuiIndices * indicesModule;
160
161         BulletsModule * bulletsModule;
162         FloatPlacement * floatModule;
163
164         ModuleSelectionManager * selectionManager;
165
166         /// Available modules
167         GuiIdListModel * availableModel() { return &modules_av_model_; }
168         /// Selected modules
169         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
170
171         /// Apply changes
172         void applyView();
173         /// update
174         void updateContents();
175         ///
176         void updateAvailableModules();
177         ///
178         void updateSelectedModules();
179         ///
180         void updateIncludeonlys();
181         /// save as default template
182         void saveDocDefault();
183         /// reset to default params
184         void useClassDefaults();
185         ///
186         void setLayoutComboByIDString(std::string const & idString);
187
188         /// available modules
189         GuiIdListModel modules_av_model_;
190         /// selected modules
191         GuiIdListModel modules_sel_model_;
192
193         /// return false if validate_listings_params returns error
194         bool isValid();
195
196         /// font family names for BufferParams::fonts_default_family
197         static char const * const fontfamilies[5];
198         /// GUI names corresponding fontfamilies
199         static char const * fontfamilies_gui[5];
200         ///
201         bool initialiseParams(std::string const & data);
202         ///
203         void clearParams();
204         ///
205         void dispatchParams();
206         ///
207         void modulesToParams(BufferParams &);
208         ///
209         bool isBufferDependent() const { return true; }
210         /// always true since we don't manipulate document contents
211         bool canApply() const { return true; }
212         ///
213         DocumentClass const & documentClass() const;
214         ///
215         BufferParams & params() { return bp_; }
216         ///
217         BufferId id() const;
218         ///
219         struct modInfoStruct {
220                 QString name;
221                 std::string id;
222                 QString description;
223         };
224         ///
225         static modInfoStruct modInfo(LyXModule const & mod);
226         /// List of available modules
227         std::list<modInfoStruct> const & getModuleInfo();
228         /// Modules in use in current buffer
229         std::list<modInfoStruct> const getSelectedModules();
230         ///
231         std::list<modInfoStruct> const getProvidedModules();
232         ///
233         std::list<modInfoStruct> const
234                         makeModuleInfo(LayoutModuleList const & mods);
235         ///
236         void setLanguage() const;
237         ///
238         void saveAsDefault() const;
239         /// does this font provide Old Style figures?
240         bool providesOSF(QString const & font) const;
241         /// does this font provide true Small Caps?
242         bool providesSC(QString const & font) const;
243         /** does this font provide OSF and Small Caps only via 
244          * a single, undifferentiated expert option?
245          */
246         bool hasMonolithicExpertSet(QString const & font) const;
247         /// does this font provide size adjustment?
248         bool providesScale(QString const & font) const;
249         /// does this font provide an alternative without math?
250         bool providesNoMath(QString const & font) const;
251         ///
252         void executeBranchRenaming() const;
253         ///
254         void setCustomPapersize(bool custom);
255 private:
256         ///
257         void loadModuleInfo();
258         ///
259         void updateUnknownBranches();
260         ///
261         void updateTexFonts();
262         ///
263         void updateMathFonts(QString const & rm);
264         ///
265         void updateFontOptions();
266         ///
267         bool ot1() const;
268         ///
269         bool completeFontset() const;
270         ///
271         bool noMathFont() const;
272         ///
273         void allPackages(int);
274         ///
275         BufferParams bp_;
276         /// List of names of available modules
277         std::list<modInfoStruct> moduleNames_;
278         ///
279         std::map<docstring, docstring> changedBranches_;
280         ///
281         std::list<std::string> includeonlys_;
282         ///
283         bool biblioChanged_;
284         /// Track if a non-module document param changed
285         bool nonModuleChanged_;
286 };
287
288
289 class PreambleModule : public UiWidget<Ui::PreambleUi>
290 {
291         Q_OBJECT
292 public:
293         PreambleModule();
294         void update(BufferParams const & params, BufferId id);
295         void apply(BufferParams & params);
296
297 Q_SIGNALS:
298         /// signal that something's changed in the Widget.
299         void changed();
300
301 private:
302         void closeEvent(QCloseEvent *);
303         void on_preambleTE_textChanged() { changed(); }
304
305 private:
306         typedef std::map<BufferId, std::pair<int,int> > Coords;
307         Coords preamble_coords_;
308         BufferId current_id_;
309 };
310
311
312 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
313 {
314         Q_OBJECT
315 public:
316         LocalLayout();
317         void update(BufferParams const & params, BufferId id);
318         void apply(BufferParams & params);
319         bool isValid() const { return validated_; }
320
321 Q_SIGNALS:
322         /// signal that something's changed in the Widget.
323         void changed();
324
325 private:
326         void validate();
327         void convert();
328         void hideConvert();
329 private Q_SLOTS:
330         void textChanged();
331         void validatePressed();
332         void convertPressed();
333
334 private:
335         BufferId current_id_;
336         bool validated_;
337 };
338
339
340 class FontModule : public UiWidget<Ui::FontUi>
341 {
342         Q_OBJECT
343 public:
344         /// The roman font currently not selected by osFontsCB->isChecked()
345         QString font_roman;
346         /// The sans font currently not selected by osFontsCB->isChecked()
347         QString font_sans;
348         /// The typewriter font currently not selected by osFontsCB->isChecked()
349         QString font_typewriter;
350         /// The math font currently not selected by osFontsCB->isChecked()
351         QString font_math;
352         /// The sans font scale currently not selected by osFontsCB->isChecked()
353         int font_sf_scale;
354         /// The typewriter font scale currently not selected by osFontsCB->isChecked()
355         int font_tt_scale;
356 };
357
358
359 } // namespace frontend
360 } // namespace lyx
361
362 #endif // GUIDOCUMENT_H