add widgets to periodic table
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-04-24 02:23:25 +09:00
commit d225f7cb72
Signed by: nishi
GPG key ID: 27EF69B208EB9343
9 changed files with 158 additions and 160 deletions

View file

@ -145,11 +145,12 @@ static void MWAPI menu_handler(MwWidget handle, void* user, void* call) {
}
int main() {
int i, j;
MwWidget f, w, b;
int index;
MwMenu m, m2;
void* v;
int i, j;
MwWidget f, w, b;
MwLLPixmap px;
int index;
MwMenu m, m2;
void* v;
MwLibraryInit();
@ -157,6 +158,8 @@ int main() {
MwNtitle, "Milsko Periodic Table",
NULL);
px = MwLoadIcon(window, MwIconError);
menu = MwCreateWidget(MwMenuClass, "menu", window, 0, 0, 0, 0);
m = MwMenuAdd(menu, NULL, "File");
@ -256,6 +259,12 @@ int main() {
f = frame("Entry", -PaddingContent, 24, MwEntryClass, NULL);
add(f);
f = frame("Image", -PaddingContent, -PaddingContent, MwImageClass,
MwNpixmap, px,
NULL);
w = child(f);
add(f);
f = frame("Label", -PaddingContent, -PaddingContent, MwLabelClass,
MwNtext, "Epic text",
NULL);
@ -292,6 +301,14 @@ int main() {
v = MwTreeViewAdd(w, v, NULL, "ghi");
add(f);
f = frame("Viewport", -PaddingContent, -PaddingContent, MwViewportClass, NULL);
w = child(f);
MwViewportSetSize(w, 256, 256);
MwVaCreateWidget(MwButtonClass, "btn", MwViewportGetViewport(w), 64, 64, 128, 128,
MwNtext, "Thing",
NULL);
add(f);
if(n != 0) newrow();
if(n == 0) MwDestroyWidget(boxes[row]);
@ -300,4 +317,6 @@ int main() {
resize(window, NULL, NULL);
MwLoop(window);
MwLLDestroyPixmap(px);
}

View file

@ -31,12 +31,12 @@ int main() {
if(px == NULL) px = MwLoadImage(vp, "picture.png");
// MwVaCreateWidget(MwImageClass, "image", MwViewportGetViewport(vp), 0, 0, 1024, 1024,
// MwNpixmap, px,
// NULL);
// MwVaCreateWidget(MwImageClass, "image", MwViewportGetViewport(vp), 0, 0, 1024, 1024,
// MwNpixmap, px,
// NULL);
MwViewportSetSize(vp, 1024, 1024);
MwWidget f = MwCreateWidget(MwFrameClass, "fr", MwViewportGetViewport(vp), 256, 256, 128, 128);
f = MwCreateWidget(MwFrameClass, "fr", f, 0, 0, 128, 128);
f = MwCreateWidget(MwFrameClass, "fr", f, 0, 0, 128, 128);
MwCreateWidget(MwButtonClass, "btn", f, 64, 64, 128, 128);
MwAddUserHandler(w, MwNresizeHandler, resize, NULL);

View file

@ -4,36 +4,36 @@
#define CP_UTF8 65001
#endif
char* MwACPToUTF8(const char* input){
char* MwACPToUTF8(const char* input) {
#if defined(_WIN32) && defined(MW_HAS_WCHAR)
int mbbytes = (strlen(input) + 1) * 4;
int wbytes = 0;
int wbytes = 0;
int len;
wchar_t* wout;
char* mbout = malloc(mbbytes);
char* mbout = malloc(mbbytes);
wbytes = MultiByteToWideChar(CP_ACP, 0, input, strlen(input), NULL, 0) * sizeof(wchar_t);
if(wbytes == 0){
if(wbytes == 0) {
free(mbout);
return MwStringDuplicate(input);
}
wout = malloc(wbytes);
len = wbytes / sizeof(wchar_t);
len = wbytes / sizeof(wchar_t);
memset(wout, 0, wbytes);
memset(mbout, 0, mbbytes);
len = MultiByteToWideChar(CP_ACP, 0, input, strlen(input), wout, len);
if(len == 0){
if(len == 0) {
free(mbout);
free(wout);
return MwStringDuplicate(input);
}
len = WideCharToMultiByte(CP_UTF8, 0, wout, len, mbout, mbbytes, 0, 0);
if(len == 0){
if(len == 0) {
free(mbout);
free(wout);
return MwStringDuplicate(input);
@ -46,39 +46,39 @@ char* MwACPToUTF8(const char* input){
return mbout;
#else
return MwStringDuplicate(input);
#endif
#endif
}
char* MwUTF8ToACP(const char* input){
char* MwUTF8ToACP(const char* input) {
#if defined(_WIN32) && defined(MW_HAS_WCHAR)
int mbbytes = (strlen(input) + 1) * 4;
int wbytes = 0;
int wbytes = 0;
int len;
wchar_t* wout;
char* mbout = malloc(mbbytes);
char* mbout = malloc(mbbytes);
wbytes = MultiByteToWideChar(CP_UTF8, 0, input, strlen(input), NULL, 0) * sizeof(wchar_t);
if(wbytes == 0){
if(wbytes == 0) {
free(mbout);
return MwStringDuplicate(input);
}
wout = malloc(wbytes);
len = wbytes / sizeof(wchar_t);
len = wbytes / sizeof(wchar_t);
memset(wout, 0, wbytes);
memset(mbout, 0, mbbytes);
len = MultiByteToWideChar(CP_UTF8, 0, input, strlen(input), wout, len);
if(len == 0){
if(len == 0) {
free(mbout);
free(wout);
return MwStringDuplicate(input);
}
len = WideCharToMultiByte(CP_ACP, 0, wout, len, mbout, mbbytes, 0, 0);
if(len == 0){
if(len == 0) {
free(mbout);
free(wout);
return MwStringDuplicate(input);
@ -91,5 +91,5 @@ char* MwUTF8ToACP(const char* input){
return mbout;
#else
return MwStringDuplicate(input);
#endif
#endif
}

View file

@ -1751,13 +1751,13 @@ static void clip(MwLL handle) {
x += ws[i]->wayland.x;
y += ws[i]->wayland.y;
for(j = i - 1; j >= 0; j--){
for(j = i - 1; j >= 0; j--) {
if(ws[j]->wayland.x > cx) l = 1;
if(ws[j]->wayland.y > cy) l = 1;
if(l) break;
}
if(!l){
if(!l) {
cx = MAX(cx, ws[i]->wayland.x);
cy = MAX(cy, ws[i]->wayland.y);
}

View file

@ -7,44 +7,37 @@
* These ""glyphs"" are unencumbered
*/
MwCursor MwCursorArrow = {
14, 14, -13, -14,
{
3, /* ............## */
15, /* ..........#### */
62, /* ........#####. */
254, /* ......#######. */
1020, /* ....########.. */
4092, /* ..##########.. */
248, /* ......#####... */
504, /* .....######... */
944, /* ....###.##.... */
1840, /* ...###..##.... */
3616, /* ..###...#..... */
7200, /* .###....#..... */
14336, /* ###........... */
4096, /* .#............ */
0,
0
}
};
14, 14, -13, -14, {3, /* ............## */
15, /* ..........#### */
62, /* ........#####. */
254, /* ......#######. */
1020, /* ....########.. */
4092, /* ..##########.. */
248, /* ......#####... */
504, /* .....######... */
944, /* ....###.##.... */
1840, /* ...###..##.... */
3616, /* ..###...#..... */
7200, /* .###....#..... */
14336, /* ###........... */
4096, /* .#............ */
0, 0}};
MwCursor MwCursorArrowMask = {
16, 16, -14, -15,
{
7, /* .............### */
31, /* ...........##### */
127, /* .........####### */
510, /* .......########. */
2046, /* .....##########. */
8188, /* ...###########.. */
16380, /* ..############.. */
16376, /* ..###########... */
2040, /* .....########... */
4080, /* ....########.... */
8176, /* ...#########.... */
16096, /* ..#####.###..... */
31968, /* .#####..###..... */
63552, /* #####....#...... */
28672, /* .###............ */
8192 /* ..#............. */
}
};
16, 16, -14, -15, {
7, /* .............### */
31, /* ...........##### */
127, /* .........####### */
510, /* .......########. */
2046, /* .....##########. */
8188, /* ...###########.. */
16380, /* ..############.. */
16376, /* ..###########... */
2040, /* .....########... */
4080, /* ....########.... */
8176, /* ...#########.... */
16096, /* ..#####.###..... */
31968, /* .#####..###..... */
63552, /* #####....#...... */
28672, /* .###............ */
8192 /* ..#............. */
}};

View file

@ -7,44 +7,37 @@
* These ""glyphs"" are unencumbered
*/
MwCursor MwCursorDefault = {
8, 14, 0, -14,
{
128, /* #....... */
192, /* ##...... */
224, /* ###..... */
240, /* ####.... */
248, /* #####... */
252, /* ######.. */
254, /* #######. */
255, /* ######## */
248, /* #####... */
216, /* ##.##... */
140, /* #...##.. */
12, /* ....##.. */
6, /* .....##. */
6, /* .....##. */
0,
0
}
};
8, 14, 0, -14, {128, /* #....... */
192, /* ##...... */
224, /* ###..... */
240, /* ####.... */
248, /* #####... */
252, /* ######.. */
254, /* #######. */
255, /* ######## */
248, /* #####... */
216, /* ##.##... */
140, /* #...##.. */
12, /* ....##.. */
6, /* .....##. */
6, /* .....##. */
0, 0}};
MwCursor MwCursorDefaultMask = {
10, 16, -1, -15,
{
768, /* ##........ */
896, /* ###....... */
960, /* ####...... */
992, /* #####..... */
1008, /* ######.... */
1016, /* #######... */
1020, /* ########.. */
1022, /* #########. */
1023, /* ########## */
1023, /* ########## */
1016, /* #######... */
956, /* ###.####.. */
828, /* ##..####.. */
30, /* .....####. */
30, /* .....####. */
12 /* ......##.. */
}
};
10, 16, -1, -15, {
768, /* ##........ */
896, /* ###....... */
960, /* ####...... */
992, /* #####..... */
1008, /* ######.... */
1016, /* #######... */
1020, /* ########.. */
1022, /* #########. */
1023, /* ########## */
1023, /* ########## */
1016, /* #######... */
956, /* ###.####.. */
828, /* ##..####.. */
30, /* .....####. */
30, /* .....####. */
12 /* ......##.. */
}};

View file

@ -7,44 +7,37 @@
* These ""glyphs"" are unencumbered
*/
MwCursor MwCursorText = {
7, 14, -3, -7,
{
119, /* ###.### */
28, /* ..###.. */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
28, /* ..###.. */
119, /* ###.### */
0,
0
}
};
7, 14, -3, -7, {119, /* ###.### */
28, /* ..###.. */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
8, /* ...#... */
28, /* ..###.. */
119, /* ###.### */
0, 0}};
MwCursor MwCursorTextMask = {
9, 16, -4, -8,
{
495, /* ####.#### */
511, /* ######### */
511, /* ######### */
124, /* ..#####.. */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
124, /* ..#####.. */
511, /* ######### */
511, /* ######### */
495 /* ####.#### */
}
};
9, 16, -4, -8, {
495, /* ####.#### */
511, /* ######### */
511, /* ######### */
124, /* ..#####.. */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
56, /* ...###... */
124, /* ..#####.. */
511, /* ######### */
511, /* ######### */
495 /* ####.#### */
}};

View file

@ -468,7 +468,7 @@ static void scan(MwWidget handle, const char* path, int record) {
for(i = 0; i < arrlen(fc->entries); i++) {
if(strcmp(fc->entries[i]->name, ".") == 0 || strcmp(fc->entries[i]->name, "..") == 0) continue;
if(fc->entries[i]->type == MwDIRECTORY_DIRECTORY) {
char date[128];
char date[128];
char* n = MwACPToUTF8(fc->entries[i]->name);
MwStringTime(date, fc->entries[i]->mtime);
@ -477,7 +477,7 @@ static void scan(MwWidget handle, const char* path, int record) {
MwListBoxSet(fc->files, index, -1, date);
MwListBoxSet(fc->files, index, -1, NULL);
MwListBoxSetIcon(fc->files, index, fc->dir);
free(n);
arrput(fc->sorted_entries, fc->entries[i]);
@ -485,8 +485,8 @@ static void scan(MwWidget handle, const char* path, int record) {
}
for(i = 0; i < arrlen(fc->entries); i++) {
if(fc->entries[i]->type == MwDIRECTORY_FILE && !fc->dir_only) {
char date[128];
char size[128];
char date[128];
char size[128];
char* n = MwACPToUTF8(fc->entries[i]->name);
MwStringTime(date, fc->entries[i]->mtime);

View file

@ -189,9 +189,9 @@ static void frame_draw(MwWidget handle) {
}
p.x = MwDefaultBorderWidth(handle) + MwGetInteger(handle->parent, MwNleftPadding);
for(j = 0; j < arrlen(lb->list[i].name); j++) {
char* t = lb->list[i].name[j];
char* str;
int l = (j == 0 ? MwGetInteger(handle->parent, MwNleftPadding) : 0);
char* t = lb->list[i].name[j];
char* str;
int l = (j == 0 ? MwGetInteger(handle->parent, MwNleftPadding) : 0);
MwPoint p2 = p;
p2.y += (MwTextHeight(handle, Font, "M") + Padding) / 2;
@ -200,11 +200,11 @@ static void frame_draw(MwWidget handle) {
str = MwStringDuplicate(t);
if(MwUTF8Length(str) > (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M")) {
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M");
int ind = (get_col_width(lb, j) - l) / MwTextWidth(handle, Font, "M");
int seek = 0;
int l = 0;
int l = 0;
while(str[seek] != 0){
while(str[seek] != 0) {
int cp;
seek += MwUTF8ToUTF32(str + seek, &cp);
@ -411,7 +411,7 @@ static int mwListBoxSetImpl(MwWidget handle, int row, int col, const char* text)
MwListBox lb = handle->internal;
MwListBoxEntry entry;
char* t = text == NULL ? NULL : MwStringDuplicate(text);
int new = 0;
int new = 0;
if(row == -1) row = arrlen(lb->list);
entry.name = NULL;