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_WIN_H_ | 5 #ifndef UI_VIEWS_WIDGET_TOOLTIP_MANAGER_WIN_H_ |
6 #define UI_VIEWS_WIDGET_TOOLTIP_MANAGER_WIN_H_ | 6 #define UI_VIEWS_WIDGET_TOOLTIP_MANAGER_WIN_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 #include <commctrl.h> | 9 #include <commctrl.h> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/compiler_specific.h" | 13 #include "base/compiler_specific.h" |
14 #include "base/memory/weak_ptr.h" | |
15 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
16 #include "ui/gfx/native_widget_types.h" | 15 #include "ui/gfx/native_widget_types.h" |
17 #include "ui/gfx/point.h" | 16 #include "ui/gfx/point.h" |
18 #include "ui/views/widget/tooltip_manager.h" | 17 #include "ui/views/widget/tooltip_manager.h" |
19 | 18 |
20 namespace gfx { | 19 namespace gfx { |
21 class Point; | 20 class Point; |
22 } | 21 } |
23 | 22 |
24 namespace views { | 23 namespace views { |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
66 // successful. If this returns false the TooltipManager should be destroyed | 65 // successful. If this returns false the TooltipManager should be destroyed |
67 // and not used. | 66 // and not used. |
68 bool Init(); | 67 bool Init(); |
69 | 68 |
70 // Notification that the view hierarchy has changed in some way. | 69 // Notification that the view hierarchy has changed in some way. |
71 virtual void UpdateTooltip() OVERRIDE; | 70 virtual void UpdateTooltip() OVERRIDE; |
72 | 71 |
73 // Invoked when the tooltip text changes for the specified views. | 72 // Invoked when the tooltip text changes for the specified views. |
74 virtual void TooltipTextChanged(View* view) OVERRIDE; | 73 virtual void TooltipTextChanged(View* view) OVERRIDE; |
75 | 74 |
76 // Invoked when toolbar icon gets focus. | |
77 virtual void ShowKeyboardTooltip(View* view) OVERRIDE; | |
78 | |
79 // Invoked when toolbar loses focus. | |
80 virtual void HideKeyboardTooltip() OVERRIDE; | |
81 | |
82 // Message handlers. These forward to the tooltip control. | 75 // Message handlers. These forward to the tooltip control. |
83 virtual void OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param); | 76 virtual void OnMouse(UINT u_msg, WPARAM w_param, LPARAM l_param); |
84 LRESULT OnNotify(int w_param, NMHDR* l_param, bool* handled); | 77 LRESULT OnNotify(int w_param, NMHDR* l_param, bool* handled); |
85 | 78 |
86 protected: | 79 protected: |
87 // Returns the Widget we're showing tooltips for. | 80 // Returns the Widget we're showing tooltips for. |
88 gfx::NativeView GetParent(); | 81 gfx::NativeView GetParent(); |
89 | 82 |
90 // Updates the tooltip for the specified location. | 83 // Updates the tooltip for the specified location. |
91 void UpdateTooltip(const gfx::Point& location); | 84 void UpdateTooltip(const gfx::Point& location); |
(...skipping 12 matching lines...) Expand all Loading... |
104 | 97 |
105 private: | 98 private: |
106 // Sets the tooltip position based on the x/y position of the text. If the | 99 // Sets the tooltip position based on the x/y position of the text. If the |
107 // tooltip fits, true is returned. | 100 // tooltip fits, true is returned. |
108 bool SetTooltipPosition(int text_x, int text_y); | 101 bool SetTooltipPosition(int text_x, int text_y); |
109 | 102 |
110 // Calculates the preferred height for tooltips. This always returns a | 103 // Calculates the preferred height for tooltips. This always returns a |
111 // positive value. | 104 // positive value. |
112 int CalcTooltipHeight(); | 105 int CalcTooltipHeight(); |
113 | 106 |
114 // Invoked when the timer elapses and tooltip has to be destroyed. | |
115 void DestroyKeyboardTooltipWindow(HWND window_to_destroy); | |
116 | |
117 // Hosting Widget. | 107 // Hosting Widget. |
118 Widget* widget_; | 108 Widget* widget_; |
119 | 109 |
120 // The View the mouse is under. This is null if the mouse isn't under a | 110 // The View the mouse is under. This is null if the mouse isn't under a |
121 // View. | 111 // View. |
122 View* last_tooltip_view_; | 112 View* last_tooltip_view_; |
123 | 113 |
124 // Whether or not the view under the mouse needs to be refreshed. If this | 114 // Whether or not the view under the mouse needs to be refreshed. If this |
125 // is true, when the tooltip is asked for the view under the mouse is | 115 // is true, when the tooltip is asked for the view under the mouse is |
126 // refreshed. | 116 // refreshed. |
127 bool last_view_out_of_sync_; | 117 bool last_view_out_of_sync_; |
128 | 118 |
129 // Text for tooltip from the view. | 119 // Text for tooltip from the view. |
130 string16 tooltip_text_; | 120 string16 tooltip_text_; |
131 | 121 |
132 // The clipped tooltip. | 122 // The clipped tooltip. |
133 string16 clipped_text_; | 123 string16 clipped_text_; |
134 | 124 |
135 // Number of lines in the tooltip. | 125 // Number of lines in the tooltip. |
136 int line_count_; | 126 int line_count_; |
137 | 127 |
138 // Width of the last tooltip. | 128 // Width of the last tooltip. |
139 int tooltip_width_; | 129 int tooltip_width_; |
140 | 130 |
141 // control window for tooltip displayed using keyboard. | |
142 HWND keyboard_tooltip_hwnd_; | |
143 | |
144 // Used to register DestroyTooltipWindow function with PostDelayedTask | |
145 // function. | |
146 base::WeakPtrFactory<TooltipManagerWin> keyboard_tooltip_factory_; | |
147 | |
148 DISALLOW_COPY_AND_ASSIGN(TooltipManagerWin); | 131 DISALLOW_COPY_AND_ASSIGN(TooltipManagerWin); |
149 }; | 132 }; |
150 | 133 |
151 } // namespace views | 134 } // namespace views |
152 | 135 |
153 #endif // UI_VIEWS_WIDGET_TOOLTIP_MANAGER_WIN_H_ | 136 #endif // UI_VIEWS_WIDGET_TOOLTIP_MANAGER_WIN_H_ |
OLD | NEW |