4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
8 * \author Richard Heck (modules)
10 * Full author contact details are available in file CREDITS.
16 #include "BufferParams.h"
17 #include "BulletsModule.h"
18 #include "GuiDialog.h"
19 #include "GuiIdListModel.h"
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"
43 class LayoutModuleList;
52 class ModuleSelectionManager;
58 typedef void const * BufferId;
61 class UiWidget : public QWidget, public UI
64 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
68 class GuiDocument : public GuiDialog, public Ui::DocumentUi
72 GuiDocument(GuiView & lv);
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 &);
83 BufferParams const & params() const { return bp_; }
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);
94 void papersizeChanged(int);
96 void setCustomMargins(bool);
97 void fontencChanged(int);
98 void romanChanged(int);
99 void sansChanged(int);
101 void fontOsfToggled(bool state);
102 void fontScToggled(bool state);
104 void enableIndent(bool);
106 void enableSkip(bool);
110 void classChanged_adaptor();
111 void languagePackageChanged(int);
112 void biblioChanged();
113 void bibtexChanged(int);
114 void setAuthorYear(bool);
115 void setNumerical(bool);
116 void updateModuleInfo();
117 void modulesChanged();
118 void changeBackgroundColor();
119 void deleteBackgroundColor();
120 void changeFontColor();
121 void deleteFontColor();
122 void changeNoteFontColor();
123 void deleteNoteFontColor();
124 void changeBoxBackgroundColor();
125 void deleteBoxBackgroundColor();
126 void languageChanged(int);
127 void osFontsChanged(bool);
128 void mathFontChanged(int);
129 void branchesRename(docstring const &, docstring const &);
130 void allPackagesAuto();
131 void allPackagesAlways();
132 void allPackagesNot();
134 /// validate listings parameters and return an error message, if any
135 QString validateListingsParameters();
137 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
138 UiWidget<Ui::MasterChildUi> *masterChildModule;
139 FontModule *fontModule;
140 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
141 UiWidget<Ui::MarginsUi> *marginsModule;
142 UiWidget<Ui::LanguageUi> *langModule;
143 UiWidget<Ui::ColorUi> *colorModule;
144 UiWidget<Ui::NumberingUi> *numberingModule;
145 UiWidget<Ui::BiblioUi> *biblioModule;
146 UiWidget<Ui::MathsUi> *mathsModule;
147 UiWidget<Ui::LaTeXUi> *latexModule;
148 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
149 UiWidget<Ui::ModulesUi> *modulesModule;
150 UiWidget<Ui::OutputUi> *outputModule;
151 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
152 PreambleModule * preambleModule;
153 LocalLayout * localLayout;
155 GuiBranches * branchesModule;
156 GuiIndices * indicesModule;
158 BulletsModule * bulletsModule;
159 FloatPlacement * floatModule;
161 ModuleSelectionManager * selectionManager;
163 /// Available modules
164 GuiIdListModel * availableModel() { return &modules_av_model_; }
166 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
171 void updateContents();
173 void updateAvailableModules();
175 void updateSelectedModules();
177 void updateIncludeonlys();
178 /// save as default template
179 void saveDocDefault();
180 /// reset to default params
181 void useClassDefaults();
183 void setLayoutComboByIDString(std::string const & idString);
185 /// available modules
186 GuiIdListModel modules_av_model_;
188 GuiIdListModel modules_sel_model_;
190 /// return false if validate_listings_params returns error
193 /// font family names for BufferParams::fonts_default_family
194 static char const * const fontfamilies[5];
195 /// GUI names corresponding fontfamilies
196 static char const * fontfamilies_gui[5];
198 bool initialiseParams(std::string const & data);
202 void dispatchParams();
204 void modulesToParams(BufferParams &);
206 bool isBufferDependent() const { return true; }
207 /// always true since we don't manipulate document contents
208 bool canApply() const { return true; }
210 DocumentClass const & documentClass() const;
212 BufferParams & params() { return bp_; }
216 struct modInfoStruct {
222 static modInfoStruct modInfo(LyXModule const & mod);
223 /// List of available modules
224 std::list<modInfoStruct> const & getModuleInfo();
225 /// Modules in use in current buffer
226 std::list<modInfoStruct> const getSelectedModules();
228 std::list<modInfoStruct> const getProvidedModules();
230 std::list<modInfoStruct> const
231 makeModuleInfo(LayoutModuleList const & mods);
233 void setLanguage() const;
235 void saveAsDefault() const;
236 /// does this font provide Old Style figures?
237 bool providesOSF(QString const & font) const;
238 /// does this font provide true Small Caps?
239 bool providesSC(QString const & font) const;
240 /** does this font provide OSF and Small Caps only via
241 * a single, undifferentiated expert option?
243 bool hasMonolithicExpertSet(QString const & font) const;
244 /// does this font provide size adjustment?
245 bool providesScale(QString const & font) const;
246 /// does this font provide an alternative without math?
247 bool providesNoMath(QString const & font) const;
249 void executeBranchRenaming() const;
251 void setCustomPapersize(bool custom);
254 void loadModuleInfo();
256 void updateUnknownBranches();
258 void updateTexFonts();
260 void updateMathFonts(QString const & rm);
262 void updateFontOptions();
266 bool completeFontset() const;
268 bool noMathFont() const;
270 void allPackages(int);
273 /// List of names of available modules
274 std::list<modInfoStruct> moduleNames_;
276 std::map<docstring, docstring> changedBranches_;
278 std::list<std::string> includeonlys_;
281 /// Track if a non-module document param changed
282 bool nonModuleChanged_;
286 class PreambleModule : public UiWidget<Ui::PreambleUi>
291 void update(BufferParams const & params, BufferId id);
292 void apply(BufferParams & params);
295 /// signal that something's changed in the Widget.
299 void closeEvent(QCloseEvent *);
300 void on_preambleTE_textChanged() { changed(); }
303 typedef std::map<BufferId, std::pair<int,int> > Coords;
304 Coords preamble_coords_;
305 BufferId current_id_;
309 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
314 void update(BufferParams const & params, BufferId id);
315 void apply(BufferParams & params);
316 bool isValid() const { return validated_; }
319 /// signal that something's changed in the Widget.
328 void validatePressed();
329 void convertPressed();
332 BufferId current_id_;
337 class FontModule : public UiWidget<Ui::FontUi>
341 /// The roman font currently not selected by osFontsCB->isChecked()
343 /// The sans font currently not selected by osFontsCB->isChecked()
345 /// The typewriter font currently not selected by osFontsCB->isChecked()
346 QString font_typewriter;
347 /// The math font currently not selected by osFontsCB->isChecked()
349 /// The sans font scale currently not selected by osFontsCB->isChecked()
351 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
356 } // namespace frontend
359 #endif // GUIDOCUMENT_H