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 3 // found in the LICENSE file. 4 5 #ifndef UI_VIEWS_TEST_CHILD_WMODAL_WINDOW_H_ 6 #define UI_VIEWS_TEST_CHILD_WMODAL_WINDOW_H_ 7 8 #include "ui/views/controls/button/button.h" 9 #include "ui/views/widget/widget_delegate.h" 10 #include "ui/views/widget/widget_observer.h" 11 12 namespace views { 13 class LabelButton; 14 class NativeViewHost; 15 class Textfield; 16 class View; 17 class Widget; 18 namespace test { 19 20 void CreateChildModalParent(gfx::NativeView context); 21 22 class ChildModalParent : public WidgetDelegateView, 23 public ButtonListener, 24 public WidgetObserver { 25 public: 26 ChildModalParent(gfx::NativeView context); 27 virtual ~ChildModalParent(); 28 29 void ShowChild(); 30 gfx::NativeWindow GetModalParent() const; 31 gfx::NativeWindow GetChild() const; 32 33 private: 34 Widget* CreateChild(); 35 36 // Overridden from WidgetDelegate: 37 virtual View* GetContentsView() OVERRIDE; 38 virtual string16 GetWindowTitle() const OVERRIDE; 39 virtual bool CanResize() const OVERRIDE; 40 virtual void DeleteDelegate() OVERRIDE; 41 virtual void Layout() OVERRIDE; 42 virtual void ViewHierarchyChanged( 43 const ViewHierarchyChangedDetails& details) OVERRIDE; 44 45 // Overridden from ButtonListener: 46 virtual void ButtonPressed(Button* sender, 47 const ui::Event& event) OVERRIDE; 48 49 // Overridden from WidgetObserver: 50 virtual void OnWidgetDestroying(Widget* widget) OVERRIDE; 51 52 // The button to toggle showing and hiding the child window. The child window 53 // does not block input to this button. 54 LabelButton* button_; 55 56 // The text field to indicate the keyboard focus. 57 Textfield* textfield_; 58 59 // The host for the modal parent. 60 NativeViewHost* host_; 61 62 // The modal parent of the child window. The child window blocks input to this 63 // view. 64 gfx::NativeWindow modal_parent_; 65 66 // The child window. 67 Widget* child_; 68 69 DISALLOW_COPY_AND_ASSIGN(ChildModalParent); 70 }; 71 72 } // namespace test 73 } // namespace views 74 75 #endif // UI_VIEWS_TEST_CHILD_WMODAL_WINDOW_H_ 76