#ifndef UI_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_H_
#define UI_VIEWS_CONTROLS_MESSAGE_BOX_VIEW_H_
#include <stdint.h>
#include <string>
#include <string_view>
#include <vector>
#include "base/gtest_prod_util.h"
#include "base/memory/raw_ptr.h"
#include "ui/base/metadata/metadata_header_macros.h"
#include "ui/gfx/geometry/insets.h"
#include "ui/views/controls/link.h"
#include "ui/views/layout/box_layout_view.h"
#include "ui/views/metadata/view_factory.h"
#include "ui/views/view.h"
namespace views {
class Checkbox;
class Label;
class LayoutProvider;
class ScrollView;
class Textfield;
class VIEWS_EXPORT MessageBoxView : public BoxLayoutView {
METADATA_HEADER(MessageBoxView, BoxLayoutView)
public:
using MessageLabels = std::vector<raw_ptr<views::Label, VectorExperimental>>;
explicit MessageBoxView(const std::u16string& message = std::u16string(),
bool detect_directionality = false);
MessageBoxView(const MessageBoxView&) = delete;
MessageBoxView& operator=(const MessageBoxView&) = delete;
~MessageBoxView() override;
void SetMessageLabel(std::u16string_view message);
views::Textfield* GetVisiblePromptField();
std::u16string_view GetInputText();
bool HasVisibleCheckBox() const;
bool IsCheckBoxSelected();
void SetCheckBoxLabel(const std::u16string& label);
void SetCheckBoxSelected(bool selected);
void SetLink(const std::u16string& text, Link::ClickedCallback callback);
void SetInterRowVerticalSpacing(int spacing);
void SetMessageWidth(int width);
void SetPromptField(const std::u16string& default_prompt);
const std::u16string& label_text_for_testing() const { return label_text_; }
protected:
gfx::Size CalculatePreferredSize(
const SizeBounds& available_size) const override;
void ViewHierarchyChanged(
const ViewHierarchyChangedDetails& details) override;
bool AcceleratorPressed(const ui::Accelerator& accelerator) override;
private:
FRIEND_TEST_ALL_PREFIXES(MessageBoxViewTest, CheckMessageOnlySize);
FRIEND_TEST_ALL_PREFIXES(MessageBoxViewTest, CheckWithOptionalViewsSize);
FRIEND_TEST_ALL_PREFIXES(MessageBoxViewTest, CheckInterRowHeightChange);
void ResetLayoutManager();
gfx::Insets GetHorizontalInsets(const LayoutProvider* provider);
const bool detect_directionality_;
std::u16string label_text_;
raw_ptr<BoxLayoutView> message_contents_ = nullptr;
MessageLabels message_labels_;
raw_ptr<ScrollView> scroll_view_ = nullptr;
raw_ptr<Textfield> prompt_field_ = nullptr;
raw_ptr<Checkbox> checkbox_ = nullptr;
raw_ptr<Link> link_ = nullptr;
int inter_row_vertical_spacing_ = 0;
int message_width_ = 0;
};
BEGIN_VIEW_BUILDER(VIEWS_EXPORT, MessageBoxView, BoxLayoutView)
VIEW_BUILDER_PROPERTY(const std::u16string&, CheckBoxLabel)
VIEW_BUILDER_PROPERTY(bool, CheckBoxSelected)
VIEW_BUILDER_METHOD(SetLink, const std::u16string&, Link::ClickedCallback)
VIEW_BUILDER_PROPERTY(int, InterRowVerticalSpacing)
VIEW_BUILDER_PROPERTY(int, MessageWidth)
VIEW_BUILDER_PROPERTY(const std::u16string&, PromptField)
END_VIEW_BUILDER
}
DEFINE_VIEW_BUILDER(VIEWS_EXPORT, views::MessageBoxView)
#endif