00001 #ifndef GUI_SLIDER_HPP 00002 #define GUI_SLIDER_HPP 00003 00004 #include <utils.hpp> 00005 #include "gui_frame.hpp" 00006 00007 namespace gui 00008 { 00009 class texture; 00010 00012 00017 class slider : public frame 00018 { 00019 public : 00020 00021 enum orientation 00022 { 00023 ORIENT_VERTICAL, 00024 ORIENT_HORIZONTAL 00025 }; 00026 00028 explicit slider(manager* pManager); 00029 00031 virtual ~slider(); 00032 00034 00037 virtual std::string serialize(const std::string& sTab) const; 00038 00040 00043 virtual bool can_use_script(const std::string& sScriptName) const; 00044 00046 00048 virtual void copy_from(uiobject* pObj); 00049 00051 00053 void set_thumb_texture(texture* pTexture); 00054 00056 00058 texture* get_thumb_texture() const; 00059 00061 00063 void set_orientation(orientation mOrientation); 00064 00066 00068 orientation get_orientation() const; 00069 00071 00074 void set_min_max_values(float fMin, float fMax); 00075 00077 00079 void set_min_value(float fMin); 00080 00082 00084 void set_max_value(float fMax); 00085 00087 00089 float get_min_value() const; 00090 00092 00094 float get_max_value() const; 00095 00097 00100 void set_value(float fValue, bool bSilent = false); 00101 00103 00105 float get_value() const; 00106 00108 00110 void set_value_step(float fValueStep); 00111 00113 00115 float get_value_step() const; 00116 00118 00120 void set_thumb_draw_layer(layer_type mThumbLayer); 00121 00123 00125 void set_thumb_draw_layer(const std::string& sBarLayer); 00126 00128 00130 layer_type get_thumb_draw_layer() const; 00131 00133 00135 void set_allow_clicks_outside_thumb(bool bAllow); 00136 00138 00141 bool are_clicks_outside_thumb_allowed(); 00142 00144 00150 virtual bool is_in_frame(int iX, int iY) const; 00151 00153 00157 virtual void notify_mouse_in_frame(bool bMouseInFrame, int iX, int iY); 00158 00160 00162 virtual void on_event(const event& mEvent); 00163 00165 virtual void create_glue(); 00166 00168 00170 virtual void parse_block(xml::block* pBlock); 00171 00173 virtual void fire_update_borders() const; 00174 00176 virtual void update(float fDelta); 00177 00179 static void register_glue(utils::wptr<lua::state> pLua); 00180 00181 protected : 00182 00183 void constrain_thumb_(); 00184 00185 texture* create_thumb_texture_(); 00186 void fire_update_thumb_texture_() const; 00187 00188 mutable bool bUpdateThumbTexture_; 00189 00190 orientation mOrientation_; 00191 00192 float fValue_; 00193 float fMinValue_; 00194 float fMaxValue_; 00195 float fValueStep_; 00196 00197 bool bAllowClicksOutsideThumb_; 00198 00199 layer_type mThumbLayer_; 00200 texture* pThumbTexture_; 00201 bool bThumbMoved_; 00202 bool bMouseInThumb_; 00203 }; 00204 00208 class lua_slider : public lua_frame 00209 { 00210 public : 00211 00212 explicit lua_slider(lua_State* pLua); 00213 00214 // Glues 00215 int _allow_clicks_outside_thumb(lua_State*); 00216 int _get_max_value(lua_State*); 00217 int _get_min_value(lua_State*); 00218 int _get_min_max_values(lua_State*); 00219 int _get_orientation(lua_State*); 00220 int _get_thumb_texture(lua_State*); 00221 int _get_value(lua_State*); 00222 int _get_value_step(lua_State*); 00223 int _set_max_value(lua_State*); 00224 int _set_min_value(lua_State*); 00225 int _set_min_max_values(lua_State*); 00226 int _set_orientation(lua_State*); 00227 int _set_thumb_texture(lua_State*); 00228 int _set_value(lua_State*); 00229 int _set_value_step(lua_State*); 00230 00231 static const char className[]; 00232 static const char* classList[]; 00233 static Lunar<lua_slider>::RegType methods[]; 00234 00235 protected : 00236 00237 slider* pSliderParent_; 00238 }; 00239 00242 } 00243 00244 #endif