Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [platform-swt-dev] Q's about adding new function to SWT: transparent regions


First off, a good rule of thumb when you are dealing with multiple window systems is to never do a big, "generic" thing when all you are looking for is a very specific thing. If you believe shells need to have a region, then put the api on shell, not control. In this case, the potential for non-rectangular widgets (other than shells) to interact badly with the existing code is, I supect, quite high.

Secondly, how much investigation have you done on this on other window systems? I know X supports non-rectangular windows, so I think you need to take a look at what that support looks like. I'd also check Photon, GTk, and Mac at the very least. Basically, what you are trying to do is synthesize a single clean _expression_ of all the different flavours of the API wherever it's supported. This is (potentially, at least) a much more difficult problem.

You also have to watch out for interactions with GC.copyArea with shells, and search for any other places where that region may be currently being used internally.

That's all I can think of to start with. In terms of getting the code here, the best thing is just to zip it up and mail it to one of the committers. Please make sure it has the appropriate "I'm released under CPL" words.

McQ.



"Patrick Mueller" <pmuellr@xxxxxxx>
Sent by: platform-swt-dev-admin@xxxxxxxxxxx

04/15/2002 11:45 PM
Please respond to platform-swt-dev

       
        To:        <platform-swt-dev@xxxxxxxxxxx>
        cc:        
        Subject:        Re: [platform-swt-dev] Q's about adding new function to SWT: transparent regions


So, I actually checked the SWT code <g> and noticed Region is already a 1st class citizen.  So, all I would really want to add API wise is a method on control called setRegion(Region).  noop'd everywhere but Win32, which is the only place I know how to write the code for this (and know that it's implemented).
 
Some oddities with this call though: you lose ownership of the Region after passing it in.  Which I suppose means that a copy should be made, and the copy passed into the the SetWindowRgn() call.

Patrick Mueller

pmuellr@xxxxxxx

----- Original Message -----
From: Patrick Mueller
To: platform-swt-dev@xxxxxxxxxxx
Sent: Monday, April 15, 2002 10:56 PM
Subject: [platform-swt-dev] Q's about adding new function to SWT: transparent regions

I'm thinking about submitting some new function to SWT.  Namely, use of the regions in Win32 and the call SetWindowRgn() to associate a region with a control.  This allows you to have non-rectangular windows, which I'm thinking of using specifically with shells.  To make some kind of a groovy looking app like the mp3 players du jour do.
 
So, couple of questions:
 
- say I hack the C code and Java code to do this in Windows; how do I submit this as a candidate?  Zip it up and attach it to an email?
 
- more importantly, what do you think this interface should look like in SWT itself?  I think (but am not sure) that the SetWindowRgn() will work with any HWND,  so, should be on Control.  The whole region business is a bit complicated, so I'm thinking that to make it easier, the interface would be to pass an image in, and any transparent pixels (or pixels with alpha set to 0) would indicate areas of the region that were transparent.  It would boil the API down to one new method.  A setter:
 
    void setTransparentRegion(Image image)
 
Or would it be better to expose all the region glorp?  And would we want a getter?
 
    Image getTransparentRegion()
 
Since this is aimed at Shells (in my case anyway), keeping the images around, which might be large, seems like a huge waste of space.  And it seems like there wouldn't really be much use for getting this data back anyway.  And to get the original Image back, you'd really have to hold onto it, since the only data used is the transparent-ness, and there would be no way to recreate the pixel data from a GetWindowRgn() call.
 
Just curious ...

Patrick Mueller

pmuellr@xxxxxxx


Back to the top