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