Mercurial > dwindows
comparison mac/dw.m @ 669:62aae18e7b7d
Implemented most of the listbox functions for the actual listbox control...
previously it was just for comboboxes. Also added pointer/cursor support.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 27 Feb 2011 06:00:49 +0000 |
parents | 7b99731c6484 |
children | 0b920d0dc13e |
comparison
equal
deleted
inserted
replaced
668:7b99731c6484 | 669:62aae18e7b7d |
---|---|
169 { | 169 { |
170 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; | 170 int (* API clickfunc)(HWND, void *) = (int (* API)(HWND, void *))handler->signalfunction; |
171 | 171 |
172 return clickfunc(object, handler->data); | 172 return clickfunc(object, handler->data); |
173 } | 173 } |
174 case 9: | |
175 { | |
176 int (*containerselectfunc)(HWND, char *, void *) = handler->signalfunction; | |
177 | |
178 return containerselectfunc(handler->window, (char *)event, handler->data); | |
179 } | |
174 case 10: | 180 case 10: |
175 { | 181 { |
176 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; | 182 int (* API containercontextfunc)(HWND, char *, int, int, void *, void *) = (int (* API)(HWND, char *, int, int, void *, void *))handler->signalfunction; |
177 char *text = (char *)event; | 183 char *text = (char *)event; |
178 void *user = NULL; | 184 void *user = NULL; |
568 int lastAddPoint; | 574 int lastAddPoint; |
569 id scrollview; | 575 id scrollview; |
570 } | 576 } |
571 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; | 577 -(NSInteger)numberOfRowsInTableView:(NSTableView *)aTable; |
572 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; | 578 -(id)tableView:(NSTableView *)aTable objectValueForTableColumn:(NSTableColumn *)aCol row:(NSInteger)aRow; |
573 -(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex; | 579 /*-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex;*/ |
574 -(void *)userdata; | 580 -(void *)userdata; |
575 -(void)setUserdata:(void *)input; | 581 -(void)setUserdata:(void *)input; |
576 -(id)scrollview; | 582 -(id)scrollview; |
577 -(void)setScrollview:(id)input; | 583 -(void)setScrollview:(id)input; |
578 -(void)addColumn:(NSTableColumn *)input andType:(int)type; | 584 -(void)addColumn:(NSTableColumn *)input andType:(int)type; |
580 -(int)addRows:(int)number; | 586 -(int)addRows:(int)number; |
581 -(void)editCell:(id)input at:(int)row and:(int)col; | 587 -(void)editCell:(id)input at:(int)row and:(int)col; |
582 -(void)removeRow:(int)row; | 588 -(void)removeRow:(int)row; |
583 -(void)setRow:(int)row title:(void *)input; | 589 -(void)setRow:(int)row title:(void *)input; |
584 -(void *)getRowTitle:(int)row; | 590 -(void *)getRowTitle:(int)row; |
591 -(id)getRow:(int)row and:(int)col; | |
585 -(int)cellType:(int)col; | 592 -(int)cellType:(int)col; |
586 -(int)lastAddPoint; | 593 -(int)lastAddPoint; |
587 -(void)clear; | 594 -(void)clear; |
588 -(void)setup; | 595 -(void)setup; |
589 -(void)selectionChanged:(id)sender; | 596 -(void)selectionChanged:(id)sender; |
625 return ([this isKindOfClass:[NSNull class]]) ? nil : this; | 632 return ([this isKindOfClass:[NSNull class]]) ? nil : this; |
626 } | 633 } |
627 } | 634 } |
628 return nil; | 635 return nil; |
629 } | 636 } |
630 -(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex | 637 /*-(void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex |
631 { | 638 { |
632 if(tvcols) | 639 if(tvcols) |
633 { | 640 { |
634 int z, col = -1; | 641 int z, col = -1; |
635 int count = (int)[tvcols count]; | 642 int count = (int)[tvcols count]; |
646 { | 653 { |
647 int index = (int)(rowIndex * count) + col; | 654 int index = (int)(rowIndex * count) + col; |
648 [data replaceObjectAtIndex:index withObject:anObject]; | 655 [data replaceObjectAtIndex:index withObject:anObject]; |
649 } | 656 } |
650 } | 657 } |
651 } | 658 }*/ |
652 -(void *)userdata { return userdata; } | 659 -(void *)userdata { return userdata; } |
653 -(void)setUserdata:(void *)input { userdata = input; } | 660 -(void)setUserdata:(void *)input { userdata = input; } |
654 -(NSScrollView *)scrollview { return scrollview; } | 661 -(NSScrollView *)scrollview { return scrollview; } |
655 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } | 662 -(void)setScrollview:(NSScrollView *)input { scrollview = input; } |
656 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } | 663 -(void)addColumn:(NSTableColumn *)input andType:(int)type { if(tvcols) { [tvcols addObject:input]; [types addObject:[NSNumber numberWithInt:type]]; } } |
657 -(int)addRow:(NSArray *)input { if(data) { [data addObjectsFromArray:input]; [titles addPointer:NULL]; return (int)[titles count]; } return 0; } | 664 -(int)addRow:(NSArray *)input { if(data) { lastAddPoint = (int)[titles count]; [data addObjectsFromArray:input]; [titles addPointer:NULL]; return (int)[titles count]; } return 0; } |
658 -(int)addRows:(int)number | 665 -(int)addRows:(int)number |
659 { | 666 { |
660 if(tvcols) | 667 if(tvcols) |
661 { | 668 { |
662 int count = (int)number * [tvcols count]; | 669 int count = (int)number * [tvcols count]; |
705 } | 712 } |
706 } | 713 } |
707 } | 714 } |
708 -(void)setRow:(int)row title:(void *)input { if(titles && input) { [titles replacePointerAtIndex:row withPointer:input]; } } | 715 -(void)setRow:(int)row title:(void *)input { if(titles && input) { [titles replacePointerAtIndex:row withPointer:input]; } } |
709 -(void *)getRowTitle:(int)row { if(titles) { return [titles pointerAtIndex:row]; } return NULL; } | 716 -(void *)getRowTitle:(int)row { if(titles) { return [titles pointerAtIndex:row]; } return NULL; } |
717 -(id)getRow:(int)row and:(int)col { if(data) { int index = (int)(row * [tvcols count]) + col; return [data objectAtIndex:index]; } return nil; } | |
710 -(int)cellType:(int)col { return [[types objectAtIndex:col] intValue]; } | 718 -(int)cellType:(int)col { return [[types objectAtIndex:col] intValue]; } |
711 -(int)lastAddPoint { return lastAddPoint; } | 719 -(int)lastAddPoint { return lastAddPoint; } |
712 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; } | 720 -(void)clear { if(data) { [data removeAllObjects]; while([titles count]) { [titles removePointerAtIndex:0]; } } lastAddPoint = 0; } |
713 -(void)setup | 721 -(void)setup |
714 { | 722 { |
718 titles = [NSPointerArray pointerArrayWithWeakObjects]; | 726 titles = [NSPointerArray pointerArrayWithWeakObjects]; |
719 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:[self window]]; | 727 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(selectionChanged:) name:NSTableViewSelectionDidChangeNotification object:[self window]]; |
720 } | 728 } |
721 -(void)selectionChanged:(id)sender | 729 -(void)selectionChanged:(id)sender |
722 { | 730 { |
723 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 12); | 731 _event_handler(self, (NSEvent *)[self getRowTitle:(int)[self selectedRow]], 9); |
724 } | 732 } |
725 -(NSMenu *)menuForEvent:(NSEvent *)event | 733 -(NSMenu *)menuForEvent:(NSEvent *)event |
726 { | 734 { |
727 int row; | 735 int row; |
728 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; | 736 NSPoint where = [self convertPoint:[event locationInWindow] fromView:nil]; |
1888 /* Free the old data */ | 1896 /* Free the old data */ |
1889 if(thisbox->count) | 1897 if(thisbox->count) |
1890 free(thisitem); | 1898 free(thisitem); |
1891 } | 1899 } |
1892 | 1900 |
1901 HWND _button_new(char *text, ULONG id) | |
1902 { | |
1903 DWButton *button = [[DWButton alloc] init]; | |
1904 if(text && *text) | |
1905 { | |
1906 [button setTitle:[ NSString stringWithUTF8String:text ]]; | |
1907 } | |
1908 [button setTarget:button]; | |
1909 [button setAction:@selector(buttonClicked:)]; | |
1910 [button setTag:id]; | |
1911 [button setButtonType:NSMomentaryPushInButton]; | |
1912 [button setBezelStyle:NSThickerSquareBezelStyle]; | |
1913 return button; | |
1914 } | |
1915 | |
1893 /* | 1916 /* |
1894 * Create a new button window (widget) to be packed. | 1917 * Create a new button window (widget) to be packed. |
1895 * Parameters: | 1918 * Parameters: |
1896 * text: The text to be display by the static text widget. | 1919 * text: The text to be display by the static text widget. |
1897 * id: An ID to be used with dw_window_from_id() or 0L. | 1920 * id: An ID to be used with dw_window_from_id() or 0L. |
1898 */ | 1921 */ |
1899 HWND API dw_button_new(char *text, ULONG id) | 1922 HWND API dw_button_new(char *text, ULONG id) |
1900 { | 1923 { |
1901 DWButton *button = [[DWButton alloc] init]; | 1924 DWButton *button = _button_new(text, id); |
1902 if(text && *text) | 1925 [button setButtonType:NSMomentaryPushInButton]; |
1903 { | 1926 [button setBezelStyle:NSRoundedBezelStyle]; |
1904 [button setTitle:[ NSString stringWithUTF8String:text ]]; | 1927 [button setImagePosition:NSNoImage]; |
1905 } | 1928 [button setAlignment:NSCenterTextAlignment]; |
1906 [button setButtonType:NSMomentaryPushInButton]; | 1929 [[button cell] setControlTint:NSBlueControlTint]; |
1907 [button setBezelStyle:NSThickerSquareBezelStyle]; | |
1908 [button setTarget:button]; | |
1909 [button setAction:@selector(buttonClicked:)]; | |
1910 /*[button setGradientType:NSGradientConvexWeak];*/ | |
1911 [button setTag:id]; | |
1912 return button; | 1930 return button; |
1913 } | 1931 } |
1914 | 1932 |
1915 /* | 1933 /* |
1916 * Create a new Entryfield window (widget) to be packed. | 1934 * Create a new Entryfield window (widget) to be packed. |
1973 * (BMP on OS/2 or Windows, XPM on Unix) | 1991 * (BMP on OS/2 or Windows, XPM on Unix) |
1974 */ | 1992 */ |
1975 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) | 1993 HWND API dw_bitmapbutton_new_from_file(char *text, unsigned long id, char *filename) |
1976 { | 1994 { |
1977 NSImage *image = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; | 1995 NSImage *image = [[NSImage alloc] initWithContentsOfFile:[ NSString stringWithUTF8String:filename ]]; |
1978 DWButton *button = dw_button_new("", id); | 1996 DWButton *button = _button_new("", id); |
1979 [button setImage:image]; | 1997 [button setImage:image]; |
1980 return button; | 1998 return button; |
1981 } | 1999 } |
1982 | 2000 |
1983 /* | 2001 /* |
1991 */ | 2009 */ |
1992 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) | 2010 HWND API dw_bitmapbutton_new_from_data(char *text, unsigned long id, char *data, int len) |
1993 { | 2011 { |
1994 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; | 2012 NSData *thisdata = [[NSData alloc] dataWithBytes:data length:len]; |
1995 NSImage *image = [[NSImage alloc] initWithData:thisdata]; | 2013 NSImage *image = [[NSImage alloc] initWithData:thisdata]; |
1996 DWButton *button = dw_button_new("", id); | 2014 DWButton *button = _button_new("", id); |
1997 [button setImage:image]; | 2015 [button setImage:image]; |
1998 return button; | 2016 return button; |
1999 } | 2017 } |
2000 | 2018 |
2001 /* | 2019 /* |
2050 * text: The text to be display by the static text widget. | 2068 * text: The text to be display by the static text widget. |
2051 * id: An ID to be used with dw_window_from_id() or 0L. | 2069 * id: An ID to be used with dw_window_from_id() or 0L. |
2052 */ | 2070 */ |
2053 HWND API dw_radiobutton_new(char *text, ULONG id) | 2071 HWND API dw_radiobutton_new(char *text, ULONG id) |
2054 { | 2072 { |
2055 DWButton *button = dw_button_new(text, id); | 2073 DWButton *button = _button_new(text, id); |
2056 [button setButtonType:NSRadioButton]; | 2074 [button setButtonType:NSRadioButton]; |
2057 return button; | 2075 return button; |
2058 } | 2076 } |
2059 | 2077 |
2060 /* | 2078 /* |
2188 * text: The text to be display by the static text widget. | 2206 * text: The text to be display by the static text widget. |
2189 * id: An ID to be used with dw_window_from_id() or 0L. | 2207 * id: An ID to be used with dw_window_from_id() or 0L. |
2190 */ | 2208 */ |
2191 HWND API dw_checkbox_new(char *text, ULONG id) | 2209 HWND API dw_checkbox_new(char *text, ULONG id) |
2192 { | 2210 { |
2193 DWButton *button = dw_button_new(text, id); | 2211 DWButton *button = _button_new(text, id); |
2194 [button setButtonType:NSSwitchButton]; | 2212 [button setButtonType:NSSwitchButton]; |
2195 [button setBezelStyle:NSRegularSquareBezelStyle]; | 2213 [button setBezelStyle:NSRegularSquareBezelStyle]; |
2196 return button; | 2214 return button; |
2197 } | 2215 } |
2198 | 2216 |
2287 { | 2305 { |
2288 DWComboBox *combo = handle; | 2306 DWComboBox *combo = handle; |
2289 | 2307 |
2290 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]]; | 2308 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text ]]; |
2291 } | 2309 } |
2310 else if([object isMemberOfClass:[DWContainer class]]) | |
2311 { | |
2312 DWContainer *cont = handle; | |
2313 NSString *nstr = [ NSString stringWithUTF8String:text ]; | |
2314 NSArray *newrow = [NSArray arrayWithObject:nstr]; | |
2315 | |
2316 [cont addRow:newrow]; | |
2317 | |
2318 [newrow release]; | |
2319 } | |
2292 } | 2320 } |
2293 | 2321 |
2294 /* | 2322 /* |
2295 * Inserts the specified text into the listbox's (or combobox) entry list. | 2323 * Inserts the specified text into the listbox's (or combobox) entry list. |
2296 * Parameters: | 2324 * Parameters: |
2306 { | 2334 { |
2307 DWComboBox *combo = handle; | 2335 DWComboBox *combo = handle; |
2308 | 2336 |
2309 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos]; | 2337 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:text ] atIndex:pos]; |
2310 } | 2338 } |
2339 else if([object isMemberOfClass:[DWContainer class]]) | |
2340 { | |
2341 NSLog(@"dw_listbox_insert() unimplemented\n"); | |
2342 } | |
2311 } | 2343 } |
2312 | 2344 |
2313 /* | 2345 /* |
2314 * Appends the specified text items to the listbox's (or combobox) entry list. | 2346 * Appends the specified text items to the listbox's (or combobox) entry list. |
2315 * Parameters: | 2347 * Parameters: |
2329 for(z=0;z<count;z++) | 2361 for(z=0;z<count;z++) |
2330 { | 2362 { |
2331 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]]; | 2363 [combo addItemWithObjectValue:[ NSString stringWithUTF8String:text[z] ]]; |
2332 } | 2364 } |
2333 } | 2365 } |
2366 else if([object isMemberOfClass:[DWContainer class]]) | |
2367 { | |
2368 DWContainer *cont = handle; | |
2369 int z; | |
2370 | |
2371 for(z=0;z<count;z++) | |
2372 { | |
2373 NSString *nstr = [ NSString stringWithUTF8String:text[z] ]; | |
2374 NSArray *newrow = [[NSArray alloc] arrayWithObject:nstr]; | |
2375 | |
2376 [cont addRow:newrow]; | |
2377 | |
2378 [newrow release]; | |
2379 } | |
2380 } | |
2334 } | 2381 } |
2335 | 2382 |
2336 /* | 2383 /* |
2337 * Clears the listbox's (or combobox) list of all entries. | 2384 * Clears the listbox's (or combobox) list of all entries. |
2338 * Parameters: | 2385 * Parameters: |
2346 { | 2393 { |
2347 DWComboBox *combo = handle; | 2394 DWComboBox *combo = handle; |
2348 | 2395 |
2349 [combo removeAllItems]; | 2396 [combo removeAllItems]; |
2350 } | 2397 } |
2398 else if([object isMemberOfClass:[DWContainer class]]) | |
2399 { | |
2400 DWContainer *cont = handle; | |
2401 | |
2402 [cont clear]; | |
2403 } | |
2351 } | 2404 } |
2352 | 2405 |
2353 /* | 2406 /* |
2354 * Returns the listbox's item count. | 2407 * Returns the listbox's item count. |
2355 * Parameters: | 2408 * Parameters: |
2363 { | 2416 { |
2364 DWComboBox *combo = handle; | 2417 DWComboBox *combo = handle; |
2365 | 2418 |
2366 return (int)[combo numberOfItems]; | 2419 return (int)[combo numberOfItems]; |
2367 } | 2420 } |
2421 else if([object isMemberOfClass:[DWContainer class]]) | |
2422 { | |
2423 DWContainer *cont = handle; | |
2424 | |
2425 return (int)[cont numberOfRowsInTableView:cont]; | |
2426 } | |
2368 return 0; | 2427 return 0; |
2369 } | 2428 } |
2370 | 2429 |
2371 /* | 2430 /* |
2372 * Sets the topmost item in the viewport. | 2431 * Sets the topmost item in the viewport. |
2382 { | 2441 { |
2383 DWComboBox *combo = handle; | 2442 DWComboBox *combo = handle; |
2384 | 2443 |
2385 [combo scrollItemAtIndexToTop:top]; | 2444 [combo scrollItemAtIndexToTop:top]; |
2386 } | 2445 } |
2446 else if([object isMemberOfClass:[DWContainer class]]) | |
2447 { | |
2448 DWContainer *cont = handle; | |
2449 | |
2450 [cont scrollRowToVisible:top]; | |
2451 } | |
2387 } | 2452 } |
2388 | 2453 |
2389 /* | 2454 /* |
2390 * Copies the given index item's text into buffer. | 2455 * Copies the given index item's text into buffer. |
2391 * Parameters: | 2456 * Parameters: |
2402 { | 2467 { |
2403 DWComboBox *combo = handle; | 2468 DWComboBox *combo = handle; |
2404 NSString *nstr = [combo itemObjectValueAtIndex:index]; | 2469 NSString *nstr = [combo itemObjectValueAtIndex:index]; |
2405 strncpy(buffer, [ nstr UTF8String ], length - 1); | 2470 strncpy(buffer, [ nstr UTF8String ], length - 1); |
2406 } | 2471 } |
2472 else if([object isMemberOfClass:[DWContainer class]]) | |
2473 { | |
2474 DWContainer *cont = handle; | |
2475 NSString *nstr = [cont getRow:index and:0]; | |
2476 | |
2477 strncpy(buffer, [ nstr UTF8String ], length - 1); | |
2478 } | |
2407 } | 2479 } |
2408 | 2480 |
2409 /* | 2481 /* |
2410 * Sets the text of a given listbox entry. | 2482 * Sets the text of a given listbox entry. |
2411 * Parameters: | 2483 * Parameters: |
2422 DWComboBox *combo = handle; | 2494 DWComboBox *combo = handle; |
2423 | 2495 |
2424 [combo removeItemAtIndex:index]; | 2496 [combo removeItemAtIndex:index]; |
2425 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:buffer ] atIndex:index]; | 2497 [combo insertItemWithObjectValue:[ NSString stringWithUTF8String:buffer ] atIndex:index]; |
2426 } | 2498 } |
2499 else if([object isMemberOfClass:[DWContainer class]]) | |
2500 { | |
2501 DWContainer *cont = handle; | |
2502 NSString *nstr = [ NSString stringWithUTF8String:buffer ]; | |
2503 | |
2504 [cont editCell:nstr at:index and:0]; | |
2505 } | |
2506 | |
2427 } | 2507 } |
2428 | 2508 |
2429 /* | 2509 /* |
2430 * Returns the index to the item in the list currently selected. | 2510 * Returns the index to the item in the list currently selected. |
2431 * Parameters: | 2511 * Parameters: |
2438 if([object isMemberOfClass:[DWComboBox class]]) | 2518 if([object isMemberOfClass:[DWComboBox class]]) |
2439 { | 2519 { |
2440 DWComboBox *combo = handle; | 2520 DWComboBox *combo = handle; |
2441 return (int)[combo indexOfSelectedItem]; | 2521 return (int)[combo indexOfSelectedItem]; |
2442 } | 2522 } |
2523 else if([object isMemberOfClass:[DWContainer class]]) | |
2524 { | |
2525 DWContainer *cont = handle; | |
2526 | |
2527 return (int)[cont selectedRow]; | |
2528 } | |
2443 return -1; | 2529 return -1; |
2444 } | 2530 } |
2445 | 2531 |
2446 /* | 2532 /* |
2447 * Returns the index to the current selected item or -1 when done. | 2533 * Returns the index to the current selected item or -1 when done. |
2449 * handle: Handle to the listbox to be queried. | 2535 * handle: Handle to the listbox to be queried. |
2450 * where: Either the previous return or -1 to restart. | 2536 * where: Either the previous return or -1 to restart. |
2451 */ | 2537 */ |
2452 int API dw_listbox_selected_multi(HWND handle, int where) | 2538 int API dw_listbox_selected_multi(HWND handle, int where) |
2453 { | 2539 { |
2454 NSLog(@"dw_listbox_selected_multi() unimplemented\n"); | 2540 id object = handle; |
2455 return 0; | 2541 int retval = -1; |
2542 | |
2543 if([object isMemberOfClass:[DWContainer class]]) | |
2544 { | |
2545 DWContainer *cont = handle; | |
2546 NSIndexSet *selected = [cont selectedRowIndexes]; | |
2547 NSUInteger result = [selected indexGreaterThanIndex:where]; | |
2548 | |
2549 if(result != NSNotFound) | |
2550 { | |
2551 retval = (int)result; | |
2552 } | |
2553 [selected release]; | |
2554 } | |
2555 return retval; | |
2456 } | 2556 } |
2457 | 2557 |
2458 /* | 2558 /* |
2459 * Sets the selection state of a given index. | 2559 * Sets the selection state of a given index. |
2460 * Parameters: | 2560 * Parameters: |
2472 if(state) | 2572 if(state) |
2473 [combo selectItemAtIndex:index]; | 2573 [combo selectItemAtIndex:index]; |
2474 else | 2574 else |
2475 [combo deselectItemAtIndex:index]; | 2575 [combo deselectItemAtIndex:index]; |
2476 } | 2576 } |
2577 else if([object isMemberOfClass:[DWContainer class]]) | |
2578 { | |
2579 DWContainer *cont = handle; | |
2580 NSIndexSet *selected = [[NSIndexSet alloc] initWithIndex:(NSUInteger)index]; | |
2581 | |
2582 [cont selectRowIndexes:selected byExtendingSelection:YES]; | |
2583 [selected release]; | |
2584 } | |
2477 } | 2585 } |
2478 | 2586 |
2479 /* | 2587 /* |
2480 * Deletes the item with given index from the list. | 2588 * Deletes the item with given index from the list. |
2481 * Parameters: | 2589 * Parameters: |
2490 { | 2598 { |
2491 DWComboBox *combo = handle; | 2599 DWComboBox *combo = handle; |
2492 | 2600 |
2493 [combo removeItemAtIndex:index]; | 2601 [combo removeItemAtIndex:index]; |
2494 } | 2602 } |
2603 else if([object isMemberOfClass:[DWContainer class]]) | |
2604 { | |
2605 DWContainer *cont = handle; | |
2606 | |
2607 [cont removeRow:index]; | |
2608 } | |
2495 } | 2609 } |
2496 | 2610 |
2497 /* | 2611 /* |
2498 * Create a new Combobox window (widget) to be packed. | 2612 * Create a new Combobox window (widget) to be packed. |
2499 * Parameters: | 2613 * Parameters: |
2739 */ | 2853 */ |
2740 unsigned long API dw_color_choose(unsigned long value) | 2854 unsigned long API dw_color_choose(unsigned long value) |
2741 { | 2855 { |
2742 /* Create the File Save Dialog class. */ | 2856 /* Create the File Save Dialog class. */ |
2743 DWColorChoose *colorDlg = (DWColorChoose *)[DWColorChoose sharedColorPanel]; | 2857 DWColorChoose *colorDlg = (DWColorChoose *)[DWColorChoose sharedColorPanel]; |
2744 NSColor *color = [[[NSColor alloc] init] autorelease]; | 2858 NSColor *color = [NSColor colorWithDeviceRed: DW_RED_VALUE(_foreground)/255.0 green: DW_GREEN_VALUE(_foreground)/255.0 blue: DW_BLUE_VALUE(_foreground)/255.0 alpha: 1]; |
2745 DWDialog *dialog = dw_dialog_new(colorDlg); | 2859 DWDialog *dialog = dw_dialog_new(colorDlg); |
2746 | 2860 |
2747 /* Set defaults for the dialog. */ | 2861 /* Set defaults for the dialog. */ |
2748 [colorDlg setColor:color]; | 2862 [colorDlg setColor:color]; |
2749 [colorDlg setDialog:dialog]; | 2863 [colorDlg setDialog:dialog]; |
4376 * handle: Handle to widget for which to change. | 4490 * handle: Handle to widget for which to change. |
4377 * cursortype: ID of the pointer you want. | 4491 * cursortype: ID of the pointer you want. |
4378 */ | 4492 */ |
4379 void API dw_window_set_pointer(HWND handle, int pointertype) | 4493 void API dw_window_set_pointer(HWND handle, int pointertype) |
4380 { | 4494 { |
4381 NSLog(@"dw_window_set_pointer() unimplemented\n"); | 4495 id object = handle; |
4496 | |
4497 if([ object isKindOfClass:[ NSView class ] ]) | |
4498 { | |
4499 NSView *view = handle; | |
4500 | |
4501 if(pointertype == DW_POINTER_DEFAULT) | |
4502 { | |
4503 [view discardCursorRects]; | |
4504 } | |
4505 else if(pointertype == DW_POINTER_ARROW) | |
4506 { | |
4507 NSRect rect = [view frame]; | |
4508 NSCursor *cursor = [NSCursor arrowCursor]; | |
4509 | |
4510 [view addCursorRect:rect cursor:cursor]; | |
4511 } | |
4512 /* No cursor for DW_POINTER_CLOCK? */ | |
4513 } | |
4382 } | 4514 } |
4383 | 4515 |
4384 /* | 4516 /* |
4385 * Makes the window visible. | 4517 * Makes the window visible. |
4386 * Parameters: | 4518 * Parameters: |