X64 transport [Part 5] (Update plugins.cpp)
[xy_vsfilter.git] / src / apps / mplayerc / SubtitleDlDlg.cpp
blobbdf4d0609f3e8b420e40d4827669a4e5b4f79856
1 // SubtitleDlDlg.cpp : implementation file
2 //
4 #include "stdafx.h"
5 #include "mplayerc.h"
6 #include "SubtitleDlDlg.h"
9 // CSubtitleDlDlg dialog
11 //IMPLEMENT_DYNAMIC(CSubtitleDlDlg, CResizableDialog)
12 CSubtitleDlDlg::CSubtitleDlDlg(CList<isdb_movie>& movies, CWnd* pParent /*=NULL*/)
13 : CResizableDialog(CSubtitleDlDlg::IDD, pParent)
15 m_movies.AddTail(&movies);
18 CSubtitleDlDlg::~CSubtitleDlDlg()
22 int CSubtitleDlDlg::GetChecked(int iItem)
24 LVITEM lvi;
25 lvi.iItem = iItem;
26 lvi.iSubItem = 0;
27 lvi.mask = LVIF_IMAGE;
28 m_list.GetItem(&lvi);
29 return(lvi.iImage);
32 void CSubtitleDlDlg::SetChecked(int iItem, int iChecked)
34 LVITEM lvi;
35 lvi.iItem = iItem;
36 lvi.iSubItem = 0;
37 lvi.mask = LVIF_IMAGE;
38 lvi.iImage = iChecked;
39 m_list.SetItem(&lvi);
42 void CSubtitleDlDlg::DoDataExchange(CDataExchange* pDX)
44 __super::DoDataExchange(pDX);
45 DDX_Control(pDX, IDC_LIST1, m_list);
49 BEGIN_MESSAGE_MAP(CSubtitleDlDlg, CResizableDialog)
50 ON_NOTIFY(NM_CLICK, IDC_LIST1, OnNMClickList1)
51 ON_UPDATE_COMMAND_UI(IDOK, OnUpdateOk)
52 END_MESSAGE_MAP()
54 // CSubtitleDlDlg message handlers
56 BOOL CSubtitleDlDlg::OnInitDialog()
58 __super::OnInitDialog();
61 AddAnchor(IDC_LIST1, TOP_LEFT, BOTTOM_RIGHT);
62 AddAnchor(IDC_CHECK1, BOTTOM_LEFT);
63 AddAnchor(IDOK, BOTTOM_RIGHT);
65 CSize s(200, 150);
66 SetMinTrackSize(s);
69 m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT);
71 m_list.InsertColumn(COL_FILENAME, _T("File"), LVCFMT_LEFT, 160);
72 m_list.InsertColumn(COL_LANGUAGE, _T("Language"), LVCFMT_CENTER, 80);
73 m_list.InsertColumn(COL_FORMAT, _T("Format"), LVCFMT_CENTER, 50);
74 m_list.InsertColumn(COL_DISC, _T("Disc"), LVCFMT_CENTER, 50);
75 m_list.InsertColumn(COL_TITLES, _T("Title(s)"), LVCFMT_LEFT, 300);
77 m_onoff.Create(IDB_ONOFF, 12, 3, 0xffffff);
78 m_list.SetImageList(&m_onoff, LVSIL_SMALL);
81 int i = 0;
83 POSITION pos = m_movies.GetHeadPosition();
84 while(pos)
86 isdb_movie& m = m_movies.GetNext(pos);
88 CStringA titlesA = Implode(m.titles, '|');
89 titlesA.Replace("|", ", ");
90 CString titles = UTF8To16(titlesA);
92 POSITION pos2 = m.subs.GetHeadPosition();
93 while(pos2)
95 isdb_subtitle& s = m.subs.GetNext(pos2);
96 CString name = UTF8To16(s.name);
97 CString language = s.language;
98 CString format = s.format;
99 CString disc;
100 disc.Format(_T("%d/%d"), s.disc_no, s.discs);
102 int iItem = m_list.InsertItem(i++, _T(""));
103 m_list.SetItemData(iItem, (DWORD_PTR)&s);
104 m_list.SetItemText(iItem, COL_FILENAME, name);
105 m_list.SetItemText(iItem, COL_LANGUAGE, language);
106 m_list.SetItemText(iItem, COL_FORMAT, format);
107 m_list.SetItemText(iItem, COL_DISC, disc);
108 m_list.SetItemText(iItem, COL_TITLES, titles);
112 m_selsubs.RemoveAll();
114 return TRUE; // return TRUE unless you set the focus to a control
115 // EXCEPTION: OCX Property Pages should return FALSE
118 void CSubtitleDlDlg::OnOK()
120 for(int i = 0; i < m_list.GetItemCount(); i++)
121 if(GetChecked(i))
122 m_selsubs.AddTail(*(isdb_subtitle*)m_list.GetItemData(i));
124 m_fReplaceSubs = IsDlgButtonChecked(IDC_CHECK1) == BST_CHECKED;
126 __super::OnOK();
129 void CSubtitleDlDlg::OnNMClickList1(NMHDR *pNMHDR, LRESULT *pResult)
131 LPNMLISTVIEW lpnmlv = (LPNMLISTVIEW)pNMHDR;
133 if(lpnmlv->iItem >= 0)
135 CRect r;
136 m_list.GetItemRect(lpnmlv->iItem, r, LVIR_ICON);
137 if(r.PtInRect(lpnmlv->ptAction))
139 SetChecked(lpnmlv->iItem, (GetChecked(lpnmlv->iItem)&1) == 0 ? 1 : 0);
143 *pResult = 0;
146 void CSubtitleDlDlg::OnUpdateOk(CCmdUI* pCmdUI)
148 bool fEnable = false;
149 for(int i = 0; !fEnable && i < m_list.GetItemCount(); i++)
150 fEnable = !!GetChecked(i);
152 pCmdUI->Enable(fEnable);