A Fast Bresenham Type Algorithm For Drawing Ellipses by John Kennedy
[xy_vsfilter.git] / src / apps / mplayerc / PPageLogo.cpp
blobbde90c206a4df3e5a59ee4d680369849fbadf741
1 /*
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)
8 * any later version.
9 *
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
25 #include "stdafx.h"
26 #include "mplayerc.h"
27 #include "MainFrm.h"
28 #include "PPageLogo.h"
30 // CPPageLogo dialog
32 IMPLEMENT_DYNAMIC(CPPageLogo, CPPageBase)
33 CPPageLogo::CPPageLogo()
34 : CPPageBase(CPPageLogo::IDD, CPPageLogo::IDD)
35 , m_intext(0)
36 , m_logofn(_T(""))
37 , m_author(_T(""))
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)
68 END_MESSAGE_MAP()
71 // CPPageLogo message handlers
73 BOOL CPPageLogo::OnInitDialog()
75 __super::OnInitDialog();
77 AppSettings& s = AfxGetAppSettings();
79 m_intext = s.logoext?1:0;
80 m_logofn = s.logofn;
81 m_logoidpos = NULL;
83 UpdateData(FALSE);
85 for(POSITION pos = m_logoids.GetHeadPosition(); pos; m_logoids.GetNext(pos))
87 if(m_logoids.GetAt(pos) == s.logoid)
89 m_logoidpos = pos;
90 break;
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()
103 UpdateData();
105 AppSettings& s = AfxGetAppSettings();
107 s.logoext = !!m_intext;
108 s.logofn = m_logofn;
109 s.logoid = m_logoids.GetAt(m_logoidpos);
111 ((CMainFrame*)AfxGetMainWnd())->m_wndView.LoadLogo();
113 return __super::OnApply();
117 void CPPageLogo::OnBnClickedRadio1()
119 ASSERT(m_logoidpos);
121 m_author.Empty();
123 m_logobm.Destroy();
124 UINT id = m_logoids.GetAt(m_logoidpos);
125 if(IDF_LOGO0 != id)
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);
132 Invalidate();
134 m_intext = 0;
135 UpdateData(FALSE);
137 SetModified();
140 void CPPageLogo::OnBnClickedRadio2()
142 UpdateData();
144 m_author.Empty();
146 m_logobm.Destroy();
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);
152 Invalidate();
154 m_intext = 1;
155 UpdateData(FALSE);
157 SetModified();
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();
169 else
171 m_logoids.GetPrev(m_logoidpos);
172 if(!m_logoidpos) m_logoidpos = m_logoids.GetTailPosition();
175 OnBnClickedRadio1();
177 *pResult = 0;
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 (*.*)|*.*||")
187 , this, 0);
189 if(dlg.DoModal() == IDOK)
191 m_logofn = dlg.GetPathName();
192 UpdateData(FALSE);
193 OnBnClickedRadio2();