]> git.lyx.org Git - features.git/blob - src/mathed/math_macro.h
more mathed changes, read the changelog
[features.git] / src / mathed / math_macro.h
1 // -*- C++ -*-
2 /*
3  *  File:        math_macro.h
4  *  Purpose:     Declaration of macro class for mathed 
5  *  Author:      Alejandro Aguilar Sierra <asierra@servidor.unam.mx> 
6  *  Created:     November 1996
7  *  Description: WYSIWYG math macros
8  *
9  *  Dependencies: Mathed
10  *
11  *  Copyright: 1996, 1997 Alejandro Aguilar Sierra
12  *
13  *   Version: 0.2, Mathed & Lyx project.
14  *
15  *   This code is under the GNU General Public Licence version 2 or later.
16  */
17 #ifndef MATH_MACRO
18 #define MATH_MACRO
19
20 #ifdef __GNUG__
21 #pragma interface
22 #endif
23
24 #include <vector>
25 #include <boost/smart_ptr.hpp>
26
27 #include "math_parinset.h"
28
29 class MathMacroTemplate;
30
31
32 /** This class contains the data for a macro
33     \author Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
34     \version November 1996
35  */
36 class MathMacro : public MathParInset {
37 public:
38         /// A macro can only be builded from an existing template
39         explicit
40         MathMacro(boost::shared_ptr<MathMacroTemplate> const &);
41         /// or from another macro.
42         explicit
43         MathMacro(MathMacro const &);
44         ///
45         void draw(Painter &, int, int);
46         ///
47         void Metrics();
48         ///
49         MathedInset * Clone();
50         ///
51         void Write(std::ostream &, bool fragile);
52         ///
53         bool setArgumentIdx(int);
54         ///
55         int getArgumentIdx() const;
56         ///
57         int getMaxArgumentIdx() const;
58         ///
59         int GetColumns() const;
60         ///
61         void GetXY(int &, int &) const;
62         ///
63         void SetFocus(int, int);
64         ///
65         MathedArray & GetData();
66         ///
67         MathedArray const & GetData() const;
68         ///
69         MathedRowSt * getRowSt() const;
70         ///
71         void setData(MathedArray const &);
72         ///
73         MathedTextCodes getTCode() const;
74         ///
75         bool Permit(short) const;
76 private:
77         ///
78         boost::shared_ptr<MathMacroTemplate> tmplate_;
79         ///
80         struct MacroArgumentBase {
81                 ///
82                 MathedRowSt * row;
83                 ///
84                 MathedArray array;
85                 ///
86                 MacroArgumentBase()
87                         :  row(0)
88                         {}
89         };
90         std::vector<MacroArgumentBase> args_;
91         ///
92         int idx_;
93         ///
94         int nargs_;
95         ///
96         MathedTextCodes tcode_;
97 };
98 #endif