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 // PPageExternalFilters.cpp : implementation file
27 #include "PPageExternalFilters.h"
28 #include "ComPropertySheet.h"
29 #include "RegFilterChooserDlg.h"
30 #include "SelectMediaType.h"
32 #include "..\..\..\include\moreuuids.h"
37 // CPPageExternalFilters dialog
39 IMPLEMENT_DYNAMIC(CPPageExternalFilters
, CPPageBase
)
40 CPPageExternalFilters::CPPageExternalFilters()
41 : CPPageBase(CPPageExternalFilters::IDD
, CPPageExternalFilters::IDD
)
42 , m_iLoadType(FilterOverride::PREFERRED
)
43 , m_pLastSelFilter(NULL
)
47 CPPageExternalFilters::~CPPageExternalFilters()
51 void CPPageExternalFilters::DoDataExchange(CDataExchange
* pDX
)
53 __super::DoDataExchange(pDX
);
54 DDX_Control(pDX
, IDC_LIST1
, m_filters
);
55 DDX_Radio(pDX
, IDC_RADIO1
, m_iLoadType
);
56 DDX_Control(pDX
, IDC_EDIT1
, m_dwMerit
);
57 DDX_Control(pDX
, IDC_TREE2
, m_tree
);
60 void CPPageExternalFilters::StepUp(CCheckListBox
& list
)
62 int i
= list
.GetCurSel();
67 DWORD_PTR dwItemData
= list
.GetItemData(i
);
68 int nCheck
= list
.GetCheck(i
);
71 list
.InsertString(i
, str
);
72 list
.SetItemData(i
, dwItemData
);
73 list
.SetCheck(i
, nCheck
);
77 void CPPageExternalFilters::StepDown(CCheckListBox
& list
)
79 int i
= list
.GetCurSel();
80 if(i
< 0 || i
>= list
.GetCount()-1) return;
84 DWORD_PTR dwItemData
= list
.GetItemData(i
);
85 int nCheck
= list
.GetCheck(i
);
88 list
.InsertString(i
, str
);
89 list
.SetItemData(i
, dwItemData
);
90 list
.SetCheck(i
, nCheck
);
94 FilterOverride
* CPPageExternalFilters::GetCurFilter()
96 int i
= m_filters
.GetCurSel();
97 return i
>= 0 ? (FilterOverride
*)m_pFilters
.GetAt((POSITION
)m_filters
.GetItemDataPtr(i
)) : (FilterOverride
*)NULL
;
100 void CPPageExternalFilters::SetupMajorTypes(CAtlArray
<GUID
>& guids
)
103 guids
.Add(MEDIATYPE_NULL
);
104 guids
.Add(MEDIATYPE_Video
);
105 guids
.Add(MEDIATYPE_Audio
);
106 guids
.Add(MEDIATYPE_Text
);
107 guids
.Add(MEDIATYPE_Midi
);
108 guids
.Add(MEDIATYPE_Stream
);
109 guids
.Add(MEDIATYPE_Interleaved
);
110 guids
.Add(MEDIATYPE_File
);
111 guids
.Add(MEDIATYPE_ScriptCommand
);
112 guids
.Add(MEDIATYPE_AUXLine21Data
);
113 guids
.Add(MEDIATYPE_VBI
);
114 guids
.Add(MEDIATYPE_Timecode
);
115 guids
.Add(MEDIATYPE_LMRT
);
116 guids
.Add(MEDIATYPE_URL_STREAM
);
117 guids
.Add(MEDIATYPE_MPEG1SystemStream
);
118 guids
.Add(MEDIATYPE_AnalogVideo
);
119 guids
.Add(MEDIATYPE_AnalogAudio
);
120 guids
.Add(MEDIATYPE_MPEG2_PACK
);
121 guids
.Add(MEDIATYPE_MPEG2_PES
);
122 guids
.Add(MEDIATYPE_MPEG2_SECTIONS
);
123 guids
.Add(MEDIATYPE_DVD_ENCRYPTED_PACK
);
124 guids
.Add(MEDIATYPE_DVD_NAVIGATION
);
127 void CPPageExternalFilters::SetupSubTypes(CAtlArray
<GUID
>& guids
)
130 guids
.Add(MEDIASUBTYPE_None
);
131 guids
.Add(MEDIASUBTYPE_CLPL
);
132 guids
.Add(MEDIASUBTYPE_YUYV
);
133 guids
.Add(MEDIASUBTYPE_IYUV
);
134 guids
.Add(MEDIASUBTYPE_YVU9
);
135 guids
.Add(MEDIASUBTYPE_Y411
);
136 guids
.Add(MEDIASUBTYPE_Y41P
);
137 guids
.Add(MEDIASUBTYPE_YUY2
);
138 guids
.Add(MEDIASUBTYPE_YVYU
);
139 guids
.Add(MEDIASUBTYPE_UYVY
);
140 guids
.Add(MEDIASUBTYPE_Y211
);
141 guids
.Add(MEDIASUBTYPE_CLJR
);
142 guids
.Add(MEDIASUBTYPE_IF09
);
143 guids
.Add(MEDIASUBTYPE_CPLA
);
144 guids
.Add(MEDIASUBTYPE_MJPG
);
145 guids
.Add(MEDIASUBTYPE_TVMJ
);
146 guids
.Add(MEDIASUBTYPE_WAKE
);
147 guids
.Add(MEDIASUBTYPE_CFCC
);
148 guids
.Add(MEDIASUBTYPE_IJPG
);
149 guids
.Add(MEDIASUBTYPE_Plum
);
150 guids
.Add(MEDIASUBTYPE_DVCS
);
151 guids
.Add(MEDIASUBTYPE_DVSD
);
152 guids
.Add(MEDIASUBTYPE_MDVF
);
153 guids
.Add(MEDIASUBTYPE_RGB1
);
154 guids
.Add(MEDIASUBTYPE_RGB4
);
155 guids
.Add(MEDIASUBTYPE_RGB8
);
156 guids
.Add(MEDIASUBTYPE_RGB565
);
157 guids
.Add(MEDIASUBTYPE_RGB555
);
158 guids
.Add(MEDIASUBTYPE_RGB24
);
159 guids
.Add(MEDIASUBTYPE_RGB32
);
160 guids
.Add(MEDIASUBTYPE_ARGB1555
);
161 guids
.Add(MEDIASUBTYPE_ARGB4444
);
162 guids
.Add(MEDIASUBTYPE_ARGB32
);
163 guids
.Add(MEDIASUBTYPE_A2R10G10B10
);
164 guids
.Add(MEDIASUBTYPE_A2B10G10R10
);
165 guids
.Add(MEDIASUBTYPE_AYUV
);
166 guids
.Add(MEDIASUBTYPE_AI44
);
167 guids
.Add(MEDIASUBTYPE_IA44
);
168 guids
.Add(MEDIASUBTYPE_RGB32_D3D_DX7_RT
);
169 guids
.Add(MEDIASUBTYPE_RGB16_D3D_DX7_RT
);
170 guids
.Add(MEDIASUBTYPE_ARGB32_D3D_DX7_RT
);
171 guids
.Add(MEDIASUBTYPE_ARGB4444_D3D_DX7_RT
);
172 guids
.Add(MEDIASUBTYPE_ARGB1555_D3D_DX7_RT
);
173 guids
.Add(MEDIASUBTYPE_RGB32_D3D_DX9_RT
);
174 guids
.Add(MEDIASUBTYPE_RGB16_D3D_DX9_RT
);
175 guids
.Add(MEDIASUBTYPE_ARGB32_D3D_DX9_RT
);
176 guids
.Add(MEDIASUBTYPE_ARGB4444_D3D_DX9_RT
);
177 guids
.Add(MEDIASUBTYPE_ARGB1555_D3D_DX9_RT
);
178 guids
.Add(MEDIASUBTYPE_YV12
);
179 guids
.Add(MEDIASUBTYPE_NV12
);
180 guids
.Add(MEDIASUBTYPE_IMC1
);
181 guids
.Add(MEDIASUBTYPE_IMC2
);
182 guids
.Add(MEDIASUBTYPE_IMC3
);
183 guids
.Add(MEDIASUBTYPE_IMC4
);
184 guids
.Add(MEDIASUBTYPE_S340
);
185 guids
.Add(MEDIASUBTYPE_S342
);
186 guids
.Add(MEDIASUBTYPE_Overlay
);
187 guids
.Add(MEDIASUBTYPE_MPEG1Packet
);
188 guids
.Add(MEDIASUBTYPE_MPEG1Payload
);
189 guids
.Add(MEDIASUBTYPE_MPEG1AudioPayload
);
190 guids
.Add(MEDIASUBTYPE_MPEG1System
);
191 guids
.Add(MEDIASUBTYPE_MPEG1VideoCD
);
192 guids
.Add(MEDIASUBTYPE_MPEG1Video
);
193 guids
.Add(MEDIASUBTYPE_MPEG1Audio
);
194 guids
.Add(MEDIASUBTYPE_Avi
);
195 guids
.Add(MEDIASUBTYPE_Asf
);
196 guids
.Add(MEDIASUBTYPE_QTMovie
);
197 guids
.Add(MEDIASUBTYPE_QTRpza
);
198 guids
.Add(MEDIASUBTYPE_QTSmc
);
199 guids
.Add(MEDIASUBTYPE_QTRle
);
200 guids
.Add(MEDIASUBTYPE_QTJpeg
);
201 guids
.Add(MEDIASUBTYPE_PCMAudio_Obsolete
);
202 guids
.Add(MEDIASUBTYPE_PCM
);
203 guids
.Add(MEDIASUBTYPE_WAVE
);
204 guids
.Add(MEDIASUBTYPE_AU
);
205 guids
.Add(MEDIASUBTYPE_AIFF
);
206 guids
.Add(MEDIASUBTYPE_dvsd
);
207 guids
.Add(MEDIASUBTYPE_dvhd
);
208 guids
.Add(MEDIASUBTYPE_dvsl
);
209 guids
.Add(MEDIASUBTYPE_dv25
);
210 guids
.Add(MEDIASUBTYPE_dv50
);
211 guids
.Add(MEDIASUBTYPE_dvh1
);
212 guids
.Add(MEDIASUBTYPE_Line21_BytePair
);
213 guids
.Add(MEDIASUBTYPE_Line21_GOPPacket
);
214 guids
.Add(MEDIASUBTYPE_Line21_VBIRawData
);
215 guids
.Add(MEDIASUBTYPE_TELETEXT
);
216 guids
.Add(MEDIASUBTYPE_DRM_Audio
);
217 guids
.Add(MEDIASUBTYPE_IEEE_FLOAT
);
218 guids
.Add(MEDIASUBTYPE_DOLBY_AC3_SPDIF
);
219 guids
.Add(MEDIASUBTYPE_RAW_SPORT
);
220 guids
.Add(MEDIASUBTYPE_SPDIF_TAG_241h
);
221 guids
.Add(MEDIASUBTYPE_DssVideo
);
222 guids
.Add(MEDIASUBTYPE_DssAudio
);
223 guids
.Add(MEDIASUBTYPE_VPVideo
);
224 guids
.Add(MEDIASUBTYPE_VPVBI
);
225 guids
.Add(MEDIASUBTYPE_ATSC_SI
);
226 guids
.Add(MEDIASUBTYPE_DVB_SI
);
227 guids
.Add(MEDIASUBTYPE_MPEG2DATA
);
228 guids
.Add(MEDIASUBTYPE_MPEG2_VIDEO
);
229 guids
.Add(MEDIASUBTYPE_MPEG2_PROGRAM
);
230 guids
.Add(MEDIASUBTYPE_MPEG2_TRANSPORT
);
231 guids
.Add(MEDIASUBTYPE_MPEG2_TRANSPORT_STRIDE
);
232 guids
.Add(MEDIASUBTYPE_MPEG2_AUDIO
);
233 guids
.Add(MEDIASUBTYPE_DOLBY_AC3
);
234 guids
.Add(MEDIASUBTYPE_DVD_SUBPICTURE
);
235 guids
.Add(MEDIASUBTYPE_DVD_LPCM_AUDIO
);
236 guids
.Add(MEDIASUBTYPE_DTS
);
237 guids
.Add(MEDIASUBTYPE_SDDS
);
238 guids
.Add(MEDIASUBTYPE_DVD_NAVIGATION_PCI
);
239 guids
.Add(MEDIASUBTYPE_DVD_NAVIGATION_DSI
);
240 guids
.Add(MEDIASUBTYPE_DVD_NAVIGATION_PROVIDER
);
241 guids
.Add(MEDIASUBTYPE_I420
);
242 guids
.Add(MEDIASUBTYPE_WAVE_DOLBY_AC3
);
243 guids
.Add(MEDIASUBTYPE_WAVE_DTS
);
246 BEGIN_MESSAGE_MAP(CPPageExternalFilters
, CPPageBase
)
247 ON_UPDATE_COMMAND_UI(IDC_BUTTON2
, OnUpdateFilter
)
248 ON_UPDATE_COMMAND_UI(IDC_RADIO1
, OnUpdateFilter
)
249 ON_UPDATE_COMMAND_UI(IDC_RADIO2
, OnUpdateFilter
)
250 ON_UPDATE_COMMAND_UI(IDC_RADIO3
, OnUpdateFilter
)
251 ON_UPDATE_COMMAND_UI(IDC_BUTTON3
, OnUpdateFilterUp
)
252 ON_UPDATE_COMMAND_UI(IDC_BUTTON4
, OnUpdateFilterDown
)
253 ON_UPDATE_COMMAND_UI(IDC_EDIT1
, OnUpdateFilterMerit
)
254 ON_UPDATE_COMMAND_UI(IDC_BUTTON5
, OnUpdateFilter
)
255 ON_UPDATE_COMMAND_UI(IDC_BUTTON6
, OnUpdateSubType
)
256 ON_UPDATE_COMMAND_UI(IDC_BUTTON7
, OnUpdateDeleteType
)
257 ON_UPDATE_COMMAND_UI(IDC_BUTTON8
, OnUpdateFilter
)
258 ON_BN_CLICKED(IDC_BUTTON1
, OnAddRegistered
)
259 ON_BN_CLICKED(IDC_BUTTON2
, OnRemoveFilter
)
260 ON_BN_CLICKED(IDC_BUTTON3
, OnMoveFilterUp
)
261 ON_BN_CLICKED(IDC_BUTTON4
, OnMoveFilterDown
)
262 ON_LBN_DBLCLK(IDC_LIST1
, OnLbnDblclkFilter
)
263 ON_BN_CLICKED(IDC_BUTTON5
, OnAddMajorType
)
264 ON_BN_CLICKED(IDC_BUTTON6
, OnAddSubType
)
265 ON_BN_CLICKED(IDC_BUTTON7
, OnDeleteType
)
266 ON_BN_CLICKED(IDC_BUTTON8
, OnResetTypes
)
267 ON_LBN_SELCHANGE(IDC_LIST1
, OnLbnSelchangeList1
)
268 ON_BN_CLICKED(IDC_RADIO1
, OnBnClickedRadio
)
269 ON_BN_CLICKED(IDC_RADIO2
, OnBnClickedRadio
)
270 ON_BN_CLICKED(IDC_RADIO3
, OnBnClickedRadio
)
271 ON_EN_CHANGE(IDC_EDIT1
, OnEnChangeEdit1
)
272 ON_NOTIFY(NM_DBLCLK
, IDC_TREE2
, OnNMDblclkTree2
)
277 // CPPageExternalFilters message handlers
279 BOOL
CPPageExternalFilters::OnInitDialog()
281 __super::OnInitDialog();
283 DragAcceptFiles(TRUE
);
285 AppSettings
& s
= AfxGetAppSettings();
287 m_pFilters
.RemoveAll();
289 POSITION pos
= s
.filters
.GetHeadPosition();
292 CAutoPtr
<FilterOverride
> f(new FilterOverride(s
.filters
.GetNext(pos
)));
294 CString
name(_T("<unknown>"));
296 if(f
->type
== FilterOverride::REGISTERED
)
298 name
= CFGFilterRegistry(f
->dispname
).GetName();
299 if(name
.IsEmpty()) name
= f
->name
+ _T(" <not registered>");
301 else if(f
->type
== FilterOverride::EXTERNAL
)
304 if(f
->fTemporary
) name
+= _T(" <temporary>");
305 if(!CPath(MakeFullPath(f
->path
)).FileExists()) name
+= _T(" <not found!>");
308 int i
= m_filters
.AddString(name
);
309 m_filters
.SetCheck(i
, f
->fDisabled
? 0 : 1);
310 m_filters
.SetItemDataPtr(i
, m_pFilters
.AddTail(f
));
315 return TRUE
; // return TRUE unless you set the focus to a control
316 // EXCEPTION: OCX Property Pages should return FALSE
319 BOOL
CPPageExternalFilters::OnApply()
323 AppSettings
& s
= AfxGetAppSettings();
325 s
.filters
.RemoveAll();
327 for(int i
= 0; i
< m_filters
.GetCount(); i
++)
329 if(POSITION pos
= (POSITION
)m_filters
.GetItemData(i
))
331 CAutoPtr
<FilterOverride
> f(new FilterOverride(m_pFilters
.GetAt(pos
)));
332 f
->fDisabled
= !m_filters
.GetCheck(i
);
333 s
.filters
.AddTail(f
);
337 return __super::OnApply();
340 void CPPageExternalFilters::OnUpdateFilter(CCmdUI
* pCmdUI
)
342 if(FilterOverride
* f
= GetCurFilter())
344 pCmdUI
->Enable(!(pCmdUI
->m_nID
== IDC_RADIO2
&& f
->type
== FilterOverride::EXTERNAL
));
348 pCmdUI
->Enable(FALSE
);
352 void CPPageExternalFilters::OnUpdateFilterUp(CCmdUI
* pCmdUI
)
354 pCmdUI
->Enable(m_filters
.GetCurSel() > 0);
357 void CPPageExternalFilters::OnUpdateFilterDown(CCmdUI
* pCmdUI
)
359 pCmdUI
->Enable(m_filters
.GetCurSel() >= 0 && m_filters
.GetCurSel() < m_filters
.GetCount()-1);
362 void CPPageExternalFilters::OnUpdateFilterMerit(CCmdUI
* pCmdUI
)
365 pCmdUI
->Enable(m_iLoadType
== FilterOverride::MERIT
);
368 void CPPageExternalFilters::OnUpdateSubType(CCmdUI
* pCmdUI
)
370 HTREEITEM node
= m_tree
.GetSelectedItem();
371 pCmdUI
->Enable(node
!= NULL
&& m_tree
.GetItemData(node
) == NULL
);
374 void CPPageExternalFilters::OnUpdateDeleteType(CCmdUI
* pCmdUI
)
376 pCmdUI
->Enable(!!m_tree
.GetSelectedItem());
379 void CPPageExternalFilters::OnAddRegistered()
381 CRegFilterChooserDlg
dlg(this);
382 if(dlg
.DoModal() == IDOK
)
384 while(!dlg
.m_filters
.IsEmpty())
386 if(FilterOverride
* f
= dlg
.m_filters
.RemoveHead())
388 CAutoPtr
<FilterOverride
> p(f
);
390 CString name
= f
->name
;
392 if(f
->type
== FilterOverride::EXTERNAL
)
394 if(!CPath(MakeFullPath(f
->path
)).FileExists()) name
+= _T(" <not found!>");
397 int i
= m_filters
.AddString(name
);
398 m_filters
.SetItemDataPtr(i
, m_pFilters
.AddTail(p
));
399 m_filters
.SetCheck(i
, 1);
401 if(dlg
.m_filters
.IsEmpty())
403 m_filters
.SetCurSel(i
);
404 OnLbnSelchangeList1();
411 void CPPageExternalFilters::OnRemoveFilter()
413 int i
= m_filters
.GetCurSel();
414 m_pFilters
.RemoveAt((POSITION
)m_filters
.GetItemDataPtr(i
));
415 m_filters
.DeleteString(i
);
416 if(i
>= m_filters
.GetCount()) i
--;
417 m_filters
.SetCurSel(i
);
418 OnLbnSelchangeList1();
421 void CPPageExternalFilters::OnMoveFilterUp()
426 void CPPageExternalFilters::OnMoveFilterDown()
431 void CPPageExternalFilters::OnLbnDblclkFilter()
433 if(FilterOverride
* f
= GetCurFilter())
435 CComPtr
<IBaseFilter
> pBF
;
438 if(f
->type
== FilterOverride::REGISTERED
)
441 if(CreateFilter(f
->dispname
, &pBF
, namew
))
444 else if(f
->type
== FilterOverride::EXTERNAL
)
446 if(SUCCEEDED(LoadExternalFilter(f
->path
, f
->clsid
, &pBF
)))
450 if(CComQIPtr
<ISpecifyPropertyPages
> pSPP
= pBF
)
452 CComPropertySheet
ps(name
, this);
453 if(ps
.AddPages(pSPP
) > 0)
455 CComPtr
<IFilterGraph
> pFG
;
456 if(SUCCEEDED(pFG
.CoCreateInstance(CLSID_FilterGraph
)))
457 pFG
->AddFilter(pBF
, L
"");
465 void CPPageExternalFilters::OnAddMajorType()
467 FilterOverride
* f
= GetCurFilter();
470 CAtlArray
<GUID
> guids
;
471 SetupMajorTypes(guids
);
473 CSelectMediaType
dlg(guids
, MEDIATYPE_NULL
, this);
474 if(dlg
.DoModal() == IDOK
)
476 POSITION pos
= f
->guids
.GetHeadPosition();
479 if(f
->guids
.GetNext(pos
) == dlg
.m_guid
) {AfxMessageBox(_T("Already on the list!")); return;}
480 f
->guids
.GetNext(pos
);
483 f
->guids
.AddTail(dlg
.m_guid
);
484 pos
= f
->guids
.GetTailPosition();
485 f
->guids
.AddTail(GUID_NULL
);
487 CString major
= GetMediaTypeName(dlg
.m_guid
);
488 CString sub
= GetMediaTypeName(GUID_NULL
);
490 HTREEITEM node
= m_tree
.InsertItem(major
);
491 m_tree
.SetItemData(node
, NULL
);
493 node
= m_tree
.InsertItem(sub
, node
);
494 m_tree
.SetItemData(node
, (DWORD_PTR
)pos
);
498 void CPPageExternalFilters::OnAddSubType()
500 FilterOverride
* f
= GetCurFilter();
503 HTREEITEM node
= m_tree
.GetSelectedItem();
506 HTREEITEM child
= m_tree
.GetChildItem(node
);
509 POSITION pos
= (POSITION
)m_tree
.GetItemData(child
);
510 GUID major
= f
->guids
.GetAt(pos
);
512 CAtlArray
<GUID
> guids
;
513 SetupSubTypes(guids
);
515 CSelectMediaType
dlg(guids
, MEDIASUBTYPE_NULL
, this);
516 if(dlg
.DoModal() == IDOK
)
518 for(child
= m_tree
.GetChildItem(node
); child
; child
= m_tree
.GetNextSiblingItem(child
))
520 pos
= (POSITION
)m_tree
.GetItemData(child
);
521 f
->guids
.GetNext(pos
);
522 if(f
->guids
.GetAt(pos
) == dlg
.m_guid
) {AfxMessageBox(_T("Already on the list!")); return;}
525 f
->guids
.AddTail(major
);
526 pos
= f
->guids
.GetTailPosition();
527 f
->guids
.AddTail(dlg
.m_guid
);
529 CString sub
= GetMediaTypeName(dlg
.m_guid
);
531 node
= m_tree
.InsertItem(sub
, node
);
532 m_tree
.SetItemData(node
, (DWORD_PTR
)pos
);
536 void CPPageExternalFilters::OnDeleteType()
538 if(FilterOverride
* f
= GetCurFilter())
540 HTREEITEM node
= m_tree
.GetSelectedItem();
543 POSITION pos
= (POSITION
)m_tree
.GetItemData(node
);
547 for(HTREEITEM child
= m_tree
.GetChildItem(node
); child
; child
= m_tree
.GetNextSiblingItem(child
))
549 pos
= (POSITION
)m_tree
.GetItemData(child
);
552 f
->guids
.GetNext(pos
);
554 f
->guids
.GetNext(pos
);
556 f
->guids
.RemoveAt(pos1
);
557 f
->guids
.RemoveAt(pos2
);
560 m_tree
.DeleteItem(node
);
564 HTREEITEM parent
= m_tree
.GetParentItem(node
);
567 f
->guids
.GetNext(pos
);
569 f
->guids
.GetNext(pos
);
571 m_tree
.DeleteItem(node
);
573 if(!m_tree
.ItemHasChildren(parent
))
575 f
->guids
.SetAt(pos2
, GUID_NULL
);
576 node
= m_tree
.InsertItem(GetMediaTypeName(GUID_NULL
), parent
);
577 m_tree
.SetItemData(node
, (DWORD_PTR
)pos1
);
581 f
->guids
.RemoveAt(pos1
);
582 f
->guids
.RemoveAt(pos2
);
588 void CPPageExternalFilters::OnResetTypes()
590 if(FilterOverride
* f
= GetCurFilter())
592 f
->guids
.RemoveAll();
593 f
->guids
.AddTailList(&f
->backup
);
595 m_pLastSelFilter
= NULL
;
596 OnLbnSelchangeList1();
600 void CPPageExternalFilters::OnLbnSelchangeList1()
602 if(FilterOverride
* f
= GetCurFilter())
604 if(m_pLastSelFilter
== f
) return;
605 m_pLastSelFilter
= f
;
607 m_iLoadType
= f
->iLoadType
;
609 m_dwMerit
= f
->dwMerit
;
611 HTREEITEM dummy_item
= m_tree
.InsertItem(_T(""), 0,0, NULL
, TVI_FIRST
);
613 for(HTREEITEM item
= m_tree
.GetNextVisibleItem(dummy_item
); item
; item
= m_tree
.GetNextVisibleItem(dummy_item
))
614 m_tree
.DeleteItem(item
);
618 POSITION pos
= f
->guids
.GetHeadPosition();
622 CString major
= GetMediaTypeName(f
->guids
.GetNext(pos
));
623 CString sub
= GetMediaTypeName(f
->guids
.GetNext(pos
));
625 HTREEITEM node
= NULL
;
628 if(map
.Lookup(major
, val
)) node
= (HTREEITEM
)val
;
629 else map
[major
] = node
= m_tree
.InsertItem(major
);
630 m_tree
.SetItemData(node
, NULL
);
632 node
= m_tree
.InsertItem(sub
, node
);
633 m_tree
.SetItemData(node
, (DWORD_PTR
)tmp
);
636 m_tree
.DeleteItem(dummy_item
);
638 for(HTREEITEM item
= m_tree
.GetFirstVisibleItem(); item
; item
= m_tree
.GetNextVisibleItem(item
))
639 m_tree
.Expand(item
, TVE_EXPAND
);
641 m_tree
.EnsureVisible(m_tree
.GetRootItem());
645 m_pLastSelFilter
= NULL
;
647 m_iLoadType
= FilterOverride::PREFERRED
;
651 m_tree
.DeleteAllItems();
655 void CPPageExternalFilters::OnBnClickedRadio()
658 if(FilterOverride
* f
= GetCurFilter())
659 f
->iLoadType
= m_iLoadType
;
662 void CPPageExternalFilters::OnEnChangeEdit1()
665 if(FilterOverride
* f
= GetCurFilter())
668 if(m_dwMerit
.GetDWORD(dw
))
673 void CPPageExternalFilters::OnNMDblclkTree2(NMHDR
*pNMHDR
, LRESULT
*pResult
)
677 if(FilterOverride
* f
= GetCurFilter())
679 HTREEITEM node
= m_tree
.GetSelectedItem();
682 POSITION pos
= (POSITION
)m_tree
.GetItemData(node
);
685 f
->guids
.GetNext(pos
);
688 CAtlArray
<GUID
> guids
;
689 SetupSubTypes(guids
);
691 CSelectMediaType
dlg(guids
, f
->guids
.GetAt(pos
), this);
692 if(dlg
.DoModal() == IDOK
)
694 f
->guids
.SetAt(pos
, dlg
.m_guid
);
695 m_tree
.SetItemText(node
, GetMediaTypeName(dlg
.m_guid
));
700 void CPPageExternalFilters::OnDropFiles(HDROP hDropInfo
)
704 UINT nFiles
= ::DragQueryFile(hDropInfo
, (UINT
)-1, NULL
, 0);
705 for(UINT iFile
= 0; iFile
< nFiles
; iFile
++)
707 TCHAR szFileName
[_MAX_PATH
];
708 ::DragQueryFile(hDropInfo
, iFile
, szFileName
, _MAX_PATH
);
710 CFilterMapper2
fm2(false);
711 fm2
.Register(szFileName
);
713 while(!fm2
.m_filters
.IsEmpty())
715 if(FilterOverride
* f
= fm2
.m_filters
.RemoveHead())
717 CAutoPtr
<FilterOverride
> p(f
);
718 int i
= m_filters
.AddString(f
->name
);
719 m_filters
.SetItemDataPtr(i
, m_pFilters
.AddTail(p
));
720 m_filters
.SetCheck(i
, 1);
722 if(fm2
.m_filters
.IsEmpty())
724 m_filters
.SetCurSel(i
);
725 OnLbnSelchangeList1();
730 ::DragFinish(hDropInfo
);