diff --git a/GNUmakefile b/GNUmakefile index ba2557a..9216a0c 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -3,7 +3,7 @@ TARGET = $(shell uname -s) CC = gcc -CFLAGS = -fPIC -Iinclude -D_MILSKO +CFLAGS = -fPIC -Iinclude -D_MW LDFLAGS = LIBS = @@ -40,12 +40,12 @@ endif .PHONY: all format clean .SUFFIXES: .c .o -all: $(LIB)milsko$(SO) +all: $(LIB)Mw$(SO) format: clang-format --verbose -i $(shell find src include -name "*.c" -or -name "*.h") -$(LIB)milsko$(SO): $(L_OBJS) +$(LIB)Mw$(SO): $(L_OBJS) $(CC) $(LDFLAGS) -shared -o $@ $(L_OBJS) $(L_LIBS) clean: diff --git a/example.c b/example.c index f28c6a0..73197bc 100644 --- a/example.c +++ b/example.c @@ -1,18 +1,18 @@ /* $Id$ */ -#include +#include -void handler(MilskoWidget handle, void* user_data, void* call_data){ +void handler(MwWidget handle, void* user_data, void* call_data){ printf("hello world!\n"); } int main(){ - MilskoWidget window = MilskoVaCreateWidget(MilskoWindowClass, "main", NULL, 0, 0, 400, 400, - MilskoNtitle, "hello world", + MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 400, + MwNtitle, "hello world", NULL); - MilskoWidget button = MilskoVaCreateWidget(MilskoButtonClass, "button", window, 50, 50, 300, 300, NULL); + MwWidget button = MwVaCreateWidget(MwButtonClass, "button", window, 50, 50, 300, 300, NULL); - MilskoAddUserHandler(button, MilskoNactivateHandler, handler, NULL); + MwAddUserHandler(button, MwNactivateHandler, handler, NULL); - MilskoLoop(window); + MwLoop(window); } diff --git a/include/Milsko/Button.h b/include/Milsko/Button.h deleted file mode 100644 index 95da160..0000000 --- a/include/Milsko/Button.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $Id$ */ -#ifndef __MILSKO_BUTTON_H__ -#define __MILSKO_BUTTON_H__ - -#include - -MILSKODECL MwClass MwButtonClass; - -#endif diff --git a/include/Milsko/Core.h b/include/Milsko/Core.h deleted file mode 100644 index 36659bb..0000000 --- a/include/Milsko/Core.h +++ /dev/null @@ -1,31 +0,0 @@ -/* $Id$ */ -#ifndef __MILSKO_CORE_H__ -#define __MILSKO_CORE_H__ - -#include -#include - -#define MwDispatch(x, y) \ - if(x->class != NULL && x->class->y != NULL) x->class->y(x) - -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 MwLoop(MwWidget handle); -MILSKODECL void MwStep(MwWidget handle); -MILSKODECL int MwPending(MwWidget handle); - -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 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 deleted file mode 100644 index 6597f2b..0000000 --- a/include/Milsko/Default.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $Id$ */ -#ifndef __MILSKO_DEFAULT_H__ -#define __MILSKO_DEFAULT_H__ - -#include - -MILSKODECL const char* MwDefaultBackground; - -#endif diff --git a/include/Milsko/Draw.h b/include/Milsko/Draw.h deleted file mode 100644 index c0c09e5..0000000 --- a/include/Milsko/Draw.h +++ /dev/null @@ -1,14 +0,0 @@ -/* $Id$ */ -#ifndef __MILSKO_DRAW_H__ -#define __MILSKO_DRAW_H__ - -#include -#include -#include - -MILSKODECL MwLLColor MwParseColor(MwWidget handle, const char* text); - -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/LowLevel.h b/include/Milsko/LowLevel.h deleted file mode 100644 index 6ae1329..0000000 --- a/include/Milsko/LowLevel.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $Id$ */ -#ifndef __MILSKO_LOWLEVEL_H__ -#define __MILSKO_LOWLEVEL_H__ - -#include - -typedef struct _MwLLHandler *MwLLHandler, MwLLHandlerRec; -#ifdef _MILSKO -typedef struct _MwLL * MwLL, MwLLRec; -typedef struct _MwLLColor *MwLLColor, MwLLColorRec; -#else -typedef void* MwLL; -typedef void* MwLLColor; -#endif - -#ifdef _MILSKO -#ifdef USE_X11 -#include -#endif -#ifdef USE_GDI -#include -#endif -#endif -#include - -#define MwLLDispatch(x, y) \ - if(x->handler != NULL && x->handler->y != NULL) x->handler->y(x) - -struct _MwLLHandler { - void (*draw)(MwLL handle); - void (*up)(MwLL handle); - void (*down)(MwLL handle); -}; - -/* lowlevel.c, common part */ -MILSKODECL void MwLLCreateCommon(MwLL handle); -MILSKODECL void MwLLDestroyCommon(MwLL handle); - -/* driver-specific */ -MILSKODECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height); -MILSKODECL void MwLLDestroy(MwLL handle); - -MILSKODECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color); - -MILSKODECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b); -MILSKODECL void MwLLFreeColor(MwLLColor color); - -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 MwLLSetTitle(MwLL handle, const char* title); - -MILSKODECL int MwLLPending(MwLL handle); -MILSKODECL void MwLLNextEvent(MwLL handle); -MILSKODECL void MwLLSleep(int ms); - -#endif diff --git a/include/Milsko/MachDep.h b/include/Milsko/MachDep.h deleted file mode 100644 index c084398..0000000 --- a/include/Milsko/MachDep.h +++ /dev/null @@ -1,23 +0,0 @@ -/* $Id$ */ -#ifndef __MILSKO_MACHDEP_H__ -#define __MILSKO_MACHDEP_H__ - -#include -#include -#include -#include -#ifdef _WIN32 -#include -#else -#include -#endif - -#if defined(_MILSKO) && defined(_WIN32) -#define MILSKODECL extern __declspec(dllexport) -#elif defined(_WIN32) -#define MILSKODECL extern __declspec(dllimport) -#else -#define MILSKODECL extern -#endif - -#endif diff --git a/include/Milsko/Window.h b/include/Milsko/Window.h deleted file mode 100644 index c2a72b5..0000000 --- a/include/Milsko/Window.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $Id$ */ -#ifndef __MILSKO_WINDOW_H__ -#define __MILSKO_WINDOW_H__ - -#include - -MILSKODECL MwClass MwWindowClass; - -#endif diff --git a/include/Mw/Button.h b/include/Mw/Button.h new file mode 100644 index 0000000..ad86ac3 --- /dev/null +++ b/include/Mw/Button.h @@ -0,0 +1,9 @@ +/* $Id$ */ +#ifndef __MW_BUTTON_H__ +#define __MW_BUTTON_H__ + +#include + +MWDECL MwClass MwButtonClass; + +#endif diff --git a/include/Mw/Core.h b/include/Mw/Core.h new file mode 100644 index 0000000..14abbb4 --- /dev/null +++ b/include/Mw/Core.h @@ -0,0 +1,31 @@ +/* $Id$ */ +#ifndef __MW_CORE_H__ +#define __MW_CORE_H__ + +#include +#include + +#define MwDispatch(x, y) \ + if(x->class != NULL && x->class->y != NULL) x->class->y(x) + +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 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 MwLoop(MwWidget handle); +MWDECL void MwStep(MwWidget handle); +MWDECL int MwPending(MwWidget handle); + +MWDECL void MwSetInteger(MwWidget handle, const char* key, int n); +MWDECL void MwSetText(MwWidget handle, const char* key, const char* value); +MWDECL int MwGetInteger(MwWidget handle, const char* key); +MWDECL const char* MwGetText(MwWidget handle, const char* key); +MWDECL void MwSetDefault(MwWidget handle); +MWDECL void MwVaApply(MwWidget handle, ...); +MWDECL void MwVaListApply(MwWidget handle, va_list va); + +MWDECL void MwAddUserHandler(MwWidget handle, const char* key, MwUserHandler handler, void* user_data); +MWDECL void MwDispatchUserHandler(MwWidget handle, const char* key, void* handler_data); + +#endif diff --git a/include/Mw/Default.h b/include/Mw/Default.h new file mode 100644 index 0000000..4796995 --- /dev/null +++ b/include/Mw/Default.h @@ -0,0 +1,9 @@ +/* $Id$ */ +#ifndef __MW_DEFAULT_H__ +#define __MW_DEFAULT_H__ + +#include + +MWDECL const char* MwDefaultBackground; + +#endif diff --git a/include/Mw/Draw.h b/include/Mw/Draw.h new file mode 100644 index 0000000..2ec1edc --- /dev/null +++ b/include/Mw/Draw.h @@ -0,0 +1,14 @@ +/* $Id$ */ +#ifndef __MW_DRAW_H__ +#define __MW_DRAW_H__ + +#include +#include +#include + +MWDECL MwLLColor MwParseColor(MwWidget handle, const char* text); + +MWDECL void MwDrawRect(MwWidget handle, MwRect* rect, MwLLColor color); +MWDECL void MwDrawFrame(MwWidget handle, MwRect* rect, MwLLColor color, int invert); + +#endif diff --git a/include/Milsko/GDI.h b/include/Mw/GDI.h similarity index 86% rename from include/Milsko/GDI.h rename to include/Mw/GDI.h index 1505974..d3b0e9f 100644 --- a/include/Milsko/GDI.h +++ b/include/Mw/GDI.h @@ -1,6 +1,6 @@ /* $Id$ */ -#ifndef __MILSKO_GDI_H__ -#define __MILSKO_GDI_H__ +#ifndef __MW_GDI_H__ +#define __MW_GDI_H__ #include diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h new file mode 100644 index 0000000..e978369 --- /dev/null +++ b/include/Mw/LowLevel.h @@ -0,0 +1,58 @@ +/* $Id$ */ +#ifndef __MW_LOWLEVEL_H__ +#define __MW_LOWLEVEL_H__ + +#include + +typedef struct _MwLLHandler *MwLLHandler, MwLLHandlerRec; +#ifdef _MW +typedef struct _MwLL * MwLL, MwLLRec; +typedef struct _MwLLColor *MwLLColor, MwLLColorRec; +#else +typedef void* MwLL; +typedef void* MwLLColor; +#endif + +#ifdef _MW +#ifdef USE_X11 +#include +#endif +#ifdef USE_GDI +#include +#endif +#endif +#include + +#define MwLLDispatch(x, y) \ + if(x->handler != NULL && x->handler->y != NULL) x->handler->y(x) + +struct _MwLLHandler { + void (*draw)(MwLL handle); + void (*up)(MwLL handle); + void (*down)(MwLL handle); +}; + +/* lowlevel.c, common part */ +MWDECL void MwLLCreateCommon(MwLL handle); +MWDECL void MwLLDestroyCommon(MwLL handle); + +/* driver-specific */ +MWDECL MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height); +MWDECL void MwLLDestroy(MwLL handle); + +MWDECL void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color); + +MWDECL MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b); +MWDECL void MwLLFreeColor(MwLLColor color); + +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 MwLLSetWH(MwLL handle, int w, int h); + +MWDECL void MwLLSetTitle(MwLL handle, const char* title); + +MWDECL int MwLLPending(MwLL handle); +MWDECL void MwLLNextEvent(MwLL handle); +MWDECL void MwLLSleep(int ms); + +#endif diff --git a/include/Mw/MachDep.h b/include/Mw/MachDep.h new file mode 100644 index 0000000..1975851 --- /dev/null +++ b/include/Mw/MachDep.h @@ -0,0 +1,23 @@ +/* $Id$ */ +#ifndef __MW_MACHDEP_H__ +#define __MW_MACHDEP_H__ + +#include +#include +#include +#include +#ifdef _WIN32 +#include +#else +#include +#endif + +#if defined(_MW) && defined(_WIN32) +#define MWDECL extern __declspec(dllexport) +#elif defined(_WIN32) +#define MWDECL extern __declspec(dllimport) +#else +#define MWDECL extern +#endif + +#endif diff --git a/include/Milsko/Milsko.h b/include/Mw/Mw.h similarity index 80% rename from include/Milsko/Milsko.h rename to include/Mw/Mw.h index f0c0020..7866327 100644 --- a/include/Milsko/Milsko.h +++ b/include/Mw/Mw.h @@ -1,6 +1,6 @@ /* $Id$ */ -#ifndef __MILSKO_MILSKO_H__ -#define __MILSKO_MILSKO_H__ +#ifndef __MW_MW_H__ +#define __MW_MW_H__ #include #include diff --git a/include/Milsko/StringDefs.h b/include/Mw/StringDefs.h similarity index 76% rename from include/Milsko/StringDefs.h rename to include/Mw/StringDefs.h index 6523d6a..fc236ba 100644 --- a/include/Milsko/StringDefs.h +++ b/include/Mw/StringDefs.h @@ -1,6 +1,6 @@ /* $Id$ */ -#ifndef __MILSKO_STRINGDEFS_H__ -#define __MILSKO_STRINGDEFS_H__ +#ifndef __MW_STRINGDEFS_H__ +#define __MW_STRINGDEFS_H__ #define MwNx "Ix" #define MwNy "Iy" diff --git a/include/Milsko/TypeDefs.h b/include/Mw/TypeDefs.h similarity index 92% rename from include/Milsko/TypeDefs.h rename to include/Mw/TypeDefs.h index 6dbd0f5..eec316c 100644 --- a/include/Milsko/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -1,6 +1,6 @@ /* $Id$ */ -#ifndef __MILSKO_TYPEDEFS_H__ -#define __MILSKO_TYPEDEFS_H__ +#ifndef __MW_TYPEDEFS_H__ +#define __MW_TYPEDEFS_H__ #include @@ -10,7 +10,7 @@ typedef struct _MwRect MwRect; typedef struct _MwIntegerKeyValue MwIntegerKeyValue; typedef struct _MwTextKeyValue MwTextKeyValue; typedef struct _MwUserHandlerKeyValue MwUserHandlerKeyValue; -#ifdef _MILSKO +#ifdef _MW typedef struct _MwWidget *MwWidget, MwWidgetRec; #else typedef void* MwWidget; @@ -18,7 +18,7 @@ typedef void* MwWidget; typedef void (*MwHandler)(MwWidget handle); typedef void (*MwUserHandler)(MwWidget handle, void* user_data, void* call_data); -#ifdef _MILSKO +#ifdef _MW #include #endif @@ -50,7 +50,7 @@ struct _MwUserHandlerKeyValue { MwUserHandler value; }; -#ifdef _MILSKO +#ifdef _MW struct _MwWidget { char* name; diff --git a/include/Mw/Window.h b/include/Mw/Window.h new file mode 100644 index 0000000..af2aff1 --- /dev/null +++ b/include/Mw/Window.h @@ -0,0 +1,9 @@ +/* $Id$ */ +#ifndef __MW_WINDOW_H__ +#define __MW_WINDOW_H__ + +#include + +MWDECL MwClass MwWindowClass; + +#endif diff --git a/include/Milsko/X11.h b/include/Mw/X11.h similarity index 90% rename from include/Milsko/X11.h rename to include/Mw/X11.h index c12b089..75dd92d 100644 --- a/include/Milsko/X11.h +++ b/include/Mw/X11.h @@ -1,6 +1,6 @@ /* $Id$ */ -#ifndef __MILSKO_X11_H__ -#define __MILSKO_X11_H__ +#ifndef __MW_X11_H__ +#define __MW_X11_H__ #include