]> git.lyx.org Git - lyx.git/blob - src/frontends/xforms/FormMathsPanel.h
Bugfixes: checkboxes to radiobuttons (from J�rgen S) and remove a little
[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_AMS_MISC,
54         MM_AMS_ARROWS,
55         MM_AMS_BREL,
56         MM_AMS_NREL,
57         MM_AMS_OPS,
58         MM_FUNC
59 };
60  
61 /** 
62  * This class provides an XForms implementation of the maths panel.
63  */
64 class FormMathsPanel : public FormBaseBD {
65 public:
66         ///
67         FormMathsPanel(LyXView *, Dialogs *);
68         ///
69         void setActive(FormMathsSub *) const;
70         /// dispatch a symbol insert 
71         void insertSymbol(string const & sym, bool bs = true) const;
72         /// dispatch an LFUN:
73         void dispatchFunc(kb_action action) const;
74 private:
75         /// Pointer to the actual instantiation of the ButtonController.
76         virtual xformsBC & bc();
77         
78         /// Build the dialog
79         virtual void build();
80         /// input handler
81         virtual bool input(FL_OBJECT *, long);
82    
83         /// Pointer to the actual instantiation of the xforms form
84         virtual FL_FORM * form() const;
85
86         // build the panels
87         FD_form_maths_panel * build_maths_panel();
88         
89         /// send LFUN_MATH_DISPLAY
90         void mathDisplay() const;
91
92         // Real GUI implementation
93         boost::scoped_ptr<FD_form_maths_panel> dialog_;
94
95         /// Subdialogs
96         boost::scoped_ptr<FormMathsDeco>   deco_;
97         boost::scoped_ptr<FormMathsDelim>  delim_;
98         boost::scoped_ptr<FormMathsMatrix> matrix_;
99         boost::scoped_ptr<FormMathsSpace>  space_;
100         boost::scoped_ptr<FormMathsStyle>  style_;
101         boost::scoped_ptr<FormMathsBitmap> arrow_;
102         boost::scoped_ptr<FormMathsBitmap> boperator_;
103         boost::scoped_ptr<FormMathsBitmap> brelats_;
104         boost::scoped_ptr<FormMathsBitmap> greek_;
105         boost::scoped_ptr<FormMathsBitmap> misc_;
106         boost::scoped_ptr<FormMathsBitmap> dots_;
107         boost::scoped_ptr<FormMathsBitmap> varsize_;
108         boost::scoped_ptr<FormMathsBitmap> ams_misc_;
109         boost::scoped_ptr<FormMathsBitmap> ams_arrows_;
110         boost::scoped_ptr<FormMathsBitmap> ams_rel_;
111         boost::scoped_ptr<FormMathsBitmap> ams_nrel_;
112         boost::scoped_ptr<FormMathsBitmap> ams_ops_;
113
114         /// A pointer to the currently active subdialog
115         mutable FormMathsSub * active_;
116
117         /// The ButtonController
118         ButtonController<OkCancelReadOnlyPolicy, xformsBC> bc_;
119 };
120
121
122 class FormMathsSub : public FormBaseBD {
123         friend class FormMathsPanel; // has subdialogs to manipulate
124
125 public:
126         ///
127         FormMathsSub(LyXView *, Dialogs *, FormMathsPanel const &,
128                      string const &, bool allowResize=true);
129
130 protected:
131         /// Pointer to the actual instantiation of the ButtonController.
132         virtual xformsBC & bc();
133         /// The parent Maths Panel
134         FormMathsPanel const & parent_;
135 private:
136         ///
137         virtual void connect();
138         ///
139         virtual void disconnect();
140         /// The ButtonController
141         ButtonController<IgnorantPolicy, xformsBC> bc_;
142 };
143
144
145 inline
146 xformsBC & FormMathsSub::bc()
147 {
148         return bc_;
149 }
150
151 inline
152 xformsBC & FormMathsPanel::bc()
153 {
154         return bc_;
155 }
156 #endif //  FORM_MATHSPANEL_H