From: borisgaertner56@gmail.com
Subject: Re: Where do I get my Cairo context from (in GTK3)?
Date: Fri, 5 Aug 2016 08:56:12 -0700 (PDT)
Date: 2016-08-05T08:56:12-07:00 [thread overview]
Message-ID: <f1b3b835-f0f9-4112-bc21-3275e23c4fe1@googlegroups.com> (raw)
In-Reply-To: <do4ph6Fa6ghU1@mid.individual.net>
Am Sonntag, 24. April 2016 22:44:25 UTC+2 schrieb hreba:
> In GTk2 you got it from a call of Gdk.Cairo.Create.
>
> In GTK3 it is passed as a parameter of the callback function for the
> "draw" signal with the C prototype:
.....
To make a long story short, you have to add two lines and to modify one line:
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
DA_Ret_Callback.Marshallers.Generic_Marshaller
(Cairo.Cairo_context, Cairo.Get_Context);
.. end of addition
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;
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 yourself.
In GtkAda for Gtk-3, the instantiations of the generic package Return_Callback provide a marshaller that can forward a cairo context to a callback function.
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
prev parent reply other threads:[~2016-08-05 15:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-24 20:44 Where do I get my Cairo context from (in GTK3)? hreba
2016-04-25 7:40 ` Dmitry A. Kazakov
2016-04-25 10:03 ` hreba
2016-04-25 11:58 ` Dmitry A. Kazakov
2016-04-26 7:22 ` briot.emmanuel
2016-04-26 7:34 ` hreba
2016-04-27 7:47 ` briot.emmanuel
2016-04-27 8:08 ` Dmitry A. Kazakov
2016-04-28 7:48 ` briot.emmanuel
2016-04-27 13:15 ` hreba
2016-04-27 13:37 ` Dmitry A. Kazakov
2016-04-28 7:49 ` briot.emmanuel
2016-08-05 15:56 ` borisgaertner56 [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox