Compare commits

...
Sign in to create a new pull request.

6 commits

27 changed files with 8560 additions and 8473 deletions

3
.gitignore vendored
View file

@ -24,10 +24,11 @@ compile_flags.txt
*.err *.err
*.zip *.zip
*.err
*.pef *.pef
*.dsk *.dsk
*.bin *.bin
*.rsrc *.rsrc
*.finf *.finf
*.gdb *.gdb

1
NTMakefile generated
View file

@ -5,6 +5,7 @@ MW_CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /D_MILSKO_BUILD /DUSE_G
MW_LDFLAGS = /DLL MW_LDFLAGS = /DLL
EXE_CFLAGS = /Iinclude EXE_CFLAGS = /Iinclude
EXE_LDFLAGS = EXE_LDFLAGS =
.SUFFIXES: .obj .c .SUFFIXES: .obj .c
all: src\Mw.dll examples\basic\box.exe examples\basic\calculator.exe examples\basic\checkbox.exe examples\basic\clipboard.exe examples\basic\colorpicker.exe examples\basic\combobox.exe examples\basic\example.exe examples\basic\filechooser.exe examples\basic\image.exe examples\basic\listbox.exe examples\basic\messagebox.exe examples\basic\periodic.exe examples\basic\progressbar.exe examples\basic\radiobox.exe examples\basic\rotate.exe examples\basic\scrollbar.exe examples\basic\sevensegment.exe examples\basic\subwindow.exe examples\basic\tab.exe examples\basic\treeview.exe examples\basic\viewport.exe examples\gldemos\boing.exe examples\gldemos\clock.exe examples\gldemos\cube.exe examples\gldemos\gears.exe examples\gldemos\triangle.exe examples\gldemos\tripaint.exe all: src\Mw.dll examples\basic\box.exe examples\basic\calculator.exe examples\basic\checkbox.exe examples\basic\clipboard.exe examples\basic\colorpicker.exe examples\basic\combobox.exe examples\basic\example.exe examples\basic\filechooser.exe examples\basic\image.exe examples\basic\listbox.exe examples\basic\messagebox.exe examples\basic\periodic.exe examples\basic\progressbar.exe examples\basic\radiobox.exe examples\basic\rotate.exe examples\basic\scrollbar.exe examples\basic\sevensegment.exe examples\basic\subwindow.exe examples\basic\tab.exe examples\basic\treeview.exe examples\basic\viewport.exe examples\gldemos\boing.exe examples\gldemos\clock.exe examples\gldemos\cube.exe examples\gldemos\gears.exe examples\gldemos\triangle.exe examples\gldemos\tripaint.exe
lib: src\Mw.dll lib: src\Mw.dll

17
WatMakefile generated
View file

@ -1,10 +1,21 @@
!ifndef %mw16
CC = wcc386 -bt=nt -q CC = wcc386 -bt=nt -q
!else
CC = wcc -bt=windows -q
!endif
LD = wlink option quiet LD = wlink option quiet
!ifndef %mw16
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 -dMW_OPENGL
MW_LDFLAGS = system nt_dll MW_LDFLAGS = system nt_dll
EXE_CFLAGS = -i=include EXE_CFLAGS = -i=include
EXE_LDFLAGS = system nt EXE_LDFLAGS = system nt
!else
MW_CFLAGS = -bd -i=include -i=external/libz/include -d_MILSKO -d_MILSKO_BUILD -dUSE_GDI -dSTBI_NO_SIMD -dNO_IMAGE -dMW_16
MW_LDFLAGS = system windows_dll
EXE_LDFLAGS = system windows
!endif
all: src/Mw.dll examples/basic/box.exe examples/basic/calculator.exe examples/basic/checkbox.exe examples/basic/clipboard.exe examples/basic/colorpicker.exe examples/basic/combobox.exe examples/basic/example.exe examples/basic/filechooser.exe examples/basic/image.exe examples/basic/listbox.exe examples/basic/messagebox.exe examples/basic/periodic.exe examples/basic/progressbar.exe examples/basic/radiobox.exe examples/basic/rotate.exe examples/basic/scrollbar.exe examples/basic/sevensegment.exe examples/basic/subwindow.exe examples/basic/tab.exe examples/basic/treeview.exe examples/basic/viewport.exe examples/gldemos/boing.exe examples/gldemos/clock.exe examples/gldemos/cube.exe examples/gldemos/gears.exe examples/gldemos/triangle.exe examples/gldemos/tripaint.exe all: src/Mw.dll examples/basic/box.exe examples/basic/calculator.exe examples/basic/checkbox.exe examples/basic/clipboard.exe examples/basic/colorpicker.exe examples/basic/combobox.exe examples/basic/example.exe examples/basic/filechooser.exe examples/basic/image.exe examples/basic/listbox.exe examples/basic/messagebox.exe examples/basic/periodic.exe examples/basic/progressbar.exe examples/basic/radiobox.exe examples/basic/rotate.exe examples/basic/scrollbar.exe examples/basic/sevensegment.exe examples/basic/subwindow.exe examples/basic/tab.exe examples/basic/treeview.exe examples/basic/viewport.exe examples/gldemos/boing.exe examples/gldemos/clock.exe examples/gldemos/cube.exe examples/gldemos/gears.exe examples/gldemos/triangle.exe examples/gldemos/tripaint.exe
lib: src/Mw.dll lib: src/Mw.dll
examples: examples/basic/box.exe examples/basic/calculator.exe examples/basic/checkbox.exe examples/basic/clipboard.exe examples/basic/colorpicker.exe examples/basic/combobox.exe examples/basic/example.exe examples/basic/filechooser.exe examples/basic/image.exe examples/basic/listbox.exe examples/basic/messagebox.exe examples/basic/periodic.exe examples/basic/progressbar.exe examples/basic/radiobox.exe examples/basic/rotate.exe examples/basic/scrollbar.exe examples/basic/sevensegment.exe examples/basic/subwindow.exe examples/basic/tab.exe examples/basic/treeview.exe examples/basic/viewport.exe examples/gldemos/boing.exe examples/gldemos/clock.exe examples/gldemos/cube.exe examples/gldemos/gears.exe examples/gldemos/triangle.exe examples/gldemos/tripaint.exe examples: examples/basic/box.exe examples/basic/calculator.exe examples/basic/checkbox.exe examples/basic/clipboard.exe examples/basic/colorpicker.exe examples/basic/combobox.exe examples/basic/example.exe examples/basic/filechooser.exe examples/basic/image.exe examples/basic/listbox.exe examples/basic/messagebox.exe examples/basic/periodic.exe examples/basic/progressbar.exe examples/basic/radiobox.exe examples/basic/rotate.exe examples/basic/scrollbar.exe examples/basic/sevensegment.exe examples/basic/subwindow.exe examples/basic/tab.exe examples/basic/treeview.exe examples/basic/viewport.exe examples/gldemos/boing.exe examples/gldemos/clock.exe examples/gldemos/cube.exe examples/gldemos/gears.exe examples/gldemos/triangle.exe examples/gldemos/tripaint.exe
@ -319,8 +330,14 @@ examples/gldemos/tripaint.obj: examples/gldemos/tripaint.c
$(CC) $(EXE_CFLAGS) -fo=$@ examples/gldemos/tripaint.c $(CC) $(EXE_CFLAGS) -fo=$@ examples/gldemos/tripaint.c
!ifndef %mw16
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 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 ole32.lib library uuid.lib library user32.lib library advapi32.lib
!else
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 clibs.lib
!endif

View file

@ -2,8 +2,16 @@
MwWidget fpicker; MwWidget fpicker;
MwWidget window; MwWidget window;
MwWidget button;
/* This example does nothing on Win16 because we don't support the color picker on it (yet?) */
#ifdef MW_16
MwWidget missing_text;
#else
MwWidget button;
#endif
/* don't bother with color picker on 16-bit */
#ifndef MW_16
void MWAPI file_callback(MwWidget handle, void* user_data, void* call_data) { void MWAPI file_callback(MwWidget handle, void* user_data, void* call_data) {
char hexColor[8]; char hexColor[8];
MwRGB* rgb = call_data; MwRGB* rgb = call_data;
@ -29,6 +37,7 @@ void MWAPI file_picker(MwWidget handle, void* user_data, void* call_data) {
MwSetText(cpicker, MwNbackground, MwGetInteger(cpicker, MwNdarkTheme) ? MwDefaultDarkBackground : MwDefaultBackground); MwSetText(cpicker, MwNbackground, MwGetInteger(cpicker, MwNdarkTheme) ? MwDefaultDarkBackground : MwDefaultBackground);
} }
#endif
int main() { int main() {
MwLibraryInit(); MwLibraryInit();
@ -37,12 +46,18 @@ int main() {
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL); MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
MwSetText(window, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground); MwSetText(window, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
#ifndef MW_16
button = MwVaCreateWidget(MwButtonClass, "button", window, 160, 180, 320, 120, button = MwVaCreateWidget(MwButtonClass, "button", window, 160, 180, 320, 120,
MwNtext, "change window background", MwNtext, "change window background",
NULL); NULL);
MwSetText(button, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground); MwSetText(button, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
MwAddUserHandler(button, MwNactivateHandler, file_picker, NULL); MwAddUserHandler(button, MwNactivateHandler, file_picker, NULL);
#else
missing_text = MwVaCreateWidget(MwLabelClass, NULL, window, 160, 180, 320, 120,
MwNtext, "Color picker doesn't yet exist on 16-bit Windows",
NULL);
#endif
MwLoop(window); MwLoop(window);
} }

2443
external/stb_ds.h generated vendored

File diff suppressed because it is too large Load diff

11643
external/stb_image.h generated vendored

File diff suppressed because it is too large Load diff

View file

@ -49,6 +49,9 @@ typedef __int8 MwI8;
typedef unsigned __int8 MwU8; typedef unsigned __int8 MwU8;
#define MW_OTHER_TYPES_DEFINED #define MW_OTHER_TYPES_DEFINED
#elif defined(MW_16)
typedef long long MwI64;
typedef unsigned long long MwU64;
#else #else
/* out of hope */ /* out of hope */
typedef long MwI64; typedef long MwI64;
@ -58,6 +61,16 @@ typedef unsigned long MwU64;
#ifdef MW_OTHER_TYPES_DEFINED #ifdef MW_OTHER_TYPES_DEFINED
#undef MW_OTHER_TYPES_DEFINED #undef MW_OTHER_TYPES_DEFINED
#else #else
#ifdef MW_16
typedef long MwI32;
typedef unsigned long MwU32;
typedef int MwI16;
typedef unsigned int MwU16;
typedef signed char MwI8;
typedef unsigned char MwU8;
#else
typedef int MwI32; typedef int MwI32;
typedef unsigned int MwU32; typedef unsigned int MwU32;
@ -67,6 +80,7 @@ typedef unsigned short MwU16;
typedef signed char MwI8; typedef signed char MwI8;
typedef unsigned char MwU8; typedef unsigned char MwU8;
#endif #endif
#endif
typedef MwI64 MwOffset; typedef MwI64 MwOffset;

View file

@ -35,7 +35,11 @@ enum MwALIGNMENT {
/*! /*!
* @brief Default * @brief Default
*/ */
#ifdef MW_16
#define MwDEFAULT 0x0ffff
#else
#define MwDEFAULT 0x0fffffff #define MwDEFAULT 0x0fffffff
#endif
/*! /*!
* @brief Directory entry type * @brief Directory entry type

View file

@ -12,6 +12,9 @@
extern "C" { extern "C" {
#endif #endif
#ifdef MW_16
#error Color Picker Widget is not avaliable on 16-bit platforms
#else
/*! /*!
* @brief Creates a color picker * @brief Creates a color picker
* @param handle Widget * @param handle Widget
@ -19,6 +22,7 @@ extern "C" {
* @return Widget * @return Widget
*/ */
MWDECL MwWidget MWAPI MwColorPicker(MwWidget handle, const char* title); MWDECL MwWidget MWAPI MwColorPicker(MwWidget handle, const char* title);
#endif
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -343,6 +343,7 @@ MWDECL void (*MwLLRaise)(MwLL handle);
MWDECL void (*MwLLClip)(MwLL handle, MwRect* rect); MWDECL void (*MwLLClip)(MwLL handle, MwRect* rect);
/* font renderer */ /* font renderer */
#ifndef MW_16
MWDECL void MwFLSetup(void); MWDECL void MwFLSetup(void);
#ifdef USE_FREETYPE2 #ifdef USE_FREETYPE2
@ -362,11 +363,12 @@ MWDECL int (*MwFLTextHeight)(MwFLFont ttf, int count);
MWDECL int (*MwFLTextHeightWithText)(MwFLFont ttf, const char* text); MWDECL int (*MwFLTextHeightWithText)(MwFLFont ttf, const char* text);
MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px); MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px);
MWDECL void (*MwFLFontFree)(void* handle); MWDECL void (*MwFLFontFree)(void* handle);
#endif
#ifdef _WIN32 #if defined(_WIN32) || defined(__WINDOWS__)
MWDECL void *MwLL_winmmLib; MWDECL void* MwLL_winmmLib;
MWDECL long (__stdcall* MwLL_PFN_timeGetTime)(void); MWDECL long(WINAPI* MwLL_PFN_timeGetTime)(void);
MWDECL unsigned int (__stdcall* MwLL_PFN_timeBeginPeriod)(unsigned int period); MWDECL unsigned int(WINAPI* MwLL_PFN_timeBeginPeriod)(unsigned int period);
#endif #endif
#ifdef __cplusplus #ifdef __cplusplus

View file

@ -42,6 +42,7 @@ struct _MwLLGDIPixmap {
RGBQUAD* quad; RGBQUAD* quad;
HBITMAP hBitmap; HBITMAP hBitmap;
HDC hBitmapMem;
HBITMAP hMask; HBITMAP hMask;
HBITMAP hMask2; HBITMAP hMask2;
}; };

View file

@ -20,12 +20,19 @@
#include <wchar.h> #include <wchar.h>
#define MW_HAS_WCHAR #define MW_HAS_WCHAR
#endif #endif
#ifdef _WIN32 #if defined(_WIN32) || defined(__WINDOWS__)
#include <direct.h> #include <direct.h>
#ifdef _MILSKO #ifdef _MILSKO
#include <windows.h> #include <windows.h>
#include <mmsystem.h> #if defined(__WINDOWS__)
#include <dos.h>
#define GetSysColorBrush(x) CreateSolidBrush(GetSysColor(x))
#endif
#ifndef HALFTONE
#define HALFTONE 4
#endif
#ifndef GWLP_USERDATA #ifndef GWLP_USERDATA
#define GWLP_USERDATA GWL_USERDATA #define GWLP_USERDATA GWL_USERDATA
#define GWLP_WNDPROC GWL_WNDPROC #define GWLP_WNDPROC GWL_WNDPROC
@ -36,6 +43,9 @@
#define SetClassLongPtr SetClassLong #define SetClassLongPtr SetClassLong
#define GetClassLongPtr GetClassLong #define GetClassLongPtr GetClassLong
#endif #endif
#ifndef GWL_USERDATA
#define GWL_USERDATA (-21)
#endif
#ifndef WM_MOUSEWHEEL #ifndef WM_MOUSEWHEEL
#define WM_MOUSEWHEEL 0x020a #define WM_MOUSEWHEEL 0x020a
#define GET_WHEEL_DELTA_WPARAM(x) ((short)HIWORD(x)) #define GET_WHEEL_DELTA_WPARAM(x) ((short)HIWORD(x))
@ -90,9 +100,9 @@
#endif #endif
/* Windows */ /* Windows */
#if defined(_MILSKO) && defined(_MILSKO_BUILD) && defined(_WIN32) #if defined(_MILSKO) && defined(_MILSKO_BUILD) && defined(_WIN32) || defined(__WINDOWS__)
#define MWDECL extern __declspec(dllexport) #define MWDECL extern __declspec(dllexport)
#elif defined(_WIN32) #elif defined(_WIN32) || defined(__WINDOWS__)
#define MWDECL extern __declspec(dllimport) #define MWDECL extern __declspec(dllimport)
/* GCC/Clang */ /* GCC/Clang */
/* First check if we have __has_attribute and can check for the existence of visibility */ /* First check if we have __has_attribute and can check for the existence of visibility */
@ -112,7 +122,7 @@
#define MWDECL extern #define MWDECL extern
#endif #endif
#if defined(_WIN32) #if defined(_WIN32) || defined(__WINDOWS__)
#define MWAPI __cdecl #define MWAPI __cdecl
#else #else
#define MWAPI #define MWAPI

View file

@ -31,7 +31,9 @@
#include <Mw/Dialog/MessageBox.h> #include <Mw/Dialog/MessageBox.h>
#include <Mw/Dialog/FileChooser.h> #include <Mw/Dialog/FileChooser.h>
#include <Mw/Dialog/DirectoryChooser.h> #include <Mw/Dialog/DirectoryChooser.h>
#ifndef __WINDOWS__
#include <Mw/Dialog/ColorPicker.h> #include <Mw/Dialog/ColorPicker.h>
#endif
#include <Mw/Widget/Box.h> #include <Mw/Widget/Box.h>
#include <Mw/Widget/Button.h> #include <Mw/Widget/Button.h>

View file

@ -10,7 +10,7 @@
#include <Mw/TypeDefs.h> #include <Mw/TypeDefs.h>
#if !defined(MW_OPENGL_NO_INCLUDE) && !defined(__gl_h_) #if !defined(MW_OPENGL_NO_INCLUDE) && !defined(__gl_h_)
#ifdef _WIN32 #if defined(_WIN32) || defined(__WINDOWS__)
#include <windows.h> #include <windows.h>
#elif defined(__APPLE__) #elif defined(__APPLE__)
#else #else

View file

@ -1,11 +1,16 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
#ifdef _WIN32 #if defined(_WIN32)
typedef struct dir { typedef struct dir {
HANDLE hFind; HANDLE hFind;
WIN32_FIND_DATA ffd; WIN32_FIND_DATA ffd;
int next; int next;
} dir_t; } dir_t;
#elif defined(__WINDOWS__)
typedef struct dir {
struct find_t result;
int next;
} dir_t;
#elif defined(CLASSIC_MAC_OS) #elif defined(CLASSIC_MAC_OS)
typedef struct dir { typedef struct dir {
int dummy; int dummy;
@ -19,8 +24,8 @@ typedef struct dir {
void* MwDirectoryOpen(const char* path) { void* MwDirectoryOpen(const char* path) {
dir_t* dir = malloc(sizeof(*dir)); dir_t* dir = malloc(sizeof(*dir));
char * p; char* p;
if(!dir) { if(!dir) {
printf("Out Of Memory\n"); printf("Out Of Memory\n");
return NULL; return NULL;
} }
@ -39,6 +44,22 @@ void* MwDirectoryOpen(const char* path) {
} }
free(p); free(p);
dir->next = 1; dir->next = 1;
#elif defined(__WINDOWS__)
p = malloc(strlen(path) + 2 + 1);
strcpy(p, path);
if(strchr(path, '/') != NULL) {
strcat(p, "/");
} else {
strcat(p, "\\");
}
strcat(p, "*.*");
if(_dos_findfirst(p, _A_NORMAL, &dir->result) != 0) {
free(p);
free(dir);
return NULL;
}
free(p);
dir->next = 1;
#elif defined(CLASSIC_MAC_OS) #elif defined(CLASSIC_MAC_OS)
/* todo */ /* todo */
#else #else
@ -55,8 +76,10 @@ void* MwDirectoryOpen(const char* path) {
void MwDirectoryClose(void* handle) { void MwDirectoryClose(void* handle) {
dir_t* dir = handle; dir_t* dir = handle;
#ifdef _WIN32 #if defined(_WIN32)
FindClose(dir->hFind); FindClose(dir->hFind);
#elif defined(__WINDOWS__)
/* nothing? */
#elif defined(CLASSIC_MAC_OS) #elif defined(CLASSIC_MAC_OS)
/* todo */ /* todo */
#else #else
@ -69,20 +92,9 @@ void MwDirectoryClose(void* handle) {
MwDirectoryEntry* MwDirectoryRead(void* handle) { MwDirectoryEntry* MwDirectoryRead(void* handle) {
dir_t* dir = handle; dir_t* dir = handle;
MwDirectoryEntry* entry = malloc(sizeof(*entry)); MwDirectoryEntry* entry = malloc(sizeof(*entry));
#ifdef _WIN32 #if defined(_WIN32)
ULARGE_INTEGER* l; 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
if(!dir->next) return NULL; if(!dir->next) return NULL;
entry->name = MwStringDuplicate(dir->ffd.cFileName); entry->name = MwStringDuplicate(dir->ffd.cFileName);
@ -103,6 +115,21 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
entry->mtime = l->QuadPart / 10000000 - 11644473600; entry->mtime = l->QuadPart / 10000000 - 11644473600;
dir->next = FindNextFile(dir->hFind, &dir->ffd); dir->next = FindNextFile(dir->hFind, &dir->ffd);
#elif defined(__WINDOWS__)
if(!dir->next) return NULL;
entry->name = MwStringDuplicate(dir->result.name);
if(dir->result.attrib & _A_SUBDIR) {
entry->type = MwDIRECTORY_DIRECTORY;
} else {
entry->type = MwDIRECTORY_FILE;
}
entry->size = dir->result.size;
entry->mtime = MwDosDateTimeToUnix(dir->result.wr_date, dir->result.wr_time);
dir->next = (_dos_findnext(&dir->result) == 0);
#elif defined(CLASSIC_MAC_OS) #elif defined(CLASSIC_MAC_OS)
/* todo */ /* todo */
#else #else
@ -138,7 +165,7 @@ void MwDirectoryFreeEntry(MwDirectoryEntry* entry) {
} }
char* MwDirectoryCurrent(void) { char* MwDirectoryCurrent(void) {
#ifdef _WIN32 #if defined(_WIN32) || defined(__WINDOWS__)
int len = GetCurrentDirectory(0, NULL); int len = GetCurrentDirectory(0, NULL);
char* out = malloc(len); char* out = malloc(len);
@ -152,7 +179,7 @@ char* MwDirectoryCurrent(void) {
#endif #endif
} }
#ifdef _WIN32 #if defined(_WIN32) || defined(__WINDOWS__)
#define DIRSEP '\\' #define DIRSEP '\\'
#else #else
#define DIRSEP '/' #define DIRSEP '/'

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
#if defined(_WIN32) #if defined(_WIN32) || defined(__WINDOWS__)
void* MwDynamicOpen(const char* path) { void* MwDynamicOpen(const char* path) {
return LoadLibrary(path); return LoadLibrary(path);
} }

View file

@ -1,6 +1,6 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
#if defined(_WIN32) #if defined(_WIN32) || defined(__WINDOWS__)
long MwTimeGetTick(void) { long MwTimeGetTick(void) {
return MwLL_PFN_timeGetTime(); return MwLL_PFN_timeGetTime();
} }

View file

@ -10,6 +10,7 @@ typedef struct userdata {
int max_set; int max_set;
} userdata_t; } userdata_t;
#ifndef __WINDOWS__
static struct symtbl { static struct symtbl {
void* lib_dwmapi; void* lib_dwmapi;
void* shell32lib; void* shell32lib;
@ -22,8 +23,6 @@ static struct symtbl {
void (*DragFinish)(HDROP hDrop); void (*DragFinish)(HDROP hDrop);
} wsymtbl; } wsymtbl;
static int is_plgblt_reliable = 0;
#define DwmSetWindowAttribute wsymtbl.DwmSetWindowAttribute #define DwmSetWindowAttribute wsymtbl.DwmSetWindowAttribute
/* Dark theme detection for classic Windows: check if the user has set their theme to be dark. */ /* Dark theme detection for classic Windows: check if the user has set their theme to be dark. */
@ -70,6 +69,15 @@ static void detect_darktheme(MwLL handle) {
MwLLDispatch(handle, dark_theme, &t); MwLLDispatch(handle, dark_theme, &t);
} }
#endif
/* There isn't any plgblt on Win16 at all */
#ifdef __WINDOWS__
#define is_plgblt_reliable 0
#else
static int is_plgblt_reliable = 0;
#endif
static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) { static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
userdata_t* u = (userdata_t*)GetWindowLongPtr(hWnd, GWLP_USERDATA); userdata_t* u = (userdata_t*)GetWindowLongPtr(hWnd, GWLP_USERDATA);
@ -147,7 +155,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
p.button = MwMOUSE_RIGHT; p.button = MwMOUSE_RIGHT;
} }
SetCapture(NULL); SetCapture(0);
MwLLDispatch(u->ll, up, &p); MwLLDispatch(u->ll, up, &p);
break; break;
} }
@ -168,6 +176,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
MwLLDispatch(u->ll, up, &p); MwLLDispatch(u->ll, up, &p);
break; break;
} }
#ifndef __WINDOWS__
case WM_DROPFILES: case WM_DROPFILES:
{ {
HDROP hDrop = (HDROP)wp; HDROP hDrop = (HDROP)wp;
@ -189,6 +198,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
wsymtbl.DragFinish(hDrop); wsymtbl.DragFinish(hDrop);
break; break;
} }
#endif
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{ {
MwPoint p; MwPoint p;
@ -249,12 +259,18 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
case WM_CHAR: case WM_CHAR:
case WM_SYSCHAR: case WM_SYSCHAR:
{ {
int n = wp; #ifndef __WINDOWS__
int n = wp;
#else
unsigned long n = wp;
#endif
const int base = 'A' - 1; const int base = 'A' - 1;
if(n != 0x1b && n <= 0x1f) { if(n != 0x1b && n <= 0x1f) {
n = (n + base) | MwKEY_CONTROL_FLAG; n = (n + base) | MwKEY_CONTROL_FLAG;
#ifndef __WINDOWS__
if(!(GetKeyState(VK_LSHIFT) || GetKeyState(VK_RSHIFT))) n += 0x20; if(!(GetKeyState(VK_LSHIFT) || GetKeyState(VK_RSHIFT))) n += 0x20;
#endif
} }
if(HIBYTE(VkKeyScan(wp)) & 2) n |= MwKEY_CONTROL_FLAG; if(HIBYTE(VkKeyScan(wp)) & 2) n |= MwKEY_CONTROL_FLAG;
if(msg == WM_SYSCHAR) n |= MwKEY_ALT_FLAG; if(msg == WM_SYSCHAR) n |= MwKEY_ALT_FLAG;
@ -277,9 +293,11 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
case WM_SYSKEYDOWN: case WM_SYSKEYDOWN:
case WM_SYSKEYUP: case WM_SYSKEYUP:
{ {
#ifndef __WINDOWS__
int n = -1; int n = -1;
#else
if(wp == VK_MENU && msg == WM_KEYUP) return 0; unsigned long n = -1;
#endif
switch(wp) { switch(wp) {
case VK_LEFT: case VK_LEFT:
n = MwKEY_LEFT; n = MwKEY_LEFT;
@ -302,12 +320,14 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
case VK_ESCAPE: case VK_ESCAPE:
n = MwKEY_ESCAPE; n = MwKEY_ESCAPE;
break; break;
#ifndef __WINDOWS__
case VK_LSHIFT: case VK_LSHIFT:
n = MwKEY_LEFTSHIFT; n = MwKEY_LEFTSHIFT;
break; break;
case VK_RSHIFT: case VK_RSHIFT:
n = MwKEY_RIGHTSHIFT; n = MwKEY_RIGHTSHIFT;
break; break;
#endif
case VK_MENU: case VK_MENU:
n = MwKEY_ALT; n = MwKEY_ALT;
break; break;
@ -365,8 +385,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
case WM_SETCURSOR: case WM_SETCURSOR:
{ {
if(LOWORD(lp) != HTCLIENT) return DefWindowProc(hWnd, msg, wp, lp); if(LOWORD(lp) != HTCLIENT) return DefWindowProc(hWnd, msg, wp, lp);
if(u->ll->gdi.cursor != NULL) SetCursor(u->ll->gdi.cursor); if(u->ll->gdi.cursor != 0) SetCursor(u->ll->gdi.cursor);
break;
} }
case WM_USER: case WM_USER:
{ {
@ -379,9 +398,11 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
char* s = (char*)lp; char* s = (char*)lp;
LPARAM style = GetWindowLongPtr(hWnd, GWL_STYLE); LPARAM style = GetWindowLongPtr(hWnd, GWL_STYLE);
#ifndef __WINDOWS__
if(!(style & WS_CHILD)) { if(!(style & WS_CHILD)) {
if(s != NULL && strcmp(s, "ImmersiveColorSet") == 0) detect_darktheme(u->ll); if(s != NULL && strcmp(s, "ImmersiveColorSet") == 0) detect_darktheme(u->ll);
} }
#endif
break; break;
} }
default: default:
@ -395,7 +416,11 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) { static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLL r = malloc(sizeof(*r)); MwLL r = malloc(sizeof(*r));
userdata_t* u = malloc(sizeof(*u)); userdata_t* u = malloc(sizeof(*u));
WNDCLASSEX wc; #ifdef __WINDOWS__
WNDCLASS wc;
#else
WNDCLASSEX wc;
#endif
if(!r || !u) { if(!r || !u) {
printf("Out Of Memory\n"); printf("Out Of Memory\n");
@ -403,7 +428,9 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
} }
memset(&wc, 0, sizeof(wc)); memset(&wc, 0, sizeof(wc));
wc.cbSize = sizeof(WNDCLASSEX); #ifndef __WINDOWS__
wc.cbSize = sizeof(WNDCLASSEX);
#endif
wc.style = CS_HREDRAW | CS_VREDRAW; wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = wndproc; wc.lpfnWndProc = wndproc;
wc.cbClsExtra = 0; wc.cbClsExtra = 0;
@ -411,14 +438,22 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
wc.hInstance = (HINSTANCE)GetModuleHandle(NULL); wc.hInstance = (HINSTANCE)GetModuleHandle(NULL);
wc.lpszClassName = "milsko"; wc.lpszClassName = "milsko";
wc.lpszMenuName = NULL; wc.lpszMenuName = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW); wc.hCursor = LoadCursor(0, IDC_ARROW);
wc.hbrBackground = GetSysColorBrush(COLOR_MENU); wc.hbrBackground = GetSysColorBrush(COLOR_MENU);
wc.hIcon = LoadIcon(NULL, IDI_WINLOGO); #ifndef __WINDOWS__
wc.hIconSm = NULL; wc.hIcon = LoadIcon(NULL, IDI_WINLOGO);
wc.hIconSm = NULL;
#else
wc.hIcon = LoadIcon(0, IDI_APPLICATION);
#endif
MwLLCreateCommon(r); MwLLCreateCommon(r);
#ifdef __WINDOWS__
RegisterClass(&wc);
#else
RegisterClassEx(&wc); RegisterClassEx(&wc);
#endif
r->common.copy_buffer = 1; r->common.copy_buffer = 1;
r->common.type = MwLLBackendGDI; r->common.type = MwLLBackendGDI;
@ -427,12 +462,12 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
if(parent == NULL) r->gdi.get_darktheme = 1; if(parent == NULL) r->gdi.get_darktheme = 1;
r->gdi.force_render = 0; r->gdi.force_render = 0;
r->gdi.grabbed = 0; r->gdi.grabbed = 0;
r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL); r->gdi.hWnd = CreateWindow("milsko", "Milsko", parent == NULL ? (WS_OVERLAPPEDWINDOW) : (WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? 0 : parent->gdi.hWnd, 0, wc.hInstance, NULL);
r->gdi.hInstance = wc.hInstance; r->gdi.hInstance = wc.hInstance;
r->gdi.cursor = NULL; r->gdi.cursor = 0;
r->gdi.icon = NULL; r->gdi.icon = 0;
r->gdi.clip = NULL; r->gdi.clip = 0;
u->ll = r; u->ll = r;
u->min_set = 0; u->min_set = 0;
@ -447,7 +482,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
rc.right = width; rc.right = width;
rc.bottom = height; rc.bottom = height;
AdjustWindowRect(&rc, GetWindowLongPtr(r->gdi.hWnd, GWL_STYLE), FALSE); AdjustWindowRect(&rc, GetWindowLongPtr(r->gdi.hWnd, GWL_STYLE), FALSE);
SetWindowPos(r->gdi.hWnd, NULL, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE); SetWindowPos(r->gdi.hWnd, 0, rc.left, rc.top, rc.right - rc.left, rc.bottom - rc.top, SWP_NOMOVE);
ShowWindow(r->gdi.hWnd, SW_NORMAL); ShowWindow(r->gdi.hWnd, SW_NORMAL);
UpdateWindow(r->gdi.hWnd); UpdateWindow(r->gdi.hWnd);
@ -455,7 +490,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
InvalidateRect(r->gdi.hWnd, NULL, FALSE); InvalidateRect(r->gdi.hWnd, NULL, FALSE);
} }
SetWindowPos(r->gdi.hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetWindowPos(r->gdi.hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
return r; return r;
} }
@ -467,9 +502,9 @@ static void MwLLDestroyImpl(MwLL handle) {
SetWindowLongPtr(handle->gdi.hWnd, GWLP_USERDATA, (LPARAM)NULL); SetWindowLongPtr(handle->gdi.hWnd, GWLP_USERDATA, (LPARAM)NULL);
DestroyWindow(handle->gdi.hWnd); DestroyWindow(handle->gdi.hWnd);
if(handle->gdi.clip != NULL) DeleteObject(handle->gdi.clip); if(handle->gdi.clip) DeleteObject(handle->gdi.clip);
if(handle->gdi.cursor != NULL) DestroyCursor(handle->gdi.cursor); if(handle->gdi.cursor) DestroyCursor(handle->gdi.cursor);
free(handle); free(handle);
} }
@ -531,7 +566,7 @@ static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
return NULL; return NULL;
} }
c->gdi.brush = NULL; c->gdi.brush = 0;
MwLLColorUpdate(handle, c, r, g, b); MwLLColorUpdate(handle, c, r, g, b);
@ -551,7 +586,7 @@ static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
color = GetNearestColor(dc, RGB(r, g, b)); color = GetNearestColor(dc, RGB(r, g, b));
if(c->gdi.brush != NULL) DeleteObject(c->gdi.brush); if(c->gdi.brush != 0) DeleteObject(c->gdi.brush);
c->gdi.brush = CreateSolidBrush(color); c->gdi.brush = CreateSolidBrush(color);
c->common.red = r; c->common.red = r;
c->common.green = g; c->common.green = g;
@ -579,12 +614,12 @@ static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsign
} }
static void MwLLSetXYImpl(MwLL handle, int x, int y) { static void MwLLSetXYImpl(MwLL handle, int x, int y) {
SetWindowPos(handle->gdi.hWnd, NULL, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER); SetWindowPos(handle->gdi.hWnd, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
} }
static void MwLLSetWHImpl(MwLL handle, int w, int h) { static void MwLLSetWHImpl(MwLL handle, int w, int h) {
SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(handle->gdi.hWnd, 0, 0, 0, w, h, SWP_NOMOVE | SWP_NOZORDER);
InvalidateRect(handle->gdi.hWnd, NULL, FALSE); InvalidateRect(handle->gdi.hWnd, 0, FALSE);
} }
static void MwLLSetTitleImpl(MwLL handle, const char* title) { static void MwLLSetTitleImpl(MwLL handle, const char* title) {
@ -605,12 +640,12 @@ static void MwLLNextEventImpl(MwLL handle) {
(void)handle; (void)handle;
#ifndef __WINDOWS__
if(handle->gdi.get_clipboard) { if(handle->gdi.get_clipboard) {
HGLOBAL hg; HGLOBAL hg;
if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) { if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != 0) {
int sz = GlobalSize(hg);
char* txt = malloc(sz);
char* clp = GlobalLock(hg); char* clp = GlobalLock(hg);
char* txt = malloc(GlobalSize(hg));
if(!txt || !clp) { if(!txt || !clp) {
printf("Out of Memory\n"); printf("Out of Memory\n");
@ -633,23 +668,30 @@ static void MwLLNextEventImpl(MwLL handle) {
handle->gdi.get_clipboard = 0; handle->gdi.get_clipboard = 0;
} }
#endif
#ifndef __WINDOWS__
if(handle->gdi.get_darktheme) { if(handle->gdi.get_darktheme) {
detect_darktheme(handle); detect_darktheme(handle);
handle->gdi.get_darktheme = 0; handle->gdi.get_darktheme = 0;
} }
while(PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { #endif
if(GetMessage(&msg, NULL, 0, 0)) { while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) {
TranslateMessage(&msg); GetMessage(&msg, handle->gdi.hWnd, 0, 0);
DispatchMessage(&msg); TranslateMessage(&msg);
} DispatchMessage(&msg);
} }
} }
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) { static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
MwLLPixmap r = malloc(sizeof(*r)); MwLLPixmap r = malloc(sizeof(*r));
HDC dc = GetDC(handle->gdi.hWnd); HDC dc = GetDC(handle->gdi.hWnd);
#ifndef __WINDOWS__
BITMAPINFOHEADER bmih; BITMAPINFOHEADER bmih;
#else
BITMAPINFO bmi;
#endif
if(!r) { if(!r) {
printf("Out Of Memory\n"); printf("Out Of Memory\n");
@ -667,6 +709,7 @@ static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int wid
r->common.width = width; r->common.width = width;
r->common.height = height; r->common.height = height;
#ifndef __WINDOWS__
bmih.biSize = sizeof(bmih); bmih.biSize = sizeof(bmih);
bmih.biWidth = width; bmih.biWidth = width;
bmih.biHeight = -(LONG)height; bmih.biHeight = -(LONG)height;
@ -680,9 +723,15 @@ static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int wid
bmih.biClrImportant = 0; bmih.biClrImportant = 0;
r->gdi.hBitmap = CreateDIBSection(dc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&r->gdi.quad, NULL, (DWORD)0); r->gdi.hBitmap = CreateDIBSection(dc, (BITMAPINFO*)&bmih, DIB_RGB_COLORS, (void**)&r->gdi.quad, NULL, (DWORD)0);
#else
r->gdi.hBitmap = CreateCompatibleBitmap(dc, width, height);
r->gdi.hBitmapMem = CreateCompatibleDC(dc);
SelectObject(r->gdi.hBitmapMem, r->gdi.hBitmap);
SetDIBits(r->gdi.hBitmapMem, r->gdi.hBitmap, 0, height, r->common.raw, &bmi, DIB_RGB_COLORS);
#endif
r->gdi.hMask = NULL; r->gdi.hMask = 0;
r->gdi.hMask2 = NULL; r->gdi.hMask2 = 0;
ReleaseDC(handle->gdi.hWnd, dc); ReleaseDC(handle->gdi.hWnd, dc);
@ -728,8 +777,8 @@ static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
} }
} }
if(r->gdi.hMask != NULL) DeleteObject(r->gdi.hMask); if(r->gdi.hMask != 0) DeleteObject(r->gdi.hMask);
if(r->gdi.hMask2 != NULL) DeleteObject(r->gdi.hMask2); if(r->gdi.hMask2 != 0) DeleteObject(r->gdi.hMask2);
r->gdi.hMask = CreateBitmap(r->common.width, r->common.height, 1, 1, words); r->gdi.hMask = CreateBitmap(r->common.width, r->common.height, 1, 1, words);
r->gdi.hMask2 = CreateBitmap(r->common.width, r->common.height, 1, 1, words2); r->gdi.hMask2 = CreateBitmap(r->common.width, r->common.height, 1, 1, words2);
@ -763,18 +812,27 @@ static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
SelectObject(hmdc, pixmap->gdi.hBitmap); SelectObject(hmdc, pixmap->gdi.hBitmap);
#ifndef __WINDOWS__
if(!is_plgblt_reliable || PlgBlt(handle->gdi.hDC, p, hmdc, 0, 0, pixmap->common.width, pixmap->common.height, pixmap->gdi.hMask, 0, 0) == 0) { if(!is_plgblt_reliable || PlgBlt(handle->gdi.hDC, p, hmdc, 0, 0, pixmap->common.width, pixmap->common.height, pixmap->gdi.hMask, 0, 0) == 0) {
#endif
SelectObject(hmdc, pixmap->gdi.hMask2); SelectObject(hmdc, pixmap->gdi.hMask2);
StretchBlt(handle->gdi.hDC, rect->x, rect->y, rect->width, rect->height, hmdc, 0, 0, pixmap->common.width, pixmap->common.height, SRCAND); StretchBlt(handle->gdi.hDC, rect->x, rect->y, rect->width, rect->height, hmdc, 0, 0, pixmap->common.width, pixmap->common.height, SRCAND);
SelectObject(hmdc, pixmap->gdi.hBitmap); SelectObject(hmdc, pixmap->gdi.hBitmap);
StretchBlt(handle->gdi.hDC, rect->x, rect->y, rect->width, rect->height, hmdc, 0, 0, pixmap->common.width, pixmap->common.height, SRCPAINT); StretchBlt(handle->gdi.hDC, rect->x, rect->y, rect->width, rect->height, hmdc, 0, 0, pixmap->common.width, pixmap->common.height, SRCPAINT);
#ifndef __WINDOWS__
} }
#endif
DeleteDC(hmdc); DeleteDC(hmdc);
} }
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) { static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
/* it's probably (presumably) not possible to set the icon on 16-bit windows */
#ifdef __WINDOWS__
(void)handle;
(void)pixmap;
#else
ICONINFO ii; ICONINFO ii;
memset(&ii, 0, sizeof(ii)); memset(&ii, 0, sizeof(ii));
@ -788,6 +846,7 @@ static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
handle->gdi.icon = CreateIconIndirect(&ii); handle->gdi.icon = CreateIconIndirect(&ii);
SendMessage(handle->gdi.hWnd, WM_SETICON, ICON_SMALL, (LPARAM)handle->gdi.icon); SendMessage(handle->gdi.hWnd, WM_SETICON, ICON_SMALL, (LPARAM)handle->gdi.icon);
SendMessage(handle->gdi.hWnd, WM_SETICON, ICON_BIG, (LPARAM)handle->gdi.icon); SendMessage(handle->gdi.hWnd, WM_SETICON, ICON_BIG, (LPARAM)handle->gdi.icon);
#endif
} }
static void MwLLForceRenderImpl(MwLL handle) { static void MwLLForceRenderImpl(MwLL handle) {
@ -848,11 +907,19 @@ HCURSOR MwLLGDICreateCursor(MwCursor* image, MwCursor* mask) {
} }
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) { static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
HCURSOR cursor = MwLLGDICreateCursor(image, mask); if(image && mask) {
HCURSOR cursor = MwLLGDICreateCursor(image, mask);
if(handle->gdi.cursor != NULL) DestroyCursor(handle->gdi.cursor); if(handle->gdi.cursor != 0) DestroyCursor(handle->gdi.cursor);
if(handle->gdi.icon != NULL) DestroyIcon(handle->gdi.icon); if(handle->gdi.icon != 0) DestroyIcon(handle->gdi.icon);
handle->gdi.cursor = cursor; handle->gdi.cursor = cursor;
}
/* Only on Win16: hide the cursor outright if image/mask are null */
#ifndef __WINDOWS__
else if(!image && !mask) {
ShowCursor(FALSE);
}
#endif
} }
static void MwLLDetachImpl(MwLL handle, MwPoint* point) { static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
@ -866,12 +933,16 @@ static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
GetClientRect(handle->gdi.hWnd, &rc2); GetClientRect(handle->gdi.hWnd, &rc2);
#ifdef __WINDOWS__
if(lp2 & WS_POPUP) {
#else
if(lp2 & WS_EX_TOOLWINDOW) { if(lp2 & WS_EX_TOOLWINDOW) {
#endif
SetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE, (LPARAM)lp); SetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE, (LPARAM)lp);
} else { } else {
SetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE, (LPARAM)WS_OVERLAPPEDWINDOW | lp); SetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE, (LPARAM)WS_OVERLAPPEDWINDOW | lp);
} }
SetParent(handle->gdi.hWnd, NULL); SetParent(handle->gdi.hWnd, 0);
rc.left += point->x; rc.left += point->x;
rc.top += point->y; rc.top += point->y;
@ -917,7 +988,7 @@ static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
SetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE, lp); SetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE, lp);
SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); SetWindowPos(handle->gdi.hWnd, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
} }
static void MwLLFocusImpl(MwLL handle) { static void MwLLFocusImpl(MwLL handle) {
@ -954,6 +1025,11 @@ static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
} }
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) { static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
#ifdef __WINDOWS__
(void)handle;
(void)text;
(void)clipboard_type;
#else
HGLOBAL hg; HGLOBAL hg;
(void)clipboard_type; (void)clipboard_type;
if(OpenClipboard(handle->gdi.hWnd) != 0) { if(OpenClipboard(handle->gdi.hWnd) != 0) {
@ -988,6 +1064,7 @@ static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_ty
CloseClipboard(); CloseClipboard();
} }
#endif
} }
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) { static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
@ -1001,14 +1078,17 @@ static void MwLLMakeToolWindowImpl(MwLL handle) {
int w, h; int w, h;
SetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE, (LPARAM)lp); SetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE, (LPARAM)lp);
#ifdef __WINDOWS__
SetWindowLongPtr(handle->gdi.hWnd, GWL_EXSTYLE, (LPARAM)WS_POPUP);
#else
SetWindowLongPtr(handle->gdi.hWnd, GWL_EXSTYLE, (LPARAM)WS_EX_TOOLWINDOW); SetWindowLongPtr(handle->gdi.hWnd, GWL_EXSTYLE, (LPARAM)WS_EX_TOOLWINDOW);
#endif
GetClientRect(handle->gdi.hWnd, &rc); GetClientRect(handle->gdi.hWnd, &rc);
w = rc.right - rc.left; w = rc.right - rc.left;
h = rc.bottom - rc.top; h = rc.bottom - rc.top;
SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, w, h, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(handle->gdi.hWnd, 0, 0, 0, w, h, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
} }
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) { static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
@ -1043,13 +1123,21 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
} }
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) { static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) {
#ifdef __WINDOWS__
(void)handle;
(void)toggle;
#else
BOOL v = toggle ? TRUE : FALSE; BOOL v = toggle ? TRUE : FALSE;
if(DwmSetWindowAttribute) if(DwmSetWindowAttribute)
DwmSetWindowAttribute(handle->gdi.hWnd, 20, &v, sizeof(v)); DwmSetWindowAttribute(handle->gdi.hWnd, 20, &v, sizeof(v));
#endif
} }
static MwBool MwLLDoModernImpl(MwLL handle) { static MwBool MwLLDoModernImpl(MwLL handle) {
#ifdef __WINDOWS__
return MwFALSE;
#else
OSVERSIONINFO osvi; OSVERSIONINFO osvi;
(void)handle; (void)handle;
@ -1063,38 +1151,41 @@ static MwBool MwLLDoModernImpl(MwLL handle) {
} }
return MwTRUE; return MwTRUE;
#endif
} }
static void MwLLRaiseImpl(MwLL handle) { static void MwLLRaiseImpl(MwLL handle) {
SetWindowPos(handle->gdi.hWnd, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE); SetWindowPos(handle->gdi.hWnd, 0, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE);
} }
static void MwLLClipImpl(MwLL handle, MwRect* rect) { static void MwLLClipImpl(MwLL handle, MwRect* rect) {
if(rect == NULL) { if(rect == NULL) {
SelectClipRgn(handle->gdi.hDC, NULL); SelectClipRgn(handle->gdi.hDC, 0);
if(handle->gdi.clip != NULL) { if(handle->gdi.clip) {
DeleteObject(handle->gdi.clip); DeleteObject(handle->gdi.clip);
handle->gdi.clip = NULL; handle->gdi.clip = 0;
} }
} else { } else {
HRGN clip = CreateRectRgn(rect->x, rect->y, rect->x + rect->width, rect->y + rect->height); HRGN clip = CreateRectRgn(rect->x, rect->y, rect->x + rect->width, rect->y + rect->height);
SelectClipRgn(handle->gdi.hDC, clip); SelectClipRgn(handle->gdi.hDC, clip);
if(handle->gdi.clip != NULL) DeleteObject(handle->gdi.clip); if(handle->gdi.clip != 0) DeleteObject(handle->gdi.clip);
handle->gdi.clip = clip; handle->gdi.clip = clip;
} }
} }
static void MwLLSetupDragAndDropImpl(MwLL handle) { static void MwLLSetupDragAndDropImpl(MwLL handle) {
#ifndef __WINDOWS__
wsymtbl.DragAcceptFiles(handle->gdi.hWnd, TRUE); wsymtbl.DragAcceptFiles(handle->gdi.hWnd, TRUE);
#endif
} }
static int MwLLGDICallInitImpl(void) { static int MwLLGDICallInitImpl(void) {
#ifndef __WINDOWS__
void* ntdll; void* ntdll;
memset(&wsymtbl, 0, sizeof(wsymtbl)); memset(&wsymtbl, 0, sizeof(wsymtbl));
wsymtbl.lib_dwmapi = MwDynamicOpen("dwmapi.dll"); wsymtbl.lib_dwmapi = MwDynamicOpen("dwmapi.dll");
@ -1128,6 +1219,7 @@ static int MwLLGDICallInitImpl(void) {
wsymtbl.has_drag_and_drop = MwTRUE; wsymtbl.has_drag_and_drop = MwTRUE;
} }
dnd_error: dnd_error:
#endif
/* TODO: check properly */ /* TODO: check properly */
return 0; return 0;

File diff suppressed because it is too large Load diff

View file

@ -1006,10 +1006,14 @@ void MwDispatchError(int code, const char* message) {
if(error_handler != NULL) { if(error_handler != NULL) {
error_handler(code, message, error_user_data); error_handler(code, message, error_user_data);
} else { } else {
#ifdef _WIN32 #if defined(_WIN32) || defined(__WINDOWS__)
char buffer[1024]; char buffer[1024];
MwStringPrintIntoBuffer(buffer, 1024, "Error: %s\r\nCode : %d\r\n\r\nMilsko is exiting.", message, code); MwStringPrintIntoBuffer(buffer, 1024, "Error: %s\r\nCode : %d\r\n\r\nMilsko is exiting.", message, code);
#if defined(__WINDOWS__)
MessageBox(NULL, buffer, "Error", MB_ICONHAND | MB_OK);
#else
MessageBox(NULL, buffer, "Error", MB_ICONERROR | MB_OK); MessageBox(NULL, buffer, "Error", MB_ICONERROR | MB_OK);
#endif
#else #else
fprintf(stderr, "Error: %s\nCode : %d\n\nMilsko is exiting.", message, code); fprintf(stderr, "Error: %s\nCode : %d\n\nMilsko is exiting.", message, code);
#endif #endif
@ -1089,15 +1093,17 @@ int MwLibraryInit(void) {
NULL}; NULL};
int i; int i;
#ifdef _WIN32 #if defined(_WIN32) || defined(__WINDOWS__)
/* /*
There's no Windows configuration that Milsko supports that doesn't have winmm. There's no Windows configuration that Milsko supports that doesn't have winmm.
However, uhh, Visual Studio 2022. For some fucking reason. This could maybe be removed? However if we ever get any proof of concept working on Win2.0
Thanks for coming to my TED Talk. this could be useful.
*/ */
MwLL_winmmLib = LoadLibrary("winmm.dll"); MwLL_winmmLib = LoadLibrary("winmm.dll");
MwLL_PFN_timeGetTime = (void *)GetProcAddress(MwLL_winmmLib, "timeGetTime"); MwLL_PFN_timeGetTime = (void*)GetProcAddress(MwLL_winmmLib, "timeGetTime");
MwLL_PFN_timeBeginPeriod = (void *)GetProcAddress(MwLL_winmmLib, "timeBeginPeriod"); MwLL_PFN_timeBeginPeriod = (void*)GetProcAddress(MwLL_winmmLib, "timeBeginPeriod");
assert(MwLL_PFN_timeGetTime);
assert(MwLL_PFN_timeBeginPeriod);
MwLL_PFN_timeBeginPeriod(10); MwLL_PFN_timeBeginPeriod(10);
#endif #endif
@ -1112,7 +1118,9 @@ int MwLibraryInit(void) {
MwColorTableInit(); MwColorTableInit();
#ifndef MW_16
MwFLSetup(); MwFLSetup();
#endif
for(i = 0; calls[i] != NULL; i++) { for(i = 0; calls[i] != NULL; i++) {
if(calls[i]() == 0) return 0; if(calls[i]() == 0) return 0;

View file

@ -1,5 +1,7 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
#ifndef MW_16
#define WIN_SIZE 464 #define WIN_SIZE 464
#define PICKER_SIZE 364 #define PICKER_SIZE 364
#define IMG_POS_X(w) ((w - PICKER_SIZE) / 2) #define IMG_POS_X(w) ((w - PICKER_SIZE) / 2)
@ -378,3 +380,5 @@ MwWidget MwColorPicker(MwWidget handle, const char* title) {
return window; return window;
} }
#endif

View file

@ -146,7 +146,7 @@ static void MWAPI nav_activate(MwWidget handle, void* user, void* call) {
(void)user; (void)user;
if(strcmp(e, "Home") == 0) { if(strcmp(e, "Home") == 0) {
#if defined(_WIN32) || defined(CLASSIC_MAC_OS) #if defined(_WIN32) || defined(CLASSIC_MAC_OS) || defined(__WINDOWS__)
#else #else
struct passwd* p = getpwuid(getuid()); struct passwd* p = getpwuid(getuid());
@ -505,8 +505,9 @@ static void scan(MwWidget handle, const char* path, int record) {
} }
static void setup_fallback_filechooser(MwWidget window, int dir) { static void setup_fallback_filechooser(MwWidget window, int dir) {
char* path; char* path;
MwLLPixmap icon; MwLLPixmap icon;
filechooser_t* fc = malloc(sizeof(*fc)); filechooser_t* fc = malloc(sizeof(*fc));
memset(fc, 0, sizeof(*fc)); memset(fc, 0, sizeof(*fc));

View file

@ -124,7 +124,7 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
int ColorDiff = get_color_diff(handle); int ColorDiff = get_color_diff(handle);
double darkenStep = (ColorDiff / 2.) / rect->height; double darkenStep = (ColorDiff / 2.) / rect->height;
unsigned long sz = 1 * rect->height * 4; unsigned long sz = 1 * rect->height * 4;
unsigned char* data = malloc(sz*2); unsigned char* data = malloc(sz * 2);
MwRect r = *rect; MwRect r = *rect;
if(!data) { if(!data) {
return; return;
@ -952,8 +952,8 @@ MwLLPixmap MwLoadXPM(MwWidget handle, char** data) {
} }
} }
rgb = malloc(row * col * 4); rgb = malloc(row * col * 4);
comp = malloc(cpp + 1); comp = malloc(cpp + 1);
if(!rgb || !comp) { if(!rgb || !comp) {
printf("Null malloc! Out of memory?"); printf("Null malloc! Out of memory?");
return NULL; return NULL;

View file

@ -1,9 +1,9 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
#ifdef _WIN32 #if defined(WIN32) || defined(__WINDOWS__)
void *MwLL_winmmLib; void* MwLL_winmmLib;
long (__stdcall* MwLL_PFN_timeGetTime)(void); long(WINAPI* MwLL_PFN_timeGetTime)(void);
unsigned int (__stdcall* MwLL_PFN_timeBeginPeriod)(unsigned int period); unsigned int(WINAPI* MwLL_PFN_timeBeginPeriod)(unsigned int period);
#endif #endif
MwLL (*MwLLCreate)(MwLL parent, int x, int y, int width, int height) = NULL; MwLL (*MwLLCreate)(MwLL parent, int x, int y, int width, int height) = NULL;

View file

@ -1,13 +1,15 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
#ifndef __WINDOWS
int (*MwFLDrawText)(MwWidget handle, MwFLFont font, MwPoint* point, const char* text, MwLLColor color) = NULL; int (*MwFLDrawText)(MwWidget handle, MwFLFont font, MwPoint* point, const char* text, MwLLColor color) = NULL;
int (*MwFLTextWidth)(MwFLFont font, const char* text) = NULL; int (*MwFLTextWidth)(MwFLFont font, const char* text) = NULL;
int (*MwFLTextHeight)(MwFLFont font, int count) = NULL; int (*MwFLTextHeight)(MwFLFont font, int count) = NULL;
int (*MwFLTextHeightWithText)(MwFLFont ttf, const char* text) = NULL; int (*MwFLTextHeightWithText)(MwFLFont ttf, const char* text) = NULL;
void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px) = NULL; void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px) = NULL;
void (*MwFLFontFree)(void* handle) = NULL; void (*MwFLFontFree)(void* handle) = NULL;
#endif
#if defined(USE_FREETYPE2) || defined(USE_STB_TRUETYPE) || defined(USE_GDI_TEXT) #if (defined(USE_FREETYPE2) || defined(USE_STB_TRUETYPE))
#define TTF #define TTF
#endif #endif
@ -313,6 +315,7 @@ static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text,
free(px); free(px);
} }
#ifndef __INWDOWS__
typedef int (*call_t)(void); typedef int (*call_t)(void);
void MwFLSetup(void) { void MwFLSetup(void) {
call_t calls[] = { call_t calls[] = {
@ -332,3 +335,4 @@ void MwFLSetup(void) {
if(calls[i]() == 0) return; if(calls[i]() == 0) return;
} }
} }
#endif

View file

@ -122,6 +122,7 @@ static void draw_h(MwWidget handle, unsigned char* raw, int x, int y, int stride
} }
} }
#ifndef HAVE_SEVEN_SEGMENT
static void draw_seven_segment(MwWidget handle) { static void draw_seven_segment(MwWidget handle) {
MwRect r; MwRect r;
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground)); MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
@ -311,6 +312,7 @@ static void draw_seven_segment(MwWidget handle) {
MwLLDestroyPixmap(px); MwLLDestroyPixmap(px);
} }
#endif
static void draw_normal(MwWidget handle) { static void draw_normal(MwWidget handle) {
MwRect r; MwRect r;
@ -377,9 +379,11 @@ static void prop_change(MwWidget handle, const char* key) {
if(strcmp(key, MwNsevenSegment) == 0) { if(strcmp(key, MwNsevenSegment) == 0) {
MwLabel lab = handle->internal; MwLabel lab = handle->internal;
#ifndef HAVE_SEVEN_SEGMENT
if(MwGetInteger(handle, MwNsevenSegment)) if(MwGetInteger(handle, MwNsevenSegment))
lab->draw = draw_seven_segment; lab->draw = draw_seven_segment;
else else
#endif
lab->draw = draw_normal; lab->draw = draw_normal;
} }
} }

View file

@ -112,15 +112,33 @@ sub generate {
} }
open(OUT, ">", $output); open(OUT, ">", $output);
print(OUT "CC = $cc\n"); if ($type eq "Watcom") {
print(OUT "!ifndef %mw16\n");
print(OUT "CC = $cc\n");
print(OUT "!else\n");
print(OUT "CC = wcc -bt=windows -q\n");
print(OUT "!endif\n");
} else {
print(OUT "CC = $cc\n");
}
print(OUT "LD = $link\n"); print(OUT "LD = $link\n");
print(OUT "\n"); print(OUT "\n");
if ($type eq "Watcom") {
print(OUT "!ifndef %mw16\n");
}
print(OUT 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 ${def}MW_OPENGL\n"
); );
print(OUT "MW_LDFLAGS = $dll\n"); print(OUT "MW_LDFLAGS = $dll\n");
print(OUT "EXE_CFLAGS = ${inc}include\n"); print(OUT "EXE_CFLAGS = ${inc}include\n");
print(OUT "EXE_LDFLAGS = $exe"); print(OUT "EXE_LDFLAGS = $exe\n");
if ($type eq "Watcom") {
print(OUT "!else\n");
print(OUT "MW_CFLAGS = -bd ${inc}include ${inc}external/libz/include ${def}_MILSKO ${def}_MILSKO_BUILD ${def}USE_GDI ${def}STBI_NO_SIMD ${def}NO_IMAGE ${def}MW_16\n");
print(OUT "MW_LDFLAGS = system windows_dll\n");
print(OUT "EXE_LDFLAGS = system windows\n");
print(OUT "!endif\n");
}
print(OUT "\n"); print(OUT "\n");
if ($suffix) { if ($suffix) {
@ -187,11 +205,24 @@ sub generate {
print(OUT "\n"); print(OUT "\n");
} }
print(OUT "\n"); print(OUT "\n");
if ($type eq "Watcom") {
print(OUT "!ifndef %mw16\n");
}
print(OUT "src${dir}Mw.dll: " . cobjs($dir) . "\n"); print(OUT "src${dir}Mw.dll: " . cobjs($dir) . "\n");
print( OUT " \$(LD) \$(MW_LDFLAGS) $c_dllout $dllout\$@ " print( OUT " \$(LD) \$(MW_LDFLAGS) $c_dllout $dllout\$@ "
. cobjs($dir, $prefobj) . 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}ole32.lib ${lib}uuid.lib ${lib}user32.lib ${lib}advapi32.lib\n"
); );
if ($type eq "Watcom") {
print(OUT "!else\n");
print(OUT "src${dir}Mw.dll: " . cobjs($dir) . "\n");
print( OUT " \$(LD) \$(MW_LDFLAGS) $c_dllout $dllout\$@ "
. cobjs($dir, $prefobj)
. " $needlibs ${lib}clibs.lib\n"
);
print(OUT "\n");
print(OUT "!endif\n");
}
print(OUT " $c_dllafter\n"); print(OUT " $c_dllafter\n");
print(OUT "\n"); print(OUT "\n");