home *** CD-ROM | disk | FTP | other *** search
/ AI Game Programming Wisdom / AIGameProgrammingWisdom.iso / SourceCode / 03 Pathfinding with Astar / 01 Matthews / ase / MainFrm.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2001-07-02  |  3.5 KB  |  161 lines

  1. // MainFrm.cpp : implementation of the CMainFrame class
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "ase.h"
  6.  
  7. #include "MainFrm.h"
  8. #include "NodeView.h"
  9. #include "aseView.h"
  10. #include "aseDoc.h"
  11.  
  12. #ifdef _DEBUG
  13. #define new DEBUG_NEW
  14. #undef THIS_FILE
  15. static char THIS_FILE[] = __FILE__;
  16. #endif
  17.  
  18. /////////////////////////////////////////////////////////////////////////////
  19. // CMainFrame
  20.  
  21. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  22.  
  23. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  24.     //{{AFX_MSG_MAP(CMainFrame)
  25.     ON_WM_CREATE()
  26.     ON_COMMAND(ID_PATHING_DISPLAYGOALNODE, OnPathingDisplayGoalNode)
  27.     //}}AFX_MSG_MAP
  28. END_MESSAGE_MAP()
  29.  
  30. static UINT indicators[] =
  31. {
  32.     ID_SEPARATOR,           // status line indicator
  33.     ID_INDICATOR_CAPS,
  34.     ID_INDICATOR_NUM,
  35.     ID_INDICATOR_SCRL,
  36. };
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // CMainFrame construction/destruction
  40.  
  41. CMainFrame::CMainFrame()
  42. {
  43. }
  44.  
  45. CMainFrame::~CMainFrame()
  46. {
  47. }
  48.  
  49. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  50. {
  51.     if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  52.         return -1;
  53.     
  54.     if (!m_wndToolBar.CreateEx(this) ||
  55.         !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  56.     {
  57.         TRACE0("Failed to create toolbar\n");
  58.         return -1;      // fail to create
  59.     }
  60. /*    if (!m_wndDlgBar.Create(this, IDR_MAINFRAME, 
  61.         CBRS_ALIGN_TOP, AFX_IDW_DIALOGBAR))
  62.     {
  63.         TRACE0("Failed to create dialogbar\n");
  64.         return -1;        // fail to create
  65.     }*/
  66.  
  67.     if (!m_wndReBar.Create(this) ||
  68.         !m_wndReBar.AddBar(&m_wndToolBar)/* ||
  69.         !m_wndReBar.AddBar(&m_wndDlgBar)*/)
  70.     {
  71.         TRACE0("Failed to create rebar\n");
  72.         return -1;      // fail to create
  73.     }
  74.  
  75.     if (!m_wndStatusBar.Create(this) ||
  76.         !m_wndStatusBar.SetIndicators(indicators,
  77.           sizeof(indicators)/sizeof(UINT)))
  78.     {
  79.         TRACE0("Failed to create status bar\n");
  80.         return -1;      // fail to create
  81.     }
  82.  
  83.     // TODO: Remove this if you don't want tool tips
  84.     m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  85.         CBRS_TOOLTIPS | CBRS_FLYBY);
  86.  
  87.     return 0;
  88. }
  89.  
  90. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
  91.     CCreateContext* pContext)
  92. {
  93.     // create splitter window
  94.     if (!m_wndSplitter.CreateStatic(this, 1, 2))
  95.         return FALSE;
  96.  
  97.     if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CNodeView), CSize(175, 100), pContext) ||
  98.         !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CAseView), CSize(100, 100), pContext))
  99.     {
  100.         m_wndSplitter.DestroyWindow();
  101.         return FALSE;
  102.     }
  103.  
  104.     return TRUE;
  105. }
  106.  
  107. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  108. {
  109.     if( !CFrameWnd::PreCreateWindow(cs) )
  110.         return FALSE;
  111.     // TODO: Modify the Window class or styles here by modifying
  112.     //  the CREATESTRUCT cs
  113.  
  114.     return TRUE;
  115. }
  116.  
  117. /////////////////////////////////////////////////////////////////////////////
  118. // CMainFrame diagnostics
  119.  
  120. #ifdef _DEBUG
  121. void CMainFrame::AssertValid() const
  122. {
  123.     CFrameWnd::AssertValid();
  124. }
  125.  
  126. void CMainFrame::Dump(CDumpContext& dc) const
  127. {
  128.     CFrameWnd::Dump(dc);
  129. }
  130.  
  131. #endif //_DEBUG
  132.  
  133. /////////////////////////////////////////////////////////////////////////////
  134. // CMainFrame message handlers
  135.  
  136. CAseDoc * CMainFrame::GetAseDocument()
  137. {
  138.     return reinterpret_cast<CAseDoc *>(GetActiveDocument());
  139. }
  140.  
  141. CAseView* CMainFrame::GetRightPane()
  142. {
  143.     CWnd* pWnd = m_wndSplitter.GetPane(0, 1);
  144.     CAseView* pView = reinterpret_cast<CAseView *>(pWnd);
  145.  
  146.     return pView;
  147. }
  148.  
  149. CNodeView *CMainFrame::GetLeftPane()
  150. {
  151.     CWnd* pWnd = m_wndSplitter.GetPane(0, 0);
  152.     CNodeView* pView = reinterpret_cast<CNodeView *>(pWnd);
  153.  
  154.     return pView;
  155. }
  156.  
  157. void CMainFrame::OnPathingDisplayGoalNode() 
  158. {
  159.     GetLeftPane()->DisplayGoalNode();
  160. }
  161.