OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "views/widget/tooltip_manager_win.h" | 5 #include "views/widget/tooltip_manager_win.h" |
6 | 6 |
7 #include <windowsx.h> | 7 #include <windowsx.h> |
8 #include <limits> | 8 #include <limits> |
9 | 9 |
10 #include "app/l10n_util_win.h" | 10 #include "app/l10n_util_win.h" |
(...skipping 19 matching lines...) Expand all Loading... |
30 int TooltipManager::GetTooltipHeight() { | 30 int TooltipManager::GetTooltipHeight() { |
31 DCHECK(tooltip_height_ > 0); | 31 DCHECK(tooltip_height_ > 0); |
32 return tooltip_height_; | 32 return tooltip_height_; |
33 } | 33 } |
34 | 34 |
35 static gfx::Font DetermineDefaultFont() { | 35 static gfx::Font DetermineDefaultFont() { |
36 HWND window = CreateWindowEx( | 36 HWND window = CreateWindowEx( |
37 WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), | 37 WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), |
38 TOOLTIPS_CLASS, NULL, 0 , 0, 0, 0, 0, NULL, NULL, NULL, NULL); | 38 TOOLTIPS_CLASS, NULL, 0 , 0, 0, 0, 0, NULL, NULL, NULL, NULL); |
39 HFONT hfont = reinterpret_cast<HFONT>(SendMessage(window, WM_GETFONT, 0, 0)); | 39 HFONT hfont = reinterpret_cast<HFONT>(SendMessage(window, WM_GETFONT, 0, 0)); |
40 gfx::Font font = hfont ? gfx::Font::CreateFont(hfont) : gfx::Font(); | 40 gfx::Font font = hfont ? gfx::Font(hfont) : gfx::Font(); |
41 DestroyWindow(window); | 41 DestroyWindow(window); |
42 return font; | 42 return font; |
43 } | 43 } |
44 | 44 |
45 // static | 45 // static |
46 gfx::Font TooltipManager::GetDefaultFont() { | 46 gfx::Font TooltipManager::GetDefaultFont() { |
47 static gfx::Font* font = NULL; | 47 static gfx::Font* font = NULL; |
48 if (!font) | 48 if (!font) |
49 font = new gfx::Font(DetermineDefaultFont()); | 49 font = new gfx::Font(DetermineDefaultFont()); |
50 return *font; | 50 return *font; |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 TEXTMETRIC font_metrics; | 253 TEXTMETRIC font_metrics; |
254 GetTextMetrics(dc, &font_metrics); | 254 GetTextMetrics(dc, &font_metrics); |
255 height = font_metrics.tmHeight; | 255 height = font_metrics.tmHeight; |
256 // To avoid the DC referencing font_handle_, select the previous font. | 256 // To avoid the DC referencing font_handle_, select the previous font. |
257 SelectObject(dc, previous_font); | 257 SelectObject(dc, previous_font); |
258 SetMapMode(dc, last_map_mode); | 258 SetMapMode(dc, last_map_mode); |
259 ReleaseDC(NULL, dc); | 259 ReleaseDC(NULL, dc); |
260 } else { | 260 } else { |
261 // Tooltip is using the system font. Use gfx::Font, which should pick | 261 // Tooltip is using the system font. Use gfx::Font, which should pick |
262 // up the system font. | 262 // up the system font. |
263 height = gfx::Font().height(); | 263 height = gfx::Font().GetHeight(); |
264 } | 264 } |
265 // Get the margins from the tooltip | 265 // Get the margins from the tooltip |
266 RECT tooltip_margin; | 266 RECT tooltip_margin; |
267 SendMessage(tooltip_hwnd_, TTM_GETMARGIN, 0, (LPARAM)&tooltip_margin); | 267 SendMessage(tooltip_hwnd_, TTM_GETMARGIN, 0, (LPARAM)&tooltip_margin); |
268 return height + tooltip_margin.top + tooltip_margin.bottom; | 268 return height + tooltip_margin.top + tooltip_margin.bottom; |
269 } | 269 } |
270 | 270 |
271 void TooltipManagerWin::UpdateTooltip(const gfx::Point& mouse_pos) { | 271 void TooltipManagerWin::UpdateTooltip(const gfx::Point& mouse_pos) { |
272 RootView* root_view = widget_->GetRootView(); | 272 RootView* root_view = widget_->GetRootView(); |
273 View* view = root_view->GetViewForPoint(mouse_pos); | 273 View* view = root_view->GetViewForPoint(mouse_pos); |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 keyboard_tooltip_hwnd_ = NULL; | 376 keyboard_tooltip_hwnd_ = NULL; |
377 } | 377 } |
378 } | 378 } |
379 | 379 |
380 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { | 380 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { |
381 if (keyboard_tooltip_hwnd_ == window_to_destroy) | 381 if (keyboard_tooltip_hwnd_ == window_to_destroy) |
382 HideKeyboardTooltip(); | 382 HideKeyboardTooltip(); |
383 } | 383 } |
384 | 384 |
385 } // namespace views | 385 } // namespace views |
OLD | NEW |