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