I wanted to create a custom window, but NSBorderlessWindow is ugly, because you have to implement most of the functionality yourself. Taking a page from Uli, I extended that functionality a little bit.
I present you with my hacky box:
UPDATE:
Anyone who has tried to use the code below, would get this result:
A method went missing. I've added it to the code below.
Notable things:
- This is just a textured window. All usual functionality (resizing, exposé, shortcuts) is there.
- Notice the location of the close/miniaturize/zoom buttons. They are moved to the right.
- The resize handle is also moved to a better location.
- The window title (aptly named, "Window") is the usual one, set in IB.
- No borders are drawn.
- When resized, the image scales with the window.
- I can't draw :)
To do this, download the above mentioned class, and add the following methods:
- (struct _NSPoint)_closeButtonOrigin
{
NSPoint point = [super _closeButtonOrigin];
point.x += 35.0;
point.y -= 5.0;
return point;
}
- (struct _NSRect)_titlebarTitleRect
{
NSRect res = [super _titlebarTitleRect];
res.origin.y-=6.0;
return res;
}
- (struct _NSRect)_maxXminYResizeRect
{
NSRect res = [super _maxXminYResizeRect];
res.origin.x-=13;
return res;
}
// to make the borders disappear
+ (void)drawBevel:(struct _NSRect)fp8
inFrame:(struct _NSRect)fp24
topCornerRounded:(char)fp40
bottomCornerRounded:(char)fp44
{
return;
}
Can't help with the drawing skills, sorry. You have to be born with them.
Of course, all this is undocumented and will probably break tomorrow... But still, it's fun and a much better way than reimplementing everything in a borderless window!
Comments
Comment by Orestis Markou , 2 years, 11 months ago :
I just copied the methods over from the Secret Headers you supplied :) While I can't use NSRect in the code, _NSRect seems to work in the method signature.
I'm still very new to Cocoa & Objective-C, my MacBook is about 1 month old...
Well, I can't paint either :)
Comment by Mark Hilley , 2 years, 11 months ago :
Cool trick! I just started learning cocoa last week, but this is definitely on my list of things to try. Thanks for posting.
This post is older than 30 days and comments have been turned off.

Comment by Uli Kusterer , 2 years, 11 months ago :
Oooo. Nice hack! :-)
Instead of struct _NSRect, you can just say NSRect. The latter is typedefed to be equivalent to the former. Same for struct _NSPoint.
Oh, and that's not a drawing, that looks more like a painting :-p