1 // Ryzom - MMORPG Framework <http://dev.ryzom.com/projects/ryzom/>
2 // Copyright (C) 2010 Winch Gate Property Limited
4 // This source file has been modified by the following contributors:
5 // Copyright (C) 2019 Jan BOON (Kaetemi) <jan.boon@kaetemi.be>
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/>.
21 #include "georges_edit.h"
23 #include "child_frm.h"
25 #include "left_view.h"
26 #include "georges_edit_view.h"
27 #include "georges_edit_doc.h"
29 /////////////////////////////////////////////////////////////////////////////
31 IMPLEMENT_DYNCREATE(CChildFrame
, CMDIChildWnd
)
33 BEGIN_MESSAGE_MAP(CChildFrame
, CMDIChildWnd
)
34 //{{AFX_MSG_MAP(CChildFrame)
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
)
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))
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();
69 theApp
.loadWindowState (this, _T("child"), true, false);
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
) )
87 /////////////////////////////////////////////////////////////////////////////
88 // CChildFrame diagnostics
91 void CChildFrame::AssertValid() const
93 CMDIChildWnd::AssertValid();
96 void CChildFrame::Dump(CDumpContext
& dc
) const
98 CMDIChildWnd::Dump(dc
);
103 /////////////////////////////////////////////////////////////////////////////
104 // CChildFrame message handlers
105 CGeorgesEditView
* CChildFrame::GetRightPane()
107 CWnd
* pWnd
= m_wndSplitter
.GetPane(0, 1);
108 CGeorgesEditView
* pView
= DYNAMIC_DOWNCAST(CGeorgesEditView
, pWnd
);
112 void CChildFrame::OnUpdateViewStyles(CCmdUI
* pCmdUI
)
114 // TODO: customize or extend this code to handle choices on the
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
123 pCmdUI
->Enable(FALSE
);
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
)
136 pCmdUI
->Enable(FALSE
);
140 // otherwise, use dots to reflect the style of the view
142 BOOL bChecked
= FALSE
;
144 switch (pCmdUI
->m_nID
)
146 case ID_VIEW_DETAILS
:
147 bChecked
= (dwStyle
== LVS_REPORT
);
150 case ID_VIEW_SMALLICON
:
151 bChecked
= (dwStyle
== LVS_SMALLICON
);
154 case ID_VIEW_LARGEICON
:
155 bChecked
= (dwStyle
== LVS_ICON
);
159 bChecked
= (dwStyle
== LVS_LIST
);
167 pCmdUI
->SetRadio(bChecked
? 1 : 0);
173 void CChildFrame::OnViewStyle(UINT nCommandID
)
175 // TODO: customize or extend this code to handle choices on the
177 CGeorgesEditView
* pView
= GetRightPane();
179 // if the right-hand pane has been created and is a CGeorgesEditView,
180 // process the menu commands...
189 // ask the list control to snap to grid
190 /*CListCtrl& refListCtrl = pView->GetListCtrl();
191 refListCtrl.Arrange(LVA_SNAPTOGRID);*/
195 // other commands change the style on the list control
196 case ID_VIEW_DETAILS
:
197 dwStyle
= LVS_REPORT
;
200 case ID_VIEW_SMALLICON
:
201 dwStyle
= LVS_SMALLICON
;
204 case ID_VIEW_LARGEICON
:
213 // change the style; window will repaint automatically
215 pView
->ModifyStyle(LVS_TYPEMASK
, dwStyle
);
219 void CChildFrame::OnMDIActivate(BOOL bActivate
, CWnd
* pActivateWnd
, CWnd
* pDeactivateWnd
)
221 CMDIChildWnd::OnMDIActivate(bActivate
, pActivateWnd
, pDeactivateWnd
);
224 CGeorgesEditDoc
* pDoc
= GetRightPane()->GetDocument();
227 pDoc
->onActivateView ((bActivate
==TRUE
));
231 BOOL
CChildFrame::PreTranslateMessage(MSG
* pMsg
)
233 CGeorgesEditDoc
*doc
= (CGeorgesEditDoc
*)(GetRightPane()->GetDocument( ));
237 for (i
=0; i
<doc
->PluginArray
.size (); i
++)
239 if (doc
->PluginArray
[i
].PluginInterface
->pretranslateMessage (pMsg
))
244 return CMDIChildWnd::PreTranslateMessage(pMsg
);