]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormBaseDeprecated.h
Really dull and boring header shit
[features.git] / src / frontends / xforms / FormBaseDeprecated.h
1 // -*- C++ -*-
2 /**
3  * \file FormBaseDeprecated.h
4  * Read the file COPYING
5  *
6  * \author Angus Leeming 
7  *
8  * Full author contact details are available in file CREDITS
9  */
10
11 /* A base class for those remaining xforms dialogs that haven't yet undergone
12  * the controller-view split.
13  * It is meant to be used solely as the parent class to FormBaseBI
14  * and FormBaseBD.
15  */
16
17 #ifndef FORMBASEDEPRECATED_H
18 #define FORMBASEDEPRECATED_H
19
20 #ifdef __GNUG__
21 #pragma interface
22 #endif
23
24 #include "LString.h"
25 #include "xformsBC.h"
26 #include "FeedbackController.h"
27
28 #include "forms_fwd.h"
29
30 #include <boost/utility.hpp>
31 #include <boost/signals/connection.hpp>
32
33 class Buffer;
34 class Dialogs;
35 class LyXView;
36 class Tooltips;
37
38 class FormBaseDeprecated : boost::noncopyable, public FeedbackController
39 {
40 public:
41         ///
42         FormBaseDeprecated(LyXView &, Dialogs &, string const &, bool);
43         ///
44         virtual ~FormBaseDeprecated();
45
46         /// Callback functions
47         void WMHideCB();
48         ///
49         void ApplyCB();
50         ///
51         void OKCB();
52         ///
53         void CancelCB();
54         ///
55         void InputCB(FL_OBJECT *, long);
56         ///
57         void RestoreCB();
58
59         Tooltips & tooltips();
60
61         /// Create the dialog if necessary, update it and display it.
62         virtual void show();
63
64 protected: // methods
65
66         /// Pointer to the actual instantiation of the ButtonController.
67         virtual xformsBC & bc() = 0;
68
69         /** Redraw the form (on receipt of a Signal indicating, for example,
70          *  that the xform colors have been re-mapped).
71          *  Must be virtual because dialogs with tabbed folders will need to
72          *  redraw the form for each tab.
73          */
74         virtual void redraw();
75
76         /// Hide the dialog.
77         virtual void hide();
78         /// Update the dialog.
79         virtual void update() {}
80         /// Connect signals. Also perform any necessary initialisation.
81         virtual void connect();
82         /// Disconnect signals. Also perform any necessary housekeeping.
83         virtual void disconnect();
84         /// Build the dialog
85         virtual void build() = 0;
86         /** Filter the inputs on callback from xforms
87          *  Return true if inputs are valid.
88          */
89         virtual bool input(FL_OBJECT *, long) {
90                 return true;
91         }
92         /// Apply from dialog (modify or create inset)
93         virtual void apply() {}
94         /// OK from dialog
95         virtual void ok() {
96                 apply();
97                 hide();
98         }
99         /// Cancel from dialog
100         virtual void cancel() {
101                 hide();
102         }
103         /// Restore from dialog
104         virtual void restore() {
105                 update();
106         }
107         /// Pointer to the actual instantiation of xform's form
108         virtual FL_FORM * form() const = 0;
109
110         /** Prepare the way to:
111          *  1. display feedback as the mouse moves over ob. This feedback will
112          *  typically be rather more verbose than just a tooltip.
113          *  2. activate the button controller after a paste with the middle
114          *  mouse button.
115          */
116         static void setPrehandler(FL_OBJECT * ob);
117
118         /** Which LyXFunc do we use?
119          *  We could modify Dialogs to have a visible LyXFunc* instead and
120          *  save a couple of bytes per dialog.
121          */
122         LyXView & lv_;
123         /// Used so we can get at the signals we have to connect to.
124         Dialogs & d_;
125         /// Hide connection.
126         boost::signals::connection h_;
127         /// Redraw connection.
128         boost::signals::connection r_;
129         /// dialog title, displayed by WM.
130         string title_;
131
132 private:
133         /// The dialog's minimum allowable dimensions.
134         int minw_;
135         ///
136         int minh_;
137         /// Can the dialog be resized after it has been created?
138         bool allow_resize_;
139         ///
140         Tooltips * tooltips_;
141 };
142
143
144 /** This class is an XForms GUI base class for Buffer Independent dialogs.
145  *  Such dialogs do not require an update Connection although they may use
146  *  an update() function which is also supported by restore().
147  */
148 class FormBaseBI : public FormBaseDeprecated {
149 protected:
150         /// Constructor
151         FormBaseBI(LyXView &, Dialogs &, string const &,
152                    bool allowResize = true);
153
154         /// Connect signals
155         virtual void connect();
156 };
157
158
159 /** This class is an XForms GUI base class for Buffer Dependent dialogs
160  */
161 class FormBaseBD : public FormBaseDeprecated {
162 protected:
163         /// Constructor
164         FormBaseBD(LyXView &, Dialogs &, string const &,
165                    bool allowResize = true);
166
167         /// Connect signals
168         virtual void connect();
169         /// Disconnect signals
170         virtual void disconnect();
171         /// bool indicates if a buffer switch took place
172         virtual void updateSlot(bool) { update(); }
173
174         /// Update connection.
175         boost::signals::connection u_;
176 };
177
178
179 #endif // FORMBASEDEPRECATED_H