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_MarginsUi.h"
31 #include "ui_MasterChildUi.h"
32 #include "ui_MathsUi.h"
33 #include "ui_ModulesUi.h"
34 #include "ui_NumberingUi.h"
35 #include "ui_OutputUi.h"
36 #include "ui_PageLayoutUi.h"
37 #include "ui_PDFSupportUi.h"
38 #include "ui_PreambleUi.h"
39 #include "ui_TextLayoutUi.h"
44 class LayoutModuleList;
52 class ModuleSelectionManager;
56 typedef void const * BufferId;
59 class UiWidget : public QWidget, public UI
62 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
66 class GuiDocument : public GuiDialog, public Ui::DocumentUi
70 GuiDocument(GuiView & lv);
72 void paramsToDialog();
73 void updateFontsize(std::string const &, std::string const &);
74 void updateFontlist();
75 void updateDefaultFormat();
76 void updatePagestyle(std::string const &, std::string const &);
77 bool isChildIncluded(std::string const &);
81 BufferParams const & params() const { return bp_; }
84 void updateNumbering();
85 void change_adaptor();
86 void includeonlyClicked(QTreeWidgetItem * item, int);
87 void setListingsMessage();
88 void saveDefaultClicked();
89 void useDefaultsClicked();
90 void setLSpacing(int);
91 void setMargins(bool);
92 void papersizeChanged(int);
94 void setCustomMargins(bool);
95 void fontencChanged(int);
96 void romanChanged(int);
97 void sansChanged(int);
100 void enableIndent(bool);
102 void enableSkip(bool);
103 void portraitChanged();
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 xetexChanged(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;
141 GuiBranches * branchesModule;
142 GuiIndices * indicesModule;
144 BulletsModule * bulletsModule;
145 FloatPlacement * floatModule;
147 ModuleSelectionManager * selectionManager;
149 /// Available modules
150 GuiIdListModel * availableModel() { return &modules_av_model_; }
152 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
157 void updateContents();
159 void updateAvailableModules();
161 void updateSelectedModules();
163 void updateIncludeonlys();
164 /// save as default template
165 void saveDocDefault();
166 /// reset to default params
167 void useClassDefaults();
169 void setLayoutComboByIDString(std::string const & idString);
171 /// available classes
172 GuiIdListModel classes_model_;
173 /// available modules
174 GuiIdListModel modules_av_model_;
176 GuiIdListModel modules_sel_model_;
178 BufferId current_id_;
180 /// return false if validate_listings_params returns error
183 /// font family names for BufferParams::fontsDefaultFamily
184 static char const * const fontfamilies[5];
185 /// GUI names corresponding fontfamilies
186 static char const * fontfamilies_gui[5];
188 bool initialiseParams(std::string const & data);
192 void dispatchParams();
194 void modulesToParams(BufferParams &);
196 bool isBufferDependent() const { return true; }
197 /// always true since we don't manipulate document contents
198 bool canApply() const { return true; }
200 DocumentClass const & documentClass() const;
202 BufferParams & params() { return bp_; }
206 struct modInfoStruct {
211 /// List of available modules
212 std::list<modInfoStruct> const & getModuleInfo();
213 /// Modules in use in current buffer
214 std::list<modInfoStruct> const getSelectedModules();
216 std::list<modInfoStruct> const getProvidedModules();
218 std::list<modInfoStruct> const
219 makeModuleInfo(LayoutModuleList const & mods);
221 void setLanguage() const;
223 void saveAsDefault() const;
225 bool isFontAvailable(std::string const & font) const;
226 /// does this font provide Old Style figures?
227 bool providesOSF(std::string const & font) const;
228 /// does this font provide true Small Caps?
229 bool providesSC(std::string const & font) const;
230 /// does this font provide size adjustment?
231 bool providesScale(std::string const & font) const;
233 void executeBranchRenaming() const;
235 void setCustomPapersize(bool custom);
238 void loadModuleInfo();
240 void updateUnknownBranches();
243 /// List of names of available modules
244 std::list<modInfoStruct> moduleNames_;
246 std::map<docstring, docstring> changedBranches_;
248 std::list<std::string> includeonlys_;
252 class PreambleModule : public UiWidget<Ui::PreambleUi>
257 void update(BufferParams const & params, BufferId id);
258 void apply(BufferParams & params);
261 /// signal that something's changed in the Widget.
265 void closeEvent(QCloseEvent *);
266 void on_preambleTE_textChanged() { changed(); }
269 typedef std::map<BufferId, std::pair<int,int> > Coords;
270 Coords preamble_coords_;
271 BufferId current_id_;
275 } // namespace frontend
278 #endif // GUIDOCUMENT_H