]> git.lyx.org Git - features.git/blob - src/mathed/math_macro.h
fix macro, small cleanup
[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 "math_parinset.h"
26
27 class MathMacroTemplate;
28
29
30 /** This class contains the data for a macro
31     \author Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
32     \version November 1996
33  */
34 class MathMacro : public MathParInset
35 {
36 public:
37         /// A macro can only be builded from an existing template
38         explicit
39         MathMacro(MathMacroTemplate *);
40         /// or from another macro.
41         explicit
42         MathMacro(MathMacro *);
43         ///
44         void draw(Painter &, int, int);
45         ///
46         void Metrics();
47         ///
48         MathedInset * Clone();
49         ///
50         void Write(std::ostream &, bool fragile);
51         ///
52         bool setArgumentIdx(int);
53         ///
54         int getArgumentIdx() const;
55         ///
56         int getMaxArgumentIdx() const;
57         ///
58         int GetColumns() const;
59         ///
60         void GetXY(int &, int &) const;
61         ///
62         void SetFocus(int, int);
63         ///
64         MathedArray & GetData();
65         ///
66         MathedRowSt * getRowSt() const;
67         ///
68         void setData(MathedArray const &);
69         ///
70         MathedTextCodes getTCode() const;
71         ///
72         bool Permit(short) const;
73 private:
74         ///
75         MathMacroTemplate * tmplate_;
76         ///
77         struct MacroArgumentBase {
78                 /// Position of the macro
79                 int x;
80                 ///
81                 int y;
82                 ///
83                 MathedRowSt * row;
84                 ///
85                 MathedArray array;
86                 ///
87                 MacroArgumentBase()
88                         : x(0), y(0), row(0)
89                         {}
90         };
91         std::vector<MacroArgumentBase> args_;
92         ///
93         int idx_;
94         ///
95         int nargs_;
96         ///
97         MathedTextCodes tcode_;
98 };
99 #endif