summaryrefslogtreecommitdiffstats
path: root/chrome/views
diff options
context:
space:
mode:
authorerg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-17 01:21:56 +0000
committererg@google.com <erg@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-17 01:21:56 +0000
commit81514c583f3c281ddbb72d13a021bfed58f7e3c7 (patch)
treebeab789f1dbb7629c8bbf95acb27ba224bb35650 /chrome/views
parent0999c45abbe8d57f1c62c65f91459881a4af321a (diff)
downloadchromium_src-81514c583f3c281ddbb72d13a021bfed58f7e3c7.zip
chromium_src-81514c583f3c281ddbb72d13a021bfed58f7e3c7.tar.gz
chromium_src-81514c583f3c281ddbb72d13a021bfed58f7e3c7.tar.bz2
Add #ifdefs to the views/ code and move windows specific code into their own files to get some files compiling.
Review URL: http://codereview.chromium.org/18136 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8250 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/views')
-rw-r--r--chrome/views/SConscript14
-rw-r--r--chrome/views/background.cc10
-rw-r--r--chrome/views/focus_manager.h15
-rw-r--r--chrome/views/root_view.cc129
-rw-r--r--chrome/views/root_view.h12
-rw-r--r--chrome/views/root_view_gtk.cc17
-rw-r--r--chrome/views/root_view_win.cc82
-rw-r--r--chrome/views/view.cc112
-rw-r--r--chrome/views/view.h8
-rw-r--r--chrome/views/view_gtk.cc56
-rw-r--r--chrome/views/view_win.cc91
-rw-r--r--chrome/views/views.vcproj8
-rw-r--r--chrome/views/widget.h4
13 files changed, 387 insertions, 171 deletions
diff --git a/chrome/views/SConscript b/chrome/views/SConscript
index 7e4596a..a15a0e5 100644
--- a/chrome/views/SConscript
+++ b/chrome/views/SConscript
@@ -92,7 +92,18 @@ input_files = [
'window_delegate.cc',
]
+if env.Bit('windows'):
+ input_files += [
+ "root_view_win.cc",
+ "view_win.cc"
+ ]
+
if env.Bit('linux'):
+ input_files += [
+ "root_view_gtk.cc",
+ "view_gtk.cc"
+ ]
+
# TODO(port): Port to Linux.
remove_files = [
'accelerator.cc',
@@ -100,7 +111,6 @@ if env.Bit('linux'):
'accessibility/accessible_wrapper.cc',
'accessibility/view_accessibility.cc',
'aero_tooltip_manager.cc',
- 'background.cc',
'base_button.cc',
'bitmap_scroll_bar.cc',
'button.cc',
@@ -130,7 +140,6 @@ if env.Bit('linux'):
'painter.cc',
'radio_button.cc',
'resize_corner.cc',
- 'root_view.cc',
'root_view_drop_target.cc',
'scroll_view.cc',
'separator.cc',
@@ -142,7 +151,6 @@ if env.Bit('linux'):
'throbber.cc',
'tooltip_manager.cc',
'tree_view.cc',
- 'view.cc',
'widget_win.cc',
'window.cc',
'window_delegate.cc',
diff --git a/chrome/views/background.cc b/chrome/views/background.cc
index 1aa631e..056e511 100644
--- a/chrome/views/background.cc
+++ b/chrome/views/background.cc
@@ -59,16 +59,24 @@ class BackgroundPainter : public Background {
DISALLOW_EVIL_CONSTRUCTORS(BackgroundPainter);
};
-Background::Background() : native_control_brush_(NULL) {
+Background::Background()
+#if defined(OS_WIN)
+ : native_control_brush_(NULL)
+#endif
+{
}
Background::~Background() {
+#if defined(OS_WIN)
DeleteObject(native_control_brush_);
+#endif
}
void Background::SetNativeControlColor(SkColor color) {
+#if defined(OS_WIN)
DeleteObject(native_control_brush_);
native_control_brush_ = CreateSolidBrush(skia::SkColorToCOLORREF(color));
+#endif
}
//static
diff --git a/chrome/views/focus_manager.h b/chrome/views/focus_manager.h
index 4fcd1ce..b2de656 100644
--- a/chrome/views/focus_manager.h
+++ b/chrome/views/focus_manager.h
@@ -5,7 +5,9 @@
#ifndef CHROME_VIEWS_FOCUS_MANAGER_H__
#define CHROME_VIEWS_FOCUS_MANAGER_H__
+#if defined(OS_WIN)
#include <windows.h>
+#endif
#include <vector>
#include <map>
@@ -136,8 +138,10 @@ class KeystrokeListener {
public:
// If this returns true, then the component handled the keystroke and ate
// it.
+#if defined(OS_WIN)
virtual bool ProcessKeyDown(HWND window, UINT message, WPARAM wparam,
LPARAM lparam) = 0;
+#endif
};
// This interface should be implemented by classes that want to be notified when
@@ -149,6 +153,7 @@ class FocusChangeListener {
class FocusManager : public NotificationObserver {
public:
+#if defined(OS_WIN)
// Creates a FocusManager for the specified window. Top level windows
// must invoked this when created.
// The RootView specified should be the top RootView of the window.
@@ -167,7 +172,6 @@ class FocusManager : public NotificationObserver {
static FocusManager* GetFocusManager(HWND window);
-
// Message handlers (for messages received from registered windows).
// Should return true if the message should be forwarded to the window
// original proc function, false otherwise.
@@ -181,6 +185,7 @@ class FocusManager : public NotificationObserver {
// OnPostActivate is called after WM_ACTIVATE has been propagated to the
// DefWindowProc.
bool OnPostActivate(HWND window, int activation_state, int minimized_state);
+#endif
// Returns true is the specified is part of the hierarchy of the window
// associated with this FocusManager.
@@ -202,17 +207,21 @@ class FocusManager : public NotificationObserver {
// Note that this does not change the currently focused view.
void ClearHWNDFocus();
+#if defined(OS_WIN)
// Focus the specified |hwnd| without changing the focused view.
void FocusHWND(HWND hwnd);
+#endif
// Validates the focused view, clearing it if the window it belongs too is not
// attached to the window hierarchy anymore.
void ValidateFocusedView();
+#if defined(OS_WIN)
// Returns the view associated with the specified window if any.
// If |look_in_parents| is true, it goes up the window parents until it find
// a view.
static View* GetViewForWindow(HWND window, bool look_in_parents);
+#endif
// Stores and restores the focused view. Used when the window becomes
// active/inactive.
@@ -279,7 +288,9 @@ class FocusManager : public NotificationObserver {
const Accelerator& accelerator) const;
private:
+#if defined(OS_WIN)
explicit FocusManager(HWND root, RootView* root_view);
+#endif
~FocusManager();
// Returns the next focusable view.
@@ -307,8 +318,10 @@ class FocusManager : public NotificationObserver {
// had focus.
int stored_focused_view_storage_id_;
+#if defined(OS_WIN)
// The window associated with this focus manager.
HWND root_;
+#endif
// Used to allow setting the focus on an HWND without changing the currently
// focused view.
diff --git a/chrome/views/root_view.cc b/chrome/views/root_view.cc
index ac59d3f..4029e66 100644
--- a/chrome/views/root_view.cc
+++ b/chrome/views/root_view.cc
@@ -6,12 +6,16 @@
#include <algorithm>
+#if defined(OS_WIN)
#include "base/base_drag_source.h"
+#endif
#include "base/logging.h"
#include "base/message_loop.h"
#include "chrome/common/drag_drop_types.h"
#include "chrome/common/gfx/chrome_canvas.h"
+#if defined(OS_WIN)
#include "chrome/views/root_view_drop_target.h"
+#endif
#include "chrome/views/widget.h"
namespace views {
@@ -52,20 +56,22 @@ const char RootView::kViewClassName[] = "chrome/views/RootView";
/////////////////////////////////////////////////////////////////////////////
RootView::RootView(Widget* widget)
- : widget_(widget),
- mouse_pressed_handler_(NULL),
+ : mouse_pressed_handler_(NULL),
mouse_move_handler_(NULL),
- explicit_mouse_handler_(FALSE),
+ widget_(widget),
+ invalid_rect_urgent_(false),
+ pending_paint_task_(NULL),
+ paint_task_needed_(false),
+ explicit_mouse_handler_(false),
+#if defined(OS_WIN)
previous_cursor_(NULL),
+#endif
default_keyboard_hander_(NULL),
+ focus_listener_(NULL),
focus_on_mouse_pressed_(false),
ignore_set_focus_calls_(false),
- focus_listener_(NULL),
focus_traversable_parent_(NULL),
focus_traversable_parent_view_(NULL),
- invalid_rect_urgent_(false),
- pending_paint_task_(NULL),
- paint_task_needed_(false),
drag_view_(NULL)
#ifndef NDEBUG
,
@@ -143,9 +149,13 @@ void RootView::ProcessPaint(ChromeCanvas* canvas) {
ScopedProcessingPaint processing_paint(&is_processing_paint_);
#endif
+#if defined(OS_WIN)
// Clip the invalid rect to our bounds. If a view is in a scrollview
// it could be a lot larger
invalid_rect_ = gfx::Rect(GetScheduledPaintRectConstrainedToSize());
+#else
+ NOTIMPLEMENTED();
+#endif
if (invalid_rect_.IsEmpty())
return;
@@ -199,13 +209,6 @@ const gfx::Rect& RootView::GetScheduledPaintRect() {
return invalid_rect_;
}
-RECT RootView::GetScheduledPaintRectConstrainedToSize() {
- if (invalid_rect_.IsEmpty())
- return invalid_rect_.ToRECT();
-
- return invalid_rect_.Intersect(GetLocalBounds(true)).ToRECT();
-}
-
/////////////////////////////////////////////////////////////////////////////
//
// RootView - tree
@@ -228,8 +231,12 @@ void RootView::ViewHierarchyChanged(bool is_add, View* parent, View* child) {
mouse_pressed_handler_ = NULL;
}
+#if defined(OS_WIN)
if (drop_target_.get())
drop_target_->ResetTargetViewIfEquals(child);
+#else
+ NOTIMPLEMENTED();
+#endif
if (mouse_move_handler_ == child) {
mouse_move_handler_ = NULL;
@@ -311,10 +318,14 @@ bool RootView::OnMousePressed(const MouseEvent& e) {
mouse_pressed_handler_ = NULL;
if (focus_on_mouse_pressed_) {
+#if defined(OS_WIN)
HWND hwnd = GetWidget()->GetHWND();
if (::GetFocus() != hwnd) {
::SetFocus(hwnd);
}
+#else
+ NOTIMPLEMENTED();
+#endif
}
return hit_disabled_view;
}
@@ -382,23 +393,6 @@ void RootView::OnMouseReleased(const MouseEvent& e, bool canceled) {
}
}
-void RootView::UpdateCursor(const MouseEvent& e) {
- View *v = GetViewForPoint(e.location());
-
- if (v && v != this) {
- gfx::Point l(e.location());
- View::ConvertPointToView(this, v, &l);
- HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y());
- if (cursor) {
- ::SetCursor(cursor);
- return;
- }
- }
- if (previous_cursor_) {
- SetCursor(previous_cursor_);
- }
-}
-
void RootView::OnMouseMoved(const MouseEvent& e) {
View *v = GetViewForPoint(e.location());
// Find the first enabled view.
@@ -427,6 +421,7 @@ void RootView::OnMouseMoved(const MouseEvent& e) {
0);
mouse_move_handler_->OnMouseMoved(moved_event);
+#if defined(OS_WIN)
HCURSOR cursor = mouse_move_handler_->GetCursorForPoint(
moved_event.GetType(), moved_event.x(), moved_event.y());
if (cursor) {
@@ -435,13 +430,20 @@ void RootView::OnMouseMoved(const MouseEvent& e) {
::SetCursor(previous_cursor_);
previous_cursor_ = NULL;
}
+#else
+ NOTIMPLEMENTED();
+#endif
} else if (mouse_move_handler_ != NULL) {
MouseEvent exited_event(Event::ET_MOUSE_EXITED, 0, 0, 0);
mouse_move_handler_->OnMouseExited(exited_event);
+#if defined(OS_WIN)
if (previous_cursor_) {
::SetCursor(previous_cursor_);
previous_cursor_ = NULL;
}
+#else
+ NOTIMPLEMENTED();
+#endif
}
}
@@ -460,15 +462,25 @@ void RootView::SetMouseHandler(View *new_mh) {
}
void RootView::OnWidgetCreated() {
+#if defined(OS_WIN)
DCHECK(!drop_target_.get());
drop_target_ = new RootViewDropTarget(this);
+#else
+ // TODO(port): Port RootViewDropTarget and this goes away.
+ NOTIMPLEMENTED();
+#endif
}
void RootView::OnWidgetDestroyed() {
+#if defined(OS_WIN)
if (drop_target_.get()) {
RevokeDragDrop(GetWidget()->GetHWND());
drop_target_ = NULL;
}
+#else
+ // TODO(port): Port RootViewDropTarget and this goes away.
+ NOTIMPLEMENTED();
+#endif
widget_ = NULL;
}
@@ -487,6 +499,7 @@ void RootView::SetFocusListener(FocusListener* listener) {
void RootView::FocusView(View* view) {
if (view != GetFocusedView()) {
+#if defined(OS_WIN)
FocusManager* focus_manager = GetFocusManager();
DCHECK(focus_manager) << "No Focus Manager for Window " <<
(GetWidget() ? GetWidget()->GetHWND() : 0);
@@ -498,6 +511,10 @@ void RootView::FocusView(View* view) {
if (focus_listener_)
focus_listener_->FocusChanged(prev_focused_view, view);
+#else
+ // TODO(port): Port the focus manager and this goes away.
+ NOTIMPLEMENTED();
+#endif
}
}
@@ -799,6 +816,7 @@ void RootView::ProcessKeyEvent(const KeyEvent& event) {
bool consumed = false;
if (GetFocusedView()) {
+#if defined(OS_WIN)
// Special case to handle right-click context menus triggered by the
// keyboard.
if ((event.GetCharacter() == VK_APPS) ||
@@ -810,6 +828,10 @@ void RootView::ProcessKeyEvent(const KeyEvent& event) {
return;
}
}
+#else
+ // TODO(port): The above block needs the VK_* refactored out.
+ NOTIMPLEMENTED();
+#endif
for (v = GetFocusedView();
v && v != this && !consumed; v = v->GetParent()) {
@@ -908,39 +930,12 @@ void RootView::ClearPaintRect() {
paint_task_needed_ = false;
}
-void RootView::OnPaint(HWND hwnd) {
- RECT original_dirty_region = GetScheduledPaintRectConstrainedToSize();
- if (!IsRectEmpty(&original_dirty_region)) {
- // Invoke InvalidateRect so that the dirty region of the window includes the
- // region we need to paint. If we didn't do this and the region didn't
- // include the dirty region, ProcessPaint would incorrectly mark everything
- // as clean. This can happen if a WM_PAINT is generated by the system before
- // the InvokeLater schedule by RootView is processed.
- InvalidateRect(hwnd, &original_dirty_region, FALSE);
- }
- ChromeCanvasPaint canvas(hwnd);
- if (!canvas.isEmpty()) {
- const PAINTSTRUCT& ps = canvas.paintStruct();
- SchedulePaint(gfx::Rect(ps.rcPaint), false);
- if (NeedsPainting(false))
- ProcessPaint(&canvas);
- }
-}
-
/////////////////////////////////////////////////////////////////////////////
//
// RootView - accessibility
//
/////////////////////////////////////////////////////////////////////////////
-bool RootView::GetAccessibleRole(VARIANT* role) {
- DCHECK(role);
-
- role->vt = VT_I4;
- role->lVal = ROLE_SYSTEM_APPLICATION;
- return true;
-}
-
bool RootView::GetAccessibleName(std::wstring* name) {
if (!accessible_name_.empty()) {
*name = accessible_name_;
@@ -953,24 +948,6 @@ void RootView::SetAccessibleName(const std::wstring& name) {
accessible_name_.assign(name);
}
-void RootView::StartDragForViewFromMouseEvent(
- View* view,
- IDataObject* data,
- int operation) {
- drag_view_ = view;
- scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
- DWORD effects;
- DoDragDrop(data, drag_source,
- DragDropTypes::DragOperationToDropEffect(operation), &effects);
- // If the view is removed during the drag operation, drag_view_ is set to
- // NULL.
- if (drag_view_ == view) {
- View* drag_view = drag_view_;
- drag_view_ = NULL;
- drag_view->OnDragDone();
- }
-}
-
View* RootView::GetDragView() {
return drag_view_;
}
diff --git a/chrome/views/root_view.h b/chrome/views/root_view.h
index 6c62ba8..f1a0d89 100644
--- a/chrome/views/root_view.h
+++ b/chrome/views/root_view.h
@@ -73,8 +73,10 @@ class RootView : public View,
// Invoked by the Widget to discover what rectangle should be painted.
const gfx::Rect& GetScheduledPaintRect();
+#if defined(OS_WIN)
// Returns the region scheduled to paint clipped to the RootViews bounds.
RECT GetScheduledPaintRectConstrainedToSize();
+#endif
// Tree functions
@@ -167,13 +169,17 @@ class RootView : public View,
// to invoke this. This is primarily intended for Widgets.
void ClearPaintRect();
+#if defined(OS_WIN)
// Invoked from the Widget to service a WM_PAINT call.
void OnPaint(HWND hwnd);
+#endif
+#if defined(OS_WIN)
// Returns the MSAA role of the current view. The role is what assistive
// technologies (ATs) use to determine what behavior to expect from a given
// control.
bool GetAccessibleRole(VARIANT* role);
+#endif
// Returns a brief, identifying string, containing a unique, readable name.
bool GetAccessibleName(std::wstring* name);
@@ -248,12 +254,14 @@ class RootView : public View,
// Updates the last_mouse_* fields from e.
void SetMouseLocationAndFlags(const MouseEvent& e);
+#if defined(OS_WIN)
// Starts a drag operation for the specified view. This blocks until done.
// If the view has not been deleted during the drag, OnDragDone is invoked
// on the view.
void StartDragForViewFromMouseEvent(View* view,
IDataObject* data,
int operation);
+#endif
// If a view is dragging, this returns it. Otherwise returns NULL.
View* GetDragView();
@@ -284,8 +292,10 @@ class RootView : public View,
// true if mouse_handler_ has been explicitly set
bool explicit_mouse_handler_;
+#if defined(OS_WIN)
// Previous cursor
HCURSOR previous_cursor_;
+#endif
// Default keyboard handler
View* default_keyboard_hander_;
@@ -317,8 +327,10 @@ class RootView : public View,
// wrapped inside native components, and is used for the focus traversal.
View* focus_traversable_parent_view_;
+#if defined(OS_WIN)
// Handles dnd for us.
scoped_refptr<RootViewDropTarget> drop_target_;
+#endif
// Storage of strings needed for accessibility.
std::wstring accessible_name_;
diff --git a/chrome/views/root_view_gtk.cc b/chrome/views/root_view_gtk.cc
new file mode 100644
index 0000000..4615a82
--- /dev/null
+++ b/chrome/views/root_view_gtk.cc
@@ -0,0 +1,17 @@
+// Copyright (c) 2006-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 "chrome/views/root_view.h"
+
+namespace views {
+
+// TODO(port): Port GetScheduledPaintRectConstrainedToSize() to not use RECT.
+
+void RootView::UpdateCursor(const MouseEvent& e) {
+ NOTIMPLEMENTED();
+}
+
+// TODO(port): Port OnPaint() to not use HWNDs in its public interface.
+
+}
diff --git a/chrome/views/root_view_win.cc b/chrome/views/root_view_win.cc
new file mode 100644
index 0000000..a843f1d
--- /dev/null
+++ b/chrome/views/root_view_win.cc
@@ -0,0 +1,82 @@
+// Copyright (c) 2006-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 "chrome/views/root_view.h"
+
+#include "base/base_drag_source.h"
+#include "chrome/common/drag_drop_types.h"
+#include "chrome/views/root_view_drop_target.h"
+
+namespace views {
+
+RECT RootView::GetScheduledPaintRectConstrainedToSize() {
+ if (invalid_rect_.IsEmpty())
+ return invalid_rect_.ToRECT();
+
+ return invalid_rect_.Intersect(GetLocalBounds(true)).ToRECT();
+}
+
+void RootView::UpdateCursor(const MouseEvent& e) {
+ View *v = GetViewForPoint(e.location());
+
+ if (v && v != this) {
+ gfx::Point l(e.location());
+ View::ConvertPointToView(this, v, &l);
+ HCURSOR cursor = v->GetCursorForPoint(e.GetType(), l.x(), l.y());
+ if (cursor) {
+ ::SetCursor(cursor);
+ return;
+ }
+ }
+ if (previous_cursor_) {
+ SetCursor(previous_cursor_);
+ }
+}
+
+void RootView::OnPaint(HWND hwnd) {
+ RECT original_dirty_region = GetScheduledPaintRectConstrainedToSize();
+ if (!IsRectEmpty(&original_dirty_region)) {
+ // Invoke InvalidateRect so that the dirty region of the window includes the
+ // region we need to paint. If we didn't do this and the region didn't
+ // include the dirty region, ProcessPaint would incorrectly mark everything
+ // as clean. This can happen if a WM_PAINT is generated by the system before
+ // the InvokeLater schedule by RootView is processed.
+ InvalidateRect(hwnd, &original_dirty_region, FALSE);
+ }
+ ChromeCanvasPaint canvas(hwnd);
+ if (!canvas.isEmpty()) {
+ const PAINTSTRUCT& ps = canvas.paintStruct();
+ SchedulePaint(gfx::Rect(ps.rcPaint), false);
+ if (NeedsPainting(false))
+ ProcessPaint(&canvas);
+ }
+}
+
+bool RootView::GetAccessibleRole(VARIANT* role) {
+ DCHECK(role);
+
+ role->vt = VT_I4;
+ role->lVal = ROLE_SYSTEM_APPLICATION;
+ return true;
+}
+
+void RootView::StartDragForViewFromMouseEvent(
+ View* view,
+ IDataObject* data,
+ int operation) {
+ drag_view_ = view;
+ scoped_refptr<BaseDragSource> drag_source(new BaseDragSource);
+ DWORD effects;
+ DoDragDrop(data, drag_source,
+ DragDropTypes::DragOperationToDropEffect(operation), &effects);
+ // If the view is removed during the drag operation, drag_view_ is set to
+ // NULL.
+ if (drag_view_ == view) {
+ View* drag_view = drag_view_;
+ drag_view_ = NULL;
+ drag_view->OnDragDone();
+ }
+}
+
+}
diff --git a/chrome/views/view.cc b/chrome/views/view.cc
index 7ace91d..e65a0c9 100644
--- a/chrome/views/view.cc
+++ b/chrome/views/view.cc
@@ -16,16 +16,15 @@
#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/tooltip_manager.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 "SkShader.h"
namespace views {
@@ -70,20 +69,22 @@ class RestoreFocusTask : public Task {
View::View()
: id_(0),
group_(-1),
+ enabled_(true),
+ focusable_(false),
bounds_(0,0,0,0),
parent_(NULL),
- enabled_(true),
+ should_restore_focus_(false),
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) {
@@ -176,7 +177,6 @@ gfx::Size View::GetMinimumSize() {
int View::GetHeightForWidth(int w) {
if (layout_manager_.get())
return layout_manager_->GetPreferredHeightForWidth(this, w);
-
return GetPreferredSize().height();
}
@@ -281,20 +281,7 @@ 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;
@@ -508,7 +495,6 @@ 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 {
@@ -517,17 +503,6 @@ 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);
}
@@ -1045,19 +1020,6 @@ void View::UnregisterAccelerators() {
/////////////////////////////////////////////////////////////////////////////
//
-// View - accessibility
-//
-/////////////////////////////////////////////////////////////////////////////
-
-AccessibleWrapper* View::GetAccessibleWrapper() {
- if (accessibility_.get() == NULL) {
- accessibility_.reset(new AccessibleWrapper(this));
- }
- return accessibility_.get();
-}
-
-/////////////////////////////////////////////////////////////////////////////
-//
// View - floating views
//
/////////////////////////////////////////////////////////////////////////////
@@ -1402,26 +1364,6 @@ 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
@@ -1482,34 +1424,12 @@ 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;
}
@@ -1524,15 +1444,27 @@ 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) {
diff --git a/chrome/views/view.h b/chrome/views/view.h
index f7d9906..52f2665 100644
--- a/chrome/views/view.h
+++ b/chrome/views/view.h
@@ -1132,6 +1132,12 @@ class View : public AcceleratorTarget {
int start_y;
};
+ // Returns how much the mouse needs to move in one direction to start a
+ // drag. These methods cache in a platform-appropriate way. These values are
+ // used by the public static method ExceededDragThreshold().
+ static int GetHorizontalDragThreshold();
+ static int GetVerticalDragThreshold();
+
// RootView invokes these. These in turn invoke the appropriate OnMouseXXX
// method. If a drag is detected, DoDrag is invoked.
bool ProcessMousePressed(const MouseEvent& e, DragInfo* drop_info);
@@ -1302,8 +1308,10 @@ class View : public AcceleratorTarget {
// The menu controller.
ContextMenuController* context_menu_controller_;
+#if defined(OS_WIN)
// The accessibility implementation for this View.
scoped_ptr<AccessibleWrapper> accessibility_;
+#endif
DragController* drag_controller_;
diff --git a/chrome/views/view_gtk.cc b/chrome/views/view_gtk.cc
new file mode 100644
index 0000000..f8b465c
--- /dev/null
+++ b/chrome/views/view_gtk.cc
@@ -0,0 +1,56 @@
+// 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.
+
+#include "chrome/views/view.h"
+
+#include "base/logging.h"
+
+namespace views {
+
+FocusManager* View::GetFocusManager() {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+void View::DoDrag(const MouseEvent& e, int press_x, int press_y) {
+ NOTIMPLEMENTED();
+}
+
+AccessibleWrapper* View::GetAccessibleWrapper() {
+ NOTIMPLEMENTED();
+ return NULL;
+}
+
+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()) {
+ // TODO(port): port the windows hit test code here. Once that's factored
+ // out, we can probably move View::HitTest back into views.cc.
+ NOTIMPLEMENTED();
+ }
+ // No mask, but inside our bounds.
+ return true;
+ }
+ // Outside our bounds.
+ return false;
+}
+
+void View::Focus() {
+ NOTIMPLEMENTED();
+}
+
+int View::GetHorizontalDragThreshold() {
+ static int threshold = -1;
+ NOTIMPLEMENTED();
+ return threshold;
+}
+
+int View::GetVerticalDragThreshold() {
+ static int threshold = -1;
+ NOTIMPLEMENTED();
+ return threshold;
+}
+
+} // namespace views
diff --git a/chrome/views/view_win.cc b/chrome/views/view_win.cc
new file mode 100644
index 0000000..190d21f
--- /dev/null
+++ b/chrome/views/view_win.cc
@@ -0,0 +1,91 @@
+// 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.
+
+#include "chrome/views/view.h"
+
+#include "base/scoped_handle.h"
+#include "base/string_util.h"
+#include "chrome/common/gfx/chrome_canvas.h"
+#include "chrome/common/gfx/path.h"
+#include "chrome/common/os_exchange_data.h"
+#include "chrome/views/accessibility/accessible_wrapper.h"
+#include "chrome/views/border.h"
+#include "chrome/views/root_view.h"
+#include "chrome/views/widget.h"
+
+namespace views {
+
+FocusManager* View::GetFocusManager() {
+ Widget* widget = GetWidget();
+ if (!widget)
+ return NULL;
+
+ HWND hwnd = widget->GetHWND();
+ if (!hwnd)
+ return NULL;
+
+ return FocusManager::GetFocusManager(hwnd);
+}
+
+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));
+}
+
+AccessibleWrapper* View::GetAccessibleWrapper() {
+ if (accessibility_.get() == NULL) {
+ accessibility_.reset(new AccessibleWrapper(this));
+ }
+ return accessibility_.get();
+}
+
+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;
+}
+
+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());
+}
+
+int View::GetHorizontalDragThreshold() {
+ static int threshold = -1;
+ if (threshold == -1)
+ threshold = GetSystemMetrics(SM_CXDRAG) / 2;
+ return threshold;
+}
+
+int View::GetVerticalDragThreshold() {
+ static int threshold = -1;
+ if (threshold == -1)
+ threshold = GetSystemMetrics(SM_CYDRAG) / 2;
+ return threshold;
+}
+
+} // namespace views
diff --git a/chrome/views/views.vcproj b/chrome/views/views.vcproj
index 172e6f1..6d5ce3d 100644
--- a/chrome/views/views.vcproj
+++ b/chrome/views/views.vcproj
@@ -490,6 +490,10 @@
>
</File>
<File
+ RelativePath=".\root_view_win.cc"
+ >
+ </File>
+ <File
RelativePath=".\scroll_bar.cc"
>
</File>
@@ -618,6 +622,10 @@
>
</File>
<File
+ RelativePath=".\view_win.cc"
+ >
+ </File>
+ <File
RelativePath=".\widget.h"
>
</File>
diff --git a/chrome/views/widget.h b/chrome/views/widget.h
index 4192912..d135860 100644
--- a/chrome/views/widget.h
+++ b/chrome/views/widget.h
@@ -5,8 +5,10 @@
#ifndef CHROME_VIEWS_WIDGET_H_
#define CHROME_VIEWS_WIDGET_H_
+#if defined(OS_WIN)
// TODO(maruel): Remove once HWND is abstracted.
#include <windows.h>
+#endif
namespace gfx {
class Rect;
@@ -48,8 +50,10 @@ class Widget {
// the window should also become the active window.
virtual void MoveToFront(bool should_activate) = 0;
+#if defined(OS_WIN)
// Returns the Window HWND associated with this Widget.
virtual HWND GetHWND() const = 0;
+#endif
// Forces a paint of a specified rectangle immediately.
virtual void PaintNow(const gfx::Rect& update_rect) = 0;