src/widget/widget_button_txt.cpp
branchcpp_gui
changeset 6301 e0251f797d59
parent 6295 a88d8c2cff6e
equal deleted inserted replaced
6300:1f0d2abac815 6301:e0251f797d59
    18 #include "window_events.hpp"
    18 #include "window_events.hpp"
    19 #include "widget_types.h"
    19 #include "widget_types.h"
    20 
    20 
    21 namespace gui {
    21 namespace gui {
    22 
    22 
       
    23 StringID TextButton::GetTextId()
       
    24 {
       
    25 	if (m_text_id != STR_NULL) return m_text_id;
       
    26 	StringID temp_id = BindCString(m_text.c_str());
       
    27 	return temp_id;
       
    28 }
       
    29 
       
    30 /*virtual*/ void TextButton::QuerySizes()
       
    31 {
       
    32 	static Point16 border_size(6, 2);
       
    33 	StringID text_id = GetTextId();
       
    34 	m_min_size = GetStringSize(text_id) + border_size;
       
    35 }
       
    36 
    23 /*virtual*/ void TextButton::OnPaint(EvtPaint &ev)
    37 /*virtual*/ void TextButton::OnPaint(EvtPaint &ev)
    24 {
    38 {
    25 	DrawBackground(ev);
    39 	DrawBackground(ev);
    26 	Point center = Size() / 2;
    40 	Point center = GetSize() / 2;
    27 	if (m_pushed) center += Point(1, 1);
    41 	if (m_pushed) center += Point(1, 1);
    28 	DrawStringCentered(center.x, center.y - 5, m_text, 0);
    42 	StringID text_id = GetTextId();
       
    43 	DrawStringCentered(center.x, center.y - 5, text_id, 16);
    29 	ev.SetHandled();
    44 	ev.SetHandled();
    30 }
    45 }
    31 
    46 
    32 
    47 
    33 }; // namespace gui
    48 }; // namespace gui