| OLD | NEW |
| 1 // Copyright (c) 2010 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 "views/widget/aero_tooltip_manager.h" | 5 #include "views/widget/aero_tooltip_manager.h" |
| 6 | 6 |
| 7 #include <windows.h> | 7 #include <windows.h> |
| 8 #include <commctrl.h> | 8 #include <commctrl.h> |
| 9 #include <shlobj.h> | 9 #include <shlobj.h> |
| 10 | 10 |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "ui/base/l10n/l10n_util_win.h" | 12 #include "ui/base/l10n/l10n_util_win.h" |
| 13 #include "ui/gfx/point.h" | 13 #include "ui/gfx/point.h" |
| 14 | 14 |
| 15 namespace views { | 15 namespace views { |
| 16 | 16 |
| 17 /////////////////////////////////////////////////////////////////////////////// | 17 /////////////////////////////////////////////////////////////////////////////// |
| 18 // AeroTooltipManager, public: | 18 // AeroTooltipManager, public: |
| 19 | 19 |
| 20 AeroTooltipManager::AeroTooltipManager(Widget* widget) | 20 AeroTooltipManager::AeroTooltipManager(Widget* widget) |
| 21 : TooltipManagerWin(widget), | 21 : TooltipManagerWin(widget), |
| 22 initial_delay_(0) { | 22 initial_delay_(0) { |
| 23 } | 23 } |
| 24 | 24 |
| 25 AeroTooltipManager::~AeroTooltipManager() { | 25 AeroTooltipManager::~AeroTooltipManager() { |
| 26 if (initial_timer_) | 26 if (initial_timer_) |
| 27 initial_timer_->Disown(); | 27 initial_timer_->Disown(); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) { | 30 void AeroTooltipManager::OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param) { |
| 31 if (u_msg == WM_MOUSELEAVE) { |
| 32 last_mouse_pos_.SetPoint(-1, -1); |
| 33 UpdateTooltip(); |
| 34 return; |
| 35 } |
| 36 |
| 31 if (initial_timer_) | 37 if (initial_timer_) |
| 32 initial_timer_->Disown(); | 38 initial_timer_->Disown(); |
| 33 | 39 |
| 34 if (u_msg == WM_MOUSEMOVE || u_msg == WM_NCMOUSEMOVE) { | 40 if (u_msg == WM_MOUSEMOVE || u_msg == WM_NCMOUSEMOVE) { |
| 35 gfx::Point mouse_pos(l_param); | 41 gfx::Point mouse_pos(l_param); |
| 36 if (u_msg == WM_NCMOUSEMOVE) { | 42 if (u_msg == WM_NCMOUSEMOVE) { |
| 37 // NC message coordinates are in screen coordinates. | 43 // NC message coordinates are in screen coordinates. |
| 38 POINT temp = mouse_pos.ToPOINT(); | 44 POINT temp = mouse_pos.ToPOINT(); |
| 39 ::MapWindowPoints(HWND_DESKTOP, GetParent(), &temp, 1); | 45 ::MapWindowPoints(HWND_DESKTOP, GetParent(), &temp, 1); |
| 40 mouse_pos.SetPoint(temp.x, temp.y); | 46 mouse_pos.SetPoint(temp.x, temp.y); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 55 initial_timer_ = new InitialTimer(this); | 61 initial_timer_ = new InitialTimer(this); |
| 56 initial_timer_->Start(initial_delay_); | 62 initial_timer_->Start(initial_delay_); |
| 57 } else { | 63 } else { |
| 58 // Hide the tooltip and cancel any timers. | 64 // Hide the tooltip and cancel any timers. |
| 59 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); | 65 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); |
| 60 ::SendMessage(tooltip_hwnd_, TTM_TRACKACTIVATE, false, (LPARAM)&toolinfo_); | 66 ::SendMessage(tooltip_hwnd_, TTM_TRACKACTIVATE, false, (LPARAM)&toolinfo_); |
| 61 return; | 67 return; |
| 62 } | 68 } |
| 63 } | 69 } |
| 64 | 70 |
| 65 void AeroTooltipManager::OnMouseLeave() { | |
| 66 last_mouse_pos_.SetPoint(-1, -1); | |
| 67 UpdateTooltip(); | |
| 68 } | |
| 69 | |
| 70 /////////////////////////////////////////////////////////////////////////////// | 71 /////////////////////////////////////////////////////////////////////////////// |
| 71 // AeroTooltipManager, private: | 72 // AeroTooltipManager, private: |
| 72 | 73 |
| 73 void AeroTooltipManager::Init() { | 74 void AeroTooltipManager::Init() { |
| 74 // Create the tooltip control. | 75 // Create the tooltip control. |
| 75 tooltip_hwnd_ = CreateWindowEx( | 76 tooltip_hwnd_ = CreateWindowEx( |
| 76 WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), | 77 WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), |
| 77 TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0, | 78 TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0, |
| 78 GetParent(), NULL, NULL, NULL); | 79 GetParent(), NULL, NULL, NULL); |
| 79 | 80 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 void AeroTooltipManager::InitialTimer::Disown() { | 125 void AeroTooltipManager::InitialTimer::Disown() { |
| 125 manager_ = NULL; | 126 manager_ = NULL; |
| 126 } | 127 } |
| 127 | 128 |
| 128 void AeroTooltipManager::InitialTimer::Execute() { | 129 void AeroTooltipManager::InitialTimer::Execute() { |
| 129 if (manager_) | 130 if (manager_) |
| 130 manager_->OnTimer(); | 131 manager_->OnTimer(); |
| 131 } | 132 } |
| 132 | 133 |
| 133 } // namespace views | 134 } // namespace views |
| OLD | NEW |