]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsPanel.h
e1a4fd3853fa684b82ab9c5881121a0b7cd45f1a
[lyx.git] / src / frontends / xforms / FormMathsPanel.h
1 // -*- C++ -*-
2 /**
3  * \file FormMathsPanel.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Alejandro Aguilar Sierra
8  * \author John Levon
9  * \author Angus Leeming 
10  *
11  * Full author contact details are available in file CREDITS
12  */
13
14 #ifndef FORM_MATHSPANEL_H
15 #define FORM_MATHSPANEL_H
16
17 #include "commandtags.h"
18
19 #ifdef __GNUG__
20 #pragma interface
21 #endif
22
23 #include "FormBaseDeprecated.h"
24
25 #include <boost/shared_ptr.hpp>
26 #include <map>
27
28 class FormMathsBitmap;
29 class FormMathsSub;
30 struct FD_maths_panel;
31
32 /**
33  * This class provides an XForms implementation of the maths panel.
34  */
35 class FormMathsPanel : public FormBaseBD {
36 public:
37         ///
38         FormMathsPanel(LyXView &, Dialogs &);
39         /// dispatch an LFUN:
40         void dispatchFunc(kb_action action,
41                           string const & arg = string()) const;
42         /// dispatch a symbol insert
43         void insertSymbol(string const & sym, bool bs = true) const;
44
45 private:
46         /// Pointer to the actual instantiation of the ButtonController.
47         virtual xformsBC & bc();
48
49         /// Build the dialog
50         virtual void build();
51         /// input handler
52         virtual bool input(FL_OBJECT *, long);
53
54         /// Pointer to the actual instantiation of the xforms form
55         virtual FL_FORM * form() const;
56
57         // Real GUI implementation
58         boost::scoped_ptr<FD_maths_panel> dialog_;
59
60         /** Add a bitmap dialog to the store of all daughters_ and
61          *  return a pointer to the dialog, so that bitmaps can be added to it.
62          */
63         FormMathsBitmap * addDaughter(FL_OBJECT * button, string const & title,
64                                       char const * const * data, int size);
65
66         ///
67         void showDaughter(FL_OBJECT *);
68
69         ///
70         typedef boost::shared_ptr<FormMathsSub> DaughterDialog;
71         typedef std::map<FL_OBJECT *, DaughterDialog> Store;
72
73         /** The store of all daughter dialogs.
74          *  The map uses the button on the main panel to identify them.
75          */
76         Store daughters_;
77
78         /// A pointer to the currently active daughter dialog.
79         FormMathsSub * active_;
80
81         /// The ButtonController.
82         ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
83 };
84
85
86 class FormMathsSub : public FormBaseBD {
87 public:
88         ///
89         FormMathsSub(LyXView &, Dialogs &, FormMathsPanel const &,
90                      string const &, bool allowResize = true);
91
92         ///
93         bool isVisible() const;
94
95 protected:
96         /// Pointer to the actual instantiation of the ButtonController.
97         virtual xformsBC & bc();
98         /// The parent Maths Panel
99         FormMathsPanel const & parent_;
100 private:
101         /// The ButtonController
102         ButtonController<IgnorantPolicy, xformsBC> bc_;
103 };
104
105
106 inline
107 xformsBC & FormMathsSub::bc()
108 {
109         return bc_;
110 }
111
112 inline
113 xformsBC & FormMathsPanel::bc()
114 {
115         return bc_;
116 }
117 #endif //  FORM_MATHSPANEL_H