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 "FormCitation.h"
70 #include "FormDocument.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 "FormThesaurus.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));
185 dialog->bc().view(new xformsBC(dialog->bc()));
187 if (name == "aboutlyx") {
188 dialog->bc().view(new GBC(dialog->bc()));
189 dialog->setController(new ControlAboutlyx(*dialog));
190 dialog->setView(new GAboutlyx(*dialog));
191 dialog->bc().bp(new OkCancelPolicy);
192 } else if (name == "bibitem") {
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->setController(new ControlBibtex(*dialog));
198 dialog->setView(new FormBibtex(*dialog));
199 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
200 } else if (name == "box") {
201 dialog->bc().view(new GBC(dialog->bc()));
202 dialog->setController(new ControlBox(*dialog));
203 dialog->setView(new GBox(*dialog));
204 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
205 } else if (name == "changes") {
206 dialog->bc().view(new GBC(dialog->bc()));
207 dialog->setController(new ControlChanges(*dialog));
208 dialog->setView(new GChanges(*dialog));
209 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
210 } else if (name == "character") {
211 dialog->bc().view(new GBC(dialog->bc()));
212 dialog->setController(new ControlCharacter(*dialog));
213 dialog->setView(new GCharacter(*dialog));
214 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
215 } else if (name == "citation") {
216 dialog->setController(new ControlCitation(*dialog));
217 dialog->setView(new FormCitation(*dialog));
218 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
219 } else if (name == "document") {
220 dialog->setController(new ControlDocument(*dialog));
221 dialog->setView(new FormDocument(*dialog));
222 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
223 } else if (name == "errorlist") {
224 dialog->bc().view(new GBC(dialog->bc()));
225 dialog->setController(new ControlErrorList(*dialog));
226 dialog->setView(new GErrorList(*dialog));
227 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
228 } else if (name == "ert") {
229 dialog->bc().view(new GBC(dialog->bc()));
230 dialog->setController(new ControlERT(*dialog));
231 dialog->setView(new GERT(*dialog));
232 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
233 } else if (name == "external") {
234 dialog->setController(new ControlExternal(*dialog));
235 dialog->setView(new FormExternal(*dialog));
236 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
237 } else if (name == "file") {
238 dialog->bc().view(new GBC(dialog->bc()));
239 dialog->setController(new ControlShowFile(*dialog));
240 dialog->setView(new GShowFile(*dialog));
241 dialog->bc().bp(new OkCancelPolicy);
242 } else if (name == "findreplace") {
243 dialog->bc().view(new GBC(dialog->bc()));
244 dialog->setController(new ControlSearch(*dialog));
245 dialog->setView(new GSearch(*dialog));
246 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
247 } else if (name == "float") {
248 dialog->bc().view(new GBC(dialog->bc()));
249 dialog->setController(new ControlFloat(*dialog));
250 dialog->setView(new GFloat(*dialog));
251 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
252 } else if (name == "graphics") {
253 dialog->bc().view(new GBC(dialog->bc()));
254 dialog->setController(new ControlGraphics(*dialog));
255 dialog->setView(new GGraphics(*dialog));
256 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
257 } else if (name == "include") {
258 dialog->bc().view(new GBC(dialog->bc()));
259 dialog->setController(new ControlInclude(*dialog));
260 dialog->setView(new GInclude(*dialog));
261 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
262 } else if (name == "index") {
263 dialog->bc().view(new GBC(dialog->bc()));
264 dialog->setController(new ControlCommand(*dialog, name));
265 dialog->setView(new GText(*dialog,
266 _("Index"), _("Keyword:|#K")));
267 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
268 } else if (name == "label") {
269 dialog->bc().view(new GBC(dialog->bc()));
270 dialog->setController(new ControlCommand(*dialog, name));
271 dialog->setView(new GText(*dialog,
272 _("Label"), _("Label:|#L")));
273 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
274 } else if (name == "log") {
275 dialog->bc().view(new GBC(dialog->bc()));
276 dialog->setController(new ControlLog(*dialog));
277 dialog->setView(new GLog(*dialog));
278 dialog->bc().bp(new OkCancelPolicy);
280 } else if (name == "mathpanel") {
281 dialog->bc().view(new GBC(dialog->bc()));
282 dialog->setController(new ControlMath(*dialog));
283 dialog->setView(new GMathPanel(*dialog));
284 dialog->bc().bp(new IgnorantPolicy);
286 } else if (name == "mathaccents") {
287 FormMathsBitmap * bitmap =
288 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
289 latex_deco, nr_latex_deco);
291 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
293 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
295 dialog->setController(new ControlMath(*dialog));
296 dialog->setView(bitmap);
297 dialog->bc().bp(new IgnorantPolicy);
299 } else if (name == "matharrows") {
300 FormMathsBitmap * bitmap =
301 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
303 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
305 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
307 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
309 dialog->setController(new ControlMath(*dialog));
310 dialog->setView(bitmap);
311 dialog->bc().bp(new IgnorantPolicy);
313 } else if (name == "mathoperators") {
314 FormMathsBitmap * bitmap =
315 createFormBitmap(*dialog, _("Binary Ops"),
316 latex_bop, nr_latex_bop);
318 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
320 dialog->setController(new ControlMath(*dialog));
321 dialog->setView(bitmap);
322 dialog->bc().bp(new IgnorantPolicy);
324 } else if (name == "mathrelations") {
325 FormMathsBitmap * bitmap =
326 createFormBitmap(*dialog, _("Binary Relations"),
327 latex_brel, nr_latex_brel);
329 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
331 dialog->setController(new ControlMath(*dialog));
332 dialog->setView(bitmap);
333 dialog->bc().bp(new IgnorantPolicy);
335 } else if (name == "mathgreek") {
336 FormMathsBitmap * bitmap =
337 createFormBitmap(*dialog, _("Greek"),
338 latex_greek, nr_latex_greek);
340 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
342 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
344 dialog->setController(new ControlMath(*dialog));
345 dialog->setView(bitmap);
346 dialog->bc().bp(new IgnorantPolicy);
348 } else if (name == "mathmisc") {
349 FormMathsBitmap * bitmap =
350 createFormBitmap(*dialog, _("Misc"),
351 latex_misc, nr_latex_misc);
353 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
355 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
357 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
359 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
361 dialog->setController(new ControlMath(*dialog));
362 dialog->setView(bitmap);
363 dialog->bc().bp(new IgnorantPolicy);
365 } else if (name == "mathdots") {
366 FormMathsBitmap * bitmap =
367 createFormBitmap(*dialog, _("Dots"),
368 latex_dots, nr_latex_dots);
370 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
372 dialog->setController(new ControlMath(*dialog));
373 dialog->setView(bitmap);
374 dialog->bc().bp(new IgnorantPolicy);
376 } else if (name == "mathbigoperators") {
377 FormMathsBitmap * bitmap =
378 createFormBitmap(*dialog, _("Big Operators"),
379 latex_varsz, nr_latex_varsz);
381 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
383 dialog->setController(new ControlMath(*dialog));
384 dialog->setView(bitmap);
385 dialog->bc().bp(new IgnorantPolicy);
387 } else if (name == "mathamsmisc") {
388 FormMathsBitmap * bitmap =
389 createFormBitmap(*dialog, _("AMS Misc"),
390 latex_ams_misc, nr_latex_ams_misc);
392 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
394 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
396 dialog->setController(new ControlMath(*dialog));
397 dialog->setView(bitmap);
398 dialog->bc().bp(new IgnorantPolicy);
400 } else if (name == "mathamsarrows") {
401 FormMathsBitmap * bitmap =
402 createFormBitmap(*dialog, _("AMS Arrows"),
403 latex_ams_arrows, nr_latex_ams_arrows);
405 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
407 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
409 dialog->setController(new ControlMath(*dialog));
410 dialog->setView(bitmap);
411 dialog->bc().bp(new IgnorantPolicy);
413 } else if (name == "mathamsrelations") {
414 FormMathsBitmap * bitmap =
415 createFormBitmap(*dialog, _("AMS Relations"),
416 latex_ams_rel, nr_latex_ams_rel);
418 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
420 dialog->setController(new ControlMath(*dialog));
421 dialog->setView(bitmap);
422 dialog->bc().bp(new IgnorantPolicy);
424 } else if (name == "mathamsnegatedrelations") {
425 FormMathsBitmap * bitmap =
426 createFormBitmap(*dialog, _("AMS Negated Rel"),
427 latex_ams_nrel, nr_latex_ams_nrel);
429 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
431 dialog->setController(new ControlMath(*dialog));
432 dialog->setView(bitmap);
433 dialog->bc().bp(new IgnorantPolicy);
435 } else if (name == "mathamsoperators") {
436 FormMathsBitmap * bitmap =
437 createFormBitmap(*dialog, _("AMS Operators"),
438 latex_ams_ops, nr_latex_ams_ops);
440 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
442 dialog->setController(new ControlMath(*dialog));
443 dialog->setView(bitmap);
444 dialog->bc().bp(new IgnorantPolicy);
446 } else if (name == "mathdelimiter") {
447 dialog->bc().view(new GBC(dialog->bc()));
448 dialog->setController(new ControlMath(*dialog));
449 dialog->setView(new GMathDelim(*dialog));
450 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
451 } else if (name == "mathmatrix") {
452 dialog->bc().view(new GBC(dialog->bc()));
453 dialog->setController(new ControlMath(*dialog));
454 dialog->setView(new GMathsMatrix(*dialog));
455 dialog->bc().bp(new OkCancelReadOnlyPolicy);
456 } else if (name == "mathspace") {
457 dialog->setController(new ControlMath(*dialog));
458 dialog->setView(new FormMathsSpace(*dialog));
459 dialog->bc().bp(new IgnorantPolicy);
460 } else if (name == "mathstyle") {
461 dialog->setController(new ControlMath(*dialog));
462 dialog->setView(new FormMathsStyle(*dialog));
463 dialog->bc().bp(new IgnorantPolicy);
464 } else if (name == "note") {
465 dialog->bc().view(new GBC(dialog->bc()));
466 dialog->setController(new ControlNote(*dialog));
467 dialog->setView(new GNote(*dialog));
468 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
469 } else if (name == "branch") {
470 dialog->setController(new ControlBranch(*dialog));
471 dialog->setView(new FormBranch(*dialog));
472 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
473 } else if (name == "paragraph") {
474 dialog->bc().view(new GBC(dialog->bc()));
475 dialog->setController(new ControlParagraph(*dialog));
476 dialog->setView(new GParagraph(*dialog));
477 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
478 } else if (name == "preamble") {
479 dialog->setController(new ControlPreamble(*dialog));
480 dialog->setView(new FormPreamble(*dialog));
481 dialog->bc().bp(new OkApplyCancelPolicy);
482 } else if (name == "prefs") {
483 dialog->setController(new ControlPrefs(*dialog));
484 dialog->setView(new FormPreferences(*dialog));
485 dialog->bc().bp(new PreferencesPolicy);
486 } else if (name == "print") {
487 dialog->bc().view(new GBC(dialog->bc()));
488 dialog->setController(new ControlPrint(*dialog));
489 dialog->setView(new GPrint(*dialog));
490 dialog->bc().bp(new OkCancelPolicy);
491 } else if (name == "ref") {
492 dialog->setController(new ControlRef(*dialog));
493 dialog->setView(new FormRef(*dialog));
494 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
495 } else if (name == "sendto") {
496 dialog->bc().view(new GBC(dialog->bc()));
497 dialog->setController(new ControlSendto(*dialog));
498 dialog->setView(new GSendto(*dialog));
499 dialog->bc().bp(new OkApplyCancelPolicy);
500 } else if (name == "spellchecker") {
501 dialog->bc().view(new GBC(dialog->bc()));
502 dialog->setController(new ControlSpellchecker(*dialog));
503 dialog->setView(new GSpellchecker(*dialog));
504 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
505 } else if (name == "tabular") {
506 dialog->setController(new ControlTabular(*dialog));
507 dialog->setView(new FormTabular(*dialog));
508 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
509 } else if (name == "tabularcreate") {
510 dialog->bc().view(new GBC(dialog->bc()));
511 dialog->setController(new ControlTabularCreate(*dialog));
512 dialog->setView(new GTableCreate(*dialog));
513 dialog->bc().bp(new IgnorantPolicy);
514 } else if (name == "texinfo") {
515 dialog->bc().view(new GBC(dialog->bc()));
516 dialog->setController(new ControlTexinfo(*dialog));
517 dialog->setView(new GTexinfo(*dialog));
518 dialog->bc().bp(new OkCancelPolicy);
519 #ifdef HAVE_LIBAIKSAURUS
520 } else if (name == "thesaurus") {
521 dialog->setController(new ControlThesaurus(*dialog));
522 dialog->setView(new FormThesaurus(*dialog));
523 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
525 } else if (name == "toc") {
526 dialog->bc().view(new GBC(dialog->bc()));
527 dialog->setController(new ControlToc(*dialog));
528 dialog->setView(new GToc(*dialog));
529 dialog->bc().bp(new OkCancelPolicy);
530 } else if (name == "url") {
531 dialog->bc().view(new GBC(dialog->bc()));
532 dialog->setController(new ControlCommand(*dialog, name));
533 dialog->setView(new GUrl(*dialog));
534 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
535 } else if (name == "vspace") {
536 dialog->bc().view(new GBC(dialog->bc()));
537 dialog->setController(new ControlVSpace(*dialog));
538 dialog->setView(new GVSpace(*dialog));
539 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
540 } else if (name == "wrap") {
541 dialog->setController(new ControlWrap(*dialog));
542 dialog->setView(new FormWrap(*dialog));
543 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
550 void Dialogs::toggleTooltips()
552 Tooltips::toggleEnabled();
556 /// Are the tooltips on or off?
557 bool Dialogs::tooltipsEnabled()
559 return Tooltips::enabled();