| OLD | NEW |
| 1 // Copyright (c) 2011 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 |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 65 // Hide the tooltip and cancel any timers. | 65 // Hide the tooltip and cancel any timers. |
| 66 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); | 66 ::SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); |
| 67 ::SendMessage(tooltip_hwnd_, TTM_TRACKACTIVATE, false, (LPARAM)&toolinfo_); | 67 ::SendMessage(tooltip_hwnd_, TTM_TRACKACTIVATE, false, (LPARAM)&toolinfo_); |
| 68 return; | 68 return; |
| 69 } | 69 } |
| 70 } | 70 } |
| 71 | 71 |
| 72 /////////////////////////////////////////////////////////////////////////////// | 72 /////////////////////////////////////////////////////////////////////////////// |
| 73 // AeroTooltipManager, private: | 73 // AeroTooltipManager, private: |
| 74 | 74 |
| 75 void AeroTooltipManager::Init() { | |
| 76 // Create the tooltip control. | |
| 77 tooltip_hwnd_ = CreateWindowEx( | |
| 78 WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), | |
| 79 TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0, | |
| 80 GetParent(), NULL, NULL, NULL); | |
| 81 ui::CheckWindowCreated(tooltip_hwnd_); | |
| 82 | |
| 83 l10n_util::AdjustUIFontForWindow(tooltip_hwnd_); | |
| 84 | |
| 85 // Add one tool that is used for all tooltips. | |
| 86 toolinfo_.cbSize = sizeof(toolinfo_); | |
| 87 | |
| 88 // We use tracking tooltips on Vista to allow us to manually control the | |
| 89 // visibility of the tooltip. | |
| 90 toolinfo_.uFlags = TTF_TRANSPARENT | TTF_IDISHWND | TTF_TRACK | TTF_ABSOLUTE; | |
| 91 toolinfo_.hwnd = GetParent(); | |
| 92 toolinfo_.uId = (UINT_PTR)GetParent(); | |
| 93 | |
| 94 // Setting this tells windows to call GetParent() back (using a WM_NOTIFY | |
| 95 // message) for the actual tooltip contents. | |
| 96 toolinfo_.lpszText = LPSTR_TEXTCALLBACK; | |
| 97 SetRectEmpty(&toolinfo_.rect); | |
| 98 ::SendMessage(tooltip_hwnd_, TTM_ADDTOOL, 0, (LPARAM)&toolinfo_); | |
| 99 } | |
| 100 | |
| 101 void AeroTooltipManager::OnTimer() { | 75 void AeroTooltipManager::OnTimer() { |
| 102 initial_timer_ = NULL; | 76 initial_timer_ = NULL; |
| 103 | 77 |
| 104 POINT pt = last_mouse_pos_.ToPOINT(); | 78 POINT pt = last_mouse_pos_.ToPOINT(); |
| 105 ::ClientToScreen(GetParent(), &pt); | 79 ::ClientToScreen(GetParent(), &pt); |
| 106 | 80 |
| 107 // Set the position and visibility. | 81 // Set the position and visibility. |
| 108 if (!tooltip_showing_) { | 82 if (!tooltip_showing_) { |
| 109 ::SendMessage(tooltip_hwnd_, TTM_POPUP, 0, 0); | 83 ::SendMessage(tooltip_hwnd_, TTM_POPUP, 0, 0); |
| 110 ::SendMessage(tooltip_hwnd_, TTM_TRACKPOSITION, 0, MAKELPARAM(pt.x, pt.y)); | 84 ::SendMessage(tooltip_hwnd_, TTM_TRACKPOSITION, 0, MAKELPARAM(pt.x, pt.y)); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 127 void AeroTooltipManager::InitialTimer::Disown() { | 101 void AeroTooltipManager::InitialTimer::Disown() { |
| 128 manager_ = NULL; | 102 manager_ = NULL; |
| 129 } | 103 } |
| 130 | 104 |
| 131 void AeroTooltipManager::InitialTimer::Execute() { | 105 void AeroTooltipManager::InitialTimer::Execute() { |
| 132 if (manager_) | 106 if (manager_) |
| 133 manager_->OnTimer(); | 107 manager_->OnTimer(); |
| 134 } | 108 } |
| 135 | 109 |
| 136 } // namespace views | 110 } // namespace views |
| OLD | NEW |