diff --git a/include/Milsko/Button.h b/include/Milsko/Button.h index ca6445e..95da160 100644 --- a/include/Milsko/Button.h +++ b/include/Milsko/Button.h @@ -2,8 +2,8 @@ #ifndef __MILSKO_BUTTON_H__ #define __MILSKO_BUTTON_H__ -#include +#include -MILSKODECL MilskoClass MilskoButtonClass; +MILSKODECL MwClass MwButtonClass; #endif diff --git a/include/Milsko/Core.h b/include/Milsko/Core.h index 7926665..36659bb 100644 --- a/include/Milsko/Core.h +++ b/include/Milsko/Core.h @@ -2,30 +2,30 @@ #ifndef __MILSKO_CORE_H__ #define __MILSKO_CORE_H__ -#include -#include +#include +#include -#define MilskoDispatch(x, y) \ +#define MwDispatch(x, y) \ if(x->class != NULL && x->class->y != NULL) x->class->y(x) -MILSKODECL MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height); -MILSKODECL MilskoWidget MilskoVaCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height, ...); -MILSKODECL MilskoWidget MilskoVaListCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va); -MILSKODECL void MilskoDestroyWidget(MilskoWidget handle); +MILSKODECL MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height); +MILSKODECL MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...); +MILSKODECL MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va); +MILSKODECL void MwDestroyWidget(MwWidget handle); -MILSKODECL void MilskoLoop(MilskoWidget handle); -MILSKODECL void MilskoStep(MilskoWidget handle); -MILSKODECL int MilskoPending(MilskoWidget handle); +MILSKODECL void MwLoop(MwWidget handle); +MILSKODECL void MwStep(MwWidget handle); +MILSKODECL int MwPending(MwWidget handle); -MILSKODECL void MilskoSetInteger(MilskoWidget handle, const char* key, int n); -MILSKODECL void MilskoSetText(MilskoWidget handle, const char* key, const char* value); -MILSKODECL int MilskoGetInteger(MilskoWidget handle, const char* key); -MILSKODECL const char* MilskoGetText(MilskoWidget handle, const char* key); -MILSKODECL void MilskoSetDefault(MilskoWidget handle); -MILSKODECL void MilskoVaApply(MilskoWidget handle, ...); -MILSKODECL void MilskoVaListApply(MilskoWidget handle, va_list va); +MILSKODECL void MwSetInteger(MwWidget handle, const char* key, int n); +MILSKODECL void MwSetText(MwWidget handle, const char* key, const char* value); +MILSKODECL int MwGetInteger(MwWidget handle, const char* key); +MILSKODECL const char* MwGetText(MwWidget handle, const char* key); +MILSKODECL void MwSetDefault(MwWidget handle); +MILSKODECL void MwVaApply(MwWidget handle, ...); +MILSKODECL void MwVaListApply(MwWidget handle, va_list va); -MILSKODECL void MilskoAddUserHandler(MilskoWidget handle, const char* key, MilskoUserHandler handler, void* user_data); -MILSKODECL void MilskoDispatchUserHandler(MilskoWidget handle, const char* key, void* handler_data); +MILSKODECL void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data); +MILSKODECL void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data); #endif diff --git a/include/Milsko/Default.h b/include/Milsko/Default.h index 17e4860..6597f2b 100644 --- a/include/Milsko/Default.h +++ b/include/Milsko/Default.h @@ -2,8 +2,8 @@ #ifndef __MILSKO_DEFAULT_H__ #define __MILSKO_DEFAULT_H__ -#include +#include -MILSKODECL const char* MilskoDefaultBackground; +MILSKODECL const char* MwDefaultBackground; #endif diff --git a/include/Milsko/Draw.h b/include/Milsko/Draw.h index 2177a22..c0c09e5 100644 --- a/include/Milsko/Draw.h +++ b/include/Milsko/Draw.h @@ -2,13 +2,13 @@ #ifndef __MILSKO_DRAW_H__ #define __MILSKO_DRAW_H__ -#include -#include -#include +#include +#include +#include -MILSKODECL MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text); +MILSKODECL MwLLColor MwParseColor(MwWidget handle, const char* text); -MILSKODECL void MilskoDrawRect(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color); -MILSKODECL void MilskoDrawFrame(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color, int invert); +MILSKODECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color); +MILSKODECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert); #endif diff --git a/include/Milsko/GDI.h b/include/Milsko/GDI.h index f57b19f..1505974 100644 --- a/include/Milsko/GDI.h +++ b/include/Milsko/GDI.h @@ -2,23 +2,23 @@ #ifndef __MILSKO_GDI_H__ #define __MILSKO_GDI_H__ -#include +#include -typedef struct _MilskoLL * MilskoLL, MilskoLLRec; -typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec; +typedef struct _MwLL * MwLL, MwLLRec; +typedef struct _MwLLColor *MwLLColor, MwLLColorRec; -#include -#include +#include +#include #include -struct _MilskoLL { +struct _MwLL { void* user; - MilskoLLHandler handler; + MwLLHandler handler; }; -struct _MilskoColor { +struct _MwColor { int red; int green; int blue; diff --git a/include/Milsko/LowLevel.h b/include/Milsko/LowLevel.h index f6eb82f..6ae1329 100644 --- a/include/Milsko/LowLevel.h +++ b/include/Milsko/LowLevel.h @@ -2,57 +2,57 @@ #ifndef __MILSKO_LOWLEVEL_H__ #define __MILSKO_LOWLEVEL_H__ -#include +#include -typedef struct _MilskoLLHandler *MilskoLLHandler, MilskoLLHandlerRec; +typedef struct _MwLLHandler *MwLLHandler, MwLLHandlerRec; #ifdef _MILSKO -typedef struct _MilskoLL * MilskoLL, MilskoLLRec; -typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec; +typedef struct _MwLL * MwLL, MwLLRec; +typedef struct _MwLLColor *MwLLColor, MwLLColorRec; #else -typedef void* MilskoLL; -typedef void* MilskoLLColor; +typedef void* MwLL; +typedef void* MwLLColor; #endif #ifdef _MILSKO #ifdef USE_X11 -#include +#include #endif #ifdef USE_GDI -#include +#include #endif #endif -#include +#include -#define MilskoLLDispatch(x, y) \ +#define MwLLDispatch(x, y) \ if(x->handler != NULL && x->handler->y != NULL) x->handler->y(x) -struct _MilskoLLHandler { - void (*draw)(MilskoLL handle); - void (*up)(MilskoLL handle); - void (*down)(MilskoLL handle); +struct _MwLLHandler { + void (*draw)(MwLL handle); + void (*up)(MwLL handle); + void (*down)(MwLL handle); }; /* lowlevel.c, common part */ -MILSKODECL void MilskoLLCreateCommon(MilskoLL handle); -MILSKODECL void MilskoLLDestroyCommon(MilskoLL handle); +MILSKODECL void MwLLCreateCommon(MwLL handle); +MILSKODECL void MwLLDestroyCommon(MwLL handle); /* driver-specific */ -MILSKODECL MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height); -MILSKODECL void MilskoLLDestroy(MilskoLL handle); +MILSKODECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height); +MILSKODECL void MwLLDestroy(MwLL handle); -MILSKODECL void MilskoLLPolygon(MilskoLL handle, MilskoPoint* points, int points_count, MilskoLLColor color); +MILSKODECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color); -MILSKODECL MilskoLLColor MilskoLLAllocColor(MilskoLL handle, int r, int g, int b); -MILSKODECL void MilskoLLFreeColor(MilskoLLColor color); +MILSKODECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b); +MILSKODECL void MwLLFreeColor(MwLLColor color); -MILSKODECL void MilskoLLGetXYWH(MilskoLL handle, int* x, int* y, unsigned int* w, unsigned int* h); -MILSKODECL void MilskoLLSetXY(MilskoLL handle, int x, int y); -MILSKODECL void MilskoLLSetWH(MilskoLL handle, int w, int h); +MILSKODECL void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h); +MILSKODECL void MwLLSetXY(MwLL handle, int x, int y); +MILSKODECL void MwLLSetWH(MwLL handle, int w, int h); -MILSKODECL void MilskoLLSetTitle(MilskoLL handle, const char* title); +MILSKODECL void MwLLSetTitle(MwLL handle, const char* title); -MILSKODECL int MilskoLLPending(MilskoLL handle); -MILSKODECL void MilskoLLNextEvent(MilskoLL handle); -MILSKODECL void MilskoLLSleep(int ms); +MILSKODECL int MwLLPending(MwLL handle); +MILSKODECL void MwLLNextEvent(MwLL handle); +MILSKODECL void MwLLSleep(int ms); #endif diff --git a/include/Milsko/Milsko.h b/include/Milsko/Milsko.h index 082bf62..f0c0020 100644 --- a/include/Milsko/Milsko.h +++ b/include/Milsko/Milsko.h @@ -2,15 +2,15 @@ #ifndef __MILSKO_MILSKO_H__ #define __MILSKO_MILSKO_H__ -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include +#include +#include #endif diff --git a/include/Milsko/StringDefs.h b/include/Milsko/StringDefs.h index 7cf1f8a..6523d6a 100644 --- a/include/Milsko/StringDefs.h +++ b/include/Milsko/StringDefs.h @@ -2,14 +2,14 @@ #ifndef __MILSKO_STRINGDEFS_H__ #define __MILSKO_STRINGDEFS_H__ -#define MilskoNx "Ix" -#define MilskoNy "Iy" -#define MilskoNwidth "Iwidth" -#define MilskoNheight "Iheight" +#define MwNx "Ix" +#define MwNy "Iy" +#define MwNwidth "Iwidth" +#define MwNheight "Iheight" -#define MilskoNtitle "Stitle" -#define MilskoNbackground "Sbackground" +#define MwNtitle "Stitle" +#define MwNbackground "Sbackground" -#define MilskoNactivateHandler "Cactivate" +#define MwNactivateHandler "Cactivate" #endif diff --git a/include/Milsko/TypeDefs.h b/include/Milsko/TypeDefs.h index f91287a..6dbd0f5 100644 --- a/include/Milsko/TypeDefs.h +++ b/include/Milsko/TypeDefs.h @@ -2,77 +2,77 @@ #ifndef __MILSKO_TYPEDEFS_H__ #define __MILSKO_TYPEDEFS_H__ -#include +#include -typedef struct _MilskoClass * MilskoClass, MilskoClassRec; -typedef struct _MilskoPoint MilskoPoint; -typedef struct _MilskoRect MilskoRect; -typedef struct _MilskoIntegerKeyValue MilskoIntegerKeyValue; -typedef struct _MilskoTextKeyValue MilskoTextKeyValue; -typedef struct _MilskoUserHandlerKeyValue MilskoUserHandlerKeyValue; +typedef struct _MwClass * MwClass, MwClassRec; +typedef struct _MwPoint MwPoint; +typedef struct _MwRect MwRect; +typedef struct _MwIntegerKeyValue MwIntegerKeyValue; +typedef struct _MwTextKeyValue MwTextKeyValue; +typedef struct _MwUserHandlerKeyValue MwUserHandlerKeyValue; #ifdef _MILSKO -typedef struct _MilskoWidget *MilskoWidget, MilskoWidgetRec; +typedef struct _MwWidget *MwWidget, MwWidgetRec; #else -typedef void* MilskoWidget; +typedef void* MwWidget; #endif -typedef void (*MilskoHandler)(MilskoWidget handle); -typedef void (*MilskoUserHandler)(MilskoWidget handle, void* user_data, void* call_data); +typedef void (*MwHandler)(MwWidget handle); +typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data); #ifdef _MILSKO -#include +#include #endif -struct _MilskoPoint { +struct _MwPoint { int x; int y; }; -struct _MilskoRect { +struct _MwRect { int x; int y; unsigned int width; unsigned int height; }; -struct _MilskoTextKeyValue { +struct _MwTextKeyValue { char* key; char* value; }; -struct _MilskoIntegerKeyValue { +struct _MwIntegerKeyValue { char* key; int value; }; -struct _MilskoUserHandlerKeyValue { +struct _MwUserHandlerKeyValue { char* key; void* user_data; - MilskoUserHandler value; + MwUserHandler value; }; #ifdef _MILSKO -struct _MilskoWidget { +struct _MwWidget { char* name; - MilskoLL lowlevel; - MilskoWidget parent; - MilskoWidget* children; - MilskoClass class; + MwLL lowlevel; + MwWidget parent; + MwWidget* children; + MwClass class; int pressed; - MilskoIntegerKeyValue* integer; - MilskoTextKeyValue* text; - MilskoUserHandlerKeyValue* handler; + MwIntegerKeyValue* integer; + MwTextKeyValue* text; + MwUserHandlerKeyValue* handler; }; #endif -struct _MilskoClass { +struct _MwClass { void* opaque; - MilskoHandler create; - MilskoHandler destroy; - MilskoHandler draw; - MilskoHandler click; + MwHandler create; + MwHandler destroy; + MwHandler draw; + MwHandler click; }; #endif diff --git a/include/Milsko/Window.h b/include/Milsko/Window.h index ee2b3ce..c2a72b5 100644 --- a/include/Milsko/Window.h +++ b/include/Milsko/Window.h @@ -2,8 +2,8 @@ #ifndef __MILSKO_WINDOW_H__ #define __MILSKO_WINDOW_H__ -#include +#include -MILSKODECL MilskoClass MilskoWindowClass; +MILSKODECL MwClass MwWindowClass; #endif diff --git a/include/Milsko/X11.h b/include/Milsko/X11.h index d3edc32..c12b089 100644 --- a/include/Milsko/X11.h +++ b/include/Milsko/X11.h @@ -2,28 +2,28 @@ #ifndef __MILSKO_X11_H__ #define __MILSKO_X11_H__ -#include +#include -typedef struct _MilskoLL * MilskoLL, MilskoLLRec; -typedef struct _MilskoLLColor *MilskoLLColor, MilskoLLColorRec; +typedef struct _MwLL * MwLL, MwLLRec; +typedef struct _MwLLColor *MwLLColor, MwLLColorRec; -#include -#include +#include +#include #include #include -struct _MilskoLL { +struct _MwLL { Display* display; Window window; GC gc; Colormap colormap; void* user; - MilskoLLHandler handler; + MwLLHandler handler; }; -struct _MilskoLLColor { +struct _MwLLColor { unsigned long pixel; int red; int green; diff --git a/src/button.c b/src/button.c index 5c690b0..a502c2b 100644 --- a/src/button.c +++ b/src/button.c @@ -1,32 +1,32 @@ /* $Id$ */ -#include +#include -static void create(MilskoWidget handle) { - MilskoSetDefault(handle); +static void create(MwWidget handle) { + MwSetDefault(handle); } -static void draw(MilskoWidget handle) { - MilskoRect r; +static void draw(MwWidget handle) { + MwRect r; r.x = 0; r.y = 0; - r.width = MilskoGetInteger(handle, MilskoNwidth); - r.height = MilskoGetInteger(handle, MilskoNheight); + r.width = MwGetInteger(handle, MwNwidth); + r.height = MwGetInteger(handle, MwNheight); - MilskoDrawFrame(handle, &r, MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground)), handle->pressed); + MwDrawFrame(handle, &r, MwParseColor(handle, MwGetText(handle, MwNbackground)), handle->pressed); - MilskoDrawRect(handle, &r, MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground))); + MwDrawRect(handle, &r, MwParseColor(handle, MwGetText(handle, MwNbackground))); } -static void click(MilskoWidget handle) { - MilskoDispatchUserHandler(handle, MilskoNactivateHandler, NULL); +static void click(MwWidget handle) { + MwDispatchUserHandler(handle, MwNactivateHandler, NULL); } -MilskoClassRec MilskoButtonClassRec = { +MwClassRec MwButtonClassRec = { NULL, /* opaque */ create, /* create */ NULL, /* destroy */ draw, /* draw */ click /* click */ }; -MilskoClass MilskoButtonClass = &MilskoButtonClassRec; +MwClass MwButtonClass = &MwButtonClassRec; diff --git a/src/core.c b/src/core.c index ebd330c..dc979b0 100644 --- a/src/core.c +++ b/src/core.c @@ -1,34 +1,34 @@ /* $Id$ */ -#include +#include #include "stb_ds.h" -static void lldrawhandler(MilskoLL handle) { - MilskoWidget h = (MilskoWidget)handle->user; - MilskoDispatch(h, draw); +static void lldrawhandler(MwLL handle) { + MwWidget h = (MwWidget)handle->user; + MwDispatch(h, draw); } -static void lluphandler(MilskoLL handle) { - MilskoWidget h = (MilskoWidget)handle->user; +static void lluphandler(MwLL handle) { + MwWidget h = (MwWidget)handle->user; h->pressed = 0; - MilskoDispatch(h, click); + MwDispatch(h, click); } -static void lldownhandler(MilskoLL handle) { - MilskoWidget h = (MilskoWidget)handle->user; +static void lldownhandler(MwLL handle) { + MwWidget h = (MwWidget)handle->user; h->pressed = 1; } -MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height) { - MilskoWidget h = malloc(sizeof(*h)); +MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height) { + MwWidget h = malloc(sizeof(*h)); h->name = malloc(strlen(name) + 1); strcpy(h->name, name); h->parent = parent; h->children = NULL; - h->lowlevel = MilskoLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height); + h->lowlevel = MwLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height); h->class = class; h->pressed = 0; @@ -46,42 +46,42 @@ MilskoWidget MilskoCreateWidget(MilskoClass class, const char* name, MilskoWidge shdefault(h->text, NULL); shdefault(h->handler, NULL); - MilskoDispatch(h, create); + MwDispatch(h, create); return h; } -MilskoWidget MilskoVaCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height, ...) { - MilskoWidget h; +MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...) { + MwWidget h; va_list va; va_start(va, height); - h = MilskoVaListCreateWidget(class, name, parent, x, y, width, height, va); + h = MwVaListCreateWidget(class, name, parent, x, y, width, height, va); va_end(va); return h; } -MilskoWidget MilskoVaListCreateWidget(MilskoClass class, const char* name, MilskoWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va) { - MilskoWidget h; +MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va) { + MwWidget h; - h = MilskoCreateWidget(class, name, parent, x, y, width, height); - MilskoVaListApply(h, va); + h = MwCreateWidget(class, name, parent, x, y, width, height); + MwVaListApply(h, va); return h; } -void MilskoDestroyWidget(MilskoWidget handle) { +void MwDestroyWidget(MwWidget handle) { int i; - MilskoDispatch(handle, destroy); + MwDispatch(handle, destroy); free(handle->name); if(handle->children != NULL) { for(i = 0; i < arrlen(handle->children); i++) { if(handle->children[i] == handle) { - MilskoDestroyWidget(handle->children[i]); + MwDestroyWidget(handle->children[i]); break; } } @@ -96,7 +96,7 @@ void MilskoDestroyWidget(MilskoWidget handle) { } } } - MilskoLLDestroy(handle->lowlevel); + MwLLDestroy(handle->lowlevel); shfree(handle->integer); @@ -110,49 +110,49 @@ void MilskoDestroyWidget(MilskoWidget handle) { free(handle); } -void MilskoStep(MilskoWidget handle) { +void MwStep(MwWidget handle) { int i; - for(i = 0; i < arrlen(handle->children); i++) MilskoStep(handle->children[i]); - MilskoLLNextEvent(handle->lowlevel); + for(i = 0; i < arrlen(handle->children); i++) MwStep(handle->children[i]); + MwLLNextEvent(handle->lowlevel); } -int MilskoPending(MilskoWidget handle) { +int MwPending(MwWidget handle) { int i; for(i = 0; i < arrlen(handle->children); i++) { - if(MilskoPending(handle->children[i])) return 1; + if(MwPending(handle->children[i])) return 1; } - return MilskoLLPending(handle->lowlevel); + return MwLLPending(handle->lowlevel); } -void MilskoLoop(MilskoWidget handle) { +void MwLoop(MwWidget handle) { while(1) { - MilskoStep(handle); - MilskoLLSleep(5); + MwStep(handle); + MwLLSleep(5); } } -void MilskoSetInteger(MilskoWidget handle, const char* key, int n) { +void MwSetInteger(MwWidget handle, const char* key, int n) { int xy = 0; int wh = 0; - if((xy = (strcmp(key, MilskoNx) == 0 || strcmp(key, MilskoNy) == 0)) || (wh = (strcmp(key, MilskoNwidth) == 0 || strcmp(key, MilskoNheight) == 0))) { + if((xy = (strcmp(key, MwNx) == 0 || strcmp(key, MwNy) == 0)) || (wh = (strcmp(key, MwNwidth) == 0 || strcmp(key, MwNheight) == 0))) { int x, y; unsigned int w, h; - MilskoLLGetXYWH(handle->lowlevel, &x, &y, &w, &h); - if(strcmp(key, MilskoNx) == 0) x = n; - if(strcmp(key, MilskoNy) == 0) y = n; - if(strcmp(key, MilskoNwidth) == 0) w = n; - if(strcmp(key, MilskoNheight) == 0) h = n; - if(xy) MilskoLLSetXY(handle->lowlevel, x, y); - if(wh) MilskoLLSetWH(handle->lowlevel, w, h); + MwLLGetXYWH(handle->lowlevel, &x, &y, &w, &h); + if(strcmp(key, MwNx) == 0) x = n; + if(strcmp(key, MwNy) == 0) y = n; + if(strcmp(key, MwNwidth) == 0) w = n; + if(strcmp(key, MwNheight) == 0) h = n; + if(xy) MwLLSetXY(handle->lowlevel, x, y); + if(wh) MwLLSetWH(handle->lowlevel, w, h); } else { shput(handle->integer, key, n); } } -void MilskoSetText(MilskoWidget handle, const char* key, const char* value) { - if(strcmp(key, MilskoNtitle) == 0) { - MilskoLLSetTitle(handle->lowlevel, value); +void MwSetText(MwWidget handle, const char* key, const char* value) { + if(strcmp(key, MwNtitle) == 0) { + MwLLSetTitle(handle->lowlevel, value); } else { char* v = malloc(strlen(value) + 1); strcpy(v, value); @@ -163,47 +163,47 @@ void MilskoSetText(MilskoWidget handle, const char* key, const char* value) { } } -int MilskoGetInteger(MilskoWidget handle, const char* key) { - if(strcmp(key, MilskoNx) == 0 || strcmp(key, MilskoNy) == 0 || strcmp(key, MilskoNwidth) == 0 || strcmp(key, MilskoNheight) == 0) { +int MwGetInteger(MwWidget handle, const char* key) { + if(strcmp(key, MwNx) == 0 || strcmp(key, MwNy) == 0 || strcmp(key, MwNwidth) == 0 || strcmp(key, MwNheight) == 0) { int x, y; unsigned int w, h; - MilskoLLGetXYWH(handle->lowlevel, &x, &y, &w, &h); + MwLLGetXYWH(handle->lowlevel, &x, &y, &w, &h); - if(strcmp(key, MilskoNx) == 0) return x; - if(strcmp(key, MilskoNy) == 0) return y; - if(strcmp(key, MilskoNwidth) == 0) return w; - if(strcmp(key, MilskoNheight) == 0) return h; + if(strcmp(key, MwNx) == 0) return x; + if(strcmp(key, MwNy) == 0) return y; + if(strcmp(key, MwNwidth) == 0) return w; + if(strcmp(key, MwNheight) == 0) return h; return -1; } else { return shget(handle->integer, key); } } -const char* MilskoGetText(MilskoWidget handle, const char* key) { +const char* MwGetText(MwWidget handle, const char* key) { return shget(handle->text, key); } -void MilskoVaApply(MilskoWidget handle, ...) { +void MwVaApply(MwWidget handle, ...) { va_list va; va_start(va, handle); - MilskoVaListApply(handle, va); + MwVaListApply(handle, va); va_end(va); } -void MilskoVaListApply(MilskoWidget handle, va_list va) { +void MwVaListApply(MwWidget handle, va_list va) { char* key; while((key = va_arg(va, char*)) != NULL) { if(key[0] == 'I') { int n = va_arg(va, int); - MilskoSetInteger(handle, key, n); + MwSetInteger(handle, key, n); } else if(key[0] == 'S') { char* t = va_arg(va, char*); - MilskoSetText(handle, key, t); + MwSetText(handle, key, t); } else if(key[0] == 'C') { - MilskoUserHandler h = va_arg(va, MilskoUserHandler); + MwUserHandler h = va_arg(va, MwUserHandler); int ind; shput(handle->handler, key, h); @@ -213,18 +213,18 @@ void MilskoVaListApply(MilskoWidget handle, va_list va) { } } -void MilskoSetDefault(MilskoWidget handle) { - MilskoSetText(handle, MilskoNbackground, MilskoDefaultBackground); +void MwSetDefault(MwWidget handle) { + MwSetText(handle, MwNbackground, MwDefaultBackground); } -void MilskoDispatchUserHandler(MilskoWidget handle, const char* key, void* handler_data) { +void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data) { int ind = shgeti(handle->handler, key); if(ind == -1) return; handle->handler[ind].value(handle, handle->handler[ind].user_data, handler_data); } -void MilskoAddUserHandler(MilskoWidget handle, const char* key, MilskoUserHandler handler, void* user_data) { +void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data) { int ind; shput(handle->handler, key, handler); diff --git a/src/default.c b/src/default.c index 0be0163..c2ab803 100644 --- a/src/default.c +++ b/src/default.c @@ -1,4 +1,4 @@ /* $Id$ */ -#include +#include -const char* MilskoDefaultBackground = "#ddd"; +const char* MwDefaultBackground = "#ddd"; diff --git a/src/draw.c b/src/draw.c index 126aa74..a22b356 100644 --- a/src/draw.c +++ b/src/draw.c @@ -1,5 +1,5 @@ /* $Id$ */ -#include +#include static int hex(const char* txt, int len) { int i; @@ -20,7 +20,7 @@ static int hex(const char* txt, int len) { return r; } -MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text) { +MwLLColor MwParseColor(MwWidget handle, const char* text) { int r = 0; int g = 0; int b = 0; @@ -39,11 +39,11 @@ MilskoLLColor MilskoParseColor(MilskoWidget handle, const char* text) { b = hex(text + 5, 2); } - return MilskoLLAllocColor(handle->lowlevel, r, g, b); + return MwLLAllocColor(handle->lowlevel, r, g, b); } -void MilskoDrawRect(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color) { - MilskoPoint p[4]; +void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color) { + MwPoint p[4]; p[0].x = rect->x; p[0].y = rect->y; @@ -57,15 +57,15 @@ void MilskoDrawRect(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color) p[3].x = rect->x; p[3].y = rect->y + rect->height; - MilskoLLPolygon(handle->lowlevel, p, 4, color); + MwLLPolygon(handle->lowlevel, p, 4, color); } -void MilskoDrawFrame(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color, int invert) { - MilskoPoint p[6]; +void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert) { + MwPoint p[6]; const int diff = 128; const int border = 2; - MilskoLLColor darker = MilskoLLAllocColor(handle->lowlevel, color->red - diff, color->green - diff, color->blue - diff); - MilskoLLColor lighter = MilskoLLAllocColor(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); p[0].x = rect->x; p[0].y = rect->y; @@ -85,7 +85,7 @@ void MilskoDrawFrame(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color, p[5].x = rect->x; p[5].y = rect->y + rect->height; - MilskoLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter); + MwLLPolygon(handle->lowlevel, p, 6, invert ? darker : lighter); p[0].x = rect->x + rect->width; p[0].y = rect->y; @@ -105,10 +105,10 @@ void MilskoDrawFrame(MilskoWidget handle, MilskoRect* rect, MilskoLLColor color, p[5].x = rect->x + rect->height; p[5].y = rect->y + rect->height; - MilskoLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker); + MwLLPolygon(handle->lowlevel, p, 6, invert ? lighter : darker); - MilskoLLFreeColor(lighter); - MilskoLLFreeColor(darker); + MwLLFreeColor(lighter); + MwLLFreeColor(darker); rect->x += border; rect->y += border; diff --git a/src/gdi.c b/src/gdi.c index af9b01a..4bf7082 100644 --- a/src/gdi.c +++ b/src/gdi.c @@ -1,2 +1,2 @@ /* $Id$ */ -#include +#include diff --git a/src/lowlevel.c b/src/lowlevel.c index d3aed0e..20b5e56 100644 --- a/src/lowlevel.c +++ b/src/lowlevel.c @@ -1,11 +1,11 @@ /* $Id$ */ -#include +#include -void MilskoLLCreateCommon(MilskoLL handle) { +void MwLLCreateCommon(MwLL handle) { handle->handler = malloc(sizeof(*handle->handler)); memset(handle->handler, 0, sizeof(*handle->handler)); } -void MilskoLLDestroyCommon(MilskoLL handle) { +void MwLLDestroyCommon(MwLL handle) { free(handle->handler); } diff --git a/src/window.c b/src/window.c index ea67983..80b947e 100644 --- a/src/window.c +++ b/src/window.c @@ -1,29 +1,29 @@ /* $Id$ */ -#include +#include -static void create(MilskoWidget handle) { - MilskoSetDefault(handle); +static void create(MwWidget handle) { + MwSetDefault(handle); } -static void draw(MilskoWidget handle) { - MilskoLLColor c = MilskoParseColor(handle, MilskoGetText(handle, MilskoNbackground)); - MilskoRect r; +static void draw(MwWidget handle) { + MwLLColor c = MwParseColor(handle, MwGetText(handle, MwNbackground)); + MwRect r; r.x = 0; r.y = 0; - r.width = MilskoGetInteger(handle, MilskoNwidth); - r.height = MilskoGetInteger(handle, MilskoNheight); + r.width = MwGetInteger(handle, MwNwidth); + r.height = MwGetInteger(handle, MwNheight); - MilskoDrawRect(handle, &r, c); + MwDrawRect(handle, &r, c); - MilskoLLFreeColor(c); + MwLLFreeColor(c); } -MilskoClassRec MilskoWindowClassRec = { +MwClassRec MwWindowClassRec = { NULL, /* opaque */ create, /* create */ NULL, /* destroy */ draw, /* draw */ NULL /* click */ }; -MilskoClass MilskoWindowClass = &MilskoWindowClassRec; +MwClass MwWindowClass = &MwWindowClassRec; diff --git a/src/x11.c b/src/x11.c index 4431e6e..8e079d7 100644 --- a/src/x11.c +++ b/src/x11.c @@ -1,17 +1,17 @@ /* $Id$ */ -#include +#include static unsigned long mask = ExposureMask | StructureNotifyMask | ButtonPressMask | ButtonReleaseMask; -MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height) { - MilskoLL r; +MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) { + MwLL r; Window p; Window root; unsigned int border, depth; r = malloc(sizeof(*r)); - MilskoLLCreateCommon(r); + MwLLCreateCommon(r); if(parent == NULL) { r->display = XOpenDisplay(NULL); @@ -31,15 +31,15 @@ MilskoLL MilskoLLCreate(MilskoLL parent, int x, int y, int width, int height) { return r; } -void MilskoLLDestroy(MilskoLL handle) { - MilskoLLDestroyCommon(handle); +void MwLLDestroy(MwLL handle) { + MwLLDestroyCommon(handle); XFreeGC(handle->display, handle->gc); XDestroyWindow(handle->display, handle->window); free(handle); } -void MilskoLLPolygon(MilskoLL handle, MilskoPoint* points, int points_count, MilskoLLColor color) { +void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) { int i; XPoint* p = malloc(sizeof(*p) * points_count); @@ -54,8 +54,8 @@ void MilskoLLPolygon(MilskoLL handle, MilskoPoint* points, int points_count, Mil free(p); } -MilskoLLColor MilskoLLAllocColor(MilskoLL handle, int r, int g, int b) { - MilskoLLColor c = malloc(sizeof(*c)); +MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) { + MwLLColor c = malloc(sizeof(*c)); XColor xc; if(r > 255) r = 255; @@ -77,26 +77,26 @@ MilskoLLColor MilskoLLAllocColor(MilskoLL handle, int r, int g, int b) { return c; } -void MilskoLLGetXYWH(MilskoLL 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) { Window root; unsigned int border, depth; XGetGeometry(handle->display, handle->window, &root, x, y, w, h, &border, &depth); } -void MilskoLLSetXY(MilskoLL handle, int x, int y) { +void MwLLSetXY(MwLL handle, int x, int y) { XMoveWindow(handle->display, handle->window, x, y); } -void MilskoLLSetWH(MilskoLL handle, int w, int h) { +void MwLLSetWH(MwLL handle, int w, int h) { XResizeWindow(handle->display, handle->window, w, h); } -void MilskoLLFreeColor(MilskoLLColor color) { +void MwLLFreeColor(MwLLColor color) { free(color); } -int MilskoLLPending(MilskoLL handle) { +int MwLLPending(MwLL handle) { XEvent ev; if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) { XPutBackEvent(handle->display, &ev); @@ -105,29 +105,29 @@ int MilskoLLPending(MilskoLL handle) { return 0; } -void MilskoLLNextEvent(MilskoLL handle) { +void MwLLNextEvent(MwLL handle) { XEvent ev; if(XCheckWindowEvent(handle->display, handle->window, mask, &ev)) { if(ev.type == Expose) { - MilskoLLDispatch(handle, draw); + MwLLDispatch(handle, draw); } else if(ev.type == ButtonPress) { if(ev.xbutton.button == Button1) { - MilskoLLDispatch(handle, down); - MilskoLLDispatch(handle, draw); + MwLLDispatch(handle, down); + MwLLDispatch(handle, draw); } } else if(ev.type == ButtonRelease) { if(ev.xbutton.button == Button1) { - MilskoLLDispatch(handle, up); - MilskoLLDispatch(handle, draw); + MwLLDispatch(handle, up); + MwLLDispatch(handle, draw); } } } } -void MilskoLLSleep(int ms) { +void MwLLSleep(int ms) { usleep(ms * 1000); } -void MilskoLLSetTitle(MilskoLL handle, const char* title) { - XSetStandardProperties(handle->display, handle->window, title, "Milsko Widget Toolkit", None, (char**)NULL, 0, NULL); +void MwLLSetTitle(MwLL handle, const char* title) { + XSetStandardProperties(handle->display, handle->window, title, "Mw Widget Toolkit", None, (char**)NULL, 0, NULL); }