summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorsky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 17:51:04 +0000
committersky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-09-08 17:51:04 +0000
commit4fea07faa60c88589599bf60b33a36961be68491 (patch)
treee82d02260a590898641ffd7520cfd9e62c0c8764 /chrome
parent97afa066c572a1f56e0e8cbf1e93e8437a201eb7 (diff)
downloadchromium_src-4fea07faa60c88589599bf60b33a36961be68491.zip
chromium_src-4fea07faa60c88589599bf60b33a36961be68491.tar.gz
chromium_src-4fea07faa60c88589599bf60b33a36961be68491.tar.bz2
Fleshes out the tooltip implementation for views on Gtk. It doesn't
support explicit positioning of the tooltip as windows does. That'll have to be added later. BUG=none TEST=make sure tooltips still work correctly on windows Review URL: http://codereview.chromium.org/197031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25635 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/views/bookmark_bar_view.cc25
-rw-r--r--chrome/browser/views/toolbar_view.cc36
2 files changed, 20 insertions, 41 deletions
diff --git a/chrome/browser/views/bookmark_bar_view.cc b/chrome/browser/views/bookmark_bar_view.cc
index 889e910..96dc4b7 100644
--- a/chrome/browser/views/bookmark_bar_view.cc
+++ b/chrome/browser/views/bookmark_bar_view.cc
@@ -43,11 +43,6 @@
#include "views/widget/widget.h"
#include "views/window/window.h"
-#if defined(OS_WIN)
-#include "app/win_util.h"
-#include "base/base_drag_source.h"
-#endif
-
using views::CustomButton;
using views::DropTargetEvent;
using views::MenuButton;
@@ -141,13 +136,8 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc,
const GURL& url,
const std::wstring& title,
const std::wstring& languages) {
-#if defined(OS_WIN)
- gfx::Rect monitor_bounds = win_util::GetMonitorBoundsForRect(
- gfx::Rect(screen_loc.x(), screen_loc.y(), 1, 1));
-#else
- gfx::Rect monitor_bounds(0, 0, 10000, 10000);
- NOTIMPLEMENTED();
-#endif
+ int max_width = views::TooltipManager::GetMaxWidth(screen_loc.x(),
+ screen_loc.y());
gfx::Font tt_font = views::TooltipManager::GetDefaultFont();
std::wstring result;
@@ -155,11 +145,9 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc,
if (!title.empty()) {
std::wstring localized_title;
if (l10n_util::AdjustStringForLocaleDirection(title, &localized_title))
- result.append(gfx::ElideText(localized_title,
- tt_font,
- monitor_bounds.width()));
+ result.append(gfx::ElideText(localized_title, tt_font, max_width));
else
- result.append(gfx::ElideText(title, tt_font, monitor_bounds.width()));
+ result.append(gfx::ElideText(title, tt_font, max_width));
}
// Only show the URL if the url and title differ.
@@ -173,10 +161,7 @@ static std::wstring CreateToolTipForURLAndTitle(const gfx::Point& screen_loc,
// "/http://www.yahoo.com" when rendered, as is, in an RTL context since
// the Unicode BiDi algorithm puts certain characters on the left by
// default.
- std::wstring elided_url(gfx::ElideUrl(url,
- tt_font,
- monitor_bounds.width(),
- languages));
+ std::wstring elided_url(gfx::ElideUrl(url, tt_font, max_width, languages));
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&elided_url);
result.append(elided_url);
diff --git a/chrome/browser/views/toolbar_view.cc b/chrome/browser/views/toolbar_view.cc
index 664068d..2c87d7a 100644
--- a/chrome/browser/views/toolbar_view.cc
+++ b/chrome/browser/views/toolbar_view.cc
@@ -12,6 +12,7 @@
#include "app/os_exchange_data.h"
#include "app/resource_bundle.h"
#include "base/command_line.h"
+#include "base/keyboard_codes.h"
#include "base/logging.h"
#include "base/path_service.h"
#include "chrome/app/chrome_dll_resource.h"
@@ -46,9 +47,9 @@
#include "views/background.h"
#include "views/controls/button/button_dropdown.h"
#include "views/controls/label.h"
+#include "views/widget/tooltip_manager.h"
#if defined(OS_WIN)
#include "views/drag_utils.h"
-#include "views/widget/tooltip_manager.h"
#endif
#include "views/window/non_client_view.h"
#include "views/window/window.h"
@@ -584,7 +585,6 @@ void ToolbarView::ShowContextMenu(int x, int y, bool is_mouse_gesture) {
}
void ToolbarView::DidGainFocus() {
-#if defined(OS_WIN)
// Check to see if MSAA focus should be restored to previously focused button,
// and if button is an enabled, visibled child of toolbar.
if (!acc_focused_view_ ||
@@ -616,6 +616,7 @@ void ToolbarView::DidGainFocus() {
view_index = acc_focused_view_->GetID();
}
+#if defined(OS_WIN)
gfx::NativeView wnd = GetWidget()->GetNativeView();
// Notify Access Technology that there was a change in keyboard focus.
@@ -628,7 +629,6 @@ void ToolbarView::DidGainFocus() {
}
void ToolbarView::WillLoseFocus() {
-#if defined(OS_WIN)
if (acc_focused_view_) {
// Resetting focus state.
acc_focused_view_->SetHotTracked(false);
@@ -636,14 +636,9 @@ void ToolbarView::WillLoseFocus() {
// Any tooltips that are active should be hidden when toolbar loses focus.
if (GetWidget() && GetWidget()->GetTooltipManager())
GetWidget()->GetTooltipManager()->HideKeyboardTooltip();
-#else
- // TODO(port): deal with toolbar a11y focus.
- NOTIMPLEMENTED();
-#endif
}
bool ToolbarView::OnKeyPressed(const views::KeyEvent& e) {
-#if defined(OS_WIN)
// Paranoia check, button should be initialized upon toolbar gaining focus.
if (!acc_focused_view_)
return false;
@@ -652,15 +647,15 @@ bool ToolbarView::OnKeyPressed(const views::KeyEvent& e) {
int next_view = focused_view;
switch (e.GetCharacter()) {
- case VK_LEFT:
+ case base::VKEY_LEFT:
next_view = GetNextAccessibleViewIndex(focused_view, true);
break;
- case VK_RIGHT:
+ case base::VKEY_RIGHT:
next_view = GetNextAccessibleViewIndex(focused_view, false);
break;
- case VK_DOWN:
- case VK_RETURN:
- // VK_SPACE is already handled by the default case.
+ case base::VKEY_DOWN:
+ case base::VKEY_RETURN:
+ // VKEY_SPACE is already handled by the default case.
if (acc_focused_view_->GetID() == VIEW_ID_PAGE_MENU ||
acc_focused_view_->GetID() == VIEW_ID_APP_MENU) {
// If a menu button in toolbar is activated and its menu is displayed,
@@ -697,24 +692,23 @@ bool ToolbarView::OnKeyPressed(const views::KeyEvent& e) {
// Hot-track new focused button.
acc_focused_view_->SetHotTracked(true);
- // Retrieve information to generate an MSAA focus event.
- int view_id = acc_focused_view_->GetID();
- gfx::NativeView wnd = GetWidget()->GetNativeView();
-
// Show the tooltip for the view that got the focus.
if (GetWidget()->GetTooltipManager()) {
GetWidget()->GetTooltipManager()->
ShowKeyboardTooltip(GetChildViewAt(next_view));
}
+#if defined(OS_WIN)
+ // Retrieve information to generate an MSAA focus event.
+ gfx::NativeView wnd = GetWidget()->GetNativeView();
+ int view_id = acc_focused_view_->GetID();
// Notify Access Technology that there was a change in keyboard focus.
::NotifyWinEvent(EVENT_OBJECT_FOCUS, wnd, OBJID_CLIENT,
static_cast<LONG>(view_id));
- return true;
- }
#else
- // TODO(port): deal with toolbar a11y focus.
- NOTIMPLEMENTED();
+ NOTIMPLEMENTED();
#endif
+ return true;
+ }
return false;
}