comparison mac/dw.m @ 938:cfcf66a90e8c

Add support for different image file types in dw_*_from_file() functions. Supported types are: png, ico, icns, gif, jpg, jpeg, tiff, bmp
author mhessling@81767d24-ef19-dc11-ae90-00e081727c95
date Wed, 27 Apr 2011 07:56:50 +0000
parents 83aceaaef6ed
children 0ba3003272a1
comparison
equal deleted inserted replaced
937:83aceaaef6ed 938:cfcf66a90e8c
59 0x00eeee00, /* 14 bright cyan */ 59 0x00eeee00, /* 14 bright cyan */
60 0x00ffffff, /* 15 bright white */ 60 0x00ffffff, /* 15 bright white */
61 0xff000000 /* 16 default color */ 61 0xff000000 /* 16 default color */
62 }; 62 };
63 63
64 /*
65 * List those icons that have transparency first
66 */
67 #define NUM_EXTS 8
68 char *image_exts[NUM_EXTS] =
69 {
70 ".png",
71 ".ico",
72 ".icns",
73 ".gif",
74 ".jpg",
75 ".jpeg",
76 ".tiff",
77 ".bmp"
78 };
79
80 char *_dw_get_image_extension( char *filename )
81 {
82 char *file = alloca(strlen(filename) + 6);
83 int found_ext = 0,i;
84
85 /* Try various extentions */
86 for ( i = 0; i < NUM_EXTS; i++ )
87 {
88 strcpy( file, filename );
89 strcat( file, image_exts[i] );
90 if ( access( file, R_OK ) == 0 )
91 {
92 found_ext = 1;
93 break;
94 }
95 }
96 if ( found_ext == 1 )
97 {
98 return image_exts[found_ext];
99 }
100 return NULL;
101 }
102
64 unsigned long _get_color(unsigned long thiscolor) 103 unsigned long _get_color(unsigned long thiscolor)
65 { 104 {
66 if(thiscolor & DW_RGB_COLOR) 105 if(thiscolor & DW_RGB_COLOR)
67 { 106 {
68 return thiscolor & ~DW_RGB_COLOR; 107 return thiscolor & ~DW_RGB_COLOR;
83 122
84 /* Create a default colors for a thread */ 123 /* Create a default colors for a thread */
85 void _init_colors(void) 124 void _init_colors(void)
86 { 125 {
87 NSColor *fgcolor = [[NSColor grayColor] retain]; 126 NSColor *fgcolor = [[NSColor grayColor] retain];
88 127
89 pthread_setspecific(_dw_fg_color_key, fgcolor); 128 pthread_setspecific(_dw_fg_color_key, fgcolor);
90 pthread_setspecific(_dw_bg_color_key, NULL); 129 pthread_setspecific(_dw_bg_color_key, NULL);
91 } 130 }
92 131
93 typedef struct _sighandler 132 typedef struct _sighandler
110 int _dw_main_iteration(NSDate *date); 149 int _dw_main_iteration(NSDate *date);
111 150
112 SignalHandler *_get_handler(HWND window, int messageid) 151 SignalHandler *_get_handler(HWND window, int messageid)
113 { 152 {
114 SignalHandler *tmp = Root; 153 SignalHandler *tmp = Root;
115 154
116 /* Find any callbacks for this function */ 155 /* Find any callbacks for this function */
117 while(tmp) 156 while(tmp)
118 { 157 {
119 if(tmp->message == messageid && window == tmp->window) 158 if(tmp->message == messageid && window == tmp->window)
120 { 159 {
222 { 261 {
223 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 262 int (* API buttonfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
224 NSPoint p = [object convertPoint:[event locationInWindow] fromView:nil]; 263 NSPoint p = [object convertPoint:[event locationInWindow] fromView:nil];
225 NSEventType type = [event type]; 264 NSEventType type = [event type];
226 int button = 1; 265 int button = 1;
227 266
228 if(type == NSRightMouseDown || type == NSRightMouseUp) 267 if(type == NSRightMouseDown || type == NSRightMouseUp)
229 { 268 {
230 button = 2; 269 button = 2;
231 } 270 }
232 else if(type == NSOtherMouseDown || type == NSOtherMouseUp) 271 else if(type == NSOtherMouseDown || type == NSOtherMouseUp)
240 case 5: 279 case 5:
241 { 280 {
242 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction; 281 int (* API motionfunc)(HWND, int, int, int, void *) = (int (* API)(HWND, int, int, int, void *))handler->signalfunction;
243 int buttonmask = (int)[NSEvent pressedMouseButtons]; 282 int buttonmask = (int)[NSEvent pressedMouseButtons];
244 NSPoint point = [object convertPoint:[event locationInWindow] fromView:nil]; 283 NSPoint point = [object convertPoint:[event locationInWindow] fromView:nil];
245 284
246 return motionfunc(object, (int)point.x, (int)point.y, buttonmask, handler->data); 285 return motionfunc(object, (int)point.x, (int)point.y, buttonmask, handler->data);
247 } 286 }
248 /* Window close event */ 287 /* Window close event */
249 case 6: 288 case 6:
250 { 289 {
356 } 395 }
357 case 17: 396 case 17:
358 { 397 {
359 int (*clickcolumnfunc)(HWND, int, void *) = handler->signalfunction; 398 int (*clickcolumnfunc)(HWND, int, void *) = handler->signalfunction;
360 int column_num = (int)event; 399 int column_num = (int)event;
361 400
362 return clickcolumnfunc(handler->window, column_num, handler->data); 401 return clickcolumnfunc(handler->window, column_num, handler->data);
363 } 402 }
364 } 403 }
365 } 404 }
366 return -1; 405 return -1;
430 469
431 if([bltdest isMemberOfClass:[NSBitmapImageRep class]]) 470 if([bltdest isMemberOfClass:[NSBitmapImageRep class]])
432 { 471 {
433 [NSGraphicsContext saveGraphicsState]; 472 [NSGraphicsContext saveGraphicsState];
434 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 473 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
435 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:bltdest] graphicsPort] flipped:YES]]; 474 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:bltdest] graphicsPort] flipped:YES]];
436 [[NSDictionary alloc] initWithObjectsAndKeys:bltdest, NSGraphicsContextDestinationAttributeName, nil]; 475 [[NSDictionary alloc] initWithObjectsAndKeys:bltdest, NSGraphicsContextDestinationAttributeName, nil];
437 } 476 }
438 else 477 else
439 { 478 {
440 if([bltdest lockFocusIfCanDraw] == NO) 479 if([bltdest lockFocusIfCanDraw] == NO)
446 } 485 }
447 if([bltsrc isMemberOfClass:[NSBitmapImageRep class]]) 486 if([bltsrc isMemberOfClass:[NSBitmapImageRep class]])
448 { 487 {
449 NSBitmapImageRep *rep = bltsrc; 488 NSBitmapImageRep *rep = bltsrc;
450 NSImage *image; 489 NSImage *image;
451 490
452 if(DWOSMinor > 5) 491 if(DWOSMinor > 5)
453 { 492 {
454 image = [[NSImage alloc] initWithCGImage:[rep CGImage] size:NSZeroSize]; 493 image = [[NSImage alloc] initWithCGImage:[rep CGImage] size:NSZeroSize];
455 } 494 }
456 else 495 else
458 image = [[NSImage alloc] initWithSize:[rep size]]; 497 image = [[NSImage alloc] initWithSize:[rep size]];
459 [image addRepresentation:rep]; 498 [image addRepresentation:rep];
460 } 499 }
461 // make a new transform: 500 // make a new transform:
462 NSAffineTransform *t = [NSAffineTransform transform]; 501 NSAffineTransform *t = [NSAffineTransform transform];
463 502
464 // by scaling Y negatively, we effectively flip the image: 503 // by scaling Y negatively, we effectively flip the image:
465 [t scaleXBy:1.0 yBy:-1.0]; 504 [t scaleXBy:1.0 yBy:-1.0];
466 505
467 // but we also have to translate it back by its height: 506 // but we also have to translate it back by its height:
468 [t translateXBy:0.0 yBy:-[rep size].height]; 507 [t translateXBy:0.0 yBy:-[rep size].height];
469 508
470 // apply the transform: 509 // apply the transform:
471 [t concat]; 510 [t concat];
472 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height) 511 [image drawAtPoint:NSMakePoint(bltinfo->xdest, bltinfo->ydest) fromRect:NSMakeRect(bltinfo->xsrc, bltinfo->ysrc, bltinfo->width, bltinfo->height)
473 operation:NSCompositeCopy fraction:1.0]; 512 operation:NSCompositeCopy fraction:1.0];
474 [bltsrc release]; 513 [bltsrc release];
475 [image release]; 514 [image release];
476 } 515 }
601 [orig release]; 640 [orig release];
602 } 641 }
603 @end 642 @end
604 643
605 /* Subclass for a group box type */ 644 /* Subclass for a group box type */
606 @interface DWGroupBox : NSBox 645 @interface DWGroupBox : NSBox
607 { 646 {
608 void *userdata; 647 void *userdata;
609 NSColor *bgcolor; 648 NSColor *bgcolor;
610 NSSize borderSize; 649 NSSize borderSize;
611 } 650 }
616 655
617 @implementation DWGroupBox 656 @implementation DWGroupBox
618 -(Box *)box { return [[self contentView] box]; } 657 -(Box *)box { return [[self contentView] box]; }
619 -(void *)userdata { return userdata; } 658 -(void *)userdata { return userdata; }
620 -(NSSize)borderSize { return borderSize; } 659 -(NSSize)borderSize { return borderSize; }
621 -(NSSize)initBorder 660 -(NSSize)initBorder
622 { 661 {
623 NSSize frameSize = [self frame].size; 662 NSSize frameSize = [self frame].size;
624 663
625 if(frameSize.height < 20 || frameSize.width < 20) 664 if(frameSize.height < 20 || frameSize.width < 20)
626 { 665 {
627 frameSize.width = frameSize.height = 100; 666 frameSize.width = frameSize.height = 100;
628 [self setFrameSize:frameSize]; 667 [self setFrameSize:frameSize];
629 } 668 }
630 NSSize contentSize = [[self contentView] frame].size; 669 NSSize contentSize = [[self contentView] frame].size;
631 NSSize titleSize = [self titleRect].size; 670 NSSize titleSize = [self titleRect].size;
632 671
633 borderSize.width = 100-contentSize.width; 672 borderSize.width = 100-contentSize.width;
634 borderSize.height = (100-contentSize.height)-titleSize.height; 673 borderSize.height = (100-contentSize.height)-titleSize.height;
635 return borderSize; 674 return borderSize;
636 } 675 }
637 -(void)setUserdata:(void *)input { userdata = input; } 676 -(void)setUserdata:(void *)input { userdata = input; }
687 [super dealloc]; 726 [super dealloc];
688 } 727 }
689 - (void)windowResized:(NSNotification *)notification; 728 - (void)windowResized:(NSNotification *)notification;
690 { 729 {
691 NSSize size = [self frame].size; 730 NSSize size = [self frame].size;
692 731
693 if(oldsize.width != size.width || oldsize.height != size.height) 732 if(oldsize.width != size.width || oldsize.height != size.height)
694 { 733 {
695 _do_resize(box, size.width, size.height); 734 _do_resize(box, size.width, size.height);
696 _event_handler([self window], nil, 1); 735 _event_handler([self window], nil, 1);
697 oldsize.width = size.width; 736 oldsize.width = size.width;
700 } 739 }
701 } 740 }
702 -(void)showWindow 741 -(void)showWindow
703 { 742 {
704 NSSize size = [self frame].size; 743 NSSize size = [self frame].size;
705 744
706 if(oldsize.width == size.width && oldsize.height == size.height) 745 if(oldsize.width == size.width && oldsize.height == size.height)
707 { 746 {
708 _do_resize(box, size.width, size.height); 747 _do_resize(box, size.width, size.height);
709 _handle_resize_events(box); 748 _handle_resize_events(box);
710 } 749 }
711 750
712 } 751 }
713 -(void)windowDidBecomeMain:(id)sender 752 -(void)windowDidBecomeMain:(id)sender
714 { 753 {
715 if(windowmenu) 754 if(windowmenu)
716 { 755 {
744 @end 783 @end
745 784
746 @implementation DWButton 785 @implementation DWButton
747 -(void *)userdata { return userdata; } 786 -(void *)userdata { return userdata; }
748 -(void)setUserdata:(void *)input { userdata = input; } 787 -(void)setUserdata:(void *)input { userdata = input; }
749 -(void)buttonClicked:(id)sender 788 -(void)buttonClicked:(id)sender
750 { 789 {
751 _event_handler(self, nil, 8); 790 _event_handler(self, nil, 8);
752 if([self buttonType] == NSRadioButton) 791 if([self buttonType] == NSRadioButton)
753 { 792 {
754 DWBox *viewbox = [self parent]; 793 DWBox *viewbox = [self parent];
755 Box *thisbox = [viewbox box]; 794 Box *thisbox = [viewbox box];
756 int z; 795 int z;
757 796
758 for(z=0;z<thisbox->count;z++) 797 for(z=0;z<thisbox->count;z++)
759 { 798 {
760 if(thisbox->items[z].type != TYPEBOX) 799 if(thisbox->items[z].type != TYPEBOX)
761 { 800 {
762 id object = thisbox->items[z].hwnd; 801 id object = thisbox->items[z].hwnd;
763 802
764 if([object isMemberOfClass:[DWButton class]]) 803 if([object isMemberOfClass:[DWButton class]])
765 { 804 {
766 DWButton *button = object; 805 DWButton *button = object;
767 806
768 if(button != self && [button buttonType] == NSRadioButton) 807 if(button != self && [button buttonType] == NSRadioButton)
769 { 808 {
770 [button setState:NSOffState]; 809 [button setState:NSOffState];
771 } 810 }
772 } 811 }
828 @implementation DWTextFieldCell 867 @implementation DWTextFieldCell
829 -(NSRect)drawingRectForBounds:(NSRect)theRect 868 -(NSRect)drawingRectForBounds:(NSRect)theRect
830 { 869 {
831 /* Get the parent's idea of where we should draw */ 870 /* Get the parent's idea of where we should draw */
832 NSRect newRect = [super drawingRectForBounds:theRect]; 871 NSRect newRect = [super drawingRectForBounds:theRect];
833 872
834 /* If we are being vertically centered */ 873 /* If we are being vertically centered */
835 if(vcenter) 874 if(vcenter)
836 { 875 {
837 /* Get our ideal size for current text */ 876 /* Get our ideal size for current text */
838 NSSize textSize = [self cellSizeForBounds:theRect]; 877 NSSize textSize = [self cellSizeForBounds:theRect];
839 878
840 /* Center that in the proposed rect */ 879 /* Center that in the proposed rect */
841 float heightDelta = newRect.size.height - textSize.height; 880 float heightDelta = newRect.size.height - textSize.height;
842 if (heightDelta > 0) 881 if (heightDelta > 0)
843 { 882 {
844 newRect.size.height -= heightDelta; 883 newRect.size.height -= heightDelta;
849 return newRect; 888 return newRect;
850 } 889 }
851 -(void)setVCenter:(BOOL)input { vcenter = input; } 890 -(void)setVCenter:(BOOL)input { vcenter = input; }
852 @end 891 @end
853 892
854 @interface DWEntryFieldFormatter : NSFormatter 893 @interface DWEntryFieldFormatter : NSFormatter
855 { 894 {
856 int maxLength; 895 int maxLength;
857 } 896 }
858 - (void)setMaximumLength:(int)len; 897 - (void)setMaximumLength:(int)len;
859 - (int)maximumLength; 898 - (int)maximumLength;
860 @end 899 @end
861 900
862 /* This formatter subclass will allow us to limit 901 /* This formatter subclass will allow us to limit
863 * the text length in an entryfield. 902 * the text length in an entryfield.
864 */ 903 */
865 @implementation DWEntryFieldFormatter 904 @implementation DWEntryFieldFormatter
866 -(id)init 905 -(id)init
867 { 906 {
868 [super init]; 907 [super init];
869 maxLength = INT_MAX; 908 maxLength = INT_MAX;
870 return self; 909 return self;
871 } 910 }
875 -(BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error { *object = string; return YES; } 914 -(BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error { *object = string; return YES; }
876 -(BOOL)isPartialStringValid:(NSString **)partialStringPtr 915 -(BOOL)isPartialStringValid:(NSString **)partialStringPtr
877 proposedSelectedRange:(NSRangePointer)proposedSelRangePtr 916 proposedSelectedRange:(NSRangePointer)proposedSelRangePtr
878 originalString:(NSString *)origString 917 originalString:(NSString *)origString
879 originalSelectedRange:(NSRange)origSelRange 918 originalSelectedRange:(NSRange)origSelRange
880 errorDescription:(NSString **)error 919 errorDescription:(NSString **)error
881 { 920 {
882 if([*partialStringPtr length] > maxLength) 921 if([*partialStringPtr length] > maxLength)
883 { 922 {
884 return NO; 923 return NO;
885 } 924 }
886 return YES; 925 return YES;
887 } 926 }
901 940
902 @implementation DWEntryField 941 @implementation DWEntryField
903 -(void *)userdata { return userdata; } 942 -(void *)userdata { return userdata; }
904 -(void)setUserdata:(void *)input { userdata = input; } 943 -(void)setUserdata:(void *)input { userdata = input; }
905 -(void)setClickDefault:(id)input { clickDefault = input; } 944 -(void)setClickDefault:(id)input { clickDefault = input; }
906 -(void)keyUp:(NSEvent *)theEvent 945 -(void)keyUp:(NSEvent *)theEvent
907 { 946 {
908 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0]; 947 unichar vk = [[theEvent charactersIgnoringModifiers] characterAtIndex:0];
909 if(clickDefault && vk == VK_RETURN) 948 if(clickDefault && vk == VK_RETURN)
910 { 949 {
911 [[self window] makeFirstResponder:clickDefault]; 950 [[self window] makeFirstResponder:clickDefault];
912 } else 951 } else
913 { 952 {
914 [super keyUp:theEvent]; 953 [super keyUp:theEvent];
915 } 954 }
916 } 955 }
917 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } 956 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; }
918 @end 957 @end
919 958
920 /* Subclass for a entryfield password type */ 959 /* Subclass for a entryfield password type */
930 969
931 @implementation DWEntryFieldPassword 970 @implementation DWEntryFieldPassword
932 -(void *)userdata { return userdata; } 971 -(void *)userdata { return userdata; }
933 -(void)setUserdata:(void *)input { userdata = input; } 972 -(void)setUserdata:(void *)input { userdata = input; }
934 -(void)setClickDefault:(id)input { clickDefault = input; } 973 -(void)setClickDefault:(id)input { clickDefault = input; }
935 -(void)keyUp:(NSEvent *)theEvent 974 -(void)keyUp:(NSEvent *)theEvent
936 { 975 {
937 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 976 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
938 { 977 {
939 [[self window] makeFirstResponder:clickDefault]; 978 [[self window] makeFirstResponder:clickDefault];
940 } else 979 } else
941 { 980 {
942 [super keyUp:theEvent]; 981 [super keyUp:theEvent];
943 } 982 }
944 } 983 }
945 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } 984 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; }
946 @end 985 @end
947 986
948 /* Subclass for a Notebook control type */ 987 /* Subclass for a Notebook control type */
1104 -(void)scrollerChanged:(id)sender 1143 -(void)scrollerChanged:(id)sender
1105 { 1144 {
1106 double max = (range - visible); 1145 double max = (range - visible);
1107 double result = ([self doubleValue] * max); 1146 double result = ([self doubleValue] * max);
1108 double newpos = result; 1147 double newpos = result;
1109 1148
1110 switch ([sender hitPart]) 1149 switch ([sender hitPart])
1111 { 1150 {
1112 1151
1113 case NSScrollerDecrementLine: 1152 case NSScrollerDecrementLine:
1114 if(newpos > 0) 1153 if(newpos > 0)
1422 if(tvcols) 1461 if(tvcols)
1423 { 1462 {
1424 int z; 1463 int z;
1425 int colcount = (int)[tvcols count]; 1464 int colcount = (int)[tvcols count];
1426 int rowcount = (int)[self numberOfRowsInTableView:self]; 1465 int rowcount = (int)[self numberOfRowsInTableView:self];
1427 1466
1428 for(z=0;z<colcount;z++) 1467 for(z=0;z<colcount;z++)
1429 { 1468 {
1430 NSTableColumn *column = [tvcols objectAtIndex:z]; 1469 NSTableColumn *column = [tvcols objectAtIndex:z];
1431 if([column resizingMask] != NSTableColumnNoResizing) 1470 if([column resizingMask] != NSTableColumnNoResizing)
1432 { 1471 {
1433 if(rowcount > 0) 1472 if(rowcount > 0)
1434 { 1473 {
1435 int x; 1474 int x;
1436 int width = 0; 1475 int width = 0;
1437 1476
1438 for(x=0;x<rowcount;x++) 1477 for(x=0;x<rowcount;x++)
1439 { 1478 {
1440 NSCell *cell = [self preparedCellAtColumn:z row:x]; 1479 NSCell *cell = [self preparedCellAtColumn:z row:x];
1441 int thiswidth = [cell cellSize].width; 1480 int thiswidth = [cell cellSize].width;
1442 1481
1443 /* Check the image inside the cell to get its width */ 1482 /* Check the image inside the cell to get its width */
1444 if([cell isMemberOfClass:[NSImageCell class]]) 1483 if([cell isMemberOfClass:[NSImageCell class]])
1445 { 1484 {
1446 int index = (int)(x * [tvcols count]) + z; 1485 int index = (int)(x * [tvcols count]) + z;
1447 NSImage *image = [data objectAtIndex:index]; 1486 NSImage *image = [data objectAtIndex:index];
1448 if([image isMemberOfClass:[NSImage class]]) 1487 if([image isMemberOfClass:[NSImage class]])
1449 { 1488 {
1450 thiswidth = [image size].width; 1489 thiswidth = [image size].width;
1451 } 1490 }
1452 } 1491 }
1453 1492
1454 if(thiswidth > width) 1493 if(thiswidth > width)
1455 { 1494 {
1456 width = thiswidth; 1495 width = thiswidth;
1457 } 1496 }
1458 } 1497 }
1473 } 1512 }
1474 } 1513 }
1475 } 1514 }
1476 } 1515 }
1477 } 1516 }
1478 -(void)setForegroundColor:(NSColor *)input 1517 -(void)setForegroundColor:(NSColor *)input
1479 { 1518 {
1480 int z, count = (int)[tvcols count]; 1519 int z, count = (int)[tvcols count];
1481 1520
1482 fgcolor = input; 1521 fgcolor = input;
1483 [fgcolor retain]; 1522 [fgcolor retain];
1484 1523
1485 for(z=0;z<count;z++) 1524 for(z=0;z<count;z++)
1486 { 1525 {
1487 NSTableColumn *tableColumn = [tvcols objectAtIndex:z]; 1526 NSTableColumn *tableColumn = [tvcols objectAtIndex:z];
1488 NSTextFieldCell *cell = [tableColumn dataCell]; 1527 NSTextFieldCell *cell = [tableColumn dataCell];
1489 [cell setTextColor:fgcolor]; 1528 [cell setTextColor:fgcolor];
1492 -(void)doubleClicked:(id)sender 1531 -(void)doubleClicked:(id)sender
1493 { 1532 {
1494 /* Handler for container class */ 1533 /* Handler for container class */
1495 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); 1534 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9);
1496 } 1535 }
1497 -(void)keyUp:(NSEvent *)theEvent 1536 -(void)keyUp:(NSEvent *)theEvent
1498 { 1537 {
1499 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 1538 if([[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
1500 { 1539 {
1501 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); 1540 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9);
1502 } 1541 }
1503 [super keyUp:theEvent]; 1542 [super keyUp:theEvent];
1504 } 1543 }
1505 1544
1506 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn 1545 -(void)tableView:(NSTableView *)tableView didClickTableColumn:(NSTableColumn *)tableColumn
1507 { 1546 {
1508 NSUInteger index = [tvcols indexOfObject:tableColumn]; 1547 NSUInteger index = [tvcols indexOfObject:tableColumn];
1509 1548
1510 /* Handler for column click class */ 1549 /* Handler for column click class */
1511 _event_handler(self, (NSEvent *)index, 17); 1550 _event_handler(self, (NSEvent *)index, 17);
1512 } 1551 }
1513 -(void)selectionChanged:(id)sender 1552 -(void)selectionChanged:(id)sender
1514 { 1553 {
1732 return nil; 1771 return nil;
1733 } 1772 }
1734 -(NSScrollView *)scrollview { return scrollview; } 1773 -(NSScrollView *)scrollview { return scrollview; }
1735 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } 1774 -(void)setScrollview:(NSScrollView *)input { scrollview = input; }
1736 -(void)deleteNode:(NSPointerArray *)item { _free_tree_recurse(data, item); } 1775 -(void)deleteNode:(NSPointerArray *)item { _free_tree_recurse(data, item); }
1737 -(void)setForegroundColor:(NSColor *)input 1776 -(void)setForegroundColor:(NSColor *)input
1738 { 1777 {
1739 NSTextFieldCell *cell = [treecol dataCell]; 1778 NSTextFieldCell *cell = [treecol dataCell];
1740 fgcolor = input; 1779 fgcolor = input;
1741 [fgcolor retain]; 1780 [fgcolor retain];
1742 [cell setTextColor:fgcolor]; 1781 [cell setTextColor:fgcolor];
1743 } 1782 }
1744 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; } 1783 -(void)clear { NSMutableArray *toclear = data; data = nil; _free_tree_recurse(toclear, NULL); [self reloadData]; }
1745 -(void)dealloc 1784 -(void)dealloc
1746 { 1785 {
1785 @implementation DWComboBox 1824 @implementation DWComboBox
1786 -(void *)userdata { return userdata; } 1825 -(void *)userdata { return userdata; }
1787 -(void)setUserdata:(void *)input { userdata = input; } 1826 -(void)setUserdata:(void *)input { userdata = input; }
1788 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); } 1827 -(void)comboBoxSelectionDidChange:(NSNotification *)not { _event_handler(self, (void *)[self indexOfSelectedItem], 11); }
1789 -(void)setClickDefault:(id)input { clickDefault = input; } 1828 -(void)setClickDefault:(id)input { clickDefault = input; }
1790 -(void)keyUp:(NSEvent *)theEvent 1829 -(void)keyUp:(NSEvent *)theEvent
1791 { 1830 {
1792 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 1831 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
1793 { 1832 {
1794 [[self window] makeFirstResponder:clickDefault]; 1833 [[self window] makeFirstResponder:clickDefault];
1795 } else 1834 } else
1796 { 1835 {
1797 [super keyUp:theEvent]; 1836 [super keyUp:theEvent];
1798 } 1837 }
1799 } 1838 }
1800 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } 1839 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; }
1801 @end 1840 @end
1802 1841
1803 /* Subclass for a stepper component of the spinbutton type */ 1842 /* Subclass for a stepper component of the spinbutton type */
1883 [stepper takeIntValueFrom:textfield]; 1922 [stepper takeIntValueFrom:textfield];
1884 [textfield takeIntValueFrom:stepper]; 1923 [textfield takeIntValueFrom:stepper];
1885 _event_handler(self, (void *)[stepper integerValue], 14); 1924 _event_handler(self, (void *)[stepper integerValue], 14);
1886 } 1925 }
1887 -(void)setClickDefault:(id)input { clickDefault = input; } 1926 -(void)setClickDefault:(id)input { clickDefault = input; }
1888 -(void)keyUp:(NSEvent *)theEvent 1927 -(void)keyUp:(NSEvent *)theEvent
1889 { 1928 {
1890 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN) 1929 if(clickDefault && [[theEvent charactersIgnoringModifiers] characterAtIndex:0] == VK_RETURN)
1891 { 1930 {
1892 [[self window] makeFirstResponder:clickDefault]; 1931 [[self window] makeFirstResponder:clickDefault];
1893 } 1932 }
1894 else 1933 else
1895 { 1934 {
1896 [super keyUp:theEvent]; 1935 [super keyUp:theEvent];
1897 } 1936 }
1898 } 1937 }
1899 -(void)performClick:(id)sender { [textfield performClick:sender]; } 1938 -(void)performClick:(id)sender { [textfield performClick:sender]; }
1900 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; } 1939 -(void)dealloc { UserData *root = userdata; _remove_userdata(&root, NULL, TRUE); [super dealloc]; }
1901 @end 1940 @end
1902 1941
1965 unsigned long _foreground = 0xAAAAAA, _background = 0; 2004 unsigned long _foreground = 0xAAAAAA, _background = 0;
1966 2005
1967 void _handle_resize_events(Box *thisbox) 2006 void _handle_resize_events(Box *thisbox)
1968 { 2007 {
1969 int z; 2008 int z;
1970 2009
1971 for(z=0;z<thisbox->count;z++) 2010 for(z=0;z<thisbox->count;z++)
1972 { 2011 {
1973 id handle = thisbox->items[z].hwnd; 2012 id handle = thisbox->items[z].hwnd;
1974 2013
1975 if(thisbox->items[z].type == TYPEBOX) 2014 if(thisbox->items[z].type == TYPEBOX)
1976 { 2015 {
1977 Box *tmp = [handle box]; 2016 Box *tmp = [handle box];
1978 2017
1979 if(tmp) 2018 if(tmp)
1980 { 2019 {
1981 _handle_resize_events(tmp); 2020 _handle_resize_events(tmp);
1982 } 2021 }
1983 } 2022 }
1987 { 2026 {
1988 DWRender *render = (DWRender *)handle; 2027 DWRender *render = (DWRender *)handle;
1989 NSSize oldsize = [render size]; 2028 NSSize oldsize = [render size];
1990 NSSize newsize = [render frame].size; 2029 NSSize newsize = [render frame].size;
1991 NSWindow *window = [render window]; 2030 NSWindow *window = [render window];
1992 2031
1993 if([window preferredBackingLocation] != NSWindowBackingLocationVideoMemory) 2032 if([window preferredBackingLocation] != NSWindowBackingLocationVideoMemory)
1994 { 2033 {
1995 [window setPreferredBackingLocation:NSWindowBackingLocationVideoMemory]; 2034 [window setPreferredBackingLocation:NSWindowBackingLocationVideoMemory];
1996 } 2035 }
1997 2036
1998 /* Eliminate duplicate configure requests */ 2037 /* Eliminate duplicate configure requests */
1999 if(oldsize.width != newsize.width || oldsize.height != newsize.height) 2038 if(oldsize.width != newsize.width || oldsize.height != newsize.height)
2000 { 2039 {
2001 if(newsize.width > 0 && newsize.height > 0) 2040 if(newsize.width > 0 && newsize.height > 0)
2002 { 2041 {
2009 else if([handle isMemberOfClass:[DWNotebook class]]) 2048 else if([handle isMemberOfClass:[DWNotebook class]])
2010 { 2049 {
2011 DWNotebook *notebook = (DWNotebook *)handle; 2050 DWNotebook *notebook = (DWNotebook *)handle;
2012 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; 2051 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem];
2013 id view = [notepage view]; 2052 id view = [notepage view];
2014 2053
2015 if(view != nil) 2054 if(view != nil)
2016 { 2055 {
2017 Box *box = [view box]; 2056 Box *box = [view box];
2018 _handle_resize_events(box); 2057 _handle_resize_events(box);
2019 } 2058 }
2024 else if([handle isMemberOfClass:[DWScrollBox class]]) 2063 else if([handle isMemberOfClass:[DWScrollBox class]])
2025 { 2064 {
2026 DWScrollBox *scrollbox = (DWScrollBox *)handle; 2065 DWScrollBox *scrollbox = (DWScrollBox *)handle;
2027 DWBox *contentbox = [scrollbox documentView]; 2066 DWBox *contentbox = [scrollbox documentView];
2028 Box *thisbox = [contentbox box]; 2067 Box *thisbox = [contentbox box];
2029 2068
2030 /* Get the required space for the box */ 2069 /* Get the required space for the box */
2031 _handle_resize_events(thisbox); 2070 _handle_resize_events(thisbox);
2032 } 2071 }
2033 } 2072 }
2034 } 2073 }
2046 /* Used for the SIZEEXPAND */ 2085 /* Used for the SIZEEXPAND */
2047 int nux = *usedx, nuy = *usedy; 2086 int nux = *usedx, nuy = *usedy;
2048 int nupx = *usedpadx, nupy = *usedpady; 2087 int nupx = *usedpadx, nupy = *usedpady;
2049 int thispadx = thisbox->pad * 2; 2088 int thispadx = thisbox->pad * 2;
2050 int thispady = thisbox->pad * 2; 2089 int thispady = thisbox->pad * 2;
2051 2090
2052 /* Handle special groupbox case */ 2091 /* Handle special groupbox case */
2053 if(thisbox->grouphwnd) 2092 if(thisbox->grouphwnd)
2054 { 2093 {
2055 DWGroupBox *groupbox = thisbox->grouphwnd; 2094 DWGroupBox *groupbox = thisbox->grouphwnd;
2056 NSSize borderSize = [groupbox borderSize]; 2095 NSSize borderSize = [groupbox borderSize];
2057 NSRect titleRect; 2096 NSRect titleRect;
2058 2097
2059 if(borderSize.width == 0 || borderSize.height == 0) 2098 if(borderSize.width == 0 || borderSize.height == 0)
2060 { 2099 {
2061 borderSize = [groupbox initBorder]; 2100 borderSize = [groupbox initBorder];
2062 } 2101 }
2063 /* Get the title size for a more accurate groupbox padding size */ 2102 /* Get the title size for a more accurate groupbox padding size */
2064 titleRect = [groupbox titleRect]; 2103 titleRect = [groupbox titleRect];
2065 2104
2066 thisbox->grouppadx = borderSize.width; 2105 thisbox->grouppadx = borderSize.width;
2067 thisbox->grouppady = borderSize.height + titleRect.size.height; 2106 thisbox->grouppady = borderSize.height + titleRect.size.height;
2068 2107
2069 (*usedx) += thisbox->grouppadx; 2108 (*usedx) += thisbox->grouppadx;
2070 (*usedpadx) += thisbox->grouppadx; 2109 (*usedpadx) += thisbox->grouppadx;
2071 (*usedy) += thisbox->grouppady; 2110 (*usedy) += thisbox->grouppady;
2072 (*usedpady) += thisbox->grouppady; 2111 (*usedpady) += thisbox->grouppady;
2073 } 2112 }
2074 2113
2075 (*usedx) += thispadx; 2114 (*usedx) += thispadx;
2076 (*usedy) += thispady; 2115 (*usedy) += thispady;
2077 2116
2078 for(z=0;z<thisbox->count;z++) 2117 for(z=0;z<thisbox->count;z++)
2079 { 2118 {
2080 if(thisbox->items[z].type == TYPEBOX) 2119 if(thisbox->items[z].type == TYPEBOX)
2081 { 2120 {
2082 int initialx, initialy; 2121 int initialx, initialy;
2083 id box = thisbox->items[z].hwnd; 2122 id box = thisbox->items[z].hwnd;
2084 Box *tmp = [box box]; 2123 Box *tmp = [box box];
2085 2124
2086 initialx = x - (*usedx); 2125 initialx = x - (*usedx);
2087 initialy = y - (*usedy); 2126 initialy = y - (*usedy);
2088 2127
2089 if(tmp) 2128 if(tmp)
2090 { 2129 {
2091 int newx, newy; 2130 int newx, newy;
2092 int nux = *usedx, nuy = *usedy; 2131 int nux = *usedx, nuy = *usedy;
2093 int tmppadx = tmp->pad*2; 2132 int tmppadx = tmp->pad*2;
2094 int tmppady = tmp->pad*2; 2133 int tmppady = tmp->pad*2;
2095 int upx, upy; 2134 int upx, upy;
2096 2135
2097 upx = *usedpadx + tmppadx; 2136 upx = *usedpadx + tmppadx;
2098 upy = *usedpady + tmppady; 2137 upy = *usedpady + tmppady;
2099 2138
2100 /* On the second pass we know how big the box needs to be and how 2139 /* On the second pass we know how big the box needs to be and how
2101 * much space we have, so we can calculate a ratio for the new box. 2140 * much space we have, so we can calculate a ratio for the new box.
2102 */ 2141 */
2103 if(pass > 1) 2142 if(pass > 1)
2104 { 2143 {
2105 int deep = *depth + 1; 2144 int deep = *depth + 1;
2106 int tux = nux, tuy = nuy, tupx = upx, tupy = upy; 2145 int tux = nux, tuy = nuy, tupx = upx, tupy = upy;
2107 2146
2108 _resize_box(tmp, &deep, x, y, &tux, &tuy, 1, &tupx, &tupy); 2147 _resize_box(tmp, &deep, x, y, &tux, &tuy, 1, &tupx, &tupy);
2109 2148
2110 tmp->upx = tupx - *usedpadx; 2149 tmp->upx = tupx - *usedpadx;
2111 tmp->upy = tupy - *usedpady; 2150 tmp->upy = tupy - *usedpady;
2112 2151
2113 newx = x - tux; 2152 newx = x - tux;
2114 newy = y - tuy; 2153 newy = y - tuy;
2115 2154
2116 tmp->width = thisbox->items[z].width = initialx - newx; 2155 tmp->width = thisbox->items[z].width = initialx - newx;
2117 tmp->height = thisbox->items[z].height = initialy - newy; 2156 tmp->height = thisbox->items[z].height = initialy - newy;
2118 2157
2119 tmp->parentxratio = thisbox->xratio; 2158 tmp->parentxratio = thisbox->xratio;
2120 tmp->parentyratio = thisbox->yratio; 2159 tmp->parentyratio = thisbox->yratio;
2121 2160
2122 tmp->parentpad = tmp->pad; 2161 tmp->parentpad = tmp->pad;
2123 2162
2124 /* Just in case */ 2163 /* Just in case */
2125 tmp->xratio = thisbox->xratio; 2164 tmp->xratio = thisbox->xratio;
2126 tmp->yratio = thisbox->yratio; 2165 tmp->yratio = thisbox->yratio;
2127 2166
2128 if(thisbox->type == DW_VERT) 2167 if(thisbox->type == DW_VERT)
2129 { 2168 {
2130 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppady; 2169 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppady;
2131 2170
2132 if((thisbox->items[z].width - tmppad)!=0) 2171 if((thisbox->items[z].width - tmppad)!=0)
2133 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmppad))/((float)(thisbox->items[z].width-tmppad)); 2172 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmppad))/((float)(thisbox->items[z].width-tmppad));
2134 } 2173 }
2135 else 2174 else
2136 { 2175 {
2138 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx)); 2177 tmp->xratio = ((float)((thisbox->items[z].width * thisbox->xratio)-tmp->upx))/((float)(thisbox->items[z].width-tmp->upx));
2139 } 2178 }
2140 if(thisbox->type == DW_HORZ) 2179 if(thisbox->type == DW_HORZ)
2141 { 2180 {
2142 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppadx; 2181 int tmppad = (thisbox->items[z].pad*2)+(tmp->pad*2)+tmp->grouppadx;
2143 2182
2144 if((thisbox->items[z].height-tmppad)!=0) 2183 if((thisbox->items[z].height-tmppad)!=0)
2145 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmppad))/((float)(thisbox->items[z].height-tmppad)); 2184 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmppad))/((float)(thisbox->items[z].height-tmppad));
2146 } 2185 }
2147 else 2186 else
2148 { 2187 {
2149 if((thisbox->items[z].height-tmp->upy)!=0) 2188 if((thisbox->items[z].height-tmp->upy)!=0)
2150 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy)); 2189 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-tmp->upy))/((float)(thisbox->items[z].height-tmp->upy));
2151 } 2190 }
2152 } 2191 }
2153 2192
2154 (*depth)++; 2193 (*depth)++;
2155 2194
2156 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy); 2195 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &upx, &upy);
2157 2196
2158 (*depth)--; 2197 (*depth)--;
2159 2198
2160 newx = x - nux; 2199 newx = x - nux;
2161 newy = y - nuy; 2200 newy = y - nuy;
2162 2201
2163 tmp->minwidth = thisbox->items[z].width = initialx - newx; 2202 tmp->minwidth = thisbox->items[z].width = initialx - newx;
2164 tmp->minheight = thisbox->items[z].height = initialy - newy; 2203 tmp->minheight = thisbox->items[z].height = initialy - newy;
2165 } 2204 }
2166 } 2205 }
2167 2206
2168 if(pass > 1 && *depth > 0) 2207 if(pass > 1 && *depth > 0)
2169 { 2208 {
2170 if(thisbox->type == DW_VERT) 2209 if(thisbox->type == DW_VERT)
2171 { 2210 {
2172 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppadx; 2211 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppadx;
2173 2212
2174 if((thisbox->minwidth-tmppad) == 0) 2213 if((thisbox->minwidth-tmppad) == 0)
2175 thisbox->items[z].xratio = 1.0; 2214 thisbox->items[z].xratio = 1.0;
2176 else 2215 else
2177 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-tmppad))/((float)(thisbox->minwidth-tmppad)); 2216 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-tmppad))/((float)(thisbox->minwidth-tmppad));
2178 } 2217 }
2181 if(thisbox->minwidth-thisbox->upx == 0) 2220 if(thisbox->minwidth-thisbox->upx == 0)
2182 thisbox->items[z].xratio = 1.0; 2221 thisbox->items[z].xratio = 1.0;
2183 else 2222 else
2184 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx)); 2223 thisbox->items[z].xratio = ((float)((thisbox->width * thisbox->parentxratio)-thisbox->upx))/((float)(thisbox->minwidth-thisbox->upx));
2185 } 2224 }
2186 2225
2187 if(thisbox->type == DW_HORZ) 2226 if(thisbox->type == DW_HORZ)
2188 { 2227 {
2189 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppady; 2228 int tmppad = (thisbox->items[z].pad*2)+(thisbox->parentpad*2)+thisbox->grouppady;
2190 2229
2191 if((thisbox->minheight-tmppad) == 0) 2230 if((thisbox->minheight-tmppad) == 0)
2192 thisbox->items[z].yratio = 1.0; 2231 thisbox->items[z].yratio = 1.0;
2193 else 2232 else
2194 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-tmppad))/((float)(thisbox->minheight-tmppad)); 2233 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-tmppad))/((float)(thisbox->minheight-tmppad));
2195 } 2234 }
2198 if(thisbox->minheight-thisbox->upy == 0) 2237 if(thisbox->minheight-thisbox->upy == 0)
2199 thisbox->items[z].yratio = 1.0; 2238 thisbox->items[z].yratio = 1.0;
2200 else 2239 else
2201 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy)); 2240 thisbox->items[z].yratio = ((float)((thisbox->height * thisbox->parentyratio)-thisbox->upy))/((float)(thisbox->minheight-thisbox->upy));
2202 } 2241 }
2203 2242
2204 if(thisbox->items[z].type == TYPEBOX) 2243 if(thisbox->items[z].type == TYPEBOX)
2205 { 2244 {
2206 id box = thisbox->items[z].hwnd; 2245 id box = thisbox->items[z].hwnd;
2207 Box *tmp = [box box]; 2246 Box *tmp = [box box];
2208 2247
2209 if(tmp) 2248 if(tmp)
2210 { 2249 {
2211 tmp->parentxratio = thisbox->items[z].xratio; 2250 tmp->parentxratio = thisbox->items[z].xratio;
2212 tmp->parentyratio = thisbox->items[z].yratio; 2251 tmp->parentyratio = thisbox->items[z].yratio;
2213 } 2252 }
2216 else 2255 else
2217 { 2256 {
2218 thisbox->items[z].xratio = thisbox->xratio; 2257 thisbox->items[z].xratio = thisbox->xratio;
2219 thisbox->items[z].yratio = thisbox->yratio; 2258 thisbox->items[z].yratio = thisbox->yratio;
2220 } 2259 }
2221 2260
2222 if(thisbox->type == DW_VERT) 2261 if(thisbox->type == DW_VERT)
2223 { 2262 {
2224 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax) 2263 if((thisbox->items[z].width + (thisbox->items[z].pad*2)) > uxmax)
2225 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2)); 2264 uxmax = (thisbox->items[z].width + (thisbox->items[z].pad*2));
2226 if(thisbox->items[z].hsize != SIZEEXPAND) 2265 if(thisbox->items[z].hsize != SIZEEXPAND)
2280 else 2319 else
2281 (*usedpady) += thisbox->items[z].pad*2; 2320 (*usedpady) += thisbox->items[z].pad*2;
2282 } 2321 }
2283 } 2322 }
2284 } 2323 }
2285 2324
2286 (*usedx) += uxmax; 2325 (*usedx) += uxmax;
2287 (*usedy) += uymax; 2326 (*usedy) += uymax;
2288 (*usedpadx) += upxmax; 2327 (*usedpadx) += upxmax;
2289 (*usedpady) += upymax; 2328 (*usedpady) += upymax;
2290 2329
2291 currentx += thisbox->pad; 2330 currentx += thisbox->pad;
2292 currenty += thisbox->pad; 2331 currenty += thisbox->pad;
2293 2332
2294 /* The second pass is for expansion. */ 2333 /* The second pass is for expansion. */
2295 if(pass > 1) 2334 if(pass > 1)
2296 { 2335 {
2297 /* Any SIZEEXPAND items should be set to uxmax/uymax */ 2336 /* Any SIZEEXPAND items should be set to uxmax/uymax */
2298 for(z=0;z<thisbox->count;z++) 2337 for(z=0;z<thisbox->count;z++)
2305 if(thisbox->items[z].type == TYPEBOX) 2344 if(thisbox->items[z].type == TYPEBOX)
2306 { 2345 {
2307 int tux = nux, tuy = nuy, tupx = nupx, tupy = nupy; 2346 int tux = nux, tuy = nuy, tupx = nupx, tupy = nupy;
2308 id box = thisbox->items[z].hwnd; 2347 id box = thisbox->items[z].hwnd;
2309 Box *tmp = [box box]; 2348 Box *tmp = [box box];
2310 2349
2311 if(tmp) 2350 if(tmp)
2312 { 2351 {
2313 if(*depth > 0) 2352 if(*depth > 0)
2314 { 2353 {
2315 float calcval; 2354 float calcval;
2316 2355
2317 if(thisbox->type == DW_VERT) 2356 if(thisbox->type == DW_VERT)
2318 { 2357 {
2319 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+thispadx)); 2358 calcval = (float)(tmp->minwidth-((thisbox->items[z].pad*2)+thispadx));
2320 if(calcval == 0.0) 2359 if(calcval == 0.0)
2321 tmp->xratio = thisbox->xratio; 2360 tmp->xratio = thisbox->xratio;
2331 else 2370 else
2332 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+thispady)))/calcval; 2371 tmp->yratio = ((float)((thisbox->items[z].height * thisbox->yratio)-((thisbox->items[z].pad*2)+thispady)))/calcval;
2333 tmp->height = thisbox->items[z].height; 2372 tmp->height = thisbox->items[z].height;
2334 } 2373 }
2335 } 2374 }
2336 2375
2337 2376
2338 (*depth)++; 2377 (*depth)++;
2339 2378
2340 _resize_box(tmp, depth, x, y, &tux, &tuy, pass, &tupx, &tupy); 2379 _resize_box(tmp, depth, x, y, &tux, &tuy, pass, &tupx, &tupy);
2341 2380
2342 (*depth)--; 2381 (*depth)--;
2343 2382
2344 } 2383 }
2345 } 2384 }
2346 } 2385 }
2347 } 2386 }
2348 2387
2349 /* The third pass is for actual placement. */ 2388 /* The third pass is for actual placement. */
2350 if(pass > 2) 2389 if(pass > 2)
2351 { 2390 {
2352 for(z=0;z<(thisbox->count);z++) 2391 for(z=0;z<(thisbox->count);z++)
2353 { 2392 {
2356 int pad = thisbox->items[z].pad; 2395 int pad = thisbox->items[z].pad;
2357 NSView *handle = thisbox->items[z].hwnd; 2396 NSView *handle = thisbox->items[z].hwnd;
2358 NSPoint point; 2397 NSPoint point;
2359 NSSize size; 2398 NSSize size;
2360 int vectorx, vectory; 2399 int vectorx, vectory;
2361 2400
2362 /* When upxmax != pad*2 then ratios are incorrect. */ 2401 /* When upxmax != pad*2 then ratios are incorrect. */
2363 vectorx = (int)((width*thisbox->items[z].xratio)-width); 2402 vectorx = (int)((width*thisbox->items[z].xratio)-width);
2364 vectory = (int)((height*thisbox->items[z].yratio)-height); 2403 vectory = (int)((height*thisbox->items[z].yratio)-height);
2365 2404
2366 if(width > 0 && height > 0) 2405 if(width > 0 && height > 0)
2367 { 2406 {
2368 /* This is a hack to fix rounding of the sizing */ 2407 /* This is a hack to fix rounding of the sizing */
2369 if(*depth == 0) 2408 if(*depth == 0)
2370 { 2409 {
2371 vectorx++; 2410 vectorx++;
2372 vectory++; 2411 vectory++;
2373 } 2412 }
2374 2413
2375 /* If this item isn't going to expand... reset the vectors to 0 */ 2414 /* If this item isn't going to expand... reset the vectors to 0 */
2376 if(thisbox->items[z].vsize != SIZEEXPAND) 2415 if(thisbox->items[z].vsize != SIZEEXPAND)
2377 vectory = 0; 2416 vectory = 0;
2378 if(thisbox->items[z].hsize != SIZEEXPAND) 2417 if(thisbox->items[z].hsize != SIZEEXPAND)
2379 vectorx = 0; 2418 vectorx = 0;
2380 2419
2381 point.x = currentx + pad; 2420 point.x = currentx + pad;
2382 point.y = currenty + pad; 2421 point.y = currenty + pad;
2383 size.width = width + vectorx; 2422 size.width = width + vectorx;
2384 size.height = height + vectory; 2423 size.height = height + vectory;
2385 [handle setFrameOrigin:point]; 2424 [handle setFrameOrigin:point];
2386 [handle setFrameSize:size]; 2425 [handle setFrameSize:size];
2387 2426
2388 /* After placing a box... place its components */ 2427 /* After placing a box... place its components */
2389 if(thisbox->items[z].type == TYPEBOX) 2428 if(thisbox->items[z].type == TYPEBOX)
2390 { 2429 {
2391 id box = thisbox->items[z].hwnd; 2430 id box = thisbox->items[z].hwnd;
2392 Box *tmp = [box box]; 2431 Box *tmp = [box box];
2393 2432
2394 if(tmp) 2433 if(tmp)
2395 { 2434 {
2396 (*depth)++; 2435 (*depth)++;
2397 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &nupx, &nupy); 2436 _resize_box(tmp, depth, x, y, &nux, &nuy, pass, &nupx, &nupy);
2398 (*depth)--; 2437 (*depth)--;
2399 } 2438 }
2400 } 2439 }
2401 2440
2402 /* Special handling for notebook controls */ 2441 /* Special handling for notebook controls */
2403 if([handle isMemberOfClass:[DWNotebook class]]) 2442 if([handle isMemberOfClass:[DWNotebook class]])
2404 { 2443 {
2405 DWNotebook *notebook = (DWNotebook *)handle; 2444 DWNotebook *notebook = (DWNotebook *)handle;
2406 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem]; 2445 DWNotebookPage *notepage = (DWNotebookPage *)[notebook selectedTabViewItem];
2407 id view = [notepage view]; 2446 id view = [notepage view];
2408 2447
2409 if(view != nil) 2448 if(view != nil)
2410 { 2449 {
2411 Box *box = [view box]; 2450 Box *box = [view box];
2412 NSSize size = [view frame].size; 2451 NSSize size = [view frame].size;
2413 _do_resize(box, size.width, size.height); 2452 _do_resize(box, size.width, size.height);
2422 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; 2461 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
2423 DWScrollBox *scrollbox = (DWScrollBox *)handle; 2462 DWScrollBox *scrollbox = (DWScrollBox *)handle;
2424 DWBox *contentbox = [scrollbox documentView]; 2463 DWBox *contentbox = [scrollbox documentView];
2425 Box *thisbox = [contentbox box]; 2464 Box *thisbox = [contentbox box];
2426 NSSize contentsize = [scrollbox contentSize]; 2465 NSSize contentsize = [scrollbox contentSize];
2427 2466
2428 /* Get the required space for the box */ 2467 /* Get the required space for the box */
2429 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); 2468 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
2430 2469
2431 if(contentsize.width < usedx) 2470 if(contentsize.width < usedx)
2432 { 2471 {
2433 contentsize.width = usedx; 2472 contentsize.width = usedx;
2434 } 2473 }
2435 if(contentsize.height < usedy) 2474 if(contentsize.height < usedy)
2436 { 2475 {
2437 contentsize.height = usedy; 2476 contentsize.height = usedy;
2438 } 2477 }
2439 [contentbox setFrameSize:contentsize]; 2478 [contentbox setFrameSize:contentsize];
2440 2479
2441 /* Layout the content of the scrollbox */ 2480 /* Layout the content of the scrollbox */
2442 _do_resize(thisbox, contentsize.width, contentsize.height); 2481 _do_resize(thisbox, contentsize.width, contentsize.height);
2443 _handle_resize_events(thisbox); 2482 _handle_resize_events(thisbox);
2444 } 2483 }
2445 /* Special handling for spinbutton controls */ 2484 /* Special handling for spinbutton controls */
2455 } 2494 }
2456 else if([handle isMemberOfClass:[DWSplitBar class]] && size.width > 20 && size.height > 20) 2495 else if([handle isMemberOfClass:[DWSplitBar class]] && size.width > 20 && size.height > 20)
2457 { 2496 {
2458 DWSplitBar *split = (DWSplitBar *)handle; 2497 DWSplitBar *split = (DWSplitBar *)handle;
2459 float percent = [split percent]; 2498 float percent = [split percent];
2460 2499
2461 if(percent > 0) 2500 if(percent > 0)
2462 { 2501 {
2463 dw_splitbar_set(handle, percent); 2502 dw_splitbar_set(handle, percent);
2464 [split setPercent:0]; 2503 [split setPercent:0];
2465 } 2504 }
2479 if(x != 0 && y != 0) 2518 if(x != 0 && y != 0)
2480 { 2519 {
2481 if(thisbox) 2520 if(thisbox)
2482 { 2521 {
2483 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0; 2522 int usedx = 0, usedy = 0, usedpadx = 0, usedpady = 0, depth = 0;
2484 2523
2485 /* Calculate space requirements */ 2524 /* Calculate space requirements */
2486 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady); 2525 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 1, &usedpadx, &usedpady);
2487 2526
2488 if(usedx-usedpadx == 0 || usedy-usedpady == 0) 2527 if(usedx-usedpadx == 0 || usedy-usedpady == 0)
2489 return; 2528 return;
2490 2529
2491 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); 2530 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
2492 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); 2531 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
2493 2532
2494 usedx = usedy = usedpadx = usedpady = depth = 0; 2533 usedx = usedy = usedpadx = usedpady = depth = 0;
2495 2534
2496 /* Calculate sub-box ratios for expansion */ 2535 /* Calculate sub-box ratios for expansion */
2497 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady); 2536 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 2, &usedpadx, &usedpady);
2498 2537
2499 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx)); 2538 thisbox->xratio = ((float)(x-usedpadx))/((float)(usedx-usedpadx));
2500 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady)); 2539 thisbox->yratio = ((float)(y-usedpady))/((float)(usedy-usedpady));
2501 2540
2502 usedx = usedy = usedpadx = usedpady = depth = 0; 2541 usedx = usedy = usedpadx = usedpady = depth = 0;
2503 2542
2504 /* Finally place all the boxes and controls */ 2543 /* Finally place all the boxes and controls */
2505 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 3, &usedpadx, &usedpady); 2544 _resize_box(thisbox, &depth, x, y, &usedx, &usedy, 3, &usedpadx, &usedpady);
2506 } 2545 }
2507 } 2546 }
2508 } 2547 }
2740 if(flags & DW_MB_ERROR) 2779 if(flags & DW_MB_ERROR)
2741 { 2780 {
2742 iResponse = (int) 2781 iResponse = (int)
2743 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ], 2782 NSRunCriticalAlertPanel([ NSString stringWithUTF8String:title ],
2744 [ NSString stringWithUTF8String:outbuf ], 2783 [ NSString stringWithUTF8String:outbuf ],
2745 button1, button2, button3); 2784 button1, button2, button3);
2746 } 2785 }
2747 else if(flags & DW_MB_INFORMATION) 2786 else if(flags & DW_MB_INFORMATION)
2748 { 2787 {
2749 iResponse = (int) 2788 iResponse = (int)
2750 NSRunInformationalAlertPanel([ NSString stringWithUTF8String:title ], 2789 NSRunInformationalAlertPanel([ NSString stringWithUTF8String:title ],
2751 [ NSString stringWithUTF8String:outbuf ], 2790 [ NSString stringWithUTF8String:outbuf ],
2752 button1, button2, button3); 2791 button1, button2, button3);
2753 } 2792 }
2754 else 2793 else
2755 { 2794 {
2756 iResponse = (int) 2795 iResponse = (int)
2757 NSRunAlertPanel([ NSString stringWithUTF8String:title ], 2796 NSRunAlertPanel([ NSString stringWithUTF8String:title ],
2974 HWND API dw_groupbox_new(int type, int pad, char *title) 3013 HWND API dw_groupbox_new(int type, int pad, char *title)
2975 { 3014 {
2976 NSBox *groupbox = [[DWGroupBox alloc] init]; 3015 NSBox *groupbox = [[DWGroupBox alloc] init];
2977 DWBox *thisbox = dw_box_new(type, pad); 3016 DWBox *thisbox = dw_box_new(type, pad);
2978 Box *box = [thisbox box]; 3017 Box *box = [thisbox box];
2979 3018
2980 [groupbox setBorderType:NSBezelBorder]; 3019 [groupbox setBorderType:NSBezelBorder];
2981 [groupbox setTitle:[NSString stringWithUTF8String:title]]; 3020 [groupbox setTitle:[NSString stringWithUTF8String:title]];
2982 box->grouphwnd = groupbox; 3021 box->grouphwnd = groupbox;
2983 [groupbox setContentView:thisbox]; 3022 [groupbox setContentView:thisbox];
2984 return groupbox; 3023 return groupbox;
3151 [view addSubview:this]; 3190 [view addSubview:this];
3152 /* If we are packing a button... */ 3191 /* If we are packing a button... */
3153 if([this isMemberOfClass:[DWButton class]]) 3192 if([this isMemberOfClass:[DWButton class]])
3154 { 3193 {
3155 DWButton *button = (DWButton *)this; 3194 DWButton *button = (DWButton *)this;
3156 3195
3157 /* Save the parent box so radio 3196 /* Save the parent box so radio
3158 * buttons can use it later. 3197 * buttons can use it later.
3159 */ 3198 */
3160 [button setParent:view]; 3199 [button setParent:view];
3161 } 3200 }
3259 [view addSubview:this]; 3298 [view addSubview:this];
3260 /* If we are packing a button... */ 3299 /* If we are packing a button... */
3261 if([this isMemberOfClass:[DWButton class]]) 3300 if([this isMemberOfClass:[DWButton class]])
3262 { 3301 {
3263 DWButton *button = (DWButton *)this; 3302 DWButton *button = (DWButton *)this;
3264 3303
3265 /* Save the parent box so radio 3304 /* Save the parent box so radio
3266 * buttons can use it later. 3305 * buttons can use it later.
3267 */ 3306 */
3268 [button setParent:view]; 3307 [button setParent:view];
3269 } 3308 }
3346 */ 3385 */
3347 void API dw_entryfield_set_limit(HWND handle, ULONG limit) 3386 void API dw_entryfield_set_limit(HWND handle, ULONG limit)
3348 { 3387 {
3349 DWEntryField *entry = handle; 3388 DWEntryField *entry = handle;
3350 DWEntryFieldFormatter *formatter = [[DWEntryFieldFormatter alloc] init]; 3389 DWEntryFieldFormatter *formatter = [[DWEntryFieldFormatter alloc] init];
3351 3390
3352 [formatter setMaximumLength:(int)limit]; 3391 [formatter setMaximumLength:(int)limit];
3353 [[entry cell] setFormatter:formatter]; 3392 [[entry cell] setFormatter:formatter];
3354 } 3393 }
3355 3394
3356 /* 3395 /*
3384 * DW pick the appropriate file extension. 3423 * DW pick the appropriate file extension.
3385 * (BMP on OS/2 or Windows, XPM on Unix) 3424 * (BMP on OS/2 or Windows, XPM on Unix)
3386 */ 3425 */
3387 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long cid, char *filename) 3426 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long cid, char *filename)
3388 { 3427 {
3428 char *ext = _dw_get_image_extension( filename );
3429
3389 NSString *nstr = [ NSString stringWithUTF8String:filename ]; 3430 NSString *nstr = [ NSString stringWithUTF8String:filename ];
3390 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; 3431 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr];
3391 if(!image) 3432
3392 { 3433 if(!image && ext)
3393 nstr = [nstr stringByAppendingString:@".png"]; 3434 {
3435 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
3394 image = [[NSImage alloc] initWithContentsOfFile:nstr]; 3436 image = [[NSImage alloc] initWithContentsOfFile:nstr];
3395 } 3437 }
3396 DWButton *button = _button_new("", cid); 3438 DWButton *button = _button_new("", cid);
3397 if(image) 3439 if(image)
3398 { 3440 {
4217 NSScrollView *sv = handle; 4259 NSScrollView *sv = handle;
4218 DWMLE *mle = [sv documentView]; 4260 DWMLE *mle = [sv documentView];
4219 NSTextStorage *ts = [mle textStorage]; 4261 NSTextStorage *ts = [mle textStorage];
4220 NSMutableString *ms = [ts mutableString]; 4262 NSMutableString *ms = [ts mutableString];
4221 NSUInteger numberOfLines, index, stringLength = [ms length]; 4263 NSUInteger numberOfLines, index, stringLength = [ms length];
4222 4264
4223 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++) 4265 for(index=0, numberOfLines=0; index < stringLength; numberOfLines++)
4224 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]); 4266 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]);
4225 4267
4226 *bytes = stringLength; 4268 *bytes = stringLength;
4227 *lines = numberOfLines; 4269 *lines = numberOfLines;
4269 NSScrollView *sv = handle; 4311 NSScrollView *sv = handle;
4270 DWMLE *mle = [sv documentView]; 4312 DWMLE *mle = [sv documentView];
4271 NSTextStorage *ts = [mle textStorage]; 4313 NSTextStorage *ts = [mle textStorage];
4272 NSMutableString *ms = [ts mutableString]; 4314 NSMutableString *ms = [ts mutableString];
4273 NSUInteger numberOfLines, index, stringLength = [ms length]; 4315 NSUInteger numberOfLines, index, stringLength = [ms length];
4274 4316
4275 for(index=0, numberOfLines=0; index < stringLength && numberOfLines < line; numberOfLines++) 4317 for(index=0, numberOfLines=0; index < stringLength && numberOfLines < line; numberOfLines++)
4276 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]); 4318 index = NSMaxRange([ms lineRangeForRange:NSMakeRange(index, 0)]);
4277 4319
4278 if(line == numberOfLines) 4320 if(line == numberOfLines)
4279 { 4321 {
4280 [mle scrollRangeToVisible:[ms lineRangeForRange:NSMakeRange(index, 0)]]; 4322 [mle scrollRangeToVisible:[ms lineRangeForRange:NSMakeRange(index, 0)]];
4281 } 4323 }
4282 } 4324 }
4350 NSMutableString *ms = [ts mutableString]; 4392 NSMutableString *ms = [ts mutableString];
4351 NSString *searchForMe = [NSString stringWithUTF8String:text]; 4393 NSString *searchForMe = [NSString stringWithUTF8String:text];
4352 NSRange searchRange = NSMakeRange(point, [ms length] - point); 4394 NSRange searchRange = NSMakeRange(point, [ms length] - point);
4353 NSRange range = NSMakeRange(NSNotFound, 0); 4395 NSRange range = NSMakeRange(NSNotFound, 0);
4354 NSUInteger options = flags ? flags : NSCaseInsensitiveSearch; 4396 NSUInteger options = flags ? flags : NSCaseInsensitiveSearch;
4355 4397
4356 if(ms) 4398 if(ms)
4357 { 4399 {
4358 range = [ms rangeOfString:searchForMe options:options range:searchRange]; 4400 range = [ms rangeOfString:searchForMe options:options range:searchRange];
4359 } 4401 }
4360 4402
4361 if(range.location != NSNotFound) 4403 if(range.location != NSNotFound)
4362 { 4404 {
4363 return -1; 4405 return -1;
4364 } 4406 }
4365 return (int)range.location; 4407 return (int)range.location;
4366 } 4408 }
4450 */ 4492 */
4451 void API dw_color_foreground_set(unsigned long value) 4493 void API dw_color_foreground_set(unsigned long value)
4452 { 4494 {
4453 NSColor *oldcolor = pthread_getspecific(_dw_fg_color_key); 4495 NSColor *oldcolor = pthread_getspecific(_dw_fg_color_key);
4454 NSColor *newcolor; 4496 NSColor *newcolor;
4455 4497
4456 _foreground = _get_color(value); 4498 _foreground = _get_color(value);
4457 4499
4458 newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: 4500 newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green:
4459 DW_GREEN_VALUE(_foreground)/255.0 blue: 4501 DW_GREEN_VALUE(_foreground)/255.0 blue:
4460 DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] retain]; 4502 DW_BLUE_VALUE(_foreground)/255.0 alpha: 1] retain];
4461 pthread_setspecific(_dw_fg_color_key, newcolor); 4503 pthread_setspecific(_dw_fg_color_key, newcolor);
4462 [oldcolor release]; 4504 [oldcolor release];
4463 } 4505 }
4464 4506
4470 */ 4512 */
4471 void API dw_color_background_set(unsigned long value) 4513 void API dw_color_background_set(unsigned long value)
4472 { 4514 {
4473 NSColor *oldcolor = pthread_getspecific(_dw_bg_color_key); 4515 NSColor *oldcolor = pthread_getspecific(_dw_bg_color_key);
4474 NSColor *newcolor; 4516 NSColor *newcolor;
4475 4517
4476 if(value == DW_CLR_DEFAULT) 4518 if(value == DW_CLR_DEFAULT)
4477 { 4519 {
4478 pthread_setspecific(_dw_bg_color_key, NULL); 4520 pthread_setspecific(_dw_bg_color_key, NULL);
4479 } 4521 }
4480 else 4522 else
4481 { 4523 {
4482 _background = _get_color(value); 4524 _background = _get_color(value);
4483 4525
4484 newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_background)/255.0 green: 4526 newcolor = [[NSColor colorWithDeviceRed: DW_RED_VALUE(_background)/255.0 green:
4485 DW_GREEN_VALUE(_background)/255.0 blue: 4527 DW_GREEN_VALUE(_background)/255.0 blue:
4486 DW_BLUE_VALUE(_background)/255.0 alpha: 1] retain]; 4528 DW_BLUE_VALUE(_background)/255.0 alpha: 1] retain];
4487 pthread_setspecific(_dw_bg_color_key, newcolor); 4529 pthread_setspecific(_dw_bg_color_key, newcolor);
4488 } 4530 }
4489 [oldcolor release]; 4531 [oldcolor release];
4490 } 4532 }
4550 if(pixmap) 4592 if(pixmap)
4551 { 4593 {
4552 image = (id)pixmap->image; 4594 image = (id)pixmap->image;
4553 [NSGraphicsContext saveGraphicsState]; 4595 [NSGraphicsContext saveGraphicsState];
4554 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4596 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4555 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; 4597 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4556 } 4598 }
4557 else 4599 else
4558 { 4600 {
4559 if([image lockFocusIfCanDraw] == NO) 4601 if([image lockFocusIfCanDraw] == NO)
4560 { 4602 {
4598 if(pixmap) 4640 if(pixmap)
4599 { 4641 {
4600 image = (id)pixmap->image; 4642 image = (id)pixmap->image;
4601 [NSGraphicsContext saveGraphicsState]; 4643 [NSGraphicsContext saveGraphicsState];
4602 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4644 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4603 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; 4645 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4604 } 4646 }
4605 else 4647 else
4606 { 4648 {
4607 if([image lockFocusIfCanDraw] == NO) 4649 if([image lockFocusIfCanDraw] == NO)
4608 { 4650 {
4682 font = [render font]; 4724 font = [render font];
4683 } 4725 }
4684 image = (id)pixmap->image; 4726 image = (id)pixmap->image;
4685 [NSGraphicsContext saveGraphicsState]; 4727 [NSGraphicsContext saveGraphicsState];
4686 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4728 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4687 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; 4729 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4688 NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key); 4730 NSColor *fgcolor = pthread_getspecific(_dw_fg_color_key);
4689 NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key); 4731 NSColor *bgcolor = pthread_getspecific(_dw_bg_color_key);
4690 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil]; 4732 NSMutableDictionary *dict = [[NSMutableDictionary alloc] initWithObjectsAndKeys:fgcolor, NSForegroundColorAttributeName, nil];
4691 if(bgcolor) 4733 if(bgcolor)
4692 { 4734 {
4760 if(pixmap) 4802 if(pixmap)
4761 { 4803 {
4762 image = (id)pixmap->image; 4804 image = (id)pixmap->image;
4763 [NSGraphicsContext saveGraphicsState]; 4805 [NSGraphicsContext saveGraphicsState];
4764 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4806 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4765 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; 4807 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4766 } 4808 }
4767 else 4809 else
4768 { 4810 {
4769 if([image lockFocusIfCanDraw] == NO) 4811 if([image lockFocusIfCanDraw] == NO)
4770 { 4812 {
4818 if(pixmap) 4860 if(pixmap)
4819 { 4861 {
4820 image = (id)pixmap->image; 4862 image = (id)pixmap->image;
4821 [NSGraphicsContext saveGraphicsState]; 4863 [NSGraphicsContext saveGraphicsState];
4822 [NSGraphicsContext setCurrentContext:[NSGraphicsContext 4864 [NSGraphicsContext setCurrentContext:[NSGraphicsContext
4823 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]]; 4865 graphicsContextWithGraphicsPort:[[NSGraphicsContext graphicsContextWithBitmapImageRep:image] graphicsPort] flipped:YES]];
4824 } 4866 }
4825 else 4867 else
4826 { 4868 {
4827 if([image lockFocusIfCanDraw] == NO) 4869 if([image lockFocusIfCanDraw] == NO)
4828 { 4870 {
4950 */ 4992 */
4951 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item) 4993 HTREEITEM API dw_tree_get_parent(HWND handle, HTREEITEM item)
4952 { 4994 {
4953 int _locked_by_me = FALSE; 4995 int _locked_by_me = FALSE;
4954 HTREEITEM parent; 4996 HTREEITEM parent;
4955 4997
4956 DW_MUTEX_LOCK; 4998 DW_MUTEX_LOCK;
4957 NSPointerArray *array = (NSPointerArray *)item; 4999 NSPointerArray *array = (NSPointerArray *)item;
4958 parent = (HTREEITEM)[array pointerAtIndex:4]; 5000 parent = (HTREEITEM)[array pointerAtIndex:4];
4959 DW_MUTEX_UNLOCK; 5001 DW_MUTEX_UNLOCK;
4960 return parent; 5002 return parent;
5159 [browsercell release]; 5201 [browsercell release];
5160 } 5202 }
5161 /* Defaults to left justified so just handle right and center */ 5203 /* Defaults to left justified so just handle right and center */
5162 if(flags[z] & DW_CFA_RIGHT) 5204 if(flags[z] & DW_CFA_RIGHT)
5163 { 5205 {
5164 [(NSCell *)[column dataCell] setAlignment:NSRightTextAlignment]; 5206 [(NSCell *)[column dataCell] setAlignment:NSRightTextAlignment];
5165 [(NSCell *)[column headerCell] setAlignment:NSRightTextAlignment]; 5207 [(NSCell *)[column headerCell] setAlignment:NSRightTextAlignment];
5166 } 5208 }
5167 else if(flags[z] & DW_CFA_CENTER) 5209 else if(flags[z] & DW_CFA_CENTER)
5168 { 5210 {
5169 [(NSCell *)[column dataCell] setAlignment:NSCenterTextAlignment]; 5211 [(NSCell *)[column dataCell] setAlignment:NSCenterTextAlignment];
5170 [(NSCell *)[column headerCell] setAlignment:NSCenterTextAlignment]; 5212 [(NSCell *)[column headerCell] setAlignment:NSCenterTextAlignment];
5171 } 5213 }
5172 [column setEditable:NO]; 5214 [column setEditable:NO];
5173 [cont addTableColumn:column]; 5215 [cont addTableColumn:column];
5174 [cont addColumn:column andType:(int)flags[z]]; 5216 [cont addColumn:column andType:(int)flags[z]];
5175 [column release]; 5217 [column release];
5238 DW_MUTEX_LOCK; 5280 DW_MUTEX_LOCK;
5239 DWContainer *cont = handle; 5281 DWContainer *cont = handle;
5240 id object = nil; 5282 id object = nil;
5241 int type = [cont cellType:column]; 5283 int type = [cont cellType:column];
5242 int lastadd = 0; 5284 int lastadd = 0;
5243 5285
5244 /* If pointer is NULL we are getting a change request instead of set */ 5286 /* If pointer is NULL we are getting a change request instead of set */
5245 if(pointer) 5287 if(pointer)
5246 { 5288 {
5247 lastadd = [cont lastAddPoint]; 5289 lastadd = [cont lastAddPoint];
5248 } 5290 }
5362 int _locked_by_me = FALSE; 5404 int _locked_by_me = FALSE;
5363 DW_MUTEX_LOCK; 5405 DW_MUTEX_LOCK;
5364 DWContainer *cont = handle; 5406 DWContainer *cont = handle;
5365 NSBrowserCell *browsercell; 5407 NSBrowserCell *browsercell;
5366 int lastadd = 0; 5408 int lastadd = 0;
5367 5409
5368 /* If pointer is NULL we are getting a change request instead of set */ 5410 /* If pointer is NULL we are getting a change request instead of set */
5369 if(pointer) 5411 if(pointer)
5370 { 5412 {
5371 lastadd = [cont lastAddPoint]; 5413 lastadd = [cont lastAddPoint];
5372 } 5414 }
5373 5415
5374 browsercell = [[NSBrowserCell alloc] init]; 5416 browsercell = [[NSBrowserCell alloc] init];
5375 [browsercell setLeaf:YES]; 5417 [browsercell setLeaf:YES];
5376 [browsercell setImage:icon]; 5418 [browsercell setImage:icon];
5377 [browsercell setStringValue:[ NSString stringWithUTF8String:filename ]]; 5419 [browsercell setStringValue:[ NSString stringWithUTF8String:filename ]];
5378 [cont editCell:browsercell at:(row+lastadd) and:0]; 5420 [cont editCell:browsercell at:(row+lastadd) and:0];
5558 DWContainer *cont = handle; 5600 DWContainer *cont = handle;
5559 NSScrollView *sv = [cont scrollview]; 5601 NSScrollView *sv = [cont scrollview];
5560 NSScroller *scrollbar = [sv verticalScroller]; 5602 NSScroller *scrollbar = [sv verticalScroller];
5561 int rowcount = (int)[cont numberOfRowsInTableView:cont]; 5603 int rowcount = (int)[cont numberOfRowsInTableView:cont];
5562 float currpos = [scrollbar floatValue]; 5604 float currpos = [scrollbar floatValue];
5563 float change; 5605 float change;
5564 5606
5565 /* Safety check */ 5607 /* Safety check */
5566 if(rowcount < 1) 5608 if(rowcount < 1)
5567 { 5609 {
5568 return; 5610 return;
5569 } 5611 }
5570 5612
5571 change = (float)rows/(float)rowcount; 5613 change = (float)rows/(float)rowcount;
5572 5614
5573 switch(direction) 5615 switch(direction)
5574 { 5616 {
5575 case DW_SCROLL_TOP: 5617 case DW_SCROLL_TOP:
5576 { 5618 {
5577 [scrollbar setFloatValue:0]; 5619 [scrollbar setFloatValue:0];
5779 * DW pick the appropriate file extension. 5821 * DW pick the appropriate file extension.
5780 * (ICO on OS/2 or Windows, XPM on Unix) 5822 * (ICO on OS/2 or Windows, XPM on Unix)
5781 */ 5823 */
5782 HICN API dw_icon_load_from_file(char *filename) 5824 HICN API dw_icon_load_from_file(char *filename)
5783 { 5825 {
5826 char *ext = _dw_get_image_extension( filename );
5827
5784 NSString *nstr = [ NSString stringWithUTF8String:filename ]; 5828 NSString *nstr = [ NSString stringWithUTF8String:filename ];
5785 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr]; 5829 NSImage *image = [[NSImage alloc] initWithContentsOfFile:nstr];
5786 if(!image) 5830 if(!image && ext)
5787 { 5831 {
5788 nstr = [nstr stringByAppendingString:@".png"]; 5832 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
5789 image = [[NSImage alloc] initWithContentsOfFile:nstr]; 5833 image = [[NSImage alloc] initWithContentsOfFile:nstr];
5790 } 5834 }
5791 return image; 5835 return image;
5792 } 5836 }
5793 5837
5969 if(!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 6013 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
5970 return NULL; 6014 return NULL;
5971 pixmap->width = width; 6015 pixmap->width = width;
5972 pixmap->height = height; 6016 pixmap->height = height;
5973 pixmap->handle = handle; 6017 pixmap->handle = handle;
5974 pixmap->image = [[NSBitmapImageRep alloc] 6018 pixmap->image = [[NSBitmapImageRep alloc]
5975 initWithBitmapDataPlanes:NULL 6019 initWithBitmapDataPlanes:NULL
5976 pixelsWide:width 6020 pixelsWide:width
5977 pixelsHigh:height 6021 pixelsHigh:height
5978 bitsPerSample:8 6022 bitsPerSample:8
5979 samplesPerPixel:4 6023 samplesPerPixel:4
5980 hasAlpha:YES 6024 hasAlpha:YES
5981 isPlanar:NO 6025 isPlanar:NO
5982 colorSpaceName:NSDeviceRGBColorSpace 6026 colorSpaceName:NSDeviceRGBColorSpace
5983 bytesPerRow:0 6027 bytesPerRow:0
5984 bitsPerPixel:0]; 6028 bitsPerPixel:0];
5985 return pixmap; 6029 return pixmap;
5986 } 6030 }
5987 6031
5988 /* 6032 /*
5996 * A handle to a pixmap or NULL on failure. 6040 * A handle to a pixmap or NULL on failure.
5997 */ 6041 */
5998 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename) 6042 HPIXMAP API dw_pixmap_new_from_file(HWND handle, char *filename)
5999 { 6043 {
6000 HPIXMAP pixmap; 6044 HPIXMAP pixmap;
6045 char *ext = _dw_get_image_extension( filename );
6001 6046
6002 if(!(pixmap = calloc(1,sizeof(struct _hpixmap)))) 6047 if(!(pixmap = calloc(1,sizeof(struct _hpixmap))))
6003 return NULL; 6048 return NULL;
6004 NSString *nstr = [ NSString stringWithUTF8String:filename ]; 6049 NSString *nstr = [ NSString stringWithUTF8String:filename ];
6005 NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithContentsOfFile:nstr]; 6050 NSBitmapImageRep *image = [[NSBitmapImageRep alloc] initWithContentsOfFile:nstr];
6006 if(!image) 6051 if(!image && ext)
6007 { 6052 {
6008 nstr = [nstr stringByAppendingString:@".png"]; 6053 nstr = [nstr stringByAppendingString: [NSString stringWithUTF8String:ext]];
6009 image = [[NSBitmapImageRep alloc] initWithContentsOfFile:nstr]; 6054 image = [[NSBitmapImageRep alloc] initWithContentsOfFile:nstr];
6010 } 6055 }
6011 NSSize size = [image size]; 6056 NSSize size = [image size];
6012 pixmap->width = size.width; 6057 pixmap->width = size.width;
6013 pixmap->height = size.height; 6058 pixmap->height = size.height;
6825 id object = handle; 6870 id object = handle;
6826 unsigned long _fore = _get_color(fore); 6871 unsigned long _fore = _get_color(fore);
6827 unsigned long _back = _get_color(back); 6872 unsigned long _back = _get_color(back);
6828 NSColor *fg = NULL; 6873 NSColor *fg = NULL;
6829 NSColor *bg = NULL; 6874 NSColor *bg = NULL;
6830 6875
6831 /* Get the NSColor for non-default colors */ 6876 /* Get the NSColor for non-default colors */
6832 if(fore != DW_CLR_DEFAULT) 6877 if(fore != DW_CLR_DEFAULT)
6833 { 6878 {
6834 fg = [NSColor colorWithDeviceRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1]; 6879 fg = [NSColor colorWithDeviceRed: DW_RED_VALUE(_fore)/255.0 green: DW_GREEN_VALUE(_fore)/255.0 blue: DW_BLUE_VALUE(_fore)/255.0 alpha: 1];
6835 } 6880 }
6845 } 6890 }
6846 /* Get the cell on classes using NSCell */ 6891 /* Get the cell on classes using NSCell */
6847 if([object isKindOfClass:[NSTextField class]]) 6892 if([object isKindOfClass:[NSTextField class]])
6848 { 6893 {
6849 id cell = [object cell]; 6894 id cell = [object cell];
6850 6895
6851 if(fg) 6896 if(fg)
6852 { 6897 {
6853 [cell setTextColor:fg]; 6898 [cell setTextColor:fg];
6854 } 6899 }
6855 } 6900 }
6856 if([object isKindOfClass:[NSTextField class]] || [object isKindOfClass:[NSButton class]]) 6901 if([object isKindOfClass:[NSTextField class]] || [object isKindOfClass:[NSButton class]])
6857 { 6902 {
6858 id cell = [object cell]; 6903 id cell = [object cell];
6859 6904
6860 if(bg) 6905 if(bg)
6861 { 6906 {
6862 [cell setBackgroundColor:bg]; 6907 [cell setBackgroundColor:bg];
6863 } 6908 }
6864 } 6909 }
6872 } 6917 }
6873 } 6918 }
6874 else if([object isKindOfClass:[NSTableView class]]) 6919 else if([object isKindOfClass:[NSTableView class]])
6875 { 6920 {
6876 DWContainer *cont = handle; 6921 DWContainer *cont = handle;
6877 6922
6878 if(bg) 6923 if(bg)
6879 { 6924 {
6880 [cont setBackgroundColor:bg]; 6925 [cont setBackgroundColor:bg];
6881 } 6926 }
6882 if(fg) 6927 if(fg)
6937 [tv setAlignment:(style & mask)]; 6982 [tv setAlignment:(style & mask)];
6938 } 6983 }
6939 else if([object isMemberOfClass:[DWButton class]]) 6984 else if([object isMemberOfClass:[DWButton class]])
6940 { 6985 {
6941 DWButton *button = handle; 6986 DWButton *button = handle;
6942 6987
6943 if(mask & DW_BS_NOBORDER) 6988 if(mask & DW_BS_NOBORDER)
6944 { 6989 {
6945 if(style & DW_BS_NOBORDER) 6990 if(style & DW_BS_NOBORDER)
6946 { 6991 {
6947 [button setButtonType:NSMomentaryLight]; 6992 [button setButtonType:NSMomentaryLight];
6964 */ 7009 */
6965 void API dw_window_default(HWND handle, HWND defaultitem) 7010 void API dw_window_default(HWND handle, HWND defaultitem)
6966 { 7011 {
6967 DWWindow *window = handle; 7012 DWWindow *window = handle;
6968 id object = defaultitem; 7013 id object = defaultitem;
6969 7014
6970 if([window isKindOfClass:[NSWindow class]] && [object isKindOfClass:[NSControl class]]) 7015 if([window isKindOfClass:[NSWindow class]] && [object isKindOfClass:[NSControl class]])
6971 { 7016 {
6972 [window setInitialFirstResponder:defaultitem]; 7017 [window setInitialFirstResponder:defaultitem];
6973 } 7018 }
6974 } 7019 }
6981 */ 7026 */
6982 void API dw_window_click_default(HWND handle, HWND next) 7027 void API dw_window_click_default(HWND handle, HWND next)
6983 { 7028 {
6984 id object = handle; 7029 id object = handle;
6985 id control = next; 7030 id control = next;
6986 7031
6987 if([object isMemberOfClass:[DWWindow class]]) 7032 if([object isMemberOfClass:[DWWindow class]])
6988 { 7033 {
6989 if([control isMemberOfClass:[DWButton class]]) 7034 if([control isMemberOfClass:[DWButton class]])
6990 { 7035 {
6991 NSWindow *window = object; 7036 NSWindow *window = object;
6992 7037
6993 [window setDefaultButtonCell:control]; 7038 [window setDefaultButtonCell:control];
6994 } 7039 }
6995 } 7040 }
6996 else 7041 else
6997 { 7042 {
7228 7273
7229 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ]) 7274 if([ object isKindOfClass:[ NSWindow class ] ] || [ object isKindOfClass:[ NSButton class ] ])
7230 { 7275 {
7231 id window = handle; 7276 id window = handle;
7232 NSString *nsstr = [ window title]; 7277 NSString *nsstr = [ window title];
7233 7278
7234 return strdup([ nsstr UTF8String ]); 7279 return strdup([ nsstr UTF8String ]);
7235 } 7280 }
7236 else if([ object isKindOfClass:[ NSControl class ] ]) 7281 else if([ object isKindOfClass:[ NSControl class ] ])
7237 { 7282 {
7238 NSControl *control = handle; 7283 NSControl *control = handle;
7274 * handle: Handle to the window. 7319 * handle: Handle to the window.
7275 */ 7320 */
7276 void API dw_window_disable(HWND handle) 7321 void API dw_window_disable(HWND handle)
7277 { 7322 {
7278 id object = handle; 7323 id object = handle;
7279 7324
7280 if([object isMemberOfClass:[NSScrollView class]]) 7325 if([object isMemberOfClass:[NSScrollView class]])
7281 { 7326 {
7282 NSScrollView *sv = handle; 7327 NSScrollView *sv = handle;
7283 object = [sv documentView]; 7328 object = [sv documentView];
7284 } 7329 }
7288 [control setEnabled:NO]; 7333 [control setEnabled:NO];
7289 } 7334 }
7290 if([object isKindOfClass:[NSTextView class]]) 7335 if([object isKindOfClass:[NSTextView class]])
7291 { 7336 {
7292 NSTextView *mle = object; 7337 NSTextView *mle = object;
7293 7338
7294 [mle setEditable:NO]; 7339 [mle setEditable:NO];
7295 } 7340 }
7296 } 7341 }
7297 7342
7298 /* 7343 /*
7301 * handle: Handle to the window. 7346 * handle: Handle to the window.
7302 */ 7347 */
7303 void API dw_window_enable(HWND handle) 7348 void API dw_window_enable(HWND handle)
7304 { 7349 {
7305 id object = handle; 7350 id object = handle;
7306 7351
7307 if([object isMemberOfClass:[NSScrollView class]]) 7352 if([object isMemberOfClass:[NSScrollView class]])
7308 { 7353 {
7309 NSScrollView *sv = handle; 7354 NSScrollView *sv = handle;
7310 object = [sv documentView]; 7355 object = [sv documentView];
7311 } 7356 }
7315 [control setEnabled:YES]; 7360 [control setEnabled:YES];
7316 } 7361 }
7317 if([object isKindOfClass:[NSTextView class]]) 7362 if([object isKindOfClass:[NSTextView class]])
7318 { 7363 {
7319 NSTextView *mle = object; 7364 NSTextView *mle = object;
7320 7365
7321 [mle setEditable:YES]; 7366 [mle setEditable:YES];
7322 } 7367 }
7323 } 7368 }
7324 7369
7325 /* 7370 /*
8626 void _dwthreadstart(void *data) 8671 void _dwthreadstart(void *data)
8627 { 8672 {
8628 void (*threadfunc)(void *) = NULL; 8673 void (*threadfunc)(void *) = NULL;
8629 void **tmp = (void **)data; 8674 void **tmp = (void **)data;
8630 NSColor *color; 8675 NSColor *color;
8631 8676
8632 /* If we aren't using garbage collection we need autorelease pools */ 8677 /* If we aren't using garbage collection we need autorelease pools */
8633 #if !defined(GARBAGE_COLLECT) 8678 #if !defined(GARBAGE_COLLECT)
8634 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; 8679 NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
8635 pthread_setspecific(_dw_pool_key, pool); 8680 pthread_setspecific(_dw_pool_key, pool);
8636 #endif 8681 #endif
8638 8683
8639 threadfunc = (void (*)(void *))tmp[0]; 8684 threadfunc = (void (*)(void *))tmp[0];
8640 8685
8641 /* Start our thread function */ 8686 /* Start our thread function */
8642 threadfunc(tmp[1]); 8687 threadfunc(tmp[1]);
8643 8688
8644 /* Release the pool when we are done so we don't leak */ 8689 /* Release the pool when we are done so we don't leak */
8645 color = pthread_getspecific(_dw_fg_color_key); 8690 color = pthread_getspecific(_dw_fg_color_key);
8646 [color release]; 8691 [color release];
8647 color = pthread_getspecific(_dw_bg_color_key); 8692 color = pthread_getspecific(_dw_bg_color_key);
8648 [color release]; 8693 [color release];