]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsPanel.h
Rewrote the maths panel so that ALL the popups now derive from FormBaseBD,
[lyx.git] / src / frontends / xforms / FormMathsPanel.h
1 /** 
2  * \file FormMathsPanel.h
3  * Copyright 2001 The LyX Team.
4  * See the file COPYING.
5  * 
6  * \author Alejandro Aguilar Sierra 
7  * \author John Levon, moz@compsoc.man.ac.uk
8  * \author Angus Leeming, a.leeming@ic.ac.uk
9  */
10
11 #ifndef FORM_MATHSPANEL_H
12 #define FORM_MATHSPANEL_H
13
14 #include <boost/smart_ptr.hpp>
15
16 #ifdef __GNUG_
17 #pragma interface
18 #endif
19
20 #include "FormBaseDeprecated.h"
21
22 class FormMathsBitmap;
23 class FormMathsDeco;
24 class FormMathsDelim;
25 class FormMathsMatrix;
26 class FormMathsSpace;
27 class FormMathsSub;
28 struct FD_form_maths_panel;
29
30 /// values used by the xforms callbacks 
31 enum MathsCallbackValues {
32         MM_GREEK,
33         MM_ARROW,
34         MM_BOP,
35         MM_BRELATS,
36         MM_VARSIZE,
37         MM_MISC,
38         MM_FRAC,
39         MM_SQRT,
40         MM_DELIM,
41         MM_MATRIX,
42         MM_EQU,
43         MM_DECO,
44         MM_SPACE,
45         MM_DOTS,
46         MM_FUNC
47 };
48  
49 /** 
50  * This class provides an XForms implementation of the maths panel.
51  */
52 class FormMathsPanel : public FormBaseBD {
53 public:
54         ///
55         FormMathsPanel(LyXView *, Dialogs *);
56         ///
57         void setActive(FormMathsSub *) const;
58         /// dispatch a symbol insert 
59         void insertSymbol(string const & sym) const;
60
61 private:
62         /// Pointer to the actual instantiation of the ButtonController.
63         virtual xformsBC & bc();
64         
65         /// Build the popup
66         virtual void build();
67         /// input handler
68         virtual bool input(FL_OBJECT *, long);
69    
70         /// Pointer to the actual instantiation of the xforms form
71         virtual FL_FORM * form() const;
72
73         // build the panels
74         FD_form_maths_panel * build_maths_panel();
75         
76         /// send LFUN_MATH_DISPLAY
77         void mathDisplay() const;
78
79         // Real GUI implementation
80         boost::scoped_ptr<FD_form_maths_panel> dialog_;
81
82         /// Subdialogs
83         boost::scoped_ptr<FormMathsDeco>   deco_;
84         boost::scoped_ptr<FormMathsDelim>  delim_;
85         boost::scoped_ptr<FormMathsMatrix> matrix_;
86         boost::scoped_ptr<FormMathsSpace>  space_;
87         boost::scoped_ptr<FormMathsBitmap> arrow_;
88         boost::scoped_ptr<FormMathsBitmap> boperator_;
89         boost::scoped_ptr<FormMathsBitmap> brelats_;
90         boost::scoped_ptr<FormMathsBitmap> greek_;
91         boost::scoped_ptr<FormMathsBitmap> misc_;
92         boost::scoped_ptr<FormMathsBitmap> varsize_;
93
94         /// A pointer to the currently active subdialog
95         mutable FormMathsSub * active_;
96
97         /// The ButtonController
98         ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
99 };
100
101
102 class FormMathsSub : public FormBaseBD {
103         friend class FormMathsPanel; // has subdialogs to manipulate
104
105 public:
106         ///
107         FormMathsSub(LyXView *, Dialogs *, FormMathsPanel const &,
108                      string const &);
109
110 protected:
111         /// Pointer to the actual instantiation of the ButtonController.
112         virtual xformsBC & bc();
113         /// The parent Maths Panel
114         FormMathsPanel const & parent_;
115 private:
116         ///
117         virtual void connect();
118         ///
119         virtual void disconnect();
120         /// The ButtonController
121         ButtonController<OkApplyCancelReadOnlyPolicy, xformsBC> bc_;
122 };
123
124
125 inline
126 xformsBC & FormMathsSub::bc()
127 {
128         return bc_;
129 }
130
131 inline
132 xformsBC & FormMathsPanel::bc()
133 {
134         return bc_;
135 }
136 #endif //  FORM_MATHSPANEL_H