OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 5 #ifndef UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
6 #define UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 6 #define UI_VIEWS_WIDGET_NATIVE_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 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 virtual void OnThemeChanged(); | 417 virtual void OnThemeChanged(); |
418 virtual LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param); | 418 virtual LRESULT OnTouchEvent(UINT message, WPARAM w_param, LPARAM l_param); |
419 virtual void OnVScroll(int scroll_type, short position, HWND scrollbar); | 419 virtual void OnVScroll(int scroll_type, short position, HWND scrollbar); |
420 virtual void OnWindowPosChanging(WINDOWPOS* window_pos); | 420 virtual void OnWindowPosChanging(WINDOWPOS* window_pos); |
421 virtual void OnWindowPosChanged(WINDOWPOS* window_pos); | 421 virtual void OnWindowPosChanged(WINDOWPOS* window_pos); |
422 | 422 |
423 // Deletes this window as it is destroyed, override to provide different | 423 // Deletes this window as it is destroyed, override to provide different |
424 // behavior. | 424 // behavior. |
425 virtual void OnFinalMessage(HWND window); | 425 virtual void OnFinalMessage(HWND window); |
426 | 426 |
427 // Retrieve the show state of the window. This is one of the SW_SHOW* flags | |
428 // passed into Windows' ShowWindow method. For normal windows this defaults | |
429 // to SW_SHOWNORMAL, however windows (e.g. the main window) can override this | |
430 // method to provide different values (e.g. retrieve the user's specified | |
431 // show state from the shortcut starutp info). | |
432 virtual int GetShowState() const; | |
433 | |
434 // Called when a MSAA screen reader client is detected. | 427 // Called when a MSAA screen reader client is detected. |
435 virtual void OnScreenReaderDetected(); | 428 virtual void OnScreenReaderDetected(); |
436 | 429 |
437 // The TooltipManager. This is NULL if there is a problem creating the | 430 // The TooltipManager. This is NULL if there is a problem creating the |
438 // underlying tooltip window. | 431 // underlying tooltip window. |
439 // WARNING: RootView's destructor calls into the TooltipManager. As such, this | 432 // WARNING: RootView's destructor calls into the TooltipManager. As such, this |
440 // must be destroyed AFTER root_view_. | 433 // must be destroyed AFTER root_view_. |
441 scoped_ptr<TooltipManagerWin> tooltip_manager_; | 434 scoped_ptr<TooltipManagerWin> tooltip_manager_; |
442 | 435 |
443 scoped_refptr<DropTargetWin> drop_target_; | 436 scoped_refptr<DropTargetWin> drop_target_; |
444 | 437 |
445 // Overridden from HWNDMessageHandlerDelegate: | 438 // Overridden from HWNDMessageHandlerDelegate: |
446 virtual bool IsWidgetWindow() const OVERRIDE; | 439 virtual bool IsWidgetWindow() const OVERRIDE; |
447 virtual bool IsUsingCustomFrame() const OVERRIDE; | 440 virtual bool IsUsingCustomFrame() const OVERRIDE; |
448 virtual void SchedulePaint() OVERRIDE; | 441 virtual void SchedulePaint() OVERRIDE; |
449 virtual void EnableInactiveRendering() OVERRIDE; | 442 virtual void EnableInactiveRendering() OVERRIDE; |
450 virtual bool IsInactiveRenderingDisabled() OVERRIDE; | 443 virtual bool IsInactiveRenderingDisabled() OVERRIDE; |
451 virtual bool CanResize() const OVERRIDE; | 444 virtual bool CanResize() const OVERRIDE; |
452 virtual bool CanMaximize() const OVERRIDE; | 445 virtual bool CanMaximize() const OVERRIDE; |
453 virtual bool CanActivate() const OVERRIDE; | 446 virtual bool CanActivate() const OVERRIDE; |
| 447 virtual bool CanSaveFocus() const OVERRIDE; |
| 448 virtual void SaveFocusOnDeactivate() OVERRIDE; |
| 449 virtual void RestoreFocusOnActivate() OVERRIDE; |
| 450 virtual void RestoreFocusOnEnable() OVERRIDE; |
| 451 virtual bool IsModal() const OVERRIDE; |
| 452 virtual int GetInitialShowState() const OVERRIDE; |
454 virtual bool WillProcessWorkAreaChange() const OVERRIDE; | 453 virtual bool WillProcessWorkAreaChange() const OVERRIDE; |
455 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; | 454 virtual int GetNonClientComponent(const gfx::Point& point) const OVERRIDE; |
456 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* path) OVERRIDE; | 455 virtual void GetWindowMask(const gfx::Size& size, gfx::Path* path) OVERRIDE; |
457 virtual bool GetClientAreaInsets(gfx::Insets* insets) const OVERRIDE; | 456 virtual bool GetClientAreaInsets(gfx::Insets* insets) const OVERRIDE; |
458 virtual void GetMinMaxSize(gfx::Size* min_size, | 457 virtual void GetMinMaxSize(gfx::Size* min_size, |
459 gfx::Size* max_size) const OVERRIDE; | 458 gfx::Size* max_size) const OVERRIDE; |
460 virtual gfx::Size GetRootViewSize() const OVERRIDE; | 459 virtual gfx::Size GetRootViewSize() const OVERRIDE; |
461 virtual void ResetWindowControls() OVERRIDE; | 460 virtual void ResetWindowControls() OVERRIDE; |
462 virtual void UpdateFrame() OVERRIDE; | 461 virtual void UpdateFrame() OVERRIDE; |
463 virtual void PaintLayeredWindow(gfx::Canvas* canvas) OVERRIDE; | 462 virtual void PaintLayeredWindow(gfx::Canvas* canvas) OVERRIDE; |
464 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; | 463 virtual gfx::NativeViewAccessible GetNativeViewAccessible() OVERRIDE; |
465 virtual InputMethod* GetInputMethod() OVERRIDE; | 464 virtual InputMethod* GetInputMethod() OVERRIDE; |
466 virtual void HandleAppDeactivated() OVERRIDE; | 465 virtual void HandleAppDeactivated() OVERRIDE; |
467 virtual void HandleActivationChanged(bool active) OVERRIDE; | 466 virtual void HandleActivationChanged(bool active) OVERRIDE; |
468 virtual bool HandleAppCommand(short command) OVERRIDE; | 467 virtual bool HandleAppCommand(short command) OVERRIDE; |
469 virtual void HandleCaptureLost() OVERRIDE; | 468 virtual void HandleCaptureLost() OVERRIDE; |
470 virtual void HandleClose() OVERRIDE; | 469 virtual void HandleClose() OVERRIDE; |
471 virtual bool HandleCommand(int command) OVERRIDE; | 470 virtual bool HandleCommand(int command) OVERRIDE; |
472 virtual void HandleAccelerator(const ui::Accelerator& accelerator) OVERRIDE; | 471 virtual void HandleAccelerator(const ui::Accelerator& accelerator) OVERRIDE; |
473 virtual void HandleCreate() OVERRIDE; | 472 virtual void HandleCreate() OVERRIDE; |
474 virtual void HandleDestroy() OVERRIDE; | 473 virtual void HandleDestroying() OVERRIDE; |
| 474 virtual void HandleDestroyed() OVERRIDE; |
| 475 virtual bool HandleInitialFocus() OVERRIDE; |
475 virtual void HandleDisplayChange() OVERRIDE; | 476 virtual void HandleDisplayChange() OVERRIDE; |
476 virtual void HandleGlassModeChange() OVERRIDE; | 477 virtual void HandleGlassModeChange() OVERRIDE; |
477 virtual void HandleBeginWMSizeMove() OVERRIDE; | 478 virtual void HandleBeginWMSizeMove() OVERRIDE; |
478 virtual void HandleEndWMSizeMove() OVERRIDE; | 479 virtual void HandleEndWMSizeMove() OVERRIDE; |
479 virtual void HandleMove() OVERRIDE; | 480 virtual void HandleMove() OVERRIDE; |
480 virtual void HandleWorkAreaChanged() OVERRIDE; | 481 virtual void HandleWorkAreaChanged() OVERRIDE; |
481 virtual void HandleVisibilityChanged(bool visible) OVERRIDE; | 482 virtual void HandleVisibilityChanged(bool visible) OVERRIDE; |
482 virtual void HandleClientSizeChanged(const gfx::Size& new_size) OVERRIDE; | 483 virtual void HandleClientSizeChanged(const gfx::Size& new_size) OVERRIDE; |
483 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE; | 484 virtual void HandleNativeFocus(HWND last_focused_window) OVERRIDE; |
484 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE; | 485 virtual void HandleNativeBlur(HWND focused_window) OVERRIDE; |
(...skipping 10 matching lines...) Expand all Loading... |
495 LPARAM l_param) OVERRIDE; | 496 LPARAM l_param) OVERRIDE; |
496 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE; | 497 virtual NativeWidgetWin* AsNativeWidgetWin() OVERRIDE; |
497 | 498 |
498 private: | 499 private: |
499 typedef ScopedVector<ui::ViewProp> ViewProps; | 500 typedef ScopedVector<ui::ViewProp> ViewProps; |
500 | 501 |
501 // TODO(beng): This friendship can be removed once all methods relating to | 502 // TODO(beng): This friendship can be removed once all methods relating to |
502 // this object being a WindowImpl are moved to HWNDMessageHandler. | 503 // this object being a WindowImpl are moved to HWNDMessageHandler. |
503 friend HWNDMessageHandler; | 504 friend HWNDMessageHandler; |
504 | 505 |
505 // Called after the WM_ACTIVATE message has been processed by the default | |
506 // windows procedure. | |
507 static void PostProcessActivateMessage(NativeWidgetWin* widget, | |
508 int activation_state); | |
509 | |
510 void SetInitParams(const Widget::InitParams& params); | 506 void SetInitParams(const Widget::InitParams& params); |
511 | 507 |
512 // Determines whether the delegate expects the client size or the window size. | 508 // Determines whether the delegate expects the client size or the window size. |
513 bool WidgetSizeIsClientSize() const; | 509 bool WidgetSizeIsClientSize() const; |
514 | 510 |
515 void RestoreEnabledIfNecessary(); | |
516 | |
517 void SetInitialFocus(); | |
518 | |
519 // A delegate implementation that handles events received here. | 511 // A delegate implementation that handles events received here. |
520 // See class documentation for Widget in widget.h for a note about ownership. | 512 // See class documentation for Widget in widget.h for a note about ownership. |
521 internal::NativeWidgetDelegate* delegate_; | 513 internal::NativeWidgetDelegate* delegate_; |
522 | 514 |
523 // The following factory is used for calls to close the NativeWidgetWin | |
524 // instance. | |
525 base::WeakPtrFactory<NativeWidgetWin> close_widget_factory_; | |
526 | |
527 // See class documentation for Widget in widget.h for a note about ownership. | 515 // See class documentation for Widget in widget.h for a note about ownership. |
528 Widget::InitParams::Ownership ownership_; | 516 Widget::InitParams::Ownership ownership_; |
529 | 517 |
530 // Whether the focus should be restored next time we get enabled. Needed to | |
531 // restore focus correctly when Windows modal dialogs are displayed. | |
532 bool restore_focus_when_enabled_; | |
533 | |
534 // Instance of accessibility information and handling for MSAA root | 518 // Instance of accessibility information and handling for MSAA root |
535 base::win::ScopedComPtr<IAccessible> accessibility_root_; | 519 base::win::ScopedComPtr<IAccessible> accessibility_root_; |
536 | 520 |
537 // Value determines whether the Widget is customized for accessibility. | 521 // Value determines whether the Widget is customized for accessibility. |
538 static bool screen_reader_active_; | 522 static bool screen_reader_active_; |
539 | 523 |
540 // The maximum number of view events in our vector below. | 524 // The maximum number of view events in our vector below. |
541 static const int kMaxAccessibilityViewEvents = 20; | 525 static const int kMaxAccessibilityViewEvents = 20; |
542 | 526 |
543 // A vector used to access views for which we have sent notifications to | 527 // A vector used to access views for which we have sent notifications to |
544 // accessibility clients. It is used as a circular queue. | 528 // accessibility clients. It is used as a circular queue. |
545 std::vector<View*> accessibility_view_events_; | 529 std::vector<View*> accessibility_view_events_; |
546 | 530 |
547 // The current position of the view events vector. When incrementing, | 531 // The current position of the view events vector. When incrementing, |
548 // we always mod this value with the max view events above . | 532 // we always mod this value with the max view events above . |
549 int accessibility_view_events_index_; | 533 int accessibility_view_events_index_; |
550 | 534 |
551 ViewProps props_; | 535 ViewProps props_; |
552 | 536 |
553 // The window styles before we modified them for the drag frame appearance. | 537 // The window styles before we modified them for the drag frame appearance. |
554 DWORD drag_frame_saved_window_style_; | 538 DWORD drag_frame_saved_window_style_; |
555 DWORD drag_frame_saved_window_ex_style_; | 539 DWORD drag_frame_saved_window_ex_style_; |
556 | 540 |
557 // Whether all ancestors have been enabled. This is only used if is_modal_ is | |
558 // true. | |
559 bool restored_enabled_; | |
560 | |
561 // True if the widget is going to have a non_client_view. We cache this value | 541 // True if the widget is going to have a non_client_view. We cache this value |
562 // rather than asking the Widget for the non_client_view so that we know at | 542 // rather than asking the Widget for the non_client_view so that we know at |
563 // Init time, before the Widget has created the NonClientView. | 543 // Init time, before the Widget has created the NonClientView. |
564 bool has_non_client_view_; | 544 bool has_non_client_view_; |
565 | 545 |
566 scoped_ptr<HWNDMessageHandler> message_handler_; | 546 scoped_ptr<HWNDMessageHandler> message_handler_; |
567 | 547 |
568 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); | 548 DISALLOW_COPY_AND_ASSIGN(NativeWidgetWin); |
569 }; | 549 }; |
570 | 550 |
571 } // namespace views | 551 } // namespace views |
572 | 552 |
573 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ | 553 #endif // UI_VIEWS_WIDGET_NATIVE_WIDGET_WIN_H_ |
OLD | NEW |