]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/GuiDocument.h
xpdf support for forward view via synctex. This is quite powerful tool.
[lyx.git] / src / frontends / qt4 / GuiDocument.h
1 // -*- C++ -*-
2 /**
3  * \file GuiDocument.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Edwin Leuven
8  * \author Richard Heck (modules)
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef GUIDOCUMENT_H
14 #define GUIDOCUMENT_H
15
16 #include <QDialog>
17
18 #include "BufferParams.h"
19 #include "BulletsModule.h"
20 #include "GuiDialog.h"
21 #include "GuiIdListModel.h"
22
23 #include "ui_BiblioUi.h"
24 #include "ui_ColorUi.h"
25 #include "ui_DocumentUi.h"
26 #include "ui_FontUi.h"
27 #include "ui_LanguageUi.h"
28 #include "ui_LaTeXUi.h"
29 #include "ui_ListingsSettingsUi.h"
30 #include "ui_MarginsUi.h"
31 #include "ui_MasterChildUi.h"
32 #include "ui_MathsUi.h"
33 #include "ui_ModulesUi.h"
34 #include "ui_NumberingUi.h"
35 #include "ui_OutputUi.h"
36 #include "ui_PageLayoutUi.h"
37 #include "ui_PDFSupportUi.h"
38 #include "ui_PreambleUi.h"
39 #include "ui_TextLayoutUi.h"
40
41 namespace lyx {
42
43 class BufferParams;
44 class LayoutModuleList;
45 class TextClass;
46
47 namespace frontend {
48
49 class FloatPlacement;
50 class GuiBranches;
51 class GuiIndices;
52 class ModuleSelectionManager;
53 class PreambleModule;
54
55 ///
56 typedef void const * BufferId;
57
58 template<class UI>
59 class UiWidget : public QWidget, public UI
60 {
61 public:
62         UiWidget(QWidget * parent = 0) : QWidget(parent) { UI::setupUi(this); }
63 };
64
65
66 class GuiDocument : public GuiDialog, public Ui::DocumentUi
67 {
68         Q_OBJECT
69 public:
70         GuiDocument(GuiView & lv);
71
72         void paramsToDialog();
73         void updateFontsize(std::string const &, std::string const &);
74         void updateFontlist();
75         void updateDefaultFormat();
76         void updatePagestyle(std::string const &, std::string const &);
77         bool isChildIncluded(std::string const &);
78
79         void showPreamble();
80         ///
81         BufferParams const & params() const { return bp_; }
82
83 private Q_SLOTS:
84         void updateNumbering();
85         void change_adaptor();
86         void includeonlyClicked(QTreeWidgetItem * item, int);
87         void setListingsMessage();
88         void saveDefaultClicked();
89         void useDefaultsClicked();
90         void setLSpacing(int);
91         void setMargins(bool);
92         void papersizeChanged(int);
93         void setColSep();
94         void setCustomMargins(bool);
95         void fontencChanged(int);
96         void romanChanged(int);
97         void sansChanged(int);
98         void ttChanged(int);
99         void setIndent(int);
100         void enableIndent(bool);
101         void setSkip(int);
102         void enableSkip(bool);
103         void portraitChanged();
104         void browseLayout();
105         void browseMaster();
106         void classChanged();
107         void bibtexChanged(int);
108         void updateModuleInfo();
109         void modulesChanged();
110         void changeBackgroundColor();
111         void deleteBackgroundColor();
112         void changeFontColor();
113         void deleteFontColor();
114         void changeNoteFontColor();
115         void deleteNoteFontColor();
116         void changeBoxBackgroundColor();
117         void deleteBoxBackgroundColor();
118         void xetexChanged(bool);
119         void branchesRename(docstring const &, docstring const &);
120 private:
121         /// validate listings parameters and return an error message, if any
122         QString validateListingsParameters();
123
124         UiWidget<Ui::TextLayoutUi> *textLayoutModule;
125         UiWidget<Ui::MasterChildUi> *masterChildModule;
126         UiWidget<Ui::FontUi> *fontModule;
127         UiWidget<Ui::PageLayoutUi> *pageLayoutModule;
128         UiWidget<Ui::MarginsUi> *marginsModule;
129         UiWidget<Ui::LanguageUi> *langModule;
130         UiWidget<Ui::ColorUi> *colorModule;
131         UiWidget<Ui::NumberingUi> *numberingModule;
132         UiWidget<Ui::BiblioUi> *biblioModule;
133         UiWidget<Ui::MathsUi> *mathsModule;
134         UiWidget<Ui::LaTeXUi> *latexModule;
135         UiWidget<Ui::PDFSupportUi> *pdfSupportModule;
136         UiWidget<Ui::ModulesUi> *modulesModule;
137         UiWidget<Ui::OutputUi> *outputModule;
138         UiWidget<Ui::ListingsSettingsUi> *listingsModule;
139         PreambleModule * preambleModule;
140         
141         GuiBranches * branchesModule;
142         GuiIndices * indicesModule;
143
144         BulletsModule * bulletsModule;
145         FloatPlacement * floatModule;
146
147         ModuleSelectionManager * selectionManager;
148
149         /// Available modules
150         GuiIdListModel * availableModel() { return &modules_av_model_; }
151         /// Selected modules
152         GuiIdListModel * selectedModel() { return &modules_sel_model_; }
153
154         /// Apply changes
155         void applyView();
156         /// update
157         void updateContents();
158         ///
159         void updateAvailableModules();
160         ///
161         void updateSelectedModules();
162         ///
163         void updateIncludeonlys();
164         /// save as default template
165         void saveDocDefault();
166         /// reset to default params
167         void useClassDefaults();
168         ///
169         void setLayoutComboByIDString(std::string const & idString);
170         /// available classes
171         GuiIdListModel classes_model_;
172         /// available modules
173         GuiIdListModel modules_av_model_;
174         /// selected modules
175         GuiIdListModel modules_sel_model_;
176         /// current buffer
177         BufferId current_id_;
178
179         /// return false if validate_listings_params returns error
180         bool isValid();
181
182         /// font family names for BufferParams::fontsDefaultFamily
183         static char const * const fontfamilies[5];
184         /// GUI names corresponding fontfamilies
185         static char const * fontfamilies_gui[5];
186         ///
187         bool initialiseParams(std::string const & data);
188         ///
189         void clearParams();
190         ///
191         void dispatchParams();
192         ///
193         void modulesToParams(BufferParams &);
194         ///
195         bool isBufferDependent() const { return true; }
196         /// always true since we don't manipulate document contents
197         bool canApply() const { return true; }
198         ///
199         DocumentClass const & documentClass() const;
200         ///
201         BufferParams & params() { return bp_; }
202         ///
203         BufferId id() const;
204         ///
205         struct modInfoStruct {
206                 QString name;
207                 std::string id;
208                 QString description;
209         };
210         /// List of available modules
211         std::list<modInfoStruct> const & getModuleInfo();
212         /// Modules in use in current buffer
213         std::list<modInfoStruct> const getSelectedModules();
214         ///
215         std::list<modInfoStruct> const getProvidedModules();
216         ///
217         std::list<modInfoStruct> const 
218                         makeModuleInfo(LayoutModuleList const & mods);
219         ///
220         void setLanguage() const;
221         ///
222         void saveAsDefault() const;
223         ///
224         bool isFontAvailable(std::string const & font) const;
225         /// does this font provide Old Style figures?
226         bool providesOSF(std::string const & font) const;
227         /// does this font provide true Small Caps?
228         bool providesSC(std::string const & font) const;
229         /// does this font provide size adjustment?
230         bool providesScale(std::string const & font) const;
231         ///
232         void executeBranchRenaming() const;
233         ///
234         void setCustomPapersize(bool custom);
235 private:
236         ///
237         void loadModuleInfo();
238         ///
239         void updateUnknownBranches();
240         ///
241         BufferParams bp_;
242         /// List of names of available modules
243         std::list<modInfoStruct> moduleNames_;
244         ///
245         std::map<docstring, docstring> changedBranches_;
246         ///
247         std::list<std::string> includeonlys_;
248 };
249
250
251 class PreambleModule : public UiWidget<Ui::PreambleUi>
252 {
253         Q_OBJECT
254 public:
255         PreambleModule();
256         void update(BufferParams const & params, BufferId id);
257         void apply(BufferParams & params);
258
259 Q_SIGNALS:
260         /// signal that something's changed in the Widget.
261         void changed();
262
263 private:
264         void closeEvent(QCloseEvent *);
265         void on_preambleTE_textChanged() { changed(); }
266
267 private:
268         typedef std::map<BufferId, std::pair<int,int> > Coords;
269         Coords preamble_coords_;
270         BufferId current_id_;
271 };
272
273
274 } // namespace frontend
275 } // namespace lyx
276
277 #endif // GUIDOCUMENT_H