how to force sizer to refresh after children resize

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
curtisnewton
In need of some credit
In need of some credit
Posts: 8
Joined: Thu Aug 28, 2014 12:24 pm

how to force sizer to refresh after children resize

Post by curtisnewton »

Hello,

as i want do have a wxPanel component to be resized on image contentmodification, it works
but the parent sizers stays the same
so i request the parent to do a layout but the sizer dont change size upon new children size
(then the wxPanel is not refreshing anymore)

Code: Select all

void CameraPreview::OnPaint(wxPaintEvent& event)
{
  wxPaintDC dc(this);

  int x,y,w,h;
  dc.GetClippingBox( &x, &y, &w, &h );

  if(refreshImage)
  {
     dc.DrawBitmap( *toDraw,(wxCoord) x,(wxCoord) y ,false);  <------------ is still called but the result is black
     delete toDraw;
     refreshImage = false;
  }
}

void CameraPreview::SetData(IplImage img)
{
...

        toDraw = new wxBitmap( pWxImg );
        ResizeOnce(img.width, img.height);
    
    refreshImage=true;
    Refresh();
}

void CameraPreview::OnSize(wxSizeEvent& event)
{
  Refresh();
}

void CameraPreview::ResizeOnce(int width, int height)
{
    wxSize size = GetSize(); 
    if((size.GetWidth()==width)&&(size.GetHeight()==height))
        return;

    SetSize(width, height);    --------> does not work becos of following line i guess
    //GetParent()->Layout(); --------> when enabled, the bitmap above is still drawn, but the result is a black
}
curtisnewton
In need of some credit
In need of some credit
Posts: 8
Joined: Thu Aug 28, 2014 12:24 pm

Re: how to force sizer to refresh after children resize

Post by curtisnewton »

ok i figured it out

i added an extra sizer and i uses setmin/maxsize for the wxpanel
DavidHart
Site Admin
Site Admin
Posts: 4252
Joined: Thu Jan 12, 2006 6:23 pm
Location: IoW, UK

Re: how to force sizer to refresh after children resize

Post by DavidHart »

Hi,
ok i figured it out
I'm glad it works. However, I notice that you handle wxSizeEvents, and don't do event.Skip(). That will often cause sizing to fail...

Regards,

David
Post Reply