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