]> git.lyx.org Git - features.git/blob - src/frontends/gtk/Dialogs.C
trivial compile fix: remove obsolete mentions of vclog from gtk's Dialogs.C and Makef...
[features.git] / src / frontends / gtk / Dialogs.C
1 /**
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.
5  *
6  * \author Angus Leeming
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Dialogs.h"
14 #include "Dialog.h"
15
16 #include "Tooltips.h"
17
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 "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 "ControlWrap.h"
42
43 #include "GAboutlyx.h"
44 #include "GText.h"
45 #include "FormBibitem.h"
46 #include "FormBibtex.h"
47 #include "FormBranch.h"
48 #include "FormChanges.h"
49 #include "FormCharacter.h"
50 #include "FormCitation.h"
51 #include "FormErrorList.h"
52 #include "FormERT.h"
53 #include "FormExternal.h"
54 #include "FormFloat.h"
55 #include "FormGraphics.h"
56 #include "FormInclude.h"
57 #include "FormLog.h"
58 #include "GMathPanel.h"
59 #include "FormMathsBitmap.h"
60 #include "FormMathsDelim.h"
61 #include "FormMathsMatrix.h"
62 #include "FormMathsSpace.h"
63 #include "FormMathsStyle.h"
64 #include "FormNote.h"
65 #include "FormParagraph.h"
66 #include "FormRef.h"
67 #include "FormTabular.h"
68 #include "FormTexinfo.h"
69 #include "FormShowFile.h"
70 #include "GTableCreate.h"
71 #include "FormToc.h"
72 #include "GUrl.h"
73 #include "FormWrap.h"
74
75 #ifdef HAVE_LIBAIKSAURUS
76 #include "ControlThesaurus.h"
77 #include "FormThesaurus.h"
78 #endif
79
80 #include "xformsBC.h"
81 #include "ButtonController.h"
82
83 #include "arrows.xbm"
84 #include "bop.xbm"
85 #include "brel.xbm"
86 #include "deco.xbm"
87 #include "dots.xbm"
88 #include "greek.xbm"
89 #include "misc.xbm"
90 #include "varsz.xbm"
91
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"
97
98 #include <vector>
99
100 using std::string;
101
102
103 namespace {
104
105 FormMathsBitmap * createFormBitmap(Dialog & parent, string const & title,
106                                    char const * const * data, int size)
107 {
108         char const * const * const end = data + size;
109         return new FormMathsBitmap(parent, title, std::vector<string>(data, end));
110 }
111
112
113 char const * const dialognames[] = { "aboutlyx", "bibitem", "bibtex", "branch", "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 "box", "note", "paragraph", "ref", "tabular", "tabularcreate", "texinfo",
121
122 #ifdef HAVE_LIBAIKSAURUS
123 "thesaurus",
124 #endif
125
126 "toc", "url", "wrap" };
127
128 char const * const * const end_dialognames =
129         dialognames + (sizeof(dialognames) / sizeof(char *));
130
131 struct cmpCStr {
132         cmpCStr(char const * name) : name_(name) {}
133         bool operator()(char const * other) {
134                 return strcmp(other, name_) == 0;
135         }
136 private:
137         char const * name_;
138 };
139
140 } // namespace anon
141
142
143 bool Dialogs::isValidName(string const & name) const
144 {
145         return std::find_if(dialognames, end_dialognames,
146                             cmpCStr(name.c_str())) != end_dialognames;
147 }
148
149
150 Dialog * Dialogs::build(string const & name)
151 {
152         if (!isValidName(name))
153                 return 0;
154
155         Dialog * dialog = new Dialog(lyxview_, name);
156         dialog->bc().view(new xformsBC(dialog->bc()));
157
158         if (name == "aboutlyx") {
159                 dialog->bc().view(new GBC(dialog->bc()));
160                 dialog->setController(new ControlAboutlyx(*dialog));
161                 dialog->setView(new GAboutlyx(*dialog));
162                 dialog->bc().bp(new OkCancelPolicy);
163         } else if (name == "bibitem") {
164                 dialog->setController(new ControlCommand(*dialog, name));
165                 dialog->setView(new FormBibitem(*dialog));
166                 dialog->bc().bp(new OkCancelReadOnlyPolicy);
167         } else if (name == "bibtex") {
168                 dialog->setController(new ControlBibtex(*dialog));
169                 dialog->setView(new FormBibtex(*dialog));
170                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
171         } else if (name == "character") {
172                 dialog->setController(new ControlCharacter(*dialog));
173                 dialog->setView(new FormCharacter(*dialog));
174                 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
175         } else if (name == "changes") {
176                 dialog->setController(new ControlChanges(*dialog));
177                 dialog->setView(new FormChanges(*dialog));
178                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
179         } else if (name == "citation") {
180                 dialog->setController(new ControlCitation(*dialog));
181                 dialog->setView(new FormCitation(*dialog));
182                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
183         } else if (name == "errorlist") {
184                 dialog->setController(new ControlErrorList(*dialog));
185                 dialog->setView(new FormErrorList(*dialog));
186                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
187         } else if (name == "ert") {
188                 dialog->setController(new ControlERT(*dialog));
189                 dialog->setView(new FormERT(*dialog));
190                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
191         } else if (name == "external") {
192                 dialog->setController(new ControlExternal(*dialog));
193                 dialog->setView(new FormExternal(*dialog));
194                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
195         } else if (name == "file") {
196                 dialog->setController(new ControlShowFile(*dialog));
197                 dialog->setView(new FormShowFile(*dialog));
198                 dialog->bc().bp(new OkCancelPolicy);
199         } else if (name == "float") {
200                 dialog->setController(new ControlFloat(*dialog));
201                 dialog->setView(new FormFloat(*dialog));
202                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
203         } else if (name == "graphics") {
204                 dialog->setController(new ControlGraphics(*dialog));
205                 dialog->setView(new FormGraphics(*dialog));
206                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
207         } else if (name == "include") {
208                 dialog->setController(new ControlInclude(*dialog));
209                 dialog->setView(new FormInclude(*dialog));
210                 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
211         } else if (name == "index") {
212                 dialog->bc().view(new GBC(dialog->bc()));
213                 dialog->setController(new ControlCommand(*dialog, name));
214                 dialog->setView(new GText(*dialog,
215                                           _("Index"), _("Keyword:|#K")));
216                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
217         } else if (name == "label") {
218                 dialog->bc().view(new GBC(dialog->bc()));
219                 dialog->setController(new ControlCommand(*dialog, name));
220                 dialog->setView(new GText(*dialog,
221                                           _("Label"), _("Label:|#L")));
222                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
223         } else if (name == "latexlog") {
224                 dialog->setController(new ControlLog(*dialog));
225                 dialog->setView(new FormLog(*dialog));
226                 dialog->bc().bp(new OkCancelPolicy);
227
228         } else if (name == "mathpanel") {
229                 dialog->bc().view(new GBC(dialog->bc()));
230                 dialog->setController(new ControlMath(*dialog));
231                 dialog->setView(new GMathPanel(*dialog));
232                 dialog->bc().bp(new IgnorantPolicy);
233
234         } else if (name == "mathaccents") {
235                 FormMathsBitmap * bitmap =
236                         createFormBitmap(*dialog, _("Maths Decorations & Accents"),
237                                          latex_deco, nr_latex_deco);
238                 bitmap->addBitmap(
239                         BitmapStore(12, 3, 4, deco1_width, deco1_height, deco1_bits, true));
240                 bitmap->addBitmap(
241                         BitmapStore(10, 4, 3, deco2_width, deco2_height, deco2_bits, true));
242
243                 dialog->setController(new ControlMath(*dialog));
244                 dialog->setView(bitmap);
245                 dialog->bc().bp(new IgnorantPolicy);
246
247         } else if (name == "matharrows") {
248                 FormMathsBitmap * bitmap =
249                         createFormBitmap(*dialog, _("Arrows"), latex_arrow, nr_latex_arrow);
250                 bitmap->addBitmap(
251                         BitmapStore(20, 5, 4, arrow_width,  arrow_height,  arrow_bits, true));
252                 bitmap->addBitmap(
253                         BitmapStore(7,  2, 4, larrow_width, larrow_height, larrow_bits, false));
254                 bitmap->addBitmap(
255                         BitmapStore(4,  2, 2, darrow_width,  darrow_height, darrow_bits, true));
256
257                 dialog->setController(new ControlMath(*dialog));
258                 dialog->setView(bitmap);
259                 dialog->bc().bp(new IgnorantPolicy);
260
261         } else if (name == "mathoperators") {
262                 FormMathsBitmap * bitmap =
263                         createFormBitmap(*dialog, _("Binary Ops"),
264                                          latex_bop, nr_latex_bop);
265                 bitmap->addBitmap(
266                         BitmapStore(31, 4, 8, bop_width, bop_height, bop_bits, true));
267
268                 dialog->setController(new ControlMath(*dialog));
269                 dialog->setView(bitmap);
270                 dialog->bc().bp(new IgnorantPolicy);
271
272         } else if (name == "mathrelations") {
273                 FormMathsBitmap * bitmap =
274                         createFormBitmap(*dialog, _("Binary Relations"),
275                                          latex_brel, nr_latex_brel);
276                 bitmap->addBitmap(
277                         BitmapStore(35, 4, 9, brel_width, brel_height, brel_bits, true));
278
279                 dialog->setController(new ControlMath(*dialog));
280                 dialog->setView(bitmap);
281                 dialog->bc().bp(new IgnorantPolicy);
282
283         } else if (name == "mathgreek") {
284                 FormMathsBitmap * bitmap =
285                         createFormBitmap(*dialog, _("Greek"),
286                                          latex_greek, nr_latex_greek);
287                 bitmap->addBitmap(
288                         BitmapStore(11, 6, 2, Greek_width, Greek_height, Greek_bits, true));
289                 bitmap->addBitmap(
290                         BitmapStore(28, 7, 4, greek_width, greek_height, greek_bits, true));
291
292                 dialog->setController(new ControlMath(*dialog));
293                 dialog->setView(bitmap);
294                 dialog->bc().bp(new IgnorantPolicy);
295
296         } else if (name == "mathmisc") {
297                 FormMathsBitmap * bitmap =
298                         createFormBitmap(*dialog, _("Misc"),
299                                          latex_misc, nr_latex_misc);
300                 bitmap->addBitmap(
301                         BitmapStore(29, 5, 6, misc_width, misc_height, misc_bits, true));
302                 bitmap->addBitmap(
303                         BitmapStore(5, 5, 1, misc4_width, misc4_height, misc4_bits, true));
304                 bitmap->addBitmap(
305                         BitmapStore(6, 3, 2, misc2_width, misc2_height, misc2_bits, false));
306                 bitmap->addBitmap(
307                         BitmapStore(4, 2, 2, misc3_width, misc3_height, misc3_bits, true));
308
309                 dialog->setController(new ControlMath(*dialog));
310                 dialog->setView(bitmap);
311                 dialog->bc().bp(new IgnorantPolicy);
312
313         } else if (name == "mathdots") {
314                 FormMathsBitmap * bitmap =
315                         createFormBitmap(*dialog, _("Dots"),
316                                          latex_dots, nr_latex_dots);
317                 bitmap->addBitmap(
318                         BitmapStore(4, 4, 1, dots_width, dots_height, dots_bits, true));
319
320                 dialog->setController(new ControlMath(*dialog));
321                 dialog->setView(bitmap);
322                 dialog->bc().bp(new IgnorantPolicy);
323
324         } else if (name == "mathbigoperators") {
325                 FormMathsBitmap * bitmap =
326                         createFormBitmap(*dialog, _("Big Operators"),
327                                          latex_varsz, nr_latex_varsz);
328                 bitmap->addBitmap(
329                         BitmapStore(14, 3, 5, varsz_width, varsz_height, varsz_bits, true));
330
331                 dialog->setController(new ControlMath(*dialog));
332                 dialog->setView(bitmap);
333                 dialog->bc().bp(new IgnorantPolicy);
334
335         } else if (name == "mathamsmisc") {
336                 FormMathsBitmap * bitmap =
337                         createFormBitmap(*dialog, _("AMS Misc"),
338                                          latex_ams_misc, nr_latex_ams_misc);
339                 bitmap->addBitmap(
340                         BitmapStore(9, 5, 2, ams1_width, ams1_height, ams1_bits, true));
341                 bitmap->addBitmap(
342                         BitmapStore(26, 3, 9, ams7_width, ams7_height, ams7_bits, true));
343
344                 dialog->setController(new ControlMath(*dialog));
345                 dialog->setView(bitmap);
346                 dialog->bc().bp(new IgnorantPolicy);
347
348         } else if (name == "mathamsarrows") {
349                 FormMathsBitmap * bitmap =
350                         createFormBitmap(*dialog, _("AMS Arrows"),
351                                          latex_ams_arrows, nr_latex_ams_arrows);
352                 bitmap->addBitmap(
353                         BitmapStore(32, 3, 11, ams2_width, ams2_height, ams2_bits, true));
354                 bitmap->addBitmap(
355                         BitmapStore(6, 3, 2, ams3_width, ams3_height, ams3_bits, true));
356
357                 dialog->setController(new ControlMath(*dialog));
358                 dialog->setView(bitmap);
359                 dialog->bc().bp(new IgnorantPolicy);
360
361         } else if (name == "mathamsrelations") {
362                 FormMathsBitmap * bitmap =
363                         createFormBitmap(*dialog, _("AMS Relations"),
364                                          latex_ams_rel, nr_latex_ams_rel);
365                 bitmap->addBitmap(
366                         BitmapStore(66, 6, 11, ams_rel_width, ams_rel_height, ams_rel_bits, true));
367
368                 dialog->setController(new ControlMath(*dialog));
369                 dialog->setView(bitmap);
370                 dialog->bc().bp(new IgnorantPolicy);
371
372         } else if (name == "mathamsnegatedrelations") {
373                 FormMathsBitmap * bitmap =
374                         createFormBitmap(*dialog, _("AMS Negated Rel"),
375                                          latex_ams_nrel, nr_latex_ams_nrel);
376                 bitmap->addBitmap(
377                         BitmapStore(51, 6, 9, ams_nrel_width, ams_nrel_height, ams_nrel_bits, true));
378
379                 dialog->setController(new ControlMath(*dialog));
380                 dialog->setView(bitmap);
381                 dialog->bc().bp(new IgnorantPolicy);
382
383         } else if (name == "mathamsoperators") {
384                 FormMathsBitmap * bitmap =
385                         createFormBitmap(*dialog, _("AMS Operators"),
386                                          latex_ams_ops, nr_latex_ams_ops);
387                 bitmap->addBitmap(
388                         BitmapStore(23, 3, 8, ams_ops_width, ams_ops_height, ams_ops_bits, true));
389
390                 dialog->setController(new ControlMath(*dialog));
391                 dialog->setView(bitmap);
392                 dialog->bc().bp(new IgnorantPolicy);
393
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 == "note") {
411                 dialog->setController(new ControlNote(*dialog));
412                 dialog->setView(new FormNote(*dialog));
413                 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
414         } else if (name == "branch") {
415                 dialog->setController(new ControlBranch(*dialog));
416                 dialog->setView(new FormBranch(*dialog));
417                 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
418         } else if (name == "paragraph") {
419                 dialog->setController(new ControlParagraph(*dialog));
420                 dialog->setView(new FormParagraph(*dialog));
421                 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
422         } else if (name == "ref") {
423                 dialog->setController(new ControlRef(*dialog));
424                 dialog->setView(new FormRef(*dialog));
425                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
426         } else if (name == "tabular") {
427                 dialog->setController(new ControlTabular(*dialog));
428                 dialog->setView(new FormTabular(*dialog));
429                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
430         } else if (name == "tabularcreate") {
431                 dialog->bc().view(new GBC(dialog->bc()));
432                 dialog->setController(new ControlTabularCreate(*dialog));
433                 dialog->setView(new GTableCreate(*dialog));
434                 dialog->bc().bp(new IgnorantPolicy);
435         } else if (name == "texinfo") {
436                 dialog->setController(new ControlTexinfo(*dialog));
437                 dialog->setView(new FormTexinfo(*dialog));
438                 dialog->bc().bp(new OkCancelPolicy);
439 #ifdef HAVE_LIBAIKSAURUS
440         } else if (name == "thesaurus") {
441                 dialog->setController(new ControlThesaurus(*dialog));
442                 dialog->setView(new FormThesaurus(*dialog));
443                 dialog->bc().bp(new OkApplyCancelReadOnlyPolicy);
444 #endif
445         } else if (name == "toc") {
446                 dialog->setController(new ControlToc(*dialog));
447                 dialog->setView(new FormToc(*dialog));
448                 dialog->bc().bp(new OkCancelPolicy);
449         } else if (name == "url") {
450                 dialog->bc().view(new GBC(dialog->bc()));
451                 dialog->setController(new ControlCommand(*dialog, name));
452                 dialog->setView(new GUrl(*dialog));
453                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
454         } else if (name == "wrap") {
455                 dialog->setController(new ControlWrap(*dialog));
456                 dialog->setView(new FormWrap(*dialog));
457                 dialog->bc().bp(new NoRepeatedApplyReadOnlyPolicy);
458         }
459
460         return dialog;
461 }
462
463
464 void Dialogs::toggleTooltips()
465 {
466         Tooltips::toggleEnabled();
467 }
468
469
470 /// Are the tooltips on or off?
471 bool Dialogs::tooltipsEnabled()
472 {
473         return Tooltips::enabled();
474 }