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