diff --git a/CMakeLists.txt b/CMakeLists.txt index 5441692..b9e90d0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -329,14 +329,12 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows" OR CMAKE_SYSTEM_NAME STREQUAL "MSYS") PRIVATE USE_GDI ) - list(APPEND LIBRARIES gdi32 ole32 uuid) - if(NOT MSVC) + list(APPEND LIBRARIES gdi32 winmm) target_link_options( Mw PRIVATE -static-libgcc ) - endif() elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") # target_sources( # Mw @@ -466,14 +464,11 @@ if(MW_BUILD_VULKAN) ) endif() - check_include_files(vulkan/VULKAN.h HAS_VK_HEADER) - if(HAS_VK_HEADER) target_compile_definitions( Mw PRIVATE MW_VULKAN ) - endif() endif() target_compile_definitions( diff --git a/NTMakefile b/NTMakefile index 63a4a2c..a3fc76a 100644 --- a/NTMakefile +++ b/NTMakefile @@ -1,7 +1,7 @@ CC = cl /TC /c /nologo LD = link /nologo -MW_CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /D_MILSKO_BUILD /DUSE_GDI /DUSE_STB_IMAGE /DSTBI_NO_SIMD /DUSE_GDI_TEXT /DMW_OPENGL +MW_CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /D_MILSKO_BUILD /DUSE_GDI /DUSE_STB_IMAGE /DSTBI_NO_SIMD /DUSE_GDI_TEXT MW_LDFLAGS = /DLL EXE_CFLAGS = /Iinclude EXE_LDFLAGS = @@ -321,7 +321,7 @@ examples\gldemos\tripaint.obj: examples/gldemos/tripaint.c src\Mw.dll: external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj - $(LD) $(MW_LDFLAGS) /OUT:$@ external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib ole32.lib uuid.lib user32.lib advapi32.lib + $(LD) $(MW_LDFLAGS) /OUT:$@ external\libz\src\adler32.obj external\libz\src\compress.obj external\libz\src\crc32.obj external\libz\src\deflate.obj external\libz\src\gzclose.obj external\libz\src\gzlib.obj external\libz\src\gzread.obj external\libz\src\gzwrite.obj external\libz\src\infback.obj external\libz\src\inffast.obj external\libz\src\inflate.obj external\libz\src\inftrees.obj external\libz\src\trees.obj external\libz\src\uncompr.obj external\libz\src\zutil.obj external\stb_ds.obj external\stb_image.obj external\stb_truetype.obj src\abstract\charset.obj src\abstract\directory.obj src\abstract\dynamic.obj src\abstract\time.obj src\backend\gdi.obj src\color.obj src\core.obj src\cursor\arrow.obj src\cursor\cross.obj src\cursor\default.obj src\cursor\hidden.obj src\cursor\text.obj src\default.obj src\dialog\colorpicker.obj src\dialog\directorychooser.obj src\dialog\filechooser.obj src\dialog\messagebox.obj src\draw.obj src\icon\back.obj src\icon\clock.obj src\icon\computer.obj src\icon\directory.obj src\icon\down.obj src\icon\error.obj src\icon\file.obj src\icon\forward.obj src\icon\info.obj src\icon\left.obj src\icon\news.obj src\icon\note.obj src\icon\right.obj src\icon\search.obj src\icon\up.obj src\icon\warning.obj src\lowlevel.obj src\string.obj src\text\font\boldfont.obj src\text\font\boldmonottf.obj src\text\font\boldttf.obj src\text\font\font.obj src\text\font\monottf.obj src\text\font\ttf.obj src\text\ft2.obj src\text\gdi.obj src\text\stbtt.obj src\text\text.obj src\truetype.obj src\unicode.obj src\widget\box.obj src\widget\button.obj src\widget\calendar.obj src\widget\checkbox.obj src\widget\combobox.obj src\widget\entry.obj src\widget\frame.obj src\widget\image.obj src\widget\label.obj src\widget\listbox.obj src\widget\menu.obj src\widget\numberentry.obj src\widget\opengl.obj src\widget\progressbar.obj src\widget\radiobox.obj src\widget\scrollbar.obj src\widget\separator.obj src\widget\submenu.obj src\widget\subwindow.obj src\widget\tab.obj src\widget\table.obj src\widget\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib winmm.lib user32.lib advapi32.lib .c.obj: diff --git a/WatMakefile b/WatMakefile index 4533f3c..afeb560 100644 --- a/WatMakefile +++ b/WatMakefile @@ -1,7 +1,7 @@ CC = wcc386 -bt=nt -q LD = wlink option quiet -MW_CFLAGS = -bd -i=include -i=external/libz/include -d_MILSKO -d_MILSKO_BUILD -dUSE_GDI -dUSE_STB_IMAGE -dSTBI_NO_SIMD -dUSE_GDI_TEXT -dMW_OPENGL +MW_CFLAGS = -bd -i=include -i=external/libz/include -d_MILSKO -d_MILSKO_BUILD -dUSE_GDI -dUSE_STB_IMAGE -dSTBI_NO_SIMD -dUSE_GDI_TEXT MW_LDFLAGS = system nt_dll EXE_CFLAGS = -i=include EXE_LDFLAGS = system nt @@ -320,7 +320,7 @@ examples/gldemos/tripaint.obj: examples/gldemos/tripaint.c src/Mw.dll: external/libz/src/adler32.obj external/libz/src/compress.obj external/libz/src/crc32.obj external/libz/src/deflate.obj external/libz/src/gzclose.obj external/libz/src/gzlib.obj external/libz/src/gzread.obj external/libz/src/gzwrite.obj external/libz/src/infback.obj external/libz/src/inffast.obj external/libz/src/inflate.obj external/libz/src/inftrees.obj external/libz/src/trees.obj external/libz/src/uncompr.obj external/libz/src/zutil.obj external/stb_ds.obj external/stb_image.obj external/stb_truetype.obj src/abstract/charset.obj src/abstract/directory.obj src/abstract/dynamic.obj src/abstract/time.obj src/backend/gdi.obj src/color.obj src/core.obj src/cursor/arrow.obj src/cursor/cross.obj src/cursor/default.obj src/cursor/hidden.obj src/cursor/text.obj src/default.obj src/dialog/colorpicker.obj src/dialog/directorychooser.obj src/dialog/filechooser.obj src/dialog/messagebox.obj src/draw.obj src/icon/back.obj src/icon/clock.obj src/icon/computer.obj src/icon/directory.obj src/icon/down.obj src/icon/error.obj src/icon/file.obj src/icon/forward.obj src/icon/info.obj src/icon/left.obj src/icon/news.obj src/icon/note.obj src/icon/right.obj src/icon/search.obj src/icon/up.obj src/icon/warning.obj src/lowlevel.obj src/string.obj src/text/font/boldfont.obj src/text/font/boldmonottf.obj src/text/font/boldttf.obj src/text/font/font.obj src/text/font/monottf.obj src/text/font/ttf.obj src/text/ft2.obj src/text/gdi.obj src/text/stbtt.obj src/text/text.obj src/truetype.obj src/unicode.obj src/widget/box.obj src/widget/button.obj src/widget/calendar.obj src/widget/checkbox.obj src/widget/combobox.obj src/widget/entry.obj src/widget/frame.obj src/widget/image.obj src/widget/label.obj src/widget/listbox.obj src/widget/menu.obj src/widget/numberentry.obj src/widget/opengl.obj src/widget/progressbar.obj src/widget/radiobox.obj src/widget/scrollbar.obj src/widget/separator.obj src/widget/submenu.obj src/widget/subwindow.obj src/widget/tab.obj src/widget/table.obj src/widget/treeview.obj src/widget/viewport.obj src/widget/window.obj - $(LD) $(MW_LDFLAGS) option implib=src/Mw.lib name $@ file external/libz/src/adler32.obj file external/libz/src/compress.obj file external/libz/src/crc32.obj file external/libz/src/deflate.obj file external/libz/src/gzclose.obj file external/libz/src/gzlib.obj file external/libz/src/gzread.obj file external/libz/src/gzwrite.obj file external/libz/src/infback.obj file external/libz/src/inffast.obj file external/libz/src/inflate.obj file external/libz/src/inftrees.obj file external/libz/src/trees.obj file external/libz/src/uncompr.obj file external/libz/src/zutil.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/abstract/charset.obj file src/abstract/directory.obj file src/abstract/dynamic.obj file src/abstract/time.obj file src/backend/gdi.obj file src/color.obj file src/core.obj file src/cursor/arrow.obj file src/cursor/cross.obj file src/cursor/default.obj file src/cursor/hidden.obj file src/cursor/text.obj file src/default.obj file src/dialog/colorpicker.obj file src/dialog/directorychooser.obj file src/dialog/filechooser.obj file src/dialog/messagebox.obj file src/draw.obj file src/icon/back.obj file src/icon/clock.obj file src/icon/computer.obj file src/icon/directory.obj file src/icon/down.obj file src/icon/error.obj file src/icon/file.obj file src/icon/forward.obj file src/icon/info.obj file src/icon/left.obj file src/icon/news.obj file src/icon/note.obj file src/icon/right.obj file src/icon/search.obj file src/icon/up.obj file src/icon/warning.obj file src/lowlevel.obj file src/string.obj file src/text/font/boldfont.obj file src/text/font/boldmonottf.obj file src/text/font/boldttf.obj file src/text/font/font.obj file src/text/font/monottf.obj file src/text/font/ttf.obj file src/text/ft2.obj file src/text/gdi.obj file src/text/stbtt.obj file src/text/text.obj file src/truetype.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.obj file src/widget/calendar.obj file src/widget/checkbox.obj file src/widget/combobox.obj file src/widget/entry.obj file src/widget/frame.obj file src/widget/image.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/menu.obj file src/widget/numberentry.obj file src/widget/opengl.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/widget/scrollbar.obj file src/widget/separator.obj file src/widget/submenu.obj file src/widget/subwindow.obj file src/widget/tab.obj file src/widget/table.obj file src/widget/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library ole32.lib library uuid.lib library user32.lib library advapi32.lib + $(LD) $(MW_LDFLAGS) option implib=src/Mw.lib name $@ file external/libz/src/adler32.obj file external/libz/src/compress.obj file external/libz/src/crc32.obj file external/libz/src/deflate.obj file external/libz/src/gzclose.obj file external/libz/src/gzlib.obj file external/libz/src/gzread.obj file external/libz/src/gzwrite.obj file external/libz/src/infback.obj file external/libz/src/inffast.obj file external/libz/src/inflate.obj file external/libz/src/inftrees.obj file external/libz/src/trees.obj file external/libz/src/uncompr.obj file external/libz/src/zutil.obj file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.obj file src/abstract/charset.obj file src/abstract/directory.obj file src/abstract/dynamic.obj file src/abstract/time.obj file src/backend/gdi.obj file src/color.obj file src/core.obj file src/cursor/arrow.obj file src/cursor/cross.obj file src/cursor/default.obj file src/cursor/hidden.obj file src/cursor/text.obj file src/default.obj file src/dialog/colorpicker.obj file src/dialog/directorychooser.obj file src/dialog/filechooser.obj file src/dialog/messagebox.obj file src/draw.obj file src/icon/back.obj file src/icon/clock.obj file src/icon/computer.obj file src/icon/directory.obj file src/icon/down.obj file src/icon/error.obj file src/icon/file.obj file src/icon/forward.obj file src/icon/info.obj file src/icon/left.obj file src/icon/news.obj file src/icon/note.obj file src/icon/right.obj file src/icon/search.obj file src/icon/up.obj file src/icon/warning.obj file src/lowlevel.obj file src/string.obj file src/text/font/boldfont.obj file src/text/font/boldmonottf.obj file src/text/font/boldttf.obj file src/text/font/font.obj file src/text/font/monottf.obj file src/text/font/ttf.obj file src/text/ft2.obj file src/text/gdi.obj file src/text/stbtt.obj file src/text/text.obj file src/truetype.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.obj file src/widget/calendar.obj file src/widget/checkbox.obj file src/widget/combobox.obj file src/widget/entry.obj file src/widget/frame.obj file src/widget/image.obj file src/widget/label.obj file src/widget/listbox.obj file src/widget/menu.obj file src/widget/numberentry.obj file src/widget/opengl.obj file src/widget/progressbar.obj file src/widget/radiobox.obj file src/widget/scrollbar.obj file src/widget/separator.obj file src/widget/submenu.obj file src/widget/subwindow.obj file src/widget/tab.obj file src/widget/table.obj file src/widget/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library winmm.lib library user32.lib library advapi32.lib diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index 6647672..a2be271 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -205,7 +205,6 @@ struct _MwLLHandler { void (*focus_out)(MwLL handle, void* data); void (*clipboard)(MwLL handle, void* data); void (*dark_theme)(MwLL handle, void* data); - void (*drag_and_drop)(MwLL handle, void* data); }; struct _MwLLTextDispatchTable { @@ -316,12 +315,6 @@ MWDECL void (*MwLLGetClipboard)(MwLL handle, int clipboard_type); MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point); MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect); -/*! - * @brief Setup drag and drop capabilities, should the user request it with MwNacceptsDnD - * @param handle Handle - */ -MWDECL void (*MwLLSetupDragAndDrop)(MwLL handle); - /*! * @brief Set any extra parameters for dark theme * @param handle Handle @@ -363,12 +356,6 @@ MWDECL int (*MwFLTextHeightWithText)(MwFLFont ttf, const char* text); MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px); MWDECL void (*MwFLFontFree)(void* handle); -#ifdef _WIN32 -MWDECL void *MwLL_winmmLib; -MWDECL long (__stdcall* MwLL_PFN_timeGetTime)(void); -MWDECL unsigned int (__stdcall* MwLL_PFN_timeBeginPeriod)(unsigned int period); -#endif - #ifdef __cplusplus } #endif diff --git a/include/Mw/LowLevel/GDI.h b/include/Mw/LowLevel/GDI.h index d2e2473..e505b0a 100644 --- a/include/Mw/LowLevel/GDI.h +++ b/include/Mw/LowLevel/GDI.h @@ -34,7 +34,8 @@ struct _MwLLGDI { struct _MwLLGDIColor { struct _MwLLCommonColor common; - HBRUSH brush; + COLORREF color; + HBRUSH brush; }; struct _MwLLGDIPixmap { diff --git a/include/Mw/StringDefs.h b/include/Mw/StringDefs.h index 6ad4e46..b95fe93 100644 --- a/include/Mw/StringDefs.h +++ b/include/Mw/StringDefs.h @@ -53,7 +53,6 @@ #define MwNcolumnSpan "IcolumnSpan" #define MwNrowSpan "IrowSpan" #define MwNdisabled "Idisabled" -#define MwNacceptsDnD "IacceptsDnD" #define MwNtitle "Stitle" #define MwNtext "Stext" @@ -99,6 +98,5 @@ #define MwNdrawHandler "Cdraw" #define MwNclipboardHandler "Cclipboard" #define MwNdarkThemeHandler "CdarkTheme" -#define MwNdragAndDropHandler "CdragAndDrop" #endif diff --git a/include/Mw/TypeDefs.h b/include/Mw/TypeDefs.h index ad072a3..5989e1b 100644 --- a/include/Mw/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -274,7 +274,7 @@ struct _MwClass { MwHandlerChildrenProp children_prop_change; MwHandlerClipboardReceived clipboard; MwHandlerProps props_change; - MwHandler drag_and_drop; + void* reserved1; void* reserved2; void* reserved3; }; diff --git a/pl/ostype/Windows.pl b/pl/ostype/Windows.pl index e2ed1ab..f79469f 100644 --- a/pl/ostype/Windows.pl +++ b/pl/ostype/Windows.pl @@ -4,7 +4,6 @@ $executable_suffix = ".exe"; $math = ""; add_ldflags("-Wl,--out-implib,src/libMw.dll.a -static-libgcc"); use_backend("gdi"); -add_libs("-lole32"); -add_libs("-luuid"); +add_libs("-lwinmm"); 1; diff --git a/src/abstract/directory.c b/src/abstract/directory.c index ddf10e1..ac5a382 100644 --- a/src/abstract/directory.c +++ b/src/abstract/directory.c @@ -19,19 +19,15 @@ typedef struct dir { void* MwDirectoryOpen(const char* path) { dir_t* dir = malloc(sizeof(*dir)); - char * p; - if(!dir) { - printf("Out Of Memory\n"); - return NULL; - } #ifdef _WIN32 - p = MwStringDuplicate(path); + char* p = malloc(strlen(path) + 2 + 1); + strcpy(p, path); if(strchr(path, '/') != NULL) { - MwStringConcat(p, "/"); + strcat(p, "/"); } else { - MwStringConcat(p, "\\"); + strcat(p, "\\"); } - MwStringConcat(p, "*"); + strcat(p, "*"); if((dir->hFind = FindFirstFile(p, &dir->ffd)) == INVALID_HANDLE_VALUE) { free(p); free(dir); @@ -70,19 +66,8 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) { dir_t* dir = handle; MwDirectoryEntry* entry = malloc(sizeof(*entry)); #ifdef _WIN32 - ULARGE_INTEGER* l; -#elif defined(CLASSIC_MAC_OS) -#else - struct dirent* d; - struct stat s; - char* p; -#endif - - if(!entry) { - printf("Out Of Memory\n"); - return NULL; - } -#ifdef _WIN32 + ULARGE_INTEGER* l; + if(!dir->next) return NULL; entry->name = MwStringDuplicate(dir->ffd.cFileName); @@ -106,6 +91,9 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) { #elif defined(CLASSIC_MAC_OS) /* todo */ #else + struct dirent* d; + struct stat s; + char* p; if((d = readdir(dir->dir)) == NULL) { free(entry); return NULL; @@ -182,8 +170,8 @@ static void MwDirectoryJoinSingle(char* target, char* p) { b[0] = DIRSEP; b[1] = 0; - MwStringConcat(target, b); - MwStringConcat(target, p); + strcat(target, b); + strcat(target, p); } for(i = strlen(target) - 1; i >= 0; i--) { @@ -199,16 +187,17 @@ static void MwDirectoryJoinSingle(char* target, char* p) { b[0] = DIRSEP; b[1] = 0; - MwStringConcat(target, b); + strcat(target, b); } } char* MwDirectoryJoin(char* a, char* b) { - char* p = MwStringDuplicate(a); + char* p = malloc(strlen(a) + 1 + strlen(b) + 1); char* bdup = MwStringDuplicate(b); char* b2 = bdup; int i; + strcpy(p, a); for(i = strlen(p) - 1; i >= 0; i--) { if(p[i] == DIRSEP) { p[i] = 0; diff --git a/src/abstract/time.c b/src/abstract/time.c index 892cd32..59e9774 100644 --- a/src/abstract/time.c +++ b/src/abstract/time.c @@ -2,7 +2,7 @@ #if defined(_WIN32) long MwTimeGetTick(void) { - return MwLL_PFN_timeGetTime(); + return timeGetTime(); } void MwTimeSleep(int ms) { diff --git a/src/backend/cairo.c b/src/backend/cairo.c index 65380fb..0c26ff3 100644 --- a/src/backend/cairo.c +++ b/src/backend/cairo.c @@ -255,7 +255,6 @@ static MwBool MwLLDoModernImpl(MwLL handle) { } static void MwLLRaiseImpl(MwLL handle) {} static void MwLLClipImpl(MwLL handle, MwRect* rect) {} -static void MwLLSetupDragAndDropImpl(MwLL handle) {} static int MwLLCairoCallInitImpl(void) { if(cairo_load_funcs() != 0) { return 1; diff --git a/src/backend/call.c b/src/backend/call.c index 0deffb4..f84247f 100644 --- a/src/backend/call.c +++ b/src/backend/call.c @@ -52,9 +52,8 @@ MwLLSetClipboard = MwLLSetClipboardImpl; \ MwLLGetClipboard = MwLLGetClipboardImpl; \ \ - MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \ - MwLLGetScreenSize = MwLLGetScreenSizeImpl; \ - MwLLSetupDragAndDrop = MwLLSetupDragAndDropImpl; \ + MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \ + MwLLGetScreenSize = MwLLGetScreenSizeImpl; \ \ MwLLSetDarkTheme = MwLLSetDarkThemeImpl; \ MwLLDoModern = MwLLDoModernImpl; \ diff --git a/src/backend/classicmacos.c b/src/backend/classicmacos.c index f063551..d3da454 100644 --- a/src/backend/classicmacos.c +++ b/src/backend/classicmacos.c @@ -347,10 +347,6 @@ static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) { static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { } -static void MwLLSetupDragAndDropImpl(MwLL handle) { - (void)handle; -} - static void MwLLBeginStateChangeImpl(MwLL handle) { MwLLShow(handle, 0); } diff --git a/src/backend/cocoa.m b/src/backend/cocoa.m index 85b8b5b..e07eb64 100644 --- a/src/backend/cocoa.m +++ b/src/backend/cocoa.m @@ -1146,10 +1146,6 @@ static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { rect->height = [screen frame].size.height; } -static void MwLLSetupDragAndDropImpl(MwLL handle) { - (void)handle; -} - static void MwLLBeginStateChangeImpl(MwLL handle) { MwLLShow(handle, 0); } diff --git a/src/backend/gdi.c b/src/backend/gdi.c index eace1d3..acc341e 100644 --- a/src/backend/gdi.c +++ b/src/backend/gdi.c @@ -1,7 +1,5 @@ #include -#include "../../external/stb_ds.h" - typedef struct userdata { MwLL ll; POINT min; @@ -12,14 +10,8 @@ typedef struct userdata { static struct symtbl { void* lib_dwmapi; - void* shell32lib; - MwBool has_drag_and_drop; HRESULT(WINAPI* DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute); - - UINT(WINAPI* DragQueryFileW)(HDROP hDrop, UINT iFile, LPWSTR lpszFile, UINT cch); - void (*DragAcceptFiles)(HWND hWnd, BOOL fAccept); - void (*DragFinish)(HDROP hDrop); } wsymtbl; static int is_plgblt_reliable = 0; @@ -76,8 +68,6 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { if(u == NULL) return DefWindowProc(hWnd, msg, wp, lp); switch(msg) { - case WM_INITDIALOG: - return TRUE; case WM_PAINT: { PAINTSTRUCT ps; @@ -168,27 +158,6 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { MwLLDispatch(u->ll, up, &p); break; } - case WM_DROPFILES: - { - HDROP hDrop = (HDROP)wp; - UINT count; - UINT i; - - count = wsymtbl.DragQueryFileW(hDrop, 0xFFFFFFFF, NULL, 0); - - for(i = 0; i < count; i++) { - wchar_t wpath[MAX_PATH]; - char path[MAX_PATH]; - wsymtbl.DragQueryFileW(hDrop, i, wpath, MAX_PATH); - - memset(path, 0, sizeof(path)); - WideCharToMultiByte(CP_UTF8, 0, wpath, -1, path, sizeof(path) - 1, NULL, NULL); - - MwLLDispatch(u->ll, drag_and_drop, path); - } - wsymtbl.DragFinish(hDrop); - break; - } case WM_MOUSEMOVE: { MwPoint p; @@ -218,7 +187,6 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { SetCursorPos(p.x, p.y); } - break; } case WM_SIZE: @@ -397,11 +365,6 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { userdata_t* u = malloc(sizeof(*u)); WNDCLASSEX wc; - if(!r || !u) { - printf("Out Of Memory\n"); - return NULL; - } - memset(&wc, 0, sizeof(wc)); wc.cbSize = sizeof(WNDCLASSEX); wc.style = CS_HREDRAW | CS_VREDRAW; @@ -487,11 +450,6 @@ static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLL HPEN pen = CreatePen(PS_NULL, 0, RGB(0, 0, 0)); int i; - if(!p) { - printf("Out Of Memory\n"); - return; - } - for(i = 0; i < points_count; i++) { p[i].x = points[i].x; p[i].y = points[i].y; @@ -526,11 +484,6 @@ static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) { static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) { MwLLColor c = malloc(sizeof(*c)); - if(!c) { - printf("Out Of Memory\n"); - return NULL; - } - c->gdi.brush = NULL; MwLLColorUpdate(handle, c, r, g, b); @@ -539,8 +492,7 @@ static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) { } static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) { - HDC dc = GetDC(handle->gdi.hWnd); - COLORREF color; + HDC dc = GetDC(handle->gdi.hWnd); if(r > 255) r = 255; if(g > 255) g = 255; @@ -549,10 +501,9 @@ static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) { if(g < 0) g = 0; if(b < 0) b = 0; - color = GetNearestColor(dc, RGB(r, g, b)); - if(c->gdi.brush != NULL) DeleteObject(c->gdi.brush); - c->gdi.brush = CreateSolidBrush(color); + c->gdi.color = GetNearestColor(dc, RGB(r, g, b)); + c->gdi.brush = CreateSolidBrush(c->gdi.color); c->common.red = r; c->common.green = g; c->common.blue = b; @@ -608,20 +559,10 @@ static void MwLLNextEventImpl(MwLL handle) { if(handle->gdi.get_clipboard) { HGLOBAL hg; if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) { - int sz = GlobalSize(hg); - char* txt = malloc(sz); + char* txt = malloc(GlobalSize(hg)); char* clp = GlobalLock(hg); - if(!txt || !clp) { - printf("Out of Memory\n"); - return; - } - -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - strcpy_s(txt, sz, clp); -#else strcpy(txt, clp); -#endif GlobalUnlock(hg); CloseClipboard(); @@ -638,11 +579,10 @@ static void MwLLNextEventImpl(MwLL handle) { handle->gdi.get_darktheme = 0; } - while(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { - if(GetMessage(&msg, NULL, 0, 0)) { - TranslateMessage(&msg); - DispatchMessage(&msg); - } + while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) { + GetMessage(&msg, handle->gdi.hWnd, 0, 0); + TranslateMessage(&msg); + DispatchMessage(&msg); } } @@ -651,17 +591,7 @@ static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int wid HDC dc = GetDC(handle->gdi.hWnd); BITMAPINFOHEADER bmih; - if(!r) { - printf("Out Of Memory\n"); - return NULL; - } - r->common.raw = malloc(width * height * 4); - if(!r->common.raw) { - printf("Out Of Memory\n"); - return NULL; - } - memcpy(r->common.raw, data, 4 * width * height); r->common.width = width; @@ -701,12 +631,6 @@ static void MwLLPixmapUpdateImpl(MwLLPixmap r) { words = malloc(w * r->common.height); words2 = malloc(w * r->common.height); - - if(!words || !words2) { - printf("Out Of Memory\n"); - return; - } - memset(words, 0, w * r->common.height); memset(words2, 0, w * r->common.height); for(y = 0; y < r->common.height; y++) { @@ -958,30 +882,12 @@ static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_ty (void)clipboard_type; if(OpenClipboard(handle->gdi.hWnd) != 0) { char* lock; - int sz = strlen(text) + 1; EmptyClipboard(); - hg = GlobalAlloc(GHND | GMEM_SHARE, sz); - - if(!hg) { - printf("Out of Memory\n"); - return; - } + hg = GlobalAlloc(GHND | GMEM_SHARE, strlen(text) + 1); lock = GlobalLock(hg); - - if(!lock) { - printf("Out Of Memory\n"); - GlobalUnlock(hg); - CloseClipboard(); - return; - } - -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - strcpy_s(lock, sz, text); -#else strcpy(lock, text); -#endif GlobalUnlock(hg); SetClipboardData(CF_TEXT, hg); @@ -1088,10 +994,6 @@ static void MwLLClipImpl(MwLL handle, MwRect* rect) { } } -static void MwLLSetupDragAndDropImpl(MwLL handle) { - wsymtbl.DragAcceptFiles(handle->gdi.hWnd, TRUE); -} - static int MwLLGDICallInitImpl(void) { void* ntdll; @@ -1107,28 +1009,6 @@ static int MwLLGDICallInitImpl(void) { is_plgblt_reliable = 1; } - wsymtbl.has_drag_and_drop = MwFALSE; - - /* Drag and Drop initialization */ - { - if(!(wsymtbl.shell32lib = LoadLibrary("shell32.dll"))) { - goto dnd_error; - }; - -#define SHELL32_FUNC(x) \ - if(!(wsymtbl.x = (void*)GetProcAddress(wsymtbl.shell32lib, #x))) { \ - printf(#x "not found, drag and drop will not be supported"); \ - goto dnd_error; \ - } - - SHELL32_FUNC(DragQueryFileW); - SHELL32_FUNC(DragAcceptFiles); - SHELL32_FUNC(DragFinish); - - wsymtbl.has_drag_and_drop = MwTRUE; - } -dnd_error: - /* TODO: check properly */ return 0; } diff --git a/src/backend/haiku.cc b/src/backend/haiku.cc index 2c796d6..8c4f8bf 100644 --- a/src/backend/haiku.cc +++ b/src/backend/haiku.cc @@ -879,10 +879,6 @@ static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { delete screen; } -static void MwLLSetupDragAndDropImpl(MwLL handle) { - (void)handle; -} - static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) { (void)handle; (void)toggle; diff --git a/src/backend/wayland/wayland.c b/src/backend/wayland/wayland.c index 839e9ac..48d6c76 100644 --- a/src/backend/wayland/wayland.c +++ b/src/backend/wayland/wayland.c @@ -1779,10 +1779,6 @@ static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { rect->height = handle->wayland.mh; } -static void MwLLSetupDragAndDropImpl(MwLL handle) { - (void)handle; -} - static void MwLLBeginStateChangeImpl(MwLL handle) { (void)handle; /* no-op */ diff --git a/src/backend/x11.c b/src/backend/x11.c index cc4d22b..79ce429 100644 --- a/src/backend/x11.c +++ b/src/backend/x11.c @@ -1361,10 +1361,6 @@ static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) { rect->height = xwa.height; } -static void MwLLSetupDragAndDropImpl(MwLL handle) { - (void)handle; -} - static void MwLLBeginStateChangeImpl(MwLL handle) { MwLLShow(handle, 0); } diff --git a/src/core.c b/src/core.c index c27b1a6..7059840 100644 --- a/src/core.c +++ b/src/core.c @@ -145,9 +145,8 @@ static void llclosehandler(MwLL handle, void* data) { } static void llmovehandler(MwLL handle, void* data) { - MwWidget h = (MwWidget)handle->common.user; - MwPoint* p = data; - + MwWidget h = (MwWidget)handle->common.user; + MwPoint* p = data; h->mouse_point.x = p->x; h->mouse_point.y = p->y; @@ -193,13 +192,6 @@ static void llclipboardhandler(MwLL handle, void* data) { MwDispatchUserHandler(h, MwNclipboardHandler, data); } -static void lldraganddrophandler(MwLL handle, void* data) { - MwWidget h = (MwWidget)handle->common.user; - if(MwGetInteger(h, MwNdisabled) == 1) return; - - MwDispatchUserHandler(h, MwNdragAndDropHandler, data); -} - /* if both of them are true * 1. widget class is not NULL * 2. parent is NULL @@ -280,20 +272,19 @@ static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name, if(parent == NULL) h->top_step = 1; if(h->lowlevel != NULL) { - h->lowlevel->common.user = h; - h->lowlevel->common.handler->draw = lldrawhandler; - h->lowlevel->common.handler->up = lluphandler; - h->lowlevel->common.handler->down = lldownhandler; - h->lowlevel->common.handler->resize = llresizehandler; - h->lowlevel->common.handler->close = llclosehandler; - h->lowlevel->common.handler->move = llmovehandler; - h->lowlevel->common.handler->key = llkeyhandler; - h->lowlevel->common.handler->key_released = llkeyrelhandler; - h->lowlevel->common.handler->focus_in = llfocusinhandler; - h->lowlevel->common.handler->focus_out = llfocusouthandler; - h->lowlevel->common.handler->clipboard = llclipboardhandler; - h->lowlevel->common.handler->dark_theme = lldarkthemehandler; - h->lowlevel->common.handler->drag_and_drop = lldraganddrophandler; + h->lowlevel->common.user = h; + h->lowlevel->common.handler->draw = lldrawhandler; + h->lowlevel->common.handler->up = lluphandler; + h->lowlevel->common.handler->down = lldownhandler; + h->lowlevel->common.handler->resize = llresizehandler; + h->lowlevel->common.handler->close = llclosehandler; + h->lowlevel->common.handler->move = llmovehandler; + h->lowlevel->common.handler->key = llkeyhandler; + h->lowlevel->common.handler->key_released = llkeyrelhandler; + h->lowlevel->common.handler->focus_in = llfocusinhandler; + h->lowlevel->common.handler->focus_out = llfocusouthandler; + h->lowlevel->common.handler->clipboard = llclipboardhandler; + h->lowlevel->common.handler->dark_theme = lldarkthemehandler; } if(parent != NULL) arrput(parent->children, h); @@ -327,9 +318,7 @@ static MwWidget MwCreateWidget_Internal(MwClass widget_class, const char* name, #if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2) || defined(USE_GDI_TEXT) if(IsFirstVisible(h)) { -#ifdef USE_STB_TRUETYPE font_setup: -#endif h->root_font = MwFontLoad(MwTTFData, MwTTFDataSize); h->root_boldfont = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize); h->root_monofont = MwFontLoad(MwMonospaceTTFData, MwMonospaceTTFDataSize); @@ -573,7 +562,6 @@ int MwStep(MwWidget handle) { MwFreeWidget(handle); return 1; } - return 0; } @@ -670,10 +658,6 @@ void MwSetInteger(MwWidget handle, const char* key, int n) { if(h->lowlevel != NULL) MwLLSetDarkTheme(h->lowlevel, n); } - - if(strcmp(key, MwNacceptsDnD) == 0) { - if(handle->lowlevel != NULL) MwLLSetupDragAndDrop(handle->lowlevel); - } } void MwSetText(MwWidget handle, const char* key, const char* value) { @@ -1090,16 +1074,7 @@ int MwLibraryInit(void) { int i; #ifdef _WIN32 - /* - There's no Windows configuration that Milsko supports that doesn't have winmm. - However, uhh, Visual Studio 2022. For some fucking reason. - Thanks for coming to my TED Talk. - */ - MwLL_winmmLib = LoadLibrary("winmm.dll"); - MwLL_PFN_timeGetTime = (void *)GetProcAddress(MwLL_winmmLib, "timeGetTime"); - MwLL_PFN_timeBeginPeriod = (void *)GetProcAddress(MwLL_winmmLib, "timeBeginPeriod"); - - MwLL_PFN_timeBeginPeriod(10); + timeBeginPeriod(10); #endif #ifdef USE_WAYLAND diff --git a/src/dialog/colorpicker.c b/src/dialog/colorpicker.c index 95fc283..926fddc 100644 --- a/src/dialog/colorpicker.c +++ b/src/dialog/colorpicker.c @@ -110,9 +110,9 @@ static void color_picker_image_update(color_picker_t* picker) { picker->color_picker_image_data[i + 2] = 0; picker->color_picker_image_data[i + 3] = 0; } else if(dist >= 180.) { - picker->color_picker_image_data[i] = (unsigned char)dist; - picker->color_picker_image_data[i + 1] = (unsigned char)dist; - picker->color_picker_image_data[i + 2] = (unsigned char)dist; + picker->color_picker_image_data[i] = dist; + picker->color_picker_image_data[i + 1] = dist; + picker->color_picker_image_data[i + 2] = dist; picker->color_picker_image_data[i + 3] = 255; } else { MwHSV hsv_v; @@ -121,26 +121,26 @@ static void color_picker_image_update(color_picker_t* picker) { double xd = (M_PI / 180.) * ((double)_x); double yd = (M_PI / 180.) * ((double)_y); - double angle = atan2(yd, xd) - M_PI; - double hue = (angle * 180.) / M_PI; + float angle = atan2(yd, xd) - M_PI; + float hue = (angle * 180.) / M_PI; if(hue < 0.0) { hue += 360; } - hsv_v.h = (MwU8)((hue) * (HSV_HUE_STEPS / 360.)); - hsv_v.s = (MwU8)((dist) * (HSV_SAT_MAX / 180.)); + hsv_v.h = (hue) * (HSV_HUE_STEPS / 360.); + hsv_v.s = (dist) * (HSV_SAT_MAX / 180.); picker->hue_table[n] = hsv_v; picker->hue_table[n].generated = 1; } hsv_v = picker->hue_table[n]; - hsv_v.v = (MwU8)(HSV_VAL_MAX - (picker->value * HSV_VAL_MAX)); + hsv_v.v = HSV_VAL_MAX - (picker->value * HSV_VAL_MAX); hsv2rgb(hsv_v.h, hsv_v.s, hsv_v.v, &color.red, &color.green, &color.blue); - picker->color_picker_image_data[i] = (unsigned char)color.red; - picker->color_picker_image_data[i + 1] = (unsigned char)color.green; - picker->color_picker_image_data[i + 2] = (unsigned char)color.blue; + picker->color_picker_image_data[i] = color.red; + picker->color_picker_image_data[i + 1] = color.green; + picker->color_picker_image_data[i + 2] = color.blue; picker->color_picker_image_data[i + 3] = 255; n++; diff --git a/src/dialog/messagebox.c b/src/dialog/messagebox.c index ff72bc8..6a96f6d 100644 --- a/src/dialog/messagebox.c +++ b/src/dialog/messagebox.c @@ -68,9 +68,9 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi if(flag & MwMB_BUTTONYES) spawn_button(window, w - (x += 8 + 80), h - 8 - 24, MwMB_BUTTONYES, "Yes"); if((flag & MwMB_ICONMASK) != 0) { - MwWidget icon; - MwLLPixmap px; - MwU32* data = NULL; + MwWidget icon; + MwLLPixmap px; + MwU32* data = NULL; icon = MwCreateWidget(MwImageClass, "image", window, 8, (h - 48) / 2, 48, 48); diff --git a/src/draw.c b/src/draw.c index 2314c02..ce86d90 100644 --- a/src/draw.c +++ b/src/draw.c @@ -43,9 +43,9 @@ static void color_set_disabled_if_disabled(MwWidget handle, MwLLColor rgb) { MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground)); if(c != NULL) { - rgb->common.red = (MwU8)(rgb->common.red + (c->common.red - rgb->common.red) * 0.5); - rgb->common.green = (MwU8)(rgb->common.green + (c->common.green - rgb->common.green) * 0.5); - rgb->common.blue = (MwU8)(rgb->common.blue + (c->common.blue - rgb->common.blue) * 0.5); + rgb->common.red = rgb->common.red + (c->common.red - rgb->common.red) * 0.5; + rgb->common.green = rgb->common.green + (c->common.green - rgb->common.green) * 0.5; + rgb->common.blue = rgb->common.blue + (c->common.blue - rgb->common.blue) * 0.5; MwLLColorUpdate(handle->lowlevel, rgb, rgb->common.red, rgb->common.green, rgb->common.blue); MwLLFreeColor(c); @@ -124,11 +124,8 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) { int ColorDiff = get_color_diff(handle); double darkenStep = (ColorDiff / 2.) / rect->height; unsigned long sz = 1 * rect->height * 4; - unsigned char* data = malloc(sz*2); + unsigned char* data = malloc(sz); MwRect r = *rect; - if(!data) { - return; - } if(rect->width <= 0 || rect->height <= 0) { free(data); return; @@ -141,7 +138,7 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) { r.height -= 2; for(y = 0; y < rect->height; y++) { - MwLLColor col = MwLightenColor(handle, color, (int)-darken, (int)-darken, (int)-darken); + MwLLColor col = MwLightenColor(handle, color, -darken, -darken, -darken); int idx = y * 4; color_set_disabled_if_disabled(handle, col); data[idx] = col->common.red; @@ -461,11 +458,11 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p1[1].x = rect->x; p1[1].y = rect->y + rect->height; - p1[2].x = (int)(rect->x + c * border); - p1[2].y = (int)(rect->y + rect->height - s * border); + p1[2].x = rect->x + c * border; + p1[2].y = rect->y + rect->height - s * border; p1[3].x = rect->x + rect->width / 2; - p1[3].y = (int)(rect->y + border); + p1[3].y = rect->y + border; p2[0].x = rect->x + rect->width / 2; p2[0].y = rect->y; @@ -473,14 +470,14 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p2[1].x = rect->x + rect->width; p2[1].y = rect->y + rect->height; - p2[2].x = (int)(rect->x + rect->width - c * border); - p2[2].y = (int)(rect->y + rect->height - s * border); + p2[2].x = rect->x + rect->width - c * border; + p2[2].y = rect->y + rect->height - s * border; p2[3].x = rect->x + rect->width / 2; - p2[3].y = (int)(rect->y + border); + p2[3].y = rect->y + border; - p3[0].x = (int)(rect->x + c * border); - p3[0].y = (int)(rect->y + rect->height - s * border); + p3[0].x = rect->x + c * border; + p3[0].y = rect->y + rect->height - s * border; p3[1].x = rect->x; p3[1].y = rect->y + rect->height; @@ -488,30 +485,30 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p3[2].x = rect->x + rect->width; p3[2].y = rect->y + rect->height; - p3[3].x = (int)(rect->x + rect->width - c * border); - p3[3].y = (int)(rect->y + rect->height - s * border); + p3[3].x = rect->x + rect->width - c * border; + p3[3].y = rect->y + rect->height - s * border; MwLLPolygon(handle->lowlevel, p1, 4, invert ? darker : lighter); MwLLPolygon(handle->lowlevel, p2, 4, invert ? lighter : darker); MwLLPolygon(handle->lowlevel, p3, 4, invert ? lighter : darker); - p4[0].x = (int)(rect->x + c * border); - p4[0].y = (int)(rect->y + rect->height - s * border); + p4[0].x = rect->x + c * border; + p4[0].y = rect->y + rect->height - s * border; - p4[1].x = (int)(rect->x + rect->width - c * border); - p4[1].y = (int)(rect->y + rect->height - s * border); + p4[1].x = rect->x + rect->width - c * border; + p4[1].y = rect->y + rect->height - s * border; p4[2].x = rect->x + rect->width / 2; - p4[2].y = (int)(rect->y + border); + p4[2].y = rect->y + border; } else if(direction == MwSOUTH) { p1[0].x = rect->x; p1[0].y = rect->y; - p1[1].x = (int)(rect->x + c * border); - p1[1].y = (int)(rect->y + s * border); + p1[1].x = rect->x + c * border; + p1[1].y = rect->y + s * border; - p1[2].x = (int)(rect->x + rect->width - c * border); - p1[2].y = (int)(rect->y + s * border); + p1[2].x = rect->x + rect->width - c * border; + p1[2].y = rect->y + s * border; p1[3].x = rect->x + rect->width; p1[3].y = rect->y; @@ -519,11 +516,11 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p2[0].x = rect->x; p2[0].y = rect->y; - p2[1].x = (int)(rect->x + c * border); - p2[1].y = (int)(rect->y + s * border); + p2[1].x = rect->x + c * border; + p2[1].y = rect->y + s * border; p2[2].x = rect->x + rect->width / 2; - p2[2].y = (int)(rect->y + rect->height - border); + p2[2].y = rect->y + rect->height - border; p2[3].x = rect->x + rect->width / 2; p2[3].y = rect->y + rect->height; @@ -535,32 +532,32 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p3[1].y = rect->y + rect->height; p3[2].x = rect->x + rect->width / 2; - p3[2].y = (int)(rect->y + rect->height - border); + p3[2].y = rect->y + rect->height - border; - p3[3].x = (int)(rect->x + rect->width - c * border); - p3[3].y = (int)(rect->y + s * border); + p3[3].x = rect->x + rect->width - c * border; + p3[3].y = rect->y + s * border; MwLLPolygon(handle->lowlevel, p1, 4, invert ? darker : lighter); MwLLPolygon(handle->lowlevel, p2, 4, invert ? darker : lighter); MwLLPolygon(handle->lowlevel, p3, 4, invert ? lighter : darker); - p4[0].x = (int)(rect->x + c * border); - p4[0].y = (int)(rect->y + s * border); + p4[0].x = rect->x + c * border; + p4[0].y = rect->y + s * border; - p4[1].x = (int)(rect->x + rect->width - c * border); - p4[1].y = (int)(rect->y + s * border); + p4[1].x = rect->x + rect->width - c * border; + p4[1].y = rect->y + s * border; p4[2].x = rect->x + rect->width / 2; - p4[2].y = (int)(rect->y + rect->height - border); + p4[2].y = rect->y + rect->height - border; } else if(direction == MwEAST) { p1[0].x = rect->x; p1[0].y = rect->y; - p1[1].x = (int)(rect->x + c * border); - p1[1].y = (int)(rect->y + s * border); + p1[1].x = rect->x + c * border; + p1[1].y = rect->y + s * border; - p1[2].x = (int)(rect->x + c * border); - p1[2].y = (int)(rect->y + rect->height - s * border); + p1[2].x = rect->x + c * border; + p1[2].y = rect->y + rect->height - s * border; p1[3].x = rect->x; p1[3].y = rect->y + rect->height; @@ -571,14 +568,14 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p2[1].x = rect->x + rect->width; p2[1].y = rect->y + rect->height / 2; - p2[2].x = (int)(rect->x + rect->width - border); + p2[2].x = rect->x + rect->width - border; p2[2].y = rect->y + rect->height / 2; - p2[3].x = (int)(rect->x + c * border); - p2[3].y = (int)(rect->y + s * border); + p2[3].x = rect->x + c * border; + p2[3].y = rect->y + s * border; - p3[0].x = (int)(rect->x + c * border); - p3[0].y = (int)(rect->y + rect->height - s * border); + p3[0].x = rect->x + c * border; + p3[0].y = rect->y + rect->height - s * border; p3[1].x = rect->x; p3[1].y = rect->y + rect->height; @@ -586,30 +583,30 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p3[2].x = rect->x + rect->width; p3[2].y = rect->y + rect->height / 2; - p3[3].x = (int)(rect->x + rect->width - border); + p3[3].x = rect->x + rect->width - border; p3[3].y = rect->y + rect->height / 2; MwLLPolygon(handle->lowlevel, p1, 4, invert ? darker : lighter); MwLLPolygon(handle->lowlevel, p2, 4, invert ? darker : lighter); MwLLPolygon(handle->lowlevel, p3, 4, invert ? lighter : darker); - p4[0].x = (int)(rect->x + rect->width - border); + p4[0].x = rect->x + rect->width - border; p4[0].y = rect->y + rect->height / 2; - p4[1].x = (int)(rect->x + c * border); - p4[1].y = (int)(rect->y + rect->height - s * border); + p4[1].x = rect->x + c * border; + p4[1].y = rect->y + rect->height - s * border; - p4[2].x = (int)(rect->x + c * border); - p4[2].y = (int)(rect->y + s * border); + p4[2].x = rect->x + c * border; + p4[2].y = rect->y + s * border; } else if(direction == MwWEST) { p1[0].x = rect->x; p1[0].y = rect->y + rect->height / 2; - p1[1].x = (int)(rect->x + border); + p1[1].x = rect->x + border; p1[1].y = rect->y + rect->height / 2; - p1[2].x = (int)(rect->x + rect->width - c * border); - p1[2].y = (int)(rect->y + s * border); + p1[2].x = rect->x + rect->width - c * border; + p1[2].y = rect->y + s * border; p1[3].x = rect->x + rect->width; p1[3].y = rect->y; @@ -617,11 +614,11 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p2[0].x = rect->x; p2[0].y = rect->y + rect->height / 2; - p2[1].x = (int)(rect->x + border); + p2[1].x = rect->x + border; p2[1].y = rect->y + rect->height / 2; - p2[2].x = (int)(rect->x + rect->width - c * border); - p2[2].y = (int)(rect->y + rect->height - s * border); + p2[2].x = rect->x + rect->width - c * border; + p2[2].y = rect->y + rect->height - s * border; p2[3].x = rect->x + rect->width; p2[3].y = rect->y + rect->height; @@ -629,11 +626,11 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, p3[0].x = rect->x + rect->width; p3[0].y = rect->y; - p3[1].x = (int)(rect->x + rect->width - c * border); - p3[1].y = (int)(rect->y + s * border); + p3[1].x = rect->x + rect->width - c * border; + p3[1].y = rect->y + s * border; - p3[2].x = (int)(rect->x + rect->width - c * border); - p3[2].y = (int)(rect->y + rect->height - s * border); + p3[2].x = rect->x + rect->width - c * border; + p3[2].y = rect->y + rect->height - s * border; p3[3].x = rect->x + rect->width; p3[3].y = rect->y + rect->height; @@ -642,14 +639,14 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, MwLLPolygon(handle->lowlevel, p2, 4, invert ? lighter : darker); MwLLPolygon(handle->lowlevel, p3, 4, invert ? lighter : darker); - p4[0].x = (int)(rect->x + border); + p4[0].x = rect->x + border; p4[0].y = rect->y + rect->height / 2; - p4[1].x = (int)(rect->x + rect->width - c * border); - p4[1].y = (int)(rect->y + rect->height - s * border); + p4[1].x = rect->x + rect->width - c * border; + p4[1].y = rect->y + rect->height - s * border; - p4[2].x = (int)(rect->x + rect->width - c * border); - p4[2].y = (int)(rect->y + s * border); + p4[2].x = rect->x + rect->width - c * border; + p4[2].y = rect->y + s * border; } MwLLPolygon(handle->lowlevel, p4, 3, col); @@ -833,13 +830,13 @@ void MwPixmapReloadRaw(MwLLPixmap px, unsigned char* rgb) { a /= 255; if(a != 0) { - pout[0] = (unsigned char)(pin[0] * a); - pout[1] = (unsigned char)(pin[1] * a); - pout[2] = (unsigned char)(pin[2] * a); + pout[0] = pin[0] * a; + pout[1] = pin[1] * a; + pout[2] = pin[2] * a; - pout[0] += (unsigned char)(base->common.red * (1 - a)); - pout[1] += (unsigned char)(base->common.green * (1 - a)); - pout[2] += (unsigned char)(base->common.blue * (1 - a)); + pout[0] += base->common.red * (1 - a); + pout[1] += base->common.green * (1 - a); + pout[2] += base->common.blue * (1 - a); pout[3] = 255; } } @@ -871,11 +868,6 @@ MwLLPixmap MwLoadIcon(MwWidget handle, MwU32* data) { MwLLPixmap px; int i; - if(!rgba) { - printf("Null malloc! out of memory?\n"); - return NULL; - } - memset(rgba, 0, width * height * 4); for(i = 0; i < width * height; i++) { @@ -913,11 +905,7 @@ MwLLPixmap MwLoadXPM(MwWidget handle, char** data) { sh_new_strdup(c); -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - sscanf_s(data[0], "%d %d %d %d", &col, &row, &colors, &cpp); -#else sscanf(data[0], "%d %d %d %d", &col, &row, &colors, &cpp); -#endif for(i = 0; i < colors; i++) { char k[128]; @@ -954,10 +942,6 @@ MwLLPixmap MwLoadXPM(MwWidget handle, char** data) { rgb = malloc(row * col * 4); comp = malloc(cpp + 1); - if(!rgb || !comp) { - printf("Null malloc! Out of memory?"); - return NULL; - } comp[cpp] = 0; for(y = 0; y < row; y++) { for(x = 0; x < col; x++) { diff --git a/src/lowlevel.c b/src/lowlevel.c index 2fe1535..bc9e55b 100644 --- a/src/lowlevel.c +++ b/src/lowlevel.c @@ -1,11 +1,5 @@ #include -#ifdef _WIN32 -void *MwLL_winmmLib; -long (__stdcall* MwLL_PFN_timeGetTime)(void); -unsigned int (__stdcall* MwLL_PFN_timeBeginPeriod)(unsigned int period); -#endif - MwLL (*MwLLCreate)(MwLL parent, int x, int y, int width, int height) = NULL; void (*MwLLDestroy)(MwLL handle) = NULL; @@ -56,8 +50,8 @@ void (*MwLLGetClipboard)(MwLL, int clipboard_type) = NULL; void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point) = NULL; void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect) = NULL; -void (*MwLLSetupDragAndDrop)(MwLL handle) = NULL; -void (*MwLLSetDarkTheme)(MwLL handle, int toggle) = NULL; + +void (*MwLLSetDarkTheme)(MwLL handle, int toggle) = NULL; MwBool (*MwLLDoModern)(MwLL handle) = NULL; diff --git a/src/string.c b/src/string.c index c894b9a..f56b9ac 100644 --- a/src/string.c +++ b/src/string.c @@ -1,53 +1,21 @@ #include char* MwStringDuplicate(const char* str) { - int sz = strlen(str) + 1; - char* r = malloc(sz); - if(!r) { - printf("Out Of Memory\n"); - return NULL; - } - -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - strcpy_s(r, sz, str); -#else + char* r = malloc(strlen(str) + 1); strcpy(r, str); -#endif return r; } char* MwStringConcat(const char* str1, const char* str2) { - int sz = strlen(str1) + strlen(str2) + 1; - char* r = malloc(sz); - if(!r) { - printf("Out Of Memory\n"); - return NULL; - } - -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - strcpy_s(r, sz, str1); - strcat_s(r, sz, str2); -#else + char* r = malloc(strlen(str1) + strlen(str2) + 1); strcpy(r, str1); strcat(r, str2); -#endif return r; } void MwStringSize(char* out, MwOffset size) { -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - if(size / 1024 == 0) { - sprintf_s(out, 255, "%d", (int)size); - } else if(size / 1024 / 1024 == 0) { - sprintf_s(out, 255, "%.1fK", (double)size / 1024); - } else if(size / 1024 / 1024 / 1024 == 0) { - sprintf_s(out, 255, "%.1fM", (double)size / 1024 / 1024); - } else { - sprintf_s(out, 255, "%.1fG", (double)size / 1024 / 1024 / 1024); - } -#else if(size / 1024 == 0) { sprintf(out, "%d", (int)size); } else if(size / 1024 / 1024 == 0) { @@ -57,28 +25,16 @@ void MwStringSize(char* out, MwOffset size) { } else { sprintf(out, "%.1fG", (double)size / 1024 / 1024 / 1024); } -#endif } void MwStringTime(char* out, time_t t) { struct tm* tm = localtime(&t); const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - - if(tm == NULL) { -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - sprintf_s(out, 255, "localtime error"); -#else sprintf(out, "localtime error"); -#endif - } else { -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - sprintf_s(out, 255, "%s %2d %02d:%02d %d", months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, 1900 + tm->tm_year); -#else sprintf(out, "%s %2d %02d:%02d %d", months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, 1900 + tm->tm_year); -#endif } } void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...) { @@ -87,9 +43,6 @@ void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...) { #if __STDC_VERSION__ >= 199901L vsnprintf(out, size, fmt, va); -/* MSVC2022 reports the STDC_VERSION as fucking 1994. Thanks Bill Gates. */ -#elif defined(_MSC_VER) && (_MSC_VER >= 1400) - vsprintf_s(out, size, fmt, va); #else vsprintf(out, fmt, va); #endif diff --git a/src/text/gdi.c b/src/text/gdi.c index 97e6870..b764353 100644 --- a/src/text/gdi.c +++ b/src/text/gdi.c @@ -28,10 +28,10 @@ static int GDI_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const c tw = MwTextWidth(handle, ttf, text); th = MwTextHeight(handle, ttf, text); - if(handle->lowlevel->common.type == MwLLBackendGDI) { + if(handle->lowlevel->common.type == MwLLBackendGDI && MwGetInteger(handle, MwNmodernLook) == MwFALSE) { HFONT old_font = SelectObject(handle->lowlevel->gdi.hDC, ttf->font); int old_bkmode = SetBkMode(handle->lowlevel->gdi.hDC, TRANSPARENT); - COLORREF old_color = SetTextColor(handle->lowlevel->gdi.hDC, RGB(color->common.red, color->common.green, color->common.blue)); + COLORREF old_color = SetTextColor(handle->lowlevel->gdi.hDC, color->gdi.color); TextOut(handle->lowlevel->gdi.hDC, point->x, point->y - th / 2, t, strlen(t)); @@ -180,19 +180,19 @@ static HANDLE WINAPI _AddFontMemResourceExPolyFill(PVOID pFileView, DWORD cjSize CHAR temp_path_dir[MAX_PATH]; CHAR temp_path_name[MAX_PATH]; HANDLE tempFile = NULL; - DWORD hr; + int hr; (void)pvResrved; hr = GetTempPathA(MAX_PATH, temp_path_dir); if(hr == 0) { printf("GetTempPathA error %08lX\n", hr); - return NULL; + return hr; } hr = GetTempFileNameA(temp_path_dir, TEXT("MILSKO"), 0, temp_path_name); if(hr == 0) { printf("GetTempFileNameA error %08lX\n", hr); - return NULL; + return hr; } printf("extracting mem font to %s\n", temp_path_name); @@ -215,6 +215,7 @@ static HANDLE WINAPI _AddFontMemResourceExPolyFill(PVOID pFileView, DWORD cjSize OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_DELETE_ON_CLOSE, NULL); + printf("%d\n", tempFile); if(tempFile != INVALID_HANDLE_VALUE) { goto success; } else { @@ -222,14 +223,14 @@ static HANDLE WINAPI _AddFontMemResourceExPolyFill(PVOID pFileView, DWORD cjSize } } printf("CreateFileA error %08lX\n", err); - return NULL; + return hr; } success: hr = WriteFile(tempFile, pFileView, cjSize, NULL, NULL); if(hr != 0) { printf("WriteFile error %08lX\n", hr); - return NULL; + return 0; } *pNumFonts = AddFontResource(temp_path_name); @@ -245,7 +246,7 @@ static BOOL WINAPI _RemoveFontMemResourceExPolyFill(HANDLE h) { int MwFL_GDISetup(void) { void* gdilib = LoadLibrary("gdi32.dll"); if(!gdilib) { - printf("gdi32.dll not found(what)\n"); + printf("gdi32.dll not found(?????)\n"); } else { _AddFontMemResourceEx = (void*)GetProcAddress(gdilib, "AddFontMemResourceEx"); if(!_AddFontMemResourceEx) { diff --git a/src/text/text.c b/src/text/text.c index 2bb89b6..9ad1e94 100644 --- a/src/text/text.c +++ b/src/text/text.c @@ -88,10 +88,9 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, if(c != NULL) { fadedColor = MwLLAllocColor(handle->lowlevel, color->common.red, color->common.blue, color->common.green); - fadedColor->common.red = (MwU8)(fadedColor->common.red + (c->common.red - fadedColor->common.red) * 0.5); - fadedColor->common.green = (MwU8)(fadedColor->common.green + (c->common.green - fadedColor->common.green) * 0.5); - fadedColor->common.blue = (MwU8)(fadedColor->common.blue + (c->common.blue - fadedColor->common.blue) * 0.5); - MwLLColorUpdate(handle->lowlevel, fadedColor, fadedColor->common.red, fadedColor->common.green, fadedColor->common.blue); + fadedColor->common.red = fadedColor->common.red + (c->common.red - fadedColor->common.red) * 0.5; + fadedColor->common.green = fadedColor->common.green + (c->common.green - fadedColor->common.green) * 0.5; + fadedColor->common.blue = fadedColor->common.blue + (c->common.blue - fadedColor->common.blue) * 0.5; MwLLFreeColor(c); } @@ -110,11 +109,6 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, char* line = malloc(input - last + 1); int i; - if(!line) { - printf("Out Of Memory\n"); - return; - } - memcpy(line, last, input - last); line[input - last] = 0; @@ -182,11 +176,6 @@ int MwTextWidth(MwWidget handle, MwFLFont ttf, const char* text) { char* line = malloc(input - last + 1); int i; - if(!line) { - printf("Out Of Memory\n"); - return 1; - } - memcpy(line, last, input - last); line[input - last] = 0; @@ -260,11 +249,6 @@ static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, th = MwTextHeight(handle, NULL, text); px = malloc(tw * th * 4); - if(!px) { - printf("Out of Memory\n"); - return; - } - memset(px, 0, tw * th * 4); sx = 0; diff --git a/src/widget/button.c b/src/widget/button.c index 7f1da57..51337e6 100644 --- a/src/widget/button.c +++ b/src/widget/button.c @@ -55,11 +55,11 @@ static void draw(MwWidget handle) { double sh = (double)oh / px->common.height; if(sw < sh) { - r.width = (int)(px->common.width * sw); - r.height = (int)(px->common.height * sw); + r.width = px->common.width * sw; + r.height = px->common.height * sw; } else { - r.width = (int)(px->common.width * sh); - r.height = (int)(px->common.height * sh); + r.width = px->common.width * sh; + r.height = px->common.height * sh; } r.width -= MwGetInteger(handle, MwNpadding) * 2; r.height -= MwGetInteger(handle, MwNpadding) * 2; @@ -68,8 +68,8 @@ static void draw(MwWidget handle) { r.height = px->common.height; } - r.x += (int)((double)(ow - r.width) / 2); - r.y += (int)((double)(oh - r.height) / 2); + r.x += (double)(ow - r.width) / 2; + r.y += (double)(oh - r.height) / 2; MwLLDrawPixmap(handle->lowlevel, &r, px); } else { diff --git a/src/widget/entry.c b/src/widget/entry.c index 9d423bf..65cd903 100644 --- a/src/widget/entry.c +++ b/src/widget/entry.c @@ -9,7 +9,6 @@ static int wcreate(MwWidget handle) { t->right = 0; t->length = 0; t->cursor_blink_timer = 0; - t->active = 0; handle->internal = t; while(topmost_parent->parent) topmost_parent = topmost_parent->parent; @@ -41,7 +40,7 @@ static void tick(MwWidget handle) { if(++t->cursor_blink_timer >= 30) { t->cursor_blink_timer = 0; } - MwForceRender(handle); + MwDispatch(handle, draw); } } static void draw(MwWidget handle) { @@ -180,15 +179,13 @@ static void mouse_down(MwWidget handle, void* ptr) { MwEntry t = handle->internal; MwWidget topmost_parent = handle->parent; - (void)ptr; - while(topmost_parent->parent) topmost_parent = topmost_parent->parent; for(i = 0; i < arrlen(topmost_parent->monitored_entries); i++) { MwEntry t = topmost_parent->monitored_entries[i]->internal; t->active = MwFALSE; t->cursor_blink_timer = 0; - MwForceRender(topmost_parent->monitored_entries[i]); + MwDispatch(topmost_parent->monitored_entries[i], draw); } t->active = MwTRUE; MwForceRender2(handle, NULL); diff --git a/src/widget/listbox.c b/src/widget/listbox.c index cc17362..32be887 100644 --- a/src/widget/listbox.c +++ b/src/widget/listbox.c @@ -203,16 +203,11 @@ static void frame_draw(MwWidget handle) { int seek = 0; int l = 0; char* old = str; - int sz = strlen(old) + 5; if(ind < 0) ind = 0; - str = malloc(sz); -#if defined(_MSC_VER) && (_MSC_VER >= 1400) - strcpy_s(str, sz, old); -#else + str = malloc(strlen(old) + 5); strcpy(str, old); -#endif free(old); while(str[seek] != 0) { @@ -322,11 +317,6 @@ static void resize(MwWidget handle, int no_resize) { static int wcreate(MwWidget handle) { MwListBox lb = malloc(sizeof(*lb)); - if(!lb) { - printf("Out Of Memory\n"); - return 1; - } - memset(lb, 0, sizeof(*lb)); handle->internal = lb; diff --git a/src/widget/progressbar.c b/src/widget/progressbar.c index 8adf028..3185c23 100644 --- a/src/widget/progressbar.c +++ b/src/widget/progressbar.c @@ -34,7 +34,7 @@ static void draw(MwWidget handle) { r.width -= MwDefaultBorderWidth(handle) * 2; r.height -= MwDefaultBorderWidth(handle) * 2; - r.width = (int)(r.width * w); + r.width = r.width * w; MwDrawRect(handle, &r, fill); MwLLFreeColor(fill); diff --git a/src/widget/scrollbar.c b/src/widget/scrollbar.c index 3bd2fdf..346f818 100644 --- a/src/widget/scrollbar.c +++ b/src/widget/scrollbar.c @@ -28,7 +28,7 @@ static int calc_length(MwWidget handle) { int area = MwGetInteger(handle, MwNareaShown); if(area > len) area = len; - return (int)(max * (double)area / len); + return max * (double)area / len; } static int calc_position(MwWidget handle) { @@ -36,7 +36,7 @@ static int calc_position(MwWidget handle) { int len = MwGetInteger(handle, MwNmaxValue) - MwGetInteger(handle, MwNminValue); int val = MwGetInteger(handle, MwNvalue); - return (int)((max - calc_length(handle)) * (double)val / len); + return (max - calc_length(handle)) * (double)val / len; } static void add_value(MwWidget handle, int mul) { @@ -54,7 +54,7 @@ static void add_value(MwWidget handle, int mul) { } static void draw(MwWidget handle) { - MwRect r = {0}, rt = {0}, rbar = {0}; + MwRect r, rt, rbar; MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground)); MwLLColor dark = MwLightenColor(handle, base, -64, -64, -64); MwScrollBar scr = handle->internal; diff --git a/src/widget/viewport.c b/src/widget/viewport.c index 803c424..2541b65 100644 --- a/src/widget/viewport.c +++ b/src/widget/viewport.c @@ -76,12 +76,6 @@ static void resize(MwWidget handle) { static int wcreate(MwWidget handle) { MwViewport vp = malloc(sizeof(*vp)); - - if(!vp) { - printf("Out Of Memory\n"); - return 1; - } - memset(vp, 0, sizeof(*vp)); handle->internal = vp; @@ -157,7 +151,7 @@ static void tick(MwWidget handle) { v = MwGetInteger(vp->vscroll, MwNvalue); mv = MwGetInteger(vp->vscroll, MwNmaxValue); l = MwGetInteger(vp->frame, MwNheight); - v = (int)((mv - l) * (double)v / mv); + v = (mv - l) * (double)v / mv; if(v < 0) v = 0; MwVaApply(vp->inframe, @@ -172,7 +166,7 @@ static void tick(MwWidget handle) { v = MwGetInteger(vp->hscroll, MwNvalue); mv = MwGetInteger(vp->hscroll, MwNmaxValue); l = MwGetInteger(vp->frame, MwNwidth); - v = (int)((mv - l) * (double)v / mv); + v = (mv - l) * (double)v / mv; if(v < 0) v = 0; MwVaApply(vp->inframe, diff --git a/tools/genmk.pl b/tools/genmk.pl index 689e09e..9903c11 100755 --- a/tools/genmk.pl +++ b/tools/genmk.pl @@ -116,7 +116,7 @@ sub generate { print(OUT "LD = $link\n"); print(OUT "\n"); print(OUT -"MW_CFLAGS = ${cdll} ${inc}include ${inc}external${dir}libz${dir}include ${def}_MILSKO ${def}_MILSKO_BUILD ${def}USE_GDI ${def}USE_STB_IMAGE ${def}STBI_NO_SIMD ${def}USE_GDI_TEXT ${def}MW_OPENGL\n" +"MW_CFLAGS = ${cdll} ${inc}include ${inc}external${dir}libz${dir}include ${def}_MILSKO ${def}_MILSKO_BUILD ${def}USE_GDI ${def}USE_STB_IMAGE ${def}STBI_NO_SIMD ${def}USE_GDI_TEXT\n" ); print(OUT "MW_LDFLAGS = $dll\n"); print(OUT "EXE_CFLAGS = ${inc}include\n"); @@ -190,7 +190,7 @@ sub generate { print(OUT "src${dir}Mw.dll: " . cobjs($dir) . "\n"); print( OUT " \$(LD) \$(MW_LDFLAGS) $c_dllout $dllout\$@ " . cobjs($dir, $prefobj) - . " $needlibs ${lib}opengl32.lib ${lib}gdi32.lib ${lib}ole32.lib ${lib}uuid.lib ${lib}user32.lib ${lib}advapi32.lib\n" + . " $needlibs ${lib}opengl32.lib ${lib}gdi32.lib ${lib}winmm.lib ${lib}user32.lib ${lib}advapi32.lib\n" ); print(OUT " $c_dllafter\n"); print(OUT "\n");