]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/Dialogs.C
Add fl_set_input_return to input_paperoption.
[lyx.git] / src / frontends / xforms / Dialogs.C
1 /* This file is part of
2  * ======================================================
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 1995 Matthias Ettrich
7  *           Copyright 1995-2001 The LyX Team.
8  *
9  * ======================================================
10  */
11
12 #include <config.h>
13
14 #ifdef __GNUG__
15 #pragma implementation
16 #endif
17
18 #include "Dialogs.h"
19 #include "BufferView.h"
20
21 #include "xformsBC.h"
22
23 #include "ControlAboutlyx.h"
24 #include "ControlBibitem.h"
25 #include "ControlBibtex.h"
26 #include "ControlCharacter.h"
27 #include "ControlCitation.h"
28 #include "ControlError.h"
29 #include "ControlERT.h"
30 #include "ControlExternal.h"
31 #include "ControlFloat.h"
32 #include "ControlGraphics.h"
33 #include "insets/insetgraphicsParams.h"
34 #include "ControlInclude.h"
35 #include "ControlIndex.h"
36 #include "ControlLog.h"
37 #include "ControlMinipage.h"
38 #include "ControlPreamble.h"
39 #include "ControlPrint.h"
40 #include "ControlRef.h"
41 #include "ControlSearch.h"
42 #include "ControlSpellchecker.h"
43 #include "ControlSplash.h"
44 #include "ControlTabularCreate.h"
45 #include "ControlThesaurus.h"
46 #include "ControlToc.h"
47 #include "ControlUrl.h"
48 #include "ControlVCLog.h"
49
50 #include "GUI.h"
51
52 #include "combox.h"       // needed for clean destruction of boost::scoped_ptr
53 #include "form_aboutlyx.h"
54 #include "form_bibitem.h"
55 #include "form_bibtex.h"
56 #include "form_browser.h"
57 #include "form_character.h"
58 #include "form_citation.h"
59 #include "form_error.h"
60 #include "form_ert.h"
61 #include "form_external.h"
62 #include "form_float.h"
63 #include "form_graphics.h"
64 #include "form_include.h"
65 #include "form_index.h"
66 #include "form_minipage.h"
67 #include "form_preamble.h"
68 #include "form_print.h"
69 #include "form_ref.h"
70 #include "form_search.h"
71 #include "form_spellchecker.h"
72 #include "form_splash.h"
73 #include "form_tabular_create.h"
74 #include "form_thesaurus.h"
75 #include "form_toc.h"
76 #include "form_url.h"
77
78 #include "FormAboutlyx.h"
79 #include "FormBibitem.h"
80 #include "FormBibtex.h"
81 #include "FormCharacter.h"
82 #include "FormCitation.h"
83 #include "FormError.h"
84 #include "FormERT.h"
85 #include "FormExternal.h"
86 #include "FormFloat.h"
87 #include "FormGraphics.h"
88 #include "FormInclude.h"
89 #include "FormIndex.h"
90 #include "FormLog.h"
91 #include "FormMinipage.h"
92 #include "FormPreamble.h"
93 #include "FormPrint.h"
94 #include "FormRef.h"
95 #include "FormSearch.h"
96 #include "FormSpellchecker.h"
97 #include "FormSplash.h"
98 #include "FormTabularCreate.h"
99 #include "FormThesaurus.h" 
100 #include "FormToc.h"
101 #include "FormUrl.h"
102 #include "FormVCLog.h"
103
104 #include "FormDocument.h"
105 #include "FormMathsPanel.h"
106 #include "FormParagraph.h"
107 #include "FormPreferences.h"
108 #include "FormTabular.h"
109
110 // Signal enabling all visible dialogs to be redrawn if so desired.
111 // E.g., when the GUI colours have been remapped.
112 SigC::Signal0<void> Dialogs::redrawGUI;
113
114 Dialogs::Dialogs(LyXView * lv)
115 {
116         splash_.reset(new GUISplash<FormSplash>(*this));
117
118         add(new GUIAboutlyx<FormAboutlyx, xformsBC>(*lv, *this));
119         add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
120         add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
121         add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
122         add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
123         add(new GUIError<FormError, xformsBC>(*lv, *this));
124         add(new GUIERT<FormERT, xformsBC>(*lv, *this));
125         add(new GUIExternal<FormExternal, xformsBC>(*lv, *this));
126         add(new GUIGraphics<FormGraphics, xformsBC>(*lv, *this));
127         add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
128         add(new GUIIndex<FormIndex, xformsBC>(*lv, *this));
129         add(new GUILog<FormLog, xformsBC>(*lv, *this));
130         add(new GUIMinipage<FormMinipage, xformsBC>(*lv, *this));
131         add(new GUIFloat<FormFloat, xformsBC>(*lv, *this));
132         add(new GUIPreamble<FormPreamble, xformsBC>(*lv, *this));
133         add(new GUIPrint<FormPrint, xformsBC>(*lv, *this));
134         add(new GUIRef<FormRef, xformsBC>(*lv, *this));
135         add(new GUISearch<FormSearch, xformsBC>(*lv, *this));
136         add(new GUISpellchecker<FormSpellchecker, xformsBC>(*lv, *this));
137         add(new GUITabularCreate<FormTabularCreate, xformsBC>(*lv, *this));
138 #ifdef HAVE_LIBAIKSAURUS
139         add(new GUIThesaurus<FormThesaurus, xformsBC>(*lv, *this));
140 #endif
141         add(new GUIToc<FormToc, xformsBC>(*lv, *this));
142         add(new GUIUrl<FormUrl, xformsBC>(*lv, *this));
143         add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
144
145         add(new FormDocument(lv, this));
146         add(new FormMathsPanel(lv, this));
147         add(new FormParagraph(lv, this));
148         add(new FormPreferences(lv, this));
149         add(new FormTabular(lv, this));
150         
151         // reduce the number of connections needed in
152         // dialogs by a simple connection here.
153         hideAll.connect(hideBufferDependent.slot());
154 }
155
156 /*****************************************************************************
157
158 Q.  WHY does Dialogs::Dialogs pass `this' to dialog constructors?
159
160 A.  To avoid a segfault.
161     The dialog constructors need to connect to their
162     respective showSomeDialog signal(*) but in order to do
163     that they need to get the address of the Dialogs instance
164     from LyXView::getDialogs().  However, since the Dialogs
165     instance is still being constructed at that time
166     LyXView::getDialogs() will *not* return the correct
167     address because it hasn't finished being constructed.
168     A Catch-22 situation (or is that the chicken and the egg...).
169     So to get around the problem we pass the address of
170     the newly created Dialogs instance using `this'.
171
172 (*) -- I'm using signals exclusively to guarantee that the gui code
173        remains hidden from the rest of the system.  In fact the only 
174        header related to dialogs that anything in the non-gui-specific
175        code gets to see is Dialogs.h!  Even Dialogs.h doesn't know what a 
176        FormCopyright class looks like or that its even going to be used!
177
178        No other gui dialog headers are seen outside of the gui-specific
179        directories!  This ensures that the gui is completely separate from
180        the rest of LyX.  All this through the use of a few simple signals.
181        BUT, the price is that during construction we need to connect the
182        implementations show() method to the showSomeDialog signal and this
183        requires that we have an instance of Dialogs and the problem mentioned
184        above.
185
186        Almost all other dialogs should be able to operate using the same style
187        of signalling used for Copyright.  Exceptions should be handled
188        by adding a specific show or update signal.  For example, spellchecker
189        needs to set the next suspect word and its options/replacements so we
190        need a:
191                  Signal0<void> updateSpellChecker;
192
193        Since we would have to have a
194                  Signal0<void> showSpellChecker;
195
196        in order to just see the spellchecker and let the user push the [Start]
197        button then the updateSpellChecker signal will make the SpellChecker
198        dialog get the new word and replacements list from LyX.  If you really,
199        really wanted to you could define a signal that would pass the new
200        word and replacements:
201                  Signal2<void, string, vector<string> > updateSpellChecker;
202
203        (or something similar) but, why bother when the spellchecker can get
204        it anyway with a LyXFunc call or two.  Besides if someone extends
205        what a dialog does then they also have to change code in the rest of 
206        LyX to pass more parameters or get the extra info via a function 
207        call anyway.  Thus reducing the independence of the two code bases.
208
209        We don't need a separate update signal for each dialog because most of 
210        them will be changed only when the buffer is changed (either by closing
211        the current open buffer or switching to another buffer in the current
212        LyXView -- different BufferView same LyXView or same BufferView same
213        LyXView).
214
215        So we minimise signals but maximise independence and programming 
216        simplicity, understandability and maintainability.  It's also
217        extremely easy to add support for Qt or gtk-- because they use
218        signals already. Guis that use callbacks, like xforms, must have their
219        code wrapped up like that in the form_copyright.[Ch] which is awkward
220        but will at least allow multiple instances of the same dialog.
221
222        Signals will also be a great help in controlling the splashscreen --
223        once signalled to hide it can disconnect from the signal and remove
224        itself from memory.
225
226        LyXFuncs will be used for requesting/setting LyX internal info.  This
227        will ensure that scripts or LyXServer-connected applications can all
228        have access to the same calls as the internal user-interface.
229
230 ******************************************************************************/