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