]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Dialogs3.C
Move the float dialog to the new scheme.
[lyx.git] / src / frontends / xforms / Dialogs3.C
1 /**
2  * \file xforms/Dialogs3.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 #include <config.h>
12
13 #include "Dialogs.h"
14 #include "Dialog.h"
15
16 #include "Tooltips.h"
17
18 #include "ControlBibitem.h"
19 #include "FormBibitem.h"
20 #include "forms/form_bibitem.h"
21
22 #include "ControlBibtex.h"
23 #include "FormBibtex.h"
24 #include "forms/form_bibtex.h"
25
26 #include "ControlCitation.h"
27 #include "FormCitation.h"
28 #include "forms/form_citation.h"
29
30 #include "ControlError.h"
31 #include "FormError.h"
32 #include "forms/form_error.h"
33
34 #include "ControlERT.h"
35 #include "FormERT.h"
36 #include "forms/form_ert.h"
37
38 #include "ControlExternal.h"
39 #include "FormExternal.h"
40 #include "forms/form_external.h"
41
42 #include "ControlFloat.h"
43 #include "FormFloat.h"
44 #include "forms/form_float.h"
45
46 #include "ControlInclude.h"
47 #include "FormInclude.h"
48 #include "forms/form_include.h"
49
50 #include "ControlIndex.h"
51 #include "ControlLabel.h"
52
53 #include "FormText.h"
54 #include "forms/form_text.h"
55
56 #include "ControlRef.h"
57 #include "FormRef.h"
58 #include "forms/form_ref.h"
59
60 #include "ControlToc.h"
61 #include "FormToc.h"
62 #include "forms/form_toc.h"
63
64 #include "ControlUrl.h"
65 #include "FormUrl.h"
66 #include "forms/form_url.h"
67
68 #include "xformsBC.h"
69 #include "ButtonController.h"
70
71
72 typedef ButtonController<OkCancelPolicy, xformsBC>
73         OkCancelBC;
74
75 typedef ButtonController<OkCancelReadOnlyPolicy, xformsBC>
76         OkCancelReadOnlyBC;
77
78 typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC>
79         OkApplyCancelReadOnlyBC;
80
81 typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC>
82         NoRepeatedApplyReadOnlyBC;
83
84
85 namespace {
86
87 // char const * const dialognames[] = { "bibitem", "bibtex", "citation",
88 //                                   "error", "ert", "external", "float",
89 //                                   "graphics", "include", "index",
90 //                                   "minipage", "ref", "tabular", "toc",
91 //                                   "url", "wrap" };
92 char const * const dialognames[] = { "bibitem", "bibtex", "citation",
93                                      "error", "ert", "external", "float",
94                                      "include", "index", "label", "ref",
95                                      "toc", "url" };
96
97 char const * const * const end_dialognames =
98         dialognames + (sizeof(dialognames) / sizeof(char *));
99
100 struct cmpCStr {
101         cmpCStr(char const * name) : name_(name) {}
102         bool operator()(char const * other) {
103                 return strcmp(other, name_) == 0;
104         }
105 private:
106         char const * name_;
107 };
108
109
110 } // namespace anon
111
112
113 bool Dialogs::isValidName(string const & name) const
114 {
115         return std::find_if(dialognames, end_dialognames,
116                             cmpCStr(name.c_str())) != end_dialognames;
117 }
118
119
120 Dialog * Dialogs::build(string const & name)
121 {
122         if (!isValidName(name))
123                 return 0;
124
125         Dialog * dialog = new Dialog(lyxview_, name);
126
127         if (name == "bibitem") {
128                 dialog->setController(new ControlBibitem(*dialog));
129                 dialog->setView(new FormBibitem(*dialog));
130                 dialog->setButtonController(new OkCancelReadOnlyBC);
131         } else if (name == "bibtex") {
132                 dialog->setController(new ControlBibtex(*dialog));
133                 dialog->setView(new FormBibtex(*dialog));
134                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
135         } else if (name == "citation") {
136                 dialog->setController(new ControlCitation(*dialog));
137                 dialog->setView(new FormCitation(*dialog));
138                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
139         } else if (name == "error") {
140                 dialog->setController(new ControlError(*dialog));
141                 dialog->setView(new FormError(*dialog));
142                 dialog->setButtonController(new OkCancelBC);
143         } else if (name == "ert") {
144                 dialog->setController(new ControlERT(*dialog));
145                 dialog->setView(new FormERT(*dialog));
146                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
147         } else if (name == "external") {
148                 dialog->setController(new ControlExternal(*dialog));
149                 dialog->setView(new FormExternal(*dialog));
150                 dialog->setButtonController(new OkApplyCancelReadOnlyBC);
151         } else if (name == "float") {
152                 dialog->setController(new ControlFloat(*dialog));
153                 dialog->setView(new FormFloat(*dialog));
154                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
155         } else if (name == "include") {
156                 dialog->setController(new ControlInclude(*dialog));
157                 dialog->setView(new FormInclude(*dialog));
158                 dialog->setButtonController(new OkApplyCancelReadOnlyBC);
159         } else if (name == "index") {
160                 dialog->setController(new ControlIndex(*dialog));
161                 dialog->setView(new FormText(*dialog,
162                                              _("Index"), _("Keyword:|#K")));
163                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
164         } else if (name == "label") {
165                 dialog->setController(new ControlLabel(*dialog));
166                 dialog->setView(new FormText(*dialog,
167                                              _("Label"), _("Label:|#L")));
168                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
169         } else if (name == "ref") {
170                 dialog->setController(new ControlRef(*dialog));
171                 dialog->setView(new FormRef(*dialog));
172                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
173         } else if (name == "toc") {
174                 dialog->setController(new ControlToc(*dialog));
175                 dialog->setView(new FormToc(*dialog));
176                 dialog->setButtonController(new OkCancelBC);
177         } else if (name == "url") {
178                 dialog->setController(new ControlUrl(*dialog));
179                 dialog->setView(new FormUrl(*dialog));
180                 dialog->setButtonController(new NoRepeatedApplyReadOnlyBC);
181         }
182
183         return dialog;
184 }
185
186
187 void Dialogs::toggleTooltips()
188 {
189         Tooltips::toggleEnabled();
190 }
191
192
193 /// Are the tooltips on or off?
194 bool Dialogs::tooltipsEnabled()
195 {
196         return Tooltips::enabled();
197 }