GME
13
|
00001 // ChildFrm.cpp : implementation of the CChildFrame class 00002 // 00003 00004 #include "stdafx.h" 00005 #include "GMEApp.h" 00006 00007 #include "ChildFrm.h" 00008 #include "MainFrm.h" 00009 00010 #include "GMEView.h" 00011 00012 #ifdef _DEBUG 00013 #define new DEBUG_NEW 00014 #undef THIS_FILE 00015 static char THIS_FILE[] = __FILE__; 00016 #endif 00017 00019 // CChildFrame 00020 00021 IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWndEx) 00022 00023 BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWndEx) 00024 ON_WM_CREATE() 00025 ON_COMMAND_EX(CG_ID_VIEW_MODELPROPERTIESBAR, OnBarCheck) 00026 ON_UPDATE_COMMAND_UI(CG_ID_VIEW_MODELPROPERTIESBAR, OnUpdateControlBarMenu) 00027 //{{AFX_MSG_MAP(CChildFrame) 00028 ON_WM_CLOSE() 00029 ON_WM_MDIACTIVATE() 00030 //}}AFX_MSG_MAP 00031 ON_WM_SIZE() 00032 END_MESSAGE_MAP() 00033 00035 // CChildFrame construction/destruction 00036 00037 CChildFrame::CChildFrame() 00038 { 00039 sendEvent = true; 00040 view = 0; 00041 } 00042 00043 CChildFrame::~CChildFrame() 00044 { 00045 } 00046 00047 CString CChildFrame::GetTitle(void) const 00048 { 00049 return m_title; 00050 } 00051 00052 void CChildFrame::SetTitle(const CString& title) 00053 { 00054 m_title = title; 00055 } 00056 00057 CString CChildFrame::GetAppTitle(void) const 00058 { 00059 return m_appTitle; 00060 } 00061 00062 void CChildFrame::SetAppTitle(const CString& appTitle) 00063 { 00064 m_appTitle = appTitle; 00065 } 00066 00067 void CChildFrame::SetSendEvent(bool sendEventParam) 00068 { 00069 sendEvent = sendEventParam; 00070 } 00071 00072 void CChildFrame::SetView(CView* viewParam) 00073 { 00074 view = viewParam; 00075 } 00076 00077 BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) 00078 { 00079 // TODO: Modify the Window class or styles here by modifying 00080 // the CREATESTRUCT cs 00081 00082 if( !CMDIChildWndEx::PreCreateWindow(cs) ) 00083 return FALSE; 00084 00085 return TRUE; 00086 } 00087 00088 00089 00091 // CChildFrame diagnostics 00092 00093 #ifdef _DEBUG 00094 void CChildFrame::AssertValid() const 00095 { 00096 CMDIChildWndEx::AssertValid(); 00097 } 00098 00099 void CChildFrame::Dump(CDumpContext& dc) const 00100 { 00101 CMDIChildWndEx::Dump(dc); 00102 } 00103 00104 #endif //_DEBUG 00105 00107 // CChildFrame message handlers 00108 00109 int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) 00110 { 00111 if (CMDIChildWndEx::OnCreate(lpCreateStruct) == -1) 00112 return -1; 00113 00114 #if !defined(ACTIVEXGMEVIEW) 00115 { 00116 // Initialize dialog bar propBar 00117 if (!propBar.Create(_T("Model Properties"), this, FALSE, CG_IDD_MODELPROPERTIESBAR, 00118 WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | CBRS_TOP, 00119 CG_ID_VIEW_MODELPROPERTIESBAR)) 00120 { 00121 TRACE0("Failed to create dialog bar propBar\n"); 00122 return -1; // fail to create 00123 } 00124 00125 // terge 00126 int zoomvals[] = {ZOOM_MIN, 10, 25, 50, 75, ZOOM_NO, 150, 200, 300, ZOOM_MAX, ZOOM_WIDTH, ZOOM_HEIGHT, ZOOM_ALL, 0}; 00127 // int zoomvals[] = {ZOOM_NO, 150, 200, 250, 300, 350, 400, 0}; // for test 00128 propBar.SetZoomList(zoomvals); 00129 propBar.DockToFrameWindow(CBRS_ALIGN_TOP); 00130 propBar.SetMinSize(CSize(10, 26 * GetDC()->GetDeviceCaps(LOGPIXELSY) / 96)); 00131 00132 ShowPane(&propBar, true, false, true); 00133 } 00134 #endif 00135 00136 return 0; 00137 } 00138 00139 void CChildFrame::OnClose() 00140 { 00141 bool doClose = true; 00142 if (sendEvent && view) 00143 doClose = ((CGMEView *)view)->SendCloseModelEvent(); 00144 sendEvent = true; 00145 00146 if(doClose) 00147 { 00148 CGMEMFCTabCtrl& tabs = *(CGMEMFCTabCtrl*)m_pRelatedTabGroup; 00149 00150 tabs.EnableActivateLastActive(TRUE); 00151 tabs.EnableActivateLastVisible(TRUE); 00152 tabs._SetLastActiveTab(); 00153 if (tabs.GetTabsNum() > 2) 00154 { 00155 int active = tabs.GetActiveTab(); 00156 int visible; 00157 CWnd* activeWnd = tabs.GetFirstVisibleTab(active, visible); 00158 bool thisWindowActive = activeWnd != NULL && activeWnd->GetSafeHwnd() == GetSafeHwnd(); 00159 if (thisWindowActive && active != tabs.GetTabsNum()) 00160 { 00161 tabs.EnableActivateLastActive(FALSE); 00162 } 00163 } 00164 // CFramewWnd::OnClose calls CMDIChildWnd::DestroyWindow 00165 CMDIChildWndEx::OnClose(); 00166 } 00167 00168 00169 // CMDIChildWndEx::OnClose: when the last ChildWnd is closed 00170 // the document is considered closed and the title changes to Paradigm 00171 // that's why we call this: 00172 theApp.UpdateMainTitle(); 00173 00174 // DestroyWindow(); 00175 } 00176 00177 void CChildFrame::OnSize(UINT nType, int cx, int cy) 00178 { 00179 CMDIChildWndEx::OnSize(nType, cx, cy); 00180 00181 // it is necessary to change the title manually especially 00182 // when the first childwnd is created 00183 // when the childwnd's are maximized 00184 theApp.UpdateMainTitle(); 00185 } 00186 00187 void CChildFrame::OnUpdateFrameTitle(BOOL bAddToTitle) { 00188 TCHAR szOld[256]; 00189 if (GetWindowText(szOld, _countof(szOld)) != m_title.GetLength() || 00190 lstrcmp(szOld, m_title) != 0) { 00191 SetWindowText(m_title); 00192 } 00193 } 00194 00195 BOOL CChildFrame::PreTranslateMessage(MSG* pMsg) 00196 { 00197 00198 if (pMsg->message == WM_MBUTTONUP) { 00199 CMFCTabCtrl* tabCtrl = GetRelatedTabGroup(); 00200 long xPos = GET_X_LPARAM(pMsg->lParam); 00201 long yPos = GET_Y_LPARAM(pMsg->lParam); 00202 CPoint point(xPos, yPos); 00203 if (tabCtrl->IsPtInTabArea(point)) { 00204 int i = tabCtrl->GetTabFromPoint(point); 00205 if (i >= 0) { 00206 CWnd* tabCtrlWnd = tabCtrl->GetTabWnd(i); 00207 if (tabCtrlWnd != NULL && tabCtrlWnd->IsKindOf(RUNTIME_CLASS(CChildFrame))) { 00208 CChildFrame* cf = STATIC_DOWNCAST(CChildFrame, tabCtrlWnd); 00209 cf->PostMessage(WM_CLOSE); 00210 } 00211 } 00212 } 00213 } 00214 00215 return CMDIChildWndEx::PreTranslateMessage(pMsg); 00216 } 00217 00218 void CChildFrame::OnMDIActivate(BOOL bActivate, 00219 CWnd* pActivateWnd, CWnd* pDeactivateWnd) 00220 { 00221 CMDIChildWndEx::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd); 00222 if (pActivateWnd == this) 00223 { 00224 CGMEView* view = ((CGMEView*)GetActiveView()); 00225 if (!view->alive) 00226 return; 00227 00228 view->DoPannWinRefresh(); 00229 if (view->guiMeta) { 00230 theApp.UpdateCompList4CurrentKind( view->guiMeta->name); 00231 CMainFrame::theInstance->SetPartBrowserMetaModel(view->guiMeta); 00232 CMainFrame::theInstance->SetPartBrowserBg(view->bgColor); 00233 CMainFrame::theInstance->ChangePartBrowserAspect(view->currentAspect->index); 00234 00235 view->ChangeAttrPrefObjs(view->selected); 00236 00237 } 00238 view->SetScroll(); 00239 } 00240 }