]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/guiapi.C
Create a grfx::Loader class and so move large chunks of code out of
[lyx.git] / src / frontends / xforms / guiapi.C
1 #include <config.h>
2
3 #include "guiapi.h"
4
5 #include "FormAboutlyx.h"
6 #include "forms/form_aboutlyx.h"
7
8 #include "FormBibitem.h"
9 #include "forms/form_bibitem.h"
10
11 #include "FormBibtex.h"
12 #include "forms/form_bibtex.h"
13
14 #include "FormBrowser.h"
15 #include "forms/form_browser.h"
16
17 #include "FormCharacter.h"
18 #include "forms/form_character.h"
19
20 #include "FormCitation.h"
21 #include "forms/form_citation.h"
22
23 #include "FormDocument.h"
24 #include "forms/form_document.h"
25
26 #include "FormError.h"
27 #include "forms/form_error.h"
28
29 #include "FormERT.h"
30 #include "forms/form_ert.h"
31
32 #include "FormExternal.h"
33 #include "forms/form_external.h"
34
35 #include "FormFloat.h"
36 #include "forms/form_float.h"
37
38 #include "FormForks.h"
39 #include "forms/form_forks.h"
40
41 #include "FormGraphics.h"
42 #include "forms/form_graphics.h"
43
44 #include "FormInclude.h"
45 #include "forms/form_include.h"
46
47 #include "FormIndex.h"
48 #include "forms/form_index.h"
49
50 #include "FormLog.h"
51
52 #include "FormMathsPanel.h"
53 #include "FormMathsBitmap.h"
54 #include "FormMathsDeco.h"
55 #include "FormMathsDelim.h"
56 #include "FormMathsMatrix.h"
57 #include "FormMathsSpace.h"
58 #include "FormMathsStyle.h"
59
60 #include "forms/form_maths_deco.h"
61 #include "forms/form_maths_delim.h"
62 #include "forms/form_maths_matrix.h"
63 #include "forms/form_maths_panel.h"
64 #include "forms/form_maths_space.h"
65 #include "forms/form_maths_style.h"
66
67 #include "FormMinipage.h"
68 #include "forms/form_minipage.h"
69
70 #include "FormParagraph.h"
71 #include "forms/form_paragraph.h"
72
73 #include "FormPreamble.h"
74 #include "forms/form_preamble.h"
75
76 #include "FormPreferences.h"
77 #include "forms/form_preferences.h"
78
79 #include "FormPrint.h"
80 #include "forms/form_print.h"
81
82 #include "FormRef.h"
83 #include "forms/form_ref.h"
84
85 #include "FormSearch.h"
86 #include "forms/form_search.h"
87
88 #include "FormSendto.h"
89 #include "forms/form_sendto.h"
90
91 #include "FormShowFile.h"
92
93 #include "FormSpellchecker.h"
94 #include "forms/form_spellchecker.h"
95
96 #include "FormTabular.h"
97 #include "forms/form_tabular.h"
98
99 #include "FormTabularCreate.h"
100 #include "forms/form_tabular_create.h"
101
102 #include "FormTexinfo.h"
103 #include "forms/form_texinfo.h"
104
105 #ifdef HAVE_LIBAIKSAURUS
106 #include "FormThesaurus.h"
107 #include "forms/form_thesaurus.h"
108 #endif
109
110 #include "FormToc.h"
111 #include "forms/form_toc.h"
112
113 #include "FormUrl.h"
114 #include "forms/form_url.h"
115
116 #include "FormVCLog.h"
117
118 #include "xformsBC.h"
119 #include "combox.h"
120
121 #include "controllers/GUI.h"
122 #include "insets/inseterror.h"
123
124 #include "LyXView.h"
125
126 #include "ControlAboutlyx.h"
127 #include "ControlBibitem.h"
128 #include "ControlBibtex.h"
129 #include "ControlCharacter.h"
130 #include "ControlCitation.h"
131 #include "ControlError.h"
132 #include "ControlERT.h"
133 #include "ControlExternal.h"
134 #include "ControlFloat.h"
135 #include "ControlForks.h"
136 #include "ControlGraphics.h"
137 #include "insets/insetgraphicsParams.h"
138 #include "ControlInclude.h"
139 #include "ControlIndex.h"
140 #include "ControlLog.h"
141 #include "ControlMinipage.h"
142 #include "ControlParagraph.h"
143 #include "ControlPreamble.h"
144 #include "ControlPrint.h"
145 #include "ControlRef.h"
146 #include "ControlSearch.h"
147 #include "ControlSendto.h"
148 #include "ControlShowFile.h"
149 #include "ControlSpellchecker.h"
150 #include "ControlTabularCreate.h"
151 #include "ControlTexinfo.h"
152 #include "ControlThesaurus.h"
153 #include "ControlToc.h"
154 #include "ControlUrl.h"
155 #include "ControlVCLog.h"
156
157
158 namespace { // anon
159
160 // I belive that this one is buggy (Lgb)
161 // But not if used correctly. (Lgb)
162 template <class T>
163 class GUISingleton {
164 public:
165         static
166         T & get(LyXView & lv, Dialogs & d) {
167                 static T t(lv, d);
168                 return t;
169         }
170 };
171
172
173 GUISingleton<GUI<ControlCharacter, FormCharacter,
174                  OkApplyCancelReadOnlyPolicy, xformsBC> >
175 controlCharacterSingleton;
176
177 GUISingleton<GUI<ControlCitation, FormCitation,
178                  NoRepeatedApplyReadOnlyPolicy, xformsBC> >
179 controlCitationSingleton;
180
181
182 GUISingleton<GUI<ControlERT, FormERT,
183                  NoRepeatedApplyReadOnlyPolicy, xformsBC> >
184 controlERTSingleton;
185
186 GUISingleton<GUI<ControlIndex, FormIndex,
187                  NoRepeatedApplyReadOnlyPolicy, xformsBC> >
188 controlIndexSingleton;
189
190 GUISingleton<GUI<ControlMinipage, FormMinipage,
191                  NoRepeatedApplyReadOnlyPolicy, xformsBC> >
192 controlMinipageSingleton;
193
194 GUISingleton<FormPreferences> formPreferencesSingleton;
195
196 GUISingleton<GUI<ControlRef, FormRef,
197                  NoRepeatedApplyReadOnlyPolicy, xformsBC> >
198 controlRefSingleton;
199
200 GUISingleton<FormTabular> formTabularSingleton;
201
202 GUISingleton<GUI<ControlToc, FormToc,
203                  OkCancelPolicy, xformsBC> >
204 controlTocSingleton;
205
206 GUISingleton<GUI<ControlUrl, FormUrl,
207                  NoRepeatedApplyReadOnlyPolicy, xformsBC> >
208 controlUrlSingleton;
209
210 } // anon
211
212
213 extern "C" {
214
215         void gui_ShowAboutlyx(LyXView & lv, Dialogs & d)
216         {
217                 static GUI<ControlAboutlyx, FormAboutlyx,
218                         OkCancelPolicy, xformsBC> cal(lv, d);
219                 cal.show();
220         }
221
222
223         void gui_ShowBibitem(InsetCommand * ic, LyXView & lv, Dialogs & d)
224         {
225                 static GUI<ControlBibitem, FormBibitem,
226                         OkCancelReadOnlyPolicy, xformsBC> cbi(lv, d);
227                 cbi.showInset(ic);
228         }
229
230
231         void gui_ShowBibtex(InsetCommand * ic, LyXView & lv, Dialogs & d)
232         {
233                 static GUI<ControlBibtex, FormBibtex,
234                         OkCancelReadOnlyPolicy, xformsBC> cbt(lv, d);
235                 cbt.showInset(ic);
236         }
237
238
239         void gui_ShowCharacter(LyXView & lv, Dialogs & d)
240         {
241                 controlCharacterSingleton.get(lv, d).show();
242         }
243
244
245         void gui_SetUserFreeFont(LyXView & lv, Dialogs & d)
246         {
247                 controlCharacterSingleton.get(lv, d).apply();
248         }
249
250
251         void gui_ShowCitation(InsetCommand * ic, LyXView & lv, Dialogs & d)
252         {
253                 controlCitationSingleton.get(lv, d).showInset(ic);
254         }
255
256
257         void gui_CreateCitation(string const & s, LyXView & lv, Dialogs & d)
258         {
259                 controlCitationSingleton.get(lv, d).createInset(s);
260         }
261
262
263         void gui_ShowDocument(LyXView & lv, Dialogs & d)
264         {
265                 static FormDocument fd(&lv, &d);
266                 fd.show();
267         }
268
269
270         void gui_ShowError(InsetError * ie, LyXView & lv, Dialogs & d)
271         {
272                 static GUI<ControlError, FormError,
273                         OkCancelPolicy, xformsBC> ce(lv, d);
274                 ce.showInset(ie);
275         }
276
277
278         void gui_ShowERT(InsetERT * ie, LyXView & lv, Dialogs & d)
279         {
280                 controlERTSingleton.get(lv, d).showInset(ie);
281         }
282
283
284         void gui_UpdateERT(InsetERT * ie, LyXView & lv, Dialogs & d)
285         {
286                 controlERTSingleton.get(lv, d).showInset(ie);
287         }
288
289
290         void gui_ShowExternal(InsetExternal * ie, LyXView & lv, Dialogs & d)
291         {
292                 static GUI<ControlExternal, FormExternal,
293                         OkApplyCancelReadOnlyPolicy, xformsBC> ce(lv, d);
294                 ce.showInset(ie);
295         }
296
297
298         void gui_ShowFile(string const & f, LyXView & lv, Dialogs & d)
299         {
300                 static GUI<ControlShowFile, FormShowFile,
301                         OkCancelPolicy, xformsBC> csf(lv, d);
302                 csf.showFile(f);
303         }
304
305
306         void gui_ShowFloat(InsetFloat * ifl, LyXView & lv, Dialogs & d)
307         {
308                 static GUI<ControlFloat, FormFloat,
309                         NoRepeatedApplyReadOnlyPolicy, xformsBC> cf(lv, d);
310                 cf.showInset(ifl);
311         }
312
313
314         void gui_ShowForks(LyXView & lv, Dialogs & d)
315         {
316                 static GUI<ControlForks, FormForks,
317                         OkApplyCancelPolicy, xformsBC> cf(lv, d);
318                 cf.show();
319         }
320
321
322         void gui_ShowGraphics(InsetGraphics * ig, LyXView & lv, Dialogs & d)
323         {
324                 static GUI<ControlGraphics, FormGraphics,
325                         NoRepeatedApplyReadOnlyPolicy, xformsBC> cg(lv, d);
326                 cg.showInset(ig);
327         }
328
329
330         void gui_ShowInclude(InsetInclude * ii, LyXView & lv, Dialogs & d)
331         {
332                 static GUI<ControlInclude, FormInclude,
333                         OkCancelReadOnlyPolicy, xformsBC> ci(lv, d);
334                 ci.showInset(ii);
335         }
336
337
338         void gui_ShowIndex(InsetCommand * ic, LyXView & lv, Dialogs & d)
339         {
340                 controlIndexSingleton.get(lv, d).showInset(ic);
341         }
342
343
344         void gui_CreateIndex(LyXView & lv, Dialogs & d)
345         {
346                 controlIndexSingleton.get(lv, d).createInset("");
347         }
348
349
350 #if 0
351         void gui_ShowInfo(InsetInfo *, LyXView & lv, Dialogs & d)
352         {
353         }
354 #endif
355
356
357         void gui_ShowLogFile(LyXView & lv, Dialogs & d)
358         {
359                 static GUI<ControlLog, FormLog,
360                         OkCancelPolicy, xformsBC> cl(lv, d);
361                 cl.show();
362         }
363
364
365         void gui_ShowMathPanel(LyXView & lv, Dialogs & d)
366         {
367                 static FormMathsPanel fmp(&lv, &d);
368                 fmp.show();
369         }
370
371
372         void gui_ShowMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
373         {
374                 controlMinipageSingleton.get(lv, d).showInset(im);
375         }
376
377
378         void gui_UpdateMinipage(InsetMinipage * im, LyXView & lv, Dialogs & d)
379         {
380                 controlMinipageSingleton.get(lv, d).showInset(im);
381         }
382
383
384         void gui_ShowParagraph(LyXView & lv, Dialogs & d)
385         {
386                 static GUI<ControlParagraph, FormParagraph,
387                         OkApplyCancelReadOnlyPolicy, xformsBC> cp(lv, d);
388                 cp.show();
389         }
390
391
392 #if 0
393         void gui_UpdateParagraph(LyXView & lv, Dialogs & d)
394         {
395 #warning FIXME!
396                 // This should be the same object as in gui_ShowParagraph
397                 static GUI<ControlParagraph, FormParagraph,
398                         OkApplyCancelReadOnlyPolicy, xformsBC> cp(lv, d);
399 #if 0
400                 cp.
401 #endif
402         }
403 #endif
404
405
406         void gui_ShowPreamble(LyXView & lv, Dialogs & d)
407         {
408                 static GUI<ControlPreamble, FormPreamble,
409                         NoRepeatedApplyReadOnlyPolicy, xformsBC> cp(lv, d);
410                 cp.show();
411         }
412
413
414         void gui_ShowPreferences(LyXView & lv, Dialogs & d)
415         {
416                 formPreferencesSingleton.get(lv, d).show();
417         }
418
419
420         void gui_ShowPrint(LyXView & lv, Dialogs & d)
421         {
422                 static GUI<ControlPrint, FormPrint,
423                         OkApplyCancelPolicy, xformsBC> cp(lv, d);
424                 cp.show();
425         }
426
427
428         void gui_ShowRef(InsetCommand * ic, LyXView & lv, Dialogs & d)
429         {
430                 controlRefSingleton.get(lv, d).showInset(ic);
431         }
432
433
434         void gui_CreateRef(string const & s, LyXView & lv, Dialogs & d)
435         {
436                 controlRefSingleton.get(lv, d).createInset(s);
437         }
438
439
440         void gui_ShowSearch(LyXView & lv, Dialogs & d)
441         {
442                 static GUI<ControlSearch, FormSearch,
443                         NoRepeatedApplyReadOnlyPolicy, xformsBC> cs(lv, d);
444                 cs.show();
445         }
446
447
448         void gui_ShowSendto(LyXView & lv, Dialogs & d)
449         {
450                 static GUI<ControlSendto, FormSendto,
451                         OkApplyCancelPolicy, xformsBC> cs(lv, d);
452                 cs.show();
453         }
454
455
456         void gui_ShowSpellchecker(LyXView & lv, Dialogs & d)
457         {
458                 static GUI<ControlSpellchecker, FormSpellchecker,
459                         NoRepeatedApplyReadOnlyPolicy, xformsBC> cp(lv, d);
460                 cp.show();
461         }
462
463
464         void gui_ShowSpellcheckerPreferences(LyXView & lv, Dialogs & d)
465         {
466                 formPreferencesSingleton.get(lv, d).showSpellPref();
467         }
468
469
470         void gui_ShowTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
471         {
472                 formTabularSingleton.get(lv, d).showInset(it);
473         }
474
475
476         void gui_UpdateTabular(InsetTabular * it, LyXView & lv, Dialogs & d)
477         {
478                 formTabularSingleton.get(lv, d).updateInset(it);
479         }
480
481
482         void gui_ShowTabularCreate(LyXView & lv, Dialogs & d)
483         {
484                 static GUI<ControlTabularCreate, FormTabularCreate,
485                         OkApplyCancelReadOnlyPolicy, xformsBC> ctc(lv, d);
486                 ctc.show();
487         }
488
489
490         void gui_ShowTexinfo(LyXView & lv, Dialogs & d)
491         {
492                 static GUI<ControlTexinfo, FormTexinfo,
493                         OkCancelPolicy, xformsBC> ct(lv, d);
494                 ct.show();
495         }
496
497
498         void gui_ShowThesaurus(string const & s, LyXView & lv, Dialogs & d)
499         {
500 #ifdef HAVE_LIBAIKSAURUS
501                 static GUI<ControlThesaurus, FormThesaurus,
502                         OkApplyCancelReadOnlyPolicy, xformsBC> ct(lv, d);
503                 ct.showEntry(s);
504 #endif
505         }
506
507
508         void gui_ShowTOC(InsetCommand * ic, LyXView & lv, Dialogs & d)
509         {
510                 controlTocSingleton.get(lv, d).showInset(ic);
511         }
512
513
514         void gui_CreateTOC(string const & s, LyXView & lv, Dialogs & d)
515         {
516                 controlTocSingleton.get(lv, d).createInset(s);
517         }
518
519
520         void gui_ShowUrl(InsetCommand * ic, LyXView & lv, Dialogs & d)
521         {
522                 controlUrlSingleton.get(lv, d).showInset(ic);
523         }
524
525
526         void gui_CreateUrl(string const & s, LyXView & lv, Dialogs & d)
527         {
528                 controlUrlSingleton.get(lv, d).createInset(s);
529         }
530
531
532         void gui_ShowVCLogFile(LyXView & lv, Dialogs & d)
533         {
534                 static GUI<ControlVCLog, FormVCLog,
535                         OkCancelPolicy, xformsBC> cv(lv, d);
536                 cv.show();
537         }
538
539 } // extern "C"