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 "base/gtest_prod_util.h" | 8 #include "base/gtest_prod_util.h" |
9 #include "base/macros.h" | 9 #include "base/macros.h" |
10 #include "ui/base/ui_base_types.h" | 10 #include "ui/base/ui_base_types.h" |
11 #include "ui/views/controls/button/button.h" | 11 #include "ui/views/controls/button/button.h" |
12 #include "ui/views/window/client_view.h" | 12 #include "ui/views/window/client_view.h" |
13 | 13 |
14 namespace views { | 14 namespace views { |
15 | 15 |
16 class DialogDelegate; | 16 class DialogDelegate; |
17 class LabelButton; | 17 class LabelButton; |
18 class Widget; | 18 class Widget; |
19 | 19 |
20 // DialogClientView provides adornments for a dialog's content view, including | 20 // DialogClientView provides adornments for a dialog's content view, including |
21 // custom-labeled [OK] and [Cancel] buttons with [Enter] and [Esc] accelerators. | 21 // custom-labeled [OK] and [Cancel] buttons with [Enter] and [Esc] accelerators. |
22 // The view also displays the delegate's extra view alongside the buttons and | 22 // The view also displays the delegate's extra view alongside the buttons and |
23 // the delegate's footnote view below the buttons. The view appears like below. | 23 // the delegate's footnote view below the buttons. The view appears like below. |
msw
2016/02/22 21:43:56
nit: remove mention and depiction below of the foo
Evan Stade
2016/02/22 22:58:23
Done.
| |
24 // NOTE: The contents view is not inset on the top or side client view edges. | 24 // NOTE: The contents view is not inset on the top or side client view edges. |
25 // +------------------------------+ | 25 // +------------------------------+ |
26 // | Contents View | | 26 // | Contents View | |
27 // +------------------------------+ | 27 // +------------------------------+ |
28 // | [Extra View] [OK] [Cancel] | | 28 // | [Extra View] [OK] [Cancel] | |
29 // | [ Footnote View ] | | 29 // | [ Footnote View ] | |
30 // +------------------------------+ | 30 // +------------------------------+ |
31 class VIEWS_EXPORT DialogClientView : public ClientView, | 31 class VIEWS_EXPORT DialogClientView : public ClientView, |
32 public ButtonListener { | 32 public ButtonListener { |
33 public: | 33 public: |
(...skipping 20 matching lines...) Expand all Loading... | |
54 gfx::Size GetPreferredSize() const override; | 54 gfx::Size GetPreferredSize() const override; |
55 void Layout() override; | 55 void Layout() override; |
56 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; | 56 bool AcceleratorPressed(const ui::Accelerator& accelerator) override; |
57 void ViewHierarchyChanged( | 57 void ViewHierarchyChanged( |
58 const ViewHierarchyChangedDetails& details) override; | 58 const ViewHierarchyChangedDetails& details) override; |
59 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; | 59 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; |
60 | 60 |
61 // ButtonListener implementation: | 61 // ButtonListener implementation: |
62 void ButtonPressed(Button* sender, const ui::Event& event) override; | 62 void ButtonPressed(Button* sender, const ui::Event& event) override; |
63 | 63 |
64 void set_button_row_insets(const gfx::Insets& insets) { | |
65 button_row_insets_ = insets; | |
66 } | |
67 | |
64 protected: | 68 protected: |
65 // For testing. | 69 // For testing. |
66 explicit DialogClientView(View* contents_view); | 70 explicit DialogClientView(View* contents_view); |
67 | 71 |
68 // Returns the DialogDelegate for the window. Virtual for testing. | 72 // Returns the DialogDelegate for the window. Virtual for testing. |
69 virtual DialogDelegate* GetDialogDelegate() const; | 73 virtual DialogDelegate* GetDialogDelegate() const; |
70 | 74 |
71 // Create and add the extra view, if supplied by the delegate. | 75 // Create and add the extra view, if supplied by the delegate. |
72 void CreateExtraView(); | 76 void CreateExtraView(); |
73 | 77 |
74 // Creates and adds the footnote view, if supplied by the delegate. | |
75 void CreateFootnoteView(); | |
76 | |
77 // View implementation. | 78 // View implementation. |
78 void ChildPreferredSizeChanged(View* child) override; | 79 void ChildPreferredSizeChanged(View* child) override; |
79 void ChildVisibilityChanged(View* child) override; | 80 void ChildVisibilityChanged(View* child) override; |
80 | 81 |
81 private: | 82 private: |
82 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } | 83 bool has_dialog_buttons() const { return ok_button_ || cancel_button_; } |
83 | 84 |
84 // Create a dialog button of the appropriate type. | 85 // Create a dialog button of the appropriate type. |
85 LabelButton* CreateDialogButton(ui::DialogButton type); | 86 LabelButton* CreateDialogButton(ui::DialogButton type); |
86 | 87 |
87 // Update |button|'s text and enabled state according to the delegate's state. | 88 // Update |button|'s text and enabled state according to the delegate's state. |
88 void UpdateButton(LabelButton* button, ui::DialogButton type); | 89 void UpdateButton(LabelButton* button, ui::DialogButton type); |
89 | 90 |
90 // Returns the height of the row containing the buttons and the extra view. | 91 // Returns the height of the row containing the buttons and the extra view. |
91 int GetButtonsAndExtraViewRowHeight() const; | 92 int GetButtonsAndExtraViewRowHeight() const; |
92 | 93 |
93 // Returns the insets for the buttons and extra view. | 94 // Returns the insets for the buttons and extra view. |
94 gfx::Insets GetButtonRowInsets() const; | 95 gfx::Insets GetButtonRowInsets() const; |
95 | 96 |
96 // Closes the widget. | 97 // Closes the widget. |
97 void Close(); | 98 void Close(); |
98 | 99 |
100 // How much to inset the button row. | |
101 gfx::Insets button_row_insets_; | |
102 | |
99 // The dialog buttons. | 103 // The dialog buttons. |
100 LabelButton* ok_button_; | 104 LabelButton* ok_button_; |
101 LabelButton* cancel_button_; | 105 LabelButton* cancel_button_; |
102 | 106 |
103 // The extra view shown in the row of buttons; may be NULL. | 107 // The extra view shown in the row of buttons; may be NULL. |
104 View* extra_view_; | 108 View* extra_view_; |
105 | 109 |
106 // The footnote view shown below the buttons; may be NULL. | |
107 View* footnote_view_; | |
108 | |
109 // True if we've notified the delegate the window is closing and the delegate | 110 // True if we've notified the delegate the window is closing and the delegate |
110 // allosed the close. In some situations it's possible to get two closes (see | 111 // allosed the close. In some situations it's possible to get two closes (see |
111 // http://crbug.com/71940). This is used to avoid notifying the delegate | 112 // http://crbug.com/71940). This is used to avoid notifying the delegate |
112 // twice, which can have bad consequences. | 113 // twice, which can have bad consequences. |
113 bool notified_delegate_; | 114 bool notified_delegate_; |
114 | 115 |
115 DISALLOW_COPY_AND_ASSIGN(DialogClientView); | 116 DISALLOW_COPY_AND_ASSIGN(DialogClientView); |
116 }; | 117 }; |
117 | 118 |
118 } // namespace views | 119 } // namespace views |
119 | 120 |
120 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ | 121 #endif // UI_VIEWS_WINDOW_DIALOG_CLIENT_VIEW_H_ |
OLD | NEW |