Help With XPM Images Not Showing on Linux Topic is solved

Do you have a typical platform dependent issue you're battling with ? Ask it here. Make sure you mention your platform, compiler, and wxWidgets version.
Post Reply
Xangis
Earned some good credits
Earned some good credits
Posts: 122
Joined: Fri Apr 14, 2006 9:49 pm
Location: Beaverton, OR
Contact:

Help With XPM Images Not Showing on Linux

Post by Xangis » Mon Mar 04, 2013 8:37 pm

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.

Xangis
Earned some good credits
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

Post by Xangis » Mon Mar 04, 2013 8:40 pm

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]

User avatar
nelson777
Earned some good credits
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

Post by nelson777 » Tue Mar 05, 2013 7:37 pm

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:

Code: Select all

    m_btnBlocoInicio   = new wxBitmapButton(m_pnlConexoes, BTN_BLOCO_INICIO,   wxBitmap(first_xpm), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("BTN_BLOCO_INICIO"));
Try this and see if it works. For me it works both in Linux and in Windows

-Nelson

Xangis
Earned some good credits
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

Post by Xangis » Fri Mar 08, 2013 7:56 am

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.
WinVista/7: VC++ .Net 2010 / Ubuntu 11.04: gcc4.4.3 [2.8.12 on all]

Post Reply