[gtk] GetGandle() cast

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

[gtk] GetGandle() cast

Post by ONEEYEMAN »

Hi, ALL,
What I should cast the GetHandle() to on wxGTK?

The doc says it should be "GtkWidget", but I got the error saying:

"variable GtkWidget handle has initializer but incomplete type"
"invalid use of undefined type 'struct GtkWidget'"
"defs.h: forward declaration of 'struct GtkWidget'"

What sgould I do? The first 2 errors I got from my source code...

Thank you.
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

Your source files don't know anything about GTK+. You need to #include <gtk/gtk.h>
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN »

Thank you for the reply.
I am using the "gtk" port and X11 port. What types it should be casted to? I thought that gtk2 is GTK.

Thank you.
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

ONEEYEMAN wrote:Thank you for the reply.
I am using the "gtk" port and X11 port. What types it should be casted to? I thought that gtk2 is GTK.

Thank you.
wxGTK's wxWindow::GetHandle already returns a GtkWidget object, no need to cast it if you store it in a GtkWidget (as it the practice in GTK+). If you know what more specific object it is, you can cast to it as it is done in the GTK+ world. If you don't know, then you should probably not be touching it imho.

As for X11, I don't know why that came up now.
There is the wxGTK port (which can be compiled against gtk1 or gtk2, the former highly discouraged), and there is a wxX11 port. They are completely different things (sharing some common code across all ports), and have no platform specific code shared, beside some font handling classes.
The wxGTK port is mature and supported, while wxX11 is none of that.
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7459
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Post by ONEEYEMAN »

Thank you for the reply, leio.
Originally, I was using the following code:

Code: Select all

#ifdef __WXMSW__
	HWND handle = (HWND) this->GetHandle();
#else
	GtkWidget handle = (GtkWidget) this->GetHandle();
#endif
When I removed the casting for the right value, I got only the first error message: "variable GtkWidget handle has initializer but incomplete type".

Any other suggestion?

[EDIT]
The source code for the wx/gtk/window.h suggests to use "WXWidgets". Changing the handle type and removing the casting solved the problem.
[/EDIT]

Thank you.
leio
Can't get richer than this
Can't get richer than this
Posts: 802
Joined: Mon Dec 27, 2004 10:46 am
Location: Estonia, Tallinn
Contact:

Post by leio »

ONEEYEMAN wrote:

Code: Select all

#ifdef __WXMSW__
	HWND handle = (HWND) this->GetHandle();
#else
	GtkWidget handle = (GtkWidget) this->GetHandle();
#endif
When I removed the casting for the right value, I got only the first error message: "variable GtkWidget handle has initializer but incomplete type".

Any other suggestion?
Here you needed something like this:

Code: Select all

#ifdef __WXMSW__
	HWND handle = (HWND) this->GetHandle();
#elif __WXGTK__
	GtkWidget * handle = this->GetHandle();
#else
	// Handle other ports
#endif
Compilers: gcc-3.3.6, gcc-3.4.5, gcc-4.0.2, gcc-4.1.0 and MSVC6
OS's: Gentoo Linux, WinXP; WX: CVS HEAD

Project Manager of wxMUD - http://wxmud.sf.net/
Developer of wxGTK;
gtk+ port maintainer of OMGUI - http://www.omgui.org/
Post Reply