]> git.lyx.org Git - lyx.git/blob - src/insets/insetbutton.C
FILMagain changes (will need some work)
[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 "Painter.h"
20
21 using std::ostream;
22 using std::endl;
23
24
25 InsetButton::InsetButton()
26 {
27 }
28
29 int InsetButton::ascent(Painter & pain, LyXFont const &) const
30 {
31         LyXFont font(LyXFont::ALL_SANE);
32         font.decSize();
33         
34         int width, ascent, descent;
35         string s = getScreenLabel();
36         
37         if (Editable()) {
38                 pain.buttonText(0, 0, s, font,
39                                 false, width, ascent, descent);
40         } else {
41                 pain.rectText(0, 0, s, font,
42                               LColor::commandbg, LColor::commandframe,
43                               false, width, ascent, descent);
44         }
45         return ascent;
46 }
47
48
49 int InsetButton::descent(Painter & pain, LyXFont const &) const
50 {
51         LyXFont font(LyXFont::ALL_SANE);
52         font.decSize();
53         
54         int width, ascent, descent;
55         string s = getScreenLabel();
56         
57         if (Editable()) {
58                 pain.buttonText(0, 0, s, font,
59                                 false, width, ascent, descent);
60         } else {
61                 pain.rectText(0, 0, s, font,
62                               LColor::commandbg, LColor::commandframe,
63                               false, width, ascent, descent);
64         }
65         return descent;
66 }
67
68
69 int InsetButton::width(Painter & pain, LyXFont const &) const
70 {
71         LyXFont font(LyXFont::ALL_SANE);
72         font.decSize();
73         
74         int width, ascent, descent;
75         string s = getScreenLabel();
76         
77         if (Editable()) {
78                 pain.buttonText(0, 0, s, font,
79                                 false, width, ascent, descent);
80         } else {
81                 pain.rectText(0, 0, s, font,
82                               LColor::commandbg, LColor::commandframe,
83                               false, width, ascent, descent);
84         }
85         return width + 4;
86 }
87
88
89 void InsetButton::draw(Painter & pain, LyXFont const &,
90                         int baseline, float & x) const
91 {
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 }