Fix naming.
[xy_vsfilter.git] / src / filters / transform / vsfilter / DirectVobSubPropPage.cpp
blobf7062b8e99d8c522e300a00c8cdf22b5abdb57cf
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 #include "stdafx.h"
23 #include <commdlg.h>
24 #include <afxdlgs.h>
25 #include "DirectVobSubFilter.h"
26 #include "DirectVobSubPropPage.h"
27 #include "VSFilter.h"
28 #include "StyleEditorDialog.h"
30 #include "../../../DSUtil/DSUtil.h"
31 #include "../../../DSUtil/MediaTypes.h"
33 BOOL WINAPI MyGetDialogSize(int iResourceID, DLGPROC pDlgProc, LPARAM lParam, SIZE* pResult)
35 HWND hwnd = CreateDialogParam(AfxGetResourceHandle(),
36 MAKEINTRESOURCE(iResourceID),
37 GetDesktopWindow(),
38 pDlgProc,
39 lParam);
41 if(hwnd == NULL) return FALSE;
43 RECT rc;
44 GetWindowRect(hwnd, &rc);
45 pResult->cx = rc.right - rc.left;
46 pResult->cy = rc.bottom - rc.top;
48 DestroyWindow(hwnd);
50 return TRUE;
53 STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo)
55 AFX_MANAGE_STATE(AfxGetStaticModuleState());
57 CString str;
58 if(!str.LoadString(m_TitleId)) return E_FAIL;
60 WCHAR wszTitle[STR_MAX_LENGTH];
61 #ifdef UNICODE
62 wcscpy(wszTitle, str);
63 #else
64 mbstowcs(wszTitle, str, str.GetLength()+1);
65 #endif
67 CheckPointer(pPageInfo, E_POINTER);
69 // Allocate dynamic memory for the property page title
71 LPOLESTR pszTitle;
72 HRESULT hr = AMGetWideString(wszTitle, &pszTitle);
73 if(FAILED(hr)) {NOTE("No caption memory"); return hr;}
75 pPageInfo->cb = sizeof(PROPPAGEINFO);
76 pPageInfo->pszTitle = pszTitle;
77 pPageInfo->pszDocString = NULL;
78 pPageInfo->pszHelpFile = NULL;
79 pPageInfo->dwHelpContext = 0;
80 // Set defaults in case GetDialogSize fails
81 pPageInfo->size.cx = 340;
82 pPageInfo->size.cy = 150;
84 MyGetDialogSize(m_DialogId, DialogProc, 0L, &pPageInfo->size);
86 return NOERROR;
89 STDMETHODIMP CDVSBasePPage::Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal)
91 AFX_MANAGE_STATE(AfxGetStaticModuleState());
93 CheckPointer(pRect,E_POINTER);
95 // Return failure if SetObject has not been called.
96 if (m_bObjectSet == FALSE) {
97 return E_UNEXPECTED;
100 if(m_hwnd) return E_UNEXPECTED;
102 m_hwnd = CreateDialogParam(AfxGetResourceHandle(), MAKEINTRESOURCE(m_DialogId), hwndParent, DialogProc, (LPARAM)this);
103 if(m_hwnd == NULL) return E_OUTOFMEMORY;
105 OnActivate();
106 Move(pRect);
107 return Show(SW_SHOWNORMAL);
110 /* CDVSBasePPage */
112 CDVSBasePPage::CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int TitleId) :
113 CBasePropertyPage(pName, lpunk, DialogId, TitleId),
114 m_bIsInitialized(FALSE),
115 m_fAttached(false),
116 m_fDisableInstantUpdate(false)
120 BOOL CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
122 switch(uMsg)
124 case WM_COMMAND:
126 if(m_bIsInitialized)
128 m_bDirty = TRUE;
129 if(m_pPageSite) m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
131 switch(HIWORD(wParam))
133 case BN_CLICKED:
134 case CBN_SELCHANGE:
135 case EN_CHANGE:
137 AFX_MANAGE_STATE(AfxGetStaticModuleState());
139 if(!m_fDisableInstantUpdate
140 && !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
141 && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1))
142 OnApplyChanges();
147 break;
149 case WM_NCDESTROY:
150 DetachControls();
151 break;
154 return OnMessage(uMsg, wParam, lParam)
155 ? 0
156 : CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
159 HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
161 if(!(m_pDirectVobSub = pUnknown)) return E_NOINTERFACE;
162 if(!(m_pDirectVobSubXy = pUnknown)) return E_NOINTERFACE;
164 m_pDirectVobSub->LockSubtitleReloader(true); // *
166 AFX_MANAGE_STATE(AfxGetStaticModuleState());
168 UpdateObjectData(false);
170 m_bIsInitialized = FALSE;
172 return NOERROR;
175 HRESULT CDVSBasePPage::OnDisconnect()
177 if(m_pDirectVobSub == NULL) return E_UNEXPECTED;
179 m_pDirectVobSub->LockSubtitleReloader(false); // *
181 // for some reason OnDisconnect() will be called twice, that's why we
182 // need to release m_pDirectVobSub manually on the first call to avoid
183 // a second "m_pDirectVobSub->LockSubtitleReloader(false);"
185 m_pDirectVobSub.Release();
187 return NOERROR;
190 HRESULT CDVSBasePPage::OnActivate()
192 ASSERT(m_pDirectVobSub);
194 AttachControls();
196 AFX_MANAGE_STATE(AfxGetStaticModuleState());
198 UpdateControlData(false);
200 m_bIsInitialized = TRUE;
202 return NOERROR;
205 HRESULT CDVSBasePPage::OnDeactivate()
207 ASSERT(m_pDirectVobSub);
209 AFX_MANAGE_STATE(AfxGetStaticModuleState());
211 UpdateControlData(true);
213 m_bIsInitialized = FALSE;
215 return NOERROR;
218 HRESULT CDVSBasePPage::OnApplyChanges()
220 ASSERT(m_pDirectVobSub);
222 AFX_MANAGE_STATE(AfxGetStaticModuleState());
224 if(m_bIsInitialized)
226 OnDeactivate();
227 UpdateObjectData(true);
228 m_pDirectVobSub->UpdateRegistry(); // *
229 OnActivate();
232 return NOERROR;
235 void CDVSBasePPage::AttachControls()
237 DetachControls();
239 AFX_MANAGE_STATE(AfxGetStaticModuleState());
241 POSITION pos = m_controls.GetStartPosition();
242 while(pos)
244 UINT id;
245 CWnd* pControl;
246 m_controls.GetNextAssoc(pos, id, pControl);
247 if(pControl)
249 BOOL fRet = pControl->Attach(GetDlgItem(m_Dlg, id));
250 ASSERT(fRet);
254 m_fAttached = true;
257 void CDVSBasePPage::DetachControls()
259 if(!m_fAttached) return;
261 AFX_MANAGE_STATE(AfxGetStaticModuleState());
263 POSITION pos = m_controls.GetStartPosition();
264 while(pos)
266 UINT id;
267 CWnd* pControl;
268 m_controls.GetNextAssoc(pos, id, pControl);
269 if(pControl) pControl->Detach();
272 m_fAttached = false;
275 void CDVSBasePPage::BindControl(UINT id, CWnd& control)
277 m_controls[id] = &control;
280 /* CDVSMainPPage */
282 CDVSMainPPage::CDVSMainPPage(LPUNKNOWN pUnk, HRESULT* phr) :
283 CDVSBasePPage(NAME("DirectVobSub Property Page (main)"), pUnk, IDD_DVSMAINPAGE, IDD_DVSMAINPAGE),
284 m_nLangs(0),
285 m_ppLangs(NULL)
287 BindControl(IDC_FILENAME, m_fnedit);
288 BindControl(IDC_LANGCOMBO, m_langs);
289 BindControl(IDC_OVERRIDEPLACEMENT, m_oplacement);
290 BindControl(IDC_SPIN1, m_subposx);
291 BindControl(IDC_SPIN2, m_subposy);
292 BindControl(IDC_FONT, m_font);
293 BindControl(IDC_ONLYSHOWFORCEDSUBS, m_forcedsubs);
294 BindControl(IDC_PARCOMBO, m_PARCombo);
295 BindControl(IDC_CHECKBOX_HideTrayIcon, m_hide_tray_icon);
298 CDVSMainPPage::~CDVSMainPPage()
300 FreeLangs();
303 void CDVSMainPPage::FreeLangs()
305 if(m_nLangs > 0 && m_ppLangs)
307 for(int i = 0; i < m_nLangs; i++) CoTaskMemFree(m_ppLangs[i]);
308 CoTaskMemFree(m_ppLangs);
309 m_nLangs = 0;
310 m_ppLangs = NULL;
314 void CDVSMainPPage::AllocLangs(int nLangs)
316 m_ppLangs = (WCHAR**)CoTaskMemRealloc(m_ppLangs, sizeof(WCHAR*)*nLangs);
317 m_nLangs = nLangs;
320 bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
322 switch(uMsg)
324 case WM_COMMAND:
326 switch(HIWORD(wParam))
328 case BN_CLICKED:
330 if(LOWORD(wParam) == IDC_OPEN)
332 AFX_MANAGE_STATE(AfxGetStaticModuleState());
334 CFileDialog fd(TRUE, NULL, NULL,
335 OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST,
336 _T(".idx .smi .sub .srt .psb .ssa .ass .usf .ssf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf;*.ssf|")
337 _T("All files (*.*)|*.*||"),
338 CDialog::FromHandle(m_Dlg), 0);
340 if(fd.DoModal() == IDOK)
342 m_fnedit.SetWindowText(fd.GetPathName());
345 return(true);
347 else if(LOWORD(wParam) == IDC_FONT)
349 AFX_MANAGE_STATE(AfxGetStaticModuleState());
351 CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
353 if(dlg.DoModal() == IDOK)
355 m_defStyle = dlg.m_stss;
356 CString str = m_defStyle.fontName;
357 if(str.GetLength() > 18) str = str.Left(16).TrimRight() + _T("...");
358 m_font.SetWindowText(str);
361 return(true);
364 break;
367 break;
370 return(false);
373 void CDVSMainPPage::UpdateObjectData(bool fSave)
375 if(fSave)
377 if(m_pDirectVobSub->put_FileName(m_fn) == S_OK)
379 int nLangs;
380 m_pDirectVobSub->get_LanguageCount(&nLangs);
381 AllocLangs(nLangs);
382 for(int i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
383 m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
386 m_pDirectVobSub->put_SelectedLanguage(m_iSelectedLanguage);
387 m_pDirectVobSub->put_Placement(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc);
388 m_pDirectVobSub->put_VobSubSettings(true, m_fOnlyShowForcedVobSubs, false);
389 m_pDirectVobSub->put_TextSettings(&m_defStyle);
390 m_pDirectVobSub->put_AspectRatioSettings(&m_ePARCompensationType);
391 m_pDirectVobSubXy->XySetBool(DirectVobSubXyOptions::BOOL_HIDE_TRAY_ICON, m_fHideTrayIcon);
393 else
395 m_pDirectVobSub->get_FileName(m_fn);
396 int nLangs;
397 m_pDirectVobSub->get_LanguageCount(&nLangs);
398 AllocLangs(nLangs);
399 for(int i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
400 m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
401 m_pDirectVobSub->get_Placement(&m_fOverridePlacement, &m_PlacementXperc, &m_PlacementYperc);
402 m_pDirectVobSub->get_VobSubSettings(NULL, &m_fOnlyShowForcedVobSubs, NULL);
403 m_pDirectVobSub->get_TextSettings(&m_defStyle);
404 m_pDirectVobSub->get_AspectRatioSettings(&m_ePARCompensationType);
405 m_pDirectVobSubXy->XyGetBool(DirectVobSubXyOptions::BOOL_HIDE_TRAY_ICON, &m_fHideTrayIcon);
409 void CDVSMainPPage::UpdateControlData(bool fSave)
411 if(fSave)
413 CString fn;
414 m_fnedit.GetWindowText(fn);
415 #ifdef UNICODE
416 wcscpy(m_fn, fn);
417 #else
418 mbstowcs(m_fn, fn, fn.GetLength()+1);
419 #endif
420 m_iSelectedLanguage = m_langs.GetCurSel();
421 m_fOverridePlacement = !!m_oplacement.GetCheck();
422 m_PlacementXperc = m_subposx.GetPos();
423 m_PlacementYperc = m_subposy.GetPos();
424 m_fOnlyShowForcedVobSubs = !!m_forcedsubs.GetCheck();
425 if (m_PARCombo.GetCurSel() != CB_ERR)
426 m_ePARCompensationType = static_cast<CSimpleTextSubtitle::EPARCompensationType>(m_PARCombo.GetItemData(m_PARCombo.GetCurSel()));
427 else
428 m_ePARCompensationType = CSimpleTextSubtitle::EPCTDisabled;
429 m_fHideTrayIcon = !!m_hide_tray_icon.GetCheck();
431 else
433 m_fnedit.SetWindowText(CString(m_fn));
434 m_oplacement.SetCheck(m_fOverridePlacement);
435 m_subposx.SetRange(-20, 120);
436 m_subposx.SetPos(m_PlacementXperc);
437 m_subposx.EnableWindow(m_fOverridePlacement);
438 m_subposy.SetRange(-20, 120);
439 m_subposy.SetPos(m_PlacementYperc);
440 m_subposy.EnableWindow(m_fOverridePlacement);
441 m_font.SetWindowText(m_defStyle.fontName);
442 m_forcedsubs.SetCheck(m_fOnlyShowForcedVobSubs);
443 m_langs.ResetContent();
444 m_langs.EnableWindow(m_nLangs > 0);
445 for(int i = 0; i < m_nLangs; i++) m_langs.AddString(CString(m_ppLangs[i]));
446 m_langs.SetCurSel(m_iSelectedLanguage);
448 m_PARCombo.ResetContent();
449 m_PARCombo.InsertString(0, ResStr(IDS_RT_PAR_DISABLED));
450 m_PARCombo.SetItemData(0, CSimpleTextSubtitle::EPCTDisabled);
451 if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDisabled)
452 m_PARCombo.SetCurSel(0);
454 m_PARCombo.InsertString(1, ResStr(IDS_RT_PAR_DOWNSCALE));
455 m_PARCombo.SetItemData(1, CSimpleTextSubtitle::EPCTDownscale);
456 if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTDownscale)
457 m_PARCombo.SetCurSel(1);
459 m_PARCombo.InsertString(2, ResStr(IDS_RT_PAR_UPSCALE));
460 m_PARCombo.SetItemData(2, CSimpleTextSubtitle::EPCTUpscale);
461 if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTUpscale)
462 m_PARCombo.SetCurSel(2);
464 m_PARCombo.InsertString(3, ResStr(IDS_RT_PAR_ACCURATE_SIZE));
465 m_PARCombo.SetItemData(3, CSimpleTextSubtitle::EPCTAccurateSize);
466 if (m_ePARCompensationType == CSimpleTextSubtitle::EPCTAccurateSize)
467 m_PARCombo.SetCurSel(3);
468 m_hide_tray_icon.SetCheck(m_fHideTrayIcon);
472 /* CDVSGeneralPPage */
474 CDVSGeneralPPage::CDVSGeneralPPage(LPUNKNOWN pUnk, HRESULT* phr) :
475 CDVSBasePPage(NAME("DirectVobSub Property Page (global settings)"), pUnk, IDD_DVSGENERALPAGE, IDD_DVSGENERALPAGE)
477 BindControl(IDC_VEREXTCOMBO, m_verext);
478 BindControl(IDC_MOD32FIX, m_mod32fix);
479 BindControl(IDC_RESX2COMBO, m_resx2);
480 BindControl(IDC_SPIN3, m_resx2w);
481 BindControl(IDC_SPIN4, m_resx2h);
482 BindControl(IDC_LOADCOMBO, m_load);
483 BindControl(IDC_EXTLOAD, m_extload);
484 BindControl(IDC_WEBLOAD, m_webload);
485 BindControl(IDC_EMBLOAD, m_embload);
488 bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
490 switch(uMsg)
492 case WM_COMMAND:
494 switch(HIWORD(wParam))
496 case CBN_SELCHANGE:
498 AFX_MANAGE_STATE(AfxGetStaticModuleState());
500 if(LOWORD(wParam) == IDC_RESX2COMBO)
502 m_resx2w.EnableWindow(m_resx2.GetCurSel() == 2);
503 m_resx2h.EnableWindow(m_resx2.GetCurSel() == 2);
504 return(true);
506 else if(LOWORD(wParam) == IDC_LOADCOMBO)
508 m_extload.EnableWindow(m_load.GetCurSel() == 1);
509 m_webload.EnableWindow(m_load.GetCurSel() == 1);
510 m_embload.EnableWindow(m_load.GetCurSel() == 1);
511 return(true);
514 break;
517 break;
520 return(false);
523 void CDVSGeneralPPage::UpdateObjectData(bool fSave)
525 if(fSave)
527 m_pDirectVobSub->put_ExtendPicture(m_HorExt, m_VerExt, m_ResX2, m_ResX2minw, m_ResX2minh);
528 m_pDirectVobSub->put_LoadSettings(m_LoadLevel, m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad);
530 else
532 m_pDirectVobSub->get_ExtendPicture(&m_HorExt, &m_VerExt, &m_ResX2, &m_ResX2minw, &m_ResX2minh);
533 m_pDirectVobSub->get_LoadSettings(&m_LoadLevel, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
537 void CDVSGeneralPPage::UpdateControlData(bool fSave)
539 if(fSave)
541 if(m_verext.GetCurSel() >= 0) m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
542 m_HorExt = !!m_mod32fix.GetCheck();
543 if(m_resx2.GetCurSel() >= 0) m_ResX2 = m_resx2.GetItemData(m_resx2.GetCurSel());
544 m_ResX2minw = m_resx2w.GetPos();
545 m_ResX2minh = m_resx2h.GetPos();
546 if(m_load.GetCurSel() >= 0) m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
547 m_fExternalLoad = !!m_extload.GetCheck();
548 m_fWebLoad = !!m_webload.GetCheck();
549 m_fEmbeddedLoad = !!m_embload.GetCheck();
551 else
553 m_verext.ResetContent();
554 m_verext.AddString(ResStr(IDS_ORGHEIGHT)); m_verext.SetItemData(0, 0);
555 m_verext.AddString(ResStr(IDS_EXTTO169)); m_verext.SetItemData(1, 1);
556 m_verext.AddString(ResStr(IDS_EXTTO43)); m_verext.SetItemData(2, 2);
557 m_verext.AddString(ResStr(IDS_EXTTO480)); m_verext.SetItemData(3, 3);
558 m_verext.AddString(ResStr(IDS_EXTTO576)); m_verext.SetItemData(4, 4);
559 m_verext.AddString(ResStr(IDS_CROPTO169)); m_verext.SetItemData(5, 0x81);
560 m_verext.AddString(ResStr(IDS_CROPTO43)); m_verext.SetItemData(6, 0x82);
561 m_verext.SetCurSel((m_VerExt&0x7f) + ((m_VerExt&0x80)?4:0));
562 m_mod32fix.SetCheck(m_HorExt&1);
563 m_resx2.ResetContent();
564 m_resx2.AddString(ResStr(IDS_ORGRES)); m_resx2.SetItemData(0, 0);
565 m_resx2.AddString(ResStr(IDS_DBLRES)); m_resx2.SetItemData(1, 1);
566 m_resx2.AddString(ResStr(IDS_DBLRESIF)); m_resx2.SetItemData(2, 2);
567 m_resx2.SetCurSel(m_ResX2);
568 m_resx2w.SetRange(0, 2048);
569 m_resx2w.SetPos(m_ResX2minw);
570 m_resx2w.EnableWindow(m_ResX2 == 2);
571 m_resx2h.SetRange(0, 2048);
572 m_resx2h.SetPos(m_ResX2minh);
573 m_resx2h.EnableWindow(m_ResX2 == 2);
574 m_load.ResetContent();
575 m_load.AddString(ResStr(IDS_DONOTLOAD)); m_load.SetItemData(0, 2);
576 m_load.AddString(ResStr(IDS_LOADWHENNEEDED)); m_load.SetItemData(1, 0);
577 m_load.AddString(ResStr(IDS_ALWAYSLOAD)); m_load.SetItemData(2, 1);
578 m_load.SetCurSel(!m_LoadLevel?1:m_LoadLevel==1?2:0);
579 m_extload.SetCheck(m_fExternalLoad);
580 m_webload.SetCheck(m_fWebLoad);
581 m_embload.SetCheck(m_fEmbeddedLoad);
582 m_extload.EnableWindow(m_load.GetCurSel() == 1);
583 m_webload.EnableWindow(m_load.GetCurSel() == 1);
584 m_embload.EnableWindow(m_load.GetCurSel() == 1);
588 /* CDVSMiscPPage */
590 CDVSMiscPPage::CDVSMiscPPage(LPUNKNOWN pUnk, HRESULT* phr) :
591 CDVSBasePPage(NAME("DirectVobSub Property Page (misc settings)"), pUnk, IDD_DVSMISCPAGE, IDD_DVSMISCPAGE)
593 BindControl(IDC_FLIP, m_flippic);
594 BindControl(IDC_FLIPSUB, m_flipsub);
595 BindControl(IDC_HIDE, m_hidesub);
596 BindControl(IDC_SHOWOSDSTATS, m_showosd);
597 //BindControl(IDC_PREBUFFERING, m_prebuff);
598 BindControl(IDC_COMBO_COLOR_SPACE, m_colorSpaceDropList);
599 BindControl(IDC_COMBO_YUV_RANGE, m_yuvRangeDropList);
600 BindControl(IDC_AUTORELOAD, m_autoreload);
601 BindControl(IDC_SAVEFULLPATH, m_savefullpath);
602 BindControl(IDC_INSTANTUPDATE, m_instupd);
605 bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
607 switch(uMsg)
609 case WM_COMMAND:
611 switch(HIWORD(wParam))
613 case BN_CLICKED:
615 if(LOWORD(wParam) == IDC_INSTANTUPDATE)
617 AFX_MANAGE_STATE(AfxGetStaticModuleState());
618 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
619 return(true);
622 break;
625 break;
628 return(false);
631 void CDVSMiscPPage::UpdateObjectData(bool fSave)
633 if(fSave)
635 m_pDirectVobSub->put_Flip(m_fFlipPicture, m_fFlipSubtitles);
636 m_pDirectVobSub->put_HideSubtitles(m_fHideSubtitles);
637 m_pDirectVobSub->put_OSD(m_fOSD);
638 m_pDirectVobSub->put_PreBuffering(m_fDoPreBuffering);
639 m_pDirectVobSubXy->XySetInt(DirectVobSubXyOptions::INT_COLOR_SPACE, m_colorSpace);
640 m_pDirectVobSubXy->XySetInt(DirectVobSubXyOptions::INT_YUV_RANGE, m_yuvRange);
641 m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled);
642 m_pDirectVobSub->put_SaveFullPath(m_fSaveFullPath);
644 else
646 m_pDirectVobSub->get_Flip(&m_fFlipPicture, &m_fFlipSubtitles);
647 m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles);
648 m_pDirectVobSub->get_OSD(&m_fOSD);
649 m_pDirectVobSub->get_PreBuffering(&m_fDoPreBuffering);
650 m_pDirectVobSubXy->XyGetInt(DirectVobSubXyOptions::INT_COLOR_SPACE, &m_colorSpace);
651 m_pDirectVobSubXy->XyGetInt(DirectVobSubXyOptions::INT_YUV_RANGE, &m_yuvRange);
652 m_pDirectVobSub->get_SubtitleReloader(&m_fReloaderDisabled);
653 m_pDirectVobSub->get_SaveFullPath(&m_fSaveFullPath);
657 void CDVSMiscPPage::UpdateControlData(bool fSave)
659 if(fSave)
661 m_fFlipPicture = !!m_flippic.GetCheck();
662 m_fFlipSubtitles = !!m_flipsub.GetCheck();
663 m_fHideSubtitles = !!m_hidesub.GetCheck();
664 m_fSaveFullPath = !!m_savefullpath.GetCheck();
665 //m_fDoPreBuffering = !!m_prebuff.GetCheck();
667 if (m_colorSpaceDropList.GetCurSel() != CB_ERR)
669 m_colorSpace = m_colorSpaceDropList.GetCurSel();
671 else
673 m_colorSpace = CDirectVobSub::YuvMatrix_AUTO;
676 if (m_yuvRangeDropList.GetCurSel() != CB_ERR)
678 m_yuvRange = m_yuvRangeDropList.GetCurSel();
680 else
682 m_yuvRange = CDirectVobSub::YuvRange_Auto;
685 m_fOSD = !!m_showosd.GetCheck();
686 m_fReloaderDisabled = !m_autoreload.GetCheck();
688 else
690 m_flippic.SetCheck(m_fFlipPicture);
691 m_flipsub.SetCheck(m_fFlipSubtitles);
692 m_hidesub.SetCheck(m_fHideSubtitles);
693 m_savefullpath.SetCheck(m_fSaveFullPath);
694 //m_prebuff.SetCheck(m_fDoPreBuffering);
696 //CString str;str.Format(_T("m_colorSpace:%d"),m_colorSpace);
697 if( m_colorSpace != CDirectVobSub::YuvMatrix_AUTO &&
698 m_colorSpace != CDirectVobSub::BT_601 &&
699 m_colorSpace != CDirectVobSub::BT_709 &&
700 m_colorSpace != CDirectVobSub::GUESS )
702 m_colorSpace = CDirectVobSub::YuvMatrix_AUTO;
704 m_colorSpaceDropList.ResetContent();
705 m_colorSpaceDropList.AddString( CString(_T("Auto")) );
706 m_colorSpaceDropList.SetItemData( CDirectVobSub::YuvMatrix_AUTO, CDirectVobSub::YuvMatrix_AUTO );
707 m_colorSpaceDropList.AddString( CString(_T("BT.601")) );
708 m_colorSpaceDropList.SetItemData( CDirectVobSub::BT_601, CDirectVobSub::BT_601 );
709 m_colorSpaceDropList.AddString( CString(_T("BT.709")) );
710 m_colorSpaceDropList.SetItemData( CDirectVobSub::BT_709, CDirectVobSub::BT_709);
711 m_colorSpaceDropList.AddString( CString(_T("Guess")) );
712 m_colorSpaceDropList.SetItemData( CDirectVobSub::GUESS, CDirectVobSub::GUESS );
713 m_colorSpaceDropList.SetCurSel( m_colorSpace );
715 if( m_yuvRange != CDirectVobSub::YuvRange_Auto &&
716 m_yuvRange != CDirectVobSub::YuvRange_PC &&
717 m_yuvRange != CDirectVobSub::YuvRange_TV )
719 m_yuvRange = CDirectVobSub::YuvRange_Auto;
721 m_yuvRangeDropList.ResetContent();
722 m_yuvRangeDropList.AddString( CString(_T("Auto")) );
723 m_yuvRangeDropList.SetItemData( CDirectVobSub::YuvRange_Auto, CDirectVobSub::YuvRange_Auto );
724 m_yuvRangeDropList.AddString( CString(_T("TV")) );
725 m_yuvRangeDropList.SetItemData( CDirectVobSub::YuvRange_TV, CDirectVobSub::YuvRange_TV );
726 m_yuvRangeDropList.AddString( CString(_T("PC")) );
727 m_yuvRangeDropList.SetItemData( CDirectVobSub::YuvRange_PC, CDirectVobSub::YuvRange_PC );
728 m_yuvRangeDropList.SetCurSel( m_yuvRange );
730 m_showosd.SetCheck(m_fOSD);
731 m_autoreload.SetCheck(!m_fReloaderDisabled);
732 m_instupd.SetCheck(!!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 1));
736 /* CDVSTimingPPage */
738 CDVSTimingPPage::CDVSTimingPPage(LPUNKNOWN pUnk, HRESULT* phr) :
739 CDVSBasePPage(NAME("DirectVobSub Timing Property Page"), pUnk, IDD_DVSTIMINGPAGE, IDD_DVSTIMINGPAGE)
741 BindControl(IDC_MODFPS, m_modfps);
742 BindControl(IDC_FPS, m_fps);
743 BindControl(IDC_SPIN5, m_subdelay);
744 BindControl(IDC_SPIN6, m_subspeedmul);
745 BindControl(IDC_SPIN9, m_subspeeddiv);
748 bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
750 switch(uMsg)
752 case WM_COMMAND:
754 switch(HIWORD(wParam))
756 case BN_CLICKED:
758 if(LOWORD(wParam) == IDC_MODFPS)
760 AFX_MANAGE_STATE(AfxGetStaticModuleState());
761 m_fps.EnableWindow(!!m_modfps.GetCheck());
762 return(true);
765 break;
768 break;
771 return(false);
774 void CDVSTimingPPage::UpdateObjectData(bool fSave)
776 if(fSave)
778 m_pDirectVobSub->put_SubtitleTiming(m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv);
779 m_pDirectVobSub->put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
781 else
783 m_pDirectVobSub->get_SubtitleTiming(&m_SubtitleDelay, &m_SubtitleSpeedMul, &m_SubtitleSpeedDiv);
784 m_pDirectVobSub->get_MediaFPS(&m_fMediaFPSEnabled, &m_MediaFPS);
788 void CDVSTimingPPage::UpdateControlData(bool fSave)
790 if(fSave)
792 m_fMediaFPSEnabled = !!m_modfps.GetCheck();
793 CString fpsstr;
794 m_fps.GetWindowText(fpsstr);
795 float fps;
796 if(_stscanf(fpsstr, _T("%f"), &fps) == 1) m_MediaFPS = fps;
797 #if _MFC_VER >= 0x0700
798 m_SubtitleDelay = m_subdelay.GetPos32();
799 m_SubtitleSpeedMul = m_subspeedmul.GetPos32();
800 m_SubtitleSpeedDiv = m_subspeeddiv.GetPos32();
801 #else
802 m_SubtitleDelay = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN5), UDM_GETPOS32, 0, 0);
803 m_SubtitleSpeedMul = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN6), UDM_GETPOS32, 0, 0);
804 m_SubtitleSpeedDiv = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN9), UDM_GETPOS32, 0, 0);
805 #endif
807 else
809 m_modfps.SetCheck(m_fMediaFPSEnabled);
810 CString fpsstr;
811 fpsstr.Format(_T("%.4f"), m_MediaFPS);
812 m_fps.SetWindowText(fpsstr);
813 m_fps.EnableWindow(m_fMediaFPSEnabled);
814 m_subdelay.SetRange32(-180*60*1000, 180*60*1000);
815 m_subspeedmul.SetRange32(0, 1000000);
816 m_subspeeddiv.SetRange32(1, 1000000);
817 #if _MFC_VER >= 0x0700
818 m_subdelay.SetPos32(m_SubtitleDelay);
819 m_subspeedmul.SetPos32(m_SubtitleSpeedMul);
820 m_subspeeddiv.SetPos32(m_SubtitleSpeedDiv);
821 #else
822 SendMessage(GetDlgItem(m_Dlg, IDC_SPIN5), UDM_SETPOS32, 0, (LPARAM)m_SubtitleDelay);
823 SendMessage(GetDlgItem(m_Dlg, IDC_SPIN6), UDM_SETPOS32, 0, (LPARAM)m_SubtitleSpeedMul);
824 SendMessage(GetDlgItem(m_Dlg, IDC_SPIN9), UDM_SETPOS32, 0, (LPARAM)m_SubtitleSpeedDiv);
825 #endif
829 /* CDVSMorePPage */
830 CDVSMorePPage::CDVSMorePPage(LPUNKNOWN pUnk, HRESULT* phr) :
831 CDVSBasePPage(NAME("DirectVobSub More Property Page"), pUnk, IDD_DVSMOREPAGE, IDD_DVSMOREPAGE)
833 BindControl(IDC_SPINPathCache, m_path_cache);
834 BindControl(IDC_SPINScanlineCache, m_scanline_cache);
835 BindControl(IDC_SPINOverlayNoBlurCache, m_overlay_no_blur_cache);
836 BindControl(IDC_SPINOverlayCache, m_overlay_cache);
837 BindControl(IDC_COMBO_SUBPIXEL_POS, m_combo_subpixel_pos);
839 BindControl(IDC_COMBO_LAYOUT_SIZE_OPT, m_combo_layout_size_opt);
840 BindControl(IDC_SPIN_LAYOUT_SIZE_X, m_layout_size_x);
841 BindControl(IDC_SPIN_LAYOUT_SIZE_Y, m_layout_size_y);
844 bool CDVSMorePPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
846 switch(uMsg)
848 case WM_COMMAND:
850 switch(HIWORD(wParam))
852 case BN_CLICKED:
854 if(LOWORD(wParam) == IDC_CACHES_INFO_BTN)
856 AFX_MANAGE_STATE(AfxGetStaticModuleState());
858 DirectVobSubXyOptions::CachesInfo *caches_info = NULL;
859 DirectVobSubXyOptions::XyFlyWeightInfo *xy_fw_info = NULL;
860 int tmp;
861 m_pDirectVobSubXy->XyGetBin(DirectVobSubXyOptions::BIN_CACHES_INFO, reinterpret_cast<LPVOID*>(&caches_info), &tmp);
862 m_pDirectVobSubXy->XyGetBin(DirectVobSubXyOptions::BIN_XY_FLY_WEIGHT_INFO, reinterpret_cast<LPVOID*>(&xy_fw_info), &tmp);
863 ASSERT(caches_info);
864 ASSERT(xy_fw_info);
865 CString msg;
866 msg.Format(
867 _T("Cache :stored_num/hit_count/query_count\n")\
868 _T(" Parser cache 1:%ld/%ld/%ld\n")\
869 _T(" Parser cache 2:%ld/%ld/%ld\n")\
870 _T("\n")\
871 _T(" LV 4:%ld/%ld/%ld\t\t")\
872 _T(" LV 3:%ld/%ld/%ld\n")\
873 _T(" LV 2:%ld/%ld/%ld\t\t")\
874 _T(" LV 1:%ld/%ld/%ld\n")\
875 _T(" LV 0:%ld/%ld/%ld\n")\
876 _T("\n")\
877 _T(" bitmap :%ld/%ld/%ld\t\t")\
878 _T(" scan line:%ld/%ld/%ld\n")\
879 _T(" relay key:%ld/%ld/%ld\t\t")\
880 _T(" clipper :%ld/%ld/%ld\n")\
881 _T("\n")\
882 _T(" FW string pool :%ld/%ld/%ld\t\t")\
883 _T(" FW bitmap key pool:%ld/%ld/%ld\n")\
885 caches_info->text_info_cache_cur_item_num, caches_info->text_info_cache_hit_count, caches_info->text_info_cache_query_count,
886 caches_info->word_info_cache_cur_item_num, caches_info->word_info_cache_hit_count, caches_info->word_info_cache_query_count,
887 caches_info->path_cache_cur_item_num, caches_info->path_cache_hit_count, caches_info->path_cache_query_count,
888 caches_info->scanline_cache2_cur_item_num, caches_info->scanline_cache2_hit_count, caches_info->scanline_cache2_query_count,
889 caches_info->non_blur_cache_cur_item_num, caches_info->non_blur_cache_hit_count, caches_info->non_blur_cache_query_count,
890 caches_info->overlay_cache_cur_item_num, caches_info->overlay_cache_hit_count, caches_info->overlay_cache_query_count,
891 caches_info->interpolate_cache_cur_item_num, caches_info->interpolate_cache_hit_count, caches_info->interpolate_cache_query_count,
892 caches_info->bitmap_cache_cur_item_num, caches_info->bitmap_cache_hit_count, caches_info->bitmap_cache_query_count,
893 caches_info->scanline_cache_cur_item_num, caches_info->scanline_cache_hit_count, caches_info->scanline_cache_query_count,
894 caches_info->overlay_key_cache_cur_item_num, caches_info->overlay_key_cache_hit_count, caches_info->overlay_key_cache_query_count,
895 caches_info->clipper_cache_cur_item_num, caches_info->clipper_cache_hit_count, caches_info->clipper_cache_query_count,
897 xy_fw_info->xy_fw_string_w.cur_item_num, xy_fw_info->xy_fw_string_w.hit_count, xy_fw_info->xy_fw_string_w.query_count,
898 xy_fw_info->xy_fw_grouped_draw_items_hash_key.cur_item_num, xy_fw_info->xy_fw_grouped_draw_items_hash_key.hit_count, xy_fw_info->xy_fw_grouped_draw_items_hash_key.query_count
900 MessageBox(
901 m_hwnd,
902 msg,
903 _T("Caches Info"),
904 MB_OK | MB_ICONINFORMATION | MB_APPLMODAL
906 delete []caches_info;
907 delete []xy_fw_info;
908 return(true);
911 break;
914 break;
916 return(false);
919 void CDVSMorePPage::UpdateObjectData(bool fSave)
921 if(fSave)
923 m_pDirectVobSubXy->XySetInt(DirectVobSubXyOptions::INT_OVERLAY_CACHE_MAX_ITEM_NUM, m_overlay_cache_max_item_num);
924 m_pDirectVobSubXy->XySetInt(DirectVobSubXyOptions::INT_OVERLAY_NO_BLUR_CACHE_MAX_ITEM_NUM, m_overlay_no_blur_cache_max_item_num);
925 m_pDirectVobSubXy->XySetInt(DirectVobSubXyOptions::INT_SCAN_LINE_DATA_CACHE_MAX_ITEM_NUM, m_scan_line_data_cache_max_item_num);
926 m_pDirectVobSubXy->XySetInt(DirectVobSubXyOptions::INT_PATH_DATA_CACHE_MAX_ITEM_NUM, m_path_cache_max_item_num);
927 m_pDirectVobSubXy->XySetInt(DirectVobSubXyOptions::INT_SUBPIXEL_POS_LEVEL, m_subpixel_pos_level);
929 m_pDirectVobSubXy->XySetInt(DirectVobSubXyOptions::INT_LAYOUT_SIZE_OPT, m_layout_size_opt);
930 m_pDirectVobSubXy->XySetSize(DirectVobSubXyOptions::SIZE_USER_SPECIFIED_LAYOUT_SIZE, m_layout_size);
932 else
934 m_pDirectVobSubXy->XyGetInt(DirectVobSubXyOptions::INT_OVERLAY_CACHE_MAX_ITEM_NUM, &m_overlay_cache_max_item_num);
935 m_pDirectVobSubXy->XyGetInt(DirectVobSubXyOptions::INT_OVERLAY_NO_BLUR_CACHE_MAX_ITEM_NUM, &m_overlay_no_blur_cache_max_item_num);
936 m_pDirectVobSubXy->XyGetInt(DirectVobSubXyOptions::INT_SCAN_LINE_DATA_CACHE_MAX_ITEM_NUM, &m_scan_line_data_cache_max_item_num);
937 m_pDirectVobSubXy->XyGetInt(DirectVobSubXyOptions::INT_PATH_DATA_CACHE_MAX_ITEM_NUM, &m_path_cache_max_item_num);
938 m_pDirectVobSubXy->XyGetInt(DirectVobSubXyOptions::INT_SUBPIXEL_POS_LEVEL, &m_subpixel_pos_level);
940 m_pDirectVobSubXy->XyGetInt(DirectVobSubXyOptions::INT_LAYOUT_SIZE_OPT, &m_layout_size_opt);
941 m_pDirectVobSubXy->XyGetSize(DirectVobSubXyOptions::SIZE_USER_SPECIFIED_LAYOUT_SIZE, &m_layout_size);
945 void CDVSMorePPage::UpdateControlData(bool fSave)
947 if(fSave)
949 m_overlay_cache_max_item_num = m_overlay_cache.GetPos32();
950 m_overlay_no_blur_cache_max_item_num = m_overlay_no_blur_cache.GetPos32();
951 m_scan_line_data_cache_max_item_num = m_scanline_cache.GetPos32();
952 m_path_cache_max_item_num = m_path_cache.GetPos32();
954 if (m_combo_subpixel_pos.GetCurSel() != CB_ERR)
956 m_subpixel_pos_level = m_combo_subpixel_pos.GetCurSel();
958 else
960 m_subpixel_pos_level = 0;
963 if (m_combo_layout_size_opt.GetCurSel() != CB_ERR)
965 m_layout_size_opt = m_combo_layout_size_opt.GetItemData(m_combo_layout_size_opt.GetCurSel());
967 else
969 m_layout_size_opt = DirectVobSubXyOptions::LAYOUT_SIZE_OPT_FOLLOW_ORIGINAL_VIDEO_SIZE;
971 m_layout_size.cx = m_layout_size_x.GetPos32();
972 m_layout_size.cy = m_layout_size_y.GetPos32();
974 else
976 m_overlay_cache.SetRange32(0, 2048);
977 m_overlay_no_blur_cache.SetRange32(0, 2048);
978 m_scanline_cache.SetRange32(0, 2048);
979 m_path_cache.SetRange32(0, 2048);
981 m_overlay_cache.SetPos32(m_overlay_cache_max_item_num);
982 m_overlay_no_blur_cache.SetPos32(m_overlay_no_blur_cache_max_item_num);
983 m_scanline_cache.SetPos32(m_scan_line_data_cache_max_item_num);
984 m_path_cache.SetPos32(m_path_cache_max_item_num);
986 int temp = m_subpixel_pos_level;
987 if(m_subpixel_pos_level < 0)
988 temp = 0;
989 else if ( m_subpixel_pos_level >= 5 )
990 temp = 4;
992 m_combo_subpixel_pos.ResetContent();
993 m_combo_subpixel_pos.AddString( CString(_T("NONE(fastest)")) );m_combo_subpixel_pos.SetItemData(0, 0);
994 m_combo_subpixel_pos.AddString( CString(_T("2x2")) );m_combo_subpixel_pos.SetItemData(1, 1);
995 m_combo_subpixel_pos.AddString( CString(_T("4x4")) );m_combo_subpixel_pos.SetItemData(2, 2);
996 m_combo_subpixel_pos.AddString( CString(_T("8x8(vsfilter2.39 default)")) );m_combo_subpixel_pos.SetItemData(3, 3);
997 m_combo_subpixel_pos.AddString( CString(_T("8x8(bilinear)")) );m_combo_subpixel_pos.SetItemData(4, 4);
999 m_combo_subpixel_pos.SetCurSel( temp );
1001 switch(m_layout_size_opt)
1003 default:
1004 case DirectVobSubXyOptions::LAYOUT_SIZE_OPT_FOLLOW_ORIGINAL_VIDEO_SIZE:
1005 temp = 0;
1006 break;
1007 case DirectVobSubXyOptions::LAYOUT_SIZE_OPT_USER_SPECIFIED:
1008 temp = 1;
1009 break;
1012 m_combo_layout_size_opt.ResetContent();
1013 m_combo_layout_size_opt.AddString( CString(_T("Use Original Video Size")) );
1014 m_combo_layout_size_opt.SetItemData(0, DirectVobSubXyOptions::LAYOUT_SIZE_OPT_FOLLOW_ORIGINAL_VIDEO_SIZE);
1015 m_combo_layout_size_opt.AddString( CString(_T("Customize ...")) );
1016 m_combo_layout_size_opt.SetItemData(1, DirectVobSubXyOptions::LAYOUT_SIZE_OPT_USER_SPECIFIED);
1017 m_combo_layout_size_opt.SetCurSel( temp );
1019 m_layout_size_x.SetRange32(1, 12800);
1020 m_layout_size_x.SetPos32(m_layout_size.cx);
1021 m_layout_size_y.SetRange32(1, 12800);
1022 m_layout_size_y.SetPos32(m_layout_size.cy);
1026 /* CDVSAboutPPage */
1028 CDVSAboutPPage::CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr) :
1029 CDVSBasePPage(NAME("About Property Page"), lpunk, IDD_DVSABOUTPAGE, IDD_DVSABOUTPAGE)
1034 bool CDVSAboutPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
1036 switch(uMsg) {
1037 case WM_INITDIALOG: {
1038 CStringA version_sha1_short = XY_VSFILTER_VERSION_COMMIT_SHA1;
1039 version_sha1_short = version_sha1_short.Left(7);
1040 CStringA version = XY_ABOUT_VERSION_STR;
1041 version.Format("DirectVobSub %s (git %s)\nxy-VSFilter\nCopyright 2001-2012 Yu Zhuohuang, Gabest et. al.",
1042 XY_ABOUT_VERSION_STR, version_sha1_short);
1044 SetDlgItemTextA( m_Dlg, IDC_VERSION, version.GetString() );
1045 break;
1049 return false;
1051 /* CDVSZoomPPage */
1053 CDVSZoomPPage::CDVSZoomPPage(LPUNKNOWN pUnk, HRESULT* phr) :
1054 CDVSBasePPage(NAME("DirectVobSub Zoom Property Page"), pUnk, IDD_DVSZOOMPAGE, IDD_DVSZOOMPAGE)
1056 BindControl(IDC_SPIN1, m_posx);
1057 BindControl(IDC_SPIN2, m_posy);
1058 BindControl(IDC_SPIN7, m_scalex);
1059 BindControl(IDC_SPIN8, m_scaley);
1062 bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
1064 switch(uMsg)
1066 case WM_COMMAND:
1068 switch(HIWORD(wParam))
1070 case EN_CHANGE:
1072 if(LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
1073 || LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8)
1075 AFX_MANAGE_STATE(AfxGetStaticModuleState());
1076 UpdateControlData(true);
1077 UpdateObjectData(true);
1078 return(true);
1082 break;
1085 break;
1088 return(false);
1091 void CDVSZoomPPage::UpdateControlData(bool fSave)
1093 if(fSave)
1095 m_rect.left = 1.0f * (short)m_posx.GetPos() / 100;
1096 m_rect.top = 1.0f * (short)m_posy.GetPos() / 100;
1097 m_rect.right = m_rect.left + 1.0f * (short)m_scalex.GetPos() / 100;
1098 m_rect.bottom = m_rect.top + 1.0f * (short)m_scaley.GetPos() / 100;
1100 else
1102 m_posx.SetRange(-100, 100);
1103 m_posx.SetPos((int)(m_rect.left*100));
1104 m_posy.SetRange(-100, 100);
1105 m_posy.SetPos((int)(m_rect.top*100));
1106 m_scalex.SetRange(-300, 300);
1107 m_scalex.SetPos((int)((m_rect.right-m_rect.left)*100));
1108 m_scaley.SetRange(-300, 300);
1109 m_scaley.SetPos((int)((m_rect.bottom-m_rect.top)*100));
1113 void CDVSZoomPPage::UpdateObjectData(bool fSave)
1115 if(fSave)
1117 m_pDirectVobSub->put_ZoomRect(&m_rect);
1119 else
1121 m_pDirectVobSub->get_ZoomRect(&m_rect);
1125 // TODO: Make CDVSColorPPage and CDVSPathsPPage use an interface on DirectVobSub instead of the registry to communicate
1127 /* CDVSColorPPage */
1129 CDVSColorPPage::CDVSColorPPage(LPUNKNOWN pUnk, HRESULT* phr)
1130 : CDVSBasePPage(NAME("DirectVobSub Color Property Page"), pUnk, IDD_DVSCOLORPAGE, IDD_DVSCOLORPAGE)
1131 , m_outputColorSpace(NULL)
1132 , m_inputColorSpace(NULL)
1134 BindControl(IDC_OUTPUT_FORMAT_LIST, m_outputFmtList);
1135 BindControl(IDC_INPUT_FORMAT_LIST, m_inputFmtList);
1136 BindControl(IDC_CHECK_FOLLOW_UPSTREAM, m_followUpstreamPreferredOrder);
1137 BindControl(IDC_COLORUP, m_btnColorUp);
1138 BindControl(IDC_COLORDOWN, m_btnColorDown);
1140 m_fDisableInstantUpdate = true;
1142 //donot know how to detect check event of CListCtrl's checkboxes
1143 //use this to false a update
1144 m_bDirty = true;
1147 bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
1149 switch(uMsg)
1151 case WM_COMMAND:
1153 switch(HIWORD(wParam))
1155 case BN_CLICKED:
1157 switch(LOWORD(wParam))
1159 case IDC_COLORUP:
1161 int sel = m_outputFmtList.GetSelectionMark();
1162 if(sel>0)
1164 CString str = m_outputFmtList.GetItemText(sel,0);
1165 int iPos = static_cast<int>(m_outputFmtList.GetItemData(sel));
1166 BOOL checked = m_outputFmtList.GetCheck(sel);
1167 m_outputFmtList.DeleteItem(sel);
1168 sel--;
1169 m_outputFmtList.InsertItem(sel, str);
1170 m_outputFmtList.SetItemData(sel, iPos);
1171 m_outputFmtList.SetItemState(sel, LVIS_SELECTED,LVIS_SELECTED);
1172 m_outputFmtList.SetCheck(sel, checked);
1173 m_outputFmtList.SetSelectionMark(sel);
1175 if(sel>=0 && sel < m_outputFmtList.GetItemCount())
1177 m_outputFmtList.SetFocus();
1179 return(true);
1181 case IDC_COLORDOWN:
1183 int sel = m_outputFmtList.GetSelectionMark();
1184 if(sel>=0 && sel < m_outputFmtList.GetItemCount()-1)
1186 CString str = m_outputFmtList.GetItemText(sel,0);
1187 int iPos = static_cast<int>(m_outputFmtList.GetItemData(sel));
1188 BOOL checked = m_outputFmtList.GetCheck(sel);
1189 m_outputFmtList.DeleteItem(sel);
1190 sel++;
1191 m_outputFmtList.InsertItem(sel, str);
1192 m_outputFmtList.SetItemData(sel, iPos);
1193 m_outputFmtList.SetItemState(sel, LVIS_SELECTED,LVIS_SELECTED);
1194 m_outputFmtList.SetCheck(sel, checked);
1195 m_outputFmtList.SetSelectionMark(sel);
1197 if(sel>=0 && sel < m_outputFmtList.GetItemCount())
1199 m_outputFmtList.SetFocus();
1201 return(true);
1203 case IDC_CHECK_FOLLOW_UPSTREAM:
1205 AFX_MANAGE_STATE(AfxGetStaticModuleState());
1206 m_btnColorUp.EnableWindow(!m_followUpstreamPreferredOrder.GetCheck());
1207 m_btnColorDown.EnableWindow(!m_followUpstreamPreferredOrder.GetCheck());
1208 return true;
1212 break;
1215 break;
1218 return(false);
1221 void CDVSColorPPage::UpdateObjectData(bool fSave)
1223 if(fSave)
1225 m_pDirectVobSubXy->XySetBool(DirectVobSubXyOptions::BOOL_FOLLOW_UPSTREAM_PREFERRED_ORDER, m_fFollowUpstream);
1226 m_pDirectVobSubXy->XySetBin(DirectVobSubXyOptions::BIN_OUTPUT_COLOR_FORMAT, m_outputColorSpace, m_outputColorSpaceCount);
1227 m_pDirectVobSubXy->XySetBin(DirectVobSubXyOptions::BIN_INPUT_COLOR_FORMAT, m_inputColorSpace, m_inputColorSpaceCount);
1229 else
1231 delete []m_outputColorSpace; m_outputColorSpace=NULL;
1232 delete []m_inputColorSpace; m_inputColorSpace=NULL;
1233 m_pDirectVobSubXy->XyGetBool(DirectVobSubXyOptions::BOOL_FOLLOW_UPSTREAM_PREFERRED_ORDER, &m_fFollowUpstream);
1234 m_pDirectVobSubXy->XyGetBin(DirectVobSubXyOptions::BIN_OUTPUT_COLOR_FORMAT, reinterpret_cast<LPVOID*>(&m_outputColorSpace), &m_outputColorSpaceCount);
1235 m_pDirectVobSubXy->XyGetBin(DirectVobSubXyOptions::BIN_INPUT_COLOR_FORMAT, reinterpret_cast<LPVOID*>(&m_inputColorSpace), &m_inputColorSpaceCount);
1239 void CDVSColorPPage::UpdateControlData(bool fSave)
1241 if(fSave)
1243 if(m_outputFmtList.GetItemCount() == m_outputColorSpaceCount)
1245 for(int i = 0; i < m_outputColorSpaceCount; i++)
1247 m_outputColorSpace[i].color_space = static_cast<ColorSpaceId>(m_outputFmtList.GetItemData(i));
1248 m_outputColorSpace[i].selected = static_cast<bool>(m_outputFmtList.GetCheck(i));
1251 else ASSERT(0);
1252 if(m_inputFmtList.GetItemCount() == m_inputColorSpaceCount)
1254 for(int i = 0; i < m_inputColorSpaceCount; i++)
1256 m_inputColorSpace[i].color_space = static_cast<ColorSpaceId>(m_inputFmtList.GetItemData(i));
1257 m_inputColorSpace[i].selected = static_cast<bool>(m_inputFmtList.GetCheck(i));
1260 else ASSERT(0);
1262 m_fFollowUpstream = !!m_followUpstreamPreferredOrder.GetCheck();
1264 else
1266 m_followUpstreamPreferredOrder.SetCheck(m_fFollowUpstream);
1267 m_btnColorUp.EnableWindow(!m_fFollowUpstream);
1268 m_btnColorDown.EnableWindow(!m_fFollowUpstream);
1270 m_outputFmtList.ShowScrollBar(SB_HORZ, FALSE);
1271 m_outputFmtList.DeleteAllItems();
1272 m_outputFmtList.DeleteColumn(0);
1273 m_outputFmtList.SetExtendedStyle( (m_outputFmtList.GetStyle()|LVS_EX_CHECKBOXES) & ~LVS_EX_GRIDLINES );
1274 m_outputFmtList.InsertColumn(0, _T("output"), LVCFMT_LEFT, 110);
1275 for(int i = 0; i < static_cast<int>(m_outputColorSpaceCount); i++)
1277 m_outputFmtList.InsertItem(i, GetColorSpaceName(m_outputColorSpace[i].color_space,OUTPUT_COLOR_SPACE));
1278 m_outputFmtList.SetItemData(i, m_outputColorSpace[i].color_space);
1279 m_outputFmtList.SetCheck(i, static_cast<BOOL>(m_outputColorSpace[i].selected));
1282 m_inputFmtList.ShowScrollBar(SB_HORZ, FALSE);
1283 m_inputFmtList.DeleteAllItems();
1284 m_inputFmtList.DeleteColumn(0);
1285 m_inputFmtList.SetExtendedStyle(m_inputFmtList.GetStyle()|LVS_EX_CHECKBOXES);
1286 m_inputFmtList.InsertColumn(0, _T("input"), LVCFMT_LEFT, 150);
1287 for(int i = 0; i < static_cast<int>(m_inputColorSpaceCount); i++)
1289 m_inputFmtList.InsertItem(i, GetColorSpaceName(m_inputColorSpace[i].color_space,INPUT_COLOR_SPACE));
1290 m_inputFmtList.SetItemData(i, m_inputColorSpace[i].color_space);
1291 m_inputFmtList.SetCheck(i, static_cast<BOOL>(m_inputColorSpace[i].selected));
1296 CDVSColorPPage::~CDVSColorPPage()
1298 delete []m_outputColorSpace;
1299 delete []m_inputColorSpace;
1302 /* CDVSPathsPPage */
1304 CDVSPathsPPage::CDVSPathsPPage(LPUNKNOWN pUnk, HRESULT* phr) :
1305 CDVSBasePPage(NAME("DirectVobSub Paths Property Page"), pUnk, IDD_DVSPATHSPAGE, IDD_DVSPATHSPAGE)
1307 BindControl(IDC_PATHLIST, m_pathlist);
1308 BindControl(IDC_PATHEDIT, m_path);
1309 BindControl(IDC_BROWSE, m_browse);
1310 BindControl(IDC_REMOVE, m_remove);
1311 BindControl(IDC_ADD, m_add);
1313 m_fDisableInstantUpdate = true;
1316 bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
1318 switch(uMsg)
1320 case WM_COMMAND:
1322 switch(HIWORD(wParam))
1324 case LBN_SELCHANGE:
1325 if((HWND)lParam == m_pathlist.m_hWnd)
1327 int i = m_pathlist.GetCurSel();
1328 m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
1329 if(i >= 0)
1331 CString path;
1332 m_pathlist.GetText(i, path);
1333 m_path.SetWindowText(path);
1335 return(true);
1337 break;
1339 case LBN_SELCANCEL:
1340 if((HWND)lParam == m_pathlist.m_hWnd)
1342 m_remove.EnableWindow(FALSE);
1343 return(true);
1345 break;
1347 case BN_CLICKED:
1349 switch(LOWORD(wParam))
1351 case IDC_BROWSE:
1353 TCHAR pathbuff[MAX_PATH];
1355 BROWSEINFO bi;
1356 bi.hwndOwner = m_Dlg;
1357 bi.pidlRoot = NULL;
1358 bi.pszDisplayName = pathbuff;
1359 bi.lpszTitle = _T("");
1360 bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI;
1361 bi.lpfn = NULL;
1362 bi.lParam = 0;
1363 bi.iImage = 0;
1365 LPITEMIDLIST iil;
1366 if(iil = SHBrowseForFolder(&bi))
1368 SHGetPathFromIDList(iil, pathbuff);
1369 m_path.SetWindowText(pathbuff);
1372 return(true);
1374 break;
1376 case IDC_REMOVE:
1378 int i = m_pathlist.GetCurSel();
1379 if(i >= 0)
1381 m_pathlist.DeleteString(i);
1382 i = min(i, m_pathlist.GetCount()-1);
1383 if(i >= 0 && m_pathlist.GetCount() > 0)
1385 m_pathlist.SetCurSel(i);
1386 m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
1390 return(true);
1392 break;
1394 case IDC_ADD:
1396 CString path;
1397 m_path.GetWindowText(path);
1398 if(!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0)
1399 m_pathlist.AddString(path);
1401 return(true);
1403 break;
1406 break;
1409 break;
1412 return(false);
1415 void CDVSPathsPPage::UpdateObjectData(bool fSave)
1417 if(fSave)
1419 CString chk(_T("123456789")), path, tmp;
1420 int i = 0;
1423 tmp.Format(ResStr(IDS_RP_PATH), i++);
1424 path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
1425 if(path != chk) theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
1427 while(path != chk);
1429 for(i = 0; i < m_paths.GetSize(); i++)
1431 tmp.Format(ResStr(IDS_RP_PATH), i);
1432 theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, m_paths[i]);
1435 else
1437 CString chk(_T("123456789")), path, tmp;
1438 int i = 0;
1441 if(!path.IsEmpty()) m_paths.Add(path);
1442 tmp.Format(ResStr(IDS_RP_PATH), i++);
1443 path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
1445 while(path != chk);
1449 void CDVSPathsPPage::UpdateControlData(bool fSave)
1451 if(fSave)
1453 m_paths.RemoveAll();
1454 for(int i = 0; i < m_pathlist.GetCount(); i++)
1456 CString path;
1457 m_pathlist.GetText(i, path);
1458 m_paths.Add(path);
1461 else
1463 m_pathlist.ResetContent();
1464 for(int i = 0; i < m_paths.GetSize(); i++)
1465 m_pathlist.AddString(m_paths[i]);
1467 m_remove.EnableWindow(FALSE);
1468 m_add.EnableWindow(TRUE);