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

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

Issue 6386009: Remove app/win/win_util.h,cc etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with NSApp changes in r73581 Created 9 years, 10 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 | « views/widget/monitor_win.cc ('k') | views/widget/widget_win.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) 2010 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 #include "views/widget/tooltip_manager_win.h" 5 #include "views/widget/tooltip_manager_win.h"
6 6
7 #include <windowsx.h> 7 #include <windowsx.h>
8 #include <limits> 8 #include <limits>
9 9
10 #include "app/win/win_util.h"
11 #include "base/i18n/rtl.h" 10 #include "base/i18n/rtl.h"
12 #include "base/logging.h" 11 #include "base/logging.h"
13 #include "base/message_loop.h" 12 #include "base/message_loop.h"
14 #include "gfx/font.h" 13 #include "gfx/font.h"
15 #include "ui/base/l10n/l10n_util_win.h" 14 #include "ui/base/l10n/l10n_util_win.h"
16 #include "views/screen.h" 15 #include "views/screen.h"
17 #include "views/view.h" 16 #include "views/view.h"
17 #include "views/widget/monitor_win.h"
18 #include "views/widget/root_view.h" 18 #include "views/widget/root_view.h"
19 #include "views/widget/widget.h" 19 #include "views/widget/widget.h"
20 20
21 namespace views { 21 namespace views {
22 22
23 static int tooltip_height_ = 0; 23 static int tooltip_height_ = 0;
24 24
25 // Default timeout for the tooltip displayed using keyboard. 25 // Default timeout for the tooltip displayed using keyboard.
26 // Timeout is mentioned in milliseconds. 26 // Timeout is mentioned in milliseconds.
27 static const int kDefaultTimeout = 4000; 27 static const int kDefaultTimeout = 4000;
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 RECT bounds = { view_loc.x() + text_x, 221 RECT bounds = { view_loc.x() + text_x,
222 view_loc.y() + text_y, 222 view_loc.y() + text_y,
223 view_loc.x() + text_x + tooltip_width_, 223 view_loc.x() + text_x + tooltip_width_,
224 view_loc.y() + line_count_ * GetTooltipHeight() }; 224 view_loc.y() + line_count_ * GetTooltipHeight() };
225 SendMessage(tooltip_hwnd_, TTM_ADJUSTRECT, TRUE, (LPARAM)&bounds); 225 SendMessage(tooltip_hwnd_, TTM_ADJUSTRECT, TRUE, (LPARAM)&bounds);
226 226
227 // Make sure the rectangle completely fits on the current monitor. If it 227 // Make sure the rectangle completely fits on the current monitor. If it
228 // doesn't, return false so that windows positions the tooltip at the 228 // doesn't, return false so that windows positions the tooltip at the
229 // default location. 229 // default location.
230 gfx::Rect monitor_bounds = 230 gfx::Rect monitor_bounds =
231 app::win::GetMonitorBoundsForRect(gfx::Rect(bounds.left,bounds.right, 231 views::GetMonitorBoundsForRect(gfx::Rect(bounds.left,bounds.right,
232 0, 0)); 232 0, 0));
233 if (!monitor_bounds.Contains(gfx::Rect(bounds))) { 233 if (!monitor_bounds.Contains(gfx::Rect(bounds))) {
234 return false; 234 return false;
235 } 235 }
236 236
237 ::SetWindowPos(tooltip_hwnd_, NULL, bounds.left, bounds.top, 0, 0, 237 ::SetWindowPos(tooltip_hwnd_, NULL, bounds.left, bounds.top, 0, 0,
238 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); 238 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
239 return true; 239 return true;
240 } 240 }
241 241
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
349 SendMessage(keyboard_tooltip_hwnd_, TTM_TRACKACTIVATE, TRUE, 349 SendMessage(keyboard_tooltip_hwnd_, TTM_TRACKACTIVATE, TRUE,
350 reinterpret_cast<LPARAM>(&keyboard_toolinfo)); 350 reinterpret_cast<LPARAM>(&keyboard_toolinfo));
351 if (!tooltip_height_) 351 if (!tooltip_height_)
352 tooltip_height_ = CalcTooltipHeight(); 352 tooltip_height_ = CalcTooltipHeight();
353 RECT rect_bounds = {screen_point.x(), 353 RECT rect_bounds = {screen_point.x(),
354 screen_point.y() + focused_bounds.height(), 354 screen_point.y() + focused_bounds.height(),
355 screen_point.x() + tooltip_width, 355 screen_point.x() + tooltip_width,
356 screen_point.y() + focused_bounds.height() + 356 screen_point.y() + focused_bounds.height() +
357 line_count * tooltip_height_ }; 357 line_count * tooltip_height_ };
358 gfx::Rect monitor_bounds = 358 gfx::Rect monitor_bounds =
359 app::win::GetMonitorBoundsForRect(gfx::Rect(rect_bounds)); 359 views::GetMonitorBoundsForRect(gfx::Rect(rect_bounds));
360 rect_bounds = gfx::Rect(rect_bounds).AdjustToFit(monitor_bounds).ToRECT(); 360 rect_bounds = gfx::Rect(rect_bounds).AdjustToFit(monitor_bounds).ToRECT();
361 ::SetWindowPos(keyboard_tooltip_hwnd_, NULL, rect_bounds.left, 361 ::SetWindowPos(keyboard_tooltip_hwnd_, NULL, rect_bounds.left,
362 rect_bounds.top, 0, 0, 362 rect_bounds.top, 0, 0,
363 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE); 363 SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOSIZE);
364 MessageLoop::current()->PostDelayedTask(FROM_HERE, 364 MessageLoop::current()->PostDelayedTask(FROM_HERE,
365 keyboard_tooltip_factory_.NewRunnableMethod( 365 keyboard_tooltip_factory_.NewRunnableMethod(
366 &TooltipManagerWin::DestroyKeyboardTooltipWindow, 366 &TooltipManagerWin::DestroyKeyboardTooltipWindow,
367 keyboard_tooltip_hwnd_), 367 keyboard_tooltip_hwnd_),
368 kDefaultTimeout); 368 kDefaultTimeout);
369 } 369 }
370 370
371 void TooltipManagerWin::HideKeyboardTooltip() { 371 void TooltipManagerWin::HideKeyboardTooltip() {
372 if (keyboard_tooltip_hwnd_ != NULL) { 372 if (keyboard_tooltip_hwnd_ != NULL) {
373 SendMessage(keyboard_tooltip_hwnd_, WM_CLOSE, 0, 0); 373 SendMessage(keyboard_tooltip_hwnd_, WM_CLOSE, 0, 0);
374 keyboard_tooltip_hwnd_ = NULL; 374 keyboard_tooltip_hwnd_ = NULL;
375 } 375 }
376 } 376 }
377 377
378 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) { 378 void TooltipManagerWin::DestroyKeyboardTooltipWindow(HWND window_to_destroy) {
379 if (keyboard_tooltip_hwnd_ == window_to_destroy) 379 if (keyboard_tooltip_hwnd_ == window_to_destroy)
380 HideKeyboardTooltip(); 380 HideKeyboardTooltip();
381 } 381 }
382 382
383 } // namespace views 383 } // namespace views
OLDNEW
« no previous file with comments | « views/widget/monitor_win.cc ('k') | views/widget/widget_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698