Pointer to public, private, ... section of a C++ class
- From: Raphael Zulliger <zulli mail izh ch>
- To: gnome-devel-list gnome org
- Subject: Pointer to public, private, ... section of a C++ class
- Date: Tue, 18 Feb 2003 08:18:01 +0100
hi
i have the following problem: i should make use of dcopc (a C-library
for the DCOP protocol used by KDE). i can't use the KDCOP implementation
because i don't wanna create a KDE app but a wxWindows app (also written
in C++).
short version:
how can i get a pointer to the private, a pointer to my publich section
and a pointer to the methods of my C++! class?
long version:
Someone has created wrappers for cdcop for Gtk programs. now this
wrapper(-class?) is called GtkXPart (see code below).
Now i should create a class (C++) which's baseclass is GtkXPart.
Therefore I've just declared myClass like this:
class myClass : public GtkXPart { ...... };
My problem is, i don't no what to do in the constructor of my class...
of course the "constructor" of GtkXPart is called (i checked that), but
i should initialize some variables of the GtkXPart, namely: the pointers
to open_url, close_url, to myClass, ... And theres my problem: I should
have 3 different pointers to my class: one that points to myClass itself
(i think there are stored the data equivalent to GtkXPart) an other that
points to myClassClass which points to the operations and the third
should point to myClassPrivate which shows to the private vars/funcs...
but how can i do that?! i've some samplecode of kmozilla (mozilla
embeded in kde's konqueror) which makes use of GtkXPart but it is itself
a C-program, not C++ (see below).
I would be happy if someone could send me codefragments of a solution!
Thanks in advance!
raphael
-------------
|kmozilla.h:|
-------------
typedef struct _GtkKmozilla GtkKmozilla;
typedef struct _GtkKmozillaClass GtkKmozillaClass;
struct _GtkKmozilla
{
GtkXPart part;
void *data;
};
struct _GtkKmozillaClass
{
GtkXPartClass parent_class;
};
...
-------------
|kmozilla.c:|
-------------
/* class and instance initialization */
static void
gtk_kmozilla_class_init(GtkKmozillaClass *klass)
{
GtkObjectClass *object_class = (GtkObjectClass *)klass;
GtkXPartClass *xpart_class = GTK_XPART_CLASS(klass);
parent_class = (GtkXPartClass*)gtk_type_class(gtk_xpart_get_type());
object_class->destroy = gtk_kmozilla_destroy;
xpart_class->open_url = open_url;
...
}
static void
gtk_kmozilla_init(GtkKmozilla *part)
{
...
GtkKmozillaPrivate *d;
d = g_new( GtkKmozillaPrivate, 1 );
part->data = d;
....
dcop_object_set_id( DCOP_OBJECT(part), "KmozillaClient" );
....
/* g_warning( "winid %x\n", GDK_WINDOW_XWINDOW( w->window ) );*/
gtk_xpart_set_widget( (GtkXPart *)part, w );
gtk_signal_connect(GTK_OBJECT(part), "reload",
GTK_SIGNAL_FUNC(handle_reload), NULL);
gtk_signal_connect(GTK_OBJECT(moz), "open_uri",
GTK_SIGNAL_FUNC(open_url_request), NULL);
mozilla = part;
}
....
------------
|gtkpart.h:|
------------
typedef struct _GtkXPart GtkXPart;
typedef struct _GtkXPartClass GtkXPartClass;
struct _GtkXPart
{
DcopObject obj;
void *data;
};
struct _GtkXPartClass
{
DcopObjectClass parent_class;
gboolean (* open_url) ( GtkXPart *part, const char * url );
gboolean (* close_url) ( GtkXPart *part );
char * (*query_extension) ( GtkXPart *part, const char *name );
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]