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);
187 /// Update quotes styles combo, indicating the current language's default
188 void updateQuoteStyles(bool const set = false);
190 /// available modules
191 GuiIdListModel modules_av_model_;
193 GuiIdListModel modules_sel_model_;
195 /// return false if validate_listings_params returns error
198 /// font family names for BufferParams::fonts_default_family
199 static char const * const fontfamilies[5];
200 /// GUI names corresponding fontfamilies
201 static char const * fontfamilies_gui[5];
203 bool initialiseParams(std::string const & data);
207 void dispatchParams();
209 void modulesToParams(BufferParams &);
211 bool isBufferDependent() const { return true; }
212 /// always true since we don't manipulate document contents
213 bool canApply() const { return true; }
215 DocumentClass const & documentClass() const;
217 BufferParams & params() { return bp_; }
221 struct modInfoStruct {
227 static modInfoStruct modInfo(LyXModule const & mod);
228 /// List of available modules
229 std::list<modInfoStruct> const & getModuleInfo();
230 /// Modules in use in current buffer
231 std::list<modInfoStruct> const getSelectedModules();
233 std::list<modInfoStruct> const getProvidedModules();
235 std::list<modInfoStruct> const
236 makeModuleInfo(LayoutModuleList const & mods);
238 void setLanguage() const;
240 void saveAsDefault() const;
241 /// does this font provide Old Style figures?
242 bool providesOSF(QString const & font) const;
243 /// does this font provide true Small Caps?
244 bool providesSC(QString const & font) const;
245 /** does this font provide OSF and Small Caps only via
246 * a single, undifferentiated expert option?
248 bool hasMonolithicExpertSet(QString const & font) const;
249 /// does this font provide size adjustment?
250 bool providesScale(QString const & font) const;
251 /// does this font provide an alternative without math?
252 bool providesNoMath(QString const & font) const;
254 void executeBranchRenaming() const;
256 void setCustomPapersize(bool custom);
259 void loadModuleInfo();
261 void updateUnknownBranches();
263 void updateTexFonts();
265 void updateMathFonts(QString const & rm);
267 void updateFontOptions();
271 bool completeFontset() const;
273 bool noMathFont() const;
275 void allPackages(int);
278 /// List of names of available modules
279 std::list<modInfoStruct> moduleNames_;
281 std::map<docstring, docstring> changedBranches_;
283 std::list<std::string> includeonlys_;
286 /// Track if a non-module document param changed
287 bool nonModuleChanged_;
291 class PreambleModule : public UiWidget<Ui::PreambleUi>
296 void update(BufferParams const & params, BufferId id);
297 void apply(BufferParams & params);
300 /// signal that something's changed in the Widget.
304 void closeEvent(QCloseEvent *);
305 void on_preambleTE_textChanged() { changed(); }
308 typedef std::map<BufferId, std::pair<int,int> > Coords;
309 Coords preamble_coords_;
310 BufferId current_id_;
314 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
319 void update(BufferParams const & params, BufferId id);
320 void apply(BufferParams & params);
321 bool isValid() const { return validated_; }
324 /// signal that something's changed in the Widget.
333 void validatePressed();
334 void convertPressed();
337 BufferId current_id_;
342 class FontModule : public UiWidget<Ui::FontUi>
346 /// The roman font currently not selected by osFontsCB->isChecked()
348 /// The sans font currently not selected by osFontsCB->isChecked()
350 /// The typewriter font currently not selected by osFontsCB->isChecked()
351 QString font_typewriter;
352 /// The math font currently not selected by osFontsCB->isChecked()
354 /// The sans font scale currently not selected by osFontsCB->isChecked()
356 /// The typewriter font scale currently not selected by osFontsCB->isChecked()
361 } // namespace frontend
364 #endif // GUIDOCUMENT_H