wxRadioBox in a wxScrolledWindow Topic is solved

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
ddaeschl
Knows some wx things
Knows some wx things
Posts: 41
Joined: Wed Oct 27, 2004 6:06 pm
Location: Western NY
Contact:

wxRadioBox in a wxScrolledWindow

Post by ddaeschl »

For some reason when I place a wxRadioBox inside a wxScrolledWindow, the radio buttons don't draw until I resize the window. They don't even redraw if I scroll up and down.

Screen Shot:

Image


Example Code:

Code: Select all


#include <wx/wx.h>

class Test : public wxApp
{
public:
  virtual bool OnInit() {
    wxFrame* fr = new wxFrame(NULL, -1, "Scrolwin Test");
    
    //sizer to encompass the scrolled window
    wxBoxSizer* pnlsz = new wxBoxSizer(wxVERTICAL);
  
    //sizer for the inside of the scrolled window
    wxScrolledWindow* inner = new wxScrolledWindow(fr, -1, wxDefaultPosition,
      wxDefaultSize, wxVSCROLL | wxTAB_TRAVERSAL);
    
    inner->SetScrollRate(10, 10);
    
    wxBoxSizer* scrollsz = new wxBoxSizer(wxVERTICAL);
    
    wxBoxSizer* gndrsz = new wxBoxSizer(wxHORIZONTAL);
      wxStaticText* lblgndr = new wxStaticText(inner, -1, "Gender",
        wxDefaultPosition, wxSize(100, -1));
      
      wxString ch[2] = {"Male", "Female"};
      
      wxRadioBox* _rbGndr = new wxRadioBox(inner, 40000, ".", wxDefaultPosition,
        wxSize(250, 100), 2, ch, 2, wxRA_SPECIFY_COLS);
      gndrsz->Add(lblgndr, 0, wxALL, 2);
      gndrsz->Add(_rbGndr, 0, wxALL, 2);
      
    scrollsz->Add(gndrsz, 0, wxALL | wxEXPAND, 2);
    
    //add more to make scroll bar appear
    scrollsz->Add(10, 100);
    scrollsz->Add(10, 100);
      
    inner->SetSizer(scrollsz);
    pnlsz->Add(inner, 1, wxALL | wxEXPAND, 2);
    fr->SetSizer(pnlsz);
      
    
    fr->Show();
    return true;
  }
  
  virtual int OnExit() {
    return 0;
  }
};

IMPLEMENT_APP(Test)


Any workaround, patch, or information on the problem so I can create my own patch would be extremely helpful.

Info:
wxWidgets 2.6.2 (wxmsw)
Windows XP SP2
jbacigal
Knows some wx things
Knows some wx things
Posts: 33
Joined: Mon Sep 19, 2005 8:22 pm

Post by jbacigal »

perhaps if you call Layout() on your frame before you show it that will solve your problem?

[edit]
Actually I just tested, it is inner->Layout() that will fix it..not the frame
ddaeschl
Knows some wx things
Knows some wx things
Posts: 41
Joined: Wed Oct 27, 2004 6:06 pm
Location: Western NY
Contact:

Post by ddaeschl »

Well, that fixes it initially not displaying, but if you make sure the window is not big enough to hold the entire box, scroll down, and then maximize the window, the radiobuttons again are not displayed. You can even restore the window and notice that they still don't paint!

Something is definately wrong with the painting here.
Jamie
Filthy Rich wx Solver
Filthy Rich wx Solver
Posts: 205
Joined: Wed Mar 30, 2005 10:56 pm

Post by Jamie »

ddaeschl wrote:Something is definately wrong with the painting here.
I've already fixed this in CVS and it will be working correctly in 2.6.3.

See here for the necessary changes:
http://cvs.wxwidgets.org/viewcvs.cgi/wx ... =1.122.2.1
ddaeschl
Knows some wx things
Knows some wx things
Posts: 41
Joined: Wed Oct 27, 2004 6:06 pm
Location: Western NY
Contact:

Post by ddaeschl »

Thank you both, for now im just painting it when the user selects the item that chooses the radios. It's not perfect, but it works.
Post Reply