void CPUTGUIElement::Resize(CPUTRenderNode *pRoot, int width, int height)
{
    CPUTRenderNode *pNode = pRoot;
    while(pNode->GetNodeType() != CPUT_NODE_GUI_ELEMENT)    
        pNode = pNode->GetNext(pRoot);

    if(pNode)
    {
        ((CPUTGUIElement*)pNode)->Resize(0, 0, width, height, width, height);
    }
}
void CPUTGUIElement::SetEvents(CPUTRenderNode *pRoot, StringMap *pEventMap, CPUTCallbackHandler *pHandler)
{
    if(pRoot == NULL)
        return;
    CPUTRenderNode *pNode = pRoot;
    do
    {
        if(pNode->GetNodeType() == CPUTRenderNode::CPUT_NODE_TYPE::CPUT_NODE_GUI_ELEMENT)
        {
            ((CPUTGUIElement*)pNode)->SetEvents(pEventMap, pHandler);
        }
        pNode = pNode->GetNext(pRoot);
    } while(pNode  != pRoot);
}
CPUTEventHandledCode CPUTGUIElement::HandleKeyboardEvent(CPUTRenderNode *pRoot, CPUTKey key, CPUTKeyState state)
{
    if(pRoot == NULL)
        return CPUT_EVENT_UNHANDLED;;
    CPUTRenderNode* pNode = pRoot;

    do 
    {
        if(pNode->GetNodeType() == CPUTRenderNode::CPUT_NODE_TYPE::CPUT_NODE_GUI_ELEMENT)
        {
            if(CPUT_EVENT_HANDLED == ((CPUTGUIElement*)pNode)->HandleKeyboardEvent(key, state))
                return CPUT_EVENT_HANDLED;
        }
        pNode = pNode->GetNext(pRoot);
    } while(pNode  != pRoot);
    return CPUT_EVENT_UNHANDLED;
}
CPUTEventHandledCode CPUTGUIElement::HandleMouseEvent(CPUTRenderNode *pRoot, int x, int y , int wheel, CPUTMouseState state, CPUTEventID message)
{
    if(pRoot == NULL)
        return CPUT_EVENT_UNHANDLED;;
    CPUTRenderNode* pNode = pRoot;

    do 
    {
        if(pNode->GetNodeType() == CPUTRenderNode::CPUT_NODE_TYPE::CPUT_NODE_GUI_ELEMENT)
        {
            CPUTGUIElement* pElement = (CPUTGUIElement*)pNode;
            if(CPUT_EVENT_HANDLED == ((CPUTGUIElement*)pNode)->HandleMouseEvent(x, y, wheel, state, message))
                return CPUT_EVENT_HANDLED;
        }
        pNode = pNode->GetNext(pRoot);
    } while(pNode  != pRoot);
    return CPUT_EVENT_UNHANDLED;
}