From f8a94b73805c6a93aab7d1f8e9a6ad2f47de805b Mon Sep 17 00:00:00 2001 From: IoIxD Date: Wed, 15 Apr 2026 21:41:16 -0700 Subject: [PATCH] cmake --- .gitignore | 1 + CMakeLists.txt | 252 ++++++++++++++++------------- configure | 19 +-- examples/basic/CMakeLists.txt | 38 +++-- include/Mw/LowLevel.h | 6 + include/Mw/LowLevel/ClassicMacOS.h | 4 + pl/ostype/ClassicMacOS.pl | 10 ++ pl/ostype/ClassicMacOS68k.pl | 7 - pl/ostype/ClassicMacOSPPC.pl | 7 - src/backend/classicmacos.c | 12 +- src/dialog/filechooser.c | 2 +- src/widget/box.c | 2 +- src/widget/button.c | 2 +- src/widget/checkbox.c | 2 +- src/widget/combobox.c | 2 +- src/widget/entry.c | 2 +- src/widget/frame.c | 2 +- src/widget/image.c | 2 +- src/widget/label.c | 2 +- src/widget/listbox.c | 2 +- src/widget/menu.c | 2 +- src/widget/numberentry.c | 2 +- src/widget/progressbar.c | 2 +- src/widget/radiobox.c | 2 +- src/widget/scrollbar.c | 2 +- src/widget/separator.c | 2 +- src/widget/submenu.c | 2 +- src/widget/treeview.c | 2 +- src/widget/viewport.c | 2 +- src/widget/vulkan.c | 2 +- src/widget/window.c | 2 +- 31 files changed, 219 insertions(+), 179 deletions(-) create mode 100644 pl/ostype/ClassicMacOS.pl delete mode 100644 pl/ostype/ClassicMacOS68k.pl delete mode 100644 pl/ostype/ClassicMacOSPPC.pl diff --git a/.gitignore b/.gitignore index 21058b8..8535b65 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ compile_flags.txt *.bin *.rsrc *.finf +*.gdb diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cc7953..835ecdd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,24 +9,34 @@ include(GNUInstallDirs) set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}") set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) -option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" ON) -option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON) + option(MW_CLASSIC_THEME "Use classic theme" OFF) option(MW_BUILD_EXAMPLES "Build examples" OFF) option(MW_USE_STB_IMAGE "Use stb_image" ON) option(MW_USE_STB_TRUETYPE "Use stb_truetype" OFF) -option(MW_BUILD_SHARED "Build a shared library" ON) -option(MW_BUILD_STATIC "Build a static library" OFF) + +if(${CMAKE_SYSTEM_NAME} MATCHES Retro) + option(MW_BUILD_SHARED "Build a shared library" OFF) + option(MW_BUILD_STATIC "Build a static library" ON) + option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" OFF) + option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" OFF) +else() + option(MW_BUILD_SHARED "Build a shared library" ON) + option(MW_BUILD_STATIC "Build a static library" OFF) + option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" ON) + option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON) +endif() + option(MW_INSTALL_HEADERS "Install headers" ON) -if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin) - option(MW_USE_FREETYPE2 "Use FreeType 2" OFF) +if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin OR ${CMAKE_SYSTEM_NAME} MATCHES Retro) + option(MW_USE_FREETYPE2 "Use FreeType 2" OFF) else() - option(MW_USE_FREETYPE2 "Use FreeType 2" ON) + option(MW_USE_FREETYPE2 "Use FreeType 2" ON) endif() if(${CMAKE_SYSTEM_NAME} STREQUAL Linux) - option(MW_USE_WAYLAND "Enable Wayland backend" ON) + option(MW_USE_WAYLAND "Enable Wayland backend" ON) endif() file( @@ -39,83 +49,83 @@ list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c") list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c") if(NOT MW_USE_STB_IMAGE) - list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_image.c") + list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_image.c") endif() if(NOT MW_USE_STB_TRUETYPE) - list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_truetype.c") + list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_truetype.c") endif() if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD") - list(APPEND CMAKE_REQUIRED_INCLUDES "/usr/X11R7/include") - list(APPEND CMAKE_REQUIRED_INCLUDES "/usr/pkg/include") + list(APPEND CMAKE_REQUIRED_INCLUDES "/usr/X11R7/include") + list(APPEND CMAKE_REQUIRED_INCLUDES "/usr/pkg/include") endif() if(MW_TRY_OPENGL) - find_package(OpenGL) - if(OpenGL_FOUND) - set(MW_BUILD_OPENGL ON) - list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c") - if(APPLE) - list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl_cocoa.m") - endif() - message(STATUS "OpenGL widget has been enabled") - else() - message(WARNING "OpenGL widget has been disabled") + find_package(OpenGL) + if(OpenGL_FOUND) + set(MW_BUILD_OPENGL ON) + list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c") + if(APPLE) + list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl_cocoa.m") endif() + message(STATUS "OpenGL widget has been enabled") + else() + message(WARNING "OpenGL widget has been disabled") + endif() endif() if(MW_TRY_VULKAN) - check_include_files(vulkan/vulkan.h HAVE_VULKAN_VULKAN_H) - if(HAVE_VULKAN_VULKAN_H) - set(MW_BUILD_VULKAN ON) - list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c") - target_compile_definitions( + check_include_files(vulkan/vulkan.h HAVE_VULKAN_VULKAN_H) + if(HAVE_VULKAN_VULKAN_H) + set(MW_BUILD_VULKAN ON) + list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c") + target_compile_definitions( Mw PRIVATE MW_VULKAN ) - message(STATUS "Vulkan widget has been enabled") - else() - message(WARNING "Vulkan widget has been disabled") - endif() + message(STATUS "Vulkan widget has been enabled") + else() + message(WARNING "Vulkan widget has been disabled") + endif() endif() if(MW_BUILD_STATIC) - message(STATUS "Building Milsko as a static library") - add_library( + message(STATUS "Building Milsko as a static library") + add_library( Mw ${SOURCES} ) elseif(MW_BUILD_SHARED) - message(STATUS "Building Milsko as a shared library") - add_library( + message(STATUS "Building Milsko as a shared library") + add_library( Mw SHARED ${SOURCES} ) else() - message(ERROR "Must either build a shared library or a static library") + message(ERROR "Must either build a shared library or a static library") endif() if(MW_USE_STB_IMAGE) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE USE_STB_IMAGE ) else() - file( + file( GLOB IMAGE_SOURCES external/libjpeg/src/*.c external/libpng/src/*.c ) - target_sources( + target_sources( Mw PRIVATE ${MW_IMAGE_SOURCES} ) - target_include_directories( + target_include_directories( Mw PRIVATE external/libjpeg/include external/libpng/include @@ -123,7 +133,7 @@ else() endif() if(MW_USE_STB_TRUETYPE) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE USE_STB_TRUETYPE @@ -131,22 +141,22 @@ if(MW_USE_STB_TRUETYPE) endif() if(MW_USE_FREETYPE2) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE USE_FREETYPE2 ) - find_package(PkgConfig) - pkg_check_modules(FT2 REQUIRED freetype2) - list(APPEND INCLUDE_DIRS ${FT2_INCLUDE_DIRS}) - list(APPEND LIBRARY_DIRS ${FT2_LIBRARY_DIRS}) - list(APPEND LIBRARIES ${FT2_LIBRARIES}) + find_package(PkgConfig) + pkg_check_modules(FT2 REQUIRED freetype2) + list(APPEND INCLUDE_DIRS ${FT2_INCLUDE_DIRS}) + list(APPEND LIBRARY_DIRS ${FT2_LIBRARY_DIRS}) + list(APPEND LIBRARIES ${FT2_LIBRARIES}) endif() if(MW_USE_WAYLAND) - function(scan_wayland_protocol_core) - execute_process( + function(scan_wayland_protocol_core) + execute_process( COMMAND wayland-scanner private-code /usr/share/wayland/wayland.xml ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-core-protocol.c OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT ERROR_VARIABLE WAYLAND_SCANNER_ERROR @@ -154,12 +164,12 @@ if(MW_USE_WAYLAND) ECHO_ERROR_VARIABLE COMMAND_ECHO STDOUT ) - target_sources( + target_sources( Mw PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-core-protocol.c ) - execute_process( + execute_process( COMMAND wayland-scanner client-header /usr/share/wayland/wayland.xml ${CMAKE_CURRENT_SOURCE_DIR}/include/Mw/LowLevel/Wayland/wayland-core-protocol.h WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT @@ -168,11 +178,11 @@ if(MW_USE_WAYLAND) ECHO_ERROR_VARIABLE COMMAND_ECHO STDOUT ) - endfunction() + endfunction() - function(scan_wayland_protocol tier proto ver) - SET(proto_c ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-${proto}-protocol.c) - execute_process( + function(scan_wayland_protocol tier proto ver) + SET(proto_c ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-${proto}-protocol.c) + execute_process( COMMAND wayland-scanner private-code /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml ${proto_c} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT @@ -181,12 +191,12 @@ if(MW_USE_WAYLAND) ECHO_ERROR_VARIABLE COMMAND_ECHO STDOUT ) - target_sources( + target_sources( Mw PRIVATE ${proto_c} ) - execute_process( + execute_process( COMMAND wayland-scanner client-header /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml ${CMAKE_CURRENT_SOURCE_DIR}/include/Mw/LowLevel/Wayland/${proto}-client-protocol.h WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT @@ -195,49 +205,49 @@ if(MW_USE_WAYLAND) ECHO_ERROR_VARIABLE COMMAND_ECHO STDOUT ) - endfunction() + endfunction() - check_include_files(wayland-client.h HAVE_WL_H) - check_include_files(xkbcommon/xkbcommon.h HAVE_XKBCOMMON_H) - check_include_files(cairo/cairo.h HAVE_CAIRO_H) - if(HAVE_WL_H) - if(HAVE_XKBCOMMON_H) - if(HAVE_CAIRO_H) - scan_wayland_protocol_core() - scan_wayland_protocol("stable" "xdg-shell" "") - scan_wayland_protocol("stable" "viewporter" "") - scan_wayland_protocol("stable" "tablet" "-v2") - scan_wayland_protocol("staging" "xdg-toplevel-icon" "-v1") - scan_wayland_protocol("staging" "cursor-shape" "-v1") - scan_wayland_protocol("unstable" "xdg-decoration" "-unstable-v1") - scan_wayland_protocol("unstable" "primary-selection" "-unstable-v1") - scan_wayland_protocol("unstable" "pointer-constraints" "-unstable-v1") - scan_wayland_protocol("unstable" "relative-pointer" "-unstable-v1") + check_include_files(wayland-client.h HAVE_WL_H) + check_include_files(xkbcommon/xkbcommon.h HAVE_XKBCOMMON_H) + check_include_files(cairo/cairo.h HAVE_CAIRO_H) + if(HAVE_WL_H) + if(HAVE_XKBCOMMON_H) + if(HAVE_CAIRO_H) + scan_wayland_protocol_core() + scan_wayland_protocol("stable" "xdg-shell" "") + scan_wayland_protocol("stable" "viewporter" "") + scan_wayland_protocol("stable" "tablet" "-v2") + scan_wayland_protocol("staging" "xdg-toplevel-icon" "-v1") + scan_wayland_protocol("staging" "cursor-shape" "-v1") + scan_wayland_protocol("unstable" "xdg-decoration" "-unstable-v1") + scan_wayland_protocol("unstable" "primary-selection" "-unstable-v1") + scan_wayland_protocol("unstable" "pointer-constraints" "-unstable-v1") + scan_wayland_protocol("unstable" "relative-pointer" "-unstable-v1") - target_sources( + target_sources( Mw PRIVATE src/backend/wayland.c ) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE USE_WAYLAND ) - message(STATUS "Wayland backend has been enabled") - else() - message(WARNING "Wayland backend has been disabled") - endif() - else() - message(WARNING "Wayland backend has been disabled") - endif() - else() + message(STATUS "Wayland backend has been enabled") + else() message(WARNING "Wayland backend has been disabled") + endif() + else() + message(WARNING "Wayland backend has been disabled") endif() + else() + message(WARNING "Wayland backend has been disabled") + endif() endif() if(APPLE AND MW_BUILD_OPENGL) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE GL_SILENCE_DEPRECATION @@ -257,7 +267,7 @@ target_include_directories( ) if(MW_CLASSIC_THEME) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE USE_CLASSIC_THEME @@ -265,60 +275,78 @@ if(MW_CLASSIC_THEME) endif() if(CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_sources( + target_sources( Mw PRIVATE src/backend/gdi.c ) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE USE_GDI ) - list(APPEND LIBRARIES gdi32) - target_link_options( + list(APPEND LIBRARIES gdi32) + target_link_options( Mw PRIVATE -static-libgcc ) elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") - target_sources( + target_sources( Mw PRIVATE src/backend/cocoa.m ) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE USE_COCOA ) - list(APPEND LIBRARIES objc) - target_link_options( + list(APPEND LIBRARIES objc) + target_link_options( Mw PRIVATE -framework Cocoa ) -else() - find_package(PkgConfig) - pkg_check_modules(X11 REQUIRED x11) - pkg_check_modules(XRENDER REQUIRED xrender) +elseif(CMAKE_SYSTEM_NAME MATCHES "Retro") + target_sources( + Mw + PRIVATE + src/backend/classicmacos.c + ) + if(PLATFORM MATCHES retroppc) + endif() + if(PLATFORM MATCHES retroppc) + set_target_properties(Mw PROPERTIES COMPILE_FLAGS "-ffunction-sections -mcpu=601 -Os -Wall -Wextra -Wno-unused-parameter") + set_target_properties(Mw PROPERTIES LINK_FLAGS "-Wl,-gc-sections") + endif() - target_sources( + target_compile_definitions( + Mw + PRIVATE + CLASSIC_MAC_OS + ) +else() + find_package(PkgConfig) + pkg_check_modules(X11 REQUIRED x11) + pkg_check_modules(XRENDER REQUIRED xrender) + + target_sources( Mw PRIVATE src/backend/x11.c ) - target_compile_definitions( + target_compile_definitions( Mw PRIVATE USE_X11 ) - list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS} ${XRENDER_INCLUDE_DIRS}) - list(APPEND LIBRARY_DIRS ${X11_LIBRARY_DIRS} ${XRENDER_LIBRARY_DIRS}) - list(APPEND LIBRARIES ${X11_LIBRARIES} ${XRENDER_LIBRARIES} m) - if(CMAKE_SYSTEM_NAME STREQUAL "Linux") - list(APPEND LIBRARIES dl) - endif() + list(APPEND INCLUDE_DIRS ${X11_INCLUDE_DIRS} ${XRENDER_INCLUDE_DIRS}) + list(APPEND LIBRARY_DIRS ${X11_LIBRARY_DIRS} ${XRENDER_LIBRARY_DIRS}) + list(APPEND LIBRARIES ${X11_LIBRARIES} ${XRENDER_LIBRARIES} m) + if(CMAKE_SYSTEM_NAME STREQUAL "Linux") + list(APPEND LIBRARIES dl) + endif() endif() target_include_directories( @@ -338,14 +366,14 @@ target_link_libraries( ) if(MW_BUILD_VULKAN) - check_include_files(vulkan/vk_enum_string_helper.h HAS_VK_ENUM_STRING_HELPER) - if(HAS_VK_ENUM_STRING_HELPER) - target_compile_definitions( + check_include_files(vulkan/vk_enum_string_helper.h HAS_VK_ENUM_STRING_HELPER) + if(HAS_VK_ENUM_STRING_HELPER) + target_compile_definitions( Mw PRIVATE HAS_VK_ENUM_STRING_HELPER ) - endif() + endif() endif() target_compile_definitions( @@ -362,7 +390,7 @@ install( ) if(MW_INSTALL_HEADERS) - install( + install( DIRECTORY include/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" @@ -370,5 +398,5 @@ if(MW_INSTALL_HEADERS) endif() if(MW_BUILD_EXAMPLES) - add_subdirectory(examples) + add_subdirectory(examples) endif() diff --git a/configure b/configure index 1f3ee9e..a6e5941 100755 --- a/configure +++ b/configure @@ -46,6 +46,7 @@ param_set("shared", 1); param_set("static", 1); param_set("examples", 1); + my %features = ( "classic-theme" => "use classic theme", "stb-image" => "use stb_image, instead use libjpeg/libpng", @@ -131,16 +132,12 @@ foreach my $l (@ARGV) { } } -if($target ne "Darwin" and $target ne "ClassicMacOS68k" and $target ne "ClassicMacOSPPC") { +if($target ne "Darwin" and $target ne "ClassicMacOS") { param_set("freetype2", 1); param_set("stb-truetype", 0); } else { - if($target ne "ClassicMacOS68k" and $target ne "ClassicMacOSPPC"){ - param_set("freetype2", 0); - param_set("stb-truetype", 1); - } else { - param_set("stb-truetype", 0); - } + param_set("freetype2", 0); + param_set("stb-truetype", 0); } if($target eq "Linux") { @@ -289,7 +286,7 @@ if (param_get("examples")) { } if (grep(/^cocoa$/, @backends)) { print(OUT -" \$(CC) -L./src -I\$\(INCDIR) \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n" +" \$(CC) -L./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n" ); } else { @@ -304,16 +301,12 @@ if (param_get("examples")) { print(OUT " Rez -I ".$ENV{RETRO68_TOOLCHAIN_PATH}."/RIncludes ".$ENV{RETRO68_TOOLCHAIN_PATH}."/RIncludes/Retro68APPL.r -DCFRAG_NAME=\"example\" --data ${l}.pef --cc ${l}.dsk -t APPL\n" ); + } print(OUT "${s}${object_suffix}: ${s}.c\n"); print(OUT " \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n" ); - - - #print(OUT "Rez -I /path/to/Universal/RIncludes /path/to/libretro/RIncludes/Retro68APPL.r -DCFRAG_NAME="\"MyProgram\"" --data program.pef -o program.bin -t APPL"); - } - } } print(OUT "\n"); diff --git a/examples/basic/CMakeLists.txt b/examples/basic/CMakeLists.txt index ab58a5c..e69c4ae 100644 --- a/examples/basic/CMakeLists.txt +++ b/examples/basic/CMakeLists.txt @@ -1,22 +1,26 @@ file( - GLOB - EXAMPLES_BASIC_SOURCES - *.c + GLOB + EXAMPLES_BASIC_SOURCES + *.c ) foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES) - get_filename_component(TARGET ${PATH} NAME_WE) - add_executable(${TARGET} MACOSX_BUNDLE ${PATH}) - target_link_libraries( - ${TARGET} - PRIVATE - Mw - ) - if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") - target_link_libraries( - ${TARGET} - PRIVATE - m - ) - endif() + get_filename_component(TARGET ${PATH} NAME_WE) + if(CMAKE_SYSTEM_NAME MATCHES Retro) + add_application(${TARGET} ${PATH}) + else() + add_executable(${TARGET} MACOSX_BUNDLE ${PATH}) + endif() + target_link_libraries( + ${TARGET} + PRIVATE + Mw + ) + if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows") + target_link_libraries( + ${TARGET} + PRIVATE + m + ) + endif() endforeach() diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index a1a4691..2a293b0 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -106,6 +106,9 @@ MWDECL void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx); #ifdef USE_COCOA #include #endif +#ifdef CLASSIC_MAC_OS +#include +#endif union _MwLL { struct _MwLLCommon common; @@ -121,6 +124,9 @@ union _MwLL { #ifdef USE_COCOA struct _MwLLCocoa cocoa; #endif +#ifdef CLASSIC_MAC_OS + struct _MwLLClassicMacOS cmacos; +#endif }; union _MwLLColor { diff --git a/include/Mw/LowLevel/ClassicMacOS.h b/include/Mw/LowLevel/ClassicMacOS.h index 0165438..f377e4f 100644 --- a/include/Mw/LowLevel/ClassicMacOS.h +++ b/include/Mw/LowLevel/ClassicMacOS.h @@ -12,6 +12,10 @@ struct _MwLLClassicMacOS { struct _MwLLCommon common; + + WindowRef window; + EventRecord event; + Rect winRect; }; struct _MwLLClassicMacOSColor { diff --git a/pl/ostype/ClassicMacOS.pl b/pl/ostype/ClassicMacOS.pl new file mode 100644 index 0000000..751525f --- /dev/null +++ b/pl/ostype/ClassicMacOS.pl @@ -0,0 +1,10 @@ +use_backend("classicmacos"); + +print("Compiling for Classic Mac OS via ./configure currently outputs a broken executable and it only supports PowerPC. Help is wanted. In the mean time, use CMake.") + +$cc = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/powerpc-apple-macos-gcc"; +$ar = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/powerpc-apple-macos-ar"; +add_cflags("-DCLASSIC_MAC_OS"); +add_cflags("-DSTBI_NO_THREAD_LOCALS"); + +1; diff --git a/pl/ostype/ClassicMacOS68k.pl b/pl/ostype/ClassicMacOS68k.pl deleted file mode 100644 index c9ceba8..0000000 --- a/pl/ostype/ClassicMacOS68k.pl +++ /dev/null @@ -1,7 +0,0 @@ -use_backend("classicmacos"); - -$cc = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/m68k-apple-macos-gcc"; -$ar = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/m68k-apple-macos-ar"; -add_cflags("-DCLASSIC_MAC_OS"); - -1; diff --git a/pl/ostype/ClassicMacOSPPC.pl b/pl/ostype/ClassicMacOSPPC.pl deleted file mode 100644 index b2626d9..0000000 --- a/pl/ostype/ClassicMacOSPPC.pl +++ /dev/null @@ -1,7 +0,0 @@ -use_backend("classicmacos"); - -$cc = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/powerpc-apple-macos-gcc"; -$ar = $ENV{RETRO68_TOOLCHAIN_PATH}."/bin/powerpc-apple-macos-ar"; -add_cflags("-DCLASSIC_MAC_OS"); - -1; diff --git a/src/backend/classicmacos.c b/src/backend/classicmacos.c index 01a9d97..929c493 100644 --- a/src/backend/classicmacos.c +++ b/src/backend/classicmacos.c @@ -5,6 +5,15 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { MwLL r; + MwLLCreateCommon(r); + + SetRect(&r->cmacos.winRect, 100, 100, width, height); + + r->cmacos.window = NewCWindow(nil, &r->cmacos.winRect, (ConstStr255Param) "\p", true, + documentProc, (WindowPtr)(-1), true, 0); + + SetPort(r->cmacos.window); + return r; } @@ -59,8 +68,7 @@ static void MwLLFreeColorImpl(MwLLColor color) { } static int MwLLPendingImpl(MwLL handle) { - - return 0; + return GetNextEvent(everyEvent, &handle->cmacos.event); } static void MwLLNextEventImpl(MwLL handle) { diff --git a/src/dialog/filechooser.c b/src/dialog/filechooser.c index d5faa4b..c180276 100644 --- a/src/dialog/filechooser.c +++ b/src/dialog/filechooser.c @@ -383,7 +383,7 @@ static void layout(MwWidget handle) { MwNtext, "Cancel", NULL); - MwAddUserHandler(fc->cancel, MwNactivateHandler, cancel, NULL); + MwAddUserHandler(fc->cancel, MwNactivateHandler, filecancel, NULL); } else { MwVaApply(fc->cancel, MwNx, wx, diff --git a/src/widget/box.c b/src/widget/box.c index e96c008..6fb8935 100644 --- a/src/widget/box.c +++ b/src/widget/box.c @@ -135,7 +135,7 @@ static void children_update(MwWidget handle) { } MwClassRec MwBoxClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/button.c b/src/widget/button.c index 6653b54..7287f2a 100644 --- a/src/widget/button.c +++ b/src/widget/button.c @@ -93,7 +93,7 @@ static void prop_change(MwWidget handle, const char* key) { } MwClassRec MwButtonClassRec = { - create, /* create */ + wcreate, /* create */ NULL, /* destroy */ draw, /* draw */ click, /* click */ diff --git a/src/widget/checkbox.c b/src/widget/checkbox.c index 56b8f11..2301aa0 100644 --- a/src/widget/checkbox.c +++ b/src/widget/checkbox.c @@ -38,7 +38,7 @@ static void prop_change(MwWidget handle, const char* key) { } MwClassRec MwCheckBoxClassRec = { - create, /* create */ + wcreate, /* create */ NULL, /* destroy */ draw, /* draw */ click, /* click */ diff --git a/src/widget/combobox.c b/src/widget/combobox.c index 988bb24..c061512 100644 --- a/src/widget/combobox.c +++ b/src/widget/combobox.c @@ -189,7 +189,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v } MwClassRec MwComboBoxClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ click, /* click */ diff --git a/src/widget/entry.c b/src/widget/entry.c index eca5e5c..4d1cc73 100644 --- a/src/widget/entry.c +++ b/src/widget/entry.c @@ -172,7 +172,7 @@ static void clipboard(MwWidget handle, const char* data) { } MwClassRec MwEntryClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/frame.c b/src/widget/frame.c index 6f9d881..0cc0c41 100644 --- a/src/widget/frame.c +++ b/src/widget/frame.c @@ -46,7 +46,7 @@ static void prop_change(MwWidget handle, const char* key) { } MwClassRec MwFrameClassRec = { - create, /* create */ + wcreate, /* create */ NULL, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/image.c b/src/widget/image.c index 90f3cbe..791570e 100644 --- a/src/widget/image.c +++ b/src/widget/image.c @@ -42,7 +42,7 @@ static void prop_change(MwWidget handle, const char* key) { } MwClassRec MwImageClassRec = { - create, /* create */ + wcreate, /* create */ NULL, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/label.c b/src/widget/label.c index 3c88eb9..98a0d5f 100644 --- a/src/widget/label.c +++ b/src/widget/label.c @@ -360,7 +360,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v } MwClassRec MwLabelClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/listbox.c b/src/widget/listbox.c index 7f4ef0b..98c86cf 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -595,7 +595,7 @@ static void tick(MwWidget handle) { } MwClassRec MwListBoxClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/menu.c b/src/widget/menu.c index b365278..b661086 100644 --- a/src/widget/menu.c +++ b/src/widget/menu.c @@ -189,7 +189,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v } MwClassRec MwMenuClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/numberentry.c b/src/widget/numberentry.c index 96860f8..05d590f 100644 --- a/src/widget/numberentry.c +++ b/src/widget/numberentry.c @@ -128,7 +128,7 @@ static void prop_change(MwWidget handle, const char* prop) { } MwClassRec MwNumberEntryClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/progressbar.c b/src/widget/progressbar.c index 2a032b0..dedd7a9 100644 --- a/src/widget/progressbar.c +++ b/src/widget/progressbar.c @@ -46,7 +46,7 @@ static void prop_change(MwWidget handle, const char* key) { } MwClassRec MwProgressBarClassRec = { - create, /* create */ + wcreate, /* create */ NULL, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/radiobox.c b/src/widget/radiobox.c index 2416b71..1342232 100644 --- a/src/widget/radiobox.c +++ b/src/widget/radiobox.c @@ -47,7 +47,7 @@ static void prop_change(MwWidget handle, const char* key) { } MwClassRec MwRadioBoxClassRec = { - create, /* create */ + wcreate, /* create */ NULL, /* destroy */ draw, /* draw */ click, /* click */ diff --git a/src/widget/scrollbar.c b/src/widget/scrollbar.c index e11ba6a..a1df9b2 100644 --- a/src/widget/scrollbar.c +++ b/src/widget/scrollbar.c @@ -257,7 +257,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v } MwClassRec MwScrollBarClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/separator.c b/src/widget/separator.c index d7d6aae..15919d0 100644 --- a/src/widget/separator.c +++ b/src/widget/separator.c @@ -35,7 +35,7 @@ static void prop_change(MwWidget handle, const char* key) { } MwClassRec MwSeparatorClassRec = { - create, /* create */ + wcreate, /* create */ NULL, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/submenu.c b/src/widget/submenu.c index a71d65b..f14d6d5 100644 --- a/src/widget/submenu.c +++ b/src/widget/submenu.c @@ -241,7 +241,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v } MwClassRec MwSubMenuClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ click, /* click */ diff --git a/src/widget/treeview.c b/src/widget/treeview.c index bd3067c..9d33206 100644 --- a/src/widget/treeview.c +++ b/src/widget/treeview.c @@ -481,7 +481,7 @@ static void tick(MwWidget handle) { } MwClassRec MwTreeViewClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/viewport.c b/src/widget/viewport.c index 38ef899..f05b18d 100644 --- a/src/widget/viewport.c +++ b/src/widget/viewport.c @@ -176,7 +176,7 @@ static void tick(MwWidget handle) { } MwClassRec MwViewportClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ draw, /* draw */ NULL, /* click */ diff --git a/src/widget/vulkan.c b/src/widget/vulkan.c index ab73fca..7cb3312 100644 --- a/src/widget/vulkan.c +++ b/src/widget/vulkan.c @@ -556,7 +556,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v } MwClassRec MwVulkanClassRec = { - create, /* create */ + wcreate, /* create */ destroy, /* destroy */ NULL, /* draw */ NULL, /* click */ diff --git a/src/widget/window.c b/src/widget/window.c index b4aaa8d..2b596b5 100644 --- a/src/widget/window.c +++ b/src/widget/window.c @@ -44,7 +44,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v } } MwClassRec MwWindowClassRec = { - create, /* create */ + wcreate, /* create */ NULL, /* destroy */ draw, /* draw */ NULL, /* click */