• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Programmatically creating NSButton
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programmatically creating NSButton


  • Subject: Re: Programmatically creating NSButton
  • From: Greg Hulands <email@hidden>
  • Date: Sun, 25 Apr 2004 09:34:30 +1000

What I am doing is writing an application that creates aqua buttons and saves them as a png to use on a website. So what I am doing is drawing the cell into the image and then writing the image out, only that the cell is not drawing how it should be.

Here is the image: http://www.framedphotographics.com/b_Add_a_d.png


On 25/04/2004, at 12:27 AM, Jeremy Dronfield wrote:

I'm not quite clear now exactly what your goal is. Are you trying to make a button from a custom image, or are you simply trying to create and display a standard NSButton programmatically? It sounded originally like you wanted the latter, but now I'm not so sure.

-Jeremy


On 24 Apr 2004, at 2:35 pm, Greg Hulands wrote:

What I have now done is created a prototype button in IB and made
connections through to them so I can access the cell and the exact same
thing is happening when using the cell of a "properly created" button.
For instance, the text is not vertically aligned like it should be
(center) and the key equivalent is not shown, in this case the button
should be blue for "\r".

This is really quite puzzling as there seems to be something not
happening when just drawing the cell.

Here is the code that captures the button cell into an image.

- (NSImage *)btnGenerator:(NSButtonCell *)btn
{
NSSize size = [btn cellSize];
size.width += 2 * [padding floatValue];

NSImage *img = [[NSImage alloc] initWithSize:size];
NSRect frame = NSMakeRect(0,0,size.width, size.height);

[img lockFocus];
[[NSColor clearColor] set];
NSRectFill(frame);
[btn drawWithFrame:frame
inView:nil];

[img unlockFocus];

return [img autorelease];
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >Programmatically creating NSButton (From: Greg Hulands <email@hidden>)
 >Re: Programmatically creating NSButton (From: Jeremy Dronfield <email@hidden>)
 >Re: Programmatically creating NSButton (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: Adding a Systems Preference panel
  • Next by Date: Re: Adding a Systems Preference panel
  • Previous by thread: Re: Programmatically creating NSButton
  • Next by thread: Accepting a proxy-icon drop
  • Index(es):
    • Date
    • Thread