Author Topic: wxBitmapButton size problems  (Read 2521 times)

Offline richrobin

  • Single posting newcomer
  • *
  • Posts: 7
wxBitmapButton size problems
« on: October 25, 2016, 02:09:33 am »
I have a project which is written using visual C++.  I have successfully ported a tabbed dialog box to use Code::Blocks wxSmith with wxWidgets on Windows 10. However the whole purpose of the exercise is to see if I can move the application to Ubuntu Linux. I have managed to install Code::Blocks 16.01 to Ubuntu 16.04 and transferred  the project and got it to compile and run. My problem is that the properties are different between the two versions of Code::Blocks. I am using a FrameWindow that has a wxNotebook  with pages of wxBitmapButtons controlled by a wxGridBagSizer. This arrangement worked on the Windows 10 system but the Identical wxSmith XML produces a very different effect on Linux.  I need the entire face of the button to be the bitmap that is loaded into the button and the button faces to be touching each other. The wxBitmapButton while doing exactly this on Windows 10,  is instead, on Linux, surrounding the bitmap with something like 15 pixels of white space and enlarging the button in the process so that the buttons do not fit into the window space provided and look spaced out and silly. To summarise, wxBitmapButton appears to be a full bitmap button on Windows but only half a bitmap button on Linux.  Is there a solution to this problem? I am using version 3.0 of wxWidgets.

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: wxBitmapButton size problems
« Reply #1 on: October 25, 2016, 04:30:25 pm »
This seems to be a problem with wxWidgets not Codeblocks.
Can you tweak the wxSmith settings on Linux that it is the same on Windows? If so then it is a wxSmith bug, and we need a minimal example to reproduce this bug.

I think the problem here is, that wxWidgets uses the native control of the underlying operating system. If the native control for wxBitmapButton is different on Windows then on Linux they will look different... This is the philosophy of wxWidgets

Offline richrobin

  • Single posting newcomer
  • *
  • Posts: 7
Re: wxBitmapButton size problems
« Reply #2 on: October 25, 2016, 05:03:38 pm »
Thank you BlueHazzard. As I am new to Code::Blocks I made the post to check I had not missed something. In the mean time I have tried subclassing wxBitmapButton and overriding DoGetBestSize and OnPaint. The buttons are now the correct size, but OnPaint never gets called, so only the central portion of the bitmap is  displayed. I can't think why this approach has been blocked off. Looks like I will have to do some more digging.