Main Page | Class Hierarchy | Class List | File List | Class Members | Related Pages

D:/Programming/GUI Editor (Source)/GUIMenu.cpp

00001 #include "StdAfx.h" 00002 #include "GUI.h" 00003 00004 CGUIMenu::CGUIMenu() 00005 { 00006 Initialize(); 00007 } 00008 00009 CGUIMenu::~CGUIMenu() 00010 { 00011 Destroy(); 00012 } 00013 00014 void CGUIMenu::Initialize() 00015 { 00016 SetType(GUI_Menu); 00017 m_strElementType = "Menu"; 00018 } 00019 00020 int CGUIMenu::Create(CGUIElement *pParent, tRect WidgetRect, CCustomFont *pFont, CTexture *pTexture, CMaterial *pMaterial, bool bBorder) 00021 { 00022 return CGUIMenuEntry::Create(pParent, WidgetRect, pFont, pTexture, pMaterial, bBorder); 00023 } 00024 00025 int CGUIMenu::LoadXML(TiXmlNode *pDataNode, CString strFilename) 00026 { 00027 TiXmlElement* pXMLElement = NULL; 00028 const char *pcValue = NULL; 00029 00030 int iRetValue = CGUIMenuEntry::LoadXML(pDataNode, strFilename); // LoadXML the data of derivative 00031 if(iRetValue !=1) 00032 return iRetValue; 00033 00034 pXMLElement = m_pXMLElement; 00035 00036 return Resize(GetRect()); 00037 } 00038 00039 int CGUIMenu::SaveXML(TiXmlNode *pDataNode, CString strFilename) 00040 { 00041 // Nowhere to save! Nothing to save! 00042 if(pDataNode == NULL && strFilename == "") 00043 return -1; 00044 00045 char Buf[128] = ""; 00046 TiXmlElement *pSaveXMLElement = NULL; 00047 00048 if(pDataNode != NULL) 00049 pSaveXMLElement = pDataNode->ToElement(); 00050 else 00051 pSaveXMLElement = new TiXmlElement("Menu"); 00052 00053 00054 int iRetValue = CGUIMenuEntry::SaveXML(pSaveXMLElement, strFilename); 00055 00056 if(pDataNode == NULL) 00057 SAFEDEL(pSaveXMLElement) 00058 00059 return iRetValue; 00060 } 00061 00062 void CGUIMenu::Draw() 00063 { 00064 if(GetChild(GUI_Border) !=NULL) 00065 { 00066 GetChild(GUI_Border)->Show(); 00067 GetChild(GUI_Border)->ShowSiblings(); 00068 } 00069 00070 CGUIMenuEntry::Draw(); 00071 } 00072 00073 void CGUIMenu::ProcessMessage(tGUIMessage& Message) 00074 { 00075 switch(Message.uiMessage) 00076 { 00077 case GUI_Message_ButtonPressed: 00078 { 00079 if(Message.pSender == this) 00080 { 00081 if(GetChildCount() > 0) 00082 { 00083 if(GetChild(GUI_MenuEntry) !=NULL) 00084 { 00085 if(GetChild(GUI_MenuEntry)->Visible()) 00086 Collapse(); 00087 else 00088 Expand(); 00089 } 00090 } 00091 } 00092 break; 00093 } 00094 case GUI_Message_MoveX: 00095 case GUI_Message_MoveY: 00096 case GUI_Message_MoveXY: 00097 { 00098 if(Message.pSender == this) 00099 Resize(GetRect()); 00100 break; 00101 } 00102 } 00103 } 00104 00105 bool CGUIMenu::IsOfType(eEntityType eType) 00106 { 00107 if(eType == Entity_GUIMenu) 00108 return true; 00109 00110 return CGUIMenuEntry::IsOfType(eType); 00111 } 00112 00113 bool CGUIMenu::PropertyChanging( const void* pvProperty , void* pvNewValue ) 00114 { 00115 bool bChangeOK = CGUIMenuEntry::PropertyChanging(pvProperty, pvNewValue); 00116 00117 return bChangeOK; 00118 } 00119 00120 void CGUIMenu::GetProperties( EPropList& PropList ) 00121 { 00122 CGUIMenuEntry::GetProperties(PropList); 00123 } 00124 00125 /* 00126 OK, so how we are going to do it? 00127 With OnLMouseDown we are going to catch the expansion of the root element 00128 and with OnMouseOver we are going to expand the Child it's floating over 00129 When a Child K of parent P is expanded, and a mouse is floating over some other Child N of parent P, 00130 the Child K is collapsed (and all his sub-children that may be expanded) and Child N is expanded instead. 00131 How are we going to track the children that are expanded currently? 00132 Well, each time a Child is expanded, it's added to the list of m_piListExp 00133 */

Generated on Sun Jul 17 21:34:27 2005 for OpenGL GUI by doxygen 1.3.8