GME
13
|
00001 // GMESearch.cpp : implementation file 00002 // 00003 00004 #include "stdafx.h" 00005 #include "GMEApp.h" 00006 #include "GMEstd.h" 00007 #include "mainfrm.h" 00008 #include "GMEDoc.h" 00009 #include "GMEView.h" 00010 #include "GMESearch.h" 00011 #include "guimeta.h" 00012 00013 #ifdef _DEBUG 00014 #define new DEBUG_NEW 00015 #undef THIS_FILE 00016 static char THIS_FILE[] = __FILE__; 00017 #endif 00018 00019 CGMESearch* CGMESearch::theInstance = NULL; 00020 00022 // CGMESearch dialog 00023 00024 00025 CGMESearch::CGMESearch() 00026 : CDockablePane() 00027 { 00028 //{{AFX_DATA_INIT(CGMESearch) 00029 // NOTE: the ClassWizard will add member initialization here 00030 //}}AFX_DATA_INIT 00031 VERIFY(theInstance == NULL); 00032 theInstance = this; 00033 } 00034 00035 00036 void CGMESearch::DoDataExchange(CDataExchange* pDX) 00037 { 00038 CDockablePane::DoDataExchange(pDX); 00039 //{{AFX_DATA_MAP(CGMESearch) 00040 DDX_Control(pDX, IDC_SEARCHCTRL, m_search); 00041 //}}AFX_DATA_MAP 00042 } 00043 00044 00045 BEGIN_MESSAGE_MAP(CGMESearch, CDockablePane) 00046 //{{AFX_MSG_MAP(CGMESearch) 00047 ON_WM_CREATE() 00048 ON_WM_SIZE() 00049 ON_WM_SIZING() 00050 //}}AFX_MSG_MAP 00051 END_MESSAGE_MAP() 00052 00054 // CGMESearch message handlers 00055 00056 BEGIN_EVENTSINK_MAP(CGMESearch, CDockablePane) 00057 //{{AFX_EVENTSINK_MAP(CGMESearch) 00058 ON_EVENT(CGMESearch, IDC_SEARCHCTRL, 1 /* ClickMgaObject */, OnClickMgaObjectSearchctrl, VTS_UNKNOWN) 00059 ON_EVENT(CGMESearch, IDC_SEARCHCTRL, 2 /* DblClickMgaObject */, OnDblClickMgaObjectSearchctrl, VTS_UNKNOWN) 00060 ON_EVENT(CGMESearch, IDC_SEARCHCTRL, 3 /* WantToBeClosed */, OnWantToBeClosedSearchctrl, VTS_NONE) 00061 ON_EVENT(CGMESearch, IDC_SEARCHCTRL, 4 /* LocateMgaObject */, OnLocateMgaObjectSearchctrl, VTS_BSTR) 00062 //}}AFX_EVENTSINK_MAP 00063 END_EVENTSINK_MAP() 00064 00065 void CGMESearch::OnClickMgaObjectSearchctrl(LPUNKNOWN mgaObject) 00066 { 00067 SelectObject(mgaObject); 00068 00069 } 00070 00071 void CGMESearch::OnDblClickMgaObjectSearchctrl(LPUNKNOWN mgaObject) 00072 { 00073 ShowObject(mgaObject); 00074 00075 } 00076 00077 void CGMESearch::OnWantToBeClosedSearchctrl() 00078 { 00079 // was not implemented yet 00080 CMainFrame::theInstance->HideFindDlg(); 00081 // by zolmol 00082 } 00083 00084 void CGMESearch::OnLocateMgaObjectSearchctrl(LPCTSTR mgaObjectId) 00085 { 00086 LocateObject( mgaObjectId); 00087 } 00088 00089 BOOL CGMESearch::PreTranslateMessage(MSG* pMsg) 00090 { 00091 if( pMsg->message == WM_KEYDOWN ) 00092 { 00093 switch(pMsg->wParam) 00094 { 00095 //case VK_RETURN: 00096 //case VK_TAB: 00097 case VK_ESCAPE: 00098 case VK_DELETE: 00099 case VK_CONTROL: 00100 case 'z': 00101 case 'Z': 00102 ::TranslateMessage(pMsg); 00103 ::DispatchMessage(pMsg); 00104 return TRUE; 00105 } 00106 } 00107 00108 return CDockablePane::PreTranslateMessage(pMsg); 00109 } 00110 00111 int CGMESearch::OnCreate(LPCREATESTRUCT lpCreateStruct) 00112 { 00113 if (CDockablePane::OnCreate(lpCreateStruct) == -1) 00114 return -1; 00115 00116 /* //if no project is open don't draw 00117 if(m_search.GetMgaProject()==NULL) 00118 return 0;*/ 00119 00120 if(!m_search.Create(_T("Search"),WS_CHILD | WS_VISIBLE,CRect(0,0,230,300),this,IDC_SEARCHCTRL)) 00121 return -1; 00122 00123 // if(!m_search.Create("Search",WS_CHILD | WS_VISIBLE,CRect(0,0,230,300),this,IDC_SEARCHCTRL)) 00124 // return -1; 00125 00126 return 0; 00127 } 00128 00129 // OnSizing implemented as well (see below) 00130 void CGMESearch::OnSize(UINT nType, int cx, int cy) 00131 { 00132 CDockablePane::OnSize(nType, cx, cy); 00133 00134 if (m_search.GetSafeHwnd()) { 00135 CRect rc; 00136 GetClientRect(rc); 00137 m_search.MoveWindow(rc); 00138 } 00139 } 00140 00142 // CGMESearch public methods 00143 00144 void CGMESearch::SetProject(CComPtr<IMgaProject>& mgaProject) 00145 { 00146 m_search.SetMgaProject(mgaProject); 00147 } 00148 00149 void CGMESearch::SetSelMgaObjects( CComPtr<IMgaObjects> p_mgaObjects) 00150 { 00151 m_search.SelMgaObjects( p_mgaObjects); 00152 } 00153 00154 void CGMESearch::CloseProject() 00155 { 00156 m_search.SetMgaProject(NULL); 00157 } 00158 00159 void CGMESearch::ShowObject(LPUNKNOWN mgaObject) 00160 { 00161 if (CGMEDoc::theInstance && mgaObject) { 00162 CGMEDoc::theInstance->ShowObject(mgaObject); 00163 } 00164 } 00165 00166 void CGMESearch::LocateObject(LPCTSTR mgaObjectId) 00167 { 00168 if( CGMEDoc::theInstance 00169 && CGMEBrowser::theInstance 00170 && mgaObjectId) 00171 { 00172 CGMEBrowser::theInstance->FocusItem( CComBSTR( mgaObjectId)); 00173 //added :kiran 00174 CGMEDoc::theInstance->ShowObject(mgaObjectId); 00175 00176 } 00177 } 00178 00179 void CGMESearch::SelectObject(LPUNKNOWN mgaObject) 00180 { 00181 CComQIPtr<IMgaObject> ccpmgaObject = mgaObject; 00182 if (ccpmgaObject) { 00183 CComPtr<IMgaObjects> ccpSelectedObjects; 00184 COMTHROW(ccpSelectedObjects.CoCreateInstance(OLESTR("Mga.MgaObjects"))); 00185 COMTHROW(ccpSelectedObjects->Append(ccpmgaObject)); 00186 CGMEObjectInspector::theInstance->SetObjects(ccpSelectedObjects); 00187 } else { 00188 CComQIPtr<IMgaObjects> ccpSelectedObjects = mgaObject; 00189 if (ccpSelectedObjects) { 00190 CGMEObjectInspector::theInstance->SetObjects(ccpSelectedObjects); 00191 } 00192 } 00193 } 00194 00195 // OnSize implemented as well (see above) 00196 void CGMESearch::OnSizing(UINT fwSide, LPRECT pRect) 00197 { 00198 static const int desiredX = 370, desiredY = 400; 00199 // let's prevent window shrink by imposing some limits 00200 if( pRect->bottom - pRect->top < desiredY) pRect->bottom = pRect->top + desiredY; 00201 if( pRect->right - pRect->left < desiredX) pRect->right = pRect->left + desiredX; 00202 00203 CDockablePane::OnSizing(fwSide, pRect); 00204 }