]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlConnections.h
Controller-view split of Graphics and Index popups.
[lyx.git] / src / frontends / controllers / ControlConnections.h
1 /* This file is part of
2  * ====================================================== 
3  *
4  *           LyX, The Document Processor
5  *
6  *           Copyright 2001 The LyX Team.
7  *
8  * ======================================================
9  *
10  * \file ControlConnections.h
11  * \author Angus Leeming <a.leeming@ic.ac.uk>
12  *
13  * ControlConnections.h contains the definition of three controller classes,
14  * ControlConnectBase, ControlConnectBI and ControlConnectBD.
15  *
16  * Together they control the connection/disconnection of signals with the LyX
17  * kernel. Controllers of individual popups interacting with the kernel through
18  * signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
19  *
20  * A popup is classed as "Buffer Dependent" if its contents change with the
21  * buffer (document). An example would be the Citation popup. Such a popup
22  * would be derived, therefore, from ControlConnectBD.
23  *
24  * Conversely, a popup is "Buffer Independent" if its contents do not change
25  * when the buffer changes. An example would be the Copyright popup. Such a
26  * popup, is therefore derived from ControlConnectBI.
27  *
28  */
29
30 #ifndef CONTROLCONNECTIONS_H
31 #define CONTROLCONNECTIONS_H
32
33 #ifdef __GNUG__
34 #pragma interface
35 #endif
36
37 #include "ControlBase.h"
38
39 class Dialogs;
40 class LyXView;
41
42 /** Base class to control connection/disconnection of signals with the LyX
43     kernel. It is meant to be used solely as the parent class to
44     ControlConnectBI and ControlConnectBD.
45 */
46 class ControlConnectBase : public ControlBase
47 {
48 public:
49         ///
50         enum DocTypes {
51                 ///
52                 LATEX,
53                 ///
54                 LITERATE,
55                 ///
56                 LINUXDOC,
57                 ///
58                 DOCBOOK
59         };
60         ///
61         ControlConnectBase(LyXView &, Dialogs &);
62         /// The View may need to know if the buffer is read-only.
63         bool isReadonly() const;
64         /// 
65         DocTypes docType() const;
66
67 protected:
68         /// True if the dialog depends on the buffer, else false.
69         virtual bool isBufferDependent() const = 0;
70
71         /// Connect signals
72         virtual void connect();
73         /// Disconnect signals
74         virtual void disconnect();
75
76         /** Redraw the dialog (on receipt of a Signal indicating, for example,
77             its colors have been re-mapped).
78         */
79         void redraw();
80
81         /// Get at the kernel Dispatch methods we need to apply() parameters.
82         LyXView & lv_;
83         /// Contains the signals we have to connect to.
84         Dialogs & d_;
85         /// Hide connection.
86         SigC::Connection h_;
87         /// Redraw connection.
88         SigC::Connection r_;
89 };
90
91
92 /** Base class to control connection/disconnection of signals with the LyX
93     kernel for Buffer Independent dialogs.
94     Such dialogs do not require an update Connection although they may use
95     an update() function which is also supported by the Restore button.
96  */
97
98 class ControlConnectBI : public ControlConnectBase
99 {
100 public:
101         ///
102         ControlConnectBI(LyXView &, Dialogs &);
103
104 protected:
105         ///
106         virtual bool isBufferDependent() const { return false; }
107         /// Connect signals
108         virtual void connect();
109 };
110
111
112 /** Base class to control connection/disconnection of signals with the LyX
113     kernel for Buffer Dependent dialogs.
114  */
115 class ControlConnectBD : public ControlConnectBase
116 {
117 public:
118         ///
119         ControlConnectBD(LyXView &, Dialogs &);
120
121 protected:
122         ///
123         virtual bool isBufferDependent() const { return true; }
124         /// Connect signals
125         virtual void connect();
126         /// Disconnect signals
127         virtual void disconnect();
128
129 private:
130         /** Slot connected to update signal.
131             Bool indicates if a buffer switch took place.
132             Default behaviour is to ignore this and simply update().
133         */
134         virtual void updateSlot(bool) { update(); }
135         /// Update connection.
136         SigC::Connection u_;
137 };
138
139 #endif // CONTROLCONNECTIONS_H