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
99 void updateNumbering();
100 void change_adaptor();
101 void shellescapeChanged();
102 void includeonlyClicked(QTreeWidgetItem * item, int);
103 void setListingsMessage();
104 void listingsPackageChanged(int);
105 void saveDefaultClicked();
106 void useDefaultsClicked();
107 void setLSpacing(int);
109 void papersizeChanged(int);
111 void setCustomMargins(bool);
112 void fontencChanged(int);
113 void romanChanged(int);
114 void sansChanged(int);
116 void fontOsfToggled(bool state);
117 void fontScToggled(bool state);
119 void enableIndent(bool);
121 void enableSkip(bool);
122 void allowMathIndent();
123 void enableMathIndent(int);
127 void classChanged_adaptor();
128 void languagePackageChanged(int);
129 void biblioChanged();
130 void rescanBibFiles();
131 void resetDefaultBibfile(std::string const & which = std::string());
132 void resetDefaultBbxBibfile();
133 void resetDefaultCbxBibfile();
134 void citeEngineChanged(int);
135 void citeStyleChanged();
136 void bibtexChanged(int);
137 void updateResetDefaultBiblio();
138 void matchBiblatexStyles();
139 void updateEngineDependends();
140 void updateModuleInfo();
141 void modulesChanged();
142 void changeBackgroundColor();
143 void deleteBackgroundColor();
144 void changeFontColor();
145 void deleteFontColor();
146 void changeNoteFontColor();
147 void deleteNoteFontColor();
148 void changeBoxBackgroundColor();
149 void deleteBoxBackgroundColor();
150 void languageChanged(int);
151 void osFontsChanged(bool);
152 void mathFontChanged(int);
153 void branchesRename(docstring const &, docstring const &);
154 void allPackagesAuto();
155 void allPackagesAlways();
156 void allPackagesNot();
158 /// validate listings parameters and return an error message, if any
159 QString validateListingsParameters();
161 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
162 UiWidget<Ui::MasterChildUi> *masterChildModule;
163 FontModule *fontModule;
164 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
165 UiWidget<Ui::MarginsUi> *marginsModule;
166 UiWidget<Ui::LanguageUi> *langModule;
167 UiWidget<Ui::ColorUi> *colorModule;
168 UiWidget<Ui::NumberingUi> *numberingModule;
169 UiWidget<Ui::BiblioUi> *biblioModule;
170 UiWidget<Ui::MathsUi> *mathsModule;
171 UiWidget<Ui::LaTeXUi> *latexModule;
172 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
173 UiWidget<Ui::ModulesUi> *modulesModule;
174 UiWidget<Ui::OutputUi> *outputModule;
175 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
176 PreambleModule * preambleModule;
177 LocalLayout * localLayout;
179 GuiBranches * branchesModule;
180 GuiIndices * indicesModule;
182 BulletsModule * bulletsModule;
183 FloatPlacement * floatModule;
185 ModuleSelectionManager * selectionManager;
187 /// Available modules
188 GuiIdListModel * availableModel() { return &modules_av_model_; }
190 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
195 void updateContents();
197 void updateAvailableModules();
199 void updateSelectedModules();
201 void updateIncludeonlys();
203 void updateDefaultBiblio(std::string const & style,
204 std::string const & which = std::string());
205 /// save as default template
206 void saveDocDefault();
207 /// reset to default params
208 void useClassDefaults();
210 void setLayoutComboByIDString(std::string const & idString);
211 /// Update quotes styles combo, indicating the current language's default
212 void updateQuoteStyles(bool const set = false);
214 /// available modules
215 GuiIdListModel modules_av_model_;
217 GuiIdListModel modules_sel_model_;
219 /// return false if validate_listings_params returns error
222 /// font family names for BufferParams::fonts_default_family
223 static char const * const fontfamilies[5];
224 /// GUI names corresponding fontfamilies
225 static char const * fontfamilies_gui[5];
227 bool initialiseParams(std::string const & data);
231 void dispatchParams();
233 void modulesToParams(BufferParams &);
235 bool isBufferDependent() const { return true; }
236 /// always true since we don't manipulate document contents
237 bool canApply() const { return true; }
239 DocumentClass const & documentClass() const;
241 BufferParams & params() { return bp_; }
245 struct modInfoStruct {
251 static modInfoStruct modInfo(LyXModule const & mod);
252 /// List of available modules
253 std::list<modInfoStruct> const & getModuleInfo();
254 /// Modules in use in current buffer
255 std::list<modInfoStruct> const getSelectedModules();
257 std::list<modInfoStruct> const getProvidedModules();
259 std::list<modInfoStruct> const
260 makeModuleInfo(LayoutModuleList const & mods);
262 void setLanguage() const;
264 void saveAsDefault() const;
265 /// does this font provide Old Style figures?
266 bool providesOSF(QString const & font) const;
267 /// does this font provide true Small Caps?
268 bool providesSC(QString const & font) const;
269 /** does this font provide OSF and Small Caps only via
270 * a single, undifferentiated expert option?
272 bool hasMonolithicExpertSet(QString const & font) const;
273 /// does this font provide size adjustment?
274 bool providesScale(QString const & font) const;
275 /// does this font provide an alternative without math?
276 bool providesNoMath(QString const & font) const;
278 void executeBranchRenaming() const;
280 void setCustomPapersize(bool custom);
283 void loadModuleInfo();
285 void updateUnknownBranches();
287 void updateTexFonts();
289 void updateMathFonts(QString const & rm);
291 void updateFontOptions();
295 bool completeFontset() const;
297 bool noMathFont() const;
299 void allPackages(int);
301 bool isBiblatex() const;
303 void checkPossibleCiteEngines();
306 /// List of names of available modules
307 std::list<modInfoStruct> moduleNames_;
309 std::map<docstring, docstring> changedBranches_;
311 std::list<std::string> includeonlys_;
314 /// Track if a non-module document param changed
315 bool nonModuleChanged_;
316 /// Track if used modules changed
317 bool modulesChanged_;
318 /// Track if the shellescape param changed
319 bool shellescapeChanged_;
323 class PreambleModule : public UiWidget<Ui::PreambleUi>
327 PreambleModule(QWidget * parent);
328 void update(BufferParams const & params, BufferId id);
329 void apply(BufferParams & params);
330 bool editing() const { return (bool)tempfile_; }
333 /// signal that something's changed in the Widget.
337 void closeEvent(QCloseEvent *);
338 void on_preambleTE_textChanged() { changed(); }
340 typedef std::map<BufferId, std::pair<int,int> > Coords;
341 Coords preamble_coords_;
342 BufferId current_id_;
343 unique_ptr<support::TempFile> tempfile_;
347 void checkFindButton();
353 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
357 LocalLayout(QWidget * parent);
358 void update(BufferParams const & params, BufferId id);
359 void apply(BufferParams & params);
360 bool isValid() const { return validated_; }
361 bool editing() const { return (bool)tempfile_; }
364 /// signal that something's changed in the Widget.
373 void validatePressed();
374 void convertPressed();
378 BufferId current_id_;
380 unique_ptr<support::TempFile> tempfile_;
384 class FontModule : public UiWidget<Ui::FontUi>
388 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
389 font_sf_scale(100), font_tt_scale(100) {}
390 /// The roman font currently not selected by osFontsCB->isChecked()
392 /// The sans font currently not selected by osFontsCB->isChecked()
394 /// The typewriter font currently not selected by osFontsCB->isChecked()
395 QString font_typewriter;
396 /// The math font currently not selected by osFontsCB->isChecked()
398 /// The sans font scale currently not selected by osFontsCB->isChecked()
400 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
405 } // namespace frontend
408 #endif // GUIDOCUMENT_H