Develop and Download Open Source Software

Browse CVS Repository

Contents of /satellite/neuromanager/neuromanager/MainFrm.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (show annotations) (download) (as text)
Thu Mar 23 19:14:52 2006 UTC (18 years ago) by orrisroot
Branch: MAIN
CVS Tags: HEAD
Changes since 1.4: +26 -1 lines
File MIME type: text/x-c++src
added dynamic update code of main menu.

1 /* --------------------------------------------------------------------- */
2 /* NeuroManager - A spike train analysis tool */
3 /* Copyright (c) 2005-2006 RIKEN, Japan. All rights reserved. */
4 /* http://satellite.sourceforge.jp/ */
5 /* --------------------------------------------------------------------- */
6 /* This program is free software; you can redistribute it and/or */
7 /* modify it under the terms of the GNU General Public License */
8 /* as published by the Free Software Foundation; either version 2 */
9 /* of the License, or (at your option) any later version. */
10 /* */
11 /* This program is distributed in the hope that it will be useful, */
12 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
13 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
14 /* GNU General Public License for more details. */
15 /* */
16 /* You should have received a copy of the GNU General Public License */
17 /* along with this program; see the file COPYING.txt. If not, write */
18 /* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth */
19 /* Floor, Boston, MA 02110-1301, USA. */
20 /* --------------------------------------------------------------------- */
21
22 /* $Id: MainFrm.cpp,v 1.4 2006/03/20 08:34:51 orrisroot Exp $ */
23
24 // MainFrm.cpp : implementation of the CMainFrame class
25 //
26
27 #include "stdafx.h"
28 #include "NeuroManager.h"
29 #include "NeuroManagerDoc.h"
30 #include "DataViewSplitter.h"
31 #include "DataViewBar.h"
32 #include "SpikeViewSplitter.h"
33 #include "SpikeViewBar.h"
34 #include "MainFrm.h"
35 #include ".\mainfrm.h"
36
37 #ifdef _DEBUG
38 #define new DEBUG_NEW
39 #endif
40
41
42 // CMainFrame
43
44 IMPLEMENT_DYNCREATE( CMainFrame, CFrameWnd )
45
46 BEGIN_MESSAGE_MAP( CMainFrame, CFrameWnd )
47 ON_WM_CREATE()
48 ON_COMMAND( ID_VIEW_DATAVIEW_BAR, OnViewDataViewBar )
49 ON_COMMAND( ID_VIEW_SPIKEVIEW_BAR, OnViewSpikeViewBar )
50 ON_UPDATE_COMMAND_UI( ID_VIEW_DATAVIEW_BAR, OnUpdateViewDataViewBar )
51 ON_UPDATE_COMMAND_UI( ID_VIEW_SPIKEVIEW_BAR, OnUpdateViewSpikeViewBar )
52 // for Data Type Plugin
53 ON_COMMAND_RANGE( ID_MCDATAFILE_OPEN_CMD01, ID_MCDATAFILE_OPEN_CMD01 +
54 CMCDataManager::GetMaxFileTypes(),
55 OnOpenMCDataFileType )
56 END_MESSAGE_MAP()
57
58 static UINT indicators[] =
59 {
60 // status line indicator
61 ID_SEPARATOR,
62 ID_INDICATOR_CAPS,
63 ID_INDICATOR_NUM,
64 ID_INDICATOR_SCRL,
65 };
66
67
68 // CMainFrame construction/destruction
69
70 CMainFrame::CMainFrame()
71 {
72 // TODO: add member initialization code here
73 }
74
75 CMainFrame::~CMainFrame()
76 {}
77
78
79 int CMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct )
80 {
81 if ( CFrameWnd::OnCreate( lpCreateStruct ) == -1 )
82 return -1;
83
84 if ( !m_wndToolBar.CreateEx( this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
85 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC ) ||
86 !m_wndToolBar.LoadToolBar( IDR_MAINFRAME ) )
87 {
88 TRACE0( "Failed to create toolbar\n" );
89 return -1; // fail to create
90 }
91
92 if ( !m_wndStatusBar.Create( this ) ||
93 !m_wndStatusBar.SetIndicators( indicators,
94 sizeof( indicators ) / sizeof( UINT ) ) )
95 {
96 TRACE0( "Failed to create status bar\n" );
97 return -1; // fail to create
98 }
99
100 // data view bar
101 CString strDataView;
102 strDataView.LoadString( IDS_DATAVIEW );
103 if ( !m_wndDataViewBar.Create( strDataView, this,
104 CSize( DEFAULT_DATAVIEW_WIDTH, DEFAULT_DATAVIEW_HEIGHT ), TRUE, IDS_DATAVIEW ) )
105 {
106 TRACE0( "Failed to create data view bar\n" );
107 return -1; // fail to create
108 }
109 CCreateContext* pContext = ( CCreateContext* ) lpCreateStruct->lpCreateParams;
110 BOOL ret = m_wndDataViewBar.CreateInnerViews( pContext );
111 if ( ret == FALSE )
112 return -1;
113
114 m_wndDataViewBar.SetBarStyle( m_wndDataViewBar.GetBarStyle() |
115 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );
116
117 // spike view bar
118 CString strSpikeView;
119 strSpikeView.LoadString( IDS_SPIKEVIEW );
120 if ( !m_wndSpikeViewBar.Create( strSpikeView, this,
121 CSize( DEFAULT_DATAVIEW_WIDTH, DEFAULT_DATAVIEW_HEIGHT ), TRUE, IDS_SPIKEVIEW ) )
122 {
123 TRACE0( "Failed to create spike view bar\n" );
124 return -1; // fail to create
125 }
126 pContext = ( CCreateContext* ) lpCreateStruct->lpCreateParams;
127 ret = m_wndSpikeViewBar.CreateInnerViews( pContext );
128 if ( ret == FALSE )
129 return -1;
130
131 m_wndSpikeViewBar.SetBarStyle( m_wndSpikeViewBar.GetBarStyle() |
132 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );
133
134 // setting for dockable bars
135 m_wndToolBar.EnableDocking( CBRS_ALIGN_ANY );
136 m_wndDataViewBar.EnableDocking( CBRS_ALIGN_TOP );
137 m_wndSpikeViewBar.EnableDocking( CBRS_ALIGN_ANY );
138 EnableDocking( CBRS_ALIGN_ANY );
139 DockControlBar( &m_wndToolBar );
140 DockControlBar( &m_wndDataViewBar );
141 DockControlBar( &m_wndSpikeViewBar );
142
143 // load scrollbar setting
144 SaveLoadToolBar( FALSE );
145
146 return 0;
147 }
148
149 BOOL CMainFrame::PreCreateWindow( CREATESTRUCT& cs )
150 {
151 if ( !CFrameWnd::PreCreateWindow( cs ) )
152 return FALSE;
153 // TODO: Modify the Window class or styles here by modifying
154 // the CREATESTRUCT cs
155 cs.style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
156 return TRUE;
157 }
158
159
160 // CMainFrame diagnostics
161
162 #ifdef _DEBUG
163 void CMainFrame::AssertValid() const
164 {
165 CFrameWnd::AssertValid();
166 }
167
168 void CMainFrame::Dump( CDumpContext& dc ) const
169 {
170 CFrameWnd::Dump( dc );
171 }
172 #endif //_DEBUG
173
174
175 // CMainFrame message handlers
176 void CMainFrame::OnOpenMCDataFileType( UINT nID )
177 {
178 // Retrieve the selected dynamic item Name
179 CString strItemText = "item"; //m_DynamicItems.GetItemText( nID );
180
181 // Retrieve the selected dynamic item associated comment
182 CString strItemComment = "comment"; //m_DynamicItems.GetItemComment( nID );
183
184 // Display it.
185 CString strMsg = "";
186
187 strMsg.Format( "Cmd %d selected.\nItem Name: %s\nAssociated data: %s",
188 ( nID - ID_MCDATAFILE_OPEN_CMD01 ), strItemText, strItemComment );
189
190 AfxMessageBox( strMsg );
191 }
192
193 void CMainFrame::OnViewDataViewBar()
194 {
195 BOOL bShow = m_wndDataViewBar.IsVisible();
196 ShowControlBar( &m_wndDataViewBar, !bShow, FALSE );
197 }
198
199 void CMainFrame::OnViewSpikeViewBar()
200 {
201 BOOL bShow = m_wndSpikeViewBar.IsVisible();
202 ShowControlBar( &m_wndSpikeViewBar, !bShow, FALSE );
203 }
204
205 void CMainFrame::OnUpdateViewDataViewBar( CCmdUI *pCmdUI )
206 {
207 pCmdUI->Enable();
208 pCmdUI->SetCheck( m_wndDataViewBar.IsVisible() );
209 }
210
211 void CMainFrame::OnUpdateViewSpikeViewBar( CCmdUI *pCmdUI )
212 {
213 pCmdUI->Enable();
214 pCmdUI->SetCheck( m_wndSpikeViewBar.IsVisible() );
215 }
216
217 void CMainFrame::SaveLoadToolBar( BOOL bSave )
218 {
219 // when bSave = TRUE save toolbar setting, FALSE for load settings
220 CString strDataViewToolBarReg = _T( "DataViewBar" );
221 CString strSpikeViewToolBarReg = _T( "SpikeViewBar" );
222 CString strBarStateReg = _T( "BarState" );
223 if ( bSave )
224 {
225 SaveBarState( strBarStateReg );
226 m_wndDataViewBar.SaveState( strDataViewToolBarReg );
227 m_wndSpikeViewBar.SaveState( strSpikeViewToolBarReg );
228 }
229 else
230 {
231 m_wndSpikeViewBar.LoadState( strSpikeViewToolBarReg );
232 m_wndDataViewBar.LoadState( strDataViewToolBarReg );
233 LoadBarState( strBarStateReg );
234 }
235 }
236
237 BOOL CMainFrame::DestroyWindow()
238 {
239 // TODO: Add your specialized code here and/or call the base class
240 SaveLoadToolBar( TRUE );
241
242 return CFrameWnd::DestroyWindow();
243 }
244
245 void CMainFrame::GetMessageString( UINT nID, CString& rMessage ) const
246 {
247 // load appropriate string
248 LPTSTR lpsz = rMessage.GetBuffer( 255 );
249 if ( nID >= ID_MCDATAFILE_OPEN_CMD01 &&
250 nID <= ID_MCDATAFILE_OPEN_CMD01 + ( unsigned ) CMCDataManager::GetMaxFileTypes() )
251 {
252 /* ignore */
253 }
254 else if ( AfxLoadString( nID, lpsz ) != 0 )
255 {
256 // first newline terminates actual string
257 lpsz = _tcschr( lpsz, '\n' );
258 if ( lpsz != NULL )
259 * lpsz = '\0';
260 }
261 else
262 {
263 // not found
264 TRACE( traceAppMsg, 0, "Warning: no message line prompt for ID 0x%04X.\n", nID );
265 }
266 rMessage.ReleaseBuffer();
267 }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26