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 class GuiDocument : public GuiDialog, public Ui::DocumentUi
107 GuiDocument(GuiView & lv);
109 void updateParams(BufferParams const & params);
110 void apply(BufferParams & params);
112 void updateFontsize(std::string const &, std::string const &);
113 void updatePagestyle(std::string const &, std::string const &);
116 /// validate listings parameters and return an error message, if any
117 docstring validate_listings_params();
120 void updateNumbering();
121 void change_adaptor();
122 void set_listings_msg();
123 void saveDefaultClicked();
124 void useDefaultsClicked();
128 void setLSpacing(int);
129 void setMargins(bool);
130 void setCustomPapersize(int);
131 void setCustomMargins(bool);
132 void romanChanged(int);
133 void sansChanged(int);
136 void enableSkip(bool);
137 void portraitChanged();
139 void updateModuleInfo();
140 void updateEmbeddedFileList();
143 void closeEvent(QCloseEvent * e);
146 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
147 UiWidget<Ui::FontUi> *fontModule;
148 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
149 UiWidget<Ui::MarginsUi> *marginsModule;
150 UiWidget<Ui::LanguageUi> *langModule;
151 UiWidget<Ui::NumberingUi> *numberingModule;
152 UiWidget<Ui::BiblioUi> *biblioModule;
153 UiWidget<Ui::MathsUi> *mathsModule;
154 UiWidget<Ui::LaTeXUi> *latexModule;
155 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
156 UiWidget<Ui::EmbeddedFilesUi> *embeddedFilesModule;
157 PreambleModule *preambleModule;
159 GuiBranches *branchesModule;
161 BulletsModule * bulletsModule;
162 FloatPlacement * floatModule;
164 GuiSelectionManager * selectionManager;
167 std::vector<std::string> lang_;
169 /// Available modules
170 GuiIdListModel * availableModel() { return &available_model_; }
172 GuiIdListModel * selectedModel() { return &selected_model_; }
177 void updateContents();
179 void updateAvailableModules();
181 void updateSelectedModules();
182 /// save as default template
183 void saveDocDefault();
184 /// reset to default params
185 void useClassDefaults();
186 /// available modules
187 GuiIdListModel available_model_;
189 GuiIdListModel selected_model_;
192 /// return false if validate_listings_params returns error
195 /// font family names for BufferParams::fontsDefaultFamily
196 static char const * const fontfamilies[5];
197 /// GUI names corresponding fontfamilies
198 static char const * fontfamilies_gui[5];
200 bool initialiseParams(std::string const & data);
204 void dispatchParams();
206 bool isBufferDependent() const { return true; }
207 /// always true since we don't manipulate document contents
208 bool canApply() const { return true; }
210 TextClass const & textClass() const;
212 BufferParams & params() { return bp_; }
214 BufferParams const & params() const { return bp_; }
218 struct modInfoStruct {
222 /// List of available modules
223 std::vector<modInfoStruct> const & getModuleInfo();
224 /// Modules in use in current buffer
225 std::vector<modInfoStruct> const getSelectedModules();
227 void setLanguage() const;
229 void saveAsDefault() const;
231 bool isFontAvailable(std::string const & font) const;
232 /// does this font provide Old Style figures?
233 bool providesOSF(std::string const & font) const;
234 /// does this font provide true Small Caps?
235 bool providesSC(std::string const & font) const;
236 /// does this font provide size adjustment?
237 bool providesScale(std::string const & font) const;
240 void loadModuleInfo();
243 /// List of names of available modules
244 std::vector<modInfoStruct> moduleNames_;
248 typedef void const * BufferId;
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