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