| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef VIEWS_CONTROLS_MESSAGE_BOX_VIEW_H_ | |
| 6 #define VIEWS_CONTROLS_MESSAGE_BOX_VIEW_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/string16.h" | |
| 12 #include "views/view.h" | |
| 13 | |
| 14 namespace views { | |
| 15 | |
| 16 class Checkbox; | |
| 17 class ImageView; | |
| 18 class Label; | |
| 19 class Textfield; | |
| 20 | |
| 21 // This class displays the contents of a message box. It is intended for use | |
| 22 // within a constrained window, and has options for a message, prompt, OK | |
| 23 // and Cancel buttons. | |
| 24 class VIEWS_EXPORT MessageBoxView : public View { | |
| 25 public: | |
| 26 MessageBoxView(int dialog_flags, | |
| 27 const string16& message, | |
| 28 const string16& default_prompt, | |
| 29 int message_width); | |
| 30 | |
| 31 MessageBoxView(int dialog_flags, | |
| 32 const string16& message, | |
| 33 const string16& default_prompt); | |
| 34 | |
| 35 virtual ~MessageBoxView(); | |
| 36 | |
| 37 // Returns the text box. | |
| 38 views::Textfield* text_box() { return prompt_field_; } | |
| 39 | |
| 40 // Returns user entered data in the prompt field. | |
| 41 string16 GetInputText(); | |
| 42 | |
| 43 // Returns true if a checkbox is selected, false otherwise. (And false if | |
| 44 // the message box has no checkbox.) | |
| 45 bool IsCheckBoxSelected(); | |
| 46 | |
| 47 // Adds |icon| to the upper left of the message box or replaces the current | |
| 48 // icon. To start out, the message box has no icon. | |
| 49 void SetIcon(const SkBitmap& icon); | |
| 50 | |
| 51 // Adds a checkbox with the specified label to the message box if this is the | |
| 52 // first call. Otherwise, it changes the label of the current checkbox. To | |
| 53 // start, the message box has no checkbox until this function is called. | |
| 54 void SetCheckBoxLabel(const string16& label); | |
| 55 | |
| 56 // Sets the state of the check-box. | |
| 57 void SetCheckBoxSelected(bool selected); | |
| 58 | |
| 59 // View: | |
| 60 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | |
| 61 | |
| 62 protected: | |
| 63 // View: | |
| 64 virtual void ViewHierarchyChanged(bool is_add, | |
| 65 views::View* parent, | |
| 66 views::View* child) OVERRIDE; | |
| 67 // Handles Ctrl-C and writes the message in the system clipboard. | |
| 68 virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE; | |
| 69 | |
| 70 private: | |
| 71 // Sets up the layout manager and initializes the prompt field. This should | |
| 72 // only be called once, from the constructor. | |
| 73 void Init(int dialog_flags, const string16& default_prompt); | |
| 74 | |
| 75 // Sets up the layout manager based on currently initialized views. Should be | |
| 76 // called when a view is initialized or changed. | |
| 77 void ResetLayoutManager(); | |
| 78 | |
| 79 // Message for the message box. | |
| 80 Label* message_label_; | |
| 81 | |
| 82 // Input text field for the message box. | |
| 83 Textfield* prompt_field_; | |
| 84 | |
| 85 // Icon displayed in the upper left corner of the message box. | |
| 86 ImageView* icon_; | |
| 87 | |
| 88 // Checkbox for the message box. | |
| 89 Checkbox* checkbox_; | |
| 90 | |
| 91 // Maximum width of the message label. | |
| 92 int message_width_; | |
| 93 | |
| 94 DISALLOW_COPY_AND_ASSIGN(MessageBoxView); | |
| 95 }; | |
| 96 | |
| 97 } // namespace views | |
| 98 | |
| 99 #endif // VIEWS_CONTROLS_MESSAGE_BOX_VIEW_H_ | |
| OLD | NEW |