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