Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

sethi.hitesh

macrumors newbie
Original poster
Mar 23, 2006
4
0
Hi All,

I am very new to Apple, and presently i am trying to make a screen (somehting like a contact list screen of iChat)

The problem that i am facing is that i am not able to attach a thumbnail picture of the person along with his name.

Can anybody help me as to what shall i do to have a contact list with images and name side by side.

I shall be very greatful if the replies are also CC'ed to my e mail address sethi.hitesh@gmail.com

Regds,
Hitesh
 

Soulstorm

macrumors 68000
Feb 1, 2005
1,887
1
I haven't been invlolved with iChat.. but I think you are in the wrong forum section here...
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
By 'screen' do you actually mean window?

I'm sorry but it sounds that any answer I give will be really over your head at the moment. But here goes. In Cocoa you need to add the NSImage of the thumbnail as an attachment to an NSAttributedString. In other languages you'd do it differently - you don't say what language you're using.
 

sethi.hitesh

macrumors newbie
Original poster
Mar 23, 2006
4
0
Hi Caveman,

Thanks for the reply, I am using Objective C to design the GUI .

Since i am new to programming so not clear with it, Is it possible for you to send me small demo along with the code or any kind of help.

I shall really appreciate the same.

Regds,
Hitesh
 

caveman_uk

Guest
Feb 17, 2003
2,390
1
Hitchin, Herts, UK
From http://www.borkware.com/quickies/one?topic=NSString


Code:
Putting an image into an attributed string
You'll need to use a text attachment.

- (NSAttributedString *) prettyName
{
    NSTextAttachment *attachment;
    attachment = [[[NSTextAttachment alloc] init] autorelease];
    NSCell *cell = [attachment attachmentCell];

    NSImage *icon = [self icon]; // or wherever you are getting your image
    [cell setImage: icon];

    NSString *name = [self name];
    NSAttributedString *attrname;
    attrname = [[NSAttributedString alloc] initWithString: name];

    NSMutableAttributedString *prettyName;
    prettyName = (id)[NSMutableAttributedString attributedStringWithAttachment:
                                                attachment]; // cast to quiet compiler warning
    [prettyName appendAttributedString: attrname];

    [attrname release];

    return (prettyName);

} // prettyName

This puts the image at the front of the string. To put the image in the middle of the string, you'll need to create an attributedstring with attachment, and then append that to your final attributed string.

You would probably need to modify this but a buddy list is basically an NSTableView with the objectFor... datasource method returning the required attributed string. There's loads of stuff you can do with custom cells in TableViews but it's rather complicated and requires custom drawing code.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.