| 410 scrollview.hasVerticalScroller = YES; |
410 scrollview.hasVerticalScroller = YES; |
| 411 scrollview.hasHorizontalScroller = NO; |
411 scrollview.hasHorizontalScroller = NO; |
| 412 scrollview.autohidesScrollers = YES; |
412 scrollview.autohidesScrollers = YES; |
| 413 |
413 |
| 414 NSOutlineView *outline = [[NSOutlineView alloc]init]; |
414 NSOutlineView *outline = [[NSOutlineView alloc]init]; |
| 415 NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"label"]; |
415 NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:@"x"]; |
| 416 [outline addTableColumn:column]; |
416 [outline addTableColumn:column]; |
| 417 outline.outlineTableColumn = column; |
417 outline.outlineTableColumn = column; |
| 418 outline.headerView = NULL; |
418 outline.headerView = NULL; |
| 419 outline.rowSizeStyle = NSTableViewRowSizeStyleDefault; |
419 outline.rowSizeStyle = NSTableViewRowSizeStyleDefault; |
| 420 outline.usesAutomaticRowHeights = YES; |
420 outline.usesAutomaticRowHeights = YES; |
| 421 outline.indentationPerLevel = 0; |
421 outline.indentationPerLevel = 0; |
| 422 |
422 |
| 423 outline.style = NSTableViewStyleSourceList; |
423 outline.style = NSTableViewStyleSourceList; |
| 424 |
424 |
| 425 // Make background transparent so vibrancy shows through |
425 // Make background transparent so vibrancy shows through |
| 426 //outline.backgroundColor = [NSColor clearColor]; |
|
| 427 scrollview.drawsBackground = NO; |
426 scrollview.drawsBackground = NO; |
| 428 |
427 |
| 429 scrollview.documentView = outline; |
428 scrollview.documentView = outline; |
| 430 |
429 |
| 431 UiLayout layout = UI_ARGS2LAYOUT(args); |
430 UiLayout layout = UI_ARGS2LAYOUT(args); |
| 486 |
485 |
| 487 [_sections removeAllObjects]; |
486 [_sections removeAllObjects]; |
| 488 |
487 |
| 489 CxIterator i = cxListIterator(_sublists); |
488 CxIterator i = cxListIterator(_sublists); |
| 490 int index = 0; |
489 int index = 0; |
| |
490 int rownum = 0; |
| 491 cx_foreach(UiSubList *, sl, i) { |
491 cx_foreach(UiSubList *, sl, i) { |
| 492 UiSourceListItem *section = [[UiSourceListItem alloc] init:self sublist:sl]; |
492 UiSourceListItem *section = [[UiSourceListItem alloc] init:self sublist:sl]; |
| 493 section.index = index; |
493 section.index = index; |
| |
494 section.rownum = rownum; |
| |
495 section.sublistStartRow = rownum; |
| 494 [section update:-1]; |
496 [section update:-1]; |
| 495 [_sections addObject:section]; |
497 [_sections addObject:section]; |
| 496 index++; |
498 index++; |
| |
499 rownum += 1 + section.items.count; |
| 497 } |
500 } |
| 498 |
501 |
| 499 [_outlineView reloadData]; |
502 [_outlineView reloadData]; |
| 500 [_outlineView expandItem:nil expandChildren:YES]; |
503 [_outlineView expandItem:nil expandChildren:YES]; |
| 501 } |
504 } |
| 628 - (void) outlineViewSelectionDidChange:(NSNotification *) notification { |
631 - (void) outlineViewSelectionDidChange:(NSNotification *) notification { |
| 629 UiEvent event; |
632 UiEvent event; |
| 630 event.obj = _obj; |
633 event.obj = _obj; |
| 631 event.window = event.obj->window; |
634 event.window = event.obj->window; |
| 632 event.document = event.obj->ctx->document; |
635 event.document = event.obj->ctx->document; |
| 633 event.eventdata = NULL; // TODO |
636 event.eventdata = NULL; |
| 634 event.eventdatatype = 0; // TODO |
637 event.eventdatatype = 0; |
| 635 event.intval = 0; |
638 event.intval = 0; |
| 636 event.set = ui_get_setop(); |
639 event.set = ui_get_setop(); |
| 637 |
640 |
| 638 UiSubListEventData sublistEvent; |
641 UiSubListEventData sublistEvent; |
| 639 |
642 |
| 640 NSInteger selectedRow = _outlineView.selectedRow; |
643 NSInteger selectedRow = _outlineView.selectedRow; |
| 641 if(selectedRow >= 0) { |
644 if(selectedRow >= 0) { |
| 642 UiSourceListItem *item = [_outlineView itemAtRow:selectedRow]; |
645 UiSourceListItem *item = [_outlineView itemAtRow:selectedRow]; |
| 643 UiSourceListItem *parent = item.parent; |
646 UiSourceListItem *parent = item.parent; |
| |
647 UiSubList *sublist = parent != nil ? parent.sublist : item.sublist; |
| 644 UiVar *var = parent != nil ? parent.var : item.var; |
648 UiVar *var = parent != nil ? parent.var : item.var; |
| 645 if(item && var) { |
649 if(item && var) { |
| 646 sublistEvent.list = var->value; |
650 sublistEvent.list = var->value; |
| 647 sublistEvent.sublist_index = parent.index; |
651 sublistEvent.sublist_index = parent ? parent.index : item.index; |
| 648 // TODO |
652 sublistEvent.row_index = (int)selectedRow - item.sublistStartRow - 1; |
| |
653 sublistEvent.sublist_userdata = sublist ? sublist->userdata : NULL; |
| |
654 sublistEvent.event_data = item.eventdata; |
| |
655 sublistEvent.row_data = sublistEvent.list->get(sublistEvent.list, sublistEvent.row_index); |
| 649 |
656 |
| 650 event.eventdata = &sublistEvent; |
657 event.eventdata = &sublistEvent; |
| |
658 event.eventdatatype = UI_EVENT_DATA_SUBLIST; |
| 651 } |
659 } |
| 652 } |
660 } |
| 653 |
661 |
| 654 if(_onactivate) { |
662 if(_onactivate) { |
| 655 _onactivate(&event, _onactivatedata); |
663 _onactivate(&event, _onactivatedata); |
| 708 _sourcelist.getvalue(list, _sublist->userdata, elm, index, &item, _sourcelist.getvaluedata); |
717 _sourcelist.getvalue(list, _sublist->userdata, elm, index, &item, _sourcelist.getvaluedata); |
| 709 } else { |
718 } else { |
| 710 item.label = strdup(elm); |
719 item.label = strdup(elm); |
| 711 } |
720 } |
| 712 |
721 |
| 713 [_items addObject:[[UiSourceListItem alloc] init:&item parent:self]]; |
722 UiSourceListItem *it = [[UiSourceListItem alloc] init:&item parent:self]; |
| |
723 it.index = index; |
| |
724 it.rownum = self.rownum + index; |
| |
725 it.sublistStartRow = _parent ? _parent.sublistStartRow : _sublistStartRow; |
| |
726 [_items addObject:it]; |
| 714 |
727 |
| 715 elm = list->next(list); |
728 elm = list->next(list); |
| 716 index++; |
729 index++; |
| 717 } |
730 } |
| 718 } |
731 } |