Merge branch 'fixes' into main/rendor-staging
[ryzomcore.git] / ryzom / tools / leveldesign / georges_dll / child_frm.cpp
blob941992d34ce172773a412191235935d0650e7efb
1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
3 //
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
6 //
7 // This program is free software: you can redistribute it and/or modify
8 // it under the terms of the GNU Affero General Public License as
9 // published by the Free Software Foundation, either version 3 of the
10 // License, or (at your option) any later version.
12 // This program is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU Affero General Public License for more details.
17 // You should have received a copy of the GNU Affero General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
20 #include "stdafx.h"
21 #include "georges_edit.h"
23 #include "child_frm.h"
24 #include "main_frm.h"
25 #include "left_view.h"
26 #include "georges_edit_view.h"
27 #include "georges_edit_doc.h"
29 /////////////////////////////////////////////////////////////////////////////
30 // CChildFrame
31 IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)
33 BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
34 //{{AFX_MSG_MAP(CChildFrame)
35 ON_WM_MDIACTIVATE()
36 //}}AFX_MSG_MAP
37 ON_UPDATE_COMMAND_UI_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnUpdateViewStyles)
38 ON_COMMAND_RANGE(AFX_ID_VIEW_MINIMUM, AFX_ID_VIEW_MAXIMUM, OnViewStyle)
39 END_MESSAGE_MAP()
41 /////////////////////////////////////////////////////////////////////////////
42 // CChildFrame construction/destruction
44 CChildFrame::CChildFrame()
46 // TODO: add member initialization code here
50 CChildFrame::~CChildFrame()
54 BOOL CChildFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/,
55 CCreateContext* pContext)
57 // create splitter window
58 if (!m_wndSplitter.CreateStatic(this, 1, 2))
59 return FALSE;
61 if (!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(300, 100), pContext) ||
62 !m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CGeorgesEditView), CSize(100, 100), pContext))
64 m_wndSplitter.DestroyWindow();
65 return FALSE;
68 // Load state
69 theApp.loadWindowState (this, _T("child"), true, false);
71 return TRUE;
74 BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
76 // TODO: Modify the Window class or styles here by modifying
77 // the CREATESTRUCT cs
79 if( !CMDIChildWnd::PreCreateWindow(cs) )
80 return FALSE;
82 return TRUE;
87 /////////////////////////////////////////////////////////////////////////////
88 // CChildFrame diagnostics
90 #ifdef _DEBUG
91 void CChildFrame::AssertValid() const
93 CMDIChildWnd::AssertValid();
96 void CChildFrame::Dump(CDumpContext& dc) const
98 CMDIChildWnd::Dump(dc);
101 #endif //_DEBUG
103 /////////////////////////////////////////////////////////////////////////////
104 // CChildFrame message handlers
105 CGeorgesEditView* CChildFrame::GetRightPane()
107 CWnd* pWnd = m_wndSplitter.GetPane(0, 1);
108 CGeorgesEditView* pView = DYNAMIC_DOWNCAST(CGeorgesEditView, pWnd);
109 return pView;
112 void CChildFrame::OnUpdateViewStyles(CCmdUI* pCmdUI)
114 // TODO: customize or extend this code to handle choices on the
115 // View menu.
117 CGeorgesEditView* pView = GetRightPane();
119 // if the right-hand pane hasn't been created or isn't a view,
120 // disable commands in our range
122 if (pView == NULL)
123 pCmdUI->Enable(FALSE);
124 else
126 DWORD dwStyle = pView->GetStyle() & LVS_TYPEMASK;
128 // if the command is ID_VIEW_LINEUP, only enable command
129 // when we're in LVS_ICON or LVS_SMALLICON mode
131 if (pCmdUI->m_nID == ID_VIEW_LINEUP)
133 if (dwStyle == LVS_ICON || dwStyle == LVS_SMALLICON)
134 pCmdUI->Enable();
135 else
136 pCmdUI->Enable(FALSE);
138 else
140 // otherwise, use dots to reflect the style of the view
141 pCmdUI->Enable();
142 BOOL bChecked = FALSE;
144 switch (pCmdUI->m_nID)
146 case ID_VIEW_DETAILS:
147 bChecked = (dwStyle == LVS_REPORT);
148 break;
150 case ID_VIEW_SMALLICON:
151 bChecked = (dwStyle == LVS_SMALLICON);
152 break;
154 case ID_VIEW_LARGEICON:
155 bChecked = (dwStyle == LVS_ICON);
156 break;
158 case ID_VIEW_LIST:
159 bChecked = (dwStyle == LVS_LIST);
160 break;
162 default:
163 bChecked = FALSE;
164 break;
167 pCmdUI->SetRadio(bChecked ? 1 : 0);
173 void CChildFrame::OnViewStyle(UINT nCommandID)
175 // TODO: customize or extend this code to handle choices on the
176 // View menu.
177 CGeorgesEditView* pView = GetRightPane();
179 // if the right-hand pane has been created and is a CGeorgesEditView,
180 // process the menu commands...
181 if (pView != NULL)
183 DWORD dwStyle = -1;
185 switch (nCommandID)
187 case ID_VIEW_LINEUP:
189 // ask the list control to snap to grid
190 /*CListCtrl& refListCtrl = pView->GetListCtrl();
191 refListCtrl.Arrange(LVA_SNAPTOGRID);*/
193 break;
195 // other commands change the style on the list control
196 case ID_VIEW_DETAILS:
197 dwStyle = LVS_REPORT;
198 break;
200 case ID_VIEW_SMALLICON:
201 dwStyle = LVS_SMALLICON;
202 break;
204 case ID_VIEW_LARGEICON:
205 dwStyle = LVS_ICON;
206 break;
208 case ID_VIEW_LIST:
209 dwStyle = LVS_LIST;
210 break;
213 // change the style; window will repaint automatically
214 if (dwStyle != -1)
215 pView->ModifyStyle(LVS_TYPEMASK, dwStyle);
219 void CChildFrame::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
221 CMDIChildWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
223 // Get the doc
224 CGeorgesEditDoc* pDoc = GetRightPane()->GetDocument();
225 if (pDoc)
227 pDoc->onActivateView ((bActivate==TRUE));
231 BOOL CChildFrame::PreTranslateMessage(MSG* pMsg)
233 CGeorgesEditDoc *doc = (CGeorgesEditDoc*)(GetRightPane()->GetDocument( ));
234 if (doc)
236 uint i;
237 for (i=0; i<doc->PluginArray.size (); i++)
239 if (doc->PluginArray[i].PluginInterface->pretranslateMessage (pMsg))
240 return TRUE;
244 return CMDIChildWnd::PreTranslateMessage(pMsg);