00001 #include "gui_focusframe.hpp" 00002 #include "gui_manager.hpp" 00003 00004 using namespace input; 00005 00006 namespace gui 00007 { 00008 focus_frame::focus_frame(manager* pManager) : frame(pManager), 00009 bFocus_(false), bAutoFocus_(false) 00010 { 00011 lType_.push_back("FocusFrame"); 00012 } 00013 00014 focus_frame::~focus_frame() 00015 { 00016 set_focus(false); 00017 } 00018 00019 void focus_frame::copy_from(uiobject* pObj) 00020 { 00021 frame::copy_from(pObj); 00022 00023 focus_frame* pFocusFrame = dynamic_cast<focus_frame*>(pObj); 00024 00025 if (pFocusFrame) 00026 this->enable_auto_focus(pFocusFrame->is_auto_focus_enabled()); 00027 } 00028 00029 void focus_frame::create_glue() 00030 { 00031 if (bVirtual_) 00032 { 00033 utils::wptr<lua::state> pLua = pManager_->get_lua(); 00034 pLua->push_number(uiID_); 00035 lGlueList_.push_back(pLua->push_new<lua_virtual_glue>()); 00036 pLua->set_global(sLuaName_); 00037 pLua->pop(); 00038 } 00039 else 00040 { 00041 utils::wptr<lua::state> pLua = pManager_->get_lua(); 00042 pLua->push_string(sLuaName_); 00043 lGlueList_.push_back(pLua->push_new<lua_focus_frame>()); 00044 pLua->set_global(sLuaName_); 00045 pLua->pop(); 00046 } 00047 } 00048 00049 void focus_frame::enable_auto_focus(bool bEnable) 00050 { 00051 bAutoFocus_ = bEnable; 00052 } 00053 00054 bool focus_frame::is_auto_focus_enabled() const 00055 { 00056 return bAutoFocus_; 00057 } 00058 00059 void focus_frame::set_focus(bool bFocus) 00060 { 00061 if (bFocus) 00062 pManager_->request_focus(this); 00063 else if (bFocus_) 00064 pManager_->request_focus(nullptr); 00065 } 00066 00067 void focus_frame::notify_focus(bool bFocus) 00068 { 00069 bFocus_ = bFocus; 00070 } 00071 }