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.
13 // Too hard to make concept checks work with this file
14 #ifdef _GLIBCPP_CONCEPT_CHECKS
15 #undef _GLIBCPP_CONCEPT_CHECKS
23 #include "ControlAboutlyx.h"
24 #include "ControlBibtex.h"
25 #include "ControlBox.h"
26 #include "ControlBranch.h"
27 #include "ControlChanges.h"
28 #include "ControlCharacter.h"
29 #include "ControlCitation.h"
30 #include "ControlCommand.h"
31 #include "ControlDocument.h"
32 #include "ControlErrorList.h"
33 #include "ControlERT.h"
34 #include "ControlExternal.h"
35 #include "ControlFloat.h"
36 #include "ControlGraphics.h"
37 #include "ControlInclude.h"
38 #include "ControlLog.h"
39 #include "ControlMath.h"
40 #include "ControlNote.h"
41 #include "ControlParagraph.h"
42 #include "ControlPreamble.h"
43 #include "ControlPrefs.h"
44 #include "ControlPrint.h"
45 #include "ControlRef.h"
46 #include "ControlSearch.h"
47 #include "ControlSendto.h"
48 #include "ControlShowFile.h"
49 #include "ControlSpellchecker.h"
50 #include "ControlTabular.h"
51 #include "ControlTabularCreate.h"
52 #include "ControlTexinfo.h"
53 #include "ControlToc.h"
54 #include "ControlVSpace.h"
55 #include "ControlWrap.h"
57 #include "GAboutlyx.h"
59 #include "GMathDelim.h"
60 #include "FormBibitem.h"
61 #include "FormBibtex.h"
63 #include "FormBranch.h"
65 #include "GCharacter.h"
66 #include "FormCitation.h"
67 #include "FormDocument.h"
68 #include "GErrorList.h"
70 #include "FormExternal.h"
72 #include "GGraphics.h"
73 #include "FormInclude.h"
75 #include "GMathPanel.h"
76 #include "FormMathsBitmap.h"
77 #include "GMathsMatrix.h"
78 #include "FormMathsSpace.h"
79 #include "FormMathsStyle.h"
81 #include "GParagraph.h"
82 #include "FormPreamble.h"
83 #include "FormPreferences.h"
87 #include "FormSendto.h"
88 #include "FormTabular.h"
90 #include "GShowFile.h"
91 #include "GSpellchecker.h"
92 #include "GTableCreate.h"
98 #ifdef HAVE_LIBAIKSAURUS
99 #include "ControlThesaurus.h"
100 #include "FormThesaurus.h"
103 #include "xformsBC.h"
104 #include "ButtonController.h"
106 #include "arrows.xbm"
115 #include "ams_misc.xbm"
116 #include "ams_arrows.xbm"
117 #include "ams_rel.xbm"
118 #include "ams_nrel.xbm"
119 #include "ams_ops.xbm"
121 #include <boost/assert.hpp>
126 using namespace lyx::frontend;
130 FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
131 char const * const * data, int size)
133 char const * const * const end = data + size;
134 return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
138 char const * const dialognames[] = {
139 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
140 "citation", "document", "errorlist" , "ert", "external", "file",
141 "findreplace", "float", "graphics", "include", "index", "label", "log",
142 "mathpanel", "mathaccents", "matharrows", "mathoperators", "mathrelations",
143 "mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
144 "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations",
145 "mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
146 "note", "paragraph", "preamble", "prefs", "print", "ref", "sendto",
147 "spellchecker", "tabular", "tabularcreate", "texinfo",
149 #ifdef HAVE_LIBAIKSAURUS
153 "toc", "url", "vspace", "wrap" };
155 char const * const * const end_dialognames =
156 dialognames + (sizeof(dialognames) / sizeof(char *));
159 cmpCStr(char const * name) : name_(name) {}
160 bool operator()(char const * other) {
161 return strcmp(other, name_) == 0;
170 bool Dialogs::isValidName(string const & name) const
172 return std::find_if(dialognames, end_dialognames,
173 cmpCStr(name.c_str())) != end_dialognames;
177 Dialogs::DialogPtr Dialogs::build(string const & name)
179 BOOST_ASSERT(isValidName(name));
181 DialogPtr dialog(new Dialog(lyxview_, name));
182 dialog->bc().view(new xformsBC(dialog->bc()));
184 if (name == "aboutlyx") {
185 dialog->bc().view(new GBC(dialog->bc()));
186 dialog->setController(new ControlAboutlyx(*dialog));
187 dialog->setView(new GAboutlyx(*dialog));
188 dialog->bc().bp(new OkCancelPolicy);
189 } else if (name == "bibitem") {
190 dialog->setController(new ControlCommand(*dialog, name));
191 dialog->setView(new FormBibitem(*dialog));
192 dialog->bc().bp(new OkCancelReadOnlyPolicy);
193 } else if (name == "bibtex") {
194 dialog->setController(new ControlBibtex(*dialog));
195 dialog->setView(new FormBibtex(*dialog));
196 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
197 } else if (name == "box") {
198 dialog->bc().view(new GBC(dialog->bc()));
199 dialog->setController(new ControlBox(*dialog));
200 dialog->setView(new GBox(*dialog));
201 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
202 } else if (name == "changes") {
203 dialog->bc().view(new GBC(dialog->bc()));
204 dialog->setController(new ControlChanges(*dialog));
205 dialog->setView(new GChanges(*dialog));
206 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
207 } else if (name == "character") {
208 dialog->bc().view(new GBC(dialog->bc()));
209 dialog->setController(new ControlCharacter(*dialog));
210 dialog->setView(new GCharacter(*dialog));
211 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
212 } else if (name == "citation") {
213 dialog->setController(new ControlCitation(*dialog));
214 dialog->setView(new FormCitation(*dialog));
215 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
216 } else if (name == "document") {
217 dialog->setController(new ControlDocument(*dialog));
218 dialog->setView(new FormDocument(*dialog));
219 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
220 } else if (name == "errorlist") {
221 dialog->bc().view(new GBC(dialog->bc()));
222 dialog->setController(new ControlErrorList(*dialog));
223 dialog->setView(new GErrorList(*dialog));
224 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
225 } else if (name == "ert") {
226 dialog->bc().view(new GBC(dialog->bc()));
227 dialog->setController(new ControlERT(*dialog));
228 dialog->setView(new GERT(*dialog));
229 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
230 } else if (name == "external") {
231 dialog->setController(new ControlExternal(*dialog));
232 dialog->setView(new FormExternal(*dialog));
233 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
234 } else if (name == "file") {
235 dialog->bc().view(new GBC(dialog->bc()));
236 dialog->setController(new ControlShowFile(*dialog));
237 dialog->setView(new GShowFile(*dialog));
238 dialog->bc().bp(new OkCancelPolicy);
239 } else if (name == "findreplace") {
240 dialog->bc().view(new GBC(dialog->bc()));
241 dialog->setController(new ControlSearch(*dialog));
242 dialog->setView(new GSearch(*dialog));
243 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
244 } else if (name == "float") {
245 dialog->bc().view(new GBC(dialog->bc()));
246 dialog->setController(new ControlFloat(*dialog));
247 dialog->setView(new GFloat(*dialog));
248 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
249 } else if (name == "graphics") {
250 dialog->bc().view(new GBC(dialog->bc()));
251 dialog->setController(new ControlGraphics(*dialog));
252 dialog->setView(new GGraphics(*dialog));
253 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
254 } else if (name == "include") {
255 dialog->setController(new ControlInclude(*dialog));
256 dialog->setView(new FormInclude(*dialog));
257 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
258 } else if (name == "index") {
259 dialog->bc().view(new GBC(dialog->bc()));
260 dialog->setController(new ControlCommand(*dialog, name));
261 dialog->setView(new GText(*dialog,
262 _("Index"), _("Keyword:|#K")));
263 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
264 } else if (name == "label") {
265 dialog->bc().view(new GBC(dialog->bc()));
266 dialog->setController(new ControlCommand(*dialog, name));
267 dialog->setView(new GText(*dialog,
268 _("Label"), _("Label:|#L")));
269 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
270 } else if (name == "log") {
271 dialog->bc().view(new GBC(dialog->bc()));
272 dialog->setController(new ControlLog(*dialog));
273 dialog->setView(new GLog(*dialog));
274 dialog->bc().bp(new OkCancelPolicy);
276 } else if (name == "mathpanel") {
277 dialog->bc().view(new GBC(dialog->bc()));
278 dialog->setController(new ControlMath(*dialog));
279 dialog->setView(new GMathPanel(*dialog));
280 dialog->bc().bp(new IgnorantPolicy);
282 } else if (name == "mathaccents") {
283 FormMathsBitmap * bitmap =
284 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
285 latex_deco, nr_latex_deco);
287 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
289 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
291 dialog->setController(new ControlMath(*dialog));
292 dialog->setView(bitmap);
293 dialog->bc().bp(new IgnorantPolicy);
295 } else if (name == "matharrows") {
296 FormMathsBitmap * bitmap =
297 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
299 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
301 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
303 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
305 dialog->setController(new ControlMath(*dialog));
306 dialog->setView(bitmap);
307 dialog->bc().bp(new IgnorantPolicy);
309 } else if (name == "mathoperators") {
310 FormMathsBitmap * bitmap =
311 createFormBitmap(*dialog, _("Binary Ops"),
312 latex_bop, nr_latex_bop);
314 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
316 dialog->setController(new ControlMath(*dialog));
317 dialog->setView(bitmap);
318 dialog->bc().bp(new IgnorantPolicy);
320 } else if (name == "mathrelations") {
321 FormMathsBitmap * bitmap =
322 createFormBitmap(*dialog, _("Binary Relations"),
323 latex_brel, nr_latex_brel);
325 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
327 dialog->setController(new ControlMath(*dialog));
328 dialog->setView(bitmap);
329 dialog->bc().bp(new IgnorantPolicy);
331 } else if (name == "mathgreek") {
332 FormMathsBitmap * bitmap =
333 createFormBitmap(*dialog, _("Greek"),
334 latex_greek, nr_latex_greek);
336 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
338 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
340 dialog->setController(new ControlMath(*dialog));
341 dialog->setView(bitmap);
342 dialog->bc().bp(new IgnorantPolicy);
344 } else if (name == "mathmisc") {
345 FormMathsBitmap * bitmap =
346 createFormBitmap(*dialog, _("Misc"),
347 latex_misc, nr_latex_misc);
349 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
351 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
353 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
355 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
357 dialog->setController(new ControlMath(*dialog));
358 dialog->setView(bitmap);
359 dialog->bc().bp(new IgnorantPolicy);
361 } else if (name == "mathdots") {
362 FormMathsBitmap * bitmap =
363 createFormBitmap(*dialog, _("Dots"),
364 latex_dots, nr_latex_dots);
366 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
368 dialog->setController(new ControlMath(*dialog));
369 dialog->setView(bitmap);
370 dialog->bc().bp(new IgnorantPolicy);
372 } else if (name == "mathbigoperators") {
373 FormMathsBitmap * bitmap =
374 createFormBitmap(*dialog, _("Big Operators"),
375 latex_varsz, nr_latex_varsz);
377 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
379 dialog->setController(new ControlMath(*dialog));
380 dialog->setView(bitmap);
381 dialog->bc().bp(new IgnorantPolicy);
383 } else if (name == "mathamsmisc") {
384 FormMathsBitmap * bitmap =
385 createFormBitmap(*dialog, _("AMS Misc"),
386 latex_ams_misc, nr_latex_ams_misc);
388 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
390 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
392 dialog->setController(new ControlMath(*dialog));
393 dialog->setView(bitmap);
394 dialog->bc().bp(new IgnorantPolicy);
396 } else if (name == "mathamsarrows") {
397 FormMathsBitmap * bitmap =
398 createFormBitmap(*dialog, _("AMS Arrows"),
399 latex_ams_arrows, nr_latex_ams_arrows);
401 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
403 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
405 dialog->setController(new ControlMath(*dialog));
406 dialog->setView(bitmap);
407 dialog->bc().bp(new IgnorantPolicy);
409 } else if (name == "mathamsrelations") {
410 FormMathsBitmap * bitmap =
411 createFormBitmap(*dialog, _("AMS Relations"),
412 latex_ams_rel, nr_latex_ams_rel);
414 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
416 dialog->setController(new ControlMath(*dialog));
417 dialog->setView(bitmap);
418 dialog->bc().bp(new IgnorantPolicy);
420 } else if (name == "mathamsnegatedrelations") {
421 FormMathsBitmap * bitmap =
422 createFormBitmap(*dialog, _("AMS Negated Rel"),
423 latex_ams_nrel, nr_latex_ams_nrel);
425 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
427 dialog->setController(new ControlMath(*dialog));
428 dialog->setView(bitmap);
429 dialog->bc().bp(new IgnorantPolicy);
431 } else if (name == "mathamsoperators") {
432 FormMathsBitmap * bitmap =
433 createFormBitmap(*dialog, _("AMS Operators"),
434 latex_ams_ops, nr_latex_ams_ops);
436 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
438 dialog->setController(new ControlMath(*dialog));
439 dialog->setView(bitmap);
440 dialog->bc().bp(new IgnorantPolicy);
442 } else if (name == "mathdelimiter") {
443 dialog->bc().view(new GBC(dialog->bc()));
444 dialog->setController(new ControlMath(*dialog));
445 dialog->setView(new GMathDelim(*dialog));
446 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
447 } else if (name == "mathmatrix") {
448 dialog->bc().view(new GBC(dialog->bc()));
449 dialog->setController(new ControlMath(*dialog));
450 dialog->setView(new GMathsMatrix(*dialog));
451 dialog->bc().bp(new OkCancelReadOnlyPolicy);
452 } else if (name == "mathspace") {
453 dialog->setController(new ControlMath(*dialog));
454 dialog->setView(new FormMathsSpace(*dialog));
455 dialog->bc().bp(new IgnorantPolicy);
456 } else if (name == "mathstyle") {
457 dialog->setController(new ControlMath(*dialog));
458 dialog->setView(new FormMathsStyle(*dialog));
459 dialog->bc().bp(new IgnorantPolicy);
460 } else if (name == "note") {
461 dialog->bc().view(new GBC(dialog->bc()));
462 dialog->setController(new ControlNote(*dialog));
463 dialog->setView(new GNote(*dialog));
464 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
465 } else if (name == "branch") {
466 dialog->setController(new ControlBranch(*dialog));
467 dialog->setView(new FormBranch(*dialog));
468 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
469 } else if (name == "paragraph") {
470 dialog->bc().view(new GBC(dialog->bc()));
471 dialog->setController(new ControlParagraph(*dialog));
472 dialog->setView(new GParagraph(*dialog));
473 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
474 } else if (name == "preamble") {
475 dialog->setController(new ControlPreamble(*dialog));
476 dialog->setView(new FormPreamble(*dialog));
477 dialog->bc().bp(new OkApplyCancelPolicy);
478 } else if (name == "prefs") {
479 dialog->setController(new ControlPrefs(*dialog));
480 dialog->setView(new FormPreferences(*dialog));
481 dialog->bc().bp(new PreferencesPolicy);
482 } else if (name == "print") {
483 dialog->bc().view(new GBC(dialog->bc()));
484 dialog->setController(new ControlPrint(*dialog));
485 dialog->setView(new GPrint(*dialog));
486 dialog->bc().bp(new OkCancelPolicy);
487 } else if (name == "ref") {
488 dialog->setController(new ControlRef(*dialog));
489 dialog->setView(new FormRef(*dialog));
490 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
491 } else if (name == "sendto") {
492 dialog->setController(new ControlSendto(*dialog));
493 dialog->setView(new FormSendto(*dialog));
494 dialog->bc().bp(new OkApplyCancelPolicy);
495 } else if (name == "spellchecker") {
496 dialog->bc().view(new GBC(dialog->bc()));
497 dialog->setController(new ControlSpellchecker(*dialog));
498 dialog->setView(new GSpellchecker(*dialog));
499 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
500 } else if (name == "tabular") {
501 dialog->setController(new ControlTabular(*dialog));
502 dialog->setView(new FormTabular(*dialog));
503 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
504 } else if (name == "tabularcreate") {
505 dialog->bc().view(new GBC(dialog->bc()));
506 dialog->setController(new ControlTabularCreate(*dialog));
507 dialog->setView(new GTableCreate(*dialog));
508 dialog->bc().bp(new IgnorantPolicy);
509 } else if (name == "texinfo") {
510 dialog->bc().view(new GBC(dialog->bc()));
511 dialog->setController(new ControlTexinfo(*dialog));
512 dialog->setView(new GTexinfo(*dialog));
513 dialog->bc().bp(new OkCancelPolicy);
514 #ifdef HAVE_LIBAIKSAURUS
515 } else if (name == "thesaurus") {
516 dialog->setController(new ControlThesaurus(*dialog));
517 dialog->setView(new FormThesaurus(*dialog));
518 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
520 } else if (name == "toc") {
521 dialog->bc().view(new GBC(dialog->bc()));
522 dialog->setController(new ControlToc(*dialog));
523 dialog->setView(new GToc(*dialog));
524 dialog->bc().bp(new OkCancelPolicy);
525 } else if (name == "url") {
526 dialog->bc().view(new GBC(dialog->bc()));
527 dialog->setController(new ControlCommand(*dialog, name));
528 dialog->setView(new GUrl(*dialog));
529 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
530 } else if (name == "vspace") {
531 dialog->bc().view(new GBC(dialog->bc()));
532 dialog->setController(new ControlVSpace(*dialog));
533 dialog->setView(new GVSpace(*dialog));
534 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
535 } else if (name == "wrap") {
536 dialog->setController(new ControlWrap(*dialog));
537 dialog->setView(new FormWrap(*dialog));
538 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
545 void Dialogs::toggleTooltips()
547 Tooltips::toggleEnabled();
551 /// Are the tooltips on or off?
552 bool Dialogs::tooltipsEnabled()
554 return Tooltips::enabled();