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 bibtexChanged(int);
109 void updateModuleInfo();
110 void modulesChanged();
111 void changeBackgroundColor();
112 void deleteBackgroundColor();
113 void changeFontColor();
114 void deleteFontColor();
115 void changeNoteFontColor();
116 void deleteNoteFontColor();
117 void changeBoxBackgroundColor();
118 void deleteBoxBackgroundColor();
119 void osFontsChanged(bool);
120 void branchesRename(docstring const &, docstring const &);
122 /// validate listings parameters and return an error message, if any
123 QString validateListingsParameters();
125 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
126 UiWidget<Ui::MasterChildUi> *masterChildModule;
127 UiWidget<Ui::FontUi> *fontModule;
128 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
129 UiWidget<Ui::MarginsUi> *marginsModule;
130 UiWidget<Ui::LanguageUi> *langModule;
131 UiWidget<Ui::ColorUi> *colorModule;
132 UiWidget<Ui::NumberingUi> *numberingModule;
133 UiWidget<Ui::BiblioUi> *biblioModule;
134 UiWidget<Ui::MathsUi> *mathsModule;
135 UiWidget<Ui::LaTeXUi> *latexModule;
136 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
137 UiWidget<Ui::ModulesUi> *modulesModule;
138 UiWidget<Ui::OutputUi> *outputModule;
139 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
140 PreambleModule * preambleModule;
141 LocalLayout * localLayout;
143 GuiBranches * branchesModule;
144 GuiIndices * indicesModule;
146 BulletsModule * bulletsModule;
147 FloatPlacement * floatModule;
149 ModuleSelectionManager * selectionManager;
151 /// Available modules
152 GuiIdListModel * availableModel() { return &modules_av_model_; }
154 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
159 void updateContents();
161 void updateAvailableModules();
163 void updateSelectedModules();
165 void updateIncludeonlys();
166 /// save as default template
167 void saveDocDefault();
168 /// reset to default params
169 void useClassDefaults();
171 void setLayoutComboByIDString(std::string const & idString);
173 /// available classes
174 GuiIdListModel classes_model_;
175 /// available modules
176 GuiIdListModel modules_av_model_;
178 GuiIdListModel modules_sel_model_;
180 BufferId current_id_;
182 /// return false if validate_listings_params returns error
185 /// font family names for BufferParams::fonts_default_family
186 static char const * const fontfamilies[5];
187 /// GUI names corresponding fontfamilies
188 static char const * fontfamilies_gui[5];
190 bool initialiseParams(std::string const & data);
194 void dispatchParams();
196 void modulesToParams(BufferParams &);
198 bool isBufferDependent() const { return true; }
199 /// always true since we don't manipulate document contents
200 bool canApply() const { return true; }
202 DocumentClass const & documentClass() const;
204 BufferParams & params() { return bp_; }
208 struct modInfoStruct {
213 /// List of available modules
214 std::list<modInfoStruct> const & getModuleInfo();
215 /// Modules in use in current buffer
216 std::list<modInfoStruct> const getSelectedModules();
218 std::list<modInfoStruct> const getProvidedModules();
220 std::list<modInfoStruct> const
221 makeModuleInfo(LayoutModuleList const & mods);
223 void setLanguage() const;
225 void saveAsDefault() const;
227 bool isFontAvailable(std::string const & font) const;
228 /// does this font provide Old Style figures?
229 bool providesOSF(std::string const & font) const;
230 /// does this font provide true Small Caps?
231 bool providesSC(std::string const & font) const;
232 /// does this font provide size adjustment?
233 bool providesScale(std::string const & font) const;
235 void executeBranchRenaming() const;
237 void setCustomPapersize(bool custom);
240 void loadModuleInfo();
242 void updateUnknownBranches();
245 /// List of names of available modules
246 std::list<modInfoStruct> moduleNames_;
248 std::map<docstring, docstring> changedBranches_;
250 std::list<std::string> includeonlys_;
254 class PreambleModule : public UiWidget<Ui::PreambleUi>
259 void update(BufferParams const & params, BufferId id);
260 void apply(BufferParams & params);
263 /// signal that something's changed in the Widget.
267 void closeEvent(QCloseEvent *);
268 void on_preambleTE_textChanged() { changed(); }
271 typedef std::map<BufferId, std::pair<int,int> > Coords;
272 Coords preamble_coords_;
273 BufferId current_id_;
277 class LocalLayout : public UiWidget<Ui::LocalLayoutUi>
282 void update(BufferParams const & params, BufferId id);
283 void apply(BufferParams & params);
284 bool isValid() const { return is_valid_; }
287 /// signal that something's changed in the Widget.
294 void validatePressed();
297 BufferId current_id_;
302 } // namespace frontend
305 #endif // GUIDOCUMENT_H