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 "ControlBox.h"
21 #include "ControlBranch.h"
22 #include "ControlChanges.h"
23 #include "ControlCharacter.h"
24 #include "ControlCitation.h"
25 #include "ControlCommand.h"
26 #include "ControlDocument.h"
27 #include "ControlErrorList.h"
28 #include "ControlERT.h"
29 #include "ControlExternal.h"
30 #include "ControlFloat.h"
31 #include "ControlGraphics.h"
32 #include "ControlInclude.h"
33 #include "ControlLog.h"
34 #include "ControlMath.h"
35 #include "ControlNote.h"
36 #include "ControlParagraph.h"
37 #include "ControlPrefs.h"
38 #include "ControlPrint.h"
39 #include "ControlRef.h"
40 #include "ControlSearch.h"
41 #include "ControlSendto.h"
42 #include "ControlShowFile.h"
43 #include "ControlSpellchecker.h"
44 #include "ControlTabular.h"
45 #include "ControlTabularCreate.h"
46 #include "ControlTexinfo.h"
47 #include "ControlToc.h"
48 #include "ControlVSpace.h"
49 #include "ControlWrap.h"
51 #include "GAboutlyx.h"
53 #include "GMathDelim.h"
54 #include "FormBibitem.h"
55 #include "FormBibtex.h"
57 #include "FormBranch.h"
58 #include "FormChanges.h"
59 #include "FormCharacter.h"
60 #include "FormCitation.h"
61 #include "FormDocument.h"
62 #include "FormErrorList.h"
64 #include "FormExternal.h"
65 #include "FormFloat.h"
66 #include "FormGraphics.h"
67 #include "FormInclude.h"
69 #include "GMathPanel.h"
70 #include "FormMathsBitmap.h"
71 #include "FormMathsMatrix.h"
72 #include "FormMathsSpace.h"
73 #include "FormMathsStyle.h"
75 #include "FormParagraph.h"
76 #include "FormPreferences.h"
77 #include "FormPrint.h"
79 #include "FormSearch.h"
80 #include "FormSendto.h"
81 #include "FormTabular.h"
82 #include "FormTexinfo.h"
83 #include "FormShowFile.h"
84 #include "FormSpellchecker.h"
85 #include "GTableCreate.h"
88 #include "FormVSpace.h"
91 #ifdef HAVE_LIBAIKSAURUS
92 #include "ControlThesaurus.h"
93 #include "FormThesaurus.h"
97 #include "ButtonController.h"
108 #include "ams_misc.xbm"
109 #include "ams_arrows.xbm"
110 #include "ams_rel.xbm"
111 #include "ams_nrel.xbm"
112 #include "ams_ops.xbm"
121 FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
122 char const * const * data, int size)
124 char const * const * const end = data + size;
125 return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
129 char const * const dialognames[] = {
130 "aboutlyx", "bibitem", "bibtex", "box", "branch", "changes", "character",
131 "citation", "document", "error", "errorlist" , "ert", "external", "file",
132 "findreplace", "float", "graphics", "include", "index", "label", "log",
133 "mathpanel", "mathaccents", "matharrows", "mathoperators", "mathrelations",
134 "mathgreek", "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
135 "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations",
136 "mathamsoperators", "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
137 "note", "paragraph", "prefs", "print", "ref", "sendto", "spellchecker",
138 "tabular", "tabularcreate", "texinfo",
140 #ifdef HAVE_LIBAIKSAURUS
144 "toc", "url", "vspace", "wrap" };
146 char const * const * const end_dialognames =
147 dialognames + (sizeof(dialognames) / sizeof(char *));
150 cmpCStr(char const * name) : name_(name) {}
151 bool operator()(char const * other) {
152 return strcmp(other, name_) == 0;
161 bool Dialogs::isValidName(string const & name) const
163 return std::find_if(dialognames, end_dialognames,
164 cmpCStr(name.c_str())) != end_dialognames;
168 Dialog * Dialogs::build(string const & name)
170 if (!isValidName(name))
173 Dialog * dialog = new Dialog(lyxview_, name);
174 dialog->bc().view(new xformsBC(dialog->bc()));
176 if (name == "aboutlyx") {
177 dialog->bc().view(new GBC(dialog->bc()));
178 dialog->setController(new ControlAboutlyx(*dialog));
179 dialog->setView(new GAboutlyx(*dialog));
180 dialog->bc().bp(new OkCancelPolicy);
181 } else if (name == "bibitem") {
182 dialog->setController(new ControlCommand(*dialog, name));
183 dialog->setView(new FormBibitem(*dialog));
184 dialog->bc().bp(new OkCancelReadOnlyPolicy);
185 } else if (name == "bibtex") {
186 dialog->setController(new ControlBibtex(*dialog));
187 dialog->setView(new FormBibtex(*dialog));
188 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
189 } else if (name == "box") {
190 dialog->setController(new ControlBox(*dialog));
191 dialog->setView(new FormBox(*dialog));
192 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
193 } else if (name == "character") {
194 dialog->setController(new ControlCharacter(*dialog));
195 dialog->setView(new FormCharacter(*dialog));
196 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
197 } else if (name == "changes") {
198 dialog->setController(new ControlChanges(*dialog));
199 dialog->setView(new FormChanges(*dialog));
200 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
201 } else if (name == "citation") {
202 dialog->setController(new ControlCitation(*dialog));
203 dialog->setView(new FormCitation(*dialog));
204 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
205 } else if (name == "document") {
206 dialog->setController(new ControlDocument(*dialog));
207 dialog->setView(new FormDocument(*dialog));
208 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
209 } else if (name == "errorlist") {
210 dialog->setController(new ControlErrorList(*dialog));
211 dialog->setView(new FormErrorList(*dialog));
212 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
213 } else if (name == "ert") {
214 dialog->setController(new ControlERT(*dialog));
215 dialog->setView(new FormERT(*dialog));
216 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
217 } else if (name == "external") {
218 dialog->setController(new ControlExternal(*dialog));
219 dialog->setView(new FormExternal(*dialog));
220 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
221 } else if (name == "file") {
222 dialog->setController(new ControlShowFile(*dialog));
223 dialog->setView(new FormShowFile(*dialog));
224 dialog->bc().bp(new OkCancelPolicy);
225 } else if (name == "findreplace") {
226 dialog->setController(new ControlSearch(*dialog));
227 dialog->setView(new FormSearch(*dialog));
228 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
229 } else if (name == "float") {
230 dialog->setController(new ControlFloat(*dialog));
231 dialog->setView(new FormFloat(*dialog));
232 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
233 } else if (name == "graphics") {
234 dialog->setController(new ControlGraphics(*dialog));
235 dialog->setView(new FormGraphics(*dialog));
236 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
237 } else if (name == "include") {
238 dialog->setController(new ControlInclude(*dialog));
239 dialog->setView(new FormInclude(*dialog));
240 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
241 } else if (name == "index") {
242 dialog->bc().view(new GBC(dialog->bc()));
243 dialog->setController(new ControlCommand(*dialog, name));
244 dialog->setView(new GText(*dialog,
245 _("Index"), _("Keyword:|#K")));
246 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
247 } else if (name == "label") {
248 dialog->bc().view(new GBC(dialog->bc()));
249 dialog->setController(new ControlCommand(*dialog, name));
250 dialog->setView(new GText(*dialog,
251 _("Label"), _("Label:|#L")));
252 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
253 } else if (name == "log") {
254 dialog->setController(new ControlLog(*dialog));
255 dialog->setView(new FormLog(*dialog));
256 dialog->bc().bp(new OkCancelPolicy);
258 } else if (name == "mathpanel") {
259 dialog->bc().view(new GBC(dialog->bc()));
260 dialog->setController(new ControlMath(*dialog));
261 dialog->setView(new GMathPanel(*dialog));
262 dialog->bc().bp(new IgnorantPolicy);
264 } else if (name == "mathaccents") {
265 FormMathsBitmap * bitmap =
266 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
267 latex_deco, nr_latex_deco);
269 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
271 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
273 dialog->setController(new ControlMath(*dialog));
274 dialog->setView(bitmap);
275 dialog->bc().bp(new IgnorantPolicy);
277 } else if (name == "matharrows") {
278 FormMathsBitmap * bitmap =
279 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
281 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
283 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
285 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
287 dialog->setController(new ControlMath(*dialog));
288 dialog->setView(bitmap);
289 dialog->bc().bp(new IgnorantPolicy);
291 } else if (name == "mathoperators") {
292 FormMathsBitmap * bitmap =
293 createFormBitmap(*dialog, _("Binary Ops"),
294 latex_bop, nr_latex_bop);
296 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
298 dialog->setController(new ControlMath(*dialog));
299 dialog->setView(bitmap);
300 dialog->bc().bp(new IgnorantPolicy);
302 } else if (name == "mathrelations") {
303 FormMathsBitmap * bitmap =
304 createFormBitmap(*dialog, _("Binary Relations"),
305 latex_brel, nr_latex_brel);
307 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
309 dialog->setController(new ControlMath(*dialog));
310 dialog->setView(bitmap);
311 dialog->bc().bp(new IgnorantPolicy);
313 } else if (name == "mathgreek") {
314 FormMathsBitmap * bitmap =
315 createFormBitmap(*dialog, _("Greek"),
316 latex_greek, nr_latex_greek);
318 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
320 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
322 dialog->setController(new ControlMath(*dialog));
323 dialog->setView(bitmap);
324 dialog->bc().bp(new IgnorantPolicy);
326 } else if (name == "mathmisc") {
327 FormMathsBitmap * bitmap =
328 createFormBitmap(*dialog, _("Misc"),
329 latex_misc, nr_latex_misc);
331 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
333 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
335 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
337 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
339 dialog->setController(new ControlMath(*dialog));
340 dialog->setView(bitmap);
341 dialog->bc().bp(new IgnorantPolicy);
343 } else if (name == "mathdots") {
344 FormMathsBitmap * bitmap =
345 createFormBitmap(*dialog, _("Dots"),
346 latex_dots, nr_latex_dots);
348 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
350 dialog->setController(new ControlMath(*dialog));
351 dialog->setView(bitmap);
352 dialog->bc().bp(new IgnorantPolicy);
354 } else if (name == "mathbigoperators") {
355 FormMathsBitmap * bitmap =
356 createFormBitmap(*dialog, _("Big Operators"),
357 latex_varsz, nr_latex_varsz);
359 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
361 dialog->setController(new ControlMath(*dialog));
362 dialog->setView(bitmap);
363 dialog->bc().bp(new IgnorantPolicy);
365 } else if (name == "mathamsmisc") {
366 FormMathsBitmap * bitmap =
367 createFormBitmap(*dialog, _("AMS Misc"),
368 latex_ams_misc, nr_latex_ams_misc);
370 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
372 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
374 dialog->setController(new ControlMath(*dialog));
375 dialog->setView(bitmap);
376 dialog->bc().bp(new IgnorantPolicy);
378 } else if (name == "mathamsarrows") {
379 FormMathsBitmap * bitmap =
380 createFormBitmap(*dialog, _("AMS Arrows"),
381 latex_ams_arrows, nr_latex_ams_arrows);
383 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
385 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
387 dialog->setController(new ControlMath(*dialog));
388 dialog->setView(bitmap);
389 dialog->bc().bp(new IgnorantPolicy);
391 } else if (name == "mathamsrelations") {
392 FormMathsBitmap * bitmap =
393 createFormBitmap(*dialog, _("AMS Relations"),
394 latex_ams_rel, nr_latex_ams_rel);
396 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
398 dialog->setController(new ControlMath(*dialog));
399 dialog->setView(bitmap);
400 dialog->bc().bp(new IgnorantPolicy);
402 } else if (name == "mathamsnegatedrelations") {
403 FormMathsBitmap * bitmap =
404 createFormBitmap(*dialog, _("AMS Negated Rel"),
405 latex_ams_nrel, nr_latex_ams_nrel);
407 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
409 dialog->setController(new ControlMath(*dialog));
410 dialog->setView(bitmap);
411 dialog->bc().bp(new IgnorantPolicy);
413 } else if (name == "mathamsoperators") {
414 FormMathsBitmap * bitmap =
415 createFormBitmap(*dialog, _("AMS Operators"),
416 latex_ams_ops, nr_latex_ams_ops);
418 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
420 dialog->setController(new ControlMath(*dialog));
421 dialog->setView(bitmap);
422 dialog->bc().bp(new IgnorantPolicy);
424 } else if (name == "mathdelimiter") {
425 dialog->bc().view(new GBC(dialog->bc()));
426 dialog->setController(new ControlMath(*dialog));
427 dialog->setView(new GMathDelim(*dialog));
428 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
429 } else if (name == "mathmatrix") {
430 dialog->setController(new ControlMath(*dialog));
431 dialog->setView(new FormMathsMatrix(*dialog));
432 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
433 } else if (name == "mathspace") {
434 dialog->setController(new ControlMath(*dialog));
435 dialog->setView(new FormMathsSpace(*dialog));
436 dialog->bc().bp(new IgnorantPolicy);
437 } else if (name == "mathstyle") {
438 dialog->setController(new ControlMath(*dialog));
439 dialog->setView(new FormMathsStyle(*dialog));
440 dialog->bc().bp(new IgnorantPolicy);
441 } else if (name == "note") {
442 dialog->setController(new ControlNote(*dialog));
443 dialog->setView(new FormNote(*dialog));
444 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
445 } else if (name == "branch") {
446 dialog->setController(new ControlBranch(*dialog));
447 dialog->setView(new FormBranch(*dialog));
448 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
449 } else if (name == "paragraph") {
450 dialog->setController(new ControlParagraph(*dialog));
451 dialog->setView(new FormParagraph(*dialog));
452 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
453 } else if (name == "prefs") {
454 dialog->setController(new ControlPrefs(*dialog));
455 dialog->setView(new FormPreferences(*dialog));
456 dialog->bc().bp(new OkApplyCancelPolicy);
457 } else if (name == "print") {
458 dialog->setController(new ControlPrint(*dialog));
459 dialog->setView(new FormPrint(*dialog));
460 dialog->bc().bp(new OkApplyCancelPolicy);
461 } else if (name == "ref") {
462 dialog->setController(new ControlRef(*dialog));
463 dialog->setView(new FormRef(*dialog));
464 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
465 } else if (name == "sendto") {
466 dialog->setController(new ControlSendto(*dialog));
467 dialog->setView(new FormSendto(*dialog));
468 dialog->bc().bp(new OkApplyCancelPolicy);
469 } else if (name == "spellchecker") {
470 dialog->setController(new ControlSpellchecker(*dialog));
471 dialog->setView(new FormSpellchecker(*dialog));
472 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
473 } else if (name == "tabular") {
474 dialog->setController(new ControlTabular(*dialog));
475 dialog->setView(new FormTabular(*dialog));
476 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
477 } else if (name == "tabularcreate") {
478 dialog->bc().view(new GBC(dialog->bc()));
479 dialog->setController(new ControlTabularCreate(*dialog));
480 dialog->setView(new GTableCreate(*dialog));
481 dialog->bc().bp(new IgnorantPolicy);
482 } else if (name == "texinfo") {
483 dialog->setController(new ControlTexinfo(*dialog));
484 dialog->setView(new FormTexinfo(*dialog));
485 dialog->bc().bp(new OkCancelPolicy);
486 #ifdef HAVE_LIBAIKSAURUS
487 } else if (name == "thesaurus") {
488 dialog->setController(new ControlThesaurus(*dialog));
489 dialog->setView(new FormThesaurus(*dialog));
490 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
492 } else if (name == "toc") {
493 dialog->setController(new ControlToc(*dialog));
494 dialog->setView(new FormToc(*dialog));
495 dialog->bc().bp(new OkCancelPolicy);
496 } else if (name == "url") {
497 dialog->bc().view(new GBC(dialog->bc()));
498 dialog->setController(new ControlCommand(*dialog, name));
499 dialog->setView(new GUrl(*dialog));
500 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
501 } else if (name == "vspace") {
502 dialog->setController(new ControlVSpace(*dialog));
503 dialog->setView(new FormVSpace(*dialog));
504 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
505 } else if (name == "wrap") {
506 dialog->setController(new ControlWrap(*dialog));
507 dialog->setView(new FormWrap(*dialog));
508 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
515 void Dialogs::toggleTooltips()
517 Tooltips::toggleEnabled();
521 /// Are the tooltips on or off?
522 bool Dialogs::tooltipsEnabled()
524 return Tooltips::enabled();