]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormBaseDeprecated.h
5bd894e0737e2f3f4834fd04721b8b3d8d345c03
[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 <leeming@lyx.org>
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 "LString.h"
24 #include "xformsBC.h"
25 #include "FeedbackController.h"
26
27 #include "forms_fwd.h"
28
29 #include <boost/utility.hpp>
30 #include <boost/signals/connection.hpp>
31
32 class Buffer;
33 class Dialogs;
34 class LyXView;
35 class Tooltips;
36
37 class FormBaseDeprecated : boost::noncopyable, 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         /// Create the dialog if necessary, update it and display it.
61         virtual void show();
62
63 protected: // methods
64
65         /// Pointer to the actual instantiation of the ButtonController.
66         virtual xformsBC & bc() = 0;
67
68         /** Redraw the form (on receipt of a Signal indicating, for example,
69          *  that the xform colors have been re-mapped).
70          *  Must be virtual because dialogs with tabbed folders will need to
71          *  redraw the form for each tab.
72          */
73         virtual void redraw();
74
75         /// Hide the dialog.
76         virtual void hide();
77         /// Update the dialog.
78         virtual void update() {}
79         /// Connect signals. Also perform any necessary initialisation.
80         virtual void connect();
81         /// Disconnect signals. Also perform any necessary housekeeping.
82         virtual void disconnect();
83         /// Build the dialog
84         virtual void build() = 0;
85         /** Filter the inputs on callback from xforms
86          *  Return true if inputs are valid.
87          */
88         virtual bool input(FL_OBJECT *, long) {
89                 return true;
90         }
91         /// Apply from dialog (modify or create inset)
92         virtual void apply() {}
93         /// OK from dialog
94         virtual void ok() {
95                 apply();
96                 hide();
97         }
98         /// Cancel from dialog
99         virtual void cancel() {
100                 hide();
101         }
102         /// Restore from dialog
103         virtual void restore() {
104                 update();
105         }
106         /// Pointer to the actual instantiation of xform's form
107         virtual FL_FORM * form() const = 0;
108
109         /** Prepare the way to:
110          *  1. display feedback as the mouse moves over ob. This feedback will
111          *  typically be rather more verbose than just a tooltip.
112          *  2. activate the button controller after a paste with the middle
113          *  mouse button.
114          */
115         static void setPrehandler(FL_OBJECT * ob);
116
117         /** Which LyXFunc do we use?
118          *  We could modify Dialogs to have a visible LyXFunc* instead and
119          *  save a couple of bytes per dialog.
120          */
121         LyXView & lv_;
122         /// Used so we can get at the signals we have to connect to.
123         Dialogs & d_;
124         /// Hide connection.
125         boost::signals::connection h_;
126         /// Redraw connection.
127         boost::signals::connection r_;
128         /// dialog title, displayed by WM.
129         string title_;
130
131 private:
132         /// The dialog's minimum allowable dimensions.
133         int minw_;
134         ///
135         int minh_;
136         /// Can the dialog be resized after it has been created?
137         bool allow_resize_;
138         ///
139         Tooltips * tooltips_;
140 };
141
142
143 /** This class is an XForms GUI base class for Buffer Independent dialogs.
144  *  Such dialogs do not require an update Connection although they may use
145  *  an update() function which is also supported by restore().
146  */
147 class FormBaseBI : public FormBaseDeprecated {
148 protected:
149         /// Constructor
150         FormBaseBI(LyXView &, Dialogs &, string const &,
151                    bool allowResize = true);
152
153         /// Connect signals
154         virtual void connect();
155 };
156
157
158 /** This class is an XForms GUI base class for Buffer Dependent dialogs
159  */
160 class FormBaseBD : public FormBaseDeprecated {
161 protected:
162         /// Constructor
163         FormBaseBD(LyXView &, Dialogs &, string const &,
164                    bool allowResize = true);
165
166         /// Connect signals
167         virtual void connect();
168         /// Disconnect signals
169         virtual void disconnect();
170         /// bool indicates if a buffer switch took place
171         virtual void updateSlot(bool) { update(); }
172
173         /// Update connection.
174         boost::signals::connection u_;
175 };
176
177
178 #endif // FORMBASEDEPRECATED_H