Dialog.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. enum ScreenPosition {
  20. CenterWithinParent = 0,
  21. Center = 1,
  22. CenterLeft = 2,
  23. CenterRight = 3,
  24. TopLeft = 4,
  25. TopCenter = 5,
  26. TopRight = 6,
  27. BottomLeft = 7,
  28. BottomCenter = 8,
  29. BottomRight = 9,
  30. };
  31. virtual ~Dialog() override;
  32. int exec();
  33. int result() const { return m_result; }
  34. void done(int result);
  35. virtual void event(Core::Event&) override;
  36. virtual void close() override;
  37. protected:
  38. explicit Dialog(Window* parent_window, ScreenPosition screen_position = CenterWithinParent);
  39. private:
  40. OwnPtr<Core::EventLoop> m_event_loop;
  41. int m_result { ExecAborted };
  42. int m_screen_position { CenterWithinParent };
  43. };
  44. }
  45. template<>
  46. struct AK::Formatter<GUI::Dialog> : Formatter<Core::Object> {
  47. };