1/* -*- Mode: C; tab-width: 4 -*- 2 * 3 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 */ 17 18#include "stdafx.h" 19#include "PrinterSetupWizardApp.h" 20#include "PrinterSetupWizardSheet.h" 21#include "FourthPage.h" 22 23#if !defined( PBS_MARQUEE ) 24# define PBS_MARQUEE 0x08 25#endif 26 27#if !defined( PBM_SETMARQUEE ) 28# define PBM_SETMARQUEE WM_USER + 10 29#endif 30 31 32 33// CFourthPage dialog 34 35IMPLEMENT_DYNAMIC(CFourthPage, CPropertyPage) 36CFourthPage::CFourthPage() 37 : CPropertyPage(CFourthPage::IDD), 38 m_initialized(false) 39{ 40 CString fontName; 41 42 m_psp.dwFlags &= ~(PSP_HASHELP); 43 m_psp.dwFlags |= PSP_DEFAULT|PSP_HIDEHEADER; 44 45 fontName.LoadString(IDS_LARGE_FONT); 46 47 // create the large font 48 m_largeFont.CreateFont(-16, 0, 0, 0, 49 FW_BOLD, FALSE, FALSE, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, 50 CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH, fontName); 51} 52 53CFourthPage::~CFourthPage() 54{ 55} 56 57void CFourthPage::DoDataExchange(CDataExchange* pDX) 58{ 59 CPropertyPage::DoDataExchange(pDX); 60 DDX_Control(pDX, IDC_GOODBYE, m_goodbye); 61 DDX_Control(pDX, IDC_PRINTER_NAME, m_printerNameCtrl); 62 DDX_Control(pDX, IDC_PRINTER_MANUFACTURER, m_printerManufacturerCtrl); 63 DDX_Control(pDX, IDC_PRINTER_MODEL, m_printerModelCtrl); 64 DDX_Control(pDX, IDC_PRINTER_PROTOCOL, m_printerProtocolCtrl); 65 DDX_Control(pDX, IDC_PRINTER_DEFAULT, m_printerDefault); 66} 67 68 69BEGIN_MESSAGE_MAP(CFourthPage, CPropertyPage) 70END_MESSAGE_MAP() 71 72 73// CFourthPage message handlers 74OSStatus 75CFourthPage::OnInitPage() 76{ 77 CWnd * window; 78 OSStatus err = kNoErr; 79 80 window = GetDlgItem( IDC_INSTALLING ); 81 require_action( window, exit, err = kUnknownErr ); 82 window->ShowWindow( SW_HIDE ); 83 84 window = GetDlgItem( IDC_PROGRESS ); 85 require_action( window, exit, err = kUnknownErr ); 86 SetWindowLong( *window, GWL_STYLE, GetWindowLong( *window, GWL_STYLE ) | PBS_MARQUEE ); 87 SetWindowLongPtr( *window, GWL_STYLE, GetWindowLongPtr( *window, GWL_STYLE ) | PBS_MARQUEE ); 88 window->SendMessage( ( UINT ) PBM_SETMARQUEE, ( WPARAM ) FALSE,( LPARAM ) 35 ); 89 window->ShowWindow( SW_HIDE ); 90 91exit: 92 93 return err; 94} 95 96 97BOOL 98CFourthPage::OnSetActive() 99{ 100 CPrinterSetupWizardSheet * psheet; 101 CString goodbyeText; 102 Printer * printer; 103 CString defaultText; 104 105 psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent()); 106 require_quiet( psheet, exit ); 107 108 printer = psheet->GetSelectedPrinter(); 109 require_quiet( psheet, exit ); 110 111 psheet->SetWizardButtons(PSWIZB_BACK|PSWIZB_FINISH); 112 113 if (m_initialized == false) 114 { 115 m_initialized = true; 116 OnInitPage(); 117 } 118 119 m_goodbye.SetFont(&m_largeFont); 120 121 goodbyeText.LoadString(IDS_GOODBYE); 122 m_goodbye.SetWindowText(goodbyeText); 123 124 m_printerNameCtrl.SetWindowText( printer->actualName ); 125 m_printerManufacturerCtrl.SetWindowText ( printer->manufacturer ); 126 m_printerModelCtrl.SetWindowText ( printer->displayModelName ); 127 128 Service * service = printer->services.front(); 129 require_quiet( service, exit ); 130 m_printerProtocolCtrl.SetWindowText ( service->protocol ); 131 132 if (printer->deflt) 133 { 134 defaultText.LoadString(IDS_YES); 135 } 136 else 137 { 138 defaultText.LoadString(IDS_NO); 139 } 140 141 m_printerDefault.SetWindowText ( defaultText ); 142 143exit: 144 145 return CPropertyPage::OnSetActive(); 146} 147 148 149BOOL 150CFourthPage::OnKillActive() 151{ 152 CPrinterSetupWizardSheet * psheet; 153 154 psheet = reinterpret_cast<CPrinterSetupWizardSheet*>(GetParent()); 155 require_quiet( psheet, exit ); 156 157 psheet->SetLastPage(this); 158 159exit: 160 161 return CPropertyPage::OnKillActive(); 162} 163 164 165BOOL 166CFourthPage::StartActivityIndicator() 167{ 168 CWnd * window; 169 BOOL ok = TRUE; 170 171 window = GetDlgItem( IDC_COMPLETE1 ); 172 require_action( window, exit, ok = FALSE ); 173 window->ShowWindow( SW_HIDE ); 174 175 window = GetDlgItem( IDC_COMPLETE2 ); 176 require_action( window, exit, ok = FALSE ); 177 window->ShowWindow( SW_HIDE ); 178 179 window = GetDlgItem( IDC_INSTALLING ); 180 require_action( window, exit, ok = FALSE ); 181 window->ShowWindow( SW_SHOW ); 182 183 window = GetDlgItem( IDC_PROGRESS ); 184 require_action( window, exit, ok = FALSE ); 185 window->SendMessage( ( UINT ) PBM_SETMARQUEE, ( WPARAM ) TRUE,( LPARAM ) 50 ); 186 window->ShowWindow( SW_SHOW ); 187 188exit: 189 190 return ok; 191} 192 193 194BOOL 195CFourthPage::StopActivityIndicator() 196{ 197 CWnd * window; 198 BOOL ok = TRUE; 199 200 window = GetDlgItem( IDC_INSTALLING ); 201 require_action( window, exit, ok = FALSE ); 202 window->ShowWindow( SW_HIDE ); 203 204 window = GetDlgItem( IDC_PROGRESS ); 205 require_action( window, exit, ok = FALSE ); 206 window->SendMessage( ( UINT ) PBM_SETMARQUEE, ( WPARAM ) FALSE,( LPARAM ) 35 ); 207 window->ShowWindow( SW_HIDE ); 208 209exit: 210 211 return ok; 212} 213