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;
51 class ModuleSelectionManager;
56 typedef void const * BufferId;
59 class UiWidget : public QWidget, public UI
62 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
66 class GuiDocument : public GuiDialog, public Ui::DocumentUi
70 GuiDocument(GuiView & lv);
72 void paramsToDialog();
73 void updateFontsize(std::string const &, std::string const &);
74 void updateFontlist();
75 void updateDefaultFormat();
76 void updateEngineType(std::string const &, CiteEngineType const &);
77 void updatePagestyle(std::string const &, std::string const &);
78 bool isChildIncluded(std::string const &);
81 BufferParams const & params() const { return bp_; }
84 void updateNumbering();
85 void change_adaptor();
86 void includeonlyClicked(QTreeWidgetItem * item, int);
87 void setListingsMessage();
88 void saveDefaultClicked();
89 void useDefaultsClicked();
90 void setLSpacing(int);
92 void papersizeChanged(int);
94 void setCustomMargins(bool);
95 void fontencChanged(int);
96 void romanChanged(int);
97 void sansChanged(int);
99 void fontOsfToggled(bool state);
100 void fontScToggled(bool state);
102 void enableIndent(bool);
104 void enableSkip(bool);
108 void classChanged_adaptor();
109 void languagePackageChanged(int);
110 void biblioChanged();
111 void bibtexChanged(int);
112 void setAuthorYear(bool);
113 void setNumerical(bool);
114 void updateModuleInfo();
115 void modulesChanged();
116 void changeBackgroundColor();
117 void deleteBackgroundColor();
118 void changeFontColor();
119 void deleteFontColor();
120 void changeNoteFontColor();
121 void deleteNoteFontColor();
122 void changeBoxBackgroundColor();
123 void deleteBoxBackgroundColor();
124 void languageChanged(int);
125 void osFontsChanged(bool);
126 void mathFontChanged(int);
127 void branchesRename(docstring const &, docstring const &);
128 void allPackagesAuto();
129 void allPackagesAlways();
130 void allPackagesNot();
132 /// validate listings parameters and return an error message, if any
133 QString validateListingsParameters();
135 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
136 UiWidget<Ui::MasterChildUi> *masterChildModule;
137 UiWidget<Ui::FontUi> *fontModule;
138 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
139 UiWidget<Ui::MarginsUi> *marginsModule;
140 UiWidget<Ui::LanguageUi> *langModule;
141 UiWidget<Ui::ColorUi> *colorModule;
142 UiWidget<Ui::NumberingUi> *numberingModule;
143 UiWidget<Ui::BiblioUi> *biblioModule;
144 UiWidget<Ui::MathsUi> *mathsModule;
145 UiWidget<Ui::LaTeXUi> *latexModule;
146 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
147 UiWidget<Ui::ModulesUi> *modulesModule;
148 UiWidget<Ui::OutputUi> *outputModule;
149 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
150 PreambleModule * preambleModule;
151 LocalLayout * localLayout;
153 GuiBranches * branchesModule;
154 GuiIndices * indicesModule;
156 BulletsModule * bulletsModule;
157 FloatPlacement * floatModule;
159 ModuleSelectionManager * selectionManager;
161 /// Available modules
162 GuiIdListModel * availableModel() { return &modules_av_model_; }
164 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
169 void updateContents();
171 void updateAvailableModules();
173 void updateSelectedModules();
175 void updateIncludeonlys();
176 /// save as default template
177 void saveDocDefault();
178 /// reset to default params
179 void useClassDefaults();
181 void setLayoutComboByIDString(std::string const & idString);
183 /// available modules
184 GuiIdListModel modules_av_model_;
186 GuiIdListModel modules_sel_model_;
188 /// return false if validate_listings_params returns error
191 /// font family names for BufferParams::fonts_default_family
192 static char const * const fontfamilies[5];
193 /// GUI names corresponding fontfamilies
194 static char const * fontfamilies_gui[5];
196 bool initialiseParams(std::string const & data);
200 void dispatchParams();
202 void modulesToParams(BufferParams &);
204 bool isBufferDependent() const { return true; }
205 /// always true since we don't manipulate document contents
206 bool canApply() const { return true; }
208 DocumentClass const & documentClass() const;
210 BufferParams & params() { return bp_; }
214 struct modInfoStruct {
219 /// List of available modules
220 std::list<modInfoStruct> const & getModuleInfo();
221 /// Modules in use in current buffer
222 std::list<modInfoStruct> const getSelectedModules();
224 std::list<modInfoStruct> const getProvidedModules();
226 std::list<modInfoStruct> const
227 makeModuleInfo(LayoutModuleList const & mods);
229 void setLanguage() const;
231 void saveAsDefault() const;
232 /// does this font provide Old Style figures?
233 bool providesOSF(QString const & font) const;
234 /// does this font provide true Small Caps?
235 bool providesSC(QString const & font) const;
236 /** does this font provide OSF and Small Caps only via
237 * a single, undifferentiated expert option?
239 bool hasMonolithicExpertSet(QString const & font) const;
240 /// does this font provide size adjustment?
241 bool providesScale(QString const & font) const;
242 /// does this font provide an alternative without math?
243 bool providesNoMath(QString const & font) const;
245 void executeBranchRenaming() const;
247 void setCustomPapersize(bool custom);
250 void loadModuleInfo();
252 void updateUnknownBranches();
254 void updateTexFonts();
256 void updateMathFonts(QString const & rm);
258 void updateFontOptions();
262 bool completeFontset() const;
264 bool noMathFont() const;
266 void allPackages(int);
269 /// List of names of available modules
270 std::list<modInfoStruct> moduleNames_;
272 std::map<docstring, docstring> changedBranches_;
274 std::list<std::string> includeonlys_;
277 /// Track if a non-module document param changed
278 bool nonModuleChanged_;
282 class PreambleModule : public UiWidget<Ui::PreambleUi>
287 void update(BufferParams const & params, BufferId id);
288 void apply(BufferParams & params);
291 /// signal that something's changed in the Widget.
295 void closeEvent(QCloseEvent *);
296 void on_preambleTE_textChanged() { changed(); }
299 typedef std::map<BufferId, std::pair<int,int> > Coords;
300 Coords preamble_coords_;
301 BufferId current_id_;
305 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
310 void update(BufferParams const & params, BufferId id);
311 void apply(BufferParams & params);
312 bool isValid() const { return validated_; }
315 /// signal that something's changed in the Widget.
323 void validatePressed();
324 void convertPressed();
327 BufferId current_id_;
332 } // namespace frontend
335 #endif // GUIDOCUMENT_H