forked from jehy/UniShot
/
MeteringMode.cpp
100 lines (80 loc) · 3.37 KB
/
MeteringMode.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/******************************************************************************
* *
* PROJECT : EOS Digital Software Development Kit EDSDK *
* NAME : MeteringMode.cpp *
* *
* Description: This is the Sample code to show the usage of EDSDK. *
* *
* *
*******************************************************************************
* *
* Written and developed by Camera Design Dept.53 *
* Copyright Canon Inc. 2006-2008 All Rights Reserved *
* *
*******************************************************************************/
#include "stdafx.h"
#include "CameraControl.h"
#include "MeteringMode.h"
#define WM_USER_PROPERTY_CHANGED WM_APP+1
#define WM_USER_PROPERTYDESC_CHANGED WM_APP+2
// CMeteringMode
IMPLEMENT_DYNAMIC(CMeteringMode, CPropertyComboBox)
CMeteringMode::CMeteringMode()
{
// set up action command
setActionCommand("set_MeteringMode");
// Map of value and display name
_propertyTable.insert( std::pair<EdsUInt32, const char *>(1,"Spot"));
_propertyTable.insert( std::pair<EdsUInt32, const char *>(3,"Evaluative"));
_propertyTable.insert( std::pair<EdsUInt32, const char *>(4,"Partial"));
_propertyTable.insert( std::pair<EdsUInt32, const char *>(5,"Center-Weighted Average"));
_propertyTable.insert( std::pair<EdsUInt32, const char *>(0xffffffff,"unknown"));
}
CMeteringMode::~CMeteringMode()
{
}
BEGIN_MESSAGE_MAP(CMeteringMode, CPropertyComboBox)
ON_MESSAGE(WM_USER_PROPERTY_CHANGED, OnPropertyChanged)
ON_MESSAGE(WM_USER_PROPERTYDESC_CHANGED, OnPropertyDescChanged)
ON_CONTROL_REFLECT(CBN_SELCHANGE, OnSelChange)
END_MESSAGE_MAP()
// CMeteringMode message handler
void CMeteringMode::OnSelChange()
{
DWORD_PTR data = GetItemData(GetCurSel());
fireEvent(&data);
}
void CMeteringMode::update(Observable* from, CameraEvent *e)
{
std::string event = e->getEvent();
//Update property
if(event == "PropertyChanged")
{
EdsInt32 propertyID = *static_cast<EdsInt32 *>(e->getArg());
if(propertyID == kEdsPropID_MeteringMode)
{
//The update processing can be executed from another thread.
::PostMessage(this->m_hWnd, WM_USER_PROPERTY_CHANGED, NULL, NULL);
}
}
//Update of list that can set property
if(event == "PropertyDescChanged")
{
EdsInt32 propertyID = *static_cast<EdsInt32 *>(e->getArg());
if(propertyID == kEdsPropID_MeteringMode)
{
//The update processing can be executed from another thread.
::PostMessage(this->m_hWnd, WM_USER_PROPERTYDESC_CHANGED, NULL, NULL);
}
}
}
LRESULT CMeteringMode::OnPropertyChanged(WPARAM wParam, LPARAM lParam)
{
updateProperty(getCameraModel()->getMeteringMode());
return 0;
}
LRESULT CMeteringMode::OnPropertyDescChanged(WPARAM wParam, LPARAM lParam)
{
updatePropertyDesc(&getCameraModel()->getMeteringModeDesc());
return 0;
}