Develop and Download Open Source Software

Browse CVS Repository

Contents of /satellite/neuromanager/MainFrm.cpp

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


Revision 1.15 - (show annotations) (download) (as text)
Sat Feb 4 13:38:16 2006 UTC (18 years, 2 months ago) by orrisroot
Branch: MAIN
CVS Tags: HEAD
Changes since 1.14: +1 -1 lines
File MIME type: text/x-c++src
FILE REMOVED
moved main application sources to neuromanager directory.

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.14 2006/02/02 07:33:27 orrisroot Exp $ */
23
24 // MainFrm.cpp : implementation of the CMainFrame class
25 //
26
27 #include "stdafx.h"
28 #include "NeuroManager.h"
29 #include "DataViewSplitter.h"
30 #include "DataViewBar.h"
31 #include "SpikeViewSplitter.h"
32 #include "SpikeViewBar.h"
33
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 END_MESSAGE_MAP()
53
54 static UINT indicators[] =
55 {
56 // status line indicator
57 ID_SEPARATOR,
58 ID_INDICATOR_CAPS,
59 ID_INDICATOR_NUM,
60 ID_INDICATOR_SCRL,
61 };
62
63
64 // CMainFrame construction/destruction
65
66 CMainFrame::CMainFrame()
67 {
68 // TODO: add member initialization code here
69 }
70
71 CMainFrame::~CMainFrame()
72 {}
73
74
75 int CMainFrame::OnCreate( LPCREATESTRUCT lpCreateStruct )
76 {
77 if ( CFrameWnd::OnCreate( lpCreateStruct ) == -1 )
78 return -1;
79
80 if ( !m_wndToolBar.CreateEx( this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
81 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC ) ||
82 !m_wndToolBar.LoadToolBar( IDR_MAINFRAME ) )
83 {
84 TRACE0( "Failed to create toolbar\n" );
85 return -1; // fail to create
86 }
87
88 if ( !m_wndStatusBar.Create( this ) ||
89 !m_wndStatusBar.SetIndicators( indicators,
90 sizeof( indicators ) / sizeof( UINT ) ) )
91 {
92 TRACE0( "Failed to create status bar\n" );
93 return -1; // fail to create
94 }
95
96 // data view bar
97 CString strDataView;
98 strDataView.LoadString( IDS_DATAVIEW );
99 if ( !m_wndDataViewBar.Create( strDataView, this,
100 CSize( DEFAULT_DATAVIEW_WIDTH, DEFAULT_DATAVIEW_HEIGHT ), TRUE, IDS_DATAVIEW ) )
101 {
102 TRACE0( "Failed to create data view bar\n" );
103 return -1; // fail to create
104 }
105 CCreateContext* pContext = ( CCreateContext* ) lpCreateStruct->lpCreateParams;
106 BOOL ret = m_wndDataViewBar.CreateInnerViews( pContext );
107 if ( ret == FALSE )
108 return -1;
109
110 m_wndDataViewBar.SetBarStyle( m_wndDataViewBar.GetBarStyle() |
111 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );
112
113 // spike view bar
114 CString strSpikeView;
115 strSpikeView.LoadString( IDS_SPIKEVIEW );
116 if ( !m_wndSpikeViewBar.Create( strSpikeView, this,
117 CSize( DEFAULT_DATAVIEW_WIDTH, DEFAULT_DATAVIEW_HEIGHT ), TRUE, IDS_SPIKEVIEW ) )
118 {
119 TRACE0( "Failed to create spike view bar\n" );
120 return -1; // fail to create
121 }
122 pContext = ( CCreateContext* ) lpCreateStruct->lpCreateParams;
123 ret = m_wndSpikeViewBar.CreateInnerViews( pContext );
124 if ( ret == FALSE )
125 return -1;
126
127 m_wndSpikeViewBar.SetBarStyle( m_wndSpikeViewBar.GetBarStyle() |
128 CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC );
129
130 // setting for dockable bars
131 m_wndToolBar.EnableDocking( CBRS_ALIGN_ANY );
132 m_wndDataViewBar.EnableDocking( CBRS_ALIGN_TOP );
133 m_wndSpikeViewBar.EnableDocking( CBRS_ALIGN_ANY );
134 EnableDocking( CBRS_ALIGN_ANY );
135 DockControlBar( &m_wndToolBar );
136 DockControlBar( &m_wndDataViewBar );
137 DockControlBar( &m_wndSpikeViewBar );
138
139 // load scrollbar setting
140 SaveLoadToolBar( FALSE );
141
142 return 0;
143 }
144
145 BOOL CMainFrame::PreCreateWindow( CREATESTRUCT& cs )
146 {
147 if ( !CFrameWnd::PreCreateWindow( cs ) )
148 return FALSE;
149 // TODO: Modify the Window class or styles here by modifying
150 // the CREATESTRUCT cs
151 cs.style |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS;
152 return TRUE;
153 }
154
155
156 // CMainFrame diagnostics
157
158 #ifdef _DEBUG
159 void CMainFrame::AssertValid() const
160 {
161 CFrameWnd::AssertValid();
162 }
163
164 void CMainFrame::Dump( CDumpContext& dc ) const
165 {
166 CFrameWnd::Dump( dc );
167 }
168 #endif //_DEBUG
169
170
171 // CMainFrame message handlers
172
173 void CMainFrame::OnViewDataViewBar()
174 {
175 BOOL bShow = m_wndDataViewBar.IsVisible();
176 ShowControlBar( &m_wndDataViewBar, !bShow, FALSE );
177 }
178
179 void CMainFrame::OnViewSpikeViewBar()
180 {
181 BOOL bShow = m_wndSpikeViewBar.IsVisible();
182 ShowControlBar( &m_wndSpikeViewBar, !bShow, FALSE );
183 }
184
185 void CMainFrame::OnUpdateViewDataViewBar( CCmdUI *pCmdUI )
186 {
187 pCmdUI->Enable();
188 pCmdUI->SetCheck( m_wndDataViewBar.IsVisible() );
189 }
190
191 void CMainFrame::OnUpdateViewSpikeViewBar( CCmdUI *pCmdUI )
192 {
193 pCmdUI->Enable();
194 pCmdUI->SetCheck( m_wndSpikeViewBar.IsVisible() );
195 }
196
197 void CMainFrame::SaveLoadToolBar( BOOL bSave )
198 {
199 // when bSave = TRUE save toolbar setting, FALSE for load settings
200 CString strDataViewToolBarReg = _T( "DataViewBar" );
201 CString strSpikeViewToolBarReg = _T( "SpikeViewBar" );
202 CString strBarStateReg = _T( "BarState" );
203 if ( bSave )
204 {
205 SaveBarState( strBarStateReg );
206 m_wndDataViewBar.SaveState( strDataViewToolBarReg );
207 m_wndSpikeViewBar.SaveState( strSpikeViewToolBarReg );
208 }
209 else
210 {
211 m_wndSpikeViewBar.LoadState( strSpikeViewToolBarReg );
212 m_wndDataViewBar.LoadState( strDataViewToolBarReg );
213 LoadBarState( strBarStateReg );
214 }
215 }
216
217 BOOL CMainFrame::DestroyWindow()
218 {
219 // TODO: Add your specialized code here and/or call the base class
220 SaveLoadToolBar( TRUE );
221
222 return CFrameWnd::DestroyWindow();
223 }

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