The setxormode (true) method is used to make the target color the result value of the XOR operation of the source and target colors.
When the parameter is false, the difference or effect of the drawing is canceled.
Before using setxormode, you should use setbackground/setforeground to set the background color or foreground color.
In addition, we cannot use setantialias or settransform with this method. Otherwise, you will be surprised to find that using setxormode does not achieve the desired effect. Why? This is because the advanced image mode is automatically called after setantialias or settransform. You can use setadvance (false) to switch the mode to normal mode and then call the setxormode method.
Eg:
XOR failure example:
GC. setbackground (display. getsystemcolor (SWT. color_blue); GC. fillrectangle (0, 0, 60, 60); GC. setantialias (SWT. off); // setantialiasgc is called. setxormode (true); GC. setbackground (display. getsystemcolor (SWT. color_yellow); GC. fillrectangle (20, 20, 80, 80); GC. dispose ();
GC. setbackground (display. getsystemcolor (SWT. color_blue); GC. fillrectangle (0, 0, 60, 60); GC. setantialias (SWT. off); // setantialias GC is called. setxormode (true); GC. setbackground (display. getsystemcolor (SWT. color_yellow); GC. fillrectangle (20, 20, 80, 80); GC. dispose (); |
It is worth noting that setxormode is not supported on some platforms, soExercise caution when developing portable programsSetxormode.