1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
10 // Intel License Agreement
11 // For Open Source Computer Vision Library
13 // Copyright (C) 2000, Intel Corporation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
26 // * The name of Intel Corporation may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
40 //M*/// MainFrm.cpp : implementation of the CMainFrame class
51 static char THIS_FILE[] = __FILE__;
54 /////////////////////////////////////////////////////////////////////////////
57 IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
59 BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
60 //{{AFX_MSG_MAP(CMainFrame)
62 ON_UPDATE_COMMAND_UI(ID_CAPTURE, OnUpdateCapture)
63 ON_COMMAND(ID_CAPTURE, OnCapture)
64 ON_COMMAND(ID_TRACK, OnTrack)
65 ON_UPDATE_COMMAND_UI(ID_TRACK, OnUpdateTrack)
66 ON_COMMAND(ID_NIGHTMODE, OnNightmode)
67 ON_UPDATE_COMMAND_UI(ID_NIGHTMODE, OnUpdateNightmode)
68 ON_COMMAND(ID_CAPOPTIONS, OnCapOptions)
69 ON_COMMAND(ID_CAPFORMAT, OnVideoFormat)
73 static UINT indicators[] =
75 ID_SEPARATOR, // status line indicator
81 /////////////////////////////////////////////////////////////////////////////
82 // CMainFrame construction/destruction
84 CMainFrame::CMainFrame()
89 CMainFrame::~CMainFrame()
93 int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
95 if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
98 if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
99 | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
100 !m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
102 TRACE0("Failed to create toolbar\n");
103 return -1; // fail to create
106 if (!m_wndStatusBar.Create(this) ||
107 !m_wndStatusBar.SetIndicators(indicators,
108 sizeof(indicators)/sizeof(UINT)))
110 TRACE0("Failed to create status bar\n");
111 return -1; // fail to create
114 // TODO: Delete these three lines if you don't want the toolbar to
116 m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
117 EnableDocking(CBRS_ALIGN_ANY);
118 DockControlBar(&m_wndToolBar);
123 BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
125 if( !CFrameWnd::PreCreateWindow(cs) )
130 CLkDemoView* CMainFrame::GetCameraView()
132 return (CLkDemoView*)GetActiveView();
136 /////////////////////////////////////////////////////////////////////////////
137 // CMainFrame message handlers
139 void CMainFrame::OnUpdateCapture(CCmdUI* pCmdUI)
141 CLkDemoView* view = GetCameraView();
147 enable = view->Camera().IsInitialized();
148 press = view->Camera().IsRunning();
151 pCmdUI->Enable( enable );
152 pCmdUI->SetCheck( press );
155 void CMainFrame::OnCapture()
157 CLkDemoView* view = GetCameraView();
159 if( view && view->Camera().IsInitialized())
161 if( view->Camera().IsRunning())
163 view->Camera().Stop();
167 view->Camera().Start();
172 void CMainFrame::OnTrack()
174 CLkDemoView* view = GetCameraView();
176 if( view && view->Camera().IsInitialized())
178 if( view->IsTracked())
180 view->StopTracking();
184 view->StartTracking();
189 void CMainFrame::OnUpdateTrack(CCmdUI* pCmdUI)
193 CLkDemoView* view = GetCameraView();
195 if( view && view->Camera().IsInitialized())
198 press = view->IsTracked();
201 pCmdUI->Enable( enable );
202 pCmdUI->SetCheck( press );
205 void CMainFrame::OnNightmode()
207 CLkDemoView* view = GetCameraView();
211 view->SetNightMode( !view->IsNightMode() );
215 void CMainFrame::OnUpdateNightmode(CCmdUI* pCmdUI)
219 CLkDemoView* view = GetCameraView();
223 enable = view->IsTracked();
224 press = enable && view->IsNightMode();
227 pCmdUI->Enable( enable );
228 pCmdUI->SetCheck( press );
232 void CMainFrame::OnCapOptions()
234 CLkDemoView* view = GetCameraView();
238 view->Camera().VideoSourceDlg();
239 view->InvalidateRect(0);
244 void CMainFrame::OnVideoFormat()
246 CLkDemoView* view = GetCameraView();
250 view->Camera().VideoFormatDlg();
251 view->InvalidateRect(0);