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.
6 * \author Angus Leeming
8 * Full author contact details are available in file CREDITS
18 #include "ControlBibitem.h"
19 #include "FormBibitem.h"
20 #include "forms/form_bibitem.h"
22 #include "ControlBibtex.h"
23 #include "FormBibtex.h"
24 #include "forms/form_bibtex.h"
26 #include "ControlCitation.h"
27 #include "FormCitation.h"
28 #include "forms/form_citation.h"
30 #include "ControlError.h"
31 #include "FormError.h"
32 #include "forms/form_error.h"
34 #include "ControlERT.h"
36 #include "forms/form_ert.h"
38 #include "ControlExternal.h"
39 #include "FormExternal.h"
40 #include "forms/form_external.h"
42 #include "ControlFloat.h"
43 #include "FormFloat.h"
44 #include "forms/form_float.h"
46 #include "ControlInclude.h"
47 #include "FormInclude.h"
48 #include "forms/form_include.h"
50 #include "ControlIndex.h"
51 #include "ControlLabel.h"
54 #include "forms/form_text.h"
56 #include "ControlRef.h"
58 #include "forms/form_ref.h"
60 #include "ControlToc.h"
62 #include "forms/form_toc.h"
64 #include "ControlUrl.h"
66 #include "forms/form_url.h"
69 #include "ButtonController.h"
72 typedef ButtonController<OkCancelPolicy, xformsBC>
75 typedef ButtonController<OkCancelReadOnlyPolicy, xformsBC>
78 typedef ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC>
79 OkApplyCancelReadOnlyBC;
81 typedef ButtonController<NoRepeatedApplyReadOnlyPolicy, xformsBC>
82 NoRepeatedApplyReadOnlyBC;
87 // char const * const dialognames[] = { "bibitem", "bibtex", "citation",
88 // "error", "ert", "external", "float",
89 // "graphics", "include", "index",
90 // "minipage", "ref", "tabular", "toc",
92 char const * const dialognames[] = { "bibitem", "bibtex", "citation",
93 "error", "ert", "external", "float",
94 "include", "index", "label", "ref",
97 char const * const * const end_dialognames =
98 dialognames + (sizeof(dialognames) / sizeof(char *));
101 cmpCStr(char const * name) : name_(name) {}
102 bool operator()(char const * other) {
103 return strcmp(other, name_) == 0;
113 bool Dialogs::isValidName(string const & name) const
115 return std::find_if(dialognames, end_dialognames,
116 cmpCStr(name.c_str())) != end_dialognames;
120 Dialog * Dialogs::build(string const & name)
122 if (!isValidName(name))
125 Dialog * dialog = new Dialog(lyxview_, name);
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);
187 void Dialogs::toggleTooltips()
189 Tooltips::toggleEnabled();
193 /// Are the tooltips on or off?
194 bool Dialogs::tooltipsEnabled()
196 return Tooltips::enabled();