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