From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.157.44.38 with SMTP id f35mr11179602otb.14.1470412572681; Fri, 05 Aug 2016 08:56:12 -0700 (PDT) X-Received: by 10.157.47.97 with SMTP id h88mr1917503otb.10.1470412572654; Fri, 05 Aug 2016 08:56:12 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!feeder.eternal-september.org!news.glorb.com!f6no7588396ith.0!news-out.google.com!d68ni17693ith.0!nntp.google.com!f6no7588388ith.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 5 Aug 2016 08:56:12 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=62.158.18.59; posting-account=t7A86QoAAAC7cAbhCEBAMlkDj7ijrH7m NNTP-Posting-Host: 62.158.18.59 References: User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: Subject: Re: Where do I get my Cairo context from (in GTK3)? From: borisgaertner56@gmail.com Injection-Date: Fri, 05 Aug 2016 15:56:12 +0000 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:31294 Date: 2016-08-05T08:56:12-07:00 List-Id: Am Sonntag, 24. April 2016 22:44:25 UTC+2 schrieb hreba: > In GTk2 you got it from a call of Gdk.Cairo.Create. >=20 > In GTK3 it is passed as a parameter of the callback function for the=20 > "draw" signal with the C prototype: ..... To make a long story short, you have to add two lines and to modify one lin= e: package DA_Ret_Callback is new Gtk.Handlers.User_Return_Callback (Gtk.Widget.Gtk_Widget_Record, Boolean, Handler_DataD); -- begin of addition package Context_Marshaller is new=20 DA_Ret_Callback.Marshallers.Generic_Marshaller (Cairo.Cairo_context, Cairo.Get_Context); .. end of addition=20 function Draw_Handler (da: access Gtk.Widget.Gtk_Widget_Record'Class; cc: Cairo.Cairo_Context; hd: Handler_DataD) return Boolean is begin ... end Draw_Handler; procedure Connect_Handlers (obj: Glib.Object.GObject; hd: Handler_DataD; sn_realize, sn_config, sn_draw: Glib.Signal_Name) is begin ... DA_Ret_Callback.Connect (Gtk.Widget.Gtk_Widget(obj), sn_draw, Context_Marshaller.To_Marshaller(Draw_Handler'Access), --modified, was: DA_Ret_Callback.To_Marshaller( .... ) hd); end Connect_Handlers;=20 The point is that, in Gtk-3, a callback function that draws into a widget, = is called with a Cairo context,whereeas in Gtk-2, your created the context you= rself. In GtkAda for Gtk-3, the instantiations of the generic package Return_Callb= ack provide a marshaller that can forward a cairo context to a callback fun= ction. In generic package User_Return_Callback such a marshaller is still missing.= Therefore you have to define it yourself. This is done as shown above. The= good thing is that you can do it in your application - there is no need to= modify and to recompile the GtkAda sources. -- Boris Gaertner