Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / views / widget / tooltip_manager.h
blob923b19dd7559d2e7d47f0d07a6fc479e905b7e94
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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_
6 #define UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/strings/string16.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/views/views_export.h"
15 namespace gfx {
16 class Display;
17 class FontList;
18 } // namespace gfx
20 namespace views {
22 class View;
24 // 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 // the various tooltip methods on View.
27 class VIEWS_EXPORT TooltipManager {
28 public:
29 // 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 // 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 // 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 // shown.
36 static const char kGroupingPropertyKey[];
38 TooltipManager() {}
39 virtual ~TooltipManager() {}
41 // Returns the height of tooltips. This should only be invoked from within
42 // GetTooltipTextOrigin.
43 static int GetTooltipHeight();
45 // Returns the maximum width of the tooltip. |x| and |y| give the location
46 // the tooltip is to be displayed on in screen coordinates. |context| is
47 // used to determine which gfx::Screen should be used.
48 static int GetMaxWidth(int x, int y, gfx::NativeView context);
50 // Same as GetMaxWidth(), but takes a Display.
51 static int GetMaxWidth(const gfx::Display& display);
53 // If necessary trims the text of a tooltip to ensure we don't try to display
54 // a mega-tooltip.
55 static void TrimTooltipText(base::string16* text);
57 // Returns the font list used for tooltips.
58 virtual const gfx::FontList& GetFontList() const = 0;
60 // Notification that the view hierarchy has changed in some way.
61 virtual void UpdateTooltip() = 0;
63 // Invoked when the tooltip text changes for the specified views.
64 virtual void TooltipTextChanged(View* view) = 0;
67 } // namespace views
69 #endif // UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_