FROM : Ricky Sharp
DATE : Tue Nov 13 22:37:53 2007
On Nov 13, 2007, at 12:02 AM, shengjun_guan (ºÞÁn«T) wrote:
> I create one image browser application use NSMatrix .
> I show the file's image and file's name inside the Cell. Of course i
> make the Class: myCell which base from NSCell .And overwrite the
> NSCell's method: drawWithFrame: inView: to show the image in up
> content ,and text in down content .
>
> ---FOLLOW IS THE CODE of drawWithFrame: inView: IN MY CELL CLASS-----
> - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
> {
> if ((title != nil) || (image != nil))
> {
> NSRect imageFrame,textFrame, tempFrame;
> NSDivideRect(cellFrame, &imageFrame, &textFrame,
> cellFrame.size.height - 15, NSMinYEdge);
>
> [image setFlipped:YES];
> [image drawInRect:imageFrame fromRect:NSMakeRect(0,0,[image
> size].width,[image size].height) operation:NSCompositeSourceOver
> fraction:1.0];
>
> if ((cellFrame.size.width - [[title string] length] * 4) / 2 >= 0)
> {
> textFrame.origin.x += (cellFrame.size.width - [title length] *
> 4) / 2;
> }
> textFrame.origin.y += 25;
> [title drawInRect:textFrame];
> }
>
> [super drawWithFrame:cellFrame inView:controlView];
> }
>
> And , i have realizied that open the image file with Preview when
> double click the Cell.
> Now, i want to realizied to rename. When click the down content of
> the Cell, like the TextFied, user can input the
> new Text. How can i do. need I use NSView to replace NSMatrix ?
You can definitely keep using a cell. Check out Apple's sample:
/Examples/AppKit/DragNDropOutlineView/
Specifically, look at the class ImageAndTextCell.
When you run the application, you can double-click on the text next to
an icon to edit it. This is achieved by implementing
editWithFrame:inView:editor:delegate:event:. I believe you also want
to implement selectWithFrame:inView:editor:delegate:start:length:.
That class shows examples of both methods.
___________________________________________________________
Ricky A. Sharp mailto:<email_removed>
Instant Interactive(tm) http://www.instantinteractive.com
DATE : Tue Nov 13 22:37:53 2007
On Nov 13, 2007, at 12:02 AM, shengjun_guan (ºÞÁn«T) wrote:
> I create one image browser application use NSMatrix .
> I show the file's image and file's name inside the Cell. Of course i
> make the Class: myCell which base from NSCell .And overwrite the
> NSCell's method: drawWithFrame: inView: to show the image in up
> content ,and text in down content .
>
> ---FOLLOW IS THE CODE of drawWithFrame: inView: IN MY CELL CLASS-----
> - (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
> {
> if ((title != nil) || (image != nil))
> {
> NSRect imageFrame,textFrame, tempFrame;
> NSDivideRect(cellFrame, &imageFrame, &textFrame,
> cellFrame.size.height - 15, NSMinYEdge);
>
> [image setFlipped:YES];
> [image drawInRect:imageFrame fromRect:NSMakeRect(0,0,[image
> size].width,[image size].height) operation:NSCompositeSourceOver
> fraction:1.0];
>
> if ((cellFrame.size.width - [[title string] length] * 4) / 2 >= 0)
> {
> textFrame.origin.x += (cellFrame.size.width - [title length] *
> 4) / 2;
> }
> textFrame.origin.y += 25;
> [title drawInRect:textFrame];
> }
>
> [super drawWithFrame:cellFrame inView:controlView];
> }
>
> And , i have realizied that open the image file with Preview when
> double click the Cell.
> Now, i want to realizied to rename. When click the down content of
> the Cell, like the TextFied, user can input the
> new Text. How can i do. need I use NSView to replace NSMatrix ?
You can definitely keep using a cell. Check out Apple's sample:
/Examples/AppKit/DragNDropOutlineView/
Specifically, look at the class ImageAndTextCell.
When you run the application, you can double-click on the text next to
an icon to edit it. This is achieved by implementing
editWithFrame:inView:editor:delegate:event:. I believe you also want
to implement selectWithFrame:inView:editor:delegate:start:length:.
That class shows examples of both methods.
___________________________________________________________
Ricky A. Sharp mailto:<email_removed>
Instant Interactive(tm) http://www.instantinteractive.com
| Related mails | Author | Date |
|---|---|---|
| shengjun_guan (???… | Nov 13, 07:02 | |
| Ricky Sharp | Nov 13, 22:37 |






Cocoa mail archive

