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();
158 void moduleFilterPressed();
159 void moduleFilterChanged(const QString & text);
160 void resetModuleFilter();
162 /// validate listings parameters and return an error message, if any
163 QString validateListingsParameters();
165 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
166 UiWidget<Ui::MasterChildUi> *masterChildModule;
167 FontModule *fontModule;
168 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
169 UiWidget<Ui::MarginsUi> *marginsModule;
170 UiWidget<Ui::LanguageUi> *langModule;
171 UiWidget<Ui::ColorUi> *colorModule;
172 UiWidget<Ui::NumberingUi> *numberingModule;
173 UiWidget<Ui::BiblioUi> *biblioModule;
174 UiWidget<Ui::MathsUi> *mathsModule;
175 UiWidget<Ui::LaTeXUi> *latexModule;
176 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
177 UiWidget<Ui::ModulesUi> *modulesModule;
178 UiWidget<Ui::OutputUi> *outputModule;
179 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
180 PreambleModule * preambleModule;
181 LocalLayout * localLayout;
183 GuiBranches * branchesModule;
184 GuiIndices * indicesModule;
186 BulletsModule * bulletsModule;
187 FloatPlacement * floatModule;
189 ModuleSelectionManager * selectionManager;
191 /// Available modules
192 GuiIdListModel * availableModel() { return &modules_av_model_; }
194 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
199 void updateContents();
201 void updateAvailableModules();
203 void updateSelectedModules();
205 void updateIncludeonlys();
207 void updateDefaultBiblio(std::string const & style,
208 std::string const & which = std::string());
209 /// save as default template
210 void saveDocDefault();
211 /// reset to default params
212 void useClassDefaults();
214 void setLayoutComboByIDString(std::string const & idString);
215 /// Update quotes styles combo, indicating the current language's default
216 void updateQuoteStyles(bool const set = false);
218 void getTableStyles();
220 /// available modules
221 GuiIdListModel modules_av_model_;
223 GuiIdListModel modules_sel_model_;
226 FancyLineEdit * filter_;
228 /// return false if validate_listings_params returns error
231 /// font family names for BufferParams::fonts_default_family
232 static char const * const fontfamilies[5];
233 /// GUI names corresponding fontfamilies
234 static char const * fontfamilies_gui[5];
236 bool initialiseParams(std::string const & data);
240 void dispatchParams();
242 void modulesToParams(BufferParams &);
244 bool isBufferDependent() const { return true; }
245 /// always true since we don't manipulate document contents
246 bool canApply() const { return true; }
248 DocumentClass const & documentClass() const;
250 BufferParams & params() { return bp_; }
254 struct modInfoStruct {
261 static modInfoStruct modInfo(LyXModule const & mod);
262 /// List of available modules
263 std::list<modInfoStruct> const & getModuleInfo();
264 /// Modules in use in current buffer
265 std::list<modInfoStruct> const getSelectedModules();
267 std::list<modInfoStruct> const getProvidedModules();
269 std::list<modInfoStruct> const
270 makeModuleInfo(LayoutModuleList const & mods);
272 void setLanguage() const;
274 void saveAsDefault() const;
275 /// does this font provide Old Style figures?
276 bool providesOSF(QString const & font) const;
277 /// does this font provide true Small Caps?
278 bool providesSC(QString const & font) const;
279 /** does this font provide OSF and Small Caps only via
280 * a single, undifferentiated expert option?
282 bool hasMonolithicExpertSet(QString const & font) const;
283 /// does this font provide size adjustment?
284 bool providesScale(QString const & font) const;
285 /// does this font provide an alternative without math?
286 bool providesNoMath(QString const & font) const;
288 void executeBranchRenaming() const;
290 void setCustomPapersize(bool custom);
293 void loadModuleInfo();
295 void updateUnknownBranches();
297 void updateTexFonts();
299 void updateMathFonts(QString const & rm);
301 void updateFontOptions();
305 bool completeFontset() const;
307 bool noMathFont() const;
309 void allPackages(int);
311 bool isBiblatex() const;
313 void checkPossibleCiteEngines();
315 void filterModules(QString const & string);
318 /// List of names of available modules
319 std::list<modInfoStruct> moduleNames_;
321 std::map<docstring, docstring> changedBranches_;
323 std::list<std::string> includeonlys_;
326 /// Track if a non-module document param changed
327 bool nonModuleChanged_;
328 /// Track if used modules changed
329 bool modulesChanged_;
330 /// Track if the shellescape param changed
331 bool shellescapeChanged_;
335 class PreambleModule : public UiWidget<Ui::PreambleUi>
339 PreambleModule(QWidget * parent);
340 void update(BufferParams const & params, BufferId id);
341 void apply(BufferParams & params);
342 bool editing() const { return (bool)tempfile_; }
345 /// signal that something's changed in the Widget.
349 void closeEvent(QCloseEvent *);
350 void on_preambleTE_textChanged() { changed(); }
352 typedef std::map<BufferId, std::pair<int,int> > Coords;
353 Coords preamble_coords_;
354 BufferId current_id_;
355 unique_ptr<support::TempFile> tempfile_;
359 void checkFindButton();
365 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
369 LocalLayout(QWidget * parent);
370 void update(BufferParams const & params, BufferId id);
371 void apply(BufferParams & params);
372 bool isValid() const { return validated_; }
373 bool editing() const { return (bool)tempfile_; }
376 /// signal that something's changed in the Widget.
385 void validatePressed();
386 void convertPressed();
390 BufferId current_id_;
392 unique_ptr<support::TempFile> tempfile_;
396 class FontModule : public UiWidget<Ui::FontUi>
400 FontModule(QWidget * parent) : UiWidget<Ui::FontUi>(parent),
401 font_sf_scale(100), font_tt_scale(100) {}
402 /// The roman font currently not selected by osFontsCB->isChecked()
404 /// The sans font currently not selected by osFontsCB->isChecked()
406 /// The typewriter font currently not selected by osFontsCB->isChecked()
407 QString font_typewriter;
408 /// The math font currently not selected by osFontsCB->isChecked()
410 /// The sans font scale currently not selected by osFontsCB->isChecked()
412 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
417 } // namespace frontend
420 #endif // GUIDOCUMENT_H