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"
43 class LayoutModuleList;
51 class ModuleSelectionManager;
55 typedef void const * BufferId;
58 class UiWidget : public QWidget, public UI
61 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
65 class GuiDocument : public GuiDialog, public Ui::DocumentUi
69 GuiDocument(GuiView & lv);
71 void paramsToDialog();
72 void updateFontsize(std::string const &, std::string const &);
73 void updateFontlist();
74 void updateDefaultFormat();
75 void updatePagestyle(std::string const &, std::string const &);
76 bool isChildIncluded(std::string const &);
80 BufferParams const & params() const { return bp_; }
83 void updateNumbering();
84 void change_adaptor();
85 void includeonlyClicked(QTreeWidgetItem * item, int);
86 void setListingsMessage();
87 void saveDefaultClicked();
88 void useDefaultsClicked();
89 void setLSpacing(int);
90 void setMargins(bool);
91 void papersizeChanged(int);
93 void setCustomMargins(bool);
94 void fontencChanged(int);
95 void romanChanged(int);
96 void sansChanged(int);
99 void enableIndent(bool);
101 void enableSkip(bool);
102 void portraitChanged();
106 void bibtexChanged(int);
107 void updateModuleInfo();
108 void modulesChanged();
109 void changeBackgroundColor();
110 void deleteBackgroundColor();
111 void changeNoteFontColor();
112 void deleteNoteFontColor();
113 void xetexChanged(bool);
114 void branchesRename(docstring const &, docstring const &);
116 /// validate listings parameters and return an error message, if any
117 QString validateListingsParameters();
119 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
120 UiWidget<Ui::MasterChildUi> *masterChildModule;
121 UiWidget<Ui::FontUi> *fontModule;
122 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
123 UiWidget<Ui::MarginsUi> *marginsModule;
124 UiWidget<Ui::LanguageUi> *langModule;
125 UiWidget<Ui::NumberingUi> *numberingModule;
126 UiWidget<Ui::BiblioUi> *biblioModule;
127 UiWidget<Ui::MathsUi> *mathsModule;
128 UiWidget<Ui::LaTeXUi> *latexModule;
129 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
130 UiWidget<Ui::ModulesUi> *modulesModule;
131 UiWidget<Ui::OutputUi> *outputModule;
132 UiWidget<Ui::ListingsSettingsUi> *listingsModule;
133 PreambleModule * preambleModule;
135 GuiBranches * branchesModule;
136 GuiIndices * indicesModule;
138 BulletsModule * bulletsModule;
139 FloatPlacement * floatModule;
141 ModuleSelectionManager * selectionManager;
143 /// Available modules
144 GuiIdListModel * availableModel() { return &modules_av_model_; }
146 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
151 void updateContents();
153 void updateAvailableModules();
155 void updateSelectedModules();
157 void updateIncludeonlys();
158 /// save as default template
159 void saveDocDefault();
160 /// reset to default params
161 void useClassDefaults();
163 void setLayoutComboByIDString(std::string const & idString);
164 /// available classes
165 GuiIdListModel classes_model_;
166 /// available modules
167 GuiIdListModel modules_av_model_;
169 GuiIdListModel modules_sel_model_;
171 BufferId current_id_;
173 /// return false if validate_listings_params returns error
176 /// font family names for BufferParams::fontsDefaultFamily
177 static char const * const fontfamilies[5];
178 /// GUI names corresponding fontfamilies
179 static char const * fontfamilies_gui[5];
181 bool initialiseParams(std::string const & data);
185 void dispatchParams();
187 void modulesToParams(BufferParams &);
189 bool isBufferDependent() const { return true; }
190 /// always true since we don't manipulate document contents
191 bool canApply() const { return true; }
193 DocumentClass const & documentClass() const;
195 BufferParams & params() { return bp_; }
199 struct modInfoStruct {
204 /// List of available modules
205 std::list<modInfoStruct> const & getModuleInfo();
206 /// Modules in use in current buffer
207 std::list<modInfoStruct> const getSelectedModules();
209 std::list<modInfoStruct> const getProvidedModules();
211 std::list<modInfoStruct> const
212 makeModuleInfo(LayoutModuleList const & mods);
214 void setLanguage() const;
216 void saveAsDefault() const;
218 bool isFontAvailable(std::string const & font) const;
219 /// does this font provide Old Style figures?
220 bool providesOSF(std::string const & font) const;
221 /// does this font provide true Small Caps?
222 bool providesSC(std::string const & font) const;
223 /// does this font provide size adjustment?
224 bool providesScale(std::string const & font) const;
226 void executeBranchRenaming() const;
228 void setCustomPapersize(bool custom);
231 void loadModuleInfo();
233 void updateUnknownBranches();
236 /// List of names of available modules
237 std::list<modInfoStruct> moduleNames_;
239 std::map<docstring, docstring> changedBranches_;
241 std::list<std::string> includeonlys_;
245 class PreambleModule : public UiWidget<Ui::PreambleUi>
250 void update(BufferParams const & params, BufferId id);
251 void apply(BufferParams & params);
254 /// signal that something's changed in the Widget.
258 void closeEvent(QCloseEvent *);
259 void on_preambleTE_textChanged() { changed(); }
262 typedef std::map<BufferId, std::pair<int,int> > Coords;
263 Coords preamble_coords_;
264 BufferId current_id_;
268 } // namespace frontend
271 #endif // GUIDOCUMENT_H