Fix NSButtonCell's -setImagePosition: to avoid resetting the button's

image or title. Neither of this is desirable as it prevents
temporarily hiding the image or title by changing the image
position. This makes the behavior of -setImagePosition: now fully
compatible with Mac OS X.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29704 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
wlux 2010-02-22 20:50:08 +00:00
parent 5277f2a90d
commit f5dafed11d
2 changed files with 15 additions and 24 deletions

View file

@ -1,3 +1,11 @@
2010-02-22 Wolfgang Lux <wolfgang.lux@gmail.com>
* Source/NSButtonCell.m (-setImagePosition): Never call NSCell's
-setType: to change the cell's type, as this could eventually
reset the button's image or title. Neither of this is desirable
as it prevents temporarily hiding the image or title by changing
the image position.
2010-02-22 Wolfgang Lux <wolfgang.lux@gmail.com>
* Tools/GSspell.m (-spellServer:findMisspelledWord...): Check

View file

@ -481,35 +481,18 @@ typedef struct _GSButtonCellFlags
// In the GNUstep NSButtonCell implementation, the cell type depends only on
// the image position.
/* NOTE: We set the cell type attribute directly here instead of calling
NSCell's -setType: method because it may change the title or image of
the button cell. This is to make our implementation compatible with
the behavior of Mac OS X, which does not change the cell's type and
hence does not involve any of the side effects of -setType: either. */
if (_cell.image_position == NSNoImage)
{
/* NOTE: If we always call -setType: on superclass, the cell _content will
be reset each time. When we alter a button displaying both an image and
a title, by just calling -setImagePosition: with 'NSNoImage' value,
the current title is reset to NSCell default one. That's why we have to
set cell type ourself when a custom title (or attributed title) is
already in use.
Take note that [self title] is able to return the attributed title in
NSString form.
We precisely match Mac OS X behavior currently. That means... When you
switch from 'NSNoImage' option to another one, the title will be the
one in use before you switched to 'NSNoImage'. The reverse with the
image isn't true, when you switch to 'NSNoImage' option, the current
image is lost (image value being reset to nil).
*/
if ([self title] == nil || [[self title] isEqualToString: @""])
{
[super setType: NSTextCellType];
}
else
{
_cell.type = NSTextCellType;
}
_cell.type = NSTextCellType;
}
else
{
[super setType: NSImageCellType];
_cell.type = NSImageCellType;
}
}