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) : 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 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 &);
85 BufferParams const & params() const { return bp_; }
88 void onBufferViewChanged();//override
91 void updateNumbering();
92 void change_adaptor();
93 void shellescapeChanged();
94 void includeonlyClicked(QTreeWidgetItem * item, int);
95 void setListingsMessage();
96 void listingsPackageChanged(int);
97 void saveDefaultClicked();
98 void useDefaultsClicked();
99 void setLSpacing(int);
101 void papersizeChanged(int);
103 void setCustomMargins(bool);
104 void fontencChanged(int);
105 void romanChanged(int);
106 void sansChanged(int);
108 void fontOsfToggled(bool state);
109 void fontScToggled(bool state);
111 void enableIndent(bool);
113 void enableSkip(bool);
114 void allowMathIndent();
115 void enableMathIndent(int);
119 void classChanged_adaptor();
120 void languagePackageChanged(int);
121 void biblioChanged();
122 void rescanBibFiles();
123 void resetDefaultBibfile(std::string const & which = std::string());
124 void resetDefaultBbxBibfile();
125 void resetDefaultCbxBibfile();
126 void citeEngineChanged(int);
127 void citeStyleChanged();
128 void bibtexChanged(int);
129 void updateResetDefaultBiblio();
130 void matchBiblatexStyles();
131 void updateEngineDependends();
132 void updateModuleInfo();
133 void modulesChanged();
134 void changeBackgroundColor();
135 void deleteBackgroundColor();
136 void changeFontColor();
137 void deleteFontColor();
138 void changeNoteFontColor();
139 void deleteNoteFontColor();
140 void changeBoxBackgroundColor();
141 void deleteBoxBackgroundColor();
142 void languageChanged(int);
143 void osFontsChanged(bool);
144 void mathFontChanged(int);
145 void branchesRename(docstring const &, docstring const &);
146 void allPackagesAuto();
147 void allPackagesAlways();
148 void allPackagesNot();
150 /// validate listings parameters and return an error message, if any
151 QString validateListingsParameters();
153 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
154 UiWidget<Ui::MasterChildUi> *masterChildModule;
155 FontModule *fontModule;
156 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
157 UiWidget<Ui::MarginsUi> *marginsModule;
158 UiWidget<Ui::LanguageUi> *langModule;
159 UiWidget<Ui::ColorUi> *colorModule;
160 UiWidget<Ui::NumberingUi> *numberingModule;
161 UiWidget<Ui::BiblioUi> *biblioModule;
162 UiWidget<Ui::MathsUi> *mathsModule;
163 UiWidget<Ui::LaTeXUi> *latexModule;
164 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
165 UiWidget<Ui::ModulesUi> *modulesModule;
166 UiWidget<Ui::OutputUi> *outputModule;
167 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
168 PreambleModule * preambleModule;
169 LocalLayout * localLayout;
171 GuiBranches * branchesModule;
172 GuiIndices * indicesModule;
174 BulletsModule * bulletsModule;
175 FloatPlacement * floatModule;
177 ModuleSelectionManager * selectionManager;
179 /// Available modules
180 GuiIdListModel * availableModel() { return &modules_av_model_; }
182 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
187 void updateContents();
189 void updateAvailableModules();
191 void updateSelectedModules();
193 void updateIncludeonlys();
195 void updateDefaultBiblio(std::string const & style,
196 std::string const & which = std::string());
197 /// save as default template
198 void saveDocDefault();
199 /// reset to default params
200 void useClassDefaults();
202 void setLayoutComboByIDString(std::string const & idString);
203 /// Update quotes styles combo, indicating the current language's default
204 void updateQuoteStyles(bool const set = false);
206 /// available modules
207 GuiIdListModel modules_av_model_;
209 GuiIdListModel modules_sel_model_;
211 /// return false if validate_listings_params returns error
214 /// font family names for BufferParams::fonts_default_family
215 static char const * const fontfamilies[5];
216 /// GUI names corresponding fontfamilies
217 static char const * fontfamilies_gui[5];
219 bool initialiseParams(std::string const & data);
223 void dispatchParams();
225 void modulesToParams(BufferParams &);
227 bool isBufferDependent() const { return true; }
228 /// always true since we don't manipulate document contents
229 bool canApply() const { return true; }
231 DocumentClass const & documentClass() const;
233 BufferParams & params() { return bp_; }
237 struct modInfoStruct {
243 static modInfoStruct modInfo(LyXModule const & mod);
244 /// List of available modules
245 std::list<modInfoStruct> const & getModuleInfo();
246 /// Modules in use in current buffer
247 std::list<modInfoStruct> const getSelectedModules();
249 std::list<modInfoStruct> const getProvidedModules();
251 std::list<modInfoStruct> const
252 makeModuleInfo(LayoutModuleList const & mods);
254 void setLanguage() const;
256 void saveAsDefault() const;
257 /// does this font provide Old Style figures?
258 bool providesOSF(QString const & font) const;
259 /// does this font provide true Small Caps?
260 bool providesSC(QString const & font) const;
261 /** does this font provide OSF and Small Caps only via
262 * a single, undifferentiated expert option?
264 bool hasMonolithicExpertSet(QString const & font) const;
265 /// does this font provide size adjustment?
266 bool providesScale(QString const & font) const;
267 /// does this font provide an alternative without math?
268 bool providesNoMath(QString const & font) const;
270 void executeBranchRenaming() const;
272 void setCustomPapersize(bool custom);
275 void loadModuleInfo();
277 void updateUnknownBranches();
279 void updateTexFonts();
281 void updateMathFonts(QString const & rm);
283 void updateFontOptions();
287 bool completeFontset() const;
289 bool noMathFont() const;
291 void allPackages(int);
293 bool isBiblatex() const;
296 /// List of names of available modules
297 std::list<modInfoStruct> moduleNames_;
299 std::map<docstring, docstring> changedBranches_;
301 std::list<std::string> includeonlys_;
304 /// Track if a non-module document param changed
305 bool nonModuleChanged_;
309 class PreambleModule : public UiWidget<Ui::PreambleUi>
313 PreambleModule(QWidget * parent);
314 void update(BufferParams const & params, BufferId id);
315 void apply(BufferParams & params);
318 /// signal that something's changed in the Widget.
322 void closeEvent(QCloseEvent *);
323 void on_preambleTE_textChanged() { changed(); }
326 typedef std::map<BufferId, std::pair<int,int> > Coords;
327 Coords preamble_coords_;
328 BufferId current_id_;
332 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
336 LocalLayout(QWidget * parent);
337 void update(BufferParams const & params, BufferId id);
338 void apply(BufferParams & params);
339 bool isValid() const { return validated_; }
342 /// signal that something's changed in the Widget.
351 void validatePressed();
352 void convertPressed();
355 BufferId current_id_;
360 class FontModule : public UiWidget<Ui::FontUi>
364 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
365 font_sf_scale(100), font_tt_scale(100) {}
366 /// The roman font currently not selected by osFontsCB->isChecked()
368 /// The sans font currently not selected by osFontsCB->isChecked()
370 /// The typewriter font currently not selected by osFontsCB->isChecked()
371 QString font_typewriter;
372 /// The math font currently not selected by osFontsCB->isChecked()
374 /// The sans font scale currently not selected by osFontsCB->isChecked()
376 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
381 } // namespace frontend
384 #endif // GUIDOCUMENT_H