InputBox.h 1.0 KB

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