Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
MainFrm.cpp
Go to the documentation of this file.
1 // MainFrm.cpp : implementation of the MainFrame class
2 //
3 
4 #include "stdafx.h"
5 #include "Magic.h"
6 
7 #include "MainFrm.h"
8 #include "MagicView.h"
9 
10 #ifdef _DEBUG
11 #define new DEBUG_NEW
12 #undef THIS_FILE
13 static char THIS_FILE[] = __FILE__;
14 #endif
15 
17 // MainFrame
18 
19 #include "Bitmap.h"
20 
21 IMPLEMENT_DYNCREATE(MainFrame, CFrameWnd)
22 
23 BEGIN_MESSAGE_MAP(MainFrame, CFrameWnd)
24  //{{AFX_MSG_MAP(MainFrame)
25  ON_WM_CREATE()
26  ON_WM_ACTIVATEAPP()
27  ON_COMMAND(ID_VIEW_RENDER, OnRender)
28  //}}AFX_MSG_MAP
29 END_MESSAGE_MAP()
30 
31 static UINT indicators[] =
32 {
33  ID_SEPARATOR, // status line indicator
34  ID_SEPARATOR, // xy indicator
35  ID_INDICATOR_CAPS,
36  ID_INDICATOR_NUM,
37  ID_INDICATOR_SCRL,
38 };
39 
41 // MainFrame construction/destruction
42 
44 
45 
47 {
48  statframe = this;
49 
50 }
51 
53 {
55 }
56 
57 BOOL MainFrame::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
58 {
59  if (message == WM_ENTERSIZEMOVE) {
60  MagicView* magic_view = MagicView::GetInstance();
61  if (magic_view)
62  magic_view->OnEnterSizeMove();
63  }
64 
65  else if (message == WM_EXITSIZEMOVE) {
66  MagicView* magic_view = MagicView::GetInstance();
67  if (magic_view)
68  magic_view->OnExitSizeMove();
69  }
70 
71  return CFrameWnd::OnWndMsg(message, wParam, lParam, pResult);
72 }
73 
74 int MainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
75 {
76  if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
77  return -1;
78 
79  if (!m_wndToolBar.Create(this) ||
80  !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
81  {
82  TRACE0("Failed to create toolbar\n");
83  return -1; // fail to create
84  }
85 
86  if (!m_wndStatusBar.Create(this) ||
87  !m_wndStatusBar.SetIndicators(indicators,
88  sizeof(indicators)/sizeof(UINT)))
89  {
90  TRACE0("Failed to create status bar\n");
91  return -1; // fail to create
92  }
93 
94  // TODO: Remove this if you don't want tool tips or a resizeable toolbar
95  m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
96  CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
97 
98  // TODO: Delete these three lines if you don't want the toolbar to
99  // be dockable
100  m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
101  EnableDocking(CBRS_ALIGN_ANY);
102  DockControlBar(&m_wndToolBar);
103 
104  return 0;
105 }
106 
107 BOOL MainFrame::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 void MainFrame::StatusXY(const char* xy)
118 {
119  statframe->m_wndStatusBar.SetPaneText(1, xy, TRUE);
120 }
121 
123 // MainFrame diagnostics
124 
125 #ifdef _DEBUG
126 void MainFrame::AssertValid() const
127 {
128  CFrameWnd::AssertValid();
129 }
130 
131 void MainFrame::Dump(CDumpContext& dc) const
132 {
133  CFrameWnd::Dump(dc);
134 }
135 
136 #endif //_DEBUG
137 
139 // MainFrame message handlers
140 
141 
142 void MainFrame::OnActivateApp(BOOL bActive, DWORD dwThreadID)
143 {
144  ((Magic*)AfxGetApp())->SetAppActivated(bActive ? true : false);
145 }
146 
148 {
149  MagicView* magic_view = MagicView::GetInstance();
150  if (magic_view)
151  magic_view->SendMessage(WM_COMMAND, ID_VIEW_RENDER);
152 }