More Problems with wxToolbar

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Tankko
Earned a small fee
Earned a small fee
Posts: 11
Joined: Wed Aug 09, 2006 8:07 pm

More Problems with wxToolbar

Post by Tankko » Wed Aug 23, 2006 12:39 am

I am having nothing but problems with wxToolBar. I have a set of 24x24 .ico files that are being loaded from a resources in a windows app.

Code: Select all

wxToolBar *toolbar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,wxTB_FLAT|wxTB_HORIZONTAL);
toolbar->SetToolBitmapSize(wxSize(24,24)); 

wxBitmap bitmap;

icon.LoadFile("ToolSave", wxBITMAP_TYPE_ICO_RESOURCE);
bitmap.CopyFromIcon(icon);
toolbar->AddTool(LIST_SAVE, bitmap, "Save Assets");
The toolbar sizes correctly, but, the icons are scaled up to 32x32 and then displayed cut-off, and you can see there is some strange image overlap going on between the icons.

Image

What is happening here? Is this a bug in wxToolBar? wxBitmap or wxIcon?

[/img]

Tankko
Earned a small fee
Earned a small fee
Posts: 11
Joined: Wed Aug 09, 2006 8:07 pm

Post by Tankko » Wed Aug 23, 2006 11:33 pm

Does anyone have any idea what is going on with the icons being stretched?

Tankko

scorche
Experienced Solver
Experienced Solver
Posts: 59
Joined: Fri Jan 20, 2006 9:54 pm

Post by scorche » Thu Aug 24, 2006 5:11 pm

can you run a getWidth and getHeights on the bitmap?
I'm curious to see if that's what resizes it or if it's the toolbar

cpp
I live to help wx-kind
I live to help wx-kind
Posts: 195
Joined: Wed Sep 28, 2005 9:42 pm

Post by cpp » Thu Aug 24, 2006 10:25 pm

Hi! wxIcon derives from wxBitmap (so wxToolBar will accept it), theres no need to copy it to a bitmap. so,
instead of copying the icon to a wxBitmap, try passing it directly to the toolbar:

Code: Select all

wxToolBar *toolbar = new wxToolBar(this, wxID_ANY, wxDefaultPosition, wxDefaultSize,wxTB_FLAT|wxTB_HORIZONTAL);
toolbar->SetToolBitmapSize(wxSize(24,24));

// wxBitmap bitmap; 

icon.LoadFile("ToolSave", wxBITMAP_TYPE_ICO_RESOURCE);
// bitmap.CopyFromIcon(icon);
toolbar->AddTool(LIST_SAVE, /*bitmap*/ icon, "Save Assets");
HTH
Hier Kommt die Sonne...

Paulsen
Experienced Solver
Experienced Solver
Posts: 53
Joined: Wed May 24, 2006 1:56 pm
Location: Germany

Post by Paulsen » Sun Aug 27, 2006 10:27 pm

I've seen similar bugs with the MSW version. Trial & Error led me to believe that bitmap resources usually work, while icons are sometime blown up to 32x32 size.

Setting the size explicitly seemed to work sometimes, like this:

Code: Select all

wxIcon icon("ToolSave", wxBITMAP_TYPE_ICO_RESOURCE, 24, 24);
Or convert the icon to a bitmap, using your favorite image editor, and use a bitmap resource.

Post Reply