]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormBase.h
allow derived classes to manipulate signal connections
[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 "support/utility.hpp"
18 #include FORMS_H_LOCATION
19
20 class Dialogs;
21 class LyXView;
22
23 #ifdef __GNUG__
24 #pragma interface
25 #endif
26
27 #ifdef SIGC_CXX_NAMESPACES
28 using SigC::Signal0;
29 #endif
30
31 /** This class is an XForms GUI base class
32     @author Angus Leeming
33  */
34 class FormBase : public DialogBase, public noncopyable {
35 public:
36         ///
37         enum BufferDependency {
38                 ///
39                 BUFFER_DEPENDENT,
40                 ///
41                 BUFFER_INDEPENDENT
42         };
43
44         /// Constructor
45         FormBase(LyXView *, Dialogs *, BufferDependency, string const &);
46
47         /// Callback functions
48         static  int WMHideCB(FL_FORM *, void *);
49         ///
50         static void ApplyCB(FL_OBJECT *, long);
51         ///
52         static void ApplyHideCB(FL_OBJECT *, long);
53         ///
54         static void HideCB(FL_OBJECT *, long);
55         ///
56         static void InputCB(FL_OBJECT *, long);
57
58 protected:
59         /// Create the dialog if necessary, update it and display it.
60         void show();
61         /// Hide the dialog.
62         void hide();
63         /// Connect signals
64         virtual void connect();
65         /// Disconnect signals
66         virtual void disconnect();
67         /// Build the dialog
68         virtual void build() = 0;
69         /// Filter the inputs on callback from xforms
70         virtual void input( long ) {}
71         /// Update dialog before showing it
72         virtual void update() {}
73         /// Apply from dialog (modify or create inset)
74         virtual void apply() {}
75         /// delete derived class variables when hide()ing
76         virtual void clearStore() {}
77         /// Pointer to the actual instantiation of xform's form
78         virtual FL_FORM * const form() const = 0;
79
80         /// block opening of form twice at the same time
81         bool dialogIsOpen;
82         /** Which LyXFunc do we use?
83             We could modify Dialogs to have a visible LyXFunc* instead and
84             save a couple of bytes per dialog.
85         */
86         LyXView * lv_;
87
88 private:
89         /// Hide signal
90         Signal0<void> * hSignal_;
91         /// Update signal
92         Signal0<void> * uSignal_;
93         /// Update connection.
94         Connection u_;
95         /// Hide connection.
96         Connection h_;
97         /// dialog title, displayed by WM.
98         string title;
99 };
100
101 #endif