Re: Placing Cells in an NSMatrix
Re: Placing Cells in an NSMatrix
- Subject: Re: Placing Cells in an NSMatrix
- From: Erik Stainsby <email@hidden>
- Date: Wed, 04 Apr 2012 21:13:17 -0700
Small bit if knowledge to share. The stroke of the border is drawn centred over the line of the border. So your described 4pt line would intrude 2pts into the bounded area. I'm know if that will help any with understanding the left-shifting you have observed.
Erik Stainsby
email@hidden
-------------------------------------
Consistently place constants on the LHS of an expression: you cannot accidentally assign when you meant to compare.
On 2012-04-04, at 9:04 PM, Peter Teeson wrote:
> On 2012-04-04, at 6:52 PM, Peter Teeson wrote:
>> On 2012-04-04, at 5:02 PM, Fritz Anderson wrote:
>>> On 4 Apr 2012, at 2:20 PM, Peter Teeson wrote:
>>>> Given a 3 x 3 Matrix which is a sub-class of NSMatrix with Cells sub-classed from NSButton
>>>> the X origins of column 0 cells seem to be 1.0 point inside the Matrix bounds.
>>>>
>>>> So if I want to stroke the Matrix bounds with a line width of e.g. 4.0 points
>>>> it draws over the left area of the column 0 cells.
>>>>
>>>> Hence I would like to make sure that the origins of the cells are where I
>>>> want them to be, i.e. leave enough room to stroke the Matrix bounds.
>>>>
>>>> I've read Matrix Programming Guide and looked at the NSMatrix and NSCell
>>>> references but I do not understand which methods to use to accomplish this.
>>>>
>>>> Should I do this in NSCell calcDrawInfo? And then does that mean for each Cell?
>>>> Surely there must be simple way to provide a frame for all the Cells inset from the bounds of the Matrix.
>>>>
>>>> Nor can I find a way to do this in Interface Builder.
>>>> AutoLayout is checked but Automatically Resizes Cells is not.
>>>
>>> I read the NSMatrix class reference to say that NSMatrix enforces its frame being the hull of the cells plus the intercell spacing. You won't accomplish you want, in the way you propose, without fighting the framework.
>>>
>>> Why not embed the matrix in a view of your own? You can then draw whatever you like around it.
>> Thanks for your thought.
>> But the strange thing is that my experiments show that there is in fact an spacing on the top, right, and bottom
>> of the area between the cells and the matrix bounds. But not on the left side!!
>>
>> I would expect there to be equal spacing all around. I have confirmed this by reducing the size of the cells (setCellSize)
>> and the area between the cells and the Matrix bounds adjusts appropriately except for the left edge.
>>
>> Something I do not understand is going on here that I do not find logical.
>>
>> Peter
> In Lion there are new methods related to constraints (in NSLayoutConstraint.h -alignmentRectForFrame and -frameForAlignmentRect) that might be applicable to my query.
> Also in XCode in the xib Size inspector for the Matrix the View section it shows Frame Rectangle or Layout Rectangle. But changing the X value of one changes it in the other.
> Looks like I may have to override the above methods as suggested in the reference. Anyone done this and used these and can point at example code or more documentation?
>
> But these were only added in Lion so how was it done previously (if at all)?
>
> Peter
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden