ladybird/Libraries/LibGUI/GMessageBox.h
Andreas Kling a17fbd98e7 LibGUI: Add input types to GMessageBox.
Currently the two available input types are:

- GMessageBox::InputType::OK (default)
- GMessageBox::InputType::OKCancel

Based on your choice, GMessageBox::exec() will return ExecOK or ExecCancel.
2019-07-16 21:41:13 +02:00

36 lines
929 B
C++

#pragma once
#include <LibGUI/GDialog.h>
class GMessageBox : public GDialog {
public:
enum class Type {
None,
Information,
Warning,
Error,
};
enum class InputType {
OK,
OKCancel,
};
explicit GMessageBox(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
virtual ~GMessageBox() override;
static void show(const StringView& text, const StringView& title, Type type = Type::None, InputType = InputType::OK, CObject* parent = nullptr);
virtual const char* class_name() const override { return "GMessageBox"; }
private:
bool should_include_ok_button() const;
bool should_include_cancel_button() const;
void build();
RefPtr<GraphicsBitmap> icon() const;
String m_text;
Type m_type { Type::None };
InputType m_input_type { InputType::OK };
};