/*! * @file Mw/LowLevel/Cocoa.h * @brief Work in progress Cocoa Backend * @warning This is used internally. */ #ifndef __MW_LOWLEVEL_COCOA_H__ #define __MW_LOWLEVEL_COCOA_H__ #include #include #include #ifdef __OBJC__ #import #import #import #ifdef __APPLE__ #import #else #import #endif @interface MilskoCocoaWindowDelegate : NSObject { NSWindow *w; } - (instancetype)initWithWin:(NSWindow *)win; @end @interface MilskoFakePointer : NSView { void *ptr; } - (void)setPointer:(void *)ptr; - (void *)pointer; @end @interface MilskoCocoaPixmap : NSObject { MwBool valid; int width; int height; NSData *data; NSImage *image; NSBitmapImageRep *rep; } + (MilskoCocoaPixmap *)newWithWidth:(int)width height:(int)height; - (void)updateWithData:(unsigned char *)data; - (void)destroy; /* using @property to create instance variables fucks up 10.4 gcc for some * reason? */ - (NSImage *)image; @end @interface MilskoCocoaView : NSView { NSBitmapImageRep *rep; NSGraphicsContext *context; MwBool valid; CGColorSpaceRef space; CGDataProviderRef provider; float width; float height; } - (NSGraphicsContext *)context; - (void)destroy; - (NSBitmapImageRep *)getRep; @end @interface MilskoCocoa : NSObject { NSApplication *application; NSEvent *lastEvent; MwBool _forceRender; NSWindow *window; NSRect rect; MilskoCocoaView *view; MwLL parent; MilskoFakePointer *handle; MwBool doWHResize; } + (MilskoCocoa *)newWithParent:(MwLL)parent x:(int)x y:(int)y width:(int)width height:(int)height handle:(MwLL)handle; - (void)polygonWithPoints:(MwPoint *)points points_count:(int)points_count color:(MwLLColor)color; - (void)lineWithPoints:(MwPoint *)points color:(MwLLColor)color; - (void)getX:(int *)x Y:(int *)y W:(unsigned int *)w H:(unsigned int *)h; - (void)setX:(int)x Y:(int)y; - (void)setW:(int)w H:(int)h; - (int)pending; - (void)getNextEvent; - (void)setTitle:(const char *)title; - (void)drawPixmap:(MwLLPixmap)pixmap rect:(MwRect *)rect; - (void)setIcon:(MwLLPixmap)pixmap; - (void)forceRender; - (void)setCursor:(MwCursor *)image mask:(MwCursor *)mask; - (void)detachWithPoint:(MwPoint *)point; - (void)show:(int)show; - (void)makePopupWithParent:(MwLL)parent; - (void)setSizeHintsWithMinX:(int)minx MinY:(int)miny MaxX:(int)maxx MaxY:(int)maxy; - (void)makeBorderless:(int)toggle; - (void)focus; - (void)grabPointer:(int)toggle; - (void)setClipboard:(const char *)text; - (void)makeToolWindow; - (void)getCursorCoord:(MwPoint *)point; - (void)getScreenSize:(MwRect *)rect; - (void)destroy; - (void)setHandle:(MwLL)h; - (NSWindow *)parentWindow; @end #define OBJC(x) x #else #define OBJC(x) void * #endif MWDECL int MwLLCocoaCallInit(void); struct _MwLLCocoa { struct _MwLLCommon common; OBJC(MilskoCocoa *) real; }; struct _MwLLCocoaColor { struct _MwLLCommonColor common; }; struct _MwLLCocoaPixmap { struct _MwLLCommonPixmap common; OBJC(MilskoCocoaPixmap *) real; }; #endif