00001 #ifndef GUI_SCROLLFRAME_HPP 00002 #define GUI_SCROLLFRAME_HPP 00003 00004 #include <utils.hpp> 00005 #include "gui_frame.hpp" 00006 00007 namespace gui 00008 { 00009 class texture; 00010 00012 00016 class scroll_frame : public frame 00017 { 00018 public : 00019 00021 explicit scroll_frame(manager* pManager); 00022 00024 virtual ~scroll_frame(); 00025 00027 virtual void update(float fDelta); 00028 00030 00032 virtual void copy_from(uiobject* pObj); 00033 00035 00038 virtual bool can_use_script(const std::string& sScriptName) const; 00039 00041 00044 virtual void on(const std::string& sScriptName, event* pEvent = nullptr); 00045 00047 00050 void set_scroll_child(frame* pFrame); 00051 00053 00055 frame* get_scroll_child(); 00056 00058 00060 void set_horizontal_scroll(int iHorizontalScroll); 00061 00063 00065 int get_horizontal_scroll() const; 00066 00068 00070 int get_horizontal_scroll_range() const; 00071 00073 00075 void set_vertical_scroll(int iVerticalScroll); 00076 00078 00080 int get_vertical_scroll() const; 00081 00083 00085 int get_vertical_scroll_range() const; 00086 00088 00097 virtual bool is_in_frame(int iX, int iY) const; 00098 00100 00104 virtual void notify_mouse_in_frame(bool bMouseInFrame, int iX, int iY); 00105 00107 virtual void fire_redraw() const; 00108 00110 00115 virtual void notify_child_strata_changed(frame* pChild); 00116 00118 virtual void create_glue(); 00119 00121 00123 virtual void parse_block(xml::block* pBlock); 00124 00126 static void register_glue(utils::wptr<lua::state> pLua); 00127 00128 protected : 00129 00130 virtual void parse_scroll_child_block_(xml::block* pBlock); 00131 00132 virtual void notify_manually_rendered_object_(uiobject* pObject, bool bManuallyRendered); 00133 00134 void add_to_scroll_child_list_(frame* pChild); 00135 void remove_from_scroll_child_list_(frame* pChild); 00136 00137 void update_scroll_range_(); 00138 void update_scroll_child_input_(); 00139 void rebuild_scroll_render_target_(); 00140 void rebuild_scroll_strata_list_(); 00141 void render_scroll_strata_list_(); 00142 00143 int iHorizontalScroll_; 00144 int iHorizontalScrollRange_; 00145 int iVerticalScroll_; 00146 int iVerticalScrollRange_; 00147 00148 frame* pScrollChild_; 00149 00150 mutable bool bRebuildScrollRenderTarget_; 00151 mutable bool bRedrawScrollRenderTarget_; 00152 mutable bool bUpdateScrollRange_; 00153 utils::refptr<render_target> pScrollRenderTarget_; 00154 00155 texture* pScrollTexture_; 00156 00157 mutable bool bRebuildScrollStrataList_; 00158 std::map<uint, frame*> lScrollChildList_; 00159 std::map<frame_strata, strata> lScrollStrataList_; 00160 00161 bool bMouseInScrollTexture_; 00162 frame* pOveredScrollChild_; 00163 }; 00164 00168 class lua_scroll_frame : public lua_frame 00169 { 00170 public : 00171 00172 lua_scroll_frame(lua_State* pLua); 00173 00174 // Glues 00175 int _get_horizontal_scroll(lua_State*); 00176 int _get_horizontal_scroll_range(lua_State*); 00177 int _get_scroll_child(lua_State*); 00178 int _get_vertical_scroll(lua_State*); 00179 int _get_vertical_scroll_range(lua_State*); 00180 int _set_horizontal_scroll(lua_State*); 00181 int _set_scroll_child(lua_State*); 00182 int _set_vertical_scroll(lua_State*); 00183 00184 static const char className[]; 00185 static const char* classList[]; 00186 static Lunar<lua_scroll_frame>::RegType methods[]; 00187 00188 protected : 00189 00190 scroll_frame* pScrollFrameParent_; 00191 }; 00192 00195 } 00196 00197 #endif