Re: [gtk-list] Re: Line attributes



Eric Harlow wrote:
> 
> Look back a couple of days for the discussion about gdk and colors.
> I'm at work so I don't remember the specifics, but I've written some
> code to create gc's for doing all sorts of things - mostly color
> related, but you could use them for other things.
> 

I've looked over them but with no use. 

Here is what I have done in my program:

1. I use for drawing a VDKCanvas class. It has as members a GtkWidget *
widget (GtkDrawingArea) and a GdkPixmap *pixmap for buffered drawing.
The Widget() function returns the widget pointer.
 
class VDKCanvas: public VDKObject
{
 ...
  GtkWidget *widget;
 public:
  ...  
  GdkPixmap *pixmap;   // pixmap for buffering
  GtkWidget *Widget(); // return the GtkDrawingArea
  Redraw();
  ...
}

2. The VDKCanvas does all the drawing on the pixmap. The pixmap is copy
in the drawing area with the Redraw().

3. I have a function _drawLine() which tries to draw lines with
different line styles on a VDKCanvas *canvas object. It does this by:

  gdk_gc_set_line_attributes(
	canvas->Widget()->style->fg_gc[GTK_WIDGET_STATE(canvas->Widget())],
	_lineWidth,
	_lineStyle,
	_capStyle,
	_joinStyle);

The problem is that this function is changing the style of all the lines
from my application, not only the lines used for the next drawing.

4. I have try this:

  GdkGC * gc = new gdk_gc_new(canvas->pixmap);
  gdk_gc_set_line_attributes(
	gc,
	_lineWidth,
	_lineStyle,
	_capStyle,
	_joinStyle);

but this doesn't do anything at all. (Another concern of mine is what do
I do with the acquired gc when I don't need anymore it).

I have also try unsuccessfully:

  GdkGC * gc = new gdk_gc_new(canvas->Widget()->window);

What I really need is a way to set the line style for subsequent
drawings on the pixmap.

TIA,

Ionutz



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]