#include <spin_button_big.h>
Inheritance diagram for SpinButtonBig:
Public Member Functions | |
SpinButtonBig (const std::string &label, const Rectanglei &rect, int value=0, int step=1, int min_value=-1, int max_value=-1) | |
virtual | ~SpinButtonBig () |
void | SetSizePosition (const Rectanglei &rect) |
void | Draw (const Point2i &mousePosition, Surface &surf) const |
Widget * | Clic (const Point2i &mousePosition, uint button) |
int | GetValue () const |
void | SetValue (int value) |
Protected Attributes | |
Text * | txt_label |
Text * | txt_value |
int | m_value |
int | m_min_value |
int | m_max_value |
int | m_step |
Button * | m_plus |
Button * | m_minus |
Definition at line 31 of file spin_button_big.h.
SpinButtonBig::SpinButtonBig | ( | const std::string & | label, | |
const Rectanglei & | rect, | |||
int | value = 0 , |
|||
int | step = 1 , |
|||
int | min_value = -1 , |
|||
int | max_value = -1 | |||
) |
Definition at line 28 of file spin_button_big.cpp.
00030 { 00031 position = rect.GetPosition(); 00032 size = rect.GetSize(); 00033 00034 Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false); 00035 00036 txt_label = new Text(label, dark_gray_color, Font::GetInstance(Font::FONT_NORMAL, Font::BOLD), false); 00037 txt_label->SetMaxWidth(GetSizeX()); 00038 00039 if ( min_value != -1 && min_value <= value) 00040 m_min_value = min_value; 00041 else m_min_value = value/2; 00042 00043 if ( max_value != -1 && max_value >= value) 00044 m_max_value = max_value; 00045 else m_max_value = value*2; 00046 00047 txt_value = new Text("", dark_gray_color, Font::GetInstance(Font::FONT_HUGE), false); 00048 SetValue(value); 00049 00050 std::ostringstream max_value_s; 00051 max_value_s << m_max_value ; 00052 uint max_value_w = (*Font::GetInstance(Font::FONT_HUGE)).GetWidth(max_value_s.str()); 00053 00054 uint margin = 5; 00055 00056 m_plus = new Button( Point2i(position.x + size.x - 5, position.y), res, "menu/big_plus"); 00057 m_minus = new Button( Point2i(position.x + size.x - max_value_w - 5 - 2 * margin, position.y), res, "menu/big_minus"); 00058 resource_manager.UnLoadXMLProfile( res); 00059 m_step = step; 00060 }
Here is the call graph for this function:
SpinButtonBig::~SpinButtonBig | ( | ) | [virtual] |
Reimplemented from Widget.
Definition at line 108 of file spin_button_big.cpp.
00109 { 00110 need_redrawing = true; 00111 00112 if( (button == SDL_BUTTON_WHEELDOWN && Contains(mousePosition)) || 00113 (button == SDL_BUTTON_LEFT && m_minus->Contains(mousePosition)) ){ 00114 SetValue(m_value - m_step); 00115 return this; 00116 } else 00117 if( (button == SDL_BUTTON_WHEELUP && Contains(mousePosition)) || 00118 (button == SDL_BUTTON_LEFT && m_plus->Contains(mousePosition)) ){ 00119 SetValue(m_value + m_step); 00120 return this; 00121 } 00122 return NULL; 00123 }
Here is the call graph for this function:
Here is the caller graph for this function:
Implements Widget.
Definition at line 93 of file spin_button_big.cpp.
00094 { 00095 m_minus->Draw(mousePosition, surf); 00096 m_plus->Draw(mousePosition, surf); 00097 00098 uint center_x = GetPositionX() + (GetSizeX()/2); 00099 uint center_y = GetPositionY() + (GetSizeY()/2) - txt_label->GetHeight()/2; 00100 uint value_h = Font::GetInstance(Font::FONT_HUGE)->GetHeight(); 00101 00102 txt_value->DrawCenterTop(center_x, center_y - value_h/2); 00103 00104 txt_label->DrawCenterTop( GetPositionX() + GetSizeX()/2, 00105 GetPositionY() + GetSizeY() - txt_label->GetHeight() ); 00106 }
Here is the call graph for this function:
int SpinButtonBig::GetValue | ( | ) | const |
Definition at line 125 of file spin_button_big.cpp.
00126 { 00127 return m_value; 00128 }
Here is the caller graph for this function:
void SpinButtonBig::SetSizePosition | ( | const Rectanglei & | rect | ) | [virtual] |
Implements Widget.
Definition at line 70 of file spin_button_big.cpp.
00071 { 00072 StdSetSizePosition(rect); 00073 00074 // label can be multiline 00075 txt_label->SetMaxWidth(GetSizeX()); 00076 00077 std::ostringstream max_value_s; 00078 max_value_s << m_max_value ; 00079 uint max_value_w = Font::GetInstance(Font::FONT_HUGE)->GetWidth(max_value_s.str()); 00080 00081 // center the value 00082 uint center_x = GetPositionX() + GetSizeX()/2 ; 00083 uint center_y = GetPositionY() + GetSizeY()/2 - txt_label->GetHeight()/2; 00084 00085 m_minus->SetSizePosition( Rectanglei(center_x - max_value_w/2 - m_minus->GetSizeX() - 5, 00086 center_y - m_minus->GetSizeY()/2, 00087 m_minus->GetSizeX(), m_minus->GetSizeY()) ); 00088 m_plus->SetSizePosition( Rectanglei(center_x + max_value_w/2 + 5, 00089 center_y - m_plus->GetSizeY()/2, 00090 m_plus->GetSizeX(), m_plus->GetSizeY()) ); 00091 }
Here is the call graph for this function:
void SpinButtonBig::SetValue | ( | int | value | ) |
Definition at line 130 of file spin_button_big.cpp.
00131 { 00132 m_value = BorneLong(value, m_min_value, m_max_value); 00133 00134 std::ostringstream value_s; 00135 value_s << m_value ; 00136 00137 std::string s(value_s.str()); 00138 txt_value->Set(s); 00139 }
Here is the call graph for this function:
Here is the caller graph for this function:
int SpinButtonBig::m_max_value [protected] |
Definition at line 37 of file spin_button_big.h.
int SpinButtonBig::m_min_value [protected] |
Definition at line 37 of file spin_button_big.h.
Button * SpinButtonBig::m_minus [protected] |
Definition at line 38 of file spin_button_big.h.
Button* SpinButtonBig::m_plus [protected] |
Definition at line 38 of file spin_button_big.h.
int SpinButtonBig::m_step [protected] |
Definition at line 37 of file spin_button_big.h.
int SpinButtonBig::m_value [protected] |
Definition at line 36 of file spin_button_big.h.
Text* SpinButtonBig::txt_label [protected] |
Definition at line 34 of file spin_button_big.h.
Text * SpinButtonBig::txt_value [protected] |
Definition at line 34 of file spin_button_big.h.