diff --git a/include/Mw/Button.h b/include/Mw/Button.h index ad86ac3..ba2c482 100644 --- a/include/Mw/Button.h +++ b/include/Mw/Button.h @@ -4,6 +4,14 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + MWDECL MwClass MwButtonClass; +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/Mw/Core.h b/include/Mw/Core.h index f9bc766..e9c6780 100644 --- a/include/Mw/Core.h +++ b/include/Mw/Core.h @@ -6,11 +6,15 @@ #include #define MwDispatch(x, y) \ - if(x->class != NULL && x->class->y != NULL) x->class->y(x) + if(x->widget_class != NULL && x->widget_class->y != NULL) x->widget_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); +#ifdef __cplusplus +extern "C" { +#endif + +MWDECL MwWidget MwCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height); +MWDECL MwWidget MwVaCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...); +MWDECL MwWidget MwVaListCreateWidget(MwClass widget_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); @@ -28,4 +32,8 @@ 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); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/Mw/Default.h b/include/Mw/Default.h index 4796995..6cf5d3b 100644 --- a/include/Mw/Default.h +++ b/include/Mw/Default.h @@ -4,6 +4,14 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + MWDECL const char* MwDefaultBackground; +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/Mw/Draw.h b/include/Mw/Draw.h index 2ec1edc..c9fc08e 100644 --- a/include/Mw/Draw.h +++ b/include/Mw/Draw.h @@ -6,9 +6,17 @@ #include #include +#ifdef __cplusplus +extern "C" { +#endif + 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); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/Mw/LowLevel.h b/include/Mw/LowLevel.h index 10be0eb..1c22f7e 100644 --- a/include/Mw/LowLevel.h +++ b/include/Mw/LowLevel.h @@ -32,6 +32,10 @@ struct _MwLLHandler { void (*down)(MwLL handle); }; +#ifdef __cplusplus +extern "C" { +#endif + /* lowlevel.c, common part */ MWDECL void MwLLCreateCommon(MwLL handle); MWDECL void MwLLDestroyCommon(MwLL handle); @@ -55,4 +59,8 @@ MWDECL int MwLLPending(MwLL handle); MWDECL void MwLLNextEvent(MwLL handle); MWDECL void MwLLSleep(int ms); +#ifdef __cplusplus +} +#endif + #endif diff --git a/include/Mw/TypeDefs.h b/include/Mw/TypeDefs.h index 0e149c5..b4ec771 100644 --- a/include/Mw/TypeDefs.h +++ b/include/Mw/TypeDefs.h @@ -57,7 +57,7 @@ struct _MwWidget { MwLL lowlevel; MwWidget parent; MwWidget* children; - MwClass class; + MwClass widget_class; int pressed; diff --git a/include/Mw/Window.h b/include/Mw/Window.h index af2aff1..ee6fad1 100644 --- a/include/Mw/Window.h +++ b/include/Mw/Window.h @@ -4,6 +4,14 @@ #include +#ifdef __cplusplus +extern "C" { +#endif + MWDECL MwClass MwWindowClass; +#ifdef __cplusplus +} +#endif + #endif diff --git a/src/core.c b/src/core.c index a6d081b..4ae306f 100644 --- a/src/core.c +++ b/src/core.c @@ -20,17 +20,17 @@ static void lldownhandler(MwLL handle) { 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 widget_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 = MwLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height); - h->class = class; - h->pressed = 0; + h->parent = parent; + h->children = NULL; + h->lowlevel = MwLLCreate(parent == NULL ? NULL : parent->lowlevel, x, y, width, height); + h->widget_class = widget_class; + h->pressed = 0; h->lowlevel->user = h; h->lowlevel->handler->draw = lldrawhandler; @@ -51,21 +51,21 @@ MwWidget MwCreateWidget(MwClass class, const char* name, MwWidget parent, int x, return h; } -MwWidget MwVaCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, ...) { +MwWidget MwVaCreateWidget(MwClass widget_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 = MwVaListCreateWidget(class, name, parent, x, y, width, height, va); + h = MwVaListCreateWidget(widget_class, name, parent, x, y, width, height, va); va_end(va); return h; } -MwWidget MwVaListCreateWidget(MwClass class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va) { +MwWidget MwVaListCreateWidget(MwClass widget_class, const char* name, MwWidget parent, int x, int y, unsigned int width, unsigned int height, va_list va) { MwWidget h; - h = MwCreateWidget(class, name, parent, x, y, width, height); + h = MwCreateWidget(widget_class, name, parent, x, y, width, height); MwVaListApply(h, va); return h;