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