]> git.lyx.org Git - features.git/blob - src/frontends/xforms/FormCommand.h
ab3899113b3c40388cf4e3cad0904ee4cf23d631
[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
35         ///
36         static  int WMHideCB(FL_FORM *, void *);
37         ///
38         static void ApplyCB(FL_OBJECT *, long);
39         ///
40         static void CancelCB(FL_OBJECT *, long);
41         ///
42         static void InputCB(FL_OBJECT *, long);
43         ///
44         static void OKCB(FL_OBJECT *, long);
45
46 protected:
47         /// Slot launching dialog to (possibly) create a new inset
48         void createInset( string const & );
49         /// Slot launching dialog to an existing inset
50         void showInset( InsetCommand * const );
51
52         /// Build the dialog
53         virtual void build() = 0;
54         /// Filter the inputs on callback from xforms
55         virtual void input( long ) = 0;
56         /// Update dialog before showing it
57         virtual void update() = 0;
58         /// Apply from dialog (modify or create inset)
59         virtual void apply() = 0;
60         /// delete derived class variables from hide()
61         virtual void clearStore() {}
62         /// Pointer to the actual instantiation of the xform's form
63         virtual FL_FORM * const form() const = 0;
64
65         /** Which LyXFunc do we use?
66             We could modify Dialogs to have a visible LyXFunc* instead and
67             save a couple of bytes per dialog.
68         */
69         LyXView * lv_;
70         /** Which Dialogs do we belong to?
71             Used so we can get at the signals we have to connect to.
72         */
73         Dialogs * d_;
74         /// pointer to the inset passed through showInset (if any)
75         InsetCommand * inset_;
76         /// the nitty-griity. What is modified and passed back
77         InsetCommandParams params;
78 private:
79         /// Create the dialog if necessary, update it and display it.
80         void show();
81         /// Hide the dialog.
82         void hide();
83
84         /// Update connection.
85         Connection u_;
86         /// Hide connection.
87         Connection h_;
88         /// inset::hide connection.
89         Connection ih_;
90         /// block opening of form from more than one inset
91         bool dialogIsOpen;
92         /// dialog title, displayed by WM.
93         string title;
94 };
95
96 #endif