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 "ControlError.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 "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 "FormError.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"
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", "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 == "error") {
183 dialog->setController(new ControlError(*dialog));
184 dialog->setView(new FormError(*dialog));
185 dialog->bc().bp(new OkCancelPolicy);
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 == "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();