DWORD CGUIPage::OnGetObjectInsideRect(DWORD size, void *params) { DWORD retVal; OBJECTLIST::iterator olIter; IGUIElement *object; OBJINRECT *data; VERIFY_MESSAGE_SIZE(size, sizeof(OBJINRECT)); data = (OBJINRECT*)params; int x1 = data->x1; int x2 = data->x2; int y1 = data->y1; int y2 = data->y2; POSITIONDATA pd; IHashString *guiName; for(olIter = m_ObjectList.begin(); olIter != m_ObjectList.end(); olIter++) { object = dynamic_cast<IGUIElement*>(*olIter); if(!object) { m_ToolBox->SetErrorValue(ERR_NULL_POINTER); m_ToolBox->Log(LOGERROR, _T("Could not grab IGUIElement from list of gui elements")); return MSG_ERROR; } guiName = object->GetName(); static DWORD msgHash_GetPosition = CHashString(_T("GetPosition")).GetUniqueID(); retVal = m_ToolBox->SendMessage(msgHash_GetPosition, sizeof(POSITIONDATA), &pd, guiName); if(retVal != MSG_HANDLED) { m_ToolBox->Log(LOGERROR, _T("Could not send GetPosition message to %s\n"), guiName->GetString()); return MSG_ERROR; } if( InsideRect((int)pd.m_fXPos, (int)pd.m_fYPos, data->x1, data->y1, data->x2, data->y2) ) { data->list.push_back(object); } } if (data->list.empty()) { return MSG_HANDLED_PROCEED; } else { return MSG_HANDLED_STOP; } }
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; } }
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; }