forked from pyrite-dev/milsko
Compare commits
421 commits
wayland-p2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| d6b96d0f8c | |||
| 30c84a915a | |||
| 138555f41d | |||
| bc942153fe | |||
| 3e49278a15 | |||
| e41dbd43c1 | |||
|
9caa50b94d |
|||
|
d6538d4410 |
|||
|
c0e36df063 |
|||
|
6259f57677 |
|||
|
570f05540e |
|||
|
5220f742be |
|||
|
7a2ca3aa2d |
|||
|
13a2db7fa8 |
|||
|
5201c46a21 |
|||
|
b82e13cb2e |
|||
|
79efc31c55 |
|||
| c88dc48817 | |||
| 8b176d3a00 | |||
| 9b138c458e | |||
| 0e96b715b0 | |||
| 5ca241ad0a | |||
| b2ce5597b0 | |||
| 220b76135e | |||
| 15c39a2405 | |||
| 62fd2adcd1 | |||
| 2228fa1a46 | |||
| 5136207bf1 | |||
| c85b471c43 | |||
| f8a94b7380 | |||
| 47fe57b31c | |||
| 5315f4ec4d | |||
| 712a640f9d | |||
| 4e4da8659e | |||
| 6f9b3c12a7 | |||
| 48b847093b | |||
| a2c1489ffb | |||
| 0fb9c45ea4 | |||
| 677d8c8046 | |||
| 54fed150e8 | |||
| ecdecbc93b | |||
| 9087782960 | |||
| dc97522bb0 | |||
| 43c66417c7 | |||
| 12703d451e | |||
| 6257376b1f | |||
| a0c864d85b | |||
| 64930db2fc | |||
| d05e31b154 | |||
| a3bbcf30b2 | |||
| f7eb9840de | |||
| e77eb5e08a | |||
| b641a03bae | |||
| 5c386e7665 | |||
| 6ff6b22644 | |||
| 5cb9b5cab9 | |||
| 0c822d5bfa | |||
| 4ab846ad51 | |||
| fc8330f477 | |||
| 714842461c | |||
| aac2b410c0 | |||
| 83f5f7a820 | |||
| 391f5a6924 | |||
| 28f6d6ac56 | |||
| 065b0d824c | |||
| 32f99b62b6 | |||
| 4d7b33741f | |||
| a01e1a9514 | |||
| a7d790698f | |||
| 6e5057f8c6 | |||
| d597dc9411 | |||
| bfc6d8e9af | |||
| 1d59488927 | |||
| f22f45d5bf | |||
| 0e2e3a1901 | |||
| fe72bc92bf | |||
| c0d7cb3fbc | |||
| 554e5cd5dd | |||
| 522f32cfcd | |||
| 9283455cb9 | |||
| 7d85a784f5 | |||
| a4c61b0e38 | |||
| bb876b9620 | |||
| b661face26 | |||
| f44a70d4ec | |||
| 14e908488c | |||
| 728983b92c | |||
| 0ab497ca88 | |||
| c4f6d1eb14 | |||
| 2a7cf2de83 | |||
|
d1f351a7ef |
|||
|
3852646ce3 |
|||
|
00397f17ea |
|||
|
0325584319 |
|||
| 67788da3fb | |||
| 37bba97508 | |||
| c0bfb51601 | |||
| e9ea675ae6 | |||
| 84ad1b0d6b | |||
| 42af900127 | |||
|
3c336b5e95 |
|||
|
a652514ab0 |
|||
| d373f04eed | |||
|
291bb09047 |
|||
|
8a5a2f0f02 |
|||
|
6af4c73905 |
|||
|
1531f89ef0 |
|||
|
5d8e39b268 |
|||
|
5f6789631d |
|||
|
d76bb49e45 |
|||
|
8d597328f9 |
|||
|
07cab25d3e |
|||
|
29bab28b78 |
|||
|
0de09207a4 |
|||
|
9fc659b652 |
|||
|
55cb65be26 |
|||
| cce41b32b8 | |||
| a00d4ba144 | |||
| da3312cee9 | |||
| d4f6ca14e2 | |||
| 2e2a97e4a8 | |||
| b6b8f742d7 | |||
| af54b3e515 | |||
| 9d7d4541e4 | |||
| 2e30d7f4d9 | |||
| 597dbe4e5a | |||
| 9560c4fd92 | |||
| 3d99a9249f | |||
| 32842ca160 | |||
| 35d2b4bb76 | |||
|
a5beb9e6b9 |
|||
|
e8d32dafc7 |
|||
|
e312b325c8 |
|||
|
112ddd1521 |
|||
| 89dad2c4be | |||
| 252490e2cf | |||
| 4d694bba49 | |||
|
87c870a6c0 |
|||
|
dac94c78e1 |
|||
|
df50c9531c |
|||
|
7be0a72fca |
|||
|
f6abf02486 |
|||
|
251fc41020 |
|||
|
0e5f4f5ef7 |
|||
| 309cd98ea1 | |||
| 78ee4033b5 | |||
|
a16c1bcb5b |
|||
|
1d76cabf4c |
|||
| a5186cc1e9 | |||
| 414fde9b77 | |||
|
efe1ea076e |
|||
| bf9474f4f4 | |||
| a9d8d62146 | |||
|
f1c4a12cf3 |
|||
| efbf90945a | |||
| d61e432e97 | |||
| 37835cb53a | |||
| 849c439830 | |||
| 7998454ab9 | |||
|
6cc3925282 |
|||
| df11b86cea | |||
| 258d0d2cb2 | |||
| a42482a4e4 | |||
| 8f7df275fb | |||
| fc18c86201 | |||
| e5acf07b38 | |||
| 8dfa34e555 | |||
| 17e437075e | |||
| 60e1f36a41 | |||
| 00e44bec32 | |||
| 6538f8e836 | |||
| 2a2fdf55bc | |||
| 19cd6dc242 | |||
| 548d6c46fd | |||
| 8d7016367e | |||
|
70f7f8f084 |
|||
| 6ba77904d6 | |||
| 90706b184f | |||
| 0bbbc51bb9 | |||
| bcb108ae5f | |||
| 74779c8f42 | |||
| 82999d716a | |||
| 6bb72c224b | |||
|
c05843a04b |
|||
|
aa6d1f43d3 |
|||
| fa9ad8b984 | |||
| 4b2bf63889 | |||
| f4e2ec8fa9 | |||
| 9757623d3c | |||
| a826ce5e12 | |||
| 195cccd65a | |||
| 2a7327f27a | |||
| aad8d1b536 | |||
| 7162350e24 | |||
| 47746ff30e | |||
| e86d6acdf3 | |||
| 9a23045c30 | |||
| 1ad75eca90 | |||
| 57609f1823 | |||
| 5e823b5a25 | |||
| b9933b70e2 | |||
| d491357635 | |||
| 24ae1c4e11 | |||
| 8ccf819b57 | |||
| 682d84879b | |||
| ea2d62f2e1 | |||
| f4072bcb3f | |||
| 56cb0d4841 | |||
| 6277c8837a | |||
| 3d83e0ca64 | |||
| efa6804f46 | |||
|
6c65e58e37 |
|||
|
6d7fe3271f |
|||
| 9d65e9c6bf | |||
| c3d25e6b7d | |||
| 09441380b5 | |||
| 2499f82933 | |||
| 0527d376b7 | |||
| 69076f2893 | |||
| dee940161e | |||
| 52d676e54f | |||
| 4e70de98e9 | |||
| 3cf94f6651 | |||
| 22fe52c4a3 | |||
| 3eeace0963 | |||
| f78e5e620f | |||
| f44f98b8aa | |||
| 04eb28b617 | |||
| 42db5889db | |||
| 5f53236c91 | |||
| 91c05b670d | |||
| 5960823801 | |||
| 0a62467760 | |||
| 9309b5fe83 | |||
| fc7896b5ce | |||
| eb0919333a | |||
| 1cb8fb6c53 | |||
| d14c17b86e | |||
| 98eb529c6f | |||
| c64d7778cd | |||
|
3260643ada |
|||
|
8f04ccdb68 |
|||
|
43dd61ffbe |
|||
| db5f0ed40a | |||
| 96528ca433 | |||
| 13320dce78 | |||
| 02faed2f04 | |||
| 6c53df0fc5 | |||
| d9ee157ee8 | |||
| d3c30bf6d3 | |||
| 8f379e9751 | |||
| 9f1b455341 | |||
| a0e2ec7f57 | |||
| 4ca11145f1 | |||
| 3f84b0f868 | |||
| dd67e42054 | |||
| dccc402b3d | |||
| 128a1ec524 | |||
| 65afd85439 | |||
| 9eda46d981 | |||
| 21d5625ec7 | |||
| 75c9af91d1 | |||
| c20da369e8 | |||
| 3b78872ce8 | |||
| 4549e4f75b | |||
| 4319ea25b5 | |||
| 0fde05fa03 | |||
| 306f791641 | |||
| ea046f3a52 | |||
| 9d7a75394c | |||
| 9be36b0755 | |||
| e2bcd7b9e9 | |||
| 39db13fa48 | |||
| db577bb01f | |||
| f700e90d23 | |||
| b585ad69b7 | |||
| 943500a7ec | |||
| 0832533c51 | |||
| f9c35cded4 | |||
| 2e4e2a1c7f | |||
| 5eeba311ab | |||
| 890294cd55 | |||
| de1e8da6f9 | |||
| e09eccbf5f | |||
|
b3735fa364 |
|||
| cc2d3008d0 | |||
| efa43456c1 | |||
|
11fec984cf |
|||
|
d7db903695 |
|||
|
c04f751a4f |
|||
|
280ba93cf1 |
|||
|
3329184993 |
|||
|
4a092e71d2 |
|||
|
c308bd9324 |
|||
|
282283609c |
|||
|
12f7312d40 |
|||
|
5bc06dc851 |
|||
|
7ad4d82024 |
|||
|
ad5aa03d11 |
|||
|
bbb20f081e |
|||
|
626294c95f |
|||
|
9544404f7c |
|||
| 65c872710a | |||
| 64c3cdb4a5 | |||
| 5e492ee5b4 | |||
| ae96b127e1 | |||
| 0cecae2dd1 | |||
| 18457ccbcb | |||
| 8b28b3e1b0 | |||
| 836b13e62e | |||
|
5413332506 |
|||
|
8d86f185f2 |
|||
| b458613f87 | |||
| 04f1a94cb5 | |||
| a710967115 | |||
|
e2f34df4e3 |
|||
|
3dec3ff0da |
|||
|
85994d42f1 |
|||
| 32f09a9af2 | |||
| d340c64ca3 | |||
| 14e55b7f53 | |||
| 69c95d5752 | |||
| efcc176c04 | |||
| e45a1f6ad8 | |||
| 31cc8e5a0d | |||
| a70f3dbb59 | |||
| ca4adf5f39 | |||
|
eb50af2b81 |
|||
|
a0d1bada8f |
|||
|
7e32866c0a |
|||
|
e8f743ed84 |
|||
|
c61e26f028 |
|||
| e73964882e | |||
| da33a1a3c6 | |||
| 2d3bd9213e | |||
|
079cfa18b9 |
|||
|
debdaf998e |
|||
| 1f1318d0e1 | |||
|
85df90ceaf |
|||
|
e2aecbf9d4 |
|||
| d3751c0bf9 | |||
| 54cdd85015 | |||
| d784770ca9 | |||
| 12f279e83a | |||
| 8cdffa12ae | |||
| 933b5198c7 | |||
| 30a100fd28 | |||
| a148b3bedf | |||
| bed668b84a | |||
|
6183a1ccda |
|||
| f32f6cefc0 | |||
| f3683dece3 | |||
| 808495cccf | |||
| 6946c1eaf3 | |||
| 029e62d765 | |||
| a03065ae52 | |||
| 324257c43f | |||
| afecb04848 | |||
| bed63dd245 | |||
| 67bd6029af | |||
|
72820e87f1 |
|||
|
d3147ac087 |
|||
| 4bdda59693 | |||
|
823c865791 |
|||
|
3f9125d1ae |
|||
|
549d235893 |
|||
|
0daa527b1d |
|||
|
0ca7f6ed8a |
|||
| e895e96941 | |||
|
0d79141a49 |
|||
|
c80987ffe4 |
|||
|
d3a7b0a01d |
|||
|
e77c4f3c38 |
|||
|
22b4737c33 |
|||
|
509351a0a0 |
|||
|
86effbdfd7 |
|||
|
7b47524286 |
|||
|
c8e7f58230 |
|||
|
9ea54b4f88 |
|||
|
55f82e4fbc |
|||
| a23016bc05 | |||
| df99e66d87 | |||
|
e9fd2705d4 |
|||
|
a824b4fc44 |
|||
|
c7c8f236b0 |
|||
|
bdc67d6369 |
|||
|
873c75b882 |
|||
|
e44eaa2c16 |
|||
|
0d281c09ce |
|||
|
2b30a06ecf |
|||
|
188da6803e |
|||
|
2304b493d1 |
|||
|
91d9677bf7 |
|||
|
f09960195f |
|||
|
ab9d0ffc5f |
|||
|
a67a0c11f8 |
|||
|
dc8168df12 |
|||
|
604ff72d6e |
|||
| a384add9e9 | |||
| 6123fd1304 | |||
| b7488b9440 | |||
| 18511dec2f | |||
| 59ff6f1008 | |||
| a27a01ce41 | |||
| b0f4713ff1 | |||
| 8d4e845e7c | |||
| aeaf0a4547 | |||
| b366fc12a7 | |||
| d8c08f80d6 | |||
|
bfa0a5811e |
|||
|
19f52488b8 |
|||
| c6e7421b31 | |||
| e3b3363e42 | |||
| a815998ace | |||
|
75749697ba |
|||
|
c9c3a00ed3 |
|||
|
012650f06f |
|||
| 72fbba1a74 | |||
| b8a92f4ae0 | |||
| 724b008220 | |||
| 320de34ce8 |
120 changed files with 16230 additions and 1993 deletions
|
|
@ -1,5 +1,4 @@
|
||||||
---
|
---
|
||||||
Language: Cpp
|
|
||||||
UseTab: Always
|
UseTab: Always
|
||||||
TabWidth: 8
|
TabWidth: 8
|
||||||
AlignConsecutiveAssignments:
|
AlignConsecutiveAssignments:
|
||||||
|
|
|
||||||
3
.clangd
Normal file
3
.clangd
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
Completion:
|
||||||
|
HeaderInsertion: Never
|
||||||
|
ClangFormat: Tab
|
||||||
14
.gitignore
vendored
14
.gitignore
vendored
|
|
@ -5,10 +5,24 @@ examples/*/*.exe
|
||||||
!examples/*/
|
!examples/*/
|
||||||
!examples/*.*
|
!examples/*.*
|
||||||
!examples/*/*.*
|
!examples/*/*.*
|
||||||
|
*.exe
|
||||||
*.o
|
*.o
|
||||||
|
*.obj
|
||||||
|
*.core
|
||||||
*.so
|
*.so
|
||||||
*.dll
|
*.dll
|
||||||
*.lib
|
*.lib
|
||||||
|
*.dylib
|
||||||
*.a
|
*.a
|
||||||
/Makefile
|
/Makefile
|
||||||
|
/build
|
||||||
compile_flags.txt
|
compile_flags.txt
|
||||||
|
.cache
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
*.pef
|
||||||
|
*.dsk
|
||||||
|
*.bin
|
||||||
|
*.rsrc
|
||||||
|
*.finf
|
||||||
|
*.gdb
|
||||||
|
|
|
||||||
36
BorMakefile
generated
36
BorMakefile
generated
|
|
@ -1,11 +1,26 @@
|
||||||
CC = bcc32 -c
|
CC = bcc32 -c
|
||||||
LD = bcc32
|
LD = bcc32
|
||||||
|
|
||||||
CFLAGS = -Iinclude -D_MILSKO -DUSE_GDI -DUSE_STB_TRUETYPE -DUSE_STB_IMAGE -DSTBI_NO_SIMD
|
CFLAGS = -Iinclude -Iexternal\libz\include -D_MILSKO -DUSE_GDI -DUSE_STB_TRUETYPE -DUSE_STB_IMAGE -DSTBI_NO_SIMD
|
||||||
LDFLAGS = -tWD
|
LDFLAGS = -tWD
|
||||||
.SUFFIXES: .obj .c
|
.SUFFIXES: .obj .c
|
||||||
all: src\Mw.dll
|
all: src\Mw.dll
|
||||||
clean:
|
clean:
|
||||||
|
del /f /q external\libz\src\adler32.obj
|
||||||
|
del /f /q external\libz\src\compress.obj
|
||||||
|
del /f /q external\libz\src\crc32.obj
|
||||||
|
del /f /q external\libz\src\deflate.obj
|
||||||
|
del /f /q external\libz\src\gzclose.obj
|
||||||
|
del /f /q external\libz\src\gzlib.obj
|
||||||
|
del /f /q external\libz\src\gzread.obj
|
||||||
|
del /f /q external\libz\src\gzwrite.obj
|
||||||
|
del /f /q external\libz\src\infback.obj
|
||||||
|
del /f /q external\libz\src\inffast.obj
|
||||||
|
del /f /q external\libz\src\inflate.obj
|
||||||
|
del /f /q external\libz\src\inftrees.obj
|
||||||
|
del /f /q external\libz\src\trees.obj
|
||||||
|
del /f /q external\libz\src\uncompr.obj
|
||||||
|
del /f /q external\libz\src\zutil.obj
|
||||||
del /f /q external\stb_ds.obj
|
del /f /q external\stb_ds.obj
|
||||||
del /f /q external\stb_image.obj
|
del /f /q external\stb_image.obj
|
||||||
del /f /q external\stb_truetype.obj
|
del /f /q external\stb_truetype.obj
|
||||||
|
|
@ -26,11 +41,6 @@ clean:
|
||||||
del /f /q src\dialog\filechooser.obj
|
del /f /q src\dialog\filechooser.obj
|
||||||
del /f /q src\dialog\messagebox.obj
|
del /f /q src\dialog\messagebox.obj
|
||||||
del /f /q src\draw.obj
|
del /f /q src\draw.obj
|
||||||
del /f /q src\error.obj
|
|
||||||
del /f /q src\font\boldfont.obj
|
|
||||||
del /f /q src\font\boldttf.obj
|
|
||||||
del /f /q src\font\font.obj
|
|
||||||
del /f /q src\font\ttf.obj
|
|
||||||
del /f /q src\icon\back.obj
|
del /f /q src\icon\back.obj
|
||||||
del /f /q src\icon\clock.obj
|
del /f /q src\icon\clock.obj
|
||||||
del /f /q src\icon\computer.obj
|
del /f /q src\icon\computer.obj
|
||||||
|
|
@ -49,7 +59,15 @@ clean:
|
||||||
del /f /q src\icon\warning.obj
|
del /f /q src\icon\warning.obj
|
||||||
del /f /q src\lowlevel.obj
|
del /f /q src\lowlevel.obj
|
||||||
del /f /q src\string.obj
|
del /f /q src\string.obj
|
||||||
del /f /q src\text.obj
|
del /f /q src\text\font\boldfont.obj
|
||||||
|
del /f /q src\text\font\boldmonottf.obj
|
||||||
|
del /f /q src\text\font\boldttf.obj
|
||||||
|
del /f /q src\text\font\font.obj
|
||||||
|
del /f /q src\text\font\monottf.obj
|
||||||
|
del /f /q src\text\font\ttf.obj
|
||||||
|
del /f /q src\text\ft2.obj
|
||||||
|
del /f /q src\text\stbtt.obj
|
||||||
|
del /f /q src\text\text.obj
|
||||||
del /f /q src\unicode.obj
|
del /f /q src\unicode.obj
|
||||||
del /f /q src\widget\box.obj
|
del /f /q src\widget\box.obj
|
||||||
del /f /q src\widget\button.obj
|
del /f /q src\widget\button.obj
|
||||||
|
|
@ -74,8 +92,8 @@ clean:
|
||||||
del /f /q src\Mw.dll
|
del /f /q src\Mw.dll
|
||||||
del /f /q src\Mw.lib
|
del /f /q src\Mw.lib
|
||||||
|
|
||||||
src\Mw.dll: external\stb_ds.obj external\stb_image.obj external\stb_truetype.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\error.obj src\font\boldfont.obj src\font\boldttf.obj src\font\font.obj src\font\ttf.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.obj src\unicode.obj src\widget\box.obj src\widget\button.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\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\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\stbtt.obj src\text\text.obj src\unicode.obj src\widget\box.obj src\widget\button.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\treeview.obj src\widget\viewport.obj src\widget\window.obj
|
||||||
$(LD) $(LDFLAGS) -e$@ external\stb_ds.obj external\stb_image.obj external\stb_truetype.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\error.obj src\font\boldfont.obj src\font\boldttf.obj src\font\font.obj src\font\ttf.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.obj src\unicode.obj src\widget\box.obj src\widget\button.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\treeview.obj src\widget\viewport.obj src\widget\window.obj -lopengl32.lib -lgdi32.lib -luser32.lib
|
$(LD) $(LDFLAGS) -e$@ 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\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\stbtt.obj src\text\text.obj src\unicode.obj src\widget\box.obj src\widget\button.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\treeview.obj src\widget\viewport.obj src\widget\window.obj -lopengl32.lib -lgdi32.lib -luser32.lib -ladvapi32.lib
|
||||||
implib src\Mw.lib src\Mw.dll
|
implib src\Mw.lib src\Mw.dll
|
||||||
|
|
||||||
.c.obj:
|
.c.obj:
|
||||||
|
|
|
||||||
255
CMakeLists.txt
255
CMakeLists.txt
|
|
@ -9,28 +9,47 @@ include(GNUInstallDirs)
|
||||||
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
|
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_FULL_LIBDIR}")
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
|
||||||
option(TRY_OPENGL "Try to compile OpenGL widget or not" ON)
|
|
||||||
option(TRY_VULKAN "Try to compile Vulkan widget or not" ON)
|
option(MW_CLASSIC_THEME "Use classic theme" OFF)
|
||||||
option(CLASSIC_THEME "Use classic theme" OFF)
|
option(MW_BUILD_EXAMPLES "Build examples" OFF)
|
||||||
option(BUILD_EXAMPLES "Build examples" OFF)
|
option(MW_USE_STB_IMAGE "Use stb_image" ON)
|
||||||
option(USE_STB_IMAGE "Use stb_image" ON)
|
option(MW_USE_STB_TRUETYPE "Use stb_truetype" OFF)
|
||||||
option(USE_STB_TRUETYPE "Use stb_truetype" OFF)
|
|
||||||
option(USE_FREETYPE2 "Use FreeType 2" ON)
|
if(${CMAKE_SYSTEM_NAME} MATCHES Retro)
|
||||||
|
option(MW_BUILD_SHARED "Build a shared library" OFF)
|
||||||
|
option(MW_BUILD_STATIC "Build a static library" ON)
|
||||||
|
option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" OFF)
|
||||||
|
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" OFF)
|
||||||
|
else()
|
||||||
|
option(MW_BUILD_SHARED "Build a shared library" ON)
|
||||||
|
option(MW_BUILD_STATIC "Build a static library" OFF)
|
||||||
|
option(MW_TRY_OPENGL "Try to compile OpenGL widget or not" ON)
|
||||||
|
option(MW_TRY_VULKAN "Try to compile Vulkan widget or not" ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
option(MW_INSTALL_HEADERS "Install headers" ON)
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin OR ${CMAKE_SYSTEM_NAME} MATCHES Retro)
|
||||||
|
option(MW_USE_FREETYPE2 "Use FreeType 2" OFF)
|
||||||
|
else()
|
||||||
|
option(MW_USE_FREETYPE2 "Use FreeType 2" ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(${CMAKE_SYSTEM_NAME} STREQUAL Linux)
|
||||||
|
option(MW_USE_WAYLAND "Enable Wayland backend" ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
file(
|
file(
|
||||||
GLOB
|
GLOB
|
||||||
SOURCES
|
SOURCES
|
||||||
src/*.c src/cursor/*.c src/icon/*.c src/text.c src/widget/*.c src/math/*.c src/font/*.c src/dialog/*.c src/abstract/*.c external/*.c
|
external/libz/src/*.c src/*.c src/cursor/*.c src/icon/*.c src/widget/*.c src/text/*.c src/text/font/*.c src/dialog/*.c src/abstract/*.c external/*.c
|
||||||
)
|
)
|
||||||
|
|
||||||
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c")
|
if(NOT MW_USE_STB_IMAGE)
|
||||||
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c")
|
|
||||||
|
|
||||||
if(NOT USE_STB_IMAGE)
|
|
||||||
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_image.c")
|
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_image.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(NOT USE_STB_TRUETYPE)
|
if(NOT MW_USE_STB_TRUETYPE)
|
||||||
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_truetype.c")
|
list(REMOVE_ITEM SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/external/stb_truetype.c")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
@ -39,35 +58,47 @@ if(CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
|
||||||
list(APPEND CMAKE_REQUIRED_INCLUDES "/usr/pkg/include")
|
list(APPEND CMAKE_REQUIRED_INCLUDES "/usr/pkg/include")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TRY_OPENGL)
|
if(MW_TRY_OPENGL)
|
||||||
check_include_files(GL/gl.h HAVE_GL_GL_H)
|
find_package(OpenGL)
|
||||||
if(HAVE_GL_GL_H)
|
if(OpenGL_FOUND)
|
||||||
set(BUILD_OPENGL ON)
|
set(MW_BUILD_OPENGL ON)
|
||||||
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl.c")
|
if(APPLE)
|
||||||
|
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/opengl_cocoa.m")
|
||||||
|
endif()
|
||||||
message(STATUS "OpenGL widget has been enabled")
|
message(STATUS "OpenGL widget has been enabled")
|
||||||
else()
|
else()
|
||||||
message(WARNING "OpenGL widget has been disabled")
|
message(WARNING "OpenGL widget has been disabled")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(TRY_OPENGL)
|
if(MW_TRY_VULKAN)
|
||||||
check_include_files(vulkan/vulkan.h HAVE_VULKAN_VULKAN_H)
|
check_include_files(vulkan/vulkan.h HAVE_VULKAN_VULKAN_H)
|
||||||
if(HAVE_VULKAN_VULKAN_H)
|
if(HAVE_VULKAN_VULKAN_H)
|
||||||
set(BUILD_VULKAN ON)
|
set(MW_BUILD_VULKAN ON)
|
||||||
list(APPEND SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/src/widget/vulkan.c")
|
|
||||||
message(STATUS "Vulkan widget has been enabled")
|
message(STATUS "Vulkan widget has been enabled")
|
||||||
else()
|
else()
|
||||||
message(WARNING "Vulkan widget has been disabled")
|
message(WARNING "Vulkan widget has been disabled")
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MW_BUILD_STATIC)
|
||||||
|
message(STATUS "Building Milsko as a static library")
|
||||||
|
add_library(
|
||||||
|
Mw
|
||||||
|
${SOURCES}
|
||||||
|
)
|
||||||
|
elseif(MW_BUILD_SHARED)
|
||||||
|
message(STATUS "Building Milsko as a shared library")
|
||||||
add_library(
|
add_library(
|
||||||
Mw
|
Mw
|
||||||
SHARED
|
SHARED
|
||||||
${SOURCES}
|
${SOURCES}
|
||||||
)
|
)
|
||||||
|
else()
|
||||||
|
message(ERROR "Must either build a shared library or a static library")
|
||||||
|
endif()
|
||||||
|
|
||||||
if(USE_STB_IMAGE)
|
if(MW_USE_STB_IMAGE)
|
||||||
target_compile_definitions(
|
target_compile_definitions(
|
||||||
Mw
|
Mw
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
|
@ -77,21 +108,21 @@ else()
|
||||||
file(
|
file(
|
||||||
GLOB
|
GLOB
|
||||||
IMAGE_SOURCES
|
IMAGE_SOURCES
|
||||||
external/libz/src/*.c external/libjpeg/src/*.c external/libpng/src/*.c
|
external/libjpeg/src/*.c external/libpng/src/*.c
|
||||||
)
|
)
|
||||||
target_sources(
|
target_sources(
|
||||||
Mw
|
Mw
|
||||||
PRIVATE
|
PRIVATE
|
||||||
${IMAGE_SOURCES}
|
${MW_IMAGE_SOURCES}
|
||||||
)
|
)
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
Mw
|
Mw
|
||||||
PRIVATE
|
PRIVATE
|
||||||
external/libz/include external/libjpeg/include external/libpng/include
|
external/libjpeg/include external/libpng/include
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_STB_TRUETYPE)
|
if(MW_USE_STB_TRUETYPE)
|
||||||
target_compile_definitions(
|
target_compile_definitions(
|
||||||
Mw
|
Mw
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
|
@ -99,7 +130,7 @@ if(USE_STB_TRUETYPE)
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_FREETYPE2)
|
if(MW_USE_FREETYPE2)
|
||||||
target_compile_definitions(
|
target_compile_definitions(
|
||||||
Mw
|
Mw
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
|
@ -113,13 +144,119 @@ if(USE_FREETYPE2)
|
||||||
list(APPEND LIBRARIES ${FT2_LIBRARIES})
|
list(APPEND LIBRARIES ${FT2_LIBRARIES})
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(MW_USE_WAYLAND)
|
||||||
|
function(scan_wayland_protocol_core)
|
||||||
|
execute_process(
|
||||||
|
COMMAND wayland-scanner private-code /usr/share/wayland/wayland.xml ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-core-protocol.c
|
||||||
|
OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT
|
||||||
|
ERROR_VARIABLE WAYLAND_SCANNER_ERROR
|
||||||
|
ECHO_OUTPUT_VARIABLE
|
||||||
|
ECHO_ERROR_VARIABLE
|
||||||
|
COMMAND_ECHO STDOUT
|
||||||
|
)
|
||||||
|
target_sources(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-core-protocol.c
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND wayland-scanner client-header /usr/share/wayland/wayland.xml ${CMAKE_CURRENT_SOURCE_DIR}/include/Mw/LowLevel/Wayland/wayland-core-protocol.h
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT
|
||||||
|
ERROR_VARIABLE WAYLAND_SCANNER_ERROR
|
||||||
|
ECHO_OUTPUT_VARIABLE
|
||||||
|
ECHO_ERROR_VARIABLE
|
||||||
|
COMMAND_ECHO STDOUT
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(scan_wayland_protocol tier proto ver)
|
||||||
|
SET(proto_c ${CMAKE_CURRENT_SOURCE_DIR}/src/backend/wayland-${proto}-protocol.c)
|
||||||
|
execute_process(
|
||||||
|
COMMAND wayland-scanner private-code /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml ${proto_c}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT
|
||||||
|
ERROR_VARIABLE WAYLAND_SCANNER_ERROR
|
||||||
|
ECHO_OUTPUT_VARIABLE
|
||||||
|
ECHO_ERROR_VARIABLE
|
||||||
|
COMMAND_ECHO STDOUT
|
||||||
|
)
|
||||||
|
target_sources(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
${proto_c}
|
||||||
|
)
|
||||||
|
execute_process(
|
||||||
|
COMMAND wayland-scanner client-header /usr/share/wayland-protocols/${tier}/${proto}/${proto}${ver}.xml ${CMAKE_CURRENT_SOURCE_DIR}/include/Mw/LowLevel/Wayland/${proto}-client-protocol.h
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE WAYLAND_SCANNER_OUTPUT
|
||||||
|
ERROR_VARIABLE WAYLAND_SCANNER_ERROR
|
||||||
|
ECHO_OUTPUT_VARIABLE
|
||||||
|
ECHO_ERROR_VARIABLE
|
||||||
|
COMMAND_ECHO STDOUT
|
||||||
|
)
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
check_include_files(wayland-client.h HAVE_WL_H)
|
||||||
|
check_include_files(xkbcommon/xkbcommon.h HAVE_XKBCOMMON_H)
|
||||||
|
check_include_files(cairo/cairo.h HAVE_CAIRO_H)
|
||||||
|
if(HAVE_WL_H)
|
||||||
|
if(HAVE_XKBCOMMON_H)
|
||||||
|
if(HAVE_CAIRO_H)
|
||||||
|
scan_wayland_protocol_core()
|
||||||
|
scan_wayland_protocol("stable" "xdg-shell" "")
|
||||||
|
scan_wayland_protocol("stable" "viewporter" "")
|
||||||
|
scan_wayland_protocol("stable" "tablet" "-v2")
|
||||||
|
scan_wayland_protocol("staging" "xdg-toplevel-icon" "-v1")
|
||||||
|
scan_wayland_protocol("staging" "cursor-shape" "-v1")
|
||||||
|
scan_wayland_protocol("unstable" "xdg-decoration" "-unstable-v1")
|
||||||
|
scan_wayland_protocol("unstable" "primary-selection" "-unstable-v1")
|
||||||
|
scan_wayland_protocol("unstable" "pointer-constraints" "-unstable-v1")
|
||||||
|
scan_wayland_protocol("unstable" "relative-pointer" "-unstable-v1")
|
||||||
|
|
||||||
|
target_sources(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
src/backend/wayland.c
|
||||||
|
)
|
||||||
|
target_compile_definitions(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
USE_WAYLAND
|
||||||
|
)
|
||||||
|
message(STATUS "Wayland backend has been enabled")
|
||||||
|
else()
|
||||||
|
message(WARNING "Wayland backend has been disabled")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "Wayland backend has been disabled")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
message(WARNING "Wayland backend has been disabled")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(APPLE AND MW_BUILD_OPENGL)
|
||||||
|
target_compile_definitions(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
GL_SILENCE_DEPRECATION
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
target_include_directories(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
external/libz/include
|
||||||
|
)
|
||||||
|
|
||||||
target_include_directories(
|
target_include_directories(
|
||||||
Mw
|
Mw
|
||||||
PUBLIC
|
PUBLIC
|
||||||
include
|
include
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CLASSIC_THEME)
|
if(MW_CLASSIC_THEME)
|
||||||
target_compile_definitions(
|
target_compile_definitions(
|
||||||
Mw
|
Mw
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
|
@ -139,6 +276,46 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
USE_GDI
|
USE_GDI
|
||||||
)
|
)
|
||||||
list(APPEND LIBRARIES gdi32)
|
list(APPEND LIBRARIES gdi32)
|
||||||
|
target_link_options(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
-static-libgcc
|
||||||
|
)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
|
target_sources(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
src/backend/cocoa.m
|
||||||
|
)
|
||||||
|
target_compile_definitions(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
USE_COCOA
|
||||||
|
)
|
||||||
|
list(APPEND LIBRARIES objc)
|
||||||
|
target_link_options(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
-framework Cocoa
|
||||||
|
)
|
||||||
|
elseif(CMAKE_SYSTEM_NAME MATCHES "Retro")
|
||||||
|
target_sources(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
src/backend/classicmacos.c
|
||||||
|
)
|
||||||
|
if(PLATFORM MATCHES retroppc)
|
||||||
|
set_target_properties(Mw PROPERTIES COMPILE_FLAGS "-ffunction-sections -mcpu=601 -Os -Wall -Wextra -Wno-unused-parameter")
|
||||||
|
set_target_properties(Mw PROPERTIES LINK_FLAGS "-Wl,-gc-sections")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
list(APPEND LIBRARIES InterfaceLib WindowsLib ThreadsLib)
|
||||||
|
|
||||||
|
target_compile_definitions(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
CLASSIC_MAC_OS
|
||||||
|
)
|
||||||
else()
|
else()
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
pkg_check_modules(X11 REQUIRED x11)
|
pkg_check_modules(X11 REQUIRED x11)
|
||||||
|
|
@ -178,7 +355,15 @@ target_link_libraries(
|
||||||
${LIBRARIES}
|
${LIBRARIES}
|
||||||
)
|
)
|
||||||
|
|
||||||
if(BUILD_VULKAN)
|
if(MW_BUILD_OPENGL)
|
||||||
|
target_compile_definitions(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
MW_OPENGL
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(MW_BUILD_VULKAN)
|
||||||
check_include_files(vulkan/vk_enum_string_helper.h HAS_VK_ENUM_STRING_HELPER)
|
check_include_files(vulkan/vk_enum_string_helper.h HAS_VK_ENUM_STRING_HELPER)
|
||||||
if(HAS_VK_ENUM_STRING_HELPER)
|
if(HAS_VK_ENUM_STRING_HELPER)
|
||||||
target_compile_definitions(
|
target_compile_definitions(
|
||||||
|
|
@ -187,6 +372,12 @@ if(BUILD_VULKAN)
|
||||||
HAS_VK_ENUM_STRING_HELPER
|
HAS_VK_ENUM_STRING_HELPER
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
target_compile_definitions(
|
||||||
|
Mw
|
||||||
|
PRIVATE
|
||||||
|
MW_VULKAN
|
||||||
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
target_compile_definitions(
|
target_compile_definitions(
|
||||||
|
|
@ -195,19 +386,21 @@ target_compile_definitions(
|
||||||
_MILSKO
|
_MILSKO
|
||||||
)
|
)
|
||||||
|
|
||||||
include(GNUInstallDirs)
|
|
||||||
install(
|
install(
|
||||||
TARGETS Mw
|
TARGETS Mw
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if(MW_INSTALL_HEADERS)
|
||||||
install(
|
install(
|
||||||
DIRECTORY include/
|
DIRECTORY include/
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
|
||||||
FILES_MATCHING PATTERN "*.h"
|
FILES_MATCHING PATTERN "*.h"
|
||||||
)
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(BUILD_EXAMPLES)
|
if(MW_BUILD_EXAMPLES)
|
||||||
add_subdirectory(examples)
|
add_subdirectory(examples)
|
||||||
endif()
|
endif()
|
||||||
|
|
|
||||||
74
Jenkinsfile
vendored
Normal file
74
Jenkinsfile
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
||||||
|
pipeline {
|
||||||
|
agent {
|
||||||
|
label "built-in"
|
||||||
|
}
|
||||||
|
stages {
|
||||||
|
stage("Build document") {
|
||||||
|
when {
|
||||||
|
branch "master"
|
||||||
|
}
|
||||||
|
agent {
|
||||||
|
label "built-in"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh("rm -rf include/Mw/LowLevel/Wayland")
|
||||||
|
sh("doxygen")
|
||||||
|
sh("rm -rf /var/www/milsko-doxygen")
|
||||||
|
sh("mv doxygen/html /var/www/milsko-doxygen")
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
notifyDiscord()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("Build") {
|
||||||
|
parallel {
|
||||||
|
stage("Build for Linux 64-bit") {
|
||||||
|
agent {
|
||||||
|
label "built-in"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh("./configure --enable-opengl --enable-vulkan --without-vulkan-string-helper")
|
||||||
|
sh("make clean")
|
||||||
|
sh("make -j4")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("Build for Windows 32-bit") {
|
||||||
|
agent {
|
||||||
|
label "built-in"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh("./configure --enable-opengl --enable-stb-truetype --disable-freetype2 --cross --target=Windows --host=i686-w64-mingw32")
|
||||||
|
sh("make clean")
|
||||||
|
sh("make -j4")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("Build for Windows 64-bit") {
|
||||||
|
agent {
|
||||||
|
label "built-in"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
sh("./configure --enable-opengl --enable-stb-truetype --disable-freetype2 --cross --target=Windows --host=x86_64-w64-mingw32")
|
||||||
|
sh("make clean")
|
||||||
|
sh("make -j4")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
stage("Build for Windows 32-bit (MSVC)") {
|
||||||
|
agent {
|
||||||
|
label "2012r2"
|
||||||
|
}
|
||||||
|
steps {
|
||||||
|
bat("nmake -f NTMakefile clean")
|
||||||
|
bat("nmake -f NTMakefile")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
post {
|
||||||
|
always {
|
||||||
|
notifyDiscord()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
24
Koakumafile
24
Koakumafile
|
|
@ -1,24 +0,0 @@
|
||||||
# vim: syntax=tcl
|
|
||||||
|
|
||||||
proc run {project_name} {
|
|
||||||
if { "$project_name" == "MilskoDoxygen" } {
|
|
||||||
RunCommand "doxygen"
|
|
||||||
RunCommand "rm -rf /var/www/milsko-doxygen"
|
|
||||||
RunCommand "mv doxygen/html /var/www/milsko-doxygen"
|
|
||||||
} else {
|
|
||||||
foreach target {"Linux" "Win32" "Win64"} {
|
|
||||||
if { [file exists "Makefile"] == 1 } {
|
|
||||||
RunCommand "make distclean"
|
|
||||||
}
|
|
||||||
if { "$target" == "Linux" } {
|
|
||||||
RunCommand "./Makefile.pl --enable-opengl --enable-vulkan --without-vulkan-string-helper"
|
|
||||||
} elseif { "$target" == "Win32" } {
|
|
||||||
RunCommand "./Makefile.pl --enable-opengl --enable-stb-truetype --disable-freetype2 --cross --target=Windows --host=i686-w64-mingw32"
|
|
||||||
} elseif { "$target" == "Win64" } {
|
|
||||||
RunCommand "./Makefile.pl --enable-opengl --enable-stb-truetype --disable-freetype2 --cross --target=Windows --host=x86_64-w64-mingw32"
|
|
||||||
}
|
|
||||||
RunCommand "make clean"
|
|
||||||
RunCommand "make -j4"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
2
LICENSE
2
LICENSE
|
|
@ -1,4 +1,4 @@
|
||||||
Copyright (c) 2025, Pyrite development team
|
Copyright (c) 2025-2026, Pyrite development team
|
||||||
All rights reserved.
|
All rights reserved.
|
||||||
|
|
||||||
Redistribution and use in source and binary forms, with or without
|
Redistribution and use in source and binary forms, with or without
|
||||||
|
|
|
||||||
36
NTMakefile
generated
36
NTMakefile
generated
|
|
@ -1,11 +1,26 @@
|
||||||
CC = cl /TC /c /nologo
|
CC = cl /TC /c /nologo
|
||||||
LD = link /nologo
|
LD = link /nologo
|
||||||
|
|
||||||
CFLAGS = /Iinclude /D_MILSKO /DUSE_GDI /DUSE_STB_TRUETYPE /DUSE_STB_IMAGE /DSTBI_NO_SIMD
|
CFLAGS = /Iinclude /Iexternal\libz\include /D_MILSKO /DUSE_GDI /DUSE_STB_TRUETYPE /DUSE_STB_IMAGE /DSTBI_NO_SIMD
|
||||||
LDFLAGS = /DLL
|
LDFLAGS = /DLL
|
||||||
.SUFFIXES: .obj .c
|
.SUFFIXES: .obj .c
|
||||||
all: src\Mw.dll
|
all: src\Mw.dll
|
||||||
clean:
|
clean:
|
||||||
|
del /f /q external\libz\src\adler32.obj
|
||||||
|
del /f /q external\libz\src\compress.obj
|
||||||
|
del /f /q external\libz\src\crc32.obj
|
||||||
|
del /f /q external\libz\src\deflate.obj
|
||||||
|
del /f /q external\libz\src\gzclose.obj
|
||||||
|
del /f /q external\libz\src\gzlib.obj
|
||||||
|
del /f /q external\libz\src\gzread.obj
|
||||||
|
del /f /q external\libz\src\gzwrite.obj
|
||||||
|
del /f /q external\libz\src\infback.obj
|
||||||
|
del /f /q external\libz\src\inffast.obj
|
||||||
|
del /f /q external\libz\src\inflate.obj
|
||||||
|
del /f /q external\libz\src\inftrees.obj
|
||||||
|
del /f /q external\libz\src\trees.obj
|
||||||
|
del /f /q external\libz\src\uncompr.obj
|
||||||
|
del /f /q external\libz\src\zutil.obj
|
||||||
del /f /q external\stb_ds.obj
|
del /f /q external\stb_ds.obj
|
||||||
del /f /q external\stb_image.obj
|
del /f /q external\stb_image.obj
|
||||||
del /f /q external\stb_truetype.obj
|
del /f /q external\stb_truetype.obj
|
||||||
|
|
@ -26,11 +41,6 @@ clean:
|
||||||
del /f /q src\dialog\filechooser.obj
|
del /f /q src\dialog\filechooser.obj
|
||||||
del /f /q src\dialog\messagebox.obj
|
del /f /q src\dialog\messagebox.obj
|
||||||
del /f /q src\draw.obj
|
del /f /q src\draw.obj
|
||||||
del /f /q src\error.obj
|
|
||||||
del /f /q src\font\boldfont.obj
|
|
||||||
del /f /q src\font\boldttf.obj
|
|
||||||
del /f /q src\font\font.obj
|
|
||||||
del /f /q src\font\ttf.obj
|
|
||||||
del /f /q src\icon\back.obj
|
del /f /q src\icon\back.obj
|
||||||
del /f /q src\icon\clock.obj
|
del /f /q src\icon\clock.obj
|
||||||
del /f /q src\icon\computer.obj
|
del /f /q src\icon\computer.obj
|
||||||
|
|
@ -49,7 +59,15 @@ clean:
|
||||||
del /f /q src\icon\warning.obj
|
del /f /q src\icon\warning.obj
|
||||||
del /f /q src\lowlevel.obj
|
del /f /q src\lowlevel.obj
|
||||||
del /f /q src\string.obj
|
del /f /q src\string.obj
|
||||||
del /f /q src\text.obj
|
del /f /q src\text\font\boldfont.obj
|
||||||
|
del /f /q src\text\font\boldmonottf.obj
|
||||||
|
del /f /q src\text\font\boldttf.obj
|
||||||
|
del /f /q src\text\font\font.obj
|
||||||
|
del /f /q src\text\font\monottf.obj
|
||||||
|
del /f /q src\text\font\ttf.obj
|
||||||
|
del /f /q src\text\ft2.obj
|
||||||
|
del /f /q src\text\stbtt.obj
|
||||||
|
del /f /q src\text\text.obj
|
||||||
del /f /q src\unicode.obj
|
del /f /q src\unicode.obj
|
||||||
del /f /q src\widget\box.obj
|
del /f /q src\widget\box.obj
|
||||||
del /f /q src\widget\button.obj
|
del /f /q src\widget\button.obj
|
||||||
|
|
@ -74,8 +92,8 @@ clean:
|
||||||
del /f /q src\Mw.dll
|
del /f /q src\Mw.dll
|
||||||
del /f /q src\Mw.lib
|
del /f /q src\Mw.lib
|
||||||
|
|
||||||
src\Mw.dll: external\stb_ds.obj external\stb_image.obj external\stb_truetype.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\error.obj src\font\boldfont.obj src\font\boldttf.obj src\font\font.obj src\font\ttf.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.obj src\unicode.obj src\widget\box.obj src\widget\button.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\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\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\stbtt.obj src\text\text.obj src\unicode.obj src\widget\box.obj src\widget\button.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\treeview.obj src\widget\viewport.obj src\widget\window.obj
|
||||||
$(LD) $(LDFLAGS) /OUT:$@ external\stb_ds.obj external\stb_image.obj external\stb_truetype.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\error.obj src\font\boldfont.obj src\font\boldttf.obj src\font\font.obj src\font\ttf.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.obj src\unicode.obj src\widget\box.obj src\widget\button.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\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib user32.lib
|
$(LD) $(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\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\stbtt.obj src\text\text.obj src\unicode.obj src\widget\box.obj src\widget\button.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\treeview.obj src\widget\viewport.obj src\widget\window.obj opengl32.lib gdi32.lib user32.lib advapi32.lib
|
||||||
|
|
||||||
|
|
||||||
.c.obj:
|
.c.obj:
|
||||||
|
|
|
||||||
12
README.txt
12
README.txt
|
|
@ -6,8 +6,10 @@ distributions and building instructions for Milsko GUI Toolkit.
|
||||||
|
|
||||||
Requirements
|
Requirements
|
||||||
|
|
||||||
Milsko requires the Windows environment with GDI (so anything NT or 9x) or
|
Milsko requires either
|
||||||
the Unix-like environment with X11 for runtime.
|
* A Windows environment with GDI (so anything NT or 9x)
|
||||||
|
* A MacOS environment with Cocoa (10.4 or above supported)
|
||||||
|
* A Unix-like environment with X11 for runtime.
|
||||||
|
|
||||||
To build Milsko for Windows, you must have one of following compilers:
|
To build Milsko for Windows, you must have one of following compilers:
|
||||||
* Visual C++ 6.0 or newer
|
* Visual C++ 6.0 or newer
|
||||||
|
|
@ -15,7 +17,7 @@ the Unix-like environment with X11 for runtime.
|
||||||
* Open Watcom 2.0 or newer
|
* Open Watcom 2.0 or newer
|
||||||
* MinGW-w64
|
* MinGW-w64
|
||||||
|
|
||||||
and for Unix-like:
|
and for Unix-like and MacOS:
|
||||||
* GNU C Compiler
|
* GNU C Compiler
|
||||||
* Clang
|
* Clang
|
||||||
|
|
||||||
|
|
@ -61,8 +63,8 @@ D. MinGW-w64/GCC/Clang
|
||||||
|
|
||||||
1) Determine if you need Vulkan and/or OpenGL.
|
1) Determine if you need Vulkan and/or OpenGL.
|
||||||
|
|
||||||
2) Run `./Makefile.pl'.
|
2) Run `./configure'.
|
||||||
For help, run `./Makefile.pl --help'.
|
For help, run `./configure --help'.
|
||||||
|
|
||||||
3) Run `make'.
|
3) Run `make'.
|
||||||
|
|
||||||
|
|
|
||||||
96
WatMakefile
generated
96
WatMakefile
generated
|
|
@ -1,10 +1,25 @@
|
||||||
CC = wcc386 -bt=nt -q -bd
|
CC = wcc386 -bt=nt -q -bd -d3
|
||||||
LD = wlink option quiet
|
LD = wlink option quiet
|
||||||
|
|
||||||
CFLAGS = -i=include -d_MILSKO -dUSE_GDI -dUSE_STB_TRUETYPE -dUSE_STB_IMAGE -dSTBI_NO_SIMD
|
CFLAGS = -i=include -i=external/libz/include -d_MILSKO -dUSE_GDI -dUSE_STB_TRUETYPE -dUSE_STB_IMAGE -dSTBI_NO_SIMD
|
||||||
LDFLAGS = system nt_dll
|
LDFLAGS = system nt_dll
|
||||||
all: src/Mw.dll
|
all: src/Mw.dll
|
||||||
clean: .SYMBOLIC
|
clean: .SYMBOLIC
|
||||||
|
%erase external/libz/src/adler32.obj
|
||||||
|
%erase external/libz/src/compress.obj
|
||||||
|
%erase external/libz/src/crc32.obj
|
||||||
|
%erase external/libz/src/deflate.obj
|
||||||
|
%erase external/libz/src/gzclose.obj
|
||||||
|
%erase external/libz/src/gzlib.obj
|
||||||
|
%erase external/libz/src/gzread.obj
|
||||||
|
%erase external/libz/src/gzwrite.obj
|
||||||
|
%erase external/libz/src/infback.obj
|
||||||
|
%erase external/libz/src/inffast.obj
|
||||||
|
%erase external/libz/src/inflate.obj
|
||||||
|
%erase external/libz/src/inftrees.obj
|
||||||
|
%erase external/libz/src/trees.obj
|
||||||
|
%erase external/libz/src/uncompr.obj
|
||||||
|
%erase external/libz/src/zutil.obj
|
||||||
%erase external/stb_ds.obj
|
%erase external/stb_ds.obj
|
||||||
%erase external/stb_image.obj
|
%erase external/stb_image.obj
|
||||||
%erase external/stb_truetype.obj
|
%erase external/stb_truetype.obj
|
||||||
|
|
@ -25,11 +40,6 @@ clean: .SYMBOLIC
|
||||||
%erase src/dialog/filechooser.obj
|
%erase src/dialog/filechooser.obj
|
||||||
%erase src/dialog/messagebox.obj
|
%erase src/dialog/messagebox.obj
|
||||||
%erase src/draw.obj
|
%erase src/draw.obj
|
||||||
%erase src/error.obj
|
|
||||||
%erase src/font/boldfont.obj
|
|
||||||
%erase src/font/boldttf.obj
|
|
||||||
%erase src/font/font.obj
|
|
||||||
%erase src/font/ttf.obj
|
|
||||||
%erase src/icon/back.obj
|
%erase src/icon/back.obj
|
||||||
%erase src/icon/clock.obj
|
%erase src/icon/clock.obj
|
||||||
%erase src/icon/computer.obj
|
%erase src/icon/computer.obj
|
||||||
|
|
@ -48,7 +58,15 @@ clean: .SYMBOLIC
|
||||||
%erase src/icon/warning.obj
|
%erase src/icon/warning.obj
|
||||||
%erase src/lowlevel.obj
|
%erase src/lowlevel.obj
|
||||||
%erase src/string.obj
|
%erase src/string.obj
|
||||||
%erase src/text.obj
|
%erase src/text/font/boldfont.obj
|
||||||
|
%erase src/text/font/boldmonottf.obj
|
||||||
|
%erase src/text/font/boldttf.obj
|
||||||
|
%erase src/text/font/font.obj
|
||||||
|
%erase src/text/font/monottf.obj
|
||||||
|
%erase src/text/font/ttf.obj
|
||||||
|
%erase src/text/ft2.obj
|
||||||
|
%erase src/text/stbtt.obj
|
||||||
|
%erase src/text/text.obj
|
||||||
%erase src/unicode.obj
|
%erase src/unicode.obj
|
||||||
%erase src/widget/box.obj
|
%erase src/widget/box.obj
|
||||||
%erase src/widget/button.obj
|
%erase src/widget/button.obj
|
||||||
|
|
@ -73,11 +91,41 @@ clean: .SYMBOLIC
|
||||||
%erase src/Mw.dll
|
%erase src/Mw.dll
|
||||||
%erase src/Mw.lib
|
%erase src/Mw.lib
|
||||||
|
|
||||||
src/Mw.dll: external/stb_ds.obj external/stb_image.obj external/stb_truetype.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/error.obj src/font/boldfont.obj src/font/boldttf.obj src/font/font.obj src/font/ttf.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.obj src/unicode.obj src/widget/box.obj src/widget/button.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/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/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/stbtt.obj src/text/text.obj src/unicode.obj src/widget/box.obj src/widget/button.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/treeview.obj src/widget/viewport.obj src/widget/window.obj
|
||||||
$(LD) $(LDFLAGS) option implib=src/Mw.lib name $@ file external/stb_ds.obj file external/stb_image.obj file external/stb_truetype.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/error.obj file src/font/boldfont.obj file src/font/boldttf.obj file src/font/font.obj file src/font/ttf.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.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.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/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library user32.lib
|
$(LD) $(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/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/stbtt.obj file src/text/text.obj file src/unicode.obj file src/widget/box.obj file src/widget/button.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/treeview.obj file src/widget/viewport.obj file src/widget/window.obj library clib3r.lib library opengl32.lib library gdi32.lib library user32.lib library advapi32.lib
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
external/libz/src/adler32.obj: external/libz/src/adler32.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/compress.obj: external/libz/src/compress.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/crc32.obj: external/libz/src/crc32.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/deflate.obj: external/libz/src/deflate.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/gzclose.obj: external/libz/src/gzclose.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/gzlib.obj: external/libz/src/gzlib.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/gzread.obj: external/libz/src/gzread.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/gzwrite.obj: external/libz/src/gzwrite.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/infback.obj: external/libz/src/infback.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/inffast.obj: external/libz/src/inffast.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/inflate.obj: external/libz/src/inflate.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/inftrees.obj: external/libz/src/inftrees.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/trees.obj: external/libz/src/trees.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/uncompr.obj: external/libz/src/uncompr.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
external/libz/src/zutil.obj: external/libz/src/zutil.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
external/stb_ds.obj: external/stb_ds.c
|
external/stb_ds.obj: external/stb_ds.c
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
external/stb_image.obj: external/stb_image.c
|
external/stb_image.obj: external/stb_image.c
|
||||||
|
|
@ -118,16 +166,6 @@ src/dialog/messagebox.obj: src/dialog/messagebox.c
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
src/draw.obj: src/draw.c
|
src/draw.obj: src/draw.c
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
src/error.obj: src/error.c
|
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
|
||||||
src/font/boldfont.obj: src/font/boldfont.c
|
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
|
||||||
src/font/boldttf.obj: src/font/boldttf.c
|
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
|
||||||
src/font/font.obj: src/font/font.c
|
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
|
||||||
src/font/ttf.obj: src/font/ttf.c
|
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
|
||||||
src/icon/back.obj: src/icon/back.c
|
src/icon/back.obj: src/icon/back.c
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
src/icon/clock.obj: src/icon/clock.c
|
src/icon/clock.obj: src/icon/clock.c
|
||||||
|
|
@ -164,7 +202,23 @@ src/lowlevel.obj: src/lowlevel.c
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
src/string.obj: src/string.c
|
src/string.obj: src/string.c
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
src/text.obj: src/text.c
|
src/text/font/boldfont.obj: src/text/font/boldfont.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
src/text/font/boldmonottf.obj: src/text/font/boldmonottf.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
src/text/font/boldttf.obj: src/text/font/boldttf.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
src/text/font/font.obj: src/text/font/font.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
src/text/font/monottf.obj: src/text/font/monottf.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
src/text/font/ttf.obj: src/text/font/ttf.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
src/text/ft2.obj: src/text/ft2.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
src/text/stbtt.obj: src/text/stbtt.c
|
||||||
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
src/text/text.obj: src/text/text.c
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
src/unicode.obj: src/unicode.c
|
src/unicode.obj: src/unicode.c
|
||||||
$(CC) $(CFLAGS) -fo=$@ $<
|
$(CC) $(CFLAGS) -fo=$@ $<
|
||||||
|
|
|
||||||
81
Makefile.pl → configure
vendored
81
Makefile.pl → configure
vendored
|
|
@ -14,11 +14,12 @@ our $prefix = "/usr/local";
|
||||||
our $cc = defined($ENV{CC}) ? $ENV{CC} : "*host*gcc";
|
our $cc = defined($ENV{CC}) ? $ENV{CC} : "*host*gcc";
|
||||||
our $ar = defined($ENV{AR}) ? $ENV{AR} : "*host*ar";
|
our $ar = defined($ENV{AR}) ? $ENV{AR} : "*host*ar";
|
||||||
our $incdir = "-I include";
|
our $incdir = "-I include";
|
||||||
our $cflags = "-fPIC -D_MILSKO";
|
our $incdir2 = "";
|
||||||
|
our $cflags = "-fPIC -D_MILSKO -fvisibility=hidden";
|
||||||
our $libdir = "";
|
our $libdir = "";
|
||||||
our $ldflags = "";
|
our $ldflags = "";
|
||||||
our $math = "-lm";
|
our $math = "-lm";
|
||||||
our $shared = "-shared";
|
our @shared = "-shared";
|
||||||
our @backends = ();
|
our @backends = ();
|
||||||
|
|
||||||
our $library_prefix = "lib";
|
our $library_prefix = "lib";
|
||||||
|
|
@ -37,18 +38,18 @@ require("./pl/utils.pl");
|
||||||
|
|
||||||
param_set("classic-theme", 0);
|
param_set("classic-theme", 0);
|
||||||
param_set("stb-image", 1);
|
param_set("stb-image", 1);
|
||||||
param_set("stb-truetype", 0);
|
|
||||||
param_set("freetype2", 1);
|
|
||||||
param_set("xrender", 1);
|
param_set("xrender", 1);
|
||||||
param_set("opengl", 0);
|
param_set("opengl", 0);
|
||||||
param_set("vulkan", 0);
|
param_set("vulkan", 0);
|
||||||
param_set("vulkan-string-helper", 1);
|
param_set("vulkan-string-helper", 1);
|
||||||
param_set("shared", 1);
|
param_set("shared", 1);
|
||||||
param_set("static", 1);
|
param_set("static", 1);
|
||||||
|
param_set("examples", 1);
|
||||||
|
|
||||||
|
|
||||||
my %features = (
|
my %features = (
|
||||||
"classic-theme" => "use classic theme",
|
"classic-theme" => "use classic theme",
|
||||||
"stb-image" => "use stb_image instead of libjpeg/libpng",
|
"stb-image" => "use stb_image, instead use libjpeg/libpng",
|
||||||
"stb-truetype" => "use stb_truetype",
|
"stb-truetype" => "use stb_truetype",
|
||||||
"freetype2" => "use FreeType2",
|
"freetype2" => "use FreeType2",
|
||||||
"xrender" => "use XRender",
|
"xrender" => "use XRender",
|
||||||
|
|
@ -57,7 +58,8 @@ my %features = (
|
||||||
"vulkan-string-helper" => "use Vulkan string helper",
|
"vulkan-string-helper" => "use Vulkan string helper",
|
||||||
"shared" => "build shared library",
|
"shared" => "build shared library",
|
||||||
"static" => "build static library",
|
"static" => "build static library",
|
||||||
"experimental-wayland" => "enable WIP wayland backend",
|
"wayland" => "enable wayland backend",
|
||||||
|
"gnustep" => "use gnustep",
|
||||||
);
|
);
|
||||||
my @features_keys = (
|
my @features_keys = (
|
||||||
"1classic-theme", "1stb-image",
|
"1classic-theme", "1stb-image",
|
||||||
|
|
@ -65,7 +67,7 @@ my @features_keys = (
|
||||||
"1opengl", "2xrender",
|
"1opengl", "2xrender",
|
||||||
"1vulkan", "2vulkan-string-helper",
|
"1vulkan", "2vulkan-string-helper",
|
||||||
"1shared", "1static",
|
"1shared", "1static",
|
||||||
"1experimental-wayland"
|
"1wayland", "1gnustep",
|
||||||
);
|
);
|
||||||
|
|
||||||
foreach my $l (@ARGV) {
|
foreach my $l (@ARGV) {
|
||||||
|
|
@ -84,9 +86,15 @@ foreach my $l (@ARGV) {
|
||||||
elsif ($l =~ /^--host=(.+)$/) {
|
elsif ($l =~ /^--host=(.+)$/) {
|
||||||
$host = $1 . "-";
|
$host = $1 . "-";
|
||||||
}
|
}
|
||||||
|
elsif ($l =~ /^--cflags=(.+)$/) {
|
||||||
|
add_cflags($1);
|
||||||
|
}
|
||||||
elsif ($l eq "--cross") {
|
elsif ($l eq "--cross") {
|
||||||
$cross = 1;
|
$cross = 1;
|
||||||
}
|
}
|
||||||
|
elsif ($l eq "--tiny") {
|
||||||
|
param_set("tiny",1);
|
||||||
|
}
|
||||||
elsif (($l eq "-h") or ($l eq "--help")) {
|
elsif (($l eq "-h") or ($l eq "--help")) {
|
||||||
print("Milsko Toolkit Configuration Utility\n");
|
print("Milsko Toolkit Configuration Utility\n");
|
||||||
print("\n");
|
print("\n");
|
||||||
|
|
@ -97,6 +105,8 @@ foreach my $l (@ARGV) {
|
||||||
print(" --prefix=PREFIX Installation prefix\n");
|
print(" --prefix=PREFIX Installation prefix\n");
|
||||||
print(" --host=TARGET Host for compiler/archiver\n");
|
print(" --host=TARGET Host for compiler/archiver\n");
|
||||||
print(" --target=TARGET Specify target\n");
|
print(" --target=TARGET Specify target\n");
|
||||||
|
print(" --cflags=CFLAGS Add cflags\n");
|
||||||
|
print(" --tiny Build smallest possible library\n");
|
||||||
print(" --cross Indicate cross compilation\n");
|
print(" --cross Indicate cross compilation\n");
|
||||||
print("\n");
|
print("\n");
|
||||||
print("Features:\n");
|
print("Features:\n");
|
||||||
|
|
@ -122,6 +132,21 @@ foreach my $l (@ARGV) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($target ne "Darwin" and $target ne "ClassicMacOS" and $target ne "Windows") {
|
||||||
|
param_set("freetype2", 1);
|
||||||
|
param_set("stb-truetype", 0);
|
||||||
|
} else {
|
||||||
|
param_set("freetype2", 0);
|
||||||
|
param_set("stb-truetype", 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($target eq "Linux") {
|
||||||
|
param_set("x11", 1);
|
||||||
|
if(!param_get("tiny")){
|
||||||
|
param_set("wayland", 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (-f "./pl/ostype/${target}.pl") {
|
if (-f "./pl/ostype/${target}.pl") {
|
||||||
require("./pl/ostype/${target}.pl");
|
require("./pl/ostype/${target}.pl");
|
||||||
}
|
}
|
||||||
|
|
@ -160,13 +185,13 @@ open(OUT, ">", "Makefile");
|
||||||
print(OUT "PREFIX = ${prefix}\n");
|
print(OUT "PREFIX = ${prefix}\n");
|
||||||
print(OUT "AR = ${ar}\n");
|
print(OUT "AR = ${ar}\n");
|
||||||
print(OUT "CC = ${cc}\n");
|
print(OUT "CC = ${cc}\n");
|
||||||
print(OUT "INCDIR = ${incdir}\n");
|
print(OUT "INCDIR = ${incdir} ${incdir2}\n");
|
||||||
print(OUT "CFLAGS = ${cflags}\n");
|
print(OUT "CFLAGS = ${cflags}\n");
|
||||||
print(OUT "LIBDIR = ${libdir}\n");
|
print(OUT "LIBDIR = ${libdir}\n");
|
||||||
print(OUT "LDFLAGS = ${ldflags}\n");
|
print(OUT "LDFLAGS = ${ldflags}\n");
|
||||||
print(OUT "LIBS = ${math} ${libs}\n");
|
print(OUT "LIBS = ${math} ${libs}\n");
|
||||||
print(OUT "MATH = ${math}\n");
|
print(OUT "MATH = ${math}\n");
|
||||||
print(OUT "SHARED = ${shared}\n");
|
print(OUT "SHARED = @{shared}\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT ".PHONY: all format clean distclean lib examples install\n");
|
print(OUT ".PHONY: all format clean distclean lib examples install\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
|
|
@ -183,10 +208,10 @@ print(OUT " cp -rf include \$(DESTDIR)\$(PREFIX)/\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "format:\n");
|
print(OUT "format:\n");
|
||||||
print(OUT
|
print(OUT
|
||||||
" clang-format --verbose -i `find src include examples -name \"*.c\" -or -name \"*.h\"`\n"
|
" clang-format --verbose -i `find src include examples \"(\" -name \"*.c\" -or -name \"*.h\" -or -name \"*.m\" \")\" -and -not -name \"*ttf.c\"`\n"
|
||||||
);
|
);
|
||||||
print(OUT
|
print(OUT
|
||||||
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl Makefile.pl -name \"*.pl\"`\n"
|
" perltidy -b -bext=\"/\" --paren-tightness=2 `find tools pl configure -name \"*.pl\"`\n"
|
||||||
);
|
);
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "lib:");
|
print(OUT "lib:");
|
||||||
|
|
@ -219,17 +244,24 @@ foreach my $l (@library_targets) {
|
||||||
my $s = $l;
|
my $s = $l;
|
||||||
my $o = $object_suffix;
|
my $o = $object_suffix;
|
||||||
$o =~ s/\./\\\./g;
|
$o =~ s/\./\\\./g;
|
||||||
|
|
||||||
|
if ($l =~ /cocoa/) {
|
||||||
|
$s =~ s/$o$/.m/;
|
||||||
|
}
|
||||||
|
else {
|
||||||
$s =~ s/$o$/.c/;
|
$s =~ s/$o$/.c/;
|
||||||
|
}
|
||||||
|
|
||||||
if ($l =~ /^external\//) {
|
if ($l =~ /^external\//) {
|
||||||
$warn = "";
|
$warn = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
print(OUT "${l}: ${s}\n");
|
print(OUT "${l}: ${s}\n");
|
||||||
print(OUT " \$(CC) $warn \$(CFLAGS\) \$\(INCDIR) -c -o ${l} ${s}\n");
|
print(OUT " \$(CC) $warn \$\(INCDIR) \$(CFLAGS\) -c -o ${l} ${s}\n");
|
||||||
}
|
}
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
|
if (param_get("examples")) {
|
||||||
print(OUT "examples: " . join(" ", @examples_targets) . "\n");
|
print(OUT "examples: " . join(" ", @examples_targets) . "\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
foreach my $l (@examples_targets) {
|
foreach my $l (@examples_targets) {
|
||||||
|
|
@ -243,21 +275,44 @@ foreach my $l (@examples_targets) {
|
||||||
$libs = $examples_libs{$l};
|
$libs = $examples_libs{$l};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (param_get("shared")) {
|
||||||
print(OUT
|
print(OUT
|
||||||
"${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"
|
"${l}: ${s}${object_suffix} src/${library_prefix}Mw${library_suffix}\n"
|
||||||
);
|
);
|
||||||
|
} else {
|
||||||
|
print(OUT
|
||||||
|
"${l}: ${s}${object_suffix} src/${library_prefix}Mw.a\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
if (grep(/^cocoa$/, @backends)) {
|
||||||
|
print(OUT
|
||||||
|
" \$(CC) -L./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
print(OUT
|
print(OUT
|
||||||
" \$(CC) -L src -Wl,-R./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
" \$(CC) -L src -Wl,-R./src \$\(LIBDIR) -o ${l} ${s}${object_suffix} -lMw ${math} ${libs}\n"
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($target eq "ClassicMacOS") {
|
||||||
|
print(OUT
|
||||||
|
" ".$ENV{RETRO68_TOOLCHAIN_PATH}."/bin/MakePEF ${l} -o ${s}.pef\n");
|
||||||
|
print(OUT
|
||||||
|
" Rez -I ".$ENV{RETRO68_TOOLCHAIN_PATH}."/RIncludes ".$ENV{RETRO68_TOOLCHAIN_PATH}."/RIncludes/Retro68APPL.r -DCFRAG_NAME=\"example\" --data ${l}.pef --cc ${l}.dsk -t APPL\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
print(OUT "${s}${object_suffix}: ${s}.c\n");
|
print(OUT "${s}${object_suffix}: ${s}.c\n");
|
||||||
print(OUT
|
print(OUT
|
||||||
" \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n"
|
" \$(CC) -c \$\(INCDIR) -o ${s}${object_suffix} ${s}.c -lMw ${math}\n"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
print(OUT "clean:\n");
|
print(OUT "clean:\n");
|
||||||
print(OUT
|
print(OUT
|
||||||
" rm -f */*.o */*/*.o */*/*/*.o */*.exe */*/*.exe */*/*/*.exe src/*.so src/*.dll src/*.a "
|
" rm -f */*.o */*/*.o */*/*/*.o */*.exe */*/*.exe */*/*/*.exe src/*.so src/*.dll src/*.dylib src/*.a "
|
||||||
. join(" ", @examples_targets)
|
. join(" ", @examples_targets)
|
||||||
. "\n");
|
. "\n");
|
||||||
print(OUT "\n");
|
print(OUT "\n");
|
||||||
8
doc/TINYCONFIG.md
Normal file
8
doc/TINYCONFIG.md
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Tiny Config
|
||||||
|
|
||||||
|
Milsko's configure script supports the `--tiny` option for building the tiniest possible Milsko library (~400kb as of writing). Currently, what it does is:
|
||||||
|
|
||||||
|
- Add `-Oz` to the cflags
|
||||||
|
- (clang only) add `-flto=thin` to the cflags and linker flags
|
||||||
|
- Build stb-image with `STB_IMAGE_STATIC` (this is why you get warnings with stb_image when you use it)
|
||||||
|
- Disable the Wayland backend
|
||||||
|
|
@ -1 +1,7 @@
|
||||||
add_subdirectory(basic)
|
add_subdirectory(basic)
|
||||||
|
if(${MW_TRY_OPENGL})
|
||||||
|
add_subdirectory(gldemos)
|
||||||
|
endif()
|
||||||
|
if(${MW_TRY_VULKAN})
|
||||||
|
add_subdirectory(vkdemos)
|
||||||
|
endif()
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,11 @@ file(
|
||||||
|
|
||||||
foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES)
|
foreach(PATH IN LISTS EXAMPLES_BASIC_SOURCES)
|
||||||
get_filename_component(TARGET ${PATH} NAME_WE)
|
get_filename_component(TARGET ${PATH} NAME_WE)
|
||||||
add_executable(${TARGET} ${PATH})
|
if(CMAKE_SYSTEM_NAME MATCHES Retro)
|
||||||
|
add_application(${TARGET} ${PATH})
|
||||||
|
else()
|
||||||
|
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
|
||||||
|
endif()
|
||||||
target_link_libraries(
|
target_link_libraries(
|
||||||
${TARGET}
|
${TARGET}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
|
|
|
||||||
185
examples/basic/calculator.c
Normal file
185
examples/basic/calculator.c
Normal file
|
|
@ -0,0 +1,185 @@
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
MwWidget widgets[18];
|
||||||
|
MwWidget inp;
|
||||||
|
|
||||||
|
/* probably enough for most tasks */
|
||||||
|
double stack[512];
|
||||||
|
int sp = 0;
|
||||||
|
|
||||||
|
static void resize(MwWidget handle, void* client, void* user) {
|
||||||
|
int ww = MwGetInteger(handle, MwNwidth);
|
||||||
|
int wh = MwGetInteger(handle, MwNheight) - MwGetInteger(inp, MwNheight);
|
||||||
|
int i;
|
||||||
|
|
||||||
|
MwVaApply(inp,
|
||||||
|
MwNwidth, ww,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) {
|
||||||
|
int x = i % 4;
|
||||||
|
int y = i / 4;
|
||||||
|
if(widgets[i] != NULL) {
|
||||||
|
MwVaApply(widgets[i],
|
||||||
|
MwNwidth, ww / 4,
|
||||||
|
MwNheight, wh / 5,
|
||||||
|
MwNx, ww / 4 * x,
|
||||||
|
MwNy, wh / 5 * y + MwGetInteger(inp, MwNheight),
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void activate(MwWidget handle, void* client, void* user) {
|
||||||
|
const char* n = MwGetText(handle, MwNtext);
|
||||||
|
|
||||||
|
if(('0' <= n[0] && n[0] <= '9') || n[0] == '.') {
|
||||||
|
const char* s = MwGetText(inp, MwNtext);
|
||||||
|
char* r;
|
||||||
|
|
||||||
|
if(n[0] == '.' && s != NULL) {
|
||||||
|
int i;
|
||||||
|
for(i = 0; s[i] != 0; i++) {
|
||||||
|
if(s[i] == '.') return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(s == NULL) s = "";
|
||||||
|
|
||||||
|
r = MwStringConcat(s, n);
|
||||||
|
MwVaApply(inp,
|
||||||
|
MwNtext, r,
|
||||||
|
NULL);
|
||||||
|
free(r);
|
||||||
|
} else if(n[0] == 'E') {
|
||||||
|
const char* s = MwGetText(inp, MwNtext);
|
||||||
|
|
||||||
|
if(s != NULL) {
|
||||||
|
stack[sp++] = atof(s);
|
||||||
|
|
||||||
|
MwVaApply(inp,
|
||||||
|
MwNtext, "",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
} else if(n[0] == 'C') {
|
||||||
|
MwVaApply(inp,
|
||||||
|
MwNtext, "",
|
||||||
|
NULL);
|
||||||
|
} else if(n[0] == '+' || n[0] == '-' || n[0] == '*' || n[0] == '/') {
|
||||||
|
if(sp >= 2) {
|
||||||
|
double sv = stack[--sp];
|
||||||
|
double fv = stack[--sp];
|
||||||
|
double v;
|
||||||
|
char buf[256];
|
||||||
|
|
||||||
|
if(n[0] == '+') {
|
||||||
|
v = fv + sv;
|
||||||
|
} else if(n[0] == '-') {
|
||||||
|
v = fv - sv;
|
||||||
|
} else if(n[0] == '*') {
|
||||||
|
v = fv * sv;
|
||||||
|
} else if(n[0] == '/') {
|
||||||
|
v = fv / sv;
|
||||||
|
}
|
||||||
|
|
||||||
|
MwStringPrintIntoBuffer(buf, 256, "%g", v);
|
||||||
|
|
||||||
|
MwVaApply(inp,
|
||||||
|
MwNtext, buf,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
MwWidget w;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) widgets[i] = NULL;
|
||||||
|
|
||||||
|
MwLibraryInit();
|
||||||
|
|
||||||
|
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 150, 150,
|
||||||
|
MwNtitle, "Calculator",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
inp = MwCreateWidget(MwEntryClass, "entry", w, 0, 0, 0, 24);
|
||||||
|
|
||||||
|
widgets[0] = MwVaCreateWidget(MwButtonClass, "7", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "7",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[1] = MwVaCreateWidget(MwButtonClass, "8", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "8",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[2] = MwVaCreateWidget(MwButtonClass, "9", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "9",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[3] = MwVaCreateWidget(MwButtonClass, "/", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "/",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[4] = MwVaCreateWidget(MwButtonClass, "4", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "4",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[5] = MwVaCreateWidget(MwButtonClass, "5", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "5",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[6] = MwVaCreateWidget(MwButtonClass, "6", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "6",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[7] = MwVaCreateWidget(MwButtonClass, "*", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "*",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[8] = MwVaCreateWidget(MwButtonClass, "1", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "1",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[9] = MwVaCreateWidget(MwButtonClass, "2", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "2",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[10] = MwVaCreateWidget(MwButtonClass, "3", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "3",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[11] = MwVaCreateWidget(MwButtonClass, "-", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "-",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[12] = MwVaCreateWidget(MwButtonClass, "0", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "0",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[13] = MwVaCreateWidget(MwButtonClass, ".", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, ".",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[16] = MwVaCreateWidget(MwButtonClass, "E", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "E",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[15] = MwVaCreateWidget(MwButtonClass, "+", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "+",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
widgets[17] = MwVaCreateWidget(MwButtonClass, "C", w, 0, 0, 0, 0,
|
||||||
|
MwNtext, "C",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
for(i = 0; i < sizeof(widgets) / sizeof(widgets[0]); i++) {
|
||||||
|
if(widgets[i] != NULL) MwAddUserHandler(widgets[i], MwNactivateHandler, activate, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);
|
||||||
|
|
||||||
|
resize(w, NULL, NULL);
|
||||||
|
|
||||||
|
MwLoop(w);
|
||||||
|
}
|
||||||
78
examples/basic/clipboard.c
Normal file
78
examples/basic/clipboard.c
Normal file
|
|
@ -0,0 +1,78 @@
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
MwWidget window, instructions, text1, text2, cur_text;
|
||||||
|
|
||||||
|
static void resize(MwWidget handle, void* user_data, void* call_data) {
|
||||||
|
unsigned int w, h;
|
||||||
|
|
||||||
|
(void)user_data;
|
||||||
|
(void)call_data;
|
||||||
|
|
||||||
|
w = MwGetInteger(handle, MwNwidth);
|
||||||
|
h = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
|
MwVaApply(instructions,
|
||||||
|
MwNy, 50,
|
||||||
|
MwNwidth, w - 50 * 2,
|
||||||
|
MwNheight, h - 125 - 50 * 3,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
MwVaApply(text1,
|
||||||
|
MwNy, 150,
|
||||||
|
MwNwidth, w - 25 * 2,
|
||||||
|
MwNheight, h - 125 - 50 * 3,
|
||||||
|
NULL);
|
||||||
|
MwVaApply(text2,
|
||||||
|
MwNy, 250,
|
||||||
|
MwNwidth, w - 25 * 2,
|
||||||
|
MwNheight, h - 125 - 50 * 3,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
static void clipboard(MwWidget handle, void* user_data, void* call_data) {
|
||||||
|
char* clipboard = call_data;
|
||||||
|
|
||||||
|
(void)handle;
|
||||||
|
(void)user_data;
|
||||||
|
|
||||||
|
if(clipboard != NULL) {
|
||||||
|
MwVaApply(cur_text, MwNtext, clipboard, NULL);
|
||||||
|
MwForceRender(cur_text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void tick(MwWidget handle, void* user_data, void* call_data) {
|
||||||
|
cur_text = text1;
|
||||||
|
MwGetClipboard(handle, MwCLIPBOARD_MAIN);
|
||||||
|
cur_text = text2;
|
||||||
|
MwGetClipboard(handle, MwCLIPBOARD_PRIMARY);
|
||||||
|
MwForceRender(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
MwLibraryInit();
|
||||||
|
|
||||||
|
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 400, 400,
|
||||||
|
MwNtitle, "clipboard",
|
||||||
|
NULL);
|
||||||
|
instructions = MwVaCreateWidget(MwLabelClass, "button", window, 50, 50, 300, 125,
|
||||||
|
MwNtext, "clipboard contents will show up below.",
|
||||||
|
NULL);
|
||||||
|
text1 = MwVaCreateWidget(MwLabelClass, "label", window, 25, 150, 300, 75,
|
||||||
|
MwNtext, "",
|
||||||
|
NULL);
|
||||||
|
text2 = MwVaCreateWidget(MwLabelClass, "label2", window, 25, 250, 300, 75,
|
||||||
|
MwNtext, "",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
cur_text = text1;
|
||||||
|
|
||||||
|
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||||
|
MwAddUserHandler(window, MwNclipboardHandler, clipboard, NULL);
|
||||||
|
MwAddUserHandler(instructions, MwNclipboardHandler, clipboard, NULL);
|
||||||
|
MwAddUserHandler(cur_text, MwNclipboardHandler, clipboard, NULL);
|
||||||
|
MwAddUserHandler(window, MwNtickHandler, tick, NULL);
|
||||||
|
|
||||||
|
resize(window, NULL, NULL);
|
||||||
|
|
||||||
|
MwLoop(window);
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
|
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
MwWidget cpicker;
|
MwWidget cpicker;
|
||||||
|
|
@ -15,7 +14,7 @@ void color_callback(MwWidget handle, void* user_data, void* call_data) {
|
||||||
rgb->red &= 0xff;
|
rgb->red &= 0xff;
|
||||||
rgb->green &= 0xff;
|
rgb->green &= 0xff;
|
||||||
rgb->blue &= 0xff;
|
rgb->blue &= 0xff;
|
||||||
sprintf(hexColor, "#%02X%02X%02X", rgb->red, rgb->green, rgb->blue);
|
MwStringPrintIntoBuffer(hexColor, 8, "#%02X%02X%02X", rgb->red, rgb->green, rgb->blue);
|
||||||
MwSetText(window, MwNbackground, hexColor);
|
MwSetText(window, MwNbackground, hexColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -28,7 +27,7 @@ void color_picker(MwWidget handle, void* user_data, void* call_data) {
|
||||||
|
|
||||||
MwAddUserHandler(cpicker, MwNcolorChosenHandler, color_callback, NULL);
|
MwAddUserHandler(cpicker, MwNcolorChosenHandler, color_callback, NULL);
|
||||||
|
|
||||||
MwSetText(cpicker, MwNbackground, MwDefaultBackground);
|
MwSetText(cpicker, MwNbackground, MwGetInteger(cpicker, MwNdarkTheme) ? MwDefaultDarkBackground : MwDefaultBackground);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
@ -36,12 +35,12 @@ int main() {
|
||||||
|
|
||||||
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
|
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
|
||||||
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
|
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
|
||||||
MwSetText(window, MwNbackground, "#000000");
|
MwSetText(window, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
|
||||||
|
|
||||||
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, MwDefaultBackground);
|
MwSetText(button, MwNbackground, MwGetInteger(window, MwNdarkTheme) ? MwDefaultBackground : MwDefaultDarkBackground);
|
||||||
|
|
||||||
MwAddUserHandler(button, MwNactivateHandler, color_picker, NULL);
|
MwAddUserHandler(button, MwNactivateHandler, color_picker, NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
MwWidget window, menu, button, button2, button3, button4;
|
MwWidget window, menu, button, button2, button3, button4, button5, button6;
|
||||||
|
|
||||||
void handler(MwWidget handle, void* user_data, void* call_data) {
|
void handler(MwWidget handle, void* user_data, void* call_data) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
|
@ -10,14 +10,34 @@ void handler(MwWidget handle, void* user_data, void* call_data) {
|
||||||
printf("hello world!\n");
|
printf("hello world!\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
int toggle = 0;
|
void handler_theme(MwWidget handle, void* user_data, void* call_data) {
|
||||||
void handler_dark(MwWidget handle, void* user_data, void* call_data) {
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)user_data;
|
(void)user_data;
|
||||||
(void)call_data;
|
(void)call_data;
|
||||||
|
|
||||||
toggle = toggle ? 0 : 1;
|
MwVaApply(window,
|
||||||
MwToggleDarkTheme(window, toggle);
|
MwNdarkTheme, MwGetInteger(window, MwNdarkTheme) == 0 ? 1 : 0,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handler_look(MwWidget handle, void* user_data, void* call_data) {
|
||||||
|
(void)handle;
|
||||||
|
(void)user_data;
|
||||||
|
(void)call_data;
|
||||||
|
|
||||||
|
MwVaApply(window,
|
||||||
|
MwNmodernLook, MwGetInteger(window, MwNmodernLook) == 0 ? 1 : 0,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
void handler_font(MwWidget handle, void* user_data, void* call_data) {
|
||||||
|
(void)handle;
|
||||||
|
(void)user_data;
|
||||||
|
(void)call_data;
|
||||||
|
|
||||||
|
MwVaApply(window,
|
||||||
|
MwNbitmapFont, MwGetInteger(window, MwNbitmapFont) == 0 ? 1 : 0,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
void resize(MwWidget handle, void* user_data, void* call_data) {
|
void resize(MwWidget handle, void* user_data, void* call_data) {
|
||||||
|
|
@ -31,23 +51,37 @@ void resize(MwWidget handle, void* user_data, void* call_data) {
|
||||||
|
|
||||||
MwVaApply(button,
|
MwVaApply(button,
|
||||||
MwNy, 50 + mh,
|
MwNy, 50 + mh,
|
||||||
MwNwidth, w - 50 * 2,
|
MwNwidth, (w - 50 * 2) / 3,
|
||||||
MwNheight, h - 125 - 50 * 3,
|
MwNheight, h - 125 - 50 * 3,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwVaApply(button2,
|
MwVaApply(button2,
|
||||||
|
MwNx, 50 + (w - 50 * 2) / 3,
|
||||||
|
MwNy, 50 + mh,
|
||||||
|
MwNwidth, (w - 50 * 2) / 3,
|
||||||
|
MwNheight, h - 125 - 50 * 3,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
MwVaApply(button3,
|
||||||
|
MwNx, 50 + (w - 50 * 2) / 3 * 2,
|
||||||
|
MwNy, 50 + mh,
|
||||||
|
MwNwidth, (w - 50 * 2) / 3,
|
||||||
|
MwNheight, h - 125 - 50 * 3,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
MwVaApply(button4,
|
||||||
MwNx, 50 + (w - 50 * 2) / 3 * 0,
|
MwNx, 50 + (w - 50 * 2) / 3 * 0,
|
||||||
MwNy, h - 50 - 125 + mh,
|
MwNy, h - 50 - 125 + mh,
|
||||||
MwNwidth, (w - 50 * 2) / 3,
|
MwNwidth, (w - 50 * 2) / 3,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwVaApply(button3,
|
MwVaApply(button5,
|
||||||
MwNx, 50 + (w - 50 * 2) / 3 * 1,
|
MwNx, 50 + (w - 50 * 2) / 3 * 1,
|
||||||
MwNy, h - 50 - 125 + mh,
|
MwNy, h - 50 - 125 + mh,
|
||||||
MwNwidth, (w - 50 * 2) / 3,
|
MwNwidth, (w - 50 * 2) / 3,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwVaApply(button4,
|
MwVaApply(button6,
|
||||||
MwNx, 50 + (w - 50 * 2) / 3 * 2,
|
MwNx, 50 + (w - 50 * 2) / 3 * 2,
|
||||||
MwNy, h - 50 - 125 + mh,
|
MwNy, h - 50 - 125 + mh,
|
||||||
MwNwidth, (w - 50 * 2) / 3,
|
MwNwidth, (w - 50 * 2) / 3,
|
||||||
|
|
@ -63,30 +97,38 @@ int main() {
|
||||||
MwNtitle, "hello world",
|
MwNtitle, "hello world",
|
||||||
NULL);
|
NULL);
|
||||||
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
|
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
|
||||||
button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 125,
|
button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 100, 125,
|
||||||
MwNtext, "toggle dark theme",
|
MwNtext, "theme",
|
||||||
NULL);
|
NULL);
|
||||||
button2 = MwVaCreateWidget(MwButtonClass, "button", window, 50, 225, 100, 125,
|
button2 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 50, 100, 125,
|
||||||
|
MwNtext, "look",
|
||||||
|
NULL);
|
||||||
|
button3 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 50, 100, 125,
|
||||||
|
MwNtext, "font",
|
||||||
|
NULL);
|
||||||
|
button4 = MwVaCreateWidget(MwButtonClass, "button", window, 50, 225, 100, 125,
|
||||||
MwNtext, "lorem ipsum",
|
MwNtext, "lorem ipsum",
|
||||||
MwNbackground, "#f66",
|
MwNbackground, "#f66",
|
||||||
MwNforeground, "#000",
|
MwNforeground, "#000",
|
||||||
NULL);
|
NULL);
|
||||||
button3 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 225, 100, 125,
|
button5 = MwVaCreateWidget(MwButtonClass, "button", window, 150, 225, 100, 125,
|
||||||
MwNtext, "lorem ipsum",
|
MwNtext, "lorem ipsum",
|
||||||
MwNbackground, "#6f6",
|
MwNbackground, "#6f6",
|
||||||
MwNforeground, "#000",
|
MwNforeground, "#000",
|
||||||
NULL);
|
NULL);
|
||||||
button4 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 225, 100, 125,
|
button6 = MwVaCreateWidget(MwButtonClass, "button", window, 250, 225, 100, 125,
|
||||||
MwNtext, "lorem ipsum",
|
MwNtext, "lorem ipsum",
|
||||||
MwNbackground, "#66f",
|
MwNbackground, "#66f",
|
||||||
MwNforeground, "#000",
|
MwNforeground, "#000",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||||
MwAddUserHandler(button, MwNactivateHandler, handler_dark, NULL);
|
MwAddUserHandler(button, MwNactivateHandler, handler_theme, NULL);
|
||||||
MwAddUserHandler(button2, MwNactivateHandler, handler, NULL);
|
MwAddUserHandler(button2, MwNactivateHandler, handler_look, NULL);
|
||||||
MwAddUserHandler(button3, MwNactivateHandler, handler, NULL);
|
MwAddUserHandler(button3, MwNactivateHandler, handler_font, NULL);
|
||||||
MwAddUserHandler(button4, MwNactivateHandler, handler, NULL);
|
MwAddUserHandler(button4, MwNactivateHandler, handler, NULL);
|
||||||
|
MwAddUserHandler(button5, MwNactivateHandler, handler, NULL);
|
||||||
|
MwAddUserHandler(button6, MwNactivateHandler, handler, NULL);
|
||||||
|
|
||||||
resize(window, NULL, NULL);
|
resize(window, NULL, NULL);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ void activate(MwWidget handle, void* user, void* call) {
|
||||||
|
|
||||||
(void)user;
|
(void)user;
|
||||||
|
|
||||||
sprintf(msg, "You pressed: %s", MwListBoxGet(handle, *(int*)call));
|
MwStringPrintIntoBuffer(msg, 256, "You pressed: %s", MwListBoxGet(handle, *(int*)call));
|
||||||
|
|
||||||
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
|
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
|
||||||
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
|
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
|
||||||
|
|
@ -48,7 +48,7 @@ int main() {
|
||||||
|
|
||||||
for(i = 0; i < len; i++) {
|
for(i = 0; i < len; i++) {
|
||||||
char sz[16];
|
char sz[16];
|
||||||
sprintf(sz, "%d", (int)strlen(harvard[i]));
|
MwStringPrintIntoBuffer(sz, 16, "%d", (int)strlen(harvard[i]));
|
||||||
index = MwListBoxPacketInsert(packet, -1);
|
index = MwListBoxPacketInsert(packet, -1);
|
||||||
MwListBoxPacketSetIcon(packet, index, px);
|
MwListBoxPacketSetIcon(packet, index, px);
|
||||||
MwListBoxPacketSet(packet, index, 0, harvard[i]);
|
MwListBoxPacketSet(packet, index, 0, harvard[i]);
|
||||||
|
|
|
||||||
285
examples/basic/periodic.c
Normal file
285
examples/basic/periodic.c
Normal file
|
|
@ -0,0 +1,285 @@
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
#define Columns 5
|
||||||
|
#define Padding 20
|
||||||
|
#define PaddingContent 2
|
||||||
|
|
||||||
|
MwWidget window, menu, box;
|
||||||
|
MwWidget boxes[32];
|
||||||
|
int n = 0, row = -1;
|
||||||
|
MwMenu e;
|
||||||
|
|
||||||
|
static void resize(MwWidget handle, void* user, void* call) {
|
||||||
|
int w = MwGetInteger(window, MwNwidth);
|
||||||
|
int h = MwGetInteger(window, MwNheight);
|
||||||
|
|
||||||
|
MwVaApply(box,
|
||||||
|
MwNx, Padding,
|
||||||
|
MwNy, MwGetInteger(menu, MwNheight) + Padding,
|
||||||
|
MwNwidth, w - Padding * 2,
|
||||||
|
MwNheight, h - MwGetInteger(menu, MwNheight) - Padding * 2,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void newrow(void) {
|
||||||
|
if(row >= 0) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = n; i < Columns; i++) MwCreateWidget(MwFrameClass, "frame", boxes[row], 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
boxes[++row] = MwCreateWidget(MwBoxClass, "box", box, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
n = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void add(MwWidget w) {
|
||||||
|
int r = MwGetInteger(w, MwNratio);
|
||||||
|
|
||||||
|
if(r == MwDEFAULT) r = 1;
|
||||||
|
|
||||||
|
n += r;
|
||||||
|
|
||||||
|
if(n == Columns) {
|
||||||
|
newrow();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void resize_content(MwWidget handle, void* user, void* call) {
|
||||||
|
MwWidget* ws = MwGetChildren(handle);
|
||||||
|
if(ws != NULL) {
|
||||||
|
int pw = MwGetInteger(ws[0], "IpWidth");
|
||||||
|
int ph = MwGetInteger(ws[0], "IpHeight");
|
||||||
|
|
||||||
|
if(pw < 0) {
|
||||||
|
pw += MwGetInteger(handle, MwNwidth);
|
||||||
|
} else if(pw == 0) {
|
||||||
|
pw = MwGetInteger(handle, MwNwidth);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(ph < 0) {
|
||||||
|
ph += MwGetInteger(handle, MwNheight);
|
||||||
|
} else if(ph == 0) {
|
||||||
|
ph = MwGetInteger(handle, MwNheight);
|
||||||
|
}
|
||||||
|
|
||||||
|
MwVaApply(ws[0],
|
||||||
|
MwNx, (MwGetInteger(handle, MwNwidth) - pw) / 2,
|
||||||
|
MwNy, (MwGetInteger(handle, MwNheight) - ph) / 2,
|
||||||
|
MwNwidth, pw,
|
||||||
|
MwNheight, ph,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
free(ws);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void resize_frame(MwWidget handle, void* user, void* call) {
|
||||||
|
MwWidget* ws = MwGetChildren(handle);
|
||||||
|
if(ws != NULL) {
|
||||||
|
int w = MwGetInteger(handle, MwNwidth);
|
||||||
|
int h = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
|
if(ws[0] != NULL) {
|
||||||
|
MwVaApply(ws[0],
|
||||||
|
MwNx, MwDefaultBorderWidth(handle) + PaddingContent,
|
||||||
|
MwNy, MwDefaultBorderWidth(handle) + PaddingContent,
|
||||||
|
MwNwidth, w - (MwDefaultBorderWidth(handle) + PaddingContent) * 2,
|
||||||
|
MwNheight, h - (MwDefaultBorderWidth(handle) + PaddingContent) * 2,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
free(ws);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static MwWidget frame(const char* name, int width, int height, MwClass cl, ...) {
|
||||||
|
MwWidget f = MwVaCreateWidget(MwFrameClass, "frame", boxes[row], 0, 0, 0, 0,
|
||||||
|
MwNhasBorder, 1,
|
||||||
|
MwNinverted, 1,
|
||||||
|
NULL);
|
||||||
|
MwWidget box = MwVaCreateWidget(MwBoxClass, "box", f, 0, 0, 0, 0,
|
||||||
|
MwNorientation, MwVERTICAL,
|
||||||
|
NULL);
|
||||||
|
MwWidget label = MwVaCreateWidget(MwLabelClass, "label", box, 0, 0, 0, 0,
|
||||||
|
MwNtext, name,
|
||||||
|
MwNalignment, MwALIGNMENT_BEGINNING,
|
||||||
|
MwNfixedSize, 20,
|
||||||
|
NULL);
|
||||||
|
va_list va;
|
||||||
|
|
||||||
|
if(cl != NULL) {
|
||||||
|
MwWidget frame = MwCreateWidget(MwFrameClass, "frame", box, 0, 0, 0, 0);
|
||||||
|
MwWidget w;
|
||||||
|
|
||||||
|
va_start(va, cl);
|
||||||
|
w = MwVaListCreateWidget(cl, "widget", frame, 0, 0, 0, 0, va);
|
||||||
|
va_end(va);
|
||||||
|
|
||||||
|
MwVaApply(w,
|
||||||
|
"IpWidth", width,
|
||||||
|
"IpHeight", height,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
MwAddUserHandler(frame, MwNresizeHandler, resize_content, NULL);
|
||||||
|
|
||||||
|
MwVaApply(f,
|
||||||
|
"VhandledWidget", w,
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
MwAddUserHandler(f, MwNresizeHandler, resize_frame, NULL);
|
||||||
|
|
||||||
|
resize_frame(f, NULL, NULL);
|
||||||
|
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
static MwWidget child(MwWidget w) {
|
||||||
|
return MwGetVoid(w, "VhandledWidget");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void menu_handler(MwWidget handle, void* user, void* call) {
|
||||||
|
if(call == e) MwDestroyWidget(window);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int i;
|
||||||
|
MwWidget f, w;
|
||||||
|
MwListBoxPacket* pkt;
|
||||||
|
int index;
|
||||||
|
MwMenu m, m2;
|
||||||
|
void* v;
|
||||||
|
|
||||||
|
MwLibraryInit();
|
||||||
|
|
||||||
|
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 800, 800,
|
||||||
|
MwNtitle, "Milsko Periodic Table",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
|
||||||
|
|
||||||
|
m = MwMenuAdd(menu, NULL, "File");
|
||||||
|
MwMenuAdd(menu, m, "New");
|
||||||
|
MwMenuAdd(menu, m, "Open");
|
||||||
|
MwMenuAdd(menu, m, "Save");
|
||||||
|
MwMenuAdd(menu, m, "Save As");
|
||||||
|
MwMenuAdd(menu, m, "Print");
|
||||||
|
e = MwMenuAdd(menu, m, "Exit");
|
||||||
|
|
||||||
|
m = MwMenuAdd(menu, NULL, "Edit");
|
||||||
|
MwMenuAdd(menu, m, "Undo");
|
||||||
|
MwMenuAdd(menu, m, "----");
|
||||||
|
MwMenuAdd(menu, m, "Cut");
|
||||||
|
MwMenuAdd(menu, m, "Copy");
|
||||||
|
MwMenuAdd(menu, m, "Paste");
|
||||||
|
MwMenuAdd(menu, m, "----");
|
||||||
|
MwMenuAdd(menu, m, "Clear");
|
||||||
|
MwMenuAdd(menu, m, "Delete");
|
||||||
|
|
||||||
|
m = MwMenuAdd(menu, NULL, "View");
|
||||||
|
MwMenuAdd(menu, m, "Stack");
|
||||||
|
MwMenuAdd(menu, m, "Tile");
|
||||||
|
MwMenuAdd(menu, m, "----");
|
||||||
|
MwMenuAdd(menu, m, "Day");
|
||||||
|
MwMenuAdd(menu, m, "Week");
|
||||||
|
MwMenuAdd(menu, m, "Month");
|
||||||
|
MwMenuAdd(menu, m, "Year");
|
||||||
|
|
||||||
|
m = MwMenuAdd(menu, NULL, "Options");
|
||||||
|
m2 = MwMenuAdd(menu, m, "Font");
|
||||||
|
MwMenuAdd(menu, m2, "Small");
|
||||||
|
MwMenuAdd(menu, m2, "Medium");
|
||||||
|
MwMenuAdd(menu, m2, "Large");
|
||||||
|
m2 = MwMenuAdd(menu, m, "Direction");
|
||||||
|
MwMenuAdd(menu, m2, "Up");
|
||||||
|
MwMenuAdd(menu, m2, "Down");
|
||||||
|
MwMenuAdd(menu, m2, "Left");
|
||||||
|
MwMenuAdd(menu, m2, "Right");
|
||||||
|
MwMenuAdd(menu, m, "Case Sensitive");
|
||||||
|
MwMenuAdd(menu, m, "Word Wrap");
|
||||||
|
|
||||||
|
m = MwMenuAdd(menu, NULL, "?Help");
|
||||||
|
MwMenuAdd(menu, m, "On Context");
|
||||||
|
MwMenuAdd(menu, m, "On Window");
|
||||||
|
MwMenuAdd(menu, m, "Tutorial");
|
||||||
|
MwMenuAdd(menu, m, "On Version");
|
||||||
|
|
||||||
|
MwAddUserHandler(menu, MwNmenuHandler, menu_handler, NULL);
|
||||||
|
|
||||||
|
box = MwVaCreateWidget(MwBoxClass, "box", window, 0, 0, 0, 0,
|
||||||
|
MwNorientation, MwVERTICAL,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
newrow();
|
||||||
|
|
||||||
|
f = frame("Button", -PaddingContent, -PaddingContent, MwButtonClass,
|
||||||
|
MwNtext, "Press me",
|
||||||
|
NULL);
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
add(MwVaCreateWidget(MwLabelClass, "label", boxes[row], 0, 0, 0, 0,
|
||||||
|
MwNbold, 1,
|
||||||
|
MwNtext, "The Periodic Table of Milsko Widgets",
|
||||||
|
MwNratio, Columns - 2,
|
||||||
|
NULL));
|
||||||
|
|
||||||
|
f = frame("ComboBox", -PaddingContent, 24, MwComboBoxClass, NULL);
|
||||||
|
w = child(f);
|
||||||
|
MwComboBoxAdd(w, -1, "Hello!");
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
f = frame("Entry", -PaddingContent, 24, MwEntryClass, NULL);
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
f = frame("Label", -PaddingContent, -PaddingContent, MwLabelClass,
|
||||||
|
MwNtext, "Epic text",
|
||||||
|
NULL);
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
f = frame("ListBox", -PaddingContent, -PaddingContent, MwListBoxClass,
|
||||||
|
MwNhasHeading, 1,
|
||||||
|
NULL);
|
||||||
|
w = child(f);
|
||||||
|
pkt = MwListBoxCreatePacket();
|
||||||
|
index = MwListBoxPacketInsert(pkt, -1);
|
||||||
|
MwListBoxPacketSet(pkt, index, 0, "Epic title...");
|
||||||
|
index = MwListBoxPacketInsert(pkt, -1);
|
||||||
|
MwListBoxPacketSet(pkt, index, 0, "Hello");
|
||||||
|
MwListBoxInsert(w, -1, pkt);
|
||||||
|
MwListBoxDestroyPacket(pkt);
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
f = frame("NumberEntry", -PaddingContent, 24, MwNumberEntryClass, NULL);
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
f = frame("ProgressBar", -PaddingContent, 24, MwProgressBarClass,
|
||||||
|
MwNvalue, 25,
|
||||||
|
NULL);
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
f = frame("ScrollBar", -PaddingContent, 16, MwScrollBarClass,
|
||||||
|
MwNorientation, MwHORIZONTAL,
|
||||||
|
NULL);
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL);
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
f = frame("TreeView", -PaddingContent, -PaddingContent, MwTreeViewClass, NULL);
|
||||||
|
w = child(f);
|
||||||
|
v = MwTreeViewAdd(w, NULL, NULL, "abc");
|
||||||
|
v = MwTreeViewAdd(w, v, NULL, "def");
|
||||||
|
v = MwTreeViewAdd(w, v, NULL, "ghi");
|
||||||
|
add(f);
|
||||||
|
|
||||||
|
if(n != 0) newrow();
|
||||||
|
if(n == 0) MwDestroyWidget(boxes[row]);
|
||||||
|
|
||||||
|
MwAddUserHandler(window, MwNresizeHandler, resize, NULL);
|
||||||
|
|
||||||
|
resize(window, NULL, NULL);
|
||||||
|
|
||||||
|
MwLoop(window);
|
||||||
|
}
|
||||||
23
examples/basic/sevensegment.c
Normal file
23
examples/basic/sevensegment.c
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
MwWidget wnd, label;
|
||||||
|
int W = 480, H = 40;
|
||||||
|
|
||||||
|
MwLibraryInit();
|
||||||
|
|
||||||
|
wnd = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, W, H,
|
||||||
|
MwNtitle, "seven segment",
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
label = MwVaCreateWidget(MwLabelClass, "label", wnd, 0, 0, W, H,
|
||||||
|
MwNtext, " 123456:78.90 abcdef",
|
||||||
|
MwNsevenSegment, 1,
|
||||||
|
MwNalignment, MwALIGNMENT_BEGINNING,
|
||||||
|
MwNlength, 8,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
MwLabelSetSevenSegment(label, 0, (1 << 0) | (1 << 3) | (1 << 6));
|
||||||
|
|
||||||
|
MwLoop(wnd);
|
||||||
|
}
|
||||||
|
|
@ -14,7 +14,7 @@ void activate(MwWidget handle, void* user, void* call) {
|
||||||
|
|
||||||
(void)user;
|
(void)user;
|
||||||
|
|
||||||
sprintf(msg, "You pressed: %s", MwTreeViewGet(handle, call));
|
MwStringPrintIntoBuffer(msg, 256, "You pressed: %s", MwTreeViewGet(handle, call));
|
||||||
|
|
||||||
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
|
msgbox = MwMessageBox(wmain, msg, "wow", MwMB_ICONINFO | MwMB_BUTTONOK);
|
||||||
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
|
MwAddUserHandler(MwMessageBoxGetChild(msgbox, MwMB_BUTTONOK), MwNactivateHandler, destroy, msgbox);
|
||||||
|
|
|
||||||
27
examples/gldemos/CMakeLists.txt
Normal file
27
examples/gldemos/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
file(
|
||||||
|
GLOB
|
||||||
|
EXAMPLES_GL_SOURCES
|
||||||
|
*.c
|
||||||
|
)
|
||||||
|
find_package(OpenGL)
|
||||||
|
|
||||||
|
foreach(PATH IN LISTS EXAMPLES_GL_SOURCES)
|
||||||
|
get_filename_component(TARGET ${PATH} NAME_WE)
|
||||||
|
if(${TARGET} STREQUAL "glutlayer")
|
||||||
|
continue()
|
||||||
|
endif()
|
||||||
|
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
|
||||||
|
target_link_libraries(
|
||||||
|
${TARGET}
|
||||||
|
PRIVATE
|
||||||
|
Mw
|
||||||
|
OpenGL::GL OpenGL::GLU
|
||||||
|
)
|
||||||
|
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
target_link_libraries(
|
||||||
|
${TARGET}
|
||||||
|
PRIVATE
|
||||||
|
m
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
@ -32,10 +32,10 @@ void tick(MwWidget handle, void* user, void* call) {
|
||||||
char buf[512];
|
char buf[512];
|
||||||
tm = localtime(&t);
|
tm = localtime(&t);
|
||||||
|
|
||||||
sprintf(buf, "%s %02d %s", mon[tm->tm_mon], tm->tm_mday, wday[tm->tm_wday]);
|
MwStringPrintIntoBuffer(buf, 512, "%s %02d %s", mon[tm->tm_mon], tm->tm_mday, wday[tm->tm_wday]);
|
||||||
MwSetText(ldate, MwNtext, buf);
|
MwSetText(ldate, MwNtext, buf);
|
||||||
|
|
||||||
sprintf(buf, "%02d:%02d %s", tm->tm_hour % 12, tm->tm_min, tm->tm_hour >= 12 ? "PM" : "AM");
|
MwStringPrintIntoBuffer(buf, 512, "%02d:%02d %s", tm->tm_hour % 12, tm->tm_min, tm->tm_hour >= 12 ? "PM" : "AM");
|
||||||
MwSetText(ltime, MwNtext, buf);
|
MwSetText(ltime, MwNtext, buf);
|
||||||
|
|
||||||
render = 1;
|
render = 1;
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,13 @@
|
||||||
#define TITLE "cube"
|
#define TITLE "cube"
|
||||||
#include "glutlayer.c"
|
#include "glutlayer.c"
|
||||||
|
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
#else
|
||||||
|
#include <GL/gl.h>
|
||||||
#include <GL/glu.h>
|
#include <GL/glu.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
static double deg = 0;
|
static double deg = 0;
|
||||||
|
|
||||||
|
|
@ -15,12 +21,18 @@ static void draw(void) {
|
||||||
glRotatef(deg, 0, 0, 1);
|
glRotatef(deg, 0, 0, 1);
|
||||||
|
|
||||||
for(i = 0; i < 6; i++) {
|
for(i = 0; i < 6; i++) {
|
||||||
if(i == 0) glColor3f(1, 0, 0);
|
if(i == 0)
|
||||||
if(i == 1) glColor3f(0, 1, 0);
|
glColor3f(1, 0, 0);
|
||||||
if(i == 2) glColor3f(1, 1, 0);
|
if(i == 1)
|
||||||
if(i == 3) glColor3f(0, 0, 1);
|
glColor3f(0, 1, 0);
|
||||||
if(i == 4) glColor3f(1, 0, 1);
|
if(i == 2)
|
||||||
if(i == 5) glColor3f(0, 1, 1);
|
glColor3f(1, 1, 0);
|
||||||
|
if(i == 3)
|
||||||
|
glColor3f(0, 0, 1);
|
||||||
|
if(i == 4)
|
||||||
|
glColor3f(1, 0, 1);
|
||||||
|
if(i == 5)
|
||||||
|
glColor3f(0, 1, 1);
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
glNormal3f(0, 1, 0);
|
glNormal3f(0, 1, 0);
|
||||||
|
|
@ -30,9 +42,12 @@ static void draw(void) {
|
||||||
glVertex3f(1, 1, -1);
|
glVertex3f(1, 1, -1);
|
||||||
glEnd();
|
glEnd();
|
||||||
|
|
||||||
if(i < 3) glRotatef(90, 0, 0, 1);
|
if(i < 3)
|
||||||
if(i == 3) glRotatef(90, 1, 0, 0);
|
glRotatef(90, 0, 0, 1);
|
||||||
if(i == 4) glRotatef(180, 0, 0, 1);
|
if(i == 3)
|
||||||
|
glRotatef(90, 1, 0, 0);
|
||||||
|
if(i == 4)
|
||||||
|
glRotatef(180, 0, 0, 1);
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,12 +51,12 @@ static void tick(MwWidget handle, void* user, void* call) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void mouse(MwWidget handle, void* user, void* call) {
|
static void mouse(MwWidget handle, void* user, void* call) {
|
||||||
MwLLMouse* mouse = call;
|
MwMouse* mouse = call;
|
||||||
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)user;
|
(void)user;
|
||||||
|
|
||||||
if(mouse->button == MwLLMouseLeft) {
|
if(mouse->button == MwMOUSE_LEFT) {
|
||||||
t[ct].points[click * 2 + 0] = mouse->point.x;
|
t[ct].points[click * 2 + 0] = mouse->point.x;
|
||||||
t[ct].points[click * 2 + 1] = mouse->point.y;
|
t[ct].points[click * 2 + 1] = mouse->point.y;
|
||||||
click++;
|
click++;
|
||||||
|
|
@ -82,7 +82,7 @@ static void mouse(MwWidget handle, void* user, void* call) {
|
||||||
for(i = 0; i < ct; i++) t[i] = old[i];
|
for(i = 0; i < ct; i++) t[i] = old[i];
|
||||||
free(old);
|
free(old);
|
||||||
}
|
}
|
||||||
} else if(mouse->button == MwLLMouseRight) {
|
} else if(mouse->button == MwMOUSE_RIGHT) {
|
||||||
if(click > 0) {
|
if(click > 0) {
|
||||||
click = 0;
|
click = 0;
|
||||||
} else if(ct > 0) {
|
} else if(ct > 0) {
|
||||||
|
|
|
||||||
28
examples/vkdemos/CMakeLists.txt
Normal file
28
examples/vkdemos/CMakeLists.txt
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
file(
|
||||||
|
GLOB
|
||||||
|
EXAMPLES_VULKAN_SOURCES
|
||||||
|
*.c
|
||||||
|
)
|
||||||
|
find_package(Vulkan)
|
||||||
|
|
||||||
|
foreach(PATH IN LISTS EXAMPLES_VULKAN_SOURCES)
|
||||||
|
get_filename_component(TARGET ${PATH} NAME_WE)
|
||||||
|
add_executable(${TARGET} MACOSX_BUNDLE ${PATH})
|
||||||
|
target_include_directories(
|
||||||
|
${TARGET}
|
||||||
|
PRIVATE
|
||||||
|
${Vulkan_INCLUDE_DIR}
|
||||||
|
)
|
||||||
|
target_link_libraries(
|
||||||
|
${TARGET}
|
||||||
|
PRIVATE
|
||||||
|
Mw
|
||||||
|
)
|
||||||
|
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
target_link_libraries(
|
||||||
|
${TARGET}
|
||||||
|
PRIVATE
|
||||||
|
m
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
@ -5,7 +5,6 @@
|
||||||
* ioixd maintains this file. nishi doesn't know vulkan at all
|
* ioixd maintains this file. nishi doesn't know vulkan at all
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Mw/Error.h"
|
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
#include <Mw/Widget/Vulkan.h>
|
#include <Mw/Widget/Vulkan.h>
|
||||||
|
|
||||||
|
|
@ -17,7 +16,7 @@
|
||||||
char buffer[512];
|
char buffer[512];
|
||||||
|
|
||||||
char* string_VkResult(VkResult res) {
|
char* string_VkResult(VkResult res) {
|
||||||
sprintf(buffer, "%d", res);
|
MwStringPrintIntoBuffer(buffer, 512, "%d", res);
|
||||||
|
|
||||||
return &buffer[0];
|
return &buffer[0];
|
||||||
}
|
}
|
||||||
|
|
@ -27,6 +26,8 @@ MwWidget window, vulkan;
|
||||||
int ow = 300;
|
int ow = 300;
|
||||||
int oh = 250;
|
int oh = 250;
|
||||||
|
|
||||||
|
double timer = 0;
|
||||||
|
|
||||||
PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr;
|
PFN_vkGetInstanceProcAddr _vkGetInstanceProcAddr;
|
||||||
VkInstance instance;
|
VkInstance instance;
|
||||||
VkDevice device;
|
VkDevice device;
|
||||||
|
|
@ -75,9 +76,10 @@ void tick(MwWidget handle, void* user_data, void* call_data) {
|
||||||
VkSubmitInfo submitInfo = {};
|
VkSubmitInfo submitInfo = {};
|
||||||
VkPresentInfoKHR presentInfo = {};
|
VkPresentInfoKHR presentInfo = {};
|
||||||
|
|
||||||
VkClearValue clearColor = {{{0.0f, 0.0f, 0.0f, 1.0f}}};
|
VkClearValue clearColor = {{{sin(timer) / 10., cos(timer) / 10., atan(timer) / 10., 1.0f}}};
|
||||||
uint32_t vertexCount = 3;
|
uint32_t vertexCount = 3;
|
||||||
uint32_t instanceCount = 1;
|
uint32_t instanceCount = 1;
|
||||||
|
timer += (float)(rand() % 1000) / 1000.;
|
||||||
|
|
||||||
VkPipelineStageFlags waitStages[] = {VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT};
|
VkPipelineStageFlags waitStages[] = {VK_PIPELINE_STAGE_2_VERTEX_SHADER_BIT};
|
||||||
|
|
||||||
|
|
@ -229,43 +231,16 @@ void vulkan_setup(MwWidget handle) {
|
||||||
VkSemaphoreCreateInfo semaphoreInfo = {};
|
VkSemaphoreCreateInfo semaphoreInfo = {};
|
||||||
VkFenceCreateInfo fenceInfo = {};
|
VkFenceCreateInfo fenceInfo = {};
|
||||||
|
|
||||||
MwErrorEnum err = MwEsuccess;
|
int err = 0;
|
||||||
_vkGetInstanceProcAddr = MwVulkanGetField(handle, MwVulkanField_GetInstanceProcAddr, &err);
|
_vkGetInstanceProcAddr = MwVulkanGetField(handle, MwVULKANFIELD_GETINSTANCEPROCADDR, &err);
|
||||||
if(err != MwEsuccess) {
|
instance = MwVulkanGetField(handle, MwVULKANFIELD_INSTANCE, &err);
|
||||||
printf("Error getting vkGetInstanceProcAddr!\n%s\n", MwGetLastError());
|
device = MwVulkanGetField(handle, MwVULKANFIELD_LOGICALDEVICE, &err);
|
||||||
}
|
physicalDevice = MwVulkanGetField(handle, MwVULKANFIELD_PHYSICALDEVICE, &err);
|
||||||
instance = MwVulkanGetField(handle, MwVulkanField_Instance, &err);
|
graphicsQueue = MwVulkanGetField(handle, MwVULKANFIELD_GRAPHICSQUEUE, &err);
|
||||||
if(err != MwEsuccess) {
|
presentQueue = MwVulkanGetField(handle, MwVULKANFIELD_PRESENTQUEUE, &err);
|
||||||
printf("Error getting vulkan instance!\n%s\n", MwGetLastError());
|
surface = MwVulkanGetField(handle, MwVULKANFIELD_SURFACE, &err);
|
||||||
}
|
presentQueueIndex = MwVulkanGetField(handle, MwVULKANFIELD_PRESENTQUEUEINDEX, &err);
|
||||||
device = MwVulkanGetField(handle, MwVulkanField_LogicalDevice, &err);
|
graphicsQueueIndex = MwVulkanGetField(handle, MwVULKANFIELD_GRAPHICSQUEUEINDEX, &err);
|
||||||
if(err != MwEsuccess) {
|
|
||||||
printf("Error getting VkDevice!\n%s\n", MwGetLastError());
|
|
||||||
}
|
|
||||||
physicalDevice = MwVulkanGetField(handle, MwVulkanField_PhysicalDevice, &err);
|
|
||||||
if(err != MwEsuccess) {
|
|
||||||
printf("Error getting physical device!\n%s\n", MwGetLastError());
|
|
||||||
}
|
|
||||||
graphicsQueue = MwVulkanGetField(handle, MwVulkanField_GraphicsQueue, &err);
|
|
||||||
if(err != MwEsuccess) {
|
|
||||||
printf("Error getting graphics queue!\n%s\n", MwGetLastError());
|
|
||||||
}
|
|
||||||
presentQueue = MwVulkanGetField(handle, MwVulkanField_PresentQueue, &err);
|
|
||||||
if(err != MwEsuccess) {
|
|
||||||
printf("Error getting present queue!\n%s\n", MwGetLastError());
|
|
||||||
}
|
|
||||||
surface = MwVulkanGetField(handle, MwVulkanField_Surface, &err);
|
|
||||||
if(err != MwEsuccess) {
|
|
||||||
printf("Error getting surface!\n%s\n", MwGetLastError());
|
|
||||||
}
|
|
||||||
presentQueueIndex = MwVulkanGetField(handle, MwVulkanField_PresentQueueIndex, &err);
|
|
||||||
if(err != MwEsuccess) {
|
|
||||||
printf("Error getting present queue index!\n%s\n", MwGetLastError());
|
|
||||||
}
|
|
||||||
graphicsQueueIndex = MwVulkanGetField(handle, MwVulkanField_GraphicsQueueIndex, &err);
|
|
||||||
if(err != MwEsuccess) {
|
|
||||||
printf("Error getting graphics queue index!\n%s\n", MwGetLastError());
|
|
||||||
}
|
|
||||||
|
|
||||||
LOAD_VK_FUNCTION(vkCreateShaderModule);
|
LOAD_VK_FUNCTION(vkCreateShaderModule);
|
||||||
LOAD_VK_FUNCTION(vkCreatePipelineLayout);
|
LOAD_VK_FUNCTION(vkCreatePipelineLayout);
|
||||||
|
|
|
||||||
|
|
@ -32,7 +32,7 @@ typedef int8_t MwI8;
|
||||||
typedef uint8_t MwU8;
|
typedef uint8_t MwU8;
|
||||||
|
|
||||||
#define MW_OTHER_TYPES_DEFINED
|
#define MW_OTHER_TYPES_DEFINED
|
||||||
#elif __GNUC__ > 2
|
#elif !defined(__STRICT_ANSI__) && (defined(__GNUC__) || defined(__clang__))
|
||||||
typedef long long MwI64;
|
typedef long long MwI64;
|
||||||
typedef unsigned long long MwU64;
|
typedef unsigned long long MwU64;
|
||||||
#elif defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
|
#elif defined(_MSC_VER) || defined(__BORLANDC__) || defined(__WATCOMC__)
|
||||||
|
|
@ -78,8 +78,8 @@ struct _MwPoint {
|
||||||
struct _MwRect {
|
struct _MwRect {
|
||||||
int x;
|
int x;
|
||||||
int y;
|
int y;
|
||||||
unsigned int width;
|
int width;
|
||||||
unsigned int height;
|
int height;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwSizeHints {
|
struct _MwSizeHints {
|
||||||
|
|
|
||||||
|
|
@ -99,4 +99,26 @@ enum MwMB_ICON {
|
||||||
*/
|
*/
|
||||||
#define MwMB_BUTTONYESNOCANCEL (MwMB_BUTTONYES | MwMB_BUTTONNO | MwMB_BUTTONCANCEL)
|
#define MwMB_BUTTONYESNOCANCEL (MwMB_BUTTONYES | MwMB_BUTTONNO | MwMB_BUTTONCANCEL)
|
||||||
|
|
||||||
|
/* Whether or not GetXY/SetXY works with global or local coordinates */
|
||||||
|
enum MwCOORDINATE {
|
||||||
|
MwCOORDINATE_GLOBAL = 0,
|
||||||
|
MwCOORDINATE_LOCAL,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* The clipboard type that MwGetClipboard should return */
|
||||||
|
enum MwCLIPBOARD {
|
||||||
|
/* the clipboard that is present on every platform that supports it */
|
||||||
|
MwCLIPBOARD_MAIN = 0,
|
||||||
|
/* the "primary" clipboard that Wayland stores to emulate X11's behavior. */
|
||||||
|
MwCLIPBOARD_PRIMARY,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum MwMOUSE {
|
||||||
|
MwMOUSE_LEFT = 1,
|
||||||
|
MwMOUSE_MIDDLE,
|
||||||
|
MwMOUSE_RIGHT,
|
||||||
|
MwMOUSE_WHEELUP,
|
||||||
|
MwMOUSE_WHEELDOWN
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -295,8 +295,9 @@ MWDECL void MwHideCursor(MwWidget handle);
|
||||||
* @brief Toggles the dark theme
|
* @brief Toggles the dark theme
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
* @param toggle Toggle
|
* @param toggle Toggle
|
||||||
|
* @deprecated Use MwNdarkTheme instead
|
||||||
*/
|
*/
|
||||||
MWDECL void MwToggleDarkTheme(MwWidget handle, int toggle);
|
MWDECL void MwSetDarkTheme(MwWidget handle, int toggle);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Gets the parent widget
|
* @brief Gets the parent widget
|
||||||
|
|
@ -354,6 +355,19 @@ MWDECL void MwGetCursorCoord(MwWidget handle, MwPoint* point);
|
||||||
*/
|
*/
|
||||||
MWDECL void MwGetScreenSize(MwWidget handle, MwRect* rect);
|
MWDECL void MwGetScreenSize(MwWidget handle, MwRect* rect);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Reports whether a widget reports global or local coordinates upon GetXY/SetXY. Anything with a parent reports local, and most backends report global coordinates being supported for top level windows, but some (Wayland) do not.
|
||||||
|
* @param handle Widget
|
||||||
|
*/
|
||||||
|
MWDECL int MwGetCoordinateType(MwWidget handle);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Queue to get clipboard content.
|
||||||
|
* @param handle Widget
|
||||||
|
* @param clipboard_type The Clipboard Type to get. See MwClipboardType. This is ignored on backends that aren't X11/Wayland, so if you're unsure, just use MwClipboardMain
|
||||||
|
*/
|
||||||
|
MWDECL void MwGetClipboard(MwWidget handle, int clipboard_type);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,11 @@ MWDECL const char* MwDefaultDarkSubBackground;
|
||||||
*/
|
*/
|
||||||
MWDECL const char* MwDefaultDarkSubForeground;
|
MWDECL const char* MwDefaultDarkSubForeground;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default shadow difference
|
||||||
|
*/
|
||||||
|
MWDECL const int MwDefaultShadow;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Gets default border width
|
* @brief Gets default border width
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
|
|
|
||||||
|
|
@ -93,6 +93,7 @@ MWDECL void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int i
|
||||||
* @param border Border width
|
* @param border Border width
|
||||||
* @param diff Difference (set this to 0 if you don't know what this does)
|
* @param diff Difference (set this to 0 if you don't know what this does)
|
||||||
* @param same Same as dark color
|
* @param same Same as dark color
|
||||||
|
* @param rounded Rounded or not
|
||||||
* @warning `rect` gets changed to the area of rectangle inside
|
* @warning `rect` gets changed to the area of rectangle inside
|
||||||
*/
|
*/
|
||||||
MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same);
|
MWDECL void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same);
|
||||||
|
|
@ -175,29 +176,31 @@ MWDECL void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int in
|
||||||
/*!
|
/*!
|
||||||
* @brief Draws a text
|
* @brief Draws a text
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
|
* @param ttf TTF, NULLable
|
||||||
* @param point Center point of the text
|
* @param point Center point of the text
|
||||||
* @param text Text
|
* @param text Text
|
||||||
* @param bold Bold
|
|
||||||
* @param align Align
|
* @param align Align
|
||||||
* @param color Color
|
* @param color Color
|
||||||
*/
|
*/
|
||||||
MWDECL void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
MWDECL void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Calculates a text width
|
* @brief Calculates a text width
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
* @param text Text
|
* @param text Text
|
||||||
|
* @param font Font, NULLable
|
||||||
* @return Text width
|
* @return Text width
|
||||||
*/
|
*/
|
||||||
MWDECL int MwTextWidth(MwWidget handle, const char* text);
|
MWDECL int MwTextWidth(MwWidget handle, MwFLFont font, const char* text);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Calculates a text height
|
* @brief Calculates a text height
|
||||||
* @param handle Widget
|
* @param handle Widget
|
||||||
* @param text Text
|
* @param text Text
|
||||||
|
* @param font Font, NULLable
|
||||||
* @return Text height
|
* @return Text height
|
||||||
*/
|
*/
|
||||||
MWDECL int MwTextHeight(MwWidget handle, const char* text);
|
MWDECL int MwTextHeight(MwWidget handle, MwFLFont font, const char* text);
|
||||||
|
|
||||||
/* color.c */
|
/* color.c */
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
/*!
|
|
||||||
* @file Mw/Error.h
|
|
||||||
* @brief Error codes
|
|
||||||
*/
|
|
||||||
#ifndef __MW_ERROR_H__
|
|
||||||
#define __MW_ERROR_H__
|
|
||||||
|
|
||||||
#include <Mw/MachDep.h>
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Error code enumeration
|
|
||||||
*/
|
|
||||||
typedef enum MwErrorEnum_T {
|
|
||||||
/*!
|
|
||||||
* @brief No error
|
|
||||||
*/
|
|
||||||
MwEsuccess = 0,
|
|
||||||
/*!
|
|
||||||
* @brief There was an error
|
|
||||||
*/
|
|
||||||
MwEerror,
|
|
||||||
} MwErrorEnum;
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* @brief Get the last error
|
|
||||||
*/
|
|
||||||
MWDECL const char* MwGetLastError(void);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
@ -6,10 +6,10 @@
|
||||||
#ifndef __MW_LOWLEVEL_H__
|
#ifndef __MW_LOWLEVEL_H__
|
||||||
#define __MW_LOWLEVEL_H__
|
#define __MW_LOWLEVEL_H__
|
||||||
|
|
||||||
|
#include <Mw/BaseTypes.h>
|
||||||
#include <Mw/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
|
|
||||||
typedef struct _MwLLHandler* MwLLHandler;
|
typedef struct _MwLLHandler* MwLLHandler;
|
||||||
typedef struct _MwLLMouse MwLLMouse;
|
|
||||||
typedef struct _MwLLCommon* MwLLCommon;
|
typedef struct _MwLLCommon* MwLLCommon;
|
||||||
typedef struct _MwLLCommonColor* MwLLCommonColor;
|
typedef struct _MwLLCommonColor* MwLLCommonColor;
|
||||||
typedef struct _MwLLCommonPixmap* MwLLCommonPixmap;
|
typedef struct _MwLLCommonPixmap* MwLLCommonPixmap;
|
||||||
|
|
@ -17,30 +17,35 @@ typedef struct _MwLLCommonPixmap* MwLLCommonPixmap;
|
||||||
typedef union _MwLL* MwLL;
|
typedef union _MwLL* MwLL;
|
||||||
typedef union _MwLLColor* MwLLColor;
|
typedef union _MwLLColor* MwLLColor;
|
||||||
typedef union _MwLLPixmap* MwLLPixmap;
|
typedef union _MwLLPixmap* MwLLPixmap;
|
||||||
|
typedef struct _MwFLFont* MwFLFont;
|
||||||
#else
|
#else
|
||||||
typedef void* MwLL;
|
typedef void* MwLL;
|
||||||
typedef void* MwLLColor;
|
typedef void* MwLLColor;
|
||||||
typedef void* MwLLPixmap;
|
typedef void* MwLLPixmap;
|
||||||
|
typedef void* MwFLFont;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
enum MwLLBackends {
|
enum MwLLBackends {
|
||||||
MwLLBackendX11 = 0,
|
MwLLBackendX11 = 0,
|
||||||
MwLLBackendGDI,
|
MwLLBackendGDI,
|
||||||
MwLLBackendWayland,
|
MwLLBackendWayland,
|
||||||
|
MwLLBackendCocoa,
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLCommon {
|
struct _MwLLCommon {
|
||||||
void* user;
|
void* user;
|
||||||
int copy_buffer;
|
int copy_buffer;
|
||||||
int type;
|
int type;
|
||||||
|
int coordinate_type;
|
||||||
|
MwBool supports_transparency;
|
||||||
|
|
||||||
MwLLHandler handler;
|
MwLLHandler handler;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLCommonColor {
|
struct _MwLLCommonColor {
|
||||||
int red;
|
MwU8 red;
|
||||||
int green;
|
MwU8 green;
|
||||||
int blue;
|
MwU8 blue;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLCommonPixmap {
|
struct _MwLLCommonPixmap {
|
||||||
|
|
@ -50,6 +55,52 @@ struct _MwLLCommonPixmap {
|
||||||
void* user;
|
void* user;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
typedef struct _MwLLDBusFuncTable {
|
||||||
|
void* lib;
|
||||||
|
|
||||||
|
void (*dbus_error_init)(DBusError* error);
|
||||||
|
DBusConnection* (*dbus_bus_get)(DBusBusType type, DBusError* error);
|
||||||
|
dbus_bool_t (*dbus_error_is_set)(const DBusError* error);
|
||||||
|
void (*dbus_error_free)(DBusError* error);
|
||||||
|
DBusMessage* (*dbus_message_new_method_call)(const char* bus_name, const char* path, const char* iface, const char* method);
|
||||||
|
void (*dbus_message_iter_init_append)(DBusMessage* message, DBusMessageIter* iter);
|
||||||
|
dbus_bool_t (*dbus_message_iter_append_basic)(DBusMessageIter* iter, int type, const void* value);
|
||||||
|
void (*dbus_connection_flush)(DBusConnection* connection);
|
||||||
|
dbus_bool_t (*dbus_connection_read_write)(DBusConnection* connection, int timeout_milliseconds);
|
||||||
|
DBusMessage* (*dbus_connection_send_with_reply_and_block)(DBusConnection* connection, DBusMessage* message, int timeout_milliseconds, DBusError* error);
|
||||||
|
DBusMessage* (*dbus_connection_pop_message)(DBusConnection* connection);
|
||||||
|
void (*dbus_bus_add_match)(DBusConnection* connection, const char* rule, DBusError* error);
|
||||||
|
void (*dbus_message_unref)(DBusMessage* message);
|
||||||
|
dbus_bool_t (*dbus_message_iter_init)(DBusMessage* message, DBusMessageIter* iter);
|
||||||
|
dbus_bool_t (*dbus_message_is_signal)(DBusMessage* message, const char* iface, const char* signal_name);
|
||||||
|
int (*dbus_message_iter_get_arg_type)(DBusMessageIter* iter);
|
||||||
|
void (*dbus_message_iter_recurse)(DBusMessageIter* iter, DBusMessageIter* sub);
|
||||||
|
void (*dbus_message_iter_next)(DBusMessageIter* iter);
|
||||||
|
void (*dbus_connection_unref)(DBusConnection* connection);
|
||||||
|
void (*dbus_message_iter_get_basic)(DBusMessageIter* iter, void* value);
|
||||||
|
} MwLLDBusFuncTable;
|
||||||
|
|
||||||
|
typedef struct _MwLLDBusContext {
|
||||||
|
DBusConnection* dbus_conn;
|
||||||
|
DBusError dbus_err;
|
||||||
|
DBusMessage* dbus_msg;
|
||||||
|
DBusMessage* dbus_reply;
|
||||||
|
} MwLLDBusContext;
|
||||||
|
|
||||||
|
typedef void (*MwLLDBusPortalPollListener)(MwLL handle, MwU32 new_value);
|
||||||
|
|
||||||
|
/* setup the dbus func table. Returns false and prints a warning if dbus couldn't be found. */
|
||||||
|
MWDECL MwBool MwLLDBusFuncSetup(MwLLDBusFuncTable* tbl);
|
||||||
|
|
||||||
|
MWDECL MwBool MwLLDBusNewContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx);
|
||||||
|
MWDECL MwBool MwLLDBusPortalGet(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal, const char* namespace, const char* key, void* out);
|
||||||
|
MWDECL MwBool MwLLDBusPortalWatch(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal);
|
||||||
|
MWDECL MwBool MwLLDBusPortalPoll(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, MwLL handle, const char* portal, const char* namespace, const char* key, MwLLDBusPortalPollListener);
|
||||||
|
MWDECL void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
#ifdef USE_X11
|
#ifdef USE_X11
|
||||||
#include <Mw/LowLevel/X11.h>
|
#include <Mw/LowLevel/X11.h>
|
||||||
|
|
@ -60,6 +111,12 @@ struct _MwLLCommonPixmap {
|
||||||
#ifdef USE_WAYLAND
|
#ifdef USE_WAYLAND
|
||||||
#include <Mw/LowLevel/Wayland.h>
|
#include <Mw/LowLevel/Wayland.h>
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_COCOA
|
||||||
|
#include <Mw/LowLevel/Cocoa.h>
|
||||||
|
#endif
|
||||||
|
#ifdef CLASSIC_MAC_OS
|
||||||
|
#include <Mw/LowLevel/ClassicMacOS.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
union _MwLL {
|
union _MwLL {
|
||||||
struct _MwLLCommon common;
|
struct _MwLLCommon common;
|
||||||
|
|
@ -72,6 +129,12 @@ union _MwLL {
|
||||||
#ifdef USE_WAYLAND
|
#ifdef USE_WAYLAND
|
||||||
struct _MwLLWayland wayland;
|
struct _MwLLWayland wayland;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_COCOA
|
||||||
|
struct _MwLLCocoa cocoa;
|
||||||
|
#endif
|
||||||
|
#ifdef CLASSIC_MAC_OS
|
||||||
|
struct _MwLLClassicMacOS cmacos;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
union _MwLLColor {
|
union _MwLLColor {
|
||||||
|
|
@ -85,6 +148,9 @@ union _MwLLColor {
|
||||||
#ifdef USE_WAYLAND
|
#ifdef USE_WAYLAND
|
||||||
struct _MwLLWaylandColor wayland;
|
struct _MwLLWaylandColor wayland;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_COCOA
|
||||||
|
struct _MwLLCocoaColor cocoa;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
union _MwLLPixmap {
|
union _MwLLPixmap {
|
||||||
|
|
@ -98,6 +164,12 @@ union _MwLLPixmap {
|
||||||
#ifdef USE_WAYLAND
|
#ifdef USE_WAYLAND
|
||||||
struct _MwLLWaylandPixmap wayland;
|
struct _MwLLWaylandPixmap wayland;
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_COCOA
|
||||||
|
struct _MwLLCocoaPixmap cocoa;
|
||||||
|
#endif
|
||||||
|
#ifdef CLASSIC_MAC_OS
|
||||||
|
struct _MwLLClassicMacOSPixmap cmacos;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
#include <Mw/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
|
|
@ -123,19 +195,6 @@ enum MwLLKeyEnum {
|
||||||
#define MwLLControlMask MwLLKeyMask | (1 << 30)
|
#define MwLLControlMask MwLLKeyMask | (1 << 30)
|
||||||
#define MwLLAltMask MwLLKeyMask | (1 << 29)
|
#define MwLLAltMask MwLLKeyMask | (1 << 29)
|
||||||
|
|
||||||
enum MwLLMouseEnum {
|
|
||||||
MwLLMouseLeft = 1,
|
|
||||||
MwLLMouseMiddle,
|
|
||||||
MwLLMouseRight,
|
|
||||||
MwLLMouseWheelUp,
|
|
||||||
MwLLMouseWheelDown
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _MwLLMouse {
|
|
||||||
MwPoint point;
|
|
||||||
int button;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct _MwLLHandler {
|
struct _MwLLHandler {
|
||||||
void (*draw)(MwLL handle, void* data);
|
void (*draw)(MwLL handle, void* data);
|
||||||
void (*up)(MwLL handle, void* data);
|
void (*up)(MwLL handle, void* data);
|
||||||
|
|
@ -147,8 +206,22 @@ struct _MwLLHandler {
|
||||||
void (*key_released)(MwLL handle, void* data);
|
void (*key_released)(MwLL handle, void* data);
|
||||||
void (*focus_in)(MwLL handle, void* data);
|
void (*focus_in)(MwLL handle, void* data);
|
||||||
void (*focus_out)(MwLL handle, void* data);
|
void (*focus_out)(MwLL handle, void* data);
|
||||||
|
void (*clipboard)(MwLL handle, void* data);
|
||||||
|
void (*dark_theme)(MwLL handle, void* data);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _MwLLTextDispatchTable {
|
||||||
|
int (*drawText)(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color);
|
||||||
|
int (*textWidth)(MwWidget handle, const char* text);
|
||||||
|
int (*textHeight)(MwWidget handle, int count);
|
||||||
|
void* (*fontLoad)(unsigned char* data, unsigned int size);
|
||||||
|
void (*fontFree)(void* handle);
|
||||||
|
};
|
||||||
|
|
||||||
|
#define MwFLFlagMonospace (1 << 0)
|
||||||
|
#define MwFLFlagBold (1 << 1)
|
||||||
|
#define MwFLBuildFont(x) ((MwFLFont)(void*)(size_t)(x))
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
@ -202,12 +275,30 @@ MWDECL void (*MwLLEndStateChange)(MwLL handle);
|
||||||
MWDECL void (*MwLLFocus)(MwLL handle);
|
MWDECL void (*MwLLFocus)(MwLL handle);
|
||||||
MWDECL void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
MWDECL void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
||||||
|
|
||||||
MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text);
|
MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text, int clipboard_type);
|
||||||
MWDECL char* (*MwLLGetClipboard)(MwLL handle);
|
MWDECL void (*MwLLGetClipboard)(MwLL handle, int clipboard_type);
|
||||||
|
|
||||||
MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
MWDECL void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
||||||
MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
MWDECL void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
||||||
|
|
||||||
|
MWDECL void (*MwLLSetDarkTheme)(MwLL handle, int toggle);
|
||||||
|
|
||||||
|
/* font renderer */
|
||||||
|
MWDECL void MwFLSetup(void);
|
||||||
|
|
||||||
|
#ifdef USE_FREETYPE2
|
||||||
|
MWDECL int MWFL_FT2Setup(void);
|
||||||
|
#endif
|
||||||
|
#ifdef USE_STB_TRUETYPE
|
||||||
|
MWDECL int MwFL_STBTTSetup(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MWDECL int (*MwFLDrawText)(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color);
|
||||||
|
MWDECL int (*MwFLTextWidth)(MwFLFont ttf, const char* text);
|
||||||
|
MWDECL int (*MwFLTextHeight)(MwFLFont ttf, int count);
|
||||||
|
MWDECL void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px);
|
||||||
|
MWDECL void (*MwFLFontFree)(void* handle);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
35
include/Mw/LowLevel/ClassicMacOS.h
Normal file
35
include/Mw/LowLevel/ClassicMacOS.h
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
/*!
|
||||||
|
* @file Mw/LowLevel/ClassicMacOS.h
|
||||||
|
* @brief ClassicMacOS Backend
|
||||||
|
* @warning This is used internally
|
||||||
|
*/
|
||||||
|
#ifndef __MW_LOWLEVEL_ClassicMacOS_H__
|
||||||
|
#define __MW_LOWLEVEL_ClassicMacOS_H__
|
||||||
|
|
||||||
|
#include <Mw/MachDep.h>
|
||||||
|
#include <Mw/TypeDefs.h>
|
||||||
|
#include <Mw/LowLevel.h>
|
||||||
|
|
||||||
|
struct _MwLLClassicMacOS {
|
||||||
|
struct _MwLLCommon common;
|
||||||
|
|
||||||
|
MwLL parent;
|
||||||
|
|
||||||
|
WindowRef window;
|
||||||
|
ControlHandle control;
|
||||||
|
EventRecord event;
|
||||||
|
Rect winRect;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MwLLClassicMacOSColor {
|
||||||
|
struct _MwLLCommonColor common;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MwLLClassicMacOSPixmap {
|
||||||
|
struct _MwLLCommonPixmap common;
|
||||||
|
BitMap bmp;
|
||||||
|
};
|
||||||
|
|
||||||
|
MWDECL int MwLLClassicMacOSCallInit(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
180
include/Mw/LowLevel/Cocoa.h
Normal file
180
include/Mw/LowLevel/Cocoa.h
Normal file
|
|
@ -0,0 +1,180 @@
|
||||||
|
/*!
|
||||||
|
* @file Mw/LowLevel/Cocoa.h
|
||||||
|
* @brief Work in progress Cocoa Backend
|
||||||
|
* @warning This is used internally.
|
||||||
|
*/
|
||||||
|
#ifndef __MW_LOWLEVEL_COCOA_H__
|
||||||
|
#define __MW_LOWLEVEL_COCOA_H__
|
||||||
|
|
||||||
|
#include <Mw/LowLevel.h>
|
||||||
|
#include <Mw/MachDep.h>
|
||||||
|
#include <Mw/TypeDefs.h>
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
enum {
|
||||||
|
COCOA_DRAW_COMMAND_POLY = 0,
|
||||||
|
COCOA_DRAW_COMMAND_LINES,
|
||||||
|
COCOA_DRAW_COMMAND_PIXMAP,
|
||||||
|
} type;
|
||||||
|
union {
|
||||||
|
struct {
|
||||||
|
MwPoint* points;
|
||||||
|
int points_count;
|
||||||
|
struct _MwLLCommonColor color;
|
||||||
|
} poly;
|
||||||
|
struct {
|
||||||
|
MwPoint* points;
|
||||||
|
struct _MwLLCommonColor color;
|
||||||
|
} lines;
|
||||||
|
struct {
|
||||||
|
MwRect rect;
|
||||||
|
MwLLPixmap pixmap;
|
||||||
|
} pixmap;
|
||||||
|
};
|
||||||
|
} draw_command;
|
||||||
|
|
||||||
|
#ifdef __OBJC__
|
||||||
|
#import <AppKit/AppKit.h>
|
||||||
|
#import <Foundation/Foundation.h>
|
||||||
|
#import <Foundation/NSGeometry.h>
|
||||||
|
|
||||||
|
@interface MilskoCocoaApplication : NSApplication {
|
||||||
|
MwBool doPending;
|
||||||
|
}
|
||||||
|
- (MwBool)pending;
|
||||||
|
@end
|
||||||
|
|
||||||
|
// Note: implements NSApplicationDelegate
|
||||||
|
@interface MilskoCocoaApplicationDelegate : NSObject {
|
||||||
|
MilskoCocoaApplication* appl;
|
||||||
|
}
|
||||||
|
- (MilskoCocoaApplicationDelegate*)initWithAppl:(MilskoCocoaApplication*)appl;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface MilskoCocoaWindow : NSWindow {
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
// Note: implements NSWindowDelegate
|
||||||
|
@interface MilskoCocoaWindowDelegate : NSObject {
|
||||||
|
NSWindow* w;
|
||||||
|
}
|
||||||
|
- (MilskoCocoaWindowDelegate*)initWithWin:(NSWindow*)win;
|
||||||
|
@end
|
||||||
|
|
||||||
|
/*
|
||||||
|
So we want to associate each NSWindow with its corresponding MwLL handle. The
|
||||||
|
conventional way of doing this is through "associative pointers", however
|
||||||
|
this is a feature that Apple added in 10.6 (marketted back then as "Objective
|
||||||
|
C 2" iirc). For 10.4 compatibility, we have to do a bit of an ugly hack that
|
||||||
|
might seem like horrifically undefined behavior, but I've tested this on
|
||||||
|
both 10.4 and modern Mac OS and as long as we're careful there's no
|
||||||
|
problems: we override NSView, use NSView's "frame" property to store the
|
||||||
|
pointer, and then override functions appropriately so that this frame is never
|
||||||
|
actually used. This can then be attached to an NSWindow with addSubview and
|
||||||
|
retrieved appropriately.
|
||||||
|
*/
|
||||||
|
@interface MilskoFakePointer : NSView {
|
||||||
|
void* ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)setPointer:(void*)ptr;
|
||||||
|
- (void*)pointer;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface MilskoCocoaPixmap : NSObject {
|
||||||
|
@public
|
||||||
|
MwBool valid;
|
||||||
|
int width;
|
||||||
|
int height;
|
||||||
|
unsigned char* buf;
|
||||||
|
NSImage* image;
|
||||||
|
NSBitmapImageRep* rep;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (MilskoCocoaPixmap*)newWithWidth:(int)width height:(int)height;
|
||||||
|
- (void)updateWithData:(unsigned char*)data;
|
||||||
|
- (void)destroy;
|
||||||
|
|
||||||
|
/* using @property to create instance variables fucks up 10.4 gcc for some
|
||||||
|
* reason? */
|
||||||
|
- (NSImage*)image;
|
||||||
|
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface MilskoCocoaView : NSView {
|
||||||
|
MwBool _child;
|
||||||
|
|
||||||
|
@public
|
||||||
|
draw_command* commands;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void)destroy;
|
||||||
|
- (void)setChild;
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface MilskoCocoaSubView : MilskoCocoaView {
|
||||||
|
}
|
||||||
|
@end
|
||||||
|
|
||||||
|
@interface MilskoCocoa : NSObject {
|
||||||
|
@public
|
||||||
|
MilskoCocoaApplication* application;
|
||||||
|
MwBool _forceRender;
|
||||||
|
MwBool _eventsPending;
|
||||||
|
NSWindow* window;
|
||||||
|
NSRect rect;
|
||||||
|
MilskoCocoaView* view;
|
||||||
|
MwLL parent;
|
||||||
|
MilskoFakePointer* handle;
|
||||||
|
unsigned int strHash;
|
||||||
|
NSEvent* lastEvent;
|
||||||
|
|
||||||
|
MilskoCocoaPixmap* cursorPixmap;
|
||||||
|
NSCursor* cursor;
|
||||||
|
NSModalSession modalSession;
|
||||||
|
|
||||||
|
MwBool pointerLocked;
|
||||||
|
MwBool mouseMoved;
|
||||||
|
|
||||||
|
MwBool rejectFirstTest;
|
||||||
|
}
|
||||||
|
- (void)destroy;
|
||||||
|
- (void)sendClipboardEvent;
|
||||||
|
|
||||||
|
- (MwLL)getParent;
|
||||||
|
- (NSView*)getView;
|
||||||
|
- (NSWindow*)getWindow;
|
||||||
|
- (void)nudge;
|
||||||
|
|
||||||
|
- (void)pushCursor;
|
||||||
|
- (void)popCursor;
|
||||||
|
|
||||||
|
- (MilskoFakePointer*)getHandle;
|
||||||
|
|
||||||
|
@end
|
||||||
|
#define OBJC(x) x
|
||||||
|
#else
|
||||||
|
#define OBJC(x) void*
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MWDECL int MwLLCocoaCallInit(void);
|
||||||
|
|
||||||
|
struct _MwLLCocoa {
|
||||||
|
struct _MwLLCommon common;
|
||||||
|
OBJC(MilskoCocoa*)
|
||||||
|
real;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MwLLCocoaColor {
|
||||||
|
struct _MwLLCommonColor common;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MwLLCocoaPixmap {
|
||||||
|
struct _MwLLCommonPixmap common;
|
||||||
|
OBJC(MilskoCocoaPixmap*)
|
||||||
|
real;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
@ -21,6 +21,8 @@ struct _MwLLGDI {
|
||||||
|
|
||||||
int grabbed;
|
int grabbed;
|
||||||
int force_render;
|
int force_render;
|
||||||
|
int get_clipboard;
|
||||||
|
int get_darktheme;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLGDIColor {
|
struct _MwLLGDIColor {
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,7 @@
|
||||||
/*!
|
/*!
|
||||||
* @file Mw/LowLevel/Wayland.h
|
* @file Mw/LowLevel/Wayland.h
|
||||||
* @brief Work in progress Wayland Backend
|
* @brief Wayland Backend
|
||||||
* @warning This is used internally.
|
* @warning This is used internally.
|
||||||
* @warning This is disabled by default.
|
|
||||||
*/
|
*/
|
||||||
#ifndef __MW_LOWLEVEL_WAYLAND_H__
|
#ifndef __MW_LOWLEVEL_WAYLAND_H__
|
||||||
#define __MW_LOWLEVEL_WAYLAND_H__
|
#define __MW_LOWLEVEL_WAYLAND_H__
|
||||||
|
|
@ -10,30 +9,317 @@
|
||||||
#include <Mw/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
#include <Mw/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
#include <Mw/LowLevel.h>
|
#include <Mw/LowLevel.h>
|
||||||
|
#include <Mw/Abstract/Dynamic.h>
|
||||||
|
|
||||||
#include <wayland-client-protocol.h>
|
|
||||||
|
|
||||||
#include <wayland-client.h>
|
|
||||||
#include <xkbcommon/xkbcommon.h>
|
#include <xkbcommon/xkbcommon.h>
|
||||||
#include <cairo/cairo.h>
|
#include <cairo/cairo.h>
|
||||||
|
#include <pthread.h>
|
||||||
|
#include <dbus/dbus.h>
|
||||||
|
|
||||||
MWDECL int MwLLWaylandCallInit(void);
|
MWDECL int MwLLWaylandCallInit(void);
|
||||||
|
|
||||||
#ifndef WL_PROTOCOLS_DEFINED
|
#define CSD_BORDER_FRAME_LEFT 5
|
||||||
#define WL_PROTOCOLS_DEFINED
|
#define CSD_BORDER_FRAME_RIGHT 5
|
||||||
#include "Wayland/xdg-shell-client-protocol.h"
|
#define CSD_BORDER_FRAME_TOP 24
|
||||||
#include "Wayland/xdg-decoration-client-protocol.h"
|
#define CSD_BORDER_FRAME_BOTTOM 5
|
||||||
#include "Wayland/cursor-shape-client-protocol.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct _MwLLWayland;
|
struct _MwLLWayland;
|
||||||
|
|
||||||
|
#include <wayland-client-core.h>
|
||||||
|
|
||||||
|
#if WAYLAND_LOAD_OPENGL
|
||||||
|
#include <EGL/egl.h>
|
||||||
|
#include <wayland-egl-core.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct wayland_call_table {
|
||||||
|
void* lib;
|
||||||
|
void* xkb_lib;
|
||||||
|
void* cairo_lib;
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
MwLLDBusFuncTable dbus;
|
||||||
|
MwBool has_dbus;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int (*wl_display_dispatch)(struct wl_display* display);
|
||||||
|
int (*wl_display_dispatch_pending)(struct wl_display* display);
|
||||||
|
void (*wl_display_disconnect)(struct wl_display* display);
|
||||||
|
void (*wl_display_cancel_read)(struct wl_display* display);
|
||||||
|
int (*wl_display_prepare_read)(struct wl_display* display);
|
||||||
|
int (*wl_display_read_events)(struct wl_display* display);
|
||||||
|
int (*wl_display_flush)(struct wl_display* display);
|
||||||
|
int (*wl_display_get_fd)(struct wl_display* display);
|
||||||
|
int (*wl_display_roundtrip)(struct wl_display* display);
|
||||||
|
int (*wl_proxy_add_listener)(struct wl_proxy* proxy, void (**implementation)(void), void* data);
|
||||||
|
void (*wl_proxy_destroy)(struct wl_proxy* proxy);
|
||||||
|
void (*wl_log_set_handler_client)(wl_log_func_t handler);
|
||||||
|
struct wl_proxy* (*wl_proxy_marshal_flags)(struct wl_proxy* proxy, uint32_t opcode,
|
||||||
|
const struct wl_interface* interface,
|
||||||
|
uint32_t version,
|
||||||
|
uint32_t flags, ...);
|
||||||
|
struct wl_display* (*wl_display_connect)(const char* name);
|
||||||
|
uint32_t (*wl_proxy_get_version)(struct wl_proxy* proxy);
|
||||||
|
struct wl_display* (*wl_display_connect_to_fd)(int fd);
|
||||||
|
|
||||||
|
struct xkb_context* (*xkb_context_new)(enum xkb_context_flags flags);
|
||||||
|
void (*xkb_context_unref)(struct xkb_context* context);
|
||||||
|
struct xkb_state* (*xkb_state_new)(struct xkb_keymap* keymap);
|
||||||
|
void (*xkb_state_unref)(struct xkb_state* state);
|
||||||
|
struct xkb_keymap* (*xkb_keymap_new_from_string)(struct xkb_context* context, const char* string, enum xkb_keymap_format format, enum xkb_keymap_compile_flags flags);
|
||||||
|
xkb_level_index_t (*xkb_keymap_num_levels_for_key)(struct xkb_keymap* keymap, xkb_keycode_t key, xkb_layout_index_t layout);
|
||||||
|
int (*xkb_keymap_key_get_syms_by_level)(struct xkb_keymap* keymap, xkb_keycode_t key, xkb_layout_index_t layout, xkb_level_index_t level, const xkb_keysym_t** syms_out);
|
||||||
|
xkb_layout_index_t (*xkb_state_key_get_layout)(struct xkb_state* state, xkb_keycode_t key);
|
||||||
|
void (*xkb_keymap_unref)(struct xkb_keymap* keymap);
|
||||||
|
|
||||||
|
void (*cairo_set_line_width)(cairo_t* cr,
|
||||||
|
double width);
|
||||||
|
void (*cairo_scale)(cairo_t* cr,
|
||||||
|
double sx,
|
||||||
|
double sy);
|
||||||
|
cairo_t* (*cairo_create)(cairo_surface_t* target);
|
||||||
|
void (*cairo_move_to)(cairo_t* cr,
|
||||||
|
double x,
|
||||||
|
double y);
|
||||||
|
|
||||||
|
void (*cairo_rectangle)(cairo_t* cr,
|
||||||
|
double x,
|
||||||
|
double y,
|
||||||
|
double width,
|
||||||
|
double height);
|
||||||
|
void (*cairo_new_path)(cairo_t* cr);
|
||||||
|
void (*cairo_set_line_cap)(cairo_t* cr,
|
||||||
|
cairo_line_cap_t line_cap);
|
||||||
|
void (*cairo_set_source_rgba)(cairo_t* cr,
|
||||||
|
double red,
|
||||||
|
double green,
|
||||||
|
double blue,
|
||||||
|
double alpha);
|
||||||
|
void (*cairo_set_source_rgb)(cairo_t* cr,
|
||||||
|
double red,
|
||||||
|
double green,
|
||||||
|
double blue);
|
||||||
|
void (*cairo_reset_clip)(cairo_t* cr);
|
||||||
|
unsigned char* (*cairo_image_surface_get_data)(cairo_surface_t* surface);
|
||||||
|
void (*cairo_line_to)(cairo_t* cr,
|
||||||
|
double x,
|
||||||
|
double y);
|
||||||
|
void (*cairo_surface_destroy)(cairo_surface_t* surface);
|
||||||
|
cairo_surface_t* (*cairo_image_surface_create_for_data)(unsigned char* data,
|
||||||
|
cairo_format_t format,
|
||||||
|
int width,
|
||||||
|
int height,
|
||||||
|
int stride);
|
||||||
|
cairo_surface_t* (*cairo_image_surface_create)(cairo_format_t format,
|
||||||
|
int width,
|
||||||
|
int height);
|
||||||
|
void (*cairo_destroy)(cairo_t* cr);
|
||||||
|
cairo_pattern_t* (*cairo_get_source)(cairo_t* cr);
|
||||||
|
void (*cairo_close_path)(cairo_t* cr);
|
||||||
|
void (*cairo_paint)(cairo_t* cr);
|
||||||
|
void (*cairo_surface_flush)(cairo_surface_t* surface);
|
||||||
|
void (*cairo_clip)(cairo_t* cr);
|
||||||
|
void (*cairo_surface_mark_dirty)(cairo_surface_t* surface);
|
||||||
|
void (*cairo_stroke)(cairo_t* cr);
|
||||||
|
void (*cairo_set_source_surface)(cairo_t* cr,
|
||||||
|
cairo_surface_t* surface,
|
||||||
|
double x,
|
||||||
|
double y);
|
||||||
|
void (*cairo_fill)(cairo_t* cr);
|
||||||
|
void (*cairo_pattern_set_filter)(cairo_pattern_t* pattern,
|
||||||
|
cairo_filter_t filter);
|
||||||
|
void (*cairo_set_antialias)(cairo_t*, cairo_antialias_t);
|
||||||
|
void (*cairo_set_operator)(cairo_t* cr, cairo_operator_t op);
|
||||||
|
|
||||||
|
} wayland_call_table_t;
|
||||||
|
|
||||||
|
extern wayland_call_table_t wl_call_tbl;
|
||||||
|
extern MwBool MwWaylandAlwaysRender;
|
||||||
|
/* defined inline right here so that it doesn't conflict with the other macros */
|
||||||
|
MwInline int wayland_load_funcs() {
|
||||||
|
wl_call_tbl.lib = MwDynamicOpen("libwayland-client.so");
|
||||||
|
if(!wl_call_tbl.lib) {
|
||||||
|
printf("(libwayland-client.so not found, falling back to X11)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
wl_call_tbl.xkb_lib = MwDynamicOpen("libxkbcommon.so");
|
||||||
|
if(!wl_call_tbl.xkb_lib) {
|
||||||
|
printf("(libxkbcommon.so not found, cannot use Wayland backend.)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
wl_call_tbl.cairo_lib = MwDynamicOpen("libcairo.so");
|
||||||
|
if(!wl_call_tbl.cairo_lib) {
|
||||||
|
printf("(libcairo.so not found, cannot use Wayland backend.)\n");
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
#define WAYLAND_FUNC(x) \
|
||||||
|
wl_call_tbl.x = MwDynamicSymbol(wl_call_tbl.lib, #x); \
|
||||||
|
if(!wl_call_tbl.x) { \
|
||||||
|
printf("WARNING: Could use Wayland backend if " #x " was found.\n"); \
|
||||||
|
return 1; \
|
||||||
|
};
|
||||||
|
|
||||||
|
WAYLAND_FUNC(wl_display_dispatch)
|
||||||
|
WAYLAND_FUNC(wl_display_dispatch_pending)
|
||||||
|
WAYLAND_FUNC(wl_display_disconnect)
|
||||||
|
WAYLAND_FUNC(wl_display_cancel_read)
|
||||||
|
WAYLAND_FUNC(wl_display_prepare_read)
|
||||||
|
WAYLAND_FUNC(wl_display_read_events)
|
||||||
|
WAYLAND_FUNC(wl_display_flush)
|
||||||
|
WAYLAND_FUNC(wl_display_get_fd)
|
||||||
|
WAYLAND_FUNC(wl_display_roundtrip)
|
||||||
|
WAYLAND_FUNC(wl_proxy_add_listener)
|
||||||
|
WAYLAND_FUNC(wl_proxy_destroy)
|
||||||
|
WAYLAND_FUNC(wl_log_set_handler_client)
|
||||||
|
WAYLAND_FUNC(wl_proxy_marshal_flags)
|
||||||
|
WAYLAND_FUNC(wl_display_connect)
|
||||||
|
WAYLAND_FUNC(wl_proxy_get_version)
|
||||||
|
WAYLAND_FUNC(wl_display_connect_to_fd)
|
||||||
|
|
||||||
|
#undef WAYLAND_FUNC
|
||||||
|
|
||||||
|
#define XKB_FUNC(x) \
|
||||||
|
wl_call_tbl.x = MwDynamicSymbol(wl_call_tbl.xkb_lib, #x); \
|
||||||
|
if(!wl_call_tbl.x) { \
|
||||||
|
printf("WARNING: Could use Wayland backend if " #x " was found. Do you have libxkbcommon?\n"); \
|
||||||
|
return 1; \
|
||||||
|
};
|
||||||
|
|
||||||
|
XKB_FUNC(xkb_state_unref)
|
||||||
|
XKB_FUNC(xkb_context_new)
|
||||||
|
XKB_FUNC(xkb_context_unref)
|
||||||
|
XKB_FUNC(xkb_state_new)
|
||||||
|
XKB_FUNC(xkb_keymap_new_from_string)
|
||||||
|
XKB_FUNC(xkb_keymap_unref)
|
||||||
|
XKB_FUNC(xkb_keymap_num_levels_for_key)
|
||||||
|
XKB_FUNC(xkb_keymap_key_get_syms_by_level)
|
||||||
|
XKB_FUNC(xkb_state_key_get_layout)
|
||||||
|
#undef XKB_FUNC
|
||||||
|
|
||||||
|
#define CAIRO_FUNC(x) \
|
||||||
|
wl_call_tbl.x = MwDynamicSymbol(wl_call_tbl.cairo_lib, #x); \
|
||||||
|
if(!wl_call_tbl.x) { \
|
||||||
|
printf("WARNING: Could use Wayland backend if " #x " was found. Do you have libcairo?\n"); \
|
||||||
|
return 1; \
|
||||||
|
};
|
||||||
|
|
||||||
|
CAIRO_FUNC(cairo_set_line_width);
|
||||||
|
CAIRO_FUNC(cairo_scale);
|
||||||
|
CAIRO_FUNC(cairo_create);
|
||||||
|
CAIRO_FUNC(cairo_move_to);
|
||||||
|
CAIRO_FUNC(cairo_rectangle);
|
||||||
|
CAIRO_FUNC(cairo_new_path);
|
||||||
|
CAIRO_FUNC(cairo_set_line_cap);
|
||||||
|
CAIRO_FUNC(cairo_set_antialias);
|
||||||
|
CAIRO_FUNC(cairo_set_source_rgba);
|
||||||
|
CAIRO_FUNC(cairo_set_source_rgb);
|
||||||
|
CAIRO_FUNC(cairo_reset_clip);
|
||||||
|
CAIRO_FUNC(cairo_image_surface_get_data);
|
||||||
|
CAIRO_FUNC(cairo_line_to);
|
||||||
|
CAIRO_FUNC(cairo_surface_destroy);
|
||||||
|
CAIRO_FUNC(cairo_image_surface_create_for_data);
|
||||||
|
CAIRO_FUNC(cairo_image_surface_create);
|
||||||
|
CAIRO_FUNC(cairo_destroy);
|
||||||
|
CAIRO_FUNC(cairo_get_source);
|
||||||
|
CAIRO_FUNC(cairo_close_path);
|
||||||
|
CAIRO_FUNC(cairo_paint);
|
||||||
|
CAIRO_FUNC(cairo_surface_flush);
|
||||||
|
CAIRO_FUNC(cairo_clip);
|
||||||
|
CAIRO_FUNC(cairo_surface_mark_dirty);
|
||||||
|
CAIRO_FUNC(cairo_stroke);
|
||||||
|
CAIRO_FUNC(cairo_set_source_surface);
|
||||||
|
CAIRO_FUNC(cairo_fill);
|
||||||
|
CAIRO_FUNC(cairo_set_operator);
|
||||||
|
CAIRO_FUNC(cairo_pattern_set_filter);
|
||||||
|
#undef CAIRO_FUNC
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
wl_call_tbl.has_dbus = MwLLDBusFuncSetup(&wl_call_tbl.dbus);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define wl_display_dispatch wl_call_tbl.wl_display_dispatch
|
||||||
|
#define wl_display_dispatch_pending wl_call_tbl.wl_display_dispatch_pending
|
||||||
|
#define wl_display_disconnect wl_call_tbl.wl_display_disconnect
|
||||||
|
#define wl_display_cancel_read wl_call_tbl.wl_display_cancel_read
|
||||||
|
#define wl_display_prepare_read wl_call_tbl.wl_display_prepare_read
|
||||||
|
#define wl_display_read_events wl_call_tbl.wl_display_read_events
|
||||||
|
#define wl_display_flush wl_call_tbl.wl_display_flush
|
||||||
|
#define wl_display_get_fd wl_call_tbl.wl_display_get_fd
|
||||||
|
#define wl_display_roundtrip wl_call_tbl.wl_display_roundtrip
|
||||||
|
#define wl_proxy_add_listener wl_call_tbl.wl_proxy_add_listener
|
||||||
|
#define wl_proxy_destroy wl_call_tbl.wl_proxy_destroy
|
||||||
|
#define wl_log_set_handler_client wl_call_tbl.wl_log_set_handler_client
|
||||||
|
#define wl_proxy_marshal_flags wl_call_tbl.wl_proxy_marshal_flags
|
||||||
|
#define wl_display_connect wl_call_tbl.wl_display_connect
|
||||||
|
#define wl_proxy_get_version wl_call_tbl.wl_proxy_get_version
|
||||||
|
#define wl_display_connect_to_fd wl_call_tbl.wl_display_connect_to_fd
|
||||||
|
|
||||||
|
#define xkb_state_unref wl_call_tbl.xkb_state_unref
|
||||||
|
#define xkb_context_new wl_call_tbl.xkb_context_new
|
||||||
|
#define xkb_context_unref wl_call_tbl.xkb_context_unref
|
||||||
|
#define xkb_state_new wl_call_tbl.xkb_state_new
|
||||||
|
#define xkb_keymap_new_from_string wl_call_tbl.xkb_keymap_new_from_string
|
||||||
|
#define xkb_keymap_unref wl_call_tbl.xkb_keymap_unref
|
||||||
|
#define xkb_keymap_num_levels_for_key wl_call_tbl.xkb_keymap_num_levels_for_key
|
||||||
|
#define xkb_keymap_key_get_syms_by_level wl_call_tbl.xkb_keymap_key_get_syms_by_level
|
||||||
|
#define xkb_state_key_get_layout wl_call_tbl.xkb_state_key_get_layout
|
||||||
|
|
||||||
|
#define cairo_set_line_width wl_call_tbl.cairo_set_line_width
|
||||||
|
#define cairo_scale wl_call_tbl.cairo_scale
|
||||||
|
#define cairo_create wl_call_tbl.cairo_create
|
||||||
|
#define cairo_move_to wl_call_tbl.cairo_move_to
|
||||||
|
#define cairo_rectangle wl_call_tbl.cairo_rectangle
|
||||||
|
#define cairo_new_path wl_call_tbl.cairo_new_path
|
||||||
|
#define cairo_set_line_cap wl_call_tbl.cairo_set_line_cap
|
||||||
|
#define cairo_set_antialias wl_call_tbl.cairo_set_antialias
|
||||||
|
#define cairo_set_source_rgba wl_call_tbl.cairo_set_source_rgba
|
||||||
|
#define cairo_set_source_rgb wl_call_tbl.cairo_set_source_rgb
|
||||||
|
#define cairo_reset_clip wl_call_tbl.cairo_reset_clip
|
||||||
|
#define cairo_image_surface_get_data wl_call_tbl.cairo_image_surface_get_data
|
||||||
|
#define cairo_line_to wl_call_tbl.cairo_line_to
|
||||||
|
#define cairo_surface_destroy wl_call_tbl.cairo_surface_destroy
|
||||||
|
#define cairo_image_surface_create_for_data wl_call_tbl.cairo_image_surface_create_for_data
|
||||||
|
#define cairo_image_surface_create wl_call_tbl.cairo_image_surface_create
|
||||||
|
#define cairo_destroy wl_call_tbl.cairo_destroy
|
||||||
|
#define cairo_get_source wl_call_tbl.cairo_get_source
|
||||||
|
#define cairo_close_path wl_call_tbl.cairo_close_path
|
||||||
|
#define cairo_paint wl_call_tbl.cairo_paint
|
||||||
|
#define cairo_surface_flush wl_call_tbl.cairo_surface_flush
|
||||||
|
#define cairo_clip wl_call_tbl.cairo_clip
|
||||||
|
#define cairo_surface_mark_dirty wl_call_tbl.cairo_surface_mark_dirty
|
||||||
|
#define cairo_stroke wl_call_tbl.cairo_stroke
|
||||||
|
#define cairo_set_source_surface wl_call_tbl.cairo_set_source_surface
|
||||||
|
#define cairo_fill wl_call_tbl.cairo_fill
|
||||||
|
#define cairo_set_operator wl_call_tbl.cairo_set_operator
|
||||||
|
#define cairo_pattern_set_filter wl_call_tbl.cairo_pattern_set_filter
|
||||||
|
|
||||||
|
#ifndef WL_PROTOCOLS_DEFINED
|
||||||
|
#define WL_PROTOCOLS_DEFINED
|
||||||
|
#include "Wayland/wayland-core-protocol.h"
|
||||||
|
#include "Wayland/xdg-shell-client-protocol.h"
|
||||||
|
#include "Wayland/viewporter-client-protocol.h"
|
||||||
|
#include "Wayland/xdg-decoration-client-protocol.h"
|
||||||
|
#include "Wayland/cursor-shape-client-protocol.h"
|
||||||
|
#include "Wayland/primary-selection-client-protocol.h"
|
||||||
|
#include "Wayland/pointer-constraints-client-protocol.h"
|
||||||
|
#include "Wayland/relative-pointer-client-protocol.h"
|
||||||
|
#include "Wayland/xdg-toplevel-icon-client-protocol.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct wayland_protocol {
|
typedef struct wayland_protocol {
|
||||||
void* listener;
|
void* listener;
|
||||||
void* context;
|
void* context;
|
||||||
} wayland_protocol_t;
|
} wayland_protocol_t;
|
||||||
|
|
||||||
typedef wayland_protocol_t*(wl_setup_func)(MwU32, struct _MwLLWayland*);
|
typedef wayland_protocol_t*(wl_setup_func)(MwU32, struct _MwLLWayland*);
|
||||||
|
typedef void(wl_destroy_func)(struct _MwLLWayland* wayland, wayland_protocol_t* data);
|
||||||
|
|
||||||
|
typedef struct wayland_protocol_callback_table {
|
||||||
|
wl_setup_func* setup;
|
||||||
|
wl_destroy_func* destroy;
|
||||||
|
} wayland_protocol_callback_table_t;
|
||||||
|
|
||||||
struct _MwLLWaylandTopLevel {
|
struct _MwLLWaylandTopLevel {
|
||||||
struct xdg_surface* xdg_surface;
|
struct xdg_surface* xdg_surface;
|
||||||
|
|
@ -41,13 +327,12 @@ struct _MwLLWaylandTopLevel {
|
||||||
struct xdg_toplevel_listener xdg_toplevel_listener;
|
struct xdg_toplevel_listener xdg_toplevel_listener;
|
||||||
struct xdg_surface_listener xdg_surface_listener;
|
struct xdg_surface_listener xdg_surface_listener;
|
||||||
|
|
||||||
struct xkb_context* xkb_context;
|
|
||||||
struct xkb_keymap* xkb_keymap;
|
|
||||||
struct xkb_state* xkb_state;
|
|
||||||
|
|
||||||
MwBool compositor_created;
|
MwBool compositor_created;
|
||||||
MwBool xdg_wm_base_created;
|
MwBool xdg_wm_base_created;
|
||||||
MwBool xdg_surface_created;
|
MwBool xdg_surface_created;
|
||||||
|
|
||||||
|
struct wl_subsurface* ssurface;
|
||||||
|
struct wl_subcompositor* scompositor;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLWaylandSublevel {
|
struct _MwLLWaylandSublevel {
|
||||||
|
|
@ -55,9 +340,59 @@ struct _MwLLWaylandSublevel {
|
||||||
struct wl_subcompositor* subcompositor;
|
struct wl_subcompositor* subcompositor;
|
||||||
|
|
||||||
MwLL parent;
|
MwLL parent;
|
||||||
MwLL topmost_parent; /* The parent at the top of all the other parents. Usually a toplevel. */
|
|
||||||
|
struct xdg_surface* xdg_surface;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _MwLLWaylandPopup {
|
||||||
|
struct xdg_surface* xdg_surface;
|
||||||
|
struct xdg_popup* xdg_popup;
|
||||||
|
struct xdg_positioner* xdg_positioner;
|
||||||
|
struct xdg_surface_listener xdg_surface_listener;
|
||||||
|
struct xdg_wm_base* xdg_wm_base;
|
||||||
|
MwLL topmost_parent;
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Shared set of anything needed for a shm buffer. */
|
||||||
|
struct _MwLLWaylandShmBuffer {
|
||||||
|
struct wl_shm* shm;
|
||||||
|
struct wl_shm_pool* shm_pool;
|
||||||
|
struct wl_buffer* shm_buffer;
|
||||||
|
struct wl_shm_pool* shm_pool_back;
|
||||||
|
struct wl_buffer* shm_buffer_back;
|
||||||
|
struct wl_surface* surface;
|
||||||
|
struct wl_output* output;
|
||||||
|
|
||||||
|
MwU8* buf;
|
||||||
|
MwU8* buf_back;
|
||||||
|
MwU64 buf_size;
|
||||||
|
int fd;
|
||||||
|
int fd_back;
|
||||||
|
MwBool setup;
|
||||||
|
};
|
||||||
|
|
||||||
|
enum _MwLLWaylandType {
|
||||||
|
MWLL_WAYLAND_UNKNOWN = 0,
|
||||||
|
MWLL_WAYLAND_TOPLEVEL,
|
||||||
|
MWLL_WAYLAND_SUBLEVEL,
|
||||||
|
MWLL_WAYLAND_POPUP,
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct wl_clipboard_device_context {
|
||||||
|
struct {
|
||||||
|
struct wl_data_device* wl;
|
||||||
|
struct zwp_primary_selection_device_v1* zwp;
|
||||||
|
} device;
|
||||||
|
struct {
|
||||||
|
struct wl_data_offer* wl;
|
||||||
|
struct zwp_primary_selection_offer_v1* zwp;
|
||||||
|
} offer;
|
||||||
|
|
||||||
|
MwLL ll;
|
||||||
|
struct wl_seat* seat;
|
||||||
|
MwU32 capabilities;
|
||||||
|
} wl_clipboard_device_context_t;
|
||||||
|
|
||||||
struct _MwLLWayland {
|
struct _MwLLWayland {
|
||||||
struct _MwLLCommon common;
|
struct _MwLLCommon common;
|
||||||
|
|
||||||
|
|
@ -66,47 +401,129 @@ struct _MwLLWayland {
|
||||||
struct _MwLLWaylandTopLevel* toplevel;
|
struct _MwLLWaylandTopLevel* toplevel;
|
||||||
/* Pointer for data that's only loaded if the widget is a sublevel */
|
/* Pointer for data that's only loaded if the widget is a sublevel */
|
||||||
struct _MwLLWaylandSublevel* sublevel;
|
struct _MwLLWaylandSublevel* sublevel;
|
||||||
|
/* Pointer for data that's only loaded if the widget is a popup */
|
||||||
|
struct _MwLLWaylandPopup* popup;
|
||||||
};
|
};
|
||||||
|
|
||||||
enum {
|
enum _MwLLWaylandType type;
|
||||||
MWLL_WAYLAND_TOPLEVEL = 0,
|
enum _MwLLWaylandType type_to_be;
|
||||||
MWLL_WAYLAND_SUBLEVEL, /* Sublevels are surfaces that have the toplevel as a parent. Some parts of the code also call them subwidgets. */
|
|
||||||
} type;
|
MwBool detatching;
|
||||||
|
MwPoint detach_point;
|
||||||
|
|
||||||
|
MwBool did_initial_resize;
|
||||||
|
|
||||||
/* Map of Wayland interfaces to their relevant setup functions. */
|
/* Map of Wayland interfaces to their relevant setup functions. */
|
||||||
struct {
|
struct {
|
||||||
const char* key;
|
char key[255];
|
||||||
wl_setup_func* value;
|
wayland_protocol_callback_table_t* value;
|
||||||
}* wl_protocol_setup_map;
|
}* wl_protocol_setup_map;
|
||||||
|
|
||||||
/* Map of Wayland interfaces to any information we keep about them once we've registered them. */
|
/* Map of Wayland interfaces to any information we keep about them once we've registered them. */
|
||||||
struct {
|
struct {
|
||||||
const char* key;
|
char key[255];
|
||||||
wayland_protocol_t* value;
|
wayland_protocol_t* value;
|
||||||
}* wl_protocol_map;
|
}* wl_protocol_map;
|
||||||
|
|
||||||
|
MwBool has_decorations;
|
||||||
|
char title[255];
|
||||||
|
|
||||||
|
struct xkb_context* xkb_context;
|
||||||
|
struct xkb_keymap* xkb_keymap;
|
||||||
|
struct xkb_state* xkb_state;
|
||||||
|
|
||||||
struct wl_display* display;
|
struct wl_display* display;
|
||||||
struct wl_registry* registry;
|
struct wl_registry* registry;
|
||||||
struct wl_compositor* compositor;
|
struct wl_compositor* compositor;
|
||||||
struct wl_surface* surface;
|
|
||||||
struct wl_registry_listener registry_listener;
|
struct wl_registry_listener registry_listener;
|
||||||
/*struct wl_event_queue* event_queue;*/
|
struct wl_region* o_region;
|
||||||
|
struct wl_region* region;
|
||||||
|
struct wl_output* output;
|
||||||
|
|
||||||
|
struct wp_viewport* vp;
|
||||||
|
|
||||||
|
MwBool do_lock_pointer;
|
||||||
|
struct zwp_pointer_constraints_v1* pointer_constraints;
|
||||||
|
struct zwp_relative_pointer_manager_v1* relative_pointer_manager;
|
||||||
|
struct zwp_relative_pointer_v1* relative_pointer;
|
||||||
|
struct zwp_locked_pointer_v1* locked_pointer;
|
||||||
|
MwBool pointer_constrained;
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
MwLLDBusContext dbus;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MwBool dark_theme_detection;
|
||||||
|
MwU32 dark_theme;
|
||||||
|
|
||||||
|
/* clipboard related stuff.
|
||||||
|
* Note that unlike most interfaces, we don't keep zwp_primary_selection stuff in a wayland_protocol_t because we use wl_data_device as a fallback and want to have it share memory space.*/
|
||||||
|
|
||||||
|
struct {
|
||||||
|
struct wl_data_device_manager* wl;
|
||||||
|
struct zwp_primary_selection_device_manager_v1* zwp;
|
||||||
|
} clipboard_manager;
|
||||||
|
union {
|
||||||
|
struct wl_data_source* wl;
|
||||||
|
struct zwp_primary_selection_source_v1* zwp;
|
||||||
|
} clipboard_source;
|
||||||
|
char* clipboard_buffer;
|
||||||
|
MwBool supports_zwp;
|
||||||
|
|
||||||
|
uint32_t clipboard_serial;
|
||||||
|
wl_clipboard_device_context_t** clipboard_devices_wl;
|
||||||
|
wl_clipboard_device_context_t** clipboard_devices_zwp;
|
||||||
|
|
||||||
|
struct wl_pointer* pointer;
|
||||||
|
MwU32 pointer_serial;
|
||||||
|
struct wl_seat* pointer_seat;
|
||||||
|
|
||||||
|
struct wl_keyboard* keyboard;
|
||||||
|
MwU32 keyboard_serial;
|
||||||
|
|
||||||
|
MwU64 events_pending;
|
||||||
|
|
||||||
|
MwU32 mod_state;
|
||||||
|
|
||||||
MwLL* sublevels; /* stb_ds managed array of any sublevels */
|
|
||||||
MwBool configured; /* Whether or not xdg_toplevel_configure has run once */
|
MwBool configured; /* Whether or not xdg_toplevel_configure has run once */
|
||||||
|
|
||||||
MwU32 x, y, ww, wh; /* Window position */
|
MwBool held_down;
|
||||||
|
|
||||||
|
MwI32 x, y;
|
||||||
|
MwI32 ox, oy;
|
||||||
|
MwU32 ww, wh; /* Window position */
|
||||||
MwPoint cur_mouse_pos; /* Currently known mouse position */
|
MwPoint cur_mouse_pos; /* Currently known mouse position */
|
||||||
|
|
||||||
struct wl_shm* shm;
|
MwU32 mw, mh; /* Monitor width and height as advertised by wl_output.mode */
|
||||||
struct wl_shm_pool* shm_pool;
|
|
||||||
struct wl_buffer* shm_buffer;
|
|
||||||
void* mapped_shm_buf;
|
|
||||||
MwU64 mapped_shm_buf_size;
|
|
||||||
int shm_fd;
|
|
||||||
|
|
||||||
cairo_surface_t* cs;
|
MwLL parent;
|
||||||
cairo_t* cairo;
|
|
||||||
|
MwBool force_render;
|
||||||
|
MwBool did_event_loop_early;
|
||||||
|
|
||||||
|
MwBool dispatching_resize;
|
||||||
|
|
||||||
|
struct _MwLLWaylandShmBuffer framebuffer;
|
||||||
|
struct _MwLLWaylandShmBuffer backbuffer;
|
||||||
|
struct _MwLLWaylandShmBuffer cursor;
|
||||||
|
struct _MwLLWaylandShmBuffer* icon;
|
||||||
|
|
||||||
|
/*
|
||||||
|
Events mutex. Any time a keyboard/mouse event happens, we try to lock this for 100 milliseconds, then give up if we can't do it. This is used in conjunction with some code in the MwLLDestroyImpl to make sure that destroy is NEVER interferes with an ongoing event.
|
||||||
|
|
||||||
|
IOI_XD: This sounds like a hilariously rare edge case, so it's almost funnier that this happened with 100% certainty for me and I spent day(s) trying to figure out what was happening. */
|
||||||
|
pthread_mutex_t eventsMutex;
|
||||||
|
|
||||||
|
uint32_t last_time;
|
||||||
|
|
||||||
|
MwBool moving;
|
||||||
|
|
||||||
|
cairo_surface_t* front_cs;
|
||||||
|
cairo_surface_t* back_cs;
|
||||||
|
cairo_t* front_cairo;
|
||||||
|
cairo_t* back_cairo;
|
||||||
|
/* The cairo to actually use for draw operations. Typically is front_cairo, but MwLLBeginDraw can change this to the back_cairo so it can be used to draw window decorations. */
|
||||||
|
cairo_t* selected_cairo;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLWaylandColor {
|
struct _MwLLWaylandColor {
|
||||||
|
|
|
||||||
|
|
@ -29,9 +29,18 @@ struct _MwLLX11 {
|
||||||
GC gc;
|
GC gc;
|
||||||
Colormap colormap;
|
Colormap colormap;
|
||||||
Atom wm_delete;
|
Atom wm_delete;
|
||||||
|
Atom wm_protocols;
|
||||||
|
Atom utf8_string;
|
||||||
|
Atom compound_text;
|
||||||
|
Atom text;
|
||||||
|
Atom clipboard;
|
||||||
|
Atom selection;
|
||||||
XIM xim;
|
XIM xim;
|
||||||
XIC xic;
|
XIC xic;
|
||||||
|
|
||||||
|
long clipboard_time;
|
||||||
|
int clipboard_pending; /* 1 if UTF8_STRING, 2 if COMPOUNd_TEXT, 3 if TEXT, 4 if STRING, otherwise 0 */
|
||||||
|
|
||||||
int top;
|
int top;
|
||||||
int toplevel;
|
int toplevel;
|
||||||
int grabbed;
|
int grabbed;
|
||||||
|
|
@ -48,6 +57,12 @@ struct _MwLLX11 {
|
||||||
unsigned long blue_mask;
|
unsigned long blue_mask;
|
||||||
unsigned long blue_max;
|
unsigned long blue_max;
|
||||||
unsigned long blue_shift;
|
unsigned long blue_shift;
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
MwLLDBusContext dbus;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
MwBool dark_theme_detection;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwLLX11Color {
|
struct _MwLLX11Color {
|
||||||
|
|
|
||||||
|
|
@ -37,27 +37,63 @@
|
||||||
#define GET_WHEEL_DELTA_WPARAM(x) ((short)HIWORD(x))
|
#define GET_WHEEL_DELTA_WPARAM(x) ((short)HIWORD(x))
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
#elif defined(CLASSIC_MAC_OS)
|
||||||
|
#include <unistd.h>
|
||||||
|
#include <MacTypes.h>
|
||||||
|
#include <CFBundle.h>
|
||||||
|
#include <CodeFragments.h>
|
||||||
|
#include <Timer.h>
|
||||||
|
#include <MacWindows.h>
|
||||||
|
#include <TextEdit.h>
|
||||||
|
#include <Dialogs.h>
|
||||||
#else
|
#else
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <pwd.h>
|
#include <pwd.h>
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <dirent.h>
|
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
|
#include <limits.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __unix__
|
||||||
|
#include <dirent.h>
|
||||||
|
#include <dlfcn.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
#include <mach/clock.h>
|
||||||
|
#include <mach/mach.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
#include <dbus/dbus.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef M_PI
|
#ifndef M_PI
|
||||||
#define M_PI 3.14159265
|
#define M_PI 3.14159265
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* Windows */
|
||||||
#if defined(_MILSKO) && defined(_WIN32)
|
#if defined(_MILSKO) && defined(_WIN32)
|
||||||
#define MWDECL extern __declspec(dllexport)
|
#define MWDECL extern __declspec(dllexport)
|
||||||
#elif defined(_WIN32)
|
#elif defined(_WIN32)
|
||||||
#define MWDECL extern __declspec(dllimport)
|
#define MWDECL extern __declspec(dllimport)
|
||||||
|
/* GCC/Clang */
|
||||||
|
/* First check if we have __has_attribute and can check for the existence of visibility */
|
||||||
|
#elif defined(__has_attribute)
|
||||||
|
#if __has_attribute(visibility)
|
||||||
|
#define MWDECL extern __attribute__((visibility("default")))
|
||||||
#else
|
#else
|
||||||
#define MWDECL extern
|
#define MWDECL extern
|
||||||
#endif
|
#endif
|
||||||
|
/* It might be that we're on an old version of GCC (like the one Apple ships with older versions of Mac OS).
|
||||||
|
* If we're on gcc 3 or above, assume it's there
|
||||||
|
*/
|
||||||
|
#elif __GNUC__ >= 3
|
||||||
|
#define MWDECL extern __attribute__((visibility("default")))
|
||||||
|
#else
|
||||||
|
/* all else fails */
|
||||||
|
#define MWDECL extern
|
||||||
|
#endif
|
||||||
|
|
||||||
#define MwInline static __inline
|
#define MwInline static __inline
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@
|
||||||
#include <Mw/Core.h>
|
#include <Mw/Core.h>
|
||||||
#include <Mw/Default.h>
|
#include <Mw/Default.h>
|
||||||
#include <Mw/Font.h>
|
#include <Mw/Font.h>
|
||||||
#include <Mw/Error.h>
|
|
||||||
#include <Mw/Constants.h>
|
#include <Mw/Constants.h>
|
||||||
#include <Mw/Unicode.h>
|
#include <Mw/Unicode.h>
|
||||||
#include <Mw/String.h>
|
#include <Mw/String.h>
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,26 @@ MWDECL unsigned char MwBoldTTFData[];
|
||||||
*/
|
*/
|
||||||
MWDECL unsigned int MwBoldTTFDataSize;
|
MWDECL unsigned int MwBoldTTFDataSize;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default monospace TTF font data
|
||||||
|
*/
|
||||||
|
MWDECL unsigned char MwMonospaceTTFData[];
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default monospace TTF font size
|
||||||
|
*/
|
||||||
|
MWDECL unsigned int MwMonospaceTTFDataSize;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default bold monospace TTF font data
|
||||||
|
*/
|
||||||
|
MWDECL unsigned char MwBoldMonospaceTTFData[];
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Default bold monospace TTF font size
|
||||||
|
*/
|
||||||
|
MWDECL unsigned int MwBoldMonospaceTTFDataSize;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,21 @@ MWDECL void MwStringSize(char* out, MwOffset size);
|
||||||
*/
|
*/
|
||||||
MWDECL void MwStringTime(char* out, time_t t);
|
MWDECL void MwStringTime(char* out, time_t t);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Prints up to n characters into a bufferMwStringPrintIntoBuffer.
|
||||||
|
* @note On compilers that support C99, this uses vsnprintf to safely print into a buffer; on compilers that don't, vsprintf is used.
|
||||||
|
* @param out Buffer
|
||||||
|
* @param size Max size
|
||||||
|
*/
|
||||||
|
MWDECL void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...);
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Check if the given key is UTF8
|
||||||
|
* @param key Input
|
||||||
|
* @return whether its utf8
|
||||||
|
*/
|
||||||
|
MWDECL MwBool MwStringIsKeyUTF8(MwU32 key);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -35,6 +35,14 @@
|
||||||
#define MwNratio "Iratio"
|
#define MwNratio "Iratio"
|
||||||
#define MwNfixedSize "IfixedSize"
|
#define MwNfixedSize "IfixedSize"
|
||||||
#define MwNmargin "Imargin"
|
#define MwNmargin "Imargin"
|
||||||
|
#define MwNbitmapFont "IbitmapFont"
|
||||||
|
#define MwNsevenSegment "IsevenSegment"
|
||||||
|
#define MwNlength "Ilength"
|
||||||
|
#define MwNforceInverted "IforceInverted"
|
||||||
|
#define MwNroundness "Iroundness"
|
||||||
|
#define MwNisRounded "IisRounded"
|
||||||
|
#define MwNdarkTheme "IdarkTheme"
|
||||||
|
#define MwNuseMonospace "IuseMonospace"
|
||||||
|
|
||||||
#define MwNtitle "Stitle"
|
#define MwNtitle "Stitle"
|
||||||
#define MwNtext "Stext"
|
#define MwNtext "Stext"
|
||||||
|
|
@ -49,15 +57,20 @@
|
||||||
#define MwNfont "Vfont"
|
#define MwNfont "Vfont"
|
||||||
#define MwNboldFont "VboldFont"
|
#define MwNboldFont "VboldFont"
|
||||||
#define MwNbackgroundPixmap "VbackgroundPixmap"
|
#define MwNbackgroundPixmap "VbackgroundPixmap"
|
||||||
|
#define MwNmonospaceFont "VmonospaceFont"
|
||||||
|
#define MwNboldMonospaceFont "VboldMonospaceFont"
|
||||||
|
|
||||||
#define MwNactivateHandler "Cactivate" /* NULL/int* (MwListBox)/void* (MwTreeView) */
|
#define MwNactivateHandler "Cactivate" /* NULL */
|
||||||
|
#define MwNlistBoxActivateHandler "ClistBoxActivate" /* int* */
|
||||||
|
#define MwNtreeViewActivateHandler "CtreeViewActivate" /* void* */
|
||||||
#define MwNresizeHandler "Cresize" /* NULL */
|
#define MwNresizeHandler "Cresize" /* NULL */
|
||||||
#define MwNtickHandler "Ctick" /* NULL */
|
#define MwNtickHandler "Ctick" /* NULL */
|
||||||
#define MwNmenuHandler "Cmenu" /* MwMenu */
|
#define MwNmenuHandler "Cmenu" /* MwMenu */
|
||||||
#define MwNmouseDownHandler "CmouseDown" /* MwLLMouse* */
|
#define MwNmouseDownHandler "CmouseDown" /* MwMouse* */
|
||||||
#define MwNmouseUpHandler "CmouseUp" /* same as MwNmouseDownHandler */
|
#define MwNmouseUpHandler "CmouseUp" /* same as MwNmouseDownHandler */
|
||||||
#define MwNmouseMoveHandler "CmouseMove" /* MwPoint* */
|
#define MwNmouseMoveHandler "CmouseMove" /* MwPoint* */
|
||||||
#define MwNchangedHandler "Cchanged" /* NULL/int* (MwComboBox) */
|
#define MwNchangedHandler "Cchanged" /* NULL */
|
||||||
|
#define MwNcomboBoxChangedHandler "CcomboBoxChanged" /* int* */
|
||||||
#define MwNkeyHandler "Ckey" /* int* (MwLLKeyEnum or character code) */
|
#define MwNkeyHandler "Ckey" /* int* (MwLLKeyEnum or character code) */
|
||||||
#define MwNkeyReleaseHandler "CkeyRelease" /* same as MwNkeyHandler */
|
#define MwNkeyReleaseHandler "CkeyRelease" /* same as MwNkeyHandler */
|
||||||
#define MwNcloseHandler "Cclose" /* NULL */
|
#define MwNcloseHandler "Cclose" /* NULL */
|
||||||
|
|
@ -67,5 +80,7 @@
|
||||||
#define MwNdirectoryChosenHandler "CdirectoryChosen" /* char* */
|
#define MwNdirectoryChosenHandler "CdirectoryChosen" /* char* */
|
||||||
#define MwNcolorChosenHandler "CcolorChosen" /* MwRGB* */
|
#define MwNcolorChosenHandler "CcolorChosen" /* MwRGB* */
|
||||||
#define MwNdrawHandler "Cdraw" /* NULL */
|
#define MwNdrawHandler "Cdraw" /* NULL */
|
||||||
|
#define MwNclipboardHandler "Cclipboard" /* char* */
|
||||||
|
#define MwNdarkThemeHandler "CdarkTheme" /* int* */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -20,10 +20,15 @@ typedef struct _MwViewport* MwViewport;
|
||||||
typedef struct _MwListBox* MwListBox;
|
typedef struct _MwListBox* MwListBox;
|
||||||
typedef struct _MwComboBox* MwComboBox;
|
typedef struct _MwComboBox* MwComboBox;
|
||||||
typedef struct _MwTreeView* MwTreeView;
|
typedef struct _MwTreeView* MwTreeView;
|
||||||
|
typedef struct _MwScrollBar* MwScrollBar;
|
||||||
|
typedef struct _MwLabel* MwLabel;
|
||||||
|
typedef struct _MwLabelSegment MwLabelSegment;
|
||||||
typedef struct _MwListBoxEntry MwListBoxEntry;
|
typedef struct _MwListBoxEntry MwListBoxEntry;
|
||||||
typedef struct _MwTreeViewEntry MwTreeViewEntry;
|
typedef struct _MwTreeViewEntry MwTreeViewEntry;
|
||||||
typedef struct _MwDirectoryEntry MwDirectoryEntry;
|
typedef struct _MwDirectoryEntry MwDirectoryEntry;
|
||||||
typedef struct _MwListBoxPacket MwListBoxPacket;
|
typedef struct _MwListBoxPacket MwListBoxPacket;
|
||||||
|
typedef struct _MwBox* MwBox;
|
||||||
|
typedef struct _MwMouse MwMouse;
|
||||||
#ifdef _MILSKO
|
#ifdef _MILSKO
|
||||||
typedef struct _MwWidget* MwWidget;
|
typedef struct _MwWidget* MwWidget;
|
||||||
#else
|
#else
|
||||||
|
|
@ -36,6 +41,7 @@ typedef void (*MwHandlerChildrenProp)(MwWidget handle, MwWidget child, const cha
|
||||||
typedef void (*MwHandlerKey)(MwWidget handle, int key);
|
typedef void (*MwHandlerKey)(MwWidget handle, int key);
|
||||||
typedef void (*MwHandlerMouse)(MwWidget handle, void* ptr);
|
typedef void (*MwHandlerMouse)(MwWidget handle, void* ptr);
|
||||||
typedef void (*MwHandlerExecute)(MwWidget handle, const char* name, void* out, va_list args);
|
typedef void (*MwHandlerExecute)(MwWidget handle, const char* name, void* out, va_list args);
|
||||||
|
typedef void (*MwHandlerClipboardReceived)(MwWidget handle, const char* data);
|
||||||
|
|
||||||
typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data);
|
||||||
typedef void (*MwErrorHandler)(int code, const char* message, void* user_data);
|
typedef void (*MwErrorHandler)(int code, const char* message, void* user_data);
|
||||||
|
|
@ -71,7 +77,6 @@ struct _MwVoidKeyValue {
|
||||||
struct _MwWidget {
|
struct _MwWidget {
|
||||||
char* name;
|
char* name;
|
||||||
MwLLColor bgcolor;
|
MwLLColor bgcolor;
|
||||||
int dark_theme;
|
|
||||||
|
|
||||||
MwLL lowlevel;
|
MwLL lowlevel;
|
||||||
MwWidget parent;
|
MwWidget parent;
|
||||||
|
|
@ -97,6 +102,16 @@ struct _MwWidget {
|
||||||
MwWidget* tick_list;
|
MwWidget* tick_list;
|
||||||
|
|
||||||
int destroyed;
|
int destroyed;
|
||||||
|
|
||||||
|
void* root_font;
|
||||||
|
void* root_boldfont;
|
||||||
|
void* root_monofont;
|
||||||
|
void* root_boldmonofont;
|
||||||
|
|
||||||
|
int top_step;
|
||||||
|
MwWidget* draw_queue;
|
||||||
|
|
||||||
|
int berserk;
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
@ -105,6 +120,7 @@ struct _MwMenu {
|
||||||
int keep;
|
int keep;
|
||||||
MwWidget wsub;
|
MwWidget wsub;
|
||||||
MwMenu* sub;
|
MwMenu* sub;
|
||||||
|
void* opaque;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _MwEntry {
|
struct _MwEntry {
|
||||||
|
|
@ -164,6 +180,21 @@ struct _MwTreeView {
|
||||||
MwPoint pressed;
|
MwPoint pressed;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _MwScrollBar {
|
||||||
|
MwPoint point;
|
||||||
|
int drag;
|
||||||
|
int pos;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MwLabel {
|
||||||
|
MwLabelSegment* segment;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MwLabelSegment {
|
||||||
|
int key;
|
||||||
|
unsigned char value;
|
||||||
|
};
|
||||||
|
|
||||||
struct _MwDirectoryEntry {
|
struct _MwDirectoryEntry {
|
||||||
char* name;
|
char* name;
|
||||||
int type;
|
int type;
|
||||||
|
|
@ -176,6 +207,15 @@ struct _MwListBoxPacket {
|
||||||
char*** names;
|
char*** names;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct _MwBox {
|
||||||
|
int layout;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct _MwMouse {
|
||||||
|
MwPoint point;
|
||||||
|
int button;
|
||||||
|
};
|
||||||
|
|
||||||
struct _MwClass {
|
struct _MwClass {
|
||||||
MwHandlerWithStatus create;
|
MwHandlerWithStatus create;
|
||||||
MwHandler destroy;
|
MwHandler destroy;
|
||||||
|
|
@ -192,11 +232,11 @@ struct _MwClass {
|
||||||
MwHandler resize;
|
MwHandler resize;
|
||||||
MwHandler children_update;
|
MwHandler children_update;
|
||||||
MwHandlerChildrenProp children_prop_change;
|
MwHandlerChildrenProp children_prop_change;
|
||||||
|
MwHandlerClipboardReceived clipboard;
|
||||||
void* reserved1;
|
void* reserved1;
|
||||||
void* reserved2;
|
void* reserved2;
|
||||||
void* reserved3;
|
void* reserved3;
|
||||||
void* reserved4;
|
void* reserved4;
|
||||||
void* reserved5;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,17 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
MWDECL MwClass MwLabelClass;
|
MWDECL MwClass MwLabelClass;
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Sets the custom data for seven segment
|
||||||
|
* @param handle Widget
|
||||||
|
* @param index Index
|
||||||
|
* @param data Data, `GFEDCBA` as 7-bit value
|
||||||
|
* @note See https://en.wikipedia.org/wiki/File:7_Segment_Display_with_Labeled_Segments.svg for what alphabets mean here
|
||||||
|
* */
|
||||||
|
MwInline void MwLabelSetSevenSegment(MwWidget handle, int index, int data) {
|
||||||
|
MwVaWidgetExecute(handle, "mwLabelSetSevenSegment", NULL, index, data);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -5,20 +5,29 @@
|
||||||
#ifndef __MW_WIDGET_OPENGL_H__
|
#ifndef __MW_WIDGET_OPENGL_H__
|
||||||
#define __MW_WIDGET_OPENGL_H__
|
#define __MW_WIDGET_OPENGL_H__
|
||||||
|
|
||||||
|
#include <Mw/Core.h>
|
||||||
#include <Mw/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
#include <Mw/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
#include <Mw/Core.h>
|
|
||||||
|
|
||||||
|
#if !defined(MW_OPENGL_NO_INCLUDE) && !defined(__gl_h_)
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
#elif defined(__APPLE__)
|
||||||
#else
|
#else
|
||||||
#include <GL/glx.h>
|
#include <GL/glx.h>
|
||||||
#endif
|
#endif
|
||||||
|
#if defined(__APPLE__)
|
||||||
|
#include <OpenGL/gl.h>
|
||||||
|
#include <OpenGL/glu.h>
|
||||||
|
#else
|
||||||
#include <GL/gl.h>
|
#include <GL/gl.h>
|
||||||
|
#include <GL/glu.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifndef GLAPIENTRY
|
#ifndef GLAPIENTRY
|
||||||
#define GLAPIENTRY APIENTRY
|
#define GLAPIENTRY APIENTRY
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,25 @@ extern "C" {
|
||||||
*/
|
*/
|
||||||
MWDECL MwClass MwSubMenuClass;
|
MWDECL MwClass MwSubMenuClass;
|
||||||
|
|
||||||
MwInline void MwSubMenuAppear(MwWidget handle, MwMenu menu, MwPoint* point) {
|
/*!
|
||||||
MwVaWidgetExecute(handle, "mwSubMenuAppear", NULL, menu, point);
|
* @brief Makes submenu appear
|
||||||
|
* @param handle Handle
|
||||||
|
* @param menu Menu
|
||||||
|
* @param point Point
|
||||||
|
* @param diff_calc Toggles different way to calculate positiion
|
||||||
|
*/
|
||||||
|
MwInline void MwSubMenuAppear(MwWidget handle, MwMenu menu, MwPoint* point, int diff_calc) {
|
||||||
|
MwVaWidgetExecute(handle, "mwSubMenuAppear", NULL, menu, point, diff_calc);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* @brief Calculates the size of submenu
|
||||||
|
* @param handle Handle
|
||||||
|
* @param menu Menu
|
||||||
|
* @param rect Size
|
||||||
|
*/
|
||||||
|
MwInline void MwSubMenuGetSize(MwWidget handle, MwMenu menu, MwRect* rect) {
|
||||||
|
MwVaWidgetExecute(handle, "mwSubMenuGetSize", NULL, menu, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -11,17 +11,18 @@
|
||||||
#ifndef __MW_WIDGET_VULKAN_H__
|
#ifndef __MW_WIDGET_VULKAN_H__
|
||||||
#define __MW_WIDGET_VULKAN_H__
|
#define __MW_WIDGET_VULKAN_H__
|
||||||
|
|
||||||
#if !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
|
#if defined(MW_VULKAN) && !defined(_WIN32) && !defined(__linux__) && !defined(__FreeBSD__) && !defined(__NetBSD__)
|
||||||
#error Vulkan is unsupported on the requested platform.
|
#error Vulkan is unsupported on the requested platform.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !defined(MW_VULKAN_NO_INCLUDE)
|
||||||
#include <vulkan/vulkan.h>
|
#include <vulkan/vulkan.h>
|
||||||
#include <vulkan/vulkan_core.h>
|
#include <vulkan/vulkan_core.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <Mw/MachDep.h>
|
#include <Mw/MachDep.h>
|
||||||
#include <Mw/TypeDefs.h>
|
#include <Mw/TypeDefs.h>
|
||||||
#include <Mw/Core.h>
|
#include <Mw/Core.h>
|
||||||
#include <Mw/Error.h>
|
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
@ -47,19 +48,19 @@ MWDECL void MwVulkanEnableLayer(const char* ext_name);
|
||||||
/*!
|
/*!
|
||||||
* @brief Configuration options that can be passed to setup Vulkan before a widget is created.
|
* @brief Configuration options that can be passed to setup Vulkan before a widget is created.
|
||||||
*/
|
*/
|
||||||
typedef struct MwVulkanConfig_T {
|
typedef struct _MwVulkanConfig {
|
||||||
/*!
|
/*!
|
||||||
* @brief Vulkan API version (default: VK_API_VERSION_1_0)
|
* @brief Vulkan API version (default: VK_API_VERSION_1_0)
|
||||||
*/
|
*/
|
||||||
uint32_t api_version;
|
MwU32 api_version;
|
||||||
/*!
|
/*!
|
||||||
* @brief Vulkan version (default: VK_VERSION_1_0)
|
* @brief Vulkan version (default: VK_VERSION_1_0)
|
||||||
*/
|
*/
|
||||||
uint32_t vk_version;
|
MwU32 vk_version;
|
||||||
/*!
|
/*!
|
||||||
* @brief Whether or not to enable validation layers (default: false)
|
* @brief Whether or not to enable validation layers (default: false)
|
||||||
*/
|
*/
|
||||||
VkBool32 validation_layers;
|
int validation_layers;
|
||||||
} MwVulkanConfig;
|
} MwVulkanConfig;
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
@ -67,61 +68,61 @@ typedef struct MwVulkanConfig_T {
|
||||||
* @warning This must be called before MwCreateWidget.
|
* @warning This must be called before MwCreateWidget.
|
||||||
* @warning The configuration provided will be used for future initializations of the Vulkan widget (unless it's changed)
|
* @warning The configuration provided will be used for future initializations of the Vulkan widget (unless it's changed)
|
||||||
*/
|
*/
|
||||||
MWDECL void MwVulkanConfigure(MwVulkanConfig cfg);
|
MWDECL void MwVulkanConfigure(MwVulkanConfig* cfg);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Field that can be gotten from Vulkan.
|
* @brief Field that can be gotten from Vulkan.
|
||||||
*/
|
*/
|
||||||
typedef enum MwVulkanField_T {
|
enum MwVULKANFIELD {
|
||||||
/*!
|
/*!
|
||||||
* @brief The address of the vulkan widget's vkGetInstanceProcAddr function (PFN_vkGetInstanceProcAddr)
|
* @brief The address of the vulkan widget's vkGetInstanceProcAddr function (PFN_vkGetInstanceProcAddr)
|
||||||
*/
|
*/
|
||||||
MwVulkanField_GetInstanceProcAddr = 0,
|
MwVULKANFIELD_GETINSTANCEPROCADDR = 0,
|
||||||
/*!
|
/*!
|
||||||
* @brief The address of the vulkan widget's instance (VkInstance)
|
* @brief The address of the vulkan widget's instance (VkInstance)
|
||||||
*/
|
*/
|
||||||
MwVulkanField_Instance,
|
MwVULKANFIELD_INSTANCE,
|
||||||
/*!
|
/*!
|
||||||
* @brief The address of the vulkan widget's surface (VkSurfaceKHR)
|
* @brief The address of the vulkan widget's surface (VkSurfaceKHR)
|
||||||
*/
|
*/
|
||||||
MwVulkanField_Surface,
|
MwVULKANFIELD_SURFACE,
|
||||||
/*!
|
/*!
|
||||||
* @brief The address of the vulkan widget's physical device (VkPhysicalDevice)
|
* @brief The address of the vulkan widget's physical device (VkPhysicalDevice)
|
||||||
*/
|
*/
|
||||||
MwVulkanField_PhysicalDevice,
|
MwVULKANFIELD_PHYSICALDEVICE,
|
||||||
/*!
|
/*!
|
||||||
* @brief The address of the vulkan widget's logical device (VkDevice)
|
* @brief The address of the vulkan widget's logical device (VkDevice)
|
||||||
*/
|
*/
|
||||||
MwVulkanField_LogicalDevice,
|
MwVULKANFIELD_LOGICALDEVICE,
|
||||||
/*!
|
/*!
|
||||||
* @brief The address of the index that the vulkan widget uses for the graphics queue (uint32_t *)
|
* @brief The address of the index that the vulkan widget uses for the graphics queue (uint32_t *)
|
||||||
*/
|
*/
|
||||||
MwVulkanField_GraphicsQueueIndex,
|
MwVULKANFIELD_GRAPHICSQUEUEINDEX,
|
||||||
/*!
|
/*!
|
||||||
* @brief The address of the index that the vulkan widget uses for the present queue (uint32_t *)
|
* @brief The address of the index that the vulkan widget uses for the present queue (uint32_t *)
|
||||||
*/
|
*/
|
||||||
MwVulkanField_PresentQueueIndex,
|
MwVULKANFIELD_PRESENTQUEUEINDEX,
|
||||||
MwVulkanField_GraphicsQueue,
|
MwVULKANFIELD_GRAPHICSQUEUE,
|
||||||
/*!
|
/*!
|
||||||
* @brief The address of the vulkan widget's graphics queue (VkQueue)
|
* @brief The address of the vulkan widget's graphics queue (VkQueue)
|
||||||
*/
|
*/
|
||||||
MwVulkanField_PresentQueue,
|
MwVULKANFIELD_PRESENTQUEUE,
|
||||||
} MwVulkanField;
|
};
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Function for getting a field from within Vulkan.
|
* @brief Function for getting a field from within Vulkan.
|
||||||
* @warning Consult the documentation for MwVulkanField to know what type is expected for out.
|
* @note Consult the documentation for MwVULKANFIELD to know what type is expected for output.
|
||||||
*/
|
*/
|
||||||
MwInline void* MwVulkanGetField(MwWidget handle, MwVulkanField field, MwErrorEnum* out) {
|
MwInline void* MwVulkanGetField(MwWidget handle, int field, int* err) {
|
||||||
void* field_out;
|
void* field_out;
|
||||||
MwVaWidgetExecute(handle, "mwVulkanGetField", &field_out, field, out);
|
MwVaWidgetExecute(handle, "mwVulkanGetField", &field_out, field, err);
|
||||||
return field_out;
|
return field_out;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* @brief Return whether Vulkan is installed on the target platform.
|
* @brief Return whether Vulkan is installed on the target platform.
|
||||||
*/
|
*/
|
||||||
MWDECL VkBool32 MwVulkanSupported(void);
|
MWDECL int MwVulkanSupported(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
||||||
236
milsko.xml
236
milsko.xml
|
|
@ -38,19 +38,18 @@
|
||||||
<short name="green" unsigned="yes" />
|
<short name="green" unsigned="yes" />
|
||||||
<short name="blue" unsigned="yes" />
|
<short name="blue" unsigned="yes" />
|
||||||
</struct>
|
</struct>
|
||||||
|
<struct name="MwMouse">
|
||||||
|
<struct defname="MwPoint" name="point" />
|
||||||
|
<integer name="button" />
|
||||||
|
</struct>
|
||||||
|
<struct name="MwVulkanConfig">
|
||||||
|
<integer name="api_version" unsigned="yes" />
|
||||||
|
<integer name="vk_version" unsigned="yes" />
|
||||||
|
<integer name="validation_layers" />
|
||||||
|
</struct>
|
||||||
</structs>
|
</structs>
|
||||||
<!--
|
<!--
|
||||||
All widgets have:
|
All widgets have properties that are common="yes".
|
||||||
- MwNbackground
|
|
||||||
- MwNforeground
|
|
||||||
- MwNx
|
|
||||||
- MwNy
|
|
||||||
- MwNwidth
|
|
||||||
- MwNheight
|
|
||||||
- MwNborderWidth
|
|
||||||
- MwNbackgroundPixmap
|
|
||||||
- MwNratio
|
|
||||||
- MwNfixedSize
|
|
||||||
|
|
||||||
Integer properties must be prefixed with I.
|
Integer properties must be prefixed with I.
|
||||||
String properties must be prefixed with S.
|
String properties must be prefixed with S.
|
||||||
|
|
@ -58,10 +57,10 @@
|
||||||
Other properties must be prefixed with V.
|
Other properties must be prefixed with V.
|
||||||
-->
|
-->
|
||||||
<properties>
|
<properties>
|
||||||
<integer name="x" />
|
<integer name="x" common="yes" />
|
||||||
<integer name="y" />
|
<integer name="y" common="yes" />
|
||||||
<integer name="width" />
|
<integer name="width" common="yes" />
|
||||||
<integer name="height" />
|
<integer name="height" common="yes" />
|
||||||
<integer name="orientation" />
|
<integer name="orientation" />
|
||||||
<integer name="minValue" />
|
<integer name="minValue" />
|
||||||
<integer name="maxValue" />
|
<integer name="maxValue" />
|
||||||
|
|
@ -76,46 +75,93 @@
|
||||||
<integer name="hasHeading" />
|
<integer name="hasHeading" />
|
||||||
<integer name="hasBorder" />
|
<integer name="hasBorder" />
|
||||||
<integer name="inverted" />
|
<integer name="inverted" />
|
||||||
<integer name="modernLook" />
|
<integer name="modernLook" common="yes" />
|
||||||
<integer name="waitMS" />
|
|
||||||
<integer name="hideInput" />
|
<integer name="hideInput" />
|
||||||
<integer name="singleClickSelectable" />
|
<integer name="singleClickSelectable" />
|
||||||
<integer name="flat" />
|
<integer name="flat" />
|
||||||
<integer name="showArrows" />
|
<integer name="showArrows" />
|
||||||
<integer name="padding" />
|
<integer name="padding" />
|
||||||
<integer name="borderWidth" />
|
<integer name="borderWidth" common="yes" />
|
||||||
<integer name="ratio" />
|
<integer name="ratio" common="yes" />
|
||||||
<integer name="fixedSize" />
|
<integer name="fixedSize" common="yes" />
|
||||||
<integer name="margin" />
|
<integer name="margin" />
|
||||||
|
<integer name="bitmapFont" common="yes" />
|
||||||
|
<integer name="sevenSegment" />
|
||||||
|
<integer name="length" />
|
||||||
|
<integer name="forceInverted" common="yes" />
|
||||||
|
<integer name="isRounded" common="yes" />
|
||||||
|
<integer name="darkTheme" common="yes" />
|
||||||
|
<integer name="useMonospace" common="yes" />
|
||||||
|
|
||||||
|
<!-- waitMS is a special property, only applies to toplevel widget -->
|
||||||
|
<integer name="waitMS" common="yes" />
|
||||||
|
|
||||||
<string name="title" />
|
<string name="title" />
|
||||||
<string name="text" />
|
<string name="text" />
|
||||||
<string name="background" />
|
<string name="background" common="yes" />
|
||||||
<string name="foreground" />
|
<string name="subBackground" common="yes" />
|
||||||
|
<string name="foreground" common="yes" />
|
||||||
|
<string name="subForeground" common="yes" />
|
||||||
|
|
||||||
<pixmap name="pixmap" />
|
<pixmap name="pixmap" />
|
||||||
<pixmap name="iconPixmap" />
|
<pixmap name="iconPixmap" />
|
||||||
<struct defname="MwSizeHints" pointer="yes" name="sizeHints" />
|
<struct defname="MwSizeHints" pointer="yes" name="sizeHints" />
|
||||||
<pointer name="font" />
|
<pointer name="font" />
|
||||||
<pointer name="boldFont" />
|
<pointer name="boldFont" />
|
||||||
|
<pixmap name="backgroundPixmap" common="yes" />
|
||||||
|
<pointer name="monospaceFont" />
|
||||||
|
<pointer name="boldMonospaceFont" />
|
||||||
|
|
||||||
<handler name="activate" />
|
<handler name="activate" />
|
||||||
|
<handler name="listBoxActivate">
|
||||||
|
<integer pointer="yes" />
|
||||||
|
</handler>
|
||||||
|
<handler name="treeViewActivate">
|
||||||
|
<pointer />
|
||||||
|
</handler>
|
||||||
<handler name="resize" />
|
<handler name="resize" />
|
||||||
<handler name="tick" />
|
<handler name="tick" />
|
||||||
<handler name="menu" />
|
<handler name="menu">
|
||||||
<handler name="mouseDown" />
|
<pointer />
|
||||||
<handler name="mouseUp" />
|
</handler>
|
||||||
<handler name="mouseMove" />
|
<handler name="mouseDown">
|
||||||
|
<struct defname="MwMouse" pointer="yes" />
|
||||||
|
</handler>
|
||||||
|
<handler name="mouseUp">
|
||||||
|
<struct defname="MwMouse" pointer="yes" />
|
||||||
|
</handler>
|
||||||
|
<handler name="mouseMove">
|
||||||
|
<struct defname="MwPoint" pointer="yes" />
|
||||||
|
</handler>
|
||||||
<handler name="changed" />
|
<handler name="changed" />
|
||||||
<handler name="key" />
|
<handler name="comboBoxChanged">
|
||||||
<handler name="keyRelease" />
|
<integer pointer="yes" />
|
||||||
|
</handler>
|
||||||
|
<handler name="key">
|
||||||
|
<integer pointer="yes" />
|
||||||
|
</handler>
|
||||||
|
<handler name="keyRelease">
|
||||||
|
<integer pointer="yes" />
|
||||||
|
</handler>
|
||||||
<handler name="close" />
|
<handler name="close" />
|
||||||
<handler name="focusIn" />
|
<handler name="focusIn" />
|
||||||
<handler name="focusOut" />
|
<handler name="focusOut" />
|
||||||
<handler name="fileChosen" />
|
<handler name="fileChosen">
|
||||||
<handler name="directoryChosen" />
|
<string />
|
||||||
<handler name="colorChosen" />
|
</handler>
|
||||||
|
<handler name="directoryChosen">
|
||||||
|
<string />
|
||||||
|
</handler>
|
||||||
|
<handler name="colorChosen">
|
||||||
|
<struct defname="MwRGB" pointer="yes" />
|
||||||
|
</handler>
|
||||||
<handler name="draw" />
|
<handler name="draw" />
|
||||||
|
<handler name="clipboard">
|
||||||
|
<string />
|
||||||
|
</handler>
|
||||||
|
<handler name="darkTheme">
|
||||||
|
<integer pointer="yes" />
|
||||||
|
</handler>
|
||||||
</properties>
|
</properties>
|
||||||
<enumerations>
|
<enumerations>
|
||||||
<enumeration name="MwDIRECTION">
|
<enumeration name="MwDIRECTION">
|
||||||
|
|
@ -142,6 +188,32 @@
|
||||||
<integer name="MwMB_ICONERROR" />
|
<integer name="MwMB_ICONERROR" />
|
||||||
<integer name="MwMB_ICONCLOCK" />
|
<integer name="MwMB_ICONCLOCK" />
|
||||||
</enumeration>
|
</enumeration>
|
||||||
|
<enumeration name="MwCOORDINATE">
|
||||||
|
<integer name="MwCOORDINATE_GLOBAL">0</integer>
|
||||||
|
<integer name="MwCOORDINATE_LOCAL" />
|
||||||
|
</enumeration>
|
||||||
|
<enumeration name="MwCLIPBOARD">
|
||||||
|
<integer name="MwCLIPBOARD_MAIN">0</integer>
|
||||||
|
<integer name="MwCLIPBOARD_PRIMARY" />
|
||||||
|
</enumeration>
|
||||||
|
<enumeration name="MwMOUSE">
|
||||||
|
<integer name="MwMOUSE_LEFT">1</integer>
|
||||||
|
<integer name="MwMOUSE_MIDDLE" />
|
||||||
|
<integer name="MwMOUSE_RIGHT" />
|
||||||
|
<integer name="MwMOUSE_WHEELUP" />
|
||||||
|
<integer name="MwMOUSE_WHEELDOWN" />
|
||||||
|
</enumeration>
|
||||||
|
<enumeration name="MwVULKANFIELD">
|
||||||
|
<integer name="MwVULKANFIELD_GETINSTANCEPROCADDR">0</integer>
|
||||||
|
<integer name="MwVULKANFIELD_INSTANCE" />
|
||||||
|
<integer name="MwVULKANFIELD_SURFACE" />
|
||||||
|
<integer name="MwVULKANFIELD_PHYSICALDEVICE" />
|
||||||
|
<integer name="MwVULKANFIELD_LOGICALDEVICE" />
|
||||||
|
<integer name="MwVULKANFIELD_GRAPHICSQUEUEINDEX" />
|
||||||
|
<integer name="MwVULKANFIELD_PRESENTQUEUEINDEX" />
|
||||||
|
<integer name="MwVULKANFIELD_GRAPHICSQUEUE" />
|
||||||
|
<integer name="MwVULKANFIELD_PRESENTQUEUE" />
|
||||||
|
</enumeration>
|
||||||
</enumerations>
|
</enumerations>
|
||||||
<constants>
|
<constants>
|
||||||
<integer name="MwDEFAULT">0x0fffffff</integer>
|
<integer name="MwDEFAULT">0x0fffffff</integer>
|
||||||
|
|
@ -346,7 +418,7 @@
|
||||||
<widget name="handle" />
|
<widget name="handle" />
|
||||||
</arguments>
|
</arguments>
|
||||||
</function>
|
</function>
|
||||||
<function name="MwToggleDarkTheme">
|
<function name="MwSetDarkTheme">
|
||||||
<arguments>
|
<arguments>
|
||||||
<widget name="handle" />
|
<widget name="handle" />
|
||||||
<integer name="toggle" />
|
<integer name="toggle" />
|
||||||
|
|
@ -395,14 +467,18 @@
|
||||||
<struct defname="MwRect" pointer="yes" name="rect" />
|
<struct defname="MwRect" pointer="yes" name="rect" />
|
||||||
</arguments>
|
</arguments>
|
||||||
</function>
|
</function>
|
||||||
</functions>
|
<function name="MwGetClipboard">
|
||||||
</header>
|
<arguments>
|
||||||
<header name="Error">
|
<widget name="handle" />
|
||||||
<functions>
|
<integer enumname="MwClipboardType" name="clipboard_type" />
|
||||||
<function name="MwGetLastError">
|
</arguments>
|
||||||
<return>
|
</function>
|
||||||
<string />
|
<function name="MwSetClipboard">
|
||||||
</return>
|
<arguments>
|
||||||
|
<widget name="handle" />
|
||||||
|
<string name="text" />
|
||||||
|
<integer enumname="MwClipboardType" name="clipboard_type" />
|
||||||
|
</arguments>
|
||||||
</function>
|
</function>
|
||||||
</functions>
|
</functions>
|
||||||
</header>
|
</header>
|
||||||
|
|
@ -486,13 +562,31 @@
|
||||||
</function>
|
</function>
|
||||||
</functions>
|
</functions>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
|
<!-- They are not alphabetically sorted for reasons -->
|
||||||
|
<header name="Widget/Vulkan.h">
|
||||||
|
<functions>
|
||||||
|
<function name="MwVulkanConfigure">
|
||||||
|
<return>
|
||||||
|
<pointer />
|
||||||
|
</return>
|
||||||
|
<arguments>
|
||||||
|
<struct defname="MwVulkanConfig" name="cfg" pointer="yes" />
|
||||||
|
</arguments>
|
||||||
|
</function>
|
||||||
|
</functions>
|
||||||
|
</header>
|
||||||
</headers>
|
</headers>
|
||||||
|
|
||||||
|
<!-- Widget functions are prefixed with mw<widget name> -->
|
||||||
<widgets>
|
<widgets>
|
||||||
<widget name="Box">
|
<widget name="Box">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="orientation" />
|
<property name="orientation" />
|
||||||
<property name="margin" />
|
<property name="margin" />
|
||||||
<property name="padding" />
|
<property name="padding" />
|
||||||
|
<property name="hasBorder" />
|
||||||
|
<property name="inverted" />
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
<widget name="Button">
|
<widget name="Button">
|
||||||
|
|
@ -526,6 +620,7 @@
|
||||||
<property name="pixmap" />
|
<property name="pixmap" />
|
||||||
<property name="hasBorder" />
|
<property name="hasBorder" />
|
||||||
<property name="inverted" />
|
<property name="inverted" />
|
||||||
|
<property name="fillArea" />
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
<widget name="Label">
|
<widget name="Label">
|
||||||
|
|
@ -533,7 +628,18 @@
|
||||||
<property name="text" />
|
<property name="text" />
|
||||||
<property name="alignment" />
|
<property name="alignment" />
|
||||||
<property name="bold" />
|
<property name="bold" />
|
||||||
|
<property name="sevenSegment" />
|
||||||
|
<property name="length" />
|
||||||
|
<property name="leftPadding" />
|
||||||
</properties>
|
</properties>
|
||||||
|
<functions>
|
||||||
|
<function name="SetSevenSegment">
|
||||||
|
<arguments>
|
||||||
|
<integer name="index" />
|
||||||
|
<integer name="data" />
|
||||||
|
</arguments>
|
||||||
|
</function>
|
||||||
|
</functions>
|
||||||
</widget>
|
</widget>
|
||||||
<widget name="ListBox">
|
<widget name="ListBox">
|
||||||
<properties>
|
<properties>
|
||||||
|
|
@ -588,20 +694,6 @@
|
||||||
<property name="text" />
|
<property name="text" />
|
||||||
</properties>
|
</properties>
|
||||||
</widget>
|
</widget>
|
||||||
<widget name="OpenGL">
|
|
||||||
<functions>
|
|
||||||
<function name="MakeCurrent" />
|
|
||||||
<function name="GetProcAddress">
|
|
||||||
<return>
|
|
||||||
<pointer />
|
|
||||||
</return>
|
|
||||||
<arguments>
|
|
||||||
<string name="name" />
|
|
||||||
</arguments>
|
|
||||||
</function>
|
|
||||||
<function name="SwapBuffer" />
|
|
||||||
</functions>
|
|
||||||
</widget>
|
|
||||||
<widget name="ScrollBar">
|
<widget name="ScrollBar">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="showArrows" />
|
<property name="showArrows" />
|
||||||
|
|
@ -621,6 +713,9 @@
|
||||||
</functions>
|
</functions>
|
||||||
</widget>
|
</widget>
|
||||||
<widget name="SubMenu">
|
<widget name="SubMenu">
|
||||||
|
<properties>
|
||||||
|
<property name="leftPadding" />
|
||||||
|
</properties>
|
||||||
<functions>
|
<functions>
|
||||||
<function name="Appear">
|
<function name="Appear">
|
||||||
<arguments>
|
<arguments>
|
||||||
|
|
@ -689,15 +784,48 @@
|
||||||
</properties>
|
</properties>
|
||||||
<functions>
|
<functions>
|
||||||
<function name="Add">
|
<function name="Add">
|
||||||
|
<arguments>
|
||||||
<pointer name="parent" />
|
<pointer name="parent" />
|
||||||
<pixmap name="pixmap" />
|
<pixmap name="pixmap" />
|
||||||
<string name="item" />
|
<string name="item" />
|
||||||
|
</arguments>
|
||||||
</function>
|
</function>
|
||||||
<function name="Delete">
|
<function name="Delete">
|
||||||
|
<arguments>
|
||||||
<pointer name="item" />
|
<pointer name="item" />
|
||||||
|
</arguments>
|
||||||
</function>
|
</function>
|
||||||
<function name="Reset" />
|
<function name="Reset" />
|
||||||
</functions>
|
</functions>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
||||||
|
<!-- They are not alphabetically sorted for reasons -->
|
||||||
|
<widget name="OpenGL">
|
||||||
|
<functions>
|
||||||
|
<function name="MakeCurrent" />
|
||||||
|
<function name="GetProcAddress">
|
||||||
|
<return>
|
||||||
|
<pointer />
|
||||||
|
</return>
|
||||||
|
<arguments>
|
||||||
|
<string name="name" />
|
||||||
|
</arguments>
|
||||||
|
</function>
|
||||||
|
<function name="SwapBuffer" />
|
||||||
|
</functions>
|
||||||
|
</widget>
|
||||||
|
<widget name="Vulkan">
|
||||||
|
<functions>
|
||||||
|
<function name="GetField">
|
||||||
|
<return>
|
||||||
|
<pointer />
|
||||||
|
</return>
|
||||||
|
<arguments>
|
||||||
|
<integer enumname="MwVulkanField" name="field" />
|
||||||
|
<integer pointer="yes" name="output" />
|
||||||
|
</arguments>
|
||||||
|
</function>
|
||||||
|
</functions>
|
||||||
|
</widget>
|
||||||
</widgets>
|
</widgets>
|
||||||
</milsko>
|
</milsko>
|
||||||
|
|
|
||||||
12
pl/ostype/ClassicMacOS.pl
Normal file
12
pl/ostype/ClassicMacOS.pl
Normal file
|
|
@ -0,0 +1,12 @@
|
||||||
|
use_backend("classicmacos");
|
||||||
|
|
||||||
|
print(
|
||||||
|
"Compiling for Classic Mac OS via ./configure currently outputs a broken executable and it only supports PowerPC. Help is wanted. In the mean time, use CMake."
|
||||||
|
);
|
||||||
|
|
||||||
|
$cc = $ENV{RETRO68_TOOLCHAIN_PATH} . "/bin/powerpc-apple-macos-gcc";
|
||||||
|
$ar = $ENV{RETRO68_TOOLCHAIN_PATH} . "/bin/powerpc-apple-macos-ar";
|
||||||
|
add_cflags("-DCLASSIC_MAC_OS");
|
||||||
|
add_cflags("-DSTBI_NO_THREAD_LOCALS");
|
||||||
|
|
||||||
|
1;
|
||||||
9
pl/ostype/Darwin.pl
Normal file
9
pl/ostype/Darwin.pl
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
$library_suffix = ".dylib";
|
||||||
|
set_shared_flag("-dynamiclib");
|
||||||
|
|
||||||
|
use_backend("cocoa");
|
||||||
|
|
||||||
|
add_cflags("-DSTBI_NO_THREAD_LOCALS");
|
||||||
|
add_ldflags("-framework Cocoa -lobjc");
|
||||||
|
|
||||||
|
1;
|
||||||
|
|
@ -1,8 +1,14 @@
|
||||||
if (param_get("experimental-wayland")) {
|
my @enabled_backends = ();
|
||||||
use_backend("wayland", "x11");
|
|
||||||
|
if (param_get("wayland")) {
|
||||||
|
push(@enabled_backends, "wayland");
|
||||||
}
|
}
|
||||||
else {
|
if (param_get("x11")) {
|
||||||
use_backend("x11");
|
push(@enabled_backends, "x11");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_cflags("-DUSE_DBUS");
|
||||||
|
|
||||||
|
use_backend(@enabled_backends);
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,9 @@
|
||||||
add_incdir("-I/usr/X11R7/include -I/usr/pkg/include");
|
add_incdir2("-I/usr/X11R7/include -I/usr/pkg/include");
|
||||||
add_libdir(
|
add_libdir(
|
||||||
"-L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib");
|
"-L/usr/X11R7/lib -Wl,-R/usr/X11R7/lib -L/usr/pkg/lib -Wl,-R/usr/pkg/lib");
|
||||||
use_backend("x11");
|
use_backend("x11");
|
||||||
|
add_libs("-lpthread");
|
||||||
|
|
||||||
|
add_cflags("-DUSE_DBUS");
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
|
|
||||||
90
pl/rules.pl
90
pl/rules.pl
|
|
@ -1,20 +1,24 @@
|
||||||
new_object("src/*.c");
|
new_object("src/*.c");
|
||||||
|
|
||||||
my $gl_libs = "";
|
my $gl_libs = "";
|
||||||
|
if (param_get("tiny")) {
|
||||||
|
add_cflags("-Oz");
|
||||||
|
if (defined($ENV{CC}) && grep(/^clang$/, $ENV{CC})) {
|
||||||
|
add_libs("-flto=thin");
|
||||||
|
add_cflags("-flto=thin");
|
||||||
|
}
|
||||||
|
}
|
||||||
if (param_get("classic-theme")) {
|
if (param_get("classic-theme")) {
|
||||||
add_cflags("-DUSE_CLASSIC_THEME");
|
add_cflags("-DUSE_CLASSIC_THEME");
|
||||||
}
|
}
|
||||||
if (grep(/^x11$/, @backends)) {
|
if (grep(/^x11$/, @backends)) {
|
||||||
add_cflags("-DUSE_X11");
|
add_cflags("-DUSE_X11");
|
||||||
new_object("src/backend/x11.c");
|
new_object("src/backend/x11.c");
|
||||||
add_libs("-lX11");
|
|
||||||
|
|
||||||
$gl_libs = "-lGL -lGLU";
|
$gl_libs = "-lGL -lGLU";
|
||||||
|
|
||||||
if (param_get("xrender")) {
|
if (param_get("xrender")) {
|
||||||
add_cflags("-DUSE_XRENDER");
|
add_cflags("-DUSE_XRENDER");
|
||||||
add_libs("-lXrender");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,34 +30,83 @@ if (grep(/^gdi$/, @backends)) {
|
||||||
$gl_libs = "-lopengl32 -lglu32";
|
$gl_libs = "-lopengl32 -lglu32";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grep(/^classicmacos$/, @backends)) {
|
||||||
|
|
||||||
|
#add_cflags("-DCLASSIC_MAC_OS");
|
||||||
|
new_object("src/backend/classicmacos.c");
|
||||||
|
|
||||||
|
$gl_libs = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (grep(/^wayland$/, @backends)) {
|
if (grep(/^wayland$/, @backends)) {
|
||||||
add_cflags("-DUSE_WAYLAND");
|
add_cflags("-DUSE_WAYLAND");
|
||||||
new_object("src/backend/wayland.c");
|
new_object("src/backend/wayland.c");
|
||||||
add_cflags(`pkg-config --cflags cairo wayland-client xkbcommon`);
|
|
||||||
add_libs(`pkg-config --libs cairo wayland-client xkbcommon`);
|
|
||||||
|
|
||||||
|
if (param_get("opengl")) {
|
||||||
|
add_cflags("-DWAYLAND_LOAD_OPENGL");
|
||||||
|
}
|
||||||
|
|
||||||
|
scan_wayland_protocol_core();
|
||||||
scan_wayland_protocol("stable", "xdg-shell", "");
|
scan_wayland_protocol("stable", "xdg-shell", "");
|
||||||
|
scan_wayland_protocol("stable", "viewporter", "");
|
||||||
scan_wayland_protocol("stable", "tablet", "-v2");
|
scan_wayland_protocol("stable", "tablet", "-v2");
|
||||||
|
scan_wayland_protocol("staging", "xdg-toplevel-icon", "-v1");
|
||||||
scan_wayland_protocol("staging", "cursor-shape", "-v1");
|
scan_wayland_protocol("staging", "cursor-shape", "-v1");
|
||||||
scan_wayland_protocol("unstable", "xdg-decoration", "-unstable-v1");
|
scan_wayland_protocol("unstable", "xdg-decoration", "-unstable-v1");
|
||||||
|
scan_wayland_protocol("unstable", "primary-selection", "-unstable-v1");
|
||||||
|
scan_wayland_protocol("unstable", "pointer-constraints", "-unstable-v1");
|
||||||
|
scan_wayland_protocol("unstable", "relative-pointer", "-unstable-v1");
|
||||||
|
|
||||||
$gl_libs = "-lEGL -lwayland-egl lGL -lGLU";
|
$gl_libs = "-lGL -lGLU";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grep(/( |^)-DUSE_DBUS( |$)/, $cflags)) {
|
||||||
|
add_cflags(`pkg-config --cflags dbus-1`);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grep(/^cocoa$/, @backends) || param_get("gnustep")) {
|
||||||
|
add_cflags("-DUSE_COCOA");
|
||||||
|
new_object("src/backend/cocoa.m");
|
||||||
|
|
||||||
|
if (param_get("gnustep")) {
|
||||||
|
add_incdir("-I" . `gnustep-config --variable=GNUSTEP_SYSTEM_HEADERS`);
|
||||||
|
add_libdir("-L" . `gnustep-config --variable=GNUSTEP_SYSTEM_LIBRARIES`);
|
||||||
|
add_cflags("-fobjc-runtime=gnustep-2.0 -fblocks");
|
||||||
|
add_ldflags("-lobjc -lgnustep-base -lm -lgnustep-gui");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (param_get("opengl")) {
|
||||||
|
new_object("src/widget/opengl_cocoa.m");
|
||||||
|
}
|
||||||
|
|
||||||
|
# tim cook my man literally everybody and their mother who knows what opengl is knows its deprecated on macos and i'm not having you spam the console with this
|
||||||
|
add_cflags("-DGL_SILENCE_DEPRECATION");
|
||||||
|
|
||||||
|
$gl_libs = "-framework OpenGL";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (param_get("stb-image")) {
|
if (param_get("stb-image")) {
|
||||||
add_cflags("-DUSE_STB_IMAGE");
|
add_cflags("-DUSE_STB_IMAGE");
|
||||||
|
if (param_get("tiny")) {
|
||||||
|
add_cflags("-DSTB_IMAGE_STATIC");
|
||||||
|
add_cflags("-DSTB_IMAGE_IMPLEMENTATION");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new_object("external/libjpeg/src/*.c");
|
||||||
|
new_object("external/libpng/src/*.c");
|
||||||
|
add_incdir("-Iexternal/libjpeg/include -Iexternal/libpng/include");
|
||||||
}
|
}
|
||||||
if (param_get("stb-truetype")) {
|
if (param_get("stb-truetype")) {
|
||||||
add_cflags("-DUSE_STB_TRUETYPE");
|
add_cflags("-DUSE_STB_TRUETYPE");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
add_incdir("-Iexternal/libz/include");
|
||||||
|
|
||||||
if (param_get("freetype2")) {
|
if (param_get("freetype2")) {
|
||||||
add_cflags("-DUSE_FREETYPE2");
|
add_cflags("-DUSE_FREETYPE2");
|
||||||
if ($cross) {
|
if (!$cross) {
|
||||||
add_libs("-lfreetype");
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
add_cflags(`pkg-config --cflags freetype2`);
|
add_cflags(`pkg-config --cflags freetype2`);
|
||||||
add_libs(`pkg-config --libs freetype2`);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -62,8 +115,9 @@ if (param_get("vulkan") && param_get("vulkan-string-helper")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
new_object("src/icon/*.c");
|
new_object("src/icon/*.c");
|
||||||
new_object("src/font/*.c");
|
|
||||||
new_object("src/cursor/*.c");
|
new_object("src/cursor/*.c");
|
||||||
|
new_object("src/text/*.c");
|
||||||
|
new_object("src/text/font/*.c");
|
||||||
|
|
||||||
new_object("src/widget/box.c");
|
new_object("src/widget/box.c");
|
||||||
new_object("src/widget/button.c");
|
new_object("src/widget/button.c");
|
||||||
|
|
@ -85,11 +139,14 @@ new_object("src/widget/treeview.c");
|
||||||
new_object("src/widget/viewport.c");
|
new_object("src/widget/viewport.c");
|
||||||
new_object("src/widget/window.c");
|
new_object("src/widget/window.c");
|
||||||
|
|
||||||
if (param_get("opengl")) {
|
|
||||||
new_object("src/widget/opengl.c");
|
new_object("src/widget/opengl.c");
|
||||||
|
new_object("src/widget/vulkan.c");
|
||||||
|
|
||||||
|
if (param_get("opengl")) {
|
||||||
|
add_cflags("-DMW_OPENGL");
|
||||||
}
|
}
|
||||||
if (param_get("vulkan")) {
|
if (param_get("vulkan")) {
|
||||||
new_object("src/widget/vulkan.c");
|
add_cflags("-DMW_VULKAN");
|
||||||
}
|
}
|
||||||
|
|
||||||
new_object("src/dialog/*.c");
|
new_object("src/dialog/*.c");
|
||||||
|
|
@ -97,6 +154,7 @@ new_object("src/dialog/*.c");
|
||||||
new_object("src/abstract/*.c");
|
new_object("src/abstract/*.c");
|
||||||
|
|
||||||
new_object("external/*.c");
|
new_object("external/*.c");
|
||||||
|
new_object("external/libz/src/*.c");
|
||||||
|
|
||||||
new_example("examples/basic/example");
|
new_example("examples/basic/example");
|
||||||
new_example("examples/basic/rotate");
|
new_example("examples/basic/rotate");
|
||||||
|
|
@ -112,6 +170,10 @@ new_example("examples/basic/colorpicker");
|
||||||
new_example("examples/basic/combobox");
|
new_example("examples/basic/combobox");
|
||||||
new_example("examples/basic/treeview");
|
new_example("examples/basic/treeview");
|
||||||
new_example("examples/basic/box");
|
new_example("examples/basic/box");
|
||||||
|
new_example("examples/basic/clipboard");
|
||||||
|
new_example("examples/basic/sevensegment");
|
||||||
|
new_example("examples/basic/calculator");
|
||||||
|
new_example("examples/basic/periodic");
|
||||||
|
|
||||||
if (param_get("opengl")) {
|
if (param_get("opengl")) {
|
||||||
new_example("examples/gldemos/boing", $gl_libs);
|
new_example("examples/gldemos/boing", $gl_libs);
|
||||||
|
|
|
||||||
41
pl/utils.pl
41
pl/utils.pl
|
|
@ -5,6 +5,13 @@ sub add_incdir {
|
||||||
$incdir = "${incdir} ${input}";
|
$incdir = "${incdir} ${input}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub add_incdir2 {
|
||||||
|
my $input = $_[0];
|
||||||
|
$input =~ s/\r?\n/ /g;
|
||||||
|
|
||||||
|
$incdir2 = "${incdir2} ${input}";
|
||||||
|
}
|
||||||
|
|
||||||
sub add_cflags {
|
sub add_cflags {
|
||||||
my $input = $_[0];
|
my $input = $_[0];
|
||||||
$input =~ s/\r?\n/ /g;
|
$input =~ s/\r?\n/ /g;
|
||||||
|
|
@ -40,10 +47,14 @@ sub new_example {
|
||||||
push(@examples_targets, "${_[0]}${executable_suffix}");
|
push(@examples_targets, "${_[0]}${executable_suffix}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_shared_flag {
|
||||||
|
@shared = $_[0];
|
||||||
|
}
|
||||||
|
|
||||||
sub new_object {
|
sub new_object {
|
||||||
my @l = glob($_[0]);
|
my @l = glob($_[0]);
|
||||||
foreach my $e (@l) {
|
foreach my $e (@l) {
|
||||||
$e =~ s/\.c$/$object_suffix/;
|
$e =~ s/\.(c|m)$/$object_suffix/;
|
||||||
push(@library_targets, $e);
|
push(@library_targets, $e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -54,6 +65,34 @@ sub use_backend {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub scan_wayland_protocol_core {
|
||||||
|
my $proto_c = "src/backend/wayland-core-protocol.c";
|
||||||
|
|
||||||
|
if (
|
||||||
|
system(
|
||||||
|
"wayland-scanner private-code /usr/share/wayland/wayland.xml ${proto_c}"
|
||||||
|
) != 0
|
||||||
|
)
|
||||||
|
{
|
||||||
|
print(
|
||||||
|
"^ Error on getting private code for /usr/share/wayland/wayland.xml\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new_object($proto_c);
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
system(
|
||||||
|
"wayland-scanner client-header /usr/share/wayland/wayland.xml include/Mw/LowLevel/Wayland/wayland-core-protocol.h"
|
||||||
|
)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
print(
|
||||||
|
"^ Error on getting client header for /usr/share/wayland/wayland.xml\n"
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub scan_wayland_protocol {
|
sub scan_wayland_protocol {
|
||||||
my $tier = $_[0];
|
my $tier = $_[0];
|
||||||
my $proto = $_[1];
|
my $proto = $_[1];
|
||||||
|
|
|
||||||
BIN
resource/font/OpenSans-Bold.ttf
Normal file
BIN
resource/font/OpenSans-Bold.ttf
Normal file
Binary file not shown.
BIN
resource/font/OpenSans-Regular.ttf
Normal file
BIN
resource/font/OpenSans-Regular.ttf
Normal file
Binary file not shown.
|
|
@ -4,7 +4,11 @@
|
||||||
typedef struct dir {
|
typedef struct dir {
|
||||||
HANDLE hFind;
|
HANDLE hFind;
|
||||||
WIN32_FIND_DATA ffd;
|
WIN32_FIND_DATA ffd;
|
||||||
int first;
|
int next;
|
||||||
|
} dir_t;
|
||||||
|
#elif defined(CLASSIC_MAC_OS)
|
||||||
|
typedef struct dir {
|
||||||
|
int dummy;
|
||||||
} dir_t;
|
} dir_t;
|
||||||
#else
|
#else
|
||||||
typedef struct dir {
|
typedef struct dir {
|
||||||
|
|
@ -18,14 +22,21 @@ void* MwDirectoryOpen(const char* path) {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char* p = malloc(strlen(path) + 2 + 1);
|
char* p = malloc(strlen(path) + 2 + 1);
|
||||||
strcpy(p, path);
|
strcpy(p, path);
|
||||||
strcat(p, "/*");
|
if(strchr(path, '/') != NULL) {
|
||||||
|
strcat(p, "/");
|
||||||
|
} else {
|
||||||
|
strcat(p, "\\");
|
||||||
|
}
|
||||||
|
strcat(p, "*");
|
||||||
if((dir->hFind = FindFirstFile(p, &dir->ffd)) == INVALID_HANDLE_VALUE) {
|
if((dir->hFind = FindFirstFile(p, &dir->ffd)) == INVALID_HANDLE_VALUE) {
|
||||||
free(p);
|
free(p);
|
||||||
free(dir);
|
free(dir);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
free(p);
|
free(p);
|
||||||
dir->first = 1;
|
dir->next = 1;
|
||||||
|
#elif defined(CLASSIC_MAC_OS)
|
||||||
|
/* todo */
|
||||||
#else
|
#else
|
||||||
if((dir->dir = opendir(path)) == NULL) {
|
if((dir->dir = opendir(path)) == NULL) {
|
||||||
free(dir);
|
free(dir);
|
||||||
|
|
@ -42,6 +53,8 @@ void MwDirectoryClose(void* handle) {
|
||||||
dir_t* dir = handle;
|
dir_t* dir = handle;
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
FindClose(dir->hFind);
|
FindClose(dir->hFind);
|
||||||
|
#elif defined(CLASSIC_MAC_OS)
|
||||||
|
/* todo */
|
||||||
#else
|
#else
|
||||||
closedir(dir->dir);
|
closedir(dir->dir);
|
||||||
free(dir->base);
|
free(dir->base);
|
||||||
|
|
@ -54,14 +67,10 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
|
||||||
MwDirectoryEntry* entry = malloc(sizeof(*entry));
|
MwDirectoryEntry* entry = malloc(sizeof(*entry));
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
ULARGE_INTEGER* l;
|
ULARGE_INTEGER* l;
|
||||||
if(dir->first) {
|
|
||||||
dir->first = 0;
|
|
||||||
} else if(FindNextFile(dir->hFind, &dir->ffd) == 0) {
|
|
||||||
free(entry);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
entry->name = MwStringDuplicate(dir->ffd.cFileName);
|
|
||||||
|
|
||||||
|
if(!dir->next) return NULL;
|
||||||
|
|
||||||
|
entry->name = MwStringDuplicate(dir->ffd.cFileName);
|
||||||
if(dir->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
if(dir->ffd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) {
|
||||||
entry->type = MwDIRECTORY_DIRECTORY;
|
entry->type = MwDIRECTORY_DIRECTORY;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -77,6 +86,10 @@ MwDirectoryEntry* MwDirectoryRead(void* handle) {
|
||||||
l = (ULARGE_INTEGER*)&dir->ffd.ftLastWriteTime;
|
l = (ULARGE_INTEGER*)&dir->ffd.ftLastWriteTime;
|
||||||
|
|
||||||
entry->mtime = l->QuadPart / 10000000 - 11644473600;
|
entry->mtime = l->QuadPart / 10000000 - 11644473600;
|
||||||
|
|
||||||
|
dir->next = FindNextFile(dir->hFind, &dir->ffd);
|
||||||
|
#elif defined(CLASSIC_MAC_OS)
|
||||||
|
/* todo */
|
||||||
#else
|
#else
|
||||||
struct dirent* d;
|
struct dirent* d;
|
||||||
struct stat s;
|
struct stat s;
|
||||||
|
|
@ -120,6 +133,8 @@ char* MwDirectoryCurrent(void) {
|
||||||
GetCurrentDirectory(len, out);
|
GetCurrentDirectory(len, out);
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
|
#elif CLASSIC_MAC_OS
|
||||||
|
return "";
|
||||||
#else
|
#else
|
||||||
return getcwd(NULL, 0);
|
return getcwd(NULL, 0);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,43 @@ void* MwDynamicSymbol(void* handle, const char* symbol) {
|
||||||
void MwDynamicClose(void* handle) {
|
void MwDynamicClose(void* handle) {
|
||||||
FreeLibrary(handle);
|
FreeLibrary(handle);
|
||||||
}
|
}
|
||||||
#elif defined(__unix__)
|
#elif defined(CLASSIC_MAC_OS)
|
||||||
|
void* MwDynamicOpen(const char* path) {
|
||||||
|
// CFragConnectionID connID;
|
||||||
|
// Ptr* addr;
|
||||||
|
// unsigned char err[255];
|
||||||
|
|
||||||
|
// if(GetSharedLibrary((ConstStr63Param)path, kPowerPCCFragArch, kPrivateCFragCopy,
|
||||||
|
// &connID, addr, err)) {
|
||||||
|
// printf("Error getting %s: %s\n", path, err);
|
||||||
|
// return NULL;
|
||||||
|
// };
|
||||||
|
// return connID;
|
||||||
|
printf("MwDynamicOpen not implemented yet.\n");
|
||||||
|
getchar();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* MwDynamicSymbol(void* handle, const char* symbol) {
|
||||||
|
// CFragConnectionID connID = (CFragConnectionID)handle;
|
||||||
|
// Ptr* symAddr;
|
||||||
|
// CFragSymbolClass* symClass;
|
||||||
|
// OSErr err;
|
||||||
|
// if((err = FindSymbol(connID, (ConstStr63Param)symbol, symAddr, symClass))) {
|
||||||
|
// printf("Error getting %s: %d\n", symbol, err);
|
||||||
|
// return NULL;
|
||||||
|
// };
|
||||||
|
// return symAddr;
|
||||||
|
printf("MwDynamicSymbol not implemented yet.\n");
|
||||||
|
getchar();
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwDynamicClose(void* handle) {
|
||||||
|
// CFragConnectionID connID = (CFragConnectionID)handle;
|
||||||
|
// CloseConnection(&connID);
|
||||||
|
}
|
||||||
|
#elif defined(__unix__) || defined(__APPLE__)
|
||||||
void* MwDynamicOpen(const char* path) {
|
void* MwDynamicOpen(const char* path) {
|
||||||
return dlopen(path, RTLD_LOCAL | RTLD_LAZY);
|
return dlopen(path, RTLD_LOCAL | RTLD_LAZY);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,6 +8,53 @@ long MwTimeGetTick(void) {
|
||||||
void MwTimeSleep(int ms) {
|
void MwTimeSleep(int ms) {
|
||||||
Sleep(ms);
|
Sleep(ms);
|
||||||
}
|
}
|
||||||
|
#elif defined(__APPLE__)
|
||||||
|
long MwTimeGetTick(void) {
|
||||||
|
struct timespec ts;
|
||||||
|
long n = 0;
|
||||||
|
clock_serv_t cclock;
|
||||||
|
mach_timespec_t mts;
|
||||||
|
|
||||||
|
host_get_clock_service(mach_host_self(), CALENDAR_CLOCK, &cclock);
|
||||||
|
clock_get_time(cclock, &mts);
|
||||||
|
mach_port_deallocate(mach_task_self(), cclock);
|
||||||
|
|
||||||
|
n += ts.tv_nsec / 1000 / 1000;
|
||||||
|
n += ts.tv_sec * 1000;
|
||||||
|
|
||||||
|
return n;
|
||||||
|
}
|
||||||
|
void MwTimeSleep(int ms) {
|
||||||
|
struct timespec ts;
|
||||||
|
|
||||||
|
ts.tv_sec = ms / 1000;
|
||||||
|
ts.tv_nsec = (ms % 1000) * 1000 * 1000;
|
||||||
|
|
||||||
|
nanosleep(&ts, NULL);
|
||||||
|
}
|
||||||
|
#elif defined(CLASSIC_MAC_OS)
|
||||||
|
// static TMTask tm;
|
||||||
|
// static int timer;
|
||||||
|
// void timerUpdateFunc(void) {
|
||||||
|
// timer += 1;
|
||||||
|
// PrimeTime((QElemPtr)&tm, 1);
|
||||||
|
// };
|
||||||
|
|
||||||
|
long MwTimeGetTick(void) {
|
||||||
|
UnsignedWide h;
|
||||||
|
Microseconds(&h);
|
||||||
|
return h.lo;
|
||||||
|
}
|
||||||
|
void MwTimeSleep(int ms) {
|
||||||
|
// tm.tmAddr = NewTimerProc(timerUpdateFunc);
|
||||||
|
// tm.tmWakeUp = 0;
|
||||||
|
// tm.tmReserved = 0;
|
||||||
|
|
||||||
|
// InsTime((QElemPtr)&tm);
|
||||||
|
// PrimeTime((QElemPtr)&tm, 1);
|
||||||
|
|
||||||
|
// DisposeTimerUPP(tm.tmAddr);
|
||||||
|
}
|
||||||
#elif defined(__unix__)
|
#elif defined(__unix__)
|
||||||
long MwTimeGetTick(void) {
|
long MwTimeGetTick(void) {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
@ -25,7 +72,7 @@ void MwTimeSleep(int ms) {
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
|
|
||||||
ts.tv_sec = ms / 1000;
|
ts.tv_sec = ms / 1000;
|
||||||
ts.tv_nsec = (ms % 1000) * 1000 * 1000;
|
ts.tv_nsec = (ms % 1000) * 1000000;
|
||||||
|
|
||||||
nanosleep(&ts, NULL);
|
nanosleep(&ts, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -54,6 +54,8 @@
|
||||||
\
|
\
|
||||||
MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \
|
MwLLGetCursorCoord = MwLLGetCursorCoordImpl; \
|
||||||
MwLLGetScreenSize = MwLLGetScreenSizeImpl; \
|
MwLLGetScreenSize = MwLLGetScreenSizeImpl; \
|
||||||
|
\
|
||||||
|
MwLLSetDarkTheme = MwLLSetDarkThemeImpl; \
|
||||||
\
|
\
|
||||||
return 0; \
|
return 0; \
|
||||||
}
|
}
|
||||||
|
|
|
||||||
357
src/backend/classicmacos.c
Normal file
357
src/backend/classicmacos.c
Normal file
|
|
@ -0,0 +1,357 @@
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
#include <Threads.h>
|
||||||
|
#include <QuickDraw.h>
|
||||||
|
|
||||||
|
#include "../../external/stb_ds.h"
|
||||||
|
|
||||||
|
static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
|
MwLL r;
|
||||||
|
r = malloc(sizeof(*r));
|
||||||
|
memset(r, 0, sizeof(*r));
|
||||||
|
MwLLCreateCommon(r);
|
||||||
|
|
||||||
|
r->cmacos.parent = parent;
|
||||||
|
|
||||||
|
if(x == MwDEFAULT) {
|
||||||
|
x = (qd.screenBits.bounds.right / 2) - (width / 2);
|
||||||
|
}
|
||||||
|
if(y == MwDEFAULT) {
|
||||||
|
y = (qd.screenBits.bounds.bottom / 2) - (height / 2);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* todo: how do we set parent windows? If we can't, what is our equivalant to MacOS's NSViews, Wayland's subsurfaces, etc.? */
|
||||||
|
SetRect(&r->cmacos.winRect, x, y, width, height);
|
||||||
|
r->cmacos.window = newcwindow(nil, &r->cmacos.winRect, "", true,
|
||||||
|
documentProc, (WindowPtr)(-1), true, 0);
|
||||||
|
SetPort(r->cmacos.window);
|
||||||
|
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLDestroyImpl(MwLL handle) {
|
||||||
|
MwLLDestroyCommon(handle);
|
||||||
|
|
||||||
|
free(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLBeginDrawImpl(MwLL handle) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLEndDrawImpl(MwLL handle) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||||
|
int i;
|
||||||
|
PolyHandle p;
|
||||||
|
RGBColor col;
|
||||||
|
|
||||||
|
SetPort(handle->cmacos.window);
|
||||||
|
BeginUpdate(handle->cmacos.window);
|
||||||
|
|
||||||
|
p = OpenPoly();
|
||||||
|
col.red = color->common.red * 0x101;
|
||||||
|
col.green = color->common.green * 0x101;
|
||||||
|
col.blue = color->common.blue * 0x101;
|
||||||
|
|
||||||
|
RGBForeColor(&col);
|
||||||
|
PenMode(patCopy);
|
||||||
|
|
||||||
|
for(i = 0; i < points_count; i++) {
|
||||||
|
if(i == 0) {
|
||||||
|
MoveTo(points[i].x, points[i].y);
|
||||||
|
} else {
|
||||||
|
LineTo(points[i].x, points[i].y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ClosePoly();
|
||||||
|
FillCPoly(p, &qd.ltGray);
|
||||||
|
KillPoly(p);
|
||||||
|
|
||||||
|
EndUpdate(handle->cmacos.window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
|
||||||
|
RGBColor col;
|
||||||
|
SetPort(handle->cmacos.window);
|
||||||
|
|
||||||
|
col.red = color->common.red;
|
||||||
|
col.green = color->common.green;
|
||||||
|
col.blue = color->common.blue;
|
||||||
|
|
||||||
|
RGBForeColor(&col);
|
||||||
|
|
||||||
|
PenMode(patCopy);
|
||||||
|
|
||||||
|
MoveTo(points[0].x, points[0].y);
|
||||||
|
LineTo(points[1].x, points[1].y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
|
||||||
|
MwLLColor c = malloc(sizeof(*c));
|
||||||
|
MwLLColorUpdate(handle, c, r, g, b);
|
||||||
|
return c;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
|
||||||
|
c->common.red = r;
|
||||||
|
c->common.green = g;
|
||||||
|
c->common.blue = b;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
|
||||||
|
Rect bounds;
|
||||||
|
GetWindowBounds(handle->cmacos.window, kWindowContentRgn, &bounds);
|
||||||
|
*x = bounds.left;
|
||||||
|
*y = bounds.top;
|
||||||
|
*w = bounds.right;
|
||||||
|
*h = bounds.bottom;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLSetXYImpl(MwLL handle, int x, int y) {
|
||||||
|
MoveWindow(handle->cmacos.window, x, y, MwTRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLSetWHImpl(MwLL handle, int w, int h) {
|
||||||
|
SizeWindow(handle->cmacos.window, w, h, MwTRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLFreeColorImpl(MwLLColor color) {
|
||||||
|
free(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int MwLLPendingImpl(MwLL handle) {
|
||||||
|
YieldToAnyThread();
|
||||||
|
return EventAvail(everyEvent, &handle->cmacos.event);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLNextEventImpl(MwLL handle) {
|
||||||
|
EventRecord event;
|
||||||
|
GetNextEvent(everyEvent, &event);
|
||||||
|
|
||||||
|
switch(event.what) {
|
||||||
|
case updateEvt: {
|
||||||
|
}
|
||||||
|
// MwLLDispatch(handle, draw, NULL);
|
||||||
|
break;
|
||||||
|
case osEvt:
|
||||||
|
break;
|
||||||
|
case mouseUp: {
|
||||||
|
// MwLLMouse m;
|
||||||
|
// m.button = MwLLMouseLeft;
|
||||||
|
// if(___curWindow->mouseButtonCallback != NULL) {
|
||||||
|
// int mods = MacModifiersToGLFWModifiers(event.modifiers);
|
||||||
|
|
||||||
|
// if(___curWindow->keyStateMap[MK_LCTRL] == 1) {
|
||||||
|
// ___curWindow->mouseButtonCallback(
|
||||||
|
// ___curWindow, GLFW_MOUSE_BUTTON_RIGHT, GLFW_RELEASE, mods);
|
||||||
|
// } else {
|
||||||
|
// ___curWindow->mouseButtonCallback(
|
||||||
|
// ___curWindow, GLFW_MOUSE_BUTTON_LEFT, GLFW_RELEASE, mods);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
case mouseDown: {
|
||||||
|
// // start with callback stuff
|
||||||
|
// if(___curWindow->mouseButtonCallback != NULL) {
|
||||||
|
// int mods = MacModifiersToGLFWModifiers(event.modifiers);
|
||||||
|
|
||||||
|
// if(___curWindow->keyStateMap[MK_LCTRL] == 1) {
|
||||||
|
// ___curWindow->mouseButtonCallback(
|
||||||
|
// ___curWindow, GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS, mods);
|
||||||
|
// } else {
|
||||||
|
// ___curWindow->mouseButtonCallback(
|
||||||
|
// ___curWindow, GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS, mods);
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
// then do system stuff
|
||||||
|
switch(FindWindow(event.where, &handle->cmacos.window)) {
|
||||||
|
case inDrag:
|
||||||
|
DragWindow(handle->cmacos.window, event.where, &qd.screenBits.bounds);
|
||||||
|
// if(___curWindow->windowPosCallback != NULL) {
|
||||||
|
// ___curWindow->windowPosCallback(___curWindow, event.where.h,
|
||||||
|
// event.where.v);
|
||||||
|
// }
|
||||||
|
break;
|
||||||
|
case inGrow: {
|
||||||
|
long growResult =
|
||||||
|
GrowWindow(handle->cmacos.window, event.where, &qd.screenBits.bounds);
|
||||||
|
|
||||||
|
int width = growResult & 0xFFFF;
|
||||||
|
int height = growResult >> 16;
|
||||||
|
|
||||||
|
SizeWindow(handle->cmacos.window, growResult & 0xFFFF, growResult >> 16, true);
|
||||||
|
|
||||||
|
Rect rect;
|
||||||
|
GetWindowBounds(handle->cmacos.window, kWindowStructureRgn, &rect);
|
||||||
|
rect.right = width;
|
||||||
|
rect.bottom = height;
|
||||||
|
SetWindowBounds(handle->cmacos.window, kWindowStructureRgn, &rect);
|
||||||
|
|
||||||
|
// ___curWindow->width = width;
|
||||||
|
// ___curWindow->height = height;
|
||||||
|
|
||||||
|
// if(___curWindow->windowSizeCallback != NULL) {
|
||||||
|
// ___curWindow->windowSizeCallback(___curWindow, width, height);
|
||||||
|
// }
|
||||||
|
// if(___curWindow->windowSetFramebufferSizeCallback != NULL) {
|
||||||
|
// ___curWindow->windowSetFramebufferSizeCallback(___curWindow,
|
||||||
|
// width, height);
|
||||||
|
// }
|
||||||
|
} break;
|
||||||
|
|
||||||
|
case inGoAway: {
|
||||||
|
if(TrackGoAway(handle->cmacos.window, event.where)) {
|
||||||
|
MwLLDispatch(handle, close, NULL);
|
||||||
|
// if(___curWindow->windowCloseCallback != NULL) {
|
||||||
|
// ___curWindow->windowCloseCallback(___curWindow);
|
||||||
|
// }
|
||||||
|
// ___curWindow->shouldClose = true;
|
||||||
|
}
|
||||||
|
} break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
case autoKey:
|
||||||
|
case keyDown:
|
||||||
|
case keyUp: {
|
||||||
|
// // key char stuff
|
||||||
|
// unsigned char ch = (event.message & charCodeMask);
|
||||||
|
// if(*___curWindow->charCallback != NULL) {
|
||||||
|
// ___curWindow->charCallback(___curWindow, ch);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // key state map
|
||||||
|
// unsigned char key = (event.message & keyCodeMask) >> 8;
|
||||||
|
// ___curWindow->keyStateMap[key] = 0;
|
||||||
|
// if(event.what == keyDown || event.what == autoKey) {
|
||||||
|
// ___curWindow->keyStateMap[key] &= 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if(*___curWindow->keyCallback != NULL) {
|
||||||
|
// int key = MacKeyToGLFWKey(event.message);
|
||||||
|
// int scancode = (event.message & adbAddrMask) >> 16;
|
||||||
|
|
||||||
|
// int mods = MacModifiersToGLFWModifiers(event.modifiers);
|
||||||
|
|
||||||
|
// int action;
|
||||||
|
// if(event.what == keyUp) {
|
||||||
|
// action = GLFW_RELEASE;
|
||||||
|
// } else {
|
||||||
|
// action = GLFW_PRESS;
|
||||||
|
// }
|
||||||
|
// ___curWindow->keyCallback(___curWindow, key, scancode, action,
|
||||||
|
// mods);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FlushEvents(everyEvent, -1);
|
||||||
|
YieldToAnyThread();
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLSetTitleImpl(MwLL handle, const char* title) {
|
||||||
|
setwtitle(handle->cmacos.window, title);
|
||||||
|
}
|
||||||
|
|
||||||
|
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
|
||||||
|
MwLLPixmap r = malloc(sizeof(*r));
|
||||||
|
|
||||||
|
r->common.raw = malloc(4 * width * height);
|
||||||
|
memcpy(r->common.raw, data, 4 * width * height);
|
||||||
|
|
||||||
|
MwLLPixmapUpdate(r);
|
||||||
|
return r;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLForceRenderImpl(MwLL handle) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLShowImpl(MwLL handle, int show) {
|
||||||
|
if(show)
|
||||||
|
ShowWindow(handle->cmacos.window);
|
||||||
|
else
|
||||||
|
HideWindow(handle->cmacos.window);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLFocusImpl(MwLL handle) {
|
||||||
|
HiliteWindow(handle->cmacos.window, MwTRUE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
|
||||||
|
/* TODO */
|
||||||
|
|
||||||
|
(void)handle;
|
||||||
|
(void)text;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLGetCursorCoordImpl(MwLL handle, MwPoint* point) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLGetScreenSizeImpl(MwLL handle, MwRect* rect) {
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLBeginStateChangeImpl(MwLL handle) {
|
||||||
|
MwLLShow(handle, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLEndStateChangeImpl(MwLL handle) {
|
||||||
|
MwLLShow(handle, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) {
|
||||||
|
(void)handle;
|
||||||
|
(void)toggle;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int MwLLClassicMacOSCallInitImpl(void) {
|
||||||
|
InitGraf(&qd.thePort);
|
||||||
|
InitFonts();
|
||||||
|
FlushEvents(everyEvent, 0);
|
||||||
|
InitWindows();
|
||||||
|
InitMenus();
|
||||||
|
TEInit();
|
||||||
|
InitDialogs(0L);
|
||||||
|
InitCursor();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#include "call.c"
|
||||||
|
CALL(ClassicMacOS);
|
||||||
1115
src/backend/cocoa.m
Normal file
1115
src/backend/cocoa.m
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -8,6 +8,40 @@ typedef struct userdata {
|
||||||
int max_set;
|
int max_set;
|
||||||
} userdata_t;
|
} userdata_t;
|
||||||
|
|
||||||
|
static struct symtbl {
|
||||||
|
void* lib_dwmapi;
|
||||||
|
|
||||||
|
HRESULT(WINAPI* DwmSetWindowAttribute)(HWND hwnd, DWORD dwAttribute, LPCVOID pvAttribute, DWORD cbAttribute);
|
||||||
|
} wsymtbl;
|
||||||
|
|
||||||
|
#define DwmSetWindowAttribute wsymtbl.DwmSetWindowAttribute
|
||||||
|
|
||||||
|
static void detect_darktheme(MwLL handle) {
|
||||||
|
DWORD dw;
|
||||||
|
DWORD sz = sizeof(dw);
|
||||||
|
int err, t;
|
||||||
|
HKEY hkey;
|
||||||
|
DWORD type;
|
||||||
|
|
||||||
|
err = RegOpenKeyEx(HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize", 0, KEY_QUERY_VALUE, &hkey);
|
||||||
|
if(err != ERROR_SUCCESS) return;
|
||||||
|
|
||||||
|
err = RegQueryValueEx(hkey, "AppsUseLightTheme", NULL, &type, (PBYTE)&dw, &sz);
|
||||||
|
RegCloseKey(hkey);
|
||||||
|
if(err != ERROR_SUCCESS || type != REG_DWORD) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
t = dw ? 0 : 1;
|
||||||
|
|
||||||
|
if(t && DwmSetWindowAttribute != NULL) {
|
||||||
|
LPARAM style = GetWindowLongPtr(handle->gdi.hWnd, GWL_STYLE);
|
||||||
|
if(!(style & WS_CHILD)) MwLLSetDarkTheme(handle, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
MwLLDispatch(handle, dark_theme, &t);
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
|
||||||
|
|
@ -45,44 +79,44 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||||
EndPaint(hWnd, &ps);
|
EndPaint(hWnd, &ps);
|
||||||
}
|
}
|
||||||
} else if(msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
|
} else if(msg == WM_LBUTTONDOWN || msg == WM_MBUTTONDOWN || msg == WM_RBUTTONDOWN) {
|
||||||
MwLLMouse p;
|
MwMouse p;
|
||||||
p.point.x = LOWORD(lp);
|
p.point.x = LOWORD(lp);
|
||||||
p.point.y = HIWORD(lp);
|
p.point.y = HIWORD(lp);
|
||||||
if(msg == WM_LBUTTONDOWN) {
|
if(msg == WM_LBUTTONDOWN) {
|
||||||
p.button = MwLLMouseLeft;
|
p.button = MwMOUSE_LEFT;
|
||||||
} else if(msg == WM_MBUTTONDOWN) {
|
} else if(msg == WM_MBUTTONDOWN) {
|
||||||
p.button = MwLLMouseMiddle;
|
p.button = MwMOUSE_MIDDLE;
|
||||||
} else if(msg == WM_RBUTTONDOWN) {
|
} else if(msg == WM_RBUTTONDOWN) {
|
||||||
p.button = MwLLMouseRight;
|
p.button = MwMOUSE_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCapture(hWnd);
|
SetCapture(hWnd);
|
||||||
SetFocus(hWnd);
|
SetFocus(hWnd);
|
||||||
MwLLDispatch(u->ll, down, &p);
|
MwLLDispatch(u->ll, down, &p);
|
||||||
} else if(msg == WM_LBUTTONUP || msg == WM_MBUTTONUP || msg == WM_RBUTTONUP) {
|
} else if(msg == WM_LBUTTONUP || msg == WM_MBUTTONUP || msg == WM_RBUTTONUP) {
|
||||||
MwLLMouse p;
|
MwMouse p;
|
||||||
p.point.x = LOWORD(lp);
|
p.point.x = LOWORD(lp);
|
||||||
p.point.y = HIWORD(lp);
|
p.point.y = HIWORD(lp);
|
||||||
if(msg == WM_LBUTTONUP) {
|
if(msg == WM_LBUTTONUP) {
|
||||||
p.button = MwLLMouseLeft;
|
p.button = MwMOUSE_LEFT;
|
||||||
} else if(msg == WM_MBUTTONUP) {
|
} else if(msg == WM_MBUTTONUP) {
|
||||||
p.button = MwLLMouseMiddle;
|
p.button = MwMOUSE_MIDDLE;
|
||||||
} else if(msg == WM_RBUTTONUP) {
|
} else if(msg == WM_RBUTTONUP) {
|
||||||
p.button = MwLLMouseRight;
|
p.button = MwMOUSE_RIGHT;
|
||||||
}
|
}
|
||||||
|
|
||||||
SetCapture(NULL);
|
SetCapture(NULL);
|
||||||
MwLLDispatch(u->ll, up, &p);
|
MwLLDispatch(u->ll, up, &p);
|
||||||
} else if(msg == WM_MOUSEWHEEL) {
|
} else if(msg == WM_MOUSEWHEEL) {
|
||||||
int d = GET_WHEEL_DELTA_WPARAM(wp);
|
int d = GET_WHEEL_DELTA_WPARAM(wp);
|
||||||
MwLLMouse p;
|
MwMouse p;
|
||||||
p.point.x = LOWORD(lp);
|
p.point.x = LOWORD(lp);
|
||||||
p.point.y = HIWORD(lp);
|
p.point.y = HIWORD(lp);
|
||||||
|
|
||||||
if(d > 0) {
|
if(d > 0) {
|
||||||
p.button = MwLLMouseWheelUp;
|
p.button = MwMOUSE_WHEELUP;
|
||||||
} else if(d < 0) {
|
} else if(d < 0) {
|
||||||
p.button = MwLLMouseWheelDown;
|
p.button = MwMOUSE_WHEELDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLDispatch(u->ll, down, &p);
|
MwLLDispatch(u->ll, down, &p);
|
||||||
|
|
@ -205,6 +239,13 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
|
||||||
} else if(msg == WM_USER) {
|
} else if(msg == WM_USER) {
|
||||||
InvalidateRect(hWnd, NULL, FALSE);
|
InvalidateRect(hWnd, NULL, FALSE);
|
||||||
UpdateWindow(hWnd);
|
UpdateWindow(hWnd);
|
||||||
|
} else if(msg == WM_WININICHANGE) {
|
||||||
|
char* s = (char*)lp;
|
||||||
|
LPARAM style = GetWindowLongPtr(hWnd, GWL_STYLE);
|
||||||
|
|
||||||
|
if(!(style & WS_CHILD)) {
|
||||||
|
if(s != NULL && strcmp(s, "ImmersiveColorSet") == 0) detect_darktheme(u->ll);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
return DefWindowProc(hWnd, msg, wp, lp);
|
return DefWindowProc(hWnd, msg, wp, lp);
|
||||||
}
|
}
|
||||||
|
|
@ -237,6 +278,8 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
r->common.copy_buffer = 1;
|
r->common.copy_buffer = 1;
|
||||||
r->common.type = MwLLBackendGDI;
|
r->common.type = MwLLBackendGDI;
|
||||||
|
|
||||||
|
r->gdi.get_clipboard = 0;
|
||||||
|
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), 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), x == MwDEFAULT ? CW_USEDEFAULT : x, y == MwDEFAULT ? CW_USEDEFAULT : y, width, height, parent == NULL ? NULL : parent->gdi.hWnd, 0, wc.hInstance, NULL);
|
||||||
|
|
@ -383,6 +426,7 @@ static int MwLLPendingImpl(MwLL handle) {
|
||||||
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
|
||||||
|
if(handle->gdi.get_clipboard || handle->gdi.get_darktheme) return 1;
|
||||||
return PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
|
return PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -391,6 +435,29 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
|
||||||
|
if(handle->gdi.get_clipboard) {
|
||||||
|
HGLOBAL hg;
|
||||||
|
if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) {
|
||||||
|
char* txt = malloc(GlobalSize(hg));
|
||||||
|
char* clp = GlobalLock(hg);
|
||||||
|
|
||||||
|
strcpy(txt, clp);
|
||||||
|
|
||||||
|
GlobalUnlock(hg);
|
||||||
|
CloseClipboard();
|
||||||
|
|
||||||
|
MwLLDispatch(handle, clipboard, txt);
|
||||||
|
|
||||||
|
free(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
handle->gdi.get_clipboard = 0;
|
||||||
|
}
|
||||||
|
if(handle->gdi.get_darktheme) {
|
||||||
|
detect_darktheme(handle);
|
||||||
|
|
||||||
|
handle->gdi.get_darktheme = 0;
|
||||||
|
}
|
||||||
while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) {
|
while(PeekMessage(&msg, handle->gdi.hWnd, 0, 0, PM_NOREMOVE)) {
|
||||||
GetMessage(&msg, handle->gdi.hWnd, 0, 0);
|
GetMessage(&msg, handle->gdi.hWnd, 0, 0);
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
|
|
@ -535,8 +602,8 @@ HCURSOR MwLLGDICreateCursor(MwCursor* image, MwCursor* mask) {
|
||||||
int y, x, ys, xs;
|
int y, x, ys, xs;
|
||||||
|
|
||||||
xs = -mask->x + image->x;
|
xs = -mask->x + image->x;
|
||||||
ys = MwCursorDataHeight + mask->y;
|
ys = mask->height + mask->y;
|
||||||
ys = MwCursorDataHeight + image->y - ys;
|
ys = image->height + image->y - ys;
|
||||||
|
|
||||||
memset(dmask, 0xff, (MwCursorDataHeight / 8) * MwCursorDataHeight);
|
memset(dmask, 0xff, (MwCursorDataHeight / 8) * MwCursorDataHeight);
|
||||||
memset(dimage, 0, (MwCursorDataHeight / 8) * MwCursorDataHeight);
|
memset(dimage, 0, (MwCursorDataHeight / 8) * MwCursorDataHeight);
|
||||||
|
|
@ -567,7 +634,7 @@ HCURSOR MwLLGDICreateCursor(MwCursor* image, MwCursor* mask) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cursor = CreateCursor(GetModuleHandle(NULL), xs, ys, MwCursorDataHeight, MwCursorDataHeight, dmask, dimage);
|
cursor = CreateCursor(GetModuleHandle(NULL), xs - image->x, ys + (MwCursorDataHeight + image->y), MwCursorDataHeight, MwCursorDataHeight, dmask, dimage);
|
||||||
|
|
||||||
free(dimage);
|
free(dimage);
|
||||||
free(dmask);
|
free(dmask);
|
||||||
|
|
@ -609,6 +676,8 @@ static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
|
||||||
rc2.bottom -= rc2.top;
|
rc2.bottom -= rc2.top;
|
||||||
|
|
||||||
SetWindowPos(handle->gdi.hWnd, HWND_TOPMOST, rc.left, rc.top, rc2.right == 0 ? 1 : rc2.right, rc2.bottom == 0 ? 1 : rc2.bottom, SWP_FRAMECHANGED | SWP_NOACTIVATE);
|
SetWindowPos(handle->gdi.hWnd, HWND_TOPMOST, rc.left, rc.top, rc2.right == 0 ? 1 : rc2.right, rc2.bottom == 0 ? 1 : rc2.bottom, SWP_FRAMECHANGED | SWP_NOACTIVATE);
|
||||||
|
|
||||||
|
handle->gdi.get_darktheme = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLShowImpl(MwLL handle, int show) {
|
static void MwLLShowImpl(MwLL handle, int show) {
|
||||||
|
|
@ -679,8 +748,9 @@ static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
|
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
|
||||||
HGLOBAL hg;
|
HGLOBAL hg;
|
||||||
|
(void)clipboard_type;
|
||||||
if(OpenClipboard(handle->gdi.hWnd) != 0) {
|
if(OpenClipboard(handle->gdi.hWnd) != 0) {
|
||||||
char* lock;
|
char* lock;
|
||||||
|
|
||||||
|
|
@ -697,21 +767,9 @@ static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* MwLLGetClipboardImpl(MwLL handle) {
|
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
|
||||||
HGLOBAL hg;
|
(void)clipboard_type;
|
||||||
char* r = NULL;
|
handle->gdi.get_clipboard = 1; /* nishi: we do this to make clipboard api work similar to other backends */
|
||||||
if(OpenClipboard(handle->gdi.hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) {
|
|
||||||
char* lock;
|
|
||||||
|
|
||||||
r = malloc(GlobalSize(hg));
|
|
||||||
|
|
||||||
lock = GlobalLock(hg);
|
|
||||||
strcpy(r, lock);
|
|
||||||
GlobalUnlock(hg);
|
|
||||||
|
|
||||||
CloseClipboard();
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||||
|
|
@ -761,7 +819,19 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) {
|
||||||
|
BOOL v = toggle ? TRUE : FALSE;
|
||||||
|
|
||||||
|
DwmSetWindowAttribute(handle->gdi.hWnd, 20, &v, sizeof(v));
|
||||||
|
}
|
||||||
|
|
||||||
static int MwLLGDICallInitImpl(void) {
|
static int MwLLGDICallInitImpl(void) {
|
||||||
|
memset(&wsymtbl, 0, sizeof(wsymtbl));
|
||||||
|
|
||||||
|
wsymtbl.lib_dwmapi = MwDynamicOpen("dwmapi.dll");
|
||||||
|
|
||||||
|
if(wsymtbl.lib_dwmapi != NULL) DwmSetWindowAttribute = MwDynamicSymbol(wsymtbl.lib_dwmapi, "DwmSetWindowAttribute");
|
||||||
|
|
||||||
/* TODO: check properly */
|
/* TODO: check properly */
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
|
|
@ -2,6 +2,190 @@
|
||||||
|
|
||||||
#include "../../external/stb_ds.h"
|
#include "../../external/stb_ds.h"
|
||||||
|
|
||||||
|
#define ClipboardTimeout 100
|
||||||
|
|
||||||
|
static struct symtbl {
|
||||||
|
void* lib_xlib;
|
||||||
|
void* lib_xrender;
|
||||||
|
MwBool has_xrender;
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
MwLLDBusFuncTable dbus;
|
||||||
|
MwBool has_dbus;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int (*XClearWindow)(Display* display, Window w);
|
||||||
|
XImage* (*XCreateImage)(Display*, Visual*, unsigned int, int, int, char*, unsigned int, unsigned int, int, int);
|
||||||
|
Display* (*XOpenDisplay)(_Xconst char*);
|
||||||
|
char* (*XKeysymToString)(KeySym);
|
||||||
|
Atom (*XInternAtom)(Display*, _Xconst char*, Bool);
|
||||||
|
Cursor (*XCreatePixmapCursor)(Display*, Pixmap, Pixmap, XColor*, XColor*, unsigned int, unsigned int);
|
||||||
|
GC (*XCreateGC)(Display*, Drawable, unsigned long, XGCValues*);
|
||||||
|
Pixmap (*XCreatePixmap)(Display*, Drawable, unsigned int, unsigned int, unsigned int);
|
||||||
|
Window (*XCreateSimpleWindow)(Display*, Window, int, int, unsigned int, unsigned int, unsigned int, unsigned long, unsigned long);
|
||||||
|
VisualID (*XVisualIDFromVisual)(Visual*);
|
||||||
|
Window (*XRootWindow)(Display*, int);
|
||||||
|
Status (*XSetWMProtocols)(Display*, Window, Atom*, int);
|
||||||
|
int (*XSetTransientForHint)(Display*, Window, Window);
|
||||||
|
Status (*XAllocColor)(Display*, Colormap, XColor*);
|
||||||
|
int (*XChangeProperty)(Display*, Window, Atom, Atom, int, int, _Xconst unsigned char*, int);
|
||||||
|
int (*XChangeWindowAttributes)(Display*, Window, unsigned long, XSetWindowAttributes*);
|
||||||
|
Bool (*XCheckTypedWindowEvent)(Display*, Window, int, XEvent*);
|
||||||
|
Bool (*XCheckWindowEvent)(Display*, Window, long, XEvent*);
|
||||||
|
int (*XCloseDisplay)(Display*);
|
||||||
|
int (*XConfigureWindow)(Display*, Window, unsigned int, XWindowChanges*);
|
||||||
|
int (*XConvertSelection)(Display*, Atom, Atom, Atom, Window, Time);
|
||||||
|
int (*XCopyArea)(Display*, Drawable, Drawable, GC, int, int, unsigned int, unsigned int, int, int);
|
||||||
|
int (*XDefaultScreen)(Display*);
|
||||||
|
int (*XDefineCursor)(Display*, Window, Cursor);
|
||||||
|
int (*XDeleteProperty)(Display*, Window, Atom);
|
||||||
|
int (*XDestroyWindow)(Display*, Window);
|
||||||
|
int (*XDrawLine)(Display*, Drawable, GC, int, int, int, int);
|
||||||
|
int (*XFillPolygon)(Display*, Drawable, GC, XPoint*, int, int, int);
|
||||||
|
int (*XFree)(void*);
|
||||||
|
int (*XFreeCursor)(Display*, Cursor);
|
||||||
|
int (*XFreeGC)(Display*, GC);
|
||||||
|
int (*XFreePixmap)(Display*, Pixmap);
|
||||||
|
Status (*XGetGeometry)(Display*, Drawable, Window*, int*, int*, unsigned int*, unsigned int*, unsigned int*, unsigned int*);
|
||||||
|
int (*XGetWindowProperty)(Display*, Window, Atom, long, long, Bool, Atom, Atom*, int*, unsigned long*, unsigned long*, unsigned char**);
|
||||||
|
Status (*XGetWindowAttributes)(Display*, Window, XWindowAttributes*);
|
||||||
|
int (*XMapWindow)(Display*, Window);
|
||||||
|
int (*XNextEvent)(Display*, XEvent*);
|
||||||
|
int (*XPending)(Display*);
|
||||||
|
int (*XPutBackEvent)(Display*, XEvent*);
|
||||||
|
int (*XPutImage)(Display*, Drawable, GC, XImage*, int, int, int, int, unsigned int, unsigned int);
|
||||||
|
Bool (*XQueryPointer)(Display*, Window, Window*, Window*, int*, int*, int*, int*, unsigned int*);
|
||||||
|
Status (*XQueryTree)(Display*, Window, Window*, Window*, Window**, unsigned int*);
|
||||||
|
int (*XReparentWindow)(Display*, Window, Window, int, int);
|
||||||
|
int (*XSelectInput)(Display*, Window, long);
|
||||||
|
Status (*XSendEvent)(Display*, Window, Bool, long, XEvent*);
|
||||||
|
int (*XSetClipMask)(Display*, GC, Pixmap);
|
||||||
|
int (*XSetClipOrigin)(Display*, GC, int, int);
|
||||||
|
int (*XSetForeground)(Display*, GC, unsigned long);
|
||||||
|
int (*XSetGraphicsExposures)(Display*, GC, Bool);
|
||||||
|
int (*XSetInputFocus)(Display*, Window, int, Time);
|
||||||
|
int (*XSetWindowBackgroundPixmap)(Display*, Window, Pixmap);
|
||||||
|
int (*XSync)(Display*, Bool);
|
||||||
|
Bool (*XTranslateCoordinates)(Display*, Window, Window, int, int, int*, int*, Window*);
|
||||||
|
int (*XUnmapWindow)(Display*, Window);
|
||||||
|
int (*XWarpPointer)(Display*, Window, Window, int, int, unsigned int, unsigned int, int, int);
|
||||||
|
char* (*XSetLocaleModifiers)(const char*);
|
||||||
|
XIM (*XOpenIM)(Display*, struct _XrmHashBucketRec*, char*, char*);
|
||||||
|
Status (*XCloseIM)(XIM);
|
||||||
|
XIC (*XCreateIC)(XIM, ...);
|
||||||
|
void (*XDestroyIC)(XIC);
|
||||||
|
void (*XSetICFocus)(XIC);
|
||||||
|
|
||||||
|
XSizeHints* (*XAllocSizeHints)(void);
|
||||||
|
XVisualInfo* (*XGetVisualInfo)(Display*, long, XVisualInfo*, int*);
|
||||||
|
Status (*XGetWMNormalHints)(Display*, Window, XSizeHints*, long*);
|
||||||
|
Status (*XGetWMSizeHints)(Display*, Window, XSizeHints*, long*, Atom);
|
||||||
|
int (*XLookupString)(XKeyEvent*, char*, int, KeySym*, XComposeStatus*);
|
||||||
|
int (*XSetStandardProperties)(Display*, Window, _Xconst char*, _Xconst char*, Pixmap, char**, int, XSizeHints*);
|
||||||
|
void (*XSetWMNormalHints)(Display*, Window, XSizeHints*);
|
||||||
|
void (*XSetWMSizeHints)(Display*, Window, XSizeHints*, Atom);
|
||||||
|
|
||||||
|
#if USE_XRENDER
|
||||||
|
Bool (*XRenderQueryExtension)(Display* dpy, int* event_basep, int* error_basep);
|
||||||
|
|
||||||
|
XRenderPictFormat* (*XRenderFindStandardFormat)(Display* dpy, int format);
|
||||||
|
|
||||||
|
Picture (*XRenderCreatePicture)(Display* dpy, Drawable drawable,
|
||||||
|
_Xconst XRenderPictFormat* format,
|
||||||
|
unsigned long valuemask,
|
||||||
|
_Xconst XRenderPictureAttributes* attributes);
|
||||||
|
|
||||||
|
void (*XRenderFreePicture)(Display* dpy, Picture picture);
|
||||||
|
|
||||||
|
void (*XRenderSetPictureTransform)(Display* dpy, Picture picture,
|
||||||
|
XTransform* transform);
|
||||||
|
|
||||||
|
void (*XRenderComposite)(Display* dpy, int op, Picture src, Picture mask,
|
||||||
|
Picture dst, int src_x, int src_y, int mask_x, int mask_y,
|
||||||
|
int dst_x, int dst_y, unsigned int width,
|
||||||
|
unsigned int height);
|
||||||
|
#endif
|
||||||
|
} xsymtbl;
|
||||||
|
|
||||||
|
#define XClearWindow xsymtbl.XClearWindow
|
||||||
|
#define XCreateIC xsymtbl.XCreateIC
|
||||||
|
#define XFree xsymtbl.XFree
|
||||||
|
#define XFreeCursor xsymtbl.XFreeCursor
|
||||||
|
#define XConfigureWindow xsymtbl.XConfigureWindow
|
||||||
|
#define XCheckTypedWindowEvent xsymtbl.XCheckTypedWindowEvent
|
||||||
|
#define XGetWMNormalHints xsymtbl.XGetWMNormalHints
|
||||||
|
#define XLookupString xsymtbl.XLookupString
|
||||||
|
#define XCreateImage xsymtbl.XCreateImage
|
||||||
|
#define XSetClipMask xsymtbl.XSetClipMask
|
||||||
|
#define XConvertSelection xsymtbl.XConvertSelection
|
||||||
|
#define XGetWindowProperty xsymtbl.XGetWindowProperty
|
||||||
|
#define XSetWMNormalHints xsymtbl.XSetWMNormalHints
|
||||||
|
#define XTranslateCoordinates xsymtbl.XTranslateCoordinates
|
||||||
|
#define XCreateSimpleWindow xsymtbl.XCreateSimpleWindow
|
||||||
|
#define XGetWMSizeHints xsymtbl.XGetWMSizeHints
|
||||||
|
#define XRootWindow xsymtbl.XRootWindow
|
||||||
|
#define XOpenDisplay xsymtbl.XOpenDisplay
|
||||||
|
#define XCopyArea xsymtbl.XCopyArea
|
||||||
|
#define XDeleteProperty xsymtbl.XDeleteProperty
|
||||||
|
#define XDrawLine xsymtbl.XDrawLine
|
||||||
|
#define XSetGraphicsExposures xsymtbl.XSetGraphicsExposures
|
||||||
|
#define XDestroyWindow xsymtbl.XDestroyWindow
|
||||||
|
#define XCloseDisplay xsymtbl.XCloseDisplay
|
||||||
|
#define XSetForeground xsymtbl.XSetForeground
|
||||||
|
#define XGetGeometry xsymtbl.XGetGeometry
|
||||||
|
#define XUnmapWindow xsymtbl.XUnmapWindow
|
||||||
|
#define XSetTransientForHint xsymtbl.XSetTransientForHint
|
||||||
|
#define XSetWMSizeHints xsymtbl.XSetWMSizeHints
|
||||||
|
#define XCreatePixmapCursor xsymtbl.XCreatePixmapCursor
|
||||||
|
#define XFreeGC xsymtbl.XFreeGC
|
||||||
|
#define XNextEvent xsymtbl.XNextEvent
|
||||||
|
#define XSetWMProtocols xsymtbl.XSetWMProtocols
|
||||||
|
#define XDefaultScreen xsymtbl.XDefaultScreen
|
||||||
|
#define XKeysymToString xsymtbl.XKeysymToString
|
||||||
|
#define XMapWindow xsymtbl.XMapWindow
|
||||||
|
#define XPutBackEvent xsymtbl.XPutBackEvent
|
||||||
|
#define XCreateGC xsymtbl.XCreateGC
|
||||||
|
#define XSelectInput xsymtbl.XSelectInput
|
||||||
|
#define XSetInputFocus xsymtbl.XSetInputFocus
|
||||||
|
#define XDestroyIC xsymtbl.XDestroyIC
|
||||||
|
#define XSync xsymtbl.XSync
|
||||||
|
#define XSendEvent xsymtbl.XSendEvent
|
||||||
|
#define XSetICFocus xsymtbl.XSetICFocus
|
||||||
|
#define XWarpPointer xsymtbl.XWarpPointer
|
||||||
|
#define XPutImage xsymtbl.XPutImage
|
||||||
|
#define XFillPolygon xsymtbl.XFillPolygon
|
||||||
|
#define XOpenIM xsymtbl.XOpenIM
|
||||||
|
#define XDefineCursor xsymtbl.XDefineCursor
|
||||||
|
#define XSetWindowBackgroundPixmap xsymtbl.XSetWindowBackgroundPixmap
|
||||||
|
#define XAllocColor xsymtbl.XAllocColor
|
||||||
|
#define XInternAtom xsymtbl.XInternAtom
|
||||||
|
#define XQueryPointer xsymtbl.XQueryPointer
|
||||||
|
#define XGetVisualInfo xsymtbl.XGetVisualInfo
|
||||||
|
#define XVisualIDFromVisual xsymtbl.XVisualIDFromVisual
|
||||||
|
#define XSetLocaleModifiers xsymtbl.XSetLocaleModifiers
|
||||||
|
#define XGetWindowAttributes xsymtbl.XGetWindowAttributes
|
||||||
|
#define XSetStandardProperties xsymtbl.XSetStandardProperties
|
||||||
|
#define XChangeProperty xsymtbl.XChangeProperty
|
||||||
|
#define XAllocSizeHints xsymtbl.XAllocSizeHints
|
||||||
|
#define XCheckWindowEvent xsymtbl.XCheckWindowEvent
|
||||||
|
#define XFreePixmap xsymtbl.XFreePixmap
|
||||||
|
#define XReparentWindow xsymtbl.XReparentWindow
|
||||||
|
#define XCreatePixmap xsymtbl.XCreatePixmap
|
||||||
|
#define XSetClipOrigin xsymtbl.XSetClipOrigin
|
||||||
|
#define XCloseIM xsymtbl.XCloseIM
|
||||||
|
#define XQueryTree xsymtbl.XQueryTree
|
||||||
|
#define XPending xsymtbl.XPending
|
||||||
|
#define XChangeWindowAttributes xsymtbl.XChangeWindowAttributes
|
||||||
|
|
||||||
|
#if USE_XRENDER
|
||||||
|
#define XRenderFindStandardFormat xsymtbl.XRenderFindStandardFormat
|
||||||
|
#define XRenderCreatePicture xsymtbl.XRenderCreatePicture
|
||||||
|
#define XRenderFreePicture xsymtbl.XRenderFreePicture
|
||||||
|
#define XRenderComposite xsymtbl.XRenderComposite
|
||||||
|
#define XRenderQueryExtension xsymtbl.XRenderQueryExtension
|
||||||
|
#define XRenderSetPictureTransform xsymtbl.XRenderSetPictureTransform
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct mwm_hints {
|
typedef struct mwm_hints {
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
unsigned long functions;
|
unsigned long functions;
|
||||||
|
|
@ -9,10 +193,10 @@ typedef struct mwm_hints {
|
||||||
long input_mode;
|
long input_mode;
|
||||||
unsigned long status;
|
unsigned long status;
|
||||||
} mwm_hints_t;
|
} mwm_hints_t;
|
||||||
|
|
||||||
enum mwm_hints_enum {
|
enum mwm_hints_enum {
|
||||||
MWM_HINTS_FUNCTIONS = (1L << 0),
|
MWM_HINTS_FUNCTIONS = (1L << 0),
|
||||||
MWM_HINTS_DECORATIONS = (1L << 1),
|
MWM_HINTS_DECORATIONS = (1L << 1),
|
||||||
|
|
||||||
MWM_FUNC_ALL = (1L << 0),
|
MWM_FUNC_ALL = (1L << 0),
|
||||||
MWM_FUNC_RESIZE = (1L << 1),
|
MWM_FUNC_RESIZE = (1L << 1),
|
||||||
MWM_FUNC_MOVE = (1L << 2),
|
MWM_FUNC_MOVE = (1L << 2),
|
||||||
|
|
@ -129,6 +313,18 @@ static XVisualInfo* get_visual_info(Display* display) {
|
||||||
return XGetVisualInfo(display, VisualIDMask, &xvi, &n);
|
return XGetVisualInfo(display, VisualIDMask, &xvi, &n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
static void detect_dark_theme(MwLL handle) {
|
||||||
|
MwU32 value = 0;
|
||||||
|
MwU32 dark_theme = 0;
|
||||||
|
MwLLDBusPortalGet(&xsymtbl.dbus, &handle->x11.dbus, "org.freedesktop.portal.Settings", "org.freedesktop.appearance", "color-scheme", &value);
|
||||||
|
|
||||||
|
dark_theme = (value == 1) ? 1 : 0;
|
||||||
|
|
||||||
|
MwLLDispatch(handle, dark_theme, &dark_theme);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
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;
|
MwLL r;
|
||||||
Window p;
|
Window p;
|
||||||
|
|
@ -159,6 +355,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
r->x11.toplevel = 0;
|
r->x11.toplevel = 0;
|
||||||
}
|
}
|
||||||
r->x11.window = XCreateSimpleWindow(r->x11.display, p, px, py, width, height, 0, 0, WhitePixel(r->x11.display, DefaultScreen(r->x11.display)));
|
r->x11.window = XCreateSimpleWindow(r->x11.display, p, px, py, width, height, 0, 0, WhitePixel(r->x11.display, DefaultScreen(r->x11.display)));
|
||||||
|
|
||||||
sh.flags = PWinGravity;
|
sh.flags = PWinGravity;
|
||||||
sh.win_gravity = StaticGravity;
|
sh.win_gravity = StaticGravity;
|
||||||
XSetWMNormalHints(r->x11.display, r->x11.window, &sh);
|
XSetWMNormalHints(r->x11.display, r->x11.window, &sh);
|
||||||
|
|
@ -187,6 +384,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
|
|
||||||
XFree(xvi);
|
XFree(xvi);
|
||||||
|
|
||||||
|
#ifdef DO_XIM
|
||||||
XSetLocaleModifiers("");
|
XSetLocaleModifiers("");
|
||||||
if((r->x11.xim = XOpenIM(r->x11.display, 0, 0, 0)) == NULL) {
|
if((r->x11.xim = XOpenIM(r->x11.display, 0, 0, 0)) == NULL) {
|
||||||
XSetLocaleModifiers("@im=none");
|
XSetLocaleModifiers("@im=none");
|
||||||
|
|
@ -199,6 +397,7 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
XNFocusWindow, r->x11.window,
|
XNFocusWindow, r->x11.window,
|
||||||
NULL);
|
NULL);
|
||||||
XSetICFocus(r->x11.xic);
|
XSetICFocus(r->x11.xic);
|
||||||
|
#endif
|
||||||
|
|
||||||
r->common.copy_buffer = 1;
|
r->common.copy_buffer = 1;
|
||||||
r->common.type = MwLLBackendX11;
|
r->common.type = MwLLBackendX11;
|
||||||
|
|
@ -211,8 +410,17 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
|
|
||||||
r->x11.colormap = DefaultColormap(r->x11.display, XDefaultScreen(r->x11.display));
|
r->x11.colormap = DefaultColormap(r->x11.display, XDefaultScreen(r->x11.display));
|
||||||
r->x11.wm_delete = XInternAtom(r->x11.display, "WM_DELETE_WINDOW", False);
|
r->x11.wm_delete = XInternAtom(r->x11.display, "WM_DELETE_WINDOW", False);
|
||||||
|
r->x11.wm_protocols = XInternAtom(r->x11.display, "WM_PROTOCOLS", False);
|
||||||
XSetWMProtocols(r->x11.display, r->x11.window, &r->x11.wm_delete, 1);
|
XSetWMProtocols(r->x11.display, r->x11.window, &r->x11.wm_delete, 1);
|
||||||
|
|
||||||
|
r->x11.utf8_string = XInternAtom(r->x11.display, "UTF8_STRING", False);
|
||||||
|
r->x11.compound_text = XInternAtom(r->x11.display, "COMPOUND_TEXT", False);
|
||||||
|
r->x11.text = XInternAtom(r->x11.display, "TEXT", False);
|
||||||
|
r->x11.clipboard = XInternAtom(r->x11.display, "CLIPBOARD", False);
|
||||||
|
r->x11.selection = XInternAtom(r->x11.display, "_MILSKO_SELECTION_", False);
|
||||||
|
|
||||||
|
r->x11.clipboard_pending = 0;
|
||||||
|
|
||||||
r->x11.gc = XCreateGC(r->x11.display, r->x11.window, 0, NULL);
|
r->x11.gc = XCreateGC(r->x11.display, r->x11.window, 0, NULL);
|
||||||
|
|
||||||
create_pixmap(r);
|
create_pixmap(r);
|
||||||
|
|
@ -238,14 +446,24 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
memset(&r->x11.dbus, 0, sizeof(r->x11.dbus));
|
||||||
|
if(!parent && xsymtbl.has_dbus) {
|
||||||
|
xsymtbl.has_dbus = MwLLDBusNewContext(&xsymtbl.dbus, &r->x11.dbus);
|
||||||
|
r->x11.dark_theme_detection = MwTRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLDestroyImpl(MwLL handle) {
|
static void MwLLDestroyImpl(MwLL handle) {
|
||||||
MwLLDestroyCommon(handle);
|
MwLLDestroyCommon(handle);
|
||||||
|
|
||||||
|
#ifdef DO_XIM
|
||||||
if(handle->x11.xic) XDestroyIC(handle->x11.xic);
|
if(handle->x11.xic) XDestroyIC(handle->x11.xic);
|
||||||
if(handle->x11.xim) XCloseIM(handle->x11.xim);
|
if(handle->x11.xim) XCloseIM(handle->x11.xim);
|
||||||
|
#endif
|
||||||
|
|
||||||
destroy_pixmap(handle);
|
destroy_pixmap(handle);
|
||||||
XFreeGC(handle->x11.display, handle->x11.gc);
|
XFreeGC(handle->x11.display, handle->x11.gc);
|
||||||
|
|
@ -256,6 +474,12 @@ static void MwLLDestroyImpl(MwLL handle) {
|
||||||
|
|
||||||
if(handle->x11.toplevel) XCloseDisplay(handle->x11.display);
|
if(handle->x11.toplevel) XCloseDisplay(handle->x11.display);
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
if(!xsymtbl.has_dbus) {
|
||||||
|
MwLLDBusFreeContext(&xsymtbl.dbus, &handle->x11.dbus);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -265,6 +489,8 @@ static void MwLLBeginDrawImpl(MwLL handle) {
|
||||||
|
|
||||||
static void MwLLEndDrawImpl(MwLL handle) {
|
static void MwLLEndDrawImpl(MwLL handle) {
|
||||||
(void)handle;
|
(void)handle;
|
||||||
|
|
||||||
|
XClearWindow(handle->x11.display, handle->x11.window);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
|
||||||
|
|
@ -411,7 +637,22 @@ static void MwLLFreeColorImpl(MwLLColor color) {
|
||||||
|
|
||||||
static int MwLLPendingImpl(MwLL handle) {
|
static int MwLLPendingImpl(MwLL handle) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
if(XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, ClientMessage, &ev) || XCheckWindowEvent(handle->x11.display, handle->x11.window, mask, &ev)) {
|
|
||||||
|
if(handle->x11.dark_theme_detection) {
|
||||||
|
handle->x11.dark_theme_detection = MwFALSE;
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
if(xsymtbl.has_dbus) {
|
||||||
|
detect_dark_theme(handle);
|
||||||
|
MwLLDispatch(handle, draw, NULL);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
if(handle->x11.clipboard_pending && (MwTimeGetTick() - handle->x11.clipboard_time) >= ClipboardTimeout) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, ClientMessage, &ev) || XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, SelectionNotify, &ev) || XCheckWindowEvent(handle->x11.display, handle->x11.window, mask, &ev)) {
|
||||||
XPutBackEvent(handle->x11.display, &ev);
|
XPutBackEvent(handle->x11.display, &ev);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
@ -420,44 +661,71 @@ static int MwLLPendingImpl(MwLL handle) {
|
||||||
|
|
||||||
static void MwLLNextEventImpl(MwLL handle) {
|
static void MwLLNextEventImpl(MwLL handle) {
|
||||||
XEvent ev;
|
XEvent ev;
|
||||||
while(XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, ClientMessage, &ev) || XCheckWindowEvent(handle->x11.display, handle->x11.window, mask, &ev)) {
|
|
||||||
|
if(handle->x11.clipboard_pending && (MwTimeGetTick() - handle->x11.clipboard_time) >= ClipboardTimeout) {
|
||||||
|
Atom a = handle->x11.selection;
|
||||||
|
|
||||||
|
handle->x11.clipboard_pending++;
|
||||||
|
handle->x11.clipboard_time = MwTimeGetTick();
|
||||||
|
|
||||||
|
switch(handle->x11.clipboard_pending) {
|
||||||
|
case 2:
|
||||||
|
a = handle->x11.compound_text;
|
||||||
|
break;
|
||||||
|
case 3:
|
||||||
|
a = handle->x11.text;
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
a = XA_STRING;
|
||||||
|
break;
|
||||||
|
case 5:
|
||||||
|
handle->x11.clipboard_pending = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(a != handle->x11.selection) {
|
||||||
|
XConvertSelection(handle->x11.display, handle->x11.clipboard, a, handle->x11.selection, handle->x11.window, CurrentTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while(XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, ClientMessage, &ev) || XCheckTypedWindowEvent(handle->x11.display, handle->x11.window, SelectionNotify, &ev) || XCheckWindowEvent(handle->x11.display, handle->x11.window, mask, &ev)) {
|
||||||
int render = 0;
|
int render = 0;
|
||||||
if(ev.type == Expose) {
|
if(ev.type == Expose) {
|
||||||
handle->x11.force_render = 0;
|
handle->x11.force_render = 0;
|
||||||
render = 1;
|
render = 1;
|
||||||
} else if(ev.type == ButtonPress) {
|
} else if(ev.type == ButtonPress) {
|
||||||
MwLLMouse p;
|
MwMouse p;
|
||||||
p.point.x = ev.xbutton.x;
|
p.point.x = ev.xbutton.x;
|
||||||
p.point.y = ev.xbutton.y;
|
p.point.y = ev.xbutton.y;
|
||||||
if(ev.xbutton.button == Button1) {
|
if(ev.xbutton.button == Button1) {
|
||||||
p.button = MwLLMouseLeft;
|
p.button = MwMOUSE_LEFT;
|
||||||
} else if(ev.xbutton.button == Button2) {
|
} else if(ev.xbutton.button == Button2) {
|
||||||
p.button = MwLLMouseMiddle;
|
p.button = MwMOUSE_MIDDLE;
|
||||||
} else if(ev.xbutton.button == Button3) {
|
} else if(ev.xbutton.button == Button3) {
|
||||||
p.button = MwLLMouseRight;
|
p.button = MwMOUSE_RIGHT;
|
||||||
} else if(ev.xbutton.button == Button4) {
|
} else if(ev.xbutton.button == Button4) {
|
||||||
p.button = MwLLMouseWheelUp;
|
p.button = MwMOUSE_WHEELUP;
|
||||||
} else if(ev.xbutton.button == Button5) {
|
} else if(ev.xbutton.button == Button5) {
|
||||||
p.button = MwLLMouseWheelDown;
|
p.button = MwMOUSE_WHEELDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
XSetInputFocus(handle->x11.display, handle->x11.window, RevertToNone, CurrentTime);
|
XSetInputFocus(handle->x11.display, handle->x11.window, RevertToNone, CurrentTime);
|
||||||
|
|
||||||
MwLLDispatch(handle, down, &p);
|
MwLLDispatch(handle, down, &p);
|
||||||
} else if(ev.type == ButtonRelease) {
|
} else if(ev.type == ButtonRelease) {
|
||||||
MwLLMouse p;
|
MwMouse p;
|
||||||
p.point.x = ev.xbutton.x;
|
p.point.x = ev.xbutton.x;
|
||||||
p.point.y = ev.xbutton.y;
|
p.point.y = ev.xbutton.y;
|
||||||
if(ev.xbutton.button == Button1) {
|
if(ev.xbutton.button == Button1) {
|
||||||
p.button = MwLLMouseLeft;
|
p.button = MwMOUSE_LEFT;
|
||||||
} else if(ev.xbutton.button == Button2) {
|
} else if(ev.xbutton.button == Button2) {
|
||||||
p.button = MwLLMouseMiddle;
|
p.button = MwMOUSE_MIDDLE;
|
||||||
} else if(ev.xbutton.button == Button3) {
|
} else if(ev.xbutton.button == Button3) {
|
||||||
p.button = MwLLMouseRight;
|
p.button = MwMOUSE_RIGHT;
|
||||||
} else if(ev.xbutton.button == Button4) {
|
} else if(ev.xbutton.button == Button4) {
|
||||||
p.button = MwLLMouseWheelUp;
|
p.button = MwMOUSE_WHEELUP;
|
||||||
} else if(ev.xbutton.button == Button5) {
|
} else if(ev.xbutton.button == Button5) {
|
||||||
p.button = MwLLMouseWheelDown;
|
p.button = MwMOUSE_WHEELDOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLDispatch(handle, up, &p);
|
MwLLDispatch(handle, up, &p);
|
||||||
|
|
@ -471,7 +739,7 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
handle->x11.width = ev.xconfigure.width;
|
handle->x11.width = ev.xconfigure.width;
|
||||||
handle->x11.height = ev.xconfigure.height;
|
handle->x11.height = ev.xconfigure.height;
|
||||||
} else if(ev.type == ClientMessage) {
|
} else if(ev.type == ClientMessage) {
|
||||||
if(ev.xclient.data.l[0] == (long)handle->x11.wm_delete) {
|
if(ev.xclient.message_type == handle->x11.wm_protocols && ev.xclient.data.l[0] == (long)handle->x11.wm_delete) {
|
||||||
MwLLDispatch(handle, close, NULL);
|
MwLLDispatch(handle, close, NULL);
|
||||||
}
|
}
|
||||||
} else if(ev.type == FocusIn) {
|
} else if(ev.type == FocusIn) {
|
||||||
|
|
@ -512,8 +780,7 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
strcpy(str, s);
|
strcpy(str, s);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* HACK: this is bad, you can guess why */
|
if(MwStringIsKeyUTF8(sym)) {
|
||||||
if(strlen(str) == 1) {
|
|
||||||
char s = str[0];
|
char s = str[0];
|
||||||
|
|
||||||
if(ev.xkey.state & (ShiftMask | LockMask) && !(ev.xkey.state & (ControlMask | Mod1Mask))) {
|
if(ev.xkey.state & (ShiftMask | LockMask) && !(ev.xkey.state & (ControlMask | Mod1Mask))) {
|
||||||
|
|
@ -559,6 +826,49 @@ static void MwLLNextEventImpl(MwLL handle) {
|
||||||
MwLLDispatch(handle, key_released, &n);
|
MwLLDispatch(handle, key_released, &n);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if(ev.type == SelectionNotify) {
|
||||||
|
handle->x11.clipboard_pending = 0;
|
||||||
|
|
||||||
|
if(ev.xselection.property != None) {
|
||||||
|
Atom type;
|
||||||
|
int format;
|
||||||
|
unsigned long nitems, after, size;
|
||||||
|
unsigned char* pdat;
|
||||||
|
int ret = XGetWindowProperty(handle->x11.display, handle->x11.window, handle->x11.selection, 0, 0, False, AnyPropertyType, &type, &format, &nitems, &after, &pdat);
|
||||||
|
|
||||||
|
if(pdat != NULL) XFree(pdat);
|
||||||
|
|
||||||
|
size = after;
|
||||||
|
|
||||||
|
if(ret == Success && type != None && format == 8) {
|
||||||
|
char* buf = malloc(size + 1);
|
||||||
|
int offset;
|
||||||
|
|
||||||
|
for(offset = 0; after > 0; offset += nitems) {
|
||||||
|
ret = XGetWindowProperty(handle->x11.display, handle->x11.window, handle->x11.selection, offset / 4, after / 4 + 1, False, AnyPropertyType, &type, &format, &nitems, &after, &pdat);
|
||||||
|
|
||||||
|
if(ret != Success) {
|
||||||
|
free(buf);
|
||||||
|
buf = NULL;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
memcpy(buf + offset, pdat, nitems);
|
||||||
|
|
||||||
|
XFree(pdat);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(buf != NULL) {
|
||||||
|
buf[size] = 0;
|
||||||
|
|
||||||
|
MwLLDispatch(handle, clipboard, buf);
|
||||||
|
|
||||||
|
free(buf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
XDeleteProperty(handle->x11.display, handle->x11.window, handle->x11.selection);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if(render) {
|
if(render) {
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
@ -598,7 +908,9 @@ static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int wid
|
||||||
r->x11.handle = handle;
|
r->x11.handle = handle;
|
||||||
|
|
||||||
#ifdef USE_XRENDER
|
#ifdef USE_XRENDER
|
||||||
|
if(xsymtbl.has_xrender) {
|
||||||
r->x11.use_xrender = XRenderQueryExtension(handle->x11.display, &evbase, &erbase) ? 1 : 0;
|
r->x11.use_xrender = XRenderQueryExtension(handle->x11.display, &evbase, &erbase) ? 1 : 0;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
r->x11.image = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), r->x11.depth, ZPixmap, 0, NULL, width, height, 32, 0);
|
r->x11.image = XCreateImage(handle->x11.display, DefaultVisual(handle->x11.display, DefaultScreen(handle->x11.display)), r->x11.depth, ZPixmap, 0, NULL, width, height, 32, 0);
|
||||||
|
|
@ -649,7 +961,7 @@ static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
|
||||||
if(rect->width == 0 || rect->height == 0 || pixmap->common.width == 0 || pixmap->common.height == 0) return;
|
if(rect->width <= 0 || rect->height <= 0 || pixmap->common.width <= 0 || pixmap->common.height <= 0) return;
|
||||||
#ifdef USE_XRENDER
|
#ifdef USE_XRENDER
|
||||||
if(pixmap->x11.image != NULL && pixmap->x11.use_xrender) {
|
if(pixmap->x11.image != NULL && pixmap->x11.use_xrender) {
|
||||||
Pixmap px = XCreatePixmap(handle->x11.display, handle->x11.window, pixmap->common.width, pixmap->common.height, pixmap->x11.depth);
|
Pixmap px = XCreatePixmap(handle->x11.display, handle->x11.window, pixmap->common.width, pixmap->common.height, pixmap->x11.depth);
|
||||||
|
|
@ -807,8 +1119,8 @@ Cursor MwLLX11CreateCursor(Display* display, MwCursor* image, MwCursor* mask) {
|
||||||
XColor cfg, cbg;
|
XColor cfg, cbg;
|
||||||
|
|
||||||
xs = -mask->x + image->x;
|
xs = -mask->x + image->x;
|
||||||
ys = MwCursorDataHeight + mask->y;
|
ys = mask->height + mask->y;
|
||||||
ys = MwCursorDataHeight + image->y - ys;
|
ys = image->height + image->y - ys;
|
||||||
|
|
||||||
memset(cimage->data, 0, cimage->bytes_per_line * cimage->height);
|
memset(cimage->data, 0, cimage->bytes_per_line * cimage->height);
|
||||||
memset(cmask->data, 0, cmask->bytes_per_line * cmask->height);
|
memset(cmask->data, 0, cmask->bytes_per_line * cmask->height);
|
||||||
|
|
@ -845,7 +1157,7 @@ Cursor MwLLX11CreateCursor(Display* display, MwCursor* image, MwCursor* mask) {
|
||||||
XPutImage(display, pimage, imagegc, cimage, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
XPutImage(display, pimage, imagegc, cimage, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
||||||
XPutImage(display, pmask, maskgc, cmask, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
XPutImage(display, pmask, maskgc, cmask, 0, 0, 0, 0, MwCursorDataHeight, MwCursorDataHeight);
|
||||||
|
|
||||||
cur = XCreatePixmapCursor(display, pimage, pmask, &cfg, &cbg, xs, ys);
|
cur = XCreatePixmapCursor(display, pimage, pmask, &cfg, &cbg, xs - image->x, ys + (MwCursorDataHeight + image->y));
|
||||||
|
|
||||||
XFreePixmap(display, pimage);
|
XFreePixmap(display, pimage);
|
||||||
XFreePixmap(display, pmask);
|
XFreePixmap(display, pmask);
|
||||||
|
|
@ -949,52 +1261,23 @@ static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
|
static void MwLLSetClipboardImpl(MwLL handle, const char* text, int clipboard_type) {
|
||||||
/* TODO */
|
/* TODO */
|
||||||
|
|
||||||
(void)handle;
|
(void)handle;
|
||||||
(void)text;
|
(void)text;
|
||||||
|
(void)clipboard_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
static char* MwLLGetClipboardImpl(MwLL handle) {
|
static void MwLLGetClipboardImpl(MwLL handle, int clipboard_type) {
|
||||||
Atom clip, target, prop;
|
(void)clipboard_type;
|
||||||
XEvent ev;
|
|
||||||
XEvent* queue = NULL;
|
|
||||||
char* r = NULL;
|
|
||||||
|
|
||||||
clip = XInternAtom(handle->x11.display, "CLIPBOARD", 0);
|
if(handle->x11.clipboard_pending) return;
|
||||||
target = XA_STRING;
|
|
||||||
prop = XInternAtom(handle->x11.display, "XSEL_DATA", 0);
|
|
||||||
|
|
||||||
XConvertSelection(handle->x11.display, clip, target, prop, handle->x11.window, CurrentTime);
|
XConvertSelection(handle->x11.display, handle->x11.clipboard, handle->x11.utf8_string, handle->x11.selection, handle->x11.window, CurrentTime);
|
||||||
|
|
||||||
while(1) {
|
handle->x11.clipboard_pending = 1;
|
||||||
XNextEvent(handle->x11.display, &ev);
|
handle->x11.clipboard_time = MwTimeGetTick();
|
||||||
if(ev.type == SelectionNotify) {
|
|
||||||
if(ev.xselection.selection == clip && ev.xselection.property != 0) {
|
|
||||||
Atom t;
|
|
||||||
unsigned long size, N;
|
|
||||||
char* data;
|
|
||||||
int format;
|
|
||||||
|
|
||||||
XGetWindowProperty(ev.xselection.display, ev.xselection.requestor, ev.xselection.property, 0, (~0L), 0, AnyPropertyType, &t, &format, &size, &N, (unsigned char**)&data);
|
|
||||||
if(t == target) {
|
|
||||||
r = MwStringDuplicate(data);
|
|
||||||
XFree(data);
|
|
||||||
}
|
|
||||||
XDeleteProperty(ev.xselection.display, ev.xselection.requestor, ev.xselection.property);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(arrlen(queue) > 0) {
|
|
||||||
XPutBackEvent(handle->x11.display, &queue[0]);
|
|
||||||
arrdel(queue, 0);
|
|
||||||
}
|
|
||||||
arrfree(queue);
|
|
||||||
|
|
||||||
return r;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
static void MwLLMakeToolWindowImpl(MwLL handle) {
|
||||||
|
|
@ -1036,7 +1319,128 @@ static void MwLLEndStateChangeImpl(MwLL handle) {
|
||||||
MwLLShow(handle, 1);
|
MwLLShow(handle, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MwLLSetDarkThemeImpl(MwLL handle, int toggle) {
|
||||||
|
(void)handle;
|
||||||
|
(void)toggle;
|
||||||
|
}
|
||||||
|
|
||||||
static int MwLLX11CallInitImpl(void) {
|
static int MwLLX11CallInitImpl(void) {
|
||||||
|
MwBool loadX11 = MwFALSE;
|
||||||
|
if(getenv("MILSKO_BACKEND")) {
|
||||||
|
loadX11 |=
|
||||||
|
(strcmp(getenv("MILSKO_BACKEND"), "x11") == 0);
|
||||||
|
} else if(getenv("DISPLAY")) {
|
||||||
|
loadX11 |= (getenv("DISPLAY") != NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!loadX11) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef __APPLE__
|
||||||
|
xsymtbl.lib_xlib = MwDynamicOpen("libX11.dylib");
|
||||||
|
#else
|
||||||
|
xsymtbl.lib_xlib = MwDynamicOpen("libX11.so");
|
||||||
|
#endif
|
||||||
|
if(!xsymtbl.lib_xlib) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
xsymtbl.has_xrender = MwFALSE;
|
||||||
|
#if USE_XRENDER
|
||||||
|
xsymtbl.lib_xrender = MwDynamicOpen("libXrender.so");
|
||||||
|
if(xsymtbl.lib_xrender) {
|
||||||
|
xsymtbl.has_xrender = MwTRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define X11_FUNC_LOAD(x) x = MwDynamicSymbol(xsymtbl.lib_xlib, #x)
|
||||||
|
|
||||||
|
X11_FUNC_LOAD(XClearWindow);
|
||||||
|
X11_FUNC_LOAD(XCreateImage);
|
||||||
|
X11_FUNC_LOAD(XOpenDisplay);
|
||||||
|
X11_FUNC_LOAD(XKeysymToString);
|
||||||
|
X11_FUNC_LOAD(XInternAtom);
|
||||||
|
X11_FUNC_LOAD(XCreatePixmapCursor);
|
||||||
|
X11_FUNC_LOAD(XCreateGC);
|
||||||
|
X11_FUNC_LOAD(XCreatePixmap);
|
||||||
|
X11_FUNC_LOAD(XCreateSimpleWindow);
|
||||||
|
X11_FUNC_LOAD(XVisualIDFromVisual);
|
||||||
|
X11_FUNC_LOAD(XRootWindow);
|
||||||
|
X11_FUNC_LOAD(XSetWMProtocols);
|
||||||
|
X11_FUNC_LOAD(XSetTransientForHint);
|
||||||
|
X11_FUNC_LOAD(XAllocColor);
|
||||||
|
X11_FUNC_LOAD(XChangeProperty);
|
||||||
|
X11_FUNC_LOAD(XChangeWindowAttributes);
|
||||||
|
X11_FUNC_LOAD(XCheckTypedWindowEvent);
|
||||||
|
X11_FUNC_LOAD(XCheckWindowEvent);
|
||||||
|
X11_FUNC_LOAD(XCloseDisplay);
|
||||||
|
X11_FUNC_LOAD(XConfigureWindow);
|
||||||
|
X11_FUNC_LOAD(XConvertSelection);
|
||||||
|
X11_FUNC_LOAD(XCopyArea);
|
||||||
|
X11_FUNC_LOAD(XDefaultScreen);
|
||||||
|
X11_FUNC_LOAD(XDefineCursor);
|
||||||
|
X11_FUNC_LOAD(XDeleteProperty);
|
||||||
|
X11_FUNC_LOAD(XDestroyWindow);
|
||||||
|
X11_FUNC_LOAD(XDrawLine);
|
||||||
|
X11_FUNC_LOAD(XFillPolygon);
|
||||||
|
X11_FUNC_LOAD(XFree);
|
||||||
|
X11_FUNC_LOAD(XFreeCursor);
|
||||||
|
X11_FUNC_LOAD(XFreeGC);
|
||||||
|
X11_FUNC_LOAD(XFreePixmap);
|
||||||
|
X11_FUNC_LOAD(XGetGeometry);
|
||||||
|
X11_FUNC_LOAD(XGetWindowProperty);
|
||||||
|
X11_FUNC_LOAD(XGetWindowAttributes);
|
||||||
|
X11_FUNC_LOAD(XMapWindow);
|
||||||
|
X11_FUNC_LOAD(XNextEvent);
|
||||||
|
X11_FUNC_LOAD(XPending);
|
||||||
|
X11_FUNC_LOAD(XPutBackEvent);
|
||||||
|
X11_FUNC_LOAD(XPutImage);
|
||||||
|
X11_FUNC_LOAD(XQueryPointer);
|
||||||
|
X11_FUNC_LOAD(XQueryTree);
|
||||||
|
X11_FUNC_LOAD(XReparentWindow);
|
||||||
|
X11_FUNC_LOAD(XSelectInput);
|
||||||
|
X11_FUNC_LOAD(XSendEvent);
|
||||||
|
X11_FUNC_LOAD(XSetClipMask);
|
||||||
|
X11_FUNC_LOAD(XSetClipOrigin);
|
||||||
|
X11_FUNC_LOAD(XSetForeground);
|
||||||
|
X11_FUNC_LOAD(XSetGraphicsExposures);
|
||||||
|
X11_FUNC_LOAD(XSetInputFocus);
|
||||||
|
X11_FUNC_LOAD(XSetWindowBackgroundPixmap);
|
||||||
|
X11_FUNC_LOAD(XSync);
|
||||||
|
X11_FUNC_LOAD(XTranslateCoordinates);
|
||||||
|
X11_FUNC_LOAD(XUnmapWindow);
|
||||||
|
X11_FUNC_LOAD(XWarpPointer);
|
||||||
|
X11_FUNC_LOAD(XSetLocaleModifiers);
|
||||||
|
X11_FUNC_LOAD(XOpenIM);
|
||||||
|
X11_FUNC_LOAD(XCloseIM);
|
||||||
|
X11_FUNC_LOAD(XCreateIC);
|
||||||
|
X11_FUNC_LOAD(XDestroyIC);
|
||||||
|
X11_FUNC_LOAD(XSetICFocus);
|
||||||
|
|
||||||
|
X11_FUNC_LOAD(XAllocSizeHints);
|
||||||
|
X11_FUNC_LOAD(XGetVisualInfo);
|
||||||
|
X11_FUNC_LOAD(XGetWMNormalHints);
|
||||||
|
X11_FUNC_LOAD(XGetWMSizeHints);
|
||||||
|
X11_FUNC_LOAD(XLookupString);
|
||||||
|
X11_FUNC_LOAD(XSetStandardProperties);
|
||||||
|
X11_FUNC_LOAD(XSetWMNormalHints);
|
||||||
|
X11_FUNC_LOAD(XSetWMSizeHints);
|
||||||
|
|
||||||
|
#if USE_XRENDER
|
||||||
|
#define XRENDER_FUNC_LOAD(x) x = MwDynamicSymbol(xsymtbl.lib_xrender, #x);
|
||||||
|
|
||||||
|
XRENDER_FUNC_LOAD(XRenderQueryExtension)
|
||||||
|
XRENDER_FUNC_LOAD(XRenderFindStandardFormat)
|
||||||
|
XRENDER_FUNC_LOAD(XRenderCreatePicture)
|
||||||
|
XRENDER_FUNC_LOAD(XRenderFreePicture)
|
||||||
|
XRENDER_FUNC_LOAD(XRenderSetPictureTransform)
|
||||||
|
XRENDER_FUNC_LOAD(XRenderComposite)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
xsymtbl.has_dbus = MwLLDBusFuncSetup(&xsymtbl.dbus);
|
||||||
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
367
src/core.c
367
src/core.c
|
|
@ -2,37 +2,73 @@
|
||||||
|
|
||||||
#include "../external/stb_ds.h"
|
#include "../external/stb_ds.h"
|
||||||
|
|
||||||
|
#ifdef USE_COCOA
|
||||||
|
#define PERIODIC
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DRAW(handle) \
|
||||||
|
{ \
|
||||||
|
MwLLBeginDraw(handle->lowlevel); \
|
||||||
|
\
|
||||||
|
handle->bgcolor = NULL; \
|
||||||
|
MwDispatch(handle, draw); \
|
||||||
|
if(handle->draw_inject != NULL) handle->draw_inject(handle); \
|
||||||
|
MwDispatchUserHandler(handle, MwNdrawHandler, NULL); \
|
||||||
|
\
|
||||||
|
MwLLEndDraw(handle->lowlevel); \
|
||||||
|
}
|
||||||
|
|
||||||
static void lldrawhandler(MwLL handle, void* data) {
|
static void lldrawhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
|
#ifdef PERIODIC
|
||||||
|
MwWidget top;
|
||||||
|
#endif
|
||||||
|
|
||||||
(void)data;
|
(void)data;
|
||||||
MwLLBeginDraw(handle);
|
|
||||||
|
|
||||||
h->bgcolor = NULL;
|
#ifdef PERIODIC
|
||||||
MwDispatch(h, draw);
|
top = h;
|
||||||
if(h->draw_inject != NULL) h->draw_inject(h);
|
while(top != NULL) {
|
||||||
MwDispatchUserHandler(h, MwNdrawHandler, NULL);
|
if(top->top_step) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
MwLLEndDraw(handle);
|
top = top->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(top == NULL) {
|
||||||
|
DRAW(h); /* fallback */
|
||||||
|
} else {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < arrlen(top->draw_queue); i++) {
|
||||||
|
if(top->draw_queue[i] == h) break;
|
||||||
|
}
|
||||||
|
if(i == arrlen(top->draw_queue)) arrput(top->draw_queue, h);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
DRAW(h);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lluphandler(MwLL handle, void* data) {
|
static void lluphandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
MwLLMouse* p = data;
|
MwMouse* p = data;
|
||||||
|
|
||||||
if(p->button == MwLLMouseLeft) h->pressed = 0;
|
if(p->button == MwMOUSE_LEFT) h->pressed = 0;
|
||||||
h->mouse_point.x = p->point.x;
|
h->mouse_point.x = p->point.x;
|
||||||
h->mouse_point.y = p->point.y;
|
h->mouse_point.y = p->point.y;
|
||||||
|
|
||||||
if(p->button == MwLLMouseLeft) MwDispatch(h, click);
|
if(p->button == MwMOUSE_LEFT) MwDispatch(h, click);
|
||||||
MwDispatch3(h, mouse_up, data);
|
MwDispatch3(h, mouse_up, data);
|
||||||
MwDispatchUserHandler(h, MwNmouseUpHandler, data);
|
MwDispatchUserHandler(h, MwNmouseUpHandler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void lldownhandler(MwLL handle, void* data) {
|
static void lldownhandler(MwLL handle, void* data) {
|
||||||
MwWidget h = (MwWidget)handle->common.user;
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
MwLLMouse* p = data;
|
MwMouse* p = data;
|
||||||
if(p->button == MwLLMouseLeft) h->pressed = 1;
|
|
||||||
|
if(p->button == MwMOUSE_LEFT) h->pressed = 1;
|
||||||
h->mouse_point.x = p->point.x;
|
h->mouse_point.x = p->point.x;
|
||||||
h->mouse_point.y = p->point.y;
|
h->mouse_point.y = p->point.y;
|
||||||
|
|
||||||
|
|
@ -49,6 +85,7 @@ static void llresizehandler(MwLL handle, void* data) {
|
||||||
MwDispatchUserHandler(h, MwNresizeHandler, NULL);
|
MwDispatchUserHandler(h, MwNresizeHandler, NULL);
|
||||||
for(i = 0; i < arrlen(h->children); i++) {
|
for(i = 0; i < arrlen(h->children); i++) {
|
||||||
MwDispatch(h->children[i], parent_resize);
|
MwDispatch(h->children[i], parent_resize);
|
||||||
|
MwDispatch(h->children[i], draw);
|
||||||
}
|
}
|
||||||
MwDispatch(h, resize);
|
MwDispatch(h, resize);
|
||||||
}
|
}
|
||||||
|
|
@ -107,6 +144,39 @@ static void llfocusouthandler(MwLL handle, void* data) {
|
||||||
MwDispatchUserHandler(h, MwNfocusOutHandler, data);
|
MwDispatchUserHandler(h, MwNfocusOutHandler, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void llclipboardhandler(MwLL handle, void* data) {
|
||||||
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
|
|
||||||
|
MwDispatch3(h, clipboard, data);
|
||||||
|
MwDispatchUserHandler(h, MwNclipboardHandler, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* if both of them are true
|
||||||
|
* 1. widget class is not NULL
|
||||||
|
* 2. parent is NULL
|
||||||
|
* or parent's widget class is NULL
|
||||||
|
*
|
||||||
|
* most likely this widget is first *visible* widget
|
||||||
|
*
|
||||||
|
* this macro is not used anywhere else - we could expose it if we have to
|
||||||
|
*
|
||||||
|
* (nishi)
|
||||||
|
*/
|
||||||
|
#define IsFirstVisible(handle) ((handle)->widget_class != NULL && ((handle)->parent == NULL || (handle)->parent->widget_class == NULL))
|
||||||
|
|
||||||
|
static void lldarkthemehandler(MwLL handle, void* data) {
|
||||||
|
MwWidget h = (MwWidget)handle->common.user;
|
||||||
|
int* ptr = data;
|
||||||
|
|
||||||
|
if(IsFirstVisible(h)) {
|
||||||
|
MwVaApply(h,
|
||||||
|
MwNdarkTheme, *ptr,
|
||||||
|
NULL);
|
||||||
|
|
||||||
|
MwDispatchUserHandler(h, MwNdarkThemeHandler, data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
|
||||||
MwWidget h = malloc(sizeof(*h));
|
MwWidget h = malloc(sizeof(*h));
|
||||||
|
|
||||||
|
|
@ -114,6 +184,7 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||||
|
|
||||||
h->parent = parent;
|
h->parent = parent;
|
||||||
h->children = NULL;
|
h->children = NULL;
|
||||||
|
|
||||||
if(widget_class != NULL) {
|
if(widget_class != NULL) {
|
||||||
if((h->lowlevel = MwLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height)) == NULL) {
|
if((h->lowlevel = MwLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height)) == NULL) {
|
||||||
free(h->name);
|
free(h->name);
|
||||||
|
|
@ -131,11 +202,18 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||||
h->draw_inject = NULL;
|
h->draw_inject = NULL;
|
||||||
h->tick_list = NULL;
|
h->tick_list = NULL;
|
||||||
h->destroyed = 0;
|
h->destroyed = 0;
|
||||||
h->dark_theme = 0;
|
|
||||||
h->bgcolor = NULL;
|
h->bgcolor = NULL;
|
||||||
|
h->berserk = 0;
|
||||||
|
|
||||||
|
h->top_step = 0;
|
||||||
|
h->draw_queue = NULL;
|
||||||
|
|
||||||
if(parent == NULL) arrput(h->tick_list, h);
|
if(parent == NULL) arrput(h->tick_list, h);
|
||||||
|
|
||||||
|
#ifdef PERIODIC
|
||||||
|
if(parent == NULL) h->top_step = 1;
|
||||||
|
#endif
|
||||||
|
|
||||||
if(h->lowlevel != NULL) {
|
if(h->lowlevel != NULL) {
|
||||||
h->lowlevel->common.user = h;
|
h->lowlevel->common.user = h;
|
||||||
h->lowlevel->common.handler->draw = lldrawhandler;
|
h->lowlevel->common.handler->draw = lldrawhandler;
|
||||||
|
|
@ -148,6 +226,8 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||||
h->lowlevel->common.handler->key_released = llkeyrelhandler;
|
h->lowlevel->common.handler->key_released = llkeyrelhandler;
|
||||||
h->lowlevel->common.handler->focus_in = llfocusinhandler;
|
h->lowlevel->common.handler->focus_in = llfocusinhandler;
|
||||||
h->lowlevel->common.handler->focus_out = llfocusouthandler;
|
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);
|
if(parent != NULL) arrput(parent->children, h);
|
||||||
|
|
@ -177,6 +257,19 @@ MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent,
|
||||||
MwAddTickList(h);
|
MwAddTickList(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
|
if(IsFirstVisible(h)) {
|
||||||
|
h->root_font = MwFontLoad(MwTTFData, MwTTFDataSize);
|
||||||
|
h->root_boldfont = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize);
|
||||||
|
h->root_monofont = MwFontLoad(MwMonospaceTTFData, MwMonospaceTTFDataSize);
|
||||||
|
h->root_boldmonofont = MwFontLoad(MwBoldMonospaceTTFData, MwBoldMonospaceTTFDataSize);
|
||||||
|
} else
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
h->root_font = NULL;
|
||||||
|
h->root_boldfont = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
if(h->parent != NULL) MwDispatch(h->parent, children_update);
|
if(h->parent != NULL) MwDispatch(h->parent, children_update);
|
||||||
|
|
||||||
return h;
|
return h;
|
||||||
|
|
@ -205,6 +298,22 @@ MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget p
|
||||||
static void MwFreeWidget(MwWidget handle) {
|
static void MwFreeWidget(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
MwWidget root = handle;
|
MwWidget root = handle;
|
||||||
|
MwWidget w;
|
||||||
|
|
||||||
|
w = handle;
|
||||||
|
while(w != NULL) {
|
||||||
|
if(w->top_step) break;
|
||||||
|
w = w->parent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(w != NULL) {
|
||||||
|
for(i = 0; i < arrlen(w->draw_queue); i++) {
|
||||||
|
if(w->draw_queue[i] == handle) {
|
||||||
|
arrdel(w->draw_queue, i);
|
||||||
|
i--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handle->destroyed = 0;
|
handle->destroyed = 0;
|
||||||
MwDispatch(handle, destroy);
|
MwDispatch(handle, destroy);
|
||||||
|
|
@ -241,6 +350,11 @@ static void MwFreeWidget(MwWidget handle) {
|
||||||
arrfree(handle->destroy_queue);
|
arrfree(handle->destroy_queue);
|
||||||
arrfree(handle->tick_list);
|
arrfree(handle->tick_list);
|
||||||
|
|
||||||
|
arrfree(handle->draw_queue);
|
||||||
|
|
||||||
|
if(handle->root_font != NULL) MwFontFree(handle->root_font);
|
||||||
|
if(handle->root_boldfont != NULL) MwFontFree(handle->root_boldfont);
|
||||||
|
|
||||||
free(handle);
|
free(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -261,6 +375,8 @@ void MwDestroyWidget(MwWidget handle) {
|
||||||
if(i == arrlen(handle->parent->destroy_queue)) {
|
if(i == arrlen(handle->parent->destroy_queue)) {
|
||||||
arrput(handle->parent->destroy_queue, handle);
|
arrput(handle->parent->destroy_queue, handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MwDispatch(handle->parent, children_update);
|
||||||
}
|
}
|
||||||
destroy_children(handle);
|
destroy_children(handle);
|
||||||
handle->destroyed = 1;
|
handle->destroyed = 1;
|
||||||
|
|
@ -297,6 +413,22 @@ static void clean_destroy_queue(MwWidget handle) {
|
||||||
arrfree(handle->destroy_queue);
|
arrfree(handle->destroy_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void MwAfterStep(MwWidget handle) {
|
||||||
|
#ifdef PERIODIC
|
||||||
|
if(handle->top_step) {
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; i < arrlen(handle->draw_queue); i++) {
|
||||||
|
DRAW(handle->draw_queue[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
arrfree(handle->draw_queue);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
(void)handle;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
int MwStep(MwWidget handle) {
|
int MwStep(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
MwWidget* widgets = NULL;
|
MwWidget* widgets = NULL;
|
||||||
|
|
@ -310,11 +442,13 @@ int MwStep(MwWidget handle) {
|
||||||
|
|
||||||
handle->prop_event = 0;
|
handle->prop_event = 0;
|
||||||
|
|
||||||
if(handle->lowlevel != NULL && MwLLPending(handle->lowlevel))
|
while(handle->lowlevel != NULL && MwLLPending(handle->lowlevel))
|
||||||
MwLLNextEvent(handle->lowlevel);
|
MwLLNextEvent(handle->lowlevel);
|
||||||
|
|
||||||
handle->prop_event = 1;
|
handle->prop_event = 1;
|
||||||
|
|
||||||
|
if(handle->top_step) MwAfterStep(handle);
|
||||||
|
|
||||||
clean_destroy_queue(handle);
|
clean_destroy_queue(handle);
|
||||||
if(handle->parent == NULL && handle->destroyed) {
|
if(handle->parent == NULL && handle->destroyed) {
|
||||||
MwFreeWidget(handle);
|
MwFreeWidget(handle);
|
||||||
|
|
@ -328,7 +462,7 @@ int MwPending(MwWidget handle) {
|
||||||
for(i = 0; i < arrlen(handle->children); i++) {
|
for(i = 0; i < arrlen(handle->children); i++) {
|
||||||
if(MwPending(handle->children[i])) return 1;
|
if(MwPending(handle->children[i])) return 1;
|
||||||
}
|
}
|
||||||
return (arrlen(handle->destroy_queue) > 0 ? 1 : 0) || (handle->widget_class == NULL ? 0 : MwLLPending(handle->lowlevel));
|
return (arrlen(handle->destroy_queue) > 0) || (handle->widget_class == NULL ? 0 : MwLLPending(handle->lowlevel));
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLoop(MwWidget handle) {
|
void MwLoop(MwWidget handle) {
|
||||||
|
|
@ -354,7 +488,7 @@ void MwLoop(MwWidget handle) {
|
||||||
more = over % (wait / 2);
|
more = over % (wait / 2);
|
||||||
t = (tick + wait - more) - (t2 = MwTimeGetTick());
|
t = (tick + wait - more) - (t2 = MwTimeGetTick());
|
||||||
if(t > 0) {
|
if(t > 0) {
|
||||||
MwTimeSleep(t);
|
if(!handle->berserk) MwTimeSleep(t);
|
||||||
tick = MwTimeGetTick();
|
tick = MwTimeGetTick();
|
||||||
over -= more;
|
over -= more;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -364,6 +498,14 @@ void MwLoop(MwWidget handle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void force_render_all(MwWidget handle) {
|
||||||
|
int i;
|
||||||
|
for(i = 0; i < arrlen(handle->children); i++) {
|
||||||
|
force_render_all(handle->children[i]);
|
||||||
|
}
|
||||||
|
if(handle->lowlevel != NULL) MwForceRender(handle);
|
||||||
|
}
|
||||||
|
|
||||||
void MwSetInteger(MwWidget handle, const char* key, int n) {
|
void MwSetInteger(MwWidget handle, const char* key, int n) {
|
||||||
int xy;
|
int xy;
|
||||||
int wh = 0;
|
int wh = 0;
|
||||||
|
|
@ -385,6 +527,20 @@ void MwSetInteger(MwWidget handle, const char* key, int n) {
|
||||||
MwDispatch3(handle, prop_change, key);
|
MwDispatch3(handle, prop_change, key);
|
||||||
if(handle->parent != NULL) MwDispatch4(handle->parent, children_prop_change, handle, key);
|
if(handle->parent != NULL) MwDispatch4(handle->parent, children_prop_change, handle, key);
|
||||||
}
|
}
|
||||||
|
if(strcmp(key, MwNforceInverted) == 0) {
|
||||||
|
MwForceRender(handle);
|
||||||
|
}
|
||||||
|
if(strcmp(key, MwNmodernLook) == 0 || strcmp(key, MwNdarkTheme) == 0 || strcmp(key, MwNbitmapFont) == 0) {
|
||||||
|
force_render_all(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(strcmp(key, MwNdarkTheme) == 0) {
|
||||||
|
MwWidget h = handle;
|
||||||
|
|
||||||
|
while(h->parent != NULL && h->parent->widget_class != NULL) h = h->parent;
|
||||||
|
|
||||||
|
MwLLSetDarkTheme(h->lowlevel, n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwSetText(MwWidget handle, const char* key, const char* value) {
|
void MwSetText(MwWidget handle, const char* key, const char* value) {
|
||||||
|
|
@ -428,6 +584,15 @@ void MwSetVoid(MwWidget handle, const char* key, void* value) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int inherit_integer(MwWidget handle, const char* key, int default_v) {
|
||||||
|
int v;
|
||||||
|
|
||||||
|
if(handle->parent != NULL && (v = MwGetInteger(handle->parent, key)) != MwDEFAULT) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
return default_v;
|
||||||
|
}
|
||||||
|
|
||||||
int MwGetInteger(MwWidget handle, const char* key) {
|
int MwGetInteger(MwWidget handle, const char* key) {
|
||||||
if(strcmp(key, MwNx) == 0 || strcmp(key, MwNy) == 0 || strcmp(key, MwNwidth) == 0 || strcmp(key, MwNheight) == 0) {
|
if(strcmp(key, MwNx) == 0 || strcmp(key, MwNy) == 0 || strcmp(key, MwNwidth) == 0 || strcmp(key, MwNheight) == 0) {
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
@ -441,6 +606,20 @@ int MwGetInteger(MwWidget handle, const char* key) {
|
||||||
if(strcmp(key, MwNheight) == 0) return h;
|
if(strcmp(key, MwNheight) == 0) return h;
|
||||||
return MwDEFAULT;
|
return MwDEFAULT;
|
||||||
} else {
|
} else {
|
||||||
|
if(shgeti(handle->integer, key) == -1) {
|
||||||
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
|
if(strcmp(key, MwNbitmapFont) == 0) return inherit_integer(handle, key, 0);
|
||||||
|
#else
|
||||||
|
if(strcmp(key, MwNbitmapFont) == 0) return inherit_integer(handle, key, 1);
|
||||||
|
#endif
|
||||||
|
#ifdef USE_CLASSIC_THEME
|
||||||
|
if(strcmp(key, MwNmodernLook) == 0) return inherit_integer(handle, key, 0);
|
||||||
|
#else
|
||||||
|
if(strcmp(key, MwNmodernLook) == 0) return inherit_integer(handle, key, 1);
|
||||||
|
#endif
|
||||||
|
if(strcmp(key, MwNdarkTheme) == 0) return inherit_integer(handle, key, 0);
|
||||||
|
if(strcmp(key, MwNuseMonospace) == 0) return inherit_integer(handle, key, 0);
|
||||||
|
}
|
||||||
return shget(handle->integer, key);
|
return shget(handle->integer, key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -454,7 +633,7 @@ const char* MwGetText(MwWidget handle, const char* key) {
|
||||||
h = h->parent;
|
h = h->parent;
|
||||||
}
|
}
|
||||||
if(v == NULL) {
|
if(v == NULL) {
|
||||||
if(handle->dark_theme) {
|
if(MwGetInteger(handle, MwNdarkTheme)) {
|
||||||
if(strcmp(key, MwNbackground) == 0) return MwDefaultDarkBackground;
|
if(strcmp(key, MwNbackground) == 0) return MwDefaultDarkBackground;
|
||||||
if(strcmp(key, MwNforeground) == 0) return MwDefaultDarkForeground;
|
if(strcmp(key, MwNforeground) == 0) return MwDefaultDarkForeground;
|
||||||
if(strcmp(key, MwNsubBackground) == 0) return MwDefaultDarkSubBackground;
|
if(strcmp(key, MwNsubBackground) == 0) return MwDefaultDarkSubBackground;
|
||||||
|
|
@ -472,8 +651,47 @@ const char* MwGetText(MwWidget handle, const char* key) {
|
||||||
return shget(handle->text, key);
|
return shget(handle->text, key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
|
static void* inherit_void(MwWidget handle, const char* key) {
|
||||||
|
void* v;
|
||||||
|
|
||||||
|
if(handle->parent != NULL && (v = MwGetVoid(handle->parent, key)) != NULL) {
|
||||||
|
return v;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void* MwGetVoid(MwWidget handle, const char* key) {
|
void* MwGetVoid(MwWidget handle, const char* key) {
|
||||||
return shget(handle->data, key);
|
void* v = shget(handle->data, key);
|
||||||
|
|
||||||
|
if(v != NULL) return v;
|
||||||
|
|
||||||
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
|
if(strcmp(key, MwNfont) == 0 || strcmp(key, MwNboldFont) == 0 || strcmp(key, MwNmonospaceFont) == 0 || strcmp(key, MwNboldMonospaceFont) == 0) {
|
||||||
|
v = inherit_void(handle, key);
|
||||||
|
|
||||||
|
if(v == NULL) {
|
||||||
|
MwWidget w = handle;
|
||||||
|
|
||||||
|
while(w != NULL && v == NULL) {
|
||||||
|
if(strcmp(key, MwNfont) == 0) {
|
||||||
|
v = w->root_font;
|
||||||
|
} else if(strcmp(key, MwNboldFont) == 0) {
|
||||||
|
v = w->root_boldfont;
|
||||||
|
} else if(strcmp(key, MwNmonospaceFont) == 0) {
|
||||||
|
v = w->root_monofont;
|
||||||
|
} else if(strcmp(key, MwNboldMonospaceFont) == 0) {
|
||||||
|
v = w->root_boldmonofont;
|
||||||
|
}
|
||||||
|
|
||||||
|
w = w->parent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwVaApply(MwWidget handle, ...) {
|
void MwVaApply(MwWidget handle, ...) {
|
||||||
|
|
@ -541,61 +759,8 @@ void MwVaListApply(MwWidget handle, va_list va) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void inherit_integer(MwWidget handle, const char* key, int default_value) {
|
|
||||||
int n;
|
|
||||||
MwWidget h = handle;
|
|
||||||
while(h != NULL) {
|
|
||||||
if((n = MwGetInteger(h, key)) != MwDEFAULT) {
|
|
||||||
MwSetInteger(handle, key, n);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
h = h->parent;
|
|
||||||
}
|
|
||||||
MwSetInteger(handle, key, default_value);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
|
||||||
static void set_font(MwWidget handle) {
|
|
||||||
void* f;
|
|
||||||
MwWidget h = handle;
|
|
||||||
while(h != NULL) {
|
|
||||||
if((f = MwGetVoid(h, MwNfont)) != NULL) {
|
|
||||||
MwSetVoid(handle, MwNfont, f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
h = h->parent;
|
|
||||||
}
|
|
||||||
f = MwFontLoad(MwTTFData, MwTTFDataSize);
|
|
||||||
MwSetVoid(handle, MwNfont, f);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void set_boldfont(MwWidget handle) {
|
|
||||||
void* f;
|
|
||||||
MwWidget h = handle;
|
|
||||||
while(h != NULL) {
|
|
||||||
if((f = MwGetVoid(h, MwNboldFont)) != NULL) {
|
|
||||||
MwSetVoid(handle, MwNboldFont, f);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
h = h->parent;
|
|
||||||
}
|
|
||||||
f = MwFontLoad(MwBoldTTFData, MwBoldTTFDataSize);
|
|
||||||
MwSetVoid(handle, MwNboldFont, f);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void MwSetDefault(MwWidget handle) {
|
void MwSetDefault(MwWidget handle) {
|
||||||
if(handle->lowlevel != NULL) MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
if(handle->lowlevel != NULL) MwLLSetCursor(handle->lowlevel, &MwCursorDefault, &MwCursorDefaultMask);
|
||||||
|
|
||||||
#ifdef USE_CLASSIC_THEME
|
|
||||||
inherit_integer(handle, MwNmodernLook, 0);
|
|
||||||
#else
|
|
||||||
inherit_integer(handle, MwNmodernLook, 1);
|
|
||||||
#endif
|
|
||||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
|
||||||
set_font(handle);
|
|
||||||
set_boldfont(handle);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwHideCursor(MwWidget handle) {
|
void MwHideCursor(MwWidget handle) {
|
||||||
|
|
@ -649,7 +814,7 @@ void MwDispatchError(int code, const char* message) {
|
||||||
} else {
|
} else {
|
||||||
#ifdef _WIN32
|
#ifdef _WIN32
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
sprintf(buffer, "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);
|
||||||
MessageBox(NULL, buffer, "Error", MB_ICONERROR | MB_OK);
|
MessageBox(NULL, buffer, "Error", MB_ICONERROR | MB_OK);
|
||||||
#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);
|
||||||
|
|
@ -688,21 +853,10 @@ void MwGrabPointer(MwWidget handle, int toggle) {
|
||||||
MwLLGrabPointer(handle->lowlevel, toggle);
|
MwLLGrabPointer(handle->lowlevel, toggle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void force_render_all(MwWidget handle) {
|
void MwSetDarkTheme(MwWidget handle, int toggle) {
|
||||||
int i;
|
MwVaApply(handle,
|
||||||
for(i = 0; i < arrlen(handle->children); i++) {
|
MwNdarkTheme, toggle,
|
||||||
force_render_all(handle->children[i]);
|
NULL);
|
||||||
}
|
|
||||||
MwForceRender(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
void MwToggleDarkTheme(MwWidget handle, int toggle) {
|
|
||||||
int old = handle->dark_theme;
|
|
||||||
if(old != toggle) {
|
|
||||||
handle->dark_theme = toggle;
|
|
||||||
|
|
||||||
force_render_all(handle);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
MwWidget MwGetParent(MwWidget handle) {
|
MwWidget MwGetParent(MwWidget handle) {
|
||||||
|
|
@ -715,19 +869,46 @@ int MwLibraryInit(void) {
|
||||||
#ifdef USE_WAYLAND
|
#ifdef USE_WAYLAND
|
||||||
MwLLWaylandCallInit,
|
MwLLWaylandCallInit,
|
||||||
#endif
|
#endif
|
||||||
|
/* x11 has higher priority then cocoa until it works */
|
||||||
#ifdef USE_X11
|
#ifdef USE_X11
|
||||||
MwLLX11CallInit,
|
MwLLX11CallInit,
|
||||||
#endif
|
#endif
|
||||||
|
#ifdef USE_COCOA
|
||||||
|
MwLLCocoaCallInit,
|
||||||
|
#endif
|
||||||
#ifdef USE_GDI
|
#ifdef USE_GDI
|
||||||
MwLLGDICallInit,
|
MwLLGDICallInit,
|
||||||
|
#endif
|
||||||
|
#ifdef CLASSIC_MAC_OS
|
||||||
|
MwLLClassicMacOSCallInit,
|
||||||
#endif
|
#endif
|
||||||
NULL};
|
NULL};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
MwFLSetup();
|
||||||
|
|
||||||
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("[WARNING] No suitable GUI backend found! Enabled:"
|
||||||
|
#ifdef USE_COCOA
|
||||||
|
" Cocoa"
|
||||||
|
#endif
|
||||||
|
#ifdef USE_WAYLAND
|
||||||
|
" Wayland"
|
||||||
|
#endif
|
||||||
|
#ifdef USE_X11
|
||||||
|
" X11"
|
||||||
|
#endif
|
||||||
|
#ifdef USE_GDI
|
||||||
|
" GDI"
|
||||||
|
#endif
|
||||||
|
#ifdef CLASSIC_MAC_OS
|
||||||
|
" ClassicMacOS"
|
||||||
|
#endif
|
||||||
|
"\n");
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -752,6 +933,8 @@ void MwReparent(MwWidget handle, MwWidget new_parent) {
|
||||||
arrput(new_parent->children, handle);
|
arrput(new_parent->children, handle);
|
||||||
|
|
||||||
MwDispatch(handle->parent, children_update);
|
MwDispatch(handle->parent, children_update);
|
||||||
|
|
||||||
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClass MwGetClass(MwWidget handle) {
|
MwClass MwGetClass(MwWidget handle) {
|
||||||
|
|
@ -781,3 +964,15 @@ void MwGetCursorCoord(MwWidget handle, MwPoint* point) {
|
||||||
void MwGetScreenSize(MwWidget handle, MwRect* rect) {
|
void MwGetScreenSize(MwWidget handle, MwRect* rect) {
|
||||||
MwLLGetScreenSize(handle->lowlevel, rect);
|
MwLLGetScreenSize(handle->lowlevel, rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int MwGetCoordinateType(MwWidget handle) {
|
||||||
|
if(handle->parent == NULL || handle->parent->lowlevel == NULL) {
|
||||||
|
return handle->lowlevel->common.coordinate_type;
|
||||||
|
} else {
|
||||||
|
return MwCOORDINATE_LOCAL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwGetClipboard(MwWidget handle, int clipboard_type) {
|
||||||
|
MwLLGetClipboard(handle->lowlevel, clipboard_type);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,8 @@ const char* MwDefaultDarkForeground = "#ddd";
|
||||||
const char* MwDefaultDarkSubBackground = "#333";
|
const char* MwDefaultDarkSubBackground = "#333";
|
||||||
const char* MwDefaultDarkSubForeground = "#ddd";
|
const char* MwDefaultDarkSubForeground = "#ddd";
|
||||||
|
|
||||||
|
const int MwDefaultShadow = -32;
|
||||||
|
|
||||||
int MwDefaultBorderWidth(MwWidget handle) {
|
int MwDefaultBorderWidth(MwWidget handle) {
|
||||||
int bw = MwGetInteger(handle, MwNborderWidth);
|
int bw = MwGetInteger(handle, MwNborderWidth);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
#define WIN_SIZE 464
|
#define WIN_SIZE 464
|
||||||
#define PICKER_SIZE 360
|
#define PICKER_SIZE 364
|
||||||
#define IMG_POS_X(w) ((w - PICKER_SIZE) / 2)
|
#define IMG_POS_X(w) ((w - PICKER_SIZE) / 2)
|
||||||
#define IMG_POS_Y(h) ((h - PICKER_SIZE) / 2)
|
#define IMG_POS_Y(h) ((h - PICKER_SIZE) / 2)
|
||||||
#define SCROLL_BAR_WIDTH 16
|
#define SCROLL_BAR_WIDTH 16
|
||||||
|
|
@ -104,11 +104,16 @@ static void color_picker_image_update(color_picker_t* picker) {
|
||||||
int _y = y - (PICKER_SIZE / 2);
|
int _y = y - (PICKER_SIZE / 2);
|
||||||
double dist = sqrt(_x * _x + _y * _y);
|
double dist = sqrt(_x * _x + _y * _y);
|
||||||
|
|
||||||
if(dist >= 180.) {
|
if(dist >= 182.) {
|
||||||
picker->color_picker_image_data[i] = 0;
|
picker->color_picker_image_data[i] = 0;
|
||||||
picker->color_picker_image_data[i + 1] = 0;
|
picker->color_picker_image_data[i + 1] = 0;
|
||||||
picker->color_picker_image_data[i + 2] = 0;
|
picker->color_picker_image_data[i + 2] = 0;
|
||||||
picker->color_picker_image_data[i + 3] = 0;
|
picker->color_picker_image_data[i + 3] = 0;
|
||||||
|
} else if(dist >= 180.) {
|
||||||
|
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 {
|
} else {
|
||||||
MwHSV hsv_v;
|
MwHSV hsv_v;
|
||||||
MwRGB color;
|
MwRGB color;
|
||||||
|
|
@ -155,7 +160,7 @@ static void color_picker_image_update(color_picker_t* picker) {
|
||||||
|
|
||||||
static void color_picker_click(MwWidget handle, void* user, void* call) {
|
static void color_picker_click(MwWidget handle, void* user, void* call) {
|
||||||
color_picker_t* picker = user;
|
color_picker_t* picker = user;
|
||||||
MwLLMouse* mouse = call;
|
MwMouse* mouse = call;
|
||||||
char hexColor[8];
|
char hexColor[8];
|
||||||
int i;
|
int i;
|
||||||
char fgColor[8];
|
char fgColor[8];
|
||||||
|
|
@ -173,13 +178,13 @@ static void color_picker_click(MwWidget handle, void* user, void* call) {
|
||||||
picker->chosen_color.green = picker->color_picker_image_data[i + 1];
|
picker->chosen_color.green = picker->color_picker_image_data[i + 1];
|
||||||
picker->chosen_color.blue = picker->color_picker_image_data[i + 2];
|
picker->chosen_color.blue = picker->color_picker_image_data[i + 2];
|
||||||
|
|
||||||
sprintf(hexColor, "#%02X%02X%02X", picker->chosen_color.red & 0xff, picker->chosen_color.green & 0xff, picker->chosen_color.blue & 0xff);
|
MwStringPrintIntoBuffer(hexColor, 8, "#%02X%02X%02X", picker->chosen_color.red & 0xff, picker->chosen_color.green & 0xff, picker->chosen_color.blue & 0xff);
|
||||||
|
|
||||||
fr = picker->chosen_color.red > 128 ? 0 : 255;
|
fr = picker->chosen_color.red > 128 ? 0 : 255;
|
||||||
fg = picker->chosen_color.green > 128 ? 0 : 255;
|
fg = picker->chosen_color.green > 128 ? 0 : 255;
|
||||||
fb = picker->chosen_color.blue > 128 ? 0 : 255;
|
fb = picker->chosen_color.blue > 128 ? 0 : 255;
|
||||||
|
|
||||||
sprintf(fgColor, "#%02X%02X%02X", fr, fg, fb);
|
MwStringPrintIntoBuffer(fgColor, 8, "#%02X%02X%02X", fr, fg, fb);
|
||||||
MwSetText(picker->color_display_text, MwNforeground, fgColor);
|
MwSetText(picker->color_display_text, MwNforeground, fgColor);
|
||||||
|
|
||||||
MwSetText(picker->color_display_text, MwNbackground, hexColor);
|
MwSetText(picker->color_display_text, MwNbackground, hexColor);
|
||||||
|
|
@ -247,7 +252,7 @@ static void color_display_text_change(MwWidget handle, void* user,
|
||||||
fg = color->common.green > 128 ? 0 : 255;
|
fg = color->common.green > 128 ? 0 : 255;
|
||||||
fb = color->common.blue > 128 ? 0 : 255;
|
fb = color->common.blue > 128 ? 0 : 255;
|
||||||
|
|
||||||
sprintf(fgColor, "#%02X%02X%02X", fr, fg, fb);
|
MwStringPrintIntoBuffer(fgColor, 9, "#%02X%02X%02X", fr, fg, fb);
|
||||||
MwSetText(picker->color_display_text, MwNforeground, fgColor);
|
MwSetText(picker->color_display_text, MwNforeground, fgColor);
|
||||||
|
|
||||||
MwSetText(picker->color_display_text, MwNbackground, hexColor);
|
MwSetText(picker->color_display_text, MwNbackground, hexColor);
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@ static void destroy(MwWidget handle) {
|
||||||
MwDestroyWidget(handle);
|
MwDestroyWidget(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cancel(MwWidget handle, void* user, void* call) {
|
static void filecancel(MwWidget handle, void* user, void* call) {
|
||||||
(void)user;
|
(void)user;
|
||||||
(void)call;
|
(void)call;
|
||||||
|
|
||||||
|
|
@ -147,7 +147,7 @@ static void nav_activate(MwWidget handle, void* user, void* call) {
|
||||||
(void)user;
|
(void)user;
|
||||||
|
|
||||||
if(strcmp(e, "Home") == 0) {
|
if(strcmp(e, "Home") == 0) {
|
||||||
#ifdef _WIN32
|
#if defined(_WIN32) || defined(CLASSIC_MAC_OS)
|
||||||
#else
|
#else
|
||||||
struct passwd* p = getpwuid(getuid());
|
struct passwd* p = getpwuid(getuid());
|
||||||
|
|
||||||
|
|
@ -221,7 +221,7 @@ static void layout(MwWidget handle) {
|
||||||
MwNleftPadding, 16,
|
MwNleftPadding, 16,
|
||||||
NULL);
|
NULL);
|
||||||
MwListBoxInsert(fc->nav, -1, p);
|
MwListBoxInsert(fc->nav, -1, p);
|
||||||
MwAddUserHandler(fc->nav, MwNactivateHandler, nav_activate, NULL);
|
MwAddUserHandler(fc->nav, MwNlistBoxActivateHandler, nav_activate, NULL);
|
||||||
|
|
||||||
MwListBoxDestroyPacket(p);
|
MwListBoxDestroyPacket(p);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -242,7 +242,7 @@ static void layout(MwWidget handle) {
|
||||||
MwNhasHeading, 1,
|
MwNhasHeading, 1,
|
||||||
MwNleftPadding, 16,
|
MwNleftPadding, 16,
|
||||||
NULL);
|
NULL);
|
||||||
MwAddUserHandler(fc->files, MwNactivateHandler, files_activate, NULL);
|
MwAddUserHandler(fc->files, MwNlistBoxActivateHandler, files_activate, NULL);
|
||||||
} else {
|
} else {
|
||||||
MwVaApply(fc->files,
|
MwVaApply(fc->files,
|
||||||
MwNx, wx,
|
MwNx, wx,
|
||||||
|
|
@ -383,7 +383,7 @@ static void layout(MwWidget handle) {
|
||||||
MwNtext, "Cancel",
|
MwNtext, "Cancel",
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
MwAddUserHandler(fc->cancel, MwNactivateHandler, cancel, NULL);
|
MwAddUserHandler(fc->cancel, MwNactivateHandler, filecancel, NULL);
|
||||||
} else {
|
} else {
|
||||||
MwVaApply(fc->cancel,
|
MwVaApply(fc->cancel,
|
||||||
MwNx, wx,
|
MwNx, wx,
|
||||||
|
|
|
||||||
|
|
@ -102,7 +102,7 @@ MwWidget MwMessageBox(MwWidget handle, const char* text, const char* title, unsi
|
||||||
left = 8 + 48 + 8;
|
left = 8 + 48 + 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
th = MwTextHeight(handle, text);
|
th = MwTextHeight(handle, NULL, text);
|
||||||
(void)MwVaCreateWidget(MwLabelClass, "label", window, left, (h - th) / 2, w - left - 8, th,
|
(void)MwVaCreateWidget(MwLabelClass, "label", window, left, (h - th) / 2, w - left - 8, th,
|
||||||
MwNtext, text,
|
MwNtext, text,
|
||||||
MwNalignment, MwALIGNMENT_BEGINNING,
|
MwNalignment, MwALIGNMENT_BEGINNING,
|
||||||
|
|
|
||||||
127
src/draw.c
127
src/draw.c
|
|
@ -1,6 +1,7 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
#ifdef USE_STB_IMAGE
|
#ifdef NO_IMAGE
|
||||||
|
#elif defined(USE_STB_IMAGE)
|
||||||
#include "../external/stb_image.h"
|
#include "../external/stb_image.h"
|
||||||
#else
|
#else
|
||||||
#include <png.h>
|
#include <png.h>
|
||||||
|
|
@ -12,7 +13,7 @@
|
||||||
|
|
||||||
static int get_color_diff(MwWidget handle) {
|
static int get_color_diff(MwWidget handle) {
|
||||||
if(MwGetInteger(handle, MwNmodernLook)) {
|
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||||
return 46;
|
return 40;
|
||||||
} else {
|
} else {
|
||||||
return 80;
|
return 80;
|
||||||
}
|
}
|
||||||
|
|
@ -28,7 +29,7 @@ static int hex(const char* txt, int len) {
|
||||||
n = c - 'a' + 10;
|
n = c - 'a' + 10;
|
||||||
} else if('A' <= c && c <= 'F') {
|
} else if('A' <= c && c <= 'F') {
|
||||||
n = c - 'A' + 10;
|
n = c - 'A' + 10;
|
||||||
} else if('0' <= c && c <= '9') {
|
} else if('0' <= c && c <= 'g') {
|
||||||
n = c - '0';
|
n = c - '0';
|
||||||
}
|
}
|
||||||
r = r << 4;
|
r = r << 4;
|
||||||
|
|
@ -106,11 +107,21 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
|
||||||
int y;
|
int y;
|
||||||
double darken = 0.;
|
double darken = 0.;
|
||||||
int ColorDiff = get_color_diff(handle);
|
int ColorDiff = get_color_diff(handle);
|
||||||
double darkenStep = (ColorDiff / 4.) / 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);
|
unsigned char* data = malloc(sz);
|
||||||
|
MwRect r = *rect;
|
||||||
|
if(rect->width <= 0 || rect->height <= 0) {
|
||||||
|
free(data);
|
||||||
|
return;
|
||||||
|
}
|
||||||
memset(data, 0, sz);
|
memset(data, 0, sz);
|
||||||
|
|
||||||
|
r.x += 1;
|
||||||
|
r.y += 1;
|
||||||
|
r.width -= 2;
|
||||||
|
r.height -= 2;
|
||||||
|
|
||||||
for(y = 0; y < rect->height; y++) {
|
for(y = 0; y < rect->height; y++) {
|
||||||
MwLLColor col = MwLightenColor(handle, color, -darken, -darken, -darken);
|
MwLLColor col = MwLightenColor(handle, color, -darken, -darken, -darken);
|
||||||
int idx = y * 4;
|
int idx = y * 4;
|
||||||
|
|
@ -123,13 +134,16 @@ void MwDrawRectFading(MwWidget handle, MwRect* rect, MwLLColor color) {
|
||||||
}
|
}
|
||||||
|
|
||||||
pixmap = MwLLCreatePixmap(handle->lowlevel, data, 1, rect->height);
|
pixmap = MwLLCreatePixmap(handle->lowlevel, data, 1, rect->height);
|
||||||
MwLLDrawPixmap(handle->lowlevel, rect, pixmap);
|
MwLLDrawPixmap(handle->lowlevel, &r, pixmap);
|
||||||
MwLLDestroyPixmap(pixmap);
|
MwLLDestroyPixmap(pixmap);
|
||||||
|
|
||||||
free(data);
|
free(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||||
|
int inv;
|
||||||
|
|
||||||
|
if((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv) invert = 1;
|
||||||
if(MwGetInteger(handle, MwNmodernLook)) {
|
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||||
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0);
|
MwDrawFrameEx(handle, rect, color, invert, MwDefaultBorderWidth(handle), 0, 0);
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -151,7 +165,18 @@ void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||||
void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border) {
|
||||||
MwLLColor col;
|
MwLLColor col;
|
||||||
|
|
||||||
|
if(rect->width <= 0 || rect->height <= 0) return;
|
||||||
|
|
||||||
if(border) {
|
if(border) {
|
||||||
|
if(!handle->lowlevel->common.supports_transparency) {
|
||||||
|
MwLLColor c = handle->parent == NULL ? NULL : MwParseColor(handle->parent, MwGetText(handle->parent, MwNbackground));
|
||||||
|
|
||||||
|
if(c != NULL) {
|
||||||
|
MwDrawRect(handle, rect, c);
|
||||||
|
MwLLFreeColor(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MwDrawFrame(handle, rect, color, invert);
|
MwDrawFrame(handle, rect, color, invert);
|
||||||
}
|
}
|
||||||
col = invert ? MwLightenColor(handle, color, -8, -8, -8) : color;
|
col = invert ? MwLightenColor(handle, color, -8, -8, -8) : color;
|
||||||
|
|
@ -166,7 +191,7 @@ void MwDrawWidgetBack(MwWidget handle, MwRect* rect, MwLLColor color, int invert
|
||||||
void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||||
MwPoint p[6];
|
MwPoint p[6];
|
||||||
int border = MwDefaultBorderWidth(handle);
|
int border = MwDefaultBorderWidth(handle);
|
||||||
int ColorDiff = get_color_diff(handle);
|
int ColorDiff = get_color_diff(handle) + (MwGetInteger(handle, MwNmodernLook) ? 48 : 0);
|
||||||
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff, -ColorDiff, -ColorDiff);
|
||||||
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
MwLLColor lighter = MwLightenColor(handle, color, ColorDiff, ColorDiff, ColorDiff);
|
||||||
MwLLColor col = invert ? MwLightenColor(handle, color, -8, -8, -8) : color;
|
MwLLColor col = invert ? MwLightenColor(handle, color, -8, -8, -8) : color;
|
||||||
|
|
@ -230,12 +255,11 @@ void MwDrawDiamond(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
|
||||||
MwLLFreeColor(darker);
|
MwLLFreeColor(darker);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
static void MwDrawFrameEx_simple(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
||||||
MwPoint p[6];
|
MwPoint p[7];
|
||||||
int ColorDiff = get_color_diff(handle);
|
int ColorDiff = get_color_diff(handle);
|
||||||
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff);
|
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff);
|
||||||
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, ColorDiff - diff, ColorDiff - diff, ColorDiff - diff);
|
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, ColorDiff - diff, ColorDiff - diff, ColorDiff - diff);
|
||||||
|
|
||||||
p[0].x = rect->x;
|
p[0].x = rect->x;
|
||||||
p[0].y = rect->y;
|
p[0].y = rect->y;
|
||||||
|
|
||||||
|
|
@ -244,7 +268,6 @@ void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, i
|
||||||
|
|
||||||
p[2].x = rect->x + rect->width - border;
|
p[2].x = rect->x + rect->width - border;
|
||||||
p[2].y = rect->y + border;
|
p[2].y = rect->y + border;
|
||||||
|
|
||||||
p[3].x = rect->x + border;
|
p[3].x = rect->x + border;
|
||||||
p[3].y = rect->y + border;
|
p[3].y = rect->y + border;
|
||||||
|
|
||||||
|
|
@ -253,7 +276,6 @@ void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, i
|
||||||
|
|
||||||
p[5].x = rect->x;
|
p[5].x = rect->x;
|
||||||
p[5].y = rect->y + rect->height;
|
p[5].y = rect->y + rect->height;
|
||||||
|
|
||||||
MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter);
|
MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter);
|
||||||
|
|
||||||
p[0].x = rect->x + rect->width;
|
p[0].x = rect->x + rect->width;
|
||||||
|
|
@ -273,7 +295,6 @@ void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, i
|
||||||
|
|
||||||
p[5].x = rect->x + rect->width;
|
p[5].x = rect->x + rect->width;
|
||||||
p[5].y = rect->y + rect->height;
|
p[5].y = rect->y + rect->height;
|
||||||
|
|
||||||
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||||
|
|
||||||
MwLLFreeColor(lighter);
|
MwLLFreeColor(lighter);
|
||||||
|
|
@ -285,6 +306,81 @@ void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, i
|
||||||
rect->height -= border * 2;
|
rect->height -= border * 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void frame_border_complex(MwWidget handle, MwRect* rect, MwLLColor lighter, MwLLColor darker, int invert, int border, int diff, int same) {
|
||||||
|
MwPoint p[7];
|
||||||
|
|
||||||
|
(void)diff;
|
||||||
|
(void)same;
|
||||||
|
|
||||||
|
p[0].x = rect->x;
|
||||||
|
p[0].y = rect->y;
|
||||||
|
|
||||||
|
p[1].x = rect->x + rect->width;
|
||||||
|
p[1].y = rect->y;
|
||||||
|
|
||||||
|
p[2].x = rect->x + rect->width - border;
|
||||||
|
p[2].y = rect->y + border;
|
||||||
|
p[3].x = rect->x + border;
|
||||||
|
p[3].y = rect->y + border;
|
||||||
|
|
||||||
|
p[4].x = rect->x + border;
|
||||||
|
p[4].y = rect->y + rect->height - border;
|
||||||
|
|
||||||
|
p[5].x = rect->x;
|
||||||
|
p[5].y = rect->y + rect->height;
|
||||||
|
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||||
|
|
||||||
|
p[0].x = rect->x + rect->width;
|
||||||
|
p[0].y = rect->y;
|
||||||
|
|
||||||
|
p[1].x = rect->x + rect->width - border;
|
||||||
|
p[1].y = rect->y + border;
|
||||||
|
|
||||||
|
p[2].x = rect->x + rect->width - border;
|
||||||
|
p[2].y = rect->y + rect->height - border;
|
||||||
|
|
||||||
|
p[3].x = rect->x + border;
|
||||||
|
p[3].y = rect->y + rect->height - border;
|
||||||
|
|
||||||
|
p[4].x = rect->x;
|
||||||
|
p[4].y = rect->y + rect->height;
|
||||||
|
|
||||||
|
p[5].x = rect->x + rect->width;
|
||||||
|
p[5].y = rect->y + rect->height;
|
||||||
|
MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void MwDrawFrameEx_complex(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
||||||
|
int ColorDiff = get_color_diff(handle);
|
||||||
|
MwLLColor darker = MwLightenColor(handle, color, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff, -ColorDiff * 3 / 2 + diff);
|
||||||
|
MwLLColor lighter = same ? MwLightenColor(handle, darker, 0, 0, 0) : MwLightenColor(handle, color, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff, (ColorDiff / 2) - diff);
|
||||||
|
MwRect r = *rect;
|
||||||
|
|
||||||
|
frame_border_complex(handle, rect, lighter, darker, invert, border, diff, same);
|
||||||
|
|
||||||
|
r.x += 1;
|
||||||
|
r.y += 1;
|
||||||
|
r.width -= 2;
|
||||||
|
r.height -= 2;
|
||||||
|
frame_border_complex(handle, &r, lighter, darker, !invert, border, diff, same);
|
||||||
|
|
||||||
|
MwLLFreeColor(lighter);
|
||||||
|
MwLLFreeColor(darker);
|
||||||
|
|
||||||
|
rect->x += border;
|
||||||
|
rect->y += border;
|
||||||
|
rect->width -= border * 2;
|
||||||
|
rect->height -= border * 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwDrawFrameEx(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int border, int diff, int same) {
|
||||||
|
if(MwGetInteger(handle, MwNmodernLook)) {
|
||||||
|
MwDrawFrameEx_complex(handle, rect, color, invert, border, diff, same);
|
||||||
|
} else {
|
||||||
|
MwDrawFrameEx_simple(handle, rect, color, invert, border, diff, same);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
|
void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert, int direction) {
|
||||||
MwPoint p1[4], p2[4], p3[4], p4[3];
|
MwPoint p1[4], p2[4], p3[4], p4[3];
|
||||||
const int border = MwGetInteger(handle, MwNmodernLook) ? 2 : MwDefaultBorderWidth(handle);
|
const int border = MwGetInteger(handle, MwNmodernLook) ? 2 : MwDefaultBorderWidth(handle);
|
||||||
|
|
@ -502,7 +598,8 @@ void MwDrawTriangle(MwWidget handle, MwRect* rect, MwLLColor color, int invert,
|
||||||
MwLLFreeColor(darker);
|
MwLLFreeColor(darker);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef USE_STB_IMAGE
|
#if defined(NO_IMAGE)
|
||||||
|
#elif !defined(USE_STB_IMAGE)
|
||||||
static void PNGCAPI user_error(png_structp png, const char* str) {
|
static void PNGCAPI user_error(png_structp png, const char* str) {
|
||||||
(void)str;
|
(void)str;
|
||||||
|
|
||||||
|
|
@ -617,7 +714,9 @@ static unsigned char* load_jpeg(FILE* f, int* w, int* h) {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static unsigned char* load_image(const char* path, int* w, int* h) {
|
static unsigned char* load_image(const char* path, int* w, int* h) {
|
||||||
#ifdef USE_STB_IMAGE
|
#if defined(NO_IMAGE)
|
||||||
|
return NULL;
|
||||||
|
#elif defined(USE_STB_IMAGE)
|
||||||
int ch;
|
int ch;
|
||||||
|
|
||||||
return stbi_load(path, w, h, &ch, 4);
|
return stbi_load(path, w, h, &ch, 4);
|
||||||
|
|
|
||||||
23
src/error.c
23
src/error.c
|
|
@ -1,23 +0,0 @@
|
||||||
#include <Mw/Milsko.h>
|
|
||||||
#include "error_internal.h"
|
|
||||||
|
|
||||||
#define MAX_ERROR_LEN 512
|
|
||||||
|
|
||||||
/* buffer for holding the error. +1 to ensure there's always a null terminator. */
|
|
||||||
char error[MAX_ERROR_LEN + 1] = {0};
|
|
||||||
|
|
||||||
const char* MwGetLastError(void) {
|
|
||||||
return error;
|
|
||||||
}
|
|
||||||
|
|
||||||
void setLastError(const char* fmt, ...) {
|
|
||||||
va_list va;
|
|
||||||
char out[MAX_ERROR_LEN];
|
|
||||||
memset(out, 0, MAX_ERROR_LEN);
|
|
||||||
|
|
||||||
va_start(va, fmt);
|
|
||||||
vsprintf(out, fmt, va);
|
|
||||||
va_end(va);
|
|
||||||
|
|
||||||
memcpy(error, out, MAX_ERROR_LEN);
|
|
||||||
}
|
|
||||||
|
|
@ -1,15 +0,0 @@
|
||||||
#ifndef __MW_ERROR_INTERNAL_H__
|
|
||||||
#define __MW_ERROR_INTERNAL_H__
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is not to be documented or exposed publically.
|
|
||||||
* This contains an internal function for setting the error,
|
|
||||||
* something the user shouldn't want to do and thus we don't want them to.
|
|
||||||
* (hence also, its placement in the src directory)
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <Mw/Error.h>
|
|
||||||
|
|
||||||
void setLastError(const char* fmt, ...);
|
|
||||||
|
|
||||||
#endif
|
|
||||||
316
src/lowlevel.c
316
src/lowlevel.c
|
|
@ -1,61 +1,305 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
MwLL (*MwLLCreate)(MwLL parent, int x, int y, int width, int height);
|
MwLL (*MwLLCreate)(MwLL parent, int x, int y, int width, int height) = NULL;
|
||||||
void (*MwLLDestroy)(MwLL handle);
|
void (*MwLLDestroy)(MwLL handle) = NULL;
|
||||||
|
|
||||||
void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
|
void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color) = NULL;
|
||||||
void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color);
|
void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color) = NULL;
|
||||||
|
|
||||||
void (*MwLLBeginDraw)(MwLL handle);
|
void (*MwLLBeginDraw)(MwLL handle) = NULL;
|
||||||
void (*MwLLEndDraw)(MwLL handle);
|
void (*MwLLEndDraw)(MwLL handle) = NULL;
|
||||||
|
|
||||||
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);
|
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b) = NULL;
|
||||||
void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
|
void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b) = NULL;
|
||||||
void (*MwLLFreeColor)(MwLLColor color);
|
void (*MwLLFreeColor)(MwLLColor color) = NULL;
|
||||||
|
|
||||||
void (*MwLLGetXYWH)(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
|
void (*MwLLGetXYWH)(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) = NULL;
|
||||||
void (*MwLLSetXY)(MwLL handle, int x, int y);
|
void (*MwLLSetXY)(MwLL handle, int x, int y) = NULL;
|
||||||
void (*MwLLSetWH)(MwLL handle, int w, int h);
|
void (*MwLLSetWH)(MwLL handle, int w, int h) = NULL;
|
||||||
|
|
||||||
void (*MwLLSetTitle)(MwLL handle, const char* title);
|
void (*MwLLSetTitle)(MwLL handle, const char* title) = NULL;
|
||||||
|
|
||||||
int (*MwLLPending)(MwLL handle);
|
int (*MwLLPending)(MwLL handle) = NULL;
|
||||||
void (*MwLLNextEvent)(MwLL handle);
|
void (*MwLLNextEvent)(MwLL handle) = NULL;
|
||||||
|
|
||||||
MwLLPixmap (*MwLLCreatePixmap)(MwLL handle, unsigned char* data, int width, int height);
|
MwLLPixmap (*MwLLCreatePixmap)(MwLL handle, unsigned char* data, int width, int height) = NULL;
|
||||||
void (*MwLLPixmapUpdate)(MwLLPixmap pixmap);
|
void (*MwLLPixmapUpdate)(MwLLPixmap pixmap) = NULL;
|
||||||
void (*MwLLDestroyPixmap)(MwLLPixmap pixmap);
|
void (*MwLLDestroyPixmap)(MwLLPixmap pixmap) = NULL;
|
||||||
void (*MwLLDrawPixmap)(MwLL handle, MwRect* rect, MwLLPixmap pixmap);
|
void (*MwLLDrawPixmap)(MwLL handle, MwRect* rect, MwLLPixmap pixmap) = NULL;
|
||||||
void (*MwLLSetIcon)(MwLL handle, MwLLPixmap pixmap);
|
void (*MwLLSetIcon)(MwLL handle, MwLLPixmap pixmap) = NULL;
|
||||||
|
|
||||||
void (*MwLLForceRender)(MwLL handle);
|
void (*MwLLForceRender)(MwLL handle) = NULL;
|
||||||
|
|
||||||
void (*MwLLSetCursor)(MwLL handle, MwCursor* image, MwCursor* mask);
|
void (*MwLLSetCursor)(MwLL handle, MwCursor* image, MwCursor* mask) = NULL;
|
||||||
void (*MwLLDetach)(MwLL handle, MwPoint* point);
|
void (*MwLLDetach)(MwLL handle, MwPoint* point) = NULL;
|
||||||
void (*MwLLShow)(MwLL handle, int show);
|
void (*MwLLShow)(MwLL handle, int show) = NULL;
|
||||||
|
|
||||||
void (*MwLLSetSizeHints)(MwLL handle, int minx, int miny, int maxx, int maxy);
|
void (*MwLLSetSizeHints)(MwLL handle, int minx, int miny, int maxx, int maxy) = NULL;
|
||||||
void (*MwLLMakeBorderless)(MwLL handle, int toggle);
|
void (*MwLLMakeBorderless)(MwLL handle, int toggle) = NULL;
|
||||||
void (*MwLLMakeToolWindow)(MwLL handle);
|
void (*MwLLMakeToolWindow)(MwLL handle) = NULL;
|
||||||
void (*MwLLMakePopup)(MwLL handle, MwLL parent);
|
void (*MwLLMakePopup)(MwLL handle, MwLL parent) = NULL;
|
||||||
|
|
||||||
void (*MwLLBeginStateChange)(MwLL handle);
|
void (*MwLLBeginStateChange)(MwLL handle) = NULL;
|
||||||
void (*MwLLEndStateChange)(MwLL handle);
|
void (*MwLLEndStateChange)(MwLL handle) = NULL;
|
||||||
|
|
||||||
void (*MwLLFocus)(MwLL handle);
|
void (*MwLLFocus)(MwLL handle) = NULL;
|
||||||
void (*MwLLGrabPointer)(MwLL handle, int toggle);
|
void (*MwLLGrabPointer)(MwLL handle, int toggle) = NULL;
|
||||||
|
|
||||||
void (*MwLLSetClipboard)(MwLL handle, const char* text);
|
void (*MwLLSetClipboard)(MwLL handle, const char* text, int clipboard_type) = NULL;
|
||||||
char* (*MwLLGetClipboard)(MwLL handle);
|
void (*MwLLGetClipboard)(MwLL, int clipboard_type) = NULL;
|
||||||
|
|
||||||
void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point);
|
void (*MwLLGetCursorCoord)(MwLL handle, MwPoint* point) = NULL;
|
||||||
void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect);
|
void (*MwLLGetScreenSize)(MwLL handle, MwRect* rect) = NULL;
|
||||||
|
|
||||||
|
void (*MwLLSetDarkTheme)(MwLL handle, int toggle) = NULL;
|
||||||
|
|
||||||
void MwLLCreateCommon(MwLL handle) {
|
void MwLLCreateCommon(MwLL handle) {
|
||||||
handle->common.handler = malloc(sizeof(*handle->common.handler));
|
handle->common.handler = malloc(sizeof(*handle->common.handler));
|
||||||
memset(handle->common.handler, 0, sizeof(*handle->common.handler));
|
memset(handle->common.handler, 0, sizeof(*handle->common.handler));
|
||||||
|
|
||||||
|
handle->common.supports_transparency = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MwLLDestroyCommon(MwLL handle) {
|
void MwLLDestroyCommon(MwLL handle) {
|
||||||
free(handle->common.handler);
|
free(handle->common.handler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
MwBool MwLLDBusFuncSetup(MwLLDBusFuncTable* tbl) {
|
||||||
|
tbl->lib = MwDynamicOpen("libdbus-1.so");
|
||||||
|
if(!tbl->lib) {
|
||||||
|
fprintf(stderr, "[WARNING] dbus library (libdbus-1.so) not found, will not be able to check for any XDG settings.\n");
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define DBUS_FUNC(x) \
|
||||||
|
tbl->x = MwDynamicSymbol(tbl->lib, #x); \
|
||||||
|
if(!tbl->x) { \
|
||||||
|
fprintf(stderr, "[WARNING] dbus function %s not found, will not be able to check for any XDG settings.\n", #x); \
|
||||||
|
dlclose(tbl->lib); \
|
||||||
|
return MwFALSE; \
|
||||||
|
}
|
||||||
|
|
||||||
|
DBUS_FUNC(dbus_error_init);
|
||||||
|
DBUS_FUNC(dbus_bus_get);
|
||||||
|
DBUS_FUNC(dbus_bus_add_match);
|
||||||
|
DBUS_FUNC(dbus_error_is_set);
|
||||||
|
DBUS_FUNC(dbus_error_free);
|
||||||
|
DBUS_FUNC(dbus_message_new_method_call);
|
||||||
|
DBUS_FUNC(dbus_message_is_signal);
|
||||||
|
DBUS_FUNC(dbus_message_iter_init_append);
|
||||||
|
DBUS_FUNC(dbus_message_iter_append_basic);
|
||||||
|
DBUS_FUNC(dbus_connection_flush);
|
||||||
|
DBUS_FUNC(dbus_connection_pop_message);
|
||||||
|
DBUS_FUNC(dbus_connection_read_write);
|
||||||
|
DBUS_FUNC(dbus_connection_send_with_reply_and_block);
|
||||||
|
DBUS_FUNC(dbus_message_unref);
|
||||||
|
DBUS_FUNC(dbus_message_iter_init);
|
||||||
|
DBUS_FUNC(dbus_message_iter_get_arg_type);
|
||||||
|
DBUS_FUNC(dbus_message_iter_recurse);
|
||||||
|
DBUS_FUNC(dbus_message_iter_next);
|
||||||
|
DBUS_FUNC(dbus_connection_unref);
|
||||||
|
DBUS_FUNC(dbus_message_iter_get_basic);
|
||||||
|
|
||||||
|
return MwTRUE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef USE_DBUS
|
||||||
|
MwBool MwLLDBusNewContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx) {
|
||||||
|
if(!tbl->lib) {
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbl->dbus_error_init(&ctx->dbus_err);
|
||||||
|
|
||||||
|
ctx->dbus_conn = tbl->dbus_bus_get(DBUS_BUS_SESSION, &ctx->dbus_err);
|
||||||
|
if(tbl->dbus_error_is_set(&ctx->dbus_err)) {
|
||||||
|
fprintf(stderr, "[WARNING] Could not initialize dbus: Connection error: %s\n", ctx->dbus_err.message);
|
||||||
|
tbl->dbus_error_free(&ctx->dbus_err);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
if(!ctx->dbus_conn) {
|
||||||
|
fprintf(stderr, "[WARNING] Could not initialize dbus: Failed to connect to session bus\n");
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
return MwTRUE;
|
||||||
|
};
|
||||||
|
|
||||||
|
MWDECL MwBool MwLLDBusPortalGet(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal, const char* namespace, const char* key, void* out) {
|
||||||
|
DBusMessageIter dbus_args, dbus_variant, dbus_inner_variant;
|
||||||
|
char arg_type;
|
||||||
|
if(!ctx->dbus_conn) {
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ctx->dbus_msg = tbl->dbus_message_new_method_call(
|
||||||
|
"org.freedesktop.portal.Desktop",
|
||||||
|
"/org/freedesktop/portal/desktop",
|
||||||
|
portal,
|
||||||
|
"Read");
|
||||||
|
if(!ctx->dbus_msg) {
|
||||||
|
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Failed to create message\n", namespace, key);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbl->dbus_message_iter_init_append(ctx->dbus_msg, &dbus_args);
|
||||||
|
tbl->dbus_message_iter_append_basic(&dbus_args, 's', &namespace);
|
||||||
|
tbl->dbus_message_iter_append_basic(&dbus_args, 's', &key);
|
||||||
|
|
||||||
|
ctx->dbus_reply = tbl->dbus_connection_send_with_reply_and_block(ctx->dbus_conn, ctx->dbus_msg, 100, &ctx->dbus_err);
|
||||||
|
|
||||||
|
if(tbl->dbus_error_is_set(&ctx->dbus_err)) {
|
||||||
|
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Send error: %s\n", namespace, key, ctx->dbus_err.message);
|
||||||
|
tbl->dbus_error_free(&ctx->dbus_err);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
if(!ctx->dbus_reply) {
|
||||||
|
fprintf(stderr, "[WARNING] Couldn't get %s::%s: No reply received\n", namespace, key);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!tbl->dbus_message_iter_init(ctx->dbus_reply, &dbus_args)) {
|
||||||
|
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Reply has no arguments\n", namespace, key);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if((arg_type = tbl->dbus_message_iter_get_arg_type(&dbus_args)) != 'v') {
|
||||||
|
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Expected outer variant, got: %c\n", namespace, key, arg_type);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
tbl->dbus_message_iter_recurse(&dbus_args, &dbus_variant);
|
||||||
|
|
||||||
|
/* Some portals wrap the value in a second variant */
|
||||||
|
arg_type = tbl->dbus_message_iter_get_arg_type(&dbus_variant);
|
||||||
|
if(arg_type == 'v') {
|
||||||
|
tbl->dbus_message_iter_recurse(&dbus_variant, &dbus_inner_variant);
|
||||||
|
if((arg_type = tbl->dbus_message_iter_get_arg_type(&dbus_inner_variant)) != 'u') {
|
||||||
|
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Expected 'u' (uint32) for 'value', got: %c\n", portal, arg_type);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
tbl->dbus_message_iter_get_basic(&dbus_inner_variant, out);
|
||||||
|
} else if (arg_type == 'u') {
|
||||||
|
tbl->dbus_message_iter_get_basic(&dbus_variant, out);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Expected variant or string, got: %c\n", namespace, key, arg_type);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_msg);
|
||||||
|
|
||||||
|
return MwTRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MWDECL MwBool MwLLDBusPortalWatch(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, const char* portal) {
|
||||||
|
char filter_string[2048];
|
||||||
|
if(!ctx->dbus_conn) {
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
MwStringPrintIntoBuffer(filter_string, sizeof(filter_string), "type='%s',interface=%s", "signal", portal);
|
||||||
|
|
||||||
|
tbl->dbus_bus_add_match(ctx->dbus_conn, filter_string, &ctx->dbus_err);
|
||||||
|
tbl->dbus_connection_flush(ctx->dbus_conn);
|
||||||
|
|
||||||
|
return MwTRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Technically this will swallow all other results, so this is not usable multiple times.
|
||||||
|
TODO: Use a hashmap instead */
|
||||||
|
MWDECL MwBool MwLLDBusPortalPoll(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx, MwLL handle, const char* portal, const char* namespace, const char* key, MwLLDBusPortalPollListener listener) {
|
||||||
|
DBusMessageIter args, msg_value, msg_value_inner;
|
||||||
|
const char* msg_namespace;
|
||||||
|
const char* msg_key;
|
||||||
|
MwU32 msg_value_content;
|
||||||
|
char arg_type;
|
||||||
|
|
||||||
|
if(!ctx->dbus_conn) {
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
tbl->dbus_connection_read_write(ctx->dbus_conn, 0);
|
||||||
|
tbl->dbus_connection_read_write(ctx->dbus_conn, 0);
|
||||||
|
ctx->dbus_reply = tbl->dbus_connection_pop_message(ctx->dbus_conn);
|
||||||
|
|
||||||
|
if(tbl->dbus_error_is_set(&ctx->dbus_err)) {
|
||||||
|
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Poll error: %s\n", portal, ctx->dbus_err.message);
|
||||||
|
tbl->dbus_error_free(&ctx->dbus_err);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
if(!ctx->dbus_reply) {
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check if the message is a signal from the correct interface and with the correct name */
|
||||||
|
if(tbl->dbus_message_is_signal(ctx->dbus_reply, portal, "SettingChanged")) {
|
||||||
|
/* read the parameters */
|
||||||
|
if(!tbl->dbus_message_iter_init(ctx->dbus_reply, &args))
|
||||||
|
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged has no arguments\n", portal);
|
||||||
|
else {
|
||||||
|
if((arg_type = tbl->dbus_message_iter_get_arg_type(&args)) != 's') {
|
||||||
|
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Expected 's' (string) for 'namespace', got: %c\n", portal, arg_type);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
tbl->dbus_message_iter_get_basic(&args, &msg_namespace);
|
||||||
|
|
||||||
|
tbl->dbus_message_iter_next(&args);
|
||||||
|
if((arg_type = tbl->dbus_message_iter_get_arg_type(&args)) != 's') {
|
||||||
|
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Expected 's' (string) for 'key', got: %c\n", portal, arg_type);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
tbl->dbus_message_iter_get_basic(&args, &msg_key);
|
||||||
|
|
||||||
|
/* Check that key and namespace match */
|
||||||
|
if(strcmp(msg_namespace, namespace) == 0 && strcmp(msg_key, key) == 0) {
|
||||||
|
/* Assuming the value is a basic type */
|
||||||
|
tbl->dbus_message_iter_next(&args);
|
||||||
|
|
||||||
|
if((arg_type = tbl->dbus_message_iter_get_arg_type(&args)) != 'v') {
|
||||||
|
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Expected outer variant, got: %c\n", namespace, key, arg_type);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
tbl->dbus_message_iter_recurse(&args, &msg_value);
|
||||||
|
|
||||||
|
/* Some portals wrap the value in a second variant */
|
||||||
|
arg_type = tbl->dbus_message_iter_get_arg_type(&msg_value);
|
||||||
|
if(arg_type == 'v') {
|
||||||
|
tbl->dbus_message_iter_recurse(&msg_value, &msg_value_inner);
|
||||||
|
if((arg_type = tbl->dbus_message_iter_get_arg_type(&msg_value_inner)) != 'u') {
|
||||||
|
fprintf(stderr, "[WARNING] Signal reply for %s::SettingChanged: Expected 'u' (uint32) for 'value', got: %c\n", portal, arg_type);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
tbl->dbus_message_iter_get_basic(&msg_value_inner, &msg_value_content);
|
||||||
|
} else if (arg_type == 'u') {
|
||||||
|
tbl->dbus_message_iter_get_basic(&msg_value, &msg_value_content);
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "[WARNING] Couldn't get %s::%s: Expected variant or string, got: %c\n", namespace, key, arg_type);
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwFALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
listener(handle, msg_value_content);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* free the message */
|
||||||
|
tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
return MwTRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwLLDBusFreeContext(MwLLDBusFuncTable* tbl, MwLLDBusContext* ctx) {
|
||||||
|
if(!tbl->lib) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(ctx->dbus_reply) tbl->dbus_message_unref(ctx->dbus_reply);
|
||||||
|
if(ctx->dbus_conn) tbl->dbus_connection_unref(ctx->dbus_conn);
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
|
||||||
77
src/string.c
77
src/string.c
|
|
@ -37,3 +37,80 @@ void MwStringTime(char* out, time_t t) {
|
||||||
sprintf(out, "%s %2d %02d:%02d %d", months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, 1900 + tm->tm_year);
|
sprintf(out, "%s %2d %02d:%02d %d", months[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, 1900 + tm->tm_year);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
void MwStringPrintIntoBuffer(char* out, MwU32 size, const char* fmt, ...) {
|
||||||
|
va_list va;
|
||||||
|
va_start(va, fmt);
|
||||||
|
|
||||||
|
#if __STDC_VERSION__ >= 199901L
|
||||||
|
vsnprintf(out, size, fmt, va);
|
||||||
|
#else
|
||||||
|
vsprintf(out, fmt, va);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
va_end(va);
|
||||||
|
};
|
||||||
|
|
||||||
|
MWDECL MwBool MwStringIsKeyUTF8(MwU32 key) {
|
||||||
|
unsigned char bytes[4];
|
||||||
|
int i;
|
||||||
|
bytes[0] = (key & 0x000000FF);
|
||||||
|
bytes[1] = (key & 0x0000FF00) >> 8;
|
||||||
|
bytes[2] = (key & 0x00FF0000) >> 16;
|
||||||
|
bytes[3] = (key & 0xFF000000) >> 24;
|
||||||
|
|
||||||
|
for(i = 0; i < sizeof(MwU32); i++) {
|
||||||
|
if(( // ASCII
|
||||||
|
// use bytes[0] <= 0x7F to allow ASCII control characters
|
||||||
|
bytes[0] == 0x09 ||
|
||||||
|
bytes[0] == 0x0A ||
|
||||||
|
bytes[0] == 0x0D ||
|
||||||
|
(0x20 <= bytes[0] && bytes[0] <= 0x7E))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( // non-overlong 2-byte
|
||||||
|
(0xC2 <= bytes[0] && bytes[0] <= 0xDF) &&
|
||||||
|
(0x80 <= bytes[1] && bytes[1] <= 0xBF))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( // excluding overlongs
|
||||||
|
bytes[0] == 0xE0 &&
|
||||||
|
(0xA0 <= bytes[1] && bytes[1] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[2] && bytes[2] <= 0xBF)) ||
|
||||||
|
( // straight 3-byte
|
||||||
|
((0xE1 <= bytes[0] && bytes[0] <= 0xEC) ||
|
||||||
|
bytes[0] == 0xEE ||
|
||||||
|
bytes[0] == 0xEF) &&
|
||||||
|
(0x80 <= bytes[1] && bytes[1] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[2] && bytes[2] <= 0xBF)) ||
|
||||||
|
( // excluding surrogates
|
||||||
|
bytes[0] == 0xED &&
|
||||||
|
(0x80 <= bytes[1] && bytes[1] <= 0x9F) &&
|
||||||
|
(0x80 <= bytes[2] && bytes[2] <= 0xBF))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(( // planes 1-3
|
||||||
|
bytes[0] == 0xF0 &&
|
||||||
|
(0x90 <= bytes[1] && bytes[1] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[3] && bytes[3] <= 0xBF)) ||
|
||||||
|
( // planes 4-15
|
||||||
|
(0xF1 <= bytes[0] && bytes[0] <= 0xF3) &&
|
||||||
|
(0x80 <= bytes[1] && bytes[1] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[3] && bytes[3] <= 0xBF)) ||
|
||||||
|
( // plane 16
|
||||||
|
bytes[0] == 0xF4 &&
|
||||||
|
(0x80 <= bytes[1] && bytes[1] <= 0x8F) &&
|
||||||
|
(0x80 <= bytes[2] && bytes[2] <= 0xBF) &&
|
||||||
|
(0x80 <= bytes[3] && bytes[3] <= 0xBF))) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
|
||||||
384
src/text.c
384
src/text.c
|
|
@ -1,384 +0,0 @@
|
||||||
#include <Mw/Milsko.h>
|
|
||||||
|
|
||||||
#if defined(USE_FREETYPE2)
|
|
||||||
#include <ft2build.h>
|
|
||||||
#include FT_FREETYPE_H
|
|
||||||
|
|
||||||
typedef struct ttf {
|
|
||||||
FT_Library library;
|
|
||||||
FT_Face face;
|
|
||||||
void* data;
|
|
||||||
} ttf_t;
|
|
||||||
|
|
||||||
#define TTF
|
|
||||||
#elif defined(USE_STB_TRUETYPE)
|
|
||||||
#include "../external/stb_truetype.h"
|
|
||||||
|
|
||||||
typedef struct ttf {
|
|
||||||
stbtt_fontinfo font;
|
|
||||||
void* data;
|
|
||||||
float scale;
|
|
||||||
int ascent;
|
|
||||||
int descent;
|
|
||||||
} ttf_t;
|
|
||||||
|
|
||||||
#define TTF
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define FontWidth 7
|
|
||||||
#define FontHeight 14
|
|
||||||
|
|
||||||
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
|
||||||
int i = 0, x, y, sx, sy;
|
|
||||||
int tw, th;
|
|
||||||
unsigned char* px;
|
|
||||||
MwRect r;
|
|
||||||
MwLLPixmap p;
|
|
||||||
|
|
||||||
if(strlen(text) == 0) text = " ";
|
|
||||||
tw = MwTextWidth(handle, text);
|
|
||||||
th = MwTextHeight(handle, text);
|
|
||||||
px = malloc(tw * th * 4);
|
|
||||||
|
|
||||||
memset(px, 0, tw * th * 4);
|
|
||||||
|
|
||||||
sx = 0;
|
|
||||||
sy = 0;
|
|
||||||
|
|
||||||
while(text[i] != 0) {
|
|
||||||
int out;
|
|
||||||
i += MwUTF8ToUTF32(text + i, &out);
|
|
||||||
|
|
||||||
if(out > 0xff) {
|
|
||||||
out = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(out == '\n') {
|
|
||||||
sx = 0;
|
|
||||||
sy += FontHeight;
|
|
||||||
} else {
|
|
||||||
for(y = 0; y < FontHeight; y++) {
|
|
||||||
for(x = 0; x < FontWidth; x++) {
|
|
||||||
unsigned char* ppx = &px[((sy + y) * tw + sx + x) * 4];
|
|
||||||
if((bold ? MwBoldFontData : MwFontData)[out].data[y] & (1 << ((FontWidth - 1) - x))) {
|
|
||||||
ppx[0] = color->common.red;
|
|
||||||
ppx[1] = color->common.green;
|
|
||||||
ppx[2] = color->common.blue;
|
|
||||||
ppx[3] = 255;
|
|
||||||
} else {
|
|
||||||
ppx[0] = 0;
|
|
||||||
ppx[1] = 0;
|
|
||||||
ppx[2] = 0;
|
|
||||||
ppx[3] = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sx += FontWidth;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p = MwLoadRaw(handle, px, tw, th);
|
|
||||||
r.x = point->x;
|
|
||||||
r.y = point->y - th / 2;
|
|
||||||
r.width = tw;
|
|
||||||
r.height = th;
|
|
||||||
|
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
|
||||||
r.x -= tw / 2;
|
|
||||||
} else if(align == MwALIGNMENT_END) {
|
|
||||||
r.x -= tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
|
||||||
MwLLDestroyPixmap(p);
|
|
||||||
free(px);
|
|
||||||
}
|
|
||||||
|
|
||||||
#if defined(USE_STB_TRUETYPE)
|
|
||||||
static int ttf_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
|
||||||
ttf_t* ttf = MwGetVoid(handle, bold ? MwNboldFont : MwNfont);
|
|
||||||
unsigned char* px;
|
|
||||||
int tw, th;
|
|
||||||
MwRect r;
|
|
||||||
MwLLPixmap p;
|
|
||||||
int ax, lsb;
|
|
||||||
int x = 0, y = 0;
|
|
||||||
if(ttf == NULL) return 1;
|
|
||||||
|
|
||||||
tw = MwTextWidth(handle, text);
|
|
||||||
th = MwTextHeight(handle, text);
|
|
||||||
px = malloc(tw * th * 4);
|
|
||||||
|
|
||||||
memset(px, 0, tw * th * 4);
|
|
||||||
while(text[0] != 0) {
|
|
||||||
int c;
|
|
||||||
int x0, y0, x1, y1, cx, cy;
|
|
||||||
int ow, oh;
|
|
||||||
unsigned char* out;
|
|
||||||
|
|
||||||
text += MwUTF8ToUTF32(text, &c);
|
|
||||||
if(c == '\n') {
|
|
||||||
x = 0;
|
|
||||||
y += (ttf->ascent - ttf->descent) * ttf->scale;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
stbtt_GetCodepointHMetrics(&ttf->font, c, &ax, &lsb);
|
|
||||||
|
|
||||||
stbtt_GetCodepointBitmapBox(&ttf->font, c, ttf->scale, ttf->scale, &x0, &y0, &x1, &y1);
|
|
||||||
ow = x1 - x0;
|
|
||||||
oh = y1 - y0;
|
|
||||||
out = malloc(ow * oh);
|
|
||||||
stbtt_MakeCodepointBitmap(&ttf->font, out, ow, oh, ow, ttf->scale, ttf->scale, c);
|
|
||||||
|
|
||||||
for(cy = 0; cy < oh; cy++) {
|
|
||||||
for(cx = 0; cx < ow; cx++) {
|
|
||||||
int ox = x + (lsb * ttf->scale) + cx;
|
|
||||||
int oy = y + (ttf->ascent * ttf->scale) + y0 + cy;
|
|
||||||
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
|
||||||
|
|
||||||
opx[0] = color->common.red;
|
|
||||||
opx[1] = color->common.green;
|
|
||||||
opx[2] = color->common.blue;
|
|
||||||
opx[3] = out[cy * ow + cx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x += ax * ttf->scale;
|
|
||||||
|
|
||||||
free(out);
|
|
||||||
}
|
|
||||||
|
|
||||||
p = MwLoadRaw(handle, px, tw, th);
|
|
||||||
r.x = point->x;
|
|
||||||
r.y = point->y - th / 2;
|
|
||||||
r.width = tw;
|
|
||||||
r.height = th;
|
|
||||||
|
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
|
||||||
r.x -= tw / 2;
|
|
||||||
} else if(align == MwALIGNMENT_END) {
|
|
||||||
r.x -= tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
|
||||||
MwLLDestroyPixmap(p);
|
|
||||||
free(px);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ttf_MwTextWidth(MwWidget handle, const char* text) {
|
|
||||||
ttf_t* ttf = MwGetVoid(handle, MwNfont);
|
|
||||||
int ax, lsb;
|
|
||||||
int tw = 0;
|
|
||||||
if(ttf == NULL) return -1;
|
|
||||||
|
|
||||||
while(text[0] != 0) {
|
|
||||||
int c;
|
|
||||||
text += MwUTF8ToUTF32(text, &c);
|
|
||||||
|
|
||||||
stbtt_GetCodepointHMetrics(&ttf->font, c, &ax, &lsb);
|
|
||||||
|
|
||||||
tw += ax * ttf->scale;
|
|
||||||
}
|
|
||||||
|
|
||||||
return tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ttf_MwTextHeight(MwWidget handle, int count) {
|
|
||||||
ttf_t* ttf = MwGetVoid(handle, MwNfont);
|
|
||||||
if(ttf == NULL) return -1;
|
|
||||||
|
|
||||||
return (ttf->ascent - ttf->descent) * ttf->scale * count;
|
|
||||||
}
|
|
||||||
#elif defined(USE_FREETYPE2)
|
|
||||||
static int ttf_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
|
||||||
ttf_t* ttf = MwGetVoid(handle, bold ? MwNboldFont : MwNfont);
|
|
||||||
int tw, th;
|
|
||||||
unsigned char* px;
|
|
||||||
MwLLPixmap p;
|
|
||||||
MwRect r;
|
|
||||||
int x = 0, y = 0;
|
|
||||||
if(ttf == NULL) return 1;
|
|
||||||
|
|
||||||
tw = MwTextWidth(handle, text);
|
|
||||||
th = MwTextHeight(handle, text);
|
|
||||||
px = malloc(tw * th * 4);
|
|
||||||
|
|
||||||
memset(px, 0, tw * th * 4);
|
|
||||||
while(text[0] != 0) {
|
|
||||||
int c;
|
|
||||||
FT_Bitmap* bmp;
|
|
||||||
int cy, cx;
|
|
||||||
int l = MwUTF8ToUTF32(text, &c);
|
|
||||||
if(l <= 0) break;
|
|
||||||
text += l;
|
|
||||||
|
|
||||||
if(c == '\n') {
|
|
||||||
x = 0;
|
|
||||||
y += ttf->face->height * 14 / ttf->face->units_per_EM;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_Load_Char(ttf->face, c, FT_LOAD_RENDER);
|
|
||||||
bmp = &ttf->face->glyph->bitmap;
|
|
||||||
|
|
||||||
for(cy = 0; cy < bmp->rows; cy++) {
|
|
||||||
for(cx = 0; cx < bmp->width; cx++) {
|
|
||||||
int ox = x + cx + ttf->face->glyph->bitmap_left;
|
|
||||||
int oy = y + (ttf->face->height * 14 / ttf->face->units_per_EM) - ttf->face->glyph->bitmap_top + cy + (ttf->face->descender * 14 / ttf->face->units_per_EM);
|
|
||||||
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
|
||||||
|
|
||||||
opx[0] = color->common.red;
|
|
||||||
opx[1] = color->common.green;
|
|
||||||
opx[2] = color->common.blue;
|
|
||||||
opx[3] = bmp->buffer[cy * bmp->pitch + cx];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
x += ttf->face->glyph->metrics.horiAdvance / 64;
|
|
||||||
}
|
|
||||||
|
|
||||||
p = MwLoadRaw(handle, px, tw, th);
|
|
||||||
r.x = point->x;
|
|
||||||
r.y = point->y - th / 2;
|
|
||||||
r.width = tw;
|
|
||||||
r.height = th;
|
|
||||||
|
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
|
||||||
r.x -= tw / 2;
|
|
||||||
} else if(align == MwALIGNMENT_END) {
|
|
||||||
r.x -= tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
|
||||||
MwLLDestroyPixmap(p);
|
|
||||||
free(px);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ttf_MwTextWidth(MwWidget handle, const char* text) {
|
|
||||||
ttf_t* ttf = MwGetVoid(handle, MwNfont);
|
|
||||||
int tw = 0, mtw = 0;
|
|
||||||
if(ttf == NULL) return -1;
|
|
||||||
|
|
||||||
while(text[0] != 0) {
|
|
||||||
int c;
|
|
||||||
int l = MwUTF8ToUTF32(text, &c);
|
|
||||||
if(l <= 0) break;
|
|
||||||
text += l;
|
|
||||||
if(c == '\n') {
|
|
||||||
tw = 0;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
FT_Load_Char(ttf->face, c, FT_LOAD_RENDER);
|
|
||||||
|
|
||||||
tw += ttf->face->glyph->metrics.horiAdvance / 64;
|
|
||||||
if(tw > mtw) mtw = tw;
|
|
||||||
}
|
|
||||||
|
|
||||||
return mtw;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int ttf_MwTextHeight(MwWidget handle, int count) {
|
|
||||||
ttf_t* ttf = MwGetVoid(handle, MwNfont);
|
|
||||||
if(ttf == NULL) return -1;
|
|
||||||
|
|
||||||
return (ttf->face->height * 14 / ttf->face->units_per_EM) * count;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, int align, MwLLColor color) {
|
|
||||||
if(strlen(text) == 0) return;
|
|
||||||
#ifdef TTF
|
|
||||||
if(ttf_MwDrawText(handle, point, text, bold, align, color))
|
|
||||||
#endif
|
|
||||||
bitmap_MwDrawText(handle, point, text, bold, align, color);
|
|
||||||
}
|
|
||||||
|
|
||||||
int MwTextWidth(MwWidget handle, const char* text) {
|
|
||||||
/* TODO: check newline */
|
|
||||||
#ifdef TTF
|
|
||||||
int st;
|
|
||||||
|
|
||||||
if((st = ttf_MwTextWidth(handle, text)) != -1) return st;
|
|
||||||
#else
|
|
||||||
(void)handle;
|
|
||||||
|
|
||||||
#endif
|
|
||||||
return MwUTF8Length(text) * FontWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
int MwTextHeight(MwWidget handle, const char* text) {
|
|
||||||
int c = 1;
|
|
||||||
int i = 0;
|
|
||||||
#ifdef TTF
|
|
||||||
int st;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
(void)handle;
|
|
||||||
(void)text;
|
|
||||||
|
|
||||||
while(text[i] != 0) {
|
|
||||||
int out;
|
|
||||||
int l = MwUTF8ToUTF32(text + i, &out);
|
|
||||||
if(l == 0) break;
|
|
||||||
i += l;
|
|
||||||
|
|
||||||
if(out == '\n') c++;
|
|
||||||
}
|
|
||||||
#ifdef TTF
|
|
||||||
if((st = ttf_MwTextHeight(handle, c)) != -1) return st;
|
|
||||||
#endif
|
|
||||||
return FontHeight * c;
|
|
||||||
}
|
|
||||||
|
|
||||||
void* MwFontLoad(unsigned char* data, unsigned int size) {
|
|
||||||
#if defined(USE_FREETYPE2)
|
|
||||||
ttf_t* ttf = malloc(sizeof(*ttf));
|
|
||||||
ttf->data = malloc(size);
|
|
||||||
memcpy(ttf->data, data, size);
|
|
||||||
FT_Init_FreeType(&ttf->library);
|
|
||||||
FT_New_Memory_Face(ttf->library, ttf->data, size, 0, &ttf->face);
|
|
||||||
|
|
||||||
FT_Set_Pixel_Sizes(ttf->face, 0, 14);
|
|
||||||
|
|
||||||
return ttf;
|
|
||||||
#elif defined(USE_STB_TRUETYPE)
|
|
||||||
ttf_t* ttf = malloc(sizeof(*ttf));
|
|
||||||
ttf->data = malloc(size);
|
|
||||||
memcpy(ttf->data, data, size);
|
|
||||||
stbtt_InitFont(&ttf->font, ttf->data, 0);
|
|
||||||
|
|
||||||
ttf->scale = stbtt_ScaleForPixelHeight(&ttf->font, 16);
|
|
||||||
stbtt_GetFontVMetrics(&ttf->font, &ttf->ascent, &ttf->descent, 0);
|
|
||||||
|
|
||||||
return ttf;
|
|
||||||
#else
|
|
||||||
(void)data;
|
|
||||||
(void)size;
|
|
||||||
return NULL;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void MwFontFree(void* handle) {
|
|
||||||
#if defined(USE_FREETYPE2)
|
|
||||||
ttf_t* ttf = handle;
|
|
||||||
|
|
||||||
FT_Done_Face(ttf->face);
|
|
||||||
FT_Done_FreeType(ttf->library);
|
|
||||||
|
|
||||||
free(ttf->data);
|
|
||||||
free(ttf);
|
|
||||||
#elif defined(USE_STB_TRUETYPE)
|
|
||||||
ttf_t* ttf = handle;
|
|
||||||
|
|
||||||
free(ttf->data);
|
|
||||||
free(ttf);
|
|
||||||
#else
|
|
||||||
(void)handle;
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
unsigned char MwBoldTTFData[] = {
|
unsigned char MwBoldMonospaceTTFData[] = {
|
||||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x04, 0x00, 0x10,
|
0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x04, 0x00, 0x10,
|
||||||
0x46, 0x46, 0x54, 0x4d, 0xac, 0x0d, 0xe4, 0x44, 0x00, 0x00, 0x8d, 0x3c,
|
0x46, 0x46, 0x54, 0x4d, 0xac, 0x0d, 0xe4, 0x44, 0x00, 0x00, 0x8d, 0x3c,
|
||||||
0x00, 0x00, 0x00, 0x1c, 0x4f, 0x53, 0x2f, 0x32, 0xa4, 0xe6, 0xab, 0x72,
|
0x00, 0x00, 0x00, 0x1c, 0x4f, 0x53, 0x2f, 0x32, 0xa4, 0xe6, 0xab, 0x72,
|
||||||
|
|
@ -3018,5 +3018,5 @@ unsigned char MwBoldTTFData[] = {
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x16, 0xe7, 0x6b,
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x16, 0xe7, 0x6b,
|
||||||
0x00, 0x00, 0x00, 0x00, 0xe1, 0xa9, 0xde, 0x3f, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0xe1, 0xa9, 0xde, 0x3f, 0x00, 0x00, 0x00, 0x00,
|
||||||
0xe5, 0x4d, 0x1e, 0x99};
|
0xe5, 0x4d, 0x1e, 0x99};
|
||||||
unsigned int MwBoldTTFDataSize = 36184;
|
unsigned int MwBoldMonospaceTTFDataSize = 36184;
|
||||||
#endif
|
#endif
|
||||||
3052
src/text/font/boldttf.c
Normal file
3052
src/text/font/boldttf.c
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -1,7 +1,7 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
#if defined(USE_STB_TRUETYPE) || defined(USE_FREETYPE2)
|
||||||
unsigned char MwTTFData[] = {
|
unsigned char MwMonospaceTTFData[] = {
|
||||||
0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x04, 0x00, 0x10,
|
0x00, 0x01, 0x00, 0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x04, 0x00, 0x10,
|
||||||
0x46, 0x46, 0x54, 0x4d, 0xac, 0x0d, 0xe4, 0x23, 0x00, 0x00, 0x8d, 0x3c,
|
0x46, 0x46, 0x54, 0x4d, 0xac, 0x0d, 0xe4, 0x23, 0x00, 0x00, 0x8d, 0x3c,
|
||||||
0x00, 0x00, 0x00, 0x1c, 0x4f, 0x53, 0x2f, 0x32, 0xa3, 0xba, 0xa8, 0x6a,
|
0x00, 0x00, 0x00, 0x1c, 0x4f, 0x53, 0x2f, 0x32, 0xa3, 0xba, 0xa8, 0x6a,
|
||||||
|
|
@ -3018,5 +3018,5 @@ unsigned char MwTTFData[] = {
|
||||||
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x16, 0xe7, 0x6b,
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0xe5, 0x16, 0xe7, 0x6b,
|
||||||
0x00, 0x00, 0x00, 0x00, 0xe1, 0xa9, 0xde, 0x41, 0x00, 0x00, 0x00, 0x00,
|
0x00, 0x00, 0x00, 0x00, 0xe1, 0xa9, 0xde, 0x41, 0x00, 0x00, 0x00, 0x00,
|
||||||
0xe5, 0x4d, 0x1e, 0x76};
|
0xe5, 0x4d, 0x1e, 0x76};
|
||||||
unsigned int MwTTFDataSize = 36184;
|
unsigned int MwMonospaceTTFDataSize = 36184;
|
||||||
#endif
|
#endif
|
||||||
2945
src/text/font/ttf.c
Normal file
2945
src/text/font/ttf.c
Normal file
File diff suppressed because it is too large
Load diff
194
src/text/ft2.c
Normal file
194
src/text/ft2.c
Normal file
|
|
@ -0,0 +1,194 @@
|
||||||
|
#ifdef USE_FREETYPE2
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
#include <ft2build.h>
|
||||||
|
#include FT_FREETYPE_H
|
||||||
|
|
||||||
|
static struct ft_table {
|
||||||
|
FT_Error (*FT_Init_FreeType)(FT_Library* alibrary);
|
||||||
|
FT_Error (*FT_New_Memory_Face)(FT_Library library,
|
||||||
|
const FT_Byte* file_base,
|
||||||
|
FT_Long file_size,
|
||||||
|
FT_Long face_index,
|
||||||
|
FT_Face* aface);
|
||||||
|
FT_Error (*FT_Set_Pixel_Sizes)(FT_Face face,
|
||||||
|
FT_UInt pixel_width,
|
||||||
|
FT_UInt pixel_height);
|
||||||
|
FT_Error (*FT_Load_Char)(FT_Face face,
|
||||||
|
FT_ULong char_code,
|
||||||
|
FT_Int32 load_flags);
|
||||||
|
FT_Error (*FT_Get_Kerning)(FT_Face face,
|
||||||
|
FT_UInt left_glyph,
|
||||||
|
FT_UInt right_glyph,
|
||||||
|
FT_UInt kern_mode,
|
||||||
|
FT_Vector* akerning);
|
||||||
|
FT_Error (*FT_Done_Face)(FT_Face face);
|
||||||
|
FT_Error (*FT_Done_FreeType)(FT_Library library);
|
||||||
|
|
||||||
|
} ft_table;
|
||||||
|
|
||||||
|
struct _MwFLFont {
|
||||||
|
FT_Library library;
|
||||||
|
FT_Face face;
|
||||||
|
void* data;
|
||||||
|
int px;
|
||||||
|
};
|
||||||
|
static int ft2_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color) {
|
||||||
|
int tw, th;
|
||||||
|
unsigned char* px;
|
||||||
|
MwLLPixmap p;
|
||||||
|
MwRect r;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
|
||||||
|
tw = MwTextWidth(handle, ttf, text);
|
||||||
|
th = MwTextHeight(handle, ttf, text);
|
||||||
|
px = malloc(tw * th * 4);
|
||||||
|
|
||||||
|
memset(px, 0, tw * th * 4);
|
||||||
|
while(text[0] != 0) {
|
||||||
|
FT_Bitmap* bmp;
|
||||||
|
int cy, cx;
|
||||||
|
int c, c2;
|
||||||
|
int l = MwUTF8ToUTF32(text, &c);
|
||||||
|
FT_Vector vec;
|
||||||
|
const char* old_text;
|
||||||
|
if(l <= 0) break;
|
||||||
|
text += l;
|
||||||
|
|
||||||
|
if(c == '\n') {
|
||||||
|
x = 0;
|
||||||
|
y += ttf->face->height * ttf->px / ttf->face->units_per_EM;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ft_table.FT_Load_Char(ttf->face, c, FT_LOAD_RENDER);
|
||||||
|
bmp = &ttf->face->glyph->bitmap;
|
||||||
|
|
||||||
|
for(cy = 0; cy < bmp->rows; cy++) {
|
||||||
|
for(cx = 0; cx < bmp->width; cx++) {
|
||||||
|
int ox = x + (ttf->face->glyph->metrics.horiBearingX / 64) + cx + ttf->face->glyph->bitmap_left;
|
||||||
|
int oy = y + (ttf->face->height * ttf->px / ttf->face->units_per_EM) - ttf->face->glyph->bitmap_top + cy + (ttf->face->descender * ttf->px / ttf->face->units_per_EM);
|
||||||
|
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
||||||
|
opx[0] = color->common.red;
|
||||||
|
opx[1] = color->common.green;
|
||||||
|
opx[2] = color->common.blue;
|
||||||
|
/* overflow check */
|
||||||
|
if(opx[3] + bmp->buffer[cy * bmp->pitch + cx] < opx[3]) {
|
||||||
|
opx[3] = 255;
|
||||||
|
} else {
|
||||||
|
opx[3] = bmp->buffer[cy * bmp->pitch + cx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x += (ttf->face->glyph->advance.x >> 6) + (ttf->face->glyph->metrics.horiBearingX >> 6);
|
||||||
|
|
||||||
|
old_text = text;
|
||||||
|
text += MwUTF8ToUTF32(text, &c2);
|
||||||
|
|
||||||
|
if(c2 != '\n') {
|
||||||
|
ft_table.FT_Get_Kerning(ttf->face, c, c2, FT_KERNING_DEFAULT, &vec);
|
||||||
|
|
||||||
|
x += vec.x >> 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
text = old_text;
|
||||||
|
}
|
||||||
|
|
||||||
|
p = MwLoadRaw(handle, px, tw, th);
|
||||||
|
r.x = point->x;
|
||||||
|
r.y = point->y - th / 2;
|
||||||
|
r.width = tw;
|
||||||
|
r.height = th;
|
||||||
|
|
||||||
|
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||||
|
MwLLDestroyPixmap(p);
|
||||||
|
free(px);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ft2_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||||
|
int tw = 0, mtw = 0;
|
||||||
|
|
||||||
|
while(text[0] != 0) {
|
||||||
|
int c, c2;
|
||||||
|
FT_Vector vec;
|
||||||
|
const char* old_text;
|
||||||
|
|
||||||
|
text += MwUTF8ToUTF32(text, &c);
|
||||||
|
if(c == '\n') {
|
||||||
|
tw = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ft_table.FT_Load_Char(ttf->face, c, FT_LOAD_DEFAULT);
|
||||||
|
|
||||||
|
tw += (ttf->face->glyph->advance.x >> 6) + (ttf->face->glyph->metrics.horiBearingX >> 6);
|
||||||
|
|
||||||
|
old_text = text;
|
||||||
|
text += MwUTF8ToUTF32(text, &c2);
|
||||||
|
|
||||||
|
if(c2 != '\n') {
|
||||||
|
ft_table.FT_Get_Kerning(ttf->face, c, c2, FT_KERNING_DEFAULT, &vec);
|
||||||
|
|
||||||
|
tw += vec.x >> 6;
|
||||||
|
}
|
||||||
|
|
||||||
|
text = old_text;
|
||||||
|
if(tw > mtw) mtw = tw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mtw + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int ft2_MwTextHeight(MwFLFont ttf, int count) {
|
||||||
|
return ceil((ttf->face->height * ttf->px / ttf->face->units_per_EM) * count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* ft2_MwFontLoad(unsigned char* data, unsigned int size, int px) {
|
||||||
|
MwFLFont ttf = malloc(sizeof(*ttf));
|
||||||
|
ttf->data = malloc(size);
|
||||||
|
memcpy(ttf->data, data, size);
|
||||||
|
ft_table.FT_Init_FreeType(&ttf->library);
|
||||||
|
ft_table.FT_New_Memory_Face(ttf->library, ttf->data, size, 0, &ttf->face);
|
||||||
|
|
||||||
|
ttf->px = px;
|
||||||
|
ft_table.FT_Set_Pixel_Sizes(ttf->face, 0, ttf->px);
|
||||||
|
|
||||||
|
return ttf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void ft2_MwFontFree(void* handle) {
|
||||||
|
MwFLFont ttf = handle;
|
||||||
|
|
||||||
|
ft_table.FT_Done_Face(ttf->face);
|
||||||
|
ft_table.FT_Done_FreeType(ttf->library);
|
||||||
|
|
||||||
|
free(ttf->data);
|
||||||
|
free(ttf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MWFL_FT2Setup(void) {
|
||||||
|
/* Try and load FreeType2. If it fails, return 1, signifying we default to stbtt. */
|
||||||
|
void* ftlib;
|
||||||
|
if(!(ftlib = MwDynamicOpen("libfreetype.so"))) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
ft_table.FT_Init_FreeType = MwDynamicSymbol(ftlib, "FT_Init_FreeType");
|
||||||
|
ft_table.FT_New_Memory_Face = MwDynamicSymbol(ftlib, "FT_New_Memory_Face");
|
||||||
|
ft_table.FT_Set_Pixel_Sizes = MwDynamicSymbol(ftlib, "FT_Set_Pixel_Sizes");
|
||||||
|
ft_table.FT_Load_Char = MwDynamicSymbol(ftlib, "FT_Load_Char");
|
||||||
|
ft_table.FT_Get_Kerning = MwDynamicSymbol(ftlib, "FT_Get_Kerning");
|
||||||
|
ft_table.FT_Done_Face = MwDynamicSymbol(ftlib, "FT_Done_Face");
|
||||||
|
ft_table.FT_Done_FreeType = MwDynamicSymbol(ftlib, "FT_Done_FreeType");
|
||||||
|
|
||||||
|
MwFLDrawText = ft2_MwDrawText;
|
||||||
|
MwFLTextWidth = ft2_MwTextWidth;
|
||||||
|
MwFLTextHeight = ft2_MwTextHeight;
|
||||||
|
MwFLFontLoad = ft2_MwFontLoad;
|
||||||
|
MwFLFontFree = ft2_MwFontFree;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
163
src/text/stbtt.c
Normal file
163
src/text/stbtt.c
Normal file
|
|
@ -0,0 +1,163 @@
|
||||||
|
#ifdef USE_STB_TRUETYPE
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
#include "../../external/stb_truetype.h"
|
||||||
|
|
||||||
|
struct _MwFLFont {
|
||||||
|
stbtt_fontinfo font;
|
||||||
|
void* data;
|
||||||
|
float scale;
|
||||||
|
int ascent;
|
||||||
|
int descent;
|
||||||
|
};
|
||||||
|
|
||||||
|
static int stbtt_MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, MwLLColor color) {
|
||||||
|
unsigned char* px;
|
||||||
|
int tw, th;
|
||||||
|
MwRect r;
|
||||||
|
MwLLPixmap p;
|
||||||
|
int ax, lsb;
|
||||||
|
int x = 0, y = 0;
|
||||||
|
|
||||||
|
tw = MwTextWidth(handle, ttf, text);
|
||||||
|
th = MwTextHeight(handle, ttf, text);
|
||||||
|
px = malloc(tw * th * 4);
|
||||||
|
|
||||||
|
memset(px, 0, tw * th * 4);
|
||||||
|
while(text[0] != 0) {
|
||||||
|
int c, c2;
|
||||||
|
int x0, y0, x1, y1, cx, cy;
|
||||||
|
int ow, oh;
|
||||||
|
unsigned char* out;
|
||||||
|
int kern;
|
||||||
|
const char* old_text;
|
||||||
|
|
||||||
|
text += MwUTF8ToUTF32(text, &c);
|
||||||
|
if(c == '\n') {
|
||||||
|
x = 0;
|
||||||
|
y += ceil((ttf->ascent - ttf->descent) * ttf->scale);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
stbtt_GetCodepointHMetrics(&ttf->font, c, &ax, &lsb);
|
||||||
|
|
||||||
|
stbtt_GetCodepointBitmapBox(&ttf->font, c, ttf->scale, ttf->scale, &x0, &y0, &x1, &y1);
|
||||||
|
ow = x1 - x0;
|
||||||
|
oh = y1 - y0;
|
||||||
|
out = malloc(ow * oh);
|
||||||
|
stbtt_MakeCodepointBitmap(&ttf->font, out, ow, oh, ow, ttf->scale, ttf->scale, c);
|
||||||
|
|
||||||
|
for(cy = 0; cy < oh; cy++) {
|
||||||
|
for(cx = 0; cx < ow; cx++) {
|
||||||
|
int ox = x + ceil(lsb * ttf->scale) + cx;
|
||||||
|
int oy = y + ceil(ttf->ascent * ttf->scale) + y0 + cy;
|
||||||
|
unsigned char* opx = &px[(oy * tw + ox) * 4];
|
||||||
|
opx[0] = color->common.red;
|
||||||
|
opx[1] = color->common.green;
|
||||||
|
opx[2] = color->common.blue;
|
||||||
|
/* overflow check */
|
||||||
|
if(opx[3] + out[cy * ow + cx] < opx[3]) {
|
||||||
|
opx[3] = 255;
|
||||||
|
} else {
|
||||||
|
opx[3] = out[cy * ow + cx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
x += ceil(ax * ttf->scale);
|
||||||
|
|
||||||
|
old_text = text;
|
||||||
|
text += MwUTF8ToUTF32(text, &c2);
|
||||||
|
|
||||||
|
if(c2 != '\n') {
|
||||||
|
kern = stbtt_GetCodepointKernAdvance(&ttf->font, c, c2);
|
||||||
|
|
||||||
|
x += ceil(kern * ttf->scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
text = old_text;
|
||||||
|
|
||||||
|
free(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
p = MwLoadRaw(handle, px, tw, th);
|
||||||
|
r.x = point->x;
|
||||||
|
r.y = point->y - th / 2;
|
||||||
|
r.width = tw;
|
||||||
|
r.height = th;
|
||||||
|
|
||||||
|
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||||
|
MwLLDestroyPixmap(p);
|
||||||
|
free(px);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int stbtt_MwTextWidth(MwFLFont ttf, const char* text) {
|
||||||
|
int ax, lsb;
|
||||||
|
int tw = 0, mtw = 0;
|
||||||
|
|
||||||
|
while(text[0] != 0) {
|
||||||
|
int kern;
|
||||||
|
int c, c2;
|
||||||
|
const char* old_text;
|
||||||
|
|
||||||
|
text += MwUTF8ToUTF32(text, &c);
|
||||||
|
if(c == '\n') {
|
||||||
|
tw = 0;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
stbtt_GetCodepointHMetrics(&ttf->font, c, &ax, &lsb);
|
||||||
|
|
||||||
|
tw += ceil(ax * ttf->scale);
|
||||||
|
|
||||||
|
old_text = text;
|
||||||
|
text += MwUTF8ToUTF32(text, &c2);
|
||||||
|
|
||||||
|
if(c2 != '\n') {
|
||||||
|
kern = stbtt_GetCodepointKernAdvance(&ttf->font, c, c2);
|
||||||
|
|
||||||
|
tw += ceil(kern * ttf->scale);
|
||||||
|
}
|
||||||
|
|
||||||
|
text = old_text;
|
||||||
|
if(tw > mtw) mtw = tw;
|
||||||
|
}
|
||||||
|
|
||||||
|
return mtw + 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int stbtt_MwTextHeight(MwFLFont ttf, int count) {
|
||||||
|
return ceil((ttf->ascent - ttf->descent) * ttf->scale * count);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void* stbtt_MwFontLoad(unsigned char* data, unsigned int size, int px) {
|
||||||
|
MwFLFont ttf = malloc(sizeof(*ttf));
|
||||||
|
ttf->data = malloc(size);
|
||||||
|
memcpy(ttf->data, data, size);
|
||||||
|
stbtt_InitFont(&ttf->font, ttf->data, 0);
|
||||||
|
|
||||||
|
ttf->scale = stbtt_ScaleForMappingEmToPixels(&ttf->font, px);
|
||||||
|
stbtt_GetFontVMetrics(&ttf->font, &ttf->ascent, &ttf->descent, 0);
|
||||||
|
|
||||||
|
return ttf;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void stbtt_MwFontFree(void* handle) {
|
||||||
|
MwFLFont ttf = handle;
|
||||||
|
|
||||||
|
free(ttf->data);
|
||||||
|
free(ttf);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MwFL_STBTTSetup(void) {
|
||||||
|
MwFLDrawText = stbtt_MwDrawText;
|
||||||
|
MwFLTextWidth = stbtt_MwTextWidth;
|
||||||
|
MwFLTextHeight = stbtt_MwTextHeight;
|
||||||
|
MwFLFontLoad = stbtt_MwFontLoad;
|
||||||
|
MwFLFontFree = stbtt_MwFontFree;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
204
src/text/text.c
Normal file
204
src/text/text.c
Normal file
|
|
@ -0,0 +1,204 @@
|
||||||
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
|
int (*MwFLDrawText)(MwWidget handle, MwFLFont font, MwPoint* point, const char* text, MwLLColor color) = NULL;
|
||||||
|
int (*MwFLTextWidth)(MwFLFont font, const char* text) = NULL;
|
||||||
|
int (*MwFLTextHeight)(MwFLFont font, int count) = NULL;
|
||||||
|
void* (*MwFLFontLoad)(unsigned char* data, unsigned int size, int px) = NULL;
|
||||||
|
void (*MwFLFontFree)(void* handle) = NULL;
|
||||||
|
|
||||||
|
#if defined(USE_FREETYPE2) || defined(USE_STB_TRUETYPE)
|
||||||
|
#define TTF
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define FontWidth 7
|
||||||
|
#define FontHeight 14
|
||||||
|
|
||||||
|
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, MwLLColor color);
|
||||||
|
|
||||||
|
static int is_bold(MwWidget handle, MwFLFont ttf) {
|
||||||
|
size_t u = (size_t)ttf;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
if(u & MwFLFlagBold) return 1;
|
||||||
|
|
||||||
|
s = MwGetInteger(handle, MwNbold);
|
||||||
|
if(s == MwDEFAULT) return 0;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TTF
|
||||||
|
static int is_monospace(MwWidget handle, MwFLFont ttf) {
|
||||||
|
size_t u = (size_t)ttf;
|
||||||
|
int s;
|
||||||
|
|
||||||
|
if(u & MwFLFlagMonospace) return 1;
|
||||||
|
|
||||||
|
s = MwGetInteger(handle, MwNuseMonospace);
|
||||||
|
if(s == MwDEFAULT) return 0;
|
||||||
|
return s;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TTF
|
||||||
|
|
||||||
|
static MwFLFont assume_ttf(MwWidget handle, MwFLFont ttf) {
|
||||||
|
if(MwGetInteger(handle, MwNbitmapFont)) return NULL;
|
||||||
|
|
||||||
|
if(is_monospace(handle, ttf)) return is_bold(handle, ttf) ? MwGetVoid(handle, MwNboldMonospaceFont) : MwGetVoid(handle, MwNmonospaceFont);
|
||||||
|
return is_bold(handle, ttf) ? MwGetVoid(handle, MwNboldFont) : MwGetVoid(handle, MwNfont);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text, int align, MwLLColor color) {
|
||||||
|
MwPoint p = *point;
|
||||||
|
|
||||||
|
if(strlen(text) == 0) return;
|
||||||
|
#ifdef TTF
|
||||||
|
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if(align == MwALIGNMENT_CENTER) {
|
||||||
|
p.x -= MwTextWidth(handle, ttf, text) / 2;
|
||||||
|
} else if(align == MwALIGNMENT_END) {
|
||||||
|
p.x -= MwTextWidth(handle, ttf, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef TTF
|
||||||
|
if(MwFLDrawText)
|
||||||
|
if(MwGetInteger(handle, MwNbitmapFont) || ttf == NULL || MwFLDrawText(handle, ttf, &p, text, color))
|
||||||
|
#endif
|
||||||
|
bitmap_MwDrawText(handle, &p, text, is_bold(handle, ttf), color);
|
||||||
|
}
|
||||||
|
|
||||||
|
int MwTextWidth(MwWidget handle, MwFLFont ttf, const char* text) {
|
||||||
|
/* TODO: check newline */
|
||||||
|
#ifdef TTF
|
||||||
|
int st;
|
||||||
|
|
||||||
|
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||||
|
|
||||||
|
if(MwFLTextWidth)
|
||||||
|
if(!MwGetInteger(handle, MwNbitmapFont) && ttf != NULL && (st = MwFLTextWidth(ttf, text)) != -1) return st;
|
||||||
|
#else
|
||||||
|
(void)handle;
|
||||||
|
(void)ttf;
|
||||||
|
#endif
|
||||||
|
return MwUTF8Length(text) * FontWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
int MwTextHeight(MwWidget handle, MwFLFont ttf, const char* text) {
|
||||||
|
int c = 1;
|
||||||
|
int i = 0;
|
||||||
|
#ifdef TTF
|
||||||
|
int st;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef TTF
|
||||||
|
if(ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
|
||||||
|
#else
|
||||||
|
(void)handle;
|
||||||
|
(void)text;
|
||||||
|
(void)ttf;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
while(text[i] != 0) {
|
||||||
|
int out;
|
||||||
|
int l = MwUTF8ToUTF32(text + i, &out);
|
||||||
|
if(l == 0) break;
|
||||||
|
i += l;
|
||||||
|
|
||||||
|
if(out == '\n') c++;
|
||||||
|
}
|
||||||
|
#ifdef TTF
|
||||||
|
if(MwFLTextHeight)
|
||||||
|
if(!MwGetInteger(handle, MwNbitmapFont) && ttf != NULL && (st = MwFLTextHeight(ttf, c)) != -1) return st;
|
||||||
|
#endif
|
||||||
|
return FontHeight * c;
|
||||||
|
}
|
||||||
|
|
||||||
|
void* MwFontLoad(unsigned char* data, unsigned int size) {
|
||||||
|
if(MwFLFontLoad)
|
||||||
|
return MwFLFontLoad(data, size, 14);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MwFontFree(void* handle) {
|
||||||
|
if(MwFLFontFree) MwFLFontFree(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void bitmap_MwDrawText(MwWidget handle, MwPoint* point, const char* text, int bold, MwLLColor color) {
|
||||||
|
int i = 0, x, y, sx, sy;
|
||||||
|
int tw, th;
|
||||||
|
unsigned char* px;
|
||||||
|
MwRect r;
|
||||||
|
MwLLPixmap p;
|
||||||
|
|
||||||
|
if(strlen(text) == 0) text = " ";
|
||||||
|
tw = MwTextWidth(handle, NULL, text);
|
||||||
|
th = MwTextHeight(handle, NULL, text);
|
||||||
|
px = malloc(tw * th * 4);
|
||||||
|
|
||||||
|
memset(px, 0, tw * th * 4);
|
||||||
|
|
||||||
|
sx = 0;
|
||||||
|
sy = 0;
|
||||||
|
|
||||||
|
while(text[i] != 0) {
|
||||||
|
int out;
|
||||||
|
i += MwUTF8ToUTF32(text + i, &out);
|
||||||
|
|
||||||
|
if(out > 0xff) {
|
||||||
|
out = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(out == '\n') {
|
||||||
|
sx = 0;
|
||||||
|
sy += FontHeight;
|
||||||
|
} else {
|
||||||
|
for(y = 0; y < FontHeight; y++) {
|
||||||
|
for(x = 0; x < FontWidth; x++) {
|
||||||
|
unsigned char* ppx = &px[((sy + y) * tw + sx + x) * 4];
|
||||||
|
if((bold ? MwBoldFontData : MwFontData)[out].data[y] & (1 << ((FontWidth - 1) - x))) {
|
||||||
|
ppx[0] = color->common.red;
|
||||||
|
ppx[1] = color->common.green;
|
||||||
|
ppx[2] = color->common.blue;
|
||||||
|
ppx[3] = 255;
|
||||||
|
} else {
|
||||||
|
ppx[0] = 0;
|
||||||
|
ppx[1] = 0;
|
||||||
|
ppx[2] = 0;
|
||||||
|
ppx[3] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
sx += FontWidth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
p = MwLoadRaw(handle, px, tw, th);
|
||||||
|
r.x = point->x;
|
||||||
|
r.y = point->y - th / 2;
|
||||||
|
r.width = tw;
|
||||||
|
r.height = th;
|
||||||
|
|
||||||
|
MwLLDrawPixmap(handle->lowlevel, &r, p);
|
||||||
|
MwLLDestroyPixmap(p);
|
||||||
|
free(px);
|
||||||
|
}
|
||||||
|
|
||||||
|
typedef int (*call_t)(void);
|
||||||
|
void MwFLSetup(void) {
|
||||||
|
call_t calls[] = {
|
||||||
|
#ifdef USE_FREETYPE2
|
||||||
|
MWFL_FT2Setup,
|
||||||
|
#endif
|
||||||
|
#ifdef USE_STB_TRUETYPE
|
||||||
|
MwFL_STBTTSetup,
|
||||||
|
#endif
|
||||||
|
NULL};
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for(i = 0; calls[i] != NULL; i++) {
|
||||||
|
if(calls[i]() == 0) return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -2,27 +2,28 @@
|
||||||
|
|
||||||
#include "../../external/stb_ds.h"
|
#include "../../external/stb_ds.h"
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int wcreate(MwWidget handle) {
|
||||||
|
MwBox b = malloc(sizeof(*b));
|
||||||
|
memset(b, 0, sizeof(*b));
|
||||||
|
|
||||||
|
handle->internal = b;
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwSetInteger(handle, MwNorientation, MwHORIZONTAL);
|
MwSetInteger(handle, MwNorientation, MwHORIZONTAL);
|
||||||
MwSetInteger(handle, MwNmargin, 0);
|
MwSetInteger(handle, MwNmargin, 0);
|
||||||
MwSetInteger(handle, MwNpadding, 0);
|
MwSetInteger(handle, MwNpadding, 0);
|
||||||
|
MwSetInteger(handle, MwNhasBorder, 0);
|
||||||
|
MwSetInteger(handle, MwNinverted, 1);
|
||||||
|
|
||||||
|
b->layout = 0;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void destroy(MwWidget handle) {
|
||||||
MwRect r;
|
MwBox b = handle->internal;
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
free(b);
|
||||||
|
|
||||||
r.x = 0;
|
|
||||||
r.y = 0;
|
|
||||||
r.width = MwGetInteger(handle, MwNwidth);
|
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
|
||||||
MwDrawRect(handle, &r, base);
|
|
||||||
|
|
||||||
MwLLFreeColor(base);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Margin ((i != (arrlen(handle->children) - 1)) ? MwGetInteger(handle, MwNmargin) : 0)
|
#define Margin ((i != (arrlen(handle->children) - 1)) ? MwGetInteger(handle, MwNmargin) : 0)
|
||||||
|
|
@ -31,19 +32,22 @@ static void layout(MwWidget handle) {
|
||||||
int i;
|
int i;
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
int horiz = MwGetInteger(handle, MwNorientation) == MwHORIZONTAL ? 1 : 0;
|
int horiz = MwGetInteger(handle, MwNorientation) == MwHORIZONTAL ? 1 : 0;
|
||||||
int sz = MwGetInteger(handle, horiz ? MwNwidth : MwNheight) - MwGetInteger(handle, MwNpadding) * 2;
|
int sz = MwGetInteger(handle, horiz ? MwNwidth : MwNheight) - (MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0)) * 2;
|
||||||
int fsz = MwGetInteger(handle, horiz ? MwNheight : MwNwidth) - MwGetInteger(handle, MwNpadding) * 2;
|
int fsz = MwGetInteger(handle, horiz ? MwNheight : MwNwidth) - (MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0)) * 2;
|
||||||
int sk = MwGetInteger(handle, MwNpadding);
|
int sk = MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0);
|
||||||
|
|
||||||
for(i = 0; i < arrlen(handle->children); i++) {
|
for(i = 0; i < arrlen(handle->children); i++) {
|
||||||
int n = MwGetInteger(handle->children[i], MwNratio);
|
int n = MwGetInteger(handle->children[i], MwNratio);
|
||||||
int s = MwGetInteger(handle->children[i], MwNfixedSize);
|
int s = MwGetInteger(handle->children[i], MwNfixedSize);
|
||||||
if(n == MwDEFAULT) n = 1;
|
if(n == MwDEFAULT) n = 1;
|
||||||
|
|
||||||
|
if(handle->children[i]->destroyed) continue;
|
||||||
|
|
||||||
if(s != MwDEFAULT) {
|
if(s != MwDEFAULT) {
|
||||||
sz -= s + Margin;
|
sz -= s + Margin;
|
||||||
} else {
|
} else {
|
||||||
sum += n;
|
sum += n;
|
||||||
|
sz -= Margin;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -53,16 +57,17 @@ static void layout(MwWidget handle) {
|
||||||
int wsz;
|
int wsz;
|
||||||
if(n == MwDEFAULT) n = 1;
|
if(n == MwDEFAULT) n = 1;
|
||||||
|
|
||||||
|
if(handle->children[i]->destroyed) continue;
|
||||||
|
|
||||||
if(s != MwDEFAULT) {
|
if(s != MwDEFAULT) {
|
||||||
wsz = s;
|
wsz = s;
|
||||||
} else {
|
} else {
|
||||||
wsz = sz * n / sum;
|
wsz = sz * n / sum;
|
||||||
}
|
}
|
||||||
wsz -= Margin;
|
|
||||||
|
|
||||||
MwVaApply(handle->children[i],
|
MwVaApply(handle->children[i],
|
||||||
horiz ? MwNx : MwNy, sk, /* this is what gets changed */
|
horiz ? MwNx : MwNy, sk, /* this is what gets changed */
|
||||||
horiz ? MwNy : MwNx, MwGetInteger(handle, MwNpadding), /* fixed between widgets */
|
horiz ? MwNy : MwNx, MwGetInteger(handle, MwNpadding) + (MwGetInteger(handle, MwNhasBorder) ? MwDefaultBorderWidth(handle) : 0), /* fixed between widgets */
|
||||||
horiz ? MwNwidth : MwNheight, wsz, /* this is what gets changed */
|
horiz ? MwNwidth : MwNheight, wsz, /* this is what gets changed */
|
||||||
horiz ? MwNheight : MwNwidth, fsz, /* fixed between widgets */
|
horiz ? MwNheight : MwNwidth, fsz, /* fixed between widgets */
|
||||||
NULL);
|
NULL);
|
||||||
|
|
@ -70,27 +75,68 @@ static void layout(MwWidget handle) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void draw(MwWidget handle) {
|
||||||
|
MwRect r;
|
||||||
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
|
MwBox b = handle->internal;
|
||||||
|
|
||||||
|
r.x = 0;
|
||||||
|
r.y = 0;
|
||||||
|
r.width = MwGetInteger(handle, MwNwidth);
|
||||||
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
|
if(MwGetInteger(handle, MwNhasBorder)) {
|
||||||
|
MwDrawFrame(handle, &r, base, MwGetInteger(handle, MwNinverted));
|
||||||
|
}
|
||||||
|
|
||||||
|
MwDrawRect(handle, &r, base);
|
||||||
|
|
||||||
|
MwLLFreeColor(base);
|
||||||
|
|
||||||
|
if(b->layout) {
|
||||||
|
layout(handle);
|
||||||
|
|
||||||
|
b->layout = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void prop_change(MwWidget handle, const char* key) {
|
static void prop_change(MwWidget handle, const char* key) {
|
||||||
if(strcmp(key, MwNorientation) == 0) layout(handle);
|
if(strcmp(key, MwNorientation) == 0) {
|
||||||
|
MwBox b = handle->internal;
|
||||||
|
b->layout = 1;
|
||||||
|
|
||||||
|
MwForceRender(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void children_prop_change(MwWidget handle, MwWidget child, const char* key) {
|
static void children_prop_change(MwWidget handle, MwWidget child, const char* key) {
|
||||||
(void)child;
|
(void)child;
|
||||||
|
|
||||||
if(strcmp(key, MwNratio) == 0 || strcmp(key, MwNfixedSize) == 0) layout(handle);
|
if(strcmp(key, MwNratio) == 0 || strcmp(key, MwNfixedSize) == 0) {
|
||||||
|
MwBox b = handle->internal;
|
||||||
|
b->layout = 1;
|
||||||
|
|
||||||
|
MwForceRender(handle);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void resize(MwWidget handle) {
|
static void resize(MwWidget handle) {
|
||||||
layout(handle);
|
MwBox b = handle->internal;
|
||||||
|
b->layout = 1;
|
||||||
|
|
||||||
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void children_update(MwWidget handle) {
|
static void children_update(MwWidget handle) {
|
||||||
layout(handle);
|
MwBox b = handle->internal;
|
||||||
|
b->layout = 1;
|
||||||
|
|
||||||
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwBoxClassRec = {
|
MwClassRec MwBoxClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
NULL, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
NULL, /* parent_resize */
|
NULL, /* parent_resize */
|
||||||
|
|
@ -104,7 +150,7 @@ MwClassRec MwBoxClassRec = {
|
||||||
resize, /* resize */
|
resize, /* resize */
|
||||||
children_update, /* children_update */
|
children_update, /* children_update */
|
||||||
children_prop_change, /* children_prop_change */
|
children_prop_change, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
#include "../../external/stb_ds.h"
|
||||||
|
|
||||||
|
static int wcreate(MwWidget handle) {
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwSetInteger(handle, MwNflat, 0);
|
MwSetInteger(handle, MwNflat, 0);
|
||||||
MwSetInteger(handle, MwNpadding, 0);
|
MwSetInteger(handle, MwNpadding, 0);
|
||||||
MwSetInteger(handle, MwNfillArea, 1);
|
MwSetInteger(handle, MwNfillArea, 1);
|
||||||
|
MwSetInteger(handle, MwNroundness, 5);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -18,6 +21,7 @@ static void draw(MwWidget handle) {
|
||||||
const char* str = MwGetText(handle, MwNtext);
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
MwLLPixmap px = MwGetVoid(handle, MwNpixmap);
|
MwLLPixmap px = MwGetVoid(handle, MwNpixmap);
|
||||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
int inv;
|
||||||
|
|
||||||
if(str == NULL) str = "";
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
|
|
@ -27,7 +31,7 @@ static void draw(MwWidget handle) {
|
||||||
r.height = MwGetInteger(handle, MwNheight);
|
r.height = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
if(MwGetInteger(handle, MwNflat)) {
|
if(MwGetInteger(handle, MwNflat)) {
|
||||||
if(handle->pressed) {
|
if(handle->pressed || ((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv)) {
|
||||||
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
||||||
} else {
|
} else {
|
||||||
MwDrawRect(handle, &r, base);
|
MwDrawRect(handle, &r, base);
|
||||||
|
|
@ -36,7 +40,7 @@ static void draw(MwWidget handle) {
|
||||||
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
MwDrawWidgetBack(handle, &r, base, handle->pressed, 1);
|
||||||
}
|
}
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(MwGetInteger(handle, MwNflat) && !handle->pressed) {
|
if(MwGetInteger(handle, MwNflat) && !(handle->pressed || ((inv = MwGetInteger(handle, MwNforceInverted)) != MwDEFAULT && inv))) {
|
||||||
r.x += MwDefaultBorderWidth(handle);
|
r.x += MwDefaultBorderWidth(handle);
|
||||||
r.y += MwDefaultBorderWidth(handle);
|
r.y += MwDefaultBorderWidth(handle);
|
||||||
r.width -= MwDefaultBorderWidth(handle) * 2;
|
r.width -= MwDefaultBorderWidth(handle) * 2;
|
||||||
|
|
@ -73,7 +77,7 @@ static void draw(MwWidget handle) {
|
||||||
point.x = r.x + r.width / 2;
|
point.x = r.x + r.width / 2;
|
||||||
point.y = r.x + r.height / 2;
|
point.y = r.x + r.height / 2;
|
||||||
|
|
||||||
MwDrawText(handle, &point, str, 0, MwALIGNMENT_CENTER, text);
|
MwDrawText(handle, NULL, &point, str, MwALIGNMENT_CENTER, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwLLFreeColor(text);
|
MwLLFreeColor(text);
|
||||||
|
|
@ -89,7 +93,7 @@ static void prop_change(MwWidget handle, const char* key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwButtonClassRec = {
|
MwClassRec MwButtonClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
NULL, /* destroy */
|
NULL, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
click, /* click */
|
click, /* click */
|
||||||
|
|
@ -104,7 +108,7 @@ MwClassRec MwButtonClassRec = {
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int wcreate(MwWidget handle) {
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwSetInteger(handle, MwNchecked, 0);
|
MwSetInteger(handle, MwNchecked, 0);
|
||||||
|
|
@ -38,7 +38,7 @@ static void prop_change(MwWidget handle, const char* key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwCheckBoxClassRec = {
|
MwClassRec MwCheckBoxClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
NULL, /* destroy */
|
NULL, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
click, /* click */
|
click, /* click */
|
||||||
|
|
@ -53,7 +53,7 @@ MwClassRec MwCheckBoxClassRec = {
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "../../external/stb_ds.h"
|
#include "../../external/stb_ds.h"
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int wcreate(MwWidget handle) {
|
||||||
MwComboBox cb = malloc(sizeof(*cb));
|
MwComboBox cb = malloc(sizeof(*cb));
|
||||||
|
|
||||||
cb->list = NULL;
|
cb->list = NULL;
|
||||||
|
|
@ -51,7 +51,7 @@ static void draw(MwWidget handle) {
|
||||||
p.x = MwDefaultBorderWidth(handle) * 2 + 4;
|
p.x = MwDefaultBorderWidth(handle) * 2 + 4;
|
||||||
p.y = MwGetInteger(handle, MwNheight) / 2;
|
p.y = MwGetInteger(handle, MwNheight) / 2;
|
||||||
|
|
||||||
MwDrawText(handle, &p, cb->list[MwGetInteger(handle, MwNvalue)], 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, NULL, &p, cb->list[MwGetInteger(handle, MwNvalue)], MwALIGNMENT_BEGINNING, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
r = rc;
|
r = rc;
|
||||||
|
|
@ -89,7 +89,7 @@ static void listbox_activate(MwWidget handle, void* user, void* client) {
|
||||||
|
|
||||||
MwForceRender(handle->parent);
|
MwForceRender(handle->parent);
|
||||||
|
|
||||||
MwDispatchUserHandler(handle->parent, MwNchangedHandler, client);
|
MwDispatchUserHandler(handle->parent, MwNcomboBoxChangedHandler, client);
|
||||||
|
|
||||||
MwDestroyWidget(handle);
|
MwDestroyWidget(handle);
|
||||||
}
|
}
|
||||||
|
|
@ -115,11 +115,11 @@ static void click(MwWidget handle) {
|
||||||
MwLLSetCursor(handle->lowlevel, &MwCursorArrow, &MwCursorArrowMask);
|
MwLLSetCursor(handle->lowlevel, &MwCursorArrow, &MwCursorArrowMask);
|
||||||
|
|
||||||
for(i = 0; i < arrlen(cb->list); i++) {
|
for(i = 0; i < arrlen(cb->list); i++) {
|
||||||
int l = MwTextWidth(handle, cb->list[i]) + MwDefaultBorderWidth(handle) * 2;
|
int l = MwTextWidth(handle, NULL, cb->list[i]) + MwDefaultBorderWidth(handle) * 2;
|
||||||
if(l > width) width = l;
|
if(l > width) width = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, "M") * ent + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M") / 4,
|
cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, NULL, "M") * ent + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, NULL, "M") / 4,
|
||||||
MwNsingleClickSelectable, 1,
|
MwNsingleClickSelectable, 1,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
|
|
@ -189,7 +189,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwComboBoxClassRec = {
|
MwClassRec MwComboBoxClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
click, /* click */
|
click, /* click */
|
||||||
|
|
@ -204,7 +204,7 @@ MwClassRec MwComboBoxClassRec = {
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int wcreate(MwWidget handle) {
|
||||||
MwEntry t = malloc(sizeof(*t));
|
MwEntry t = malloc(sizeof(*t));
|
||||||
|
|
||||||
t->cursor = 0;
|
t->cursor = 0;
|
||||||
|
|
@ -11,6 +11,7 @@ static int create(MwWidget handle) {
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
|
MwLLSetCursor(handle->lowlevel, &MwCursorText, &MwCursorTextMask);
|
||||||
|
MwSetInteger(handle, MwNroundness, 5);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -26,6 +27,7 @@ static void draw(MwWidget handle) {
|
||||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
const char* str = MwGetText(handle, MwNtext);
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
MwFLFont font = MwFLBuildFont(MwFLFlagMonospace);
|
||||||
if(str == NULL) str = "";
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
r.x = 0;
|
r.x = 0;
|
||||||
|
|
@ -36,8 +38,8 @@ static void draw(MwWidget handle) {
|
||||||
MwDrawWidgetBack(handle, &r, base, 1, 1);
|
MwDrawWidgetBack(handle, &r, base, 1, 1);
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
if(str != NULL) {
|
if(str != NULL) {
|
||||||
int w = MwTextWidth(handle, "M");
|
int w = MwTextWidth(handle, font, "M");
|
||||||
int h = MwTextHeight(handle, "M");
|
int h = MwTextHeight(handle, font, "M");
|
||||||
MwPoint p;
|
MwPoint p;
|
||||||
char* show;
|
char* show;
|
||||||
int len;
|
int len;
|
||||||
|
|
@ -52,6 +54,7 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
len = (r.width - p.x * 2) / w;
|
len = (r.width - p.x * 2) / w;
|
||||||
|
|
||||||
|
if(len > 0) {
|
||||||
show = malloc(len * 4 + 1);
|
show = malloc(len * 4 + 1);
|
||||||
memset(show, 0, len * 4 + 1);
|
memset(show, 0, len * 4 + 1);
|
||||||
|
|
||||||
|
|
@ -63,13 +66,13 @@ static void draw(MwWidget handle) {
|
||||||
for(i = 0; i < MwUTF8Length(str) - start; i++) show[i] = '*';
|
for(i = 0; i < MwUTF8Length(str) - start; i++) show[i] = '*';
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawText(handle, &p, show, 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, font, &p, show, MwALIGNMENT_BEGINNING, text);
|
||||||
|
|
||||||
textlen = (t->cursor - 1) % len + 1;
|
textlen = (t->cursor - 1) % len + 1;
|
||||||
for(i = 0; i < textlen; i++) show[i] = 'M';
|
for(i = 0; i < textlen; i++) show[i] = 'M';
|
||||||
show[i] = 0;
|
show[i] = 0;
|
||||||
|
|
||||||
currc.x = p.x + MwTextWidth(handle, show);
|
currc.x = p.x + MwTextWidth(handle, font, show);
|
||||||
currc.y = (r.height - h) / 2;
|
currc.y = (r.height - h) / 2;
|
||||||
currc.width = 1;
|
currc.width = 1;
|
||||||
currc.height = h;
|
currc.height = h;
|
||||||
|
|
@ -77,6 +80,7 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
free(show);
|
free(show);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
MwLLFreeColor(text);
|
MwLLFreeColor(text);
|
||||||
MwLLFreeColor(base);
|
MwLLFreeColor(base);
|
||||||
|
|
@ -109,20 +113,7 @@ static void key(MwWidget handle, int code) {
|
||||||
} else if(code == MwLLKeyEnter) {
|
} else if(code == MwLLKeyEnter) {
|
||||||
MwDispatchUserHandler(handle, MwNactivateHandler, NULL);
|
MwDispatchUserHandler(handle, MwNactivateHandler, NULL);
|
||||||
} else if(code == (MwLLControlMask | 'v')) {
|
} else if(code == (MwLLControlMask | 'v')) {
|
||||||
char* c = MwLLGetClipboard(handle->lowlevel);
|
MwLLGetClipboard(handle->lowlevel, MwCLIPBOARD_MAIN);
|
||||||
if(c != NULL) {
|
|
||||||
char* out = malloc(strlen(str) + strlen(c) + 1);
|
|
||||||
|
|
||||||
MwUTF8Copy(str, 0, out, 0, t->cursor);
|
|
||||||
MwUTF8Copy(c, 0, out, t->cursor, MwUTF8Length(c));
|
|
||||||
MwUTF8Copy(str, t->cursor, out, t->cursor + MwUTF8Length(c), MwUTF8Length(str) - t->cursor);
|
|
||||||
|
|
||||||
t->cursor += MwUTF8Length(c);
|
|
||||||
|
|
||||||
MwSetText(handle, MwNtext, out);
|
|
||||||
free(out);
|
|
||||||
free(c);
|
|
||||||
}
|
|
||||||
} else if(!(code & MwLLKeyMask)) {
|
} else if(!(code & MwLLKeyMask)) {
|
||||||
int incr = 0;
|
int incr = 0;
|
||||||
out = malloc(strlen(str) + 5 + 1);
|
out = malloc(strlen(str) + 5 + 1);
|
||||||
|
|
@ -142,6 +133,20 @@ static void key(MwWidget handle, int code) {
|
||||||
MwForceRender(handle);
|
MwForceRender(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(USE_X11) || defined(USE_WAYLAND)
|
||||||
|
static void mouse_up(MwWidget handle, void* ptr) {
|
||||||
|
if(handle->lowlevel->common.type == MwLLBackendWayland || handle->lowlevel->common.type == MwLLBackendX11) {
|
||||||
|
MwMouse* mouse = ptr;
|
||||||
|
if(mouse->button == MwMOUSE_MIDDLE) {
|
||||||
|
MwLLGetClipboard(handle->lowlevel, MwCLIPBOARD_PRIMARY);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MwForceRender2(handle, NULL);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
#define mouse_up MwForceRender2
|
||||||
|
#endif
|
||||||
|
|
||||||
static void prop_change(MwWidget handle, const char* prop) {
|
static void prop_change(MwWidget handle, const char* prop) {
|
||||||
if(strcmp(prop, MwNtext) == 0 || strcmp(prop, MwNhideInput) == 0) MwForceRender(handle);
|
if(strcmp(prop, MwNtext) == 0 || strcmp(prop, MwNhideInput) == 0) MwForceRender(handle);
|
||||||
|
|
||||||
|
|
@ -157,15 +162,38 @@ static void prop_change(MwWidget handle, const char* prop) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void clipboard(MwWidget handle, const char* data) {
|
||||||
|
MwEntry t = handle->internal;
|
||||||
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
|
char* out;
|
||||||
|
if(!str) {
|
||||||
|
str = "";
|
||||||
|
}
|
||||||
|
out = malloc(strlen(str) + strlen(data) + 1);
|
||||||
|
|
||||||
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
|
MwUTF8Copy(str, 0, out, 0, t->cursor);
|
||||||
|
MwUTF8Copy(data, 0, out, t->cursor, MwUTF8Length(data));
|
||||||
|
MwUTF8Copy(str, t->cursor, out, t->cursor + MwUTF8Length(data), MwUTF8Length(str) - t->cursor);
|
||||||
|
|
||||||
|
t->cursor += MwUTF8Length(data);
|
||||||
|
|
||||||
|
MwSetText(handle, MwNtext, out);
|
||||||
|
free(out);
|
||||||
|
|
||||||
|
MwForceRender(handle);
|
||||||
|
}
|
||||||
|
|
||||||
MwClassRec MwEntryClassRec = {
|
MwClassRec MwEntryClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
NULL, /* parent_resize */
|
NULL, /* parent_resize */
|
||||||
prop_change, /* prop_change */
|
prop_change, /* prop_change */
|
||||||
NULL, /* mouse_move */
|
NULL, /* mouse_move */
|
||||||
MwForceRender2, /* mouse_up */
|
mouse_up, /* mouse_up */
|
||||||
MwForceRender2, /* mouse_down */
|
MwForceRender2, /* mouse_down */
|
||||||
key, /* key */
|
key, /* key */
|
||||||
NULL, /* execute */
|
NULL, /* execute */
|
||||||
|
|
@ -173,7 +201,7 @@ MwClassRec MwEntryClassRec = {
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
clipboard, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int wcreate(MwWidget handle) {
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwSetInteger(handle, MwNhasBorder, 0);
|
MwSetInteger(handle, MwNhasBorder, 0);
|
||||||
|
|
@ -46,7 +46,7 @@ static void prop_change(MwWidget handle, const char* key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwFrameClassRec = {
|
MwClassRec MwFrameClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
NULL, /* destroy */
|
NULL, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
|
|
@ -61,7 +61,7 @@ MwClassRec MwFrameClassRec = {
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int wcreate(MwWidget handle) {
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
|
|
||||||
MwSetInteger(handle, MwNhasBorder, 0);
|
MwSetInteger(handle, MwNhasBorder, 0);
|
||||||
MwSetInteger(handle, MwNinverted, 1);
|
MwSetInteger(handle, MwNinverted, 1);
|
||||||
|
MwSetInteger(handle, MwNfillArea, 1);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -23,6 +24,13 @@ static void draw(MwWidget handle) {
|
||||||
|
|
||||||
MwDrawRect(handle, &r, base);
|
MwDrawRect(handle, &r, base);
|
||||||
if(px != NULL) {
|
if(px != NULL) {
|
||||||
|
if(!MwGetInteger(handle, MwNfillArea)) {
|
||||||
|
r.x = (r.width - px->common.width) / 2;
|
||||||
|
r.y = (r.height - px->common.height) / 2;
|
||||||
|
r.width = px->common.width;
|
||||||
|
r.height = px->common.height;
|
||||||
|
}
|
||||||
|
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r, px);
|
MwLLDrawPixmap(handle->lowlevel, &r, px);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -34,7 +42,7 @@ static void prop_change(MwWidget handle, const char* key) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwImageClassRec = {
|
MwClassRec MwImageClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
NULL, /* destroy */
|
NULL, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
|
|
@ -49,7 +57,7 @@ MwClassRec MwImageClassRec = {
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,139 @@
|
||||||
#include <Mw/Milsko.h>
|
#include <Mw/Milsko.h>
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
#include "../../external/stb_ds.h"
|
||||||
|
|
||||||
|
#define Spacing 1
|
||||||
|
|
||||||
|
static int wcreate(MwWidget handle) {
|
||||||
|
MwLabel lab = malloc(sizeof(*lab));
|
||||||
|
|
||||||
|
lab->segment = NULL;
|
||||||
|
handle->internal = lab;
|
||||||
|
|
||||||
MwSetDefault(handle);
|
MwSetDefault(handle);
|
||||||
MwSetInteger(handle, MwNalignment, MwALIGNMENT_CENTER);
|
MwSetInteger(handle, MwNalignment, MwALIGNMENT_CENTER);
|
||||||
MwSetInteger(handle, MwNbold, 0);
|
MwSetInteger(handle, MwNbold, 0);
|
||||||
|
MwSetInteger(handle, MwNsevenSegment, 0);
|
||||||
|
MwSetInteger(handle, MwNlength, 4);
|
||||||
|
MwSetInteger(handle, MwNleftPadding, 0);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void destroy(MwWidget handle) {
|
||||||
|
MwLabel lab = handle->internal;
|
||||||
|
|
||||||
|
hmfree(lab->segment);
|
||||||
|
|
||||||
|
free(handle->internal);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_v(MwWidget handle, unsigned char* raw, int x, int y, int stride, MwLLColor text) {
|
||||||
|
int cy, cx, b;
|
||||||
|
|
||||||
|
int l_one = MwGetInteger(handle, MwNlength) - (MwGetInteger(handle, MwNlength) % 2);
|
||||||
|
int s_one = (l_one * 3 / 4) - ((l_one * 3 / 4) % 2) + 1;
|
||||||
|
|
||||||
|
for(cy = y; cy < y + l_one; cy++) {
|
||||||
|
for(cx = x; cx < x + s_one; cx++) {
|
||||||
|
unsigned char* px = &raw[(cy * stride + cx) * 4];
|
||||||
|
px[0] = text->common.red;
|
||||||
|
px[1] = text->common.green;
|
||||||
|
px[2] = text->common.blue;
|
||||||
|
px[3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b = y - (s_one - 1) / 2;
|
||||||
|
for(cy = b; cy < b + (s_one - 1) / 2; cy++) {
|
||||||
|
int w = (cy - b) * 2 + 1;
|
||||||
|
int b2 = x + (s_one - w) / 2;
|
||||||
|
for(cx = b2; cx < b2 + w; cx++) {
|
||||||
|
unsigned char* px;
|
||||||
|
|
||||||
|
px = &raw[(cy * stride + cx) * 4];
|
||||||
|
px[0] = text->common.red;
|
||||||
|
px[1] = text->common.green;
|
||||||
|
px[2] = text->common.blue;
|
||||||
|
px[3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b = y + l_one;
|
||||||
|
for(cy = b; cy < b + (s_one - 1) / 2; cy++) {
|
||||||
|
int w = ((s_one - 1) / 2 - 1 - (cy - b)) * 2 + 1;
|
||||||
|
int b2 = x + (s_one - w) / 2;
|
||||||
|
for(cx = b2; cx < b2 + w; cx++) {
|
||||||
|
unsigned char* px;
|
||||||
|
|
||||||
|
px = &raw[(cy * stride + cx) * 4];
|
||||||
|
px[0] = text->common.red;
|
||||||
|
px[1] = text->common.green;
|
||||||
|
px[2] = text->common.blue;
|
||||||
|
px[3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void draw_h(MwWidget handle, unsigned char* raw, int x, int y, int stride, MwLLColor text) {
|
||||||
|
int cy, cx, b;
|
||||||
|
|
||||||
|
int l_one = MwGetInteger(handle, MwNlength) - (MwGetInteger(handle, MwNlength) % 2);
|
||||||
|
int s_one = (l_one * 3 / 4) - ((l_one * 3 / 4) % 2) + 1;
|
||||||
|
|
||||||
|
for(cx = x; cx < x + l_one; cx++) {
|
||||||
|
for(cy = y; cy < y + s_one; cy++) {
|
||||||
|
unsigned char* px = &raw[(cy * stride + cx) * 4];
|
||||||
|
px[0] = text->common.red;
|
||||||
|
px[1] = text->common.green;
|
||||||
|
px[2] = text->common.blue;
|
||||||
|
px[3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b = x - (s_one - 1) / 2;
|
||||||
|
for(cx = b; cx < b + (s_one - 1) / 2; cx++) {
|
||||||
|
int w = (cx - b) * 2 + 1;
|
||||||
|
int b2 = y + (s_one - w) / 2;
|
||||||
|
for(cy = b2; cy < b2 + w; cy++) {
|
||||||
|
unsigned char* px;
|
||||||
|
|
||||||
|
px = &raw[(cy * stride + cx) * 4];
|
||||||
|
px[0] = text->common.red;
|
||||||
|
px[1] = text->common.green;
|
||||||
|
px[2] = text->common.blue;
|
||||||
|
px[3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
b = x + l_one;
|
||||||
|
for(cx = b; cx < b + (s_one - 1) / 2; cx++) {
|
||||||
|
int w = ((s_one - 1) / 2 - 1 - (cx - b)) * 2 + 1;
|
||||||
|
int b2 = y + (s_one - w) / 2;
|
||||||
|
for(cy = b2; cy < b2 + w; cy++) {
|
||||||
|
unsigned char* px;
|
||||||
|
|
||||||
|
px = &raw[(cy * stride + cx) * 4];
|
||||||
|
px[0] = text->common.red;
|
||||||
|
px[1] = text->common.green;
|
||||||
|
px[2] = text->common.blue;
|
||||||
|
px[3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void draw(MwWidget handle) {
|
static void draw(MwWidget handle) {
|
||||||
MwRect r;
|
MwRect r;
|
||||||
MwPoint p;
|
MwPoint p;
|
||||||
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
MwLLColor base = MwParseColor(handle, MwGetText(handle, MwNbackground));
|
||||||
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
MwLLColor text = MwParseColor(handle, MwGetText(handle, MwNforeground));
|
||||||
|
MwLLColor shadow = MwLightenColor(handle, base, MwDefaultShadow, MwDefaultShadow, MwDefaultShadow);
|
||||||
int align;
|
int align;
|
||||||
const char* str = MwGetText(handle, MwNtext);
|
const char* str = MwGetText(handle, MwNtext);
|
||||||
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
MwLLPixmap bgpx = MwGetVoid(handle, MwNbackgroundPixmap);
|
||||||
|
MwLabel lab = handle->internal;
|
||||||
|
int l_one = MwGetInteger(handle, MwNlength) - (MwGetInteger(handle, MwNlength) % 2);
|
||||||
|
int s_one = (l_one * 3 / 4) - ((l_one * 3 / 4) % 2) + 1;
|
||||||
|
|
||||||
if(str == NULL) str = "";
|
if(str == NULL) str = "";
|
||||||
|
|
||||||
|
|
@ -28,27 +146,222 @@ static void draw(MwWidget handle) {
|
||||||
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
if(bgpx != NULL) MwLLDrawPixmap(handle->lowlevel, &r, bgpx);
|
||||||
|
|
||||||
align = MwGetInteger(handle, MwNalignment);
|
align = MwGetInteger(handle, MwNalignment);
|
||||||
|
if(MwGetInteger(handle, MwNsevenSegment)) {
|
||||||
|
MwLLPixmap px;
|
||||||
|
unsigned char* raw;
|
||||||
|
int w = 0, h = s_one * 3 + l_one * 2, i;
|
||||||
|
int x = 0;
|
||||||
|
|
||||||
|
/* so - this mode cannot do unicode.
|
||||||
|
* but you wouldn't show unicode on 7 segment anyways
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* L
|
||||||
|
* S <--->
|
||||||
|
*
|
||||||
|
* S
|
||||||
|
* ^
|
||||||
|
* |
|
||||||
|
* L |
|
||||||
|
* |
|
||||||
|
* v
|
||||||
|
*/
|
||||||
|
|
||||||
|
for(i = 0; (hmgeti(lab->segment, i) != -1) || str[i] != 0; i++) {
|
||||||
|
if(i > 0 && ((hmgeti(lab->segment, i) != -1) || str[i] != '.')) w += Spacing;
|
||||||
|
if(hmgeti(lab->segment, i) != -1 || ('0' <= str[i] && str[i] <= '9') || ('A' <= str[i] && str[i] <= 'F') || ('a' <= str[i] && str[i] <= 'f')) {
|
||||||
|
w += l_one + s_one * 2;
|
||||||
|
} else if(str[i] == ':' || str[i] == ' ') {
|
||||||
|
w += s_one;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
w++;
|
||||||
|
h++;
|
||||||
|
|
||||||
|
raw = malloc(w * h * 4);
|
||||||
|
memset(raw, 0, w * h * 4);
|
||||||
|
|
||||||
|
for(i = 0; (hmgeti(lab->segment, i) != -1) || str[i] != 0; i++) {
|
||||||
|
if((hmgeti(lab->segment, i) != -1) || ('0' <= str[i] && str[i] <= '9') || ('A' <= str[i] && str[i] <= 'F') || ('a' <= str[i] && str[i] <= 'f')) {
|
||||||
|
int la = 0, lb = 0, lc = 0, ld = 0, le = 0, lf = 0, lg = 0;
|
||||||
|
int j;
|
||||||
|
|
||||||
|
/* https://en.wikipedia.org/wiki/File:7_Segment_Display_with_Labeled_Segments.svg */
|
||||||
|
|
||||||
|
if(hmgeti(lab->segment, i) != -1) {
|
||||||
|
unsigned char c = hmget(lab->segment, i);
|
||||||
|
|
||||||
|
if(c & (1 << 0)) la = 1;
|
||||||
|
if(c & (1 << 1)) lb = 1;
|
||||||
|
if(c & (1 << 2)) lc = 1;
|
||||||
|
if(c & (1 << 3)) ld = 1;
|
||||||
|
if(c & (1 << 4)) le = 1;
|
||||||
|
if(c & (1 << 5)) lf = 1;
|
||||||
|
if(c & (1 << 6)) lg = 1;
|
||||||
|
} else {
|
||||||
|
if(str[i] == '0') {
|
||||||
|
la = lb = lc = ld = le = lf = 1;
|
||||||
|
} else if(str[i] == '1') {
|
||||||
|
lb = lc = 1;
|
||||||
|
} else if(str[i] == '2') {
|
||||||
|
la = lb = ld = le = lg = 1;
|
||||||
|
} else if(str[i] == '3') {
|
||||||
|
la = lb = lc = ld = lg = 1;
|
||||||
|
} else if(str[i] == '4') {
|
||||||
|
lb = lc = lf = lg = 1;
|
||||||
|
} else if(str[i] == '5') {
|
||||||
|
la = lc = ld = lf = lg = 1;
|
||||||
|
} else if(str[i] == '6') {
|
||||||
|
la = lc = ld = le = lf = lg = 1;
|
||||||
|
} else if(str[i] == '7') {
|
||||||
|
la = lb = lc = 1;
|
||||||
|
} else if(str[i] == '8') {
|
||||||
|
la = lb = lc = ld = le = lf = lg = 1;
|
||||||
|
} else if(str[i] == '9') {
|
||||||
|
la = lb = lc = ld = lf = lg = 1;
|
||||||
|
} else if(str[i] == 'A' || str[i] == 'a') {
|
||||||
|
la = lb = lc = le = lf = lg = 1;
|
||||||
|
} else if(str[i] == 'B' || str[i] == 'b') {
|
||||||
|
lc = ld = le = lf = lg = 1;
|
||||||
|
} else if(str[i] == 'C' || str[i] == 'c') {
|
||||||
|
ld = le = lg = 1;
|
||||||
|
} else if(str[i] == 'D' || str[i] == 'd') {
|
||||||
|
lb = lc = ld = le = lg = 1;
|
||||||
|
} else if(str[i] == 'E' || str[i] == 'e') {
|
||||||
|
la = ld = le = lf = lg = 1;
|
||||||
|
} else if(str[i] == 'F' || str[i] == 'f') {
|
||||||
|
la = le = lf = lg = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for(j = 1; j >= 0; j--) {
|
||||||
|
MwLLColor cl = j == 1 ? shadow : text;
|
||||||
|
|
||||||
|
if(la) draw_h(handle, raw, x + s_one + j, j, w, cl);
|
||||||
|
if(lb) draw_v(handle, raw, x + s_one + l_one + j, s_one + j, w, cl);
|
||||||
|
if(lc) draw_v(handle, raw, x + s_one + l_one + j, s_one * 2 + l_one + j, w, cl);
|
||||||
|
if(ld) draw_h(handle, raw, x + s_one + j, s_one * 2 + l_one * 2 + j, w, cl);
|
||||||
|
if(le) draw_v(handle, raw, x + j, s_one * 2 + l_one + j, w, cl);
|
||||||
|
if(lf) draw_v(handle, raw, x + j, s_one + j, w, cl);
|
||||||
|
if(lg) draw_h(handle, raw, x + s_one + j, s_one + l_one + j, w, cl);
|
||||||
|
}
|
||||||
|
|
||||||
|
x += l_one + s_one * 2;
|
||||||
|
} else if(str[i] == ':') {
|
||||||
|
int cy, cx;
|
||||||
|
int j;
|
||||||
|
for(j = 1; j >= 0; j--) {
|
||||||
|
MwLLColor cl = j == 1 ? shadow : text;
|
||||||
|
for(cy = 1; cy < h - 1; cy++) {
|
||||||
|
int h = s_one / 2;
|
||||||
|
int c = (l_one - h) / 2 + s_one;
|
||||||
|
|
||||||
|
int c1 = (c <= cy && cy <= (c + h)) ? 1 : 0;
|
||||||
|
int c2 = ((s_one + l_one + c) <= cy && cy <= (s_one + l_one + c + h)) ? 1 : 0;
|
||||||
|
|
||||||
|
if(c1 || c2) {
|
||||||
|
for(cx = x; cx < x + s_one; cx++) {
|
||||||
|
unsigned char* px = &raw[((cy + j) * w + (cx + j)) * 4];
|
||||||
|
px[0] = cl->common.red;
|
||||||
|
px[1] = cl->common.green;
|
||||||
|
px[2] = cl->common.blue;
|
||||||
|
px[3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
x += s_one;
|
||||||
|
} else if(str[i] == ' ') {
|
||||||
|
x += s_one;
|
||||||
|
} else if(str[i] == '.') {
|
||||||
|
int cy, cx;
|
||||||
|
int j;
|
||||||
|
for(j = 1; j >= 0; j--) {
|
||||||
|
MwLLColor cl = j == 1 ? shadow : text;
|
||||||
|
for(cy = h - (s_one - 1) / 2 - 1; cy < h; cy++) {
|
||||||
|
for(cx = x - Spacing - (s_one - 1) / 2 - 1; cx < (x - Spacing); cx++) {
|
||||||
|
unsigned char* px = &raw[((cy + j) * w + (cx + j)) * 4];
|
||||||
|
px[0] = cl->common.red;
|
||||||
|
px[1] = cl->common.green;
|
||||||
|
px[2] = cl->common.blue;
|
||||||
|
px[3] = 255;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
x += Spacing;
|
||||||
|
}
|
||||||
|
|
||||||
|
px = MwLoadRaw(handle, raw, w, h);
|
||||||
|
|
||||||
|
r.y = (r.height - h) / 2;
|
||||||
|
r.height = h;
|
||||||
|
if(align == MwALIGNMENT_CENTER) {
|
||||||
|
r.x = (r.width - w) / 2;
|
||||||
|
} else if(align == MwALIGNMENT_BEGINNING) {
|
||||||
|
r.x = 0;
|
||||||
|
} else if(align == MwALIGNMENT_END) {
|
||||||
|
r.x = r.width - w;
|
||||||
|
}
|
||||||
|
r.width = w;
|
||||||
|
MwLLDrawPixmap(handle->lowlevel, &r, px);
|
||||||
|
|
||||||
|
MwLLDestroyPixmap(px);
|
||||||
|
} else {
|
||||||
|
r.width -= MwGetInteger(handle, MwNleftPadding);
|
||||||
|
|
||||||
if(align == MwALIGNMENT_CENTER) {
|
if(align == MwALIGNMENT_CENTER) {
|
||||||
p.x = r.width / 2;
|
p.x = r.width / 2;
|
||||||
} else if(align == MwALIGNMENT_BEGINNING) {
|
} else if(align == MwALIGNMENT_BEGINNING) {
|
||||||
p.x = MwTextWidth(handle, str) / 2;
|
p.x = MwTextWidth(handle, NULL, str) / 2;
|
||||||
} else if(align == MwALIGNMENT_END) {
|
} else if(align == MwALIGNMENT_END) {
|
||||||
p.x = r.width - MwTextWidth(handle, str) / 2;
|
p.x = r.width - MwTextWidth(handle, NULL, str) / 2;
|
||||||
}
|
}
|
||||||
p.y = r.height / 2;
|
p.y = r.height / 2;
|
||||||
MwDrawText(handle, &p, str, MwGetInteger(handle, MwNbold), MwALIGNMENT_CENTER, text);
|
|
||||||
|
|
||||||
|
p.x += MwGetInteger(handle, MwNleftPadding);
|
||||||
|
|
||||||
|
p.x += 1;
|
||||||
|
p.y += 1;
|
||||||
|
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_CENTER, shadow);
|
||||||
|
|
||||||
|
p.x -= 1;
|
||||||
|
p.y -= 1;
|
||||||
|
MwDrawText(handle, NULL, &p, str, MwALIGNMENT_CENTER, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
MwLLFreeColor(shadow);
|
||||||
MwLLFreeColor(text);
|
MwLLFreeColor(text);
|
||||||
MwLLFreeColor(base);
|
MwLLFreeColor(base);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void prop_change(MwWidget handle, const char* key) {
|
static void prop_change(MwWidget handle, const char* key) {
|
||||||
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNalignment) == 0) MwForceRender(handle);
|
if(strcmp(key, MwNtext) == 0 || strcmp(key, MwNalignment) == 0 || strcmp(key, MwNsevenSegment) == 0 || strcmp(key, MwNlength) == 0 || strcmp(key, MwNleftPadding) == 0) MwForceRender(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void mwLabelSetSevenSegmentImpl(MwWidget handle, int index, unsigned char data) {
|
||||||
|
MwLabel lab = handle->internal;
|
||||||
|
|
||||||
|
hmput(lab->segment, index, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void func_handler(MwWidget handle, const char* name, void* out, va_list va) {
|
||||||
|
(void)out;
|
||||||
|
|
||||||
|
if(strcmp(name, "mwLabelSetSevenSegment") == 0) {
|
||||||
|
int index = va_arg(va, int);
|
||||||
|
int data = va_arg(va, int);
|
||||||
|
|
||||||
|
mwLabelSetSevenSegmentImpl(handle, index, data);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwLabelClassRec = {
|
MwClassRec MwLabelClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
NULL, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
NULL, /* parent_resize */
|
NULL, /* parent_resize */
|
||||||
|
|
@ -57,12 +370,12 @@ MwClassRec MwLabelClassRec = {
|
||||||
NULL, /* mouse_up */
|
NULL, /* mouse_up */
|
||||||
NULL, /* mouse_down */
|
NULL, /* mouse_down */
|
||||||
NULL, /* key */
|
NULL, /* key */
|
||||||
NULL, /* execute */
|
func_handler, /* execute */
|
||||||
NULL, /* tick */
|
NULL, /* tick */
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
|
|
||||||
#define Padding 2
|
#define Padding 2
|
||||||
|
|
||||||
|
#define Font MwFLBuildFont(MwFLFlagMonospace)
|
||||||
|
|
||||||
MwListBoxPacket* MwListBoxCreatePacket(void) {
|
MwListBoxPacket* MwListBoxCreatePacket(void) {
|
||||||
MwListBoxPacket* packet = malloc(sizeof(*packet));
|
MwListBoxPacket* packet = malloc(sizeof(*packet));
|
||||||
memset(packet, 0, sizeof(*packet));
|
memset(packet, 0, sizeof(*packet));
|
||||||
|
|
@ -118,19 +120,19 @@ static void vscroll_changed(MwWidget handle, void* user, void* call) {
|
||||||
|
|
||||||
static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
||||||
MwListBox lb = handle->parent->internal;
|
MwListBox lb = handle->parent->internal;
|
||||||
MwLLMouse* m = call;
|
MwMouse* m = call;
|
||||||
|
|
||||||
(void)user;
|
(void)user;
|
||||||
|
|
||||||
if(m->button == MwLLMouseLeft) {
|
if(m->button == MwMOUSE_LEFT) {
|
||||||
int st = 0;
|
int st = 0;
|
||||||
int i;
|
int i;
|
||||||
int y = MwDefaultBorderWidth(handle);
|
int y = MwDefaultBorderWidth(handle);
|
||||||
int h = MwGetInteger(handle, MwNheight);
|
int h = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
st = get_first_entry(handle->parent, lb);
|
st = get_first_entry(handle->parent, lb);
|
||||||
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, "M") + Padding) + 2; i++) {
|
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, Font, "M") + Padding) + 2; i++) {
|
||||||
if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, "M") + Padding)) {
|
if(y <= m->point.y && m->point.y <= (y + MwTextHeight(handle, Font, "M") + Padding)) {
|
||||||
unsigned long t;
|
unsigned long t;
|
||||||
int old = MwGetInteger(handle->parent, MwNvalue);
|
int old = MwGetInteger(handle->parent, MwNvalue);
|
||||||
|
|
||||||
|
|
@ -138,12 +140,12 @@ static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
||||||
|
|
||||||
if((((t = MwTimeGetTick()) - lb->click_time) < MwDoubleClickTimeout && old == st + i) || MwGetInteger(handle->parent, MwNsingleClickSelectable)) {
|
if((((t = MwTimeGetTick()) - lb->click_time) < MwDoubleClickTimeout && old == st + i) || MwGetInteger(handle->parent, MwNsingleClickSelectable)) {
|
||||||
int n = MwGetInteger(handle->parent, MwNvalue);
|
int n = MwGetInteger(handle->parent, MwNvalue);
|
||||||
MwDispatchUserHandler(handle->parent, MwNactivateHandler, &n);
|
MwDispatchUserHandler(handle->parent, MwNlistBoxActivateHandler, &n);
|
||||||
}
|
}
|
||||||
|
|
||||||
lb->click_time = t;
|
lb->click_time = t;
|
||||||
}
|
}
|
||||||
y += MwTextHeight(handle, "M") + Padding;
|
y += MwTextHeight(handle, Font, "M") + Padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwForceRender(lb->frame);
|
MwForceRender(lb->frame);
|
||||||
|
|
@ -153,11 +155,11 @@ static void frame_mouse_down(MwWidget handle, void* user, void* call) {
|
||||||
|
|
||||||
static void frame_mouse_up(MwWidget handle, void* user, void* call) {
|
static void frame_mouse_up(MwWidget handle, void* user, void* call) {
|
||||||
MwListBox lb = handle->parent->internal;
|
MwListBox lb = handle->parent->internal;
|
||||||
MwLLMouse* m = call;
|
MwMouse* m = call;
|
||||||
|
|
||||||
(void)user;
|
(void)user;
|
||||||
|
|
||||||
if(m->button == MwLLMouseLeft) {
|
if(m->button == MwMOUSE_LEFT) {
|
||||||
lb->pressed = 0;
|
lb->pressed = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -175,11 +177,11 @@ static void frame_mouse_move(MwWidget handle, void* user, void* call) {
|
||||||
int h = MwGetInteger(handle, MwNheight);
|
int h = MwGetInteger(handle, MwNheight);
|
||||||
|
|
||||||
st = get_first_entry(handle->parent, lb);
|
st = get_first_entry(handle->parent, lb);
|
||||||
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, "M") + Padding) + 2; i++) {
|
for(i = 0; (st + i) < arrlen(lb->list) && i < (h - MwDefaultBorderWidth(handle) * 2) / (MwTextHeight(handle, Font, "M") + Padding) + 2; i++) {
|
||||||
if(y <= p->y && p->y <= (y + MwTextHeight(handle, "M") + Padding)) {
|
if(y <= p->y && p->y <= (y + MwTextHeight(handle, Font, "M") + Padding)) {
|
||||||
MwSetInteger(handle->parent, MwNvalue, st + i);
|
MwSetInteger(handle->parent, MwNvalue, st + i);
|
||||||
}
|
}
|
||||||
y += MwTextHeight(handle, "M") + Padding;
|
y += MwTextHeight(handle, Font, "M") + Padding;
|
||||||
}
|
}
|
||||||
|
|
||||||
MwForceRender(lb->frame);
|
MwForceRender(lb->frame);
|
||||||
|
|
@ -216,7 +218,7 @@ static void frame_draw(MwWidget handle) {
|
||||||
st = get_first_entry(handle->parent, lb);
|
st = get_first_entry(handle->parent, lb);
|
||||||
|
|
||||||
area = r.height - MwDefaultBorderWidth(handle) * 2;
|
area = r.height - MwDefaultBorderWidth(handle) * 2;
|
||||||
ent = area / (MwTextHeight(handle, "M") + Padding) + 2;
|
ent = area / (MwTextHeight(handle, Font, "M") + Padding) + 2;
|
||||||
|
|
||||||
for(i = st; i < arrlen(lb->list) && i < st + ent; i++) {
|
for(i = st; i < arrlen(lb->list) && i < st + ent; i++) {
|
||||||
int selected = MwGetInteger(handle->parent, MwNvalue) == i ? 1 : 0;
|
int selected = MwGetInteger(handle->parent, MwNvalue) == i ? 1 : 0;
|
||||||
|
|
@ -227,20 +229,20 @@ static void frame_draw(MwWidget handle) {
|
||||||
r2.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
r2.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
||||||
r2.y = p.y;
|
r2.y = p.y;
|
||||||
r2.width = r.width - r2.x;
|
r2.width = r.width - r2.x;
|
||||||
r2.height = MwTextHeight(handle, "M") + Padding;
|
r2.height = MwTextHeight(handle, Font, "M") + Padding;
|
||||||
MwDrawRect(handle, &r2, text2);
|
MwDrawRect(handle, &r2, text2);
|
||||||
handle->bgcolor = text2;
|
handle->bgcolor = text2;
|
||||||
}
|
}
|
||||||
if(lb->list[i].pixmap != NULL) {
|
if(lb->list[i].pixmap != NULL) {
|
||||||
MwRect r2;
|
MwRect r2;
|
||||||
int h = (lb->list[i].pixmap->common.height > (MwTextHeight(handle, "M") + Padding)) ? (MwTextHeight(handle, "M") + Padding) : lb->list[i].pixmap->common.height;
|
int h = (lb->list[i].pixmap->common.height > (MwTextHeight(handle, Font, "M") + Padding)) ? (MwTextHeight(handle, Font, "M") + Padding) : lb->list[i].pixmap->common.height;
|
||||||
r2.x = MwDefaultBorderWidth(handle);
|
r2.x = MwDefaultBorderWidth(handle);
|
||||||
r2.y = p.y + (MwTextHeight(handle, "M") + Padding - h) / 2;
|
r2.y = p.y + (MwTextHeight(handle, Font, "M") + Padding - h) / 2;
|
||||||
r2.width = h * lb->list[i].pixmap->common.width / lb->list[i].pixmap->common.height;
|
r2.width = h * lb->list[i].pixmap->common.width / lb->list[i].pixmap->common.height;
|
||||||
r2.height = h;
|
r2.height = h;
|
||||||
MwLLDrawPixmap(handle->lowlevel, &r2, lb->list[i].pixmap);
|
MwLLDrawPixmap(handle->lowlevel, &r2, lb->list[i].pixmap);
|
||||||
}
|
}
|
||||||
p.y += (MwTextHeight(handle, "M") + Padding) / 2;
|
p.y += (MwTextHeight(handle, Font, "M") + Padding) / 2;
|
||||||
p.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
p.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
|
||||||
for(j = 0; j < arrlen(lb->list[i].name); j++) {
|
for(j = 0; j < arrlen(lb->list[i].name); j++) {
|
||||||
char* t = lb->list[i].name[j];
|
char* t = lb->list[i].name[j];
|
||||||
|
|
@ -250,8 +252,8 @@ static void frame_draw(MwWidget handle) {
|
||||||
if(t == NULL) t = "";
|
if(t == NULL) t = "";
|
||||||
|
|
||||||
str = MwStringDuplicate(t);
|
str = MwStringDuplicate(t);
|
||||||
if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, "M")) {
|
if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M")) {
|
||||||
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, "M");
|
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M");
|
||||||
str[ind] = 0;
|
str[ind] = 0;
|
||||||
if(ind > 3) memset(str + ind - 3, '.', 3);
|
if(ind > 3) memset(str + ind - 3, '.', 3);
|
||||||
}
|
}
|
||||||
|
|
@ -259,26 +261,26 @@ static void frame_draw(MwWidget handle) {
|
||||||
if(j == (arrlen(lb->list[i].name) - 1)) p.x -= MwDefaultBorderWidth(handle);
|
if(j == (arrlen(lb->list[i].name) - 1)) p.x -= MwDefaultBorderWidth(handle);
|
||||||
if(arrlen(lb->alignment) <= j || lb->alignment[j] == MwALIGNMENT_BEGINNING) {
|
if(arrlen(lb->alignment) <= j || lb->alignment[j] == MwALIGNMENT_BEGINNING) {
|
||||||
p.x += 4;
|
p.x += 4;
|
||||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_BEGINNING, selected ? base2 : text2);
|
MwDrawText(handle, Font, &p, str, MwALIGNMENT_BEGINNING, selected ? base2 : text2);
|
||||||
p.x -= 4;
|
p.x -= 4;
|
||||||
p.x += get_col_width(lb, j);
|
p.x += get_col_width(lb, j);
|
||||||
|
|
||||||
} else if(lb->alignment[j] == MwALIGNMENT_CENTER) {
|
} else if(lb->alignment[j] == MwALIGNMENT_CENTER) {
|
||||||
p.x += (get_col_width(lb, j) - l) / 2;
|
p.x += (get_col_width(lb, j) - l) / 2;
|
||||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_CENTER, selected ? base2 : text2);
|
MwDrawText(handle, Font, &p, str, MwALIGNMENT_CENTER, selected ? base2 : text2);
|
||||||
p.x += (get_col_width(lb, j) - l) / 2;
|
p.x += (get_col_width(lb, j) - l) / 2;
|
||||||
p.x += l;
|
p.x += l;
|
||||||
} else if(lb->alignment[j] == MwALIGNMENT_END) {
|
} else if(lb->alignment[j] == MwALIGNMENT_END) {
|
||||||
p.x += get_col_width(lb, j);
|
p.x += get_col_width(lb, j);
|
||||||
p.x -= 4;
|
p.x -= 4;
|
||||||
MwDrawText(handle, &p, str, 0, MwALIGNMENT_END, selected ? base2 : text2);
|
MwDrawText(handle, Font, &p, str, MwALIGNMENT_END, selected ? base2 : text2);
|
||||||
p.x += 4;
|
p.x += 4;
|
||||||
}
|
}
|
||||||
free(str);
|
free(str);
|
||||||
|
|
||||||
if(j == 0) p.x -= MwGetInteger(handle->parent, MwNleftPadding);
|
if(j == 0) p.x -= MwGetInteger(handle->parent, MwNleftPadding);
|
||||||
}
|
}
|
||||||
p.y += (MwTextHeight(handle, "M") + Padding) / 2;
|
p.y += (MwTextHeight(handle, Font, "M") + Padding) / 2;
|
||||||
handle->bgcolor = NULL;
|
handle->bgcolor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -297,7 +299,7 @@ static void resize(MwWidget handle) {
|
||||||
int ih, y;
|
int ih, y;
|
||||||
int m = 0;
|
int m = 0;
|
||||||
|
|
||||||
y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, "M") + MwDefaultBorderWidth(handle) * 2) : 0;
|
y = MwGetInteger(handle, MwNhasHeading) ? (MwTextHeight(handle, NULL, "M") + MwDefaultBorderWidth(handle) * 2) : 0;
|
||||||
|
|
||||||
if(lb->vscroll == NULL) {
|
if(lb->vscroll == NULL) {
|
||||||
lb->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h, NULL);
|
lb->vscroll = MwVaCreateWidget(MwScrollBarClass, "vscroll", handle, w - 16, 0, 16, h, NULL);
|
||||||
|
|
@ -316,7 +318,7 @@ static void resize(MwWidget handle) {
|
||||||
|
|
||||||
h -= y;
|
h -= y;
|
||||||
|
|
||||||
if(ih <= (h / (MwTextHeight(handle, "M") + Padding))) {
|
if(ih <= (h / (MwTextHeight(handle, Font, "M") + Padding))) {
|
||||||
MwLLShow(lb->vscroll->lowlevel, 0);
|
MwLLShow(lb->vscroll->lowlevel, 0);
|
||||||
} else {
|
} else {
|
||||||
MwLLShow(lb->vscroll->lowlevel, 1);
|
MwLLShow(lb->vscroll->lowlevel, 1);
|
||||||
|
|
@ -340,12 +342,12 @@ static void resize(MwWidget handle) {
|
||||||
h -= MwDefaultBorderWidth(handle) * 2;
|
h -= MwDefaultBorderWidth(handle) * 2;
|
||||||
|
|
||||||
MwVaApply(lb->vscroll,
|
MwVaApply(lb->vscroll,
|
||||||
MwNareaShown, h / (MwTextHeight(handle, "M") + Padding),
|
MwNareaShown, h / (MwTextHeight(handle, Font, "M") + Padding),
|
||||||
MwNmaxValue, ih,
|
MwNmaxValue, ih,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int wcreate(MwWidget handle) {
|
||||||
MwListBox lb = malloc(sizeof(*lb));
|
MwListBox lb = malloc(sizeof(*lb));
|
||||||
memset(lb, 0, sizeof(*lb));
|
memset(lb, 0, sizeof(*lb));
|
||||||
|
|
||||||
|
|
@ -400,7 +402,7 @@ static void draw(MwWidget handle) {
|
||||||
r.x = x;
|
r.x = x;
|
||||||
r.y = 0;
|
r.y = 0;
|
||||||
r.width = get_col_width(lb, i);
|
r.width = get_col_width(lb, i);
|
||||||
r.height = MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M");
|
r.height = MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, NULL, "M");
|
||||||
MwDrawFrame(handle, &r, base, 0);
|
MwDrawFrame(handle, &r, base, 0);
|
||||||
|
|
||||||
x += MwDefaultBorderWidth(handle);
|
x += MwDefaultBorderWidth(handle);
|
||||||
|
|
@ -408,15 +410,15 @@ static void draw(MwWidget handle) {
|
||||||
if(arrlen(lb->alignment) <= i || lb->alignment[i] == MwALIGNMENT_BEGINNING) {
|
if(arrlen(lb->alignment) <= i || lb->alignment[i] == MwALIGNMENT_BEGINNING) {
|
||||||
p.x = 4 + x;
|
p.x = 4 + x;
|
||||||
p.y = r.y + r.height / 2;
|
p.y = r.y + r.height / 2;
|
||||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_BEGINNING, text);
|
||||||
} else if(lb->alignment[i] == MwALIGNMENT_CENTER) {
|
} else if(lb->alignment[i] == MwALIGNMENT_CENTER) {
|
||||||
p.x = x + r.width / 2;
|
p.x = x + r.width / 2;
|
||||||
p.y = r.y + r.height / 2;
|
p.y = r.y + r.height / 2;
|
||||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_CENTER, text);
|
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_CENTER, text);
|
||||||
} else if(lb->alignment[i] == MwALIGNMENT_END) {
|
} else if(lb->alignment[i] == MwALIGNMENT_END) {
|
||||||
p.x = x + r.width - 4;
|
p.x = x + r.width - 4;
|
||||||
p.y = r.y + r.height / 2;
|
p.y = r.y + r.height / 2;
|
||||||
MwDrawText(handle, &p, lb->list[0].name[i], 0, MwALIGNMENT_END, text);
|
MwDrawText(handle, NULL, &p, lb->list[0].name[i], MwALIGNMENT_END, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
x += r.width;
|
x += r.width;
|
||||||
|
|
@ -593,7 +595,7 @@ static void tick(MwWidget handle) {
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwListBoxClassRec = {
|
MwClassRec MwListBoxClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
|
|
@ -608,7 +610,7 @@ MwClassRec MwListBoxClassRec = {
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ static void set_xywh(MwWidget handle) {
|
||||||
int diff = MwDefaultBorderWidth(handle);
|
int diff = MwDefaultBorderWidth(handle);
|
||||||
diff = 0;
|
diff = 0;
|
||||||
|
|
||||||
height = MwTextHeight(handle, "M") + 10;
|
height = MwTextHeight(handle, NULL, "M") + 10;
|
||||||
|
|
||||||
MwVaApply(handle,
|
MwVaApply(handle,
|
||||||
MwNx, -diff,
|
MwNx, -diff,
|
||||||
|
|
@ -18,7 +18,7 @@ static void set_xywh(MwWidget handle) {
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int create(MwWidget handle) {
|
static int wcreate(MwWidget handle) {
|
||||||
MwMenu m = malloc(sizeof(*m));
|
MwMenu m = malloc(sizeof(*m));
|
||||||
|
|
||||||
m->name = NULL;
|
m->name = NULL;
|
||||||
|
|
@ -71,8 +71,8 @@ static void destroy(MwWidget handle) {
|
||||||
#define BEGIN_MENU_LOOP \
|
#define BEGIN_MENU_LOOP \
|
||||||
for(i = 0; i < arrlen(m->sub); i++) { \
|
for(i = 0; i < arrlen(m->sub); i++) { \
|
||||||
int incr = m->sub[i]->name[0] == '?' ? 1 : 0; \
|
int incr = m->sub[i]->name[0] == '?' ? 1 : 0; \
|
||||||
int tw = MwTextWidth(handle, m->sub[i]->name + incr); \
|
int tw = MwTextWidth(handle, NULL, m->sub[i]->name + incr); \
|
||||||
int th = MwTextHeight(handle, m->sub[i]->name + incr); \
|
int th = MwTextHeight(handle, NULL, m->sub[i]->name + incr); \
|
||||||
int in_area; \
|
int in_area; \
|
||||||
\
|
\
|
||||||
if(incr) { \
|
if(incr) { \
|
||||||
|
|
@ -104,7 +104,7 @@ static void draw(MwWidget handle) {
|
||||||
MwDrawWidgetBack(handle, &r, base, 0, MwFALSE);
|
MwDrawWidgetBack(handle, &r, base, 0, MwFALSE);
|
||||||
}
|
}
|
||||||
|
|
||||||
MwDrawText(handle, &p, m->sub[i]->name + incr, m->sub[i]->wsub != NULL || (in_area && handle->pressed) ? 1 : 0, MwALIGNMENT_BEGINNING, text);
|
MwDrawText(handle, MwFLBuildFont((m->sub[i]->wsub != NULL || (in_area && handle->pressed)) ? MwFLFlagBold : 0), &p, m->sub[i]->name + incr, MwALIGNMENT_BEGINNING, text);
|
||||||
END_MENU_LOOP;
|
END_MENU_LOOP;
|
||||||
|
|
||||||
MwLLFreeColor(text);
|
MwLLFreeColor(text);
|
||||||
|
|
@ -118,7 +118,7 @@ static void parent_resize(MwWidget handle) {
|
||||||
static void mouse_down(MwWidget handle, void* ptr) {
|
static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
MENU_LOOP_DECL;
|
MENU_LOOP_DECL;
|
||||||
|
|
||||||
if(((MwLLMouse*)ptr)->button != MwLLMouseLeft) return;
|
if(((MwMouse*)ptr)->button != MwMOUSE_LEFT) return;
|
||||||
|
|
||||||
BEGIN_MENU_LOOP;
|
BEGIN_MENU_LOOP;
|
||||||
if(in_area) {
|
if(in_area) {
|
||||||
|
|
@ -129,7 +129,7 @@ static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
p2.y = p.y + th / 2 + 5;
|
p2.y = p.y + th / 2 + 5;
|
||||||
|
|
||||||
m->sub[i]->wsub = MwCreateWidget(MwSubMenuClass, "submenu", handle, 0, 0, 0, 0);
|
m->sub[i]->wsub = MwCreateWidget(MwSubMenuClass, "submenu", handle, 0, 0, 0, 0);
|
||||||
MwSubMenuAppear(m->sub[i]->wsub, m->sub[i], &p2);
|
MwSubMenuAppear(m->sub[i]->wsub, m->sub[i], &p2, 0);
|
||||||
} else if(m->sub[i]->wsub != NULL && m->sub[i]->keep) {
|
} else if(m->sub[i]->wsub != NULL && m->sub[i]->keep) {
|
||||||
MwDestroyWidget(m->sub[i]->wsub);
|
MwDestroyWidget(m->sub[i]->wsub);
|
||||||
m->sub[i]->wsub = NULL;
|
m->sub[i]->wsub = NULL;
|
||||||
|
|
@ -150,7 +150,7 @@ static void mouse_down(MwWidget handle, void* ptr) {
|
||||||
static void mouse_up(MwWidget handle, void* ptr) {
|
static void mouse_up(MwWidget handle, void* ptr) {
|
||||||
MENU_LOOP_DECL;
|
MENU_LOOP_DECL;
|
||||||
|
|
||||||
if(((MwLLMouse*)ptr)->button != MwLLMouseLeft) return;
|
if(((MwMouse*)ptr)->button != MwMOUSE_LEFT) return;
|
||||||
|
|
||||||
BEGIN_MENU_LOOP;
|
BEGIN_MENU_LOOP;
|
||||||
if(in_area && m->sub[i]->wsub != NULL) {
|
if(in_area && m->sub[i]->wsub != NULL) {
|
||||||
|
|
@ -189,7 +189,7 @@ static void func_handler(MwWidget handle, const char* name, void* out, va_list v
|
||||||
}
|
}
|
||||||
|
|
||||||
MwClassRec MwMenuClassRec = {
|
MwClassRec MwMenuClassRec = {
|
||||||
create, /* create */
|
wcreate, /* create */
|
||||||
destroy, /* destroy */
|
destroy, /* destroy */
|
||||||
draw, /* draw */
|
draw, /* draw */
|
||||||
NULL, /* click */
|
NULL, /* click */
|
||||||
|
|
@ -204,7 +204,7 @@ MwClassRec MwMenuClassRec = {
|
||||||
NULL, /* resize */
|
NULL, /* resize */
|
||||||
NULL, /* children_update */
|
NULL, /* children_update */
|
||||||
NULL, /* children_prop_change */
|
NULL, /* children_prop_change */
|
||||||
NULL,
|
NULL, /* clipboard */
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue