comparison mac/dw.m @ 1922:a2a8145f3148

Turn off smart text and quote substitution on MLE. Need a way to toggle these in future. Lots of whitespace changes :-(
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Tue, 04 Oct 2016 06:47:36 +0000
parents 3872ab37297b
children c47a04d83b90
comparison
equal deleted inserted replaced
1921:bc70b3e9dbb1 1922:a2a8145f3148
451 return result; 451 return result;
452 } 452 }
453 else if(event) 453 else if(event)
454 { 454 {
455 void **params = (void **)event; 455 void **params = (void **)event;
456 456
457 text = params[0]; 457 text = params[0];
458 user = params[1]; 458 user = params[1];
459 } 459 }
460 460
461 return treeselectfunc(handler->window, item, text, handler->data, user); 461 return treeselectfunc(handler->window, item, text, handler->data, user);
2249 } 2249 }
2250 } 2250 }
2251 -(void)doubleClicked:(id)sender 2251 -(void)doubleClicked:(id)sender
2252 { 2252 {
2253 void *params[2]; 2253 void *params[2];
2254 2254
2255 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; 2255 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]];
2256 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; 2256 params[1] = (void *)[self getRowData:(int)[self selectedRow]];
2257 2257
2258 /* Handler for container class */ 2258 /* Handler for container class */
2259 _event_handler(self, (NSEvent *)params, 9); 2259 _event_handler(self, (NSEvent *)params, 9);
2260 } 2260 }
2261 -(void)keyUp:(NSEvent *)theEvent 2261 -(void)keyUp:(NSEvent *)theEvent
2262 { 2262 {
2263 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 2263 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
2264 { 2264 {
2265 void *params[2]; 2265 void *params[2];
2266 2266
2267 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; 2267 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]];
2268 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; 2268 params[1] = (void *)[self getRowData:(int)[self selectedRow]];
2269 2269
2270 _event_handler(self, (NSEvent *)params, 9); 2270 _event_handler(self, (NSEvent *)params, 9);
2271 } 2271 }
2272 [super keyUp:theEvent]; 2272 [super keyUp:theEvent];
2273 } 2273 }
2274 2274
2280 _event_handler(self, (NSEvent *)index, 17); 2280 _event_handler(self, (NSEvent *)index, 17);
2281 } 2281 }
2282 -(void)selectionChanged:(id)sender 2282 -(void)selectionChanged:(id)sender
2283 { 2283 {
2284 void *params[2]; 2284 void *params[2];
2285 2285
2286 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]]; 2286 params[0] = (void *)[self getRowTitle:(int)[self selectedRow]];
2287 params[1] = (void *)[self getRowData:(int)[self selectedRow]]; 2287 params[1] = (void *)[self getRowData:(int)[self selectedRow]];
2288 2288
2289 /* Handler for container class */ 2289 /* Handler for container class */
2290 _event_handler(self, (NSEvent *)params, 12); 2290 _event_handler(self, (NSEvent *)params, 12);
2291 /* Handler for listbox class */ 2291 /* Handler for listbox class */
2292 _event_handler(self, DW_INT_TO_POINTER((int)[self selectedRow]), 11); 2292 _event_handler(self, DW_INT_TO_POINTER((int)[self selectedRow]), 11);
2293 } 2293 }
3463 if(button2) 3463 if(button2)
3464 [alert addButtonWithTitle:button2]; 3464 [alert addButtonWithTitle:button2];
3465 if(button3) 3465 if(button3)
3466 [alert addButtonWithTitle:button3]; 3466 [alert addButtonWithTitle:button3];
3467 va_end(args); 3467 va_end(args);
3468 3468
3469 #ifdef MAC_OS_X_VERSION_10_12 3469 #ifdef MAC_OS_X_VERSION_10_12
3470 if(flags & DW_MB_ERROR) 3470 if(flags & DW_MB_ERROR)
3471 [alert setAlertStyle:NSAlertStyleCritical]; 3471 [alert setAlertStyle:NSAlertStyleCritical];
3472 else if(flags & DW_MB_INFORMATION) 3472 else if(flags & DW_MB_INFORMATION)
3473 [alert setAlertStyle:NSAlertStyleInformational]; 3473 [alert setAlertStyle:NSAlertStyleInformational];
3481 else 3481 else
3482 [alert setAlertStyle:NSWarningAlertStyle]; 3482 [alert setAlertStyle:NSWarningAlertStyle];
3483 #endif 3483 #endif
3484 iResponse = [alert runModal]; 3484 iResponse = [alert runModal];
3485 [alert release]; 3485 [alert release];
3486 3486
3487 switch(iResponse) 3487 switch(iResponse)
3488 { 3488 {
3489 case NSAlertFirstButtonReturn: /* user pressed OK */ 3489 case NSAlertFirstButtonReturn: /* user pressed OK */
3490 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL) 3490 if(flags & DW_MB_YESNO || flags & DW_MB_YESNOCANCEL)
3491 { 3491 {
5420 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; 5420 [scrollview setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
5421 [scrollview setDocumentView:mle]; 5421 [scrollview setDocumentView:mle];
5422 [mle setVerticallyResizable:YES]; 5422 [mle setVerticallyResizable:YES];
5423 [mle setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable]; 5423 [mle setAutoresizingMask:NSViewWidthSizable|NSViewHeightSizable];
5424 [mle setScrollview:scrollview]; 5424 [mle setScrollview:scrollview];
5425 [mle setAutomaticQuoteSubstitutionEnabled:NO];
5426 [mle setAutomaticDashSubstitutionEnabled:NO];
5427 [mle setAutomaticTextReplacementEnabled:NO];
5425 /* [mle setTag:cid]; Why doesn't this work? */ 5428 /* [mle setTag:cid]; Why doesn't this work? */
5426 [mle autorelease]; 5429 [mle autorelease];
5427 return mle; 5430 return mle;
5428 } 5431 }
5429 5432
7235 DW_LOCAL_POOL_IN; 7238 DW_LOCAL_POOL_IN;
7236 DW_MUTEX_LOCK; 7239 DW_MUTEX_LOCK;
7237 DWContainer *cont = handle; 7240 DWContainer *cont = handle;
7238 void *thisdata; 7241 void *thisdata;
7239 int x, count = (int)[cont numberOfRowsInTableView:cont]; 7242 int x, count = (int)[cont numberOfRowsInTableView:cont];
7240 7243
7241 for(x=0;x<count;x++) 7244 for(x=0;x<count;x++)
7242 { 7245 {
7243 thisdata = [cont getRowData:x]; 7246 thisdata = [cont getRowData:x];
7244 7247
7245 if(thisdata == data) 7248 if(thisdata == data)
7246 { 7249 {
7247 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x]; 7250 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)x];
7248 7251
7249 [cont selectRowIndexes:selected byExtendingSelection:YES]; 7252 [cont selectRowIndexes:selected byExtendingSelection:YES];
7250 [selected release]; 7253 [selected release];
7251 [cont scrollRowToVisible:x]; 7254 [cont scrollRowToVisible:x];
7252 DW_MUTEX_UNLOCK; 7255 DW_MUTEX_UNLOCK;
7253 DW_LOCAL_POOL_OUT; 7256 DW_LOCAL_POOL_OUT;
7298 int _locked_by_me = FALSE; 7301 int _locked_by_me = FALSE;
7299 DW_MUTEX_LOCK; 7302 DW_MUTEX_LOCK;
7300 DWContainer *cont = handle; 7303 DWContainer *cont = handle;
7301 void *thisdata; 7304 void *thisdata;
7302 int x, count = (int)[cont numberOfRowsInTableView:cont]; 7305 int x, count = (int)[cont numberOfRowsInTableView:cont];
7303 7306
7304 for(x=0;x<count;x++) 7307 for(x=0;x<count;x++)
7305 { 7308 {
7306 thisdata = [cont getRowData:x]; 7309 thisdata = [cont getRowData:x];
7307 7310
7308 if(thisdata == data) 7311 if(thisdata == data)
7309 { 7312 {
7310 [cont removeRow:x]; 7313 [cont removeRow:x];
7311 [cont reloadData]; 7314 [cont reloadData];
7312 DW_MUTEX_UNLOCK; 7315 DW_MUTEX_UNLOCK;
7952 return DW_ERROR_GENERAL; 7955 return DW_ERROR_GENERAL;
7953 } 7956 }
7954 7957
7955 bltinfo = calloc(1, sizeof(DWBitBlt)); 7958 bltinfo = calloc(1, sizeof(DWBitBlt));
7956 bi = [NSValue valueWithPointer:bltinfo]; 7959 bi = [NSValue valueWithPointer:bltinfo];
7957 7960
7958 /* Fill in the information */ 7961 /* Fill in the information */
7959 bltinfo->dest = dest; 7962 bltinfo->dest = dest;
7960 bltinfo->src = src; 7963 bltinfo->src = src;
7961 bltinfo->xdest = xdest; 7964 bltinfo->xdest = xdest;
7962 bltinfo->ydest = ydest; 7965 bltinfo->ydest = ydest;
8014 NSDate *date; 8017 NSDate *date;
8015 char buffer[101]; 8018 char buffer[101];
8016 DW_LOCAL_POOL_IN; 8019 DW_LOCAL_POOL_IN;
8017 8020
8018 snprintf(buffer, 100, "%04d-%02d-%02d", year, month, day); 8021 snprintf(buffer, 100, "%04d-%02d-%02d", year, month, day);
8019 8022
8020 NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease]; 8023 NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
8021 dateFormatter.dateFormat = @"yyyy-mm-dd"; 8024 dateFormatter.dateFormat = @"yyyy-mm-dd";
8022 8025
8023 date = [dateFormatter dateFromString:[NSString stringWithUTF8String:buffer]]; 8026 date = [dateFormatter dateFromString:[NSString stringWithUTF8String:buffer]];
8024 [calendar setDateValue:date]; 8027 [calendar setDateValue:date];
8025 [date release]; 8028 [date release];
8026 DW_LOCAL_POOL_OUT; 8029 DW_LOCAL_POOL_OUT;
8027 } 8030 }
8208 * 10.6 and earlier since convertRectFromScreen was introduced in 10.7. 8211 * 10.6 and earlier since convertRectFromScreen was introduced in 10.7.
8209 */ 8212 */
8210 NSPoint _windowPointFromScreen(id window, NSPoint p) 8213 NSPoint _windowPointFromScreen(id window, NSPoint p)
8211 { 8214 {
8212 SEL crfs = NSSelectorFromString(@"convertRectFromScreen:"); 8215 SEL crfs = NSSelectorFromString(@"convertRectFromScreen:");
8213 8216
8214 if([window respondsToSelector:crfs]) 8217 if([window respondsToSelector:crfs])
8215 { 8218 {
8216 NSRect (* icrfs)(id, SEL, NSRect) = (NSRect (*)(id, SEL, NSRect))[window methodForSelector:crfs]; 8219 NSRect (* icrfs)(id, SEL, NSRect) = (NSRect (*)(id, SEL, NSRect))[window methodForSelector:crfs];
8217 NSRect rect = icrfs(window, crfs, NSMakeRect(p.x, p.y, 1, 1)); 8220 NSRect rect = icrfs(window, crfs, NSMakeRect(p.x, p.y, 1, 1));
8218 return rect.origin; 8221 return rect.origin;
8219 } 8222 }
8220 else 8223 else
8221 { 8224 {
8222 SEL cstb = NSSelectorFromString(@"convertScreenToBase:"); 8225 SEL cstb = NSSelectorFromString(@"convertScreenToBase:");
8223 8226
8224 if([window respondsToSelector:cstb]) 8227 if([window respondsToSelector:cstb])
8225 { 8228 {
8226 NSPoint (* icstb)(id, SEL, NSPoint) = (NSPoint (*)(id, SEL, NSPoint))[window methodForSelector:cstb]; 8229 NSPoint (* icstb)(id, SEL, NSPoint) = (NSPoint (*)(id, SEL, NSPoint))[window methodForSelector:cstb];
8227 return icstb(window, cstb, p); 8230 return icstb(window, cstb, p);
8228 } 8231 }
9487 * NULL if you use the id param) 9490 * NULL if you use the id param)
9488 */ 9491 */
9489 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, char *data, int len) 9492 void API dw_window_set_bitmap_from_data(HWND handle, unsigned long cid, char *data, int len)
9490 { 9493 {
9491 id object = handle; 9494 id object = handle;
9492 9495
9493 if([ object isKindOfClass:[ NSImageView class ] ] || [ object isKindOfClass:[ NSButton class ]]) 9496 if([ object isKindOfClass:[ NSImageView class ] ] || [ object isKindOfClass:[ NSButton class ]])
9494 { 9497 {
9495 if(data) 9498 if(data)
9496 { 9499 {
9497 DW_LOCAL_POOL_IN; 9500 DW_LOCAL_POOL_IN;
9535 DW_LOCAL_POOL_IN; 9538 DW_LOCAL_POOL_IN;
9536 9539
9537 if([ object isKindOfClass:[ NSImageView class ] ] || [ object isKindOfClass:[ NSButton class ]]) 9540 if([ object isKindOfClass:[ NSImageView class ] ] || [ object isKindOfClass:[ NSButton class ]])
9538 { 9541 {
9539 NSImage *bitmap = nil; 9542 NSImage *bitmap = nil;
9540 9543
9541 if(filename) 9544 if(filename)
9542 { 9545 {
9543 char *ext = _dw_get_image_extension( filename ); 9546 char *ext = _dw_get_image_extension( filename );
9544 NSString *nstr = [ NSString stringWithUTF8String:filename ]; 9547 NSString *nstr = [ NSString stringWithUTF8String:filename ];
9545 9548
9546 bitmap = [[[NSImage alloc] initWithContentsOfFile:nstr] autorelease]; 9549 bitmap = [[[NSImage alloc] initWithContentsOfFile:nstr] autorelease];
9547 9550
9548 if(!bitmap && ext) 9551 if(!bitmap && ext)
9549 { 9552 {
9550 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]]; 9553 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
9551 bitmap = [[[NSImage alloc] initWithContentsOfFile:nstr] autorelease]; 9554 bitmap = [[[NSImage alloc] initWithContentsOfFile:nstr] autorelease];
9552 } 9555 }
9557 } 9560 }
9558 9561
9559 if(bitmap) 9562 if(bitmap)
9560 { 9563 {
9561 [object setImage:bitmap]; 9564 [object setImage:bitmap];
9562 9565
9563 /* If we changed the bitmap... */ 9566 /* If we changed the bitmap... */
9564 Item *item = _box_item(handle); 9567 Item *item = _box_item(handle);
9565 9568
9566 /* Check to see if any of the sizes need to be recalculated */ 9569 /* Check to see if any of the sizes need to be recalculated */
9567 if(item && (item->origwidth == -1 || item->origheight == -1)) 9570 if(item && (item->origwidth == -1 || item->origheight == -1))
9568 { 9571 {
9569 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL); 9572 _control_size(handle, item->origwidth == -1 ? &item->width : NULL, item->origheight == -1 ? &item->height : NULL);
9570 /* Queue a redraw on the top-level window */ 9573 /* Queue a redraw on the top-level window */
10249 * data: User data to be passed to the handler function. 10252 * data: User data to be passed to the handler function.
10250 */ 10253 */
10251 void API dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data) 10254 void API dw_signal_connect_data(HWND window, char *signame, void *sigfunc, void *discfunc, void *data)
10252 { 10255 {
10253 ULONG message = 0, msgid = 0; 10256 ULONG message = 0, msgid = 0;
10254 10257
10255 /* Handle special case of application delete signal */ 10258 /* Handle special case of application delete signal */
10256 if(!window && signame && strcmp(signame, DW_SIGNAL_DELETE) == 0) 10259 if(!window && signame && strcmp(signame, DW_SIGNAL_DELETE) == 0)
10257 { 10260 {
10258 window = DWApp; 10261 window = DWApp;
10259 } 10262 }
10283 while(tmp) 10286 while(tmp)
10284 { 10287 {
10285 if(tmp->window == window && tmp->message == message) 10288 if(tmp->window == window && tmp->message == message)
10286 { 10289 {
10287 void (*discfunc)(HWND, void *) = tmp->discfunction; 10290 void (*discfunc)(HWND, void *) = tmp->discfunction;
10288 10291
10289 if(discfunc) 10292 if(discfunc)
10290 { 10293 {
10291 discfunc(tmp->window, tmp->data); 10294 discfunc(tmp->window, tmp->data);
10292 } 10295 }
10293 10296
10294 if(prev) 10297 if(prev)
10295 { 10298 {
10296 prev->next = tmp->next; 10299 prev->next = tmp->next;
10297 free(tmp); 10300 free(tmp);
10298 tmp = prev->next; 10301 tmp = prev->next;
10324 while(tmp) 10327 while(tmp)
10325 { 10328 {
10326 if(tmp->window == window) 10329 if(tmp->window == window)
10327 { 10330 {
10328 void (*discfunc)(HWND, void *) = tmp->discfunction; 10331 void (*discfunc)(HWND, void *) = tmp->discfunction;
10329 10332
10330 if(discfunc) 10333 if(discfunc)
10331 { 10334 {
10332 discfunc(tmp->window, tmp->data); 10335 discfunc(tmp->window, tmp->data);
10333 } 10336 }
10334 10337
10335 if(prev) 10338 if(prev)
10336 { 10339 {
10337 prev->next = tmp->next; 10340 prev->next = tmp->next;
10338 free(tmp); 10341 free(tmp);
10339 tmp = prev->next; 10342 tmp = prev->next;
10366 while(tmp) 10369 while(tmp)
10367 { 10370 {
10368 if(tmp->window == window && tmp->data == data) 10371 if(tmp->window == window && tmp->data == data)
10369 { 10372 {
10370 void (*discfunc)(HWND, void *) = tmp->discfunction; 10373 void (*discfunc)(HWND, void *) = tmp->discfunction;
10371 10374
10372 if(discfunc) 10375 if(discfunc)
10373 { 10376 {
10374 discfunc(tmp->window, tmp->data); 10377 discfunc(tmp->window, tmp->data);
10375 } 10378 }
10376 10379
10377 if(prev) 10380 if(prev)
10378 { 10381 {
10379 prev->next = tmp->next; 10382 prev->next = tmp->next;
10380 free(tmp); 10383 free(tmp);
10381 tmp = prev->next; 10384 tmp = prev->next;
11047 pool = [[NSAutoreleasePool alloc] init]; 11050 pool = [[NSAutoreleasePool alloc] init];
11048 pthread_setspecific(_dw_pool_key, pool); 11051 pthread_setspecific(_dw_pool_key, pool);
11049 #endif 11052 #endif
11050 } 11053 }
11051 11054
11052 /* 11055 /*
11053 * Generally an internal function called from a newly created 11056 * Generally an internal function called from a newly created
11054 * thread to setup the Dynamic Windows environment for the thread. 11057 * thread to setup the Dynamic Windows environment for the thread.
11055 * However it is exported so language bindings can call it when 11058 * However it is exported so language bindings can call it when
11056 * they create threads that require access to Dynamic Windows. 11059 * they create threads that require access to Dynamic Windows.
11057 */ 11060 */
11063 pthread_setspecific(_dw_pool_key, pool); 11066 pthread_setspecific(_dw_pool_key, pool);
11064 #endif 11067 #endif
11065 _init_colors(); 11068 _init_colors();
11066 } 11069 }
11067 11070
11068 /* 11071 /*
11069 * Generally an internal function called from a terminating 11072 * Generally an internal function called from a terminating
11070 * thread to cleanup the Dynamic Windows environment for the thread. 11073 * thread to cleanup the Dynamic Windows environment for the thread.
11071 * However it is exported so language bindings can call it when 11074 * However it is exported so language bindings can call it when
11072 * they exit threads that require access to Dynamic Windows. 11075 * they exit threads that require access to Dynamic Windows.
11073 */ 11076 */
11074 void API _dw_deinit_thread(void) 11077 void API _dw_deinit_thread(void)
11075 { 11078 {
11076 NSColor *color; 11079 NSColor *color;
11077 11080
11078 /* Release the pool when we are done so we don't leak */ 11081 /* Release the pool when we are done so we don't leak */
11079 color = pthread_getspecific(_dw_fg_color_key); 11082 color = pthread_getspecific(_dw_fg_color_key);
11080 [color release]; 11083 [color release];
11081 color = pthread_getspecific(_dw_bg_color_key); 11084 color = pthread_getspecific(_dw_bg_color_key);
11082 [color release]; 11085 [color release];
11093 { 11096 {
11094 void (*threadfunc)(void *) = NULL; 11097 void (*threadfunc)(void *) = NULL;
11095 void **tmp = (void **)data; 11098 void **tmp = (void **)data;
11096 11099
11097 _dw_init_thread(); 11100 _dw_init_thread();
11098 11101
11099 threadfunc = (void (*)(void *))tmp[0]; 11102 threadfunc = (void (*)(void *))tmp[0];
11100 11103
11101 /* Start our thread function */ 11104 /* Start our thread function */
11102 threadfunc(tmp[1]); 11105 threadfunc(tmp[1]);
11103 11106
11104 free(tmp); 11107 free(tmp);
11105 11108
11106 _dw_deinit_thread(); 11109 _dw_deinit_thread();
11107 } 11110 }
11108 11111
11109 /* 11112 /*
11110 * Sets the default font used on text based widgets. 11113 * Sets the default font used on text based widgets.