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);
170 /// available classes
171 GuiIdListModel classes_model_;
172 /// available modules
173 GuiIdListModel modules_av_model_;
175 GuiIdListModel modules_sel_model_;
177 BufferId current_id_;
179 /// return false if validate_listings_params returns error
182 /// font family names for BufferParams::fontsDefaultFamily
183 static char const * const fontfamilies[5];
184 /// GUI names corresponding fontfamilies
185 static char const * fontfamilies_gui[5];
187 bool initialiseParams(std::string const & data);
191 void dispatchParams();
193 void modulesToParams(BufferParams &);
195 bool isBufferDependent() const { return true; }
196 /// always true since we don't manipulate document contents
197 bool canApply() const { return true; }
199 DocumentClass const & documentClass() const;
201 BufferParams & params() { return bp_; }
205 struct modInfoStruct {
210 /// List of available modules
211 std::list<modInfoStruct> const & getModuleInfo();
212 /// Modules in use in current buffer
213 std::list<modInfoStruct> const getSelectedModules();
215 std::list<modInfoStruct> const getProvidedModules();
217 std::list<modInfoStruct> const
218 makeModuleInfo(LayoutModuleList const & mods);
220 void setLanguage() const;
222 void saveAsDefault() const;
224 bool isFontAvailable(std::string const & font) const;
225 /// does this font provide Old Style figures?
226 bool providesOSF(std::string const & font) const;
227 /// does this font provide true Small Caps?
228 bool providesSC(std::string const & font) const;
229 /// does this font provide size adjustment?
230 bool providesScale(std::string const & font) const;
232 void executeBranchRenaming() const;
234 void setCustomPapersize(bool custom);
237 void loadModuleInfo();
239 void updateUnknownBranches();
242 /// List of names of available modules
243 std::list<modInfoStruct> moduleNames_;
245 std::map<docstring, docstring> changedBranches_;
247 std::list<std::string> includeonlys_;
251 class PreambleModule : public UiWidget<Ui::PreambleUi>
256 void update(BufferParams const & params, BufferId id);
257 void apply(BufferParams & params);
260 /// signal that something's changed in the Widget.
264 void closeEvent(QCloseEvent *);
265 void on_preambleTE_textChanged() { changed(); }
268 typedef std::map<BufferId, std::pair<int,int> > Coords;
269 Coords preamble_coords_;
270 BufferId current_id_;
274 } // namespace frontend
277 #endif // GUIDOCUMENT_H