Cairo Context 0x0

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Cairo Context 0x0

bertus.dries
I am creating a new Drawing_Area.
I have packed the drawing Area in a Viewport which is packed in a scrolled window.
Now have the program line:
CR := Create(Get_Window (MainWindow.DrawingArea));
where MainWindow.DrawingArea is type Gtk_Drawing_Area with the value 0x4694f98
created with Gtk_New (MainWindow.DrawingArea);
The Cairo context CR has however a value 0x0 which finally results when using
Save(CR);
in:
Program received signal SIGSEGV, Segmentation fault.
cairo_save (cr=0x0) at ../../src/src/cairo.c:409
409 ../../src/src/cairo.c: No such file or directory.
Current language: auto
The current source language is "auto; currently c".

What must I do to create a valid CR?


_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cairo Context 0x0

Emmanuel Briot
> What must I do to create a valid CR?

You never (almost) create a cairo drawing context yourself.
Instead, you connect to the "draw" signal, which receives a prepared context.

Emmanuel
_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cairo Context 0x0

bertus.dries
Now put the draw routine within the On_Area_Draw bit before I can create any
interactive action I have to draw something So now I have to use
On_Area_Draw(null) and again the segmentation fault occurred.
I need to have the cairo context, I see no other way,
So

Again: How do I do that???

-----Oorspronkelijk bericht-----
From: Emmanuel Briot
Sent: Thursday, July 21, 2016 12:54 PM
To: [hidden email]
Subject: Re: [gtkada] Cairo Context 0x0

> In the initiation proces of the drawing area I  am connecting  the "draw"
> event to a handler and want to start drawing my starting figures
> with:
> Event_Cb.Connect (MainWindow.DrawingArea, "draw",
>                 Event_Cb.To_Marshaller (On_Area_Draw'Access));
>
> The first thing is setting the line thickness with:  Set_Line_Width(CR,
> 3.0); . I have commented the Save(CR) out. The segmentation  fault has
> transferred to this point. I need the context there. How do I get it?


Again:
you do everything in On_Area_Draw, nowhere else.

-----
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2016.0.7688 / Virusdatabase: 4627/12651 - datum van uitgifte:
07/21/16

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cairo Context 0x0

bertus.dries
In the 2015 version of Gtkada from AdaCore I could create The Cairo context
before I even connected to On_Area_Draw

-----Oorspronkelijk bericht-----
From: [hidden email]
Sent: Thursday, July 21, 2016 2:16 PM
To: Emmanuel Briot
Cc: Gtkada groep
Subject: Re: [gtkada] Cairo Context 0x0

Now put the draw routine within the On_Area_Draw bit before I can create any
interactive action I have to draw something So now I have to use
On_Area_Draw(null) and again the segmentation fault occurred.
I need to have the cairo context, I see no other way,
So

Again: How do I do that???

-----Oorspronkelijk bericht-----
From: Emmanuel Briot
Sent: Thursday, July 21, 2016 12:54 PM
To: [hidden email]
Subject: Re: [gtkada] Cairo Context 0x0

> In the initiation proces of the drawing area I  am connecting  the "draw"
> event to a handler and want to start drawing my starting figures
> with:
> Event_Cb.Connect (MainWindow.DrawingArea, "draw",
>                 Event_Cb.To_Marshaller (On_Area_Draw'Access));
>
> The first thing is setting the line thickness with:  Set_Line_Width(CR,
> 3.0); . I have commented the Save(CR) out. The segmentation  fault has
> transferred to this point. I need the context there. How do I get it?


Again:
you do everything in On_Area_Draw, nowhere else.

-----
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2016.0.7688 / Virusdatabase: 4627/12651 - datum van uitgifte:
07/21/16

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada


-----
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2016.0.7688 / Virusdatabase: 4627/12651 - datum van uitgifte:
07/21/16

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cairo Context 0x0

bertus.dries
I have been searching further and found in the comment of cairo.ads that I
must connect to the "expose-event". That gave again problems until  on the
internet I found that expose-event did not exist anymore and was replaced by
your "draw" event. The question that remains is how to create a "draw" event
so that I can retrieve the context to create lines with the functions that
need the Context?

Once more I don't uncerstand why such a big change was necessary between
GtkAda 2015 and 2016 and why it was carried out without extensive
documentation  and examples/tutorials of how the differences must be
handled?

-----Oorspronkelijk bericht-----
From: [hidden email]
Sent: Thursday, July 21, 2016 3:59 PM
To: Emmanuel Briot
Cc: Gtkada groep
Subject: Re: [gtkada] Cairo Context 0x0

In the 2015 version of Gtkada from AdaCore I could create The Cairo context
before I even connected to On_Area_Draw

-----Oorspronkelijk bericht-----
From: [hidden email]
Sent: Thursday, July 21, 2016 2:16 PM
To: Emmanuel Briot
Cc: Gtkada groep
Subject: Re: [gtkada] Cairo Context 0x0

Now put the draw routine within the On_Area_Draw bit before I can create any
interactive action I have to draw something So now I have to use
On_Area_Draw(null) and again the segmentation fault occurred.
I need to have the cairo context, I see no other way,
So

Again: How do I do that???

-----Oorspronkelijk bericht-----
From: Emmanuel Briot
Sent: Thursday, July 21, 2016 12:54 PM
To: [hidden email]
Subject: Re: [gtkada] Cairo Context 0x0

> In the initiation proces of the drawing area I  am connecting  the "draw"
> event to a handler and want to start drawing my starting figures
> with:
> Event_Cb.Connect (MainWindow.DrawingArea, "draw",
>                 Event_Cb.To_Marshaller (On_Area_Draw'Access));
>
> The first thing is setting the line thickness with:  Set_Line_Width(CR,
> 3.0); . I have commented the Save(CR) out. The segmentation  fault has
> transferred to this point. I need the context there. How do I get it?


Again:
you do everything in On_Area_Draw, nowhere else.

-----
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2016.0.7688 / Virusdatabase: 4627/12651 - datum van uitgifte:
07/21/16

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada


-----
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2016.0.7688 / Virusdatabase: 4627/12651 - datum van uitgifte:
07/21/16

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada


-----
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 2016.0.7688 / Virusdatabase: 4627/12651 - datum van uitgifte:
07/21/16

_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Cairo Context 0x0

Dmitry A. Kazakov
On 2016-07-22 09:11, [hidden email] wrote:
> I have been searching further and found in the comment of cairo.ads that
> I must connect to the "expose-event". That gave again problems until  on
> the internet I found that expose-event did not exist anymore and was
> replaced by your "draw" event. The question that remains is how to
> create a "draw" event so that I can retrieve the context to create lines
> with the functions that need the Context?

Queue draw:

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-queue-draw

[ Which is not needed anyway, unless the widget must be updated
periodically, e.g. an oscilloscope, clock widget ]

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
_______________________________________________
gtkada mailing list
[hidden email]
http://lists.adacore.com/mailman/listinfo/gtkada
Loading...