Re: Drawing customized window
Re: Drawing customized window
- Subject: Re: Drawing customized window
- From: Corbin Dunn <email@hidden>
- Date: Wed, 31 Oct 2012 13:17:21 -0700
On Oct 31, 2012, at 8:50 AM, Nick <email@hidden> wrote:
> Hello
>
> I am attempting to create an application with custom looking windows
> (similar to new iCalendar on mountain lion, or QuickTime player). I am
> targeting systems from Snow Leopard to Mountain Lion.
>
> So far I've been customizing the window using the idea described at
> http://parmanoir.com/Custom_NSThemeFrame
> (basically I set the window to be Textured, and swizzle the drawRect
> method of the [[window contentView] superview] (which is an instance of
> NSThemeFrame), then draw some nice gradient in that new drawRect
> implementation, and a custom gradiented toolbar.
> The advantage of this method is that I do not have to bother with resizing
> (even the resizing mark in the bottom right corner is drawn automatically)
> and manually drawing titlebar buttons (albeit they have a gray shadow,
> despite i need a black one). Another advantage is that NSToolbar works
> normally with it, and looks nicely with this customly drawn theme frame.
Don't swizzle the theme frame drawRect: -- that won't always work (as you noticed) and isn't supported.
>
> This works fine on Leopard and Snow Leopard, but not on Lion/Mountain Lion.
> Somehow, the application becomes very slow there (Instruments says that the
> application spends a whole bunch of time in some timer event somewhere deep
> in the AppKit, even though I do not use any timers in my app). Apart from
> the windows, on Lion/ML the sheets and the panels get this custom drawn
> background with a titlebar.
>
> I am wondering if anyone created customized windows like this or reverse
> engineered this NSThemeFrame? Maybe there are any articles on the internet
> that I have missed (actually the link I gave in the beginning is the only
> one I have found on this topic). Somehow Apple's iCalendar works pretty
> fast on 10.7, while my app doesn't..
Calendar uses the public API of setBackgroundColor: on the window, and sets it to a pattern color. That is it.
corbin
>
> If there's no way to fix this for 10.7/10.8, I guess I will have to draw my
> windows from scratch using NSBorderlessWindowMask, but I think it is very
> difficult to completely mimic the original window's behavior: borderless
> windows do not support NSToolBar (i.e., I have to create my own one from
> scratch), on different OS the windows look/behave differently (10.6 - large
> titlebar buttons, resizing only using right-bottom corner, while 10.7 and
> 10.8 - small titlebar buttons, resizing using any edge), etc..
>
>
> Thank you,
> Nicolas
> _______________________________________________
>
> 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
_______________________________________________
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