1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995-2001 The LyX Team.
8 * ======================================================
14 #pragma implementation
22 #include "ControlSplash.h"
23 #include "ControlBibitem.h"
24 #include "ControlBibtex.h"
25 #include "ControlCharacter.h"
26 #include "ControlCitation.h"
27 #include "ControlError.h"
28 #include "ControlInclude.h"
29 #include "ControlLog.h"
30 #include "ControlUrl.h"
31 #include "ControlVCLog.h"
32 #include "ControlTabularCreate.h"
36 #include "FormError.h"
37 #include "FormTabularCreate.h"
39 #include "FormBibitem.h"
40 #include "FormBibtex.h"
41 #include "FormCharacter.h"
42 #include "FormCitation.h"
44 #include "FormVCLog.h"
46 #include "FormDocument.h"
47 #include "FormExternal.h"
48 #include "FormGraphics.h"
49 #include "FormInclude.h"
50 #include "FormIndex.h"
51 #include "FormMathsPanel.h"
52 #include "FormParagraph.h"
53 #include "FormPreamble.h"
54 #include "FormPreferences.h"
55 #include "FormPrint.h"
57 #include "FormSearch.h"
58 #include "FormSplash.h"
59 #include "FormTabular.h"
60 #include "FormTabularCreate.h"
63 #include "FormMinipage.h"
66 // Signal enabling all visible dialogs to be redrawn if so desired.
67 // E.g., when the GUI colours have been remapped.
68 SigC::Signal0<void> Dialogs::redrawGUI;
70 Dialogs::Dialogs(LyXView * lv)
72 add(new GUIUrl<FormUrl, gnomeBC>(*lv, *this));
73 add(new GUIError<FormError, gnomeBC>(*lv, *this));
74 add(new GUITabularCreate<FormTabularCreate, gnomeBC>(*lv, *this));
77 splash_.reset(new FormSplash(lv, this));
79 add(new GUIBibitem<FormBibitem, xformsBC>(*lv, *this));
80 add(new GUIBibtex<FormBibtex, xformsBC>(*lv, *this));
81 add(new GUICharacter<FormCharacter, xformsBC>(*lv, *this));
82 //add(new GUICitation<FormCitation, xformsBC>(*lv, *this));
83 add(new GUILog<FormLog, xformsBC>(*lv, *this));
84 add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
86 // For now we use the gnome non MVC dialogs
87 add(new FormCitation(lv, this));
89 add(new FormDocument(lv, this));
90 add(new FormExternal(lv, this));
91 add(new FormGraphics(lv, this));
92 add(new FormInclude(lv, this));
93 add(new FormIndex(lv, this));
94 add(new FormMathsPanel(lv, this));
95 add(new FormParagraph(lv, this));
96 add(new FormPreamble(lv, this));
97 add(new FormPreferences(lv, this));
98 add(new FormPrint(lv, this));
99 add(new FormRef(lv, this));
100 add(new FormSearch(lv, this));
101 add(new FormSplash(lv, this));
102 add(new FormTabular(lv, this));
103 add(new FormTabularCreate(lv, this));
104 add(new FormToc(lv, this));
105 add(new FormUrl(lv, this));
106 add(new FormMinipage(lv, this));
109 // reduce the number of connections needed in
110 // dialogs by a simple connection here.
111 hideAll.connect(hideBufferDependent.slot());
114 /*****************************************************************************
116 Q. WHY does Dialogs::Dialogs pass `this' to dialog constructors?
118 A. To avoid a segfault.
119 The dialog constructors need to connect to their
120 respective showSomeDialog signal(*) but in order to do
121 that they need to get the address of the Dialogs instance
122 from LyXView::getDialogs(). However, since the Dialogs
123 instance is still being constructed at that time
124 LyXView::getDialogs() will *not* return the correct
125 address because it hasn't finished being constructed.
126 A Catch-22 situation (or is that the chicken and the egg...).
127 So to get around the problem we pass the address of
128 the newly created Dialogs instance using `this'.
130 (*) -- I'm using signals exclusively to guarantee that the gui code
131 remains hidden from the rest of the system. In fact the only
132 header related to dialogs that anything in the non-gui-specific
133 code gets to see is Dialogs.h! Even Dialogs.h doesn't know what a
134 FormCopyright class looks like or that its even going to be used!
136 No other gui dialog headers are seen outside of the gui-specific
137 directories! This ensures that the gui is completely separate from
138 the rest of LyX. All this through the use of a few simple signals.
139 BUT, the price is that during construction we need to connect the
140 implementations show() method to the showSomeDialog signal and this
141 requires that we have an instance of Dialogs and the problem mentioned
144 Almost all other dialogs should be able to operate using the same style
145 of signalling used for Copyright. Exceptions should be handled
146 by adding a specific show or update signal. For example, spellchecker
147 needs to set the next suspect word and its options/replacements so we
149 Signal0<void> updateSpellChecker;
151 Since we would have to have a
152 Signal0<void> showSpellChecker;
154 in order to just see the spellchecker and let the user push the [Start]
155 button then the updateSpellChecker signal will make the SpellChecker
156 dialog get the new word and replacements list from LyX. If you really,
157 really wanted to you could define a signal that would pass the new
158 word and replacements:
159 Signal2<void, string, vector<string> > updateSpellChecker;
161 (or something similar) but, why bother when the spellchecker can get
162 it anyway with a LyXFunc call or two. Besides if someone extends
163 what a dialog does then they also have to change code in the rest of
164 LyX to pass more parameters or get the extra info via a function
165 call anyway. Thus reducing the independence of the two code bases.
167 We don't need a separate update signal for each dialog because most of
168 them will be changed only when the buffer is changed (either by closing
169 the current open buffer or switching to another buffer in the current
170 LyXView -- different BufferView same LyXView or same BufferView same
173 So we minimise signals but maximise independence and programming
174 simplicity, understandability and maintainability. It's also
175 extremely easy to add support for Qt or gtk-- because they use
176 signals already. Guis that use callbacks, like xforms, must have their
177 code wrapped up like that in the form_copyright.[Ch] which is awkward
178 but will at least allow multiple instances of the same dialog.
180 Signals will also be a great help in controlling the splashscreen --
181 once signalled to hide it can disconnect from the signal and remove
184 LyXFuncs will be used for requesting/setting LyX internal info. This
185 will ensure that scripts or LyXServer-connected applications can all
186 have access to the same calls as the internal user-interface.
188 ******************************************************************************/