wxToolBar, XRC: PNG Problems

This forum can be used to talk about general design strategies, new ideas and questions in general related to wxWidgets. If you feel your questions doesn't fit anywhere, put it here.
Post Reply
vdell
Moderator
Moderator
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

wxToolBar, XRC: PNG Problems

Post by vdell » Wed Mar 23, 2005 7:49 am

Hi,

I'm trying to use some stock PNG icons (from here) in my toolbar and menus. They work correctly when using them for the menu, but the toolbar shows them corrupted. Here is a small screenshot:

Image

And here is the XRC snippet that I'm using to load the toolbar:

Code: Select all

<object class="wxToolBar" name="ID_ToolBar">
    <style>wxTB_FLAT|wxTB_HORIZONTAL</style>
    <object class="tool" name="ID_Tool_Test">
        <bitmapsize>16,16</bitmapsize>
        <bitmap>../images/stock_help-agent-16.png</bitmap>
    </object>
</object>  
Finally, I tested the image with DialogBlocks and created a test frame with the toolbar. Now, the image displayed wrongly when using the "Test XRC Window" but plain "Test Window" shows it correctly.

So, any ideas what could be causing this?
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere

eco
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 203
Joined: Tue Aug 31, 2004 7:06 pm
Location: Behind a can of Mountain Dew
Contact:

Post by eco » Wed Mar 23, 2005 8:03 am

Try out this tip from the Remarks section of the wxToolBar documentation.
Remarks

You may also create a toolbar that is managed by the frame, by calling wxFrame::CreateToolBar.

Due to the use of native toolbars on the various platforms, certain adaptions will often have to be made in order to get optimal look on all platforms as some platforms ignore the values for explicit placement and use their own layout and the meaning of a "separator" is a vertical line under Windows95 vs. simple space under GTK etc.

wxToolBar95: Note that this toolbar paints tools to reflect system-wide colours. If you use more than 16 colours in your tool bitmaps, you may wish to suppress this behaviour, otherwise system colours in your bitmaps will inadvertently be mapped to system colours. To do this, set the msw.remap system option before creating the toolbar:

Code: Select all

  wxSystemOptions::SetOption(wxT("msw.remap"), 0);
If you wish to use 32-bit images (which include an alpha channel for transparency) use:

Code: Select all

  wxSystemOptions::SetOption(wxT("msw.remap"), 2);
then colour remapping is switched off, and a transparent background used. But only use this option under Windows XP with true colour:

Code: Select all

  (wxTheApp->GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32)
I use PNGs with an alpha channel for my toolbar and I remember I had to use this option to get them to look clean.

vdell
Moderator
Moderator
Posts: 536
Joined: Fri Jan 07, 2005 3:44 pm
Location: Finland
Contact:

Post by vdell » Wed Mar 23, 2005 8:32 am

That helped, thanks! :D (Too bad I was again lazy and skipped those remarks whilst browsing the documentation :oops: ).
Visual C++ 9.0 / Windows XP Pro SP3 / wxWidgets 2.9.0 (SVN) | Colligere

Post Reply