-
Notifications
You must be signed in to change notification settings - Fork 4
/
ScaleSizes.cpp
178 lines (147 loc) · 5.29 KB
/
ScaleSizes.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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2005-2011 Association Homecinema Francophone. All rights reserved.
/////////////////////////////////////////////////////////////////////////////
//
// This file is subject to the terms of the GNU General Public License as
// published by the Free Software Foundation. A copy of this license is
// included with this software distribution in the file COPYING.htm. If you
// do not have a copy, you may obtain a copy by writing to the Free
// Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details
/////////////////////////////////////////////////////////////////////////////
// Author(s):
// Georges GALLERAND
/////////////////////////////////////////////////////////////////////////////
// ScaleSizes.cpp : implementation file
//
#include "stdafx.h"
#include "colorhcfr.h"
#include "DataSetDoc.h"
#include "ScaleSizes.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CScaleSizes dialog
CScaleSizes::CScaleSizes(CDataSetDoc * pDoc, CWnd* pParent /*=NULL*/)
: CDialog(CScaleSizes::IDD, pParent)
{
//{{AFX_DATA_INIT(CScaleSizes)
m_NbNearBlack = 0;
m_NbNearWhite = 0;
m_NbSat = 0;
m_bIRE = FALSE;
//}}AFX_DATA_INIT
m_pDoc = pDoc;
m_NbGrays = m_pDoc -> GetMeasure () -> GetGrayScaleSize () - 1;
m_NbNearBlack = m_pDoc -> GetMeasure () -> GetNearBlackScaleSize () - 1;
m_NbNearWhite = m_pDoc -> GetMeasure () -> GetNearWhiteScaleSize () - 1;
m_NbSat = m_pDoc -> GetMeasure () -> GetSaturationSize () - 1;
m_bIRE = m_pDoc -> GetMeasure () -> m_bIREScaleMode;
if ( m_bIRE && m_NbGrays > 10 )
m_NbGrays ++;
}
void CScaleSizes::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CScaleSizes)
DDX_Control(pDX, IDC_COMBO_EDIT_GRAYS, m_ComboEditGrays);
DDX_Control(pDX, IDC_COMBO_GRAYS, m_ComboGrays);
DDX_Text(pDX, IDC_EDIT_NEARBLACK, m_NbNearBlack);
DDV_MinMaxInt(pDX, m_NbNearBlack, 2, 50);
DDX_Text(pDX, IDC_EDIT_NEARWHITE, m_NbNearWhite);
DDV_MinMaxInt(pDX, m_NbNearWhite, 2, 50);
DDX_Text(pDX, IDC_EDIT_SAT, m_NbSat);
DDV_MinMaxInt(pDX, m_NbSat, 2, 50);
DDX_Check(pDX, IDC_CHECK_IRE, m_bIRE);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CScaleSizes, CDialog)
//{{AFX_MSG_MAP(CScaleSizes)
ON_BN_CLICKED(IDC_CHECK_IRE, OnCheckIre)
ON_BN_CLICKED(IDHELP, OnHelp)
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CScaleSizes message handlers
BOOL CScaleSizes::OnInitDialog()
{
CString str;
CDialog::OnInitDialog();
str.Format ( "%d", m_NbGrays );
if ( m_bIRE )
{
m_ComboGrays.ShowWindow ( SW_SHOW );
m_ComboEditGrays.ShowWindow ( SW_HIDE );
m_ComboGrays.SetCurSel ( m_ComboGrays.FindStringExact(-1,(LPCSTR) str) );
m_ComboEditGrays.SetCurSel ( 1 );
}
else
{
m_ComboGrays.ShowWindow ( SW_HIDE );
m_ComboEditGrays.ShowWindow ( SW_SHOW );
m_ComboEditGrays.SetWindowText ( str );
m_ComboGrays.SetCurSel ( 1 );
}
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CScaleSizes::OnOK()
{
CString str;
CDialog::OnOK();
if ( m_bIRE )
m_ComboGrays.GetLBText ( m_ComboGrays.GetCurSel (), str );
else
m_ComboEditGrays.GetWindowText ( str );
m_NbGrays = atoi ( (LPCSTR) str );
if ( m_NbGrays >= 4 && m_NbGrays <= 100 && m_NbNearBlack >= 2 && m_NbNearBlack <= 50 && m_NbNearWhite >= 2 && m_NbNearWhite <= 50 && m_NbSat >= 2 && m_NbSat <= 50 )
{
m_pDoc -> GetMeasure () -> SetIREScaleMode ( m_bIRE );
m_pDoc -> GetMeasure () -> SetGrayScaleSize ( ( m_bIRE && m_NbGrays > 10 ) ? m_NbGrays : m_NbGrays + 1 );
m_pDoc -> GetMeasure () -> SetNearBlackScaleSize ( m_NbNearBlack + 1 );
m_pDoc -> GetMeasure () -> SetNearWhiteScaleSize ( m_NbNearWhite + 1 );
m_pDoc -> GetMeasure () -> SetSaturationSize ( m_NbSat + 1 );
GetConfig()->WriteProfileInt("References","IRELevels",m_bIRE);
GetConfig()->WriteProfileInt("Scale Sizes","Gray",m_NbGrays);
GetConfig()->WriteProfileInt("Scale Sizes","Near Black",m_NbNearBlack);
GetConfig()->WriteProfileInt("Scale Sizes","Near White",m_NbNearWhite);
GetConfig()->WriteProfileInt("Scale Sizes","Saturations",m_NbSat);
m_pDoc -> UpdateAllViews ( NULL );
}
}
void CScaleSizes::OnCancel()
{
CDialog::OnCancel();
}
void CScaleSizes::OnHelp()
{
GetConfig () -> DisplayHelp ( HID_SCALESIZES, NULL );
}
BOOL CScaleSizes::OnHelpInfo(HELPINFO* pHelpInfo)
{
OnHelp ();
return TRUE;
}
void CScaleSizes::OnCheckIre()
{
// TODO: Add your control notification handler code here
UpdateData ();
if ( m_bIRE )
{
m_ComboGrays.ShowWindow ( SW_SHOW );
m_ComboEditGrays.ShowWindow ( SW_HIDE );
}
else
{
m_ComboGrays.ShowWindow ( SW_HIDE );
m_ComboEditGrays.ShowWindow ( SW_SHOW );
}
}