Dialog.h 806 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibGUI/Window.h>
  8. namespace GUI {
  9. class Dialog : public Window {
  10. C_OBJECT(Dialog)
  11. public:
  12. enum ExecResult {
  13. ExecOK = 0,
  14. ExecCancel = 1,
  15. ExecAborted = 2,
  16. ExecYes = 3,
  17. ExecNo = 4,
  18. };
  19. virtual ~Dialog() override;
  20. int exec();
  21. int result() const { return m_result; }
  22. void done(int result);
  23. virtual void event(Core::Event&) override;
  24. virtual void close() override;
  25. protected:
  26. explicit Dialog(Window* parent_window);
  27. private:
  28. OwnPtr<Core::EventLoop> m_event_loop;
  29. int m_result { ExecAborted };
  30. };
  31. }
  32. template<>
  33. struct AK::Formatter<GUI::Dialog> : Formatter<Core::Object> {
  34. };