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