Page 1 of 1

toolbar bitmap

Posted: Wed Sep 24, 2008 9:57 pm
by cenix
I'm trying to extend a particular toolbar with some convenience function. This function combines several existing functions into one.
All is going well, however when I come to create the bitmap for the toolbar, I get the following assert:

Code: Select all

ASSERT INFO:
../src/gtk/tbargtk.cpp(404): assert "bitmap.Ok()" failed in DoInsertTool(): invalid bitmap for wxToolBar icon

BACKTRACE:
[1] wxToolBar::DoInsertTool(unsigned int, wxToolBarToolBase*)
[2] wxToolBarBase::InsertTool(unsigned int, wxToolBarToolBase*)
[3] wxToolBarBase::InsertTool(unsigned int, int, wxString const&, wxBitmap const&, wxBitmap const&, wxItemKind, wxString const&, wxString const&, wxObject*)
[4] wxToolBarBase::DoAddTool(int, wxString const&, wxBitmap const&, wxBitmap const&, wxItemKind, wxString const&, wxString const&, wxObject*, int, int)
[5] wxToolBarBase::AddTool(int, wxString const&, wxBitmap const&, wxBitmap const&, wxItemKind, wxString const&, wxString const&, wxObject*) /usr/include/wx-2.8/wx/tbarbase.h:261
[6] wxToolBarBase::AddTool(int, wxString const&, wxBitmap const&, wxString const&, wxItemKind) /usr/include/wx-2.8/wx/tbarbase.h:270
[7] Frame::CreateToolbars24() /home/cenix/Programming/codelite/codelite/LiteEditor/frame.cpp:849
[8] Frame::CreateGUIControls() /home/cenix/Programming/codelite/codelite/LiteEditor/frame.cpp:681
[9] Frame() /home/cenix/Programming/codelite/codelite/LiteEditor/frame.cpp:439
[10] Frame::Initialize(bool) /home/cenix/Programming/codelite/codelite/LiteEditor/frame.cpp:508
[11] App::OnInit() /home/cenix/Programming/codelite/codelite/LiteEditor/app.cpp:312
I have modified the resources.xrc file to include the new bitmap and made the correct AddTool() call. It compiles fine.
If I replace the call to point to another existing bitmap wxXmlResource::Get()->LoadBitmap(wxT("<bitmap id>")) all goes fine.

This implies that my bitmap is not correct, however when I make a copy of an existing bitmap and use that one, it also fails(!).

I must be forgetting something (or else don't see correctly what is going wrong).
How to proceed?

Re: toolbar bitmap

Posted: Wed Sep 24, 2008 10:25 pm
by eranif
I suspect that you did not compile the resources.xrc file, did you?

to compile it you need to run this command (you should cd to /home/cenix/Programming/codelite/codelite/LiteEditor/)

Code: Select all

wxrc -c -v -o resources.cpp resources.xrc
the above command will generate new resources.cpp file from the xrc - now your bitmap should be OK.

If you dont have wxrc installed on your machine, you should install it like this:

Code: Select all

sudp apt-get install wx-common
Eran

Re: toolbar bitmap

Posted: Wed Sep 24, 2008 11:17 pm
by cenix
See, I knew I forgot something ;)

Only thing I now encounter is its long processing time. Its running for about 20 minutes now and the file is 23810 lines long, but the file isn't completed yet (at least missing some values and the closing };
So I guess something is not quite right yet.

Ah well, have to go now, will try further tomorrow.

Re: toolbar bitmap

Posted: Sat Sep 27, 2008 12:33 pm
by cenix
Still no luck :(

I can wait forever for wxrc to complete. If I try to compile a binary file (xrs), I get a segfault, so I'm not sure it wxrc is fully broken or only for binary compiles. Damnit.

Re: toolbar bitmap

Posted: Sat Sep 27, 2008 12:49 pm
by eranif
cenix wrote:I can wait forever for wxrc to complete.
Which OS?

Here, on my Kbuntu 8.04,64bit, running this command:

Code: Select all

wxrc -c -v -o resources.cpp resources.xrc 
takes less than 10 secs.

If it still fails, you can try other methods of embedding your images like load them directly from file.

try re-installing wx-common

Eran

Re: toolbar bitmap

Posted: Sat Sep 27, 2008 5:16 pm
by cenix
I tried reinstalling wx-common, but with the same result.

Code: Select all

<snip>
adding     res/error.png...
adding     res/page_white_text_modified.png...
adding     res/page_white_text_ok.png...
adding     res/error.png...
adding     res/folder_modified.png...
adding     res/folder_ok.png...
adding     res/error.png...
creating C++ source file /home/cenix/Programming/codelite/trunk/LiteEditor/resources.cpp...
And at that moment, wxrc keeps eating CPU.
Maybe I'll try to embed imaged directly from file.