Bug 4733 - Issues with Win32 GDI setBkMode(), and similar things in Motif (1GFPGK3)
Summary: Issues with Win32 GDI setBkMode(), and similar things in Motif (1GFPGK3)
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: SWT (show other bugs)
Version: 2.0   Edit
Hardware: All Windows All
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Silenio Quarti CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 11602 (view as bug list)
Depends on:
Blocks:
 
Reported: 2001-10-11 14:22 EDT by Mike Wilson CLA
Modified: 2002-09-13 15:31 EDT (History)
3 users (show)

See Also:


Attachments
Motif version of GC with workaround (97.52 KB, text/plain)
2002-09-13 14:28 EDT, Patrick Mueller CLA
no flags Details
Win32 version of GC with workaround (84.52 KB, text/plain)
2002-09-13 14:29 EDT, Patrick Mueller CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Wilson CLA 2001-10-11 14:22:05 EDT
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.
Comment 1 DJ Houghton CLA 2001-10-29 16:34:36 EST
PRODUCT VERSION:
	Build 125

Comment 2 Patrick Mueller CLA 2002-08-30 10:43:08 EDT
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 ...
Comment 3 Patrick Mueller CLA 2002-08-30 10:56:52 EDT
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?
Comment 4 Steve Northover CLA 2002-09-10 12:45:16 EDT
SSQ, is there a reason why we don't just always draw dashed lines transparent?  
What does X do?
Comment 5 Patrick Mueller CLA 2002-09-13 02:07:38 EDT
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.
Comment 6 Patrick Mueller CLA 2002-09-13 14:27:48 EDT
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.
Comment 7 Patrick Mueller CLA 2002-09-13 14:28:54 EDT
Created attachment 1992 [details]
Motif version of GC with workaround
Comment 8 Patrick Mueller CLA 2002-09-13 14:29:45 EDT
Created attachment 1993 [details]
Win32 version of GC with workaround
Comment 9 Patrick Mueller CLA 2002-09-13 14:30:26 EDT
Next time, I'll do diffs. 
This time, I needed some sleep <g>.
Comment 10 Silenio Quarti CLA 2002-09-13 14:33:32 EDT
*** Bug 11602 has been marked as a duplicate of this bug. ***
Comment 11 Silenio Quarti CLA 2002-09-13 15:31:27 EDT
Fixed > 20020913. All platforms are drawing transparent now.