Changeset 84154 in webkit
- Timestamp:
- Apr 18, 2011 10:08:45 AM (13 years ago)
- Location:
- trunk/Tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r84139 r84154 1 2011-04-18 Patrick Gansterer <paroga@webkit.org> 2 3 Reviewed by Adam Roben. 4 5 [WIN] Use WCHAR instead of TCHAR 6 https://bugs.webkit.org/show_bug.cgi?id=58755 7 8 We always use the UNICODE versions of windows functions, so 9 the usage of TCHAR makes no sense and mixing them is bad style. 10 11 * WinLauncher/PrintWebUIDelegate.cpp: 12 Also fix various style issues (including indentation and removal of ugly C-casts). 13 * WinLauncher/WinLauncher.cpp: 14 1 15 2011-04-18 Dominic Cooney <dominicc@chromium.org> 2 16 -
trunk/Tools/WinLauncher/PrintWebUIDelegate.cpp
r53154 r84154 28 28 #include "PrintWebUIDelegate.h" 29 29 30 #include <WebKit/WebKitCOMAPI.h> 30 31 #include <commctrl.h> 31 32 #include <commdlg.h> … … 33 34 #include <shlwapi.h> 34 35 #include <wininet.h> 35 36 #include <WebKit/WebKitCOMAPI.h>37 36 38 37 static const int MARGIN = 20; … … 98 97 HRESULT PrintWebUIDelegate::webViewHeaderHeight(IWebView* webView, float* height) 99 98 { 100 if (!webView || !height) 101 return E_POINTER; 102 103 HDC dc = ::GetDC(0); 99 if (!webView || !height) 100 return E_POINTER; 104 101 105 TEXTMETRIC textMetric; 106 ::GetTextMetrics(dc, &textMetric); 107 ::ReleaseDC(0, dc); 102 HDC dc = ::GetDC(0); 108 103 109 *height = 1.1 * textMetric.tmHeight; 104 TEXTMETRIC textMetric; 105 ::GetTextMetrics(dc, &textMetric); 106 ::ReleaseDC(0, dc); 110 107 111 return S_OK; 108 *height = 1.1 * textMetric.tmHeight; 109 110 return S_OK; 112 111 } 113 112 114 113 HRESULT PrintWebUIDelegate::webViewFooterHeight(IWebView* webView, float* height) 115 114 { 116 if (!webView || !height)117 return E_POINTER;115 if (!webView || !height) 116 return E_POINTER; 118 117 119 HDC dc = ::GetDC(0);118 HDC dc = ::GetDC(0); 120 119 121 TEXTMETRIC textMetric;122 ::GetTextMetrics(dc, &textMetric);123 ::ReleaseDC(0, dc);120 TEXTMETRIC textMetric; 121 ::GetTextMetrics(dc, &textMetric); 122 ::ReleaseDC(0, dc); 124 123 125 *height = 1.1 * textMetric.tmHeight;124 *height = 1.1 * textMetric.tmHeight; 126 125 127 return S_OK;126 return S_OK; 128 127 } 129 128 130 HRESULT PrintWebUIDelegate::drawHeaderInRect( 131 /* [in] */ IWebView *webView,132 /* [in] */ RECT *rect,129 HRESULT PrintWebUIDelegate::drawHeaderInRect( 130 /* [in] */ IWebView* webView, 131 /* [in] */ RECT* rect, 133 132 /* [in] */ OLE_HANDLE drawingContext) 134 133 { 135 if (!webView || !rect)136 return E_POINTER;134 if (!webView || !rect) 135 return E_POINTER; 137 136 138 // Turn off header for now.139 HDC dc = reinterpret_cast<HDC>(drawingContext);137 // Turn off header for now. 138 HDC dc = reinterpret_cast<HDC>(drawingContext); 140 139 141 HFONT hFont = (HFONT)::GetStockObject(ANSI_VAR_FONT);142 HFONT hOldFont = (HFONT)::SelectObject(dc, hFont);140 HGDIOBJ hFont = ::GetStockObject(ANSI_VAR_FONT); 141 HGDIOBJ hOldFont = ::SelectObject(dc, hFont); 143 142 144 LPCTSTR header(_T("[Sample Header]"));145 int length = _tcslen(header);143 LPCWSTR header = L"[Sample Header]"; 144 size_t length = wcslen(header); 146 145 147 int rc = ::DrawText(dc, header, length, rect, DT_LEFT | DT_NOCLIP | DT_VCENTER| DT_SINGLELINE);148 ::SelectObject(dc, hOldFont);146 int rc = ::DrawTextW(dc, header, length, rect, DT_LEFT | DT_NOCLIP | DT_VCENTER | DT_SINGLELINE); 147 ::SelectObject(dc, hOldFont); 149 148 150 if (!rc)151 return E_FAIL;149 if (!rc) 150 return E_FAIL; 152 151 153 ::MoveToEx(dc, rect->left, rect->bottom, 0);154 HPEN hPen = (HPEN)::GetStockObject(BLACK_PEN);155 HPEN hOldPen = (HPEN)::SelectObject(dc, hPen);156 ::LineTo(dc, rect->right, rect->bottom);157 ::SelectObject(dc, hOldPen);152 ::MoveToEx(dc, rect->left, rect->bottom, 0); 153 HGDIOBJ hPen = ::GetStockObject(BLACK_PEN); 154 HGDIOBJ hOldPen = ::SelectObject(dc, hPen); 155 ::LineTo(dc, rect->right, rect->bottom); 156 ::SelectObject(dc, hOldPen); 158 157 159 return S_OK;158 return S_OK; 160 159 } 161 160 162 HRESULT PrintWebUIDelegate::drawFooterInRect( 163 /* [in] */ IWebView *webView,164 /* [in] */ RECT *rect,161 HRESULT PrintWebUIDelegate::drawFooterInRect( 162 /* [in] */ IWebView* webView, 163 /* [in] */ RECT* rect, 165 164 /* [in] */ OLE_HANDLE drawingContext, 166 165 /* [in] */ UINT pageIndex, 167 166 /* [in] */ UINT pageCount) 168 167 { 169 if (!webView || !rect)170 return E_POINTER;168 if (!webView || !rect) 169 return E_POINTER; 171 170 172 HDC dc = reinterpret_cast<HDC>(drawingContext);171 HDC dc = reinterpret_cast<HDC>(drawingContext); 173 172 174 HFONT hFont = (HFONT)::GetStockObject(ANSI_VAR_FONT);175 HFONT hOldFont = (HFONT)::SelectObject(dc, hFont);173 HGDIOBJ hFont = ::GetStockObject(ANSI_VAR_FONT); 174 HGDIOBJ hOldFont = ::SelectObject(dc, hFont); 176 175 177 LPCTSTR footer(_T("[Sample Footer]"));178 int length = _tcslen(footer);176 LPCWSTR footer = L"[Sample Footer]"; 177 size_t length = wcslen(footer); 179 178 180 // Add a line, 1/10th inch above the footer text from left margin to right margin.181 ::MoveToEx(dc, rect->left, rect->top, 0);182 HPEN hPen = (HPEN)::GetStockObject(BLACK_PEN);183 HPEN hOldPen = (HPEN)::SelectObject(dc, hPen);184 ::LineTo(dc, rect->right, rect->top);185 ::SelectObject(dc, hOldPen);179 // Add a line, 1/10th inch above the footer text from left margin to right margin. 180 ::MoveToEx(dc, rect->left, rect->top, 0); 181 HGDIOBJ hPen = ::GetStockObject(BLACK_PEN); 182 HGDIOBJ hOldPen = ::SelectObject(dc, hPen); 183 ::LineTo(dc, rect->right, rect->top); 184 ::SelectObject(dc, hOldPen); 186 185 187 int rc = ::DrawText(dc, footer, length, rect, DT_LEFT | DT_NOCLIP | DT_VCENTER| DT_SINGLELINE);188 ::SelectObject(dc, hOldFont);186 int rc = ::DrawTextW(dc, footer, length, rect, DT_LEFT | DT_NOCLIP | DT_VCENTER | DT_SINGLELINE); 187 ::SelectObject(dc, hOldFont); 189 188 190 if (!rc)191 return E_FAIL;189 if (!rc) 190 return E_FAIL; 192 191 193 return S_OK;192 return S_OK; 194 193 } -
trunk/Tools/WinLauncher/WinLauncher.cpp
r72258 r84154 328 328 HDC printDC = getPrinterDC(); 329 329 if (!printDC) { 330 ::MessageBox (0, _T("Error creating printing DC"), _T("Error"), MB_APPLMODAL | MB_OK);330 ::MessageBoxW(0, L"Error creating printing DC", L"Error", MB_APPLMODAL | MB_OK); 331 331 return; 332 332 } 333 333 334 334 if (::SetAbortProc(printDC, AbortProc) == SP_ERROR) { 335 ::MessageBox (0, _T("Error setting up AbortProc"), _T("Error"), MB_APPLMODAL | MB_OK);335 ::MessageBoxW(0, L"Error setting up AbortProc", L"Error", MB_APPLMODAL | MB_OK); 336 336 return; 337 337 } … … 351 351 352 352 DOCINFO di; 353 initDocStruct(&di, _T("WebKit Doc"));353 initDocStruct(&di, L"WebKit Doc"); 354 354 ::StartDoc(printDC, &di); 355 355
Note: See TracChangeset
for help on using the changeset viewer.