InputBox.h 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. * Copyright (c) 2021, Jakob-Niklas See <git@nwex.de>
  4. * Copyright (c) 2022, the SerenityOS developers.
  5. *
  6. * SPDX-License-Identifier: BSD-2-Clause
  7. */
  8. #pragma once
  9. #include <LibGUI/Dialog.h>
  10. namespace GUI {
  11. enum class InputType {
  12. Text,
  13. Password
  14. };
  15. class InputBox : public Dialog {
  16. C_OBJECT(InputBox)
  17. public:
  18. virtual ~InputBox() override = default;
  19. static int show(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder = {}, InputType input_type = InputType::Text);
  20. private:
  21. explicit InputBox(Window* parent_window, String& text_value, StringView prompt, StringView title, StringView placeholder, InputType input_type);
  22. String text_value() const { return m_text_value; }
  23. void build(InputType input_type);
  24. String m_text_value;
  25. String m_prompt;
  26. String m_placeholder;
  27. RefPtr<Button> m_ok_button;
  28. RefPtr<Button> m_cancel_button;
  29. RefPtr<TextEditor> m_text_editor;
  30. };
  31. }