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;
56 class ModuleSelectionManager;
62 typedef Buffer const * BufferId;
65 class UiWidget : public QWidget, public UI
68 UiWidget(QWidget * parent) : QWidget(parent) { UI::setupUi(this); }
72 class GuiDocument : public GuiDialog, public Ui::DocumentUi
76 GuiDocument(GuiView & lv);
78 void paramsToDialog();
79 void updateFontsize(std::string const &, std::string const &);
80 void updateFontlist();
81 void updateDefaultFormat();
82 void updateCiteStyles(std::vector<std::string> const &,
83 CiteEngineType const & sel = ENGINE_TYPE_AUTHORYEAR);
84 void updateEngineType(std::string const &, CiteEngineType const &);
85 void updatePagestyle(std::string const &, std::string const &);
86 bool isChildIncluded(std::string const &);
89 BufferParams const & params() const { return bp_; }
92 void onBufferViewChanged();//override
95 // Apply button clicked
97 void slotButtonBox(QAbstractButton *);
100 void updateNumbering();
101 void change_adaptor();
102 void shellescapeChanged();
103 void includeonlyClicked(QTreeWidgetItem * item, int);
104 void setListingsMessage();
105 void listingsPackageChanged(int);
106 void saveDefaultClicked();
107 void useDefaultsClicked();
108 void setLSpacing(int);
110 void papersizeChanged(int);
112 void setCustomMargins(bool);
113 void fontencChanged(int);
114 void romanChanged(int);
115 void sansChanged(int);
117 void fontOsfToggled(bool state);
118 void fontScToggled(bool state);
120 void enableIndent(bool);
122 void enableSkip(bool);
123 void allowMathIndent();
124 void enableMathIndent(int);
128 void classChanged_adaptor();
129 void languagePackageChanged(int);
130 void biblioChanged();
131 void rescanBibFiles();
132 void resetDefaultBibfile(std::string const & which = std::string());
133 void resetDefaultBbxBibfile();
134 void resetDefaultCbxBibfile();
135 void citeEngineChanged(int);
136 void citeStyleChanged();
137 void bibtexChanged(int);
138 void updateResetDefaultBiblio();
139 void matchBiblatexStyles();
140 void updateEngineDependends();
141 void updateModuleInfo();
142 void modulesChanged();
143 void changeBackgroundColor();
144 void deleteBackgroundColor();
145 void changeFontColor();
146 void deleteFontColor();
147 void changeNoteFontColor();
148 void deleteNoteFontColor();
149 void changeBoxBackgroundColor();
150 void deleteBoxBackgroundColor();
151 void languageChanged(int);
152 void osFontsChanged(bool);
153 void mathFontChanged(int);
154 void branchesRename(docstring const &, docstring const &);
155 void allPackagesAuto();
156 void allPackagesAlways();
157 void allPackagesNot();
159 /// validate listings parameters and return an error message, if any
160 QString validateListingsParameters();
162 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
163 UiWidget<Ui::MasterChildUi> *masterChildModule;
164 FontModule *fontModule;
165 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
166 UiWidget<Ui::MarginsUi> *marginsModule;
167 UiWidget<Ui::LanguageUi> *langModule;
168 UiWidget<Ui::ColorUi> *colorModule;
169 UiWidget<Ui::NumberingUi> *numberingModule;
170 UiWidget<Ui::BiblioUi> *biblioModule;
171 UiWidget<Ui::MathsUi> *mathsModule;
172 UiWidget<Ui::LaTeXUi> *latexModule;
173 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
174 UiWidget<Ui::ModulesUi> *modulesModule;
175 UiWidget<Ui::OutputUi> *outputModule;
176 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
177 PreambleModule * preambleModule;
178 LocalLayout * localLayout;
180 GuiBranches * branchesModule;
181 GuiIndices * indicesModule;
183 BulletsModule * bulletsModule;
184 FloatPlacement * floatModule;
186 ModuleSelectionManager * selectionManager;
188 /// Available modules
189 GuiIdListModel * availableModel() { return &modules_av_model_; }
191 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
196 void updateContents();
198 void updateAvailableModules();
200 void updateSelectedModules();
202 void updateIncludeonlys();
204 void updateDefaultBiblio(std::string const & style,
205 std::string const & which = std::string());
206 /// save as default template
207 void saveDocDefault();
208 /// reset to default params
209 void useClassDefaults();
211 void setLayoutComboByIDString(std::string const & idString);
212 /// Update quotes styles combo, indicating the current language's default
213 void updateQuoteStyles(bool const set = false);
215 /// available modules
216 GuiIdListModel modules_av_model_;
218 GuiIdListModel modules_sel_model_;
220 /// return false if validate_listings_params returns error
223 /// font family names for BufferParams::fonts_default_family
224 static char const * const fontfamilies[5];
225 /// GUI names corresponding fontfamilies
226 static char const * fontfamilies_gui[5];
228 bool initialiseParams(std::string const & data);
232 void dispatchParams();
234 void modulesToParams(BufferParams &);
236 bool isBufferDependent() const { return true; }
237 /// always true since we don't manipulate document contents
238 bool canApply() const { return true; }
240 DocumentClass const & documentClass() const;
242 BufferParams & params() { return bp_; }
246 struct modInfoStruct {
252 static modInfoStruct modInfo(LyXModule const & mod);
253 /// List of available modules
254 std::list<modInfoStruct> const & getModuleInfo();
255 /// Modules in use in current buffer
256 std::list<modInfoStruct> const getSelectedModules();
258 std::list<modInfoStruct> const getProvidedModules();
260 std::list<modInfoStruct> const
261 makeModuleInfo(LayoutModuleList const & mods);
263 void setLanguage() const;
265 void saveAsDefault() const;
266 /// does this font provide Old Style figures?
267 bool providesOSF(QString const & font) const;
268 /// does this font provide true Small Caps?
269 bool providesSC(QString const & font) const;
270 /** does this font provide OSF and Small Caps only via
271 * a single, undifferentiated expert option?
273 bool hasMonolithicExpertSet(QString const & font) const;
274 /// does this font provide size adjustment?
275 bool providesScale(QString const & font) const;
276 /// does this font provide an alternative without math?
277 bool providesNoMath(QString const & font) const;
279 void executeBranchRenaming() const;
281 void setCustomPapersize(bool custom);
284 void loadModuleInfo();
286 void updateUnknownBranches();
288 void updateTexFonts();
290 void updateMathFonts(QString const & rm);
292 void updateFontOptions();
296 bool completeFontset() const;
298 bool noMathFont() const;
300 void allPackages(int);
302 bool isBiblatex() const;
304 void checkPossibleCiteEngines();
307 /// List of names of available modules
308 std::list<modInfoStruct> moduleNames_;
310 std::map<docstring, docstring> changedBranches_;
312 std::list<std::string> includeonlys_;
315 /// Track if a non-module document param changed
316 bool nonModuleChanged_;
317 /// Track if used modules changed
318 bool modulesChanged_;
319 /// Track if the shellescape param changed
320 bool shellescapeChanged_;
324 class PreambleModule : public UiWidget<Ui::PreambleUi>
328 PreambleModule(QWidget * parent);
329 void update(BufferParams const & params, BufferId id);
330 void apply(BufferParams & params);
331 bool editing() const { return (bool)tempfile_; }
334 /// signal that something's changed in the Widget.
338 void closeEvent(QCloseEvent *);
339 void on_preambleTE_textChanged() { changed(); }
341 typedef std::map<BufferId, std::pair<int,int> > Coords;
342 Coords preamble_coords_;
343 BufferId current_id_;
344 unique_ptr<support::TempFile> tempfile_;
348 void checkFindButton();
354 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
358 LocalLayout(QWidget * parent);
359 void update(BufferParams const & params, BufferId id);
360 void apply(BufferParams & params);
361 bool isValid() const { return validated_; }
362 bool editing() const { return (bool)tempfile_; }
365 /// signal that something's changed in the Widget.
374 void validatePressed();
375 void convertPressed();
379 BufferId current_id_;
381 unique_ptr<support::TempFile> tempfile_;
385 class FontModule : public UiWidget<Ui::FontUi>
389 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
390 font_sf_scale(100), font_tt_scale(100) {}
391 /// The roman font currently not selected by osFontsCB->isChecked()
393 /// The sans font currently not selected by osFontsCB->isChecked()
395 /// The typewriter font currently not selected by osFontsCB->isChecked()
396 QString font_typewriter;
397 /// The math font currently not selected by osFontsCB->isChecked()
399 /// The sans font scale currently not selected by osFontsCB->isChecked()
401 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
406 } // namespace frontend
409 #endif // GUIDOCUMENT_H