]> git.lyx.org Git - lyx.git/blob - src/frontends/controllers/ControlConnections.h
remove preamble dialog from the qt frontend
[lyx.git] / src / frontends / controllers / ControlConnections.h
1 // -*- C++ -*-
2 /**
3  * \file ControlConnections.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Angus Leeming
8  *
9  * Full author contact details are available in file CREDITS
10  *
11  * ControlConnections.h contains the definition of three controller classes,
12  * ControlConnectBase, ControlConnectBI and ControlConnectBD.
13  *
14  * Together they control the connection/disconnection of signals with the LyX
15  * kernel. Controllers of individual dialogs interacting with the kernel through
16  * signals/slots will all be derived from ControlConnectBI or ControlConnectBD.
17  *
18  * A dialog is classed as "Buffer Dependent" if its contents change with the
19  * buffer (document). An example would be the Citation dialog. Such a dialog
20  * would be derived, therefore, from ControlConnectBD.
21  *
22  * Conversely, a dialog is "Buffer Independent" if its contents do not change
23  * when the buffer changes. An example would be the Copyright dialog. Such a
24  * dialog is therefore derived from ControlConnectBI.
25  *
26  */
27
28 #ifndef CONTROLCONNECTIONS_H
29 #define CONTROLCONNECTIONS_H
30
31 #ifdef __GNUG__
32 #pragma interface
33 #endif
34
35 #include "ControlButtons.h"
36
37 #include <boost/signals/connection.hpp>
38
39 class Buffer;
40 class BufferView;
41 class Dialogs;
42 class LyXView;
43 class LyXFunc;
44
45 /** Base class to control connection/disconnection of signals with the LyX
46     kernel. It is meant to be used solely as the parent class to
47     ControlConnectBI and ControlConnectBD.
48 */
49 class ControlConnectBase : public ControlButtons {
50 public:
51         ///
52         enum DocTypes {
53                 ///
54                 LATEX,
55                 ///
56                 LITERATE,
57                 ///
58                 LINUXDOC,
59                 ///
60                 DOCBOOK
61         };
62         ///
63         ControlConnectBase(LyXView &, Dialogs &);
64         /// The View may need to know if the buffer is read-only.
65         bool bufferIsReadonly() const;
66         ///
67         DocTypes docType() const;
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         /// a wrapper for BufferView::avaliable()
83         bool bufferIsAvailable() const;
84         /// a wrapper for LyXView::view()
85         BufferView * bufferview();
86         ///
87         BufferView const * bufferview() const;
88         /// a wrapper for LyXView::buffer()
89         Buffer * buffer();
90         ///
91         Buffer const * buffer() const;
92         /// a wrapper for LyXView::getLyXFunc()
93         LyXFunc & lyxfunc();
94         ///
95         LyXFunc const & lyxfunc() const;
96
97         ///
98         LyXView & lv_;
99         /// Contains the signals we have to connect to.
100         Dialogs & d_;
101         /// Hide connection.
102         boost::signals::connection h_;
103         /// Redraw connection.
104         boost::signals::connection r_;
105 };
106
107
108 /** Base class to control connection/disconnection of signals with the LyX
109     kernel for Buffer Independent dialogs.
110     Such dialogs do not require an update Connection although they may use
111     an update() function which is also supported by the Restore button.
112  */
113
114 class ControlConnectBI : public ControlConnectBase {
115 public:
116         ///
117         ControlConnectBI(LyXView &, Dialogs &);
118 protected:
119         ///
120         virtual bool isBufferDependent() const { return false; }
121         /// Connect signals
122         virtual void connect();
123 };
124
125
126 /** Base class to control connection/disconnection of signals with the LyX
127     kernel for Buffer Dependent dialogs.
128  */
129 class ControlConnectBD : public ControlConnectBase {
130 public:
131         ///
132         ControlConnectBD(LyXView &, Dialogs &);
133 protected:
134         ///
135         virtual bool isBufferDependent() const { return true; }
136         /// Connect signals
137         virtual void connect();
138         /// Disconnect signals
139         virtual void disconnect();
140 private:
141         /** Slot connected to update signal.
142             Bool indicates if a buffer switch took place.
143             Default behaviour is to ignore this and simply update().
144         */
145         virtual void updateSlot(bool) { update(); }
146         /// Update connection.
147         boost::signals::connection u_;
148 };
149
150 #endif // CONTROLCONNECTIONS_H