| 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 #ifndef UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_ | 5 #ifndef UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_ |
| 6 #define UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_ | 6 #define UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "ui/gfx/native_widget_types.h" | 12 #include "ui/gfx/native_widget_types.h" |
| 13 #include "ui/views/views_export.h" | 13 #include "ui/views/views_export.h" |
| 14 | 14 |
| 15 namespace gfx { | 15 namespace gfx { |
| 16 class Display; | 16 class Display; |
| 17 class FontList; | 17 class FontList; |
| 18 class Point; |
| 18 } // namespace gfx | 19 } // namespace gfx |
| 19 | 20 |
| 20 namespace views { | 21 namespace views { |
| 21 | 22 |
| 22 class View; | 23 class View; |
| 23 | 24 |
| 24 // TooltipManager takes care of the wiring to support tooltips for Views. You | 25 // TooltipManager takes care of the wiring to support tooltips for Views. You |
| 25 // almost never need to interact directly with TooltipManager, rather look to | 26 // almost never need to interact directly with TooltipManager, rather look to |
| 26 // the various tooltip methods on View. | 27 // the various tooltip methods on View. |
| 27 class VIEWS_EXPORT TooltipManager { | 28 class VIEWS_EXPORT TooltipManager { |
| 28 public: | 29 public: |
| 29 // When a NativeView has capture all events are delivered to it. In some | 30 // When a NativeView has capture all events are delivered to it. In some |
| 30 // situations, such as menus, we want the tooltip to be shown for the | 31 // situations, such as menus, we want the tooltip to be shown for the |
| 31 // NativeView the mouse is over, even if it differs from the NativeView that | 32 // NativeView the mouse is over, even if it differs from the NativeView that |
| 32 // has capture (with menus the first menu shown has capture). To enable this | 33 // has capture (with menus the first menu shown has capture). To enable this |
| 33 // if the NativeView that has capture has the same value for the property | 34 // if the NativeView that has capture has the same value for the property |
| 34 // |kGroupingPropertyKey| as the NativeView the mouse is over the tooltip is | 35 // |kGroupingPropertyKey| as the NativeView the mouse is over the tooltip is |
| 35 // shown. | 36 // shown. |
| 36 static const char kGroupingPropertyKey[]; | 37 static const char kGroupingPropertyKey[]; |
| 37 | 38 |
| 38 TooltipManager() {} | 39 TooltipManager() {} |
| 39 virtual ~TooltipManager() {} | 40 virtual ~TooltipManager() {} |
| 40 | 41 |
| 41 // Returns the maximum width of the tooltip. |x| and |y| give the location | 42 // Returns the maximum width of the tooltip. |point| gives the location |
| 42 // the tooltip is to be displayed on in screen coordinates. |context| is | 43 // the tooltip is to be displayed on in screen coordinates. |context| is |
| 43 // used to determine which gfx::Screen should be used. | 44 // used to determine which gfx::Screen should be used. |
| 44 static int GetMaxWidth(int x, int y, gfx::NativeView context); | 45 virtual int GetMaxWidth(const gfx::Point& location, |
| 45 | 46 gfx::NativeView context) const = 0; |
| 46 // Same as GetMaxWidth(), but takes a Display. | |
| 47 static int GetMaxWidth(const gfx::Display& display); | |
| 48 | |
| 49 // If necessary trims the text of a tooltip to ensure we don't try to display | |
| 50 // a mega-tooltip. | |
| 51 static void TrimTooltipText(base::string16* text); | |
| 52 | 47 |
| 53 // Returns the font list used for tooltips. | 48 // Returns the font list used for tooltips. |
| 54 virtual const gfx::FontList& GetFontList() const = 0; | 49 virtual const gfx::FontList& GetFontList() const = 0; |
| 55 | 50 |
| 56 // Notification that the view hierarchy has changed in some way. | 51 // Notification that the view hierarchy has changed in some way. |
| 57 virtual void UpdateTooltip() = 0; | 52 virtual void UpdateTooltip() = 0; |
| 58 | 53 |
| 59 // Invoked when the tooltip text changes for the specified views. | 54 // Invoked when the tooltip text changes for the specified views. |
| 60 virtual void TooltipTextChanged(View* view) = 0; | 55 virtual void TooltipTextChanged(View* view) = 0; |
| 61 }; | 56 }; |
| 62 | 57 |
| 63 } // namespace views | 58 } // namespace views |
| 64 | 59 |
| 65 #endif // UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_ | 60 #endif // UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_ |
| OLD | NEW |