| OLD | NEW | 
|---|
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "chrome/views/widget/tooltip_manager.h" | 
|  | 6 | 
| 5 #include <limits> | 7 #include <limits> | 
| 6 | 8 | 
| 7 #include "chrome/common/gfx/chrome_font.h" |  | 
| 8 #include "base/logging.h" | 9 #include "base/logging.h" | 
| 9 #include "base/message_loop.h" | 10 #include "base/message_loop.h" | 
| 10 #include "chrome/common/l10n_util.h" | 11 #include "chrome/common/l10n_util.h" | 
| 11 #include "chrome/common/l10n_util_win.h" | 12 #include "chrome/common/l10n_util_win.h" | 
| 12 #include "chrome/common/gfx/text_elider.h" | 13 #include "chrome/common/gfx/text_elider.h" | 
| 13 #include "chrome/common/win_util.h" | 14 #include "chrome/common/win_util.h" | 
| 14 #include "chrome/views/view.h" | 15 #include "chrome/views/view.h" | 
| 15 #include "chrome/views/widget/root_view.h" | 16 #include "chrome/views/widget/root_view.h" | 
| 16 #include "chrome/views/widget/tooltip_manager.h" |  | 
| 17 #include "chrome/views/widget/widget.h" | 17 #include "chrome/views/widget/widget.h" | 
| 18 | 18 | 
| 19 namespace views { | 19 namespace views { | 
| 20 | 20 | 
| 21 //static | 21 //static | 
| 22 int TooltipManager::tooltip_height_ = 0; | 22 int TooltipManager::tooltip_height_ = 0; | 
| 23 | 23 | 
| 24 // Default timeout for the tooltip displayed using keyboard. | 24 // Default timeout for the tooltip displayed using keyboard. | 
| 25 // Timeout is mentioned in milliseconds. | 25 // Timeout is mentioned in milliseconds. | 
| 26 static const int kDefaultTimeout = 4000; | 26 static const int kDefaultTimeout = 4000; | 
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 100     DestroyWindow(keyboard_tooltip_hwnd_); | 100     DestroyWindow(keyboard_tooltip_hwnd_); | 
| 101 } | 101 } | 
| 102 | 102 | 
| 103 void TooltipManager::Init() { | 103 void TooltipManager::Init() { | 
| 104   // Create the tooltip control. | 104   // Create the tooltip control. | 
| 105   tooltip_hwnd_ = CreateWindowEx( | 105   tooltip_hwnd_ = CreateWindowEx( | 
| 106       WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), | 106       WS_EX_TRANSPARENT | l10n_util::GetExtendedTooltipStyles(), | 
| 107       TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0, | 107       TOOLTIPS_CLASS, NULL, TTS_NOPREFIX, 0, 0, 0, 0, | 
| 108       parent_, NULL, NULL, NULL); | 108       parent_, NULL, NULL, NULL); | 
| 109 | 109 | 
|  | 110   l10n_util::AdjustUIFontForWindow(tooltip_hwnd_); | 
|  | 111 | 
| 110   // This effectively turns off clipping of tooltips. We need this otherwise | 112   // This effectively turns off clipping of tooltips. We need this otherwise | 
| 111   // multi-line text (\r\n) won't work right. The size doesn't really matter | 113   // multi-line text (\r\n) won't work right. The size doesn't really matter | 
| 112   // (just as long as its bigger than the monitor's width) as we clip to the | 114   // (just as long as its bigger than the monitor's width) as we clip to the | 
| 113   // screen size before rendering. | 115   // screen size before rendering. | 
| 114   SendMessage(tooltip_hwnd_, TTM_SETMAXTIPWIDTH, 0, | 116   SendMessage(tooltip_hwnd_, TTM_SETMAXTIPWIDTH, 0, | 
| 115               std::numeric_limits<short>::max()); | 117               std::numeric_limits<short>::max()); | 
| 116 | 118 | 
| 117   // Add one tool that is used for all tooltips. | 119   // Add one tool that is used for all tooltips. | 
| 118   toolinfo_.cbSize = sizeof(toolinfo_); | 120   toolinfo_.cbSize = sizeof(toolinfo_); | 
| 119   toolinfo_.uFlags = TTF_TRANSPARENT | TTF_IDISHWND; | 121   toolinfo_.uFlags = TTF_TRANSPARENT | TTF_IDISHWND; | 
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 436     keyboard_tooltip_hwnd_ = NULL; | 438     keyboard_tooltip_hwnd_ = NULL; | 
| 437   } | 439   } | 
| 438 } | 440 } | 
| 439 | 441 | 
| 440 void TooltipManager::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { | 442 void TooltipManager::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { | 
| 441   if (keyboard_tooltip_hwnd_ == window_to_destroy) | 443   if (keyboard_tooltip_hwnd_ == window_to_destroy) | 
| 442     HideKeyboardTooltip(); | 444     HideKeyboardTooltip(); | 
| 443 } | 445 } | 
| 444 | 446 | 
| 445 }  // namespace views | 447 }  // namespace views | 
| OLD | NEW | 
|---|