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

Side by Side Diff: ui/views/widget/tooltip_manager_win.cc

Issue 10828265: Replace views::LocatedEvent with ui::LocatedEvent (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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
« no previous file with comments | « ui/views/widget/root_view.cc ('k') | ui/views/window/non_client_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 #include "ui/views/widget/tooltip_manager_win.h" 5 #include "ui/views/widget/tooltip_manager_win.h"
6 6
7 #include <windowsx.h> 7 #include <windowsx.h>
8 8
9 #include <limits> 9 #include <limits>
10 10
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Initialize the string, if we have a valid tooltip the string will 161 // Initialize the string, if we have a valid tooltip the string will
162 // get reset below. 162 // get reset below.
163 tooltip_info->szText[0] = TEXT('\0'); 163 tooltip_info->szText[0] = TEXT('\0');
164 tooltip_text_.clear(); 164 tooltip_text_.clear();
165 tooltip_info->lpszText = NULL; 165 tooltip_info->lpszText = NULL;
166 clipped_text_.clear(); 166 clipped_text_.clear();
167 if (last_tooltip_view_ != NULL) { 167 if (last_tooltip_view_ != NULL) {
168 tooltip_text_.clear(); 168 tooltip_text_.clear();
169 // Mouse is over a View, ask the View for its tooltip. 169 // Mouse is over a View, ask the View for its tooltip.
170 gfx::Point view_loc = last_mouse_pos_; 170 gfx::Point view_loc = last_mouse_pos_;
171 View::ConvertPointToView(widget_->GetRootView(), 171 View::ConvertPointToTarget(widget_->GetRootView(),
172 last_tooltip_view_, &view_loc); 172 last_tooltip_view_, &view_loc);
173 if (last_tooltip_view_->GetTooltipText(view_loc, &tooltip_text_) && 173 if (last_tooltip_view_->GetTooltipText(view_loc, &tooltip_text_) &&
174 !tooltip_text_.empty()) { 174 !tooltip_text_.empty()) {
175 // View has a valid tip, copy it into TOOLTIPINFO. 175 // View has a valid tip, copy it into TOOLTIPINFO.
176 clipped_text_ = tooltip_text_; 176 clipped_text_ = tooltip_text_;
177 gfx::Point screen_loc = last_mouse_pos_; 177 gfx::Point screen_loc = last_mouse_pos_;
178 View::ConvertPointToScreen(widget_->GetRootView(), &screen_loc); 178 View::ConvertPointToScreen(widget_->GetRootView(), &screen_loc);
179 TrimTooltipToFit(&clipped_text_, &tooltip_width_, &line_count_, 179 TrimTooltipToFit(&clipped_text_, &tooltip_width_, &line_count_,
180 screen_loc.x(), screen_loc.y()); 180 screen_loc.x(), screen_loc.y());
181 // Adjust the clipped tooltip text for locale direction. 181 // Adjust the clipped tooltip text for locale direction.
182 base::i18n::AdjustStringForLocaleDirection(&clipped_text_); 182 base::i18n::AdjustStringForLocaleDirection(&clipped_text_);
(...skipping 10 matching lines...) Expand all
193 *handled = true; 193 *handled = true;
194 return 0; 194 return 0;
195 case TTN_SHOW: { 195 case TTN_SHOW: {
196 *handled = true; 196 *handled = true;
197 tooltip_showing_ = true; 197 tooltip_showing_ = true;
198 // The tooltip is about to show, allow the view to position it 198 // The tooltip is about to show, allow the view to position it
199 gfx::Point text_origin; 199 gfx::Point text_origin;
200 if (tooltip_height_ == 0) 200 if (tooltip_height_ == 0)
201 tooltip_height_ = CalcTooltipHeight(); 201 tooltip_height_ = CalcTooltipHeight();
202 gfx::Point view_loc = last_mouse_pos_; 202 gfx::Point view_loc = last_mouse_pos_;
203 View::ConvertPointToView(widget_->GetRootView(), 203 View::ConvertPointToTarget(widget_->GetRootView(),
204 last_tooltip_view_, &view_loc); 204 last_tooltip_view_, &view_loc);
205 if (last_tooltip_view_->GetTooltipTextOrigin(view_loc, &text_origin) && 205 if (last_tooltip_view_->GetTooltipTextOrigin(view_loc, &text_origin) &&
206 SetTooltipPosition(text_origin.x(), text_origin.y())) { 206 SetTooltipPosition(text_origin.x(), text_origin.y())) {
207 // Return true, otherwise the rectangle we specified is ignored. 207 // Return true, otherwise the rectangle we specified is ignored.
208 return TRUE; 208 return TRUE;
209 } 209 }
210 return 0; 210 return 0;
211 } 211 }
212 default: 212 default:
213 // Fall through. 213 // Fall through.
214 break; 214 break;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 View* view = root_view->GetEventHandlerForPoint(mouse_pos); 273 View* view = root_view->GetEventHandlerForPoint(mouse_pos);
274 if (view != last_tooltip_view_) { 274 if (view != last_tooltip_view_) {
275 // NOTE: This *must* be sent regardless of the visibility of the tooltip. 275 // NOTE: This *must* be sent regardless of the visibility of the tooltip.
276 // It triggers Windows to ask for the tooltip again. 276 // It triggers Windows to ask for the tooltip again.
277 SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); 277 SendMessage(tooltip_hwnd_, TTM_POP, 0, 0);
278 last_tooltip_view_ = view; 278 last_tooltip_view_ = view;
279 } else if (last_tooltip_view_ != NULL) { 279 } else if (last_tooltip_view_ != NULL) {
280 // Tooltip is showing, and mouse is over the same view. See if the tooltip 280 // Tooltip is showing, and mouse is over the same view. See if the tooltip
281 // text has changed. 281 // text has changed.
282 gfx::Point view_point = mouse_pos; 282 gfx::Point view_point = mouse_pos;
283 View::ConvertPointToView(root_view, last_tooltip_view_, &view_point); 283 View::ConvertPointToTarget(root_view, last_tooltip_view_, &view_point);
284 string16 new_tooltip_text; 284 string16 new_tooltip_text;
285 bool has_tooltip_text = 285 bool has_tooltip_text =
286 last_tooltip_view_->GetTooltipText(view_point, &new_tooltip_text); 286 last_tooltip_view_->GetTooltipText(view_point, &new_tooltip_text);
287 if (!has_tooltip_text || (new_tooltip_text != tooltip_text_)) { 287 if (!has_tooltip_text || (new_tooltip_text != tooltip_text_)) {
288 // The text has changed, hide the popup. 288 // The text has changed, hide the popup.
289 SendMessage(tooltip_hwnd_, TTM_POP, 0, 0); 289 SendMessage(tooltip_hwnd_, TTM_POP, 0, 0);
290 if (has_tooltip_text && !new_tooltip_text.empty() && tooltip_showing_) { 290 if (has_tooltip_text && !new_tooltip_text.empty() && tooltip_showing_) {
291 // New text is valid, show the popup. 291 // New text is valid, show the popup.
292 SendMessage(tooltip_hwnd_, TTM_POPUP, 0, 0); 292 SendMessage(tooltip_hwnd_, TTM_POPUP, 0, 0);
293 } 293 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
381 keyboard_tooltip_hwnd_ = NULL; 381 keyboard_tooltip_hwnd_ = NULL;
382 } 382 }
383 } 383 }
384 384
385 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { 385 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) {
386 if (keyboard_tooltip_hwnd_ == window_to_destroy) 386 if (keyboard_tooltip_hwnd_ == window_to_destroy)
387 HideKeyboardTooltip(); 387 HideKeyboardTooltip();
388 } 388 }
389 389
390 } // namespace views 390 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/widget/root_view.cc ('k') | ui/views/window/non_client_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698