• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Vertically aligning text in a table while preserving fontSize bindings
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Vertically aligning text in a table while preserving fontSize bindings


  • Subject: Re: Vertically aligning text in a table while preserving fontSize bindings
  • From: George Orthwein <email@hidden>
  • Date: Thu, 22 Feb 2007 17:48:05 -0500

Yay! Thanks Mike, this is working great:

- (NSRect)centerInFrame:(NSRect)cellFrame
{
	NSSize drawingSize = [self cellSizeForBounds: cellFrame];
	float offset = (cellFrame.size.height - drawingSize.height) / 2;
	NSRect centeredFrame = cellFrame;
	if (offset > 0) {
		centeredFrame = NSInsetRect(cellFrame, 0.0, offset);
	}
	return centeredFrame;
}

- (void)selectWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject start:(int)selStart length:(int)selLength
{
[super selectWithFrame:[self centerInFrame:aRect] inView:controlView editor:textObj delegate:anObject start:selStart length:selLength];
}


- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
[super drawWithFrame:[self centerInFrame:cellFrame] inView:controlView];
}


I also tried overriding the following... but I don't even see them get called as I select and edit the text field. So I guess they're not needed:

- (void)highlight:(BOOL)flag withFrame:(NSRect)cellFrame inView: (NSView *)controlView
- (void)editWithFrame:(NSRect)aRect inView:(NSView *)controlView editor:(NSText *)textObj delegate:(id)anObject event:(NSEvent *)theEvent


I haven't experimented with it yet, but it may actually be simpler to override -cellSizeForBounds: and other similar methods.

I tried that but it didn't seem to have any effect, which makes sense because it's only returning an NSSize, not an NSRect so it lacks position. Overriding drawingRectForBounds: worked fine until I clicked to edit text, the blue outline grew 3-4 times in height. Not sure what was causing that.


Big thanks to Mike! I'm very grateful.

George


_______________________________________________

Cocoa-dev mailing list (email@hidden)

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


References: 
 >Vertically aligning text in a table while preserving fontSize bindings (From: George Orthwein <email@hidden>)
 >Re: Vertically aligning text in a table while preserving fontSize bindings (From: Mike Abdullah <email@hidden>)

  • Prev by Date: Accessing getPixel of NSBitmapImageRep Class from applescript or javascript
  • Next by Date: Re: Must remove submenu when dealloccing NSMenuItem?
  • Previous by thread: Re: Vertically aligning text in a table while preserving fontSize bindings
  • Next by thread: Getting a managed object from an NSController from a table view row index
  • Index(es):
    • Date
    • Thread