add MwLibraryInit

git-svn-id: http://svn2.nishi.boats/svn/milsko/trunk@680 b9cfdab3-6d41-4d17-bbe4-086880011989
This commit is contained in:
Nishi 2025-11-13 01:30:10 +00:00
commit b0ea597d62
27 changed files with 263 additions and 350 deletions

View file

@ -2,7 +2,11 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
int main() { int main() {
MwWidget window = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 8 + 16 + 8 + 16 * 10 + 8, 8 + 16 + 8 + 16 + 8, MwWidget window;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 8 + 16 + 8 + 16 * 10 + 8, 8 + 16 + 8 + 16 + 8,
MwNtitle, "checkbox", MwNtitle, "checkbox",
NULL); NULL);

View file

@ -33,6 +33,8 @@ void color_picker(MwWidget handle, void* user_data, void* call_data) {
} }
int main() { int main() {
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT,
MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL); MwDEFAULT, 640, 480, MwNtitle, "color picker", NULL);
MwSetText(window, MwNbackground, "#000000"); MwSetText(window, MwNbackground, "#000000");

View file

@ -58,6 +58,8 @@ void resize(MwWidget handle, void* user_data, void* call_data) {
int main() { int main() {
MwMenu m, m2; MwMenu m, m2;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 400, 400, window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 400, 400,
MwNtitle, "hello world", MwNtitle, "hello world",
NULL); NULL);

View file

@ -2,15 +2,20 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
int main() { int main() {
MwWidget window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 500, 500, MwWidget window, image, image2, image3;
MwLLPixmap px, px2, px3;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, 500, 500,
MwNtitle, "image image", MwNtitle, "image image",
NULL); NULL);
MwWidget image = MwCreateWidget(MwImageClass, "image", window, 50, 50, 200, 400); image = MwCreateWidget(MwImageClass, "image", window, 50, 50, 200, 400);
MwWidget image2 = MwCreateWidget(MwImageClass, "image", window, 250, 50, 200, 200); image2 = MwCreateWidget(MwImageClass, "image", window, 250, 50, 200, 200);
MwWidget image3 = MwCreateWidget(MwImageClass, "image", window, 250, 250, 200, 200); image3 = MwCreateWidget(MwImageClass, "image", window, 250, 250, 200, 200);
MwLLPixmap px = MwLoadImage(window, "examples/picture.png"); px = MwLoadImage(window, "examples/picture.png");
MwLLPixmap px2 = MwLoadImage(window, "examples/picture.jpg"); px2 = MwLoadImage(window, "examples/picture.jpg");
MwLLPixmap px3 = MwLoadImage(window, "resource/logo/logo.png"); px3 = MwLoadImage(window, "resource/logo/logo.png");
if(px == NULL) px = MwLoadImage(window, "../examples/picture.png"); if(px == NULL) px = MwLoadImage(window, "../examples/picture.png");
if(px2 == NULL) px2 = MwLoadImage(window, "../examples/picture.jpg"); if(px2 == NULL) px2 = MwLoadImage(window, "../examples/picture.jpg");

View file

@ -29,6 +29,9 @@ int main() {
int i; int i;
MwListBoxPacket* packet; MwListBoxPacket* packet;
int index; int index;
MwLibraryInit();
wmain = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480, wmain = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480,
MwNtitle, "listbox", MwNtitle, "listbox",
NULL); NULL);

View file

@ -38,10 +38,14 @@ void spawn3(MwWidget handle, void* user, void* call) {
} }
int main() { int main() {
MwWidget msg = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 300, 100, MwNtitle, "test", NULL); MwWidget msg, btn, btn2, btn3;
MwWidget btn = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8, 300 - 16, (100 - 16) / 2, MwNtext, "press me!", NULL);
MwWidget btn2 = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8 + (100 - 16) / 2, (300 - 16) / 2, (100 - 16) / 2, MwNtext, "press me!", NULL); MwLibraryInit();
MwWidget btn3 = MwVaCreateWidget(MwButtonClass, "button", msg, 8 + (300 - 16) / 2, 8 + (100 - 16) / 2, (300 - 16) / 2, (100 - 16) / 2, MwNtext, "press me!", NULL);
msg = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 300, 100, MwNtitle, "test", NULL);
btn = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8, 300 - 16, (100 - 16) / 2, MwNtext, "press me!", NULL);
btn2 = MwVaCreateWidget(MwButtonClass, "button", msg, 8, 8 + (100 - 16) / 2, (300 - 16) / 2, (100 - 16) / 2, MwNtext, "press me!", NULL);
btn3 = MwVaCreateWidget(MwButtonClass, "button", msg, 8 + (300 - 16) / 2, 8 + (100 - 16) / 2, (300 - 16) / 2, (100 - 16) / 2, MwNtext, "press me!", NULL);
MwAddUserHandler(btn, MwNactivateHandler, spawn, msg); MwAddUserHandler(btn, MwNactivateHandler, spawn, msg);
MwAddUserHandler(btn2, MwNactivateHandler, spawn2, msg); MwAddUserHandler(btn2, MwNactivateHandler, spawn2, msg);

View file

@ -1,10 +1,14 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
int main() { int main() {
MwWidget w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 5 + 640 + 5, 5 + 32 + 5, MwWidget w, p;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 5 + 640 + 5, 5 + 32 + 5,
MwNtitle, "progress bar", MwNtitle, "progress bar",
NULL); NULL);
MwWidget p = MwVaCreateWidget(MwProgressBarClass, "progress", w, 5, 5, 640, 32, p = MwVaCreateWidget(MwProgressBarClass, "progress", w, 5, 5, 640, 32,
MwNvalue, 25, MwNvalue, 25,
NULL); NULL);

View file

@ -2,7 +2,11 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
int main() { int main() {
MwWidget window = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 8 + 16 + 8 + 16 * 10 + 8, 8 + 16 + 8 + 16 + 8, MwWidget window;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "test", NULL, MwDEFAULT, MwDEFAULT, 8 + 16 + 8 + 16 * 10 + 8, 8 + 16 + 8 + 16 + 8,
MwNtitle, "radiobox", MwNtitle, "radiobox",
NULL); NULL);

View file

@ -55,10 +55,14 @@ void resize(MwWidget w, void* user, void* client) {
} }
int main() { int main() {
MwWidget window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, (ww = 500), (wh = 500), MwWidget window;
int i;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "window", NULL, MwDEFAULT, MwDEFAULT, (ww = 500), (wh = 500),
MwNtitle, "rotate", MwNtitle, "rotate",
NULL); NULL);
int i;
for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) { for(i = 0; i < (int)(sizeof(buttons) / sizeof(buttons[0])); i++) {
const char* color = ""; const char* color = "";

View file

@ -3,10 +3,14 @@
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
int main() { int main() {
MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 500, 500, MwWidget window;
int i;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 500, 500,
MwNtitle, "main", MwNtitle, "main",
NULL); NULL);
int i;
for(i = 0; i < 500 / 16; i++) { for(i = 0; i < 500 / 16; i++) {
MwVaCreateWidget(MwScrollBarClass, "scroll", window, 16 * i, 0, 16, 500, MwVaCreateWidget(MwScrollBarClass, "scroll", window, 16 * i, 0, 16, 500,

View file

@ -17,9 +17,13 @@ static void resize(MwWidget handle, void* user, void* call) {
} }
int main() { int main() {
MwWidget w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480, MwNtitle, "test", NULL); MwWidget w;
MwLLPixmap px; MwLLPixmap px;
MwLibraryInit();
w = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480, MwNtitle, "test", NULL);
vp = MwCreateWidget(MwViewportClass, "vp", w, 5, 5, 630, 470); vp = MwCreateWidget(MwViewportClass, "vp", w, 5, 5, 630, 470);
px = MwLoadImage(vp, "examples/picture.png"); px = MwLoadImage(vp, "examples/picture.png");

View file

@ -47,6 +47,8 @@ static void key_pressed(MwWidget handle, void* user, void* client) {
int main() { int main() {
MwWidget window; MwWidget window;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 500, 500, window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 500, 500,
MwNtitle, TITLE, MwNtitle, TITLE,
NULL); NULL);

View file

@ -71,6 +71,8 @@ void activate(MwWidget handle, void* user_data, void* call_data) {
} }
int main() { int main() {
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 450, window = MwVaCreateWidget(MwWindowClass, "main", NULL, 0, 0, 400, 450,
MwNtitle, "hello world", MwNtitle, "hello world",
NULL); NULL);

View file

@ -109,10 +109,14 @@ static void mouse_move(MwWidget handle, void* user, void* call) {
int main() { int main() {
MwSizeHints hints; MwSizeHints hints;
MwWidget window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480, MwWidget window, viewport;
MwLibraryInit();
window = MwVaCreateWidget(MwWindowClass, "main", NULL, MwDEFAULT, MwDEFAULT, 640, 480,
MwNtitle, "tripaint", MwNtitle, "tripaint",
NULL); NULL);
MwWidget viewport = MwCreateWidget(MwViewportClass, "viewport", window, 5, 5, 630, 470 - 16 - 5); viewport = MwCreateWidget(MwViewportClass, "viewport", window, 5, 5, 630, 470 - 16 - 5);
hints.min_width = hints.max_width = 640; hints.min_width = hints.max_width = 640;
hints.min_height = hints.max_height = 480; hints.min_height = hints.max_height = 480;

View file

@ -44,6 +44,12 @@
extern "C" { extern "C" {
#endif #endif
/*!
* @brief Initializes the Milsko Toolkit
* @return `0` if successful
*/
MWDECL int MwLibraryInit(void);
/*! /*!
* @brief Creates a widget * @brief Creates a widget
* @param widget_class Widget class * @param widget_class Widget class

View file

@ -89,52 +89,52 @@ extern "C" {
MWDECL void MwLLCreateCommon(MwLL handle); MWDECL void MwLLCreateCommon(MwLL handle);
MWDECL void MwLLDestroyCommon(MwLL handle); MWDECL void MwLLDestroyCommon(MwLL handle);
/* driver-specific */ /* driver-specific, these get assigned by backend */
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 void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color); MWDECL void (*MwLLLine)(MwLL handle, MwPoint* points, 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 MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b); MWDECL void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, 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);
MWDECL void MwLLSetWH(MwLL handle, int w, int h); 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 MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int height); MWDECL MwLLPixmap (*MwLLCreatePixmap)(MwLL handle, unsigned char* data, int width, int height);
MWDECL void MwLLPixmapUpdate(MwLLPixmap pixmap); MWDECL void (*MwLLPixmapUpdate)(MwLLPixmap pixmap);
MWDECL void MwLLDestroyPixmap(MwLLPixmap pixmap); MWDECL void (*MwLLDestroyPixmap)(MwLLPixmap pixmap);
MWDECL void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap); MWDECL void (*MwLLDrawPixmap)(MwLL handle, MwRect* rect, MwLLPixmap pixmap);
MWDECL void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap); MWDECL void (*MwLLSetIcon)(MwLL handle, MwLLPixmap pixmap);
MWDECL void MwLLForceRender(MwLL handle); MWDECL void (*MwLLForceRender)(MwLL handle);
MWDECL void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask); MWDECL void (*MwLLSetCursor)(MwLL handle, MwCursor* image, MwCursor* mask);
MWDECL void MwLLDetach(MwLL handle, MwPoint* point); MWDECL void (*MwLLDetach)(MwLL handle, MwPoint* point);
MWDECL void MwLLShow(MwLL handle, int show); MWDECL void (*MwLLShow)(MwLL handle, int show);
MWDECL void MwLLMakePopup(MwLL handle, MwLL parent); MWDECL void (*MwLLMakePopup)(MwLL handle, MwLL parent);
MWDECL void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy); MWDECL void (*MwLLSetSizeHints)(MwLL handle, int minx, int miny, int maxx, int maxy);
MWDECL void MwLLMakeBorderless(MwLL handle, int toggle); MWDECL void (*MwLLMakeBorderless)(MwLL handle, int toggle);
MWDECL void MwLLSetBackground(MwLL handle, MwLLColor color); MWDECL void (*MwLLSetBackground)(MwLL handle, MwLLColor color);
MWDECL void MwLLFocus(MwLL handle); MWDECL void (*MwLLFocus)(MwLL handle);
MWDECL void MwLLGrabPointer(MwLL handle, int toggle); MWDECL void (*MwLLGrabPointer)(MwLL handle, int toggle);
MWDECL void MwLLSetClipboard(MwLL handle, const char* text); MWDECL void (*MwLLSetClipboard)(MwLL handle, const char* text);
MWDECL char* MwLLGetClipboard(MwLL handle); MWDECL char* (*MwLLGetClipboard)(MwLL handle);
MWDECL void MwLLMakeToolWindow(MwLL handle); MWDECL void (*MwLLMakeToolWindow)(MwLL handle);
#ifdef __cplusplus #ifdef __cplusplus
} }

View file

@ -25,11 +25,6 @@ elsif ($backend eq "gdi") {
$gl_libs = "-lopengl32 -lglu32"; $gl_libs = "-lopengl32 -lglu32";
} }
elsif ($backend eq "darwin") {
add_cflags("-DUSE_DARWIN");
new_object("src/backend/mac/*.c");
add_ldflags("-framework Carbon");
}
if (param_get("stb-image")) { if (param_get("stb-image")) {
add_cflags("-DUSE_STB_IMAGE"); add_cflags("-DUSE_STB_IMAGE");

View file

@ -210,7 +210,7 @@ static LRESULT CALLBACK wndproc(HWND hWnd, UINT msg, WPARAM wp, LPARAM lp) {
return 0; return 0;
} }
MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) { static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLL r = malloc(sizeof(*r)); MwLL r = malloc(sizeof(*r));
userdata_t* u = malloc(sizeof(*u)); userdata_t* u = malloc(sizeof(*u));
WNDCLASSEX wc; WNDCLASSEX wc;
@ -263,7 +263,7 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
return r; return r;
} }
void MwLLDestroy(MwLL handle) { static void MwLLDestroyImpl(MwLL handle) {
MwLLDestroyCommon(handle); MwLLDestroyCommon(handle);
/* for safety */ /* for safety */
@ -275,7 +275,7 @@ void MwLLDestroy(MwLL handle) {
free(handle); free(handle);
} }
void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) { static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
POINT* p = malloc(sizeof(*p) * points_count); POINT* p = malloc(sizeof(*p) * points_count);
HPEN pen = CreatePen(PS_NULL, 0, RGB(0, 0, 0)); HPEN pen = CreatePen(PS_NULL, 0, RGB(0, 0, 0));
int i; int i;
@ -294,7 +294,7 @@ void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color
free(p); free(p);
} }
void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) { static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
HPEN pen = CreatePen(PS_SOLID, 1, RGB(color->red, color->green, color->blue)); HPEN pen = CreatePen(PS_SOLID, 1, RGB(color->red, color->green, color->blue));
SelectObject(handle->hDC, pen); SelectObject(handle->hDC, pen);
@ -304,7 +304,7 @@ void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) {
DeleteObject(pen); DeleteObject(pen);
} }
MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) { static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
MwLLColor c = malloc(sizeof(*c)); MwLLColor c = malloc(sizeof(*c));
c->brush = NULL; c->brush = NULL;
@ -314,7 +314,7 @@ MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) {
return c; return c;
} }
void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) { static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
HDC dc = GetDC(handle->hWnd); HDC dc = GetDC(handle->hWnd);
if(r > 255) r = 255; if(r > 255) r = 255;
@ -333,18 +333,18 @@ void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) {
ReleaseDC(handle->hWnd, dc); ReleaseDC(handle->hWnd, dc);
} }
void MwLLFreeColor(MwLLColor color) { static void MwLLFreeColorImpl(MwLLColor color) {
DeleteObject(color->brush); DeleteObject(color->brush);
free(color); free(color);
} }
void MwLLSetBackground(MwLL handle, MwLLColor color) { static void MwLLSetBackgroundImpl(MwLL handle, MwLLColor color) {
(void)handle; (void)handle;
(void)color; (void)color;
} }
void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) { static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
RECT rc; RECT rc;
GetClientRect(handle->hWnd, &rc); GetClientRect(handle->hWnd, &rc);
@ -356,21 +356,21 @@ void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h)
*h = rc.bottom - rc.top; *h = rc.bottom - rc.top;
} }
void MwLLSetXY(MwLL handle, int x, int y) { static void MwLLSetXYImpl(MwLL handle, int x, int y) {
SetWindowPos(handle->hWnd, NULL, x, y, 0, 0, SWP_NOSIZE); SetWindowPos(handle->hWnd, NULL, x, y, 0, 0, SWP_NOSIZE);
InvalidateRect(handle->hWnd, NULL, FALSE); InvalidateRect(handle->hWnd, NULL, FALSE);
} }
void MwLLSetWH(MwLL handle, int w, int h) { static void MwLLSetWHImpl(MwLL handle, int w, int h) {
SetWindowPos(handle->hWnd, NULL, 0, 0, w, h, SWP_NOMOVE); SetWindowPos(handle->hWnd, NULL, 0, 0, w, h, SWP_NOMOVE);
InvalidateRect(handle->hWnd, NULL, FALSE); InvalidateRect(handle->hWnd, NULL, FALSE);
} }
void MwLLSetTitle(MwLL handle, const char* title) { static void MwLLSetTitleImpl(MwLL handle, const char* title) {
SetWindowText(handle->hWnd, title); SetWindowText(handle->hWnd, title);
} }
int MwLLPending(MwLL handle) { static int MwLLPendingImpl(MwLL handle) {
MSG msg; MSG msg;
(void)handle; (void)handle;
@ -378,7 +378,7 @@ int MwLLPending(MwLL handle) {
return PeekMessage(&msg, handle->hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0; return PeekMessage(&msg, handle->hWnd, 0, 0, PM_NOREMOVE) ? 1 : 0;
} }
void MwLLNextEvent(MwLL handle) { static void MwLLNextEventImpl(MwLL handle) {
MSG msg; MSG msg;
(void)handle; (void)handle;
@ -390,7 +390,7 @@ void MwLLNextEvent(MwLL handle) {
} }
} }
MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int height) { static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
MwLLPixmap r = malloc(sizeof(*r)); MwLLPixmap r = malloc(sizeof(*r));
HDC dc = GetDC(handle->hWnd); HDC dc = GetDC(handle->hWnd);
BITMAPINFOHEADER bmih; BITMAPINFOHEADER bmih;
@ -425,7 +425,7 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei
return r; return r;
} }
void MwLLPixmapUpdate(MwLLPixmap r) { static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
int y, x; int y, x;
int w = (r->width + (16 - (r->width % 16))) / 8; int w = (r->width + (16 - (r->width % 16))) / 8;
WORD* words; WORD* words;
@ -466,7 +466,7 @@ void MwLLPixmapUpdate(MwLLPixmap r) {
free(words2); free(words2);
} }
void MwLLDestroyPixmap(MwLLPixmap pixmap) { static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
free(pixmap->raw); free(pixmap->raw);
DeleteObject(pixmap->hMask); DeleteObject(pixmap->hMask);
DeleteObject(pixmap->hMask2); DeleteObject(pixmap->hMask2);
@ -475,7 +475,7 @@ void MwLLDestroyPixmap(MwLLPixmap pixmap) {
free(pixmap); free(pixmap);
} }
void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
HDC hmdc = CreateCompatibleDC(handle->hDC); HDC hmdc = CreateCompatibleDC(handle->hDC);
POINT p[3]; POINT p[3];
@ -496,7 +496,7 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
DeleteDC(hmdc); DeleteDC(hmdc);
} }
void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) { static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
ICONINFO ii; ICONINFO ii;
HICON ico; HICON ico;
@ -514,11 +514,11 @@ void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
DestroyIcon(ico); DestroyIcon(ico);
} }
void MwLLForceRender(MwLL handle) { static void MwLLForceRenderImpl(MwLL handle) {
PostMessage(handle->hWnd, WM_USER, 0, 0); PostMessage(handle->hWnd, WM_USER, 0, 0);
} }
void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) { static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
HCURSOR cursor; HCURSOR cursor;
BYTE* dmask = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight); BYTE* dmask = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight);
BYTE* dimage = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight); BYTE* dimage = malloc((MwCursorDataHeight / 8) * MwCursorDataHeight);
@ -566,7 +566,7 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
free(dmask); free(dmask);
} }
void MwLLDetach(MwLL handle, MwPoint* point) { static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
RECT rc, rc2; RECT rc, rc2;
LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE); LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE);
@ -589,18 +589,18 @@ void MwLLDetach(MwLL handle, MwPoint* point) {
SetWindowPos(handle->hWnd, HWND_TOPMOST, rc.left, rc.top, rc2.right == 0 ? 1 : rc2.right, rc2.bottom == 0 ? 1 : rc2.bottom, SWP_FRAMECHANGED | SWP_NOACTIVATE); SetWindowPos(handle->hWnd, HWND_TOPMOST, rc.left, rc.top, rc2.right == 0 ? 1 : rc2.right, rc2.bottom == 0 ? 1 : rc2.bottom, SWP_FRAMECHANGED | SWP_NOACTIVATE);
} }
void MwLLShow(MwLL handle, int show) { static void MwLLShowImpl(MwLL handle, int show) {
ShowWindow(handle->hWnd, show ? SW_NORMAL : SW_HIDE); ShowWindow(handle->hWnd, show ? SW_NORMAL : SW_HIDE);
if(show) SetFocus(handle->hWnd); if(show) SetFocus(handle->hWnd);
} }
void MwLLMakePopup(MwLL handle, MwLL parent) { static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
(void)handle; (void)handle;
(void)parent; (void)parent;
/* TODO */ /* TODO */
} }
void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) { static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
userdata_t* u = (userdata_t*)GetWindowLongPtr(handle->hWnd, GWLP_USERDATA); userdata_t* u = (userdata_t*)GetWindowLongPtr(handle->hWnd, GWLP_USERDATA);
u->min_set = u->max_set = 1; u->min_set = u->max_set = 1;
@ -610,7 +610,7 @@ void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
u->max.y = maxy; u->max.y = maxy;
} }
void MwLLMakeBorderless(MwLL handle, int toggle) { static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE); LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE);
if(toggle) { if(toggle) {
@ -624,11 +624,11 @@ void MwLLMakeBorderless(MwLL handle, int toggle) {
SetWindowPos(handle->hWnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER); SetWindowPos(handle->hWnd, NULL, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER);
} }
void MwLLFocus(MwLL handle) { static void MwLLFocusImpl(MwLL handle) {
SetFocus(handle->hWnd); SetFocus(handle->hWnd);
} }
void MwLLGrabPointer(MwLL handle, int toggle) { static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
if(toggle) { if(toggle) {
POINT p; POINT p;
RECT rc; RECT rc;
@ -657,7 +657,7 @@ void MwLLGrabPointer(MwLL handle, int toggle) {
} }
} }
void MwLLSetClipboard(MwLL handle, const char* text) { static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
HGLOBAL hg; HGLOBAL hg;
if(OpenClipboard(handle->hWnd) != 0) { if(OpenClipboard(handle->hWnd) != 0) {
char* lock; char* lock;
@ -675,7 +675,7 @@ void MwLLSetClipboard(MwLL handle, const char* text) {
} }
} }
char* MwLLGetClipboard(MwLL handle) { static char* MwLLGetClipboardImpl(MwLL handle) {
HGLOBAL hg; HGLOBAL hg;
char* r = NULL; char* r = NULL;
if(OpenClipboard(handle->hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) { if(OpenClipboard(handle->hWnd) != 0 && (hg = GetClipboardData(CF_TEXT)) != NULL) {
@ -692,7 +692,7 @@ char* MwLLGetClipboard(MwLL handle) {
return r; return r;
} }
void MwLLMakeToolWindow(MwLL handle) { static void MwLLMakeToolWindowImpl(MwLL handle) {
LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE) & WS_VISIBLE; LPARAM lp = GetWindowLongPtr(handle->hWnd, GWL_STYLE) & WS_VISIBLE;
RECT rc; RECT rc;
@ -703,3 +703,11 @@ void MwLLMakeToolWindow(MwLL handle) {
SetWindowPos(handle->hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); SetWindowPos(handle->hWnd, NULL, 0, 0, rc.right - rc.left, rc.bottom - rc.top, SWP_FRAMECHANGED | SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER);
} }
static int MwLLGDICallInitImpl(void) {
/* TODO: check properly */
return 0;
}
#include "call.c"
CALL(GDI);

View file

@ -1,76 +0,0 @@
/* $Id: carbon.c 154 2025-10-04 12:33:26Z nishi $ */
#include "mac.h"
#include "carbon.h"
#include <dlfcn.h>
void carbonBackendUserDataInit(mac_backend_userdata ud) {
}
static MwLL carbon_create(MwLL parent, int x, int y, int width, int height) {
return NULL;
};
static void carbon_destroy(MwLL handle) {
return;
};
static void carbon_polygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
return;
};
static MwLLColor carbon_allocColor(MwLL handle, int r, int g, int b) {
return NULL;
};
static void carbon_freeColor(MwLLColor color) {
return;
};
static void carbon_getXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
return;
};
static void carbon_setXY(MwLL handle, int x, int y) {
return;
};
static void carbon_setWH(MwLL handle, int w, int h) {
return;
};
static void carbon_setTitle(MwLL handle, const char* title) {
return;
};
static int carbon_pending(MwLL handle) {
return 0;
};
static void carbon_nextEvent(MwLL handle) {
return;
};
static MwLLPixmap carbon_createPixmap(MwLL handle, unsigned char* data, int width, int height) {
return NULL;
};
static void carbon_drawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
return;
};
static void carbon_setIcon(MwLL handle, MwLLPixmap pixmap) {
return;
};
static void carbon_forceRender(MwLL handle) {
return;
};
static mac_backend carbon_backend = {
.create = carbon_create,
.destroy = carbon_destroy,
.polygon = carbon_polygon,
.allocColor = carbon_allocColor,
.freeColor = carbon_freeColor,
.getXYWH = carbon_getXYWH,
.setXY = carbon_setXY,
.setWH = carbon_setWH,
.setTitle = carbon_setTitle,
.pending = carbon_pending,
.nextEvent = carbon_nextEvent,
.createPixmap = carbon_createPixmap,
.drawPixmap = carbon_drawPixmap,
.setIcon = carbon_setIcon,
.forceRender = carbon_forceRender,
};
mac_backend getCarbonBackend(void) {
return carbon_backend;
};

View file

@ -1,12 +0,0 @@
#ifndef __QUICKDRAW_H__
#define __QUICKDRAW_H__
#include "mac.h"
struct mac_backend_userdata_t {
};
void carbonBackendUserDataInit(mac_backend_userdata);
mac_backend getCarbonBackend(void);
#endif

View file

@ -1,83 +0,0 @@
/* $Id$ */
#include <Mw/Milsko.h>
#include "mac.h"
#include "carbon.h"
MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
// void* library;
// MwLL r = malloc(sizeof(*r));
// MwLLCreateCommon(r);
//
// library = dlopen("CarbonLib", RTLD_NOW);
// if(library != NULL) {
// dlclose(library);
// r->backend = getQuickDrawBackend();
// quickDrawBackendUserDataInit(r->userdata);
// return r;
// }
//
// printf("ERROR: No supported UI library found. (Searched for: CarbonLib)\n");
// getchar();
// raise(SIGTRAP);
return NULL;
};
void MwLLSleep(int ms) {
usleep(ms * 1000);
}
void MwLLFreeColor(MwLLColor color) {
free(color);
}
void MwLLDestroyPixmap(MwLLPixmap pixmap) {
free(pixmap);
}
void MwLLDestroy(MwLL handle) {
handle->backend.destroy(handle);
};
void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
handle->backend.polygon(handle, points, points_count, color);
};
MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) {
return handle->backend.allocColor(handle, r, g, b);
};
void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
return handle->backend.getXYWH(handle, x, y, w, h);
};
void MwLLSetXY(MwLL handle, int x, int y) {
return handle->backend.setXY(handle, x, y);
};
void MwLLSetWH(MwLL handle, int w, int h) {
return handle->backend.setWH(handle, w, h);
};
void MwLLSetTitle(MwLL handle, const char* title) {
return handle->backend.setTitle(handle, title);
};
int MwLLPending(MwLL handle) {
return handle->backend.pending(handle);
};
void MwLLNextEvent(MwLL handle) {
return handle->backend.nextEvent(handle);
};
MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int height) {
return handle->backend.createPixmap(handle, data, width, height);
};
void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
return handle->backend.drawPixmap(handle, rect, pixmap);
};
void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
return handle->backend.setIcon(handle, pixmap);
};
void MwLLForceRender(MwLL handle) {
return handle->backend.forceRender(handle);
};
void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
return handle->backend.setCursor(handle, image, mask);
};
void MwLLDetach(MwLL handle, MwPoint* point) {
return handle->backend.detach(handle, point);
};

View file

@ -1,54 +0,0 @@
/* $Id$ */
#ifndef __MAC_H__
#define __MAC_H__
#include <Mw/MachDep.h>
#include <Mw/TypeDefs.h>
#include <Mw/LowLevel.h>
typedef enum {
PLATFORM_QUICKDRAW = 0,
PLATFORM_QUARTZ,
} macPlatform;
typedef struct mac_backend_t {
MwLL (*create)(MwLL parent, int x, int y, int width, int height);
void (*destroy)(MwLL handle);
void (*polygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
MwLLColor (*allocColor)(MwLL handle, int r, int g, int b);
void (*freeColor)(MwLLColor color);
void (*getXYWH)(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
void (*setXY)(MwLL handle, int x, int y);
void (*setWH)(MwLL handle, int w, int h);
void (*setTitle)(MwLL handle, const char* title);
int (*pending)(MwLL handle);
void (*nextEvent)(MwLL handle);
MwLLPixmap (*createPixmap)(MwLL handle, unsigned char* data, int width, int height);
void (*drawPixmap)(MwLL handle, MwRect* rect, MwLLPixmap pixmap);
void (*setIcon)(MwLL handle, MwLLPixmap pixmap);
void (*forceRender)(MwLL handle);
void (*setCursor)(MwLL handle, MwCursor* image, MwCursor* mask);
void (*detach)(MwLL handle, MwPoint* point);
} mac_backend;
typedef struct mac_backend_userdata_t* mac_backend_userdata;
struct _MwLL {
mac_backend backend;
mac_backend_userdata userdata;
int copy_buffer;
unsigned int width;
unsigned int height;
MwLLHandler handler;
};
struct _MwLLPixmap {
unsigned int width;
unsigned int height;
};
#endif

View file

@ -121,7 +121,7 @@ static XVisualInfo* get_visual_info(Display* display) {
return XGetVisualInfo(display, VisualIDMask, &xvi, &n); return XGetVisualInfo(display, VisualIDMask, &xvi, &n);
} }
MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) { static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLL r; MwLL r;
Window p; Window p;
XVisualInfo* xvi; XVisualInfo* xvi;
@ -225,7 +225,7 @@ MwLL MwLLCreate(MwLL parent, int x, int y, int width, int height) {
return r; return r;
} }
void MwLLDestroy(MwLL handle) { static void MwLLDestroyImpl(MwLL handle) {
MwLLDestroyCommon(handle); MwLLDestroyCommon(handle);
if(handle->xic) XDestroyIC(handle->xic); if(handle->xic) XDestroyIC(handle->xic);
@ -241,7 +241,7 @@ void MwLLDestroy(MwLL handle) {
free(handle); free(handle);
} }
void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color) { static void MwLLPolygonImpl(MwLL handle, MwPoint* points, int points_count, MwLLColor color) {
int i; int i;
XPoint* p = malloc(sizeof(*p) * points_count); XPoint* p = malloc(sizeof(*p) * points_count);
@ -256,19 +256,19 @@ void MwLLPolygon(MwLL handle, MwPoint* points, int points_count, MwLLColor color
free(p); free(p);
} }
void MwLLLine(MwLL handle, MwPoint* points, MwLLColor color) { static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
XSetForeground(handle->display, handle->gc, color->pixel); XSetForeground(handle->display, handle->gc, color->pixel);
XDrawLine(handle->display, handle->pixmap, handle->gc, points[0].x, points[0].y, points[1].x, points[1].y); XDrawLine(handle->display, handle->pixmap, handle->gc, points[0].x, points[0].y, points[1].x, points[1].y);
} }
MwLLColor MwLLAllocColor(MwLL handle, int r, int g, int b) { static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
MwLLColor c = malloc(sizeof(*c)); MwLLColor c = malloc(sizeof(*c));
MwLLColorUpdate(handle, c, r, g, b); MwLLColorUpdate(handle, c, r, g, b);
return c; return c;
} }
void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) { static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
XColor xc; XColor xc;
if(handle->red_mask == 0) { if(handle->red_mask == 0) {
@ -292,7 +292,8 @@ void MwLLColorUpdate(MwLL handle, MwLLColor c, int r, int g, int b) {
c->green = g; c->green = g;
c->blue = b; c->blue = b;
} }
void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
static void MwLLGetXYWHImpl(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h) {
Window root; Window root;
unsigned int border, depth; unsigned int border, depth;
@ -308,7 +309,7 @@ void MwLLGetXYWH(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h)
} }
} }
void MwLLSetXY(MwLL handle, int x, int y) { static void MwLLSetXYImpl(MwLL handle, int x, int y) {
XSizeHints sh; XSizeHints sh;
long r; long r;
@ -325,7 +326,7 @@ void MwLLSetXY(MwLL handle, int x, int y) {
XSync(handle->display, False); XSync(handle->display, False);
} }
void MwLLSetWH(MwLL handle, int w, int h) { static void MwLLSetWHImpl(MwLL handle, int w, int h) {
XSizeHints sh; XSizeHints sh;
long r; long r;
@ -353,15 +354,15 @@ void MwLLSetWH(MwLL handle, int w, int h) {
MwLLForceRender(handle); MwLLForceRender(handle);
} }
void MwLLFreeColor(MwLLColor color) { static void MwLLFreeColorImpl(MwLLColor color) {
free(color); free(color);
} }
void MwLLSetBackground(MwLL handle, MwLLColor color) { static void MwLLSetBackgroundImpl(MwLL handle, MwLLColor color) {
XSetWindowBackground(handle->display, handle->window, color->pixel); XSetWindowBackground(handle->display, handle->window, color->pixel);
} }
int MwLLPending(MwLL handle) { static int MwLLPendingImpl(MwLL handle) {
XEvent ev; XEvent ev;
if(XCheckTypedWindowEvent(handle->display, handle->window, ClientMessage, &ev) || XCheckWindowEvent(handle->display, handle->window, mask, &ev)) { if(XCheckTypedWindowEvent(handle->display, handle->window, ClientMessage, &ev) || XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
XPutBackEvent(handle->display, &ev); XPutBackEvent(handle->display, &ev);
@ -370,7 +371,7 @@ int MwLLPending(MwLL handle) {
return 0; return 0;
} }
void MwLLNextEvent(MwLL handle) { static void MwLLNextEventImpl(MwLL handle) {
XEvent ev; XEvent ev;
while(XCheckTypedWindowEvent(handle->display, handle->window, ClientMessage, &ev) || XCheckWindowEvent(handle->display, handle->window, mask, &ev)) { while(XCheckTypedWindowEvent(handle->display, handle->window, ClientMessage, &ev) || XCheckWindowEvent(handle->display, handle->window, mask, &ev)) {
int render = 0; int render = 0;
@ -526,11 +527,11 @@ void MwLLNextEvent(MwLL handle) {
} }
} }
void MwLLSetTitle(MwLL handle, const char* title) { static void MwLLSetTitleImpl(MwLL handle, const char* title) {
XSetStandardProperties(handle->display, handle->window, title, title, None, (char**)NULL, 0, NULL); XSetStandardProperties(handle->display, handle->window, title, title, None, (char**)NULL, 0, NULL);
} }
MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int height) { static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
MwLLPixmap r = malloc(sizeof(*r)); MwLLPixmap r = malloc(sizeof(*r));
char* di = malloc(4 * width * height); char* di = malloc(4 * width * height);
char* dm = malloc(4 * width * height); char* dm = malloc(4 * width * height);
@ -560,7 +561,7 @@ MwLLPixmap MwLLCreatePixmap(MwLL handle, unsigned char* data, int width, int hei
return r; return r;
} }
void MwLLPixmapUpdate(MwLLPixmap r) { static void MwLLPixmapUpdateImpl(MwLLPixmap r) {
int y, x; int y, x;
for(y = 0; y < r->height; y++) { for(y = 0; y < r->height; y++) {
for(x = 0; x < r->width; x++) { for(x = 0; x < r->width; x++) {
@ -588,7 +589,7 @@ void MwLLPixmapUpdate(MwLLPixmap r) {
} }
} }
void MwLLDestroyPixmap(MwLLPixmap pixmap) { static void MwLLDestroyPixmapImpl(MwLLPixmap pixmap) {
free(pixmap->raw); free(pixmap->raw);
XDestroyImage(pixmap->image); XDestroyImage(pixmap->image);
XDestroyImage(pixmap->mask); XDestroyImage(pixmap->mask);
@ -597,7 +598,7 @@ void MwLLDestroyPixmap(MwLLPixmap pixmap) {
free(pixmap); free(pixmap);
} }
void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) { static void MwLLDrawPixmapImpl(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
if(rect->width == 0 || rect->height == 0) return; if(rect->width == 0 || rect->height == 0) return;
#ifdef USE_XRENDER #ifdef USE_XRENDER
if(pixmap->image != NULL && pixmap->use_xrender) { if(pixmap->image != NULL && pixmap->use_xrender) {
@ -712,7 +713,7 @@ void MwLLDrawPixmap(MwLL handle, MwRect* rect, MwLLPixmap pixmap) {
} }
} }
void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) { static void MwLLSetIconImpl(MwLL handle, MwLLPixmap pixmap) {
unsigned long* icon = malloc((2 + pixmap->width * pixmap->height) * sizeof(*icon)); unsigned long* icon = malloc((2 + pixmap->width * pixmap->height) * sizeof(*icon));
int i; int i;
Atom atom = XInternAtom(handle->display, "_NET_WM_ICON", False); Atom atom = XInternAtom(handle->display, "_NET_WM_ICON", False);
@ -729,7 +730,7 @@ void MwLLSetIcon(MwLL handle, MwLLPixmap pixmap) {
free(icon); free(icon);
} }
void MwLLForceRender(MwLL handle) { static void MwLLForceRenderImpl(MwLL handle) {
XEvent ev; XEvent ev;
memset(&ev, 0, sizeof(ev)); memset(&ev, 0, sizeof(ev));
@ -738,7 +739,7 @@ void MwLLForceRender(MwLL handle) {
XSendEvent(handle->display, handle->window, False, ExposureMask, &ev); XSendEvent(handle->display, handle->window, False, ExposureMask, &ev);
} }
void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) { static void MwLLSetCursorImpl(MwLL handle, MwCursor* image, MwCursor* mask) {
Cursor cur; Cursor cur;
int y, x, ys, xs; int y, x, ys, xs;
char* di = malloc(MwCursorDataHeight * MwCursorDataHeight * 4); char* di = malloc(MwCursorDataHeight * MwCursorDataHeight * 4);
@ -801,7 +802,7 @@ void MwLLSetCursor(MwLL handle, MwCursor* image, MwCursor* mask) {
XDestroyImage(cmask); XDestroyImage(cmask);
} }
void MwLLDetach(MwLL handle, MwPoint* point) { static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
int x = 0, y = 0; int x = 0, y = 0;
Window child, root, parent; Window child, root, parent;
Window* children; Window* children;
@ -824,7 +825,7 @@ void MwLLDetach(MwLL handle, MwPoint* point) {
if(xwa.map_state == IsViewable) wait_map(handle, 0, 0); if(xwa.map_state == IsViewable) wait_map(handle, 0, 0);
} }
void MwLLShow(MwLL handle, int show) { static void MwLLShowImpl(MwLL handle, int show) {
if(show) { if(show) {
wait_map(handle, 0, 0); wait_map(handle, 0, 0);
@ -834,7 +835,7 @@ void MwLLShow(MwLL handle, int show) {
} }
} }
void MwLLMakePopup(MwLL handle, MwLL parent) { static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
Atom wndtype = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE", False); Atom wndtype = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE", False);
Atom wnddlg = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE_DIALOG", False); Atom wnddlg = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE_DIALOG", False);
Atom wndstate = XInternAtom(handle->display, "_NET_WM_STATE", False); Atom wndstate = XInternAtom(handle->display, "_NET_WM_STATE", False);
@ -849,7 +850,7 @@ void MwLLMakePopup(MwLL handle, MwLL parent) {
wait_map(handle, 1, 0); wait_map(handle, 1, 0);
} }
void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) { static void MwLLSetSizeHintsImpl(MwLL handle, int minx, int miny, int maxx, int maxy) {
XSizeHints* hints = XAllocSizeHints(); XSizeHints* hints = XAllocSizeHints();
long ret; long ret;
@ -868,7 +869,7 @@ void MwLLSetSizeHints(MwLL handle, int minx, int miny, int maxx, int maxy) {
wait_map(handle, 1, 0); wait_map(handle, 1, 0);
} }
void MwLLMakeBorderless(MwLL handle, int toggle) { static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
Atom atom = XInternAtom(handle->display, "_MOTIF_WM_HINTS", 0); Atom atom = XInternAtom(handle->display, "_MOTIF_WM_HINTS", 0);
mwm_hints_t hints; mwm_hints_t hints;
@ -881,11 +882,11 @@ void MwLLMakeBorderless(MwLL handle, int toggle) {
wait_map(handle, 1, 0); wait_map(handle, 1, 0);
} }
void MwLLFocus(MwLL handle) { static void MwLLFocusImpl(MwLL handle) {
XSetInputFocus(handle->display, handle->window, RevertToNone, CurrentTime); XSetInputFocus(handle->display, handle->window, RevertToNone, CurrentTime);
} }
void MwLLGrabPointer(MwLL handle, int toggle) { static void MwLLGrabPointerImpl(MwLL handle, int toggle) {
XWindowAttributes attr; XWindowAttributes attr;
XGetWindowAttributes(handle->display, handle->window, &attr); XGetWindowAttributes(handle->display, handle->window, &attr);
@ -899,14 +900,14 @@ void MwLLGrabPointer(MwLL handle, int toggle) {
} }
} }
void MwLLSetClipboard(MwLL handle, const char* text) { static void MwLLSetClipboardImpl(MwLL handle, const char* text) {
/* TODO */ /* TODO */
(void)handle; (void)handle;
(void)text; (void)text;
} }
char* MwLLGetClipboard(MwLL handle) { static char* MwLLGetClipboardImpl(MwLL handle) {
Atom clip, target, prop; Atom clip, target, prop;
XEvent ev; XEvent ev;
XEvent* queue = NULL; XEvent* queue = NULL;
@ -947,7 +948,7 @@ char* MwLLGetClipboard(MwLL handle) {
return r; return r;
} }
void MwLLMakeToolWindow(MwLL handle) { static void MwLLMakeToolWindowImpl(MwLL handle) {
XSetWindowAttributes xswa; XSetWindowAttributes xswa;
Atom wndtype = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE", False); Atom wndtype = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE", False);
Atom wndmenu = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE_MENU", False); Atom wndmenu = XInternAtom(handle->display, "_NET_WM_WINDOW_TYPE_MENU", False);
@ -957,3 +958,11 @@ void MwLLMakeToolWindow(MwLL handle) {
XChangeWindowAttributes(handle->display, handle->window, CWOverrideRedirect, &xswa); XChangeWindowAttributes(handle->display, handle->window, CWOverrideRedirect, &xswa);
XChangeProperty(handle->display, handle->window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1); XChangeProperty(handle->display, handle->window, wndtype, XA_ATOM, 32, PropModeReplace, (unsigned char*)&wndmenu, 1);
} }
static int MwLLX11CallInitImpl(void) {
/* TODO: check properly */
return 0;
}
#include "call.c"
CALL(X11);

View file

@ -604,3 +604,29 @@ void MwToggleDarkTheme(MwWidget handle, int toggle) {
MwWidget MwGetParent(MwWidget handle) { MwWidget MwGetParent(MwWidget handle) {
return handle->parent; return handle->parent;
} }
typedef int (*call_t)(void);
int MwLibraryInit(void) {
#ifdef USE_X11
extern call_t MwLLX11CallInit;
#endif
#ifdef USE_GDI
extern call_t MwLLGDICallInit;
#endif
call_t calls[] = {
#ifdef USE_X11
MwLLX11CallInit,
#endif
#ifdef USE_GDI
MwLLGDICallInit,
#endif
NULL};
int i;
for(i = 0; calls[i] != NULL; i++) {
if(calls[i]() == 0) return 0;
}
return 1;
}

View file

@ -1,6 +1,52 @@
/* $Id$ */ /* $Id$ */
#include <Mw/Milsko.h> #include <Mw/Milsko.h>
MwLL (*MwLLCreate)(MwLL parent, int x, int y, int width, int height);
void (*MwLLDestroy)(MwLL handle);
void (*MwLLPolygon)(MwLL handle, MwPoint* points, int points_count, MwLLColor color);
void (*MwLLLine)(MwLL handle, MwPoint* points, MwLLColor color);
MwLLColor (*MwLLAllocColor)(MwLL handle, int r, int g, int b);
void (*MwLLColorUpdate)(MwLL handle, MwLLColor c, int r, int g, int b);
void (*MwLLFreeColor)(MwLLColor color);
void (*MwLLGetXYWH)(MwLL handle, int* x, int* y, unsigned int* w, unsigned int* h);
void (*MwLLSetXY)(MwLL handle, int x, int y);
void (*MwLLSetWH)(MwLL handle, int w, int h);
void (*MwLLSetTitle)(MwLL handle, const char* title);
int (*MwLLPending)(MwLL handle);
void (*MwLLNextEvent)(MwLL handle);
MwLLPixmap (*MwLLCreatePixmap)(MwLL handle, unsigned char* data, int width, int height);
void (*MwLLPixmapUpdate)(MwLLPixmap pixmap);
void (*MwLLDestroyPixmap)(MwLLPixmap pixmap);
void (*MwLLDrawPixmap)(MwLL handle, MwRect* rect, MwLLPixmap pixmap);
void (*MwLLSetIcon)(MwLL handle, MwLLPixmap pixmap);
void (*MwLLForceRender)(MwLL handle);
void (*MwLLSetCursor)(MwLL handle, MwCursor* image, MwCursor* mask);
void (*MwLLDetach)(MwLL handle, MwPoint* point);
void (*MwLLShow)(MwLL handle, int show);
void (*MwLLMakePopup)(MwLL handle, MwLL parent);
void (*MwLLSetSizeHints)(MwLL handle, int minx, int miny, int maxx, int maxy);
void (*MwLLMakeBorderless)(MwLL handle, int toggle);
void (*MwLLSetBackground)(MwLL handle, MwLLColor color);
void (*MwLLFocus)(MwLL handle);
void (*MwLLGrabPointer)(MwLL handle, int toggle);
void (*MwLLSetClipboard)(MwLL handle, const char* text);
char* (*MwLLGetClipboard)(MwLL handle);
void (*MwLLMakeToolWindow)(MwLL handle);
void MwLLCreateCommon(MwLL handle) { void MwLLCreateCommon(MwLL handle) {
handle->handler = malloc(sizeof(*handle->handler)); handle->handler = malloc(sizeof(*handle->handler));
memset(handle->handler, 0, sizeof(*handle->handler)); memset(handle->handler, 0, sizeof(*handle->handler));

View file

@ -47,7 +47,7 @@ static void draw(MwWidget handle) {
if(arrlen(cb->list) > cb->selected) { if(arrlen(cb->list) > cb->selected) {
MwPoint p; MwPoint p;
p.x = MwDefaultBorderWidth(handle) * 2; p.x = MwDefaultBorderWidth(handle) * 2 + 4;
p.y = MwGetInteger(handle, MwNheight) / 2; p.y = MwGetInteger(handle, MwNheight) / 2;
MwDrawText(handle, &p, cb->list[cb->selected], 0, MwALIGNMENT_BEGINNING, text); MwDrawText(handle, &p, cb->list[cb->selected], 0, MwALIGNMENT_BEGINNING, text);
@ -110,7 +110,7 @@ static void click(MwWidget handle) {
if(l > width) width = l; if(l > width) width = l;
} }
cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, "M") * 6 + MwDefaultBorderWidth(handle) * 2, cb->listbox = MwVaCreateWidget(MwListBoxClass, "listbox", handle, 0, MwGetInteger(handle, MwNheight), width, MwTextHeight(handle, "M") * 6 + MwDefaultBorderWidth(handle) * 2 + MwTextHeight(handle, "M") / 4,
MwNsingleClickSelectable, 1, MwNsingleClickSelectable, 1,
NULL); NULL);
MwLLShow(cb->listbox->lowlevel, 0); MwLLShow(cb->listbox->lowlevel, 0);

View file

@ -231,7 +231,7 @@ static void frame_draw(MwWidget handle) {
MwLLDrawPixmap(handle->lowlevel, &r2, lb->list[i].pixmap); MwLLDrawPixmap(handle->lowlevel, &r2, lb->list[i].pixmap);
} }
p.y += MwTextHeight(handle, "M") / 2; p.y += MwTextHeight(handle, "M") / 2;
p.x = MwGetInteger(handle->parent, MwNleftPadding) + MwDefaultBorderWidth(handle); p.x = MwGetInteger(handle->parent, MwNleftPadding) + MwDefaultBorderWidth(handle) + 4;
for(j = 0; j < arrlen(lb->list[i].name); j++) { for(j = 0; j < arrlen(lb->list[i].name); j++) {
char* t = lb->list[i].name[j]; char* t = lb->list[i].name[j];
@ -344,7 +344,7 @@ static void draw(MwWidget handle) {
if(MwGetInteger(handle, MwNhasHeading) && arrlen(lb->list) > 0) { if(MwGetInteger(handle, MwNhasHeading) && arrlen(lb->list) > 0) {
MwPoint p; MwPoint p;
int i; int i;
int x = 0; int x = 4;
r.width -= 16; r.width -= 16;