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 "ControlBranch.h"
21 #include "ControlChanges.h"
22 #include "ControlCharacter.h"
23 #include "ControlCitation.h"
24 #include "ControlCommand.h"
25 #include "ControlErrorList.h"
26 #include "ControlERT.h"
27 #include "ControlExternal.h"
28 #include "ControlFloat.h"
29 #include "ControlGraphics.h"
30 #include "ControlInclude.h"
31 #include "ControlLog.h"
32 #include "ControlMath.h"
33 #include "ControlMinipage.h"
34 #include "ControlNote.h"
35 #include "ControlParagraph.h"
36 #include "ControlRef.h"
37 #include "ControlShowFile.h"
38 #include "ControlTabular.h"
39 #include "ControlTabularCreate.h"
40 #include "ControlTexinfo.h"
41 #include "ControlToc.h"
42 #include "ControlVCLog.h"
43 #include "ControlWrap.h"
45 #include "GAboutlyx.h"
47 #include "FormBibitem.h"
48 #include "FormBibtex.h"
49 #include "FormBranch.h"
50 #include "FormChanges.h"
51 #include "FormCharacter.h"
52 #include "FormCitation.h"
53 #include "FormErrorList.h"
55 #include "FormExternal.h"
56 #include "FormFloat.h"
57 #include "FormGraphics.h"
58 #include "FormInclude.h"
60 #include "FormMathsPanel.h"
61 #include "FormMathsBitmap.h"
62 #include "FormMathsDelim.h"
63 #include "FormMathsMatrix.h"
64 #include "FormMathsSpace.h"
65 #include "FormMathsStyle.h"
66 #include "FormMinipage.h"
68 #include "FormParagraph.h"
70 #include "FormTabular.h"
71 #include "FormTexinfo.h"
72 #include "FormShowFile.h"
73 #include "FormTabularCreate.h"
76 #include "FormVCLog.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"
109 FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
110 char const * const * data, int size)
112 char const * const * const end = data + size;
113 return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
117 char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "branch", "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", "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->bc().view(new GBC(dialog->bc()));
164 dialog->setController(new ControlAboutlyx(*dialog));
165 dialog->setView(new GAboutlyx(*dialog));
166 dialog->bc().bp(new OkCancelPolicy);
167 } else if (name == "bibitem") {
168 dialog->setController(new ControlCommand(*dialog, name));
169 dialog->setView(new FormBibitem(*dialog));
170 dialog->bc().bp(new OkCancelReadOnlyPolicy);
171 } else if (name == "bibtex") {
172 dialog->setController(new ControlBibtex(*dialog));
173 dialog->setView(new FormBibtex(*dialog));
174 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
175 } else if (name == "character") {
176 dialog->setController(new ControlCharacter(*dialog));
177 dialog->setView(new FormCharacter(*dialog));
178 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
179 } else if (name == "changes") {
180 dialog->setController(new ControlChanges(*dialog));
181 dialog->setView(new FormChanges(*dialog));
182 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
183 } else if (name == "citation") {
184 dialog->setController(new ControlCitation(*dialog));
185 dialog->setView(new FormCitation(*dialog));
186 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
187 } else if (name == "errorlist") {
188 dialog->setController(new ControlErrorList(*dialog));
189 dialog->setView(new FormErrorList(*dialog));
190 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
191 } else if (name == "ert") {
192 dialog->setController(new ControlERT(*dialog));
193 dialog->setView(new FormERT(*dialog));
194 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
195 } else if (name == "external") {
196 dialog->setController(new ControlExternal(*dialog));
197 dialog->setView(new FormExternal(*dialog));
198 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
199 } else if (name == "file") {
200 dialog->setController(new ControlShowFile(*dialog));
201 dialog->setView(new FormShowFile(*dialog));
202 dialog->bc().bp(new OkCancelPolicy);
203 } else if (name == "float") {
204 dialog->setController(new ControlFloat(*dialog));
205 dialog->setView(new FormFloat(*dialog));
206 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
207 } else if (name == "graphics") {
208 dialog->setController(new ControlGraphics(*dialog));
209 dialog->setView(new FormGraphics(*dialog));
210 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
211 } else if (name == "include") {
212 dialog->setController(new ControlInclude(*dialog));
213 dialog->setView(new FormInclude(*dialog));
214 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
215 } else if (name == "index") {
216 dialog->bc().view(new GBC(dialog->bc()));
217 dialog->setController(new ControlCommand(*dialog, name));
218 dialog->setView(new GText(*dialog,
219 _("Index"), _("Keyword:|#K")));
220 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
221 } else if (name == "label") {
222 dialog->bc().view(new GBC(dialog->bc()));
223 dialog->setController(new ControlCommand(*dialog, name));
224 dialog->setView(new GText(*dialog,
225 _("Label"), _("Label:|#L")));
226 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
227 } else if (name == "latexlog") {
228 dialog->setController(new ControlLog(*dialog));
229 dialog->setView(new FormLog(*dialog));
230 dialog->bc().bp(new OkCancelPolicy);
232 } else if (name == "mathpanel") {
233 dialog->setController(new ControlMath(*dialog));
234 dialog->setView(new FormMathsPanel(*dialog));
235 dialog->bc().bp(new IgnorantPolicy);
237 } else if (name == "mathaccents") {
238 FormMathsBitmap * bitmap =
239 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
240 latex_deco, nr_latex_deco);
242 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
244 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
246 dialog->setController(new ControlMath(*dialog));
247 dialog->setView(bitmap);
248 dialog->bc().bp(new IgnorantPolicy);
250 } else if (name == "matharrows") {
251 FormMathsBitmap * bitmap =
252 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
254 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
256 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
258 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
260 dialog->setController(new ControlMath(*dialog));
261 dialog->setView(bitmap);
262 dialog->bc().bp(new IgnorantPolicy);
264 } else if (name == "mathoperators") {
265 FormMathsBitmap * bitmap =
266 createFormBitmap(*dialog, _("Binary Ops"),
267 latex_bop, nr_latex_bop);
269 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
271 dialog->setController(new ControlMath(*dialog));
272 dialog->setView(bitmap);
273 dialog->bc().bp(new IgnorantPolicy);
275 } else if (name == "mathrelations") {
276 FormMathsBitmap * bitmap =
277 createFormBitmap(*dialog, _("Binary Relations"),
278 latex_brel, nr_latex_brel);
280 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
282 dialog->setController(new ControlMath(*dialog));
283 dialog->setView(bitmap);
284 dialog->bc().bp(new IgnorantPolicy);
286 } else if (name == "mathgreek") {
287 FormMathsBitmap * bitmap =
288 createFormBitmap(*dialog, _("Greek"),
289 latex_greek, nr_latex_greek);
291 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
293 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
295 dialog->setController(new ControlMath(*dialog));
296 dialog->setView(bitmap);
297 dialog->bc().bp(new IgnorantPolicy);
299 } else if (name == "mathmisc") {
300 FormMathsBitmap * bitmap =
301 createFormBitmap(*dialog, _("Misc"),
302 latex_misc, nr_latex_misc);
304 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
306 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
308 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
310 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
312 dialog->setController(new ControlMath(*dialog));
313 dialog->setView(bitmap);
314 dialog->bc().bp(new IgnorantPolicy);
316 } else if (name == "mathdots") {
317 FormMathsBitmap * bitmap =
318 createFormBitmap(*dialog, _("Dots"),
319 latex_dots, nr_latex_dots);
321 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
323 dialog->setController(new ControlMath(*dialog));
324 dialog->setView(bitmap);
325 dialog->bc().bp(new IgnorantPolicy);
327 } else if (name == "mathbigoperators") {
328 FormMathsBitmap * bitmap =
329 createFormBitmap(*dialog, _("Big Operators"),
330 latex_varsz, nr_latex_varsz);
332 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
334 dialog->setController(new ControlMath(*dialog));
335 dialog->setView(bitmap);
336 dialog->bc().bp(new IgnorantPolicy);
338 } else if (name == "mathamsmisc") {
339 FormMathsBitmap * bitmap =
340 createFormBitmap(*dialog, _("AMS Misc"),
341 latex_ams_misc, nr_latex_ams_misc);
343 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
345 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
347 dialog->setController(new ControlMath(*dialog));
348 dialog->setView(bitmap);
349 dialog->bc().bp(new IgnorantPolicy);
351 } else if (name == "mathamsarrows") {
352 FormMathsBitmap * bitmap =
353 createFormBitmap(*dialog, _("AMS Arrows"),
354 latex_ams_arrows, nr_latex_ams_arrows);
356 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
358 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
360 dialog->setController(new ControlMath(*dialog));
361 dialog->setView(bitmap);
362 dialog->bc().bp(new IgnorantPolicy);
364 } else if (name == "mathamsrelations") {
365 FormMathsBitmap * bitmap =
366 createFormBitmap(*dialog, _("AMS Relations"),
367 latex_ams_rel, nr_latex_ams_rel);
369 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
371 dialog->setController(new ControlMath(*dialog));
372 dialog->setView(bitmap);
373 dialog->bc().bp(new IgnorantPolicy);
375 } else if (name == "mathamsnegatedrelations") {
376 FormMathsBitmap * bitmap =
377 createFormBitmap(*dialog, _("AMS Negated Rel"),
378 latex_ams_nrel, nr_latex_ams_nrel);
380 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
382 dialog->setController(new ControlMath(*dialog));
383 dialog->setView(bitmap);
384 dialog->bc().bp(new IgnorantPolicy);
386 } else if (name == "mathamsoperators") {
387 FormMathsBitmap * bitmap =
388 createFormBitmap(*dialog, _("AMS Operators"),
389 latex_ams_ops, nr_latex_ams_ops);
391 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
393 dialog->setController(new ControlMath(*dialog));
394 dialog->setView(bitmap);
395 dialog->bc().bp(new IgnorantPolicy);
397 } else if (name == "mathdelimiter") {
398 dialog->setController(new ControlMath(*dialog));
399 dialog->setView(new FormMathsDelim(*dialog));
400 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
401 } else if (name == "mathmatrix") {
402 dialog->setController(new ControlMath(*dialog));
403 dialog->setView(new FormMathsMatrix(*dialog));
404 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
405 } else if (name == "mathspace") {
406 dialog->setController(new ControlMath(*dialog));
407 dialog->setView(new FormMathsSpace(*dialog));
408 dialog->bc().bp(new IgnorantPolicy);
409 } else if (name == "mathstyle") {
410 dialog->setController(new ControlMath(*dialog));
411 dialog->setView(new FormMathsStyle(*dialog));
412 dialog->bc().bp(new IgnorantPolicy);
413 } else if (name == "minipage") {
414 dialog->setController(new ControlMinipage(*dialog));
415 dialog->setView(new FormMinipage(*dialog));
416 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
417 } else if (name == "note") {
418 dialog->setController(new ControlNote(*dialog));
419 dialog->setView(new FormNote(*dialog));
420 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
421 } else if (name == "branch") {
422 dialog->setController(new ControlBranch(*dialog));
423 dialog->setView(new FormBranch(*dialog));
424 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
425 } else if (name == "paragraph") {
426 dialog->setController(new ControlParagraph(*dialog));
427 dialog->setView(new FormParagraph(*dialog));
428 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
429 } else if (name == "ref") {
430 dialog->setController(new ControlRef(*dialog));
431 dialog->setView(new FormRef(*dialog));
432 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
433 } else if (name == "tabular") {
434 dialog->setController(new ControlTabular(*dialog));
435 dialog->setView(new FormTabular(*dialog));
436 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
437 } else if (name == "tabularcreate") {
438 dialog->setController(new ControlTabularCreate(*dialog));
439 dialog->setView(new FormTabularCreate(*dialog));
440 dialog->bc().bp(new IgnorantPolicy);
441 } else if (name == "texinfo") {
442 dialog->setController(new ControlTexinfo(*dialog));
443 dialog->setView(new FormTexinfo(*dialog));
444 dialog->bc().bp(new OkCancelPolicy);
445 #ifdef HAVE_LIBAIKSAURUS
446 } else if (name == "thesaurus") {
447 dialog->setController(new ControlThesaurus(*dialog));
448 dialog->setView(new FormThesaurus(*dialog));
449 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
451 } else if (name == "toc") {
452 dialog->setController(new ControlToc(*dialog));
453 dialog->setView(new FormToc(*dialog));
454 dialog->bc().bp(new OkCancelPolicy);
455 } else if (name == "url") {
456 dialog->setController(new ControlCommand(*dialog, name));
457 dialog->setView(new FormUrl(*dialog));
458 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
459 } else if (name == "vclog") {
460 dialog->setController(new ControlVCLog(*dialog));
461 dialog->setView(new FormVCLog(*dialog));
462 dialog->bc().bp(new OkCancelPolicy);
463 } else if (name == "wrap") {
464 dialog->setController(new ControlWrap(*dialog));
465 dialog->setView(new FormWrap(*dialog));
466 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
473 void Dialogs::toggleTooltips()
475 Tooltips::toggleEnabled();
479 /// Are the tooltips on or off?
480 bool Dialogs::tooltipsEnabled()
482 return Tooltips::enabled();