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;
51 class ModuleSelectionManager;
55 typedef void const * BufferId;
58 class UiWidget : public QWidget, public UI
61 UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
65 class GuiDocument : public GuiDialog, public Ui::DocumentUi
69 GuiDocument(GuiView & lv);
71 void paramsToDialog();
72 void updateFontsize(std::string const &, std::string const &);
73 void updateFontlist();
74 void updateDefaultFormat();
75 void updatePagestyle(std::string const &, std::string const &);
79 BufferParams const & params() const { return bp_; }
82 void updateNumbering();
83 void change_adaptor();
84 void setListingsMessage();
85 void saveDefaultClicked();
86 void useDefaultsClicked();
87 void setLSpacing(int);
88 void setMargins(bool);
89 void setCustomPapersize(int);
91 void setCustomMargins(bool);
92 void romanChanged(int);
93 void sansChanged(int);
96 void enableSkip(bool);
97 void portraitChanged();
101 void updateModuleInfo();
102 void modulesChanged();
103 void changeBackgroundColor();
104 void deleteBackgroundColor();
105 void xetexChanged(bool);
107 /// validate listings parameters and return an error message, if any
108 QString validateListingsParameters();
110 UiWidget<Ui::TextLayoutUi> *textLayoutModule;
111 UiWidget<Ui::FontUi> *fontModule;
112 UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
113 UiWidget<Ui::MarginsUi> *marginsModule;
114 UiWidget<Ui::LanguageUi> *langModule;
115 UiWidget<Ui::NumberingUi> *numberingModule;
116 UiWidget<Ui::BiblioUi> *biblioModule;
117 UiWidget<Ui::MathsUi> *mathsModule;
118 UiWidget<Ui::LaTeXUi> *latexModule;
119 UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
120 UiWidget<Ui::ModulesUi> *modulesModule;
121 UiWidget<Ui::OutputUi> *outputModule;
122 PreambleModule *preambleModule;
124 GuiBranches *branchesModule;
126 BulletsModule * bulletsModule;
127 FloatPlacement * floatModule;
129 ModuleSelectionManager * selectionManager;
131 /// Available modules
132 GuiIdListModel * availableModel() { return &modules_av_model_; }
134 GuiIdListModel * selectedModel() { return &modules_sel_model_; }
139 void updateContents();
141 void updateAvailableModules();
143 void updateSelectedModules();
144 /// save as default template
145 void saveDocDefault();
146 /// reset to default params
147 void useClassDefaults();
149 void setLayoutComboByIDString(std::string const & idString);
150 /// available classes
151 GuiIdListModel classes_model_;
152 /// available modules
153 GuiIdListModel modules_av_model_;
155 GuiIdListModel modules_sel_model_;
157 BufferId current_id_;
159 /// return false if validate_listings_params returns error
162 /// font family names for BufferParams::fontsDefaultFamily
163 static char const * const fontfamilies[5];
164 /// GUI names corresponding fontfamilies
165 static char const * fontfamilies_gui[5];
167 bool initialiseParams(std::string const & data);
171 void dispatchParams();
173 void modulesToParams(BufferParams &);
175 bool isBufferDependent() const { return true; }
176 /// always true since we don't manipulate document contents
177 bool canApply() const { return true; }
179 DocumentClass const & documentClass() const;
181 BufferParams & params() { return bp_; }
185 struct modInfoStruct {
190 /// List of available modules
191 std::list<modInfoStruct> const & getModuleInfo();
192 /// Modules in use in current buffer
193 std::list<modInfoStruct> const getSelectedModules();
195 std::list<modInfoStruct> const getProvidedModules();
197 std::list<modInfoStruct> const
198 makeModuleInfo(LayoutModuleList const & mods);
200 void setLanguage() const;
202 void saveAsDefault() const;
204 bool isFontAvailable(std::string const & font) const;
205 /// does this font provide Old Style figures?
206 bool providesOSF(std::string const & font) const;
207 /// does this font provide true Small Caps?
208 bool providesSC(std::string const & font) const;
209 /// does this font provide size adjustment?
210 bool providesScale(std::string const & font) const;
213 void loadModuleInfo();
216 /// List of names of available modules
217 std::list<modInfoStruct> moduleNames_;
221 class PreambleModule : public UiWidget<Ui::PreambleUi>
226 void update(BufferParams const & params, BufferId id);
227 void apply(BufferParams & params);
230 /// signal that something's changed in the Widget.
234 void closeEvent(QCloseEvent *);
235 void on_preambleTE_textChanged() { changed(); }
238 typedef std::map<BufferId, std::pair<int,int> > Coords;
239 Coords preamble_coords_;
240 BufferId current_id_;
244 } // namespace frontend
247 #endif // GUIDOCUMENT_H