void CGUIDialogVisualisationSettings::SetupPage() { // cleanup first, if necessary FreeControls(); m_pOriginalSpin = (CGUISpinControlEx*)GetControl(CONTROL_DEFAULT_SPIN); m_pOriginalRadioButton = (CGUIRadioButtonControl *)GetControl(CONTROL_DEFAULT_RADIOBUTTON); m_pOriginalSettingsButton = (CGUIButtonControl *)GetControl(CONTROL_DEFAULT_BUTTON); if (!m_pOriginalSpin || !m_pOriginalRadioButton || !m_pOriginalSettingsButton) return; m_pOriginalSpin->SetVisible(false); m_pOriginalRadioButton->SetVisible(false); m_pOriginalSettingsButton->SetVisible(false); // update our settings label CStdString strSettings; strSettings.Format("%s %s", g_infoManager.GetLabel(402).c_str(), g_localizeStrings.Get(5)); SET_CONTROL_LABEL(CONTROL_SETTINGS_LABEL, strSettings); CGUIControlGroupList *group = (CGUIControlGroupList *)GetControl(CONTROL_GROUP_LIST); #ifdef PRE_SKIN_VERSION_2_1_COMPATIBILITY if (!group || group->GetControlType() != CGUIControl::GUICONTROL_GROUPLIST) { // our controls for layout... CGUIControl *pArea = (CGUIControl *)GetControl(CONTROL_AREA); const CGUIControl *pGap = GetControl(CONTROL_GAP); if (!pArea || !pGap) return; Remove(CONTROL_AREA); group = new CGUIControlGroupList(GetID(), CONTROL_GROUP_LIST, pArea->GetXPosition(), pArea->GetYPosition(), pArea->GetWidth(), pArea->GetHeight(), pGap->GetHeight() - m_pOriginalSettingsButton->GetHeight(), 0, VERTICAL, false); group->SetNavigation(CONTROL_GROUP_LIST, CONTROL_GROUP_LIST, CONTROL_GROUP_LIST, CONTROL_GROUP_LIST); Insert(group, pGap); pArea->FreeResources(); delete pArea; SET_CONTROL_HIDDEN(CONTROL_PAGE); } #endif if (!group) return; if (!m_pSettings || !m_pSettings->size()) { // no settings available SET_CONTROL_VISIBLE(CONTROL_NONE_AVAILABLE); return; } else { SET_CONTROL_HIDDEN(CONTROL_NONE_AVAILABLE); } // run through and create our controls for (unsigned int i = 0; i < m_pSettings->size(); i++) { VisSetting &setting = m_pSettings->at(i); AddSetting(setting, group->GetWidth(), CONTROL_START + i); } UpdateSettings(); }
void CGUIControlGroup::FreeResources(bool immediately) { CGUIControl::FreeResources(immediately); for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; control->FreeResources(immediately); } }
void CGUIDialogContextMenu::ClearButtons() { // destroy our buttons (if we have them from a previous viewing) for (int i = 1; i <= m_iNumButtons; i++) { // get the button to remove... CGUIControl *pControl = (CGUIControl *)GetControl(BUTTON_TEMPLATE + i); if (pControl) { // remove the control from our list RemoveControl(pControl); // kill the button pControl->FreeResources(); delete pControl; } } m_iNumButtons = 0; }
void CGUIWindow::ChangeButtonToEdit(int id, bool singleLabel /* = false*/) { #ifdef PRE_SKIN_VERSION_9_10_COMPATIBILITY CGUIControl *name = (CGUIControl *)GetControl(id); if (name && name->GetControlType() == CGUIControl::GUICONTROL_BUTTON) { // change it to an edit control CGUIEditControl *edit = new CGUIEditControl(*(const CGUIButtonControl *)name); if (edit) { if (singleLabel) edit->SetLabel(""); InsertControl(edit, name); RemoveControl(name); name->FreeResources(); delete name; } } #endif }
bool CGUIWindow::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_INIT: { CLog::Log(LOGDEBUG, "------ Window Init (%s) ------", GetProperty("xmlfile").c_str()); if (m_dynamicResourceAlloc || !m_bAllocated) AllocResources(); OnInitWindow(); return true; } break; case GUI_MSG_WINDOW_DEINIT: { CLog::Log(LOGDEBUG, "------ Window Deinit (%s) ------", GetProperty("xmlfile").c_str()); OnDeinitWindow(message.GetParam1()); // now free the window if (m_dynamicResourceAlloc) FreeResources(); return true; } break; case GUI_MSG_CLICKED: { // a specific control was clicked CLICK_EVENT clickEvent = m_mapClickEvents[ message.GetSenderId() ]; // determine if there are any handlers for this event if (clickEvent.HasAHandler()) { // fire the message to all handlers clickEvent.Fire(message); } break; } case GUI_MSG_SELCHANGED: { // a selection within a specific control has changed SELECTED_EVENT selectedEvent = m_mapSelectedEvents[ message.GetSenderId() ]; // determine if there are any handlers for this event if (selectedEvent.HasAHandler()) { // fire the message to all handlers selectedEvent.Fire(message); } break; } case GUI_MSG_FOCUSED: { // a control has been focused if (HasID(message.GetSenderId())) { m_focusedControl = message.GetControlId(); return true; } break; } case GUI_MSG_LOSTFOCUS: { // nothing to do at the window level when we lose focus return true; } case GUI_MSG_MOVE: { if (HasID(message.GetSenderId())) return OnMove(message.GetControlId(), message.GetParam1()); break; } case GUI_MSG_SETFOCUS: { // CLog::Log(LOGDEBUG,"set focus to control:%i window:%i (%i)\n", message.GetControlId(),message.GetSenderId(), GetID()); if ( message.GetControlId() ) { // first unfocus the current control CGUIControl *control = GetFocusedControl(); if (control) { CGUIMessage msgLostFocus(GUI_MSG_LOSTFOCUS, GetID(), control->GetID(), message.GetControlId()); control->OnMessage(msgLostFocus); } // get the control to focus CGUIControl* pFocusedControl = GetFirstFocusableControl(message.GetControlId()); if (!pFocusedControl) pFocusedControl = (CGUIControl *)GetControl(message.GetControlId()); // and focus it if (pFocusedControl) return pFocusedControl->OnMessage(message); } return true; } break; case GUI_MSG_EXCLUSIVE_MOUSE: { m_exclusiveMouseControl = message.GetSenderId(); return true; } break; case GUI_MSG_GESTURE_NOTIFY: { CAction action(ACTION_GESTURE_NOTIFY, 0, (float)message.GetParam1(), (float)message.GetParam2(), 0, 0); EVENT_RESULT result = OnMouseAction(action); message.SetParam1(result); return result != EVENT_RESULT_UNHANDLED; } case GUI_MSG_ADD_CONTROL: { if (message.GetPointer()) { CGUIControl *control = (CGUIControl *)message.GetPointer(); control->AllocResources(); AddControl(control); } return true; } case GUI_MSG_REMOVE_CONTROL: { if (message.GetPointer()) { CGUIControl *control = (CGUIControl *)message.GetPointer(); RemoveControl(control); control->FreeResources(true); delete control; } return true; } case GUI_MSG_NOTIFY_ALL: { // only process those notifications that come from this window, or those intended for every window if (HasID(message.GetSenderId()) || !message.GetSenderId()) { if (message.GetParam1() == GUI_MSG_PAGE_CHANGE || message.GetParam1() == GUI_MSG_REFRESH_THUMBS || message.GetParam1() == GUI_MSG_REFRESH_LIST || message.GetParam1() == GUI_MSG_WINDOW_RESIZE) { // alter the message accordingly, and send to all controls for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; CGUIMessage msg(message.GetParam1(), message.GetControlId(), control->GetID(), message.GetParam2()); control->OnMessage(msg); } } } } break; } return SendControlMessage(message); }
bool CGUIWindow::OnMessage(CGUIMessage& message) { switch ( message.GetMessage() ) { case GUI_MSG_WINDOW_LOAD: { Initialize(); return true; } break; case GUI_MSG_WINDOW_INIT: { CLog::Log(LOGDEBUG, "------ Window Init (%s) ------", GetProperty("xmlfile").c_str()); if (m_dynamicResourceAlloc || !m_bAllocated) AllocResources(false); OnInitWindow(); return true; } break; case GUI_MSG_WINDOW_DEINIT: { CLog::Log(LOGDEBUG, "------ Window Deinit (%s) ------", GetProperty("xmlfile").c_str()); OnDeinitWindow(message.GetParam1()); // now free the window if (m_dynamicResourceAlloc) FreeResources(); return true; } break; case GUI_MSG_UNFOCUS_ALL: { //unfocus the current focused control in this window CGUIControl *control = GetFocusedControl(); if(control) { //tell focused control that it has lost the focus CGUIMessage msgLostFocus(GUI_MSG_LOSTFOCUS, GetID(), control->GetID(), control->GetID()); control->OnMessage(msgLostFocus); CLog::Log(LOGDEBUG, "Unfocus WindowID: %i, ControlID: %i",GetID(), control->GetID()); } return true; } case GUI_MSG_FOCUSED: { // a control has been focused if (HasID(message.GetSenderId())) { m_focusedControl = message.GetControlId(); return true; } break; } case GUI_MSG_LOSTFOCUS: { // nothing to do at the window level when we lose focus return true; } case GUI_MSG_MOVE: { if (HasID(message.GetSenderId())) return OnMove(message.GetControlId(), message.GetParam1()); break; } case GUI_MSG_SETFOCUS: { // CLog::Log(LOGDEBUG,"set focus to control:%i window:%i (%i)\n", message.GetControlId(),message.GetSenderId(), GetID()); if ( message.GetControlId() ) { // first unfocus the current control CGUIControl *control = GetFocusedControl(); if (control) { CGUIMessage msgLostFocus(GUI_MSG_LOSTFOCUS, GetID(), control->GetID(), message.GetControlId()); control->OnMessage(msgLostFocus); } // get the control to focus CGUIControl* pFocusedControl = GetFirstFocusableControl(message.GetControlId()); if (!pFocusedControl) pFocusedControl = GetControl(message.GetControlId()); // and focus it if (pFocusedControl) return pFocusedControl->OnMessage(message); } return true; } break; case GUI_MSG_EXCLUSIVE_MOUSE: { m_exclusiveMouseControl = message.GetSenderId(); return true; } break; case GUI_MSG_GESTURE_NOTIFY: { CAction action(ACTION_GESTURE_NOTIFY, 0, static_cast<float>(message.GetParam1()), static_cast<float>(message.GetParam2()), 0, 0); EVENT_RESULT result = OnMouseAction(action); auto res = new int(result); message.SetPointer(static_cast<void*>(res)); return result != EVENT_RESULT_UNHANDLED; } case GUI_MSG_ADD_CONTROL: { if (message.GetPointer()) { CGUIControl *control = static_cast<CGUIControl*>(message.GetPointer()); control->AllocResources(); AddControl(control); } return true; } case GUI_MSG_REMOVE_CONTROL: { if (message.GetPointer()) { CGUIControl *control = static_cast<CGUIControl*>(message.GetPointer()); RemoveControl(control); control->FreeResources(true); delete control; } return true; } case GUI_MSG_NOTIFY_ALL: { // only process those notifications that come from this window, or those intended for every window if (HasID(message.GetSenderId()) || !message.GetSenderId()) { if (message.GetParam1() == GUI_MSG_PAGE_CHANGE || message.GetParam1() == GUI_MSG_REFRESH_THUMBS || message.GetParam1() == GUI_MSG_REFRESH_LIST || message.GetParam1() == GUI_MSG_WINDOW_RESIZE) { // alter the message accordingly, and send to all controls for (iControls it = m_children.begin(); it != m_children.end(); ++it) { CGUIControl *control = *it; CGUIMessage msg(message.GetParam1(), message.GetControlId(), control->GetID(), message.GetParam2()); control->OnMessage(msg); } } else if (message.GetParam1() == GUI_MSG_STATE_CHANGED) MarkDirtyRegion(DIRTY_STATE_CHILD); //Don't force an dirtyRect, we don't know if / what has changed. } } break; } return CGUIControlGroup::OnMessage(message); }