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