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