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