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 listingsPackageChanged(int);
96 void saveDefaultClicked();
97 void useDefaultsClicked();
98 void setLSpacing(int);
100 void papersizeChanged(int);
102 void setCustomMargins(bool);
103 void fontencChanged(int);
104 void romanChanged(int);
105 void sansChanged(int);
107 void fontOsfToggled(bool state);
108 void fontScToggled(bool state);
110 void enableIndent(bool);
112 void enableSkip(bool);
113 void allowMathIndent();
114 void enableMathIndent(int);
118 void classChanged_adaptor();
119 void languagePackageChanged(int);
120 void biblioChanged();
121 void rescanBibFiles();
122 void resetDefaultBibfile(std::string const & which = std::string());
123 void resetDefaultBbxBibfile();
124 void resetDefaultCbxBibfile();
125 void citeEngineChanged(int);
126 void citeStyleChanged();
127 void bibtexChanged(int);
128 void updateResetDefaultBiblio();
129 void matchBiblatexStyles();
130 void updateEngineDependends();
131 void updateModuleInfo();
132 void modulesChanged();
133 void changeBackgroundColor();
134 void deleteBackgroundColor();
135 void changeFontColor();
136 void deleteFontColor();
137 void changeNoteFontColor();
138 void deleteNoteFontColor();
139 void changeBoxBackgroundColor();
140 void deleteBoxBackgroundColor();
141 void languageChanged(int);
142 void osFontsChanged(bool);
143 void mathFontChanged(int);
144 void branchesRename(docstring const &, docstring const &);
145 void allPackagesAuto();
146 void allPackagesAlways();
147 void allPackagesNot();
149 /// validate listings parameters and return an error message, if any
150 QString validateListingsParameters();
152 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
153 UiWidget<Ui::MasterChildUi> *masterChildModule;
154 FontModule *fontModule;
155 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
156 UiWidget<Ui::MarginsUi> *marginsModule;
157 UiWidget<Ui::LanguageUi> *langModule;
158 UiWidget<Ui::ColorUi> *colorModule;
159 UiWidget<Ui::NumberingUi> *numberingModule;
160 UiWidget<Ui::BiblioUi> *biblioModule;
161 UiWidget<Ui::MathsUi> *mathsModule;
162 UiWidget<Ui::LaTeXUi> *latexModule;
163 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
164 UiWidget<Ui::ModulesUi> *modulesModule;
165 UiWidget<Ui::OutputUi> *outputModule;
166 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
167 PreambleModule * preambleModule;
168 LocalLayout * localLayout;
170 GuiBranches * branchesModule;
171 GuiIndices * indicesModule;
173 BulletsModule * bulletsModule;
174 FloatPlacement * floatModule;
176 ModuleSelectionManager * selectionManager;
178 /// Available modules
179 GuiIdListModel * availableModel() { return &modules_av_model_; }
181 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
186 void updateContents();
188 void updateAvailableModules();
190 void updateSelectedModules();
192 void updateIncludeonlys();
194 void updateDefaultBiblio(std::string const & style,
195 std::string const & which = std::string());
196 /// save as default template
197 void saveDocDefault();
198 /// reset to default params
199 void useClassDefaults();
201 void setLayoutComboByIDString(std::string const & idString);
202 /// Update quotes styles combo, indicating the current language's default
203 void updateQuoteStyles(bool const set = false);
205 /// available modules
206 GuiIdListModel modules_av_model_;
208 GuiIdListModel modules_sel_model_;
210 /// return false if validate_listings_params returns error
213 /// font family names for BufferParams::fonts_default_family
214 static char const * const fontfamilies[5];
215 /// GUI names corresponding fontfamilies
216 static char const * fontfamilies_gui[5];
218 bool initialiseParams(std::string const & data);
222 void dispatchParams();
224 void modulesToParams(BufferParams &);
226 bool isBufferDependent() const { return true; }
227 /// always true since we don't manipulate document contents
228 bool canApply() const { return true; }
230 DocumentClass const & documentClass() const;
232 BufferParams & params() { return bp_; }
236 struct modInfoStruct {
242 static modInfoStruct modInfo(LyXModule const & mod);
243 /// List of available modules
244 std::list<modInfoStruct> const & getModuleInfo();
245 /// Modules in use in current buffer
246 std::list<modInfoStruct> const getSelectedModules();
248 std::list<modInfoStruct> const getProvidedModules();
250 std::list<modInfoStruct> const
251 makeModuleInfo(LayoutModuleList const & mods);
253 void setLanguage() const;
255 void saveAsDefault() const;
256 /// does this font provide Old Style figures?
257 bool providesOSF(QString const & font) const;
258 /// does this font provide true Small Caps?
259 bool providesSC(QString const & font) const;
260 /** does this font provide OSF and Small Caps only via
261 * a single, undifferentiated expert option?
263 bool hasMonolithicExpertSet(QString const & font) const;
264 /// does this font provide size adjustment?
265 bool providesScale(QString const & font) const;
266 /// does this font provide an alternative without math?
267 bool providesNoMath(QString const & font) const;
269 void executeBranchRenaming() const;
271 void setCustomPapersize(bool custom);
274 void loadModuleInfo();
276 void updateUnknownBranches();
278 void updateTexFonts();
280 void updateMathFonts(QString const & rm);
282 void updateFontOptions();
286 bool completeFontset() const;
288 bool noMathFont() const;
290 void allPackages(int);
292 bool isBiblatex() const;
295 /// List of names of available modules
296 std::list<modInfoStruct> moduleNames_;
298 std::map<docstring, docstring> changedBranches_;
300 std::list<std::string> includeonlys_;
303 /// Track if a non-module document param changed
304 bool nonModuleChanged_;
308 class PreambleModule : public UiWidget<Ui::PreambleUi>
312 PreambleModule(QWidget * parent);
313 void update(BufferParams const & params, BufferId id);
314 void apply(BufferParams & params);
317 /// signal that something's changed in the Widget.
321 void closeEvent(QCloseEvent *);
322 void on_preambleTE_textChanged() { changed(); }
325 typedef std::map<BufferId, std::pair<int,int> > Coords;
326 Coords preamble_coords_;
327 BufferId current_id_;
331 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
335 LocalLayout(QWidget * parent);
336 void update(BufferParams const & params, BufferId id);
337 void apply(BufferParams & params);
338 bool isValid() const { return validated_; }
341 /// signal that something's changed in the Widget.
350 void validatePressed();
351 void convertPressed();
354 BufferId current_id_;
359 class FontModule : public UiWidget<Ui::FontUi>
363 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
364 font_sf_scale(100), font_tt_scale(100) {}
365 /// The roman font currently not selected by osFontsCB->isChecked()
367 /// The sans font currently not selected by osFontsCB->isChecked()
369 /// The typewriter font currently not selected by osFontsCB->isChecked()
370 QString font_typewriter;
371 /// The math font currently not selected by osFontsCB->isChecked()
373 /// The sans font scale currently not selected by osFontsCB->isChecked()
375 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
380 } // namespace frontend
383 #endif // GUIDOCUMENT_H