c++ - Unable to paint on Gtk drawing_area with Cairo -
I try to color a point at drawing_area on Gtk I'm Cairo . I have two functions, the do_drawing function, to draw a point on draw to paint the background, and the other one do_drawpoint .
Zero Painting: do_drawing (cairo_t * cr) {cairo_set_source_rgb (cr, 1, 1, 1); Cairo_paint (cr); } Zero Painting: do_pointDraw (CARO_T * CR) {CARO_USSET_SASS_RGB (CR, 0, 0, 0); Cairo_Arch (CR, 150, 150, 10, 0, 2 * MOPI); Cairo_fill (cr); } Now whenever the user clicks on drawing_area , then the dropout function is called.
zero drawing arrow :: dropout () {g_signal_connect (area, "button-press-event", gcalblack (clicked), tap); Std :: Court & lt; & Lt; "Drawpoint" & lt; & Lt; Std :: endl; } Gboolean clicked (GtkWidget * widget, GdkEventButton * event, cairo_t * cr, gpointer user_data) {if (event-> button == 1) {x = event-> X; Y = event- & gt; Y; } Std :: cout & lt; & Lt; X & lt; & Lt; "And" & lt; & Lt; Y & lt; & Lt; Std :: endl; Ptr- & gt; Do_pointDraw (CR); Gtk_widget_queue_draw (widget); } Return TRUE; } but after printing values of x and y , the program ends with a split error.
What could be the reason for this? Am I moving forward in the right way?
The code is difficult to read (with broken indentation and only snippets provided), but some things Keep in mind:
-
button-press eventhandler signature is incorrect. Caro's reference is not there. - Drawing only should be the signal handler of
DrawGtkDrawingArea. The idea of drawing on the button press is that Caro does not work: User interaction should change the status of your app, draw-handler should be attracted based on current app position. -
button-press-eventhandler is connected todropout (). It looks very wrong.
I recommend that you try to read and start it with a simple example, and after that, start adding complex things to work on.
Comments
Post a Comment