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
23 #include "combox.h" // needed for clean destruction of boost::scoped_ptr
24 #include "form_aboutlyx.h"
25 #include "form_bibitem.h"
26 #include "form_bibtex.h"
27 #include "form_browser.h"
28 #include "form_character.h"
29 #include "form_citation.h"
30 #include "form_error.h"
32 #include "form_external.h"
33 #include "form_float.h"
34 #include "form_forks.h"
35 #include "form_graphics.h"
36 #include "form_include.h"
37 #include "form_index.h"
38 #include "form_minipage.h"
39 #include "form_preamble.h"
40 #include "form_print.h"
42 #include "form_search.h"
43 #include "form_spellchecker.h"
44 #include "form_tabular_create.h"
45 #include "form_texinfo.h"
46 #include "form_thesaurus.h"
50 #include "FormAboutlyx.h"
51 #include "FormBibitem.h"
52 #include "FormBibtex.h"
53 #include "FormCharacter.h"
54 #include "FormCitation.h"
55 #include "FormError.h"
57 #include "FormExternal.h"
58 #include "FormFloat.h"
59 #include "FormForks.h"
60 #include "FormGraphics.h"
61 #include "FormInclude.h"
62 #include "FormIndex.h"
64 #include "FormMinipage.h"
65 #include "FormPreamble.h"
66 #include "FormPrint.h"
68 #include "FormSearch.h"
69 #include "FormShowFile.h"
70 #include "FormSpellchecker.h"
71 #include "FormTabularCreate.h"
72 #include "FormTexinfo.h"
73 #include "FormThesaurus.h"
76 #include "FormVCLog.h"
78 #include "FormDocument.h"
79 #include "FormMathsPanel.h"
80 #include "FormParagraph.h"
81 #include "FormPreferences.h"
82 #include "FormTabular.h"
84 // Signal enabling all visible dialogs to be redrawn if so desired.
85 // E.g., when the GUI colours have been remapped.
86 SigC::Signal0<void> Dialogs::redrawGUI;
88 Dialogs::Dialogs(LyXView * lv)
90 add(new GUIAboutlyx<FormAboutlyx, xformsBC>(*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 GUIError<FormError, xformsBC>(*lv, *this));
96 add(new GUIERT<FormERT, xformsBC>(*lv, *this));
97 add(new GUIExternal<FormExternal, xformsBC>(*lv, *this));
98 add(new GUIForks<FormForks, xformsBC>(*lv, *this));
99 add(new GUIGraphics<FormGraphics, xformsBC>(*lv, *this));
100 add(new GUIInclude<FormInclude, xformsBC>(*lv, *this));
101 add(new GUIIndex<FormIndex, xformsBC>(*lv, *this));
102 add(new GUILog<FormLog, xformsBC>(*lv, *this));
103 add(new GUIMinipage<FormMinipage, xformsBC>(*lv, *this));
104 add(new GUIFloat<FormFloat, xformsBC>(*lv, *this));
105 add(new GUIPreamble<FormPreamble, xformsBC>(*lv, *this));
106 add(new GUIPrint<FormPrint, xformsBC>(*lv, *this));
107 add(new GUIRef<FormRef, xformsBC>(*lv, *this));
108 add(new GUISearch<FormSearch, xformsBC>(*lv, *this));
109 add(new GUIShowFile<FormShowFile, xformsBC>(*lv, *this));
110 add(new GUISpellchecker<FormSpellchecker, xformsBC>(*lv, *this));
111 add(new GUITabularCreate<FormTabularCreate, xformsBC>(*lv, *this));
112 #ifdef HAVE_LIBAIKSAURUS
113 add(new GUIThesaurus<FormThesaurus, xformsBC>(*lv, *this));
115 add(new GUITexinfo<FormTexinfo, xformsBC>(*lv, *this));
116 add(new GUIToc<FormToc, xformsBC>(*lv, *this));
117 add(new GUIUrl<FormUrl, xformsBC>(*lv, *this));
118 add(new GUIVCLog<FormVCLog, xformsBC>(*lv, *this));
120 add(new FormDocument(lv, this));
121 add(new FormMathsPanel(lv, this));
122 add(new FormParagraph(lv, this));
123 add(new FormPreferences(lv, this));
124 add(new FormTabular(lv, this));
126 // reduce the number of connections needed in
127 // dialogs by a simple connection here.
128 hideAll.connect(hideBufferDependent.slot());
131 // Called bu the graphics cache to connect the approriate frontend
132 // image loading routines to the LyX kernel.
133 void Dialogs::initialiseGraphics()
137 /*****************************************************************************
139 Q. WHY does Dialogs::Dialogs pass `this' to dialog constructors?
141 A. To avoid a segfault.
142 The dialog constructors need to connect to their
143 respective showSomeDialog signal(*) but in order to do
144 that they need to get the address of the Dialogs instance
145 from LyXView::getDialogs(). However, since the Dialogs
146 instance is still being constructed at that time
147 LyXView::getDialogs() will *not* return the correct
148 address because it hasn't finished being constructed.
149 A Catch-22 situation (or is that the chicken and the egg...).
150 So to get around the problem we pass the address of
151 the newly created Dialogs instance using `this'.
153 (*) -- I'm using signals exclusively to guarantee that the gui code
154 remains hidden from the rest of the system. In fact the only
155 header related to dialogs that anything in the non-gui-specific
156 code gets to see is Dialogs.h! Even Dialogs.h doesn't know what a
157 FormCopyright class looks like or that its even going to be used!
159 No other gui dialog headers are seen outside of the gui-specific
160 directories! This ensures that the gui is completely separate from
161 the rest of LyX. All this through the use of a few simple signals.
162 BUT, the price is that during construction we need to connect the
163 implementations show() method to the showSomeDialog signal and this
164 requires that we have an instance of Dialogs and the problem mentioned
167 Almost all other dialogs should be able to operate using the same style
168 of signalling used for Copyright. Exceptions should be handled
169 by adding a specific show or update signal. For example, spellchecker
170 needs to set the next suspect word and its options/replacements so we
172 Signal0<void> updateSpellChecker;
174 Since we would have to have a
175 Signal0<void> showSpellChecker;
177 in order to just see the spellchecker and let the user push the [Start]
178 button then the updateSpellChecker signal will make the SpellChecker
179 dialog get the new word and replacements list from LyX. If you really,
180 really wanted to you could define a signal that would pass the new
181 word and replacements:
182 Signal2<void, string, vector<string> > updateSpellChecker;
184 (or something similar) but, why bother when the spellchecker can get
185 it anyway with a LyXFunc call or two. Besides if someone extends
186 what a dialog does then they also have to change code in the rest of
187 LyX to pass more parameters or get the extra info via a function
188 call anyway. Thus reducing the independence of the two code bases.
190 We don't need a separate update signal for each dialog because most of
191 them will be changed only when the buffer is changed (either by closing
192 the current open buffer or switching to another buffer in the current
193 LyXView -- different BufferView same LyXView or same BufferView same
196 So we minimise signals but maximise independence and programming
197 simplicity, understandability and maintainability. It's also
198 extremely easy to add support for Qt or gtk-- because they use
199 signals already. Guis that use callbacks, like xforms, must have their
200 code wrapped up like that in the form_copyright.[Ch] which is awkward
201 but will at least allow multiple instances of the same dialog.
203 LyXFuncs will be used for requesting/setting LyX internal info. This
204 will ensure that scripts or LyXServer-connected applications can all
205 have access to the same calls as the internal user-interface.
207 ******************************************************************************/