nstextfieldcell

How do I set the font size in a text cell so that the string fills the cell's rect?

不想你离开。 提交于 2019-11-30 07:33:13
I have a view that contains two NSTextFieldCell s. The size at which these cells are drawn is derived from the size of the view, and I want the text in each cell to be the largest that will fit in the derived size of the cell. Here's what I have, which doesn't set the font size: - (void)drawRect:(NSRect)dirtyRect { /* * Observant readers will notice that I update the whole view here. If * there is a perceived performance problem, then I'll switch to just * updating the dirty rect. */ NSRect boundsRect = self.bounds; const CGFloat monthHeight = 0.25 * boundsRect.size.height; NSRect monthRect =

How to setup a NSTableView with a custom cell using a subview

社会主义新天地 提交于 2019-11-29 17:23:35
I am trying to setup a NSTableView with a custom cell using an ArrayController and Bindings . To accomplish this I added a subview to the custom cell. The data connection seems to work somewhat. Though, there seems to be a redraw problem which I cannot fix. When I load the application only some of the cells are rendered. When I scroll through the rows or select one the rendering changes. I created an example project on github to illustrate what the problem is. The actual source code for the cell rendering can be found here : // CustomCell.m - (void)drawInteriorWithFrame:(NSRect)cellFrame

Truncate the last line of multi-line NSTextField

情到浓时终转凉″ 提交于 2019-11-29 15:01:03
问题 I'm trying to create a text field similar to Finder's file labels. I would like the last (second) line to be truncated in the middle. I started with a multi-line NSTextField . However, calling [self.cell setLineBreakMode:NSLineBreakByTruncatingMiddle]; results in a the text field showing only a single truncated line (no line breaks anymore). Here is what it looks like in Finder: 回答1: If you want to wrap text like finder labels, using two labels doesn't do you any good since you need to know

Is there a “right” way to have NSTextFieldCell draw vertically centered text?

蹲街弑〆低调 提交于 2019-11-27 02:46:01
I have an NSTableView with several text columns. By default, the dataCell for these columns is an instance of Apple's NSTextFieldCell class, which does all kinds of wonderful things, but it draws text aligned with the top of the cell, and I want the text to be vertically centered in the cell. There is an internal flag in NSTextFieldCell that can be used to vertically center the text, and it works beautifully. However, since it is an internal flag, its use is not sanctioned by Apple and it could simply disappear without warning in a future release. I am currently using this internal flag

Is there a “right” way to have NSTextFieldCell draw vertically centered text?

北慕城南 提交于 2019-11-26 10:16:05
问题 I have an NSTableView with several text columns. By default, the dataCell for these columns is an instance of Apple\'s NSTextFieldCell class, which does all kinds of wonderful things, but it draws text aligned with the top of the cell, and I want the text to be vertically centered in the cell. There is an internal flag in NSTextFieldCell that can be used to vertically center the text, and it works beautifully. However, since it is an internal flag, its use is not sanctioned by Apple and it