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_DocumentUi.h"
24 #include "ui_FontUi.h"
25 #include "ui_TextLayoutUi.h"
26 #include "ui_MasterChildUi.h"
27 #include "ui_MathsUi.h"
28 #include "ui_LaTeXUi.h"
29 #include "ui_PageLayoutUi.h"
30 #include "ui_LanguageUi.h"
31 #include "ui_BiblioUi.h"
32 #include "ui_NumberingUi.h"
33 #include "ui_MarginsUi.h"
34 #include "ui_PreambleUi.h"
35 #include "ui_PDFSupportUi.h"
36 #include "ui_ModulesUi.h"
37 #include "ui_OutputUi.h"
38 #include "ui_ListingsSettingsUi.h"
47 class LayoutModuleList;
54 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 &);
83 BufferParams const & params() const { return bp_; }
86 void updateNumbering();
87 void change_adaptor();
88 void includeonlyClicked(QTreeWidgetItem * item, int);
89 void setListingsMessage();
90 void saveDefaultClicked();
91 void useDefaultsClicked();
92 void setLSpacing(int);
93 void setMargins(bool);
94 void papersizeChanged(int);
96 void setCustomMargins(bool);
97 void fontencChanged(int);
98 void romanChanged(int);
99 void sansChanged(int);
102 void enableIndent(bool);
104 void enableSkip(bool);
105 void portraitChanged();
109 void bibtexChanged(int);
110 void updateModuleInfo();
111 void modulesChanged();
112 void changeBackgroundColor();
113 void deleteBackgroundColor();
114 void xetexChanged(bool);
115 void branchesRename(docstring const &, docstring const &);
117 /// validate listings parameters and return an error message, if any
118 QString validateListingsParameters();
120 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
121 UiWidget<Ui::MasterChildUi> *masterChildModule;
122 UiWidget<Ui::FontUi> *fontModule;
123 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
124 UiWidget<Ui::MarginsUi> *marginsModule;
125 UiWidget<Ui::LanguageUi> *langModule;
126 UiWidget<Ui::NumberingUi> *numberingModule;
127 UiWidget<Ui::BiblioUi> *biblioModule;
128 UiWidget<Ui::MathsUi> *mathsModule;
129 UiWidget<Ui::LaTeXUi> *latexModule;
130 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
131 UiWidget<Ui::ModulesUi> *modulesModule;
132 UiWidget<Ui::OutputUi> *outputModule;
133 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
134 PreambleModule * preambleModule;
136 GuiBranches * branchesModule;
137 GuiIndices * indicesModule;
139 BulletsModule * bulletsModule;
140 FloatPlacement * floatModule;
142 ModuleSelectionManager * selectionManager;
144 /// Available modules
145 GuiIdListModel * availableModel() { return &modules_av_model_; }
147 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
152 void updateContents();
154 void updateAvailableModules();
156 void updateSelectedModules();
158 void updateIncludeonlys();
159 /// save as default template
160 void saveDocDefault();
161 /// reset to default params
162 void useClassDefaults();
164 void setLayoutComboByIDString(std::string const & idString);
165 /// available classes
166 GuiIdListModel classes_model_;
167 /// available modules
168 GuiIdListModel modules_av_model_;
170 GuiIdListModel modules_sel_model_;
172 BufferId current_id_;
174 /// return false if validate_listings_params returns error
177 /// font family names for BufferParams::fontsDefaultFamily
178 static char const * const fontfamilies[5];
179 /// GUI names corresponding fontfamilies
180 static char const * fontfamilies_gui[5];
182 bool initialiseParams(std::string const & data);
186 void dispatchParams();
188 void modulesToParams(BufferParams &);
190 bool isBufferDependent() const { return true; }
191 /// always true since we don't manipulate document contents
192 bool canApply() const { return true; }
194 DocumentClass const & documentClass() const;
196 BufferParams & params() { return bp_; }
200 struct modInfoStruct {
205 /// List of available modules
206 std::list<modInfoStruct> const & getModuleInfo();
207 /// Modules in use in current buffer
208 std::list<modInfoStruct> const getSelectedModules();
210 std::list<modInfoStruct> const getProvidedModules();
212 std::list<modInfoStruct> const
213 makeModuleInfo(LayoutModuleList const & mods);
215 void setLanguage() const;
217 void saveAsDefault() const;
219 bool isFontAvailable(std::string const & font) const;
220 /// does this font provide Old Style figures?
221 bool providesOSF(std::string const & font) const;
222 /// does this font provide true Small Caps?
223 bool providesSC(std::string const & font) const;
224 /// does this font provide size adjustment?
225 bool providesScale(std::string const & font) const;
227 void executeBranchRenaming() const;
229 void setCustomPapersize(bool custom);
232 void loadModuleInfo();
234 void updateUnknownBranches();
237 /// List of names of available modules
238 std::list<modInfoStruct> moduleNames_;
240 std::map<docstring, docstring> changedBranches_;
242 std::list<std::string> includeonlys_;
246 class PreambleModule : public UiWidget<Ui::PreambleUi>
251 void update(BufferParams const & params, BufferId id);
252 void apply(BufferParams & params);
255 /// signal that something's changed in the Widget.
259 void closeEvent(QCloseEvent *);
260 void on_preambleTE_textChanged() { changed(); }
263 typedef std::map<BufferId, std::pair<int,int> > Coords;
264 Coords preamble_coords_;
265 BufferId current_id_;
269 } // namespace frontend
272 #endif // GUIDOCUMENT_H