]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlConnections.h
add Lsstream.h
[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         ControlConnectBase(LyXView &, Dialogs &);
51         /// The View may need to know if the buffer is read-only.
52         bool isReadonly() const;
53
54 protected:
55         /// True if the dialog depends on the buffer, else false.
56         virtual bool isBufferDependent() const = 0;
57
58         /// Connect signals
59         virtual void connect();
60         /// Disconnect signals
61         virtual void disconnect();
62
63         /** Redraw the dialog (on receipt of a Signal indicating, for example,
64             its colors have been re-mapped).
65         */
66         void redraw();
67
68         /// Get at the kernel Dispatch methods we need to apply() parameters.
69         LyXView & lv_;
70         /// Contains the signals we have to connect to.
71         Dialogs & d_;
72         /// Hide connection.
73         SigC::Connection h_;
74         /// Redraw connection.
75         SigC::Connection r_;
76 };
77
78
79 /** Base class to control connection/disconnection of signals with the LyX
80     kernel for Buffer Independent dialogs.
81     Such dialogs do not require an update Connection although they may use
82     an update() function which is also supported by the Restore button.
83  */
84
85 class ControlConnectBI : public ControlConnectBase
86 {
87 public:
88         ///
89         ControlConnectBI(LyXView &, Dialogs &);
90
91 protected:
92         ///
93         virtual bool isBufferDependent() const { return false; }
94         /// Connect signals
95         virtual void connect();
96 };
97
98
99 /** Base class to control connection/disconnection of signals with the LyX
100     kernel for Buffer Dependent dialogs.
101  */
102 class ControlConnectBD : public ControlConnectBase
103 {
104 public:
105         ///
106         ControlConnectBD(LyXView &, Dialogs &);
107
108 protected:
109         ///
110         virtual bool isBufferDependent() const { return true; }
111         /// Connect signals
112         virtual void connect();
113         /// Disconnect signals
114         virtual void disconnect();
115
116 private:
117         /** Slot connected to update signal.
118             Bool indicates if a buffer switch took place.
119             Default behaviour is to ignore this and simply update().
120         */
121         virtual void updateSlot(bool) { update(); }
122         /// Update connection.
123         SigC::Connection u_;
124 };
125
126 #endif // CONTROLCONNECTIONS_H