DWORD CGUIPage::OnGetObjectUnderCursor(DWORD size, void *params) { OBJECTLIST::iterator olIter; IGUIElement *lesserGE = NULL; IGUIElement *newGE; OBJUNDERCURSOR *data; VERIFY_MESSAGE_SIZE(size, sizeof(OBJUNDERCURSOR)); data = (OBJUNDERCURSOR*)params; float fCursorPosX = data->m_fPosX; float fCursorPosY = data->m_fPosY; data->m_Name = NULL; data->m_CompType = NULL; for(olIter = m_ObjectList.begin(); olIter != m_ObjectList.end(); olIter++) { newGE = dynamic_cast<IGUIElement*>(*olIter); if(!newGE) { EngineGetToolBox()->SetErrorValue(ERR_NULL_POINTER); EngineGetToolBox()->Log(LOGERROR, _T("Could not grab IGUIElement from list of gui elements")); return MSG_ERROR; } if(newGE->IsCursorOver(fCursorPosX, fCursorPosY)) { if(lesserGE==NULL) { lesserGE = newGE; } else if( lesserGE->GetZOrder() > newGE->GetZOrder() ) { lesserGE = newGE; } } } if(lesserGE) { data->m_Name = lesserGE->GetName(); data->m_CompType = lesserGE->GetComponentType(); } if(data->m_Name == NULL) { return MSG_HANDLED_PROCEED; } else { return MSG_HANDLED_STOP; } }
void CGUIPage::SortGUIElements() { IGUIElement *guiElement; OBJECTLIST::iterator olIter = m_ObjectList.begin(); // clear sorted map m_SortedMap.clear(); while(olIter != m_ObjectList.end()) { guiElement = dynamic_cast<IGUIElement*>((*olIter)); if(guiElement == NULL) { m_ToolBox->SetErrorValue(ERR_NULL_POINTER); m_ToolBox->Log(LOGERROR, _T("Could not cast to IGUIElement: %s"), (*olIter)->GetName()); continue; } // insert gui element into sorted map m_SortedMap.insert(make_pair(guiElement->GetZOrder(), guiElement)); IHashString *type = guiElement->GetComponentType(); if (type) { static DWORD dwGroup = CHashString(_T("CGUIGroup")).GetUniqueID(); if (type->GetUniqueID() == dwGroup) { CGUIGroup *group = dynamic_cast<CGUIGroup*>(guiElement); if (group) { group->SortElements(); } } } olIter++; } // now clear object list m_ObjectList.clear(); SORTEDGUIMAP::iterator sgmIter = m_SortedMap.begin(); while(sgmIter != m_SortedMap.end()) { // added the gui elements into the list in sorted order m_ObjectList.push_back(sgmIter->second); sgmIter++; } }
DWORD CGUIPage::OnGetPageItemList(DWORD size, void *param) { VERIFY_MESSAGE_SIZE(size, sizeof(GUIELEMLIST)); GUIELEMLIST *gel = (GUIELEMLIST*) param; IGUIElement *guiElement; OBJECTLIST::iterator olIter = m_ObjectList.begin(); while(olIter != m_ObjectList.end()) { guiElement = dynamic_cast<IGUIElement*>((*olIter)); if(guiElement == NULL) { m_ToolBox->SetErrorValue(ERR_NULL_POINTER); m_ToolBox->Log(LOGERROR, _T("Could not cast to IGUIElement: %s"), (*olIter)->GetName()); } gel->m_vNames.push_back(guiElement->GetName()->GetString()); gel->m_vTypes.push_back(guiElement->GetComponentType()->GetString()); olIter++; } return MSG_HANDLED_STOP; }