A Fast Bresenham Type Algorithm For Drawing Ellipses by John Kennedy
[xy_vsfilter.git] / src / apps / mplayerc / RegFilterChooserDlg.cpp
blobc9372c87f174d6b14599bb4d19108718a0db4339
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 // RegFilterChooserDlg.cpp : implementation file
25 #include "stdafx.h"
26 #include "mplayerc.h"
27 #include <dmo.h>
28 #include "RegFilterChooserDlg.h"
29 #include "FGFilter.h"
30 #include "..\..\DSUtil\DSUtil.h"
33 // CRegFilterChooserDlg dialog
35 //IMPLEMENT_DYNAMIC(CRegFilterChooserDlg, CResizableDialog)
36 CRegFilterChooserDlg::CRegFilterChooserDlg(CWnd* pParent /*=NULL*/)
37 : CResizableDialog(CRegFilterChooserDlg::IDD, pParent)
41 CRegFilterChooserDlg::~CRegFilterChooserDlg()
43 POSITION pos = m_filters.GetHeadPosition();
44 while(pos) delete m_filters.GetNext(pos);
47 void CRegFilterChooserDlg::DoDataExchange(CDataExchange* pDX)
49 __super::DoDataExchange(pDX);
50 DDX_Control(pDX, IDC_LIST2, m_list);
53 void CRegFilterChooserDlg::AddToList(IMoniker* pMoniker)
55 CComPtr<IPropertyBag> pPB;
56 if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
58 CComVariant var;
59 if(SUCCEEDED(pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL)))
61 m_list.SetItemData(
62 m_list.InsertItem(-1, CString(CStringW(var.bstrVal))),
63 (DWORD_PTR)m_monikers.AddTail(pMoniker));
70 BEGIN_MESSAGE_MAP(CRegFilterChooserDlg, CResizableDialog)
71 ON_LBN_DBLCLK(IDC_LIST1, OnLbnDblclkList1)
72 ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOK)
73 ON_BN_CLICKED(IDOK, OnBnClickedOk)
74 ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
75 ON_NOTIFY(NM_DBLCLK, IDC_LIST2, OnNMDblclkList2)
76 END_MESSAGE_MAP()
79 // CRegFilterChooserDlg message handlers
81 BOOL CRegFilterChooserDlg::OnInitDialog()
83 __super::OnInitDialog();
85 BeginEnumSysDev(CLSID_LegacyAmFilterCategory, pMoniker)
87 AddToList(pMoniker);
89 EndEnumSysDev
91 BeginEnumSysDev(DMOCATEGORY_VIDEO_EFFECT, pMoniker)
93 AddToList(pMoniker);
95 EndEnumSysDev
97 BeginEnumSysDev(DMOCATEGORY_AUDIO_EFFECT, pMoniker)
99 AddToList(pMoniker);
101 EndEnumSysDev
103 AddAnchor(IDC_LIST2, TOP_LEFT, BOTTOM_RIGHT);
104 AddAnchor(IDC_BUTTON1, BOTTOM_LEFT);
105 AddAnchor(IDOK, BOTTOM_RIGHT);
106 AddAnchor(IDCANCEL, BOTTOM_RIGHT);
108 SetMinTrackSize(CSize(300,100));
110 return TRUE; // return TRUE unless you set the focus to a control
111 // EXCEPTION: OCX Property Pages should return FALSE
114 void CRegFilterChooserDlg::OnLbnDblclkList1()
116 SendMessage(WM_COMMAND, IDOK);
119 void CRegFilterChooserDlg::OnUpdateOK(CCmdUI* pCmdUI)
121 pCmdUI->Enable(!!m_list.GetFirstSelectedItemPosition());
124 void CRegFilterChooserDlg::OnBnClickedOk()
126 CComPtr<IMoniker> pMoniker;
128 POSITION pos = m_list.GetFirstSelectedItemPosition();
129 if(pos) pos = (POSITION)m_list.GetItemData(m_list.GetNextSelectedItem(pos));
130 if(pos) pMoniker = m_monikers.GetAt(pos);
131 if(pMoniker)
133 CFGFilterRegistry fgf(pMoniker);
134 FilterOverride* f = new FilterOverride;
135 f->fDisabled = false;
136 f->type = FilterOverride::REGISTERED;
137 f->name = fgf.GetName();
138 f->dispname = fgf.GetDisplayName();
139 f->guids.AddTailList(&fgf.GetTypes());
140 f->backup.AddTailList(&fgf.GetTypes());
141 f->dwMerit = fgf.GetMeritForDirectShow();
142 f->iLoadType = FilterOverride::MERIT;
143 m_filters.AddTail(f);
146 __super::OnOK();
149 void CRegFilterChooserDlg::OnBnClickedButton1()
151 CFileDialog dlg(TRUE, NULL, NULL,
152 OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY,
153 _T("DirectShow Filters (*.dll,*.ax)|*.dll;*.ax|"), this, 0);
155 if(dlg.DoModal() == IDOK)
157 CFilterMapper2 fm2(false);
158 fm2.Register(dlg.GetPathName());
159 m_filters.AddTail(&fm2.m_filters);
160 fm2.m_filters.RemoveAll();
162 __super::OnOK();
166 void CRegFilterChooserDlg::OnNMDblclkList2(NMHDR *pNMHDR, LRESULT *pResult)
168 if(m_list.GetFirstSelectedItemPosition())
170 OnBnClickedOk();
173 *pResult = 0;