]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBase.h
try this for distinguishing inner and outer tabs
[lyx.git] / src / frontends / xforms / FormBase.h
1 // -*- C++ -*-
2 /* This file is part of
3  * ====================================================== 
4  *
5  *           LyX, The Document Processor
6  *
7  *           Copyright 2000 The LyX Team.
8  *
9  * ======================================================
10  */
11
12 #ifndef FORMBASE_H
13 #define FORMBASE_H
14
15 #include "DialogBase.h"
16 #include "LString.h"
17 #include FORMS_H_LOCATION
18 #include "ButtonController.h"
19 #include "gettext.h"
20 #include <sigc++/signal_system.h>
21
22 class Buffer;
23 class Dialogs;
24 class LyXView;
25
26 #ifdef __GNUG__
27 #pragma interface
28 #endif
29
30 /** This class is an XForms GUI base class.
31     It is meant to be used solely as the parent class to FormBaseBI
32     and FormBaseBD.
33     @author Angus Leeming
34  */
35
36 class FormBase : public DialogBase {
37 public:
38         /// Callback functions
39         static  int WMHideCB(FL_FORM *, void *);
40         ///
41         static void ApplyCB(FL_OBJECT *, long);
42         ///
43         static void OKCB(FL_OBJECT *, long);
44         ///
45         static void CancelCB(FL_OBJECT *, long);
46         ///
47         static void InputCB(FL_OBJECT *, long);
48         ///
49         static void RestoreCB(FL_OBJECT *, long);
50
51 protected: // methods
52         ///
53         FormBase(LyXView *, Dialogs *, string const &,
54                  ButtonPolicy *, char const *, char const *);
55         ///
56         virtual ~FormBase();
57
58         /** Redraw the form (on receipt of a Signal indicating, for example,
59             that the xform colors have been re-mapped).
60             Must be virtual because dialogs with tabbed folders will need to
61             redraw the form for each tab.
62         */
63         virtual void redraw();
64
65         /// Create the dialog if necessary, update it and display it.
66         virtual void show();
67         /// Hide the dialog.
68         virtual void hide();
69         /// Update the dialog.
70         virtual void update() {}
71         /// Connect signals. Also perform any necessary initialisation.
72         virtual void connect();
73         /// Disconnect signals. Also perform any necessary housekeeping.
74         virtual void disconnect();
75         /// Build the dialog
76         virtual void build() = 0;
77         /** Filter the inputs on callback from xforms
78             Return true if inputs are valid.
79          */
80         virtual bool input( FL_OBJECT *, long) {
81                 return true;
82         }
83         /// Apply from dialog (modify or create inset)
84         virtual void apply() {}
85         /// OK from dialog
86         virtual void ok() {
87                 apply();
88                 hide();
89         }
90         /// Cancel from dialog
91         virtual void cancel() {
92                 hide();
93         }
94         /// Restore from dialog
95         virtual void restore() {
96                 update();
97         }
98         /// Pointer to the actual instantiation of xform's form
99         virtual FL_FORM * form() const = 0;
100
101         /** Which LyXFunc do we use?
102             We could modify Dialogs to have a visible LyXFunc* instead and
103             save a couple of bytes per dialog.
104         */
105         LyXView * lv_;
106         /// Useable even in derived-class's const functions.
107         mutable ButtonController bc_;
108         /// Used so we can get at the signals we have to connect to.
109         Dialogs * d_;
110         /// Hide connection.
111         Connection h_;
112         /// Redraw connection.
113         Connection r_;
114         /// dialog title, displayed by WM.
115         string title;
116 private:
117         ///
118         ButtonPolicy * bp_;
119 public:
120         /// Overcome a dumb xforms sizing bug
121         mutable int minw_;
122         ///
123         mutable int minh_;
124 };
125
126
127 /** This class is an XForms GUI base class for Buffer Independent dialogs.
128     Such dialogs do not require an update Connection although they may use
129     an update() function which is also supported by restore().
130  */
131 class FormBaseBI : public FormBase {
132 protected:
133         /// Constructor
134         FormBaseBI(LyXView *, Dialogs *, string const &,
135                    ButtonPolicy * bp,
136                    char const * close = N_("Close"),
137                    char const * cancel = N_("Cancel"));
138
139         /// Connect signals
140         virtual void connect();
141 };
142
143
144 /** This class is an XForms GUI base class for Buffer Dependent dialogs
145  */
146 class FormBaseBD : public FormBase {
147 protected:
148         /// Constructor
149         FormBaseBD(LyXView *, Dialogs *, string const &,
150                    ButtonPolicy * bp,
151                    char const * close = N_("Close"),
152                    char const * cancel = N_("Cancel"));
153
154         /// Connect signals
155         virtual void connect();
156         /// Disconnect signals
157         virtual void disconnect();
158         /// bool indicates if a buffer switch took place
159         virtual void updateSlot(bool) { update(); }
160
161         /// Update connection.
162         Connection u_;
163 };
164
165
166 #endif