Custom Control Questions
Custom Control Questions
- Subject: Custom Control Questions
- From: "Alex Bumbu" <email@hidden>
- Date: Wed, 15 Aug 2007 18:56:19 +0200
Hello! I'm trying to create a custom control which contains an Custom View
and a Button. Until now I've never needed to use the Custom Controls. I've
found how to create Custom Controls and how to use them in the project from
the Clock Control application provided by Apple, but the problem is that I
couldn't find a way to load an image (TIFF) in the Custom View. I've put in
the palette the Custom View and the button, and I've made the Custom View of
the class I needed. The problem is that even if I tried to load the image
with the code found in the Apple's example (the image is called
ClockFace.tiff and I've put it in the resources):
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
NSImage *clockFaceImage = [NSImage imageNamed: @"ClockFace"];
float clockRadius = MIN(NSHeight(cellFrame), NSWidth(cellFrame));
// Draw the clock face (draw it flipped if we are in a flipped view,
like NSMatrix).
[clockFaceImage setFlipped:[controlView isFlipped]];
[clockFaceImage drawInRect:NSMakeRect(NSMinX(cellFrame),
NSMinY(cellFrame),clockRadius,clockRadius)
fromRect:NSMakeRect(0,0,[clockFaceImage size].width, [clockFaceImage
size].height) operation:NSCompositeSourceOver fraction:1.0];
}
or this code:
[[NSImageCell alloc] initImageCell:[NSImage imageNamed:@"ClockFace"]];
in the init method, the image wasn't displayed.
The other question I have, and maybe you can help me, is: Can I use a button
in a Custom Control? Should I create a Controller for the actions of the
button (like in the usual applications) and call those methods from the
controller in the Control main class (the one that subclasses NSControl)? Or
is there any other way. Please help me if you can. Thank you very much.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden