cmacos: very untested code but it's all so basic that it should work

This commit is contained in:
IoIxD 2026-04-16 00:45:59 -07:00
commit 9b138c458e
3 changed files with 59 additions and 12 deletions

View file

@ -125,7 +125,7 @@ union _MwLL {
struct _MwLLCocoa cocoa; struct _MwLLCocoa cocoa;
#endif #endif
#ifdef CLASSIC_MAC_OS #ifdef CLASSIC_MAC_OS
struct _MwLLClassicMacOS cmacos; struct _MwLLClassicMacOS cmacos;
#endif #endif
}; };
@ -159,6 +159,9 @@ union _MwLLPixmap {
#ifdef USE_COCOA #ifdef USE_COCOA
struct _MwLLCocoaPixmap cocoa; struct _MwLLCocoaPixmap cocoa;
#endif #endif
#ifdef CLASSIC_MAC_OS
struct _MwLLClassicMacOSPixmap cmacos;
#endif
}; };
#endif #endif
#include <Mw/TypeDefs.h> #include <Mw/TypeDefs.h>

View file

@ -24,6 +24,7 @@ struct _MwLLClassicMacOSColor {
struct _MwLLClassicMacOSPixmap { struct _MwLLClassicMacOSPixmap {
struct _MwLLCommonPixmap common; struct _MwLLCommonPixmap common;
BitMap bmp;
}; };
MWDECL int MwLLClassicMacOSCallInit(void); MWDECL int MwLLClassicMacOSCallInit(void);

View file

@ -7,12 +7,13 @@ static MwLL MwLLCreateImpl(MwLL parent, int x, int y, int width, int height) {
MwLLCreateCommon(r); MwLLCreateCommon(r);
SetRect(&r->cmacos.winRect, 100, 100, width, height); if(!parent) {
SetRect(&r->cmacos.winRect, 100, 100, width, height);
r->cmacos.window = NewCWindow(nil, &r->cmacos.winRect, (ConstStr255Param) "\p", true, r->cmacos.window = NewCWindow(nil, &r->cmacos.winRect, (ConstStr255Param) "\p", true,
documentProc, (WindowPtr)(-1), true, 0); documentProc, (WindowPtr)(-1), true, 0);
SetPort(r->cmacos.window);
SetPort(r->cmacos.window); //
}
return r; return r;
} }
@ -32,10 +33,42 @@ static void MwLLEndDrawImpl(MwLL handle) {
} }
static void MwLLPolygonImpl(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;
PolyHandle p = OpenPoly();
RGBColor col;
col.red = color->common.red;
col.green = color->common.green;
col.blue = color->common.blue;
RGBBackColor(&col);
RGBForeColor(&col);
for(i = 0; i < points_count; i++) {
if(i == 0) {
MoveTo(points[i].x, points[i].y);
} else {
LineTo(points[i].x, points[i].y);
}
}
ClosePoly();
PaintPoly(p);
KillPoly(p);
} }
static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) { static void MwLLLineImpl(MwLL handle, MwPoint* points, MwLLColor color) {
RGBColor col;
col.red = color->common.red;
col.green = color->common.green;
col.blue = color->common.blue;
RGBBackColor(&col);
RGBForeColor(&col);
MoveTo(points[0].x, points[0].y);
LineTo(points[1].x, points[1].y);
} }
static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) { static MwLLColor MwLLAllocColorImpl(MwLL handle, int r, int g, int b) {
@ -51,16 +84,20 @@ static void MwLLColorUpdateImpl(MwLL handle, MwLLColor c, int r, int g, int b) {
} }
static void MwLLGetXYWHImpl(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) {
*x = 0; Rect bounds;
*y = 0; GetWindowBounds(handle->cmacos.window, kWindowContentRgn, &bounds);
*w = 0; *x = bounds.left;
*h = 0; *y = bounds.top;
*w = bounds.right;
*h = bounds.bottom;
} }
static void MwLLSetXYImpl(MwLL handle, int x, int y) { static void MwLLSetXYImpl(MwLL handle, int x, int y) {
MoveWindow(handle->cmacos.window, x, y, MwTRUE);
} }
static void MwLLSetWHImpl(MwLL handle, int w, int h) { static void MwLLSetWHImpl(MwLL handle, int w, int h) {
SizeWindow(handle->cmacos.window, w, h, MwTRUE);
} }
static void MwLLFreeColorImpl(MwLLColor color) { static void MwLLFreeColorImpl(MwLLColor color) {
@ -75,6 +112,7 @@ static void MwLLNextEventImpl(MwLL handle) {
} }
static void MwLLSetTitleImpl(MwLL handle, const char* title) { static void MwLLSetTitleImpl(MwLL handle, const char* title) {
setwtitle(handle->cmacos.window, title);
} }
static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) { static MwLLPixmap MwLLCreatePixmapImpl(MwLL handle, unsigned char* data, int width, int height) {
@ -109,6 +147,10 @@ static void MwLLDetachImpl(MwLL handle, MwPoint* point) {
} }
static void MwLLShowImpl(MwLL handle, int show) { static void MwLLShowImpl(MwLL handle, int show) {
if(show)
ShowWindow(handle->cmacos.window);
else
HideWindow(handle->cmacos.window);
} }
static void MwLLMakePopupImpl(MwLL handle, MwLL parent) { static void MwLLMakePopupImpl(MwLL handle, MwLL parent) {
@ -121,6 +163,7 @@ static void MwLLMakeBorderlessImpl(MwLL handle, int toggle) {
} }
static void MwLLFocusImpl(MwLL handle) { static void MwLLFocusImpl(MwLL handle) {
HiliteWindow(handle->cmacos.window, MwTRUE);
} }
static void MwLLGrabPointerImpl(MwLL handle, int toggle) { static void MwLLGrabPointerImpl(MwLL handle, int toggle) {