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 includeonlyClicked(QTreeWidgetItem * item, int);
94 void setListingsMessage();
95 void saveDefaultClicked();
96 void useDefaultsClicked();
97 void setLSpacing(int);
99 void papersizeChanged(int);
101 void setCustomMargins(bool);
102 void fontencChanged(int);
103 void romanChanged(int);
104 void sansChanged(int);
106 void fontOsfToggled(bool state);
107 void fontScToggled(bool state);
108 void dashesToggled(bool state);
110 void enableIndent(bool);
112 void enableSkip(bool);
116 void classChanged_adaptor();
117 void languagePackageChanged(int);
118 void biblioChanged();
119 void rescanBibFiles();
120 void resetDefaultBibfile(std::string const & which = std::string());
121 void resetDefaultBbxBibfile();
122 void resetDefaultCbxBibfile();
123 void citeEngineChanged(int);
124 void citeStyleChanged();
125 void bibtexChanged(int);
126 void updateResetDefaultBiblio();
127 void matchBiblatexStyles();
128 void updateEngineDependends();
129 void updateModuleInfo();
130 void modulesChanged();
131 void changeBackgroundColor();
132 void deleteBackgroundColor();
133 void changeFontColor();
134 void deleteFontColor();
135 void changeNoteFontColor();
136 void deleteNoteFontColor();
137 void changeBoxBackgroundColor();
138 void deleteBoxBackgroundColor();
139 void languageChanged(int);
140 void osFontsChanged(bool);
141 void mathFontChanged(int);
142 void branchesRename(docstring const &, docstring const &);
143 void allPackagesAuto();
144 void allPackagesAlways();
145 void allPackagesNot();
147 /// validate listings parameters and return an error message, if any
148 QString validateListingsParameters();
150 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
151 UiWidget<Ui::MasterChildUi> *masterChildModule;
152 FontModule *fontModule;
153 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
154 UiWidget<Ui::MarginsUi> *marginsModule;
155 UiWidget<Ui::LanguageUi> *langModule;
156 UiWidget<Ui::ColorUi> *colorModule;
157 UiWidget<Ui::NumberingUi> *numberingModule;
158 UiWidget<Ui::BiblioUi> *biblioModule;
159 UiWidget<Ui::MathsUi> *mathsModule;
160 UiWidget<Ui::LaTeXUi> *latexModule;
161 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
162 UiWidget<Ui::ModulesUi> *modulesModule;
163 UiWidget<Ui::OutputUi> *outputModule;
164 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
165 PreambleModule * preambleModule;
166 LocalLayout * localLayout;
168 GuiBranches * branchesModule;
169 GuiIndices * indicesModule;
171 BulletsModule * bulletsModule;
172 FloatPlacement * floatModule;
174 ModuleSelectionManager * selectionManager;
176 /// Available modules
177 GuiIdListModel * availableModel() { return &modules_av_model_; }
179 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
184 void updateContents();
186 void updateAvailableModules();
188 void updateSelectedModules();
190 void updateIncludeonlys();
192 void updateDefaultBiblio(std::string const & style,
193 std::string const & which = std::string());
194 /// save as default template
195 void saveDocDefault();
196 /// reset to default params
197 void useClassDefaults();
199 void setLayoutComboByIDString(std::string const & idString);
200 /// Update quotes styles combo, indicating the current language's default
201 void updateQuoteStyles(bool const set = false);
203 /// available modules
204 GuiIdListModel modules_av_model_;
206 GuiIdListModel modules_sel_model_;
208 /// return false if validate_listings_params returns error
211 /// font family names for BufferParams::fonts_default_family
212 static char const * const fontfamilies[5];
213 /// GUI names corresponding fontfamilies
214 static char const * fontfamilies_gui[5];
216 bool initialiseParams(std::string const & data);
220 void dispatchParams();
222 void modulesToParams(BufferParams &);
224 bool isBufferDependent() const { return true; }
225 /// always true since we don't manipulate document contents
226 bool canApply() const { return true; }
228 DocumentClass const & documentClass() const;
230 BufferParams & params() { return bp_; }
234 struct modInfoStruct {
240 static modInfoStruct modInfo(LyXModule const & mod);
241 /// List of available modules
242 std::list<modInfoStruct> const & getModuleInfo();
243 /// Modules in use in current buffer
244 std::list<modInfoStruct> const getSelectedModules();
246 std::list<modInfoStruct> const getProvidedModules();
248 std::list<modInfoStruct> const
249 makeModuleInfo(LayoutModuleList const & mods);
251 void setLanguage() const;
253 void saveAsDefault() const;
254 /// does this font provide Old Style figures?
255 bool providesOSF(QString const & font) const;
256 /// does this font provide true Small Caps?
257 bool providesSC(QString const & font) const;
258 /** does this font provide OSF and Small Caps only via
259 * a single, undifferentiated expert option?
261 bool hasMonolithicExpertSet(QString const & font) const;
262 /// does this font provide size adjustment?
263 bool providesScale(QString const & font) const;
264 /// does this font provide an alternative without math?
265 bool providesNoMath(QString const & font) const;
267 void executeBranchRenaming() const;
269 void setCustomPapersize(bool custom);
272 void loadModuleInfo();
274 void updateUnknownBranches();
276 void updateTexFonts();
278 void updateMathFonts(QString const & rm);
280 void updateFontOptions();
284 bool completeFontset() const;
286 bool noMathFont() const;
288 void allPackages(int);
290 bool isBiblatex() const;
293 /// List of names of available modules
294 std::list<modInfoStruct> moduleNames_;
296 std::map<docstring, docstring> changedBranches_;
298 std::list<std::string> includeonlys_;
301 /// Track if a non-module document param changed
302 bool nonModuleChanged_;
306 class PreambleModule : public UiWidget<Ui::PreambleUi>
310 PreambleModule(QWidget * parent);
311 void update(BufferParams const & params, BufferId id);
312 void apply(BufferParams & params);
315 /// signal that something's changed in the Widget.
319 void closeEvent(QCloseEvent *);
320 void on_preambleTE_textChanged() { changed(); }
323 typedef std::map<BufferId, std::pair<int,int> > Coords;
324 Coords preamble_coords_;
325 BufferId current_id_;
329 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
333 LocalLayout(QWidget * parent);
334 void update(BufferParams const & params, BufferId id);
335 void apply(BufferParams & params);
336 bool isValid() const { return validated_; }
339 /// signal that something's changed in the Widget.
348 void validatePressed();
349 void convertPressed();
352 BufferId current_id_;
357 class FontModule : public UiWidget<Ui::FontUi>
361 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
362 font_sf_scale(100), font_tt_scale(100) {}
363 /// The roman font currently not selected by osFontsCB->isChecked()
365 /// The sans font currently not selected by osFontsCB->isChecked()
367 /// The typewriter font currently not selected by osFontsCB->isChecked()
368 QString font_typewriter;
369 /// The math font currently not selected by osFontsCB->isChecked()
371 /// The sans font scale currently not selected by osFontsCB->isChecked()
373 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
378 } // namespace frontend
381 #endif // GUIDOCUMENT_H