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;
57 typedef void const * BufferId;
60 class UiWidget : public QWidget, public UI
63 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
67 class GuiDocument : public GuiDialog, public Ui::DocumentUi
71 GuiDocument(GuiView & lv);
73 void paramsToDialog();
74 void updateFontsize(std::string const &, std::string const &);
75 void updateFontlist();
76 void updateDefaultFormat();
77 void updateEngineType(std::string const &, CiteEngineType const &);
78 void updatePagestyle(std::string const &, std::string const &);
79 bool isChildIncluded(std::string const &);
82 BufferParams const & params() const { return bp_; }
85 void updateNumbering();
86 void change_adaptor();
87 void includeonlyClicked(QTreeWidgetItem * item, int);
88 void setListingsMessage();
89 void saveDefaultClicked();
90 void useDefaultsClicked();
91 void setLSpacing(int);
93 void papersizeChanged(int);
95 void setCustomMargins(bool);
96 void fontencChanged(int);
97 void romanChanged(int);
98 void sansChanged(int);
100 void fontOsfToggled(bool state);
101 void fontScToggled(bool state);
103 void enableIndent(bool);
105 void enableSkip(bool);
109 void classChanged_adaptor();
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 &);
129 void allPackagesAuto();
130 void allPackagesAlways();
131 void allPackagesNot();
133 /// validate listings parameters and return an error message, if any
134 QString validateListingsParameters();
136 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
137 UiWidget<Ui::MasterChildUi> *masterChildModule;
138 FontModule *fontModule;
139 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
140 UiWidget<Ui::MarginsUi> *marginsModule;
141 UiWidget<Ui::LanguageUi> *langModule;
142 UiWidget<Ui::ColorUi> *colorModule;
143 UiWidget<Ui::NumberingUi> *numberingModule;
144 UiWidget<Ui::BiblioUi> *biblioModule;
145 UiWidget<Ui::MathsUi> *mathsModule;
146 UiWidget<Ui::LaTeXUi> *latexModule;
147 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
148 UiWidget<Ui::ModulesUi> *modulesModule;
149 UiWidget<Ui::OutputUi> *outputModule;
150 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
151 PreambleModule * preambleModule;
152 LocalLayout * localLayout;
154 GuiBranches * branchesModule;
155 GuiIndices * indicesModule;
157 BulletsModule * bulletsModule;
158 FloatPlacement * floatModule;
160 ModuleSelectionManager * selectionManager;
162 /// Available modules
163 GuiIdListModel * availableModel() { return &modules_av_model_; }
165 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
170 void updateContents();
172 void updateAvailableModules();
174 void updateSelectedModules();
176 void updateIncludeonlys();
177 /// save as default template
178 void saveDocDefault();
179 /// reset to default params
180 void useClassDefaults();
182 void setLayoutComboByIDString(std::string const & idString);
184 /// available modules
185 GuiIdListModel modules_av_model_;
187 GuiIdListModel modules_sel_model_;
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_;
278 /// Track if a non-module document param changed
279 bool nonModuleChanged_;
283 class PreambleModule : public UiWidget<Ui::PreambleUi>
288 void update(BufferParams const & params, BufferId id);
289 void apply(BufferParams & params);
292 /// signal that something's changed in the Widget.
296 void closeEvent(QCloseEvent *);
297 void on_preambleTE_textChanged() { changed(); }
300 typedef std::map<BufferId, std::pair<int,int> > Coords;
301 Coords preamble_coords_;
302 BufferId current_id_;
306 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
311 void update(BufferParams const & params, BufferId id);
312 void apply(BufferParams & params);
313 bool isValid() const { return validated_; }
316 /// signal that something's changed in the Widget.
324 void validatePressed();
325 void convertPressed();
328 BufferId current_id_;
333 class FontModule : public UiWidget<Ui::FontUi>
337 /// The roman font currently not selected by osFontsCB->isChecked()
339 /// The sans font currently not selected by osFontsCB->isChecked()
341 /// The typewriter font currently not selected by osFontsCB->isChecked()
342 QString font_typewriter;
343 /// The math font currently not selected by osFontsCB->isChecked()
345 /// The sans font scale currently not selected by osFontsCB->isChecked()
347 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
352 } // namespace frontend
355 #endif // GUIDOCUMENT_H