Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

titaniumdecoy

macrumors member
Original poster
Oct 13, 2005
86
0
Hi all,

I need to get rid of the line which separates a window's title bar from its contents. A textured window would be perfect for this task, except that its bottom corners are rounded, which is unacceptable for my purposes. So, is there any way to draw over a window's title bar? NSWindow has no -drawRect: method to override, so--how is this possible?

Thanks.
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
Do a search for StyledWindow. It's an NSWindow subclass that gives windows the unified appearance for Tiger that Leopard now uses natively. You could use the method that it uses.
 

titaniumdecoy

macrumors member
Original poster
Oct 13, 2005
86
0
@kainjow: Thanks for the suggestion, but! StyledWindow has the rounded corners which I hate.
 

antibact1

macrumors 6502
Jun 1, 2006
334
0
A function has been added for this in the WebKit Libraries:

void WKNSWindowMakeBottomCornersSquare(NSWindow *);

Unfortunately, its part of the closed source libWebKitSystemInterfaceLeopard.a. Good to know it is possible though.
 

antibact1

macrumors 6502
Jun 1, 2006
334
0
Alright, here is the solution! NSWindow has a private method

-setBottomCornerRounded

You can use a textured window and insert this code in the appropriate place (likely awakeFromNib)

Code:
if ([window respondsToSelector:@selector(setBottomCornerRounded:)])
		[window setBottomCornerRounded:NO];
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
I would not use private methods. If you want full control over your window's appearance, I'd subclass NSWindow, set the style mask to NSBorderlessWindowMask, and then put all your drawing in the window's content view.
 

antibact1

macrumors 6502
Jun 1, 2006
334
0
I wouldn't worry about using that method. The WebKit Library I previously mentioned is making use of it, so it is likely to remain around for a while.
 

titaniumdecoy

macrumors member
Original poster
Oct 13, 2005
86
0
I would not use private methods. If you want full control over your window's appearance, I'd subclass NSWindow, set the style mask to NSBorderlessWindowMask, and then put all your drawing in the window's content view.

Well, if I did that I would have to recreate the title bar and the resizer, which would not be much fun at all.

Also, since the method is accessible in an NSWindow subclass, wouldn't that make it protected rather than private?
 

Sijmen

macrumors 6502a
Sep 7, 2005
709
1
Well, if I did that I would have to recreate the title bar and the resizer, which would not be much fun at all.

Also, since the method is accessible in an NSWindow subclass, wouldn't that make it protected rather than private?

Technically speaking, there aren't any private methods. Either the object responds to the selector, or it does not. The method here is just not being publicized, and not officially supported. It might disappear or start doing something completely different without any warning.
 

swearbymac07

macrumors member
Dec 13, 2007
96
0
Drawing over Title Bar...

Do a search for Matt Gemmell, and download RoundedFloatingPanel. In the source folder is a .h file called Transparent Window which makes the entire window transparent and removes the title bar. All you need to do is create your own controls (Close, Minimize, Zoom) if u are using Tiger, otherwise they should still be there in Leopard. This allows you to create Modal-like windows in Cocoa.
 

titaniumdecoy

macrumors member
Original poster
Oct 13, 2005
86
0
All you need to do is create your own controls (Close, Minimize, Zoom)

Although that would be possible I believe it would be more likely to break than simply calling the setBottomCornerRounded: method. And I don't feel much like building a title bar from scratch. But thanks for the suggestion.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.