-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddPicture.cpp
112 lines (97 loc) · 3.38 KB
/
AddPicture.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
// Copyright (C) 2012-Present Andrew S. Bantly
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
// This program 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.
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
#include "stdafx.h"
#include "Fractal.h"
#include "AddPicture.h"
// CAddPicture dialog
IMPLEMENT_DYNAMIC(CAddPicture, CDialog)
CAddPicture::CAddPicture(CWnd* pParent /*=NULL*/)
: CDialog(CAddPicture::IDD, pParent)
{
m_iOpacity = 50;
m_bTransparentColor = FALSE;
m_crTransparentColor = RGB(0,128,0);
}
CAddPicture::CAddPicture(CDecorativePicture & DecorativePicture,CWnd * pParent /*=NULL*/)
: CDialog(CAddPicture::IDD, pParent)
{
m_DecorativePicture = DecorativePicture;
m_csPictureName = m_DecorativePicture.GetPictureName();
m_iOpacity = m_DecorativePicture.GetOpacity();
m_bTransparentColor = m_DecorativePicture.GetTransparentColorFlag();
m_crTransparentColor = m_DecorativePicture.GetTransparentColor();
}
CAddPicture::~CAddPicture()
{
}
void CAddPicture::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT_PICTURENAME, m_csPictureName);
DDX_Control(pDX, IDC_STATIC_OPACITY, m_Static_Opacity);
DDX_Control(pDX, IDC_EDIT_OPACITY, m_Opacity);
DDX_Text(pDX, IDC_EDIT_OPACITY, m_iOpacity);
DDV_MinMaxUInt(pDX, m_iOpacity, 0, 100);
DDX_Check(pDX, IDC_CHECK_TRANSPARENT_COLOR,m_bTransparentColor);
if (pDX->m_bSaveAndValidate)
{
m_DecorativePicture.SetPictureName(m_csPictureName);
m_DecorativePicture.SetOpacity(m_iOpacity);
m_DecorativePicture.SetTransparentColorFlag(m_bTransparentColor);
m_DecorativePicture.SetTransparentColor(m_crTransparentColor);
}
}
BOOL CAddPicture::OnInitDialog()
{
BOOL bRet = CDialog::OnInitDialog();
m_Picture.CreateBtmp(this,IDB_PICTURE,IDC_CHOOSE_PICTURE,_T("Choose Picture"));
m_TransparentColor.CreateRect(this,IDC_TRANSPARENT_COLOR,m_crTransparentColor);
m_TransparentColor.EnableWindow(m_bTransparentColor);
return bRet;
}
CDecorativePicture CAddPicture::GetDecorativePicture()
{
return m_DecorativePicture;
}
BEGIN_MESSAGE_MAP(CAddPicture, CDialog)
ON_BN_CLICKED(IDC_CHOOSE_PICTURE, &CAddPicture::OnChoosePicture)
ON_BN_CLICKED(IDC_CHECK_TRANSPARENT_COLOR, &CAddPicture::OnTransparentColor)
ON_BN_CLICKED(IDC_TRANSPARENT_COLOR, &CAddPicture::OnChangeTransparentColor)
END_MESSAGE_MAP()
// CAddPicture message handlers
void CAddPicture::OnChoosePicture()
{
// Choose the image
CString csPictureName;
if (theApp.ChooseImage(_T("Add a Picture"),csPictureName))
{
CImage Image;
if (SUCCEEDED(Image.Load(csPictureName)))
{
m_crTransparentColor = Image.GetPixel(0,0);
m_TransparentColor.SetFillColor(m_crTransparentColor);
m_csPictureName = csPictureName;
UpdateData(FALSE);
}
}
}
void CAddPicture::OnTransparentColor()
{
UpdateData();
m_TransparentColor.EnableWindow(m_bTransparentColor);
}
void CAddPicture::OnChangeTransparentColor()
{
theApp.ChangeColor(m_crTransparentColor,m_TransparentColor);
}