• 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: Title bar on left of Panel
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Title bar on left of Panel


  • Subject: Re: Title bar on left of Panel
  • From: Guy English <email@hidden>
  • Date: Wed, 3 Oct 2007 18:58:10 -0400

Do not do what follows. It's evil. It works. But it's evil.

-------------------

@interface MyLeftAlignedTitleTextFieldCell : NSTextFieldCell
// do not add any ivars. not even a little tiny one. really. we class swizzle this in and if you do add an ivar you'll regret it.
@end


@implementation MyLeftAlignedTitleTextFieldCell

- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
{
NSColor *textColor;

if ( [[controlView window] isMainWindow] )
{
textColor = [NSColor blackColor];
}
else
{
textColor = [NSColor disabledControlTextColor];
}

NSRect frame = [self titleRectForBounds: cellFrame];
NSButton *zoomButton =[[controlView window] standardWindowButton: NSWindowZoomButton];
if ( zoomButton )
{
frame.origin.x = NSMaxX( [zoomButton frame] );
}
frame.origin.x += 6; // just some padding
frame.origin.y -= 1;
NSDictionary *attrs = [NSDictionary dictionaryWithObjectsAndKeys:
textColor, NSForegroundColorAttributeName,
[NSFont titleBarFontOfSize: 0], NSFontAttributeName,
nil];
[[self stringValue] drawInRect: frame withAttributes: attrs];
}


@end

// somewhere early in your startup code but after the nib has been loaded.
// here we have a cascade of evil, each step nuttier than the one before.


if ( [theWindow respondsToSelector: @selector( _borderView )] )
{
if ( [[(id) theWindow _borderView] respondsToSelector: @selector( titleCell )] )
{
if ( [[(id)[(id) theWindow _borderView] titleCell] isKindOfClass: [NSTextFieldCell class]] )
{
[(id)[(id) theWindow _borderView] titleCell]->isa = [MyLeftAlignedTitleTextFieldCell class]; // yikes!
}
}
}


Later,
Guy
_______________________________________________

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


References: 
 >Re: Title bar on left of Panel (From: Gordon Apple <email@hidden>)

  • Prev by Date: Re: Nib & retainCount confusion
  • Next by Date: Re: problem loading a window in a new NIB using NSWindowController.
  • Previous by thread: Re: Title bar on left of Panel
  • Next by thread: Link superclass at runtime?
  • Index(es):
    • Date
    • Thread