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 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 &);
127 void allPackagesAuto();
128 void allPackagesAlways();
129 void allPackagesNot();
131 /// validate listings parameters and return an error message, if any
132 QString validateListingsParameters();
134 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
135 UiWidget<Ui::MasterChildUi> *masterChildModule;
136 UiWidget<Ui::FontUi> *fontModule;
137 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
138 UiWidget<Ui::MarginsUi> *marginsModule;
139 UiWidget<Ui::LanguageUi> *langModule;
140 UiWidget<Ui::ColorUi> *colorModule;
141 UiWidget<Ui::NumberingUi> *numberingModule;
142 UiWidget<Ui::BiblioUi> *biblioModule;
143 UiWidget<Ui::MathsUi> *mathsModule;
144 UiWidget<Ui::LaTeXUi> *latexModule;
145 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
146 UiWidget<Ui::ModulesUi> *modulesModule;
147 UiWidget<Ui::OutputUi> *outputModule;
148 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
149 PreambleModule * preambleModule;
150 LocalLayout * localLayout;
152 GuiBranches * branchesModule;
153 GuiIndices * indicesModule;
155 BulletsModule * bulletsModule;
156 FloatPlacement * floatModule;
158 ModuleSelectionManager * selectionManager;
160 /// Available modules
161 GuiIdListModel * availableModel() { return &modules_av_model_; }
163 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
168 void updateContents();
170 void updateAvailableModules();
172 void updateSelectedModules();
174 void updateIncludeonlys();
175 /// save as default template
176 void saveDocDefault();
177 /// reset to default params
178 void useClassDefaults();
180 void setLayoutComboByIDString(std::string const & idString);
182 /// available modules
183 GuiIdListModel modules_av_model_;
185 GuiIdListModel modules_sel_model_;
187 BufferId current_id_;
189 /// return false if validate_listings_params returns error
192 /// font family names for BufferParams::fonts_default_family
193 static char const * const fontfamilies[5];
194 /// GUI names corresponding fontfamilies
195 static char const * fontfamilies_gui[5];
197 bool initialiseParams(std::string const & data);
201 void dispatchParams();
203 void modulesToParams(BufferParams &);
205 bool isBufferDependent() const { return true; }
206 /// always true since we don't manipulate document contents
207 bool canApply() const { return true; }
209 DocumentClass const & documentClass() const;
211 BufferParams & params() { return bp_; }
215 struct modInfoStruct {
220 /// List of available modules
221 std::list<modInfoStruct> const & getModuleInfo();
222 /// Modules in use in current buffer
223 std::list<modInfoStruct> const getSelectedModules();
225 std::list<modInfoStruct> const getProvidedModules();
227 std::list<modInfoStruct> const
228 makeModuleInfo(LayoutModuleList const & mods);
230 void setLanguage() const;
232 void saveAsDefault() const;
233 /// does this font provide Old Style figures?
234 bool providesOSF(QString const & font) const;
235 /// does this font provide true Small Caps?
236 bool providesSC(QString const & font) const;
237 /** does this font provide OSF and Small Caps only via
238 * a single, undifferentiated expert option?
240 bool hasMonolithicExpertSet(QString const & font) const;
241 /// does this font provide size adjustment?
242 bool providesScale(QString const & font) const;
243 /// does this font provide an alternative without math?
244 bool providesNoMath(QString const & font) const;
246 void executeBranchRenaming() const;
248 void setCustomPapersize(bool custom);
251 void loadModuleInfo();
253 void updateUnknownBranches();
255 void updateTexFonts();
257 void updateMathFonts(QString const & rm);
259 void updateFontOptions();
263 bool completeFontset() const;
265 bool noMathFont() const;
267 void allPackages(int);
270 /// List of names of available modules
271 std::list<modInfoStruct> moduleNames_;
273 std::map<docstring, docstring> changedBranches_;
275 std::list<std::string> includeonlys_;
281 class PreambleModule : public UiWidget<Ui::PreambleUi>
286 void update(BufferParams const & params, BufferId id);
287 void apply(BufferParams & params);
290 /// signal that something's changed in the Widget.
294 void closeEvent(QCloseEvent *);
295 void on_preambleTE_textChanged() { changed(); }
298 typedef std::map<BufferId, std::pair<int,int> > Coords;
299 Coords preamble_coords_;
300 BufferId current_id_;
304 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
309 void update(BufferParams const & params, BufferId id);
310 void apply(BufferParams & params);
311 bool isValid() const { return validated_; }
314 /// signal that something's changed in the Widget.
322 void validatePressed();
323 void convertPressed();
326 BufferId current_id_;
331 } // namespace frontend
334 #endif // GUIDOCUMENT_H