GME
13
|
00001 // GmeDlg.cpp : implementation file 00002 // 00003 //#undef _NO_SCRIPT_GUIDS 00004 00005 #include "stdafx.h" 00006 #include "MgaUtil.h" 00007 #include "GmeDlg.h" 00008 #include "DirDialog.h" 00009 #include "comcat.h" 00010 #include "UACUtils.h" 00011 00012 //#include "basetyps.h" 00013 const GUID CATID_ActiveScript = { 0xf0b7a1a1, 0x9847, 0x11cf, { 0x8f, 0x20, 0x0, 0x80, 0x5f, 0x2c, 0xd0, 0x64} }; 00014 00015 #ifdef _DEBUG 00016 #define new DEBUG_NEW 00017 #undef THIS_FILE 00018 static char THIS_FILE[] = __FILE__; 00019 #endif 00020 00021 /*static*/ const TCHAR* CGmeDlg::m_strZWidth = _T("Fit Width"); 00022 /*static*/ const TCHAR* CGmeDlg::m_strZHeight = _T("Fit Height"); 00023 /*static*/ const TCHAR* CGmeDlg::m_strZAll = _T("Fit All"); 00024 00025 /*static*/ const TCHAR* CGmeDlg::m_strFmtStrg = _T("%g"); 00026 /*static*/ const TCHAR* CGmeDlg::m_strFmtStrf = _T("%f"); 00027 /*static*/ const TCHAR* CGmeDlg::m_strFmtStrE = _T("%E"); 00028 /*static*/ const TCHAR* CGmeDlg::m_strFmtStre = _T("%e"); 00029 /*static*/ const TCHAR* CGmeDlg::m_strFmtStrg2 = _T("%.12g"); // the default one 00030 /*static*/ const TCHAR* CGmeDlg::m_strFmtStrf2 = _T("%lf"); 00031 00032 /*static*/ const TCHAR* CGmeDlg::m_strESStrD = _T("No Smooth"); 00033 /*static*/ const TCHAR* CGmeDlg::m_strESStrHS = _T("High Speed Mode"); 00034 /*static*/ const TCHAR* CGmeDlg::m_strESStrHQ = _T("High Quality Mode"); 00035 00036 /*static*/ const TCHAR* CGmeDlg::m_strFSStrSD = _T("System Default"); 00037 /*static*/ const TCHAR* CGmeDlg::m_strFSStrSBPPGF = _T("Single Bit Per Pixel Grid Fit"); 00038 /*static*/ const TCHAR* CGmeDlg::m_strFSStrSBPP = _T("Single Bit Per Pixel"); 00039 /*static*/ const TCHAR* CGmeDlg::m_strFSStrAAGF = _T("Anti Alias Grid Fit"); 00040 /*static*/ const TCHAR* CGmeDlg::m_strFSStrAA = _T("Anti Alias"); 00041 /*static*/ const TCHAR* CGmeDlg::m_strFSStrCTGF = _T("Clear Type Grid Fit"); 00042 00043 00045 // CGmeDlg dialog 00046 00047 00048 CGmeDlg::CGmeDlg(CWnd* pParent /*=NULL*/) 00049 : CDialog(CGmeDlg::IDD, pParent) 00050 { 00051 //{{AFX_DATA_INIT(CGmeDlg) 00052 m_iconpath = _T(""); 00053 m_sysiconpath = _T(""); 00054 m_multipleview = FALSE; 00055 m_enablelogging = TRUE; 00056 m_autosave_dir = _T(""); 00057 m_autosave_enabled = FALSE; 00058 m_autosave_freq = 0; 00059 m_autosave_dest = -1; 00060 m_ext_enable = FALSE; 00061 m_ext_editor = _T(""); 00062 m_useAutoRouting = TRUE; 00063 m_labelavoidance = FALSE; 00064 m_sendOverObj = FALSE; 00065 m_timeStamps = FALSE; 00066 m_navigationHistory = FALSE; 00067 //}}AFX_DATA_INIT 00068 m_scriptEngine = _T("JScript"); 00069 } 00070 00071 00072 void CGmeDlg::DoDataExchange(CDataExchange* pDX) 00073 { 00074 CDialog::DoDataExchange(pDX); 00075 //{{AFX_DATA_MAP(CGmeDlg) 00076 DDX_Control(pDX, IDC_LIST1, m_ScriptEgines); 00077 DDX_Text(pDX, IDC_ICONPATH, m_iconpath); 00078 DDX_Text(pDX, IDC_SYSICONPATH, m_sysiconpath); 00079 DDX_Check(pDX, IDC_MULTIPLE_OPEN, m_multipleview); 00080 DDX_Check(pDX, IDC_EVENT_LOGGING, m_enablelogging); 00081 DDX_Text(pDX, IDC_AUTOSAVE_DIR, m_autosave_dir); 00082 DDX_Check(pDX, IDC_AUTOSAVE_ENABLED, m_autosave_enabled); 00083 DDX_Text(pDX, IDC_AUTOSAVE_FREQ, m_autosave_freq); 00084 DDX_Radio(pDX, IDC_AUTOSAVE_SAME_DIR, m_autosave_dest); 00085 DDX_Check(pDX, IDC_EXT_ENABLE, m_ext_enable); 00086 DDX_Text(pDX, IDC_EXT_EDITOR, m_ext_editor); 00087 DDX_Check(pDX, IDC_AUTOROUTEDEFAULT, m_useAutoRouting); 00088 DDX_Check(pDX, IDC_LABELAVOIDANCE, m_labelavoidance); 00089 DDX_Check(pDX, IDC_SENDOVEROBJECT, m_sendOverObj); 00090 DDX_Check(pDX, IDC_TIMESTAMPING, m_timeStamps); 00091 DDX_Check(pDX, IDC_NAVIGATIONHISTORY, m_navigationHistory); 00092 //}}AFX_DATA_MAP 00093 } 00094 00095 00096 BEGIN_MESSAGE_MAP(CGmeDlg, CDialog) 00097 //{{AFX_MSG_MAP(CGmeDlg) 00098 ON_BN_CLICKED(IDC_ADDICONPATH, OnAddIconPath) 00099 ON_BN_CLICKED(IDC_ADDSYSICONPATH, OnAddsysiconpath) 00100 ON_BN_CLICKED(IDC_AUTOSAVE_DIR_BUTTON, OnAutosaveDirButton) 00101 ON_BN_CLICKED(IDC_AUTOSAVE_ENABLED, OnAutosaveEnabled) 00102 ON_BN_CLICKED(IDC_AUTOSAVE_SAME_DIR, OnAutosaveSameDir) 00103 ON_BN_CLICKED(IDC_AUTOSAVE_DEDICATED_DIR, OnAutosaveDedicatedDir) 00104 ON_BN_CLICKED(IDC_EXT_BUTTON, OnExtButton) 00105 ON_BN_CLICKED(IDC_EXT_ENABLE, OnExtEnable) 00106 //}}AFX_MSG_MAP 00107 ON_CBN_SELCHANGE(IDC_ZOOMS, OnCbnSelchangeZooms) 00108 END_MESSAGE_MAP() 00109 00111 // CGmeDlg message handlers 00112 00113 static TCHAR icofilter[] = _T("Icon files (*.ico;*.bmp)|*.ico;*.bmp|All Files (*.*)|*.*||"); 00114 static TCHAR bakfilter[] = _T("Backup files (*.bak)|*.bak|All Files (*.*)|*.*||"); 00115 static TCHAR exefilter[] = _T("Executable files (*.exe)|*.exe|All Files (*.*)|*.*||"); 00116 00117 //AFX_MANAGE_STATE( AfxGetStaticModuleState()); 00118 00119 // GMEVistaUtil.cpp: 00120 HRESULT VistaBrowseDirectory(CString& directory); 00121 00122 CString CGmeDlg::getDirectory( const CString& text = _T("Specify the icons directory")) 00123 { 00124 if (CUACUtils::isVistaOrLater()) 00125 { 00126 CString ret; 00127 HRESULT hr = VistaBrowseDirectory(ret); 00128 return ret; 00129 } 00130 00131 BROWSEINFO bi; 00132 TCHAR szDir[MAX_PATH]; 00133 CString Dir = _T(""); 00134 LPITEMIDLIST pidl; 00135 LPMALLOC pMalloc; 00136 OleInitialize(NULL); 00137 if (SUCCEEDED(SHGetMalloc(&pMalloc))) 00138 { 00139 ZeroMemory(&bi,sizeof(bi)); 00140 bi.hwndOwner = NULL; 00141 bi.pszDisplayName = 0; 00142 bi.lpszTitle = text; 00143 bi.pidlRoot = 0; 00144 bi.ulFlags = /*BIF_BROWSEINCLUDEFILES |*/ BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT | BIF_EDITBOX | BIF_VALIDATE ; 00145 bi.lpfn = NULL; 00146 //Displays a dialog box that enables the user to select a shell folder 00147 pidl = SHBrowseForFolder(&bi) ; 00148 if (pidl) 00149 { 00150 // Converts an item identifier list to a file system path 00151 if (!SHGetPathFromIDList(pidl,szDir)) 00152 { 00153 pMalloc->Free(pidl) ; 00154 pMalloc->Release() ; 00155 } 00156 pMalloc->Free(pidl); 00157 pMalloc->Release(); 00158 } 00159 else 00160 { // Selected 'Not to save' 00161 return _T(""); 00162 } 00163 Dir = szDir; 00164 //Dir += _T("\\"); 00165 } 00166 // end of getting directory info 00167 return Dir; 00168 } 00169 00170 void CGmeDlg::OnAddIconPath() 00171 { 00172 //CDirDialog dlg(NULL, icofilter, NULL); 00173 //dlg.DoModal(); 00174 //CString path = dlg.GetPath(); 00175 CString path = getDirectory(); 00176 00177 GetDlgItem(IDC_ICONPATH)->GetWindowText(m_iconpath); 00178 00179 if( !m_iconpath.IsEmpty() && !path.IsEmpty() ) 00180 m_iconpath += ';'; 00181 00182 m_iconpath += path; 00183 00184 GetDlgItem(IDC_ICONPATH)->SetWindowText(m_iconpath); 00185 } 00186 00187 00188 void CGmeDlg::OnAddsysiconpath() 00189 { 00190 //CDirDialog dlg(NULL, icofilter, NULL); 00191 //dlg.DoModal(); 00192 //CString path = dlg.GetPath(); 00193 CString path = getDirectory(); 00194 00195 GetDlgItem(IDC_SYSICONPATH)->GetWindowText(m_sysiconpath); 00196 00197 if( !m_sysiconpath.IsEmpty() && !path.IsEmpty() ) 00198 m_sysiconpath += ';'; 00199 00200 m_sysiconpath += path; 00201 00202 GetDlgItem(IDC_SYSICONPATH)->SetWindowText(m_sysiconpath); 00203 } 00204 00205 void CGmeDlg::fillScripEngineList() 00206 { 00207 // enumerate ScriptEngines -> m_scriptEngines ?? 00208 // set the current to m_scriptEngine 00209 CATID ourCatID; 00210 CComPtr<ICatInformation> pCatInformation; 00211 CComPtr<IEnumCLSID> pEnumGUID; 00212 HRESULT hResult = S_OK; 00213 00214 00215 m_ScriptEgines.InsertColumn( 0, _T(""), LVCFMT_LEFT, 205, -1 ); 00216 memcpy(&ourCatID, &CATID_ActiveScript, sizeof(ourCatID)); 00217 // memcpy(&ourCatID, &CATID_ActiveScriptParse, sizeof(ourCatID)); 00218 00219 hResult = pCatInformation.CoCreateInstance(CLSID_StdComponentCategoriesMgr); 00220 00221 hResult = pCatInformation->EnumClassesOfCategories( 00222 1, &ourCatID, ((ULONG) -1), NULL, &pEnumGUID); 00223 00224 int index = 0; 00225 bool sel = false; 00226 while (1) 00227 { 00228 CLSID ourCLSID; 00229 ULONG lCount = 0; 00230 BSTR str; 00231 00232 hResult = pEnumGUID->Next(1, &ourCLSID, &lCount); 00233 00234 if (lCount == 0) 00235 break; 00236 00237 hResult = ProgIDFromCLSID(ourCLSID, &str); 00238 00239 { 00240 CString pszString(str); 00241 00242 LVITEM lvItem; 00243 lvItem.mask = LVIF_PARAM | LVIF_STATE | LVIF_TEXT; 00244 if (!m_scriptEngine.Compare(pszString)) 00245 { 00246 lvItem.state = LVIS_SELECTED; 00247 sel = true; 00248 } 00249 else 00250 lvItem.state = 0; 00251 lvItem.stateMask = LVIS_SELECTED; 00252 00253 lvItem.iItem = index++; 00254 lvItem.iSubItem = 0; 00255 lvItem.lParam = lvItem.iItem; 00256 00257 lvItem.pszText = pszString.GetBuffer(pszString.GetLength()); 00258 int ret = m_ScriptEgines.InsertItem( &lvItem ); 00259 pszString.ReleaseBuffer(); 00260 } 00261 } 00262 if (!sel) 00263 { 00264 LVITEM lvItem; 00265 lvItem.mask = LVIF_STATE; 00266 lvItem.state = LVIS_SELECTED; 00267 lvItem.stateMask = LVIS_SELECTED; 00268 lvItem.iItem = 0; 00269 lvItem.iSubItem = 0; 00270 int ret1 = m_ScriptEgines.SetItem( &lvItem ); 00271 } 00272 } 00273 00274 BOOL CGmeDlg::OnInitDialog() 00275 { 00276 MSGTRY 00277 { 00278 ASSERT( registrar == NULL ); 00279 COMTHROW( registrar.CoCreateInstance(OLESTR("MGA.MgaRegistrar")) ); 00280 ASSERT( registrar != NULL ); 00281 00282 // Icons 00283 COMTHROW( registrar->get_IconPath(REGACCESS_USER, PutOut(m_iconpath)) ); 00284 COMTHROW( registrar->get_IconPath(REGACCESS_SYSTEM, PutOut(m_sysiconpath)) ); 00285 00286 m_isave = m_iconpath; 00287 m_sysisave = m_sysiconpath; 00288 CRegKey accessTest; 00289 if (accessTest.Open(HKEY_LOCAL_MACHINE, _T("SOFTWARE\\GME"), KEY_READ | KEY_WRITE) == ERROR_ACCESS_DENIED) { 00290 GetDlgItem(IDC_SYSICONPATH)->EnableWindow(false); 00291 GetDlgItem(IDC_ADDSYSICONPATH)->EnableWindow(false); 00292 } 00293 00294 // Multiview 00295 VARIANT_BOOL enabledmv; 00296 COMTHROW( registrar->get_ShowMultipleView(REGACCESS_USER, &enabledmv) ); 00297 m_multipleview = (enabledmv == VARIANT_FALSE) ? FALSE : TRUE; 00298 00299 // Logging 00300 VARIANT_BOOL enablelogging; 00301 COMTHROW( registrar->get_EventLoggingEnabled(REGACCESS_USER, &enablelogging) ); 00302 m_enablelogging = (enablelogging == VARIANT_FALSE) ? FALSE : TRUE; 00303 00304 // Autosave 00305 VARIANT_BOOL autosaveenable; 00306 COMTHROW( registrar->get_AutosaveEnabled(REGACCESS_USER, &autosaveenable) ); 00307 m_autosave_enabled = (autosaveenable == VARIANT_FALSE) ? FALSE : TRUE; 00308 00309 long autosavefreq; 00310 COMTHROW( registrar->get_AutosaveFreq(REGACCESS_USER, &autosavefreq) ); 00311 m_autosave_freq = (int)autosavefreq; 00312 00313 VARIANT_BOOL autosaveusedir; 00314 COMTHROW( registrar->get_AutosaveUseDir(REGACCESS_USER, &autosaveusedir) ); 00315 m_autosave_dest = (autosaveusedir == VARIANT_FALSE) ? 0 : 1; 00316 00317 COMTHROW( registrar->get_AutosaveDir(REGACCESS_USER, PutOut(m_autosave_dir)) ); 00318 00319 // External Editor 00320 VARIANT_BOOL extenable; 00321 COMTHROW( registrar->get_ExternalEditorEnabled(REGACCESS_USER, &extenable) ); 00322 m_ext_enable = (extenable == VARIANT_FALSE) ? FALSE : TRUE; 00323 00324 COMTHROW( registrar->get_ExternalEditor(REGACCESS_USER, PutOut(m_ext_editor)) ); 00325 00326 // Autorouter 00327 VARIANT_BOOL useAutoRouting; 00328 COMTHROW( registrar->get_UseAutoRouting(REGACCESS_USER, &useAutoRouting) ); 00329 m_useAutoRouting = (useAutoRouting == VARIANT_FALSE) ? FALSE : TRUE; 00330 00331 VARIANT_BOOL labelavoidance; 00332 COMTHROW( registrar->get_LabelAvoidance(REGACCESS_USER, &labelavoidance) ); 00333 m_labelavoidance = (labelavoidance == VARIANT_FALSE) ? FALSE : TRUE; 00334 00335 // Script 00336 COMTHROW( registrar->get_ScriptEngine(REGACCESS_USER, PutOut(m_scriptEngine)) ); 00337 if (m_scriptEngine == _T("")) 00338 m_scriptEngine = _T("JScript"); 00339 00340 // Zoom 00341 // COMMENT: 00342 // commented out until GMEView and other classes are capable of drawing at once in ZOOM_WIDTH,Z_HEIGHT,Z_ALL mode 00343 //int zoomvals[] = {ZOOM_MIN, 10, 25, 50, 75, ZOOM_NO, 150, 200, 300, ZOOM_MAX,ZOOM_WIDTH,ZOOM_HEIGHT,ZOOM_ALL,0}; 00344 int zoomvals[] = {ZOOM_MIN, 10, 25, 50, 75, ZOOM_NO, 150, 200, 300, ZOOM_MAX,0}; 00345 fillZoomComboBox( zoomvals); 00346 00347 CString set_val = getZoomValueFromReg(); 00348 setZoomValue( set_val); 00349 00350 // Send OverObject Notification? 00351 VARIANT_BOOL send_over_obj; 00352 COMTHROW( registrar->GetMouseOverNotify(REGACCESS_USER, &send_over_obj) ); 00353 m_sendOverObj = (send_over_obj == VARIANT_FALSE) ? FALSE : TRUE; 00354 00355 // format string pref 00356 fillFmtStrComboBox(); 00357 00358 // Console Timestamping 00359 VARIANT_BOOL console_timestamps; 00360 COMTHROW( registrar->GetTimeStamping( REGACCESS_USER, &console_timestamps)); 00361 m_timeStamps = ( console_timestamps == VARIANT_FALSE) ? FALSE : TRUE; 00362 00363 // History maintained 00364 VARIANT_BOOL history_maintained; 00365 COMTHROW( registrar->GetNavigation( REGACCESS_USER, &history_maintained)); 00366 m_navigationHistory = ( history_maintained == VARIANT_FALSE) ? FALSE : TRUE; 00367 00368 // Undo queue size 00369 fillUndoComboBox(); 00370 00371 // Edge smoothing mode 00372 fillEdgeSmoothModeComboBox(); 00373 00374 // Font smoothing mode 00375 fillFontSmoothModeComboBox(); 00376 } 00377 MSGCATCH(_T("Error while initializing GmeDlg"),;) 00378 00379 AutosaveControlManager(); 00380 ExtControlManager(); 00381 CDialog::OnInitDialog(); 00382 fillScripEngineList(); 00383 00384 return TRUE; // return TRUE unless you set the focus to a control 00385 // EXCEPTION: OCX Property Pages should return FALSE 00386 } 00387 00388 void CGmeDlg::OnOK() 00389 { 00390 CDialog::OnOK(); 00391 00392 ASSERT( registrar != NULL ); 00393 // Icons 00394 if(m_iconpath.Compare(m_isave)) COMTHROW( registrar->put_IconPath(REGACCESS_USER, PutInBstr(m_iconpath)) ); 00395 if(m_sysiconpath.Compare(m_sysisave)) COMTHROW( registrar->put_IconPath(REGACCESS_SYSTEM, PutInBstr(m_sysiconpath)) ); 00396 00397 // Multiview 00398 VARIANT_BOOL enabledmv = (m_multipleview == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00399 COMTHROW( registrar->put_ShowMultipleView(REGACCESS_USER, enabledmv) ); 00400 00401 // Logging 00402 VARIANT_BOOL enablelogging = (m_enablelogging == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00403 COMTHROW( registrar->put_EventLoggingEnabled(REGACCESS_USER, enablelogging) ); 00404 00405 // Autosave 00406 VARIANT_BOOL autosaveenable = (m_autosave_enabled == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00407 COMTHROW( registrar->put_AutosaveEnabled(REGACCESS_USER, autosaveenable) ); 00408 00409 long autosavefreq = m_autosave_freq; 00410 COMTHROW( registrar->put_AutosaveFreq(REGACCESS_USER, autosavefreq) ); 00411 00412 VARIANT_BOOL autosaveusedir = (m_autosave_dest == 1) ? VARIANT_TRUE : VARIANT_FALSE; 00413 COMTHROW( registrar->put_AutosaveUseDir(REGACCESS_USER, autosaveusedir) ); 00414 00415 COMTHROW( registrar->put_AutosaveDir(REGACCESS_USER, PutInBstr(m_autosave_dir)) ); 00416 00417 // External Editor 00418 VARIANT_BOOL extenable = (m_ext_enable == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00419 COMTHROW( registrar->put_ExternalEditorEnabled(REGACCESS_USER, extenable) ); 00420 00421 COMTHROW( registrar->put_ExternalEditor(REGACCESS_USER, PutInBstr(m_ext_editor)) ); 00422 00423 // Autorouter 00424 VARIANT_BOOL useAutoRouting = (m_useAutoRouting == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00425 COMTHROW( registrar->put_UseAutoRouting(REGACCESS_USER, useAutoRouting) ); 00426 00427 VARIANT_BOOL labelavoidance = (m_labelavoidance == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00428 COMTHROW( registrar->put_LabelAvoidance(REGACCESS_USER, labelavoidance) ); 00429 00430 // ScriptEngine 00431 // m_scriptEngine <- current item from m_scriptEngines ?? 00432 POSITION pos = m_ScriptEgines.GetFirstSelectedItemPosition(); 00433 if (pos != NULL) 00434 { 00435 int nItem = m_ScriptEgines.GetNextSelectedItem(pos); 00436 m_scriptEngine = m_ScriptEgines.GetItemText(nItem, 0); 00437 } 00438 COMTHROW( registrar->put_ScriptEngine(REGACCESS_USER, PutInBstr(m_scriptEngine)) ); 00439 00440 // Zoom 00441 CString val_sel = getZoomValue(); 00442 COMTHROW( registrar->SetDefZoomLevel( REGACCESS_USER, PutInBstr(val_sel))); 00443 00444 // Send Mouse Over Object Notification 00445 VARIANT_BOOL send_over_obj = (m_sendOverObj == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00446 COMTHROW( registrar->SetMouseOverNotify(REGACCESS_USER, send_over_obj) ); 00447 00448 // format string 00449 CString fmt_sel = getFmtStrValue(); 00450 COMTHROW( registrar->SetRealNmbFmtStr(REGACCESS_USER, PutInBstr(fmt_sel))); 00451 00452 // console timestamping 00453 VARIANT_BOOL console_timestamping = ( m_timeStamps == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00454 COMTHROW( registrar->SetTimeStamping( REGACCESS_USER, console_timestamping) ); 00455 00456 // History maintained 00457 VARIANT_BOOL enable_navigation = ( m_navigationHistory == FALSE) ? VARIANT_FALSE : VARIANT_TRUE; 00458 COMTHROW( registrar->SetNavigation( REGACCESS_USER, enable_navigation) ); 00459 00460 // Undo queue size 00461 CString undo_queue_size = getUndoQueueSizeValue(); 00462 COMTHROW( registrar->SetUndoQueueSize( REGACCESS_USER, PutInBstr( undo_queue_size)) ); 00463 00464 // Edge smoothing mode 00465 edgesmoothmode_enum edgeSmoothMode = getEdgeSmoothModeValue(); 00466 COMTHROW( registrar->put_EdgeSmoothMode( REGACCESS_USER, edgeSmoothMode) ); 00467 00468 // Font smoothing mode 00469 fontsmoothmode_enum fontSmoothMode = getFontSmoothModeValue(); 00470 COMTHROW( registrar->put_FontSmoothMode( REGACCESS_USER, fontSmoothMode) ); 00471 } 00472 00473 00474 00475 void CGmeDlg::OnAutosaveDirButton() 00476 { 00477 //CDirDialog dlg(NULL, bakfilter, NULL); 00478 00479 //dlg.DoModal(); 00480 UpdateData(TRUE); 00481 //m_autosave_dir = dlg.GetPath(); 00482 m_autosave_dir = getDirectory(_T("Select output directory for autosave")); 00483 UpdateData(FALSE); 00484 } 00485 00486 void CGmeDlg::OnAutosaveEnabled() 00487 { 00488 UpdateData(TRUE); 00489 AutosaveControlManager(); 00490 } 00491 00492 void CGmeDlg::OnAutosaveSameDir() 00493 { 00494 UpdateData(TRUE); 00495 AutosaveControlManager(); 00496 } 00497 00498 void CGmeDlg::OnAutosaveDedicatedDir() 00499 { 00500 UpdateData(TRUE); 00501 AutosaveControlManager(); 00502 } 00503 00504 void CGmeDlg::AutosaveControlManager() 00505 { 00506 // NOTE: we assume, that the exchange data members are 00507 // holding valid data. So, please call UpdateData if needed 00508 // prior calling this 00509 00510 BOOL freqEnabled = FALSE; 00511 BOOL sameDirEnabled = FALSE; 00512 BOOL dedicatedDirEnabled = FALSE; 00513 BOOL dirEnabled = FALSE; 00514 BOOL dirButtonEnabled = FALSE; 00515 00516 if (m_autosave_enabled) { 00517 freqEnabled = TRUE; 00518 sameDirEnabled = TRUE; 00519 dedicatedDirEnabled = TRUE; 00520 if (m_autosave_dest == 1) { 00521 dirEnabled = TRUE; 00522 dirButtonEnabled = TRUE; 00523 } 00524 } 00525 00526 GetDlgItem(IDC_AUTOSAVE_FREQ)->EnableWindow(freqEnabled); 00527 GetDlgItem(IDC_AUTOSAVE_SAME_DIR)->EnableWindow(sameDirEnabled); 00528 GetDlgItem(IDC_AUTOSAVE_DEDICATED_DIR)->EnableWindow(dedicatedDirEnabled); 00529 GetDlgItem(IDC_AUTOSAVE_DIR)->EnableWindow(dirEnabled); 00530 GetDlgItem(IDC_AUTOSAVE_DIR_BUTTON)->EnableWindow(dirButtonEnabled); 00531 } 00532 00533 void CGmeDlg::ExtControlManager() 00534 { 00535 // NOTE: we assume, that the exchange data members are 00536 // holding valid data. So, please call UpdateData if needed 00537 // prior calling this 00538 GetDlgItem(IDC_EXT_EDITOR)->EnableWindow(m_ext_enable); 00539 GetDlgItem(IDC_EXT_BUTTON)->EnableWindow(m_ext_enable); 00540 } 00541 00542 void CGmeDlg::OnExtButton() 00543 { 00544 UpdateData(TRUE); 00545 CFileDialog dlg(TRUE, NULL, m_ext_editor, OFN_HIDEREADONLY, exefilter, NULL); 00546 if (dlg.DoModal() == IDOK) { 00547 m_ext_editor = dlg.GetPathName(); 00548 UpdateData(FALSE); 00549 } 00550 } 00551 00552 void CGmeDlg::OnExtEnable() 00553 { 00554 UpdateData(TRUE); 00555 ExtControlManager(); 00556 } 00557 00558 void CGmeDlg::fillZoomComboBox(int *list) 00559 { 00560 if (!list) return; 00561 00562 // supposed it is sorted, copy the values into the member 00563 int i; 00564 for( i = 0; list[i] != 0 && i < MAX_ZOOM-1; ++i) 00565 { 00566 m_zoomList[i] = list[i]; 00567 } 00568 if( i <= MAX_ZOOM-1) m_zoomList[i] = 0; 00569 00570 // transform the integer values to strings, and add to the comboBox 00571 CComboBox* zoom = 0; 00572 zoom = (CComboBox*)GetDlgItem(IDC_ZOOMS); 00573 for( int k=0; m_zoomList[k] != 0; ++k) 00574 { 00575 CString str; 00576 if (m_zoomList[k] > 0) 00577 { 00578 TCHAR buff[100]; 00579 _itot(m_zoomList[k], buff, 10); 00580 str = buff; 00581 str += _T("%"); 00582 } 00583 /*else // commented out for a while (see COMMENT above) 00584 { 00585 switch (m_zoomList[k]) 00586 { 00587 case ZOOM_WIDTH: 00588 str = m_strZWidth; 00589 break; 00590 case ZOOM_HEIGHT: 00591 str = m_strZHeight; 00592 break; 00593 case ZOOM_ALL: 00594 str = m_strZAll; 00595 break; 00596 } 00597 }*/ 00598 zoom->AddString(str); 00599 } 00600 } 00601 00602 CString CGmeDlg::getZoomValueFromReg() 00603 { 00604 CString def_zoom; 00605 CComBSTR bs_def_zoom; 00606 COMTHROW( registrar->GetDefZoomLevel( REGACCESS_USER, &bs_def_zoom)); 00607 if( bs_def_zoom) 00608 CopyTo( bs_def_zoom, def_zoom); 00609 00610 int level = 100; 00611 int zv = 0; 00612 int l = _stscanf( (LPCTSTR) def_zoom, _T("%d"), &zv); 00613 if( l == 1 && zv ) 00614 level = zv; 00615 00616 CString str; 00617 if (level > 0) 00618 { 00619 TCHAR buff[100]; 00620 _itot(level, buff, 10); 00621 str = buff; 00622 str += _T("%"); 00623 } 00624 /*else // for now do not accept: ZOOM_WIDTH, ZOOM_HEIGHT, ZOOM_ALL values from the registry, see COMMENT above 00625 { 00626 switch (level) 00627 { 00628 case ZOOM_WIDTH: 00629 str = m_strZWidth; 00630 break; 00631 case ZOOM_HEIGHT: 00632 str = m_strZHeight; 00633 break; 00634 case ZOOM_ALL: 00635 str = m_strZAll; 00636 break; 00637 } 00638 }*/ 00639 00640 if( str.IsEmpty()) 00641 str = _T("100%"); 00642 return str; 00643 } 00644 00645 CString CGmeDlg::getZoomValue() 00646 { 00647 CString res(_T("100")); 00648 CWnd* zoom = 0; 00649 zoom = GetDlgItem(IDC_ZOOMS); 00650 if (zoom) 00651 { 00652 CEdit* edit = 0; 00653 edit = (CEdit*)(zoom->GetDlgItem(1001)); 00654 if (edit) 00655 { 00656 CString buff = CEditGetLine(*edit, 0); 00657 00658 int zv = 0; 00659 /* for now accept only positive numbers, commented out, see COMMENT above 00660 if( strcmp( m_strZWidth, buff) == 0) 00661 zv = ZOOM_WIDTH; 00662 else if( strcmp( m_strZHeight, buff) == 0) 00663 zv = ZOOM_HEIGHT; 00664 else if( strcmp( m_strZAll, buff) == 0) 00665 zv = ZOOM_ALL; 00666 else 00667 { 00668 int l = _stscanf( buff, _T("%d"), &zv); 00669 if( l != 1 || zv < ZOOM_MIN || zv > ZOOM_MAX) 00670 zv = 100; 00671 } 00672 00673 if( !zv || zv > 0 && zv < ZOOM_MIN || zv > 0 && zv > ZOOM_MAX 00674 || zv < 0 && zv != ZOOM_WIDTH && zv != ZOOM_HEIGHT && zv != ZOOM_ALL) 00675 zv = 100; 00676 */ 00677 00678 int l = _stscanf( buff, _T("%d"), &zv); 00679 if( l != 1 || zv < ZOOM_MIN || zv > ZOOM_MAX) 00680 zv = 100; 00681 00682 _itot(zv, buff.GetBuffer(35), 10); 00683 buff.ReleaseBuffer(); 00684 res = buff; 00685 } 00686 } 00687 return res; 00688 } 00689 00690 void CGmeDlg::setZoomValue(CString& val ) 00691 { 00692 CWnd* zoom = 0; 00693 zoom = GetDlgItem(IDC_ZOOMS); 00694 if (zoom) 00695 { 00696 CEdit* edit = 0; 00697 edit = (CEdit*)(zoom->GetDlgItem(1001)); 00698 if (edit) 00699 { 00700 edit->ReplaceSel( val); 00701 } 00702 } 00703 } 00704 00705 void CGmeDlg::fillFmtStrComboBox() 00706 { 00707 CComboBox* fmtBox = 0; 00708 fmtBox = (CComboBox*)GetDlgItem(IDC_CMBFMTSTRS); 00709 fmtBox->AddString( m_strFmtStrg); 00710 fmtBox->AddString( m_strFmtStrf); 00711 fmtBox->AddString( m_strFmtStre); 00712 fmtBox->AddString( m_strFmtStrE); 00713 fmtBox->AddString( m_strFmtStrg2); 00714 fmtBox->AddString( m_strFmtStrf2); 00715 00716 CString regv = getFmtStrFromReg(); 00717 int pos = fmtBox->FindStringExact( -1, regv); 00718 if( pos == CB_ERR) 00719 fmtBox->InsertString( -1, regv); 00720 fmtBox->SelectString( -1, regv); 00721 } 00722 00723 CString CGmeDlg::getFmtStrFromReg() 00724 { 00725 CString fmt_str; 00726 CComBSTR bs_fmt_str; 00727 COMTHROW( registrar->GetRealNmbFmtStr( REGACCESS_USER, &bs_fmt_str)); 00728 if( bs_fmt_str) 00729 CopyTo( bs_fmt_str, fmt_str); 00730 00731 if( fmt_str.IsEmpty()) 00732 fmt_str = m_strFmtStrg2; 00733 00734 return fmt_str; 00735 } 00736 00737 CString CGmeDlg::getFmtStrValue() 00738 { 00739 CString res( m_strFmtStrg2); 00740 CWnd* combo = 0; 00741 combo = GetDlgItem(IDC_CMBFMTSTRS); 00742 if( combo) 00743 { 00744 CEdit* edit = 0; 00745 edit = (CEdit*)( combo->GetDlgItem(1001)); 00746 if( edit) 00747 { 00748 res = CEditGetLine(*edit, 0); 00749 } 00750 } 00751 return res; 00752 } 00753 00754 void CGmeDlg::fillUndoComboBox() 00755 { 00756 CComboBox* sz_list = 0; 00757 sz_list = (CComboBox*)GetDlgItem(IDC_UNDOSIZE); 00758 sz_list->AddString(_T("1")); 00759 sz_list->AddString(_T("10")); 00760 00761 CString regv = getUndoQueueSizeFromReg(); 00762 int pos = sz_list->FindStringExact( -1, regv); 00763 if( pos == CB_ERR) 00764 sz_list->InsertString( -1, regv); 00765 sz_list->SelectString( -1, regv); 00766 00767 } 00768 00769 CString CGmeDlg::getUndoQueueSizeFromReg() 00770 { 00771 CString queuesize; 00772 COMTHROW( registrar->GetUndoQueueSize( REGACCESS_USER, PutOut( queuesize)) ); 00773 if( queuesize.IsEmpty()) 00774 queuesize = _T("10"); 00775 00776 return queuesize; 00777 } 00778 00779 CString CGmeDlg::getUndoQueueSizeValue() 00780 { 00781 CString res( _T("10")); 00782 CWnd* combo = 0; 00783 combo = GetDlgItem(IDC_UNDOSIZE); 00784 if( combo) 00785 { 00786 CEdit* edit = 0; 00787 edit = (CEdit*)( combo->GetDlgItem(1001)); 00788 if (edit) 00789 { 00790 CString buff = CEditGetLine(*edit, 0); 00791 int value = _ttoi(buff); 00792 if (value > 0 && value < 100) // above 0 and below 100 00793 res = buff; 00794 } 00795 } 00796 return res; 00797 } 00798 00799 void CGmeDlg::fillEdgeSmoothModeComboBox() 00800 { 00801 CComboBox* modeBox = 0; 00802 modeBox = (CComboBox*)GetDlgItem(IDC_EDGESMOOTHMODE); 00803 modeBox->AddString(m_strESStrD); 00804 modeBox->AddString(m_strESStrHS); 00805 modeBox->AddString(m_strESStrHQ); 00806 00807 CString regv = getEdgeSmoothModeStrFromReg(); 00808 int pos = modeBox->FindStringExact(-1, regv); 00809 if (pos == CB_ERR) 00810 modeBox->InsertString(-1, regv); 00811 modeBox->SelectString(-1, regv); 00812 } 00813 00814 CString CGmeDlg::getEdgeSmoothModeStrFromReg() 00815 { 00816 edgesmoothmode_enum edgeSmoothMode; 00817 COMTHROW(registrar->get_EdgeSmoothMode(REGACCESS_USER, &edgeSmoothMode)); 00818 CString reg_str; 00819 switch(edgeSmoothMode) { 00820 case EdgeSmooth_NoSmooth: reg_str = m_strESStrD; break; 00821 case EdgeSmooth_HighSpeedMode: reg_str = m_strESStrHS; break; 00822 default: 00823 case EdgeSmooth_HighQualityMode: reg_str = m_strESStrHQ; break; 00824 } 00825 return reg_str; 00826 } 00827 00828 edgesmoothmode_enum CGmeDlg::getEdgeSmoothModeValue() 00829 { 00830 CString res(m_strESStrHQ); 00831 CWnd* combo = 0; 00832 combo = GetDlgItem(IDC_EDGESMOOTHMODE); 00833 if (combo) 00834 { 00835 CEdit* edit = 0; 00836 edit = (CEdit*)(combo->GetDlgItem(1001)); 00837 if (edit) 00838 { 00839 res = CEditGetLine(*edit, 0); 00840 } 00841 } 00842 edgesmoothmode_enum edgeSmoothMode = EdgeSmooth_HighQualityMode; 00843 if (res == m_strESStrD) 00844 edgeSmoothMode = EdgeSmooth_NoSmooth; 00845 else if (res == m_strESStrHS) 00846 edgeSmoothMode = EdgeSmooth_HighSpeedMode; 00847 else if (res == m_strESStrHQ) 00848 edgeSmoothMode = EdgeSmooth_HighQualityMode; 00849 return edgeSmoothMode; 00850 } 00851 00852 void CGmeDlg::fillFontSmoothModeComboBox() 00853 { 00854 CComboBox* modeBox = 0; 00855 modeBox = (CComboBox*)GetDlgItem(IDC_FONTSMOOTHMODE); 00856 modeBox->AddString(m_strFSStrSD); 00857 modeBox->AddString(m_strFSStrSBPPGF); 00858 modeBox->AddString(m_strFSStrSBPP); 00859 modeBox->AddString(m_strFSStrAAGF); 00860 modeBox->AddString(m_strFSStrAA); 00861 modeBox->AddString(m_strFSStrCTGF); 00862 00863 CString regv = getFontSmoothModeStrFromReg(); 00864 int pos = modeBox->FindStringExact(-1, regv); 00865 if (pos == CB_ERR) 00866 modeBox->InsertString(-1, regv); 00867 modeBox->SelectString(-1, regv); 00868 } 00869 00870 CString CGmeDlg::getFontSmoothModeStrFromReg() 00871 { 00872 fontsmoothmode_enum fontSmoothMode; 00873 COMTHROW(registrar->get_FontSmoothMode(REGACCESS_USER, &fontSmoothMode)); 00874 CString reg_str; 00875 switch(fontSmoothMode) { 00876 case FontSmooth_SystemDefault: reg_str = m_strFSStrSD; break; 00877 case FontSmooth_SingleBitPerPixelGridFit: reg_str = m_strFSStrSBPPGF; break; 00878 case FontSmooth_SingleBitPerPixel: reg_str = m_strFSStrSBPP; break; 00879 case FontSmooth_AntiAliasGridFit: reg_str = m_strFSStrAAGF; break; 00880 default: 00881 case FontSmooth_AntiAlias: reg_str = m_strFSStrAA; break; 00882 case FontSmooth_ClearTypeGridFit: reg_str = m_strFSStrCTGF; break; 00883 } 00884 return reg_str; 00885 } 00886 00887 fontsmoothmode_enum CGmeDlg::getFontSmoothModeValue() 00888 { 00889 CString res(m_strFSStrAA); 00890 CWnd* combo = 0; 00891 combo = GetDlgItem(IDC_FONTSMOOTHMODE); 00892 if (combo) 00893 { 00894 CEdit* edit = 0; 00895 edit = (CEdit*)(combo->GetDlgItem(1001)); 00896 if (edit) 00897 { 00898 res = CEditGetLine(*edit, 0); 00899 } 00900 } 00901 fontsmoothmode_enum fontSmoothMode = FontSmooth_AntiAlias; 00902 if (res == m_strFSStrSD) 00903 fontSmoothMode = FontSmooth_SystemDefault; 00904 else if (res == m_strFSStrSBPPGF) 00905 fontSmoothMode = FontSmooth_SingleBitPerPixelGridFit; 00906 else if (res == m_strFSStrSBPP) 00907 fontSmoothMode = FontSmooth_SingleBitPerPixel; 00908 else if (res == m_strFSStrAAGF) 00909 fontSmoothMode = FontSmooth_AntiAliasGridFit; 00910 else if (res == m_strFSStrAA) 00911 fontSmoothMode = FontSmooth_AntiAlias; 00912 else if (res == m_strFSStrCTGF) 00913 fontSmoothMode = FontSmooth_ClearTypeGridFit; 00914 return fontSmoothMode; 00915 } 00916 00917 void CGmeDlg::OnCbnSelchangeZooms() 00918 { 00919 // TODO: Add your control notification handler code here 00920 }