X64 transport [Part 5] (Update plugins.cpp)
[xy_vsfilter.git] / src / apps / mplayerc / OpenDlg.cpp
blobe5e41b2f5d431e5c1f3ce206a4e697080d47a6db
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 // OpenDlg.cpp : implementation file
25 #include "stdafx.h"
26 #include "mplayerc.h"
27 #include "OpenDlg.h"
28 #include "OpenFileDlg.h"
30 // COpenDlg dialog
32 //IMPLEMENT_DYNAMIC(COpenDlg, CResizableDialog)
33 COpenDlg::COpenDlg(CWnd* pParent /*=NULL*/)
34 : CResizableDialog(COpenDlg::IDD, pParent)
35 , m_path(_T(""))
36 , m_path2(_T(""))
37 , m_fMultipleFiles(false)
38 , m_fAppendPlaylist(FALSE)
42 COpenDlg::~COpenDlg()
46 void COpenDlg::DoDataExchange(CDataExchange* pDX)
48 __super::DoDataExchange(pDX);
49 DDX_Control(pDX, IDC_COMBO1, m_mrucombo);
50 DDX_CBString(pDX, IDC_COMBO1, m_path);
51 DDX_Control(pDX, IDC_COMBO2, m_mrucombo2);
52 DDX_CBString(pDX, IDC_COMBO2, m_path2);
53 DDX_Control(pDX, IDC_STATIC1, m_label2);
54 DDX_Check(pDX, IDC_CHECK1, m_fAppendPlaylist);
58 BEGIN_MESSAGE_MAP(COpenDlg, CResizableDialog)
59 ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedBrowsebutton)
60 ON_BN_CLICKED(IDC_BUTTON2, OnBnClickedBrowsebutton2)
61 ON_BN_CLICKED(IDOK, OnBnClickedOk)
62 ON_UPDATE_COMMAND_UI(IDC_STATIC1, OnUpdateDub)
63 ON_UPDATE_COMMAND_UI(IDC_COMBO2, OnUpdateDub)
64 ON_UPDATE_COMMAND_UI(IDC_BUTTON2, OnUpdateDub)
65 END_MESSAGE_MAP()
68 // COpenDlg message handlers
70 BOOL COpenDlg::OnInitDialog()
72 __super::OnInitDialog();
74 CRecentFileList& MRU = AfxGetAppSettings().MRU;
75 MRU.ReadList();
76 m_mrucombo.ResetContent();
77 for(int i = 0; i < MRU.GetSize(); i++)
78 if(!MRU[i].IsEmpty())
79 m_mrucombo.AddString(MRU[i]);
80 CorrectComboListWidth(m_mrucombo, GetFont());
82 CRecentFileList& MRUDub = AfxGetAppSettings().MRUDub;
83 MRUDub.ReadList();
84 m_mrucombo2.ResetContent();
85 for(int i = 0; i < MRUDub.GetSize(); i++)
86 if(!MRUDub[i].IsEmpty())
87 m_mrucombo2.AddString(MRUDub[i]);
88 CorrectComboListWidth(m_mrucombo2, GetFont());
90 if(m_mrucombo.GetCount() > 0) m_mrucombo.SetCurSel(0);
92 AddAnchor(m_mrucombo, TOP_LEFT, TOP_RIGHT);
93 AddAnchor(m_mrucombo2, TOP_LEFT, TOP_RIGHT);
94 AddAnchor(IDC_BUTTON1, TOP_RIGHT);
95 AddAnchor(IDC_BUTTON2, TOP_RIGHT);
96 AddAnchor(IDOK, TOP_RIGHT);
97 AddAnchor(IDCANCEL, TOP_RIGHT);
98 AddAnchor(IDC_STATIC1, TOP_LEFT, TOP_RIGHT);
100 CRect r;
101 GetWindowRect(r);
102 CSize s = r.Size();
103 SetMinTrackSize(s);
104 s.cx = 1000;
105 SetMaxTrackSize(s);
107 return TRUE; // return TRUE unless you set the focus to a control
108 // EXCEPTION: OCX Property Pages should return FALSE
111 static CString GetFileName(CString str)
113 CPath p = str;
114 p.StripPath();
115 return (LPCTSTR)p;
118 void COpenDlg::OnBnClickedBrowsebutton()
120 UpdateData();
122 CString filter;
123 CAtlArray<CString> mask;
124 AfxGetAppSettings().Formats.GetFilter(filter, mask);
126 COpenFileDlg fd(mask, true, NULL, m_path,
127 OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ALLOWMULTISELECT|OFN_ENABLEINCLUDENOTIFY,
128 filter, this);
129 if(fd.DoModal() != IDOK) return;
131 m_fns.RemoveAll();
133 POSITION pos = fd.GetStartPosition();
134 while(pos)
137 CString str = fd.GetNextPathName(pos);
138 POSITION insertpos = m_fns.GetTailPosition();
139 while(insertpos && GetFileName(str).CompareNoCase(GetFileName(m_fns.GetAt(insertpos))) <= 0)
140 m_fns.GetPrev(insertpos);
141 if(!insertpos) m_fns.AddHead(str);
142 else m_fns.InsertAfter(insertpos, str);
144 m_fns.AddTail(fd.GetNextPathName(pos));
147 if(m_fns.GetCount() > 1
148 || m_fns.GetCount() == 1
149 && (m_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '\\'
150 || m_fns.GetHead()[m_fns.GetHead().GetLength()-1] == '*'))
152 m_fMultipleFiles = true;
153 EndDialog(IDOK);
154 return;
157 m_mrucombo.SetWindowText(fd.GetPathName());
160 void COpenDlg::OnBnClickedBrowsebutton2()
162 UpdateData();
164 CString filter;
165 CAtlArray<CString> mask;
166 AfxGetAppSettings().Formats.GetAudioFilter(filter, mask);
168 COpenFileDlg fd(mask, false, NULL, m_path2,
169 OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_ENABLEINCLUDENOTIFY,
170 filter, this);
172 if(fd.DoModal() != IDOK) return;
174 m_mrucombo2.SetWindowText(fd.GetPathName());
177 void COpenDlg::OnBnClickedOk()
179 UpdateData();
181 m_fns.RemoveAll();
182 m_fns.AddTail(m_path);
183 if(m_mrucombo2.IsWindowEnabled())
184 m_fns.AddTail(m_path2);
186 m_fMultipleFiles = false;
188 OnOK();
191 void COpenDlg::OnUpdateDub(CCmdUI* pCmdUI)
193 m_mrucombo.GetWindowText(m_path);
194 pCmdUI->Enable(AfxGetAppSettings().Formats.GetEngine(m_path) == DirectShow);