[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Proposal to fix NSButtonCell issue with -setFont: -setTitle:

From: Fred Kiefer
Subject: Re: [PATCH] Proposal to fix NSButtonCell issue with -setFont: -setTitle:
Date: Sat, 19 Jun 2004 18:28:49 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.6) Gecko/20040114

Quentin Mathé wrote:
Le 30 mars 04, à 12:06, Quentin Mathé a écrit :

Hi Fred,

Actually when you have set the font or the title of a button cell with the -setFont: or -setTitle: methods, you cannot anymore retrieve the image associated with the button cell because the cell has been converted from NSImageCellType to NSTextCellType and the -image method is written like that :
- (NSImage*) image
  if (_cell.type == NSImageCellType)
      return _cell_image;
    return nil;

The code above is in accordance with the specification. Then I propose to not change this method but to simplify NSButtonCell -setFont: -setTitle: like in the patch below… in order to have the cell type not changed when you call -setFont: and -setTitle:. I propose to have the cell type changed only by the -setImagePosition: method.


We have such issue because NSButtonCell unlike NSCell can have a title (_contents ivar with a specified font) without being an NSTextCellType cell but an NSImageCellType cell by using an image.

What we do with this patch ?

… reply to Fred Kiefer question :

Le 30 mars 04, à 22:18, Fred Kiefer a écrit :

This patch looks dubious to me. NSButtonCell also has a method setAttributedTitle: if this gets called and later we ask for the title we get back an NSAttributedString where we would expect a normal NSString. What about decoupling the contents and the title of a button cell completely?

It was my first idea : to create a _title ivar, but I take a look at the Cocoa header for NSButtonCell and I saw no such ivar, then I have decided to still use the _contents ivar. To fix the problem you are talking about… when the method -title can return an attributed string we have the possibility to check that and to return in such case an NSString copy from the NSAttributedString.

Otherwise if we choose to decouple the title and the contents, then we should choose to be always an NSImageCellType or NSTextCellType cell (currently for NSButtonCell in Cocoa, the cell type is always NSTextCellType which is not the case with GNUstep).

What do you think of the explanations above for you question ? (I have received no reply from you).
What should we choose to implement ?

Sorry about forgetting to reply to this mail. Looks like nobody else picked it up.

From what you write, I would rather suggest that we change the methods (-image) and (-setImage) on NSButtonCell to ignore the cell type. Or did I miss something?

Somethign similar will be needed for NSBrowserCell which also supports an iamge and a text at the same time. Perhaps it would be even worthwhile to add a switch autoChangeCellType to each cell class, but I would wait with this.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]