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 languagePackageChanged(int);
108 void biblioChanged();
109 void bibtexChanged(int);
110 void setAuthorYear(bool);
111 void setNumerical(bool);
112 void updateModuleInfo();
113 void modulesChanged();
114 void changeBackgroundColor();
115 void deleteBackgroundColor();
116 void changeFontColor();
117 void deleteFontColor();
118 void changeNoteFontColor();
119 void deleteNoteFontColor();
120 void changeBoxBackgroundColor();
121 void deleteBoxBackgroundColor();
122 void osFontsChanged(bool);
123 void branchesRename(docstring const &, docstring const &);
125 /// validate listings parameters and return an error message, if any
126 QString validateListingsParameters();
128 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
129 UiWidget<Ui::MasterChildUi> *masterChildModule;
130 UiWidget<Ui::FontUi> *fontModule;
131 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
132 UiWidget<Ui::MarginsUi> *marginsModule;
133 UiWidget<Ui::LanguageUi> *langModule;
134 UiWidget<Ui::ColorUi> *colorModule;
135 UiWidget<Ui::NumberingUi> *numberingModule;
136 UiWidget<Ui::BiblioUi> *biblioModule;
137 UiWidget<Ui::MathsUi> *mathsModule;
138 UiWidget<Ui::LaTeXUi> *latexModule;
139 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
140 UiWidget<Ui::ModulesUi> *modulesModule;
141 UiWidget<Ui::OutputUi> *outputModule;
142 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
143 PreambleModule * preambleModule;
144 LocalLayout * localLayout;
146 GuiBranches * branchesModule;
147 GuiIndices * indicesModule;
149 BulletsModule * bulletsModule;
150 FloatPlacement * floatModule;
152 ModuleSelectionManager * selectionManager;
154 /// Available modules
155 GuiIdListModel * availableModel() { return &modules_av_model_; }
157 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
162 void updateContents();
164 void updateAvailableModules();
166 void updateSelectedModules();
168 void updateIncludeonlys();
169 /// save as default template
170 void saveDocDefault();
171 /// reset to default params
172 void useClassDefaults();
174 void setLayoutComboByIDString(std::string const & idString);
176 /// available classes
177 GuiIdListModel classes_model_;
178 /// available modules
179 GuiIdListModel modules_av_model_;
181 GuiIdListModel modules_sel_model_;
183 BufferId current_id_;
185 /// return false if validate_listings_params returns error
188 /// font family names for BufferParams::fonts_default_family
189 static char const * const fontfamilies[5];
190 /// GUI names corresponding fontfamilies
191 static char const * fontfamilies_gui[5];
193 bool initialiseParams(std::string const & data);
197 void dispatchParams();
199 void modulesToParams(BufferParams &);
201 bool isBufferDependent() const { return true; }
202 /// always true since we don't manipulate document contents
203 bool canApply() const { return true; }
205 DocumentClass const & documentClass() const;
207 BufferParams & params() { return bp_; }
211 struct modInfoStruct {
216 /// List of available modules
217 std::list<modInfoStruct> const & getModuleInfo();
218 /// Modules in use in current buffer
219 std::list<modInfoStruct> const getSelectedModules();
221 std::list<modInfoStruct> const getProvidedModules();
223 std::list<modInfoStruct> const
224 makeModuleInfo(LayoutModuleList const & mods);
226 void setLanguage() const;
228 void saveAsDefault() const;
230 bool isFontAvailable(std::string const & font) const;
231 /// does this font provide Old Style figures?
232 bool providesOSF(std::string const & font) const;
233 /// does this font provide true Small Caps?
234 bool providesSC(std::string const & font) const;
235 /// does this font provide size adjustment?
236 bool providesScale(std::string const & font) const;
238 void executeBranchRenaming() const;
240 void setCustomPapersize(bool custom);
243 void loadModuleInfo();
245 void updateUnknownBranches();
248 /// List of names of available modules
249 std::list<modInfoStruct> moduleNames_;
251 std::map<docstring, docstring> changedBranches_;
253 std::list<std::string> includeonlys_;
259 class PreambleModule : public UiWidget<Ui::PreambleUi>
264 void update(BufferParams const & params, BufferId id);
265 void apply(BufferParams & params);
268 /// signal that something's changed in the Widget.
272 void closeEvent(QCloseEvent *);
273 void on_preambleTE_textChanged() { changed(); }
276 typedef std::map<BufferId, std::pair<int,int> > Coords;
277 Coords preamble_coords_;
278 BufferId current_id_;
282 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
287 void update(BufferParams const & params, BufferId id);
288 void apply(BufferParams & params);
289 bool isValid() const { return is_valid_; }
292 /// signal that something's changed in the Widget.
300 void validatePressed();
301 void convertPressed();
304 BufferId current_id_;
309 } // namespace frontend
312 #endif // GUIDOCUMENT_H