]> git.lyx.org Git - lyx.git/blob - src/insets/insetbutton.C
floatlist work + handle lyxfuncs with args.
[lyx.git] / src / insets / insetbutton.C
1 /* This file is part of
2  * ======================================================
3  * 
4  *           LyX, The Document Processor
5  *       
6  *          Copyright 1995 Matthias Ettrich
7  *          Copyright 2000 The LyX Team.
8  *
9  * ====================================================== */
10
11 #include <config.h>
12
13 #ifdef __GNUG__
14 #pragma implementation
15 #endif
16
17 #include "insetbutton.h"
18 #include "debug.h"
19 #include "BufferView.h"
20 #include "Painter.h"
21 #include "support/LAssert.h"
22
23 using std::ostream;
24 using std::endl;
25
26
27 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
28 {
29         lyx::Assert(bv);
30         
31         LyXFont font(LyXFont::ALL_SANE);
32         font.decSize();
33         
34         int width;
35         int ascent;
36         int descent;
37         string const s = getScreenLabel();
38         
39         if (Editable()) {
40                 bv->painter().buttonText(0, 0, s, font,
41                                          false, width, ascent, descent);
42         } else {
43                 bv->painter().rectText(0, 0, s, font,
44                                        LColor::commandbg, LColor::commandframe,
45                                        false, width, ascent, descent);
46         }
47         return ascent;
48 }
49
50
51 int InsetButton::descent(BufferView * bv, LyXFont const &) const
52 {
53         lyx::Assert(bv);
54         
55         LyXFont font(LyXFont::ALL_SANE);
56         font.decSize();
57         
58         int width;
59         int ascent;
60         int descent;
61         string const s = getScreenLabel();
62         
63         if (Editable()) {
64                 bv->painter().buttonText(0, 0, s, font,
65                                          false, width, ascent, descent);
66         } else {
67                 bv->painter().rectText(0, 0, s, font,
68                                    LColor::commandbg, LColor::commandframe,
69                                    false, width, ascent, descent);
70         }
71         return descent;
72 }
73
74
75 int InsetButton::width(BufferView * bv, LyXFont const &) const
76 {
77         lyx::Assert(bv);
78
79         LyXFont font(LyXFont::ALL_SANE);
80         font.decSize();
81         
82         int width;
83         int ascent;
84         int descent;
85         string const s = getScreenLabel();
86         
87         if (Editable()) {
88                 bv->painter().buttonText(0, 0, s, font,
89                                          false, width, ascent, descent);
90         } else {
91                 bv->painter().rectText(0, 0, s, font,
92                                        LColor::commandbg, LColor::commandframe,
93                                        false, width, ascent, descent);
94         }
95         return width + 4;
96 }
97
98
99 void InsetButton::draw(BufferView * bv, LyXFont const &,
100                         int baseline, float & x, bool) const
101 {
102         lyx::Assert(bv);
103         
104         Painter & pain = bv->painter();
105         // Draw it as a box with the LaTeX text
106         LyXFont font(LyXFont::ALL_SANE);
107         font.setColor(LColor::command).decSize();
108
109         int width;
110         string const s = getScreenLabel();
111
112         if (Editable()) {
113                 pain.buttonText(int(x) + 2, baseline, s, font, true, width);
114         } else {
115                 pain.rectText(int(x) + 2, baseline, s, font,
116                               LColor::commandbg, LColor::commandframe,
117                               true, width);
118         }
119
120         x += width + 4;
121 }