2 * Copyright (C) 2003-2006 Gabest
3 * http://www.gabest.org
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with GNU Make; see the file COPYING. If not, write to
17 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
18 * http://www.gnu.org/copyleft/gpl.html
22 // CPPageLogo.cpp : implementation file
28 #include "PPageLogo.h"
32 IMPLEMENT_DYNAMIC(CPPageLogo
, CPPageBase
)
33 CPPageLogo::CPPageLogo()
34 : CPPageBase(CPPageLogo::IDD
, CPPageLogo::IDD
)
39 m_logoids
.AddTail(IDF_LOGO0
);
40 m_logoids
.AddTail(IDF_LOGO1
);
41 m_logoids
.AddTail(IDF_LOGO2
);
42 m_logoids
.AddTail(IDF_LOGO3
);
43 m_logoids
.AddTail(IDF_LOGO4
);
44 m_logoids
.AddTail(IDF_LOGO5
);
45 m_logoids
.AddTail(IDF_LOGO6
);
46 m_logoids
.AddTail(IDF_LOGO7
);
49 CPPageLogo::~CPPageLogo()
53 void CPPageLogo::DoDataExchange(CDataExchange
* pDX
)
55 __super::DoDataExchange(pDX
);
56 DDX_Radio(pDX
, IDC_RADIO1
, m_intext
);
57 DDX_Text(pDX
, IDC_LOGOFILENAME
, m_logofn
);
58 DDX_Control(pDX
, IDC_LOGOPREVIEW
, m_logopreview
);
59 DDX_Text(pDX
, IDC_AUTHOR
, m_author
);
63 BEGIN_MESSAGE_MAP(CPPageLogo
, CPPageBase
)
64 ON_BN_CLICKED(IDC_RADIO1
, OnBnClickedRadio1
)
65 ON_BN_CLICKED(IDC_RADIO2
, OnBnClickedRadio2
)
66 ON_NOTIFY(UDN_DELTAPOS
, IDC_SPIN1
, OnDeltaposSpin1
)
67 ON_BN_CLICKED(IDC_BUTTON2
, OnBnClickedButton2
)
71 // CPPageLogo message handlers
73 BOOL
CPPageLogo::OnInitDialog()
75 __super::OnInitDialog();
77 AppSettings
& s
= AfxGetAppSettings();
79 m_intext
= s
.logoext
?1:0;
85 for(POSITION pos
= m_logoids
.GetHeadPosition(); pos
; m_logoids
.GetNext(pos
))
87 if(m_logoids
.GetAt(pos
) == s
.logoid
)
94 if(!m_intext
) OnBnClickedRadio1();
95 else OnBnClickedRadio2();
97 return TRUE
; // return TRUE unless you set the focus to a control
98 // EXCEPTION: OCX Property Pages should return FALSE
101 BOOL
CPPageLogo::OnApply()
105 AppSettings
& s
= AfxGetAppSettings();
107 s
.logoext
= !!m_intext
;
109 s
.logoid
= m_logoids
.GetAt(m_logoidpos
);
111 ((CMainFrame
*)AfxGetMainWnd())->m_wndView
.LoadLogo();
113 return __super::OnApply();
117 void CPPageLogo::OnBnClickedRadio1()
124 UINT id
= m_logoids
.GetAt(m_logoidpos
);
127 m_logobm
.LoadFromResource(id
);
128 // m_logobm.LoadFromResource(::AfxGetInstanceHandle(), id);
129 if(!m_author
.LoadString(id
)) m_author
= _T("Author unknown. Contact me if you made this logo!");
131 m_logopreview
.SetBitmap(m_logobm
);
140 void CPPageLogo::OnBnClickedRadio2()
147 if(AfxGetAppSettings().fXpOrBetter
)
148 m_logobm
.Load(m_logofn
);
149 else if(HANDLE h
= LoadImage(NULL
, m_logofn
, IMAGE_BITMAP
, 0, 0, LR_LOADFROMFILE
))
150 m_logobm
.Attach((HBITMAP
)h
);
151 m_logopreview
.SetBitmap(m_logobm
);
160 void CPPageLogo::OnDeltaposSpin1(NMHDR
*pNMHDR
, LRESULT
*pResult
)
162 LPNMUPDOWN pNMUpDown
= reinterpret_cast<LPNMUPDOWN
>(pNMHDR
);
164 if(pNMUpDown
->iDelta
< 0)
166 m_logoids
.GetNext(m_logoidpos
);
167 if(!m_logoidpos
) m_logoidpos
= m_logoids
.GetHeadPosition();
171 m_logoids
.GetPrev(m_logoidpos
);
172 if(!m_logoidpos
) m_logoidpos
= m_logoids
.GetTailPosition();
180 void CPPageLogo::OnBnClickedButton2()
182 CFileDialog
dlg(TRUE
, NULL
, m_logofn
,
183 OFN_EXPLORER
|OFN_ENABLESIZING
|OFN_HIDEREADONLY
,
184 AfxGetAppSettings().fXpOrBetter
185 ? _T("Images (*.bmp;*.jpg;*.gif;*.png)|*.bmp;*.jpg;*.gif;*.png|All files (*.*)|*.*||")
186 : _T("Images (*.bmp)|*.bmp|All files (*.*)|*.*||")
189 if(dlg
.DoModal() == IDOK
)
191 m_logofn
= dlg
.GetPathName();