Wrapper for Callbacks
- From: Andreas Volz <lists brachttal net>
- To: gtk-app-devel-list gnome org
- Subject: Wrapper for Callbacks
- Date: Tue, 7 Sep 2004 10:56:33 +0200
Hi,
for a special use I need to create a wrapper for a subset of gtk2 (gdk).
But I've some problems with the callbacks. Perhaps it's a little
off-topic, because it's written in C++. But I know no better place. Here
is my class:
class Drawbox
{
private:
GtkWidget *window;
void (*drawCallbackFunc);
GtkWidget* create_drawbox_window (void);
static gboolean
on_drawingarea_drawbox_configure_event (GtkWidget *widget,
GdkEventConfigure *event,
gpointer user_data);
static gboolean
on_drawingarea_drawbox_expose_event (GtkWidget *widget,
GdkEventExpose *event,
gpointer user_data);
static void draw_drawbox (GtkWidget *widget,
GdkPixmap **pixmap_p,
int x, int y,
int draw_width, int draw_height);
public:
Drawbox ();
void setDrawCallback (void (*drawCallbackFunc));
};
I create the windows in the constructor and create_drawbox_window() and
bind then then callbacks with gtk_signal_connect(). I could do this all
in the constructor, but it only a draft currently. But
gtk_signal_connect() seems only to like member functions if they're
defined as static. But it seems to work with static. This callback runs
then draw_drawbox().
Now I like to register my own callbacks with setDrawCallback(). This
function is then called in draw_drawbox(). But if I try this my compiler
says:
drawbox.cpp: In static member function `static void
Drawbox::draw_drawbox(GtkWidget*, GdkPixmap**, int, int, int, int)':
drawbox.cpp:150: error: invalid use of member
`Drawbox::drawCallbackFunc' in static member function
make: *** [drawbox.o] Fehler 1
Any ideas? Or should I use gtkmm to avoid this problems with C++?
Gruß
Andreas
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]