Good day my fellow Developers and Engineers,
In my previous post I’ve written about INCLUDE_INFERIORS in Tracker Widget.
Today I’ve started working on Sash Widget’s drawBand() method, and guess what I have found there ?
….”Exactly, my old “friend” OS.GTK_INCLUDE_INFERIORS.”
Why INCLUDE_INFERIORS used in SASH ?
In Sash widget, INCLUDE_INFERIORS call is needed to put stippled rectangle ON TOP of the parent.handle.
If you try to draw rectangle without INCLUDE_INFERIORS, it appears below the parent.handle, thus you won’t be able to see it.
Hackish solution to GDK INCLUDE_INFERIORS
After “googling” this issue, I have found this article, that seems very popular, as it is referenced by many websites.
In short, article suggests to create “cairo” from “gtk_window”, than to create a “surface” that points to this “cairo”, and finally to create new “cairo_new” that uses surface that points to the first “cairo”. Got confused ? Yeah, me too!
Let’s try it again:
1. source_surface -> takes as target -> cairo (that references GTK window)
2. cairo_new -> uses source_surface (thus drawing on a surface that is on top of cairo)
I think that this is very hackish way, to achieve effect of INCLUDE_INFERIORS, but it works and I would be fully satisfied with this hack, if I didn’t need to change the color of Sash.
Why Hackish way cannot be used in Sash ?
There are two important things I need to do to replicate GDK Sash:
1. Make it appear on mouse click
2. Make it stippled or at least make it in some neat light grey colour. ( as stippling is considered outdated , maybe proposal of light grey would be accepted upstream)
Make it appear on mouse click is done by replacing: [sourcecode language=”java”]
OS.gdk_gc_set_function (gc, OS.GDK_XOR);
Point number 2 is done in Cairo by changing source rgb:
Cairo.cairo_set_source_rgb(cairo, 1, 1, 1);
In theory, to change color of Sash to light grey, I would just need to change RGB number to something like “0.3,0.3,0.3” in the function above, and celebrate my success.
Unfortunately, hackish way of replicating INCLUDE_INFERIORS, will not allow me to change RGB in this case. As I have said above, we are using cairo as target_surface, thus when I change color of Sash, it will change color of handle itself, and it is definitely not the way, I need it to behave.
Want to try it yourself and get updates on this issue ?
If you want to try it yourself:
I have opened a bug regarding this issue. Fastest way to get updates on this issue is to include yourself to CC list in this bug:
I will also post solution here, so everyone could use it, when this issue is resolved.