OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "ui/views/widget/tooltip_manager_win.h" | 5 #include "ui/views/widget/tooltip_manager_win.h" |
6 | 6 |
7 #include <windowsx.h> | 7 #include <windowsx.h> |
8 | 8 |
9 #include <limits> | 9 #include <limits> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 if (tooltip_hwnd_) | 83 if (tooltip_hwnd_) |
84 DestroyWindow(tooltip_hwnd_); | 84 DestroyWindow(tooltip_hwnd_); |
85 if (keyboard_tooltip_hwnd_) | 85 if (keyboard_tooltip_hwnd_) |
86 DestroyWindow(keyboard_tooltip_hwnd_); | 86 DestroyWindow(keyboard_tooltip_hwnd_); |
87 } | 87 } |
88 | 88 |
89 bool TooltipManagerWin::Init() { | 89 bool TooltipManagerWin::Init() { |
90 DCHECK(!tooltip_hwnd_); | 90 DCHECK(!tooltip_hwnd_); |
91 // Create the tooltip control. | 91 // Create the tooltip control. |
92 tooltip_hwnd_ = CreateWindowEx( | 92 tooltip_hwnd_ = CreateWindowEx( |
93 WS_EX_TRANSPARENT | WS_EX_TOPMOST | l10n_util::GetExtendedTooltipStyles(), | 93 WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), |
94 TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0, | 94 TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0, |
95 GetParent(), NULL, NULL, NULL); | 95 GetParent(), NULL, NULL, NULL); |
96 if (!tooltip_hwnd_) | 96 if (!tooltip_hwnd_) |
97 return false; | 97 return false; |
98 | 98 |
99 l10n_util::AdjustUIFontForWindow(tooltip_hwnd_); | 99 l10n_util::AdjustUIFontForWindow(tooltip_hwnd_); |
100 | 100 |
101 // This effectively turns off clipping of tooltips. We need this otherwise | 101 // This effectively turns off clipping of tooltips. We need this otherwise |
102 // multi-line text (\r\n) won't work right. The size doesn't really matter | 102 // multi-line text (\r\n) won't work right. The size doesn't really matter |
103 // (just as long as its bigger than the monitor's width) as we clip to the | 103 // (just as long as its bigger than the monitor's width) as we clip to the |
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 tooltip_text_.clear(); | 326 tooltip_text_.clear(); |
327 } | 327 } |
328 HideKeyboardTooltip(); | 328 HideKeyboardTooltip(); |
329 string16 tooltip_text; | 329 string16 tooltip_text; |
330 if (!focused_view->GetTooltipText(gfx::Point(), &tooltip_text)) | 330 if (!focused_view->GetTooltipText(gfx::Point(), &tooltip_text)) |
331 return; | 331 return; |
332 gfx::Rect focused_bounds = focused_view->bounds(); | 332 gfx::Rect focused_bounds = focused_view->bounds(); |
333 gfx::Point screen_point; | 333 gfx::Point screen_point; |
334 focused_view->ConvertPointToScreen(focused_view, &screen_point); | 334 focused_view->ConvertPointToScreen(focused_view, &screen_point); |
335 keyboard_tooltip_hwnd_ = CreateWindowEx( | 335 keyboard_tooltip_hwnd_ = CreateWindowEx( |
336 WS_EX_TRANSPARENT | WS_EX_TOPMOST | l10n_util::GetExtendedTooltipStyles(), | 336 WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), |
337 TOOLTIPS_CLASS, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); | 337 TOOLTIPS_CLASS, NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL); |
338 if (!keyboard_tooltip_hwnd_) | 338 if (!keyboard_tooltip_hwnd_) |
339 return; | 339 return; |
340 | 340 |
341 SendMessage(keyboard_tooltip_hwnd_, TTM_SETMAXTIPWIDTH, 0, | 341 SendMessage(keyboard_tooltip_hwnd_, TTM_SETMAXTIPWIDTH, 0, |
342 std::numeric_limits<int16>::max()); | 342 std::numeric_limits<int16>::max()); |
343 int tooltip_width; | 343 int tooltip_width; |
344 int line_count; | 344 int line_count; |
345 TrimTooltipToFit(&tooltip_text, &tooltip_width, &line_count, | 345 TrimTooltipToFit(&tooltip_text, &tooltip_width, &line_count, |
346 screen_point.x(), screen_point.y()); | 346 screen_point.x(), screen_point.y()); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 keyboard_tooltip_hwnd_ = NULL; | 382 keyboard_tooltip_hwnd_ = NULL; |
383 } | 383 } |
384 } | 384 } |
385 | 385 |
386 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { | 386 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { |
387 if (keyboard_tooltip_hwnd_ == window_to_destroy) | 387 if (keyboard_tooltip_hwnd_ == window_to_destroy) |
388 HideKeyboardTooltip(); | 388 HideKeyboardTooltip(); |
389 } | 389 } |
390 | 390 |
391 } // namespace views | 391 } // namespace views |
OLD | NEW |