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.
18 #include "BufferParams.h"
19 #include "BulletsModule.h"
20 #include "GuiDialog.h"
21 #include "GuiIdListModel.h"
23 #include "ui_BiblioUi.h"
24 #include "ui_ColorUi.h"
25 #include "ui_DocumentUi.h"
26 #include "ui_FontUi.h"
27 #include "ui_LanguageUi.h"
28 #include "ui_LaTeXUi.h"
29 #include "ui_ListingsSettingsUi.h"
30 #include "ui_LocalLayoutUi.h"
31 #include "ui_MarginsUi.h"
32 #include "ui_MasterChildUi.h"
33 #include "ui_MathsUi.h"
34 #include "ui_ModulesUi.h"
35 #include "ui_NumberingUi.h"
36 #include "ui_OutputUi.h"
37 #include "ui_PageLayoutUi.h"
38 #include "ui_PDFSupportUi.h"
39 #include "ui_PreambleUi.h"
40 #include "ui_TextLayoutUi.h"
45 class LayoutModuleList;
53 class ModuleSelectionManager;
58 typedef void const * BufferId;
61 class UiWidget : public QWidget, public UI
64 UiWidget(QWidget * parent = 0) : 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 updateEngineType(std::string const &, CiteEngineType const &);
79 void updatePagestyle(std::string const &, std::string const &);
80 bool isChildIncluded(std::string const &);
83 BufferParams const & params() const { return bp_; }
86 void updateNumbering();
87 void change_adaptor();
88 void includeonlyClicked(QTreeWidgetItem * item, int);
89 void setListingsMessage();
90 void saveDefaultClicked();
91 void useDefaultsClicked();
92 void setLSpacing(int);
94 void papersizeChanged(int);
96 void setCustomMargins(bool);
97 void fontencChanged(int);
98 void romanChanged(int);
99 void sansChanged(int);
102 void enableIndent(bool);
104 void enableSkip(bool);
108 void languagePackageChanged(int);
109 void biblioChanged();
110 void bibtexChanged(int);
111 void setAuthorYear(bool);
112 void setNumerical(bool);
113 void updateModuleInfo();
114 void modulesChanged();
115 void changeBackgroundColor();
116 void deleteBackgroundColor();
117 void changeFontColor();
118 void deleteFontColor();
119 void changeNoteFontColor();
120 void deleteNoteFontColor();
121 void changeBoxBackgroundColor();
122 void deleteBoxBackgroundColor();
123 void languageChanged(int);
124 void osFontsChanged(bool);
125 void mathFontChanged(int);
126 void branchesRename(docstring const &, docstring const &);
128 /// validate listings parameters and return an error message, if any
129 QString validateListingsParameters();
131 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
132 UiWidget<Ui::MasterChildUi> *masterChildModule;
133 UiWidget<Ui::FontUi> *fontModule;
134 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
135 UiWidget<Ui::MarginsUi> *marginsModule;
136 UiWidget<Ui::LanguageUi> *langModule;
137 UiWidget<Ui::ColorUi> *colorModule;
138 UiWidget<Ui::NumberingUi> *numberingModule;
139 UiWidget<Ui::BiblioUi> *biblioModule;
140 UiWidget<Ui::MathsUi> *mathsModule;
141 UiWidget<Ui::LaTeXUi> *latexModule;
142 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
143 UiWidget<Ui::ModulesUi> *modulesModule;
144 UiWidget<Ui::OutputUi> *outputModule;
145 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
146 PreambleModule * preambleModule;
147 LocalLayout * localLayout;
149 GuiBranches * branchesModule;
150 GuiIndices * indicesModule;
152 BulletsModule * bulletsModule;
153 FloatPlacement * floatModule;
155 ModuleSelectionManager * selectionManager;
157 /// Available modules
158 GuiIdListModel * availableModel() { return &modules_av_model_; }
160 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
165 void updateContents();
167 void updateAvailableModules();
169 void updateSelectedModules();
171 void updateIncludeonlys();
172 /// save as default template
173 void saveDocDefault();
174 /// reset to default params
175 void useClassDefaults();
177 void setLayoutComboByIDString(std::string const & idString);
179 /// available modules
180 GuiIdListModel modules_av_model_;
182 GuiIdListModel modules_sel_model_;
184 BufferId current_id_;
186 /// return false if validate_listings_params returns error
189 /// font family names for BufferParams::fonts_default_family
190 static char const * const fontfamilies[5];
191 /// GUI names corresponding fontfamilies
192 static char const * fontfamilies_gui[5];
194 bool initialiseParams(std::string const & data);
198 void dispatchParams();
200 void modulesToParams(BufferParams &);
202 bool isBufferDependent() const { return true; }
203 /// always true since we don't manipulate document contents
204 bool canApply() const { return true; }
206 DocumentClass const & documentClass() const;
208 BufferParams & params() { return bp_; }
212 struct modInfoStruct {
217 /// List of available modules
218 std::list<modInfoStruct> const & getModuleInfo();
219 /// Modules in use in current buffer
220 std::list<modInfoStruct> const getSelectedModules();
222 std::list<modInfoStruct> const getProvidedModules();
224 std::list<modInfoStruct> const
225 makeModuleInfo(LayoutModuleList const & mods);
227 void setLanguage() const;
229 void saveAsDefault() const;
230 /// does this font provide Old Style figures?
231 bool providesOSF(QString const & font) const;
232 /// does this font provide true Small Caps?
233 bool providesSC(QString const & font) const;
234 /// does this font provide size adjustment?
235 bool providesScale(QString const & font) const;
236 /// does this font provide an alternative without math?
237 bool providesNoMath(QString const & font) const;
239 void executeBranchRenaming() const;
241 void setCustomPapersize(bool custom);
244 void loadModuleInfo();
246 void updateUnknownBranches();
248 void updateTexFonts();
250 void updateMathFonts(QString const & rm);
252 void updateFontOptions();
256 bool completeFontset() const;
258 bool noMathFont() const;
261 /// List of names of available modules
262 std::list<modInfoStruct> moduleNames_;
264 std::map<docstring, docstring> changedBranches_;
266 std::list<std::string> includeonlys_;
272 class PreambleModule : public UiWidget<Ui::PreambleUi>
277 void update(BufferParams const & params, BufferId id);
278 void apply(BufferParams & params);
281 /// signal that something's changed in the Widget.
285 void closeEvent(QCloseEvent *);
286 void on_preambleTE_textChanged() { changed(); }
289 typedef std::map<BufferId, std::pair<int,int> > Coords;
290 Coords preamble_coords_;
291 BufferId current_id_;
295 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
300 void update(BufferParams const & params, BufferId id);
301 void apply(BufferParams & params);
302 bool isValid() const { return validated_; }
305 /// signal that something's changed in the Widget.
313 void validatePressed();
314 void convertPressed();
317 BufferId current_id_;
322 } // namespace frontend
325 #endif // GUIDOCUMENT_H