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