Re: [gtk-list] C++ and gtk+



On Mon, 20 Dec 1999 10:47:18 +0100 (MET), David Pettersson wrote:
> I tried to do a little program in c++ with gtk+. I have a 'class A' which
> contains a 'widget *W'. If I have more then one instance of 'A' I can for
> some signals (e.g. "clicked") send 'this' last data argument to
> 'gtk_signal_connect()', and thus know what object the signal refer to.
> With other signals (e.g. "configure_event") the last argument in the
> callback function is used for other data, so my question is, how do I know
> which of my objects the signal refers to?

I don't know what widget you're talking about, but here is an example for
an eventbox widget:

    // get the button press events and connect it to a callback function 
    gtk_widget_set_events(eventbox, GDK_BUTTON_PRESS_MASK);
    gtk_signal_connect(GTK_OBJECT(eventbox), "button_press_event",
                       GTK_SIGNAL_FUNC(gui3D_identRightButtonPressCallback), 
                       this);

And the callback function:

  void gui3D_identRightButtonPressCallback(GtkWidget *widget, 
                                           GdkEventButton *event, 
                                           gpointer data)
  {
    gui3D *gui = (gui3D *)data;
  
    assert(gui != NULL);
  
    gui->identRightButtonPressCallback(widget, event);
  }


Erik

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2785859  Fax: +31-15-2781843  Email J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]