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 "GMathPanel.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 "GTableCreate.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->bc().view(new GBC(dialog->bc()));
234 dialog->setController(new ControlMath(*dialog));
235 dialog->setView(new GMathPanel(*dialog));
236 dialog->bc().bp(new IgnorantPolicy);
238 } else if (name == "mathaccents") {
239 FormMathsBitmap * bitmap =
240 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
241 latex_deco, nr_latex_deco);
243 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
245 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
247 dialog->setController(new ControlMath(*dialog));
248 dialog->setView(bitmap);
249 dialog->bc().bp(new IgnorantPolicy);
251 } else if (name == "matharrows") {
252 FormMathsBitmap * bitmap =
253 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
255 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
257 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
259 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
261 dialog->setController(new ControlMath(*dialog));
262 dialog->setView(bitmap);
263 dialog->bc().bp(new IgnorantPolicy);
265 } else if (name == "mathoperators") {
266 FormMathsBitmap * bitmap =
267 createFormBitmap(*dialog, _("Binary Ops"),
268 latex_bop, nr_latex_bop);
270 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
272 dialog->setController(new ControlMath(*dialog));
273 dialog->setView(bitmap);
274 dialog->bc().bp(new IgnorantPolicy);
276 } else if (name == "mathrelations") {
277 FormMathsBitmap * bitmap =
278 createFormBitmap(*dialog, _("Binary Relations"),
279 latex_brel, nr_latex_brel);
281 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
283 dialog->setController(new ControlMath(*dialog));
284 dialog->setView(bitmap);
285 dialog->bc().bp(new IgnorantPolicy);
287 } else if (name == "mathgreek") {
288 FormMathsBitmap * bitmap =
289 createFormBitmap(*dialog, _("Greek"),
290 latex_greek, nr_latex_greek);
292 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
294 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
296 dialog->setController(new ControlMath(*dialog));
297 dialog->setView(bitmap);
298 dialog->bc().bp(new IgnorantPolicy);
300 } else if (name == "mathmisc") {
301 FormMathsBitmap * bitmap =
302 createFormBitmap(*dialog, _("Misc"),
303 latex_misc, nr_latex_misc);
305 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
307 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
309 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
311 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
313 dialog->setController(new ControlMath(*dialog));
314 dialog->setView(bitmap);
315 dialog->bc().bp(new IgnorantPolicy);
317 } else if (name == "mathdots") {
318 FormMathsBitmap * bitmap =
319 createFormBitmap(*dialog, _("Dots"),
320 latex_dots, nr_latex_dots);
322 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
324 dialog->setController(new ControlMath(*dialog));
325 dialog->setView(bitmap);
326 dialog->bc().bp(new IgnorantPolicy);
328 } else if (name == "mathbigoperators") {
329 FormMathsBitmap * bitmap =
330 createFormBitmap(*dialog, _("Big Operators"),
331 latex_varsz, nr_latex_varsz);
333 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
335 dialog->setController(new ControlMath(*dialog));
336 dialog->setView(bitmap);
337 dialog->bc().bp(new IgnorantPolicy);
339 } else if (name == "mathamsmisc") {
340 FormMathsBitmap * bitmap =
341 createFormBitmap(*dialog, _("AMS Misc"),
342 latex_ams_misc, nr_latex_ams_misc);
344 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
346 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
348 dialog->setController(new ControlMath(*dialog));
349 dialog->setView(bitmap);
350 dialog->bc().bp(new IgnorantPolicy);
352 } else if (name == "mathamsarrows") {
353 FormMathsBitmap * bitmap =
354 createFormBitmap(*dialog, _("AMS Arrows"),
355 latex_ams_arrows, nr_latex_ams_arrows);
357 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
359 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
361 dialog->setController(new ControlMath(*dialog));
362 dialog->setView(bitmap);
363 dialog->bc().bp(new IgnorantPolicy);
365 } else if (name == "mathamsrelations") {
366 FormMathsBitmap * bitmap =
367 createFormBitmap(*dialog, _("AMS Relations"),
368 latex_ams_rel, nr_latex_ams_rel);
370 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
372 dialog->setController(new ControlMath(*dialog));
373 dialog->setView(bitmap);
374 dialog->bc().bp(new IgnorantPolicy);
376 } else if (name == "mathamsnegatedrelations") {
377 FormMathsBitmap * bitmap =
378 createFormBitmap(*dialog, _("AMS Negated Rel"),
379 latex_ams_nrel, nr_latex_ams_nrel);
381 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
383 dialog->setController(new ControlMath(*dialog));
384 dialog->setView(bitmap);
385 dialog->bc().bp(new IgnorantPolicy);
387 } else if (name == "mathamsoperators") {
388 FormMathsBitmap * bitmap =
389 createFormBitmap(*dialog, _("AMS Operators"),
390 latex_ams_ops, nr_latex_ams_ops);
392 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
394 dialog->setController(new ControlMath(*dialog));
395 dialog->setView(bitmap);
396 dialog->bc().bp(new IgnorantPolicy);
398 } else if (name == "mathdelimiter") {
399 dialog->setController(new ControlMath(*dialog));
400 dialog->setView(new FormMathsDelim(*dialog));
401 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
402 } else if (name == "mathmatrix") {
403 dialog->setController(new ControlMath(*dialog));
404 dialog->setView(new FormMathsMatrix(*dialog));
405 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
406 } else if (name == "mathspace") {
407 dialog->setController(new ControlMath(*dialog));
408 dialog->setView(new FormMathsSpace(*dialog));
409 dialog->bc().bp(new IgnorantPolicy);
410 } else if (name == "mathstyle") {
411 dialog->setController(new ControlMath(*dialog));
412 dialog->setView(new FormMathsStyle(*dialog));
413 dialog->bc().bp(new IgnorantPolicy);
414 } else if (name == "minipage") {
415 dialog->setController(new ControlMinipage(*dialog));
416 dialog->setView(new FormMinipage(*dialog));
417 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
418 } else if (name == "note") {
419 dialog->setController(new ControlNote(*dialog));
420 dialog->setView(new FormNote(*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->bc().view(new GBC(dialog->bc()));
440 dialog->setController(new ControlTabularCreate(*dialog));
441 dialog->setView(new GTableCreate(*dialog));
442 dialog->bc().bp(new IgnorantPolicy);
443 } else if (name == "texinfo") {
444 dialog->setController(new ControlTexinfo(*dialog));
445 dialog->setView(new FormTexinfo(*dialog));
446 dialog->bc().bp(new OkCancelPolicy);
447 #ifdef HAVE_LIBAIKSAURUS
448 } else if (name == "thesaurus") {
449 dialog->setController(new ControlThesaurus(*dialog));
450 dialog->setView(new FormThesaurus(*dialog));
451 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
453 } else if (name == "toc") {
454 dialog->setController(new ControlToc(*dialog));
455 dialog->setView(new FormToc(*dialog));
456 dialog->bc().bp(new OkCancelPolicy);
457 } else if (name == "url") {
458 dialog->bc().view(new GBC(dialog->bc()));
459 dialog->setController(new ControlCommand(*dialog, name));
460 dialog->setView(new GUrl(*dialog));
461 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
462 } else if (name == "vclog") {
463 dialog->setController(new ControlVCLog(*dialog));
464 dialog->setView(new FormVCLog(*dialog));
465 dialog->bc().bp(new OkCancelPolicy);
466 } else if (name == "wrap") {
467 dialog->setController(new ControlWrap(*dialog));
468 dialog->setView(new FormWrap(*dialog));
469 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
476 void Dialogs::toggleTooltips()
478 Tooltips::toggleEnabled();
482 /// Are the tooltips on or off?
483 bool Dialogs::tooltipsEnabled()
485 return Tooltips::enabled();