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 typedef void const * BufferId;
59 class UiWidget : public QWidget, public UI
62 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
66 class ModuleSelMan : public GuiSelectionManager
70 QListView * availableLV,
71 QListView * selectedLV,
76 GuiIdListModel * availableModel,
77 GuiIdListModel * selectedModel);
80 virtual void updateAddPB();
82 virtual void updateUpPB();
84 virtual void updateDownPB();
86 virtual void updateDelPB();
87 /// returns availableModel as a GuiIdListModel
88 GuiIdListModel * getAvailableModel()
90 return dynamic_cast<GuiIdListModel *>(availableModel);
92 /// returns selectedModel as a GuiIdListModel
93 GuiIdListModel * getSelectedModel()
95 return dynamic_cast<GuiIdListModel *>(selectedModel);
100 class GuiDocument : public GuiDialog, public Ui::DocumentUi
104 GuiDocument(GuiView & lv);
106 void updateParams(BufferParams const & params);
107 void apply(BufferParams & params);
109 void updateFontsize(std::string const &, std::string const &);
110 void updatePagestyle(std::string const &, std::string const &);
113 /// validate listings parameters and return an error message, if any
114 docstring validate_listings_params();
117 void updateNumbering();
118 void change_adaptor();
119 void set_listings_msg();
120 void saveDefaultClicked();
121 void useDefaultsClicked();
125 void setLSpacing(int);
126 void setMargins(bool);
127 void setCustomPapersize(int);
128 void setCustomMargins(bool);
129 void romanChanged(int);
130 void sansChanged(int);
133 void enableSkip(bool);
134 void portraitChanged();
136 void updateModuleInfo();
137 void updateEmbeddedFileList();
140 void closeEvent(QCloseEvent * e);
143 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
144 UiWidget<Ui::FontUi> *fontModule;
145 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
146 UiWidget<Ui::MarginsUi> *marginsModule;
147 UiWidget<Ui::LanguageUi> *langModule;
148 UiWidget<Ui::NumberingUi> *numberingModule;
149 UiWidget<Ui::BiblioUi> *biblioModule;
150 UiWidget<Ui::MathsUi> *mathsModule;
151 UiWidget<Ui::LaTeXUi> *latexModule;
152 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
153 UiWidget<Ui::EmbeddedFilesUi> *embeddedFilesModule;
154 PreambleModule *preambleModule;
156 GuiBranches *branchesModule;
158 BulletsModule * bulletsModule;
159 FloatPlacement * floatModule;
161 GuiSelectionManager * selectionManager;
164 std::vector<std::string> lang_;
166 /// Available modules
167 GuiIdListModel * availableModel() { return &available_model_; }
169 GuiIdListModel * selectedModel() { return &selected_model_; }
174 void updateContents();
176 void updateAvailableModules();
178 void updateSelectedModules();
179 /// save as default template
180 void saveDocDefault();
181 /// reset to default params
182 void useClassDefaults();
183 /// available modules
184 GuiIdListModel available_model_;
186 GuiIdListModel selected_model_;
189 /// return false if validate_listings_params returns error
192 /// font family names for BufferParams::fontsDefaultFamily
193 static char const * const fontfamilies[5];
194 /// GUI names corresponding fontfamilies
195 static char const * fontfamilies_gui[5];
197 bool initialiseParams(std::string const & data);
201 void dispatchParams();
203 bool isBufferDependent() const { return true; }
204 /// always true since we don't manipulate document contents
205 bool canApply() const { return true; }
207 TextClass const & textClass() const;
209 BufferParams & params() { return bp_; }
211 BufferParams const & params() const { return bp_; }
215 struct modInfoStruct {
219 /// List of available modules
220 std::vector<modInfoStruct> const & getModuleInfo();
221 /// Modules in use in current buffer
222 std::vector<modInfoStruct> const getSelectedModules();
224 void setLanguage() const;
226 void saveAsDefault() const;
228 bool isFontAvailable(std::string const & font) const;
229 /// does this font provide Old Style figures?
230 bool providesOSF(std::string const & font) const;
231 /// does this font provide true Small Caps?
232 bool providesSC(std::string const & font) const;
233 /// does this font provide size adjustment?
234 bool providesScale(std::string const & font) const;
237 void loadModuleInfo();
240 /// List of names of available modules
241 std::vector<modInfoStruct> moduleNames_;
245 typedef void const * BufferId;
248 class PreambleModule : public UiWidget<Ui::PreambleUi>
253 void update(BufferParams const & params, BufferId id);
254 void apply(BufferParams & params);
257 /// signal that something's changed in the Widget.
261 void closeEvent(QCloseEvent *);
262 void on_preambleTE_textChanged() { changed(); }
265 typedef std::map<BufferId, std::pair<int,int> > Coords;
266 Coords preamble_coords_;
267 BufferId current_id_;
271 } // namespace frontend
274 #endif // GUIDOCUMENT_H