| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
_______________________________________________My carbon app (still kinda old school) creates windows with NewCWindow.
I'm looking to see how I can specify an alpha channel for the window, but I'm finding absolutely zilch on apple's website. OK, I did find "SetWindowAlpha()" but I want to provide basically an 8 bit bitmap of alpha and not a flat level of alpha.
Can anyone tell me how to go about setting a custom alpha channel for a carbon window?
I'm fully prepared to switch over to CreateNewWindow and whatever else may be necessary, etc.
There are at least a couple of ways to do this. The important thing to know is that it's going to be very hard to do what you want to do using QuickDraw. Unless you are really into twiddling bits, you're going to be better off drawing translucent parts of the window with Quartz.
Now the two techniques...
1. You can use an overlay window through CreateNewWindow (that is a window of class kOverlayWindowClass). To the overlay window add a handler for the kEventWindowPaint Carbon Event. In that handler, use CGContextClearRect to clear out the window's context and then proceed to use Quartz to paint the window's background in any way that you want.
2. You can use CreateCustomWindow with a window definition type of kWindowDefHIView to create a window that has a custom HIView as it's root view. To do this you will have to create both the root view (which behaves as the structure of the window) and the content view for the window. There are a number of responsibilities that each of these views have and, unfortunately, there is not much documentation on this technique. Nevertheless, it is used to create a custom menu background in the StarMenu sample available in the HIToolbox samples at Apple's web site. I can also send you a small sample that I wrote, based on StarMenu, that creates a VERY simplistic circular window.
The nice thing about these two techniques is that you have the full power of Quartz at your fingertips to draw your window's structure region. That means that if you want to draw a PNG image with an alpha channel in your favorite drawing application (like my favorite, Quartz scripting though Python on the command line) then you can load that PNG at runtime and use it as your window background.
Scott
| References: | |
| >Alpha for Carbon window... (From: Ando Sonenblick <email@hidden>) | |
| >Re: Alpha for Carbon window... (From: Ricky Sharp <email@hidden>) | |
| >Re: Alpha for Carbon window... (From: Scott Thompson <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.