I have an app that uses XPM images for icon buttons. They display fine on Windows with 2.8.12, but fail to display on either of my linux boxes, a 32-bit Mint machine with 2.8.12 (from apt), and a 64-bit Ubuntu machine with 2.8.12 (from apt). I'm calling wxInitAllImageHandlers() in the app's constructor and I've tried doing both #include "file.xpm" and loading from a file, but they just appear blank. The buttons show up and work fine, and I get no error messages, but the images don't display on the buttons.
Is there something else I should try? It's been a while since I've used wx on Linux, last time was version 2.6.4 and that's what this code was originally written to use.
Help With XPM Images Not Showing on Linux Topic is solved
-
- Earned some good credits
- Posts: 122
- Joined: Fri Apr 14, 2006 9:49 pm
- Location: Beaverton, OR
- Contact:
Re: Help With XPM Images Not Showing on Linux
Code snippet:
Code: Select all
#include "forward.xpm"
wxBitmap* bmpForward = new wxBitmap( forward_xpm, wxBITMAP_TYPE_XPM );
if( bmpForward->Ok())
{
bmpForward->SetMask(new wxMask(*bmpForward, *wxWHITE));
}
_btnForward = new wxBitmapButton( dlg, ID_BUTTON_FORWARD, *bmpForward, wxDefaultPosition, wxDefaultSize, wxBORDER_NONE );
_btnForward->SetToolTip(_("Next"));
_sizer->Add(_btnForward, 0, wxALIGN_CENTER_VERTICAL|wxALL, 3);
WinVista/7: VC++ .Net 2010 / Ubuntu 11.04: gcc4.4.3 [2.8.12 on all]
- nelson777
- Earned some good credits
- Posts: 117
- Joined: Mon Sep 19, 2005 3:50 pm
- Location: Fortaleza - Brasil
Re: Help With XPM Images Not Showing on Linux
Well, my multi-platform application uses XPM extensively, but I don't do as you are doing to incorporate the xpm in the buttons. I do it like this:
Try this and see if it works. For me it works both in Linux and in Windows
-Nelson
Code: Select all
m_btnBlocoInicio = new wxBitmapButton(m_pnlConexoes, BTN_BLOCO_INICIO, wxBitmap(first_xpm), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("BTN_BLOCO_INICIO"));
-Nelson
-
- Earned some good credits
- Posts: 122
- Joined: Fri Apr 14, 2006 9:49 pm
- Location: Beaverton, OR
- Contact:
Re: Help With XPM Images Not Showing on Linux
Thank you. For whatever reason, creating the bitmap beforehand the way I did didn't work. I changed it to this:
_btnForward = new wxBitmapButton( dlg, ID_BUTTON_FORWARD, wxBitmap(forward_xpm), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE );
And now the button shows up fine.
_btnForward = new wxBitmapButton( dlg, ID_BUTTON_FORWARD, wxBitmap(forward_xpm), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE );
And now the button shows up fine.
WinVista/7: VC++ .Net 2010 / Ubuntu 11.04: gcc4.4.3 [2.8.12 on all]