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.
16 #include "GuiDialog.h"
17 #include "BulletsModule.h"
18 #include "GuiSelectionManager.h"
19 #include "BufferParams.h"
21 #include "support/FileName.h"
22 #include "support/filetools.h"
23 #include "support/types.h"
25 #include "ui_DocumentUi.h"
26 #include "ui_FontUi.h"
27 #include "ui_TextLayoutUi.h"
28 #include "ui_MathsUi.h"
29 #include "ui_LaTeXUi.h"
30 #include "ui_PageLayoutUi.h"
31 #include "ui_LanguageUi.h"
32 #include "ui_BiblioUi.h"
33 #include "ui_NumberingUi.h"
34 #include "ui_MarginsUi.h"
35 #include "ui_PreambleUi.h"
36 #include "ui_PDFSupportUi.h"
54 typedef void const * BufferId;
56 typedef std::map<std::string, support::FileName> ModuleMap;
59 #include <QStringList>
60 #include <QStringListModel>
66 class UiWidget : public QWidget, public UI
69 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
73 class GuiDocument : public GuiDialog, public Ui::DocumentUi
77 GuiDocument(LyXView & lv);
79 void updateParams(BufferParams const & params);
80 void apply(BufferParams & params);
82 void updateFontsize(std::string const &, std::string const &);
83 void updatePagestyle(std::string const &, std::string const &);
86 /// validate listings parameters and return an error message, if any
87 docstring validate_listings_params();
90 void updateNumbering();
91 void change_adaptor();
92 void set_listings_msg();
93 void saveDefaultClicked();
94 void useDefaultsClicked();
98 void setLSpacing(int);
99 void setMargins(bool);
100 void setCustomPapersize(int);
101 void setCustomMargins(bool);
102 void romanChanged(int);
103 void sansChanged(int);
106 void enableSkip(bool);
107 void portraitChanged();
109 void updateModuleInfo();
112 void closeEvent(QCloseEvent * e);
115 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
116 UiWidget<Ui::FontUi> *fontModule;
117 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
118 UiWidget<Ui::MarginsUi> *marginsModule;
119 UiWidget<Ui::LanguageUi> *langModule;
120 UiWidget<Ui::NumberingUi> *numberingModule;
121 UiWidget<Ui::BiblioUi> *biblioModule;
122 UiWidget<Ui::MathsUi> *mathsModule;
123 UiWidget<Ui::LaTeXUi> *latexModule;
124 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
125 PreambleModule *preambleModule;
127 GuiBranches *branchesModule;
129 BulletsModule * bulletsModule;
130 FloatPlacement * floatModule;
132 GuiSelectionManager * selectionManager;
135 std::vector<std::string> lang_;
137 /// Available modules
138 QStringListModel * availableModel() { return &available_model_; }
140 QStringListModel * selectedModel() { return &selected_model_; }
145 void updateContents();
146 /// save as default template
147 void saveDocDefault();
148 /// reset to default params
149 void useClassDefaults();
150 /// available modules
151 QStringListModel available_model_;
153 QStringListModel selected_model_;
156 /// return false if validate_listings_params returns error
159 /// font family names for BufferParams::fontsDefaultFamily
160 static char const * const fontfamilies[5];
161 /// GUI names corresponding fontfamilies
162 static char const * fontfamilies_gui[5];
164 bool initialiseParams(std::string const & data);
168 void dispatchParams();
170 bool isBufferDependent() const { return true; }
171 /// always true since we don't manipulate document contents
172 bool canApply() const { return true; }
174 TextClass const & textClass() const;
176 BufferParams & params() { return bp_; }
178 BufferParams const & params() const { return bp_; }
181 /// List of available modules
182 std::vector<std::string> getModuleNames();
183 /// Modules in use in current buffer
184 std::vector<std::string> const & getSelectedModules();
186 std::string getModuleDescription(std::string const & modName) const;
188 std::vector<std::string> getPackageList(std::string const & modName) const;
190 void setLanguage() const;
192 void saveAsDefault() const;
194 bool isFontAvailable(std::string const & font) const;
195 /// does this font provide Old Style figures?
196 bool providesOSF(std::string const & font) const;
197 /// does this font provide true Small Caps?
198 bool providesSC(std::string const & font) const;
199 /// does this font provide size adjustment?
200 bool providesScale(std::string const & font) const;
203 void loadModuleNames();
206 /// List of names of available modules
207 std::vector<std::string> moduleNames_;
211 typedef void const * BufferId;
214 class PreambleModule : public UiWidget<Ui::PreambleUi>
219 void update(BufferParams const & params, BufferId id);
220 void apply(BufferParams & params);
223 /// signal that something's changed in the Widget.
227 void closeEvent(QCloseEvent *);
228 void on_preambleTE_textChanged() { changed(); }
231 typedef std::map<BufferId, std::pair<int,int> > Coords;
232 Coords preamble_coords_;
233 BufferId current_id_;
237 } // namespace frontend
240 #endif // QDOCUMENT_H