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"
22 #include "GuiSelectionManager.h"
24 #include "support/types.h"
26 #include "ui_DocumentUi.h"
27 #include "ui_EmbeddedFilesUi.h"
28 #include "ui_FontUi.h"
29 #include "ui_TextLayoutUi.h"
30 #include "ui_MathsUi.h"
31 #include "ui_LaTeXUi.h"
32 #include "ui_PageLayoutUi.h"
33 #include "ui_LanguageUi.h"
34 #include "ui_BiblioUi.h"
35 #include "ui_NumberingUi.h"
36 #include "ui_MarginsUi.h"
37 #include "ui_PreambleUi.h"
38 #include "ui_PDFSupportUi.h"
56 QModelIndex getSelectedIndex(QListView * lv);
59 typedef void const * BufferId;
62 class UiWidget : public QWidget, public UI
65 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
69 class ModuleSelMan : public GuiSelectionManager
73 QListView * availableLV,
74 QListView * selectedLV,
79 GuiIdListModel * availableModel,
80 GuiIdListModel * selectedModel);
83 virtual void updateAddPB();
85 virtual void updateUpPB();
87 virtual void updateDownPB();
89 virtual void updateDelPB();
90 /// returns availableModel as a GuiIdListModel
91 GuiIdListModel * getAvailableModel()
93 return dynamic_cast<GuiIdListModel *>(availableModel);
95 /// returns selectedModel as a GuiIdListModel
96 GuiIdListModel * getSelectedModel()
98 return dynamic_cast<GuiIdListModel *>(selectedModel);
103 typedef void const * BufferId;
106 class GuiDocument : public GuiDialog, public Ui::DocumentUi
110 GuiDocument(GuiView & lv);
112 void updateParams(BufferParams const & params);
113 void apply(BufferParams & params);
115 void updateFontsize(std::string const &, std::string const &);
116 void updatePagestyle(std::string const &, std::string const &);
119 /// validate listings parameters and return an error message, if any
120 docstring validate_listings_params();
123 void updateNumbering();
124 void change_adaptor();
125 void set_listings_msg();
126 void saveDefaultClicked();
127 void useDefaultsClicked();
131 void setLSpacing(int);
132 void setMargins(bool);
133 void setCustomPapersize(int);
135 void setCustomMargins(bool);
136 void romanChanged(int);
137 void sansChanged(int);
140 void enableSkip(bool);
141 void portraitChanged();
143 void updateModuleInfo();
144 void updateEmbeddedFileList();
147 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
148 UiWidget<Ui::FontUi> *fontModule;
149 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
150 UiWidget<Ui::MarginsUi> *marginsModule;
151 UiWidget<Ui::LanguageUi> *langModule;
152 UiWidget<Ui::NumberingUi> *numberingModule;
153 UiWidget<Ui::BiblioUi> *biblioModule;
154 UiWidget<Ui::MathsUi> *mathsModule;
155 UiWidget<Ui::LaTeXUi> *latexModule;
156 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
157 UiWidget<Ui::EmbeddedFilesUi> *embeddedFilesModule;
158 PreambleModule *preambleModule;
160 GuiBranches *branchesModule;
162 BulletsModule * bulletsModule;
163 FloatPlacement * floatModule;
165 GuiSelectionManager * selectionManager;
168 std::vector<std::string> lang_;
170 /// Available modules
171 GuiIdListModel * availableModel() { return &available_model_; }
173 GuiIdListModel * selectedModel() { return &selected_model_; }
178 void updateContents();
179 /// force content update
182 void updateAvailableModules();
184 void updateSelectedModules();
185 /// save as default template
186 void saveDocDefault();
187 /// reset to default params
188 void useClassDefaults();
189 /// available modules
190 GuiIdListModel available_model_;
192 GuiIdListModel selected_model_;
194 BufferId current_id_;
197 /// return false if validate_listings_params returns error
200 /// font family names for BufferParams::fontsDefaultFamily
201 static char const * const fontfamilies[5];
202 /// GUI names corresponding fontfamilies
203 static char const * fontfamilies_gui[5];
205 bool initialiseParams(std::string const & data);
209 void dispatchParams();
211 bool isBufferDependent() const { return true; }
212 /// always true since we don't manipulate document contents
213 bool canApply() const { return true; }
215 TextClass const & textClass() const;
217 BufferParams & params() { return bp_; }
219 BufferParams const & params() const { return bp_; }
223 struct modInfoStruct {
227 /// List of available modules
228 std::vector<modInfoStruct> const & getModuleInfo();
229 /// Modules in use in current buffer
230 std::vector<modInfoStruct> const getSelectedModules();
232 void setLanguage() const;
234 void saveAsDefault() const;
236 bool isFontAvailable(std::string const & font) const;
237 /// does this font provide Old Style figures?
238 bool providesOSF(std::string const & font) const;
239 /// does this font provide true Small Caps?
240 bool providesSC(std::string const & font) const;
241 /// does this font provide size adjustment?
242 bool providesScale(std::string const & font) const;
245 void loadModuleInfo();
248 /// List of names of available modules
249 std::vector<modInfoStruct> moduleNames_;
253 class PreambleModule : public UiWidget<Ui::PreambleUi>
258 void update(BufferParams const & params, BufferId id);
259 void apply(BufferParams & params);
262 /// signal that something's changed in the Widget.
266 void closeEvent(QCloseEvent *);
267 void on_preambleTE_textChanged() { changed(); }
270 typedef std::map<BufferId, std::pair<int,int> > Coords;
271 Coords preamble_coords_;
272 BufferId current_id_;
276 } // namespace frontend
279 #endif // GUIDOCUMENT_H