| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 VIEWS_WINDOW_DIALOG_DELEGATE_H_ | 5 #ifndef VIEWS_WINDOW_DIALOG_DELEGATE_H_ |
| 6 #define VIEWS_WINDOW_DIALOG_DELEGATE_H_ | 6 #define VIEWS_WINDOW_DIALOG_DELEGATE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "app/message_box_flags.h" | 9 #include "ui/base/message_box_flags.h" |
| 10 #include "views/accessibility/accessibility_types.h" | 10 #include "views/accessibility/accessibility_types.h" |
| 11 #include "views/window/dialog_client_view.h" | 11 #include "views/window/dialog_client_view.h" |
| 12 #include "views/window/window_delegate.h" | 12 #include "views/window/window_delegate.h" |
| 13 | 13 |
| 14 namespace views { | 14 namespace views { |
| 15 | 15 |
| 16 class View; | 16 class View; |
| 17 | 17 |
| 18 /////////////////////////////////////////////////////////////////////////////// | 18 /////////////////////////////////////////////////////////////////////////////// |
| 19 // | 19 // |
| (...skipping 10 matching lines...) Expand all Loading... |
| 30 virtual DialogDelegate* AsDialogDelegate() { return this; } | 30 virtual DialogDelegate* AsDialogDelegate() { return this; } |
| 31 | 31 |
| 32 // Returns a mask specifying which of the available DialogButtons are visible | 32 // Returns a mask specifying which of the available DialogButtons are visible |
| 33 // for the dialog. Note: If an OK button is provided, you should provide a | 33 // for the dialog. Note: If an OK button is provided, you should provide a |
| 34 // CANCEL button. A dialog box with just an OK button is frowned upon and | 34 // CANCEL button. A dialog box with just an OK button is frowned upon and |
| 35 // considered a very special case, so if you're planning on including one, | 35 // considered a very special case, so if you're planning on including one, |
| 36 // you should reconsider, or beng says there will be stabbings. | 36 // you should reconsider, or beng says there will be stabbings. |
| 37 // | 37 // |
| 38 // To use the extra button you need to override GetDialogButtons() | 38 // To use the extra button you need to override GetDialogButtons() |
| 39 virtual int GetDialogButtons() const { | 39 virtual int GetDialogButtons() const { |
| 40 return MessageBoxFlags::DIALOGBUTTON_OK | | 40 return ui::MessageBoxFlags::DIALOGBUTTON_OK | |
| 41 MessageBoxFlags::DIALOGBUTTON_CANCEL; | 41 ui::MessageBoxFlags::DIALOGBUTTON_CANCEL; |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Returns whether accelerators are enabled on the button. This is invoked | 44 // Returns whether accelerators are enabled on the button. This is invoked |
| 45 // when an accelerator is pressed, not at construction time. This | 45 // when an accelerator is pressed, not at construction time. This |
| 46 // returns true. | 46 // returns true. |
| 47 virtual bool AreAcceleratorsEnabled(MessageBoxFlags::DialogButton button) { | 47 virtual bool AreAcceleratorsEnabled( |
| 48 ui::MessageBoxFlags::DialogButton button) { |
| 48 return true; | 49 return true; |
| 49 } | 50 } |
| 50 | 51 |
| 51 // Returns the label of the specified DialogButton. | 52 // Returns the label of the specified DialogButton. |
| 52 virtual std::wstring GetDialogButtonLabel( | 53 virtual std::wstring GetDialogButtonLabel( |
| 53 MessageBoxFlags::DialogButton button) const { | 54 ui::MessageBoxFlags::DialogButton button) const { |
| 54 // empty string results in defaults for MessageBoxFlags::DIALOGBUTTON_OK, | 55 // empty string results in defaults for |
| 55 // MessageBoxFlags::DIALOGBUTTON_CANCEL. | 56 // ui::MessageBoxFlags::DIALOGBUTTON_OK, |
| 57 // ui::MessageBoxFlags::DIALOGBUTTON_CANCEL. |
| 56 return L""; | 58 return L""; |
| 57 } | 59 } |
| 58 | 60 |
| 59 // Override this function if with a view which will be shown in the same | 61 // Override this function if with a view which will be shown in the same |
| 60 // row as the OK and CANCEL buttons but flush to the left and extending | 62 // row as the OK and CANCEL buttons but flush to the left and extending |
| 61 // up to the buttons. | 63 // up to the buttons. |
| 62 virtual View* GetExtraView() { return NULL; } | 64 virtual View* GetExtraView() { return NULL; } |
| 63 | 65 |
| 64 // Returns whether the height of the extra view should be at least as tall as | 66 // Returns whether the height of the extra view should be at least as tall as |
| 65 // the buttons. The default (false) is to give the extra view it's preferred | 67 // the buttons. The default (false) is to give the extra view it's preferred |
| 66 // height. By returning true the height becomes | 68 // height. By returning true the height becomes |
| 67 // max(extra_view preferred height, buttons preferred height). | 69 // max(extra_view preferred height, buttons preferred height). |
| 68 virtual bool GetSizeExtraViewHeightToButtons() { return false; } | 70 virtual bool GetSizeExtraViewHeightToButtons() { return false; } |
| 69 | 71 |
| 70 // Returns the default dialog button. This should not be a mask as only | 72 // Returns the default dialog button. This should not be a mask as only |
| 71 // one button should ever be the default button. Return | 73 // one button should ever be the default button. Return |
| 72 // MessageBoxFlags::DIALOGBUTTON_NONE if there is no default. Default | 74 // ui::MessageBoxFlags::DIALOGBUTTON_NONE if there is no default. Default |
| 73 // behavior is to return MessageBoxFlags::DIALOGBUTTON_OK or | 75 // behavior is to return ui::MessageBoxFlags::DIALOGBUTTON_OK or |
| 74 // MessageBoxFlags::DIALOGBUTTON_CANCEL (in that order) if they are | 76 // ui::MessageBoxFlags::DIALOGBUTTON_CANCEL (in that order) if they are |
| 75 // present, MessageBoxFlags::DIALOGBUTTON_NONE otherwise. | 77 // present, ui::MessageBoxFlags::DIALOGBUTTON_NONE otherwise. |
| 76 virtual int GetDefaultDialogButton() const; | 78 virtual int GetDefaultDialogButton() const; |
| 77 | 79 |
| 78 // Returns whether the specified dialog button is enabled. | 80 // Returns whether the specified dialog button is enabled. |
| 79 virtual bool IsDialogButtonEnabled( | 81 virtual bool IsDialogButtonEnabled( |
| 80 MessageBoxFlags::DialogButton button) const { | 82 ui::MessageBoxFlags::DialogButton button) const { |
| 81 return true; | 83 return true; |
| 82 } | 84 } |
| 83 | 85 |
| 84 // Returns whether the specified dialog button is visible. | 86 // Returns whether the specified dialog button is visible. |
| 85 virtual bool IsDialogButtonVisible( | 87 virtual bool IsDialogButtonVisible( |
| 86 MessageBoxFlags::DialogButton button) const { | 88 ui::MessageBoxFlags::DialogButton button) const { |
| 87 return true; | 89 return true; |
| 88 } | 90 } |
| 89 | 91 |
| 90 // For Dialog boxes, if there is a "Cancel" button, this is called when the | 92 // For Dialog boxes, if there is a "Cancel" button, this is called when the |
| 91 // user presses the "Cancel" button or the Close button on the window or | 93 // user presses the "Cancel" button or the Close button on the window or |
| 92 // in the system menu, or presses the Esc key. This function should return | 94 // in the system menu, or presses the Esc key. This function should return |
| 93 // true if the window can be closed after it returns, or false if it must | 95 // true if the window can be closed after it returns, or false if it must |
| 94 // remain open. | 96 // remain open. |
| 95 virtual bool Cancel() { return true; } | 97 virtual bool Cancel() { return true; } |
| 96 | 98 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 121 private: | 123 private: |
| 122 // Overridden from WindowDelegate: | 124 // Overridden from WindowDelegate: |
| 123 AccessibilityTypes::Role accessible_role() const { | 125 AccessibilityTypes::Role accessible_role() const { |
| 124 return AccessibilityTypes::ROLE_DIALOG; | 126 return AccessibilityTypes::ROLE_DIALOG; |
| 125 } | 127 } |
| 126 }; | 128 }; |
| 127 | 129 |
| 128 } // namespace views | 130 } // namespace views |
| 129 | 131 |
| 130 #endif // VIEWS_WINDOW_DIALOG_DELEGATE_H_ | 132 #endif // VIEWS_WINDOW_DIALOG_DELEGATE_H_ |
| OLD | NEW |