DirectVobSubPropPage.cpp

00001 /* 
00002  *      Copyright (C) 2003-2005 Gabest
00003  *      http://www.gabest.org
00004  *
00005  *  This Program is free software; you can redistribute it and/or modify
00006  *  it under the terms of the GNU General Public License as published by
00007  *  the Free Software Foundation; either version 2, or (at your option)
00008  *  any later version.
00009  *   
00010  *  This Program is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013  *  GNU General Public License for more details.
00014  *   
00015  *  You should have received a copy of the GNU General Public License
00016  *  along with GNU Make; see the file COPYING.  If not, write to
00017  *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. 
00018  *  http://www.gnu.org/copyleft/gpl.html
00019  *
00020  */
00021 
00022 #include "stdafx.h"
00023 #include <commdlg.h>
00024 #include <afxdlgs.h>
00025 #include "DirectVobSubFilter.h"
00026 #include "DirectVobSubPropPage.h"
00027 #include "VSFilter.h"
00028 #include "StyleEditorDialog.h"
00029 
00030 #include "..\..\..\DSUtil\DSUtil.h"
00031 #include "..\..\..\DSUtil\MediaTypes.h"
00032 
00033 BOOL WINAPI MyGetDialogSize(int iResourceID, DLGPROC pDlgProc, LPARAM lParam, SIZE* pResult)
00034 {
00035     HWND hwnd = CreateDialogParam(AfxGetResourceHandle(),
00036         MAKEINTRESOURCE(iResourceID),
00037         GetDesktopWindow(),
00038         pDlgProc,
00039         lParam);
00040     
00041         if(hwnd == NULL) return FALSE;
00042 
00043     RECT rc;
00044     GetWindowRect(hwnd, &rc);
00045     pResult->cx = rc.right - rc.left;
00046     pResult->cy = rc.bottom - rc.top;
00047 
00048     DestroyWindow(hwnd);
00049 
00050     return TRUE;
00051 }
00052 
00053 STDMETHODIMP CDVSBasePPage::GetPageInfo(LPPROPPAGEINFO pPageInfo)
00054 {
00055         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00056 
00057         CString str;
00058         if(!str.LoadString(m_TitleId)) return E_FAIL;
00059 
00060         WCHAR wszTitle[STR_MAX_LENGTH];
00061 #ifdef UNICODE
00062         wcscpy(wszTitle, str);
00063 #else
00064         mbstowcs(wszTitle, str, str.GetLength()+1);
00065 #endif
00066 
00067         CheckPointer(pPageInfo, E_POINTER);
00068 
00069         // Allocate dynamic memory for the property page title
00070 
00071         LPOLESTR pszTitle;
00072         HRESULT hr = AMGetWideString(wszTitle, &pszTitle);
00073         if(FAILED(hr)) {NOTE("No caption memory"); return hr;}
00074 
00075         pPageInfo->cb               = sizeof(PROPPAGEINFO);
00076         pPageInfo->pszTitle         = pszTitle;
00077         pPageInfo->pszDocString     = NULL;
00078         pPageInfo->pszHelpFile      = NULL;
00079         pPageInfo->dwHelpContext    = 0;
00080         // Set defaults in case GetDialogSize fails
00081         pPageInfo->size.cx          = 340;
00082         pPageInfo->size.cy          = 150;
00083 
00084         MyGetDialogSize(m_DialogId, DialogProc, 0L, &pPageInfo->size);
00085 
00086         return NOERROR;
00087 }
00088 
00089 STDMETHODIMP CDVSBasePPage::Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal)
00090 {
00091         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00092 
00093         CheckPointer(pRect,E_POINTER);
00094 /*
00095     // Return failure if SetObject has not been called.
00096     if (m_bObjectSet == FALSE) {
00097         return E_UNEXPECTED;
00098     }
00099 */
00100     if(m_hwnd) return E_UNEXPECTED;
00101 
00102     m_hwnd = CreateDialogParam(AfxGetResourceHandle(), MAKEINTRESOURCE(m_DialogId), hwndParent, DialogProc, (LPARAM)this);
00103     if(m_hwnd == NULL) return E_OUTOFMEMORY;
00104 
00105     OnActivate();
00106     Move(pRect);
00107     return Show(SW_SHOWNORMAL);
00108 }
00109 
00110 /* CDVSBasePPage */
00111 
00112 CDVSBasePPage::CDVSBasePPage(TCHAR* pName, LPUNKNOWN lpunk, int DialogId, int TitleId) :
00113     CBasePropertyPage(pName, lpunk, DialogId, TitleId),
00114     m_bIsInitialized(FALSE),
00115         m_fAttached(false),
00116         m_fDisableInstantUpdate(false)
00117 {
00118 }
00119 
00120 BOOL CDVSBasePPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
00121 {
00122     switch(uMsg)
00123     {
00124         case WM_COMMAND:
00125         {
00126                         if(m_bIsInitialized)
00127                         {
00128                                 m_bDirty = TRUE;
00129                                 if(m_pPageSite) m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);
00130 
00131                                 switch(HIWORD(wParam))
00132                                 {
00133                                         case BN_CLICKED: 
00134                                         case CBN_SELCHANGE:
00135                                         case EN_CHANGE:
00136                                         {
00137                                                 AFX_MANAGE_STATE(AfxGetStaticModuleState());
00138 
00139                                                 if(!m_fDisableInstantUpdate 
00140                                                 && !(HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_INSTANTUPDATE)
00141                                                 && !!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 0)) 
00142                                                         OnApplyChanges();
00143                                         }
00144                                 }
00145                         }
00146                 }
00147                 break;
00148 
00149                 case WM_NCDESTROY:
00150                         DetachControls();
00151                 break;
00152         }
00153 
00154         return OnMessage(uMsg, wParam, lParam) 
00155                 ? 0 
00156                 : CBasePropertyPage::OnReceiveMessage(hwnd,uMsg,wParam,lParam);
00157 }
00158 
00159 HRESULT CDVSBasePPage::OnConnect(IUnknown* pUnknown)
00160 {
00161     if(!(m_pDirectVobSub = pUnknown)) return E_NOINTERFACE;
00162 
00163         m_pDirectVobSub->LockSubtitleReloader(true); // *
00164 
00165         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00166 
00167         UpdateObjectData(false);
00168 
00169         m_bIsInitialized = FALSE;
00170 
00171     return NOERROR;
00172 }
00173 
00174 HRESULT CDVSBasePPage::OnDisconnect()
00175 {
00176     if(m_pDirectVobSub == NULL) return E_UNEXPECTED;
00177 
00178         m_pDirectVobSub->LockSubtitleReloader(false); // *
00179 
00180         // for some reason OnDisconnect() will be called twice, that's why we 
00181         // need to release m_pDirectVobSub manually on the first call to avoid 
00182         // a second "m_pDirectVobSub->LockSubtitleReloader(false);"
00183 
00184         m_pDirectVobSub.Release(); 
00185 
00186         return NOERROR;
00187 }
00188 
00189 HRESULT CDVSBasePPage::OnActivate()
00190 {
00191         ASSERT(m_pDirectVobSub);
00192 
00193         AttachControls();
00194 
00195         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00196 
00197         UpdateControlData(false);
00198 
00199         m_bIsInitialized = TRUE;
00200 
00201     return NOERROR;
00202 }
00203 
00204 HRESULT CDVSBasePPage::OnDeactivate()
00205 {
00206         ASSERT(m_pDirectVobSub);
00207 
00208         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00209 
00210         UpdateControlData(true);
00211 
00212     m_bIsInitialized = FALSE;
00213 
00214     return NOERROR;
00215 }
00216 
00217 HRESULT CDVSBasePPage::OnApplyChanges()
00218 {
00219     ASSERT(m_pDirectVobSub);
00220 
00221         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00222 
00223         if(m_bIsInitialized)
00224         {
00225                 OnDeactivate();
00226         UpdateObjectData(true);
00227                 m_pDirectVobSub->UpdateRegistry(); // *
00228                 OnActivate();
00229         }
00230 
00231     return NOERROR;
00232 }
00233 
00234 void CDVSBasePPage::AttachControls()
00235 {
00236         DetachControls();
00237 
00238         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00239 
00240         POSITION pos = m_controls.GetStartPosition();
00241         while(pos)
00242         {
00243                 UINT id;
00244                 CWnd* pControl;
00245                 m_controls.GetNextAssoc(pos, id, pControl);
00246                 if(pControl) 
00247                 {
00248                         BOOL fRet = pControl->Attach(GetDlgItem(m_Dlg, id));
00249                         ASSERT(fRet);
00250                 }
00251         }
00252 
00253         m_fAttached = true;
00254 }
00255 
00256 void CDVSBasePPage::DetachControls()
00257 {
00258         if(!m_fAttached) return;
00259 
00260         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00261 
00262         POSITION pos = m_controls.GetStartPosition();
00263         while(pos)
00264         {
00265                 UINT id;
00266                 CWnd* pControl;
00267                 m_controls.GetNextAssoc(pos, id, pControl);
00268                 if(pControl) pControl->Detach();
00269         }
00270 
00271         m_fAttached = false;
00272 }
00273 
00274 void CDVSBasePPage::BindControl(UINT id, CWnd& control)
00275 {
00276         m_controls[id] = &control;
00277 }
00278 
00279 /* CDVSMainPPage */
00280 
00281 CDVSMainPPage::CDVSMainPPage(LPUNKNOWN pUnk, HRESULT* phr) :
00282     CDVSBasePPage(NAME("DirectVobSub Property Page (main)"), pUnk, IDD_DVSMAINPAGE, IDD_DVSMAINPAGE),
00283         m_nLangs(0),
00284         m_ppLangs(NULL)
00285 {
00286         BindControl(IDC_FILENAME, m_fnedit);
00287         BindControl(IDC_LANGCOMBO, m_langs);
00288         BindControl(IDC_OVERRIDEPLACEMENT, m_oplacement);
00289         BindControl(IDC_SPIN1, m_subposx);
00290         BindControl(IDC_SPIN2, m_subposy);
00291         BindControl(IDC_FONT, m_font);
00292         BindControl(IDC_ONLYSHOWFORCEDSUBS, m_forcedsubs);
00293 }
00294 
00295 CDVSMainPPage::~CDVSMainPPage()
00296 {
00297         FreeLangs();
00298 }
00299 
00300 void CDVSMainPPage::FreeLangs()
00301 {
00302         if(m_nLangs > 0 && m_ppLangs) 
00303         {
00304                 for(int i = 0; i < m_nLangs; i++) CoTaskMemFree(m_ppLangs[i]);
00305                 CoTaskMemFree(m_ppLangs);
00306                 m_nLangs = 0;
00307                 m_ppLangs = NULL;
00308         }
00309 }
00310 
00311 void CDVSMainPPage::AllocLangs(int nLangs)
00312 {
00313         m_ppLangs = (WCHAR**)CoTaskMemRealloc(m_ppLangs, sizeof(WCHAR*)*nLangs);
00314         m_nLangs = nLangs;
00315 }
00316 
00317 bool CDVSMainPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
00318 {
00319     switch(uMsg)
00320     {
00321         case WM_COMMAND:
00322         {
00323                         switch(HIWORD(wParam))
00324                         {
00325                                 case BN_CLICKED:
00326                                 {
00327                                         if(LOWORD(wParam) == IDC_OPEN)
00328                                         {
00329                                                 AFX_MANAGE_STATE(AfxGetStaticModuleState());
00330 
00331                                                 CFileDialog fd(TRUE, NULL, NULL, 
00332                                                         OFN_EXPLORER|OFN_ENABLESIZING|OFN_HIDEREADONLY|OFN_FILEMUSTEXIST|OFN_PATHMUSTEXIST,
00333                                                         _T(".idx .smi .sub .srt .psb .ssa .ass .usf|*.idx;*.smi;*.sub;*.srt;*.psb;*.ssa;*.ass;*.usf|"),
00334                                                         CDialog::FromHandle(m_Dlg), 0);
00335 
00336                                                 if(fd.DoModal() == IDOK)
00337                                                 {
00338                                                         m_fnedit.SetWindowText(fd.GetPathName());
00339                                                 }
00340 
00341                                                 return(true);
00342                                         }
00343                                         else if(LOWORD(wParam) == IDC_FONT)
00344                                         {
00345                                                 AFX_MANAGE_STATE(AfxGetStaticModuleState());
00346 
00347                                                 CStyleEditorDialog dlg(_T("Default"), &m_defStyle, CWnd::FromHandle(m_hwnd));
00348 
00349                                                 if(dlg.DoModal() == IDOK)
00350                                                 {
00351                                                         m_defStyle = dlg.m_stss;
00352                                                         CString str = m_defStyle.fontName;
00353                                                         if(str.GetLength() > 18) str = str.Left(16).TrimRight() + _T("...");
00354                                                         m_font.SetWindowText(str);
00355                                                 }
00356 
00357                                                 return(true);
00358                                         }
00359                                 }
00360                                 break;
00361                         }
00362                 }
00363                 break;
00364         }
00365 
00366         return(false);
00367 }
00368 
00369 void CDVSMainPPage::UpdateObjectData(bool fSave)
00370 {
00371         if(fSave)
00372         {
00373                 if(m_pDirectVobSub->put_FileName(m_fn) == S_OK)
00374                 {
00375                         int nLangs;
00376                         m_pDirectVobSub->get_LanguageCount(&nLangs); 
00377                         AllocLangs(nLangs);
00378                         for(int i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
00379                         m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
00380                 }
00381 
00382                 m_pDirectVobSub->put_SelectedLanguage(m_iSelectedLanguage);
00383                 m_pDirectVobSub->put_Placement(m_fOverridePlacement, m_PlacementXperc, m_PlacementYperc);
00384                 m_pDirectVobSub->put_VobSubSettings(true, m_fOnlyShowForcedVobSubs, false);
00385                 m_pDirectVobSub->put_TextSettings(&m_defStyle);
00386         }
00387         else
00388         {
00389                 m_pDirectVobSub->get_FileName(m_fn);
00390                 int nLangs;
00391                 m_pDirectVobSub->get_LanguageCount(&nLangs); 
00392                 AllocLangs(nLangs);
00393                 for(int i = 0; i < m_nLangs; i++) m_pDirectVobSub->get_LanguageName(i, &m_ppLangs[i]);
00394                 m_pDirectVobSub->get_SelectedLanguage(&m_iSelectedLanguage);
00395                 m_pDirectVobSub->get_Placement(&m_fOverridePlacement, &m_PlacementXperc, &m_PlacementYperc);
00396                 m_pDirectVobSub->get_VobSubSettings(NULL, &m_fOnlyShowForcedVobSubs, NULL);
00397                 m_pDirectVobSub->get_TextSettings(&m_defStyle);
00398         }
00399 }
00400 
00401 void CDVSMainPPage::UpdateControlData(bool fSave)
00402 {
00403         if(fSave)
00404         {
00405                 CString fn;
00406                 m_fnedit.GetWindowText(fn);
00407 #ifdef UNICODE
00408                 wcscpy(m_fn, fn);
00409 #else
00410                 mbstowcs(m_fn, fn, fn.GetLength()+1);
00411 #endif
00412                 m_iSelectedLanguage = m_langs.GetCurSel();
00413                 m_fOverridePlacement = !!m_oplacement.GetCheck();
00414                 m_PlacementXperc = m_subposx.GetPos();
00415                 m_PlacementYperc = m_subposy.GetPos();
00416                 m_fOnlyShowForcedVobSubs = !!m_forcedsubs.GetCheck();
00417         }
00418         else
00419         {
00420                 m_fnedit.SetWindowText(CString(m_fn));
00421                 m_oplacement.SetCheck(m_fOverridePlacement);
00422                 m_subposx.SetRange(-20, 120);
00423                 m_subposx.SetPos(m_PlacementXperc);
00424                 m_subposx.EnableWindow(m_fOverridePlacement);
00425                 m_subposy.SetRange(-20, 120);
00426                 m_subposy.SetPos(m_PlacementYperc);
00427                 m_subposy.EnableWindow(m_fOverridePlacement);
00428                 m_font.SetWindowText(m_defStyle.fontName);
00429                 m_forcedsubs.SetCheck(m_fOnlyShowForcedVobSubs);
00430                 m_langs.ResetContent();
00431                 m_langs.EnableWindow(m_nLangs > 0);
00432                 for(int i = 0; i < m_nLangs; i++) m_langs.AddString(CString(m_ppLangs[i]));
00433                 m_langs.SetCurSel(m_iSelectedLanguage);
00434         }
00435 }
00436 
00437 /* CDVSGeneralPPage */
00438 
00439 CDVSGeneralPPage::CDVSGeneralPPage(LPUNKNOWN pUnk, HRESULT* phr) :
00440     CDVSBasePPage(NAME("DirectVobSub Property Page (global settings)"), pUnk, IDD_DVSGENERALPAGE, IDD_DVSGENERALPAGE)
00441 {
00442         BindControl(IDC_VEREXTCOMBO, m_verext);
00443         BindControl(IDC_MOD32FIX, m_mod32fix);
00444         BindControl(IDC_RESX2COMBO, m_resx2);
00445         BindControl(IDC_SPIN3, m_resx2w);
00446         BindControl(IDC_SPIN4, m_resx2h);
00447         BindControl(IDC_LOADCOMBO, m_load);
00448         BindControl(IDC_EXTLOAD, m_extload);
00449         BindControl(IDC_WEBLOAD, m_webload);
00450         BindControl(IDC_EMBLOAD, m_embload);
00451 }
00452 
00453 bool CDVSGeneralPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
00454 {
00455     switch(uMsg)
00456     {
00457         case WM_COMMAND:
00458         {
00459                         switch(HIWORD(wParam))
00460                         {
00461                                 case CBN_SELCHANGE:
00462                                 {
00463                                         AFX_MANAGE_STATE(AfxGetStaticModuleState());
00464 
00465                                         if(LOWORD(wParam) == IDC_RESX2COMBO)
00466                                         {
00467                                                 m_resx2w.EnableWindow(m_resx2.GetCurSel() == 2);
00468                                                 m_resx2h.EnableWindow(m_resx2.GetCurSel() == 2);
00469                                                 return(true);
00470                                         }
00471                                         else if(LOWORD(wParam) == IDC_LOADCOMBO)
00472                                         {
00473                                                 m_extload.EnableWindow(m_load.GetCurSel() == 1);
00474                                                 m_webload.EnableWindow(m_load.GetCurSel() == 1);
00475                                                 m_embload.EnableWindow(m_load.GetCurSel() == 1);
00476                                                 return(true);
00477                                         }
00478                                 }
00479                                 break;
00480                         }
00481                 }
00482                 break;
00483         }
00484 
00485         return(false);
00486 }
00487 
00488 void CDVSGeneralPPage::UpdateObjectData(bool fSave)
00489 {
00490         if(fSave)
00491         {
00492                 m_pDirectVobSub->put_ExtendPicture(m_HorExt, m_VerExt, m_ResX2, m_ResX2minw, m_ResX2minh);
00493                 m_pDirectVobSub->put_LoadSettings(m_LoadLevel, m_fExternalLoad, m_fWebLoad, m_fEmbeddedLoad);
00494         }
00495         else
00496         {
00497                 m_pDirectVobSub->get_ExtendPicture(&m_HorExt, &m_VerExt, &m_ResX2, &m_ResX2minw, &m_ResX2minh);
00498                 m_pDirectVobSub->get_LoadSettings(&m_LoadLevel, &m_fExternalLoad, &m_fWebLoad, &m_fEmbeddedLoad);
00499         }
00500 }
00501 
00502 void CDVSGeneralPPage::UpdateControlData(bool fSave)
00503 {
00504         if(fSave)
00505         {
00506                 if(m_verext.GetCurSel() >= 0) m_VerExt = m_verext.GetItemData(m_verext.GetCurSel());
00507                 m_HorExt = !!m_mod32fix.GetCheck();
00508                 if(m_resx2.GetCurSel() >= 0) m_ResX2 = m_resx2.GetItemData(m_resx2.GetCurSel());
00509                 m_ResX2minw = m_resx2w.GetPos(); 
00510                 m_ResX2minh = m_resx2h.GetPos();
00511                 if(m_load.GetCurSel() >= 0) m_LoadLevel = m_load.GetItemData(m_load.GetCurSel());
00512                 m_fExternalLoad = !!m_extload.GetCheck();
00513                 m_fWebLoad = !!m_webload.GetCheck();
00514                 m_fEmbeddedLoad = !!m_embload.GetCheck();
00515         }
00516         else
00517         {
00518                 m_verext.ResetContent();
00519                 m_verext.AddString(ResStr(IDS_ORGHEIGHT)); m_verext.SetItemData(0, 0);
00520                 m_verext.AddString(ResStr(IDS_EXTTO169)); m_verext.SetItemData(1, 1);
00521                 m_verext.AddString(ResStr(IDS_EXTTO43)); m_verext.SetItemData(2, 2);
00522                 m_verext.AddString(ResStr(IDS_EXTTO480)); m_verext.SetItemData(3, 3);
00523                 m_verext.AddString(ResStr(IDS_EXTTO576)); m_verext.SetItemData(4, 4);
00524                 m_verext.AddString(ResStr(IDS_CROPTO169)); m_verext.SetItemData(5, 0x81);
00525                 m_verext.AddString(ResStr(IDS_CROPTO43)); m_verext.SetItemData(6, 0x82);
00526                 m_verext.SetCurSel((m_VerExt&0x7f) + ((m_VerExt&0x80)?4:0));
00527                 m_mod32fix.SetCheck(m_HorExt&1);
00528                 m_resx2.ResetContent();
00529                 m_resx2.AddString(ResStr(IDS_ORGRES)); m_resx2.SetItemData(0, 0);
00530                 m_resx2.AddString(ResStr(IDS_DBLRES)); m_resx2.SetItemData(1, 1);
00531                 m_resx2.AddString(ResStr(IDS_DBLRESIF)); m_resx2.SetItemData(2, 2);
00532                 m_resx2.SetCurSel(m_ResX2);
00533                 m_resx2w.SetRange(0, 2048);
00534                 m_resx2w.SetPos(m_ResX2minw);
00535                 m_resx2w.EnableWindow(m_ResX2 == 2);
00536                 m_resx2h.SetRange(0, 2048);
00537                 m_resx2h.SetPos(m_ResX2minh);
00538                 m_resx2h.EnableWindow(m_ResX2 == 2);
00539                 m_load.ResetContent();
00540                 m_load.AddString(ResStr(IDS_DONOTLOAD)); m_load.SetItemData(0, 2);
00541                 m_load.AddString(ResStr(IDS_LOADWHENNEEDED)); m_load.SetItemData(1, 0);
00542                 m_load.AddString(ResStr(IDS_ALWAYSLOAD)); m_load.SetItemData(2, 1);
00543                 m_load.SetCurSel(!m_LoadLevel?1:m_LoadLevel==1?2:0);
00544                 m_extload.SetCheck(m_fExternalLoad);
00545                 m_webload.SetCheck(m_fWebLoad);
00546                 m_embload.SetCheck(m_fEmbeddedLoad);
00547                 m_extload.EnableWindow(m_load.GetCurSel() == 1);
00548                 m_webload.EnableWindow(m_load.GetCurSel() == 1);
00549                 m_embload.EnableWindow(m_load.GetCurSel() == 1);
00550         }
00551 }
00552 
00553 /* CDVSMiscPPage */
00554 
00555 CDVSMiscPPage::CDVSMiscPPage(LPUNKNOWN pUnk, HRESULT* phr) :
00556     CDVSBasePPage(NAME("DirectVobSub Property Page (misc settings)"), pUnk, IDD_DVSMISCPAGE, IDD_DVSMISCPAGE)
00557 {
00558         BindControl(IDC_FLIP, m_flippic);
00559         BindControl(IDC_FLIPSUB, m_flipsub);
00560         BindControl(IDC_HIDE, m_hidesub);
00561         BindControl(IDC_SHOWOSDSTATS, m_showosd);
00562         BindControl(IDC_PREBUFFERING, m_prebuff);
00563         BindControl(IDC_AUTORELOAD, m_autoreload);
00564         BindControl(IDC_SAVEFULLPATH, m_savefullpath);
00565         BindControl(IDC_INSTANTUPDATE, m_instupd);
00566 }
00567 
00568 bool CDVSMiscPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
00569 {
00570     switch(uMsg)
00571     {
00572         case WM_COMMAND:
00573         {
00574                         switch(HIWORD(wParam))
00575                         {
00576                                 case BN_CLICKED:
00577                                 {
00578                                         if(LOWORD(wParam) == IDC_INSTANTUPDATE)
00579                                         {
00580                                                 AFX_MANAGE_STATE(AfxGetStaticModuleState());
00581                                                 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), !!m_instupd.GetCheck());
00582                                                 return(true);
00583                                         }
00584                                 }
00585                                 break;
00586                         }
00587                 }
00588                 break;
00589         }
00590 
00591     return(false);
00592 }
00593 
00594 void CDVSMiscPPage::UpdateObjectData(bool fSave)
00595 {
00596         if(fSave)
00597         {
00598                 m_pDirectVobSub->put_Flip(m_fFlipPicture, m_fFlipSubtitles);
00599                 m_pDirectVobSub->put_HideSubtitles(m_fHideSubtitles);
00600                 m_pDirectVobSub->put_OSD(m_fOSD);
00601                 m_pDirectVobSub->put_PreBuffering(m_fDoPreBuffering);
00602                 m_pDirectVobSub->put_SubtitleReloader(m_fReloaderDisabled);
00603                 m_pDirectVobSub->put_SaveFullPath(m_fSaveFullPath);
00604         }
00605         else
00606         {
00607                 m_pDirectVobSub->get_Flip(&m_fFlipPicture, &m_fFlipSubtitles);
00608                 m_pDirectVobSub->get_HideSubtitles(&m_fHideSubtitles);
00609                 m_pDirectVobSub->get_OSD(&m_fOSD);
00610                 m_pDirectVobSub->get_PreBuffering(&m_fDoPreBuffering);
00611                 m_pDirectVobSub->get_SubtitleReloader(&m_fReloaderDisabled);
00612                 m_pDirectVobSub->get_SaveFullPath(&m_fSaveFullPath);
00613         }
00614 }
00615 
00616 void CDVSMiscPPage::UpdateControlData(bool fSave)
00617 {
00618         if(fSave)
00619         {
00620                 m_fFlipPicture = !!m_flippic.GetCheck();
00621                 m_fFlipSubtitles = !!m_flipsub.GetCheck();
00622                 m_fHideSubtitles = !!m_hidesub.GetCheck();
00623                 m_fSaveFullPath = !!m_savefullpath.GetCheck();
00624                 m_fDoPreBuffering = !!m_prebuff.GetCheck();
00625                 m_fOSD = !!m_showosd.GetCheck();
00626                 m_fReloaderDisabled = !m_autoreload.GetCheck();
00627         }
00628         else
00629         {
00630                 m_flippic.SetCheck(m_fFlipPicture);
00631                 m_flipsub.SetCheck(m_fFlipSubtitles);
00632                 m_hidesub.SetCheck(m_fHideSubtitles);
00633                 m_savefullpath.SetCheck(m_fSaveFullPath);
00634                 m_prebuff.SetCheck(m_fDoPreBuffering);
00635                 m_showosd.SetCheck(m_fOSD);
00636                 m_autoreload.SetCheck(!m_fReloaderDisabled);
00637                 m_instupd.SetCheck(!!theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_INSTANTUPDATE), 0));
00638         }
00639 }
00640 
00641 /* CDVSTimingPPage */
00642 
00643 CDVSTimingPPage::CDVSTimingPPage(LPUNKNOWN pUnk, HRESULT* phr) :
00644     CDVSBasePPage(NAME("DirectVobSub Timing Property Page"), pUnk, IDD_DVSTIMINGPAGE, IDD_DVSTIMINGPAGE)
00645 {
00646         BindControl(IDC_MODFPS, m_modfps);
00647         BindControl(IDC_FPS, m_fps);
00648         BindControl(IDC_SPIN5, m_subdelay);
00649         BindControl(IDC_SPIN6, m_subspeedmul);
00650         BindControl(IDC_SPIN9, m_subspeeddiv);
00651 }
00652 
00653 bool CDVSTimingPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
00654 {
00655     switch(uMsg)
00656     {
00657         case WM_COMMAND:
00658         {
00659                         switch(HIWORD(wParam))
00660                         {
00661                                 case BN_CLICKED:
00662                                 {
00663                                         if(LOWORD(wParam) == IDC_MODFPS)
00664                                         {
00665                                                 AFX_MANAGE_STATE(AfxGetStaticModuleState());
00666                                                 m_fps.EnableWindow(!!m_modfps.GetCheck());
00667                                                 return(true);
00668                                         }
00669                                 }
00670                                 break;
00671                         }
00672                 }
00673                 break;
00674         }
00675 
00676         return(false);
00677 }
00678 
00679 void CDVSTimingPPage::UpdateObjectData(bool fSave)
00680 {
00681         if(fSave)
00682         {
00683                 m_pDirectVobSub->put_SubtitleTiming(m_SubtitleDelay, m_SubtitleSpeedMul, m_SubtitleSpeedDiv);
00684                 m_pDirectVobSub->put_MediaFPS(m_fMediaFPSEnabled, m_MediaFPS);
00685         }
00686         else
00687         {
00688                 m_pDirectVobSub->get_SubtitleTiming(&m_SubtitleDelay, &m_SubtitleSpeedMul, &m_SubtitleSpeedDiv);
00689                 m_pDirectVobSub->get_MediaFPS(&m_fMediaFPSEnabled, &m_MediaFPS);
00690         }
00691 }
00692 
00693 void CDVSTimingPPage::UpdateControlData(bool fSave)
00694 {
00695         if(fSave)
00696         {
00697                 m_fMediaFPSEnabled = !!m_modfps.GetCheck();
00698                 CString fpsstr;
00699                 m_fps.GetWindowText(fpsstr);
00700                 float fps;
00701                 if(_stscanf(fpsstr, _T("%f"), &fps) == 1) m_MediaFPS = fps;
00702 #if _MFC_VER >= 0x0700
00703                 m_SubtitleDelay = m_subdelay.GetPos32();
00704                 m_SubtitleSpeedMul = m_subspeedmul.GetPos32();
00705                 m_SubtitleSpeedDiv = m_subspeeddiv.GetPos32();
00706 #else
00707                 m_SubtitleDelay = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN5), UDM_GETPOS32, 0, 0);
00708                 m_SubtitleSpeedMul = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN6), UDM_GETPOS32, 0, 0);
00709                 m_SubtitleSpeedDiv = SendMessage(GetDlgItem(m_Dlg, IDC_SPIN9), UDM_GETPOS32, 0, 0);
00710 #endif
00711         }
00712         else
00713         {
00714                 m_modfps.SetCheck(m_fMediaFPSEnabled);
00715                 CString fpsstr;
00716                 fpsstr.Format(_T("%.4f"), m_MediaFPS);
00717                 m_fps.SetWindowText(fpsstr);
00718                 m_fps.EnableWindow(m_fMediaFPSEnabled);
00719                 m_subdelay.SetRange32(-180*60*1000, 180*60*1000);
00720                 m_subspeedmul.SetRange32(0, 1000000);
00721                 m_subspeeddiv.SetRange32(1, 1000000);
00722 #if _MFC_VER >= 0x0700
00723                 m_subdelay.SetPos32(m_SubtitleDelay);
00724                 m_subspeedmul.SetPos32(m_SubtitleSpeedMul);
00725                 m_subspeeddiv.SetPos32(m_SubtitleSpeedDiv);
00726 #else
00727                 SendMessage(GetDlgItem(m_Dlg, IDC_SPIN5), UDM_SETPOS32, 0, (LPARAM)m_SubtitleDelay);
00728                 SendMessage(GetDlgItem(m_Dlg, IDC_SPIN6), UDM_SETPOS32, 0, (LPARAM)m_SubtitleSpeedMul);
00729                 SendMessage(GetDlgItem(m_Dlg, IDC_SPIN9), UDM_SETPOS32, 0, (LPARAM)m_SubtitleSpeedDiv);
00730 #endif
00731         }
00732 }
00733 
00734 /* CDVSAboutPPage */
00735 
00736 CDVSAboutPPage::CDVSAboutPPage(LPUNKNOWN lpunk, HRESULT* phr) : 
00737         CDVSBasePPage(NAME("About Property Page"), lpunk, IDD_DVSABOUTPAGE, IDD_DVSABOUTPAGE)
00738 {
00739 
00740 }
00741 
00742 bool CDVSAboutPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
00743 {
00744     switch(uMsg)
00745     {
00746         case WM_COMMAND:
00747         {
00748                         switch(HIWORD(wParam))
00749                         {
00750                                 case BN_CLICKED:
00751                                 {
00752                                         if(LOWORD(wParam) == IDC_HOMEPAGEBTN)
00753                                         {
00754                                                 AFX_MANAGE_STATE(AfxGetStaticModuleState());
00755                                                 ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_HOMEPAGE), NULL, NULL, SW_SHOWNORMAL);
00756                                                 return(true);
00757                                         }
00758                                         else if(LOWORD(wParam) == IDC_BUGREPORTBTN)
00759                                         {
00760                                                 AFX_MANAGE_STATE(AfxGetStaticModuleState());
00761                                                 ShellExecute(m_Dlg, _T("open"), ResStr(IDS_URL_EMAIL), NULL, NULL, SW_SHOWNORMAL);
00762                                                 return(true);
00763                                         }
00764                                 }
00765                                 break;
00766                         }
00767                 }
00768                 break;
00769         }
00770 
00771     return(false);
00772 }
00773 
00774 /* CDVSZoomPPage */
00775 
00776 CDVSZoomPPage::CDVSZoomPPage(LPUNKNOWN pUnk, HRESULT* phr) :
00777     CDVSBasePPage(NAME("DirectVobSub Zoom Property Page"), pUnk, IDD_DVSZOOMPAGE, IDD_DVSZOOMPAGE)
00778 {
00779         BindControl(IDC_SPIN1, m_posx);
00780         BindControl(IDC_SPIN2, m_posy);
00781         BindControl(IDC_SPIN7, m_scalex);
00782         BindControl(IDC_SPIN8, m_scaley);
00783 }
00784 
00785 bool CDVSZoomPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
00786 {
00787     switch(uMsg)
00788     {
00789         case WM_COMMAND:
00790         {
00791                         switch(HIWORD(wParam))
00792                         {
00793                                 case EN_CHANGE:
00794                                 {
00795                                         if(LOWORD(wParam) == IDC_EDIT1 || LOWORD(wParam) == IDC_EDIT2
00796                                         || LOWORD(wParam) == IDC_EDIT7 || LOWORD(wParam) == IDC_EDIT8)
00797                                         {
00798                                                 AFX_MANAGE_STATE(AfxGetStaticModuleState());
00799                                                 UpdateControlData(true);
00800                                                 UpdateObjectData(true);
00801                                                 return(true);
00802                                         }
00803                                 }
00804 
00805                                 break;
00806                         }
00807                 }
00808                 break;
00809         }
00810 
00811         return(false);
00812 }
00813 
00814 void CDVSZoomPPage::UpdateControlData(bool fSave)
00815 {
00816         if(fSave)
00817         {
00818                 m_rect.left = 1.0f * (short)m_posx.GetPos() / 100;
00819                 m_rect.top = 1.0f * (short)m_posy.GetPos() / 100;
00820                 m_rect.right = m_rect.left + 1.0f * (short)m_scalex.GetPos() / 100;
00821                 m_rect.bottom = m_rect.top + 1.0f * (short)m_scaley.GetPos() / 100;
00822         }
00823         else
00824         {
00825                 m_posx.SetRange(-100, 100);
00826                 m_posx.SetPos((int)(m_rect.left*100));
00827                 m_posy.SetRange(-100, 100);
00828                 m_posy.SetPos((int)(m_rect.top*100));
00829                 m_scalex.SetRange(-300, 300);
00830                 m_scalex.SetPos((int)((m_rect.right-m_rect.left)*100));
00831                 m_scaley.SetRange(-300, 300);
00832                 m_scaley.SetPos((int)((m_rect.bottom-m_rect.top)*100));
00833         }
00834 }
00835 
00836 void CDVSZoomPPage::UpdateObjectData(bool fSave)
00837 {
00838         if(fSave)
00839         {
00840                 m_pDirectVobSub->put_ZoomRect(&m_rect);
00841         }
00842         else
00843         {
00844                 m_pDirectVobSub->get_ZoomRect(&m_rect);
00845         }
00846 }
00847 
00848 // TODO: Make CDVSColorPPage and CDVSPathsPPage use an interface on DirectVobSub instead of the registry to communicate
00849 
00850 /* CDVSColorPPage */
00851 
00852 CDVSColorPPage::CDVSColorPPage(LPUNKNOWN pUnk, HRESULT* phr) :
00853     CDVSBasePPage(NAME("DirectVobSub Color Property Page"), pUnk, IDD_DVSCOLORPAGE, IDD_DVSCOLORPAGE)
00854 {
00855         BindControl(IDC_PREFLIST, m_preflist);
00856         BindControl(IDC_DYNCHGLIST, m_dynchglist);
00857         BindControl(IDC_FORCERGBCHK, m_forcergb);
00858 
00859         m_fDisableInstantUpdate = true;
00860 }
00861 
00862 bool CDVSColorPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
00863 {
00864     switch(uMsg)
00865     {
00866         case WM_COMMAND:
00867         {
00868                         switch(HIWORD(wParam))
00869                         {
00870                                 case LBN_DBLCLK:
00871                                         if((HWND)lParam == m_dynchglist.m_hWnd)
00872                                         {
00873                                                 int old = -1; 
00874                                                 m_pDirectVobSub->get_ColorFormat(&old);
00875                                                 if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel())))
00876                                                         m_dynchglist.SetCurSel(old);
00877 
00878                                                 return(true);
00879                                         }
00880                                 break;
00881 
00882                                 case BN_CLICKED:
00883                                 {
00884                                         switch(LOWORD(wParam))
00885                                         {
00886                                                 case IDC_COLORCHANGE:
00887                                                 {
00888                                                         int old = -1; 
00889                                                         m_pDirectVobSub->get_ColorFormat(&old);
00890                                                         if(FAILED(m_pDirectVobSub->put_ColorFormat(m_dynchglist.GetCurSel())))
00891                                                                 m_dynchglist.SetCurSel(old);
00892 
00893                                                         return(true);
00894                                                 }
00895                                                 case IDC_COLORUP:
00896                                                 {
00897                                                         int sel = m_preflist.GetCurSel();
00898                                                         if(sel > 0)
00899                                                         {
00900                                                                 CString str;
00901                                                                 m_preflist.GetText(sel, str);
00902                                                                 int iPos = (int)m_preflist.GetItemData(sel);
00903                                                                 m_preflist.DeleteString(sel);
00904                                                                 sel--;
00905                                                                 m_preflist.InsertString(sel, str);
00906                                                                 m_preflist.SetItemData(sel, iPos);
00907                                                                 m_preflist.SetCurSel(sel);
00908                                                         }
00909 
00910                                                         return(true);
00911                                                 }
00912                                                 case IDC_COLORDOWN:
00913                                                 {
00914                                                         int sel = m_preflist.GetCurSel();
00915                                                         if(sel >= 0 && sel < m_preflist.GetCount()-1)
00916                                                         {
00917                                                                 CString str;
00918                                                                 m_preflist.GetText(sel, str);
00919                                                                 int iPos = (int)m_preflist.GetItemData(sel);
00920                                                                 m_preflist.DeleteString(sel);
00921                                                                 sel++;
00922                                                                 m_preflist.InsertString(sel, str);
00923                                                                 m_preflist.SetItemData(sel, iPos);
00924                                                                 m_preflist.SetCurSel(sel);
00925                                                         }
00926 
00927                                                         return(true);
00928                                                 }
00929                                         }
00930                                 }
00931                                 break;
00932                         }
00933                 }
00934                 break;
00935         }
00936 
00937     return(false);
00938 }
00939 
00940 void CDVSColorPPage::UpdateObjectData(bool fSave)
00941 {
00942         if(fSave)
00943         {
00944         }
00945         else
00946         {
00947         }
00948 }
00949 
00950 void CDVSColorPPage::UpdateControlData(bool fSave)
00951 {
00952         if(fSave)
00953         {
00954                 if(m_preflist.GetCount() == VIHSIZE)
00955                 {
00956                         BYTE* pData = new BYTE[VIHSIZE];
00957 
00958                         for(int i = 0; i < m_preflist.GetCount(); i++)
00959                                 pData[i] = (BYTE)m_preflist.GetItemData(i);
00960 
00961                         theApp.WriteProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), pData, VIHSIZE);
00962 
00963                         delete [] pData;
00964                 }
00965                 else ASSERT(0);
00966 
00967                 theApp.WriteProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), !!m_forcergb.GetCheck());
00968         }
00969         else
00970         {
00971                 m_preflist.ResetContent();
00972                 m_dynchglist.ResetContent();
00973 
00974                 BYTE* pData = NULL;
00975                 UINT nSize;
00976                 
00977                 if(!theApp.GetProfileBinary(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_COLORFORMATS), &pData, &nSize)
00978                 || !pData || nSize != VIHSIZE)
00979                 {
00980                         if(pData) delete [] pData, pData = NULL;
00981 
00982                         nSize = VIHSIZE;
00983                         pData = new BYTE[VIHSIZE];
00984                         for(int i = 0; i < VIHSIZE; i++) pData[i] = i;
00985                 }
00986 
00987                 if(pData)
00988                 {
00989                         for(int i = 0; i < (int)nSize; i++)
00990                         {
00991                                 m_dynchglist.AddString(VIH2String(pData[i]));
00992                                 m_dynchglist.SetItemData(i, pData[i]);
00993                                 m_preflist.AddString(VIH2String(pData[i]));
00994                                 m_preflist.SetItemData(i, pData[i]);
00995                         }
00996 
00997                         int iPosition = -1;
00998                         m_pDirectVobSub->get_ColorFormat(&iPosition);
00999                         m_dynchglist.SetCurSel(iPosition);
01000 
01001                         delete [] pData;
01002                 }
01003 
01004                 m_forcergb.SetCheck(theApp.GetProfileInt(ResStr(IDS_R_GENERAL), ResStr(IDS_RG_FORCERGB), 0)?BST_CHECKED:BST_UNCHECKED);
01005         }
01006 }
01007 
01008 /* CDVSPathsPPage */
01009 
01010 CDVSPathsPPage::CDVSPathsPPage(LPUNKNOWN pUnk, HRESULT* phr) :
01011     CDVSBasePPage(NAME("DirectVobSub Paths Property Page"), pUnk, IDD_DVSPATHSPAGE, IDD_DVSPATHSPAGE)
01012 {
01013         BindControl(IDC_PATHLIST, m_pathlist);
01014         BindControl(IDC_PATHEDIT, m_path);
01015         BindControl(IDC_BROWSE, m_browse);
01016         BindControl(IDC_REMOVE, m_remove);
01017         BindControl(IDC_ADD, m_add);
01018 
01019         m_fDisableInstantUpdate = true;
01020 }
01021 
01022 bool CDVSPathsPPage::OnMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)
01023 {
01024     switch(uMsg)
01025     {
01026         case WM_COMMAND:
01027         {
01028                         switch(HIWORD(wParam))
01029                         {
01030                                 case LBN_SELCHANGE:
01031                                         if((HWND)lParam == m_pathlist.m_hWnd)
01032                                         {
01033                                                 int i = m_pathlist.GetCurSel();
01034                                                 m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
01035                                                 if(i >= 0)
01036                                                 {
01037                                                         CString path;
01038                                                         m_pathlist.GetText(i, path);
01039                                                         m_path.SetWindowText(path);
01040                                                 }
01041                                                 return(true);
01042                                         }
01043                                 break;
01044 
01045                                 case LBN_SELCANCEL:
01046                                         if((HWND)lParam == m_pathlist.m_hWnd)
01047                                         {
01048                                                 m_remove.EnableWindow(FALSE);
01049                                                 return(true);
01050                                         }
01051                                 break;
01052 
01053                                 case BN_CLICKED:
01054                                 {
01055                                         switch(LOWORD(wParam))
01056                                         {
01057                                                 case IDC_BROWSE:
01058                                                 {
01059                                                         TCHAR pathbuff[MAX_PATH];
01060 
01061                                                         BROWSEINFO bi;
01062                                                         bi.hwndOwner = m_Dlg;
01063                                                         bi.pidlRoot = NULL;
01064                                                         bi.pszDisplayName = pathbuff;
01065                                                         bi.lpszTitle = _T("");
01066                                                         bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_EDITBOX | BIF_VALIDATE | BIF_USENEWUI;
01067                                                         bi.lpfn = NULL;
01068                                                         bi.lParam = 0;
01069                                                         bi.iImage = 0; 
01070 
01071                                                         LPITEMIDLIST iil;
01072                                                         if(iil = SHBrowseForFolder(&bi))
01073                                                         {
01074                                                                 SHGetPathFromIDList(iil, pathbuff);
01075                                                                 m_path.SetWindowText(pathbuff);
01076                                                         }
01077 
01078                                                         return(true);
01079                                                 }
01080                                                 break;
01081 
01082                                                 case IDC_REMOVE:
01083                                                 {
01084                                                         int i = m_pathlist.GetCurSel();
01085                                                         if(i >= 0)
01086                                                         {
01087                                                                 m_pathlist.DeleteString(i);
01088                                                                 i = min(i, m_pathlist.GetCount()-1);
01089                                                                 if(i >= 0 && m_pathlist.GetCount() > 0)
01090                                                                 {
01091                                                                         m_pathlist.SetCurSel(i);
01092                                                                         m_remove.EnableWindow(i >= 3 ? TRUE : FALSE);
01093                                                                 }
01094                                                         }
01095 
01096                                                         return(true);
01097                                                 }
01098                                                 break;
01099 
01100                                                 case IDC_ADD:
01101                                                 {
01102                                                         CString path;
01103                                                         m_path.GetWindowText(path);
01104                                                         if(!path.IsEmpty() && m_pathlist.FindString(-1, path) < 0)
01105                                                                 m_pathlist.AddString(path);
01106 
01107                                                         return(true);
01108                                                 }
01109                                                 break;
01110                                         }
01111                                 }
01112                                 break;
01113                         }
01114                 }
01115                 break;
01116         }
01117 
01118     return(false);
01119 }
01120 
01121 void CDVSPathsPPage::UpdateObjectData(bool fSave)
01122 {
01123         if(fSave)
01124         {
01125                 CString chk(_T("123456789")), path, tmp;
01126                 int i = 0;
01127                 do
01128                 {
01129                         tmp.Format(ResStr(IDS_RP_PATH), i++);
01130                         path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
01131                         if(path != chk) theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, _T(""));
01132                 }
01133                 while(path != chk);
01134 
01135                 for(i = 0; i < m_paths.GetSize(); i++)
01136                 {
01137                         tmp.Format(ResStr(IDS_RP_PATH), i);
01138                         theApp.WriteProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, m_paths[i]);
01139                 }
01140         }
01141         else
01142         {
01143                 CString chk(_T("123456789")), path, tmp;
01144                 int i = 0;
01145                 do
01146                 {
01147                         if(!path.IsEmpty()) m_paths.Add(path);
01148                         tmp.Format(ResStr(IDS_RP_PATH), i++);
01149                         path = theApp.GetProfileString(ResStr(IDS_R_DEFTEXTPATHES), tmp, chk);
01150                 }
01151                 while(path != chk);
01152         }
01153 }
01154 
01155 void CDVSPathsPPage::UpdateControlData(bool fSave)
01156 {
01157         if(fSave)
01158         {
01159                 m_paths.RemoveAll();
01160                 for(int i = 0; i < m_pathlist.GetCount(); i++) 
01161                 {
01162                         CString path;
01163                         m_pathlist.GetText(i, path);
01164                         m_paths.Add(path);
01165                 }
01166         }
01167         else
01168         {
01169                 m_pathlist.ResetContent();
01170                 for(int i = 0; i < m_paths.GetSize(); i++) 
01171                         m_pathlist.AddString(m_paths[i]);
01172 
01173                 m_remove.EnableWindow(FALSE);
01174                 m_add.EnableWindow(TRUE);
01175         }
01176 }

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