Re: GtkImage programming advice required



On Thu, 2005-12-15 at 23:05 -0500, Paul Davis wrote:
> On Fri, 2005-12-16 at 13:30 +1000, Mike Durham wrote:
> > Hi,
> > 
> > I'm struggling a bit with my first gtkmm prog and need a bit of advice.
> > 
> > I 'm using Anjuta on Linux and have a main window with buttons, sliders 
> > etc created in Glade and also a placeholder for an image. A GtkImage (is 
> > this correct?). The image will be an analogue meter indicating signal 
> > strength. I have the background bitmap to put into the GtkImage but I 
> > have to draw a black line for the needle, and of course update it as and 
> > when the signal strength changes.
> > 
> > So, I guess my question is how do I blit a bitmap image into the 
> > GtkImage placeholder?
> > 
> > I have attempted to find examples of this but they just show simple 
> > writing to the whole main window or just loading a bitmap from a file. 
> > This of course is not what I want.
> > 
> > Any help would be much appreciated.
> 
> Forget about GtkImage. Create a Gtk::Pixmap. Draw the background,
> possibly with the Gdk::Drawable::draw_pixbuf() function to put some kind
> of image background into the pixmap, then use Gdk::Drawable::draw_XXXX
> to draw your line. pick XXXX to suit how you intend to draw it (anti-
> aliased, etc. etc)
> 
> the pixmap will be double buffered by GTK.
> 
> do the drawing only in an expose handler. do not draw into the pixmap at
> other times.

rechecking my own code: in the expose handler, draw into the pixmap,
then blit it to the window with Gdk::Drawable::draw_drawable():

	Glib::RefPtr<Gdk::Window> win = get_window();
	win->draw_drawable (pixmap, .....);

you might even be able to do this straight into the window, since its
all double buffered these days anyway. doing it into the pixmap to start
with will let you experiment a little more to get started.

--p





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