1. wxTaskBarIcon help

Matt,

I'm trying to wrap wxTaskBarIcon, and I'm doing something wrong. I just committed wxTaskBarIcon.cpp. When I try to build the library, I get the following error. I'm not sure what I'm doing wrong. getlost

Open Watcom Make Version 1.7 
Portions Copyright (c) 1988-2002 Sybase, Inc. All Rights Reserved. 
Source code is available under the Sybase Open Watcom Public License. 
See http://www.openwatcom.org/ for details. 
	wpp386 -bt=nt -zq -fo=wat_dll\wxTaskBarIcon.obj /bd /xs     -d__WXMSW__     -dwxNO_THREADS -dWXEUMSW -d_UNICODE 
-i=C:\EUPHORIA\wxWidgets-2.8.7\lib\wat_dll\mswu -DWX_LIB_BUILD=13 -i=C:\EUPHORIA\wxWidgets-2.8.7\include -w0 -dWXUSINGDLL 
-i=C:\EUPHORIA\wxWidgets-2.8.7\lib\wat_dll\mswu /d1 -dNOPCH   .\wxTaskBarIcon.cpp 
	wlink runtime windows=4.0 @wat_dll\wxeu.lbc @wat_dll\exports.lbc 
Error! E2028: near wxString::wxString( int ) is an undefined reference 
file wat_dll\wxTaskBarIcon.obj(C:\EUPHORIA\wxEuphoria\wxeu\trunk\wxTaskBarIcon.cpp): undefined symbol near wxString::wxString( int ) 


Here's the code:

// For compilers that support precompilation, includes "wx/wx.h". 
#include "wx/wxprec.h" 
 
#ifdef __BORLANDC__ 
    #pragma hdrstop 
#endif 
 
#ifndef WX_PRECOMP 
    #include "wx/wx.h" 
#endif 
#include "alldefs.h" 
#include "wxeu.h" 
#include "wx/taskbar.h" 
 
 
extern "C"{ 
class EuTaskBarIcon: public wxTaskBarIcon 
{ 
public: 
    EuTaskBarIcon() {} 
    wxMenu * m_Menu; 
    virtual wxMenu *CreatePopupMenu(); 
}; 
 
wxMenu *EuTaskBarIcon::CreatePopupMenu() 
{ 
    m_Menu = new wxMenu; 
    return m_Menu; 
} 
 
object WXEUAPI new_wxTaskBarIcon(object params) 
{ 
    wxDeRefDS( params ); 
     
    EuTaskBarIcon * icon = new EuTaskBarIcon(); 
    return BOX_INT( icon ); 
} 
 
object WXEUAPI get_taskbar_menu( int taskbar ) 
{ 
    return BOX_INT( ((EuTaskBarIcon*)taskbar)->m_Menu ); 
} 
 
void WXEUAPI set_taskbar_icon( int taskbar, int icon, object tooltip ) 
{ 
    wxIcon ico = (wxIcon)icon; 
    wxString str = get_string(tooltip); 
    wxDeRefDS( tooltip ); 
     
    ((EuTaskBarIcon*)taskbar)->SetIcon( ico, str ); 
} 
 
} 

-Greg

new topic     » topic index » view message » categorize

2. Re: wxTaskBarIcon help

ghaberek said...

I'm trying to wrap wxTaskBarIcon, and I'm doing something wrong. I just committed wxTaskBarIcon.cpp. When I try to build the library, I get the following error. I'm not sure what I'm doing wrong. getlost

Stupid pointer tricks:

    wxIcon ico = (wxIcon)icon; 
...should be... 
    wxIcon ico = *(wxIcon*)icon; 
The int icon parameter is really a pointer, but since you need to pass a reference, you can dereference it like that. You could alternatively do this:
    wxIcon* ico = (wxIcon*)icon; 
    ... 
    ((EuTaskBarIcon*)taskbar)->SetIcon( *ico, str ); 
I think the weird error was probably due to the compiler trying too hard to construct a wxIcon object from an int.

Also, how are you generating the exports? It's always missing some:

Failed to link function: +get_staticbitmap 
Failed to link procedure: +set_mdi_child_title 
Failed to link procedure: +set_staticbitmap 
Failed to link variable: null_pen 
Failed to link variable: null_brush 
I committed r371 fixing wxTaskBarIcon.cpp and the exports.

Matt

new topic     » goto parent     » topic index » view message » categorize

3. Re: wxTaskBarIcon help

mattlewis said...

Stupid pointer tricks:

    wxIcon ico = (wxIcon)icon; 
...should be... 
    wxIcon ico = *(wxIcon*)icon; 
The int icon parameter is really a pointer, but since you need to pass a reference, you can dereference it like that. You could alternatively do this:
    wxIcon* ico = (wxIcon*)icon; 
    ... 
    ((EuTaskBarIcon*)taskbar)->SetIcon( *ico, str ); 
I think the weird error was probably due to the compiler trying too hard to construct a wxIcon object from an int.

Figures. This is why I hate pointers (and therefore dislike C as a whole). getlost

mattlewis said...

Also, how are you generating the exports? It's always missing some:

Failed to link function: +get_staticbitmap 
Failed to link procedure: +set_mdi_child_title 
Failed to link procedure: +set_staticbitmap 
Failed to link variable: null_pen 
Failed to link variable: null_brush 
I committed r371 fixing wxTaskBarIcon.cpp and the exports.

See export.exw. It uses the same methods as wrap.exw to fish out all the routines and dump them into wat_dll\exports.lbc. So they're in exports.lbc, but they're not showing up in the final dll, for some reason. I just updated export.exw to output null_pen and null_brush, but they're still not showing up. And with the recent addition of wxTaskBarIcon.cpp, the list gets longer:

Failed to link function: +get_staticbitmap 
Failed to link procedure: +set_mdi_child_title 
Failed to link procedure: +set_staticbitmap 
Failed to link function: +new_wxTaskBarIcon 
Failed to link function: +get_taskbar_menu 
Failed to link procedure: +set_taskbar_icon 
Failed to link variable: null_pen 
Failed to link variable: null_brush 
I just committed r372 with my changes to export.exw. Still broken. sad

-Greg

new topic     » goto parent     » topic index » view message » categorize

4. Re: wxTaskBarIcon help

ghaberek said...

See export.exw. It uses the same methods as wrap.exw to fish out all the routines and dump them into wat_dll\exports.lbc. So they're in exports.lbc, but they're not showing up in the final dll, for some reason. I just updated export.exw to output null_pen and null_brush, but they're still not showing up. And with the recent addition of wxTaskBarIcon.cpp, the list gets longer:

Failed to link function: +get_staticbitmap 
Failed to link procedure: +set_mdi_child_title 
Failed to link procedure: +set_staticbitmap 
Failed to link function: +new_wxTaskBarIcon 
Failed to link function: +get_taskbar_menu 
Failed to link procedure: +set_taskbar_icon 
Failed to link variable: null_pen 
Failed to link variable: null_brush 

Ok, the problem is that the regex is looking for an open paren immediately after the name. The functions and procedures have a space before the paren, and the variables, of course, don't have parenthesis at all.

I think the export generation should look at wxeud.e (which is what the makefile does), since it provides a double check, and ensures that everything that it wants to see is actually exported. Omitting an export 'silently' fails until wxEuphoria tries to use it, while exporting something that hasn't been compiled causes a linker error. From makefile.wat:

    grep -hP "=\s+wx_define_c_" wxeud.e | sed -re "s/.*\"(.*)\".*/EXPORT \1=_\1/" > wat_dll\exports.lbc 
The first regex finds the lines, and the second one generates the line in exports.lbc. Sheesh, just install gnuwin32 already. tongue

Matt

new topic     » goto parent     » topic index » view message » categorize

5. Re: wxTaskBarIcon help

mattlewis said...

Ok, the problem is that the regex is looking for an open paren immediately after the name. The functions and procedures have a space before the paren, and the variables, of course, don't have parenthesis at all.

I think the export generation should look at wxeud.e (which is what the makefile does), since it provides a double check, and ensures that everything that it wants to see is actually exported. Omitting an export 'silently' fails until wxEuphoria tries to use it, while exporting something that hasn't been compiled causes a linker error. From makefile.wat:

    grep -hP "=\s+wx_define_c_" wxeud.e | sed -re "s/.*\"(.*)\".*/EXPORT \1=_\1/" > wat_dll\exports.lbc 
The first regex finds the lines, and the second one generates the line in exports.lbc. Sheesh, just install gnuwin32 already. tongue

Cool. I kept seeing you mention grep/sed for generating exports, but I never knew what that was all about. I'll install GnuWin32. It's probably for the best anyway. I'm sick of trying to "figure it out" with the Windows utilities like type and find. getlost

-Greg

new topic     » goto parent     » topic index » view message » categorize

6. Re: wxTaskBarIcon help

Hrm... GunWin32 didn't seem to install grep. getlost But this works equally as well: grin

type wxeud.e | find "= wx_define_c_" | sed -re "s/.*\"(.*)\".*/EXPORT \1=_\1/" > exports.lbc 

-Greg

new topic     » goto parent     » topic index » view message » categorize

7. Re: wxTaskBarIcon help

Okay... now all the exports are fixed. blink

new topic     » goto parent     » topic index » view message » categorize

8. Re: wxTaskBarIcon help

ghaberek said...

Hrm... GunWin32 didn't seem to install grep. getlost But this works equally as well: grin

type wxeud.e | find "= wx_define_c_" | sed -re "s/.*\"(.*)\".*/EXPORT \1=_\1/" > exports.lbc 

Somehow that just seems dirty. smile

Which packages did you install? Grep has its own package.

Matt

new topic     » goto parent     » topic index » view message » categorize

9. Re: wxTaskBarIcon help

mattlewis said...

Somehow that just seems dirty. smile

It is. Cheap and dirty all the way. blink

mattlewis said...

Which packages did you install? Grep has its own package.

I downloaded the gnuwin32 package maintenance utility. It's where the "Download All" link took me.

-Greg

new topic     » goto parent     » topic index » view message » categorize

10. Re: wxTaskBarIcon help

ghaberek said...

Cool. I kept seeing you mention grep/sed for generating exports, but I never knew what that was all about. I'll install GnuWin32. It's probably for the best anyway. I'm sick of trying to "figure it out" with the Windows utilities like type and find. getlost

Or you could try the package I recommended to Matt in 2007 this post.

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu