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;
52 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 onBufferViewChanged();//override
89 void updateNumbering();
90 void change_adaptor();
91 void includeonlyClicked(QTreeWidgetItem * item, int);
92 void setListingsMessage();
93 void saveDefaultClicked();
94 void useDefaultsClicked();
95 void setLSpacing(int);
97 void papersizeChanged(int);
99 void setCustomMargins(bool);
100 void fontencChanged(int);
101 void romanChanged(int);
102 void sansChanged(int);
104 void fontOsfToggled(bool state);
105 void fontScToggled(bool state);
107 void enableIndent(bool);
109 void enableSkip(bool);
113 void classChanged_adaptor();
114 void languagePackageChanged(int);
115 void biblioChanged();
116 void bibtexChanged(int);
117 void setAuthorYear(bool);
118 void setNumerical(bool);
119 void updateModuleInfo();
120 void modulesChanged();
121 void changeBackgroundColor();
122 void deleteBackgroundColor();
123 void changeFontColor();
124 void deleteFontColor();
125 void changeNoteFontColor();
126 void deleteNoteFontColor();
127 void changeBoxBackgroundColor();
128 void deleteBoxBackgroundColor();
129 void languageChanged(int);
130 void osFontsChanged(bool);
131 void mathFontChanged(int);
132 void branchesRename(docstring const &, docstring const &);
133 void allPackagesAuto();
134 void allPackagesAlways();
135 void allPackagesNot();
137 /// validate listings parameters and return an error message, if any
138 QString validateListingsParameters();
140 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
141 UiWidget<Ui::MasterChildUi> *masterChildModule;
142 FontModule *fontModule;
143 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
144 UiWidget<Ui::MarginsUi> *marginsModule;
145 UiWidget<Ui::LanguageUi> *langModule;
146 UiWidget<Ui::ColorUi> *colorModule;
147 UiWidget<Ui::NumberingUi> *numberingModule;
148 UiWidget<Ui::BiblioUi> *biblioModule;
149 UiWidget<Ui::MathsUi> *mathsModule;
150 UiWidget<Ui::LaTeXUi> *latexModule;
151 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
152 UiWidget<Ui::ModulesUi> *modulesModule;
153 UiWidget<Ui::OutputUi> *outputModule;
154 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
155 PreambleModule * preambleModule;
156 LocalLayout * localLayout;
158 GuiBranches * branchesModule;
159 GuiIndices * indicesModule;
161 BulletsModule * bulletsModule;
162 FloatPlacement * floatModule;
164 ModuleSelectionManager * selectionManager;
166 /// Available modules
167 GuiIdListModel * availableModel() { return &modules_av_model_; }
169 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
174 void updateContents();
176 void updateAvailableModules();
178 void updateSelectedModules();
180 void updateIncludeonlys();
181 /// save as default template
182 void saveDocDefault();
183 /// reset to default params
184 void useClassDefaults();
186 void setLayoutComboByIDString(std::string const & idString);
188 /// available modules
189 GuiIdListModel modules_av_model_;
191 GuiIdListModel modules_sel_model_;
193 /// return false if validate_listings_params returns error
196 /// font family names for BufferParams::fonts_default_family
197 static char const * const fontfamilies[5];
198 /// GUI names corresponding fontfamilies
199 static char const * fontfamilies_gui[5];
201 bool initialiseParams(std::string const & data);
205 void dispatchParams();
207 void modulesToParams(BufferParams &);
209 bool isBufferDependent() const { return true; }
210 /// always true since we don't manipulate document contents
211 bool canApply() const { return true; }
213 DocumentClass const & documentClass() const;
215 BufferParams & params() { return bp_; }
219 struct modInfoStruct {
225 static modInfoStruct modInfo(LyXModule const & mod);
226 /// List of available modules
227 std::list<modInfoStruct> const & getModuleInfo();
228 /// Modules in use in current buffer
229 std::list<modInfoStruct> const getSelectedModules();
231 std::list<modInfoStruct> const getProvidedModules();
233 std::list<modInfoStruct> const
234 makeModuleInfo(LayoutModuleList const & mods);
236 void setLanguage() const;
238 void saveAsDefault() const;
239 /// does this font provide Old Style figures?
240 bool providesOSF(QString const & font) const;
241 /// does this font provide true Small Caps?
242 bool providesSC(QString const & font) const;
243 /** does this font provide OSF and Small Caps only via
244 * a single, undifferentiated expert option?
246 bool hasMonolithicExpertSet(QString const & font) const;
247 /// does this font provide size adjustment?
248 bool providesScale(QString const & font) const;
249 /// does this font provide an alternative without math?
250 bool providesNoMath(QString const & font) const;
252 void executeBranchRenaming() const;
254 void setCustomPapersize(bool custom);
257 void loadModuleInfo();
259 void updateUnknownBranches();
261 void updateTexFonts();
263 void updateMathFonts(QString const & rm);
265 void updateFontOptions();
269 bool completeFontset() const;
271 bool noMathFont() const;
273 void allPackages(int);
276 /// List of names of available modules
277 std::list<modInfoStruct> moduleNames_;
279 std::map<docstring, docstring> changedBranches_;
281 std::list<std::string> includeonlys_;
284 /// Track if a non-module document param changed
285 bool nonModuleChanged_;
289 class PreambleModule : public UiWidget<Ui::PreambleUi>
294 void update(BufferParams const & params, BufferId id);
295 void apply(BufferParams & params);
298 /// signal that something's changed in the Widget.
302 void closeEvent(QCloseEvent *);
303 void on_preambleTE_textChanged() { changed(); }
306 typedef std::map<BufferId, std::pair<int,int> > Coords;
307 Coords preamble_coords_;
308 BufferId current_id_;
312 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
317 void update(BufferParams const & params, BufferId id);
318 void apply(BufferParams & params);
319 bool isValid() const { return validated_; }
322 /// signal that something's changed in the Widget.
331 void validatePressed();
332 void convertPressed();
335 BufferId current_id_;
340 class FontModule : public UiWidget<Ui::FontUi>
344 /// The roman font currently not selected by osFontsCB->isChecked()
346 /// The sans font currently not selected by osFontsCB->isChecked()
348 /// The typewriter font currently not selected by osFontsCB->isChecked()
349 QString font_typewriter;
350 /// The math font currently not selected by osFontsCB->isChecked()
352 /// The sans font scale currently not selected by osFontsCB->isChecked()
354 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
359 } // namespace frontend
362 #endif // GUIDOCUMENT_H