1 /* -*- Mode: C; tab-width: 4 -*-
3 * Copyright (c) 1997-2004 Apple Computer, Inc. All rights reserved.
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 #include "UtilTypes.h"
21 #include <CommonServices.h>
22 #include <DebugServices.h>
30 class CThirdPage
: public CPropertyPage
32 DECLARE_DYNAMIC(CThirdPage
)
36 virtual ~CThirdPage();
39 enum { IDD
= IDD_THIRD_PAGE
};
42 virtual void DoDataExchange(CDataExchange
* pDX
); // DDX/DDV support
43 virtual BOOL
OnSetActive();
44 virtual BOOL
OnKillActive();
51 //<rdar://problem/4189721> mDNS: Epson shows up twice in the list. Use case insensitive compare
55 bool operator()( const CString
& s1
, const CString
& s2
) const
57 return s1
.CompareNoCase( s2
) < 0;
61 typedef std::map
<CString
, Manufacturer
*, compare_func
> Manufacturers
;
64 // LoadPrintDriverDefsFromFile
66 // Parses INF file and populates manufacturers
68 OSStatus
LoadPrintDriverDefsFromFile(Manufacturers
& manufacturers
, const CString
& filename
, bool checkForDuplicateModels
);
71 // LoadPrintDriverDefs
73 // Loads extant print driver definitions
75 OSStatus
LoadPrintDriverDefs(Manufacturers
& manufacturers
);
78 // LoadGenericPrintDriversDefs
80 // Loads generic postscript and pcl print driver defs
82 OSStatus
LoadGenericPrintDriverDefs( Manufacturers
& manufacturers
);
87 // Load print driver defs into UI for browsing/selection
89 OSStatus
PopulateUI(Manufacturers
& manufacturers
);
94 // Tries to match printer based on manufacturer and model
96 OSStatus
MatchPrinter(Manufacturers
& manufacturers
, Printer
* printer
, Service
* service
, bool useCUPSWorkaround
);
101 // Called first time page is activated.
102 OSStatus
OnInitPage();
105 // these functions will tweak the names so that everything is
108 CString
ConvertToManufacturerName( const CString
& name
);
109 CString
ConvertToModelName( const CString
& name
);
110 CString
NormalizeManufacturerName( const CString
& name
);
112 Manufacturer
* MatchManufacturer( Manufacturers
& manufacturer
, const CString
& name
);
113 Model
* MatchModel( Manufacturer
* manufacturer
, const CString
& name
);
114 BOOL
MatchGeneric( Manufacturers
& manufacturers
, Printer
* printer
, Service
* service
, Manufacturer
** manufacturer
, Model
** model
);
115 void SelectMatch(Printer
* printer
, Service
* service
, Manufacturer
* manufacturer
, Model
* model
);
116 void SelectMatch(Manufacturers
& manufacturers
, Printer
* printer
, Service
* service
, Manufacturer
* manufacturer
, Model
* model
);
117 void CopyPrinterSettings(Printer
* printer
, Service
* service
, Manufacturer
* manufacturer
, Model
* model
);
119 // <rdar://problem/4580061> mDNS: Printers added using Bonjour should be set as the default printer.
121 BOOL
DefaultPrinterExists();
123 //<rdar://problem/4528853> mDNS: When auto-highlighting items in lists, scroll list so highlighted item is in the middle
125 void AutoScroll(CListCtrl
& list
, int nIndex
);
127 void FreeManufacturers( Manufacturers
& manufacturers
);
129 Manufacturers m_manufacturers
;
131 CListCtrl m_manufacturerListCtrl
;
132 Manufacturer
* m_manufacturerSelected
;
134 CListCtrl m_modelListCtrl
;
135 Model
* m_modelSelected
;
137 Model
* m_genericPostscript
;
138 Model
* m_genericPCL
;
144 afx_msg
void OnLvnItemchangedManufacturer(NMHDR
*pNMHDR
, LRESULT
*pResult
);
145 CStatic m_printerName
;
146 afx_msg
void OnLvnItemchangedPrinterModel(NMHDR
*pNMHDR
, LRESULT
*pResult
);
147 afx_msg
void OnBnClickedDefaultPrinter();
151 Split( const CString
& string
, TCHAR ch
, CStringList
& components
);
153 CButton m_defaultPrinterCtrl
;
156 CStatic m_printerSelectionText
;
157 CStatic
* m_printerImage
;
158 afx_msg
void OnBnClickedHaveDisk();