views:

486

answers:

2

I want to draw an NSWindow that looks similar to this:

http://vibealicious.com/site/apps/notify/screenshots/mainUIFull.png

In that it has a typical NSWindow appearance with the bottom bar and such, but instead of a title bar at the top, I want to draw a little arrow.

Is there a simple way to do this? Do I have to draw the entire window by hand (bottom bar and all) ? Or can I slightly modify the existing NSWindow layout to just draw that arrow at the top? Thanks

+1  A: 

You could possibly fake the title bar by using a second child window that overlays the top section of the window and draws just the arrow. Otherwise, you'd need to draw the whole thing yourself.

Rob Keniger
That's pretty much what I had in mind. Is there a way to get the frame of the title bar only (origin and size) so that I can resize and position my child window to cover it?
macatomy
You can use the `+contentRectForFrameRect:styleMask:` class method of `NSWindow` to get the content rect for the window. You can then easily compare this with the window's frame to get the size of the title bar.
Rob Keniger
This is what I ended up doing, thanks :)
macatomy
A: 

Not sure what you mean by a simple way to do it, but it's not very hard to make your own window subclass and draw the window controls yourself. A child window would be a bit of overkill for this situation.

Have a look at the Round Transparent Window sample project.

NSResponder
The only problem with drawing everything yourself is that if the window style changes (e.g. in a new OS release) then your window will look out of place. Of course, that applies to the arrow overlay also.
Rob Keniger
This is true, and it's a good reason to carefully consider whether a custom window is appropriate for your situation.
NSResponder