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