4 * Copyright (C) 2003-2006 Gabest
5 * http://www.gabest.org
7 * This Program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2, or (at your option)
12 * This Program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with GNU Make; see the file COPYING. If not, write to
19 * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
20 * http://www.gnu.org/copyleft/gpl.html
24 // PPageInternalFilters.cpp : implementation file
29 #include "PPageInternalFilters.h"
30 #include "ComPropertySheet.h"
31 #include "..\..\filters\filters.h"
33 static struct filter_t
39 CUnknown
* (WINAPI
* CreateInstance
)(LPUNKNOWN lpunk
, HRESULT
* phr
);
43 {_T("AVI"), 0, SRC_AVI
, IDS_SRC_AVI
, NULL
},
44 {_T("CDDA (Audio CD)"), 0, SRC_CDDA
, IDS_SRC_CDDA
, NULL
},
45 {_T("CDXA (VCD/SVCD/XCD)"), 0, SRC_CDXA
, IDS_SRC_CDXA
, NULL
},
46 __if_exists(CDiracSplitterFilter
) {{_T("Dirac"), 0, SRC_DIRAC
, IDS_SRC_DIRAC
, NULL
},}
47 {_T("DirectShow Media"), 0, SRC_DSM
, IDS_SRC_DSM
, NULL
},
48 {_T("DTS/AC3"), 0, SRC_DTSAC3
, IDS_SRC_DTSAC3
, NULL
},
49 {_T("DVD Video Title Set"), 0, SRC_VTS
, IDS_SRC_VTS
, NULL
},
50 {_T("DVD2AVI Project File"), 0, SRC_D2V
, IDS_SRC_D2V
, NULL
},
51 {_T("FLI/FLC"), 0, SRC_FLIC
, IDS_SRC_FLIC
, NULL
},
52 {_T("FLV"), 0, SRC_FLV
, IDS_SRC_FLV
, NULL
},
53 {_T("Matroska"), 0, SRC_MATROSKA
, IDS_SRC_MATROSKA
, NULL
},
54 {_T("MP4/MOV"), 0, SRC_MP4
, IDS_SRC_MP4
, NULL
},
55 {_T("MPEG Audio"), 0, SRC_MPA
, IDS_SRC_MPA
, NULL
},
56 {_T("MPEG PS/TS/PVA"), 0, SRC_MPEG
, 0, NULL
},
57 __if_exists(CNutSplitterFilter
) {{_T("Nut"), 0, SRC_NUT
, IDS_SRC_NUT
, NULL
},}
58 {_T("Ogg"), 0, SRC_OGG
, IDS_SRC_OGG
, NULL
},
59 {_T("RealMedia"), 0, SRC_REALMEDIA
, IDS_SRC_REALMEDIA
, NULL
},
60 {_T("RoQ"), 0, SRC_ROQ
, IDS_SRC_ROQ
, NULL
},
61 {_T("SHOUTcast"), 0, SRC_SHOUTCAST
, IDS_SRC_SHOUTCAST
, NULL
},
62 __if_exists(CRadGtSplitterFilter
) {{_T("Smacker/Bink"), 0, SRC_RADGT
, IDS_SRC_RADGT
, NULL
},}
63 {_T("AAC"), 1, TRA_AAC
, IDS_TRA_AAC
, CreateInstance
<CMpaDecFilter
>},
64 {_T("AC3"), 1, TRA_AC3
, IDS_TRA_AC3
, CreateInstance
<CMpaDecFilter
>},
65 {_T("DTS"), 1, TRA_DTS
, IDS_TRA_DTS
, CreateInstance
<CMpaDecFilter
>},
66 __if_exists(CDiracVideoDecoder
) {{_T("Dirac"), 1, TRA_DIRAC
, IDS_TRA_DIRAC
, NULL
},}
67 //{_T("FLV4"), 1, TRA_FLV4, 0, NULL},
68 {_T("LPCM"), 1, TRA_LPCM
, IDS_TRA_LPCM
, CreateInstance
<CMpaDecFilter
>},
69 {_T("MPEG Audio"), 1, TRA_MPA
, IDS_TRA_MPA
, CreateInstance
<CMpaDecFilter
>},
70 {_T("MPEG-1 Video"), 1, TRA_MPEG1
, IDS_TRA_MPEG1
, CreateInstance
<CMpeg2DecFilter
>},
71 {_T("MPEG-2 Video"), 1, TRA_MPEG2
, IDS_TRA_MPEG2
, CreateInstance
<CMpeg2DecFilter
>},
72 {_T("PS2 Audio (PCM/ADPCM)"), 1, TRA_PS2AUD
, IDS_TRA_PS2AUD
, CreateInstance
<CMpaDecFilter
>},
73 {_T("RealVideo"), 1, TRA_RV
, IDS_TRA_RV
, NULL
},
74 {_T("RealAudio"), 1, TRA_RA
, IDS_TRA_RA
, NULL
},
75 {_T("Vorbis"), 1, TRA_VORBIS
, 0, NULL
/* TODO: CreateInstance<CMpaDecFilter>*/},
76 //{_T("VP62"), 1, TRA_VP62, 0, NULL},
79 IMPLEMENT_DYNAMIC(CPPageInternalFiltersListBox
, CCheckListBox
)
80 CPPageInternalFiltersListBox::CPPageInternalFiltersListBox()
85 void CPPageInternalFiltersListBox::PreSubclassWindow()
87 __super::PreSubclassWindow();
91 INT_PTR
CPPageInternalFiltersListBox::OnToolHitTest(CPoint point
, TOOLINFO
* pTI
) const
94 int row
= ItemFromPoint(point
, b
);
95 if(row
< 0) return -1;
101 pTI
->uId
= (UINT
)row
;
102 pTI
->lpszText
= LPSTR_TEXTCALLBACK
;
103 pTI
->uFlags
|= TTF_ALWAYSTIP
;
108 BEGIN_MESSAGE_MAP(CPPageInternalFiltersListBox
, CCheckListBox
)
109 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW
, 0, 0xFFFF, OnToolTipNotify
)
110 ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA
, 0, 0xFFFF, OnToolTipNotify
)
113 BOOL
CPPageInternalFiltersListBox::OnToolTipNotify(UINT id
, NMHDR
* pNMHDR
, LRESULT
* pResult
)
115 TOOLTIPTEXTA
* pTTTA
= (TOOLTIPTEXTA
*)pNMHDR
;
116 TOOLTIPTEXTW
* pTTTW
= (TOOLTIPTEXTW
*)pNMHDR
;
118 filter_t
* f
= (filter_t
*)GetItemDataPtr(pNMHDR
->idFrom
);
119 if(f
->nHintID
== 0) return FALSE
;
121 ::SendMessage(pNMHDR
->hwndFrom
, TTM_SETMAXTIPWIDTH
, 0, (LPARAM
)(INT
)1000);
123 static CStringA m_strTipTextA
;
124 static CStringW m_strTipTextW
;
126 m_strTipTextA
= CString(MAKEINTRESOURCE(f
->nHintID
));
127 m_strTipTextW
= CString(MAKEINTRESOURCE(f
->nHintID
));
129 if(pNMHDR
->code
== TTN_NEEDTEXTA
) pTTTA
->lpszText
= (LPSTR
)(LPCSTR
)m_strTipTextA
;
130 else pTTTW
->lpszText
= (LPWSTR
)(LPCWSTR
)m_strTipTextW
;
134 return TRUE
; // message was handled
137 void CPPageInternalFiltersListBox::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct
)
139 CDC
* pDC
= CDC::FromHandle(lpDrawItemStruct
->hDC
);
141 CFont
* pOldFont
= NULL
;
143 if(((filter_t
*)lpDrawItemStruct
->itemData
)->CreateInstance
)
147 CFont
* pFont
= pDC
->GetCurrentFont();
150 pFont
->GetLogFont(&lf
);
151 lf
.lfWeight
= FW_BOLD
;
153 m_bold
.CreateFontIndirect(&lf
);
158 pOldFont
= pDC
->SelectObject(&m_bold
);
162 __super::DrawItem(lpDrawItemStruct
);
166 pDC
->SelectObject(pOldFont
);
170 // CPPageInternalFilters dialog
172 IMPLEMENT_DYNAMIC(CPPageInternalFilters
, CPPageBase
)
173 CPPageInternalFilters::CPPageInternalFilters()
174 : CPPageBase(CPPageInternalFilters::IDD
, CPPageInternalFilters::IDD
)
178 CPPageInternalFilters::~CPPageInternalFilters()
183 void CPPageInternalFilters::DoDataExchange(CDataExchange
* pDX
)
185 __super::DoDataExchange(pDX
);
186 DDX_Control(pDX
, IDC_LIST1
, m_listSrc
);
187 DDX_Control(pDX
, IDC_LIST2
, m_listTra
);
190 BEGIN_MESSAGE_MAP(CPPageInternalFilters
, CPPageBase
)
191 ON_LBN_DBLCLK(IDC_LIST1
, &CPPageInternalFilters::OnLbnDblclkList1
)
192 ON_LBN_DBLCLK(IDC_LIST2
, &CPPageInternalFilters::OnLbnDblclkList2
)
195 // CPPageInternalFilters message handlers
197 BOOL
CPPageInternalFilters::OnInitDialog()
199 __super::OnInitDialog();
201 AppSettings
& s
= AfxGetAppSettings();
203 for(int i
= 0; i
< countof(s_filters
); i
++)
206 s_filters
[i
].type
== 0 ? &m_listSrc
:
207 s_filters
[i
].type
== 1 ? &m_listTra
:
211 s_filters
[i
].type
== 0 ? &s
.SrcFilters
:
212 s_filters
[i
].type
== 1 ? &s
.TraFilters
:
217 int Index
= l
->AddString(s_filters
[i
].label
);
218 l
->SetCheck(Index
, !!(*pflags
& s_filters
[i
].flag
));
219 l
->SetItemDataPtr(Index
, &s_filters
[i
]);
225 return TRUE
; // return TRUE unless you set the focus to a control
226 // EXCEPTION: OCX Property Pages should return FALSE
229 BOOL
CPPageInternalFilters::OnApply()
233 AppSettings
& s
= AfxGetAppSettings();
235 s
.SrcFilters
= s
.TraFilters
= 0;
238 for(int i
= 0; i
< m_listSrc
.GetCount(); i
++)
239 if(m_listSrc
.GetCheck(i
))
240 fl
.AddTail((filter_t
*)m_listSrc
.GetItemDataPtr(i
));
241 for(int i
= 0; i
< m_listTra
.GetCount(); i
++)
242 if(m_listTra
.GetCheck(i
))
243 fl
.AddTail((filter_t
*)m_listTra
.GetItemDataPtr(i
));
245 POSITION pos
= fl
.GetHeadPosition();
248 filter_t
* f
= fl
.GetNext(pos
);
251 f
->type
== 0 ? &s
.SrcFilters
:
252 f
->type
== 1 ? &s
.TraFilters
:
259 return __super::OnApply();
262 void CPPageInternalFilters::ShowPPage(CPPageInternalFiltersListBox
& l
)
264 int i
= l
.GetCurSel();
267 filter_t
* f
= (filter_t
*)l
.GetItemDataPtr(i
);
268 if(!f
|| !f
->CreateInstance
) return;
271 CUnknown
* pObj
= f
->CreateInstance(NULL
, &hr
);
274 CComPtr
<IUnknown
> pUnk
= (IUnknown
*)(INonDelegatingUnknown
*)pObj
;
278 if(CComQIPtr
<ISpecifyPropertyPages
> pSPP
= pUnk
)
280 CComPropertySheet
ps(ResStr(IDS_PROPSHEET_PROPERTIES
), this);
287 void CPPageInternalFilters::OnLbnDblclkList1()
289 ShowPPage(m_listSrc
);
292 void CPPageInternalFilters::OnLbnDblclkList2()
294 ShowPPage(m_listTra
);