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_MathsUi.h"
27 #include "ui_LaTeXUi.h"
28 #include "ui_PageLayoutUi.h"
29 #include "ui_LanguageUi.h"
30 #include "ui_BiblioUi.h"
31 #include "ui_NumberingUi.h"
32 #include "ui_MarginsUi.h"
33 #include "ui_PreambleUi.h"
34 #include "ui_PDFSupportUi.h"
35 #include "ui_ModulesUi.h"
36 #include "ui_OutputUi.h"
45 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 &);
80 BufferParams const & params() const { return bp_; }
83 void updateNumbering();
84 void change_adaptor();
85 void setListingsMessage();
86 void saveDefaultClicked();
87 void useDefaultsClicked();
88 void setLSpacing(int);
89 void setMargins(bool);
90 void papersizeChanged(int);
92 void setCustomMargins(bool);
93 void romanChanged(int);
94 void sansChanged(int);
97 void enableIndent(bool);
99 void enableSkip(bool);
100 void portraitChanged();
104 void bibtexChanged(int);
105 void updateModuleInfo();
106 void modulesChanged();
107 void changeBackgroundColor();
108 void deleteBackgroundColor();
109 void xetexChanged(bool);
110 void branchesRename(docstring const &, docstring const &);
112 /// validate listings parameters and return an error message, if any
113 QString validateListingsParameters();
115 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
116 UiWidget<Ui::FontUi> *fontModule;
117 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
118 UiWidget<Ui::MarginsUi> *marginsModule;
119 UiWidget<Ui::LanguageUi> *langModule;
120 UiWidget<Ui::NumberingUi> *numberingModule;
121 UiWidget<Ui::BiblioUi> *biblioModule;
122 UiWidget<Ui::MathsUi> *mathsModule;
123 UiWidget<Ui::LaTeXUi> *latexModule;
124 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
125 UiWidget<Ui::ModulesUi> *modulesModule;
126 UiWidget<Ui::OutputUi> *outputModule;
127 PreambleModule * preambleModule;
129 GuiBranches * branchesModule;
130 GuiIndices * indicesModule;
132 BulletsModule * bulletsModule;
133 FloatPlacement * floatModule;
135 ModuleSelectionManager * selectionManager;
137 /// Available modules
138 GuiIdListModel * availableModel() { return &modules_av_model_; }
140 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
145 void updateContents();
147 void updateAvailableModules();
149 void updateSelectedModules();
150 /// save as default template
151 void saveDocDefault();
152 /// reset to default params
153 void useClassDefaults();
155 void setLayoutComboByIDString(std::string const & idString);
156 /// available classes
157 GuiIdListModel classes_model_;
158 /// available modules
159 GuiIdListModel modules_av_model_;
161 GuiIdListModel modules_sel_model_;
163 BufferId current_id_;
165 /// return false if validate_listings_params returns error
168 /// font family names for BufferParams::fontsDefaultFamily
169 static char const * const fontfamilies[5];
170 /// GUI names corresponding fontfamilies
171 static char const * fontfamilies_gui[5];
173 bool initialiseParams(std::string const & data);
177 void dispatchParams();
179 void modulesToParams(BufferParams &);
181 bool isBufferDependent() const { return true; }
182 /// always true since we don't manipulate document contents
183 bool canApply() const { return true; }
185 DocumentClass const & documentClass() const;
187 BufferParams & params() { return bp_; }
191 struct modInfoStruct {
196 /// List of available modules
197 std::list<modInfoStruct> const & getModuleInfo();
198 /// Modules in use in current buffer
199 std::list<modInfoStruct> const getSelectedModules();
201 std::list<modInfoStruct> const getProvidedModules();
203 std::list<modInfoStruct> const
204 makeModuleInfo(LayoutModuleList const & mods);
206 void setLanguage() const;
208 void saveAsDefault() const;
210 bool isFontAvailable(std::string const & font) const;
211 /// does this font provide Old Style figures?
212 bool providesOSF(std::string const & font) const;
213 /// does this font provide true Small Caps?
214 bool providesSC(std::string const & font) const;
215 /// does this font provide size adjustment?
216 bool providesScale(std::string const & font) const;
218 void executeBranchRenaming() const;
220 void setCustomPapersize(bool custom);
223 void loadModuleInfo();
225 void updateUnknownBranches();
228 /// List of names of available modules
229 std::list<modInfoStruct> moduleNames_;
231 std::map<docstring, docstring> changedBranches_;
235 class PreambleModule : public UiWidget<Ui::PreambleUi>
240 void update(BufferParams const & params, BufferId id);
241 void apply(BufferParams & params);
244 /// signal that something's changed in the Widget.
248 void closeEvent(QCloseEvent *);
249 void on_preambleTE_textChanged() { changed(); }
252 typedef std::map<BufferId, std::pair<int,int> > Coords;
253 Coords preamble_coords_;
254 BufferId current_id_;
258 } // namespace frontend
261 #endif // GUIDOCUMENT_H