]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.h
If a LaTeX font has a monolithic option for all expert sets (Osf, SC), honor this...
[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 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 private Q_SLOTS:
86         void updateNumbering();
87         void change_adaptor();
88         void includeonlyClicked(QTreeWidgetItem * item, int);
89         void setListingsMessage();
90         void saveDefaultClicked();
91         void useDefaultsClicked();
92         void setLSpacing(int);
93         void setMargins();
94         void papersizeChanged(int);
95         void setColSep();
96         void setCustomMargins(bool);
97         void fontencChanged(int);
98         void romanChanged(int);
99         void sansChanged(int);
100         void ttChanged(int);
101         void fontOsfToggled(bool state);
102         void fontScToggled(bool state);
103         void setIndent(int);
104         void enableIndent(bool);
105         void setSkip(int);
106         void enableSkip(bool);
107         void browseLayout();
108         void browseMaster();
109         void classChanged();
110         void languagePackageChanged(int);
111         void biblioChanged();
112         void bibtexChanged(int);
113         void setAuthorYear(bool);
114         void setNumerical(bool);
115         void updateModuleInfo();
116         void modulesChanged();
117         void changeBackgroundColor();
118         void deleteBackgroundColor();
119         void changeFontColor();
120         void deleteFontColor();
121         void changeNoteFontColor();
122         void deleteNoteFontColor();
123         void changeBoxBackgroundColor();
124         void deleteBoxBackgroundColor();
125         void languageChanged(int);
126         void osFontsChanged(bool);
127         void mathFontChanged(int);
128         void branchesRename(docstring const &, docstring const &);
129 private:
130         /// validate listings parameters and return an error message, if any
131         QString validateListingsParameters();
132
133         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
134         UiWidget<Ui::MasterChildUi> *masterChildModule;
135         UiWidget<Ui::FontUi> *fontModule;
136         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
137         UiWidget<Ui::MarginsUi> *marginsModule;
138         UiWidget<Ui::LanguageUi> *langModule;
139         UiWidget<Ui::ColorUi> *colorModule;
140         UiWidget<Ui::NumberingUi> *numberingModule;
141         UiWidget<Ui::BiblioUi> *biblioModule;
142         UiWidget<Ui::MathsUi> *mathsModule;
143         UiWidget<Ui::LaTeXUi> *latexModule;
144         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
145         UiWidget<Ui::ModulesUi> *modulesModule;
146         UiWidget<Ui::OutputUi> *outputModule;
147         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
148         PreambleModule * preambleModule;
149         LocalLayout * localLayout;
150
151         GuiBranches * branchesModule;
152         GuiIndices * indicesModule;
153
154         BulletsModule * bulletsModule;
155         FloatPlacement * floatModule;
156
157         ModuleSelectionManager * selectionManager;
158
159         /// Available modules
160         GuiIdListModel * availableModel() { return &modules_av_model_; }
161         /// Selected modules
162         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
163
164         /// Apply changes
165         void applyView();
166         /// update
167         void updateContents();
168         ///
169         void updateAvailableModules();
170         ///
171         void updateSelectedModules();
172         ///
173         void updateIncludeonlys();
174         /// save as default template
175         void saveDocDefault();
176         /// reset to default params
177         void useClassDefaults();
178         ///
179         void setLayoutComboByIDString(std::string const & idString);
180
181         /// available modules
182         GuiIdListModel modules_av_model_;
183         /// selected modules
184         GuiIdListModel modules_sel_model_;
185         /// current buffer
186         BufferId current_id_;
187
188         /// return false if validate_listings_params returns error
189         bool isValid();
190
191         /// font family names for BufferParams::fonts_default_family
192         static char const * const fontfamilies[5];
193         /// GUI names corresponding fontfamilies
194         static char const * fontfamilies_gui[5];
195         ///
196         bool initialiseParams(std::string const & data);
197         ///
198         void clearParams();
199         ///
200         void dispatchParams();
201         ///
202         void modulesToParams(BufferParams &);
203         ///
204         bool isBufferDependent() const { return true; }
205         /// always true since we don't manipulate document contents
206         bool canApply() const { return true; }
207         ///
208         DocumentClass const & documentClass() const;
209         ///
210         BufferParams & params() { return bp_; }
211         ///
212         BufferId id() const;
213         ///
214         struct modInfoStruct {
215                 QString name;
216                 std::string id;
217                 QString description;
218         };
219         /// List of available modules
220         std::list<modInfoStruct> const & getModuleInfo();
221         /// Modules in use in current buffer
222         std::list<modInfoStruct> const getSelectedModules();
223         ///
224         std::list<modInfoStruct> const getProvidedModules();
225         ///
226         std::list<modInfoStruct> const
227                         makeModuleInfo(LayoutModuleList const & mods);
228         ///
229         void setLanguage() const;
230         ///
231         void saveAsDefault() const;
232         /// does this font provide Old Style figures?
233         bool providesOSF(QString const & font) const;
234         /// does this font provide true Small Caps?
235         bool providesSC(QString const & font) const;
236         /** does this font provide OSF and Small Caps only via 
237          * a single, undifferentiated expert option?
238          */
239         bool hasMonolithicExpertSet(QString const & font) const;
240         /// does this font provide size adjustment?
241         bool providesScale(QString const & font) const;
242         /// does this font provide an alternative without math?
243         bool providesNoMath(QString const & font) const;
244         ///
245         void executeBranchRenaming() const;
246         ///
247         void setCustomPapersize(bool custom);
248 private:
249         ///
250         void loadModuleInfo();
251         ///
252         void updateUnknownBranches();
253         ///
254         void updateTexFonts();
255         ///
256         void updateMathFonts(QString const & rm);
257         ///
258         void updateFontOptions();
259         ///
260         bool ot1() const;
261         ///
262         bool completeFontset() const;
263         ///
264         bool noMathFont() const;
265         ///
266         BufferParams bp_;
267         /// List of names of available modules
268         std::list<modInfoStruct> moduleNames_;
269         ///
270         std::map<docstring, docstring> changedBranches_;
271         ///
272         std::list<std::string> includeonlys_;
273         ///
274         bool biblioChanged_;
275 };
276
277
278 class PreambleModule : public UiWidget<Ui::PreambleUi>
279 {
280         Q_OBJECT
281 public:
282         PreambleModule();
283         void update(BufferParams const & params, BufferId id);
284         void apply(BufferParams & params);
285
286 Q_SIGNALS:
287         /// signal that something's changed in the Widget.
288         void changed();
289
290 private:
291         void closeEvent(QCloseEvent *);
292         void on_preambleTE_textChanged() { changed(); }
293
294 private:
295         typedef std::map<BufferId, std::pair<int,int> > Coords;
296         Coords preamble_coords_;
297         BufferId current_id_;
298 };
299
300
301 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
302 {
303         Q_OBJECT
304 public:
305         LocalLayout();
306         void update(BufferParams const & params, BufferId id);
307         void apply(BufferParams & params);
308         bool isValid() const { return validated_; }
309
310 Q_SIGNALS:
311         /// signal that something's changed in the Widget.
312         void changed();
313
314 private:
315         void validate();
316         void convert();
317 private Q_SLOTS:
318         void textChanged();
319         void validatePressed();
320         void convertPressed();
321
322 private:
323         BufferId current_id_;
324         bool validated_;
325 };
326
327
328 } // namespace frontend
329 } // namespace lyx
330
331 #endif // GUIDOCUMENT_H