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 _GLIBCXX_CONCEPT_CHECKS
15 #undef _GLIBCXX_CONCEPT_CHECKS
17 #ifdef _GLIBCPP_CONCEPT_CHECKS
18 #undef _GLIBCPP_CONCEPT_CHECKS
26 #include "ControlAboutlyx.h"
27 #include "ControlBibtex.h"
28 #include "ControlBox.h"
29 #include "ControlBranch.h"
30 #include "ControlChanges.h"
31 #include "ControlCharacter.h"
32 #include "ControlCitation.h"
33 #include "ControlCommand.h"
34 #include "ControlDocument.h"
35 #include "ControlErrorList.h"
36 #include "ControlERT.h"
37 #include "ControlExternal.h"
38 #include "ControlFloat.h"
39 #include "ControlGraphics.h"
40 #include "ControlInclude.h"
41 #include "ControlLog.h"
42 #include "ControlMath.h"
43 #include "ControlNote.h"
44 #include "ControlParagraph.h"
45 #include "ControlPreamble.h"
46 #include "ControlPrefs.h"
47 #include "ControlPrint.h"
48 #include "ControlRef.h"
49 #include "ControlSearch.h"
50 #include "ControlSendto.h"
51 #include "ControlShowFile.h"
52 #include "ControlSpellchecker.h"
53 #include "ControlTabular.h"
54 #include "ControlTabularCreate.h"
55 #include "ControlTexinfo.h"
56 #include "ControlToc.h"
57 #include "ControlVSpace.h"
58 #include "ControlWrap.h"
60 #include "GAboutlyx.h"
62 #include "GMathDelim.h"
63 #include "FormBibitem.h"
64 #include "FormBibtex.h"
66 #include "FormBranch.h"
68 #include "GCharacter.h"
69 #include "GCitation.h"
70 #include "GDocument.h"
71 #include "GErrorList.h"
73 #include "FormExternal.h"
75 #include "GGraphics.h"
78 #include "GMathPanel.h"
79 #include "FormMathsBitmap.h"
80 #include "GMathsMatrix.h"
81 #include "FormMathsSpace.h"
82 #include "FormMathsStyle.h"
84 #include "GParagraph.h"
85 #include "FormPreamble.h"
86 #include "FormPreferences.h"
91 #include "FormTabular.h"
93 #include "GShowFile.h"
94 #include "GSpellchecker.h"
95 #include "GTableCreate.h"
101 #ifdef HAVE_LIBAIKSAURUS
102 #include "ControlThesaurus.h"
103 #include "GThesaurus.h"
106 #include "xformsBC.h"
107 #include "ButtonController.h"
109 #include "arrows.xbm"
118 #include "ams_misc.xbm"
119 #include "ams_arrows.xbm"
120 #include "ams_rel.xbm"
121 #include "ams_nrel.xbm"
122 #include "ams_ops.xbm"
124 #include <boost/assert.hpp>
129 using namespace lyx::frontend;
133 FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
134 char const * const * data, int size)
136 char const * const * const end = data + size;
137 return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
141 char const * const dialognames[] = {
142 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
143 "citation", "document", "errorlist" , "ert", "external", "file",
144 "findreplace", "float", "graphics", "include", "index", "label", "log",
145 "mathpanel", "mathaccents", "matharrows", "mathoperators", "mathrelations",
146 "mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
147 "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations",
148 "mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
149 "note", "paragraph", "preamble", "prefs", "print", "ref", "sendto",
150 "spellchecker", "tabular", "tabularcreate", "texinfo",
152 #ifdef HAVE_LIBAIKSAURUS
156 "toc", "url", "vspace", "wrap" };
158 char const * const * const end_dialognames =
159 dialognames + (sizeof(dialognames) / sizeof(char *));
162 cmpCStr(char const * name) : name_(name) {}
163 bool operator()(char const * other) {
164 return strcmp(other, name_) == 0;
173 bool Dialogs::isValidName(string const & name) const
175 return std::find_if(dialognames, end_dialognames,
176 cmpCStr(name.c_str())) != end_dialognames;
180 Dialogs::DialogPtr Dialogs::build(string const & name)
182 BOOST_ASSERT(isValidName(name));
184 DialogPtr dialog(new Dialog(lyxview_, name));
186 if (name == "aboutlyx") {
187 dialog->bc().view(new GBC(dialog->bc()));
188 dialog->setController(new ControlAboutlyx(*dialog));
189 dialog->setView(new GAboutlyx(*dialog));
190 dialog->bc().bp(new OkCancelPolicy);
191 } else if (name == "bibitem") {
192 dialog->bc().view(new xformsBC(dialog->bc()));
193 dialog->setController(new ControlCommand(*dialog, name));
194 dialog->setView(new FormBibitem(*dialog));
195 dialog->bc().bp(new OkCancelReadOnlyPolicy);
196 } else if (name == "bibtex") {
197 dialog->bc().view(new xformsBC(dialog->bc()));
198 dialog->setController(new ControlBibtex(*dialog));
199 dialog->setView(new FormBibtex(*dialog));
200 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
201 } else if (name == "box") {
202 dialog->bc().view(new GBC(dialog->bc()));
203 dialog->setController(new ControlBox(*dialog));
204 dialog->setView(new GBox(*dialog));
205 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
206 } else if (name == "changes") {
207 dialog->bc().view(new GBC(dialog->bc()));
208 dialog->setController(new ControlChanges(*dialog));
209 dialog->setView(new GChanges(*dialog));
210 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
211 } else if (name == "character") {
212 dialog->bc().view(new GBC(dialog->bc()));
213 dialog->setController(new ControlCharacter(*dialog));
214 dialog->setView(new GCharacter(*dialog));
215 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
216 } else if (name == "citation") {
217 dialog->bc().view(new GBC(dialog->bc()));
218 dialog->setController(new ControlCitation(*dialog));
219 dialog->setView(new GCitation(*dialog));
220 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
221 } else if (name == "document") {
222 dialog->bc().view(new GBC(dialog->bc()));
223 dialog->setController(new ControlDocument(*dialog));
224 dialog->setView(new GDocument(*dialog));
225 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
226 } else if (name == "errorlist") {
227 dialog->bc().view(new GBC(dialog->bc()));
228 dialog->setController(new ControlErrorList(*dialog));
229 dialog->setView(new GErrorList(*dialog));
230 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
231 } else if (name == "ert") {
232 dialog->bc().view(new GBC(dialog->bc()));
233 dialog->setController(new ControlERT(*dialog));
234 dialog->setView(new GERT(*dialog));
235 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
236 } else if (name == "external") {
237 dialog->bc().view(new xformsBC(dialog->bc()));
238 dialog->setController(new ControlExternal(*dialog));
239 dialog->setView(new FormExternal(*dialog));
240 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
241 } else if (name == "file") {
242 dialog->bc().view(new GBC(dialog->bc()));
243 dialog->setController(new ControlShowFile(*dialog));
244 dialog->setView(new GShowFile(*dialog));
245 dialog->bc().bp(new OkCancelPolicy);
246 } else if (name == "findreplace") {
247 dialog->bc().view(new GBC(dialog->bc()));
248 dialog->setController(new ControlSearch(*dialog));
249 dialog->setView(new GSearch(*dialog));
250 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
251 } else if (name == "float") {
252 dialog->bc().view(new GBC(dialog->bc()));
253 dialog->setController(new ControlFloat(*dialog));
254 dialog->setView(new GFloat(*dialog));
255 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
256 } else if (name == "graphics") {
257 dialog->bc().view(new GBC(dialog->bc()));
258 dialog->setController(new ControlGraphics(*dialog));
259 dialog->setView(new GGraphics(*dialog));
260 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
261 } else if (name == "include") {
262 dialog->bc().view(new GBC(dialog->bc()));
263 dialog->setController(new ControlInclude(*dialog));
264 dialog->setView(new GInclude(*dialog));
265 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
266 } else if (name == "index") {
267 dialog->bc().view(new GBC(dialog->bc()));
268 dialog->setController(new ControlCommand(*dialog, name));
269 dialog->setView(new GText(*dialog,
270 _("Index Entry"), _("Keyword:|#K")));
271 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
272 } else if (name == "label") {
273 dialog->bc().view(new GBC(dialog->bc()));
274 dialog->setController(new ControlCommand(*dialog, name));
275 dialog->setView(new GText(*dialog,
276 _("Label"), _("Label:|#L")));
277 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
278 } else if (name == "log") {
279 dialog->bc().view(new GBC(dialog->bc()));
280 dialog->setController(new ControlLog(*dialog));
281 dialog->setView(new GLog(*dialog));
282 dialog->bc().bp(new OkCancelPolicy);
284 } else if (name == "mathpanel") {
285 dialog->bc().view(new GBC(dialog->bc()));
286 dialog->setController(new ControlMath(*dialog));
287 dialog->setView(new GMathPanel(*dialog));
288 dialog->bc().bp(new IgnorantPolicy);
290 } else if (name == "mathaccents") {
291 FormMathsBitmap * bitmap =
292 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
293 latex_deco, nr_latex_deco);
295 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
297 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
299 dialog->bc().view(new xformsBC(dialog->bc()));
300 dialog->setController(new ControlMath(*dialog));
301 dialog->setView(bitmap);
302 dialog->bc().bp(new IgnorantPolicy);
304 } else if (name == "matharrows") {
305 FormMathsBitmap * bitmap =
306 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
308 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
310 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
312 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
314 dialog->bc().view(new xformsBC(dialog->bc()));
315 dialog->setController(new ControlMath(*dialog));
316 dialog->setView(bitmap);
317 dialog->bc().bp(new IgnorantPolicy);
319 } else if (name == "mathoperators") {
320 FormMathsBitmap * bitmap =
321 createFormBitmap(*dialog, _("Binary Ops"),
322 latex_bop, nr_latex_bop);
324 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
326 dialog->bc().view(new xformsBC(dialog->bc()));
327 dialog->setController(new ControlMath(*dialog));
328 dialog->setView(bitmap);
329 dialog->bc().bp(new IgnorantPolicy);
331 } else if (name == "mathrelations") {
332 FormMathsBitmap * bitmap =
333 createFormBitmap(*dialog, _("Binary Relations"),
334 latex_brel, nr_latex_brel);
336 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
338 dialog->bc().view(new xformsBC(dialog->bc()));
339 dialog->setController(new ControlMath(*dialog));
340 dialog->setView(bitmap);
341 dialog->bc().bp(new IgnorantPolicy);
343 } else if (name == "mathgreek") {
344 FormMathsBitmap * bitmap =
345 createFormBitmap(*dialog, _("Greek"),
346 latex_greek, nr_latex_greek);
348 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
350 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
352 dialog->bc().view(new xformsBC(dialog->bc()));
353 dialog->setController(new ControlMath(*dialog));
354 dialog->setView(bitmap);
355 dialog->bc().bp(new IgnorantPolicy);
357 } else if (name == "mathmisc") {
358 FormMathsBitmap * bitmap =
359 createFormBitmap(*dialog, _("Misc"),
360 latex_misc, nr_latex_misc);
362 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
364 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
366 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
368 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
370 dialog->bc().view(new xformsBC(dialog->bc()));
371 dialog->setController(new ControlMath(*dialog));
372 dialog->setView(bitmap);
373 dialog->bc().bp(new IgnorantPolicy);
375 } else if (name == "mathdots") {
376 FormMathsBitmap * bitmap =
377 createFormBitmap(*dialog, _("Dots"),
378 latex_dots, nr_latex_dots);
380 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
382 dialog->bc().view(new xformsBC(dialog->bc()));
383 dialog->setController(new ControlMath(*dialog));
384 dialog->setView(bitmap);
385 dialog->bc().bp(new IgnorantPolicy);
387 } else if (name == "mathbigoperators") {
388 FormMathsBitmap * bitmap =
389 createFormBitmap(*dialog, _("Big Operators"),
390 latex_varsz, nr_latex_varsz);
392 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
394 dialog->bc().view(new xformsBC(dialog->bc()));
395 dialog->setController(new ControlMath(*dialog));
396 dialog->setView(bitmap);
397 dialog->bc().bp(new IgnorantPolicy);
399 } else if (name == "mathamsmisc") {
400 FormMathsBitmap * bitmap =
401 createFormBitmap(*dialog, _("AMS Misc"),
402 latex_ams_misc, nr_latex_ams_misc);
404 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
406 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
408 dialog->bc().view(new xformsBC(dialog->bc()));
409 dialog->setController(new ControlMath(*dialog));
410 dialog->setView(bitmap);
411 dialog->bc().bp(new IgnorantPolicy);
413 } else if (name == "mathamsarrows") {
414 FormMathsBitmap * bitmap =
415 createFormBitmap(*dialog, _("AMS Arrows"),
416 latex_ams_arrows, nr_latex_ams_arrows);
418 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
420 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
422 dialog->bc().view(new xformsBC(dialog->bc()));
423 dialog->setController(new ControlMath(*dialog));
424 dialog->setView(bitmap);
425 dialog->bc().bp(new IgnorantPolicy);
427 } else if (name == "mathamsrelations") {
428 FormMathsBitmap * bitmap =
429 createFormBitmap(*dialog, _("AMS Relations"),
430 latex_ams_rel, nr_latex_ams_rel);
432 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
434 dialog->bc().view(new xformsBC(dialog->bc()));
435 dialog->setController(new ControlMath(*dialog));
436 dialog->setView(bitmap);
437 dialog->bc().bp(new IgnorantPolicy);
439 } else if (name == "mathamsnegatedrelations") {
440 FormMathsBitmap * bitmap =
441 createFormBitmap(*dialog, _("AMS Negated Rel"),
442 latex_ams_nrel, nr_latex_ams_nrel);
444 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
446 dialog->bc().view(new xformsBC(dialog->bc()));
447 dialog->setController(new ControlMath(*dialog));
448 dialog->setView(bitmap);
449 dialog->bc().bp(new IgnorantPolicy);
451 } else if (name == "mathamsoperators") {
452 FormMathsBitmap * bitmap =
453 createFormBitmap(*dialog, _("AMS Operators"),
454 latex_ams_ops, nr_latex_ams_ops);
456 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
458 dialog->bc().view(new xformsBC(dialog->bc()));
459 dialog->setController(new ControlMath(*dialog));
460 dialog->setView(bitmap);
461 dialog->bc().bp(new IgnorantPolicy);
463 } else if (name == "mathdelimiter") {
464 dialog->bc().view(new GBC(dialog->bc()));
465 dialog->setController(new ControlMath(*dialog));
466 dialog->setView(new GMathDelim(*dialog));
467 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
468 } else if (name == "mathmatrix") {
469 dialog->bc().view(new GBC(dialog->bc()));
470 dialog->setController(new ControlMath(*dialog));
471 dialog->setView(new GMathsMatrix(*dialog));
472 dialog->bc().bp(new OkCancelReadOnlyPolicy);
473 } else if (name == "mathspace") {
474 dialog->bc().view(new xformsBC(dialog->bc()));
475 dialog->setController(new ControlMath(*dialog));
476 dialog->setView(new FormMathsSpace(*dialog));
477 dialog->bc().bp(new IgnorantPolicy);
478 } else if (name == "mathstyle") {
479 dialog->bc().view(new xformsBC(dialog->bc()));
480 dialog->setController(new ControlMath(*dialog));
481 dialog->setView(new FormMathsStyle(*dialog));
482 dialog->bc().bp(new IgnorantPolicy);
483 } else if (name == "note") {
484 dialog->bc().view(new GBC(dialog->bc()));
485 dialog->setController(new ControlNote(*dialog));
486 dialog->setView(new GNote(*dialog));
487 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
488 } else if (name == "branch") {
489 dialog->bc().view(new xformsBC(dialog->bc()));
490 dialog->setController(new ControlBranch(*dialog));
491 dialog->setView(new FormBranch(*dialog));
492 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
493 } else if (name == "paragraph") {
494 dialog->bc().view(new GBC(dialog->bc()));
495 dialog->setController(new ControlParagraph(*dialog));
496 dialog->setView(new GParagraph(*dialog));
497 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
498 } else if (name == "preamble") {
499 dialog->bc().view(new xformsBC(dialog->bc()));
500 dialog->setController(new ControlPreamble(*dialog));
501 dialog->setView(new FormPreamble(*dialog));
502 dialog->bc().bp(new OkApplyCancelPolicy);
503 } else if (name == "prefs") {
504 dialog->bc().view(new xformsBC(dialog->bc()));
505 dialog->setController(new ControlPrefs(*dialog));
506 dialog->setView(new FormPreferences(*dialog));
507 dialog->bc().bp(new PreferencesPolicy);
508 } else if (name == "print") {
509 dialog->bc().view(new GBC(dialog->bc()));
510 dialog->setController(new ControlPrint(*dialog));
511 dialog->setView(new GPrint(*dialog));
512 dialog->bc().bp(new OkCancelPolicy);
513 } else if (name == "ref") {
514 dialog->bc().view(new GBC(dialog->bc()));
515 dialog->setController(new ControlRef(*dialog));
516 dialog->setView(new GRef(*dialog));
517 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
518 } else if (name == "sendto") {
519 dialog->bc().view(new GBC(dialog->bc()));
520 dialog->setController(new ControlSendto(*dialog));
521 dialog->setView(new GSendto(*dialog));
522 dialog->bc().bp(new OkApplyCancelPolicy);
523 } else if (name == "spellchecker") {
524 dialog->bc().view(new GBC(dialog->bc()));
525 dialog->setController(new ControlSpellchecker(*dialog));
526 dialog->setView(new GSpellchecker(*dialog));
527 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
528 } else if (name == "tabular") {
529 dialog->bc().view(new xformsBC(dialog->bc()));
530 dialog->setController(new ControlTabular(*dialog));
531 dialog->setView(new FormTabular(*dialog));
532 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
533 } else if (name == "tabularcreate") {
534 dialog->bc().view(new GBC(dialog->bc()));
535 dialog->setController(new ControlTabularCreate(*dialog));
536 dialog->setView(new GTableCreate(*dialog));
537 dialog->bc().bp(new IgnorantPolicy);
538 } else if (name == "texinfo") {
539 dialog->bc().view(new GBC(dialog->bc()));
540 dialog->setController(new ControlTexinfo(*dialog));
541 dialog->setView(new GTexinfo(*dialog));
542 dialog->bc().bp(new OkCancelPolicy);
543 #ifdef HAVE_LIBAIKSAURUS
544 } else if (name == "thesaurus") {
545 dialog->bc().view(new GBC(dialog->bc()));
546 dialog->setController(new ControlThesaurus(*dialog));
547 dialog->setView(new GThesaurus(*dialog));
548 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
550 } else if (name == "toc") {
551 dialog->bc().view(new GBC(dialog->bc()));
552 dialog->setController(new ControlToc(*dialog));
553 dialog->setView(new GToc(*dialog));
554 dialog->bc().bp(new OkCancelPolicy);
555 } else if (name == "url") {
556 dialog->bc().view(new GBC(dialog->bc()));
557 dialog->setController(new ControlCommand(*dialog, name));
558 dialog->setView(new GUrl(*dialog));
559 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
560 } else if (name == "vspace") {
561 dialog->bc().view(new GBC(dialog->bc()));
562 dialog->setController(new ControlVSpace(*dialog));
563 dialog->setView(new GVSpace(*dialog));
564 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
565 } else if (name == "wrap") {
566 dialog->bc().view(new xformsBC(dialog->bc()));
567 dialog->setController(new ControlWrap(*dialog));
568 dialog->setView(new FormWrap(*dialog));
569 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
576 void Dialogs::toggleTooltips()
578 Tooltips::toggleEnabled();
582 /// Are the tooltips on or off?
583 bool Dialogs::tooltipsEnabled()
585 return Tooltips::enabled();