00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012
00013 #ifdef __GNUG__
00014 #pragma implementation "CRWindowHierarchyHandler.h"
00015 #endif
00016
00017 #include <wxGuiTest/CRWindowHierarchyHandler.h>
00018
00019 #include <wx/xrc/xmlres.h>
00020 #include <wx/dir.h>
00021
00022
00023 using namespace wxTst;
00024
00025 CRWindowHierarchyHandler::ContainerMap CRWindowHierarchyHandler::m_contMap;
00026
00027 CRWindowHierarchyHandler *CRWindowHierarchyHandler::ms_instance = NULL;
00028
00029
00030 CRWindowHierarchyHandler::CRWindowHierarchyHandler ()
00031 {
00032 m_contMap.clear();
00033 m_contMap.insert(std::make_pair(_T("wxDialog"),_T("dialog")));
00034 m_contMap.insert(std::make_pair(_T("wxFrame"), _T("frame")));
00035 m_contMap.insert(std::make_pair(_T("wxPanel"), _T("panel")));
00036 m_contMap.insert(std::make_pair(_T("wxNotebook"), _T("notebook")));
00037 m_contMap.insert(std::make_pair(_T("wxMDIChildFrame"), _T("frame")));
00038 m_contMap.insert(std::make_pair(_T("wxMDIParentFrame"), _T("frame")));
00039 }
00040
00041
00042 CRWindowHierarchyHandler::~CRWindowHierarchyHandler ()
00043 {
00044
00045 }
00046
00047
00048 CRWindowHierarchyHandler * CRWindowHierarchyHandler::GetInstance ()
00049 {
00050 if (ms_instance == NULL) {
00051
00052 ms_instance = new CRWindowHierarchyHandler ();
00053 }
00054 return ms_instance;
00055 }
00056
00057
00058 void CRWindowHierarchyHandler::Destroy ()
00059 {
00060 if (ms_instance != NULL) {
00061
00062 delete ms_instance;
00063 ms_instance = NULL;
00064 }
00065 }
00066
00067
00068 wxString CRWindowHierarchyHandler::FindContainerName (wxWindow *window)
00069 {
00070 wxASSERT (window != NULL);
00071 bool found = false;
00072 wxWindow *containerWdw = window;
00073 while ((!found) && (containerWdw != NULL)) {
00074
00075 wxClassInfo *classInfo = containerWdw->GetClassInfo ();
00076 wxASSERT (classInfo != NULL);
00077
00078 ContainerMap::const_iterator it;
00079 wxString className(classInfo->GetClassName ());
00080 it = m_contMap.find (className);
00081 if ((it != m_contMap.end ()) && (it->second != containerWdw->GetName ())) {
00082
00083 found = true;
00084
00085 } else {
00086
00087 containerWdw = containerWdw->GetParent ();
00088 }
00089 }
00090
00091 return (found ? containerWdw->GetName () : _T(""));
00092 }
00093
00094
00095