Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(169)

Side by Side Diff: ui/views/widget/tooltip_manager.h

Issue 11030017: Add context to gfx::Screen calls in support of simultaneous desktop+ash (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fixes Created 8 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/string16.h" 11 #include "base/string16.h"
12 #include "ui/gfx/native_widget_types.h"
12 #include "ui/views/views_export.h" 13 #include "ui/views/views_export.h"
13 14
14 namespace gfx { 15 namespace gfx {
15 class Font; 16 class Font;
16 } // namespace gfx 17 } // namespace gfx
17 18
18 namespace views { 19 namespace views {
19 20
20 class View; 21 class View;
21 22
22 // TooltipManager takes care of the wiring to support tooltips for Views. You 23 // TooltipManager takes care of the wiring to support tooltips for Views. You
23 // almost never need to interact directly with TooltipManager, rather look to 24 // almost never need to interact directly with TooltipManager, rather look to
24 // the various tooltip methods on View. 25 // the various tooltip methods on View.
25 class VIEWS_EXPORT TooltipManager { 26 class VIEWS_EXPORT TooltipManager {
26 public: 27 public:
27 // Returns the height of tooltips. This should only be invoked from within 28 // Returns the height of tooltips. This should only be invoked from within
28 // GetTooltipTextOrigin. 29 // GetTooltipTextOrigin.
29 static int GetTooltipHeight(); 30 static int GetTooltipHeight();
30 31
31 // Returns the default font used by tooltips. 32 // Returns the default font used by tooltips.
32 static gfx::Font GetDefaultFont(); 33 static gfx::Font GetDefaultFont();
33 34
34 // Returns the maximum width of the tooltip. |x| and |y| give the location 35 // Returns the maximum width of the tooltip. |x| and |y| give the location
35 // the tooltip is to be displayed on in screen coordinates. 36 // the tooltip is to be displayed on in screen coordinates. |context| is
36 static int GetMaxWidth(int x, int y); 37 // used to determine which gfx::Screen should be used.
38 static int GetMaxWidth(int x, int y, gfx::NativeView context);
37 39
38 TooltipManager() {} 40 TooltipManager() {}
39 virtual ~TooltipManager() {} 41 virtual ~TooltipManager() {}
40 42
41 // Notification that the view hierarchy has changed in some way. 43 // Notification that the view hierarchy has changed in some way.
42 virtual void UpdateTooltip() = 0; 44 virtual void UpdateTooltip() = 0;
43 45
44 // Invoked when the tooltip text changes for the specified views. 46 // Invoked when the tooltip text changes for the specified views.
45 virtual void TooltipTextChanged(View* view) = 0; 47 virtual void TooltipTextChanged(View* view) = 0;
46 48
47 // Invoked when toolbar icon gets focus. 49 // Invoked when toolbar icon gets focus.
48 virtual void ShowKeyboardTooltip(View* view) = 0; 50 virtual void ShowKeyboardTooltip(View* view) = 0;
49 51
50 // Invoked when toolbar loses focus. 52 // Invoked when toolbar loses focus.
51 virtual void HideKeyboardTooltip() = 0; 53 virtual void HideKeyboardTooltip() = 0;
52 54
53 protected: 55 protected:
54 // Trims the tooltip to fit, setting |text| to the clipped result, 56 // Trims the tooltip to fit, setting |text| to the clipped result,
55 // |max_width| to the width (in pixels) of the clipped text and |line_count| 57 // |max_width| to the width (in pixels) of the clipped text and |line_count|
56 // to the number of lines of text in the tooltip. |x| and |y| give the 58 // to the number of lines of text in the tooltip. |x| and |y| give the
57 // location of the tooltip in screen coordinates. 59 // location of the tooltip in screen coordinates. |context| is used to
60 // determine which gfx::Screen should be used.
58 static void TrimTooltipToFit(string16* text, 61 static void TrimTooltipToFit(string16* text,
59 int* max_width, 62 int* max_width,
60 int* line_count, 63 int* line_count,
61 int x, 64 int x,
62 int y); 65 int y,
66 gfx::NativeView context);
63 }; 67 };
64 68
65 } // namespace views 69 } // namespace views
66 70
67 #endif // UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_ 71 #endif // UI_VIEWS_WIDGET_TOOLTIP_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698