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);
101 void fontOsfToggled(bool state);
102 void fontScToggled(bool state);
104 void enableIndent(bool);
106 void enableSkip(bool);
110 void languagePackageChanged(int);
111 void biblioChanged();
112 void bibtexChanged(int);
113 void setAuthorYear(bool);
114 void setNumerical(bool);
115 void updateModuleInfo();
116 void modulesChanged();
117 void changeBackgroundColor();
118 void deleteBackgroundColor();
119 void changeFontColor();
120 void deleteFontColor();
121 void changeNoteFontColor();
122 void deleteNoteFontColor();
123 void changeBoxBackgroundColor();
124 void deleteBoxBackgroundColor();
125 void languageChanged(int);
126 void osFontsChanged(bool);
127 void mathFontChanged(int);
128 void branchesRename(docstring const &, docstring const &);
130 /// validate listings parameters and return an error message, if any
131 QString validateListingsParameters();
133 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
134 UiWidget<Ui::MasterChildUi> *masterChildModule;
135 UiWidget<Ui::FontUi> *fontModule;
136 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
137 UiWidget<Ui::MarginsUi> *marginsModule;
138 UiWidget<Ui::LanguageUi> *langModule;
139 UiWidget<Ui::ColorUi> *colorModule;
140 UiWidget<Ui::NumberingUi> *numberingModule;
141 UiWidget<Ui::BiblioUi> *biblioModule;
142 UiWidget<Ui::MathsUi> *mathsModule;
143 UiWidget<Ui::LaTeXUi> *latexModule;
144 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
145 UiWidget<Ui::ModulesUi> *modulesModule;
146 UiWidget<Ui::OutputUi> *outputModule;
147 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
148 PreambleModule * preambleModule;
149 LocalLayout * localLayout;
151 GuiBranches * branchesModule;
152 GuiIndices * indicesModule;
154 BulletsModule * bulletsModule;
155 FloatPlacement * floatModule;
157 ModuleSelectionManager * selectionManager;
159 /// Available modules
160 GuiIdListModel * availableModel() { return &modules_av_model_; }
162 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
167 void updateContents();
169 void updateAvailableModules();
171 void updateSelectedModules();
173 void updateIncludeonlys();
174 /// save as default template
175 void saveDocDefault();
176 /// reset to default params
177 void useClassDefaults();
179 void setLayoutComboByIDString(std::string const & idString);
181 /// available modules
182 GuiIdListModel modules_av_model_;
184 GuiIdListModel modules_sel_model_;
186 BufferId current_id_;
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;
267 /// List of names of available modules
268 std::list<modInfoStruct> moduleNames_;
270 std::map<docstring, docstring> changedBranches_;
272 std::list<std::string> includeonlys_;
278 class PreambleModule : public UiWidget<Ui::PreambleUi>
283 void update(BufferParams const & params, BufferId id);
284 void apply(BufferParams & params);
287 /// signal that something's changed in the Widget.
291 void closeEvent(QCloseEvent *);
292 void on_preambleTE_textChanged() { changed(); }
295 typedef std::map<BufferId, std::pair<int,int> > Coords;
296 Coords preamble_coords_;
297 BufferId current_id_;
301 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
306 void update(BufferParams const & params, BufferId id);
307 void apply(BufferParams & params);
308 bool isValid() const { return validated_; }
311 /// signal that something's changed in the Widget.
319 void validatePressed();
320 void convertPressed();
323 BufferId current_id_;
328 } // namespace frontend
331 #endif // GUIDOCUMENT_H