2 * \file xforms/Dialogs.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 "ControlAboutlyx.h"
19 #include "ControlBibtex.h"
20 #include "ControlChanges.h"
21 #include "ControlCharacter.h"
22 #include "ControlCitation.h"
23 #include "ControlCommand.h"
24 #include "ControlError.h"
25 #include "ControlErrorList.h"
26 #include "ControlERT.h"
27 #include "ControlExternal.h"
28 #include "ControlFloat.h"
29 #include "ControlGraphics.h"
30 #include "ControlInclude.h"
31 #include "ControlLog.h"
32 #include "ControlMath2.h"
33 #include "ControlMinipage.h"
34 #include "ControlParagraph.h"
35 #include "ControlRef.h"
36 #include "ControlShowFile.h"
37 #include "ControlTabular.h"
38 #include "ControlTabularCreate.h"
39 #include "ControlToc.h"
40 #include "ControlVCLog.h"
41 #include "ControlWrap.h"
43 #include "FormAboutlyx.h"
44 #include "FormBibitem.h"
45 #include "FormBibtex.h"
46 #include "FormChanges.h"
47 #include "FormCharacter.h"
48 #include "FormCitation.h"
49 #include "FormError.h"
50 #include "FormErrorList.h"
52 #include "FormExternal.h"
53 #include "FormFloat.h"
54 #include "FormGraphics.h"
55 #include "FormInclude.h"
57 #include "FormMathsBitmap.h"
58 #include "FormMathsDelim.h"
59 #include "FormMathsMatrix.h"
60 #include "FormMathsSpace.h"
61 #include "FormMathsStyle.h"
62 #include "FormMinipage.h"
63 #include "FormParagraph.h"
65 #include "FormTabular.h"
66 #include "FormShowFile.h"
67 #include "FormTabularCreate.h"
71 #include "FormVCLog.h"
74 #ifdef HAVE_LIBAIKSAURUS
75 #include "ControlThesaurus.h"
76 #include "FormThesaurus.h"
80 #include "ButtonController.h"
91 #include "ams_misc.xbm"
92 #include "ams_arrows.xbm"
93 #include "ams_rel.xbm"
94 #include "ams_nrel.xbm"
95 #include "ams_ops.xbm"
102 FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
103 char const * const * data, int size)
105 char const * const * const end = data + size;
106 return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
110 char const * const dialognames[] = { "about", "bibitem", "bibtex", "changes",
111 "character", "citation", "error", "errorlist" , "ert", "external", "file",
112 "float", "graphics", "include", "index", "label", "log",
113 "mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek",
114 "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
115 "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators",
116 "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
117 "minipage", "paragraph", "ref", "tabular", "tabularcreate",
119 #ifdef HAVE_LIBAIKSAURUS
123 "toc", "url", "vclog", "wrap" };
125 char const * const * const end_dialognames =
126 dialognames + (sizeof(dialognames) / sizeof(char *));
129 cmpCStr(char const * name) : name_(name) {}
130 bool operator()(char const * other) {
131 return strcmp(other, name_) == 0;
140 bool Dialogs::isValidName(string const & name) const
142 return std::find_if(dialognames, end_dialognames,
143 cmpCStr(name.c_str())) != end_dialognames;
147 Dialog * Dialogs::build(string const & name)
149 if (!isValidName(name))
152 Dialog * dialog = new Dialog(lyxview_, name);
153 dialog->bc().view(new xformsBC(dialog->bc()));
155 if (name == "about") {
156 dialog->setController(new ControlAboutlyx(*dialog));
157 dialog->setView(new FormAboutlyx(*dialog));
158 dialog->bc().bp(new OkCancelPolicy);
159 } else if (name == "bibitem") {
160 dialog->setController(new ControlCommand(*dialog, name));
161 dialog->setView(new FormBibitem(*dialog));
162 dialog->bc().bp(new OkCancelReadOnlyPolicy);
163 } else if (name == "bibtex") {
164 dialog->setController(new ControlBibtex(*dialog));
165 dialog->setView(new FormBibtex(*dialog));
166 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
167 } else if (name == "character") {
168 dialog->setController(new ControlCharacter(*dialog));
169 dialog->setView(new FormCharacter(*dialog));
170 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
171 } else if (name == "changes") {
172 dialog->setController(new ControlChanges(*dialog));
173 dialog->setView(new FormChanges(*dialog));
174 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
175 } else if (name == "citation") {
176 dialog->setController(new ControlCitation(*dialog));
177 dialog->setView(new FormCitation(*dialog));
178 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
179 } else if (name == "error") {
180 dialog->setController(new ControlError(*dialog));
181 dialog->setView(new FormError(*dialog));
182 dialog->bc().bp(new OkCancelPolicy);
183 } else if (name == "errorlist") {
184 dialog->setController(new ControlErrorList(*dialog));
185 dialog->setView(new FormErrorList(*dialog));
186 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
187 } else if (name == "ert") {
188 dialog->setController(new ControlERT(*dialog));
189 dialog->setView(new FormERT(*dialog));
190 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
191 } else if (name == "external") {
192 dialog->setController(new ControlExternal(*dialog));
193 dialog->setView(new FormExternal(*dialog));
194 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
195 } else if (name == "file") {
196 dialog->setController(new ControlShowFile(*dialog));
197 dialog->setView(new FormShowFile(*dialog));
198 dialog->bc().bp(new OkCancelPolicy);
199 } else if (name == "float") {
200 dialog->setController(new ControlFloat(*dialog));
201 dialog->setView(new FormFloat(*dialog));
202 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
203 } else if (name == "graphics") {
204 dialog->setController(new ControlGraphics(*dialog));
205 dialog->setView(new FormGraphics(*dialog));
206 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
207 } else if (name == "include") {
208 dialog->setController(new ControlInclude(*dialog));
209 dialog->setView(new FormInclude(*dialog));
210 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
211 } else if (name == "index") {
212 dialog->setController(new ControlCommand(*dialog, name));
213 dialog->setView(new FormText(*dialog,
214 _("Index"), _("Keyword:|#K")));
215 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
216 } else if (name == "label") {
217 dialog->setController(new ControlCommand(*dialog, name));
218 dialog->setView(new FormText(*dialog,
219 _("Label"), _("Label:|#L")));
220 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
221 } else if (name == "log") {
222 dialog->setController(new ControlLog(*dialog));
223 dialog->setView(new FormLog(*dialog));
224 dialog->bc().bp(new OkCancelPolicy);
226 } else if (name == "mathaccents") {
227 FormMathsBitmap * bitmap =
228 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
229 latex_deco, nr_latex_deco);
231 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
233 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
235 dialog->setController(new ControlMath2(*dialog));
236 dialog->setView(bitmap);
237 dialog->bc().bp(new IgnorantPolicy);
239 } else if (name == "matharrows") {
240 FormMathsBitmap * bitmap =
241 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
243 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
245 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
247 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
249 dialog->setController(new ControlMath2(*dialog));
250 dialog->setView(bitmap);
251 dialog->bc().bp(new IgnorantPolicy);
253 } else if (name == "mathoperators") {
254 FormMathsBitmap * bitmap =
255 createFormBitmap(*dialog, _("Binary Ops"),
256 latex_bop, nr_latex_bop);
258 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
260 dialog->setController(new ControlMath2(*dialog));
261 dialog->setView(bitmap);
262 dialog->bc().bp(new IgnorantPolicy);
264 } else if (name == "mathrelations") {
265 FormMathsBitmap * bitmap =
266 createFormBitmap(*dialog, _("Binary Relations"),
267 latex_brel, nr_latex_brel);
269 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
271 dialog->setController(new ControlMath2(*dialog));
272 dialog->setView(bitmap);
273 dialog->bc().bp(new IgnorantPolicy);
275 } else if (name == "mathgreek") {
276 FormMathsBitmap * bitmap =
277 createFormBitmap(*dialog, _("Greek"),
278 latex_greek, nr_latex_greek);
280 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
282 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
284 dialog->setController(new ControlMath2(*dialog));
285 dialog->setView(bitmap);
286 dialog->bc().bp(new IgnorantPolicy);
288 } else if (name == "mathmisc") {
289 FormMathsBitmap * bitmap =
290 createFormBitmap(*dialog, _("Misc"),
291 latex_misc, nr_latex_misc);
293 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
295 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
297 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
299 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
301 dialog->setController(new ControlMath2(*dialog));
302 dialog->setView(bitmap);
303 dialog->bc().bp(new IgnorantPolicy);
305 } else if (name == "mathdots") {
306 FormMathsBitmap * bitmap =
307 createFormBitmap(*dialog, _("Dots"),
308 latex_dots, nr_latex_dots);
310 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
312 dialog->setController(new ControlMath2(*dialog));
313 dialog->setView(bitmap);
314 dialog->bc().bp(new IgnorantPolicy);
316 } else if (name == "mathbigoperators") {
317 FormMathsBitmap * bitmap =
318 createFormBitmap(*dialog, _("Big Operators"),
319 latex_varsz, nr_latex_varsz);
321 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
323 dialog->setController(new ControlMath2(*dialog));
324 dialog->setView(bitmap);
325 dialog->bc().bp(new IgnorantPolicy);
327 } else if (name == "mathamsmisc") {
328 FormMathsBitmap * bitmap =
329 createFormBitmap(*dialog, _("AMS Misc"),
330 latex_ams_misc, nr_latex_ams_misc);
332 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
334 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
336 dialog->setController(new ControlMath2(*dialog));
337 dialog->setView(bitmap);
338 dialog->bc().bp(new IgnorantPolicy);
340 } else if (name == "mathamsarrows") {
341 FormMathsBitmap * bitmap =
342 createFormBitmap(*dialog, _("AMS Arrows"),
343 latex_ams_arrows, nr_latex_ams_arrows);
345 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
347 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
349 dialog->setController(new ControlMath2(*dialog));
350 dialog->setView(bitmap);
351 dialog->bc().bp(new IgnorantPolicy);
353 } else if (name == "mathamsrelations") {
354 FormMathsBitmap * bitmap =
355 createFormBitmap(*dialog, _("AMS Relations"),
356 latex_ams_rel, nr_latex_ams_rel);
358 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
360 dialog->setController(new ControlMath2(*dialog));
361 dialog->setView(bitmap);
362 dialog->bc().bp(new IgnorantPolicy);
364 } else if (name == "mathamsnegatedrelations") {
365 FormMathsBitmap * bitmap =
366 createFormBitmap(*dialog, _("AMS Negated Rel"),
367 latex_ams_nrel, nr_latex_ams_nrel);
369 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
371 dialog->setController(new ControlMath2(*dialog));
372 dialog->setView(bitmap);
373 dialog->bc().bp(new IgnorantPolicy);
375 } else if (name == "mathamsoperators") {
376 FormMathsBitmap * bitmap =
377 createFormBitmap(*dialog, _("AMS Operators"),
378 latex_ams_ops, nr_latex_ams_ops);
380 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
382 dialog->setController(new ControlMath2(*dialog));
383 dialog->setView(bitmap);
384 dialog->bc().bp(new IgnorantPolicy);
386 } else if (name == "mathdelimiter") {
387 dialog->setController(new ControlMath2(*dialog));
388 dialog->setView(new FormMathsDelim(*dialog));
389 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
390 } else if (name == "mathmatrix") {
391 dialog->setController(new ControlMath2(*dialog));
392 dialog->setView(new FormMathsMatrix(*dialog));
393 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
394 } else if (name == "mathspace") {
395 dialog->setController(new ControlMath2(*dialog));
396 dialog->setView(new FormMathsSpace(*dialog));
397 dialog->bc().bp(new IgnorantPolicy);
398 } else if (name == "mathstyle") {
399 dialog->setController(new ControlMath2(*dialog));
400 dialog->setView(new FormMathsStyle(*dialog));
401 dialog->bc().bp(new IgnorantPolicy);
402 } else if (name == "minipage") {
403 dialog->setController(new ControlMinipage(*dialog));
404 dialog->setView(new FormMinipage(*dialog));
405 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
406 } else if (name == "paragraph") {
407 dialog->setController(new ControlParagraph(*dialog));
408 dialog->setView(new FormParagraph(*dialog));
409 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
410 } else if (name == "ref") {
411 dialog->setController(new ControlRef(*dialog));
412 dialog->setView(new FormRef(*dialog));
413 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
414 } else if (name == "tabular") {
415 dialog->setController(new ControlTabular(*dialog));
416 dialog->setView(new FormTabular(*dialog));
417 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
418 } else if (name == "tabularcreate") {
419 dialog->setController(new ControlTabularCreate(*dialog));
420 dialog->setView(new FormTabularCreate(*dialog));
421 dialog->bc().bp(new IgnorantPolicy);
422 #ifdef HAVE_LIBAIKSAURUS
423 } else if (name == "thesaurus") {
424 dialog->setController(new ControlThesaurus(*dialog));
425 dialog->setView(new FormThesaurus(*dialog));
426 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
428 } else if (name == "toc") {
429 dialog->setController(new ControlToc(*dialog));
430 dialog->setView(new FormToc(*dialog));
431 dialog->bc().bp(new OkCancelPolicy);
432 } else if (name == "url") {
433 dialog->setController(new ControlCommand(*dialog, name));
434 dialog->setView(new FormUrl(*dialog));
435 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
436 } else if (name == "vclog") {
437 dialog->setController(new ControlVCLog(*dialog));
438 dialog->setView(new FormVCLog(*dialog));
439 dialog->bc().bp(new OkCancelPolicy);
440 } else if (name == "wrap") {
441 dialog->setController(new ControlWrap(*dialog));
442 dialog->setView(new FormWrap(*dialog));
443 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
450 void Dialogs::toggleTooltips()
452 Tooltips::toggleEnabled();
456 /// Are the tooltips on or off?
457 bool Dialogs::tooltipsEnabled()
459 return Tooltips::enabled();