| 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/string16.h" | 9 #include "base/string16.h" |
| 10 #include "ui/base/accessibility/accessibility_types.h" | 10 #include "ui/base/accessibility/accessibility_types.h" |
| 11 #include "ui/base/ui_base_types.h" | 11 #include "ui/base/ui_base_types.h" |
| 12 #include "ui/views/widget/widget_delegate.h" | 12 #include "ui/views/widget/widget_delegate.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 class DialogClientView; | 16 class DialogClientView; |
| 17 class View; | |
| 18 | 17 |
| 19 /////////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////////// |
| 20 // | 19 // |
| 21 // DialogDelegate | 20 // DialogDelegate |
| 22 // | 21 // |
| 23 // DialogDelegate is an interface implemented by objects that wish to show a | 22 // 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 | 23 // 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 | 24 // determine how it should be displayed and notify the delegate object of |
| 26 // certain events. | 25 // certain events. |
| 27 // | 26 // |
| 28 /////////////////////////////////////////////////////////////////////////////// | 27 /////////////////////////////////////////////////////////////////////////////// |
| 29 class VIEWS_EXPORT DialogDelegate : public WidgetDelegate { | 28 class VIEWS_EXPORT DialogDelegate : public WidgetDelegate { |
| 30 public: | 29 public: |
| 31 virtual DialogDelegate* AsDialogDelegate() OVERRIDE; | 30 virtual ~DialogDelegate(); |
| 32 | 31 |
| 33 virtual ~DialogDelegate(); | 32 // Returns whether to use the new dialog style. |
| 33 static bool UseNewStyle(); |
| 34 | 34 |
| 35 // Returns a mask specifying which of the available DialogButtons are visible | 35 // Returns a mask specifying which of the available DialogButtons are visible |
| 36 // for the dialog. Note: If an OK button is provided, you should provide a | 36 // for the dialog. Note: If an OK button is provided, you should provide a |
| 37 // CANCEL button. A dialog box with just an OK button is frowned upon and | 37 // CANCEL button. A dialog box with just an OK button is frowned upon and |
| 38 // considered a very special case, so if you're planning on including one, | 38 // considered a very special case, so if you're planning on including one, |
| 39 // you should reconsider, or beng says there will be stabbings. | 39 // you should reconsider, or beng says there will be stabbings. |
| 40 // | 40 // |
| 41 // To use the extra button you need to override GetDialogButtons() | 41 // To use the extra button you need to override GetDialogButtons() |
| 42 virtual int GetDialogButtons() const; | 42 virtual int GetDialogButtons() const; |
| 43 | 43 |
| 44 // Returns the default dialog button. This should not be a mask as only | 44 // Returns the default dialog button. This should not be a mask as only |
| 45 // one button should ever be the default button. Return | 45 // one button should ever be the default button. Return |
| 46 // ui::DIALOG_BUTTON_NONE if there is no default. Default | 46 // ui::DIALOG_BUTTON_NONE if there is no default. Default |
| 47 // behavior is to return ui::DIALOG_BUTTON_OK or | 47 // behavior is to return ui::DIALOG_BUTTON_OK or |
| 48 // ui::DIALOG_BUTTON_CANCEL (in that order) if they are | 48 // ui::DIALOG_BUTTON_CANCEL (in that order) if they are |
| 49 // present, ui::DIALOG_BUTTON_NONE otherwise. | 49 // present, ui::DIALOG_BUTTON_NONE otherwise. |
| 50 virtual int GetDefaultDialogButton() const; | 50 virtual int GetDefaultDialogButton() const; |
| 51 | 51 |
| 52 // Returns the label of the specified dialog button. | 52 // Returns the label of the specified dialog button. |
| 53 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const; | 53 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const; |
| 54 | 54 |
| 55 // Returns whether the specified dialog button is enabled. | 55 // Returns whether the specified dialog button is enabled. |
| 56 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const; | 56 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const; |
| 57 | 57 |
| 58 // Returns whether the specified dialog button is visible. | 58 // Returns whether the specified dialog button is visible. |
| 59 virtual bool IsDialogButtonVisible(ui::DialogButton button) const; | 59 virtual bool IsDialogButtonVisible(ui::DialogButton button) const; |
| 60 | 60 |
| 61 // Returns whether to use chrome style for the button strip (like WebUI). If | |
| 62 // false, native style padding is used. | |
| 63 virtual bool UseChromeStyle() const; | |
| 64 | |
| 65 // Returns whether accelerators are enabled on the button. This is invoked | 61 // Returns whether accelerators are enabled on the button. This is invoked |
| 66 // when an accelerator is pressed, not at construction time. This | 62 // when an accelerator is pressed, not at construction time. This |
| 67 // returns true. | 63 // returns true. |
| 68 virtual bool AreAcceleratorsEnabled(ui::DialogButton button); | 64 virtual bool AreAcceleratorsEnabled(ui::DialogButton button); |
| 69 | 65 |
| 70 // Override this function if with a view which will be shown in the same | 66 // Override this function if with a view which will be shown in the same |
| 71 // row as the OK and CANCEL buttons but flush to the left and extending | 67 // row as the OK and CANCEL buttons but flush to the left and extending |
| 72 // up to the buttons. | 68 // up to the buttons. |
| 73 virtual View* GetExtraView(); | 69 virtual View* GetExtraView(); |
| 74 | 70 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 88 // For Dialog boxes, this is called when the user presses the "OK" button, | 84 // For Dialog boxes, this is called when the user presses the "OK" button, |
| 89 // or the Enter key. Can also be called on Esc key or close button | 85 // or the Enter key. Can also be called on Esc key or close button |
| 90 // presses if there is no "Cancel" button. This function should return | 86 // presses if there is no "Cancel" button. This function should return |
| 91 // true if the window can be closed after it returns, or false if it must | 87 // true if the window can be closed after it returns, or false if it must |
| 92 // remain open. If |window_closing| is true, it means that this handler is | 88 // remain open. If |window_closing| is true, it means that this handler is |
| 93 // being called because the window is being closed (e.g. by Window::Close) | 89 // being called because the window is being closed (e.g. by Window::Close) |
| 94 // and there is no Cancel handler, so Accept is being called instead. | 90 // and there is no Cancel handler, so Accept is being called instead. |
| 95 virtual bool Accept(bool window_closing); | 91 virtual bool Accept(bool window_closing); |
| 96 virtual bool Accept(); | 92 virtual bool Accept(); |
| 97 | 93 |
| 98 // Overridden from WindowDelegate: | 94 // Overridden from WidgetDelegate: |
| 99 virtual View* GetInitiallyFocusedView() OVERRIDE; | 95 virtual View* GetInitiallyFocusedView() OVERRIDE; |
| 96 virtual DialogDelegate* AsDialogDelegate() OVERRIDE; |
| 100 virtual ClientView* CreateClientView(Widget* widget) OVERRIDE; | 97 virtual ClientView* CreateClientView(Widget* widget) OVERRIDE; |
| 98 virtual NonClientFrameView* CreateNonClientFrameView(Widget* widget) OVERRIDE; |
| 101 | 99 |
| 102 // Called when the window has been closed. | 100 // Called when the window has been closed. |
| 103 virtual void OnClose() {} | 101 virtual void OnClose() {} |
| 104 | 102 |
| 105 // A helper for accessing the DialogClientView object contained by this | 103 // A helper for accessing the DialogClientView object contained by this |
| 106 // delegate's Window. | 104 // delegate's Window. |
| 107 const DialogClientView* GetDialogClientView() const; | 105 const DialogClientView* GetDialogClientView() const; |
| 108 DialogClientView* GetDialogClientView(); | 106 DialogClientView* GetDialogClientView(); |
| 109 | 107 |
| 110 protected: | 108 protected: |
| 111 // Overridden from WindowDelegate: | 109 // Overridden from WindowDelegate: |
| 112 virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const OVERRIDE; | 110 virtual ui::AccessibilityTypes::Role GetAccessibleWindowRole() const OVERRIDE; |
| 113 }; | 111 }; |
| 114 | 112 |
| 115 // A DialogDelegate implementation that is-a View. Used to override GetWidget() | 113 // A DialogDelegate implementation that is-a View. Used to override GetWidget() |
| 116 // to call View's GetWidget() for the common case where a DialogDelegate | 114 // to call View's GetWidget() for the common case where a DialogDelegate |
| 117 // implementation is-a View. | 115 // implementation is-a View. |
| 118 class VIEWS_EXPORT DialogDelegateView : public DialogDelegate, | 116 class VIEWS_EXPORT DialogDelegateView : public DialogDelegate, |
| 119 public View { | 117 public View { |
| 120 public: | 118 public: |
| 121 DialogDelegateView(); | 119 DialogDelegateView(); |
| 122 virtual ~DialogDelegateView(); | 120 virtual ~DialogDelegateView(); |
| 123 | 121 |
| 124 // Overridden from DialogDelegate: | 122 // Overridden from DialogDelegate: |
| 125 virtual Widget* GetWidget() OVERRIDE; | 123 virtual Widget* GetWidget() OVERRIDE; |
| 126 virtual const Widget* GetWidget() const OVERRIDE; | 124 virtual const Widget* GetWidget() const OVERRIDE; |
| 125 virtual View* GetContentsView() OVERRIDE; |
| 127 | 126 |
| 128 private: | 127 private: |
| 129 DISALLOW_COPY_AND_ASSIGN(DialogDelegateView); | 128 DISALLOW_COPY_AND_ASSIGN(DialogDelegateView); |
| 130 }; | 129 }; |
| 131 | 130 |
| 132 } // namespace views | 131 } // namespace views |
| 133 | 132 |
| 134 #endif // UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ | 133 #endif // UI_VIEWS_WINDOW_DIALOG_DELEGATE_H_ |
| OLD | NEW |