]> git.lyx.org Git - features.git/blob - src/frontends/xforms/Dialogs.C
Compile fixes for DEC cxx, John's maths and keymap patches.
[features.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-2000 The LyX Team.
8  *
9  * ======================================================
10  */
11
12 #include <config.h>
13 #include FORMS_H_LOCATION
14
15 #ifdef __GNUG__
16 #pragma implementation
17 #endif
18
19 #include "Dialogs.h"
20
21 #include "ControlBibitem.h"
22 #include "ControlCitation.h"
23 #include "xformsBC.h"
24
25 #include "FormBibitem.h"
26 #include "FormBibtex.h"
27 #include "FormCitation.h"
28 #include "FormCharacter.h"
29 #include "FormCopyright.h"
30 #include "FormCredits.h"
31 #include "FormDocument.h"
32 #include "FormError.h"
33 #include "FormExternal.h" 
34 #include "FormGraphics.h"
35 #include "FormInclude.h"
36 #include "FormIndex.h"
37 #include "FormLog.h"
38 #include "FormMaths.h"
39 #include "FormParagraph.h"
40 #include "FormPreamble.h"
41 #include "FormPreferences.h"
42 #include "FormPrint.h"
43 #include "FormRef.h"
44 #include "FormSearch.h"
45 #include "FormSplash.h"
46 #include "FormTabular.h"
47 #include "FormTabularCreate.h"
48 #include "FormToc.h"
49 #include "FormUrl.h"
50 #include "FormVCLog.h"
51
52 // Signal enabling all visible popups to be redrawn if so desired.
53 // E.g., when the GUI colours have been remapped.
54 SigC::Signal0<void> Dialogs::redrawGUI;
55
56 Dialogs::Dialogs(LyXView * lv)
57 {
58         splash_.reset(new FormSplash(lv, this));
59
60         add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
61         add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
62
63         add(new FormBibtex(lv, this));
64         add(new FormCharacter(lv, this));
65         add(new FormCopyright(lv, this));
66         add(new FormCredits(lv, this));
67         add(new FormDocument(lv, this));
68         add(new FormError(lv, this));
69         add(new FormExternal(lv, this));
70         add(new FormGraphics(lv, this));
71         add(new FormInclude(lv, this));
72         add(new FormIndex(lv, this));
73         add(new FormLog(lv, this));
74         add(new FormMaths(lv, this));
75         add(new FormParagraph(lv, this));
76         add(new FormPreamble(lv, this));
77         add(new FormPreferences(lv, this));
78         add(new FormPrint(lv, this));
79         add(new FormRef(lv, this));
80         add(new FormSearch(lv, this));
81         add(new FormSplash(lv, this));
82         add(new FormTabular(lv, this));
83         add(new FormTabularCreate(lv, this));
84         add(new FormToc(lv, this));
85         add(new FormUrl(lv, this));
86         add(new FormVCLog(lv, this));
87         
88         // reduce the number of connections needed in
89         // dialogs by a simple connection here.
90         hideAll.connect(hideBufferDependent.slot());
91 }
92
93 /*****************************************************************************
94
95 Q.  WHY does Dialogs::Dialogs pass `this' to dialog constructors?
96
97 A.  To avoid a segfault.
98     The dialog constructors need to connect to their
99     respective showSomeDialog signal(*) but in order to do
100     that they need to get the address of the Dialogs instance
101     from LyXView::getDialogs().  However, since the Dialogs
102     instance is still being constructed at that time
103     LyXView::getDialogs() will *not* return the correct
104     address because it hasn't finished being constructed.
105     A Catch-22 situation (or is that the chicken and the egg...).
106     So to get around the problem we pass the address of
107     the newly created Dialogs instance using `this'.
108
109 (*) -- I'm using signals exclusively to guarantee that the gui code
110        remains hidden from the rest of the system.  In fact the only 
111        header related to dialogs that anything in the non-gui-specific
112        code gets to see is Dialogs.h!  Even Dialogs.h doesn't know what a 
113        FormCopyright class looks like or that its even going to be used!
114
115        No other gui dialog headers are seen outside of the gui-specific
116        directories!  This ensures that the gui is completely separate from
117        the rest of LyX.  All this through the use of a few simple signals.
118        BUT, the price is that during construction we need to connect the
119        implementations show() method to the showSomeDialog signal and this
120        requires that we have an instance of Dialogs and the problem mentioned
121        above.
122
123        Almost all other dialogs should be able to operate using the same style
124        of signalling used for Copyright.  Exceptions should be handled
125        by adding a specific show or update signal.  For example, spellchecker
126        needs to set the next suspect word and its options/replacements so we
127        need a:
128                  Signal0<void> updateSpellChecker;
129
130        Since we would have to have a
131                  Signal0<void> showSpellChecker;
132
133        in order to just see the spellchecker and let the user push the [Start]
134        button then the updateSpellChecker signal will make the SpellChecker
135        dialog get the new word and replacements list from LyX.  If you really,
136        really wanted to you could define a signal that would pass the new
137        word and replacements:
138                  Signal2<void, string, vector<string> > updateSpellChecker;
139
140        (or something similar) but, why bother when the spellchecker can get
141        it anyway with a LyXFunc call or two.  Besides if someone extends
142        what a dialog does then they also have to change code in the rest of 
143        LyX to pass more parameters or get the extra info via a function 
144        call anyway.  Thus reducing the independence of the two code bases.
145
146        We don't need a separate update signal for each dialog because most of 
147        them will be changed only when the buffer is changed (either by closing
148        the current open buffer or switching to another buffer in the current
149        LyXView -- different BufferView same LyXView or same BufferView same
150        LyXView).
151
152        So we minimise signals but maximise independence and programming 
153        simplicity, understandability and maintainability.  It's also
154        extremely easy to add support for Qt or gtk-- because they use
155        signals already. Guis that use callbacks, like xforms, must have their
156        code wrapped up like that in the form_copyright.[Ch] which is awkward
157        but will at least allow multiple instances of the same dialog.
158
159        Signals will also be a great help in controlling the splashscreen --
160        once signalled to hide it can disconnect from the signal and remove
161        itself from memory.
162
163        LyXFuncs will be used for requesting/setting LyX internal info.  This
164        will ensure that scripts or LyXServer-connected applications can all
165        have access to the same calls as the internal user-interface.
166
167 ******************************************************************************/