Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

appui.cpp

Go to the documentation of this file.
00001 /****************************************************************************** 00002 00003 Source File: AppUI.CPP 00004 00005 This file implements the Application UI. This consists of two (ANSI/UNICODE) 00006 functions that allow an application to specify profiles to be used, and so 00007 forth. 00008 00009 Copyright (c) 1996 by Microsoft Corporation 00010 00011 A Pretty Penny Enterprises Production 00012 00013 Change History: 00014 12-11-96 [email protected] Created it 00015 00016 ******************************************************************************/ 00017 00018 #include "ICMUI.H" 00019 00020 CONST DWORD ApplicationUIHelpIds[] = { 00021 ApplyButton, IDH_ICMUI_APPLY, 00022 EnableICM, IDH_APPUI_ICM, 00023 EnableBasic, IDH_APPUI_BASIC, 00024 EnableProofing, IDH_APPUI_PROOF, 00025 MonitorProfile, IDH_APPUI_MONITOR, 00026 MonitorProfileLabel, IDH_APPUI_MONITOR, 00027 PrinterProfile, IDH_APPUI_PRINTER, 00028 PrinterProfileLabel, IDH_APPUI_PRINTER, 00029 RenderingIntent, IDH_APPUI_INTENT, 00030 RenderingIntentLabel, IDH_APPUI_INTENT, 00031 TargetProfile, IDH_APPUI_EMULATE, 00032 TargetProfileLabel, IDH_APPUI_EMULATE, 00033 TargetIntent, IDH_APPUI_INTENT, 00034 TargetIntentLabel, IDH_APPUI_INTENT, 00035 #if !defined(_WIN95_) // context-sentitive help 00036 // SourceProfile, IDH_APPUI_SOURCE, 00037 SourceProfileLabel, IDH_APPUI_SOURCE, 00038 #endif 00039 0, 0 00040 }; 00041 00042 class CColorMatchDialog : public CDialog { 00043 00044 BOOL m_bSuccess, m_bEnableICM, m_bEnableProofing, m_bColorPrinter; 00045 00046 CString m_csSource, m_csMonitor, m_csPrinter, 00047 m_csMonitorProfile, m_csPrinterProfile, m_csTargetProfile; 00048 00049 CString m_csMonitorDisplayName; // since displayName != deviceName for monitor. 00050 00051 CStringArray m_csaMonitor, m_csaPrinter, m_csaTarget; 00052 CStringArray m_csaMonitorDesc, m_csaPrinterDesc, m_csaTargetDesc; 00053 00054 // For handy reference (from Setup structure) 00055 00056 DWORD m_dwRenderIntent, m_dwProofIntent; 00057 00058 // To reduce stack usage and code size 00059 00060 HWND m_hwndRenderIntent, m_hwndTargetIntent, m_hwndMonitorList, 00061 m_hwndPrinterList, m_hwndTargetList, m_hwndIntentText1, 00062 m_hwndIntentLabel, m_hwndTargetProfileLabel, m_hwndTargetIntentLabel, 00063 m_hwndMonitorProfileLabel, m_hwndPrinterProfileLabel; 00064 00065 // For Apply callback 00066 00067 PCMSCALLBACK m_dpApplyCallback; 00068 LPARAM m_lpApplyCallback; 00069 00070 // To identify callee 00071 00072 BOOL m_bAnsiCall; 00073 00074 // Display profile description or filename 00075 00076 BOOL m_bUseProfileDescription; 00077 00078 // Intent control 00079 00080 BOOL m_bDisableIntent, m_bDisableRenderIntent; 00081 00082 // Pointer to COLORMATCHSETUP[A|W] 00083 00084 PVOID m_pvCMS; 00085 00086 void Fail(DWORD dwError); 00087 BOOL GoodParms(PCOLORMATCHSETUP pcms); 00088 void CompleteInitialization(); 00089 void UpdateControls(BOOL bChanged = FALSE); 00090 00091 void FillStructure(COLORMATCHSETUPA *pcms); 00092 void FillStructure(COLORMATCHSETUPW *pcms); 00093 00094 void EnableApplyButton(BOOL bEnable = TRUE); 00095 00096 public: 00097 00098 CColorMatchDialog(COLORMATCHSETUPA *pcms); 00099 CColorMatchDialog(COLORMATCHSETUPW *pcms); 00100 00101 ~CColorMatchDialog() { 00102 m_csaMonitor.Empty(); 00103 m_csaPrinter.Empty(); 00104 m_csaTarget.Empty(); 00105 m_csaMonitorDesc.Empty(); 00106 m_csaPrinterDesc.Empty(); 00107 m_csaTargetDesc.Empty(); 00108 m_csSource.Empty(); 00109 m_csMonitor.Empty(); 00110 m_csPrinter.Empty(); 00111 m_csMonitorProfile.Empty(); 00112 m_csPrinterProfile.Empty(); 00113 m_csTargetProfile.Empty(); 00114 m_csMonitorDisplayName.Empty(); 00115 } 00116 00117 BOOL Results() const { return m_bSuccess; } 00118 00119 virtual BOOL OnInit(); 00120 00121 virtual BOOL OnCommand(WORD wNotifyCode, WORD wid, HWND hwndCtl); 00122 00123 virtual BOOL OnHelp(LPHELPINFO pHelp); 00124 virtual BOOL OnContextMenu(HWND hwnd); 00125 }; 00126 00127 // Record a failure 00128 00129 void CColorMatchDialog::Fail(DWORD dwError) { 00130 SetLastError(dwError); 00131 m_bSuccess = FALSE; 00132 } 00133 00134 // Report input parameter validity 00135 00136 BOOL CColorMatchDialog::GoodParms(PCOLORMATCHSETUP pcms) { 00137 00138 m_bSuccess = TRUE; 00139 00140 if (!pcms || pcms -> dwVersion != COLOR_MATCH_VERSION || 00141 pcms -> dwSize != sizeof *pcms || !pcms -> pMonitorProfile || 00142 !pcms -> pPrinterProfile || !pcms -> pTargetProfile || 00143 !pcms -> ccMonitorProfile || !pcms -> ccPrinterProfile || 00144 !pcms -> ccTargetProfile) { 00145 Fail(ERROR_INVALID_PARAMETER); 00146 return FALSE; 00147 } 00148 00149 if (pcms -> dwFlags & CMS_USEHOOK && !pcms -> lpfnHook) 00150 Fail(ERROR_INVALID_PARAMETER); 00151 00152 if (pcms -> dwFlags & CMS_USEAPPLYCALLBACK && !pcms -> lpfnApplyCallback) 00153 Fail(ERROR_INVALID_PARAMETER); 00154 00155 if (pcms -> dwFlags & CMS_SETRENDERINTENT && 00156 pcms -> dwRenderIntent > INTENT_ABSOLUTE_COLORIMETRIC) 00157 Fail(ERROR_INVALID_PARAMETER); 00158 00159 if (pcms -> dwFlags & CMS_SETPROOFINTENT && 00160 pcms -> dwFlags & CMS_ENABLEPROOFING && 00161 pcms -> dwProofingIntent > INTENT_ABSOLUTE_COLORIMETRIC) 00162 Fail(ERROR_INVALID_PARAMETER); 00163 00164 // Setup the hooking, if needed 00165 00166 if (pcms -> dwFlags & CMS_USEHOOK) { 00167 m_dpHook = pcms -> lpfnHook; 00168 m_lpHook = pcms -> lParam; 00169 } 00170 00171 // Setup the callback for apply, if needed 00172 00173 if (pcms -> dwFlags & CMS_USEAPPLYCALLBACK) { 00174 m_dpApplyCallback = pcms -> lpfnApplyCallback; 00175 m_lpApplyCallback = pcms -> lParamApplyCallback; 00176 } else { 00177 m_dpApplyCallback = NULL; 00178 m_lpApplyCallback = 0L; 00179 } 00180 00181 // Cache the flags... 00182 00183 DWORD dwFlags = pcms -> dwFlags; 00184 00185 // Init the intents 00186 00187 m_dwRenderIntent = (dwFlags & CMS_SETRENDERINTENT) ? 00188 pcms -> dwRenderIntent : INTENT_PERCEPTUAL; 00189 00190 m_dwProofIntent = (dwFlags & CMS_SETPROOFINTENT) && (dwFlags & CMS_ENABLEPROOFING) ? 00191 pcms -> dwProofingIntent : m_dwRenderIntent; 00192 00193 // Init the flags 00194 00195 m_bEnableICM = !(dwFlags & CMS_DISABLEICM); 00196 m_bEnableProofing = !!(dwFlags & CMS_ENABLEPROOFING); 00197 00198 m_bUseProfileDescription = !!(dwFlags & CMS_USEDESCRIPTION); 00199 00200 m_bDisableIntent = !!(dwFlags & CMS_DISABLEINTENT); 00201 m_bDisableRenderIntent = !!(dwFlags & CMS_DISABLERENDERINTENT); 00202 00203 // Init the pointer to buffer 00204 00205 m_pvCMS = (PVOID) pcms; 00206 00207 return m_bSuccess; 00208 } 00209 00210 // Encoding-independent construction actions 00211 00212 void CColorMatchDialog::CompleteInitialization() { 00213 00214 // Determine the appropriate source, monitor and printer names 00215 00216 if (m_csSource.IsEmpty()) 00217 m_csSource.Load(DefaultSourceString); 00218 00219 // Check the validation for monitor name. 00220 00221 CMonitorList cml; 00222 cml.Enumerate(); 00223 00224 if (!cml.IsValidDeviceName(m_csMonitor)) { 00225 00226 // Get primary device. 00227 00228 m_csMonitor = cml.PrimaryDeviceName(); 00229 } 00230 00231 // Map display name from device name 00232 00233 m_csMonitorDisplayName = cml.DeviceNameToDisplayName(m_csMonitor); 00234 00235 // Check the validation for printer name. 00236 00237 HANDLE hPrinter; 00238 00239 if (!m_csPrinter.IsEmpty() && OpenPrinter(m_csPrinter,&hPrinter,NULL)) { 00240 00241 // The specified printer has been found. 00242 00243 ClosePrinter(hPrinter); 00244 00245 } else { 00246 00247 // The specified printer has not been found, 00248 // Get the default printer name- do it the old, slimy way... 00249 00250 TCHAR acBuffer[MAX_PATH]; 00251 00252 GetProfileString(_TEXT("Windows"), _TEXT("Device"), _TEXT(""), 00253 acBuffer, MAX_PATH); 00254 00255 // The buffer will contains "PrinterName,DriverName,Port". 00256 // What we need is only printer name. 00257 00258 TCHAR *pTmp = acBuffer; 00259 00260 while (*pTmp) { 00261 if (*pTmp == __TEXT(',')) { 00262 *pTmp = NULL; 00263 break; 00264 } 00265 pTmp++; 00266 } 00267 00268 m_csPrinter = acBuffer; 00269 } 00270 00271 if (CGlobals::ThisIsAColorPrinter(m_csPrinter)) 00272 m_bColorPrinter = TRUE; 00273 else 00274 m_bColorPrinter = FALSE; 00275 00276 // Now, we collect the names 00277 00278 ENUMTYPE et = { sizeof et, ENUM_TYPE_VERSION, (ET_DEVICENAME|ET_DEVICECLASS) }; 00279 00280 // Enumrate monitor. 00281 00282 et.pDeviceName = m_csMonitor; 00283 et.dwDeviceClass = CLASS_MONITOR; 00284 CProfile::Enumerate(et, m_csaMonitor, m_csaMonitorDesc); 00285 00286 // Enumrate only for Color Printer. 00287 00288 if (m_bColorPrinter) { 00289 et.pDeviceName = m_csPrinter; 00290 et.dwDeviceClass = CLASS_PRINTER; 00291 CProfile::Enumerate(et, m_csaPrinter, m_csaPrinterDesc); 00292 } else { 00293 m_csaPrinter.Empty(); 00294 m_csaPrinterDesc.Empty(); 00295 } 00296 00297 et.dwFields = 0; 00298 00299 CProfile::Enumerate(et, m_csaTarget, m_csaTargetDesc); 00300 00301 // Fix up the default names for the profiles 00302 00303 if (m_csaPrinter.Map(m_csPrinterProfile) == m_csaPrinter.Count()) 00304 { 00305 _RPTF2(_CRT_WARN, "Printer Profile %s isn't associated with " 00306 "the monitor (%s)", (LPCTSTR) m_csPrinterProfile, 00307 (LPCTSTR) m_csPrinter); 00308 if (m_csaPrinter.Count()) 00309 { 00310 m_csPrinterProfile = m_csaPrinter[0]; 00311 } 00312 else 00313 { 00314 m_csPrinterProfile = (LPCTSTR) NULL; 00315 } 00316 } 00317 00318 if (m_csaMonitor.Map(m_csMonitorProfile) == m_csaMonitor.Count()) 00319 { 00320 _RPTF2(_CRT_WARN, "Monitor Profile %s isn't associated with " 00321 "the monitor (%s)", (LPCTSTR) m_csMonitorProfile, 00322 (LPCTSTR) m_csMonitor); 00323 if (m_csaMonitor.Count()) 00324 { 00325 m_csMonitorProfile = m_csaMonitor[0]; 00326 } 00327 else 00328 { 00329 m_csMonitorProfile = (LPCTSTR) NULL; 00330 } 00331 } 00332 00333 // If the target profile name is invalid, use the printer profile 00334 00335 if (m_csaTarget.Map(m_csTargetProfile) == m_csaTarget.Count()) 00336 { 00337 _RPTF1(_CRT_WARN, "Target Profile %s isn't installed", 00338 (LPCTSTR) m_csTargetProfile); 00339 if (m_csaPrinter.Count()) 00340 { 00341 m_csTargetProfile = m_csaPrinter[0]; 00342 } 00343 else 00344 { 00345 // And then, there is no printer profile, it will 00346 // be Windows color space profile. 00347 00348 TCHAR TargetProfileName[MAX_PATH]; 00349 DWORD dwSize = MAX_PATH; 00350 00351 if (GetStandardColorSpaceProfile(NULL,LCS_WINDOWS_COLOR_SPACE,TargetProfileName,&dwSize)) { 00352 m_csTargetProfile = (LPCTSTR) TargetProfileName; 00353 m_csTargetProfile = (LPCTSTR) m_csTargetProfile.NameAndExtension(); 00354 } else { 00355 m_csTargetProfile = (LPCTSTR) NULL; 00356 } 00357 } 00358 } 00359 } 00360 00361 // Update the controls 00362 00363 void CColorMatchDialog::UpdateControls(BOOL bChanged) { 00364 00365 // Switch Proofing Controls based on setting 00366 00367 ShowWindow(m_hwndIntentText1, m_bEnableProofing && m_bEnableICM ? SW_SHOWNORMAL : SW_HIDE); 00368 00369 EnableWindow(m_hwndTargetProfileLabel, m_bEnableProofing && m_bEnableICM); 00370 EnableWindow(m_hwndTargetList, m_bEnableProofing && m_bEnableICM); 00371 00372 EnableWindow(m_hwndTargetIntentLabel, m_bEnableProofing && m_bEnableICM && !m_bDisableIntent); 00373 EnableWindow(m_hwndTargetIntent, m_bEnableProofing && m_bEnableICM && !m_bDisableIntent); 00374 00375 // Switch the other Controls, as well... 00376 00377 EnableWindow(m_hwndMonitorProfileLabel, m_bEnableICM); 00378 EnableWindow(m_hwndMonitorList, m_bEnableICM); 00379 00380 EnableWindow(m_hwndPrinterProfileLabel, m_bEnableICM && !m_csPrinter.IsEmpty()); 00381 EnableWindow(m_hwndPrinterList, m_bEnableICM && m_bColorPrinter && !m_csPrinter.IsEmpty()); 00382 00383 if (m_bEnableProofing) { 00384 EnableWindow(m_hwndIntentLabel, m_bEnableICM && !m_bDisableIntent && !m_bDisableRenderIntent); 00385 EnableWindow(m_hwndRenderIntent, m_bEnableICM && !m_bDisableIntent && !m_bDisableRenderIntent); 00386 } else { 00387 EnableWindow(m_hwndIntentLabel, m_bEnableICM && !m_bDisableIntent); 00388 EnableWindow(m_hwndRenderIntent, m_bEnableICM && !m_bDisableIntent); 00389 } 00390 00391 EnableWindow(GetDlgItem(m_hwnd, EnableBasic), m_bEnableICM); 00392 EnableWindow(GetDlgItem(m_hwnd, EnableProofing), m_bEnableICM); 00393 00394 EnableApplyButton(bChanged); 00395 } 00396 00397 // Update the Apply buttom 00398 00399 void CColorMatchDialog::EnableApplyButton(BOOL bEnable) { 00400 00401 EnableWindow(GetDlgItem(m_hwnd, ApplyButton), bEnable); 00402 00403 } 00404 00405 // Flags for buffer overflow (combined) 00406 00407 #define BAD_BUFFER_FLAGS (CMS_MONITOROVERFLOW | CMS_PRINTEROVERFLOW | \ 00408 CMS_TARGETOVERFLOW) 00409 00410 // By moving the ANSI / Unicode issues into the CString class 00411 // it becomes feasible to code these two versions so they look 00412 // encoding-independent. In other words, the code for both 00413 // of these versions is written identically, and the compiler 00414 // does all the work, just like it ought to... 00415 00416 void CColorMatchDialog::FillStructure(COLORMATCHSETUPA *pcms) { 00417 00418 if (m_bEnableICM) { 00419 00420 pcms -> dwFlags = CMS_SETRENDERINTENT | CMS_SETPRINTERPROFILE | 00421 CMS_SETMONITORPROFILE; 00422 00423 pcms -> dwRenderIntent = m_dwRenderIntent; 00424 00425 // 03-20-1997 [email protected] RAID 21091 (Memphis) 00426 // Don't fail if there is no monitor or printer profile. Set 00427 // them to an empty string and succeed, instead. 00428 // We can always do this, because 0 counts and empty pointers 00429 // have already been screened out. 00430 00431 if (m_csMonitorProfile.IsEmpty()) 00432 pcms -> pMonitorProfile[0] = '\0'; 00433 else { 00434 lstrcpynA(pcms -> pMonitorProfile, m_csMonitorProfile, 00435 pcms -> ccMonitorProfile); 00436 if (lstrcmpA(pcms -> pMonitorProfile, m_csMonitorProfile)) 00437 pcms -> dwFlags |= CMS_MONITOROVERFLOW; 00438 } 00439 00440 if (m_csPrinterProfile.IsEmpty() || !m_bColorPrinter) 00441 pcms -> pPrinterProfile[0] = '\0'; 00442 else { 00443 lstrcpynA(pcms -> pPrinterProfile, m_csPrinterProfile, 00444 pcms -> ccPrinterProfile); 00445 00446 if (lstrcmpA(pcms -> pPrinterProfile, m_csPrinterProfile)) 00447 pcms -> dwFlags |= CMS_PRINTEROVERFLOW; 00448 } 00449 00450 if (m_bEnableProofing) { 00451 pcms -> dwFlags |= 00452 CMS_ENABLEPROOFING | CMS_SETTARGETPROFILE; 00453 pcms -> dwProofingIntent = m_dwProofIntent; 00454 lstrcpynA(pcms -> pTargetProfile, m_csTargetProfile, 00455 pcms -> ccTargetProfile); 00456 if (lstrcmpA(pcms -> pTargetProfile, m_csTargetProfile)) 00457 pcms -> dwFlags |= CMS_TARGETOVERFLOW; 00458 } else { 00459 pcms -> pTargetProfile[0] = '\0'; 00460 } 00461 00462 if (pcms -> dwFlags & BAD_BUFFER_FLAGS) 00463 Fail(ERROR_INSUFFICIENT_BUFFER); 00464 } 00465 else 00466 { 00467 pcms -> dwFlags = CMS_DISABLEICM; // No other flags are valid! 00468 pcms -> pMonitorProfile[0] = '\0'; // No color profiles are choosed 00469 pcms -> pPrinterProfile[0] = '\0'; 00470 pcms -> pTargetProfile[0] = '\0'; 00471 } 00472 } 00473 00474 void CColorMatchDialog::FillStructure(COLORMATCHSETUPW *pcms) { 00475 00476 if (m_bEnableICM) { 00477 00478 pcms -> dwFlags = CMS_SETRENDERINTENT | CMS_SETPRINTERPROFILE | 00479 CMS_SETMONITORPROFILE; 00480 00481 pcms -> dwRenderIntent = m_dwRenderIntent; 00482 00483 // 03-20-1997 [email protected] RAID 21091 (Memphis) 00484 // Don't fail if there is no monitor or printer profile. Set 00485 // them to an empty string and succeed, instead. 00486 // We can always do this, because 0 counts and empty pointers 00487 // have already been screened out. 00488 00489 if (m_csMonitorProfile.IsEmpty()) 00490 pcms -> pMonitorProfile[0] = '\0'; 00491 else { 00492 lstrcpynW(pcms -> pMonitorProfile, m_csMonitorProfile, 00493 pcms -> ccMonitorProfile); 00494 if (lstrcmpW(pcms -> pMonitorProfile, m_csMonitorProfile)) 00495 pcms -> dwFlags |= CMS_MONITOROVERFLOW; 00496 } 00497 00498 if (m_csPrinterProfile.IsEmpty() || !m_bColorPrinter) 00499 pcms -> pPrinterProfile[0] = '\0'; 00500 else { 00501 lstrcpynW(pcms -> pPrinterProfile, m_csPrinterProfile, 00502 pcms -> ccPrinterProfile); 00503 00504 if (lstrcmpW(pcms -> pPrinterProfile, m_csPrinterProfile)) 00505 pcms -> dwFlags |= CMS_PRINTEROVERFLOW; 00506 } 00507 00508 if (m_bEnableProofing) { 00509 pcms -> dwFlags |= 00510 CMS_ENABLEPROOFING | CMS_SETTARGETPROFILE | CMS_SETPROOFINTENT; 00511 pcms -> dwProofingIntent = m_dwProofIntent; 00512 lstrcpynW(pcms -> pTargetProfile, m_csTargetProfile, 00513 pcms -> ccTargetProfile); 00514 if (lstrcmpW(pcms -> pTargetProfile, m_csTargetProfile)) 00515 pcms -> dwFlags |= CMS_TARGETOVERFLOW; 00516 } else { 00517 pcms -> pTargetProfile[0] = '\0'; 00518 } 00519 00520 if (pcms -> dwFlags & BAD_BUFFER_FLAGS) 00521 Fail(ERROR_INSUFFICIENT_BUFFER); 00522 } 00523 else 00524 { 00525 pcms -> dwFlags = CMS_DISABLEICM; // No other flags are valid! 00526 pcms -> pMonitorProfile[0] = '\0'; // No color profiles are choosed 00527 pcms -> pPrinterProfile[0] = '\0'; 00528 pcms -> pTargetProfile[0] = '\0'; 00529 } 00530 } 00531 00532 CColorMatchDialog::CColorMatchDialog(COLORMATCHSETUPA *pcms) : 00533 CDialog(CGlobals::Instance(), ApplicationUI, pcms -> hwndOwner) { 00534 00535 if (!GoodParms((PCOLORMATCHSETUP) pcms)) 00536 return; 00537 00538 // Make sure we've initialized these, if we have to. 00539 00540 if (pcms -> dwFlags & CMS_SETMONITORPROFILE) 00541 m_csMonitorProfile = pcms -> pMonitorProfile; 00542 00543 if (pcms -> dwFlags & CMS_SETPRINTERPROFILE) 00544 m_csPrinterProfile = pcms -> pPrinterProfile; 00545 00546 if (pcms -> dwFlags & CMS_SETTARGETPROFILE) 00547 m_csTargetProfile = pcms -> pTargetProfile; 00548 00549 m_csSource = pcms -> pSourceName; 00550 m_csMonitor = pcms -> pDisplayName; 00551 m_csPrinter = pcms -> pPrinterName; 00552 00553 // Ansi version call 00554 00555 m_bAnsiCall = TRUE; 00556 00557 CompleteInitialization(); 00558 00559 // Display the UI, and watch what happens... 00560 00561 switch (DoModal()) { 00562 00563 case IDOK: 00564 if (!m_bSuccess) 00565 return; 00566 00567 // Fill up return buffer. 00568 00569 FillStructure(pcms); 00570 return; 00571 00572 case IDCANCEL: 00573 Fail(ERROR_SUCCESS); 00574 return; 00575 00576 default: 00577 Fail(GetLastError()); 00578 } 00579 } 00580 00581 CColorMatchDialog::CColorMatchDialog(COLORMATCHSETUPW *pcms) : 00582 CDialog(CGlobals::Instance(), ApplicationUI, pcms -> hwndOwner) { 00583 00584 if (!GoodParms((PCOLORMATCHSETUP) pcms)) 00585 return; 00586 00587 // Make sure we've initialized these, if we have to. 00588 00589 if (pcms -> dwFlags & CMS_SETMONITORPROFILE) { 00590 m_csMonitorProfile = pcms -> pMonitorProfile; 00591 m_csMonitorProfile = m_csMonitorProfile.NameAndExtension(); 00592 } 00593 00594 if (pcms -> dwFlags & CMS_SETPRINTERPROFILE) { 00595 m_csPrinterProfile = pcms -> pPrinterProfile; 00596 m_csPrinterProfile = m_csPrinterProfile.NameAndExtension(); 00597 } 00598 00599 if (pcms -> dwFlags & CMS_SETTARGETPROFILE) { 00600 m_csTargetProfile = pcms -> pTargetProfile; 00601 m_csTargetProfile = m_csTargetProfile.NameAndExtension(); 00602 } 00603 00604 m_csSource = pcms -> pSourceName; 00605 m_csMonitor = pcms -> pDisplayName; 00606 m_csPrinter = pcms -> pPrinterName; 00607 00608 // Unicode version call 00609 00610 m_bAnsiCall = FALSE; 00611 00612 CompleteInitialization(); 00613 00614 // Display the UI, and watch what happens... 00615 00616 switch (DoModal()) { 00617 00618 case IDOK: 00619 if (!m_bSuccess) 00620 return; 00621 00622 // Fill up return buffer. 00623 00624 FillStructure(pcms); 00625 return; 00626 00627 case IDCANCEL: 00628 Fail(ERROR_SUCCESS); 00629 return; 00630 00631 default: 00632 Fail(GetLastError()); 00633 } 00634 } 00635 00636 // Dialog initialization function 00637 00638 BOOL CColorMatchDialog::OnInit() { 00639 00640 // Collect the common handles 00641 00642 m_hwndRenderIntent = GetDlgItem(m_hwnd, RenderingIntent); 00643 m_hwndTargetIntent = GetDlgItem(m_hwnd, TargetIntent); 00644 m_hwndPrinterList = GetDlgItem(m_hwnd, PrinterProfile); 00645 m_hwndMonitorList = GetDlgItem(m_hwnd, MonitorProfile); 00646 m_hwndTargetList = GetDlgItem(m_hwnd, TargetProfile); 00647 00648 m_hwndMonitorProfileLabel = GetDlgItem(m_hwnd, MonitorProfileLabel); 00649 m_hwndPrinterProfileLabel = GetDlgItem(m_hwnd, PrinterProfileLabel); 00650 m_hwndIntentLabel = GetDlgItem(m_hwnd, RenderingIntentLabel); 00651 m_hwndTargetProfileLabel = GetDlgItem(m_hwnd, TargetProfileLabel); 00652 m_hwndTargetIntentLabel = GetDlgItem(m_hwnd, TargetIntentLabel); 00653 00654 m_hwndIntentText1 = GetDlgItem(m_hwnd, RenderingIntentText1); 00655 00656 // Fill in the source name 00657 SetDlgItemText(m_hwnd, SourceProfile, m_csSource); 00658 00659 // Set the Check Boxes 00660 00661 CheckDlgButton(m_hwnd, EnableICM, 00662 m_bEnableICM ? BST_CHECKED : BST_UNCHECKED); 00663 00664 CheckDlgButton(m_hwnd, EnableBasic, 00665 m_bEnableProofing ? BST_UNCHECKED : BST_CHECKED); 00666 CheckDlgButton(m_hwnd, EnableProofing, 00667 m_bEnableProofing ? BST_CHECKED : BST_UNCHECKED); 00668 00669 // Fill in the list(s) of Rendering Intents 00670 00671 CString csWork; // There's plenty of it to do... 00672 00673 for (int i = INTENT_PERCEPTUAL; i <= INTENT_ABSOLUTE_COLORIMETRIC; i++) { 00674 csWork.Load(i + PerceptualString); 00675 SendMessage(m_hwndRenderIntent, CB_ADDSTRING, 0, 00676 (LPARAM) (LPCTSTR) csWork); 00677 SendMessage(m_hwndTargetIntent, CB_ADDSTRING, 0, 00678 (LPARAM) (LPCTSTR) csWork); 00679 } 00680 00681 // Init the rendering intents 00682 00683 SendMessage(m_hwndRenderIntent, CB_SETCURSEL, m_dwRenderIntent, 0); 00684 SendMessage(m_hwndTargetIntent, CB_SETCURSEL, m_dwProofIntent, 0); 00685 00686 // Init the profile lists 00687 00688 // 03-20-1997 [email protected] RAID Memphis:22213 00689 // The algorithm used to determine which profile to select was incorrect. 00690 // There's a much simpler and direct way, anyway. 00691 00692 LRESULT id; 00693 00694 // Target Profiles 00695 00696 for (unsigned u = 0; u < m_csaTarget.Count(); u++) { 00697 if (m_bUseProfileDescription) { 00698 id = SendMessage(m_hwndTargetList, CB_ADDSTRING, 00699 0, (LPARAM)((LPTSTR) m_csaTargetDesc[u])); 00700 } else { 00701 id = SendMessage(m_hwndTargetList, CB_ADDSTRING, 00702 0, m_csaTarget[u].NameOnly()); 00703 } 00704 SendMessage(m_hwndTargetList, CB_SETITEMDATA, id, u); 00705 00706 if (m_csaTarget[u].IsEqualString(m_csTargetProfile)) { 00707 SendMessage(m_hwndTargetList, CB_SETCURSEL, id, 0); 00708 } 00709 } 00710 00711 // Set Target profile if specified, otherwise the default 00712 00713 if (!m_csaTarget.Count()) { 00714 CString csWork; 00715 csWork.Load(NoProfileString); 00716 00717 SendMessage(m_hwndTargetList, CB_ADDSTRING, 0, csWork); 00718 SendMessage(m_hwndTargetList, CB_SETITEMDATA, 0, -1); 00719 SendMessage(m_hwndTargetList, CB_SETCURSEL, 0, 0); 00720 } 00721 00722 // Monitor Profiles 00723 00724 // 03-20-1997 [email protected] Memphis RAID #22289 00725 00726 csWork.Load(GetDlgItem(m_hwnd, MonitorProfileLabel)); 00727 csWork = csWork + m_csMonitorDisplayName + _TEXT(")"); 00728 SetDlgItemText(m_hwnd, MonitorProfileLabel, csWork); 00729 00730 for (u = 0; u < m_csaMonitor.Count(); u++) { 00731 if (m_bUseProfileDescription) { 00732 id = SendMessage(m_hwndMonitorList, CB_ADDSTRING, 00733 0, (LPARAM)((LPTSTR) m_csaMonitorDesc[u])); 00734 } else { 00735 id = SendMessage(m_hwndMonitorList, CB_ADDSTRING, 00736 0, m_csaMonitor[u].NameOnly()); 00737 } 00738 SendMessage(m_hwndMonitorList, CB_SETITEMDATA, id, u); 00739 00740 if (m_csaMonitor[u].IsEqualString(m_csMonitorProfile)) { 00741 SendMessage(m_hwndMonitorList, CB_SETCURSEL, id, 0); 00742 } 00743 } 00744 00745 // Set Monitor profile if specified 00746 00747 if (!m_csaMonitor.Count()) { 00748 CString csWork; 00749 csWork.Load(NoProfileString); 00750 00751 SendMessage(m_hwndMonitorList, CB_ADDSTRING, 0, csWork); 00752 SendMessage(m_hwndMonitorList, CB_SETITEMDATA, 0, -1); 00753 SendMessage(m_hwndMonitorList, CB_SETCURSEL, 0, 0); 00754 } 00755 00756 // Printer Profiles 00757 00758 // 03-20-1997 [email protected] RAID Memphis:22290 00759 // If there's no printer, then we should disable all of the related 00760 // controls. 00761 00762 if (m_csPrinter.IsEmpty()) { 00763 csWork.Load(NoPrintersInstalled); 00764 } else { 00765 csWork.Load(GetDlgItem(m_hwnd, PrinterProfileLabel)); 00766 csWork = csWork + m_csPrinter + _TEXT(")"); 00767 } 00768 00769 SetDlgItemText(m_hwnd, PrinterProfileLabel, csWork); 00770 00771 for (u = 0; u < m_csaPrinter.Count(); u++) { 00772 if (m_bUseProfileDescription) { 00773 id = SendMessage(m_hwndPrinterList, CB_ADDSTRING, 00774 0, (LPARAM)((LPTSTR) m_csaPrinterDesc[u])); 00775 } else { 00776 id = SendMessage(m_hwndPrinterList, CB_ADDSTRING, 00777 0, m_csaPrinter[u].NameOnly()); 00778 } 00779 SendMessage(m_hwndPrinterList, CB_SETITEMDATA, id, u); 00780 00781 if (m_csaPrinter[u].IsEqualString(m_csPrinterProfile)) { 00782 SendMessage(m_hwndPrinterList, CB_SETCURSEL, id, 0); 00783 } 00784 } 00785 00786 // Set Printer profile if specified 00787 00788 if (!m_csaPrinter.Count()) { 00789 CString csWork; 00790 00791 if (!m_csPrinter.IsEmpty() && !m_bColorPrinter) { 00792 // Printer are specified, but it is not color printer. 00793 csWork.Load(NotColorPrinter); 00794 } else { 00795 csWork.Load(NoProfileString); 00796 } 00797 00798 SendMessage(m_hwndPrinterList, CB_ADDSTRING, 0, csWork); 00799 SendMessage(m_hwndPrinterList, CB_SETITEMDATA, 0, -1); 00800 SendMessage(m_hwndPrinterList, CB_SETCURSEL, 0, 0); 00801 } 00802 00803 // End RAID Memphis:22213, 22289, 22290 03-20-1997 00804 00805 // If Apply callback does not provided, disable apply button. 00806 00807 if (m_dpApplyCallback == NULL) { 00808 RECT rcApply, rcCancel; 00809 POINT ptApply, ptCancel; 00810 00811 // Get current "Apply" and "Cancel" buttom position 00812 00813 GetWindowRect(GetDlgItem(m_hwnd, ApplyButton), &rcApply); 00814 GetWindowRect(GetDlgItem(m_hwnd, IDCANCEL), &rcCancel); 00815 00816 // Convert the buttom coordinate to parent dialog coord from screen coord. 00817 00818 ptApply.x = rcApply.left; ptApply.y = rcApply.top; 00819 ptCancel.x = rcCancel.left; ptCancel.y = rcCancel.top; 00820 00821 ScreenToClient(m_hwnd,&ptApply); 00822 ScreenToClient(m_hwnd,&ptCancel); 00823 00824 // Move "Apply" button away... and shift "Cancel" and "OK" 00825 00826 MoveWindow(GetDlgItem(m_hwnd, ApplyButton),0,0,0,0,TRUE); 00827 MoveWindow(GetDlgItem(m_hwnd, IDCANCEL), 00828 ptApply.x,ptApply.y, 00829 rcApply.right - rcApply.left, 00830 rcApply.bottom - rcApply.top,TRUE); 00831 MoveWindow(GetDlgItem(m_hwnd, IDOK), 00832 ptCancel.x,ptCancel.y, 00833 rcCancel.right - rcCancel.left, 00834 rcCancel.bottom - rcCancel.top,TRUE); 00835 } 00836 00837 // Enable/Disable controls based upon settings 00838 00839 UpdateControls(FALSE); 00840 00841 return FALSE; // Because we've probably moved it... 00842 } 00843 00844 // Command Processing override 00845 00846 BOOL CColorMatchDialog::OnCommand(WORD wNotifyCode, WORD wid, HWND hwndCtl) { 00847 00848 switch (wNotifyCode) { 00849 00850 case BN_CLICKED: 00851 00852 switch (wid) { 00853 00854 case EnableICM: 00855 m_bEnableICM = !m_bEnableICM; 00856 UpdateControls(TRUE); 00857 return TRUE; 00858 00859 case EnableBasic: 00860 00861 if (m_bEnableProofing) 00862 { 00863 m_bEnableProofing = FALSE; 00864 00865 // Copy proof intent to rendering intent 00866 // 00867 m_dwRenderIntent = m_dwProofIntent; 00868 00869 // Update UI 00870 // 00871 SendMessage(m_hwndTargetIntent, CB_SETCURSEL, 00872 m_dwProofIntent, 0); 00873 SendMessage(m_hwndRenderIntent, CB_SETCURSEL, 00874 m_dwRenderIntent, 0); 00875 UpdateControls(TRUE); 00876 } 00877 return TRUE; 00878 00879 case EnableProofing: 00880 00881 if (m_bEnableProofing == FALSE) 00882 { 00883 m_bEnableProofing = TRUE; 00884 00885 // Copy the original rendering intent to the proofing 00886 // intent, and set original to Absolute Colorimetric 00887 00888 m_dwProofIntent = m_dwRenderIntent; 00889 m_dwRenderIntent = INTENT_ABSOLUTE_COLORIMETRIC; 00890 00891 // Update UI 00892 // 00893 SendMessage(m_hwndTargetIntent, CB_SETCURSEL, 00894 m_dwProofIntent, 0); 00895 SendMessage(m_hwndRenderIntent, CB_SETCURSEL, 00896 m_dwRenderIntent, 0); 00897 UpdateControls(TRUE); 00898 } 00899 return TRUE; 00900 00901 case ApplyButton: { 00902 00903 // Disable apply button 00904 00905 EnableApplyButton(FALSE); 00906 00907 // Callback supplied function 00908 00909 if (m_dpApplyCallback) { 00910 00911 if (m_bAnsiCall) { 00912 PCOLORMATCHSETUPA pcms = (PCOLORMATCHSETUPA) m_pvCMS; 00913 00914 FillStructure(pcms); 00915 (*(PCMSCALLBACKA)m_dpApplyCallback)(pcms,m_lpApplyCallback); 00916 } else { 00917 PCOLORMATCHSETUPW pcms = (PCOLORMATCHSETUPW) m_pvCMS; 00918 00919 FillStructure(pcms); 00920 (*(PCMSCALLBACKW)m_dpApplyCallback)(pcms,m_lpApplyCallback); 00921 } 00922 } 00923 00924 return TRUE; 00925 } 00926 } 00927 00928 break; 00929 00930 case CBN_SELCHANGE: { 00931 00932 DWORD idItem = (DWORD)SendMessage(hwndCtl, CB_GETCURSEL, 0, 0); 00933 unsigned uItem = (unsigned)SendMessage(hwndCtl, CB_GETITEMDATA, idItem, 0); 00934 00935 switch (wid) { 00936 00937 case RenderingIntent: 00938 00939 if (m_dwRenderIntent != idItem) 00940 { 00941 m_dwRenderIntent = idItem; 00942 00943 // If proofing is disabled, proof intent follows 00944 // render intent 00945 00946 if (! m_bEnableProofing) 00947 { 00948 m_dwProofIntent = idItem; 00949 SendMessage(m_hwndTargetIntent, CB_SETCURSEL, 00950 m_dwProofIntent, 0); 00951 } 00952 00953 EnableApplyButton(); 00954 } 00955 00956 return TRUE; 00957 00958 case TargetIntent: 00959 00960 if (m_dwProofIntent != idItem) 00961 { 00962 m_dwProofIntent = idItem; 00963 00964 EnableApplyButton(); 00965 } 00966 00967 return TRUE; 00968 00969 case TargetProfile: 00970 00971 // If there are no installed profiles, don't bother 00972 00973 if (!m_csaTarget.Count()) 00974 return TRUE; 00975 00976 if (m_csTargetProfile.IsEqualString(m_csaTarget[uItem]) == FALSE) 00977 { 00978 m_csTargetProfile = m_csaTarget[uItem]; 00979 00980 EnableApplyButton(); 00981 } 00982 00983 return TRUE; 00984 00985 case MonitorProfile: 00986 00987 // If there are no installed profiles, don't bother 00988 00989 if (!m_csaMonitor.Count()) 00990 return TRUE; 00991 00992 if (m_csMonitorProfile.IsEqualString(m_csaMonitor[uItem]) == FALSE) 00993 { 00994 m_csMonitorProfile = m_csaMonitor[uItem]; 00995 00996 EnableApplyButton(); 00997 } 00998 00999 return TRUE; 01000 01001 case PrinterProfile: 01002 01003 // If there are no installed profiles, don't bother 01004 01005 if (!m_csaPrinter.Count()) 01006 return TRUE; 01007 01008 if (m_csPrinterProfile.IsEqualString(m_csaPrinter[uItem]) == FALSE) 01009 { 01010 m_csPrinterProfile = m_csaPrinter[uItem]; 01011 01012 EnableApplyButton(); 01013 } 01014 01015 return TRUE; 01016 } 01017 01018 } 01019 01020 } 01021 01022 // Pass anything we didn't handle above to the base class 01023 01024 return CDialog::OnCommand(wNotifyCode, wid, hwndCtl); 01025 01026 } 01027 01028 // Context-sensitive help handler 01029 01030 BOOL CColorMatchDialog::OnHelp(LPHELPINFO pHelp) { 01031 01032 if (pHelp->iContextType == HELPINFO_WINDOW) { 01033 WinHelp((HWND) pHelp->hItemHandle, WINDOWS_HELP_FILE, 01034 HELP_WM_HELP, (ULONG_PTR) (LPSTR) ApplicationUIHelpIds); 01035 } 01036 01037 return (TRUE); 01038 } 01039 01040 BOOL CColorMatchDialog::OnContextMenu(HWND hwnd) { 01041 01042 WinHelp(hwnd, WINDOWS_HELP_FILE, 01043 HELP_CONTEXTMENU, (ULONG_PTR) (LPSTR) ApplicationUIHelpIds); 01044 01045 return (TRUE); 01046 } 01047 01048 // This are the real honest-to-goodness API! 01049 01050 extern "C" BOOL WINAPI SetupColorMatchingA(PCOLORMATCHSETUPA pcms) { 01051 01052 CColorMatchDialog ccmd(pcms); 01053 01054 return ccmd.Results(); 01055 } 01056 01057 extern "C" BOOL WINAPI SetupColorMatchingW(PCOLORMATCHSETUPW pcms) { 01058 01059 CColorMatchDialog ccmd(pcms); 01060 01061 return ccmd.Results(); 01062 }

Generated on Sat May 15 19:39:16 2004 for test by doxygen 1.3.7