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.
17 #include "ControlAboutlyx.h"
18 #include "ControlBibtex.h"
19 #include "ControlBox.h"
20 #include "ControlBranch.h"
21 #include "ControlChanges.h"
22 #include "ControlCitation.h"
23 #include "ControlErrorList.h"
24 #include "ControlERT.h"
25 #include "ControlExternal.h"
26 #include "ControlFloat.h"
27 #include "ControlGraphics.h"
28 #include "ControlInclude.h"
29 #include "ControlLog.h"
30 #include "ControlMath.h"
31 #include "ControlMinipage.h"
32 #include "ControlNote.h"
33 #include "ControlParagraph.h"
34 #include "ControlRef.h"
35 #include "ControlShowFile.h"
36 #include "ControlTabular.h"
37 #include "ControlTabularCreate.h"
38 #include "ControlToc.h"
39 #include "ControlVCLog.h"
40 #include "ControlVSpace.h"
41 #include "ControlWrap.h"
43 #include "FormAboutlyx.h"
44 #include "FormBibitem.h"
45 #include "FormBibtex.h"
47 #include "FormBranch.h"
48 #include "FormChanges.h"
49 #include "FormCharacter.h"
50 #include "FormCitation.h"
51 #include "FormErrorList.h"
53 #include "FormExternal.h"
54 #include "FormFloat.h"
55 #include "FormGraphics.h"
56 #include "FormInclude.h"
58 #include "FormMathsPanel.h"
59 #include "FormMathsBitmap.h"
60 #include "FormMathsDelim.h"
61 #include "FormMathsMatrix.h"
62 #include "FormMathsSpace.h"
63 #include "FormMathsStyle.h"
64 #include "FormMinipage.h"
66 #include "FormParagraph.h"
68 #include "FormTabular.h"
69 #include "FormTexinfo.h"
70 #include "FormShowFile.h"
71 #include "FormTabularCreate.h"
75 #include "FormVCLog.h"
76 #include "FormVSpace.h"
79 #ifdef HAVE_LIBAIKSAURUS
80 #include "ControlThesaurus.h"
81 #include "FormThesaurus.h"
85 #include "ButtonController.h"
96 #include "ams_misc.xbm"
97 #include "ams_arrows.xbm"
98 #include "ams_rel.xbm"
99 #include "ams_nrel.xbm"
100 #include "ams_ops.xbm"
108 FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
109 char const * const * data, int size)
111 char const * const * const end = data + size;
112 return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
116 char const * const dialognames[] = {
117 "aboutlyx", "bibitem", "bibtex", "branch", "box", "changes",
118 "character", "citation", "error", "errorlist" , "ert", "external", "file",
119 "float", "graphics", "include", "index", "label", "latexlog", "mathpanel",
120 "mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek",
121 "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
122 "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators",
123 "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
124 "minipage", "note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo",
126 #ifdef HAVE_LIBAIKSAURUS
130 "toc", "url", "vclog", "vspace", "wrap" };
132 char const * const * const end_dialognames =
133 dialognames + (sizeof(dialognames) / sizeof(char *));
136 cmpCStr(char const * name) : name_(name) {}
137 bool operator()(char const * other) {
138 return strcmp(other, name_) == 0;
147 bool Dialogs::isValidName(string const & name) const
149 return std::find_if(dialognames, end_dialognames,
150 cmpCStr(name.c_str())) != end_dialognames;
154 Dialog * Dialogs::build(string const & name)
156 if (!isValidName(name))
159 Dialog * dialog = new Dialog(lyxview_, name);
160 dialog->bc().view(new xformsBC(dialog->bc()));
162 if (name == "aboutlyx") {
163 dialog->setController(new ControlAboutlyx(*dialog));
164 dialog->setView(new FormAboutlyx(*dialog));
165 dialog->bc().bp(new OkCancelPolicy);
166 } else if (name == "bibitem") {
167 dialog->setController(new ControlCommand(*dialog, name));
168 dialog->setView(new FormBibitem(*dialog));
169 dialog->bc().bp(new OkCancelReadOnlyPolicy);
170 } else if (name == "bibtex") {
171 dialog->setController(new ControlBibtex(*dialog));
172 dialog->setView(new FormBibtex(*dialog));
173 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
174 } else if (name == "character") {
175 dialog->setController(new ControlCharacter(*dialog));
176 dialog->setView(new FormCharacter(*dialog));
177 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
178 } else if (name == "changes") {
179 dialog->setController(new ControlChanges(*dialog));
180 dialog->setView(new FormChanges(*dialog));
181 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
182 } else if (name == "citation") {
183 dialog->setController(new ControlCitation(*dialog));
184 dialog->setView(new FormCitation(*dialog));
185 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
186 } else if (name == "errorlist") {
187 dialog->setController(new ControlErrorList(*dialog));
188 dialog->setView(new FormErrorList(*dialog));
189 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
190 } else if (name == "ert") {
191 dialog->setController(new ControlERT(*dialog));
192 dialog->setView(new FormERT(*dialog));
193 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
194 } else if (name == "external") {
195 dialog->setController(new ControlExternal(*dialog));
196 dialog->setView(new FormExternal(*dialog));
197 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
198 } else if (name == "file") {
199 dialog->setController(new ControlShowFile(*dialog));
200 dialog->setView(new FormShowFile(*dialog));
201 dialog->bc().bp(new OkCancelPolicy);
202 } else if (name == "float") {
203 dialog->setController(new ControlFloat(*dialog));
204 dialog->setView(new FormFloat(*dialog));
205 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
206 } else if (name == "graphics") {
207 dialog->setController(new ControlGraphics(*dialog));
208 dialog->setView(new FormGraphics(*dialog));
209 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
210 } else if (name == "include") {
211 dialog->setController(new ControlInclude(*dialog));
212 dialog->setView(new FormInclude(*dialog));
213 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
214 } else if (name == "index") {
215 dialog->setController(new ControlCommand(*dialog, name));
216 dialog->setView(new FormText(*dialog,
217 _("Index"), _("Keyword:|#K")));
218 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
219 } else if (name == "label") {
220 dialog->setController(new ControlCommand(*dialog, name));
221 dialog->setView(new FormText(*dialog,
222 _("Label"), _("Label:|#L")));
223 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
224 } else if (name == "latexlog") {
225 dialog->setController(new ControlLog(*dialog));
226 dialog->setView(new FormLog(*dialog));
227 dialog->bc().bp(new OkCancelPolicy);
229 } else if (name == "mathpanel") {
230 dialog->setController(new ControlMath(*dialog));
231 dialog->setView(new FormMathsPanel(*dialog));
232 dialog->bc().bp(new IgnorantPolicy);
234 } else if (name == "mathaccents") {
235 FormMathsBitmap * bitmap =
236 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
237 latex_deco, nr_latex_deco);
239 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
241 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
243 dialog->setController(new ControlMath(*dialog));
244 dialog->setView(bitmap);
245 dialog->bc().bp(new IgnorantPolicy);
247 } else if (name == "matharrows") {
248 FormMathsBitmap * bitmap =
249 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
251 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
253 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
255 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
257 dialog->setController(new ControlMath(*dialog));
258 dialog->setView(bitmap);
259 dialog->bc().bp(new IgnorantPolicy);
261 } else if (name == "mathoperators") {
262 FormMathsBitmap * bitmap =
263 createFormBitmap(*dialog, _("Binary Ops"),
264 latex_bop, nr_latex_bop);
266 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
268 dialog->setController(new ControlMath(*dialog));
269 dialog->setView(bitmap);
270 dialog->bc().bp(new IgnorantPolicy);
272 } else if (name == "mathrelations") {
273 FormMathsBitmap * bitmap =
274 createFormBitmap(*dialog, _("Binary Relations"),
275 latex_brel, nr_latex_brel);
277 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
279 dialog->setController(new ControlMath(*dialog));
280 dialog->setView(bitmap);
281 dialog->bc().bp(new IgnorantPolicy);
283 } else if (name == "mathgreek") {
284 FormMathsBitmap * bitmap =
285 createFormBitmap(*dialog, _("Greek"),
286 latex_greek, nr_latex_greek);
288 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
290 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
292 dialog->setController(new ControlMath(*dialog));
293 dialog->setView(bitmap);
294 dialog->bc().bp(new IgnorantPolicy);
296 } else if (name == "mathmisc") {
297 FormMathsBitmap * bitmap =
298 createFormBitmap(*dialog, _("Misc"),
299 latex_misc, nr_latex_misc);
301 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
303 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
305 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
307 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
309 dialog->setController(new ControlMath(*dialog));
310 dialog->setView(bitmap);
311 dialog->bc().bp(new IgnorantPolicy);
313 } else if (name == "mathdots") {
314 FormMathsBitmap * bitmap =
315 createFormBitmap(*dialog, _("Dots"),
316 latex_dots, nr_latex_dots);
318 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
320 dialog->setController(new ControlMath(*dialog));
321 dialog->setView(bitmap);
322 dialog->bc().bp(new IgnorantPolicy);
324 } else if (name == "mathbigoperators") {
325 FormMathsBitmap * bitmap =
326 createFormBitmap(*dialog, _("Big Operators"),
327 latex_varsz, nr_latex_varsz);
329 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
331 dialog->setController(new ControlMath(*dialog));
332 dialog->setView(bitmap);
333 dialog->bc().bp(new IgnorantPolicy);
335 } else if (name == "mathamsmisc") {
336 FormMathsBitmap * bitmap =
337 createFormBitmap(*dialog, _("AMS Misc"),
338 latex_ams_misc, nr_latex_ams_misc);
340 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
342 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
344 dialog->setController(new ControlMath(*dialog));
345 dialog->setView(bitmap);
346 dialog->bc().bp(new IgnorantPolicy);
348 } else if (name == "mathamsarrows") {
349 FormMathsBitmap * bitmap =
350 createFormBitmap(*dialog, _("AMS Arrows"),
351 latex_ams_arrows, nr_latex_ams_arrows);
353 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
355 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
357 dialog->setController(new ControlMath(*dialog));
358 dialog->setView(bitmap);
359 dialog->bc().bp(new IgnorantPolicy);
361 } else if (name == "mathamsrelations") {
362 FormMathsBitmap * bitmap =
363 createFormBitmap(*dialog, _("AMS Relations"),
364 latex_ams_rel, nr_latex_ams_rel);
366 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
368 dialog->setController(new ControlMath(*dialog));
369 dialog->setView(bitmap);
370 dialog->bc().bp(new IgnorantPolicy);
372 } else if (name == "mathamsnegatedrelations") {
373 FormMathsBitmap * bitmap =
374 createFormBitmap(*dialog, _("AMS Negated Rel"),
375 latex_ams_nrel, nr_latex_ams_nrel);
377 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
379 dialog->setController(new ControlMath(*dialog));
380 dialog->setView(bitmap);
381 dialog->bc().bp(new IgnorantPolicy);
383 } else if (name == "mathamsoperators") {
384 FormMathsBitmap * bitmap =
385 createFormBitmap(*dialog, _("AMS Operators"),
386 latex_ams_ops, nr_latex_ams_ops);
388 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
390 dialog->setController(new ControlMath(*dialog));
391 dialog->setView(bitmap);
392 dialog->bc().bp(new IgnorantPolicy);
394 } else if (name == "mathdelimiter") {
395 dialog->setController(new ControlMath(*dialog));
396 dialog->setView(new FormMathsDelim(*dialog));
397 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
398 } else if (name == "mathmatrix") {
399 dialog->setController(new ControlMath(*dialog));
400 dialog->setView(new FormMathsMatrix(*dialog));
401 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
402 } else if (name == "mathspace") {
403 dialog->setController(new ControlMath(*dialog));
404 dialog->setView(new FormMathsSpace(*dialog));
405 dialog->bc().bp(new IgnorantPolicy);
406 } else if (name == "mathstyle") {
407 dialog->setController(new ControlMath(*dialog));
408 dialog->setView(new FormMathsStyle(*dialog));
409 dialog->bc().bp(new IgnorantPolicy);
410 } else if (name == "minipage") {
411 dialog->setController(new ControlMinipage(*dialog));
412 dialog->setView(new FormMinipage(*dialog));
413 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
414 } else if (name == "note") {
415 dialog->setController(new ControlNote(*dialog));
416 dialog->setView(new FormNote(*dialog));
417 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
418 } else if (name == "box") {
419 dialog->setController(new ControlBox(*dialog));
420 dialog->setView(new FormBox(*dialog));
421 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
422 } else if (name == "branch") {
423 dialog->setController(new ControlBranch(*dialog));
424 dialog->setView(new FormBranch(*dialog));
425 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
426 } else if (name == "paragraph") {
427 dialog->setController(new ControlParagraph(*dialog));
428 dialog->setView(new FormParagraph(*dialog));
429 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
430 } else if (name == "ref") {
431 dialog->setController(new ControlRef(*dialog));
432 dialog->setView(new FormRef(*dialog));
433 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
434 } else if (name == "tabular") {
435 dialog->setController(new ControlTabular(*dialog));
436 dialog->setView(new FormTabular(*dialog));
437 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
438 } else if (name == "tabularcreate") {
439 dialog->setController(new ControlTabularCreate(*dialog));
440 dialog->setView(new FormTabularCreate(*dialog));
441 dialog->bc().bp(new IgnorantPolicy);
442 } else if (name == "texinfo") {
443 dialog->setController(new ControlTexinfo(*dialog));
444 dialog->setView(new FormTexinfo(*dialog));
445 dialog->bc().bp(new OkCancelPolicy);
446 #ifdef HAVE_LIBAIKSAURUS
447 } else if (name == "thesaurus") {
448 dialog->setController(new ControlThesaurus(*dialog));
449 dialog->setView(new FormThesaurus(*dialog));
450 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
452 } else if (name == "toc") {
453 dialog->setController(new ControlToc(*dialog));
454 dialog->setView(new FormToc(*dialog));
455 dialog->bc().bp(new OkCancelPolicy);
456 } else if (name == "url") {
457 dialog->setController(new ControlCommand(*dialog, name));
458 dialog->setView(new FormUrl(*dialog));
459 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
460 } else if (name == "vclog") {
461 dialog->setController(new ControlVCLog(*dialog));
462 dialog->setView(new FormVCLog(*dialog));
463 dialog->bc().bp(new OkCancelPolicy);
464 } else if (name == "vspace") {
465 dialog->setController(new ControlVSpace(*dialog));
466 dialog->setView(new FormVSpace(*dialog));
467 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
468 } else if (name == "wrap") {
469 dialog->setController(new ControlWrap(*dialog));
470 dialog->setView(new FormWrap(*dialog));
471 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
478 void Dialogs::toggleTooltips()
480 Tooltips::toggleEnabled();
484 /// Are the tooltips on or off?
485 bool Dialogs::tooltipsEnabled()
487 return Tooltips::enabled();