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_DELEGATE_H_ | 5 #ifndef UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ |
6 #define UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ | 6 #define UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ |
7 | 7 |
8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
9 #include "base/strings/string16.h" | 9 #include "base/strings/string16.h" |
10 #include "ui/accessibility/ax_enums.h" | 10 #include "ui/accessibility/ax_enums.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // DialogDelegate is an interface implemented by objects that wish to show a | 23 // DialogDelegate is an interface implemented by objects that wish to show a |
24 // dialog box Window. The window that is displayed uses this interface to | 24 // dialog box Window. The window that is displayed uses this interface to |
25 // determine how it should be displayed and notify the delegate object of | 25 // determine how it should be displayed and notify the delegate object of |
26 // certain events. | 26 // certain events. |
27 // | 27 // |
28 /////////////////////////////////////////////////////////////////////////////// | 28 /////////////////////////////////////////////////////////////////////////////// |
29 class VIEWS_EXPORT DialogDelegate : public ui::DialogModel, | 29 class VIEWS_EXPORT DialogDelegate : public ui::DialogModel, |
30 public WidgetDelegate { | 30 public WidgetDelegate { |
31 public: | 31 public: |
32 DialogDelegate(); | 32 DialogDelegate(); |
33 virtual ~DialogDelegate(); | 33 ~DialogDelegate() override; |
34 | 34 |
35 // Same as CreateDialogWidgetWithBounds() with an empty |bounds|. | 35 // Same as CreateDialogWidgetWithBounds() with an empty |bounds|. |
36 static Widget* CreateDialogWidget(WidgetDelegate* delegate, | 36 static Widget* CreateDialogWidget(WidgetDelegate* delegate, |
37 gfx::NativeWindow context, | 37 gfx::NativeWindow context, |
38 gfx::NativeView parent); | 38 gfx::NativeView parent); |
39 | 39 |
40 // Create a dialog widget with the specified |context| or |parent|. | 40 // Create a dialog widget with the specified |context| or |parent|. |
41 // If |bounds| is not empty, used to initially place the dialog, otherwise | 41 // If |bounds| is not empty, used to initially place the dialog, otherwise |
42 // a default location is used. | 42 // a default location is used. |
43 static Widget* CreateDialogWidgetWithBounds(WidgetDelegate* delegate, | 43 static Widget* CreateDialogWidgetWithBounds(WidgetDelegate* delegate, |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 virtual bool Accept(); | 76 virtual bool Accept(); |
77 | 77 |
78 // Called when the user closes the window without selecting an option, | 78 // Called when the user closes the window without selecting an option, |
79 // e.g. by pressing the close button on the window or using a window manager | 79 // e.g. by pressing the close button on the window or using a window manager |
80 // gesture. By default, this calls Accept() if the only button in the dialog | 80 // gesture. By default, this calls Accept() if the only button in the dialog |
81 // is Accept, Cancel() otherwise. This function should return true if the | 81 // is Accept, Cancel() otherwise. This function should return true if the |
82 // window can be closed after it returns, or false if it must remain open. | 82 // window can be closed after it returns, or false if it must remain open. |
83 virtual bool Close(); | 83 virtual bool Close(); |
84 | 84 |
85 // Overridden from ui::DialogModel: | 85 // Overridden from ui::DialogModel: |
86 virtual base::string16 GetDialogLabel() const override; | 86 base::string16 GetDialogLabel() const override; |
87 virtual base::string16 GetDialogTitle() const override; | 87 base::string16 GetDialogTitle() const override; |
88 virtual int GetDialogButtons() const override; | 88 int GetDialogButtons() const override; |
89 virtual int GetDefaultDialogButton() const override; | 89 int GetDefaultDialogButton() const override; |
90 virtual bool ShouldDefaultButtonBeBlue() const override; | 90 bool ShouldDefaultButtonBeBlue() const override; |
91 virtual base::string16 GetDialogButtonLabel( | 91 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
92 ui::DialogButton button) const override; | 92 bool IsDialogButtonEnabled(ui::DialogButton button) const override; |
93 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const override; | |
94 | 93 |
95 // Overridden from WidgetDelegate: | 94 // Overridden from WidgetDelegate: |
96 virtual View* GetInitiallyFocusedView() override; | 95 View* GetInitiallyFocusedView() override; |
97 virtual DialogDelegate* AsDialogDelegate() override; | 96 DialogDelegate* AsDialogDelegate() override; |
98 virtual ClientView* CreateClientView(Widget* widget) override; | 97 ClientView* CreateClientView(Widget* widget) override; |
99 virtual NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; | 98 NonClientFrameView* CreateNonClientFrameView(Widget* widget) override; |
100 | 99 |
101 // Create a frame view using the new dialog style. | 100 // Create a frame view using the new dialog style. |
102 static NonClientFrameView* CreateDialogFrameView(Widget* widget); | 101 static NonClientFrameView* CreateDialogFrameView(Widget* widget); |
103 | 102 |
104 // Returns whether this particular dialog should use the new dialog style. | 103 // Returns whether this particular dialog should use the new dialog style. |
105 virtual bool UseNewStyleForThisDialog() const; | 104 virtual bool UseNewStyleForThisDialog() const; |
106 | 105 |
107 // Called when the window has been closed. | 106 // Called when the window has been closed. |
108 virtual void OnClosed() {} | 107 virtual void OnClosed() {} |
109 | 108 |
110 // A helper for accessing the DialogClientView object contained by this | 109 // A helper for accessing the DialogClientView object contained by this |
111 // delegate's Window. | 110 // delegate's Window. |
112 const DialogClientView* GetDialogClientView() const; | 111 const DialogClientView* GetDialogClientView() const; |
113 DialogClientView* GetDialogClientView(); | 112 DialogClientView* GetDialogClientView(); |
114 | 113 |
115 protected: | 114 protected: |
116 // Overridden from WidgetDelegate: | 115 // Overridden from WidgetDelegate: |
117 virtual ui::AXRole GetAccessibleWindowRole() const override; | 116 ui::AXRole GetAccessibleWindowRole() const override; |
118 | 117 |
119 private: | 118 private: |
120 // A flag indicating whether this dialog supports the new style. | 119 // A flag indicating whether this dialog supports the new style. |
121 bool supports_new_style_; | 120 bool supports_new_style_; |
122 }; | 121 }; |
123 | 122 |
124 // A DialogDelegate implementation that is-a View. Used to override GetWidget() | 123 // A DialogDelegate implementation that is-a View. Used to override GetWidget() |
125 // to call View's GetWidget() for the common case where a DialogDelegate | 124 // to call View's GetWidget() for the common case where a DialogDelegate |
126 // implementation is-a View. Note that DialogDelegateView is not owned by | 125 // implementation is-a View. Note that DialogDelegateView is not owned by |
127 // view's hierarchy and is expected to be deleted on DeleteDelegate call. | 126 // view's hierarchy and is expected to be deleted on DeleteDelegate call. |
128 class VIEWS_EXPORT DialogDelegateView : public DialogDelegate, | 127 class VIEWS_EXPORT DialogDelegateView : public DialogDelegate, |
129 public View { | 128 public View { |
130 public: | 129 public: |
131 DialogDelegateView(); | 130 DialogDelegateView(); |
132 virtual ~DialogDelegateView(); | 131 ~DialogDelegateView() override; |
133 | 132 |
134 // Overridden from DialogDelegate: | 133 // Overridden from DialogDelegate: |
135 virtual void DeleteDelegate() override; | 134 void DeleteDelegate() override; |
136 virtual Widget* GetWidget() override; | 135 Widget* GetWidget() override; |
137 virtual const Widget* GetWidget() const override; | 136 const Widget* GetWidget() const override; |
138 virtual View* GetContentsView() override; | 137 View* GetContentsView() override; |
139 | 138 |
140 private: | 139 private: |
141 DISALLOW_COPY_AND_ASSIGN(DialogDelegateView); | 140 DISALLOW_COPY_AND_ASSIGN(DialogDelegateView); |
142 }; | 141 }; |
143 | 142 |
144 } // namespace views | 143 } // namespace views |
145 | 144 |
146 #endif // UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ | 145 #endif // UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ |
OLD | NEW |