Sort unlaunched apps on app list start page by apps grid order.
[chromium-blink-merge.git] / ui / views / controls / message_box_view.h
blob2bb43316137a601affb3cfc4746737a7dc836353
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
3 // found in the LICENSE file.
5 #ifndef UI_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_H_
6 #define UI_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_H_
8 #include <vector>
10 #include "base/strings/string16.h"
11 #include "ui/views/view.h"
13 namespace views {
15 class Checkbox;
16 class Label;
17 class Link;
18 class LinkListener;
19 class Textfield;
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 // Internal class name.
27 static const char kViewClassName[];
29 enum Options {
30 NO_OPTIONS = 0,
31 // For a message from a web page (not from Chrome's UI), such as script
32 // dialog text, each paragraph's directionality is auto-detected using the
33 // directionality of the paragraph's first strong character's. Please refer
34 // to HTML5 spec for details.
35 // http://dev.w3.org/html5/spec/Overview.html#text-rendered-in-native-user-interfaces:
36 // The spec does not say anything about alignment. And we choose to
37 // align all paragraphs according to the direction of the first paragraph.
38 DETECT_DIRECTIONALITY = 1 << 0,
39 HAS_PROMPT_FIELD = 1 << 1,
42 struct VIEWS_EXPORT InitParams {
43 explicit InitParams(const base::string16& message);
44 ~InitParams();
46 uint16 options;
47 base::string16 message;
48 base::string16 default_prompt;
49 int message_width;
50 int inter_row_vertical_spacing;
53 explicit MessageBoxView(const InitParams& params);
55 ~MessageBoxView() override;
57 // Returns the text box.
58 views::Textfield* text_box() { return prompt_field_; }
60 // Returns user entered data in the prompt field.
61 base::string16 GetInputText();
63 // Returns true if a checkbox is selected, false otherwise. (And false if
64 // the message box has no checkbox.)
65 bool IsCheckBoxSelected();
67 // Adds a checkbox with the specified label to the message box if this is the
68 // first call. Otherwise, it changes the label of the current checkbox. To
69 // start, the message box has no checkbox until this function is called.
70 void SetCheckBoxLabel(const base::string16& label);
72 // Sets the state of the check-box.
73 void SetCheckBoxSelected(bool selected);
75 // Sets the text and the listener of the link. If |text| is empty, the link
76 // is removed.
77 void SetLink(const base::string16& text, LinkListener* listener);
79 // View:
80 void GetAccessibleState(ui::AXViewState* state) override;
82 protected:
83 // View:
84 void ViewHierarchyChanged(
85 const ViewHierarchyChangedDetails& details) override;
86 // Handles Ctrl-C and writes the message in the system clipboard.
87 bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
88 const char* GetClassName() const override;
90 private:
91 // Sets up the layout manager and initializes the message labels and prompt
92 // field. This should only be called once, from the constructor.
93 void Init(const InitParams& params);
95 // Sets up the layout manager based on currently initialized views. Should be
96 // called when a view is initialized or changed.
97 void ResetLayoutManager();
99 // Message for the message box.
100 std::vector<Label*> message_labels_;
102 // Input text field for the message box.
103 Textfield* prompt_field_;
105 // Checkbox for the message box.
106 Checkbox* checkbox_;
108 // Link displayed at the bottom of the view.
109 Link* link_;
111 // Maximum width of the message label.
112 int message_width_;
114 // Spacing between rows in the grid layout.
115 int inter_row_vertical_spacing_;
117 DISALLOW_COPY_AND_ASSIGN(MessageBoxView);
120 } // namespace views
122 #endif // UI_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_H_