I'm using Gtk# and mono on Linux to make a program where I am creating a slider control over a timeline graph. I have it basically working, but there is one nagging problem that I can not figure out--- how to use transparency when using the Gtk.Style drawing routines such as "PaintBox" AND "PaintHLine". Because I could not figure out how to use these and still maintain transparency, I am currently using Cairo drawing routines, but this does not allow me to use the theme consistent look provided by the Style routines.
Currently, I have a custom widget class that has a Gtk.DrawingArea. I have a Cairo.ImageSurface kept in memory for the underlying Graph, and a Separate Cairo.ImageSurface for the "slider" which is supposed to be painted onto the DrawingArea to set a location in the timeline.
Problem is, I cannot for the life of me determine how to get my Gtk.Style.Paint... functions to draw on my Cairo.ImageSurface and still maintain transparency. Here is some sample code that is basically what I currently have:
private Cairo.ImageSurface graphImage;
private Cairo.ImageSurface gripImage;
private int grip_width;
private int grip_height;
public void MainClass() {
*...(initialization code here)...*
}
private override void OnExposeEvent() {
if (graphImage == null) {
graphImage = new Cairo.ImageSurface(Format.Rgba,graphDrawingArea.Allocation.Width,graphDrawingArea.Allocation.Height);
}
if (gripImage == null) {
gripImage = new Cairo.ImageSurface(Format.Rgba,grip_width,grip_height);
}
DrawGraph();
DrawGrip();
}
private override void OnResizeEvent() {
MakeGraph();
MakeGrip();
}
private void MakeGraph() {
using (Cairo.Context context = Gdk.CairoHelper(graphImage)) {
*...(use cairo drawing routines to draw the graph)...*
}
}
private void MakeGrip() {
using (Cairo.Context context = Gdk.CairoHelper(gripImage)) {
*...(use cairo drawing routines to draw the graph)...*
}
}
private void DrawGraph() {
using (Cairo.Context context = Gdk.CairoHelper(graphDrawingArea.GdkWindow)) {
*...(use cairo to "paint" the graphImage onto our drawing area at the proper location)...*
}
}