diff options
-rw-r--r-- | views/controls/menu/menu_gtk.cc | 82 | ||||
-rw-r--r-- | views/controls/menu/menu_gtk.h | 52 | ||||
-rw-r--r-- | views/focus/focus_manager.cc | 54 | ||||
-rw-r--r-- | views/focus/focus_manager.h | 4 | ||||
-rw-r--r-- | views/views.gyp | 3 |
5 files changed, 185 insertions, 10 deletions
diff --git a/views/controls/menu/menu_gtk.cc b/views/controls/menu/menu_gtk.cc new file mode 100644 index 0000000..c2abb44 --- /dev/null +++ b/views/controls/menu/menu_gtk.cc @@ -0,0 +1,82 @@ +// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "views/controls/menu/menu_gtk.h" + +#include "base/logging.h" + +namespace views { + +// static +Menu* Menu::Create(Delegate* delegate, + AnchorPoint anchor, + gfx::NativeView parent) { + return new MenuGtk(delegate, anchor, parent); +} + +// static +Menu* Menu::GetSystemMenu(gfx::NativeWindow parent) { + NOTIMPLEMENTED(); + return NULL; +} + +MenuGtk::MenuGtk(Delegate* d, AnchorPoint anchor, gfx::NativeView owner) + : Menu(d, anchor) { + DCHECK(delegate()); +} + +MenuGtk::~MenuGtk() { +} + +Menu* MenuGtk::AddSubMenuWithIcon(int index, + int item_id, + const std::wstring& label, + const SkBitmap& icon) { + NOTIMPLEMENTED(); + return NULL; +} + +void MenuGtk::AddSeparator(int index) { + NOTIMPLEMENTED(); +} + +void MenuGtk::EnableMenuItemByID(int item_id, bool enabled) { + NOTIMPLEMENTED(); +} + +void MenuGtk::EnableMenuItemAt(int index, bool enabled) { + NOTIMPLEMENTED(); +} + +void MenuGtk::SetMenuLabel(int item_id, const std::wstring& label) { + NOTIMPLEMENTED(); +} + +bool MenuGtk::SetIcon(const SkBitmap& icon, int item_id) { + NOTIMPLEMENTED(); + return false; +} + +void MenuGtk::RunMenuAt(int x, int y) { + NOTIMPLEMENTED(); +} + +void MenuGtk::Cancel() { + NOTIMPLEMENTED(); +} + +int MenuGtk::ItemCount() { + NOTIMPLEMENTED(); + return 0; +} + +void MenuGtk::AddMenuItemInternal(int index, + int item_id, + const std::wstring& label, + const SkBitmap& icon, + MenuItemType type) { + NOTIMPLEMENTED(); +} + +} // namespace views diff --git a/views/controls/menu/menu_gtk.h b/views/controls/menu/menu_gtk.h new file mode 100644 index 0000000..5e7ad16 --- /dev/null +++ b/views/controls/menu/menu_gtk.h @@ -0,0 +1,52 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef VIEWS_CONTROLS_MENU_VIEWS_MENU_GTK_H_ +#define VIEWS_CONTROLS_MENU_VIEWS_MENU_GTK_H_ + +#include "base/basictypes.h" +#include "views/controls/menu/menu.h" + +namespace views { + +class MenuGtk : public Menu { + public: + // Construct a Menu using the specified controller to determine command + // state. + // delegate A Menu::Delegate implementation that provides more + // information about the Menu presentation. + // anchor An alignment hint for the popup menu. + // owner The window that the menu is being brought up relative + // to. Not actually used for anything but must not be + // NULL. + MenuGtk(Delegate* d, AnchorPoint anchor, gfx::NativeView owner); + virtual ~MenuGtk(); + + // Menu overrides. + virtual Menu* AddSubMenuWithIcon(int index, + int item_id, + const std::wstring& label, + const SkBitmap& icon); + virtual void AddSeparator(int index); + virtual void EnableMenuItemByID(int item_id, bool enabled); + virtual void EnableMenuItemAt(int index, bool enabled); + virtual void SetMenuLabel(int item_id, const std::wstring& label); + virtual bool SetIcon(const SkBitmap& icon, int item_id); + virtual void RunMenuAt(int x, int y); + virtual void Cancel(); + virtual int ItemCount(); + + protected: + virtual void AddMenuItemInternal(int index, + int item_id, + const std::wstring& label, + const SkBitmap& icon, + MenuItemType type); + + DISALLOW_COPY_AND_ASSIGN(MenuGtk); +}; + +} // namespace views + +#endif // VIEWS_CONTROLS_MENU_VIEWS_MENU_GTK_H_ diff --git a/views/focus/focus_manager.cc b/views/focus/focus_manager.cc index b33f64c..4cf6253 100644 --- a/views/focus/focus_manager.cc +++ b/views/focus/focus_manager.cc @@ -4,9 +4,14 @@ #include <algorithm> +#include "build/build_config.h" + +#if defined(OS_LINUX) +#include <gtk/gtk.h> +#endif + #include "base/histogram.h" #include "base/logging.h" -#include "base/win_util.h" #include "views/accelerator.h" #include "views/focus/focus_manager.h" #include "views/focus/view_storage.h" @@ -14,6 +19,10 @@ #include "views/widget/root_view.h" #include "views/widget/widget.h" +#if defined(OS_WIN) +#include "base/win_util.h" +#endif + // The following keys are used in SetProp/GetProp to associate additional // information needed for focus tracking with a window. @@ -41,6 +50,7 @@ static const wchar_t* const kFocusSubclassInstalled = namespace views { +#if defined(OS_WIN) // Callback installed via InstallFocusSubclass. static LRESULT CALLBACK FocusWindowCallback(HWND window, UINT message, WPARAM wParam, LPARAM lParam) { @@ -89,8 +99,11 @@ static LRESULT CALLBACK FocusWindowCallback(HWND window, UINT message, return CallWindowProc(original_handler, window, message, wParam, lParam); } +#endif + // FocusManager ----------------------------------------------------- +#if defined(OS_WIN) // static FocusManager* FocusManager::CreateFocusManager(HWND window, RootView* root_view) { @@ -131,8 +144,11 @@ void FocusManager::UninstallFocusSubclass(HWND window) { } } +#endif + // static -FocusManager* FocusManager::GetFocusManager(HWND window) { +FocusManager* FocusManager::GetFocusManager(gfx::NativeView window) { +#if defined(OS_WIN) DCHECK(window); // In case parent windows belong to a different process, yet @@ -149,17 +165,21 @@ FocusManager* FocusManager::GetFocusManager(HWND window) { GetProp(window, kFocusManagerKey)); } return focus_manager; +#else + NOTIMPLEMENTED(); + return NULL; +#endif } +#if defined(OS_WIN) // static -View* FocusManager::GetViewForWindow(HWND window, bool look_in_parents) { +View* FocusManager::GetViewForWindow(gfx::NativeView window, bool look_in_parents) { DCHECK(window); do { View* v = reinterpret_cast<View*>(GetProp(window, kViewKey)); if (v) return v; } while (look_in_parents && (window = ::GetParent(window))); - return NULL; } @@ -172,6 +192,7 @@ FocusManager::FocusManager(HWND root, RootView* root_view) ViewStorage::GetSharedInstance()->CreateStorageID(); DCHECK(root_); } +#endif FocusManager::~FocusManager() { // If there are still registered FocusChange listeners, chances are they were @@ -179,6 +200,7 @@ FocusManager::~FocusManager() { DCHECK(focus_change_listeners_.empty()); } +#if defined(OS_WIN) // Message handlers. bool FocusManager::OnSetFocus(HWND window) { if (ignore_set_focus_msg_) @@ -327,6 +349,7 @@ bool FocusManager::OnPostActivate(HWND window, } return false; } +#endif void FocusManager::ValidateFocusedView() { if (focused_view_) { @@ -348,11 +371,15 @@ bool FocusManager::ContainsView(View* view) { if (!widget) return false; - HWND window = widget->GetNativeView(); + gfx::NativeView window = widget->GetNativeView(); while (window) { if (window == root_) return true; +#if defined(OS_WIN) window = ::GetParent(window); +#else + window = gtk_widget_get_parent(window); +#endif } return false; } @@ -451,7 +478,7 @@ View* FocusManager::FindLastFocusableView() { // Just walk the entire focus loop from where we're at until we reach the end. View* new_focused = NULL; View* last_focused = focused_view_; - while (new_focused = GetNextFocusableView(last_focused, false, true)) + while ((new_focused = GetNextFocusableView(last_focused, false, true))) last_focused = new_focused; return last_focused; } @@ -493,10 +520,15 @@ void FocusManager::ClearFocus() { void FocusManager::ClearHWNDFocus() { // Keep the top root window focused so we get keyboard events. ignore_set_focus_msg_ = true; +#if defined(OS_WIN) ::SetFocus(root_); +#else + NOTIMPLEMENTED(); +#endif ignore_set_focus_msg_ = false; } +#if defined(OS_WIN) void FocusManager::FocusHWND(HWND hwnd) { ignore_set_focus_msg_ = true; // Only reset focus if hwnd is not already focused. @@ -504,6 +536,7 @@ void FocusManager::FocusHWND(HWND hwnd) { ::SetFocus(hwnd); ignore_set_focus_msg_ = false; } +#endif void FocusManager::StoreFocusedView() { ViewStorage* view_storage = ViewStorage::GetSharedInstance(); @@ -560,7 +593,11 @@ void FocusManager::ClearStoredFocusedView() { } FocusManager* FocusManager::GetParentFocusManager() const { +#if defined(OS_WIN) HWND parent = ::GetParent(root_); +#else + GtkWidget* parent = gtk_widget_get_parent(root_); +#endif // If we are a top window, we don't have a parent FocusManager. if (!parent) return NULL; @@ -666,7 +703,12 @@ AcceleratorTarget* FocusManager::GetTargetForAccelerator( // static bool FocusManager::IsTabTraversalKeyEvent(const KeyEvent& key_event) { +#if defined(OS_WIN) return key_event.GetCharacter() == VK_TAB && !win_util::IsCtrlPressed(); +#else + NOTIMPLEMENTED(); + return false; +#endif } void FocusManager::ViewRemoved(View* parent, View* removed) { diff --git a/views/focus/focus_manager.h b/views/focus/focus_manager.h index b4fd3b6..92c5480 100644 --- a/views/focus/focus_manager.h +++ b/views/focus/focus_manager.h @@ -321,10 +321,8 @@ class FocusManager { // had focus. int stored_focused_view_storage_id_; -#if defined(OS_WIN) // The window associated with this focus manager. - HWND root_; -#endif + gfx::NativeView root_; // Used to allow setting the focus on an HWND without changing the currently // focused view. diff --git a/views/views.gyp b/views/views.gyp index ab0c630..f6b49ed 100644 --- a/views/views.gyp +++ b/views/views.gyp @@ -100,6 +100,8 @@ 'controls/menu/controller.h', 'controls/menu/menu.cc', 'controls/menu/menu.h', + 'controls/menu/menu_gtk.cc', + 'controls/menu/menu_gtk.h', 'controls/menu/menu_win.cc', 'controls/menu/menu_win.h', 'controls/menu/view_menu_delegate.h', @@ -233,7 +235,6 @@ 'controls/message_box_view.cc', 'controls/scroll_view.cc', 'controls/table/group_table_view.cc', - 'focus/focus_manager.cc', 'controls/native_control.cc', 'controls/scrollbar/native_scroll_bar.cc', 'controls/button/radio_button.cc', |