[Top][All Lists]

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

Re: NSButtonCell value, contents and cell type implementation rewritten

From: Quentin Mathé
Subject: Re: NSButtonCell value, contents and cell type implementation rewritten
Date: Fri, 3 Sep 2004 00:24:39 +0200

Le 1 sept. 04, à 23:30, Fred Kiefer a écrit :

Quentin Mathé wrote:

Le 30 août 04, à 21:06, Fred Kiefer a écrit :

Quentin Mathé wrote:

hmm… Where it is ?

Problems reading your own patch file? :-)
Its in [NSButtonCell setAlternateTitle:].

ok, sorry for my laziness, but well this rule doesn't exist… :-)

From GNUstep coding guidelines :
"Finally, my own preference (not part of the standard in any way) is to generally use curly brackets for control constructs, event where only one line of code is involved"

Moreover "this rule" is poorly (to not said never) respected in GNUstep, there is lot of work to do if you want GNUstep respects such rule.

Well we can discuss it… why not…

The only question I have with this patch is, if it would not be simpler to use a call to the setType: method in the class NSCell, instead of the direct setting of _cell.type and just overwrite that method in NSButtonCell to do nothing.
Well it was my first idea, but it isn't possible.

OK, but why not? A bit of explanation might help me see the light.

Sorry again, I didn't understand what you was meaning…
My patch isn't in any way a NSCell rewrite, it is a NSButtonCell rewrite, in the case you want to rewrite NSCell to use -setType: more often you can. For NSButtonCell, the only time the cell type is changed, it is with -setImagePosition: and in this precise case it is impossible to use the NSCell method -setType because of the side effect. Otherwise it is needed to override -setType: to do nothing in NSButtonCell to match somewhat the Cocoa behavior, and more importantly to have a consistent and nice behavior (I explained that in detail and it seems we have already agreed on this in the previous thread [PATCH] Proposal to fix NSButtonCell issue with -setFont: -setTitle:)

This does not work easyly with the current implementation of [NSCell setType:], but if we takle care to convert the type first and than to set attributes it should do.
To convert the type to what ? And which attributes ?

Currently we use _cell.type = NSTextCellType a lot in the code, for example in [NSCell setStringValue:]. We could replace this line with a call to [NSCell setType:]. Fine here but in [NSCell setFont:] we first set the font and than do the conversion. This is the wrong order, we should call setType: first and only set the font after this. You understand?

Yes. As I said just above, it was not my goal to correct NSCell.m, it will be far more work than my NSButtonCell patch : NSCell is broken in many ways.

When we use the method we need to take care of the order, nothing more nothing less. Than it should work, thats why I don't belive "it isn't possible".


Could you please test if Cocoa does call the method or if everything is done on the same low level as we do it.
The Cocoa behavior is explained in the patch :
+ * On Mac OS X, the NSButtonCell cell type is NSTextCellType by default or + * NSImageCellType if the initialization has been done with -initImageCell:,
+    * it should be noted that the cell type never changes later.

Thats exaclty what I thought in the init method this method is not called, but I would expect it to be called later on, but not to have any side effect. This would just be the way to implement it I described in my mail.

hmm, I don't understand what you mean here, precisely I don't see any interest to have -setType: called in NSButtonCell when you take in account the fact that it is impossible to avoid side effect if you don't override -[NSCell setType:] in NSButtonCell. In the case you choose to override -[NSCell setType:] it with a method which is empty or not, could you explain me the interest to have it called at the NSButtonCell level… ?


Quentin Mathé

reply via email to

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