Serenity Operating System
at master 67 lines 1.4 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * Copyright (c) 2022, the SerenityOS developers. 4 * 5 * SPDX-License-Identifier: BSD-2-Clause 6 */ 7 8#pragma once 9 10#include <LibCore/EventLoop.h> 11#include <LibGUI/Window.h> 12 13namespace GUI { 14 15class Dialog : public Window { 16 C_OBJECT(Dialog) 17public: 18 enum class ExecResult { 19 OK = 0, 20 Cancel = 1, 21 Aborted = 2, 22 Yes = 3, 23 No = 4, 24 }; 25 enum class ScreenPosition { 26 CenterWithinParent = 0, 27 28 Center = 1, 29 CenterLeft = 2, 30 CenterRight = 3, 31 32 TopLeft = 4, 33 TopCenter = 5, 34 TopRight = 6, 35 36 BottomLeft = 7, 37 BottomCenter = 8, 38 BottomRight = 9, 39 }; 40 41 virtual ~Dialog() override = default; 42 43 ExecResult exec(); 44 45 ExecResult result() const { return m_result; } 46 void done(ExecResult); 47 48 virtual void event(Core::Event&) override; 49 50 virtual void close() override; 51 52protected: 53 explicit Dialog(Window* parent_window, ScreenPosition = ScreenPosition::CenterWithinParent); 54 55 virtual void on_done(ExecResult) { } 56 57private: 58 OwnPtr<Core::EventLoop> m_event_loop; 59 ExecResult m_result { ExecResult::Aborted }; 60 ScreenPosition m_screen_position { ScreenPosition::CenterWithinParent }; 61}; 62 63} 64 65template<> 66struct AK::Formatter<GUI::Dialog> : Formatter<Core::Object> { 67};