objective c - NSOutlineView Changing disclosure Image -
i outline view, adding custom cell, drawing custom cell, referring example code , present in cocoa documentation
http://www.martinkahr.com/2007/05/04/nscell-image-and-text-sample/
i want change disclosure image of cell custom image, have tried following things
- (void)outlineview:(nsoutlineview *)outlineview willdisplaycell:(id)cell fortablecolumn:(nstablecolumn *)tablecolumn item:(id)item { if([item iskindofclass:[nsvalue class]]) { mydata *pdt = (mydata *)[item pointervalue]; if(pdt->isgroupelement()) { [cell setimage:pgroupimage]; } } }
but not working, there other way change disclosure image, how can find out in willdisplaycell whether item expand or collapse, can set image accordingly,
is place change disclosure image ?
you've got basic idea need draw image yourself. here's code use:
- (void)outlineview:(nsoutlineview *)outlineview willdisplayoutlinecell:(id)cell fortablecolumn:(nstablecolumn *)tablecolumn item:(id)item { nsstring *theimagename; nsinteger thecellvalue = [cell integervalue]; if (thecellvalue==1) { theimagename = @"pmoutlinecellon"; } else if (thecellvalue==0) { theimagename = @"pmoutlinecelloff"; } else { theimagename = @"pmoutlinecellmixed"; } nsimage *theimage = [nsimage imagenamed: theimagename]; nsrect theframe = [outlineview frameofoutlinecellatrow:[outlineview rowforitem: item]]; theframe.origin.y = theframe.origin.y +17; // adjust theframe here position image [theimage compositetopoint: theframe.origin operation:nscompositesourceover]; [cell setimageposition: nsnoimage]; }
you need 3 different images can see, 1 on
state, 1 off
state , 1 mixed
state should halfway between two. mixed state makes sure still opening , closing animation.
Comments
Post a Comment