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 void getTableStyles();
217 /// available modules
218 GuiIdListModel modules_av_model_;
220 GuiIdListModel modules_sel_model_;
222 /// return false if validate_listings_params returns error
225 /// font family names for BufferParams::fonts_default_family
226 static char const * const fontfamilies[5];
227 /// GUI names corresponding fontfamilies
228 static char const * fontfamilies_gui[5];
230 bool initialiseParams(std::string const & data);
234 void dispatchParams();
236 void modulesToParams(BufferParams &);
238 bool isBufferDependent() const { return true; }
239 /// always true since we don't manipulate document contents
240 bool canApply() const { return true; }
242 DocumentClass const & documentClass() const;
244 BufferParams & params() { return bp_; }
248 struct modInfoStruct {
254 static modInfoStruct modInfo(LyXModule const & mod);
255 /// List of available modules
256 std::list<modInfoStruct> const & getModuleInfo();
257 /// Modules in use in current buffer
258 std::list<modInfoStruct> const getSelectedModules();
260 std::list<modInfoStruct> const getProvidedModules();
262 std::list<modInfoStruct> const
263 makeModuleInfo(LayoutModuleList const & mods);
265 void setLanguage() const;
267 void saveAsDefault() const;
268 /// does this font provide Old Style figures?
269 bool providesOSF(QString const & font) const;
270 /// does this font provide true Small Caps?
271 bool providesSC(QString const & font) const;
272 /** does this font provide OSF and Small Caps only via
273 * a single, undifferentiated expert option?
275 bool hasMonolithicExpertSet(QString const & font) const;
276 /// does this font provide size adjustment?
277 bool providesScale(QString const & font) const;
278 /// does this font provide an alternative without math?
279 bool providesNoMath(QString const & font) const;
281 void executeBranchRenaming() const;
283 void setCustomPapersize(bool custom);
286 void loadModuleInfo();
288 void updateUnknownBranches();
290 void updateTexFonts();
292 void updateMathFonts(QString const & rm);
294 void updateFontOptions();
298 bool completeFontset() const;
300 bool noMathFont() const;
302 void allPackages(int);
304 bool isBiblatex() const;
306 void checkPossibleCiteEngines();
309 /// List of names of available modules
310 std::list<modInfoStruct> moduleNames_;
312 std::map<docstring, docstring> changedBranches_;
314 std::list<std::string> includeonlys_;
317 /// Track if a non-module document param changed
318 bool nonModuleChanged_;
319 /// Track if used modules changed
320 bool modulesChanged_;
321 /// Track if the shellescape param changed
322 bool shellescapeChanged_;
326 class PreambleModule : public UiWidget<Ui::PreambleUi>
330 PreambleModule(QWidget * parent);
331 void update(BufferParams const & params, BufferId id);
332 void apply(BufferParams & params);
333 bool editing() const { return (bool)tempfile_; }
336 /// signal that something's changed in the Widget.
340 void closeEvent(QCloseEvent *);
341 void on_preambleTE_textChanged() { changed(); }
343 typedef std::map<BufferId, std::pair<int,int> > Coords;
344 Coords preamble_coords_;
345 BufferId current_id_;
346 unique_ptr<support::TempFile> tempfile_;
350 void checkFindButton();
356 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
360 LocalLayout(QWidget * parent);
361 void update(BufferParams const & params, BufferId id);
362 void apply(BufferParams & params);
363 bool isValid() const { return validated_; }
364 bool editing() const { return (bool)tempfile_; }
367 /// signal that something's changed in the Widget.
376 void validatePressed();
377 void convertPressed();
381 BufferId current_id_;
383 unique_ptr<support::TempFile> tempfile_;
387 class FontModule : public UiWidget<Ui::FontUi>
391 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
392 font_sf_scale(100), font_tt_scale(100) {}
393 /// The roman font currently not selected by osFontsCB->isChecked()
395 /// The sans font currently not selected by osFontsCB->isChecked()
397 /// The typewriter font currently not selected by osFontsCB->isChecked()
398 QString font_typewriter;
399 /// The math font currently not selected by osFontsCB->isChecked()
401 /// The sans font scale currently not selected by osFontsCB->isChecked()
403 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
408 } // namespace frontend
411 #endif // GUIDOCUMENT_H