diff options
author | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-17 01:36:03 +0000 |
---|---|---|
committer | erg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-17 01:36:03 +0000 |
commit | e044f8df992fcb9f289b98115d0722dcd8cea103 (patch) | |
tree | 6844ce69dfaf4cbdfe0e540e6647ef60b3c22451 /chrome/views/view.cc | |
parent | 81514c583f3c281ddbb72d13a021bfed58f7e3c7 (diff) | |
download | chromium_src-e044f8df992fcb9f289b98115d0722dcd8cea103.zip chromium_src-e044f8df992fcb9f289b98115d0722dcd8cea103.tar.gz chromium_src-e044f8df992fcb9f289b98115d0722dcd8cea103.tar.bz2 |
Revert "Add #ifdefs to the views/ code and move windows specific code
into their own files to get some files compiling."
Conflicts with something that went in in the interim...
Review URL: http://codereview.chromium.org/18187
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8251 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views/view.cc')
-rw-r--r-- | chrome/views/view.cc | 112 |
1 files changed, 90 insertions, 22 deletions
diff --git a/chrome/views/view.cc b/chrome/views/view.cc index e65a0c9..7ace91d 100644 --- a/chrome/views/view.cc +++ b/chrome/views/view.cc @@ -16,15 +16,16 @@ #include "base/string_util.h" #include "chrome/common/drag_drop_types.h" #include "chrome/common/gfx/chrome_canvas.h" +#include "chrome/common/gfx/path.h" #include "chrome/common/l10n_util.h" +#include "chrome/common/os_exchange_data.h" +#include "chrome/views/accessibility/accessible_wrapper.h" #include "chrome/views/background.h" +#include "chrome/views/border.h" #include "chrome/views/layout_manager.h" #include "chrome/views/root_view.h" -#include "chrome/views/widget.h" -#if defined(OS_WIN) #include "chrome/views/tooltip_manager.h" -#include "chrome/views/accessibility/accessible_wrapper.h" -#endif +#include "chrome/views/widget.h" #include "SkShader.h" namespace views { @@ -69,22 +70,20 @@ class RestoreFocusTask : public Task { View::View() : id_(0), group_(-1), - enabled_(true), - focusable_(false), bounds_(0,0,0,0), parent_(NULL), - should_restore_focus_(false), + enabled_(true), is_visible_(true), + focusable_(false), + accessibility_(NULL), is_parent_owned_(true), notify_when_visible_bounds_in_root_changes_(false), registered_for_visible_bounds_notification_(false), next_focusable_view_(NULL), previous_focusable_view_(NULL), + should_restore_focus_(false), restore_focus_view_task_(NULL), context_menu_controller_(NULL), -#if defined(OS_WIN) - accessibility_(NULL), -#endif drag_controller_(NULL), ui_mirroring_is_enabled_for_rtl_languages_(true), flip_canvas_on_paint_for_rtl_ui_(false) { @@ -177,6 +176,7 @@ gfx::Size View::GetMinimumSize() { int View::GetHeightForWidth(int w) { if (layout_manager_.get()) return layout_manager_->GetPreferredHeightForWidth(this, w); + return GetPreferredSize().height(); } @@ -281,7 +281,20 @@ void View::SetFocusable(bool focusable) { focusable_ = focusable; } +FocusManager* View::GetFocusManager() { + Widget* widget = GetWidget(); + if (!widget) + return NULL; + + HWND hwnd = widget->GetHWND(); + if (!hwnd) + return NULL; + + return FocusManager::GetFocusManager(hwnd); +} + bool View::HasFocus() { + RootView* root_view = GetRootView(); FocusManager* focus_manager = GetFocusManager(); if (focus_manager) return focus_manager->GetFocusedView() == this; @@ -495,6 +508,7 @@ void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) { // from mouse released. gfx::Point location(e.location()); ConvertPointToScreen(this, &location); + ContextMenuController* context_menu_controller = context_menu_controller_; OnMouseReleased(e, canceled); ShowContextMenu(location.x(), location.y(), true); } else { @@ -503,6 +517,17 @@ void View::ProcessMouseReleased(const MouseEvent& e, bool canceled) { // WARNING: we may have been deleted. } +void View::DoDrag(const MouseEvent& e, int press_x, int press_y) { + scoped_refptr<OSExchangeData> data = new OSExchangeData; + WriteDragData(press_x, press_y, data.get()); + + // Message the RootView to do the drag and drop. That way if we're removed + // the RootView can detect it and avoid calling us back. + RootView* root_view = GetRootView(); + root_view->StartDragForViewFromMouseEvent( + this, data, GetDragOperations(press_x, press_y)); +} + void View::AddChildView(View* v) { AddChildView(static_cast<int>(child_views_.size()), v, false); } @@ -1020,6 +1045,19 @@ void View::UnregisterAccelerators() { ///////////////////////////////////////////////////////////////////////////// // +// View - accessibility +// +///////////////////////////////////////////////////////////////////////////// + +AccessibleWrapper* View::GetAccessibleWrapper() { + if (accessibility_.get() == NULL) { + accessibility_.reset(new AccessibleWrapper(this)); + } + return accessibility_.get(); +} + +///////////////////////////////////////////////////////////////////////////// +// // View - floating views // ///////////////////////////////////////////////////////////////////////////// @@ -1364,6 +1402,26 @@ bool View::IsVisibleInRootView() const { return false; } +bool View::HitTest(const gfx::Point& l) const { + if (l.x() >= 0 && l.x() < static_cast<int>(width()) && + l.y() >= 0 && l.y() < static_cast<int>(height())) { + if (HasHitTestMask()) { + gfx::Path mask; + GetHitTestMask(&mask); + ScopedHRGN rgn(mask.CreateHRGN()); + return !!PtInRegion(rgn, l.x(), l.y()); + } + // No mask, but inside our bounds. + return true; + } + // Outside our bounds. + return false; +} + +HCURSOR View::GetCursorForPoint(Event::EventType event_type, int x, int y) { + return NULL; +} + ///////////////////////////////////////////////////////////////////////////// // // View - keyboard and focus @@ -1424,12 +1482,34 @@ int View::OnPerformDrop(const DropTargetEvent& event) { return DragDropTypes::DRAG_NONE; } +static int GetHorizontalDragThreshold() { + static int threshold = -1; + if (threshold == -1) + threshold = GetSystemMetrics(SM_CXDRAG) / 2; + return threshold; +} + +static int GetVerticalDragThreshold() { + static int threshold = -1; + if (threshold == -1) + threshold = GetSystemMetrics(SM_CYDRAG) / 2; + return threshold; +} + // static bool View::ExceededDragThreshold(int delta_x, int delta_y) { return (abs(delta_x) > GetHorizontalDragThreshold() || abs(delta_y) > GetVerticalDragThreshold()); } +void View::Focus() { + // Set the native focus to the root view window so it receives the keyboard + // messages. + FocusManager* focus_manager = GetFocusManager(); + if (focus_manager) + focus_manager->FocusHWND(GetRootView()->GetWidget()->GetHWND()); +} + bool View::CanProcessTabKeyEvents() { return false; } @@ -1444,27 +1524,15 @@ bool View::GetTooltipTextOrigin(int x, int y, gfx::Point* loc) { } void View::TooltipTextChanged() { -#if defined(OS_WIN) Widget* widget = GetWidget(); if (widget && widget->GetTooltipManager()) widget->GetTooltipManager()->TooltipTextChanged(this); -#else - // TODO(port): Not actually windows specific; I just haven't ported this part - // yet. - NOTIMPLEMENTED(); -#endif } void View::UpdateTooltip() { -#if defined(OS_WIN) Widget* widget = GetWidget(); if (widget && widget->GetTooltipManager()) widget->GetTooltipManager()->UpdateTooltip(); -#else - // TODO(port): Not actually windows specific; I just haven't ported this part - // yet. - NOTIMPLEMENTED(); -#endif } void View::SetParentOwned(bool f) { |