git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@39 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
NishiOwO
2025-09-29 00:10:20 +00:00
parent b518cee5cc
commit cad1113643
15 changed files with 46 additions and 46 deletions

View File

@@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>
void handler(MwWidget handle, void* user_data, void* call_data){ void handler(MwWidget handle, void* user_data, void* call_data){
printf("hello world!\n"); printf("hello world!\n");

View File

@@ -11,19 +11,19 @@
MWDECL MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height); MWDECL MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height);
MWDECL MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...); MWDECL MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...);
MWDECL MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va); MWDECL MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va);
MWDECL void MwDestroyWidget(MwWidget handle); MWDECL void MwDestroyWidget(MwWidget handle);
MWDECL void MwLoop(MwWidget handle); MWDECL void MwLoop(MwWidget handle);
MWDECL void MwStep(MwWidget handle); MWDECL void MwStep(MwWidget handle);
MWDECL int MwPending(MwWidget handle); MWDECL int MwPending(MwWidget handle);
MWDECL void MwSetInteger(MwWidget handle, const char* key, int n); MWDECL void MwSetInteger(MwWidget handle, const char* key, int n);
MWDECL void MwSetText(MwWidget handle, const char* key, const char* value); MWDECL void MwSetText(MwWidget handle, const char* key, const char* value);
MWDECL int MwGetInteger(MwWidget handle, const char* key); MWDECL int MwGetInteger(MwWidget handle, const char* key);
MWDECL const char* MwGetText(MwWidget handle, const char* key); MWDECL const char* MwGetText(MwWidget handle, const char* key);
MWDECL void MwSetDefault(MwWidget handle); MWDECL void MwSetDefault(MwWidget handle);
MWDECL void MwVaApply(MwWidget handle, ...); MWDECL void MwVaApply(MwWidget handle, ...);
MWDECL void MwVaListApply(MwWidget handle, va_list va); MWDECL void MwVaListApply(MwWidget handle, va_list va);
MWDECL void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data); MWDECL void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data);
MWDECL void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data); MWDECL void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data);

View File

@@ -4,7 +4,7 @@
#include <Mw/MachDep.h> #include <Mw/MachDep.h>
typedef struct _MwLL * MwLL, MwLLRec; typedef struct _MwLL * MwLL, MwLLRec;
typedef struct _MwLLColor *MwLLColor, MwLLColorRec; typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
#include <Mw/TypeDefs.h> #include <Mw/TypeDefs.h>

View File

@@ -6,7 +6,7 @@
typedef struct _MwLLHandler *MwLLHandler, MwLLHandlerRec; typedef struct _MwLLHandler *MwLLHandler, MwLLHandlerRec;
#ifdef _MILSKO #ifdef _MILSKO
typedef struct _MwLL * MwLL, MwLLRec; typedef struct _MwLL * MwLL, MwLLRec;
typedef struct _MwLLColor *MwLLColor, MwLLColorRec; typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
#else #else
typedef void* MwLL; typedef void* MwLL;
@@ -38,12 +38,12 @@ MWDECL void MwLLDestroyCommon(MwLL handle);
/* driver-specific */ /* driver-specific */
MWDECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height); MWDECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height);
MWDECL void MwLLDestroy(MwLL handle); MWDECL void MwLLDestroy(MwLL handle);
MWDECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color); MWDECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
MWDECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b); MWDECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b);
MWDECL void MwLLFreeColor(MwLLColor color); MWDECL void MwLLFreeColor(MwLLColor color);
MWDECL void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h); MWDECL void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
MWDECL void MwLLSetXY(MwLL handle, int x, int y); MWDECL void MwLLSetXY(MwLL handle, int x, int y);
@@ -51,7 +51,7 @@ MWDECL void MwLLSetWH(MwLL handle, int w, int h);
MWDECL void MwLLSetTitle(MwLL handle, const char* title); MWDECL void MwLLSetTitle(MwLL handle, const char* title);
MWDECL int MwLLPending(MwLL handle); MWDECL int MwLLPending(MwLL handle);
MWDECL void MwLLNextEvent(MwLL handle); MWDECL void MwLLNextEvent(MwLL handle);
MWDECL void MwLLSleep(int ms); MWDECL void MwLLSleep(int ms);

View File

@@ -1,6 +1,6 @@
/* $Id$ */ /* $Id$ */
#ifndef __MW_MW_H__ #ifndef __MW_MILSKO_H__
#define __MW_MW_H__ #define __MW_MILSKO_H__
#include <Mw/MachDep.h> #include <Mw/MachDep.h>
#include <Mw/LowLevel.h> #include <Mw/LowLevel.h>

View File

@@ -4,11 +4,11 @@
#include <Mw/MachDep.h> #include <Mw/MachDep.h>
typedef struct _MwClass * MwClass, MwClassRec; typedef struct _MwClass * MwClass, MwClassRec;
typedef struct _MwPoint MwPoint; typedef struct _MwPoint MwPoint;
typedef struct _MwRect MwRect; typedef struct _MwRect MwRect;
typedef struct _MwIntegerKeyValue MwIntegerKeyValue; typedef struct _MwIntegerKeyValue MwIntegerKeyValue;
typedef struct _MwTextKeyValue MwTextKeyValue; typedef struct _MwTextKeyValue MwTextKeyValue;
typedef struct _MwUserHandlerKeyValue MwUserHandlerKeyValue; typedef struct _MwUserHandlerKeyValue MwUserHandlerKeyValue;
#ifdef _MILSKO #ifdef _MILSKO
typedef struct _MwWidget *MwWidget, MwWidgetRec; typedef struct _MwWidget *MwWidget, MwWidgetRec;
@@ -45,8 +45,8 @@ struct _MwIntegerKeyValue {
}; };
struct _MwUserHandlerKeyValue { struct _MwUserHandlerKeyValue {
char* key; char* key;
void* user_data; void* user_data;
MwUserHandler value; MwUserHandler value;
}; };
@@ -54,21 +54,21 @@ struct _MwUserHandlerKeyValue {
struct _MwWidget { struct _MwWidget {
char* name; char* name;
MwLL lowlevel; MwLL lowlevel;
MwWidget parent; MwWidget parent;
MwWidget* children; MwWidget* children;
MwClass class; MwClass class;
int pressed; int pressed;
MwIntegerKeyValue* integer; MwIntegerKeyValue* integer;
MwTextKeyValue* text; MwTextKeyValue* text;
MwUserHandlerKeyValue* handler; MwUserHandlerKeyValue* handler;
}; };
#endif #endif
struct _MwClass { struct _MwClass {
void* opaque; void* opaque;
MwHandler create; MwHandler create;
MwHandler destroy; MwHandler destroy;
MwHandler draw; MwHandler draw;

View File

@@ -4,7 +4,7 @@
#include <Mw/MachDep.h> #include <Mw/MachDep.h>
typedef struct _MwLL * MwLL, MwLLRec; typedef struct _MwLL * MwLL, MwLLRec;
typedef struct _MwLLColor *MwLLColor, MwLLColorRec; typedef struct _MwLLColor *MwLLColor, MwLLColorRec;
#include <Mw/TypeDefs.h> #include <Mw/TypeDefs.h>

View File

@@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>
static void create(MwWidget handle) { static void create(MwWidget handle) {
MwSetDefault(handle); MwSetDefault(handle);

View File

@@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>
#include "stb_ds.h" #include "stb_ds.h"
@@ -10,14 +10,14 @@ static void lldrawhandler(MwLL handle) {
static void lluphandler(MwLL handle) { static void lluphandler(MwLL handle) {
MwWidget h = (MwWidget)handle->user; MwWidget h = (MwWidget)handle->user;
h->pressed = 0; h->pressed = 0;
MwDispatch(h, click); MwDispatch(h, click);
} }
static void lldownhandler(MwLL handle) { static void lldownhandler(MwLL handle) {
MwWidget h = (MwWidget)handle->user; MwWidget h = (MwWidget)handle->user;
h->pressed = 1; h->pressed = 1;
} }
MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) { MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) {
@@ -53,7 +53,7 @@ MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x,
MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...) { MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...) {
MwWidget h; MwWidget h;
va_list va; va_list va;
va_start(va, height); va_start(va, height);
h = MwVaListCreateWidget(class, name, parent, x, y, width, height, va); h = MwVaListCreateWidget(class, name, parent, x, y, width, height, va);
@@ -204,7 +204,7 @@ void MwVaListApply(MwWidget handle, va_list va) {
MwSetText(handle, key, t); MwSetText(handle, key, t);
} else if(key[0] == 'C') { } else if(key[0] == 'C') {
MwUserHandler h = va_arg(va, MwUserHandler); MwUserHandler h = va_arg(va, MwUserHandler);
int ind; int ind;
shput(handle->handler, key, h); shput(handle->handler, key, h);
ind = shgeti(handle->handler, key); ind = shgeti(handle->handler, key);

View File

@@ -1,4 +1,4 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>
const char* MwDefaultBackground = "#ddd"; const char* MwDefaultBackground = "#ddd";

View File

@@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>
static int hex(const char* txt, int len) { static int hex(const char* txt, int len) {
int i; int i;
@@ -61,9 +61,9 @@ void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color) {
} }
void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) { void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) {
MwPoint p[6]; MwPoint p[6];
const int diff = 128; const int diff = 128;
const int border = 2; const int border = 2;
MwLLColor darker = MwLLAllocColor(handle->lowlevel, color->red - diff, color->green - diff, color->blue - diff); MwLLColor darker = MwLLAllocColor(handle->lowlevel, color->red - diff, color->green - diff, color->blue - diff);
MwLLColor lighter = MwLLAllocColor(handle->lowlevel, color->red + diff, color->green + diff, color->blue + diff); MwLLColor lighter = MwLLAllocColor(handle->lowlevel, color->red + diff, color->green + diff, color->blue + diff);

View File

@@ -1,2 +1,2 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>

View File

@@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>
void MwLLCreateCommon(MwLL handle) { void MwLLCreateCommon(MwLL handle) {
handle->handler = malloc(sizeof(*handle->handler)); handle->handler = malloc(sizeof(*handle->handler));

View File

@@ -1,5 +1,5 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>
static void create(MwWidget handle) { static void create(MwWidget handle) {
MwSetDefault(handle); MwSetDefault(handle);
@@ -7,7 +7,7 @@ static void create(MwWidget handle) {
static void draw(MwWidget handle) { static void draw(MwWidget handle) {
MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNbackground)); MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNbackground));
MwRect r; MwRect r;
r.x = 0; r.x = 0;
r.y = 0; r.y = 0;

View File

@@ -1,10 +1,10 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Mw.h> #include <Mw/Milsko.h>
static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask; static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask;
MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) { MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
MwLL r; MwLL r;
Window p; Window p;
Window root; Window root;
unsigned int border, depth; unsigned int border, depth;
@@ -56,7 +56,7 @@ void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color
MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) { MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) {
MwLLColor c = malloc(sizeof(*c)); MwLLColor c = malloc(sizeof(*c));
XColor xc; XColor xc;
if(r > 255) r = 255; if(r > 255) r = 255;
if(g > 255) g = 255; if(g > 255) g = 255;