MainFrm.cpp 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233
  1. /*
  2. ** Command & Conquer Renegade(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /***********************************************************************************************
  19. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  20. ***********************************************************************************************
  21. * *
  22. * Project Name : ChunkView *
  23. * *
  24. * $Archive:: /Commando/Code/Tools/ChunkView/MainFrm.cpp $*
  25. * *
  26. * Author:: Greg Hjelstrom *
  27. * *
  28. * $Modtime:: 9/28/99 9:46a $*
  29. * *
  30. * $Revision:: 2 $*
  31. * *
  32. *---------------------------------------------------------------------------------------------*
  33. * Functions: *
  34. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  35. // MainFrm.cpp : implementation of the CMainFrame class
  36. //
  37. #include "stdafx.h"
  38. #include "ChunkView.h"
  39. #include "MainFrm.h"
  40. #include "ChunkDataView.h"
  41. #include "ChunkTreeView.h"
  42. #ifdef _DEBUG
  43. #define new DEBUG_NEW
  44. #undef THIS_FILE
  45. static char THIS_FILE[] = __FILE__;
  46. #endif
  47. /////////////////////////////////////////////////////////////////////////////
  48. // CMainFrame
  49. IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
  50. BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
  51. //{{AFX_MSG_MAP(CMainFrame)
  52. ON_WM_CREATE()
  53. ON_COMMAND(ID_DISPLAY_HEX, OnDisplayHex)
  54. ON_UPDATE_COMMAND_UI(ID_DISPLAY_HEX, OnUpdateDisplayHex)
  55. ON_COMMAND(ID_DISPLAY_MICROCHUNKS, OnDisplayMicrochunks)
  56. ON_UPDATE_COMMAND_UI(ID_DISPLAY_MICROCHUNKS, OnUpdateDisplayMicrochunks)
  57. ON_COMMAND(ID_WORDMODE_BYTE, OnWordmodeByte)
  58. ON_UPDATE_COMMAND_UI(ID_WORDMODE_BYTE, OnUpdateWordmodeByte)
  59. ON_COMMAND(ID_WORDMODE_SHORT, OnWordmodeShort)
  60. ON_UPDATE_COMMAND_UI(ID_WORDMODE_SHORT, OnUpdateWordmodeShort)
  61. ON_COMMAND(ID_WORDMODE_LONG, OnWordmodeLong)
  62. ON_UPDATE_COMMAND_UI(ID_WORDMODE_LONG, OnUpdateWordmodeLong)
  63. //}}AFX_MSG_MAP
  64. END_MESSAGE_MAP()
  65. static UINT indicators[] =
  66. {
  67. ID_SEPARATOR, // status line indicator
  68. ID_INDICATOR_CAPS,
  69. ID_INDICATOR_NUM,
  70. ID_INDICATOR_SCRL,
  71. };
  72. /////////////////////////////////////////////////////////////////////////////
  73. // CMainFrame construction/destruction
  74. CMainFrame::CMainFrame()
  75. {
  76. // TODO: add member initialization code here
  77. }
  78. CMainFrame::~CMainFrame()
  79. {
  80. }
  81. int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
  82. {
  83. if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
  84. return -1;
  85. if (!m_wndToolBar.CreateEx(this) ||
  86. !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
  87. {
  88. TRACE0("Failed to create toolbar\n");
  89. return -1; // fail to create
  90. }
  91. if (!m_wndReBar.Create(this) ||
  92. !m_wndReBar.AddBar(&m_wndToolBar))
  93. {
  94. TRACE0("Failed to create rebar\n");
  95. return -1; // fail to create
  96. }
  97. if (!m_wndStatusBar.Create(this) ||
  98. !m_wndStatusBar.SetIndicators(indicators,
  99. sizeof(indicators)/sizeof(UINT)))
  100. {
  101. TRACE0("Failed to create status bar\n");
  102. return -1; // fail to create
  103. }
  104. // TODO: Remove this if you don't want tool tips
  105. m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
  106. CBRS_TOOLTIPS | CBRS_FLYBY);
  107. return 0;
  108. }
  109. BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
  110. {
  111. if( !CFrameWnd::PreCreateWindow(cs) )
  112. return FALSE;
  113. // TODO: Modify the Window class or styles here by modifying
  114. // the CREATESTRUCT cs
  115. return TRUE;
  116. }
  117. /////////////////////////////////////////////////////////////////////////////
  118. // CMainFrame diagnostics
  119. #ifdef _DEBUG
  120. void CMainFrame::AssertValid() const
  121. {
  122. CFrameWnd::AssertValid();
  123. }
  124. void CMainFrame::Dump(CDumpContext& dc) const
  125. {
  126. CFrameWnd::Dump(dc);
  127. }
  128. #endif //_DEBUG
  129. BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
  130. {
  131. // Create the main splitter window for the application
  132. BOOL ok = m_wndSplitter.CreateStatic (this, 1, 2);
  133. ASSERT(ok);
  134. if (!ok) return FALSE;
  135. // Create the two sub views
  136. ok &= m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CChunkTreeView),CSize(200,10),pContext);
  137. ok &= m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CChunkDataView),CSize(340,10),pContext);
  138. ASSERT(ok);
  139. if (!ok) return FALSE;
  140. return TRUE;
  141. }
  142. CChunkDataView * CMainFrame::Get_Data_View(void)
  143. {
  144. return (CChunkDataView *)m_wndSplitter.GetPane(0,1);
  145. }
  146. CChunkTreeView * CMainFrame::Get_Tree_View(void)
  147. {
  148. return (CChunkTreeView *)m_wndSplitter.GetPane(0,0);
  149. }
  150. void CMainFrame::OnDisplayHex()
  151. {
  152. Get_Data_View()->Set_Display_Mode(CChunkDataView::DISPLAY_MODE_HEX);
  153. }
  154. void CMainFrame::OnUpdateDisplayHex(CCmdUI* pCmdUI)
  155. {
  156. pCmdUI->SetCheck(Get_Data_View()->Get_Display_Mode() == CChunkDataView::DISPLAY_MODE_HEX);
  157. }
  158. void CMainFrame::OnDisplayMicrochunks()
  159. {
  160. Get_Data_View()->Set_Display_Mode(CChunkDataView::DISPLAY_MODE_MICROCHUNKS);
  161. }
  162. void CMainFrame::OnUpdateDisplayMicrochunks(CCmdUI* pCmdUI)
  163. {
  164. pCmdUI->SetCheck(Get_Data_View()->Get_Display_Mode() == CChunkDataView::DISPLAY_MODE_MICROCHUNKS);
  165. }
  166. void CMainFrame::OnWordmodeByte()
  167. {
  168. Get_Data_View()->Set_Word_Size(CChunkDataView::WORD_SIZE_BYTE);
  169. }
  170. void CMainFrame::OnUpdateWordmodeByte(CCmdUI* pCmdUI)
  171. {
  172. pCmdUI->SetCheck(Get_Data_View()->Get_Word_Size() == CChunkDataView::WORD_SIZE_BYTE);
  173. }
  174. void CMainFrame::OnWordmodeShort()
  175. {
  176. Get_Data_View()->Set_Word_Size(CChunkDataView::WORD_SIZE_SHORT);
  177. }
  178. void CMainFrame::OnUpdateWordmodeShort(CCmdUI* pCmdUI)
  179. {
  180. pCmdUI->SetCheck(Get_Data_View()->Get_Word_Size() == CChunkDataView::WORD_SIZE_SHORT);
  181. }
  182. void CMainFrame::OnWordmodeLong()
  183. {
  184. Get_Data_View()->Set_Word_Size(CChunkDataView::WORD_SIZE_LONG);
  185. }
  186. void CMainFrame::OnUpdateWordmodeLong(CCmdUI* pCmdUI)
  187. {
  188. pCmdUI->SetCheck(Get_Data_View()->Get_Word_Size() == CChunkDataView::WORD_SIZE_LONG);
  189. }