]> git.lyx.org Git - lyx.git/blob - src/mathed/math_boxinset.h
most of the so far unapplied stuff from porto including proper support for
[lyx.git] / src / mathed / math_boxinset.h
1 // -*- C++ -*-
2 #ifndef MATH_BOXINSET_H
3 #define MATH_BOXINSET_H
4
5 #include "math_gridinset.h"
6 #include "LString.h"
7
8 #ifdef __GNUG__
9 #pragma interface
10 #endif
11
12 class LyXFont;
13
14 // Try to implement the reference inset "natively" for mathed.
15 // This is here temporarily until I can do cvs add again.
16
17 class ButtonInset: public MathNestInset {
18 public:
19         ///
20         ButtonInset();
21         ///
22         void metrics(MathMetricsInfo & mi) const;
23         ///
24         void draw(MathPainterInfo & pi, int x, int y) const;
25
26 protected:
27         /// This should provide the text for the button
28         virtual string screenLabel() const = 0;
29 };
30
31
32 // for things like \name[options]{contents}
33 class CommandInset : public ButtonInset {
34 public:
35         /// name, contents, options deliminited by '|++|'
36         explicit CommandInset(string const & data);
37         ///
38         MathInset * clone() const;
39         ///
40         void write(WriteStream & os) const;
41         ///
42         //void infoize(std::ostream & os) const;
43         ///
44         //int dispatch(string const & cmd, idx_type idx, pos_type pos);
45         ///
46         string screenLabel() const;
47 public:
48         string name_;
49 };
50
51
52 // for \ref 
53 class RefInset : public CommandInset {
54 public:
55         ///
56         RefInset();
57         ///
58         explicit RefInset(string const & data);
59         ///
60         MathInset * clone() const;
61         ///
62         //void write(WriteStream & os) const;
63         ///
64         void infoize(std::ostream & os) const;
65         ///
66         int dispatch(string const & cmd, idx_type idx, pos_type pos);
67         ///
68         string screenLabel() const;
69         ///
70         void validate(LaTeXFeatures & features) const;
71
72         /// plain ascii output
73         int ascii(std::ostream & os, int) const;
74         /// linuxdoc output
75         int linuxdoc(std::ostream & os) const;
76         /// docbook output
77         int docbook(std::ostream & os, bool) const;
78
79
80         struct type_info {
81                 ///
82                 string latex_name;
83                 ///
84                 string gui_name;
85                 ///
86                 string short_gui_name;
87         };
88         static type_info types[];
89         ///
90         static int getType(string const & name);
91         ///
92         static string const & getName(int type);
93 };
94
95
96 /// Support for \\mbox
97
98 class MathBoxInset : public MathGridInset {
99 public:
100         ///
101         explicit MathBoxInset(string const & name);
102         ///
103         MathInset * clone() const;
104         ///
105         void metrics(MathMetricsInfo & mi) const;
106         ///
107         void draw(MathPainterInfo & pi, int x, int y) const;
108         /// identifies BoxInsets
109         MathBoxInset * asBoxInset() { return this; }
110         /// identifies BoxInsets
111         MathBoxInset const * asBoxInset() const { return this; }
112         ///
113         void rebreak();
114         ///
115         void write(WriteStream & os) const;
116         ///
117         void normalize(NormalStream & ns) const;
118
119 private:
120         ///
121         mutable MathMetricsInfo mi_;
122         ///
123         string name_;
124 };
125
126
127 #endif