| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 | 7 |
| 8 #include <atlbase.h> | 8 #include <atlbase.h> |
| 9 #include <atlapp.h> | 9 #include <atlapp.h> |
| 10 #include <atlcrack.h> | 10 #include <atlcrack.h> |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 71 WidgetWin(); | 71 WidgetWin(); |
| 72 virtual ~WidgetWin(); | 72 virtual ~WidgetWin(); |
| 73 | 73 |
| 74 // Initialize the Widget with a parent and an initial desired size. | 74 // Initialize the Widget with a parent and an initial desired size. |
| 75 // |contents_view| is the view that will be the single child of RootView | 75 // |contents_view| is the view that will be the single child of RootView |
| 76 // within this Widget. As contents_view is inserted into RootView's tree, | 76 // within this Widget. As contents_view is inserted into RootView's tree, |
| 77 // RootView assumes ownership of this view and cleaning it up. If you remove | 77 // RootView assumes ownership of this view and cleaning it up. If you remove |
| 78 // this view, you are responsible for its destruction. If this value is NULL, | 78 // this view, you are responsible for its destruction. If this value is NULL, |
| 79 // the caller is responsible for populating the RootView, and sizing its | 79 // the caller is responsible for populating the RootView, and sizing its |
| 80 // contents as the window is sized. | 80 // contents as the window is sized. |
| 81 void Init(HWND parent, const gfx::Rect& bounds); | 81 // If |has_own_focus_manager| is true, the focus traversal stay confined to |
| 82 // the window. |
| 83 void Init(HWND parent, |
| 84 const gfx::Rect& bounds, |
| 85 bool has_own_focus_manager); |
| 82 | 86 |
| 83 // Sets the specified view as the contents of this Widget. There can only | 87 // Sets the specified view as the contents of this Widget. There can only |
| 84 // be one contnets view child of this Widget's RootView. This view is sized to | 88 // be one contnets view child of this Widget's RootView. This view is sized to |
| 85 // fit the entire size of the RootView. The RootView takes ownership of this | 89 // fit the entire size of the RootView. The RootView takes ownership of this |
| 86 // View, unless it is set as not being parent-owned. | 90 // View, unless it is set as not being parent-owned. |
| 87 virtual void SetContentsView(View* view); | 91 virtual void SetContentsView(View* view); |
| 88 | 92 |
| 89 // Sets the window styles. This is ONLY used when the window is created. | 93 // Sets the window styles. This is ONLY used when the window is created. |
| 90 // In other words, if you invoke this after invoking Init, nothing happens. | 94 // In other words, if you invoke this after invoking Init, nothing happens. |
| 91 void set_window_style(DWORD style) { window_style_ = style; } | 95 void set_window_style(DWORD style) { window_style_ = style; } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 111 void SetUseLayeredBuffer(bool use_layered_buffer); | 115 void SetUseLayeredBuffer(bool use_layered_buffer); |
| 112 | 116 |
| 113 // Disable Layered Window updates by setting to false. | 117 // Disable Layered Window updates by setting to false. |
| 114 void set_can_update_layered_window(bool can_update_layered_window) { | 118 void set_can_update_layered_window(bool can_update_layered_window) { |
| 115 can_update_layered_window_ = can_update_layered_window; | 119 can_update_layered_window_ = can_update_layered_window; |
| 116 } | 120 } |
| 117 | 121 |
| 118 // Returns the RootView associated with the specified HWND (if any). | 122 // Returns the RootView associated with the specified HWND (if any). |
| 119 static RootView* FindRootView(HWND hwnd); | 123 static RootView* FindRootView(HWND hwnd); |
| 120 | 124 |
| 121 // Returns the Widget associated with the specified HWND (if any). | |
| 122 static WidgetWin* GetWidget(HWND hwnd); | |
| 123 | |
| 124 // All classes registered by WidgetWin start with this name. | 125 // All classes registered by WidgetWin start with this name. |
| 125 static const wchar_t* const kBaseClassName; | 126 static const wchar_t* const kBaseClassName; |
| 126 | 127 |
| 127 BEGIN_MSG_MAP_EX(0) | 128 BEGIN_MSG_MAP_EX(0) |
| 128 // Range handlers must go first! | 129 // Range handlers must go first! |
| 129 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) | 130 MESSAGE_RANGE_HANDLER_EX(WM_MOUSEFIRST, WM_MOUSELAST, OnMouseRange) |
| 130 MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCMOUSEMOVE, OnMouseRange) | 131 MESSAGE_RANGE_HANDLER_EX(WM_NCMOUSEMOVE, WM_NCMOUSEMOVE, OnMouseRange) |
| 131 | 132 |
| 132 // Reflected message handler | 133 // Reflected message handler |
| 133 MESSAGE_HANDLER_EX(kReflectedMessage, OnReflectedMessage) | 134 MESSAGE_HANDLER_EX(kReflectedMessage, OnReflectedMessage) |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 virtual void PaintNow(const gfx::Rect& update_rect); | 223 virtual void PaintNow(const gfx::Rect& update_rect); |
| 223 virtual void SetOpacity(unsigned char opacity); | 224 virtual void SetOpacity(unsigned char opacity); |
| 224 virtual RootView* GetRootView(); | 225 virtual RootView* GetRootView(); |
| 225 virtual Widget* GetRootWidget() const; | 226 virtual Widget* GetRootWidget() const; |
| 226 virtual bool IsVisible() const; | 227 virtual bool IsVisible() const; |
| 227 virtual bool IsActive() const; | 228 virtual bool IsActive() const; |
| 228 virtual TooltipManager* GetTooltipManager(); | 229 virtual TooltipManager* GetTooltipManager(); |
| 229 virtual ThemeProvider* GetThemeProvider() const; | 230 virtual ThemeProvider* GetThemeProvider() const; |
| 230 virtual Window* GetWindow(); | 231 virtual Window* GetWindow(); |
| 231 virtual const Window* GetWindow() const; | 232 virtual const Window* GetWindow() const; |
| 232 virtual FocusManager* GetFocusManager(); | |
| 233 | 233 |
| 234 // Overridden from MessageLoop::Observer: | 234 // Overridden from MessageLoop::Observer: |
| 235 void WillProcessMessage(const MSG& msg); | 235 void WillProcessMessage(const MSG& msg); |
| 236 virtual void DidProcessMessage(const MSG& msg); | 236 virtual void DidProcessMessage(const MSG& msg); |
| 237 | 237 |
| 238 // Overridden from FocusTraversable: | 238 // Overridden from FocusTraversable: |
| 239 virtual View* FindNextFocusableView(View* starting_view, | 239 virtual View* FindNextFocusableView(View* starting_view, |
| 240 bool reverse, | 240 bool reverse, |
| 241 Direction direction, | 241 Direction direction, |
| 242 bool check_starting_view, | 242 bool check_starting_view, |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 | 320 |
| 321 // Resets the last move flag so that we can go around the optimization | 321 // Resets the last move flag so that we can go around the optimization |
| 322 // that disregards duplicate mouse moves when ending animation requires | 322 // that disregards duplicate mouse moves when ending animation requires |
| 323 // a new hit-test to do some highlighting as in TabStrip::RemoveTabAnimation | 323 // a new hit-test to do some highlighting as in TabStrip::RemoveTabAnimation |
| 324 // to cause the close button to highlight. | 324 // to cause the close button to highlight. |
| 325 void ResetLastMouseMoveFlag() { | 325 void ResetLastMouseMoveFlag() { |
| 326 last_mouse_event_was_move_ = false; | 326 last_mouse_event_was_move_ = false; |
| 327 } | 327 } |
| 328 | 328 |
| 329 protected: | 329 protected: |
| 330 |
| 330 // Call close instead of this to Destroy the window. | 331 // Call close instead of this to Destroy the window. |
| 331 BOOL DestroyWindow() { | 332 BOOL DestroyWindow() { |
| 332 DCHECK(::IsWindow(GetNativeView())); | 333 DCHECK(::IsWindow(GetNativeView())); |
| 333 return ::DestroyWindow(GetNativeView()); | 334 return ::DestroyWindow(GetNativeView()); |
| 334 } | 335 } |
| 335 | 336 |
| 336 // Message Handlers | 337 // Message Handlers |
| 337 // These are all virtual so that specialized Widgets can modify or augment | 338 // These are all virtual so that specialized Widgets can modify or augment |
| 338 // processing. | 339 // processing. |
| 339 // This list is in _ALPHABETICAL_ order! | 340 // This list is in _ALPHABETICAL_ order! |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 bool opaque() const { return opaque_; } | 516 bool opaque() const { return opaque_; } |
| 516 | 517 |
| 517 // The TooltipManager. | 518 // The TooltipManager. |
| 518 // WARNING: RootView's destructor calls into the TooltipManager. As such, this | 519 // WARNING: RootView's destructor calls into the TooltipManager. As such, this |
| 519 // must be destroyed AFTER root_view_. This really only matters during | 520 // must be destroyed AFTER root_view_. This really only matters during |
| 520 // WM_SESSIONEND, as normally the hwnd is destroyed which tiggers unsetting | 521 // WM_SESSIONEND, as normally the hwnd is destroyed which tiggers unsetting |
| 521 // the widget in the RootView so that RootView's destructor doesn't call into | 522 // the widget in the RootView so that RootView's destructor doesn't call into |
| 522 // the TooltipManager. | 523 // the TooltipManager. |
| 523 scoped_ptr<TooltipManagerWin> tooltip_manager_; | 524 scoped_ptr<TooltipManagerWin> tooltip_manager_; |
| 524 | 525 |
| 525 // The focus manager keeping track of focus for this Widget and any of its | |
| 526 // children. NULL for non top-level widgets. | |
| 527 // WARNING: RootView's destructor calls into the FocusManager. As such, this | |
| 528 // must be destroyed AFTER root_view_. | |
| 529 scoped_ptr<FocusManager> focus_manager_; | |
| 530 | |
| 531 // The root of the View hierarchy attached to this window. | 526 // The root of the View hierarchy attached to this window. |
| 532 // WARNING: see warning in tooltip_manager_ for ordering dependencies with | 527 // WARNING: see warning in tooltip_manager_ for ordering dependencies with |
| 533 // this and tooltip_manager_. | 528 // this and tooltip_manager_. |
| 534 scoped_ptr<RootView> root_view_; | 529 scoped_ptr<RootView> root_view_; |
| 535 | 530 |
| 536 // Whether or not we have capture the mouse. | 531 // Whether or not we have capture the mouse. |
| 537 bool has_capture_; | 532 bool has_capture_; |
| 538 | 533 |
| 539 // If true, the mouse is currently down. | 534 // If true, the mouse is currently down. |
| 540 bool is_mouse_down_; | 535 bool is_mouse_down_; |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 642 | 637 |
| 643 scoped_ptr<DefaultThemeProvider> default_theme_provider_; | 638 scoped_ptr<DefaultThemeProvider> default_theme_provider_; |
| 644 | 639 |
| 645 // Our hwnd. | 640 // Our hwnd. |
| 646 HWND hwnd_; | 641 HWND hwnd_; |
| 647 }; | 642 }; |
| 648 | 643 |
| 649 } // namespace views | 644 } // namespace views |
| 650 | 645 |
| 651 #endif // #ifndef VIEWS_WIDGET_WIDGET_WIN_H_ | 646 #endif // #ifndef VIEWS_WIDGET_WIDGET_WIN_H_ |
| OLD | NEW |