FW: help. refresh drawingarea pixmap.............



Hi
	I have a question regarding to a drawing area and how to update it. I
understand from the examples that I can use gdk_draw_pixmap() to copy the
updated pixmap onto my screen.  But I have been trying to retrieve pixmap
from my drawing area so taht i can use this function to update it. I am very
new to it. If someone knows how to do it. please help me. I will really
appreciate it.
THere is my code

my drawingarea is generated by creat_drawArea. I need to use the same mouse
event when I update the drawingarea. HOw can I retrieve the pixmap from my
create_DrawArea and put back to the drawingarea that i created before.
Thanks very much.
LLT....

struct UICOM
{
	GtkWidget* drawArea;
	GdkPixmap* pixmap;
	gint w; // drawarea width
	gint h; // drawarea height

	UICOM(gint nc, gint nr){
			pixmap=NULL;
			drawArea=NULL;
			w = nc;
			h = nr;
			}

	UICOM(){}
	~UICOM(){}

};

GtkWidget* create_DrawArea (gint area_width, gint area_height)
{

  static DRAWREC DrawRec;

  GtkWidget* drawArea;

  drawArea = gtk_drawing_area_new();
  DrawRec.UI.drawArea = drawArea;
  DrawRec.UI.w = area_width;
  DrawRec.UI.h = area_height;


  gtk_drawing_area_size(GTK_DRAWING_AREA(drawArea),area_width, area_height);

  gtk_widget_set_events(GTK_WIDGET(drawArea),
                        GDK_EXPOSURE_MASK|
                        GDK_BUTTON_PRESS_MASK|
		GDK_BUTTON_RELEASE_MASK|
		GDK_POINTER_MOTION_MASK|
                        GDK_POINTER_MOTION_HINT_MASK);


  gtk_signal_connect (GTK_OBJECT(drawArea), "button_release_event",
                      GTK_SIGNAL_FUNC(drawArea_button_release), NULL);


  gtk_signal_connect (GTK_OBJECT(drawArea), "button_press_event",
                      GTK_SIGNAL_FUNC(drawArea_button_press), NULL);


  gtk_signal_connect (GTK_OBJECT(drawArea), "motion_notify_event",
                      GTK_SIGNAL_FUNC(drawArea_motion_notify), NULL);

  gtk_signal_connect (GTK_OBJECT(drawArea), "expose_event",
                      GTK_SIGNAL_FUNC(drawArea_draw), (gpointer) ((DRAWREC
*) &DrawRec));


  gtk_signal_connect (GTK_OBJECT(drawArea), "configure_event",
                      GTK_SIGNAL_FUNC(drawArea_configure), (gpointer)
((DRAWREC *) &DrawRec));


  gtk_signal_connect (GTK_OBJECT(drawArea), "destroy",
                      GTK_SIGNAL_FUNC (drawArea_destroy), (gpointer)
((DRAWREC *) &DrawRec));



  return (drawArea);

}



//this is the part related to draw area
gint drawArea_draw (GtkWidget* widget, GdkEventExpose* event, gpointer
clientData)
{

    DRAWREC * pDrawRec = (DRAWREC *) clientData;
		GdkColor *bg;
    GdkGC *bg_gc;
		const gfloat factor = 65535.0f/255.0f;

    bg = (GdkColor *) g_malloc (sizeof (GdkColor));
    bg->red = gushort (255 * factor);
    bg->green = gushort (0 * factor);
    bg->blue = gushort (255* factor);

    gdk_color_alloc (gdk_colormap_get_system (), bg);

    bg_gc = gdk_gc_new (pDrawRec->UI.pixmap);

    gdk_gc_set_background (bg_gc, bg);

    gdk_draw_rectangle(pDrawRec->UI.pixmap, bg_gc, 1, event->area.x,
event->area.y,
	    event->area.width, event->area.height);




    barplot *aXYPlot = Drawbarplot(pDrawRec->UI, pDrawRec->DATA);


    gdk_draw_pixmap(widget->window,
	    widget->style->white_gc,
	    pDrawRec->UI.pixmap,
	    event->area.x, event->area.y,
	    event->area.x, event->area.y,
	    event->area.width, event->area.height);
	    return FALSE;

}





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