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 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);
101 void enableIndent(bool);
103 void enableSkip(bool);
107 void bibtexChanged(int);
108 void updateModuleInfo();
109 void modulesChanged();
110 void changeBackgroundColor();
111 void deleteBackgroundColor();
112 void changeFontColor();
113 void deleteFontColor();
114 void changeNoteFontColor();
115 void deleteNoteFontColor();
116 void changeBoxBackgroundColor();
117 void deleteBoxBackgroundColor();
118 void osFontsChanged(bool);
119 void branchesRename(docstring const &, docstring const &);
121 /// validate listings parameters and return an error message, if any
122 QString validateListingsParameters();
124 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
125 UiWidget<Ui::MasterChildUi> *masterChildModule;
126 UiWidget<Ui::FontUi> *fontModule;
127 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
128 UiWidget<Ui::MarginsUi> *marginsModule;
129 UiWidget<Ui::LanguageUi> *langModule;
130 UiWidget<Ui::ColorUi> *colorModule;
131 UiWidget<Ui::NumberingUi> *numberingModule;
132 UiWidget<Ui::BiblioUi> *biblioModule;
133 UiWidget<Ui::MathsUi> *mathsModule;
134 UiWidget<Ui::LaTeXUi> *latexModule;
135 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
136 UiWidget<Ui::ModulesUi> *modulesModule;
137 UiWidget<Ui::OutputUi> *outputModule;
138 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
139 PreambleModule * preambleModule;
140 LocalLayout * localLayout;
142 GuiBranches * branchesModule;
143 GuiIndices * indicesModule;
145 BulletsModule * bulletsModule;
146 FloatPlacement * floatModule;
148 ModuleSelectionManager * selectionManager;
150 /// Available modules
151 GuiIdListModel * availableModel() { return &modules_av_model_; }
153 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
158 void updateContents();
160 void updateAvailableModules();
162 void updateSelectedModules();
164 void updateIncludeonlys();
165 /// save as default template
166 void saveDocDefault();
167 /// reset to default params
168 void useClassDefaults();
170 void setLayoutComboByIDString(std::string const & idString);
172 /// available classes
173 GuiIdListModel classes_model_;
174 /// available modules
175 GuiIdListModel modules_av_model_;
177 GuiIdListModel modules_sel_model_;
179 BufferId current_id_;
181 /// return false if validate_listings_params returns error
184 /// font family names for BufferParams::fonts_default_family
185 static char const * const fontfamilies[5];
186 /// GUI names corresponding fontfamilies
187 static char const * fontfamilies_gui[5];
189 bool initialiseParams(std::string const & data);
193 void dispatchParams();
195 void modulesToParams(BufferParams &);
197 bool isBufferDependent() const { return true; }
198 /// always true since we don't manipulate document contents
199 bool canApply() const { return true; }
201 DocumentClass const & documentClass() const;
203 BufferParams & params() { return bp_; }
207 struct modInfoStruct {
212 /// List of available modules
213 std::list<modInfoStruct> const & getModuleInfo();
214 /// Modules in use in current buffer
215 std::list<modInfoStruct> const getSelectedModules();
217 std::list<modInfoStruct> const getProvidedModules();
219 std::list<modInfoStruct> const
220 makeModuleInfo(LayoutModuleList const & mods);
222 void setLanguage() const;
224 void saveAsDefault() const;
226 bool isFontAvailable(std::string const & font) const;
227 /// does this font provide Old Style figures?
228 bool providesOSF(std::string const & font) const;
229 /// does this font provide true Small Caps?
230 bool providesSC(std::string const & font) const;
231 /// does this font provide size adjustment?
232 bool providesScale(std::string const & font) const;
234 void executeBranchRenaming() const;
236 void setCustomPapersize(bool custom);
239 void loadModuleInfo();
241 void updateUnknownBranches();
244 /// List of names of available modules
245 std::list<modInfoStruct> moduleNames_;
247 std::map<docstring, docstring> changedBranches_;
249 std::list<std::string> includeonlys_;
253 class PreambleModule : public UiWidget<Ui::PreambleUi>
258 void update(BufferParams const & params, BufferId id);
259 void apply(BufferParams & params);
262 /// signal that something's changed in the Widget.
266 void closeEvent(QCloseEvent *);
267 void on_preambleTE_textChanged() { changed(); }
270 typedef std::map<BufferId, std::pair<int,int> > Coords;
271 Coords preamble_coords_;
272 BufferId current_id_;
276 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
281 void update(BufferParams const & params, BufferId id);
282 void apply(BufferParams & params);
283 bool isValid() const { return is_valid_; }
286 /// signal that something's changed in the Widget.
293 void validatePressed();
296 BufferId current_id_;
301 } // namespace frontend
304 #endif // GUIDOCUMENT_H