| 15 | // ---------------------------------------------------------------------------------------- |
| 16 | |
| 17 | void button_style_default::draw_button ( |
| 18 | const canvas& c, |
| 19 | const rectangle& rect, |
| 20 | const bool enabled, |
| 21 | const font& mfont, |
| 22 | const long , |
| 23 | const long , |
| 24 | const ustring& name, |
| 25 | const bool is_depressed |
| 26 | ) const |
| 27 | { |
| 28 | rectangle area = rect.intersect(c); |
| 29 | if (area.is_empty()) |
| 30 | return; |
| 31 | |
| 32 | fill_rect(c,rect,rgb_pixel(212,208,200)); |
| 33 | |
| 34 | unsigned char red, green, blue; |
| 35 | if (enabled) |
| 36 | { |
| 37 | red = 0; |
| 38 | green = 0; |
| 39 | blue = 0; |
| 40 | } |
| 41 | else |
| 42 | { |
| 43 | red = 128; |
| 44 | green = 128; |
| 45 | blue = 128; |
| 46 | } |
| 47 | |
| 48 | // compute the name length if it hasn't already been computed |
| 49 | if (name_width == 0) |
| 50 | { |
| 51 | unsigned long height; |
| 52 | mfont.compute_size(name,name_width,height); |
| 53 | } |
| 54 | |
| 55 | // figure out where the name string should appear |
| 56 | rectangle name_rect; |
| 57 | const unsigned long width = name_width; |
| 58 | const unsigned long height = mfont.height(); |
| 59 | name_rect.set_left((rect.right() + rect.left() - width)/2); |
| 60 | name_rect.set_top((rect.bottom() + rect.top() - height)/2 + 1); |
| 61 | name_rect.set_right(name_rect.left()+width-1); |
| 62 | name_rect.set_bottom(name_rect.top()+height); |
| 63 | |
| 64 | |
| 65 | if (is_depressed) |
| 66 | { |
| 67 | name_rect.set_left(name_rect.left()+1); |
| 68 | name_rect.set_right(name_rect.right()+1); |
| 69 | name_rect.set_top(name_rect.top()+1); |
| 70 | name_rect.set_bottom(name_rect.bottom()+1); |
| 71 | |
| 72 | mfont.draw_string(c,name_rect,name,rgb_pixel(red,green,blue)); |
| 73 | |
| 74 | draw_button_down(c,rect); |
no test coverage detected