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 setCustomPapersize(int);
92 void setCustomMargins(bool);
93 void romanChanged(int);
94 void sansChanged(int);
97 void enableSkip(bool);
98 void portraitChanged();
102 void updateModuleInfo();
103 void modulesChanged();
104 void changeBackgroundColor();
105 void deleteBackgroundColor();
106 void xetexChanged(bool);
108 /// validate listings parameters and return an error message, if any
109 QString validateListingsParameters();
111 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
112 UiWidget<Ui::FontUi> *fontModule;
113 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
114 UiWidget<Ui::MarginsUi> *marginsModule;
115 UiWidget<Ui::LanguageUi> *langModule;
116 UiWidget<Ui::NumberingUi> *numberingModule;
117 UiWidget<Ui::BiblioUi> *biblioModule;
118 UiWidget<Ui::MathsUi> *mathsModule;
119 UiWidget<Ui::LaTeXUi> *latexModule;
120 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
121 UiWidget<Ui::ModulesUi> *modulesModule;
122 UiWidget<Ui::OutputUi> *outputModule;
123 PreambleModule * preambleModule;
125 GuiBranches * branchesModule;
126 GuiIndices * indicesModule;
128 BulletsModule * bulletsModule;
129 FloatPlacement * floatModule;
131 ModuleSelectionManager * selectionManager;
133 /// Available modules
134 GuiIdListModel * availableModel() { return &modules_av_model_; }
136 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
141 void updateContents();
143 void updateAvailableModules();
145 void updateSelectedModules();
146 /// save as default template
147 void saveDocDefault();
148 /// reset to default params
149 void useClassDefaults();
151 void setLayoutComboByIDString(std::string const & idString);
152 /// available classes
153 GuiIdListModel classes_model_;
154 /// available modules
155 GuiIdListModel modules_av_model_;
157 GuiIdListModel modules_sel_model_;
159 BufferId current_id_;
161 /// return false if validate_listings_params returns error
164 /// font family names for BufferParams::fontsDefaultFamily
165 static char const * const fontfamilies[5];
166 /// GUI names corresponding fontfamilies
167 static char const * fontfamilies_gui[5];
169 bool initialiseParams(std::string const & data);
173 void dispatchParams();
175 void modulesToParams(BufferParams &);
177 bool isBufferDependent() const { return true; }
178 /// always true since we don't manipulate document contents
179 bool canApply() const { return true; }
181 DocumentClass const & documentClass() const;
183 BufferParams & params() { return bp_; }
187 struct modInfoStruct {
192 /// List of available modules
193 std::list<modInfoStruct> const & getModuleInfo();
194 /// Modules in use in current buffer
195 std::list<modInfoStruct> const getSelectedModules();
197 std::list<modInfoStruct> const getProvidedModules();
199 std::list<modInfoStruct> const
200 makeModuleInfo(LayoutModuleList const & mods);
202 void setLanguage() const;
204 void saveAsDefault() const;
206 bool isFontAvailable(std::string const & font) const;
207 /// does this font provide Old Style figures?
208 bool providesOSF(std::string const & font) const;
209 /// does this font provide true Small Caps?
210 bool providesSC(std::string const & font) const;
211 /// does this font provide size adjustment?
212 bool providesScale(std::string const & font) const;
215 void loadModuleInfo();
218 /// List of names of available modules
219 std::list<modInfoStruct> moduleNames_;
223 class PreambleModule : public UiWidget<Ui::PreambleUi>
228 void update(BufferParams const & params, BufferId id);
229 void apply(BufferParams & params);
232 /// signal that something's changed in the Widget.
236 void closeEvent(QCloseEvent *);
237 void on_preambleTE_textChanged() { changed(); }
240 typedef std::map<BufferId, std::pair<int,int> > Coords;
241 Coords preamble_coords_;
242 BufferId current_id_;
246 } // namespace frontend
249 #endif // GUIDOCUMENT_H