Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(387)

Side by Side Diff: views/widget/widget_win.h

Issue 7015051: Re-land: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « views/widget/widget_gtk.cc ('k') | views/widget/widget_win.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef VIEWS_WIDGET_WIDGET_WIN_H_ 5 #ifndef VIEWS_WIDGET_WIDGET_WIN_H_
6 #define VIEWS_WIDGET_WIDGET_WIN_H_ 6 #define VIEWS_WIDGET_WIDGET_WIN_H_
7 #pragma once 7 #pragma once
8 8
9 #include <atlbase.h> 9 #include <atlbase.h>
10 #include <atlapp.h> 10 #include <atlapp.h>
11 #include <atlcrack.h> 11 #include <atlcrack.h>
12 #include <atlmisc.h> 12 #include <atlmisc.h>
13 13
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
18 #include "base/memory/scoped_vector.h" 18 #include "base/memory/scoped_vector.h"
19 #include "base/message_loop.h" 19 #include "base/message_loop.h"
20 #include "base/win/scoped_comptr.h" 20 #include "base/win/scoped_comptr.h"
21 #include "ui/base/win/window_impl.h" 21 #include "ui/base/win/window_impl.h"
22 #include "views/focus/focus_manager.h" 22 #include "views/focus/focus_manager.h"
23 #include "views/ime/input_method_delegate.h" 23 #include "views/ime/input_method_delegate.h"
24 #include "views/layout/layout_manager.h" 24 #include "views/layout/layout_manager.h"
25 #include "views/widget/native_widget.h" 25 #include "views/widget/native_widget.h"
26 #include "views/widget/widget.h"
27 26
28 namespace ui { 27 namespace ui {
29 class ViewProp; 28 class ViewProp;
30 } 29 }
31 30
32 namespace gfx { 31 namespace gfx {
33 class CanvasSkia; 32 class CanvasSkia;
34 class Rect; 33 class Rect;
35 } 34 }
36 35
37 namespace views { 36 namespace views {
38 37
39 class DropTargetWin; 38 class DropTargetWin;
40 class RootView; 39 class RootView;
41 class TooltipManagerWin; 40 class TooltipManagerWin;
42 class Window; 41 class Window;
43 42
44 namespace internal { 43 namespace internal {
45 class NativeWidgetDelegate; 44 class NativeWidgetDelegate;
46 } 45 }
47 46
48 RootView* GetRootViewForHWND(HWND hwnd);
49
50 // A Windows message reflected from other windows. This message is sent 47 // A Windows message reflected from other windows. This message is sent
51 // with the following arguments: 48 // with the following arguments:
52 // hWnd - Target window 49 // hWnd - Target window
53 // uMsg - kReflectedMessage 50 // uMsg - kReflectedMessage
54 // wParam - Should be 0 51 // wParam - Should be 0
55 // lParam - Pointer to MSG struct containing the original message. 52 // lParam - Pointer to MSG struct containing the original message.
56 const int kReflectedMessage = WM_APP + 3; 53 const int kReflectedMessage = WM_APP + 3;
57 54
58 // These two messages aren't defined in winuser.h, but they are sent to windows 55 // These two messages aren't defined in winuser.h, but they are sent to windows
59 // with captions. They appear to paint the window caption and frame. 56 // with captions. They appear to paint the window caption and frame.
(...skipping 13 matching lines...) Expand all
73 // contained within an HWND, e.g. a control, a window, etc. Specializations 70 // contained within an HWND, e.g. a control, a window, etc. Specializations
74 // suitable for specific tasks, e.g. top level window, are derived from this. 71 // suitable for specific tasks, e.g. top level window, are derived from this.
75 // 72 //
76 // This Widget contains a RootView which owns the hierarchy of views within it. 73 // This Widget contains a RootView which owns the hierarchy of views within it.
77 // As long as views are part of this tree, they will be deleted automatically 74 // As long as views are part of this tree, they will be deleted automatically
78 // when the RootView is destroyed. If you remove a view from the tree, you are 75 // when the RootView is destroyed. If you remove a view from the tree, you are
79 // then responsible for cleaning up after it. 76 // then responsible for cleaning up after it.
80 // 77 //
81 /////////////////////////////////////////////////////////////////////////////// 78 ///////////////////////////////////////////////////////////////////////////////
82 class WidgetWin : public ui::WindowImpl, 79 class WidgetWin : public ui::WindowImpl,
83 public Widget,
84 public NativeWidget, 80 public NativeWidget,
85 public MessageLoopForUI::Observer, 81 public MessageLoopForUI::Observer,
86 public internal::InputMethodDelegate { 82 public internal::InputMethodDelegate {
87 public: 83 public:
88 WidgetWin(); 84 explicit WidgetWin(internal::NativeWidgetDelegate* delegate);
89 virtual ~WidgetWin(); 85 virtual ~WidgetWin();
90 86
91 // Returns true if we are on Windows Vista or greater and composition is 87 // Returns true if we are on Windows Vista or greater and composition is
92 // enabled. 88 // enabled.
93 static bool IsAeroGlassEnabled(); 89 static bool IsAeroGlassEnabled();
94 90
95 // Disable Layered Window updates by setting to false. 91 // Disable Layered Window updates by setting to false.
96 void set_can_update_layered_window(bool can_update_layered_window) { 92 void set_can_update_layered_window(bool can_update_layered_window) {
97 can_update_layered_window_ = can_update_layered_window; 93 can_update_layered_window_ = can_update_layered_window;
98 } 94 }
99 95
100 // Obtain the view event with the given MSAA child id. Used in 96 // Obtain the view event with the given MSAA child id. Used in
101 // NativeViewAccessibilityWin::get_accChild to support requests for 97 // NativeViewAccessibilityWin::get_accChild to support requests for
102 // children of windowless controls. May return NULL 98 // children of windowless controls. May return NULL
103 // (see ViewHierarchyChanged). 99 // (see ViewHierarchyChanged).
104 View* GetAccessibilityViewEventAt(int id); 100 View* GetAccessibilityViewEventAt(int id);
105 101
106 // Add a view that has recently fired an accessibility event. Returns a MSAA 102 // Add a view that has recently fired an accessibility event. Returns a MSAA
107 // child id which is generated by: -(index of view in vector + 1) which 103 // child id which is generated by: -(index of view in vector + 1) which
108 // guarantees a negative child id. This distinguishes the view from 104 // guarantees a negative child id. This distinguishes the view from
109 // positive MSAA child id's which are direct leaf children of views that have 105 // positive MSAA child id's which are direct leaf children of views that have
110 // associated hWnd's (e.g. WidgetWin). 106 // associated hWnd's (e.g. WidgetWin).
111 int AddAccessibilityViewEvent(View* view); 107 int AddAccessibilityViewEvent(View* view);
112 108
113 // Clear a view that has recently been removed on a hierarchy change. 109 // Clear a view that has recently been removed on a hierarchy change.
114 void ClearAccessibilityViewEvent(View* view); 110 void ClearAccessibilityViewEvent(View* view);
115 111
116 // Overridden from Widget:
117 virtual gfx::NativeView GetNativeView() const OVERRIDE;
118 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
119 virtual bool GetAccelerator(int cmd_id,
120 ui::Accelerator* accelerator) OVERRIDE;
121 virtual Window* GetWindow() OVERRIDE;
122 virtual const Window* GetWindow() const OVERRIDE;
123 virtual void ViewHierarchyChanged(bool is_add, View *parent,
124 View *child) OVERRIDE;
125 virtual void NotifyAccessibilityEvent(
126 View* view,
127 ui::AccessibilityTypes::Event event_type,
128 bool send_native_event);
129
130 BOOL IsWindow() const { 112 BOOL IsWindow() const {
131 return ::IsWindow(GetNativeView()); 113 return ::IsWindow(GetNativeView());
132 } 114 }
133 115
134 BOOL ShowWindow(int command) { 116 BOOL ShowWindow(int command) {
135 DCHECK(::IsWindow(GetNativeView())); 117 DCHECK(::IsWindow(GetNativeView()));
136 return ::ShowWindow(GetNativeView(), command); 118 return ::ShowWindow(GetNativeView(), command);
137 } 119 }
138 120
139 HWND GetParent() const { 121 HWND GetParent() const {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 int SetWindowRgn(HRGN region, BOOL redraw) { 158 int SetWindowRgn(HRGN region, BOOL redraw) {
177 DCHECK(::IsWindow(GetNativeView())); 159 DCHECK(::IsWindow(GetNativeView()));
178 return ::SetWindowRgn(GetNativeView(), region, redraw); 160 return ::SetWindowRgn(GetNativeView(), region, redraw);
179 } 161 }
180 162
181 BOOL GetClientRect(RECT* rect) const { 163 BOOL GetClientRect(RECT* rect) const {
182 DCHECK(::IsWindow(GetNativeView())); 164 DCHECK(::IsWindow(GetNativeView()));
183 return ::GetClientRect(GetNativeView(), rect); 165 return ::GetClientRect(GetNativeView(), rect);
184 } 166 }
185 167
186 // Resets the last move flag so that we can go around the optimization
187 // that disregards duplicate mouse moves when ending animation requires
188 // a new hit-test to do some highlighting as in TabStrip::RemoveTabAnimation
189 // to cause the close button to highlight.
190 void ResetLastMouseMoveFlag() {
191 last_mouse_event_was_move_ = false;
192 }
193
194 // Overridden from NativeWidget: 168 // Overridden from NativeWidget:
195 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE; 169 virtual void InitNativeWidget(const Widget::InitParams& params) OVERRIDE;
196 virtual Widget* GetWidget() OVERRIDE; 170 virtual Widget* GetWidget() OVERRIDE;
171 virtual const Widget* GetWidget() const OVERRIDE;
172 virtual gfx::NativeView GetNativeView() const OVERRIDE;
173 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE;
174 virtual Window* GetContainingWindow() OVERRIDE;
175 virtual const Window* GetContainingWindow() const OVERRIDE;
176 virtual void ViewRemoved(View* view) OVERRIDE;
197 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE; 177 virtual void SetNativeWindowProperty(const char* name, void* value) OVERRIDE;
198 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE; 178 virtual void* GetNativeWindowProperty(const char* name) OVERRIDE;
199 virtual TooltipManager* GetTooltipManager() const OVERRIDE; 179 virtual TooltipManager* GetTooltipManager() const OVERRIDE;
200 virtual bool IsScreenReaderActive() const OVERRIDE; 180 virtual bool IsScreenReaderActive() const OVERRIDE;
181 virtual void SendNativeAccessibilityEvent(
182 View* view,
183 ui::AccessibilityTypes::Event event_type) OVERRIDE;
201 virtual void SetMouseCapture() OVERRIDE; 184 virtual void SetMouseCapture() OVERRIDE;
202 virtual void ReleaseMouseCapture() OVERRIDE; 185 virtual void ReleaseMouseCapture() OVERRIDE;
203 virtual bool HasMouseCapture() const OVERRIDE; 186 virtual bool HasMouseCapture() const OVERRIDE;
187 virtual bool IsMouseButtonDown() const OVERRIDE;
204 virtual InputMethod* GetInputMethodNative() OVERRIDE; 188 virtual InputMethod* GetInputMethodNative() OVERRIDE;
205 virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE; 189 virtual void ReplaceInputMethod(InputMethod* input_method) OVERRIDE;
206 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE; 190 virtual gfx::Rect GetWindowScreenBounds() const OVERRIDE;
207 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE; 191 virtual gfx::Rect GetClientAreaScreenBounds() const OVERRIDE;
208 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE; 192 virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
209 virtual void SetSize(const gfx::Size& size) OVERRIDE; 193 virtual void SetSize(const gfx::Size& size) OVERRIDE;
210 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE; 194 virtual void MoveAbove(gfx::NativeView native_view) OVERRIDE;
211 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE; 195 virtual void SetShape(gfx::NativeRegion shape) OVERRIDE;
212 virtual void Close() OVERRIDE; 196 virtual void Close() OVERRIDE;
213 virtual void CloseNow() OVERRIDE; 197 virtual void CloseNow() OVERRIDE;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 // or subsequently. 420 // or subsequently.
437 void ClientAreaSizeChanged(); 421 void ClientAreaSizeChanged();
438 422
439 // Overridden from NativeWidget. 423 // Overridden from NativeWidget.
440 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE; 424 virtual gfx::AcceleratedWidget GetAcceleratedWidget() OVERRIDE;
441 425
442 // Overridden from internal::InputMethodDelegate 426 // Overridden from internal::InputMethodDelegate
443 virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE; 427 virtual void DispatchKeyEventPostIME(const KeyEvent& key) OVERRIDE;
444 428
445 // A delegate implementation that handles events received here. 429 // A delegate implementation that handles events received here.
430 // See class documentation for Widget in widget.h for a note about ownership.
446 internal::NativeWidgetDelegate* delegate_; 431 internal::NativeWidgetDelegate* delegate_;
447 432
448 // The following factory is used for calls to close the WidgetWin 433 // The following factory is used for calls to close the WidgetWin
449 // instance. 434 // instance.
450 ScopedRunnableMethodFactory<WidgetWin> close_widget_factory_; 435 ScopedRunnableMethodFactory<WidgetWin> close_widget_factory_;
451 436
452 // The flags currently being used with TrackMouseEvent to track mouse 437 // The flags currently being used with TrackMouseEvent to track mouse
453 // messages. 0 if there is no active tracking. The value of this member is 438 // messages. 0 if there is no active tracking. The value of this member is
454 // used when tracking is canceled. 439 // used when tracking is canceled.
455 DWORD active_mouse_tracking_flags_; 440 DWORD active_mouse_tracking_flags_;
(...skipping 18 matching lines...) Expand all
474 scoped_ptr<gfx::CanvasSkia> layered_window_contents_; 459 scoped_ptr<gfx::CanvasSkia> layered_window_contents_;
475 460
476 // We must track the invalid rect for a layered window ourselves, since 461 // We must track the invalid rect for a layered window ourselves, since
477 // Windows will not do this properly with InvalidateRect()/GetUpdateRect(). 462 // Windows will not do this properly with InvalidateRect()/GetUpdateRect().
478 // (In fact, it'll return misleading information from GetUpdateRect()). 463 // (In fact, it'll return misleading information from GetUpdateRect()).
479 gfx::Rect layered_window_invalid_rect_; 464 gfx::Rect layered_window_invalid_rect_;
480 465
481 // A factory that allows us to schedule a redraw for layered windows. 466 // A factory that allows us to schedule a redraw for layered windows.
482 ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_; 467 ScopedRunnableMethodFactory<WidgetWin> paint_layered_window_factory_;
483 468
484 // Whether or not the window should delete itself when it is destroyed. 469 // See class documentation for Widget in widget.h for a note about ownership.
485 // Set this to false via its setter for stack allocated instances.
486 bool delete_on_destroy_; 470 bool delete_on_destroy_;
487 471
488 // True if we are allowed to update the layered window from the DIB backing 472 // True if we are allowed to update the layered window from the DIB backing
489 // store if necessary. 473 // store if necessary.
490 bool can_update_layered_window_; 474 bool can_update_layered_window_;
491 475
492 // Whether the focus should be restored next time we get enabled. Needed to 476 // Whether the focus should be restored next time we get enabled. Needed to
493 // restore focus correctly when Windows modal dialogs are displayed. 477 // restore focus correctly when Windows modal dialogs are displayed.
494 bool restore_focus_when_enabled_; 478 bool restore_focus_when_enabled_;
495 479
(...skipping 24 matching lines...) Expand all
520 504
521 // Indicates if the |input_method_| is an InputMethodWin instance. 505 // Indicates if the |input_method_| is an InputMethodWin instance.
522 bool is_input_method_win_; 506 bool is_input_method_win_;
523 507
524 DISALLOW_COPY_AND_ASSIGN(WidgetWin); 508 DISALLOW_COPY_AND_ASSIGN(WidgetWin);
525 }; 509 };
526 510
527 } // namespace views 511 } // namespace views
528 512
529 #endif // VIEWS_WIDGET_WIDGET_WIN_H_ 513 #endif // VIEWS_WIDGET_WIDGET_WIN_H_
OLDNEW
« no previous file with comments | « views/widget/widget_gtk.cc ('k') | views/widget/widget_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698