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_WINDOW_DIALOG_CLIENT_VIEW_H_ | 5 #ifndef UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
6 #define UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 6 #define UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
7 | 7 |
8 #include "ui/base/ui_base_types.h" | 8 #include "ui/base/ui_base_types.h" |
9 #include "ui/views/controls/button/button.h" | 9 #include "ui/views/controls/button/button.h" |
10 #include "ui/views/focus/focus_manager.h" | 10 #include "ui/views/focus/focus_manager.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 // | Contents View | | 25 // | Contents View | |
26 // +------------------------------+ | 26 // +------------------------------+ |
27 // | [Extra View] [OK] [Cancel] | | 27 // | [Extra View] [OK] [Cancel] | |
28 // | [ Footnote View ] | | 28 // | [ Footnote View ] | |
29 // +------------------------------+ | 29 // +------------------------------+ |
30 class VIEWS_EXPORT DialogClientView : public ClientView, | 30 class VIEWS_EXPORT DialogClientView : public ClientView, |
31 public ButtonListener, | 31 public ButtonListener, |
32 public FocusChangeListener { | 32 public FocusChangeListener { |
33 public: | 33 public: |
34 DialogClientView(Widget* widget, View* contents_view); | 34 DialogClientView(Widget* widget, View* contents_view); |
35 virtual ~DialogClientView(); | 35 ~DialogClientView() override; |
36 | 36 |
37 // Accept or Cancel the dialog. | 37 // Accept or Cancel the dialog. |
38 void AcceptWindow(); | 38 void AcceptWindow(); |
39 void CancelWindow(); | 39 void CancelWindow(); |
40 | 40 |
41 // Accessors in case the user wishes to adjust these buttons. | 41 // Accessors in case the user wishes to adjust these buttons. |
42 LabelButton* ok_button() const { return ok_button_; } | 42 LabelButton* ok_button() const { return ok_button_; } |
43 LabelButton* cancel_button() const { return cancel_button_; } | 43 LabelButton* cancel_button() const { return cancel_button_; } |
44 | 44 |
45 // Update the dialog buttons to match the dialog's delegate. | 45 // Update the dialog buttons to match the dialog's delegate. |
46 void UpdateDialogButtons(); | 46 void UpdateDialogButtons(); |
47 | 47 |
48 // ClientView implementation: | 48 // ClientView implementation: |
49 virtual bool CanClose() override; | 49 bool CanClose() override; |
50 virtual DialogClientView* AsDialogClientView() override; | 50 DialogClientView* AsDialogClientView() override; |
51 virtual const DialogClientView* AsDialogClientView() const override; | 51 const DialogClientView* AsDialogClientView() const override; |
52 | 52 |
53 // FocusChangeListener implementation: | 53 // FocusChangeListener implementation: |
54 virtual void OnWillChangeFocus(View* focused_before, | 54 void OnWillChangeFocus(View* focused_before, View* focused_now) override; |
55 View* focused_now) override; | 55 void OnDidChangeFocus(View* focused_before, View* focused_now) override; |
56 virtual void OnDidChangeFocus(View* focused_before, | |
57 View* focused_now) override; | |
58 | 56 |
59 // View implementation: | 57 // View implementation: |
60 virtual gfx::Size GetPreferredSize() const override; | 58 gfx::Size GetPreferredSize() const override; |
61 virtual void Layout() override; | 59 void Layout() override; |
62 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 60 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
63 virtual void ViewHierarchyChanged( | 61 void ViewHierarchyChanged( |
64 const ViewHierarchyChangedDetails& details) override; | 62 const ViewHierarchyChangedDetails& details) override; |
65 virtual void NativeViewHierarchyChanged() override; | 63 void NativeViewHierarchyChanged() override; |
66 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 64 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
67 | 65 |
68 // ButtonListener implementation: | 66 // ButtonListener implementation: |
69 virtual void ButtonPressed(Button* sender, const ui::Event& event) override; | 67 void ButtonPressed(Button* sender, const ui::Event& event) override; |
70 | 68 |
71 protected: | 69 protected: |
72 // For testing. | 70 // For testing. |
73 DialogClientView(View* contents_view); | 71 DialogClientView(View* contents_view); |
74 | 72 |
75 // Returns the DialogDelegate for the window. Virtual for testing. | 73 // Returns the DialogDelegate for the window. Virtual for testing. |
76 virtual DialogDelegate* GetDialogDelegate() const; | 74 virtual DialogDelegate* GetDialogDelegate() const; |
77 | 75 |
78 // Create and add the extra view, if supplied by the delegate. | 76 // Create and add the extra view, if supplied by the delegate. |
79 void CreateExtraView(); | 77 void CreateExtraView(); |
80 | 78 |
81 // Creates and adds the footnote view, if supplied by the delegate. | 79 // Creates and adds the footnote view, if supplied by the delegate. |
82 void CreateFootnoteView(); | 80 void CreateFootnoteView(); |
83 | 81 |
84 // View implementation. | 82 // View implementation. |
85 virtual void ChildPreferredSizeChanged(View* child) override; | 83 void ChildPreferredSizeChanged(View* child) override; |
86 virtual void ChildVisibilityChanged(View* child) override; | 84 void ChildVisibilityChanged(View* child) override; |
87 | 85 |
88 private: | 86 private: |
89 FRIEND_TEST_ALL_PREFIXES(DialogClientViewTest, FocusManager); | 87 FRIEND_TEST_ALL_PREFIXES(DialogClientViewTest, FocusManager); |
90 | 88 |
91 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } | 89 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } |
92 | 90 |
93 // Create a dialog button of the appropriate type. | 91 // Create a dialog button of the appropriate type. |
94 LabelButton* CreateDialogButton(ui::DialogButton type); | 92 LabelButton* CreateDialogButton(ui::DialogButton type); |
95 | 93 |
96 // Update |button|'s text and enabled state according to the delegate's state. | 94 // Update |button|'s text and enabled state according to the delegate's state. |
(...skipping 29 matching lines...) Expand all Loading... |
126 // http://crbug.com/71940). This is used to avoid notifying the delegate | 124 // http://crbug.com/71940). This is used to avoid notifying the delegate |
127 // twice, which can have bad consequences. | 125 // twice, which can have bad consequences. |
128 bool notified_delegate_; | 126 bool notified_delegate_; |
129 | 127 |
130 DISALLOW_COPY_AND_ASSIGN(DialogClientView); | 128 DISALLOW_COPY_AND_ASSIGN(DialogClientView); |
131 }; | 129 }; |
132 | 130 |
133 } // namespace views | 131 } // namespace views |
134 | 132 |
135 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 133 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
OLD | NEW |