Re: [gtkmm] Gdk::GC doesn't work as described



On Thu, 5 Dec 2002 22:23:54 -0300
Juan Linietsky <coding reduz com ar> wrote:

> On Thu, 5 Dec 2002 22:12:08 +0100 (CET)
> Torsten Sievers <tsievers rhrk uni-kl de> wrote:
> 
> > Hello List,
> > 
> > i need to create a GC for a DrawingArea,
> > following the examples in the tutorial, i can't get any result,
> > it seems that the tutorial-code is not up-to-date.
> > here is a code-snippet:
> > (from the tutorial)
> > 
> >   Gdk::GC some_gc;
> >   some_gc.create(get_window());
> >   Gdk::Color some_color;
> >   Gdk::Colormap some_colormap(Gdk::Colormap::get_system());
> >   some_color.set_red(65535);
> >   some_color.set_green(65535);
> >   some_color.set_blue(0);
> >   some_colormap.alloc(some_color);
> >   some_gc.set_foreground(some_color);
> > 		  
> > i create all necessary things (i think)
> > 
> > but the compiler says that Gdk::GC is protected (which is correct 
> > according to the includes and the API-Reference)
> > 
> > it says also, that Gdk::Colormap::get_system() is undefined.
> > 
> > can somebody please give me a correct version of the code-snippet
> > so i can work on?
> > 
> > TIA
> > -- 
> > Greetings
> >   Torsten
> 
> I got that kind of figured out, but i dont think it's the right way since it's all messy.
> Most functions are now refptrs it seems, so you have to use the -> operator to get the data,
> instead of ".". However I dont understand what to do in case of having to pass those
> as argument, since it begs me for a refptr instead of creating one from the object i pass
> using a copyconstructor.
> 
> Juan Linietsky
> 

As i do more hacking through gtkmm source, it seems to be that I need to do

Glib::RefPtr<Gdk::GC> MyGC;
MyGC = Gdk::GC::create(drawingarea);

It used to be
Gdk_GC MyGC;
MyGC.create(drawingarea);

Beats me why it needs to be that more complicated, I am probably doing something wrong anyway.

Juan Linietsky






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