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)
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
25 #include "DirectVobSubFilter.h"
26 #include "DirectVobSubPropPage.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
),
41 if(hwnd
== NULL
) return FALSE
;
44 GetWindowRect(hwnd
, &rc
);
45 pResult
->cx
= rc
.right
- rc
.left
;
46 pResult
->cy
= rc
.bottom
- rc
.top
;
53 STDMETHODIMP
CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo
)
55 AFX_MANAGE_STATE(AfxGetStaticModuleState());
58 if(!str
.LoadString(m_TitleId
)) return E_FAIL
;
60 WCHAR wszTitle
[STR_MAX_LENGTH
];
62 wcscpy(wszTitle
, str
);
64 mbstowcs(wszTitle
, str
, str
.GetLength()+1);
67 CheckPointer(pPageInfo
, E_POINTER
);
69 // Allocate dynamic memory for the property page title
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
);
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) {
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
;
107 return Show(SW_SHOWNORMAL
);
112 CDVSBasePPage::CDVSBasePPage(TCHAR
* pName
, LPUNKNOWN lpunk
, int DialogId
, int TitleId
) :
113 CBasePropertyPage(pName
, lpunk
, DialogId
, TitleId
),
114 m_bIsInitialized(FALSE
),
116 m_fDisableInstantUpdate(false)
120 BOOL
CDVSBasePPage::OnReceiveMessage(HWND hwnd
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
129 if(m_pPageSite
) m_pPageSite
->OnStatusChange(PROPPAGESTATUS_DIRTY
);
131 switch(HIWORD(wParam
))
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))
154 return OnMessage(uMsg
, wParam
, lParam
)
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
;
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();
190 HRESULT
CDVSBasePPage::OnActivate()
192 ASSERT(m_pDirectVobSub
);
196 AFX_MANAGE_STATE(AfxGetStaticModuleState());
198 UpdateControlData(false);
200 m_bIsInitialized
= TRUE
;
205 HRESULT
CDVSBasePPage::OnDeactivate()
207 ASSERT(m_pDirectVobSub
);
209 AFX_MANAGE_STATE(AfxGetStaticModuleState());
211 UpdateControlData(true);
213 m_bIsInitialized
= FALSE
;
218 HRESULT
CDVSBasePPage::OnApplyChanges()
220 ASSERT(m_pDirectVobSub
);
222 AFX_MANAGE_STATE(AfxGetStaticModuleState());
227 UpdateObjectData(true);
228 m_pDirectVobSub
->UpdateRegistry(); // *
235 void CDVSBasePPage::AttachControls()
239 AFX_MANAGE_STATE(AfxGetStaticModuleState());
241 POSITION pos
= m_controls
.GetStartPosition();
246 m_controls
.GetNextAssoc(pos
, id
, pControl
);
249 BOOL fRet
= pControl
->Attach(GetDlgItem(m_Dlg
, id
));
257 void CDVSBasePPage::DetachControls()
259 if(!m_fAttached
) return;
261 AFX_MANAGE_STATE(AfxGetStaticModuleState());
263 POSITION pos
= m_controls
.GetStartPosition();
268 m_controls
.GetNextAssoc(pos
, id
, pControl
);
269 if(pControl
) pControl
->Detach();
275 void CDVSBasePPage::BindControl(UINT id
, CWnd
& control
)
277 m_controls
[id
] = &control
;
282 CDVSMainPPage::CDVSMainPPage(LPUNKNOWN pUnk
, HRESULT
* phr
) :
283 CDVSBasePPage(NAME("DirectVobSub Property Page (main)"), pUnk
, IDD_DVSMAINPAGE
, IDD_DVSMAINPAGE
),
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()
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
);
314 void CDVSMainPPage::AllocLangs(int nLangs
)
316 m_ppLangs
= (WCHAR
**)CoTaskMemRealloc(m_ppLangs
, sizeof(WCHAR
*)*nLangs
);
320 bool CDVSMainPPage::OnMessage(UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
326 switch(HIWORD(wParam
))
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());
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
);
373 void CDVSMainPPage::UpdateObjectData(bool fSave
)
377 if(m_pDirectVobSub
->put_FileName(m_fn
) == S_OK
)
380 m_pDirectVobSub
->get_LanguageCount(&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
);
395 m_pDirectVobSub
->get_FileName(m_fn
);
397 m_pDirectVobSub
->get_LanguageCount(&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
)
414 m_fnedit
.GetWindowText(fn
);
418 mbstowcs(m_fn
, fn
, fn
.GetLength()+1);
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()));
428 m_ePARCompensationType
= CSimpleTextSubtitle::EPCTDisabled
;
429 m_fHideTrayIcon
= !!m_hide_tray_icon
.GetCheck();
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
)
494 switch(HIWORD(wParam
))
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);
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);
523 void CDVSGeneralPPage::UpdateObjectData(bool 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
);
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
)
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();
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);
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
)
611 switch(HIWORD(wParam
))
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());
631 void CDVSMiscPPage::UpdateObjectData(bool 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
);
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
)
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();
673 m_colorSpace
= CDirectVobSub::YuvMatrix_AUTO
;
676 if (m_yuvRangeDropList
.GetCurSel() != CB_ERR
)
678 m_yuvRange
= m_yuvRangeDropList
.GetCurSel();
682 m_yuvRange
= CDirectVobSub::YuvRange_Auto
;
685 m_fOSD
= !!m_showosd
.GetCheck();
686 m_fReloaderDisabled
= !m_autoreload
.GetCheck();
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
)
754 switch(HIWORD(wParam
))
758 if(LOWORD(wParam
) == IDC_MODFPS
)
760 AFX_MANAGE_STATE(AfxGetStaticModuleState());
761 m_fps
.EnableWindow(!!m_modfps
.GetCheck());
774 void CDVSTimingPPage::UpdateObjectData(bool fSave
)
778 m_pDirectVobSub
->put_SubtitleTiming(m_SubtitleDelay
, m_SubtitleSpeedMul
, m_SubtitleSpeedDiv
);
779 m_pDirectVobSub
->put_MediaFPS(m_fMediaFPSEnabled
, m_MediaFPS
);
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
)
792 m_fMediaFPSEnabled
= !!m_modfps
.GetCheck();
794 m_fps
.GetWindowText(fpsstr
);
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();
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);
809 m_modfps
.SetCheck(m_fMediaFPSEnabled
);
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
);
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
);
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
)
850 switch(HIWORD(wParam
))
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
;
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
);
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")\
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")\
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")\
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
904 MB_OK
| MB_ICONINFORMATION
| MB_APPLMODAL
906 delete []caches_info
;
919 void CDVSMorePPage::UpdateObjectData(bool 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
);
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
)
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();
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());
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();
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)
989 else if ( m_subpixel_pos_level
>= 5 )
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
)
1004 case DirectVobSubXyOptions::LAYOUT_SIZE_OPT_FOLLOW_ORIGINAL_VIDEO_SIZE
:
1007 case DirectVobSubXyOptions::LAYOUT_SIZE_OPT_USER_SPECIFIED
:
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
)
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() );
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
)
1068 switch(HIWORD(wParam
))
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);
1091 void CDVSZoomPPage::UpdateControlData(bool 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;
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
)
1117 m_pDirectVobSub
->put_ZoomRect(&m_rect
);
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
1147 bool CDVSColorPPage::OnMessage(UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
1153 switch(HIWORD(wParam
))
1157 switch(LOWORD(wParam
))
1161 int sel
= m_outputFmtList
.GetSelectionMark();
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
);
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();
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
);
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();
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());
1221 void CDVSColorPPage::UpdateObjectData(bool 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
);
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
)
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
));
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
));
1262 m_fFollowUpstream
= !!m_followUpstreamPreferredOrder
.GetCheck();
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
)
1322 switch(HIWORD(wParam
))
1325 if((HWND
)lParam
== m_pathlist
.m_hWnd
)
1327 int i
= m_pathlist
.GetCurSel();
1328 m_remove
.EnableWindow(i
>= 3 ? TRUE
: FALSE
);
1332 m_pathlist
.GetText(i
, path
);
1333 m_path
.SetWindowText(path
);
1340 if((HWND
)lParam
== m_pathlist
.m_hWnd
)
1342 m_remove
.EnableWindow(FALSE
);
1349 switch(LOWORD(wParam
))
1353 TCHAR pathbuff
[MAX_PATH
];
1356 bi
.hwndOwner
= m_Dlg
;
1358 bi
.pszDisplayName
= pathbuff
;
1359 bi
.lpszTitle
= _T("");
1360 bi
.ulFlags
= BIF_RETURNONLYFSDIRS
| BIF_EDITBOX
| BIF_VALIDATE
| BIF_USENEWUI
;
1366 if(iil
= SHBrowseForFolder(&bi
))
1368 SHGetPathFromIDList(iil
, pathbuff
);
1369 m_path
.SetWindowText(pathbuff
);
1378 int i
= m_pathlist
.GetCurSel();
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
);
1397 m_path
.GetWindowText(path
);
1398 if(!path
.IsEmpty() && m_pathlist
.FindString(-1, path
) < 0)
1399 m_pathlist
.AddString(path
);
1415 void CDVSPathsPPage::UpdateObjectData(bool fSave
)
1419 CString
chk(_T("123456789")), path
, tmp
;
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(""));
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
]);
1437 CString
chk(_T("123456789")), path
, tmp
;
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
);
1449 void CDVSPathsPPage::UpdateControlData(bool fSave
)
1453 m_paths
.RemoveAll();
1454 for(int i
= 0; i
< m_pathlist
.GetCount(); i
++)
1457 m_pathlist
.GetText(i
, path
);
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
);