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