Community
Participate
Working Groups
A few issues related to how we're using setBkMode() 1. SWT never explicitly calls setBkMode(OS.OPAQUE) during initialization but it assumes that it has been set to that during GC operations. -- see the non-transparent branches of drawText() and drawString() 2. When the background mode is opaque and the current line style is anything other than LINE_SOLID, the background colour is used to paint the blank spaces between dots and dashes. 3. There is no API for selecting a transparent background colour (and Windows doesn't really have such a thing for drawing operations), so there is no way to specify that we want to draw dotted lines with transparent spaces. The API (JavaDoc) makes no mention of this being the intended behaviour. A quick test on Motif shows that we're doing the exact same thing over there... Recommend we add API for transparent dotted lines by adding new bit flags SWT.LINE_TRANSPARENT_DASH and SWT.LINE_ALTERNATE_DASH. Choose one of them to be the default behaviour (so its value will be 0). Extend the GC get/setLineStyle() to use a style value that consists of the logical OR of one of the existing SWT.LINE_xxx styles and one of the above flags. NOTES: CM (6/22/2001 10:44:19 AM) See also 1G863UH: SWT:ALL - How can I dash a line with one color set and the other transparent ? McQ (26/06/2001 9:11:21 AM) - Discuss with SN and McQ. Then fix. JB (30/08/2001 10:48:23 AM) Had a quick look at the changes required to implement this: Win32: call setBkMode() to set TRANSPARENT or OPAQUE mode -- note: drawString/Text will need to be updated Motif: specify LineOnOffDash or LineDoubleDash in the line attributes structure element from setLineStyle(). Photon: only supports transparent gaps! In light of Photon's support, perhaps we should opt to support only transparent dashes everywhere unless someone _really_ wants alternating foreground / background dashes.
PRODUCT VERSION: Build 125
This one is now killing us for the implementation of one of our libraries, which expects transparent holes in non-solid lines. We really need to get this support into the product ASAP. But in the meantime, I'm wondering if there's some hack I can do. ie, call private stuff in the SWT package from my library implementation. I'm going to start rooting around. A really bad hack would be for me to create an new image, with two entry palette (foreground color being drawn, and another, different color for transparency), then draw my stuff with the foreground/background set appropriately. Then paint the image into where I was going to draw the line. A performance killer for sure ...
So, here's a hack work-around for win32, which I can call from my code: org.eclipse.swt.internal.win32.OS.SetBkMode( gc.handle, org.eclipse.swt.internal.win32.OS.TRANSPARENT ); Is there something similiarly public enough for me to do in Motif as well?
SSQ, is there a reason why we don't just always draw dashed lines transparent? What does X do?
OK, some rooting around for Motif indicates that, in GC.setLineStyle(), if you change the OS.LineDoubleDash to OS.LineOnOffDash, you get transparent holes. The reference I found for this was at an obsolete page I found in Google's cache: http://216.239.37.100/search? q=cache:ed5rbn4vawAC:www.x.org/consortium/R6doc/man/X11/XCreateGC+XSetDashes&hl= en&ie=UTF-8 Here is the note: The line-style defines which sections of a line are drawn: LineSolid The full path of the line is drawn. LineDoub- The full path of the line is drawn, but the leDash even dashes are filled differently than the odd dashes (see fill-style) with CapButt style used where even and odd dashes meet. LineOnOffDash Only the even dashes are drawn, and cap-style applies to all internal ends of the indivi- dual dashes, except CapNotLast is treated as CapButt.
I'm going to attach my hacked versions of GC for win32 and motif that work around this problem ... for Motif, it was a change to setLineStyle() to use LineOnOffDash instead of LineDoubleDash. for win32, it was a change to every draw line-ish method (arc,line,rectangle,etc) to set the BkMode to transparent, draw like usual, reset BkMode to it's original value.
Created attachment 1992 [details] Motif version of GC with workaround
Created attachment 1993 [details] Win32 version of GC with workaround
Next time, I'll do diffs. This time, I needed some sleep <g>.
*** Bug 11602 has been marked as a duplicate of this bug. ***
Fixed > 20020913. All platforms are drawing transparent now.