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.
17 #include "ControlAboutlyx.h"
18 #include "ControlBibtex.h"
19 #include "ControlBranch.h"
20 #include "ControlChanges.h"
21 #include "ControlCitation.h"
22 #include "ControlErrorList.h"
23 #include "ControlERT.h"
24 #include "ControlExternal.h"
25 #include "ControlFloat.h"
26 #include "ControlGraphics.h"
27 #include "ControlInclude.h"
28 #include "ControlLog.h"
29 #include "ControlMath.h"
30 #include "ControlMinipage.h"
31 #include "ControlNote.h"
32 #include "ControlParagraph.h"
33 #include "ControlRef.h"
34 #include "ControlShowFile.h"
35 #include "ControlTabular.h"
36 #include "ControlTabularCreate.h"
37 #include "ControlToc.h"
38 #include "ControlVCLog.h"
39 #include "ControlWrap.h"
41 #include "FormAboutlyx.h"
42 #include "FormBibitem.h"
43 #include "FormBibtex.h"
44 #include "FormBranch.h"
45 #include "FormChanges.h"
46 #include "FormCharacter.h"
47 #include "FormCitation.h"
48 #include "FormErrorList.h"
50 #include "FormExternal.h"
51 #include "FormFloat.h"
52 #include "FormGraphics.h"
53 #include "FormInclude.h"
55 #include "FormMathsPanel.h"
56 #include "FormMathsBitmap.h"
57 #include "FormMathsDelim.h"
58 #include "FormMathsMatrix.h"
59 #include "FormMathsSpace.h"
60 #include "FormMathsStyle.h"
61 #include "FormMinipage.h"
63 #include "FormParagraph.h"
65 #include "FormTabular.h"
66 #include "FormTexinfo.h"
67 #include "FormShowFile.h"
68 #include "FormTabularCreate.h"
72 #include "FormVCLog.h"
75 #ifdef HAVE_LIBAIKSAURUS
76 #include "ControlThesaurus.h"
77 #include "FormThesaurus.h"
81 #include "ButtonController.h"
92 #include "ams_misc.xbm"
93 #include "ams_arrows.xbm"
94 #include "ams_rel.xbm"
95 #include "ams_nrel.xbm"
96 #include "ams_ops.xbm"
104 FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
105 char const * const * data, int size)
107 char const * const * const end = data + size;
108 return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
112 char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "branch", "changes",
113 "character", "citation", "error", "errorlist" , "ert", "external", "file",
114 "float", "graphics", "include", "index", "label", "latexlog", "mathpanel",
115 "mathaccents", "matharrows", "mathoperators", "mathrelations", "mathgreek",
116 "mathmisc", "mathdots", "mathbigoperators", "mathamsmisc",
117 "mathamsarrows", "mathamsrelations", "mathamsnegatedrelations", "mathamsoperators",
118 "mathdelimiter", "mathmatrix", "mathspace", "mathstyle",
119 "minipage", "note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo",
121 #ifdef HAVE_LIBAIKSAURUS
125 "toc", "url", "vclog", "wrap" };
127 char const * const * const end_dialognames =
128 dialognames + (sizeof(dialognames) / sizeof(char *));
131 cmpCStr(char const * name) : name_(name) {}
132 bool operator()(char const * other) {
133 return strcmp(other, name_) == 0;
142 bool Dialogs::isValidName(string const & name) const
144 return std::find_if(dialognames, end_dialognames,
145 cmpCStr(name.c_str())) != end_dialognames;
149 Dialog * Dialogs::build(string const & name)
151 if (!isValidName(name))
154 Dialog * dialog = new Dialog(lyxview_, name);
155 dialog->bc().view(new xformsBC(dialog->bc()));
157 if (name == "aboutlyx") {
158 dialog->setController(new ControlAboutlyx(*dialog));
159 dialog->setView(new FormAboutlyx(*dialog));
160 dialog->bc().bp(new OkCancelPolicy);
161 } else if (name == "bibitem") {
162 dialog->setController(new ControlCommand(*dialog, name));
163 dialog->setView(new FormBibitem(*dialog));
164 dialog->bc().bp(new OkCancelReadOnlyPolicy);
165 } else if (name == "bibtex") {
166 dialog->setController(new ControlBibtex(*dialog));
167 dialog->setView(new FormBibtex(*dialog));
168 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
169 } else if (name == "character") {
170 dialog->setController(new ControlCharacter(*dialog));
171 dialog->setView(new FormCharacter(*dialog));
172 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
173 } else if (name == "changes") {
174 dialog->setController(new ControlChanges(*dialog));
175 dialog->setView(new FormChanges(*dialog));
176 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
177 } else if (name == "citation") {
178 dialog->setController(new ControlCitation(*dialog));
179 dialog->setView(new FormCitation(*dialog));
180 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
181 } else if (name == "errorlist") {
182 dialog->setController(new ControlErrorList(*dialog));
183 dialog->setView(new FormErrorList(*dialog));
184 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
185 } else if (name == "ert") {
186 dialog->setController(new ControlERT(*dialog));
187 dialog->setView(new FormERT(*dialog));
188 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
189 } else if (name == "external") {
190 dialog->setController(new ControlExternal(*dialog));
191 dialog->setView(new FormExternal(*dialog));
192 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
193 } else if (name == "file") {
194 dialog->setController(new ControlShowFile(*dialog));
195 dialog->setView(new FormShowFile(*dialog));
196 dialog->bc().bp(new OkCancelPolicy);
197 } else if (name == "float") {
198 dialog->setController(new ControlFloat(*dialog));
199 dialog->setView(new FormFloat(*dialog));
200 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
201 } else if (name == "graphics") {
202 dialog->setController(new ControlGraphics(*dialog));
203 dialog->setView(new FormGraphics(*dialog));
204 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
205 } else if (name == "include") {
206 dialog->setController(new ControlInclude(*dialog));
207 dialog->setView(new FormInclude(*dialog));
208 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
209 } else if (name == "index") {
210 dialog->setController(new ControlCommand(*dialog, name));
211 dialog->setView(new FormText(*dialog,
212 _("Index"), _("Keyword:|#K")));
213 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
214 } else if (name == "label") {
215 dialog->setController(new ControlCommand(*dialog, name));
216 dialog->setView(new FormText(*dialog,
217 _("Label"), _("Label:|#L")));
218 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
219 } else if (name == "latexlog") {
220 dialog->setController(new ControlLog(*dialog));
221 dialog->setView(new FormLog(*dialog));
222 dialog->bc().bp(new OkCancelPolicy);
224 } else if (name == "mathpanel") {
225 dialog->setController(new ControlMath(*dialog));
226 dialog->setView(new FormMathsPanel(*dialog));
227 dialog->bc().bp(new IgnorantPolicy);
229 } else if (name == "mathaccents") {
230 FormMathsBitmap * bitmap =
231 createFormBitmap(*dialog, _("Maths Decorations & Accents"),
232 latex_deco, nr_latex_deco);
234 BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
236 BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
238 dialog->setController(new ControlMath(*dialog));
239 dialog->setView(bitmap);
240 dialog->bc().bp(new IgnorantPolicy);
242 } else if (name == "matharrows") {
243 FormMathsBitmap * bitmap =
244 createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
246 BitmapStore(20, 5, 4, arrow_width, arrow_height, arrow_bits, true));
248 BitmapStore(7, 2, 4, larrow_width, larrow_height, larrow_bits, false));
250 BitmapStore(4, 2, 2, darrow_width, darrow_height, darrow_bits, true));
252 dialog->setController(new ControlMath(*dialog));
253 dialog->setView(bitmap);
254 dialog->bc().bp(new IgnorantPolicy);
256 } else if (name == "mathoperators") {
257 FormMathsBitmap * bitmap =
258 createFormBitmap(*dialog, _("Binary Ops"),
259 latex_bop, nr_latex_bop);
261 BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
263 dialog->setController(new ControlMath(*dialog));
264 dialog->setView(bitmap);
265 dialog->bc().bp(new IgnorantPolicy);
267 } else if (name == "mathrelations") {
268 FormMathsBitmap * bitmap =
269 createFormBitmap(*dialog, _("Binary Relations"),
270 latex_brel, nr_latex_brel);
272 BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
274 dialog->setController(new ControlMath(*dialog));
275 dialog->setView(bitmap);
276 dialog->bc().bp(new IgnorantPolicy);
278 } else if (name == "mathgreek") {
279 FormMathsBitmap * bitmap =
280 createFormBitmap(*dialog, _("Greek"),
281 latex_greek, nr_latex_greek);
283 BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
285 BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
287 dialog->setController(new ControlMath(*dialog));
288 dialog->setView(bitmap);
289 dialog->bc().bp(new IgnorantPolicy);
291 } else if (name == "mathmisc") {
292 FormMathsBitmap * bitmap =
293 createFormBitmap(*dialog, _("Misc"),
294 latex_misc, nr_latex_misc);
296 BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
298 BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
300 BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
302 BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
304 dialog->setController(new ControlMath(*dialog));
305 dialog->setView(bitmap);
306 dialog->bc().bp(new IgnorantPolicy);
308 } else if (name == "mathdots") {
309 FormMathsBitmap * bitmap =
310 createFormBitmap(*dialog, _("Dots"),
311 latex_dots, nr_latex_dots);
313 BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
315 dialog->setController(new ControlMath(*dialog));
316 dialog->setView(bitmap);
317 dialog->bc().bp(new IgnorantPolicy);
319 } else if (name == "mathbigoperators") {
320 FormMathsBitmap * bitmap =
321 createFormBitmap(*dialog, _("Big Operators"),
322 latex_varsz, nr_latex_varsz);
324 BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
326 dialog->setController(new ControlMath(*dialog));
327 dialog->setView(bitmap);
328 dialog->bc().bp(new IgnorantPolicy);
330 } else if (name == "mathamsmisc") {
331 FormMathsBitmap * bitmap =
332 createFormBitmap(*dialog, _("AMS Misc"),
333 latex_ams_misc, nr_latex_ams_misc);
335 BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
337 BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
339 dialog->setController(new ControlMath(*dialog));
340 dialog->setView(bitmap);
341 dialog->bc().bp(new IgnorantPolicy);
343 } else if (name == "mathamsarrows") {
344 FormMathsBitmap * bitmap =
345 createFormBitmap(*dialog, _("AMS Arrows"),
346 latex_ams_arrows, nr_latex_ams_arrows);
348 BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
350 BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
352 dialog->setController(new ControlMath(*dialog));
353 dialog->setView(bitmap);
354 dialog->bc().bp(new IgnorantPolicy);
356 } else if (name == "mathamsrelations") {
357 FormMathsBitmap * bitmap =
358 createFormBitmap(*dialog, _("AMS Relations"),
359 latex_ams_rel, nr_latex_ams_rel);
361 BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
363 dialog->setController(new ControlMath(*dialog));
364 dialog->setView(bitmap);
365 dialog->bc().bp(new IgnorantPolicy);
367 } else if (name == "mathamsnegatedrelations") {
368 FormMathsBitmap * bitmap =
369 createFormBitmap(*dialog, _("AMS Negated Rel"),
370 latex_ams_nrel, nr_latex_ams_nrel);
372 BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
374 dialog->setController(new ControlMath(*dialog));
375 dialog->setView(bitmap);
376 dialog->bc().bp(new IgnorantPolicy);
378 } else if (name == "mathamsoperators") {
379 FormMathsBitmap * bitmap =
380 createFormBitmap(*dialog, _("AMS Operators"),
381 latex_ams_ops, nr_latex_ams_ops);
383 BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
385 dialog->setController(new ControlMath(*dialog));
386 dialog->setView(bitmap);
387 dialog->bc().bp(new IgnorantPolicy);
389 } else if (name == "mathdelimiter") {
390 dialog->setController(new ControlMath(*dialog));
391 dialog->setView(new FormMathsDelim(*dialog));
392 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
393 } else if (name == "mathmatrix") {
394 dialog->setController(new ControlMath(*dialog));
395 dialog->setView(new FormMathsMatrix(*dialog));
396 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
397 } else if (name == "mathspace") {
398 dialog->setController(new ControlMath(*dialog));
399 dialog->setView(new FormMathsSpace(*dialog));
400 dialog->bc().bp(new IgnorantPolicy);
401 } else if (name == "mathstyle") {
402 dialog->setController(new ControlMath(*dialog));
403 dialog->setView(new FormMathsStyle(*dialog));
404 dialog->bc().bp(new IgnorantPolicy);
405 } else if (name == "minipage") {
406 dialog->setController(new ControlMinipage(*dialog));
407 dialog->setView(new FormMinipage(*dialog));
408 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
409 } else if (name == "note") {
410 dialog->setController(new ControlNote(*dialog));
411 dialog->setView(new FormNote(*dialog));
412 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
413 } else if (name == "branch") {
414 dialog->setController(new ControlBranch(*dialog));
415 dialog->setView(new FormBranch(*dialog));
416 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
417 } else if (name == "paragraph") {
418 dialog->setController(new ControlParagraph(*dialog));
419 dialog->setView(new FormParagraph(*dialog));
420 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
421 } else if (name == "ref") {
422 dialog->setController(new ControlRef(*dialog));
423 dialog->setView(new FormRef(*dialog));
424 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
425 } else if (name == "tabular") {
426 dialog->setController(new ControlTabular(*dialog));
427 dialog->setView(new FormTabular(*dialog));
428 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
429 } else if (name == "tabularcreate") {
430 dialog->setController(new ControlTabularCreate(*dialog));
431 dialog->setView(new FormTabularCreate(*dialog));
432 dialog->bc().bp(new IgnorantPolicy);
433 } else if (name == "texinfo") {
434 dialog->setController(new ControlTexinfo(*dialog));
435 dialog->setView(new FormTexinfo(*dialog));
436 dialog->bc().bp(new OkCancelPolicy);
437 #ifdef HAVE_LIBAIKSAURUS
438 } else if (name == "thesaurus") {
439 dialog->setController(new ControlThesaurus(*dialog));
440 dialog->setView(new FormThesaurus(*dialog));
441 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
443 } else if (name == "toc") {
444 dialog->setController(new ControlToc(*dialog));
445 dialog->setView(new FormToc(*dialog));
446 dialog->bc().bp(new OkCancelPolicy);
447 } else if (name == "url") {
448 dialog->setController(new ControlCommand(*dialog, name));
449 dialog->setView(new FormUrl(*dialog));
450 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
451 } else if (name == "vclog") {
452 dialog->setController(new ControlVCLog(*dialog));
453 dialog->setView(new FormVCLog(*dialog));
454 dialog->bc().bp(new OkCancelPolicy);
455 } else if (name == "wrap") {
456 dialog->setController(new ControlWrap(*dialog));
457 dialog->setView(new FormWrap(*dialog));
458 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
465 void Dialogs::toggleTooltips()
467 Tooltips::toggleEnabled();
471 /// Are the tooltips on or off?
472 bool Dialogs::tooltipsEnabled()
474 return Tooltips::enabled();