aboutsummaryrefslogtreecommitdiff
path: root/src/ui/window.hpp
diff options
context:
space:
mode:
author杨宇千 <crupest@outlook.com>2018-11-10 20:05:29 +0800
committerGitHub <noreply@github.com>2018-11-10 20:05:29 +0800
commit0e9e897d306c71ab46fd9b5371d811950124ee27 (patch)
tree6e7c9dcda090b0fd0153c634165393e693894c10 /src/ui/window.hpp
parent09be0d0c86a789d568addc3153917aa604e4c7d7 (diff)
parentfd3f899964bb0a3cad80bbb9afc4445fac1e6412 (diff)
downloadcru-0e9e897d306c71ab46fd9b5371d811950124ee27.tar.gz
cru-0e9e897d306c71ab46fd9b5371d811950124ee27.tar.bz2
cru-0e9e897d306c71ab46fd9b5371d811950124ee27.zip
Merge pull request #7 from crupest/parent-window
Add parent window support.
Diffstat (limited to 'src/ui/window.hpp')
-rw-r--r--src/ui/window.hpp28
1 files changed, 25 insertions, 3 deletions
diff --git a/src/ui/window.hpp b/src/ui/window.hpp
index 2609594d..963bff78 100644
--- a/src/ui/window.hpp
+++ b/src/ui/window.hpp
@@ -83,13 +83,26 @@ namespace cru::ui
- class Window : public Control
+ class Window final : public Control
{
friend class WindowManager;
public:
static constexpr auto control_type = L"Window";
- Window();
+ public:
+ static Window* CreateOverlapped();
+ static Window* CreatePopup(Window* parent, bool caption = false);
+
+ private:
+ struct tag_overlapped_constructor {};
+ struct tag_popup_constructor {};
+
+ explicit Window(tag_overlapped_constructor);
+ Window(tag_popup_constructor, Window* parent, bool caption);
+
+ void AfterCreateHwnd(WindowManager* window_manager);
+
+ public:
Window(const Window& other) = delete;
Window(Window&& other) = delete;
Window& operator=(const Window& other) = delete;
@@ -99,6 +112,8 @@ namespace cru::ui
public:
StringView GetControlType() const override final;
+ void SetDeleteThisOnDestroy(bool value);
+
//*************** region: handle ***************
//Get the handle of the window. Return null if window is invalid.
@@ -116,6 +131,11 @@ namespace cru::ui
//*************** region: window operations ***************
+ Window* GetParentWindow() const
+ {
+ return parent_window_;
+ }
+
//Close and destroy the window if the window is valid.
void Close();
@@ -285,7 +305,10 @@ namespace cru::ui
void DispatchMouseHoverControlChangeEvent(Control* old_control, Control * new_control, const Point& point);
private:
+ bool delete_this_on_destroy_ = true;
+
HWND hwnd_ = nullptr;
+ Window* parent_window_ = nullptr;
std::shared_ptr<graph::WindowRenderTarget> render_target_{};
std::list<Control*> control_list_{};
@@ -302,4 +325,3 @@ namespace cru::ui
#endif
};
}
-