PPageFilters.cpp

00001 
00002 
00003 /* 
00004  *      Copyright (C) 2003-2005 Gabest
00005  *      http://www.gabest.org
00006  *
00007  *  This Program is free software; you can redistribute it and/or modify
00008  *  it under the terms of the GNU General Public License as published by
00009  *  the Free Software Foundation; either version 2, or (at your option)
00010  *  any later version.
00011  *   
00012  *  This Program is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00015  *  GNU General Public License for more details.
00016  *   
00017  *  You should have received a copy of the GNU General Public License
00018  *  along with GNU Make; see the file COPYING.  If not, write to
00019  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00020  *  http://www.gnu.org/copyleft/gpl.html
00021  *
00022  */
00023 
00024 // PPageFilters.cpp : implementation file
00025 //
00026 
00027 #include "stdafx.h"
00028 #include "mplayerc.h"
00029 #include "PPageFilters.h"
00030 #include "..\..\filters\filters.h"
00031 #include ".\ppagefilters.h"
00032 
00033 static struct filter_t {LPCTSTR label; int type; int flag; UINT nHintID;} s_filters[] = 
00034 {
00035         {_T("AVI"), 0, SRC_AVI, IDS_SRC_AVI},
00036         {_T("CDDA (Audio CD)"), 0, SRC_CDDA, IDS_SRC_CDDA},
00037         {_T("CDXA (VCD/SVCD/XCD)"), 0, SRC_CDXA, IDS_SRC_CDXA},
00038         {_T("Dirac"), 0, SRC_DIRAC, IDS_SRC_DIRAC},
00039         {_T("DirectShow Media"), 0, SRC_DSM, IDS_SRC_DSM},
00040         {_T("DTS/AC3"), 0, SRC_DTSAC3, IDS_SRC_DTSAC3},
00041         {_T("DVD Video Title Set"), 0, SRC_VTS, IDS_SRC_VTS},
00042         {_T("DVD2AVI Project File"), 0, SRC_D2V, IDS_SRC_D2V},
00043         {_T("FLI/FLC"), 0, SRC_FLIC, IDS_SRC_FLIC},
00044         {_T("Matroska"), 0, SRC_MATROSKA, IDS_SRC_MATROSKA},
00045         {_T("MP4"), 0, SRC_MP4, IDS_SRC_MP4},
00046         {_T("MPEG Audio"), 0, SRC_MPA, IDS_SRC_MPA},
00047         {_T("MPEG PS/TS/PVA"), 0, SRC_MPEG, 0},
00048         {_T("Nut"), 0, SRC_NUT, IDS_SRC_NUT},
00049         {_T("Ogg"), 0, SRC_OGG, IDS_SRC_OGG},
00050         {_T("RealMedia"), 0, SRC_REALMEDIA, IDS_SRC_REALMEDIA},
00051         {_T("RoQ"), 0, SRC_ROQ, IDS_SRC_ROQ},
00052         {_T("SHOUTcast"), 0, SRC_SHOUTCAST, IDS_SRC_SHOUTCAST},
00053         __if_exists(CRadGtSplitterFilter) {{_T("Smacker/Bink"), 0, SRC_RADGT, IDS_SRC_RADGT},}
00054         {_T("AAC"), 1, TRA_AAC, IDS_TRA_AAC},
00055         {_T("AC3"), 1, TRA_AC3, IDS_TRA_AC3},
00056         {_T("DTS"), 1, TRA_DTS, IDS_TRA_DTS},
00057         {_T("Dirac"), 1, TRA_DIRAC, IDS_TRA_DIRAC},
00058         {_T("LPCM"), 1, TRA_LPCM, IDS_TRA_LPCM},
00059         {_T("MPEG Audio"), 1, TRA_MPA, IDS_TRA_MPA},
00060         {_T("MPEG-1 Video"), 1, TRA_MPEG1, IDS_TRA_MPEG1},
00061         {_T("MPEG-2 Video"), 1, TRA_MPEG2, IDS_TRA_MPEG2},
00062         {_T("PS2 Audio (PCM/ADPCM)"), 1, TRA_PS2AUD, IDS_TRA_PS2AUD},
00063         {_T("RealVideo"), 1, TRA_RV, IDS_TRA_RV},
00064         {_T("RealAudio"), 1, TRA_RA, IDS_TRA_RA},
00065 };
00066 
00067 IMPLEMENT_DYNAMIC(CPPageFiltersListBox, CCheckListBox)
00068 CPPageFiltersListBox::CPPageFiltersListBox()
00069         : CCheckListBox()
00070 {
00071 }
00072 
00073 void CPPageFiltersListBox::PreSubclassWindow()
00074 {
00075         __super::PreSubclassWindow();
00076         EnableToolTips(TRUE);
00077 }
00078 
00079 INT_PTR CPPageFiltersListBox::OnToolHitTest(CPoint point, TOOLINFO* pTI) const
00080 {
00081         BOOL b = FALSE;
00082         int row = ItemFromPoint(point, b);
00083         if(row < 0) return -1;
00084 
00085         CRect r;
00086         GetItemRect(row, r);
00087         pTI->rect = r;
00088         pTI->hwnd = m_hWnd;
00089         pTI->uId = (UINT)row;
00090         pTI->lpszText = LPSTR_TEXTCALLBACK;
00091         pTI->uFlags |= TTF_ALWAYSTIP;
00092 
00093         return pTI->uId;
00094 }
00095 
00096 BEGIN_MESSAGE_MAP(CPPageFiltersListBox, CCheckListBox)
00097         ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
00098         ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)
00099 END_MESSAGE_MAP()
00100 
00101 BOOL CPPageFiltersListBox::OnToolTipNotify(UINT id, NMHDR* pNMHDR, LRESULT* pResult)
00102 {
00103         TOOLTIPTEXTA* pTTTA = (TOOLTIPTEXTA*)pNMHDR;
00104         TOOLTIPTEXTW* pTTTW = (TOOLTIPTEXTW*)pNMHDR;
00105 
00106         filter_t* f = (filter_t*)GetItemDataPtr(pNMHDR->idFrom);
00107         if(f->nHintID == 0) return FALSE;
00108 
00109         ::SendMessage(pNMHDR->hwndFrom, TTM_SETMAXTIPWIDTH, 0, (LPARAM)(INT)1000);
00110 
00111         static CStringA m_strTipTextA;
00112         static CStringW m_strTipTextW;
00113         
00114         m_strTipTextA = CString(MAKEINTRESOURCE(f->nHintID));
00115         m_strTipTextW = CString(MAKEINTRESOURCE(f->nHintID));
00116 
00117         if(pNMHDR->code == TTN_NEEDTEXTA) pTTTA->lpszText = (LPSTR)(LPCSTR)m_strTipTextA;
00118         else pTTTW->lpszText = (LPWSTR)(LPCWSTR)m_strTipTextW;
00119 
00120         *pResult = 0;
00121 
00122         return TRUE;    // message was handled
00123 }
00124 
00125 // CPPageFilters dialog
00126 
00127 IMPLEMENT_DYNAMIC(CPPageFilters, CPPageBase)
00128 CPPageFilters::CPPageFilters()
00129         : CPPageBase(CPPageFilters::IDD, CPPageFilters::IDD)
00130 {
00131 }
00132 
00133 CPPageFilters::~CPPageFilters()
00134 {
00135 }
00136 
00137 
00138 void CPPageFilters::DoDataExchange(CDataExchange* pDX)
00139 {
00140         __super::DoDataExchange(pDX);
00141         DDX_Control(pDX, IDC_LIST1, m_listSrc);
00142         DDX_Control(pDX, IDC_LIST2, m_listTra);
00143 }
00144 
00145 BEGIN_MESSAGE_MAP(CPPageFilters, CPPageBase)
00146 END_MESSAGE_MAP()
00147 
00148 // CPPageFilters message handlers
00149 
00150 BOOL CPPageFilters::OnInitDialog()
00151 {
00152         __super::OnInitDialog();
00153 
00154         AppSettings& s = AfxGetAppSettings();
00155 
00156         for(int i = 0; i < countof(s_filters); i++)
00157         {
00158                 CCheckListBox* l = 
00159                         s_filters[i].type == 0 ? &m_listSrc : 
00160                         s_filters[i].type == 1 ? &m_listTra : 
00161                         NULL; 
00162 
00163                 UINT* pflags = 
00164                         s_filters[i].type == 0 ? &s.SrcFilters : 
00165                         s_filters[i].type == 1 ? &s.TraFilters : 
00166                         NULL; 
00167 
00168                 if(l && pflags)
00169                 {
00170                         int Index = l->AddString(s_filters[i].label);
00171                         l->SetCheck(Index, !!(*pflags & s_filters[i].flag));
00172                         l->SetItemDataPtr(Index, &s_filters[i]);
00173                 }
00174         }
00175 
00176         UpdateData(FALSE);
00177 
00178         return TRUE;  // return TRUE unless you set the focus to a control
00179         // EXCEPTION: OCX Property Pages should return FALSE
00180 }
00181 
00182 BOOL CPPageFilters::OnApply()
00183 {
00184         UpdateData();
00185 
00186         AppSettings& s = AfxGetAppSettings();
00187 
00188         s.SrcFilters = s.TraFilters = 0;
00189 
00190         CList<filter_t*> fl;
00191         for(int i = 0; i < m_listSrc.GetCount(); i++)
00192                 if(m_listSrc.GetCheck(i))
00193                         fl.AddTail((filter_t*)m_listSrc.GetItemDataPtr(i));
00194         for(int i = 0; i < m_listTra.GetCount(); i++)
00195                 if(m_listTra.GetCheck(i))
00196                         fl.AddTail((filter_t*)m_listTra.GetItemDataPtr(i));
00197 
00198         POSITION pos = fl.GetHeadPosition();
00199         while(pos)
00200         {
00201                 filter_t* f = fl.GetNext(pos);
00202 
00203                 UINT* pflags = 
00204                         f->type == 0 ? &s.SrcFilters : 
00205                         f->type == 1 ? &s.TraFilters : 
00206                         NULL; 
00207 
00208                 if(pflags)
00209                         *pflags |= f->flag;
00210         }
00211 
00212         return __super::OnApply();
00213 }
00214 

Generated on Tue Dec 13 14:47:01 2005 for guliverkli by  doxygen 1.4.5