/** ******************************************************************************* * @file ewolWidgetManager.cpp * @brief basic ewol Widget Manager (Sources) * @author Edouard DUPIN * @date 13/11/2011 * @par Project * ewol * * @par Copyright * Copyright 2011 Edouard DUPIN, all right reserved * * This software is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY. * * Licence summary : * You can modify and redistribute the sources code and binaries. * You can send me the bug-fix * * Term of the licence in in the file licence.txt. * ******************************************************************************* */ #include #undef __class__ #define __class__ "ewol::WidgetManager" // internal element of the widget manager : static etk::VectorType m_widgetList; // all widget allocated ==> all time increment ... never removed ... // For the focus Management static ewol::Widget * m_focusWidgetDefault = NULL; static ewol::Widget * m_focusWidgetCurrent = NULL; void ewol::widgetManager::Init(void) { EWOL_INFO("user widget manager"); } void ewol::widgetManager::UnInit(void) { EWOL_INFO("Realease all FOCUS"); ewol::widgetManager::FocusSetDefault(NULL); ewol::widgetManager::FocusRelease(); EWOL_INFO(" Remove missing user widget"); for(int32_t iii=0; iiiCanHaveFocus()) { EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::GetId(newWidget)); return; } if (newWidget == m_focusWidgetCurrent) { // nothing to do ... return; } if (NULL != m_focusWidgetCurrent) { EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent)); m_focusWidgetCurrent->RmFocus(); } m_focusWidgetCurrent = newWidget; if (NULL != m_focusWidgetCurrent) { EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent)); m_focusWidgetCurrent->SetFocus(); } } void ewol::widgetManager::FocusSetDefault(ewol::Widget * newWidget) { if (NULL != newWidget && false == newWidget->CanHaveFocus()) { EWOL_VERBOSE("Widget can not have Focus, id=" << ewol::widgetManager::GetId(newWidget)); return; } if (m_focusWidgetDefault == m_focusWidgetCurrent) { if (NULL != m_focusWidgetCurrent) { EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent)); m_focusWidgetCurrent->RmFocus(); } m_focusWidgetCurrent = newWidget; if (NULL != m_focusWidgetCurrent) { EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent)); m_focusWidgetCurrent->SetFocus(); } } m_focusWidgetDefault = newWidget; } void ewol::widgetManager::FocusRelease(void) { if (m_focusWidgetDefault == m_focusWidgetCurrent) { // nothink to do ... return; } if (NULL != m_focusWidgetCurrent) { EWOL_DEBUG("Rm Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent)); m_focusWidgetCurrent->RmFocus(); } m_focusWidgetCurrent = m_focusWidgetDefault; if (NULL != m_focusWidgetCurrent) { EWOL_DEBUG("Set Focus on WidgetID=" << ewol::widgetManager::GetId(m_focusWidgetCurrent)); m_focusWidgetCurrent->SetFocus(); } } ewol::Widget * ewol::widgetManager::FocusGet(void) { return m_focusWidgetCurrent; }