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