# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1298532641 0 # Node ID f31a47b055f8c492396c097dd1d1890318de1966 # Parent 6c8b95ca877b8c2129c21bf54d949b9605faafed Work (unfinished) on container objects. diff -r 6c8b95ca877b -r f31a47b055f8 mac/dw.m --- a/mac/dw.m Wed Feb 23 20:45:50 2011 +0000 +++ b/mac/dw.m Thu Feb 24 07:30:41 2011 +0000 @@ -17,6 +17,40 @@ #include #include +unsigned long _colors[] = +{ + 0x00000000, /* 0 black */ + 0x00bb0000, /* 1 red */ + 0x0000bb00, /* 2 green */ + 0x00aaaa00, /* 3 yellow */ + 0x000000cc, /* 4 blue */ + 0x00bb00bb, /* 5 magenta */ + 0x0000bbbb, /* 6 cyan */ + 0x00bbbbbb, /* 7 white */ + 0x00777777, /* 8 grey */ + 0x00ff0000, /* 9 bright red */ + 0x0000ff00, /* 10 bright green */ + 0x00eeee00, /* 11 bright yellow */ + 0x000000ff, /* 12 bright blue */ + 0x00ff00ff, /* 13 bright magenta */ + 0x0000eeee, /* 14 bright cyan */ + 0x00ffffff, /* 15 bright white */ + 0xff000000 /* 16 default color */ +}; + +unsigned long _get_color(unsigned long thiscolor) +{ + if(thiscolor & DW_RGB_COLOR) + { + return thiscolor & ~DW_RGB_COLOR; + } + else if(thiscolor < 17) + { + return _colors[thiscolor]; + } + return 0; +} + typedef struct _sighandler { struct _sighandler *next; @@ -56,6 +90,14 @@ { switch(message) { + case 0: + { + int (* API timerfunc)(void *) = (int (* API)(void *))handler->signalfunction; + + if(!timerfunc(handler->data)) + dw_timer_disconnect(handler->id); + return 0; + } case 3: case 4: { @@ -116,9 +158,19 @@ return -1; } +/* Subclass for the Timer type */ +@interface DWTimerHandler : NSObject { } +-(void)runTimer:(id)sender; +@end + +@implementation DWTimerHandler +-(void)runTimer:(id)sender { _event_handler(self, nil, 0); } +@end + NSApplication *DWApp; NSRunLoop *DWRunLoop; NSMenu *DWMainMenu; +DWTimerHandler *DWHandler; #if !defined(GARBAGE_COLLECT) NSAutoreleasePool *pool; #endif @@ -146,6 +198,7 @@ -(BOOL)isFlipped; -(void)mouseDown:(NSEvent *)theEvent; -(void)mouseUp:(NSEvent *)theEvent; +-(void)setColor:(unsigned long)input; @end @implementation DWBox @@ -164,6 +217,17 @@ -(BOOL)isFlipped { return YES; } -(void)mouseDown:(NSEvent *)theEvent { _event_handler(self, theEvent, 3); } -(void)mouseUp:(NSEvent *)theEvent { _event_handler(self, theEvent, 4); } +-(void)setColor:(unsigned long)input +{ + if(input == _colors[DW_CLR_DEFAULT]) + { + bgcolor = nil; + } + else + { + bgcolor = [NSColor colorWithDeviceRed: DW_RED_VALUE(input)/255.0 green: DW_GREEN_VALUE(input)/255.0 blue: DW_BLUE_VALUE(input)/255.0 alpha: 1]; + } +} @end /* Subclass for a top-level window */ @@ -203,17 +267,15 @@ { if(windowmenu) { - NSLog(@"Setting local menu"); [DWApp setMainMenu:windowmenu]; } else { - NSLog(@"Setting global menu"); [DWApp setMainMenu:DWMainMenu]; } } --(void)setMenu:(NSMenu *)input { windowmenu = input; NSLog(@"Setting window menu"); } +-(void)setMenu:(NSMenu *)input { windowmenu = input; } -(void)menuHandler:(id)sender { _event_handler(sender, nil, 8); } @end @@ -439,14 +501,87 @@ @interface DWContainer : NSTableView { void *userdata; + NSMutableArray *tvcols; + NSMutableArray *data; + NSMutableArray *types; } -(void *)userdata; -(void)setUserdata:(void *)input; +-(id)tableView:(NSTableView *)aTable objectValueForColumn:(NSTableColumn *)aCol row:(int)aRow; +-(int)numberOfRowsInTableView:(NSTableView *)aTable; +-(void)addColumn:(NSTableColumn *)input andType:(int)type; +-(void)addRow:(NSArray *)input; +-(void)addRows:(int)number; +-(void)editCell:(id)input at:(int)row and:(int)col; +-(int)cellType:(int)col; +-(void)clear; +-(void)setup; @end @implementation DWContainer -(void *)userdata { return userdata; } -(void)setUserdata:(void *)input { userdata = input; } +-(id)tableView:(NSTableView *)aTable objectValueForColumn:(NSTableColumn *)aCol row:(int)aRow +{ + if(tvcols) + { + int z, col = -1; + int count = [tvcols count]; + + for(z=0;zosName, name.sysname); + strcpy(env->osName, "MacOS"); strcpy(tempbuf, name.release); env->MajorBuild = env->MinorBuild = 0; @@ -4284,9 +4596,20 @@ { if(tempbuf[z] == '.') { + int ver = atoi(tempbuf); tempbuf[z] = '\0'; - env->MajorVersion = atoi(&tempbuf[z-1]); - env->MinorVersion = atoi(&tempbuf[z+1]); + if(ver > 4) + { + env->MajorVersion = 10; + env->MinorVersion = ver - 4; + env->MajorBuild = atoi(&tempbuf[z+1]); + } + else + { + env->MajorVersion = ver; + env->MinorVersion = atoi(&tempbuf[z+1]); + } + return; } } @@ -4459,6 +4782,9 @@ return NULL; } +#define DW_TIMER_MAX 64 +NSTimer *DWTimers[DW_TIMER_MAX]; + /* * Add a callback to a timer event. * Parameters: @@ -4470,18 +4796,23 @@ */ int API dw_timer_connect(int interval, void *sigfunc, void *data) { - NSLog(@"dw_timer_connect() unimplemented\n"); - if(sigfunc) + int z; + + for(z=0;zid == id) + if(tmp->id == (timerid-1) && tmp->window == thistimer) { if(prev) { @@ -4536,13 +4870,13 @@ */ void API dw_signal_connect(HWND window, char *signame, void *sigfunc, void *data) { - ULONG message = 0, id = 0; + ULONG message = 0, msgid = 0; if(window && signame && sigfunc) { if((message = _findsigmessage(signame)) != 0) { - _new_signal(message, window, id, sigfunc, data); + _new_signal(message, window, msgid, sigfunc, data); } } }