]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormCommand.h
Angus insetindex patch + protect patch from Dekel
[features.git] / src / frontends / xforms / FormCommand.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 FORMCOMMAND_H
13 #define FORMCOMMAND_H
14
15 #include "DialogBase.h"
16 #include "LString.h"
17 #include "support/utility.hpp"
18 #include "insets/insetcommand.h"
19
20 class Dialogs;
21 class LyXView;
22
23 #ifdef __GNUG__
24 #pragma interface
25 #endif
26
27 /** This class is an XForms GUI base class to insets derived from
28     InsetCommand
29  */
30 class FormCommand : public DialogBase, public noncopyable {
31 public:
32         /// Constructor
33         FormCommand(LyXView *, Dialogs *, string const & );
34         /// Destructor
35         virtual ~FormCommand();
36
37         /**@name Real per-instance Callback Methods */
38         //@{
39         static  int WMHideCB(FL_FORM *, void *);
40         static void OKCB(FL_OBJECT *, long);
41         static void ApplyCB(FL_OBJECT *, long);
42         static void CancelCB(FL_OBJECT *, long);
43         static void InputCB(FL_OBJECT *, long);
44         //@}
45
46 protected:
47         /**@name Slot Methods */
48         //@{
49         /// Slot launching dialog to (possibly) create a new inset
50         void createInset( string const & );
51         /// Slot launching dialog to an existing inset
52         void showInset( InsetCommand * const );
53         //@}
54
55         /// Build the dialog
56         virtual void build() = 0;
57         /// Filter the inputs on callback from xforms
58         virtual void input( long ) = 0;
59         /// Update dialog before showing it
60         virtual void update() = 0;
61         /// Apply from dialog (modify or create inset)
62         virtual void apply() = 0;
63         /// delete derived class variables from hide()
64         virtual void clearStore() {}
65         /// Pointer to the actual instantiation of the xform's form
66         virtual FL_FORM * const form() const = 0;
67
68         /**@name Protected Data */
69         //@{
70         /** Which LyXFunc do we use?
71             We could modify Dialogs to have a visible LyXFunc* instead and
72             save a couple of bytes per dialog.
73         */
74         LyXView * lv_;
75         /** Which Dialogs do we belong to?
76             Used so we can get at the signals we have to connect to.
77         */
78         Dialogs * d_;
79         /// pointer to the inset passed through showInset (if any)
80         InsetCommand * inset_;
81         /// the nitty-griity. What is modified and passed back
82         InsetCommandParams params;
83         //@}
84
85 private:
86         /// Create the dialog if necessary, update it and display it.
87         void show();
88         /// Hide the dialog.
89         void hide();
90         /// Explicitly free the dialog.
91         void free();
92
93
94         /**@name Private Data */
95         //@{
96         /// Update connection.
97         Connection u_;
98         /// Hide connection.
99         Connection h_;
100         /// inset::hide connection.
101         Connection ih_;
102         /// block opening of form from more than one inset
103         bool dialogIsOpen;
104         /// dialog title, displayed by WM.
105         string title;
106         //@}
107 };
108
109 #endif