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 // Apply button clicked
95 void updateNumbering();
96 void change_adaptor();
97 void shellescapeChanged();
98 void includeonlyClicked(QTreeWidgetItem * item, int);
99 void setListingsMessage();
100 void listingsPackageChanged(int);
101 void saveDefaultClicked();
102 void useDefaultsClicked();
103 void setLSpacing(int);
105 void papersizeChanged(int);
107 void setCustomMargins(bool);
108 void fontencChanged(int);
109 void romanChanged(int);
110 void sansChanged(int);
112 void fontOsfToggled(bool state);
113 void fontScToggled(bool state);
115 void enableIndent(bool);
117 void enableSkip(bool);
118 void allowMathIndent();
119 void enableMathIndent(int);
123 void classChanged_adaptor();
124 void languagePackageChanged(int);
125 void biblioChanged();
126 void rescanBibFiles();
127 void resetDefaultBibfile(std::string const & which = std::string());
128 void resetDefaultBbxBibfile();
129 void resetDefaultCbxBibfile();
130 void citeEngineChanged(int);
131 void citeStyleChanged();
132 void bibtexChanged(int);
133 void updateResetDefaultBiblio();
134 void matchBiblatexStyles();
135 void updateEngineDependends();
136 void updateModuleInfo();
137 void modulesChanged();
138 void changeBackgroundColor();
139 void deleteBackgroundColor();
140 void changeFontColor();
141 void deleteFontColor();
142 void changeNoteFontColor();
143 void deleteNoteFontColor();
144 void changeBoxBackgroundColor();
145 void deleteBoxBackgroundColor();
146 void languageChanged(int);
147 void osFontsChanged(bool);
148 void mathFontChanged(int);
149 void branchesRename(docstring const &, docstring const &);
150 void allPackagesAuto();
151 void allPackagesAlways();
152 void allPackagesNot();
154 /// validate listings parameters and return an error message, if any
155 QString validateListingsParameters();
157 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
158 UiWidget<Ui::MasterChildUi> *masterChildModule;
159 FontModule *fontModule;
160 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
161 UiWidget<Ui::MarginsUi> *marginsModule;
162 UiWidget<Ui::LanguageUi> *langModule;
163 UiWidget<Ui::ColorUi> *colorModule;
164 UiWidget<Ui::NumberingUi> *numberingModule;
165 UiWidget<Ui::BiblioUi> *biblioModule;
166 UiWidget<Ui::MathsUi> *mathsModule;
167 UiWidget<Ui::LaTeXUi> *latexModule;
168 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
169 UiWidget<Ui::ModulesUi> *modulesModule;
170 UiWidget<Ui::OutputUi> *outputModule;
171 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
172 PreambleModule * preambleModule;
173 LocalLayout * localLayout;
175 GuiBranches * branchesModule;
176 GuiIndices * indicesModule;
178 BulletsModule * bulletsModule;
179 FloatPlacement * floatModule;
181 ModuleSelectionManager * selectionManager;
183 /// Available modules
184 GuiIdListModel * availableModel() { return &modules_av_model_; }
186 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
191 void updateContents();
193 void updateAvailableModules();
195 void updateSelectedModules();
197 void updateIncludeonlys();
199 void updateDefaultBiblio(std::string const & style,
200 std::string const & which = std::string());
201 /// save as default template
202 void saveDocDefault();
203 /// reset to default params
204 void useClassDefaults();
206 void setLayoutComboByIDString(std::string const & idString);
207 /// Update quotes styles combo, indicating the current language's default
208 void updateQuoteStyles(bool const set = false);
210 /// available modules
211 GuiIdListModel modules_av_model_;
213 GuiIdListModel modules_sel_model_;
215 /// return false if validate_listings_params returns error
218 /// font family names for BufferParams::fonts_default_family
219 static char const * const fontfamilies[5];
220 /// GUI names corresponding fontfamilies
221 static char const * fontfamilies_gui[5];
223 bool initialiseParams(std::string const & data);
227 void dispatchParams();
229 void modulesToParams(BufferParams &);
231 bool isBufferDependent() const { return true; }
232 /// always true since we don't manipulate document contents
233 bool canApply() const { return true; }
235 DocumentClass const & documentClass() const;
237 BufferParams & params() { return bp_; }
241 struct modInfoStruct {
247 static modInfoStruct modInfo(LyXModule const & mod);
248 /// List of available modules
249 std::list<modInfoStruct> const & getModuleInfo();
250 /// Modules in use in current buffer
251 std::list<modInfoStruct> const getSelectedModules();
253 std::list<modInfoStruct> const getProvidedModules();
255 std::list<modInfoStruct> const
256 makeModuleInfo(LayoutModuleList const & mods);
258 void setLanguage() const;
260 void saveAsDefault() const;
261 /// does this font provide Old Style figures?
262 bool providesOSF(QString const & font) const;
263 /// does this font provide true Small Caps?
264 bool providesSC(QString const & font) const;
265 /** does this font provide OSF and Small Caps only via
266 * a single, undifferentiated expert option?
268 bool hasMonolithicExpertSet(QString const & font) const;
269 /// does this font provide size adjustment?
270 bool providesScale(QString const & font) const;
271 /// does this font provide an alternative without math?
272 bool providesNoMath(QString const & font) const;
274 void executeBranchRenaming() const;
276 void setCustomPapersize(bool custom);
279 void loadModuleInfo();
281 void updateUnknownBranches();
283 void updateTexFonts();
285 void updateMathFonts(QString const & rm);
287 void updateFontOptions();
291 bool completeFontset() const;
293 bool noMathFont() const;
295 void allPackages(int);
297 bool isBiblatex() const;
299 void checkPossibleCiteEngines();
302 /// List of names of available modules
303 std::list<modInfoStruct> moduleNames_;
305 std::map<docstring, docstring> changedBranches_;
307 std::list<std::string> includeonlys_;
310 /// Track if a non-module document param changed
311 bool nonModuleChanged_;
312 /// Track if used modules changed
313 bool modulesChanged_;
314 /// Track if the shellescape param changed
315 bool shellescapeChanged_;
319 class PreambleModule : public UiWidget<Ui::PreambleUi>
323 PreambleModule(QWidget * parent);
324 void update(BufferParams const & params, BufferId id);
325 void apply(BufferParams & params);
328 /// signal that something's changed in the Widget.
332 void closeEvent(QCloseEvent *);
333 void on_preambleTE_textChanged() { changed(); }
336 typedef std::map<BufferId, std::pair<int,int> > Coords;
337 Coords preamble_coords_;
338 BufferId current_id_;
342 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
346 LocalLayout(QWidget * parent);
347 void update(BufferParams const & params, BufferId id);
348 void apply(BufferParams & params);
349 bool isValid() const { return validated_; }
352 /// signal that something's changed in the Widget.
361 void validatePressed();
362 void convertPressed();
365 BufferId current_id_;
370 class FontModule : public UiWidget<Ui::FontUi>
374 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
375 font_sf_scale(100), font_tt_scale(100) {}
376 /// The roman font currently not selected by osFontsCB->isChecked()
378 /// The sans font currently not selected by osFontsCB->isChecked()
380 /// The typewriter font currently not selected by osFontsCB->isChecked()
381 QString font_typewriter;
382 /// The math font currently not selected by osFontsCB->isChecked()
384 /// The sans font scale currently not selected by osFontsCB->isChecked()
386 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
391 } // namespace frontend
394 #endif // GUIDOCUMENT_H