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