# HG changeset patch # User Olaf Wintermann # Date 1684833088 -7200 # Node ID 7c3ff86ee9d479bd91fd42d30da902eb50e30525 # Parent e79a60b3a7cb5dc9517984244202bc811028eca9# Parent bc63cb601f6d2fc5bc3de722f0c36633f1625265 merge diff -r bc63cb601f6d -r 7c3ff86ee9d4 make/vs/testapp/main.c --- a/make/vs/testapp/main.c Mon May 22 21:21:20 2023 +0200 +++ b/make/vs/testapp/main.c Tue May 23 11:11:28 2023 +0200 @@ -1,6 +1,53 @@ -#include +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2023 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ -int main(int argc, char** argv) { - printf("hello world!\n"); - return 0; +#include + +#include +#include + +#include + + + +void application_startup(UiEvent* event, void* data) { + UiObject* obj = ui_window("Test", NULL); + + ui_show(obj); } + + +int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR lpCmdLine, int nCmdShow) +{ + ui_init("app1", 0, NULL); + ui_onstartup(application_startup, NULL); + + ui_main(); + + return (EXIT_SUCCESS); +} diff -r bc63cb601f6d -r 7c3ff86ee9d4 make/vs/testapp/testapp.vcxproj --- a/make/vs/testapp/testapp.vcxproj Mon May 22 21:21:20 2023 +0200 +++ b/make/vs/testapp/testapp.vcxproj Tue May 23 11:11:28 2023 +0200 @@ -27,6 +27,9 @@ {3541f08b-e6cc-4c23-a0d3-51983aab33c6} testapp 10.0 + true + None + false @@ -111,9 +114,10 @@ true _DEBUG;_CONSOLE;UI_WINUI;%(PreprocessorDefinitions) true + C:\Users\Olaf\Projekte\toolkit\ui;%(AdditionalIncludeDirectories) - Console + Windows true @@ -139,6 +143,11 @@ + + + {04d5ee2c-6076-4c7c-8b70-b0f6d602ff55} + + diff -r bc63cb601f6d -r 7c3ff86ee9d4 ui/ui/toolkit.h --- a/ui/ui/toolkit.h Mon May 22 21:21:20 2023 +0200 +++ b/ui/ui/toolkit.h Tue May 23 11:11:28 2023 +0200 @@ -79,6 +79,10 @@ #define FALSE 0 #endif +#ifndef UIEXPORT +#define UIEXPORT +#endif + #ifdef __cplusplus extern "C" { #endif @@ -284,8 +288,8 @@ }; -void ui_init(char *appname, int argc, char **argv); -char* ui_appname(); +void ui_init(const char *appname, int argc, char **argv); +const char* ui_appname(); UiContext* ui_global_context(void); diff -r bc63cb601f6d -r 7c3ff86ee9d4 ui/ui/window.h --- a/ui/ui/window.h Mon May 22 21:21:20 2023 +0200 +++ b/ui/ui/window.h Tue May 23 11:11:28 2023 +0200 @@ -35,7 +35,7 @@ extern "C" { #endif -UiObject* ui_window(char *title, void *window_data); +UiObject* ui_window(const char *title, void *window_data); UiObject* ui_simplewindow(char *title, void *window_data); char* ui_openfiledialog(UiObject *obj); diff -r bc63cb601f6d -r 7c3ff86ee9d4 ui/winui/toolkit.cpp --- a/ui/winui/toolkit.cpp Mon May 22 21:21:20 2023 +0200 +++ b/ui/winui/toolkit.cpp Tue May 23 11:11:28 2023 +0200 @@ -1,5 +1,134 @@ -#include "../ui/toolkit.h" +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2023 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "toolkit.h" + +#include +#undef GetCurrentTime +#include +#include +#include +#include +#include +#include + + +using namespace winrt; +using namespace Microsoft::UI::Xaml; +using namespace Microsoft::UI::Xaml::Controls; +using namespace Microsoft::UI::Xaml::XamlTypeInfo; +using namespace Microsoft::UI::Xaml::Markup; +using namespace Windows::UI::Xaml::Interop; + +static const char* application_name; + +static ui_callback startup_func; +static void* startup_data; + +static ui_callback open_func; +void* open_data; + +static ui_callback exit_func; +void* exit_data; + +static ui_callback appclose_fnc; + +static void* appclose_udata; + + +static UiObject* active_window; + -int testfunc() { - return 123; +class App : public ApplicationT { +public: + void OnLaunched(LaunchActivatedEventArgs const&) { + Resources().MergedDictionaries().Append(XamlControlsResources()); + if (startup_func) { + startup_func(NULL, startup_data); + } + } + IXamlType GetXamlType(TypeName const& type) { + return provider.GetXamlType(type); + } + IXamlType GetXamlType(hstring const& fullname) { + return provider.GetXamlType(fullname); + } + com_array GetXmlnsDefinitions() { + return provider.GetXmlnsDefinitions(); + } +private: + XamlControlsXamlMetaDataProvider provider; +}; + + + +void ui_init(const char* appname, int argc, char** argv) { + application_name = appname; +} + +const char* ui_appname() { + return application_name; +} + +UiContext* ui_global_context(void) { + return NULL; } + +void ui_context_closefunc(UiContext* ctx, ui_callback fnc, void* udata) { + +} + +void ui_onstartup(ui_callback f, void* userdata) { + startup_func = f; + startup_data = userdata; +} + +void ui_onopen(ui_callback f, void* userdata) { + open_func = f; + open_data = userdata; +} + +void ui_onexit(ui_callback f, void* userdata) { + exit_func = f; + exit_data = userdata; +} + +void ui_main() { + init_apartment(); + Application::Start([](auto&&) {make(); }); +} + +void ui_show(UiObject* obj) { + UiWidget* w = (UiWidget*)obj->widget; + w->show(); +} + +void ui_close(UiObject* obj) { + +} + diff -r bc63cb601f6d -r 7c3ff86ee9d4 ui/winui/toolkit.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/winui/toolkit.h Tue May 23 11:11:28 2023 +0200 @@ -0,0 +1,38 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2023 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#define UIEXPORT extern "C" __declspec(dllexport) +#include "../ui/toolkit.h" + + +class UiWidget { +public: + virtual void show() {}; +}; \ No newline at end of file diff -r bc63cb601f6d -r 7c3ff86ee9d4 ui/winui/window.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/winui/window.cpp Tue May 23 11:11:28 2023 +0200 @@ -0,0 +1,70 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2023 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "window.h" + +#include +#undef GetCurrentTime +#include +#include +#include +#include +#include +#include + +#include + +using namespace winrt; +using namespace Microsoft::UI::Xaml; +using namespace Microsoft::UI::Xaml::Controls; +using namespace Microsoft::UI::Xaml::XamlTypeInfo; +using namespace Microsoft::UI::Xaml::Markup; +using namespace Windows::UI::Xaml::Interop; + + +class UiWindow : UiWidget { +public: + UiWindow(const char* title) { + window = Window(); + } + + virtual void show() { + window.Activate(); + } + + Window window{ nullptr }; +}; + +UiObject* ui_window(const char* title, void* window_data) { + UiObject* obj = (UiObject*)malloc(sizeof(UiObject)); + + UiWindow* window = new UiWindow(title); + obj->widget = window; + + return obj; +} diff -r bc63cb601f6d -r 7c3ff86ee9d4 ui/winui/window.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/ui/winui/window.h Tue May 23 11:11:28 2023 +0200 @@ -0,0 +1,44 @@ +/* + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. + * + * Copyright 2023 Olaf Wintermann. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#pragma once + +#include "toolkit.h" + +#include "../ui/window.h" + +#include +#undef GetCurrentTime +#include +#include +#include +#include +#include +#include + + diff -r bc63cb601f6d -r 7c3ff86ee9d4 ui/winui/winui.vcxproj --- a/ui/winui/winui.vcxproj Mon May 22 21:21:20 2023 +0200 +++ b/ui/winui/winui.vcxproj Tue May 23 11:11:28 2023 +0200 @@ -27,6 +27,9 @@ {04d5ee2c-6076-4c7c-8b70-b0f6d602ff55} winui 10.0 + true + None + false @@ -136,10 +139,15 @@ + + + + + diff -r bc63cb601f6d -r 7c3ff86ee9d4 ui/winui/winui.vcxproj.filters --- a/ui/winui/winui.vcxproj.filters Mon May 22 21:21:20 2023 +0200 +++ b/ui/winui/winui.vcxproj.filters Tue May 23 11:11:28 2023 +0200 @@ -18,8 +18,19 @@ Quelldateien + + Quelldateien + + + + Headerdateien + + + Headerdateien + + \ No newline at end of file