[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Button Cell Images
From: |
Richard Frith-Macdonald |
Subject: |
Re: Button Cell Images |
Date: |
Mon, 25 Jun 2007 06:42:11 +0100 |
On 24 Jun 2007, at 08:34, Christopher Armstrong wrote:
Hi
I think I've written on this before, but I don't remember getting a
reply so I'll try again. I want to put some images into a theme
bundle that are to be used as button images for radio buttons and
switch buttons. It appears the API for this is incomplete. Someone
has been working on it but I am trying to understand what they were
doing.
It's a long time since I had a chance to work on that ... I can
hardly remember myself. I think I stopped at the point where I
realised I needed to do a lot of experimentation with Apple's code to
make sure we matched it's behavior, and didn't have the time to do
that experimentation.
From what I can see, button images are currently loaded from the
Appkit bundle by using the +[NSImage imageNamed:] API when -
[NSButtonCell setButtonType:] is called. I believe the intention is
to replace the encoding and decoding of system button images with
instances of NSButtonImageSource; there appears to be some code to
do this in NSButtonCell.m but it doesn't make any sense.
NSButtonImageSource also seems incomplete and it isn't clear what
role GSTheme plays in this.
My guess is that NSButtonImageSource instances are to be created
for each type of button (NSRadioButton and NSSwitch), and they are
to be put where -[NSButtonCell setImage:] is. NSButtonImageSource
appears to be a hidden class in Cocoa as both QuantumStep and
Cocotron have versions of it. I don't understand the part where it
only gets stored for the alternate image (not the main one as well).
Would someone kindly explain what the intention of this is and how
it should work? I have the time to work on it at the moment but I
have no idea what should happen.
The basic idea is that buttons of the standard types have to have a
default set of images to be automatically used when the button is in
various states, but the programmer can override this behavior by
setting their own image and alternate image. Apple implemented this
using a private NSButtonImageSource class to provide the images as
long as the button didn't have the images overridden by the
programmer. Exactly what the circumstances are in which the use of
the methods to set images will remove the NSButtonImageSource, and
how you can get it set for a button, are not clear without
experimentation.
Greg implemented a minimal NSButtonImageSource to handle decoding of
nibs, but it doesn't really work the way Apples' implementation does,
and doesn't support theming.
What I wanted to do was produce an implementation which was
consistent with Apple's implementation, but also worked with GSTheme
to provide alternative sets of images for each default button type,
so that a theme could change the default button types cleanly. So
when a button of the default type wants to draw itssself, it asks its
imagesource for the image for the current state of the button, and
the image source provides it from a cache which it populates from the
current theme (and flushes when the theme changes).
- Button Cell Images, Christopher Armstrong, 2007/06/24
- Re: Button Cell Images,
Richard Frith-Macdonald <=