#include <spin_button_picture.h>
Inheritance diagram for SpinButtonWithPicture:
Public Member Functions | |
SpinButtonWithPicture (const std::string &label, const std::string &resource_id, const Rectanglei &rect, int value=0, int step=1, int min_value=-1, int max_value=-1) | |
virtual | ~SpinButtonWithPicture () |
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 |
Private Attributes | |
Surface | m_image |
Definition at line 31 of file spin_button_picture.h.
SpinButtonWithPicture::SpinButtonWithPicture | ( | const std::string & | label, | |
const std::string & | resource_id, | |||
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_picture.cpp.
00031 { 00032 position = rect.GetPosition(); 00033 size = rect.GetSize(); 00034 00035 Profile *res = resource_manager.LoadXMLProfile( "graphism.xml", false); 00036 m_image = resource_manager.LoadImage(res, resource_id); 00037 resource_manager.UnLoadXMLProfile( res); 00038 00039 txt_label = new Text(label, dark_gray_color, Font::GetInstance(Font::FONT_NORMAL, Font::BOLD), false); 00040 txt_label->SetMaxWidth(GetSizeX()); 00041 00042 if ( min_value != -1 && min_value <= value) 00043 m_min_value = min_value; 00044 else m_min_value = value/2; 00045 00046 if ( max_value != -1 && max_value >= value) 00047 m_max_value = max_value; 00048 else m_max_value = value*2; 00049 00050 txt_value = new Text("", dark_gray_color, Font::GetInstance(Font::FONT_LARGE), false); 00051 SetValue(value); 00052 00053 m_step = step; 00054 }
Here is the call graph for this function:
SpinButtonWithPicture::~SpinButtonWithPicture | ( | ) | [virtual] |
Reimplemented from Widget.
Definition at line 87 of file spin_button_picture.cpp.
00088 { 00089 need_redrawing = true; 00090 00091 if (button == SDL_BUTTON_LEFT && Contains(mousePosition)) { 00092 00093 m_value += m_step; 00094 if (m_value > m_max_value) SetValue(m_min_value); 00095 else SetValue(m_value); 00096 00097 } else if (button == SDL_BUTTON_RIGHT && Contains(mousePosition)) { 00098 00099 m_value -= m_step; 00100 if (m_value < m_min_value) SetValue(m_max_value); 00101 else SetValue(m_value); 00102 00103 } else if( button == SDL_BUTTON_WHEELDOWN && Contains(mousePosition) ) { 00104 00105 SetValue(m_value - m_step); 00106 return this; 00107 00108 } else if( button == SDL_BUTTON_WHEELUP && Contains(mousePosition) ) { 00109 00110 SetValue(m_value + m_step); 00111 return this; 00112 } 00113 return NULL; 00114 }
Here is the call graph for this function:
Implements Widget.
Definition at line 68 of file spin_button_picture.cpp.
00069 { 00070 // center the image on the first half 00071 uint tmp_x = GetPositionX() + (GetSizeX() - m_image.GetWidth())/4 ; 00072 uint tmp_y = GetPositionY() + (GetSizeY() - m_image.GetHeight() - txt_label->GetHeight() - 5) /2; 00073 00074 AppWormux::GetInstance()->video.window.Blit(m_image, Point2i(tmp_x, tmp_y)); 00075 00076 tmp_x = GetPositionX() + (3*GetSizeX()/4); 00077 tmp_y = GetPositionY() + (GetSizeY()/2) - txt_label->GetHeight()/2; 00078 00079 uint value_h = Font::GetInstance(Font::FONT_HUGE)->GetHeight(); 00080 00081 txt_value->DrawCenterTop(tmp_x, tmp_y - value_h/2); 00082 00083 txt_label->DrawCenterTop( GetPositionX() + GetSizeX()/2, 00084 GetPositionY() + GetSizeY() - txt_label->GetHeight() ); 00085 }
Here is the call graph for this function:
int SpinButtonWithPicture::GetValue | ( | ) | const |
Definition at line 116 of file spin_button_picture.cpp.
00117 { 00118 return m_value; 00119 }
Here is the caller graph for this function:
void SpinButtonWithPicture::SetSizePosition | ( | const Rectanglei & | rect | ) | [virtual] |
Implements Widget.
Definition at line 62 of file spin_button_picture.cpp.
00063 { 00064 StdSetSizePosition(rect); 00065 txt_label->SetMaxWidth(GetSizeX()); 00066 }
Here is the call graph for this function:
void SpinButtonWithPicture::SetValue | ( | int | value | ) |
Definition at line 121 of file spin_button_picture.cpp.
00122 { 00123 m_value = BorneLong(value, m_min_value, m_max_value); 00124 00125 std::ostringstream value_s; 00126 value_s << m_value ; 00127 00128 std::string s(value_s.str()); 00129 txt_value->Set(s); 00130 00131 ForceRedraw(); 00132 }
Here is the call graph for this function:
Here is the caller graph for this function:
Surface SpinButtonWithPicture::m_image [private] |
Definition at line 34 of file spin_button_picture.h.
int SpinButtonWithPicture::m_max_value [protected] |
Definition at line 40 of file spin_button_picture.h.
int SpinButtonWithPicture::m_min_value [protected] |
Definition at line 40 of file spin_button_picture.h.
int SpinButtonWithPicture::m_step [protected] |
Definition at line 40 of file spin_button_picture.h.
int SpinButtonWithPicture::m_value [protected] |
Definition at line 39 of file spin_button_picture.h.
Text* SpinButtonWithPicture::txt_label [protected] |
Definition at line 37 of file spin_button_picture.h.
Text * SpinButtonWithPicture::txt_value [protected] |
Definition at line 37 of file spin_button_picture.h.