MainFrm.cpp
上传用户:cding2008
上传日期:2007-01-03
资源大小:1812k
文件大小:32k
源码类别:

OpenGL

开发平台:

Visual C++

  1. /////////////////////////////////////////////////////////////////////////////
  2. // MainFrm.cpp : implementation of the CMainFrame class
  3. //
  4. // ModelMagic 3D and 'glOOP' (OpenGL Object Oriented Programming library)
  5. // Copyright (c) Craig Fahrnbach 1997, 1999
  6. //
  7. // OpenGL is a registered trademark of Silicon Graphics
  8. //
  9. //
  10. // This program is provided for educational and personal use only and
  11. // is provided without guarantee or warrantee expressed or implied.
  12. //
  13. // Commercial use is strickly prohibited without written permission
  14. // from ImageWare Development.
  15. //
  16. /////////////////////////////////////////////////////////////////////////////
  17. #include "stdafx.h"
  18. #include "ModelMagic3D.h"
  19. #include "SplashDlg.h"
  20. #ifdef _DEBUG
  21. #define new DEBUG_NEW
  22. #undef THIS_FILE
  23. static char THIS_FILE[] = __FILE__;
  24. #endif
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CMainFrame
  27. IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
  28. BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
  29. //{{AFX_MSG_MAP(CMainFrame)
  30. ON_WM_CREATE()
  31. ON_WM_DESTROY()
  32. ON_COMMAND(ID_TOOLS_TREE_VIEW, OnToolsTreeCtrl)
  33. ON_COMMAND(ID_TOOLS_PALETTE, OnToolsPalette)
  34. ON_UPDATE_COMMAND_UI(ID_TOOLS_TREE_VIEW, OnUpdateToolsTreeCtrl)
  35. ON_UPDATE_COMMAND_UI(ID_TOOLS_PALETTE, OnUpdateToolsPalette)
  36. ON_WM_PALETTECHANGED()
  37. ON_WM_QUERYNEWPALETTE()
  38. ON_WM_KEYDOWN()
  39. ON_COMMAND(ID_WINDOW_NEW, OnWindowNew)
  40. ON_COMMAND(ID_VIEW_MULTIVIEW, OnViewMultiview)
  41. ON_UPDATE_COMMAND_UI(ID_VIEW_MULTIVIEW, OnUpdateViewMultiview)
  42. ON_COMMAND(ID_MATERIAL_EDIT, OnMaterialEdit)
  43. ON_UPDATE_COMMAND_UI(IDW_TOOLS_COMMAND_BAR, OnUpdateToolsCommandBar)
  44. ON_COMMAND(IDW_TOOLS_COMMAND_BAR, OnToolsCommandBar)
  45. ON_COMMAND(ID_COLORS_EDITCOLORS, OnColorsEdit)
  46. ON_COMMAND(ID_HELP_OPENGL_DIAGNOSTICS, OnHelpOpenGLDiagnostics)
  47. ON_COMMAND(IDW_TOOLS_KEYFRAME_BAR, OnToolsKeyframeBar)
  48. ON_UPDATE_COMMAND_UI(IDW_TOOLS_KEYFRAME_BAR, OnUpdateToolsKeyframeBar)
  49. ON_COMMAND(ID_KEYFRAME_DECREASE, OnKeyframeDecrease)
  50. ON_EN_UPDATE(ID_KEYFRAME_TIME, OnUpdateTime)
  51. ON_COMMAND(ID_KEYFRAME_INCREASE, OnKeyframeIncrease)
  52. ON_UPDATE_COMMAND_UI(ID_KEYFRAME_DECREASE, OnUpdateKeyframeDecrease)
  53. ON_COMMAND(ID_TOOLS_COORDINATES, OnToolsCoordinates)
  54. ON_UPDATE_COMMAND_UI(ID_TOOLS_COORDINATES, OnUpdateToolsCoordinates)
  55. ON_COMMAND(IDW_TOOLS_SELECT_BAR, OnToolsSelectBar)
  56. ON_UPDATE_COMMAND_UI(IDW_TOOLS_SELECT_BAR, OnUpdateToolsSelectBar)
  57. ON_COMMAND(IDW_TOOLS_2DSHAPE_BAR, OnTools2dshapeBar)
  58. ON_UPDATE_COMMAND_UI(IDW_TOOLS_2DSHAPE_BAR, OnUpdateTools2dshapeBar)
  59. ON_COMMAND(IDW_TOOLS_3DSHAPE_BAR, OnTools3dshapeBar)
  60. ON_UPDATE_COMMAND_UI(IDW_TOOLS_3DSHAPE_BAR, OnUpdateTools3dshapeBar)
  61. ON_COMMAND(IDW_TOOLS_SCENE_BAR, OnToolsSceneBar)
  62. ON_UPDATE_COMMAND_UI(IDW_TOOLS_SCENE_BAR, OnUpdateToolsSceneBar)
  63. //}}AFX_MSG_MAP
  64. // USER defined messages
  65. ON_MESSAGE( WM_REFRESH_DLG_BAR, OnRefreshDlgBar)
  66. // Global help commands
  67. ON_COMMAND(ID_HELP_FINDER, CMDIFrameWnd::OnHelpFinder)
  68. ON_COMMAND(ID_HELP, CMDIFrameWnd::OnHelp)
  69. ON_COMMAND(ID_CONTEXT_HELP, CMDIFrameWnd::OnContextHelp)
  70. ON_COMMAND(ID_DEFAULT_HELP, CMDIFrameWnd::OnHelpFinder)
  71. END_MESSAGE_MAP()
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CMainFrame ToolBar Button Definitions
  74. static UINT BASED_CODE SceneButtons[] =
  75. {
  76. // same order as in the bitmap 'SceneBar.bmp'
  77. ID_OBJECT_NEW_LIGHT,
  78. ID_OBJECT_NEW_TERRAIN,
  79. ID_OBJECT_NEW_CLOUD,
  80. };
  81. static UINT BASED_CODE Shape2dButtons[] =
  82. {
  83. // same order as in the bitmap '2dShapeBar.bmp'
  84. ID_OBJECT_NEW_DISK,
  85. ID_OBJECT_NEW_TRIANGLE,
  86. ID_OBJECT_NEW_PLANE,
  87. ID_OBJECT_NEW_GRID,
  88. };
  89. static UINT BASED_CODE Shape3dButtons[] =
  90. {
  91. // same order as in the bitmap '3dShapeBar.bmp'
  92. ID_OBJECT_NEW_CONE,
  93. ID_OBJECT_NEW_CYLINDER,
  94. ID_OBJECT_NEW_CSG,
  95. ID_OBJECT_NEW_CUBE,
  96. ID_OBJECT_NEW_LATHE,
  97. ID_OBJECT_NEW_HSPLINE,
  98. ID_OBJECT_NEW_NURB,
  99. ID_OBJECT_NEW_SPHERE,
  100. ID_OBJECT_NEW_TORUS,
  101. ID_OBJECT_NEW_TTF,
  102. };
  103. static UINT BASED_CODE SelectButtons[] =
  104. {
  105. // same order as in the bitmap 'selectbar.bmp'
  106. ID_SELECT_CAMERA,
  107. ID_SELECT_PARENT,
  108. ID_SELECT_CHILD,
  109. ID_SELECT_OBJECT_AXIS,
  110. ID_SELECT_OBJECT_TEXTURE,
  111. ID_SELECT_OBJECT_TEXTURE_AXIS,
  112. ID_SELECT_OBJECT_EDGES,
  113. ID_SELECT_OBJECT_POINTS,
  114. ID_SELECT_POINTS,
  115. };
  116. static UINT BASED_CODE CommandButtons[] =
  117. {
  118. // same order as in the bitmap 'Commandb.bmp'
  119. ID_COMMAND_SELECT,
  120. ID_COMMAND_MOVE,
  121. ID_COMMAND_ROTATE,
  122. ID_COMMAND_SCALE,
  123. ID_COMMAND_PAINT,
  124. ID_COMMAND_POINTS_CREATE,
  125. ID_COORDINATE_X_AXIS,
  126. ID_COORDINATE_Y_AXIS,
  127. ID_COORDINATE_Z_AXIS,
  128. };
  129. static UINT BASED_CODE KeyFrameButtons[] =
  130. {
  131. // same order as in the bitmap 'Keyframe.bmp'
  132. ID_KEYFRAME_RECORD,
  133. ID_KEYFRAME_UNRECORD,
  134. ID_KEYFRAME_PLAY,
  135. ID_KEYFRAME_FIRST,
  136. ID_KEYFRAME_PREVIOUS,
  137. ID_KEYFRAME_NEXT,
  138. ID_KEYFRAME_LAST,
  139. ID_KEYFRAME_DECREASE,
  140. ID_SEPARATOR,
  141. ID_SEPARATOR, // marker for our CEdit Window
  142. ID_SEPARATOR,
  143. ID_KEYFRAME_INCREASE,
  144. };
  145. static UINT indicators[] =
  146. {
  147. ID_SEPARATOR,           // status line indicator
  148. ID_INDICATOR_CAPS,
  149. ID_INDICATOR_NUM,
  150. ID_INDICATOR_SCRL,
  151. };
  152. // Buttons must be big enough to hold image
  153. //   + 7 pixels on x
  154. //   + 6 pixels on y
  155. SIZE sizeButton = {26, 25};
  156. SIZE sizeImage  = {19, 19};
  157. /////////////////////////////////////////////////////////////////////////////
  158. // CMainFrame construction/destruction
  159. CMainFrame::CMainFrame()
  160. {
  161. m_bWndInitialized = FALSE;
  162. m_bToolTips = TRUE;
  163. m_pColorDlg = NULL;
  164. m_pMaterialDlg = NULL;
  165. m_pActiveView = NULL;
  166. }
  167. CMainFrame::~CMainFrame()
  168. {
  169. if(m_pColorDlg)
  170. delete m_pColorDlg;
  171. if(m_pMaterialDlg)
  172. delete m_pMaterialDlg;
  173. }
  174. /////////////////////////////////////////////////////////////////////////////
  175. // CMainFrame methods
  176. /////////////////////////////////////////////////////////////////////////////
  177. // CMainFrame message handlers
  178. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  179. {
  180. // cs.style |= (CS_OWNDC);
  181. return CMDIFrameWnd::PreCreateWindow(cs);
  182. }
  183. BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID, CCreateContext* pContext) 
  184. {
  185. // TODO: Add your specialized code here and/or call the base class
  186.    LPCTSTR lpszName = AfxRegisterWndClass(CS_HREDRAW|CS_VREDRAW,
  187. ::LoadCursor(NULL, IDC_ARROW));
  188. return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
  189. }
  190. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  191. {
  192. if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
  193. return -1;
  194. // Get the last setting of the window position from
  195. // the ini file and restore
  196. WINDOWPLACEMENT wp;
  197. GetWindowPlacement(&wp);
  198. if(!ReadWindowPlacement(&wp, "Settings", "MainFramePos"))
  199. {
  200. RECT rc;
  201. // The ini file is corrupt or does not exist, so get the size of the
  202. // CMDIFrameWnd client window and position it's window
  203. GetClientRect(&rc);
  204. wp.rcNormalPosition.top    = rc.top;
  205. wp.rcNormalPosition.bottom = rc.bottom;
  206. wp.rcNormalPosition.left   = rc.left;
  207. wp.rcNormalPosition.right  = rc.right;
  208. }
  209. // Now restore (or set) our window position
  210. m_bWndInitialized = TRUE;
  211. SetWindowPlacement(&wp);
  212. // Create our floating toolbars and dialog bars..
  213. if (!m_wndToolBar.Create(this) ||
  214. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  215. {
  216. TRACE0("Failed to create the mainframe toolbarn");
  217. return -1;      // fail to create
  218. }
  219. // TODO: Remove this if you don't want tool tips or a resizeable toolbar
  220. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  221. CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
  222. if (!m_wndStatusBar.Create(this) ||
  223. !m_wndStatusBar.SetIndicators(indicators,
  224.   sizeof(indicators)/sizeof(UINT)))
  225. {
  226. TRACE0("Failed to create the status barn");
  227. return -1;      // fail to create
  228. }
  229. if (!m_wndTreeDlgBar.Create(this, ID_TOOLS_TREE_VIEW,
  230. CBRS_RIGHT | CBRS_SIZE_DYNAMIC,
  231. ID_TOOLS_TREE_VIEW)) {
  232. TRACE0("Failed to create the Tree dialogbarn");
  233. return -1; // fail to create
  234. }
  235. if (!m_wndColorDlgBar.Create(this, IDD_DIALOG_COLOR,
  236. CBRS_RIGHT | CBRS_SIZE_FIXED,
  237. IDD_DIALOG_COLOR, TRUE)) {
  238. TRACE0("Failed to create the Color dialogbarn");
  239. return -1; // fail to create
  240. }
  241. if (!m_wndCoordDlgBar.Create(this, IDD_DIALOG_COORDINATE,
  242. CBRS_RIGHT | CBRS_SIZE_FIXED,
  243. IDD_DIALOG_COORDINATE, TRUE)) {
  244. TRACE0("Failed to create the Coordinate dialogbarn");
  245. return -1; // fail to create
  246. }
  247. if (!m_wndSceneBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_DYNAMIC |
  248. CBRS_TOP | ((m_bToolTips)?(CBRS_TOOLTIPS | CBRS_FLYBY):0), IDW_TOOLS_SCENE_BAR) ||
  249. !m_wndSceneBar.LoadBitmap(IDB_SCENEBAR) ||
  250. !m_wndSceneBar.SetButtons(SceneButtons, sizeof(SceneButtons)/sizeof(UINT)))
  251. {
  252. TRACE0("Failed to create the light toolbar.n");
  253. return -1;      // fail to create
  254. }
  255. if (!m_wnd2dShapeBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_DYNAMIC |
  256. CBRS_TOP | ((m_bToolTips)?(CBRS_TOOLTIPS | CBRS_FLYBY):0), IDW_TOOLS_2DSHAPE_BAR) ||
  257. !m_wnd2dShapeBar.LoadBitmap(IDB_2DSHAPEBAR) ||
  258. !m_wnd2dShapeBar.SetButtons(Shape2dButtons, sizeof(Shape2dButtons)/sizeof(UINT)))
  259. {
  260. TRACE0("Failed to create the shape toolbar.n");
  261. return -1;      // fail to create
  262. }
  263. if (!m_wnd3dShapeBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_DYNAMIC |
  264. CBRS_TOP | ((m_bToolTips)?(CBRS_TOOLTIPS | CBRS_FLYBY):0), IDW_TOOLS_3DSHAPE_BAR) ||
  265. !m_wnd3dShapeBar.LoadBitmap(IDB_3DSHAPEBAR) ||
  266. !m_wnd3dShapeBar.SetButtons(Shape3dButtons, sizeof(Shape3dButtons)/sizeof(UINT)))
  267. {
  268. TRACE0("Failed to create the shape toolbar.n");
  269. return -1;      // fail to create
  270. }
  271. if (!m_wndSelectBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_FIXED |
  272. CBRS_TOP | ((m_bToolTips)?(CBRS_TOOLTIPS | CBRS_FLYBY):0), IDW_TOOLS_SELECT_BAR) ||
  273. !m_wndSelectBar.LoadBitmap(IDB_SELECTBAR) ||
  274. !m_wndSelectBar.SetButtons(SelectButtons, sizeof(SelectButtons)/sizeof(UINT)))
  275. {
  276. TRACE0("Failed to create the Select toolbar.n");
  277. return -1;      // fail to create
  278. }
  279. if (!m_wndCommandBar.Create(this, WS_CHILD | WS_VISIBLE | CBRS_SIZE_FIXED |
  280. CBRS_TOP | ((m_bToolTips)?(CBRS_TOOLTIPS | CBRS_FLYBY):0), IDW_TOOLS_COMMAND_BAR) ||
  281. !m_wndCommandBar.LoadBitmap(IDB_COMMANDBAR) ||
  282. !m_wndCommandBar.SetButtons(CommandButtons, sizeof(CommandButtons)/sizeof(UINT)))
  283. {
  284. TRACE0("Failed to create teh Command toolbar.n");
  285. return -1;      // fail to create
  286. }
  287. if (!m_wndKeyFrameBar.Create(this, WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS | CBRS_SIZE_FIXED |
  288. CBRS_TOP | ((m_bToolTips)?(CBRS_TOOLTIPS | CBRS_FLYBY):0), IDW_TOOLS_KEYFRAME_BAR) ||
  289. !m_wndKeyFrameBar.LoadBitmap(IDB_KEYFRAMEBAR) ||
  290. !m_wndKeyFrameBar.SetButtons(KeyFrameButtons, sizeof(KeyFrameButtons)/sizeof(UINT)))
  291. {
  292. TRACE0("Failed to create the KeyFrame toolbar.n");
  293. return -1;      // fail to create
  294. }
  295. // Now that our Toolbars have been created, resize our
  296. // Toolbar Buttons and Images
  297. m_wndToolBar.SetSizes(sizeButton, sizeImage);
  298. m_wndSceneBar.SetSizes(sizeButton, sizeImage);
  299. m_wnd2dShapeBar.SetSizes(sizeButton, sizeImage);
  300. m_wnd3dShapeBar.SetSizes(sizeButton, sizeImage);
  301. m_wndKeyFrameBar.SetSizes(sizeButton, sizeImage);
  302. m_wndSelectBar.SetSizes(sizeButton, sizeImage);
  303. m_wndCommandBar.SetSizes(sizeButton, sizeImage);
  304. // Create the CEdit window for the KeyFrameBar
  305. // Design guide advises 12 pixel gap between combos and buttons
  306. m_wndKeyFrameBar.SetButtonInfo(8, ID_SEPARATOR, TBBS_SEPARATOR, 2);
  307. m_wndKeyFrameBar.SetButtonInfo(9, ID_KEYFRAME_TIME, TBBS_BUTTON, 20);
  308. m_wndKeyFrameBar.SetButtonInfo(10, ID_SEPARATOR, TBBS_SEPARATOR, 20);
  309. CRect rect;
  310. m_wndKeyFrameBar.GetItemRect(9, &rect);
  311. // rect.top = 3;
  312. rect.right = rect.right+18;
  313. if (!m_wndKeyFrameBar.m_EditBox.Create(
  314. WS_CHILD | WS_VISIBLE | // dwStyle
  315. WS_BORDER | 
  316. ES_LEFT | ES_NOHIDESEL,
  317. rect, // rect
  318. &m_wndKeyFrameBar, // CWnd* pParentWnd
  319. ID_KEYFRAME_TIME)) // UINT  nID
  320. {
  321. TRACE0("Failed to create Edit boxn");
  322. return FALSE;
  323. }
  324. char buf[10];
  325. sprintf(buf, "%3.1f", m_wndKeyFrameBar.m_fTime);
  326. m_wndKeyFrameBar.m_EditBox.ReplaceSel(buf, FALSE);
  327. // TODO: Delete these seven lines if you don't want the toolbars to
  328. //  be dockable
  329. m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
  330. m_wndTreeDlgBar.SetWindowText(_T("Tree View"));
  331. m_wndTreeDlgBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
  332. m_wndColorDlgBar.SetWindowText(_T("Color Palette"));
  333. m_wndColorDlgBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
  334. m_wndCoordDlgBar.SetWindowText(_T("Coordinate View"));
  335. m_wndCoordDlgBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
  336. m_wndSceneBar.SetWindowText(_T("Scene Objects"));
  337. m_wndSceneBar.EnableDocking(CBRS_ALIGN_ANY);
  338. m_wnd2dShapeBar.SetWindowText(_T("2d Shapes"));
  339. m_wnd2dShapeBar.EnableDocking(CBRS_ALIGN_ANY);
  340. m_wnd3dShapeBar.SetWindowText(_T("3d Shapes"));
  341. m_wnd3dShapeBar.EnableDocking(CBRS_ALIGN_ANY);
  342. m_wndSelectBar.SetWindowText(_T("Selection"));
  343. m_wndSelectBar.EnableDocking(CBRS_ALIGN_ANY);
  344. m_wndCommandBar.SetWindowText(_T("Commands"));
  345. m_wndCommandBar.EnableDocking(CBRS_ALIGN_ANY);
  346. m_wndKeyFrameBar.SetWindowText(_T("KeyFrame Animation Control"));
  347. m_wndKeyFrameBar.EnableDocking(CBRS_ALIGN_TOP | CBRS_ALIGN_BOTTOM);
  348. EnableDocking(CBRS_ALIGN_ANY);
  349. DockControlBar(&m_wndToolBar, AFX_IDW_DOCKBAR_TOP);
  350. DockControlBar(&m_wndTreeDlgBar, AFX_IDW_DOCKBAR_RIGHT);
  351. DockControlBar(&m_wndColorDlgBar, AFX_IDW_DOCKBAR_RIGHT);
  352. DockControlBar(&m_wndCoordDlgBar, AFX_IDW_DOCKBAR_RIGHT);
  353. DockControlBar(&m_wndSelectBar,AFX_IDW_DOCKBAR_LEFT);
  354. DockControlBar(&m_wndCommandBar,AFX_IDW_DOCKBAR_LEFT);
  355. DockControlBar(&m_wndSceneBar,AFX_IDW_DOCKBAR_BOTTOM);
  356. DockControlBar(&m_wnd2dShapeBar,AFX_IDW_DOCKBAR_BOTTOM);
  357. DockControlBar(&m_wnd3dShapeBar,AFX_IDW_DOCKBAR_BOTTOM);
  358. DockControlBar(&m_wndKeyFrameBar,AFX_IDW_DOCKBAR_BOTTOM);
  359. // LoadBarState loads everything but the number of Columns in the
  360. // Scene Objects, 2dShapes, 3dShapes, and CommandBar, so we need to do that
  361. // ourseleves.
  362. m_wndSceneBar.SetColumns(AfxGetApp()->GetProfileInt(_T("General"),_T("SceneBar Columns"), 1));
  363. m_wnd2dShapeBar.SetColumns(AfxGetApp()->GetProfileInt(_T("General"),_T("2dShapeBar Columns"), 1));
  364. m_wnd3dShapeBar.SetColumns(AfxGetApp()->GetProfileInt(_T("General"),_T("3dShapeBar Columns"), 1));
  365. m_wndSelectBar.SetColumns(AfxGetApp()->GetProfileInt(_T("General"),_T("SelectBar Columns"), 2));
  366. m_wndCommandBar.SetColumns(AfxGetApp()->GetProfileInt(_T("General"),_T("CommandBar Columns"), 2));
  367. m_wndKeyFrameBar.SetColumns(AfxGetApp()->GetProfileInt(_T("General"),_T("KeyFrameBar Columns"), 12));
  368. LoadBarState(_T("General"));
  369. // Do we show the splash screen or the splash dialog?
  370. CMyglApp* pApp = (CMyglApp*)AfxGetApp();
  371. ASSERT(pApp);
  372. if(pApp->m_bRegistered)
  373. // CG: The following line was added by the Splash Screen component.
  374. CSplashWnd::ShowSplashScreen(this);
  375. else
  376. CSplashDlg::ShowSplashDlg(this);
  377. return 0;
  378. }
  379. /////////////////////////////////////////////////////////////////////////////
  380. // CMainFrame diagnostics
  381. #ifdef _DEBUG
  382. void CMainFrame::AssertValid() const
  383. {
  384. CMDIFrameWnd::AssertValid();
  385. }
  386. void CMainFrame::Dump(CDumpContext& dc) const
  387. {
  388. CMDIFrameWnd::Dump(dc);
  389. }
  390. #endif //_DEBUG
  391. /////////////////////////////////////////////////////////////////////////////
  392. // CMainFrame message handlers
  393. /*
  394. BOOL CMainFrame::SetWindowPixelFormat(HDC hDC)
  395. {
  396. int nPixelFormat; // Pixel format index
  397. static PIXELFORMATDESCRIPTOR pfd = {
  398. sizeof(PIXELFORMATDESCRIPTOR), // Size of this structure
  399. 1, // Version of this structure
  400. PFD_DRAW_TO_WINDOW | // Draw to Window (not to bitmap)
  401. PFD_SUPPORT_OPENGL | // Support OpenGL calls in window
  402. PFD_DOUBLEBUFFER, // Double buffered mode
  403. PFD_TYPE_RGBA, // RGBA Color mode
  404. 24, // Want 24bit color 
  405. 0,0,0,0,0,0, // Not used to select mode
  406. 0,0, // Not used to select mode
  407. 0,0,0,0,0, // Not used to select mode
  408. 16, // Size of depth buffer
  409. 16, // Size of the Stencel buffer
  410. 0, // Not used to select mode
  411. PFD_MAIN_PLANE, // Draw in main plane
  412. 0, // Not used to select mode
  413. 0,0,0 }; // Not used to select mode
  414. // Choose a pixel format that best matches that described in pfd
  415. nPixelFormat = ChoosePixelFormat(hDC, &pfd);
  416. if (nPixelFormat==0) { // Let's choose a default index.
  417. nPixelFormat = 1;
  418. if (DescribePixelFormat(hDC, 
  419. nPixelFormat, 
  420. sizeof(PIXELFORMATDESCRIPTOR), 
  421. &pfd)==0)
  422. {
  423. return FALSE;
  424. }
  425. }
  426. DescribePixelFormat(hDC, nPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
  427. if(pfd.dwFlags & PFD_GENERIC_FORMAT)
  428. int temp = 0;
  429. // Set the pixel format for the device context
  430. if(!SetPixelFormat(hDC, nPixelFormat, &pfd)){
  431. return FALSE;
  432. }
  433. return TRUE;
  434. }
  435. */
  436. /////////////////////////////////////////////////////////////////////////////
  437. // CMainFrame message handlers
  438. void CMainFrame::OnDestroy() 
  439. {
  440. // Save our toolbars state information
  441. SaveBarState(_T("General"));
  442. // Save the state of our CMainFrame window
  443. WINDOWPLACEMENT wp;
  444. wp.length = sizeof wp;
  445. if (GetWindowPlacement(&wp))
  446. {
  447. wp.flags = 0;
  448. if (IsZoomed()) {
  449. wp.flags |= WPF_RESTORETOMAXIMIZED;
  450. // wp.showCmd |= SW_SHOWMAXIMIZED;
  451. }
  452. // and write it to the .INI file
  453. WriteWindowPlacement(&wp, "Settings", "MainFramePos");
  454. }
  455. CMDIFrameWnd::OnDestroy();
  456. }
  457. void CMainFrame::OnToolsTreeCtrl() 
  458. {
  459. // Display or hide the Color Dialog Bar..
  460. if(m_wndTreeDlgBar)
  461. {
  462. if(m_wndTreeDlgBar.IsWindowVisible())
  463. ShowControlBar(&m_wndTreeDlgBar, FALSE, FALSE);
  464. else
  465. ShowControlBar(&m_wndTreeDlgBar, TRUE, FALSE);
  466. }
  467. }
  468. void CMainFrame::OnUpdateToolsTreeCtrl(CCmdUI* pCmdUI) 
  469. {
  470. // Update the check state of the Tree Dialog Bar..
  471. if(m_wndTreeDlgBar) {
  472. if(m_wndTreeDlgBar.IsWindowVisible())
  473. pCmdUI->SetCheck(TRUE);
  474. else
  475. pCmdUI->SetCheck(FALSE);
  476. }
  477. else
  478. pCmdUI->SetCheck(FALSE);
  479. }
  480. long CMainFrame::OnRefreshDlgBar(WPARAM wParam, LPARAM lParam)
  481. {
  482. // User has switched views or is forcing an update of our dialog bars
  483. // as indicated in the wParam (wParam = RDB_FORCE_REFRESH)
  484. static C3dWorld* pCurrentWorld = NULL;
  485. BOOL bMaximized;
  486. CMDIChildWnd* pMDIChild = MDIGetActive(&bMaximized);
  487. if(pMDIChild)
  488. {
  489. // Save the pointer to our active CMyglView class
  490. m_pActiveView = (CMyglView*)pMDIChild->GetActiveView();
  491. ASSERT_VALID(m_pActiveView);
  492. CMyglDoc* pDoc = (CMyglDoc*)pMDIChild->GetActiveDocument();
  493. ASSERT_VALID(pDoc);
  494. // Save the pointer to our active C3dWorld
  495. m_pActiveWorld = pDoc->m_pWorld;
  496. }
  497. else
  498. {
  499. m_pActiveView = NULL;
  500. m_pActiveWorld = NULL;
  501. }
  502. // Update the tree control view only if different C3dWorld
  503. if(pCurrentWorld != m_pActiveWorld || wParam == RDB_FORCE_REFRESH)
  504. {
  505. pCurrentWorld = m_pActiveWorld;
  506. if(m_wndTreeDlgBar.IsWindowVisible())
  507. m_wndTreeDlgBar.DisplayTree(m_pActiveWorld);
  508. }
  509. return 0L;
  510. }
  511. void CMainFrame::OnToolsKeyframeBar() 
  512. {
  513. // Display or hide the KeyFrame Animation Toolbar
  514. if(m_wndKeyFrameBar)
  515. {
  516. if(m_wndKeyFrameBar.IsWindowVisible())
  517. ShowControlBar(&m_wndKeyFrameBar, FALSE, FALSE);
  518. else
  519. ShowControlBar(&m_wndKeyFrameBar, TRUE, FALSE);
  520. }
  521. }
  522. void CMainFrame::OnUpdateToolsKeyframeBar(CCmdUI* pCmdUI) 
  523. {
  524. // Update the check state of the KeyFrame Animation Toolbar..
  525. if(m_wndKeyFrameBar) {
  526. if(m_wndKeyFrameBar.IsWindowVisible())
  527. pCmdUI->SetCheck(TRUE);
  528. else
  529. pCmdUI->SetCheck(FALSE);
  530. }
  531. else
  532. pCmdUI->SetCheck(FALSE);
  533. }
  534. void CMainFrame::OnToolsSelectBar() 
  535. {
  536. // Display or hide the Selection Toolbar
  537. if(m_wndSelectBar)
  538. {
  539. if(m_wndSelectBar.IsWindowVisible())
  540. ShowControlBar(&m_wndSelectBar, FALSE, FALSE);
  541. else
  542. ShowControlBar(&m_wndSelectBar, TRUE, FALSE);
  543. }
  544. }
  545. void CMainFrame::OnUpdateToolsSelectBar(CCmdUI* pCmdUI) 
  546. {
  547. // Update the check state of the Select ToolBar..
  548. if(m_wndSelectBar) {
  549. if(m_wndSelectBar.IsWindowVisible())
  550. pCmdUI->SetCheck(TRUE);
  551. else
  552. pCmdUI->SetCheck(FALSE);
  553. }
  554. else
  555. pCmdUI->SetCheck(FALSE);
  556. }
  557. void CMainFrame::OnToolsCommandBar() 
  558. {
  559. // Display or hide the Command Toolbar
  560. if(m_wndCommandBar)
  561. {
  562. if(m_wndCommandBar.IsWindowVisible())
  563. ShowControlBar(&m_wndCommandBar, FALSE, FALSE);
  564. else
  565. ShowControlBar(&m_wndCommandBar, TRUE, FALSE);
  566. }
  567. }
  568. void CMainFrame::OnUpdateToolsCommandBar(CCmdUI* pCmdUI) 
  569. {
  570. // Update the check state of the Command ToolBar..
  571. if(m_wndCommandBar) {
  572. if(m_wndCommandBar.IsWindowVisible())
  573. pCmdUI->SetCheck(TRUE);
  574. else
  575. pCmdUI->SetCheck(FALSE);
  576. }
  577. else
  578. pCmdUI->SetCheck(FALSE);
  579. }
  580. void CMainFrame::OnTools2dshapeBar() 
  581. {
  582. // Display or hide the Shape Dialog Toolbar
  583. if(m_wnd2dShapeBar)
  584. {
  585. if(m_wnd2dShapeBar.IsWindowVisible())
  586. ShowControlBar(&m_wnd2dShapeBar, FALSE, FALSE);
  587. else
  588. ShowControlBar(&m_wnd2dShapeBar, TRUE, FALSE);
  589. }
  590. }
  591. void CMainFrame::OnUpdateTools2dshapeBar(CCmdUI* pCmdUI) 
  592. {
  593. // Update the check state of the Shape Dialog Toolbar..
  594. if(m_wnd2dShapeBar) {
  595. if(m_wnd2dShapeBar.IsWindowVisible())
  596. pCmdUI->SetCheck(TRUE);
  597. else
  598. pCmdUI->SetCheck(FALSE);
  599. }
  600. else
  601. pCmdUI->SetCheck(FALSE);
  602. }
  603. void CMainFrame::OnTools3dshapeBar() 
  604. {
  605. // Display or hide the Shape Dialog Toolbar
  606. if(m_wnd3dShapeBar)
  607. {
  608. if(m_wnd3dShapeBar.IsWindowVisible())
  609. ShowControlBar(&m_wnd3dShapeBar, FALSE, FALSE);
  610. else
  611. ShowControlBar(&m_wnd3dShapeBar, TRUE, FALSE);
  612. }
  613. }
  614. void CMainFrame::OnUpdateTools3dshapeBar(CCmdUI* pCmdUI) 
  615. {
  616. // Update the check state of the Shape Dialog Toolbar..
  617. if(m_wnd3dShapeBar) {
  618. if(m_wnd3dShapeBar.IsWindowVisible())
  619. pCmdUI->SetCheck(TRUE);
  620. else
  621. pCmdUI->SetCheck(FALSE);
  622. }
  623. else
  624. pCmdUI->SetCheck(FALSE);
  625. }
  626. void CMainFrame::OnToolsSceneBar() 
  627. {
  628. // Display or hide the Light Dialog Toolbar
  629. if(m_wndSceneBar)
  630. {
  631. if(m_wndSceneBar.IsWindowVisible())
  632. ShowControlBar(&m_wndSceneBar, FALSE, FALSE);
  633. else
  634. ShowControlBar(&m_wndSceneBar, TRUE, FALSE);
  635. }
  636. }
  637. void CMainFrame::OnUpdateToolsSceneBar(CCmdUI* pCmdUI) 
  638. {
  639. // Update the check state of the Light Dialog ToolBar..
  640. if(m_wndSceneBar) {
  641. if(m_wndSceneBar.IsWindowVisible())
  642. pCmdUI->SetCheck(TRUE);
  643. else
  644. pCmdUI->SetCheck(FALSE);
  645. }
  646. else
  647. pCmdUI->SetCheck(FALSE);
  648. }
  649. void CMainFrame::OnToolsPalette() 
  650. {
  651. // Display or hide the Color Dialog Toolbar..
  652. if(m_wndColorDlgBar)
  653. {
  654. if(m_wndColorDlgBar.IsWindowVisible())
  655. ShowControlBar(&m_wndColorDlgBar, FALSE, FALSE);
  656. else
  657. ShowControlBar(&m_wndColorDlgBar, TRUE, FALSE);
  658. }
  659. }
  660. void CMainFrame::OnUpdateToolsPalette(CCmdUI* pCmdUI) 
  661. {
  662. // Update the check state of the Palette Dialog Toolbar..
  663. if(m_wndColorDlgBar) {
  664. if(m_wndColorDlgBar.IsWindowVisible())
  665. pCmdUI->SetCheck(TRUE);
  666. else
  667. pCmdUI->SetCheck(FALSE);
  668. }
  669. else
  670. pCmdUI->SetCheck(FALSE);
  671. }
  672. void CMainFrame::OnToolsCoordinates() 
  673. {
  674. // Display or hide the Coordinates Dialog Toolbar..
  675. if(m_wndCoordDlgBar)
  676. {
  677. if(m_wndCoordDlgBar.IsWindowVisible())
  678. ShowControlBar(&m_wndCoordDlgBar, FALSE, FALSE);
  679. else
  680. ShowControlBar(&m_wndCoordDlgBar, TRUE, FALSE);
  681. }
  682. }
  683. void CMainFrame::OnUpdateToolsCoordinates(CCmdUI* pCmdUI) 
  684. {
  685. // Update the check state of the Coordinates Dialog Toolbar..
  686. if(m_wndCoordDlgBar)
  687. {
  688. if(m_wndCoordDlgBar.IsWindowVisible())
  689. pCmdUI->SetCheck(TRUE);
  690. else
  691. pCmdUI->SetCheck(FALSE);
  692. }
  693. else
  694. pCmdUI->SetCheck(FALSE);
  695. }
  696. void CMainFrame::OnPaletteChanged(CWnd* pFocusWnd) 
  697. {
  698. // CMDIFrameWnd::OnPaletteChanged(pFocusWnd);
  699. // Route message to CMDIChildWnd derived class, which will
  700. // inturn route the message to its' CView derived class.
  701. CMDIChildWnd* pChildWnd = MDIGetActive();
  702. if (pChildWnd) {
  703. // OnPaletteChanged is not public, so send a message.
  704. pChildWnd->SendMessage(WM_PALETTECHANGED,
  705.   (WPARAM)(pFocusWnd->GetSafeHwnd()),
  706.   (LPARAM)0);
  707. }
  708. // Route message to our Color Palette Dialog Bar
  709. if (m_wndColorDlgBar) {
  710. // OnPaletteChanged is not public, so send a message.
  711. m_wndColorDlgBar.SendMessage(WM_PALETTECHANGED,
  712.   (WPARAM)(pFocusWnd->GetSafeHwnd()),
  713.   (LPARAM)0);
  714. }
  715. }
  716. BOOL CMainFrame::OnQueryNewPalette() 
  717. {
  718. // Route message to CMDIChildWnd derived class, which will
  719. // inturn route the message to its' CView derived class.
  720. CMDIChildWnd* pChildWnd = MDIGetActive();
  721. if (pChildWnd) {
  722. // OnPaletteChanged is not public, so send a message.
  723. pChildWnd->SendMessage(WM_QUERYNEWPALETTE,
  724.   (WPARAM)0,
  725.   (LPARAM)0);
  726. }
  727. // Route message to our Color Palette Dialog Bar
  728. if (m_wndColorDlgBar) {
  729. // OnPaletteChanged is not public, so send a message.
  730. m_wndColorDlgBar.SendMessage(WM_QUERYNEWPALETTE,
  731.   (WPARAM)0,
  732.   (LPARAM)0);
  733. }
  734. return CMDIFrameWnd::OnQueryNewPalette();
  735. }
  736. void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
  737. {
  738. // Route message to CDialogBar derived CWnd class
  739. if (m_wndColorDlgBar) {
  740. // OnKeyDown is not public, so send a message.
  741. m_wndColorDlgBar.SendMessage(WM_KEYDOWN,
  742. (WPARAM)nChar,
  743. (LPARAM)nFlags<<16 | nRepCnt);
  744. }
  745. CMDIFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
  746. }
  747. void CMainFrame::OnWindowNew() 
  748. {
  749. CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  750. CDocument* pDocument;
  751. if(pMDIChildWnd == NULL || (pDocument = pMDIChildWnd->GetActiveDocument()) == NULL) {
  752. TRACE0("Warning:  No active document for WindowNew commandn");
  753. AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
  754. return; // command failed
  755. }
  756. // otherwise, we have a new frame!
  757. CDocTemplate* pTemplate = ((CMyglApp*) AfxGetApp())->m_pDocTemplate;
  758. ASSERT_VALID(pTemplate);
  759. CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDocument, pMDIChildWnd);
  760. if(pFrame == NULL) {
  761. TRACE0("Warning:  failed to create new framen");
  762. AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
  763. return; // command failed
  764. }
  765. pTemplate->InitialUpdateFrame(pFrame, pDocument);
  766. }
  767. void CMainFrame::OnViewMultiview() 
  768. {
  769. CMDIChildWnd* pMDIChildWnd = MDIGetActive();
  770. CDocument* pDocument;
  771. if(pMDIChildWnd == NULL || (pDocument = pMDIChildWnd->GetActiveDocument()) == NULL) {
  772. TRACE0("Warning:  No active document for WindowNew commandn");
  773. AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
  774. return; // command failed
  775. }
  776. // Get a pointer to our Iso view CMyglView class
  777. CMyglView* pIsoView = (CMyglView*)pMDIChildWnd->GetActiveView();
  778. ASSERT_VALID(pIsoView);
  779. pIsoView->ViewIso();
  780. // otherwise, we have a new frame!
  781. for(int i=0; i<3; i++) {
  782. CDocTemplate* pTemplate = ((CMyglApp*) AfxGetApp())->m_pDocTemplate;
  783. ASSERT_VALID(pTemplate);
  784. CFrameWnd* pFrame = pTemplate->CreateNewFrame(pDocument, pMDIChildWnd);
  785. if(pFrame == NULL) {
  786. TRACE0("Warning:  failed to create new framen");
  787. AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
  788. return; // command failed
  789. }
  790. pTemplate->InitialUpdateFrame(pFrame, pDocument);
  791. // Get a pointer to our newly created CMyglView class
  792. CMyglView* pView = (CMyglView*)pFrame->GetActiveView();
  793. ASSERT_VALID(pView);
  794. // Set the new CMyglView camera's depth equal to the original (iso) 
  795. // CMyglView camera's depth.  (same depth perspective)
  796. pView->m_Camera.m_fOrigin[Z] = pIsoView->m_Camera.m_fOrigin[Z];
  797. if(i == 0)
  798. pView->ViewSide();
  799. if(i == 1)
  800. pView->ViewFront();
  801. if(i == 2)
  802. pView->ViewTop();
  803. // Allow the 'child' views to share display lists..
  804. wglShareLists(pIsoView->m_hRC, // OpenGL rendering context with which to share display lists
  805.   pView->m_hRC);  // OpenGL rendering context to share display lists
  806. }
  807. MDITile(MDITILE_VERTICAL);
  808. }
  809. void CMainFrame::OnUpdateViewMultiview(CCmdUI* pCmdUI) 
  810. {
  811. // TODO: Add your command update UI handler code here
  812. }
  813. void CMainFrame::OnMaterialEdit() 
  814. {
  815. if(!m_pActiveWorld) {
  816. AfxMessageBox("Please select a document view first, then edit the world's materials.", MB_OK); 
  817. return;
  818. }
  819. // Display the Material modal dialog box
  820. // CEditMaterialDlg materialDlg(&m_pActiveWorld->m_MaterialList, &m_pActiveWorld->m_ColorList, this);
  821. // materialDlg.DoModal();
  822. // Modeless Dialog Creation
  823. if(!m_pMaterialDlg) {
  824. // Create a modeless dialog
  825. m_pMaterialDlg = new CEditMaterialDlg(&m_pActiveWorld->m_MaterialList, &m_pActiveWorld->m_ColorList, this);
  826. if (!m_pMaterialDlg->Create(IDD_EDIT_MATERIAL_DIALOG,
  827.   NULL)) {
  828. delete m_pMaterialDlg;
  829. m_pMaterialDlg = NULL;
  830. return;
  831. }
  832. // Center and show the window..
  833. m_pMaterialDlg->CenterWindow(NULL);
  834. m_pMaterialDlg->ShowWindow(SW_SHOW);
  835. }
  836. else {
  837. // Reset the dialog so the list diaplay points to 
  838. // the correct material list
  839. m_pMaterialDlg->ResetDlg(&m_pActiveWorld->m_MaterialList, &m_pActiveWorld->m_ColorList);
  840. if(m_pMaterialDlg->IsWindowVisible())
  841. m_pMaterialDlg->ShowWindow(SW_HIDE);
  842. else
  843. m_pMaterialDlg->ShowWindow(SW_SHOW);
  844. }
  845. // Force a repaint of the documents views
  846. if(m_pActiveView) {
  847. CDocument* pDoc = m_pActiveView->GetDocument();
  848. if(pDoc) {
  849. // Set the document as modified...
  850. pDoc->SetModifiedFlag(TRUE);
  851. // Force a repaint of the window
  852. pDoc->UpdateAllViews(NULL);
  853. }
  854. }
  855. }
  856. void CMainFrame::OnColorsEdit() 
  857. {
  858. if(!m_pActiveWorld) {
  859. AfxMessageBox("Please select a document view first, then edit the world's materials.", MB_OK); 
  860. return;
  861. }
  862. // Display the Material modal dialog box
  863. // CEditMaterialDlg materialDlg(pFirstView);
  864. // materialDlg.DoModal();
  865. if(!m_pColorDlg) {
  866. // Create a modeless dialog
  867. m_pColorDlg = new CEditColorsDlg(&m_pActiveWorld->m_ColorList, this);
  868. if (!m_pColorDlg->Create(IDD_EDIT_COLORS_DIALOG,
  869.   NULL)) {
  870. delete m_pColorDlg;
  871. m_pColorDlg = NULL;
  872. return;
  873. }
  874. // Center and show the window..
  875. m_pColorDlg->CenterWindow(NULL);
  876. m_pColorDlg->ShowWindow(SW_SHOW);
  877. }
  878. else {
  879. // Reset the dialog so the list diaplay points to 
  880. // the correct material list
  881. m_pColorDlg->ResetDlg(&m_pActiveWorld->m_ColorList);
  882. if(m_pColorDlg->IsWindowVisible())
  883. m_pColorDlg->ShowWindow(SW_HIDE);
  884. else
  885. m_pColorDlg->ShowWindow(SW_SHOW);
  886. }
  887. // Force a repaint of the documents views
  888. if(m_pActiveView) {
  889. CDocument* pDoc = m_pActiveView->GetDocument();
  890. if(pDoc) {
  891. // Set the document as modified...
  892. pDoc->SetModifiedFlag(TRUE);
  893. // Force a repaint of the window
  894. pDoc->UpdateAllViews(NULL);
  895. }
  896. }
  897. }
  898. void CMainFrame::OnHelpOpenGLDiagnostics() 
  899. {
  900. CMyglView* pView = (CMyglView*)m_pActiveView;
  901. if(pView)
  902. {
  903. COpenGLDiagnostics dlgOpenGLDiag(pView->m_pDC->GetSafeHdc(), pView->m_hRC, this);
  904. // Display the About dialog box
  905. dlgOpenGLDiag.DoModal();
  906. }
  907. }
  908. void CMainFrame::OnKeyframeDecrease() 
  909. {
  910. m_wndKeyFrameBar.m_fTime -= 1.0f;
  911. if(m_wndKeyFrameBar.m_fTime < 0.0f)
  912. m_wndKeyFrameBar.m_fTime = 0.0f;
  913. char buf[10];
  914. sprintf(buf, "%3.1f", m_wndKeyFrameBar.m_fTime);
  915. m_wndKeyFrameBar.m_EditBox.SetSel(0, -1, FALSE);
  916. m_wndKeyFrameBar.m_EditBox.Cut();
  917. m_wndKeyFrameBar.m_EditBox.ReplaceSel(buf, FALSE);
  918. // Get a pointer to our document and save the time index
  919. CMyglDoc* pDoc = (CMyglDoc*)m_pActiveView->GetDocument();
  920. ASSERT(pDoc);
  921. // pDoc->m_dTime = m_wndKeyFrameBar.m_fTime;
  922. // Force a repaint of the window
  923. // pDoc->UpdateAllViews(NULL);
  924. }
  925. void CMainFrame::OnUpdateKeyframeDecrease(CCmdUI* pCmdUI) 
  926. {
  927. if(m_wndKeyFrameBar.m_fTime == 0.0f)
  928. pCmdUI->Enable(FALSE);
  929. else
  930. pCmdUI->Enable(TRUE);
  931. }
  932. void CMainFrame::OnUpdateTime() 
  933. {
  934. char buf[10];
  935. int nChars =  m_wndKeyFrameBar.m_EditBox.GetLine(0, &buf[0], 10);
  936. sscanf(&buf[0], "%f", &m_wndKeyFrameBar.m_fTime);
  937. }
  938. void CMainFrame::OnKeyframeIncrease() 
  939. {
  940. UINT style = m_wndKeyFrameBar.GetButtonStyle(7);
  941. m_wndKeyFrameBar.SetButtonStyle(7, style|WS_VISIBLE);
  942. m_wndKeyFrameBar.m_fTime += 1.0f;
  943. char buf[10];
  944. sprintf(buf, "%3.1f", m_wndKeyFrameBar.m_fTime);
  945. m_wndKeyFrameBar.m_EditBox.SetSel(0, -1, FALSE);
  946. m_wndKeyFrameBar.m_EditBox.Cut();
  947. m_wndKeyFrameBar.m_EditBox.ReplaceSel(buf, FALSE);
  948. // Get a pointer to our document and save the time index
  949. CMyglDoc* pDoc = (CMyglDoc*)m_pActiveView->GetDocument();
  950. ASSERT(pDoc);
  951. // pDoc->m_dTime = m_wndKeyFrameBar.m_fTime;
  952. // Force a repaint of the window
  953. // pDoc->UpdateAllViews(NULL);
  954. }