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