]> git.lyx.org Git - lyx.git/blob - src/mathed/math_macro.h
fix "make dist" target
[lyx.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 <iosfwd>
26 #include <boost/smart_ptr.hpp>
27
28 #include "math_parinset.h"
29 #include "math_macroarg.h"
30
31 class MathMacroTemplate;
32
33
34 /** This class contains the data for a macro
35     \author Alejandro Aguilar Sierra <asierra@servidor.unam.mx>
36     \version November 1996
37  */
38 class MathMacro : public MathParInset {
39 public:
40         /// A macro can be built from an existing template
41         explicit MathMacro(MathMacroTemplate const &);
42         ///
43         void draw(Painter &, int, int);
44         ///
45         void Metrics();
46         ///
47         MathedInset * Clone();
48         ///
49         void Write(std::ostream &, bool fragile);
50         ///
51         void WriteNormal(std::ostream &);
52         /// Index 0 is the template, index 1..nargs() are the parameters
53         bool setArgumentIdx(int);
54         ///
55         int getArgumentIdx() const;
56         ///
57         int getMaxArgumentIdx() const;
58         ///
59         int nargs() const;
60         ///
61         int GetColumns() const;
62         ///
63         void GetXY(int &, int &) const;
64         ///
65         void SetFocus(int, int);
66         ///
67         MathedArray & GetData();
68         ///
69         MathedArray const & GetData() const;
70         ///
71         void setData(MathedArray const &);
72         ///
73         void setData(MathedArray const &, int);
74         ///
75         MathedTextCodes getTCode() const;
76         ///
77         bool Permit(short) const;
78         ///
79         void expand();
80         ///
81         void dump(std::ostream & os) const;
82         ///
83         MathParInset const * arg(int) const;
84         ///
85         MathParInset * arg(int);
86         ///
87         MathMacroTemplate * tmplate() const;
88 private:
89         ///
90         MathMacroTemplate * tmplate_;
91         /// our arguments
92         std::vector< boost::shared_ptr<MathParInset> > args_;
93         /// the expanded version fror drawing
94         boost::shared_ptr<MathParInset> expanded_;
95         ///
96         int idx_;
97
98         /// unimplemented
99         void operator=(MathMacro const &);
100 };
101
102 inline std::ostream & operator<<(std::ostream & os, MathMacro const & m)
103 {
104         m.dump(os);
105         return os;
106 }
107 #endif