things
All checks were successful
pyrite-dev/milsko/pipeline/head This commit looks good

This commit is contained in:
Nishi 2026-05-06 00:12:06 +09:00
commit 89911082ed
Signed by: nishi
GPG key ID: 27EF69B208EB9343
9 changed files with 160 additions and 18 deletions

View file

@ -30,7 +30,9 @@ static void newrow(void) {
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);
boxes[++row] = MwVaCreateWidget(MwBoxClass, "box", box, 0, 0, 0, 0,
MwNwaitLayout, 1,
NULL);
n = 0;
}
@ -224,6 +226,7 @@ int main() {
box = MwVaCreateWidget(MwBoxClass, "box", window, 0, 0, 0, 0,
MwNorientation, MwVERTICAL,
MwNwaitLayout, 1,
NULL);
newrow();
@ -263,6 +266,10 @@ int main() {
add(f);
}
f = frame("Calendar", -PaddingContent, -PaddingContent, MwCalendarClass,
NULL);
add(f);
f = frame("ComboBox", -PaddingContent, 24, MwComboBoxClass, NULL);
w = child(f);
MwComboBoxAdd(w, -1, "Hello!");
@ -306,21 +313,18 @@ int main() {
f = frame("Separator", -PaddingContent, -PaddingContent, MwSeparatorClass, NULL);
add(f);
#if 1
f = frame("SubWindow", -PaddingContent, -PaddingContent, MwViewportClass,
MwNratio, 3,
MwNratio, 2,
NULL);
w = child(f);
MwViewportSetSize(w, 512, 512);
MwVaCreateWidget(MwSubWindowClass, "swnd", MwViewportGetViewport(w), 32, 32, 256, 128,
MwNtitle, "Sub window",
NULL);
add(f);
MwVaCreateWidget(MwSubWindowClass, "swnd", MwViewportGetViewport(w), 64, 64, 256, 128,
MwNtitle, "Sub window 2",
NULL);
add(f);
#endif
f = frame("TreeView", -PaddingContent, -PaddingContent, MwTreeViewClass, NULL);
w = child(f);
@ -344,6 +348,15 @@ int main() {
resize(window, NULL, NULL);
MwVaApply(box,
MwNwaitLayout, 0,
NULL);
for(i = 0; i < row; i++) {
MwVaApply(boxes[i],
MwNwaitLayout, 0,
NULL);
}
MwLoop(window);
MwLLDestroyPixmap(px);

View file

@ -32,25 +32,26 @@
#include <Mw/Dialog/DirectoryChooser.h>
#include <Mw/Dialog/ColorPicker.h>
#include <Mw/Widget/Window.h>
#include <Mw/Widget/Menu.h>
#include <Mw/Widget/SubMenu.h>
#include <Mw/Widget/Box.h>
#include <Mw/Widget/Button.h>
#include <Mw/Widget/Label.h>
#include <Mw/Widget/Calendar.h>
#include <Mw/Widget/CheckBox.h>
#include <Mw/Widget/ComboBox.h>
#include <Mw/Widget/Entry.h>
#include <Mw/Widget/Frame.h>
#include <Mw/Widget/Image.h>
#include <Mw/Widget/Entry.h>
#include <Mw/Widget/ScrollBar.h>
#include <Mw/Widget/NumberEntry.h>
#include <Mw/Widget/Viewport.h>
#include <Mw/Widget/Label.h>
#include <Mw/Widget/ListBox.h>
#include <Mw/Widget/Menu.h>
#include <Mw/Widget/NumberEntry.h>
#include <Mw/Widget/ProgressBar.h>
#include <Mw/Widget/RadioBox.h>
#include <Mw/Widget/ScrollBar.h>
#include <Mw/Widget/Separator.h>
#include <Mw/Widget/ComboBox.h>
#include <Mw/Widget/TreeView.h>
#include <Mw/Widget/Box.h>
#include <Mw/Widget/SubMenu.h>
#include <Mw/Widget/SubWindow.h>
#include <Mw/Widget/TreeView.h>
#include <Mw/Widget/Viewport.h>
#include <Mw/Widget/Window.h>
#endif

View file

@ -43,6 +43,10 @@
#define MwNdarkTheme "IdarkTheme"
#define MwNuseMonospace "IuseMonospace"
#define MwNdarkThemeAutomatic "IdarkThemeAutomatic"
#define MwNmonth "Imonth"
#define MwNdate "Idate"
#define MwNday "Iday"
#define MwNwaitLayout "IwaitLayout"
#define MwNtitle "Stitle"
#define MwNtext "Stext"

View file

@ -0,0 +1,24 @@
/*!
* @file Mw/Widget/Calendar.h
* @brief Calendar widget
*/
#ifndef __MW_WIDGET_CALENDAR_H__
#define __MW_WIDGET_CALENDAR_H__
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#ifdef __cplusplus
extern "C" {
#endif
/*!
* @brief Calendar widget class
*/
MWDECL MwClass MwCalendarClass;
#ifdef __cplusplus
}
#endif
#endif

View file

@ -97,6 +97,10 @@
<integer name="useMonospace" common="yes" boolean="yes" />
<integer name="fillArea" />
<integer name="darkThemeAutomatic" common="yes" boolean="yes" />
<integer name="month" />
<integer name="date" />
<integer name="day" />
<integer name="waitLayout" />
<!-- waitMS is a special property, only applies to toplevel widget -->
<integer name="waitMS" common="yes" />
@ -612,6 +616,7 @@
<property name="padding" />
<property name="hasBorder" />
<property name="inverted" />
<property name="waitLayout" />
</properties>
</widget>
<widget name="Button">
@ -627,6 +632,13 @@
<handler name="changed" />
</handlers>
</widget>
<widget name="Calendar">
<properties>
<property name="month" />
<property name="date" />
<property name="day" />
</properties>
</widget>
<widget name="CheckBox">
<properties>
<property name="checked" />
@ -883,6 +895,13 @@
<property name="iconPixmap" />
<property name="title" />
</properties>
<functions>
<function name="GetFrame">
<return>
<widget />
</return>
</function>
</functions>
</widget>
<!-- They are not alphabetically sorted for reasons -->

View file

@ -143,6 +143,7 @@ new_object("src/text/font/*.c");
new_object("src/widget/box.c");
new_object("src/widget/button.c");
new_object("src/widget/calendar.c");
new_object("src/widget/checkbox.c");
new_object("src/widget/combobox.c");
new_object("src/widget/entry.c");

View file

@ -74,7 +74,7 @@ void MwDrawText(MwWidget handle, MwFLFont ttf, MwPoint* point, const char* text,
if(!MwGetInteger(handle, MwNbitmapFont) && ttf <= MwFLBuildFont(0xff)) ttf = assume_ttf(handle, ttf);
#endif
p.y -= MwTextHeight(handle, ttf, text) / 2 - (MwTextHeight(handle, ttf, text) / count_nl(text)) / 2;
p.y -= (MwTextHeight(handle, ttf, text) - (MwTextHeight(handle, ttf, text) / count_nl(text))) / 2;
while(*input != 0) {
input += MwUTF8ToUTF32(input, &cp);

View file

@ -15,6 +15,7 @@ static int wcreate(MwWidget handle) {
MwSetInteger(handle, MwNpadding, 0);
MwSetInteger(handle, MwNhasBorder, 0);
MwSetInteger(handle, MwNinverted, 1);
MwSetInteger(handle, MwNwaitLayout, 0);
b->layout = 0;
@ -116,7 +117,7 @@ static void children_prop_change(MwWidget handle, MwWidget child, const char* ke
static void tick(MwWidget handle) {
MwBox b = handle->internal;
if(b->layout) {
if(b->layout && !MwGetInteger(handle, MwNwaitLayout)) {
layout(handle);
b->layout = 0;

79
src/widget/calendar.c Normal file
View file

@ -0,0 +1,79 @@
#include <Mw/Milsko.h>
static int wcreate(MwWidget handle) {
MwSetDefault(handle);
MwSetInteger(handle, MwNmonth, 0);
MwSetInteger(handle, MwNdate, 1);
MwSetInteger(handle, MwNday, 3);
return 0;
}
static void draw(MwWidget handle) {
MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwLLColor csb = MwParseColor(handle, MwGetText(handle, MwNsubBackground));
MwLLColor csf = MwParseColor(handle, MwGetText(handle, MwNsubForeground));
MwRect r, r2;
MwPoint p[4];
int tw = 2;
int th = 6;
char buf[3];
r.x = 0;
r.y = 0;
r.width = MwGetInteger(handle, MwNwidth);
r.height = MwGetInteger(handle, MwNheight);
MwDrawRect(handle, &r, c);
r2.width = 32;
r2.height = 32 - th - 1;
r2.x = (r.width - r2.width) / 2;
r2.y = (r.height - r2.height - th - 1) / 2;
MwDrawRect(handle, &r2, csb);
p[0].x = r2.x;
p[0].y = r2.y + r2.height;
p[1].x = r2.x - tw;
p[1].y = r2.y + r2.height + th;
p[2].x = r2.x + r2.width - tw;
p[2].y = r2.y + r2.height + th;
p[3].x = r2.x + r2.width;
p[3].y = r2.y + r2.height;
MwLLPolygon(handle->lowlevel, p, 4, csb);
p[0].x = r.width / 2;
p[0].y = r.height / 2;
sprintf(buf, "%d", MwGetInteger(handle, MwNdate));
MwDrawText(handle, MwFLBuildFont(MwFLFlagBold), p, buf, MwALIGNMENT_CENTER, csf);
MwLLFreeColor(csf);
MwLLFreeColor(csb);
MwLLFreeColor(c);
}
static void prop_change(MwWidget handle, const char* key) {
if(strcmp(key, MwNmonth) == 0 || strcmp(key, MwNdate) == 0 || strcmp(key, MwNday) == 0) MwForceRender(handle);
}
MwClassRec MwCalendarClassRec = {
wcreate, /* create */
NULL, /* destroy */
draw, /* draw */
NULL, /* click */
NULL, /* parent_resize */
prop_change, /* prop_change */
NULL, /* mouse_move */
NULL, /* mouse_up */
NULL, /* mouse_down */
NULL, /* key */
NULL, /* execute */
NULL, /* tick */
NULL, /* resize */
NULL, /* children_update */
NULL, /* children_prop_change */
NULL, /* clipboard */
NULL, /* props_change */
NULL,
NULL,
NULL};
MwClass MwCalendarClass = &MwCalendarClassRec;