OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #ifndef VIEWS_WIDGET_TOOLTIP_MANAGER_H_ | |
6 #define VIEWS_WIDGET_TOOLTIP_MANAGER_H_ | |
7 #pragma once | |
8 | |
9 #include <string> | |
10 | |
11 #include "base/basictypes.h" | |
12 #include "base/string16.h" | |
13 #include "views/views_export.h" | |
14 | |
15 namespace gfx { | |
16 class Font; | |
17 } // namespace gfx | |
18 | |
19 namespace views { | |
20 | |
21 class View; | |
22 | |
23 // TooltipManager takes care of the wiring to support tooltips for Views. You | |
24 // almost never need to interact directly with TooltipManager, rather look to | |
25 // the various tooltip methods on View. | |
26 class VIEWS_EXPORT TooltipManager { | |
27 public: | |
28 // Returns the height of tooltips. This should only be invoked from within | |
29 // GetTooltipTextOrigin. | |
30 static int GetTooltipHeight(); | |
31 | |
32 // Returns the default font used by tooltips. | |
33 static gfx::Font GetDefaultFont(); | |
34 | |
35 // Returns the maximum width of the tooltip. |x| and |y| give the location | |
36 // the tooltip is to be displayed on in screen coordinates. | |
37 static int GetMaxWidth(int x, int y); | |
38 | |
39 TooltipManager() {} | |
40 virtual ~TooltipManager() {} | |
41 | |
42 // Notification that the view hierarchy has changed in some way. | |
43 virtual void UpdateTooltip() = 0; | |
44 | |
45 // Invoked when the tooltip text changes for the specified views. | |
46 virtual void TooltipTextChanged(View* view) = 0; | |
47 | |
48 // Invoked when toolbar icon gets focus. | |
49 virtual void ShowKeyboardTooltip(View* view) = 0; | |
50 | |
51 // Invoked when toolbar loses focus. | |
52 virtual void HideKeyboardTooltip() = 0; | |
53 | |
54 protected: | |
55 // Trims the tooltip to fit, setting |text| to the clipped result, | |
56 // |max_width| to the width (in pixels) of the clipped text and |line_count| | |
57 // to the number of lines of text in the tooltip. |x| and |y| give the | |
58 // location of the tooltip in screen coordinates. | |
59 static void TrimTooltipToFit(string16* text, | |
60 int* max_width, | |
61 int* line_count, | |
62 int x, | |
63 int y); | |
64 }; | |
65 | |
66 } // namespace views | |
67 | |
68 #endif // VIEWS_WIDGET_TOOLTIP_MANAGER_H_ | |
OLD | NEW |