MyViewFrame.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. FinalSun/FinalAlert 2 Mission Editor
  3. Copyright (C) 1999-2024 Electronic Arts, Inc.
  4. Authored by Matthias Wagner
  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. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program. If not, see <https://www.gnu.org/licenses/>.
  15. */
  16. // MyViewFrame.cpp: Implementierungsdatei
  17. //
  18. #include "stdafx.h"
  19. #include "FinalSun.h"
  20. #include "MyViewFrame.h"
  21. #ifdef _DEBUG
  22. #define new DEBUG_NEW
  23. #undef THIS_FILE
  24. static char THIS_FILE[] = __FILE__;
  25. #endif
  26. /////////////////////////////////////////////////////////////////////////////
  27. // CMyViewFrame
  28. IMPLEMENT_DYNCREATE(CMyViewFrame, CFrameWnd)
  29. CMyViewFrame::CMyViewFrame()
  30. {
  31. m_isoview=0;
  32. }
  33. CMyViewFrame::~CMyViewFrame()
  34. {
  35. }
  36. BEGIN_MESSAGE_MAP(CMyViewFrame, CFrameWnd)
  37. //{{AFX_MSG_MAP(CMyViewFrame)
  38. ON_WM_SYSCOMMAND()
  39. ON_WM_SIZE()
  40. ON_WM_GETMINMAXINFO()
  41. ON_WM_KEYDOWN()
  42. ON_WM_KEYUP()
  43. ON_WM_CHAR()
  44. //}}AFX_MSG_MAP
  45. END_MESSAGE_MAP()
  46. /////////////////////////////////////////////////////////////////////////////
  47. // Behandlungsroutinen für Nachrichten CMyViewFrame
  48. BOOL CMyViewFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
  49. {
  50. SIZE z;
  51. z.cx=200;
  52. z.cy=200;
  53. CRect r;
  54. r.right=200;
  55. r.bottom=200;
  56. if(!m_Splitter.CreateStatic(this,1,2)) return FALSE;
  57. if(!m_Splitter.CreateView(0,0,
  58. RUNTIME_CLASS(CViewObjects),
  59. z,
  60. pContext)) return FALSE;
  61. if(!m_Splitter.CreateView(0,1,
  62. RUNTIME_CLASS(CRightFrame),
  63. z,
  64. pContext)) return FALSE;
  65. OutputDebugString("CMyViewFrame::OnCreateClient(): windows created\n");
  66. m_rightFrame=(CRightFrame*)m_Splitter.GetPane(0,1);
  67. m_isoview=(CIsoView*)m_rightFrame->m_Splitter.GetPane(0,0);
  68. m_isoview->owner=this;
  69. m_browser=(CTileSetBrowserFrame*)m_rightFrame->m_Splitter.GetPane(1,0);
  70. m_objectview=(CViewObjects*)m_Splitter.GetPane(0,0);
  71. // the minimap is not a child window right now, but it is created here though
  72. auto miniMapClass = AfxRegisterWndClass(0, m_hArrowCursor, static_cast<HBRUSH>(::GetStockObject(GRAY_BRUSH)));
  73. m_minimap.CreateEx(0, miniMapClass, "Minimap", WS_POPUPWINDOW | WS_CAPTION | WS_VISIBLE, r, NULL, 0);
  74. //m_minimap.Create(NULL, "Minimap", WS_OVERLAPPED)
  75. m_minimap.UpdateView();
  76. if(!m_statbar.CreateEx(this,SBARS_SIZEGRIP | SBT_TOOLTIPS)) return FALSE;
  77. return CFrameWnd::OnCreateClient(lpcs, pContext);
  78. }
  79. void CMyViewFrame::OnSysCommand(UINT nID, LPARAM lParam)
  80. {
  81. if(nID==SC_CLOSE)
  82. {
  83. // ok now just hide the window
  84. ShowWindow(SW_HIDE);
  85. return;
  86. }
  87. CFrameWnd::OnSysCommand(nID, lParam);
  88. }
  89. void CMyViewFrame::OnSize(UINT nType, int cx, int cy)
  90. {
  91. // we now check if our frame window has already created its child windows
  92. // this is true at the second OnSize
  93. // TODO: replace static
  94. static BOOL wasHere=FALSE;
  95. if(wasHere==FALSE)
  96. {
  97. wasHere=TRUE;
  98. return;
  99. }
  100. CFrameWnd::OnSize(nType, cx, cy);
  101. CStatusBarCtrl& stat=m_statbar.GetStatusBarCtrl();
  102. m_statbar.ShowWindow(SW_SHOW);
  103. CRect sr;
  104. GetWindowRect(sr);
  105. //int Widths[]={sr.right-80,80,-1};
  106. int Widths[]={sr.right-sr.left-130,-1};
  107. stat.SetParts(2, Widths);
  108. stat.SetSimple(FALSE);
  109. m_statbar.ShowWindow(SW_SHOW);
  110. }
  111. void CMyViewFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
  112. {
  113. lpMMI->ptMinTrackSize.x=260;
  114. lpMMI->ptMinTrackSize.y=150;
  115. CFrameWnd::OnGetMinMaxInfo(lpMMI);
  116. }
  117. void CMyViewFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
  118. {
  119. m_isoview->SendMessage(WM_KEYDOWN, nChar, nFlags);
  120. // CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
  121. }
  122. void CMyViewFrame::PostNcDestroy()
  123. {
  124. // do not call CFrameWnd::PostNcDestroy(), as long as MyViewFrame is not on the heap!
  125. // CFrameWnd::PostNcDestroy();
  126. }
  127. void CMyViewFrame::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
  128. {
  129. // TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen
  130. // CFrameWnd::OnKeyUp(nChar, nRepCnt, nFlags);
  131. }
  132. void CMyViewFrame::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
  133. {
  134. // TODO: Code für die Behandlungsroutine für Nachrichten hier einfügen und/oder Standard aufrufen
  135. // CFrameWnd::OnChar(nChar, nRepCnt, nFlags);
  136. }