diff options
author | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-26 20:52:36 +0000 |
---|---|---|
committer | tfarina@chromium.org <tfarina@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-10-26 20:52:36 +0000 |
commit | aca5148cbb5c19f23c20e8421ce4e74d3bbd7a05 (patch) | |
tree | 6b6dfa178f15c227bfe6cc2afb61e033d4b1c414 /ui/views/events | |
parent | d1735a7513c5516d2a14eaa8355100e4d7a90cef (diff) | |
download | chromium_src-aca5148cbb5c19f23c20e8421ce4e74d3bbd7a05.zip chromium_src-aca5148cbb5c19f23c20e8421ce4e74d3bbd7a05.tar.gz chromium_src-aca5148cbb5c19f23c20e8421ce4e74d3bbd7a05.tar.bz2 |
Remove src/ui/views.
BUG=101590
R=pkasting@chromium.org
Review URL: http://codereview.chromium.org/8395036
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107428 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/events')
-rw-r--r-- | ui/views/events/accelerator.cc | 179 | ||||
-rw-r--r-- | ui/views/events/accelerator.h | 28 | ||||
-rw-r--r-- | ui/views/events/context_menu_controller.h | 47 | ||||
-rw-r--r-- | ui/views/events/drag_controller.h | 37 | ||||
-rw-r--r-- | ui/views/events/event.cc | 76 | ||||
-rw-r--r-- | ui/views/events/event.h | 157 | ||||
-rw-r--r-- | ui/views/events/focus_event.cc | 19 | ||||
-rw-r--r-- | ui/views/events/focus_event.h | 51 |
8 files changed, 0 insertions, 594 deletions
diff --git a/ui/views/events/accelerator.cc b/ui/views/events/accelerator.cc deleted file mode 100644 index 8cd7f03a..0000000 --- a/ui/views/events/accelerator.cc +++ /dev/null @@ -1,179 +0,0 @@ -// Copyright (c) 2011 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 "ui/views/events/accelerator.h" - -#if defined(OS_WIN) -#include <windows.h> -#elif defined(TOOLKIT_USES_GTK) -#include <gdk/gdk.h> -#endif - -#include "base/i18n/rtl.h" -#include "base/logging.h" -#include "base/string_util.h" -#include "base/utf_string_conversions.h" -#include "grit/ui_strings.h" -#include "ui/base/l10n/l10n_util.h" - -namespace ui { - -namespace { - -bool IsShiftDown(const Accelerator& accelerator) { - return (accelerator.key_code() & VKEY_SHIFT) == VKEY_SHIFT; -} - -bool IsCtrlDown(const Accelerator& accelerator) { - return (accelerator.key_code() & VKEY_CONTROL) == VKEY_CONTROL; -} - -bool IsAltDown(const Accelerator& accelerator) { - return (accelerator.key_code() & VKEY_MENU) == VKEY_MENU; -} - -} // namespace - -string16 GetShortcutTextForAccelerator(const Accelerator& accelerator) { - int string_id = 0; - switch(accelerator.key_code()) { - case ui::VKEY_TAB: - string_id = IDS_APP_TAB_KEY; - break; - case ui::VKEY_RETURN: - string_id = IDS_APP_ENTER_KEY; - break; - case ui::VKEY_ESCAPE: - string_id = IDS_APP_ESC_KEY; - break; - case ui::VKEY_PRIOR: - string_id = IDS_APP_PAGEUP_KEY; - break; - case ui::VKEY_NEXT: - string_id = IDS_APP_PAGEDOWN_KEY; - break; - case ui::VKEY_END: - string_id = IDS_APP_END_KEY; - break; - case ui::VKEY_HOME: - string_id = IDS_APP_HOME_KEY; - break; - case ui::VKEY_INSERT: - string_id = IDS_APP_INSERT_KEY; - break; - case ui::VKEY_DELETE: - string_id = IDS_APP_DELETE_KEY; - break; - case ui::VKEY_LEFT: - string_id = IDS_APP_LEFT_ARROW_KEY; - break; - case ui::VKEY_RIGHT: - string_id = IDS_APP_RIGHT_ARROW_KEY; - break; - case ui::VKEY_BACK: - string_id = IDS_APP_BACKSPACE_KEY; - break; - case ui::VKEY_F1: - string_id = IDS_APP_F1_KEY; - break; - case ui::VKEY_F11: - string_id = IDS_APP_F11_KEY; - break; - default: - break; - } - - string16 shortcut; - if (!string_id) { -#if defined(OS_WIN) - // Our fallback is to try translate the key code to a regular character - // unless it is one of digits (VK_0 to VK_9). Some keyboard - // layouts have characters other than digits assigned in - // an unshifted mode (e.g. French AZERY layout has 'a with grave - // accent' for '0'). For display in the menu (e.g. Ctrl-0 for the - // default zoom level), we leave VK_[0-9] alone without translation. - wchar_t key; - if (accelerator.key_code() >= '0' && accelerator.key_code() <= '9') - key = accelerator.key_code(); - else - key = LOWORD(::MapVirtualKeyW(accelerator.key_code(), MAPVK_VK_TO_CHAR)); - shortcut += key; -#elif defined(TOOLKIT_USES_GTK) - const gchar* name = NULL; - switch (accelerator.key_code()) { - case ui::VKEY_OEM_2: - name = static_cast<const gchar*>("/"); - break; - default: - name = gdk_keyval_name(gdk_keyval_to_lower(accelerator.key_code())); - break; - } - if (name) { - if (name[0] != 0 && name[1] == 0) - shortcut += static_cast<string16::value_type>(g_ascii_toupper(name[0])); - else - shortcut += UTF8ToUTF16(name); - } -#endif - } else { - shortcut = l10n_util::GetStringUTF16(string_id); - } - - // Checking whether the character used for the accelerator is alphanumeric. - // If it is not, then we need to adjust the string later on if the locale is - // right-to-left. See below for more information of why such adjustment is - // required. - string16 shortcut_rtl; - bool adjust_shortcut_for_rtl = false; - if (base::i18n::IsRTL() && shortcut.length() == 1 && - !IsAsciiAlpha(shortcut.at(0)) && !IsAsciiDigit(shortcut.at(0))) { - adjust_shortcut_for_rtl = true; - shortcut_rtl.assign(shortcut); - } - - if (IsShiftDown(accelerator)) - shortcut = l10n_util::GetStringFUTF16(IDS_APP_SHIFT_MODIFIER, shortcut); - - // Note that we use 'else-if' in order to avoid using Ctrl+Alt as a shortcut. - // See http://blogs.msdn.com/oldnewthing/archive/2004/03/29/101121.aspx for - // more information. - if (IsCtrlDown(accelerator)) - shortcut = l10n_util::GetStringFUTF16(IDS_APP_CONTROL_MODIFIER, shortcut); - else if (IsAltDown(accelerator)) - shortcut = l10n_util::GetStringFUTF16(IDS_APP_ALT_MODIFIER, shortcut); - - // For some reason, menus in Windows ignore standard Unicode directionality - // marks (such as LRE, PDF, etc.). On RTL locales, we use RTL menus and - // therefore any text we draw for the menu items is drawn in an RTL context. - // Thus, the text "Ctrl++" (which we currently use for the Zoom In option) - // appears as "++Ctrl" in RTL because the Unicode BiDi algorithm puts - // punctuations on the left when the context is right-to-left. Shortcuts that - // do not end with a punctuation mark (such as "Ctrl+H" do not have this - // problem). - // - // The only way to solve this problem is to adjust the string if the locale - // is RTL so that it is drawn correnctly in an RTL context. Instead of - // returning "Ctrl++" in the above example, we return "++Ctrl". This will - // cause the text to appear as "Ctrl++" when Windows draws the string in an - // RTL context because the punctunation no longer appears at the end of the - // string. - // - // TODO(idana) bug# 1232732: this hack can be avoided if instead of using - // views::Menu we use views::MenuItemView because the latter is a View - // subclass and therefore it supports marking text as RTL or LTR using - // standard Unicode directionality marks. - if (adjust_shortcut_for_rtl) { - int key_length = static_cast<int>(shortcut_rtl.length()); - DCHECK_GT(key_length, 0); - shortcut_rtl.append(ASCIIToUTF16("+")); - - // Subtracting the size of the shortcut key and 1 for the '+' sign. - shortcut_rtl.append(shortcut, 0, shortcut.length() - key_length - 1); - shortcut.swap(shortcut_rtl); - } - - return shortcut; -} - -} // namespace ui diff --git a/ui/views/events/accelerator.h b/ui/views/events/accelerator.h deleted file mode 100644 index 965c447..0000000 --- a/ui/views/events/accelerator.h +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright (c) 2011 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 UI_VIEWS_EVENTS_ACCELERATOR_H_ -#define UI_VIEWS_EVENTS_ACCELERATOR_H_ -#pragma once - -#include "ui/base/models/accelerator.h" - -namespace ui { - -string16 GetShortcutTextForAccelerator(const Accelerator& accelerator); - -// An interface that classes that want to register for keyboard accelerators -// should implement. -class AcceleratorTarget { - public: - // This method should return true if the accelerator was processed. - virtual bool AcceleratorPressed(const Accelerator& accelerator) = 0; - - protected: - virtual ~AcceleratorTarget() {} -}; - -} // namespace ui - -#endif // UI_VIEWS_EVENTS_ACCELERATOR_H_ diff --git a/ui/views/events/context_menu_controller.h b/ui/views/events/context_menu_controller.h deleted file mode 100644 index ab35a32..0000000 --- a/ui/views/events/context_menu_controller.h +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright (c) 2011 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 UI_VIEWS_EVENTS_CONTEXT_MENU_CONTROLLER_H_ -#define UI_VIEWS_EVENTS_CONTEXT_MENU_CONTROLLER_H_ -#pragma once - -namespace gfx { -class Point; -} - -namespace ui { - -class View; - -// ContextMenuController is responsible for showing the context menu for a -// View. To use a ContextMenuController invoke SetContextMenuController on a -// View. When the appropriate user gesture occurs ShowContextMenu is invoked -// on the ContextMenuController. -// -// Setting a ContextMenuController on a View makes the View process mouse -// events. -// -// It is up to subclasses that do their own mouse processing to invoke -// the appropriate ContextMenuController method, typically by invoking super's -// implementation for mouse processing. -// -class ContextMenuController { - public: - // Invoked to show the context menu for the source view. If |is_mouse_gesture| - // is true, |point| is the location of the mouse. If |is_mouse_gesture| is - // false, this method was not invoked by a mouse gesture and |point| is the - // recommended location to show the menu at. - // - // |point| is in screen coordinates. - virtual void ShowContextMenuForView(View* source, - const gfx::Point& point, - bool is_mouse_gesture) = 0; - - protected: - virtual ~ContextMenuController() {} -}; - -} // namespace ui - -#endif // UI_VIEWS_EVENTS_CONTEXT_MENU_CONTROLLER_H_ diff --git a/ui/views/events/drag_controller.h b/ui/views/events/drag_controller.h deleted file mode 100644 index 6344f83..0000000 --- a/ui/views/events/drag_controller.h +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright (c) 2011 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 UI_VIEWS_EVENTS_DRAG_CONTROLLER_H_ -#define UI_VIEWS_EVENTS_DRAG_CONTROLLER_H_ -#pragma once - -namespace ui { - -// DragController is responsible for writing drag data for a View, as well as -// supplying the supported drag operations without having to subclass View. -class DragController { - public: - // Writes the data for the drag. - virtual void WriteDragDataForView(View* sender, - const gfx::Point& press_pt, - OSExchangeData* data) = 0; - - // Returns the supported drag operations (see DragDropTypes for possible - // values). A drag is only started if this returns a non-zero value. - virtual int GetDragOperationsForView(View* sender, const gfx::Point& p) = 0; - - // Returns true if a drag operation can be started. - // |press_pt| represents the coordinates where the mouse was initially - // pressed down. |p| is the current mouse coordinates. - virtual bool CanStartDragForView(View* sender, - const gfx::Point& press_pt, - const gfx::Point& p) = 0; - - protected: - virtual ~DragController() {} -}; - -} // namespace ui - -#endif // UI_VIEWS_EVENTS_DRAG_CONTROLLER_H_ diff --git a/ui/views/events/event.cc b/ui/views/events/event.cc deleted file mode 100644 index 544c2ad..0000000 --- a/ui/views/events/event.cc +++ /dev/null @@ -1,76 +0,0 @@ -// Copyright (c) 2011 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 "ui/views/events/event.h" - -#include "ui/views/view.h" - -namespace ui { - -//////////////////////////////////////////////////////////////////////////////// -// Event, protected: - -Event::Event(EventType type, int flags) - : type_(type), - flags_(flags) { -} - -int Event::GetModifiers() const { - int modifiers = 0; - if (IsShiftDown()) - modifiers |= VKEY_SHIFT; - if (IsControlDown()) - modifiers |= VKEY_CONTROL; - if (IsAltDown()) - modifiers |= VKEY_MENU; - if (IsCapsLockDown()) - modifiers |= VKEY_CAPITAL; - return modifiers; -} - -//////////////////////////////////////////////////////////////////////////////// -// LocatedEvent, protected: - -LocatedEvent::LocatedEvent(EventType type, - const gfx::Point& location, - int flags) - : Event(type, flags), - location_(location) { -} - -LocatedEvent::LocatedEvent(const LocatedEvent& other, - View* source, - View* target) - : Event(other.type(), other.flags()) { - location_ = other.location(); - View::ConvertPointToView(*source, *target, &location_); -} - -//////////////////////////////////////////////////////////////////////////////// -// MouseEvent, public: - -MouseEvent::MouseEvent(const ui::NativeEvent& native_event) - : LocatedEvent(ui::EventTypeFromNative(native_event), - ui::EventLocationFromNative(native_event), - ui::EventFlagsFromNative(native_event)) { -} - -MouseEvent::MouseEvent(const MouseEvent& other, View* source, View* target) - : LocatedEvent(other, source, target) { -} - -KeyEvent::KeyEvent(const ui::NativeEvent& native_event) - : Event(ui::EventTypeFromNative(native_event), - ui::EventFlagsFromNative(native_event)), - key_code_(ui::KeyboardCodeFromNative(native_event)) { -} - -MouseWheelEvent::MouseWheelEvent(const ui::NativeEvent& native_event) - : LocatedEvent(ui::EventTypeFromNative(native_event), - ui::EventLocationFromNative(native_event), - ui::EventFlagsFromNative(native_event)), - offset_(ui::GetMouseWheelOffset(native_event)) { -} - -} // namespace ui diff --git a/ui/views/events/event.h b/ui/views/events/event.h deleted file mode 100644 index 002608c..0000000 --- a/ui/views/events/event.h +++ /dev/null @@ -1,157 +0,0 @@ -// Copyright (c) 2011 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 UI_VIEWS_EVENTS_EVENT_H_ -#define UI_VIEWS_EVENTS_EVENT_H_ -#pragma once - -#include "base/basictypes.h" -#include "ui/base/events.h" -#include "ui/base/keycodes/keyboard_codes.h" -#include "ui/gfx/point.h" - -class OSExchangeData; - -namespace ui { - -class View; - -class Event { - public: - EventType type() const { return type_; } - int flags() const { return flags_; } - void set_flags(int flags) { flags_ = flags; } - - // The following methods return true if the respective keys were pressed at - // the time the event was created. - bool IsShiftDown() const { return (flags_ & EF_SHIFT_DOWN) != 0; } - bool IsControlDown() const { return (flags_ & EF_CONTROL_DOWN) != 0; } - bool IsCapsLockDown() const { return (flags_ & EF_CAPS_LOCK_DOWN) != 0; } - bool IsAltDown() const { return (flags_ & EF_ALT_DOWN) != 0; } - - // Return a mask of active modifier keycodes from - // ui/base/keycodes/keyboard_codes.h - int GetModifiers() const; - - // Returns true if the event is any kind of mouse event. - bool IsMouseEvent() const { - return type_ == ET_MOUSE_PRESSED || - type_ == ET_MOUSE_RELEASED || - type_ == ET_MOUSE_MOVED || - type_ == ET_MOUSE_EXITED || - type_ == ET_MOUSEWHEEL; - } - - protected: - Event(EventType type, int flags); - - private: - EventType type_; - int flags_; - - DISALLOW_COPY_AND_ASSIGN(Event); -}; - -class LocatedEvent : public Event { - public: - int x() const { return location_.x(); } - int y() const { return location_.y(); } - const gfx::Point& location() const { return location_; } - - protected: - // Constructors called from subclasses. - - // Simple initialization from cracked metadata. - LocatedEvent(EventType type, const gfx::Point& location, int flags); - - // During event processing, event locations are translated from the - // coordinates of a source View to a target as the tree is descended. This - // translation occurs by constructing a new event from another event object, - // specifying a |source| and |target| View to facilitate coordinate - // conversion. Events that are processed in this manner will have a similar - // constructor that calls into this one. - LocatedEvent(const LocatedEvent& other, View* source, View* target); - - private: - gfx::Point location_; - - DISALLOW_COPY_AND_ASSIGN(LocatedEvent); -}; - -class MouseEvent : public LocatedEvent { - public: - explicit MouseEvent(const ui::NativeEvent& native_event); - - MouseEvent(const MouseEvent& other, View* source, View* target); - - // Conveniences to quickly test what button is down: - bool IsOnlyLeftMouseButton() const { - return (flags() & EF_LEFT_BUTTON_DOWN) && - !(flags() & (EF_MIDDLE_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN)); - } - bool IsLeftMouseButton() const { - return (flags() & EF_LEFT_BUTTON_DOWN) != 0; - } - bool IsOnlyMiddleMouseButton() const { - return (flags() & EF_MIDDLE_BUTTON_DOWN) && - !(flags() & (EF_LEFT_BUTTON_DOWN | EF_RIGHT_BUTTON_DOWN)); - } - bool IsMiddleMouseButton() const { - return (flags() & EF_MIDDLE_BUTTON_DOWN) != 0; - } - bool IsOnlyRightMouseButton() const { - return (flags() & EF_RIGHT_BUTTON_DOWN) && - !(flags() & (EF_LEFT_BUTTON_DOWN | EF_MIDDLE_BUTTON_DOWN)); - } - bool IsRightMouseButton() const { - return (flags() & EF_RIGHT_BUTTON_DOWN) != 0; - } - - private: - DISALLOW_COPY_AND_ASSIGN(MouseEvent); -}; - -class KeyEvent : public Event { - public: - explicit KeyEvent(const ui::NativeEvent& native_event); - - KeyboardCode key_code() const { return key_code_; } - - private: - KeyboardCode key_code_; - - DISALLOW_COPY_AND_ASSIGN(KeyEvent); -}; - -class MouseWheelEvent : public LocatedEvent { - public: - explicit MouseWheelEvent(const ui::NativeEvent& native_event); - - int offset() const { return offset_; } - - private: - int offset_; - - DISALLOW_COPY_AND_ASSIGN(MouseWheelEvent); -}; - -/* -class DropTargetEvent : public LocatedEvent { - public: - explicit DropTargetEvent(const ui::NativeEvent& native_event); - - const OSExchangeData& data() const { return data_; } - int source_operations() const { return source_operations_; } - - private: - const OSExchangeData& data_; - int source_operations_; - - DISALLOW_COPY_AND_ASSIGN(DropTargetEvent); -}; -*/ - -} // namespace ui - -#endif // UI_VIEWS_EVENTS_EVENT_H_ diff --git a/ui/views/events/focus_event.cc b/ui/views/events/focus_event.cc deleted file mode 100644 index 4a05999..0000000 --- a/ui/views/events/focus_event.cc +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright (c) 2011 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 "ui/views/events/focus_event.h" - -namespace ui { - -//////////////////////////////////////////////////////////////////////////////// -// FocusEvent, public: - -FocusEvent::FocusEvent(Type type, Reason reason, TraversalDirection direction) - : type_(type), - reason_(reason), - direction_(direction), - Event(ET_FOCUS_CHANGE, 0) { -} - -} // namespace ui diff --git a/ui/views/events/focus_event.h b/ui/views/events/focus_event.h deleted file mode 100644 index 377c3f7..0000000 --- a/ui/views/events/focus_event.h +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright (c) 2011 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 UI_VIEWS_EVENTS_FOCUS_EVENT_H_ -#define UI_VIEWS_EVENTS_FOCUS_EVENT_H_ -#pragma once - -#include "base/basictypes.h" -#include "ui/views/events/event.h" - -namespace ui { - -class FocusEvent : public Event { - public: - enum Type { - TYPE_FOCUS_IN, // Target View did gain focus - TYPE_FOCUS_OUT // Target View will lose focus - }; - - enum Reason { - REASON_TRAVERSAL, // Focus change occurred because of a tab-traversal - REASON_RESTORE, // Focus was restored (e.g. window activation). - REASON_DIRECT // Focus was directly set (e.g. with mouse click). - }; - - enum TraversalDirection { - DIRECTION_NONE, - DIRECTION_FORWARD, - DIRECTION_REVERSE - }; - - FocusEvent(Type type, - Reason reason, - TraversalDirection direction); - - Type type() const { return type_; } - Reason reason() const { return reason_; } - TraversalDirection direction() const { return direction_; } - - private: - Type type_; - Reason reason_; - TraversalDirection direction_; - - DISALLOW_COPY_AND_ASSIGN(FocusEvent); -}; - -} // namespace ui - -#endif // UI_VIEWS_EVENTS_FOCUS_EVENT_H_ |