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