]> git.lyx.org Git - lyx.git/blob - src/insets/insetbutton.C
fix compilation pb ; update eu.po
[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
22 using std::ostream;
23 using std::endl;
24
25
26 int InsetButton::ascent(BufferView * bv, LyXFont const &) const
27 {
28         LyXFont font(LyXFont::ALL_SANE);
29         font.decSize();
30         
31         int width, ascent, descent;
32         string s = getScreenLabel();
33         
34         if (Editable()) {
35                 bv->painter().buttonText(0, 0, s, font,
36                                          false, width, ascent, descent);
37         } else {
38                 bv->painter().rectText(0, 0, s, font,
39                                        LColor::commandbg, LColor::commandframe,
40                                        false, width, ascent, descent);
41         }
42         return ascent;
43 }
44
45
46 int InsetButton::descent(BufferView * bv, LyXFont const &) const
47 {
48         LyXFont font(LyXFont::ALL_SANE);
49         font.decSize();
50         
51         int width, ascent, descent;
52         string s = getScreenLabel();
53         
54         if (Editable()) {
55                 bv->painter().buttonText(0, 0, s, font,
56                                          false, width, ascent, descent);
57         } else {
58                 bv->painter().rectText(0, 0, s, font,
59                                    LColor::commandbg, LColor::commandframe,
60                                    false, width, ascent, descent);
61         }
62         return descent;
63 }
64
65
66 int InsetButton::width(BufferView * bv, LyXFont const &) const
67 {
68         LyXFont font(LyXFont::ALL_SANE);
69         font.decSize();
70         
71         int width, ascent, descent;
72         string s = getScreenLabel();
73         //if (!bv)
74         //      int(s.length());
75         
76         if (Editable()) {
77                 bv->painter().buttonText(0, 0, s, font,
78                                          false, width, ascent, descent);
79         } else {
80                 bv->painter().rectText(0, 0, s, font,
81                                        LColor::commandbg, LColor::commandframe,
82                                        false, width, ascent, descent);
83         }
84         return width + 4;
85 }
86
87
88 void InsetButton::draw(BufferView * bv, LyXFont const &,
89                         int baseline, float & x, bool) const
90 {
91         Painter & pain = bv->painter();
92         // Draw it as a box with the LaTeX text
93         LyXFont font(LyXFont::ALL_SANE);
94         font.setColor(LColor::command).decSize();
95
96         int width;
97         string s = getScreenLabel();
98
99         if (Editable()) {
100                 pain.buttonText(int(x)+2, baseline, s, font, true, width);
101         } else {
102                 pain.rectText(int(x)+2, baseline, s, font,
103                               LColor::commandbg, LColor::commandframe,
104                               true, width);
105         }
106
107         x += width + 4;
108 }