comp.lang.ada
 help / color / mirror / Atom feed
* Where do I get my Cairo context from (in GTK3)?
@ 2016-04-24 20:44 hreba
  2016-04-25  7:40 ` Dmitry A. Kazakov
  2016-08-05 15:56 ` borisgaertner56
  0 siblings, 2 replies; 13+ messages in thread
From: hreba @ 2016-04-24 20:44 UTC (permalink / raw)


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:

    gboolean
    user_function (GtkWidget    *widget,
                   CairoContext *cr,
                   gpointer      user_data)

So I wrote in my Ada program (GNAT, gtkada):

    package DA_Ret_Callback is new Gtk.Handlers.User_Return_Callback
      (Gtk.Widget.Gtk_Widget_Record, Boolean, Handler_DataD);


    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,
	 DA_Ret_Callback.To_Marshaller(Draw_Handler'Access),
	 hd);
    end Connect_Handlers;


The compiler then tells me

    gui-canvas.adb:79:25: no candidate interpretations match the actuals:
    gui-canvas.adb:79:52: expected type "Handler" defined at
    gtk-marshallers.ads:309, instance at gtk-handlers.ads:468,
    instance at line 20

That means that he expects a handler

          type Handler is access function
	           (Widget    : access Widget_Type'Class;
	            User_Data : User_Type) return Return_Type;
	
So where do I get the cairo context from?
-- 
Frank Hrebabetzky		+49 / 6355 / 989 5070

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2016-08-05 15:56 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox