aboutsummaryrefslogtreecommitdiff
path: root/src/main.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cpp')
-rw-r--r--src/main.cpp44
1 files changed, 34 insertions, 10 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 359b511b..f9bc975c 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -6,6 +6,7 @@
#include "ui/controls/button.hpp"
#include "ui/controls/text_box.hpp"
+using cru::ui::Rect;
using cru::String;
using cru::Application;
using cru::ui::Window;
@@ -28,7 +29,7 @@ int APIENTRY wWinMain(
Application application(hInstance);
- Window window;
+ const auto window = Window::CreateOverlapped();
/*
window.native_message_event.AddHandler([](cru::ui::events::WindowNativeMessageEventArgs& args)
{
@@ -86,9 +87,6 @@ int APIENTRY wWinMain(
//test 2
-
- Window child_window(&window);
-
const auto layout = CreateWithLayout<LinearLayout>(LayoutSideParams::Exactly(500), LayoutSideParams::Content());
layout->mouse_click_event.AddHandler([layout](cru::ui::events::MouseButtonEventArgs& args)
@@ -106,7 +104,7 @@ int APIENTRY wWinMain(
#ifdef CRU_DEBUG_LAYOUT
toggle_button->toggle_event.AddHandler([&window](cru::ui::events::ToggleEventArgs& args)
{
- window.SetDebugLayout(args.GetNewState());
+ window->SetDebugLayout(args.GetNewState());
});
#endif
inner_layout->AddChild(toggle_button);
@@ -116,10 +114,36 @@ int APIENTRY wWinMain(
{
const auto button = Button::Create();
button->GetLayoutParams()->padding = Thickness(20, 5);
- button->AddChild(TextBlock::Create(L"Show child window."));
- button->mouse_click_event.AddHandler([&child_window](auto)
+ button->AddChild(TextBlock::Create(L"Show popup window parenting this."));
+ button->mouse_click_event.AddHandler([window](auto)
+ {
+ Window::CreatePopup(window)->Show();
+ });
+ layout->AddChild(button);
+ }
+
+ {
+ const auto button = Button::Create();
+ button->GetLayoutParams()->padding = Thickness(20, 5);
+ button->AddChild(TextBlock::Create(L"Show popup window parenting null."));
+ button->mouse_click_event.AddHandler([](auto)
+ {
+ auto popup = Window::CreatePopup(nullptr);
+ popup->SetWindowRect(Rect(100, 100, 300, 300));
+ popup->Show();
+ });
+ layout->AddChild(button);
+ }
+
+ {
+ const auto button = Button::Create();
+ button->GetLayoutParams()->padding = Thickness(20, 5);
+ button->AddChild(TextBlock::Create(L"Show popup window with caption."));
+ button->mouse_click_event.AddHandler([](auto)
{
- child_window.Show();
+ auto popup = Window::CreatePopup(nullptr, true);
+ popup->SetWindowRect(Rect(100, 100, 300, 300));
+ popup->Show();
});
layout->AddChild(button);
}
@@ -152,7 +176,7 @@ int APIENTRY wWinMain(
layout->AddChild(CreateWithLayout<TextBlock>(LayoutSideParams::Content(Alignment::End), LayoutSideParams::Stretch(), L"By crupest!!!"));
- window.AddChild(layout);
+ window->AddChild(layout);
/*
window.AddChild(
@@ -177,7 +201,7 @@ int APIENTRY wWinMain(
*/
- window.Show();
+ window->Show();
return application.Run();
}