00001 #ifndef SGE_GUI_MANAGER_HPP_INCLUDED 00002 #define SGE_GUI_MANAGER_HPP_INCLUDED 00003 00004 #include "types.hpp" 00005 00006 #include "../renderer/device.hpp" 00007 #include "../input/system.hpp" 00008 #include "../font/system.hpp" 00009 #include "../sprite/object.hpp" 00010 #include "../sprite/system.hpp" 00011 #include "../scoped_connection.hpp" 00012 #include "../image/loader.hpp" 00013 #include "../export.hpp" 00014 00015 namespace sge 00016 { 00017 namespace gui 00018 { 00019 // forward declaration 00020 class widget; 00021 00022 class manager 00023 { 00024 public: 00025 SGE_SYMBOL manager(renderer::device_ptr,image::loader_ptr,input::system_ptr,font::system_ptr); 00026 SGE_SYMBOL void invalidate(rect const &); 00027 SGE_SYMBOL void draw(); 00028 font::metrics_ptr const standard_font() { return standard_font_; } 00029 renderer::color const standard_color() const { return standard_color_; } 00030 renderer::color const standard_color_focused() const { return standard_color_focused_; } 00031 00032 private: 00033 friend class widget; 00034 00035 struct widget_data 00036 { 00037 widget_data( 00038 widget&, 00039 renderer::texture_ptr, 00040 sprite::object const &); 00041 00042 widget *ptr; 00043 renderer::texture_ptr texture; 00044 sprite::object spr; 00045 }; 00046 typedef std::vector<widget_data> widget_container; 00047 typedef std::vector<rect> dirt_container; 00048 00049 // engine relevant stuff 00050 renderer::device_ptr const rend; 00051 image::loader_ptr const il; 00052 input::system_ptr const is; 00053 font::system_ptr const fs; 00054 font::metrics_ptr const standard_font_; 00055 renderer::color const standard_color_; 00056 renderer::color const standard_color_focused_; 00057 scoped_connection ic; 00058 sprite::system ss; 00059 sge::sprite::object cursor; 00060 sge::sprite::point cursor_click; 00061 00062 // other internal stuff 00063 widget_container widgets_; 00064 dirt_container dirt_; 00065 00066 // focus 00067 widget *keyboard_focus; 00068 widget *mouse_focus; 00069 00070 // this is called by widget's constructor and destructor 00071 void add(widget &); 00072 void remove(widget &); 00073 void compile(widget &); 00074 00075 // this is called by widget's size/pos function (if it encounters a top level widget) 00076 void resize(widget &,dim const &); 00077 void reposition(widget &,point const &); 00078 00079 // internal search functions (just convenience) 00080 widget_data &get_data(widget &); 00081 widget_container::iterator get_data_iterator(widget &); 00082 widget_data &parent_widget_data(widget &); 00083 void recalculate_mouse_focus(); 00084 00085 // registered input callback 00086 void input_callback(input::key_pair const &); 00087 00088 void redraw_dirt(); 00089 }; 00090 } 00091 } 00092 00093 #endif
1.5.5