Page 1 of 1

StatusBar +BoxSizer

Posted: Thu Dec 15, 2005 8:18 pm
by TGT
Hi,
today I tried to place a gauge into the statusbar. So far no problems, but I wasn't able to position the gauge using the BoxSizer.



Code: Select all

public class MyFrame : Frame
{
  public MyFrame( string title, Point pos, Size size )
    : base(title, pos, size)
  {
    // (...)
    StatusBar statusBar = CreateStatusBar( 2 );

    progressBar = new Gauge( statusBar, -1, 100, wxDefaultPosition, wxDefaultSize,
      Gauge.wxGA_HORIZONTAL | Gauge.wxGA_PROGRESSBAR );

    BoxSizer statusSizer = new BoxSizer( Orientation.wxHORIZONTAL );
    statusSizer.Add( new StaticText( statusBar, "test" ), 0, Stretch.wxGROW );
    statusSizer.Add( progressBar, 1, Stretch.wxGROW );

    statusBar.Sizer = statusSizer;
    // (...)
  }
}
// (...)


Any hints?


Thanks, Tom

Re: StatusBar +BoxSizer

Posted: Fri Dec 16, 2005 7:43 am
by upCASE
Hi!
TGT wrote:Hi,
today I tried to place a gauge into the statusbar. So far no problems, but I wasn't able to position the gauge using the BoxSizer.

I'm not sure that this would be possible. A statusbar can have more than one field and I think adding a sizer to that would not be that best way.

However, I did that catching wxSizeEvents for the frame the statusbar is in, using wxStatusBar::GetFieldRect() and updating the position and size of the gauge that way. This works fine for me as the gauge is only shown when needed, otherwise hidden.

Posted: Fri Dec 16, 2005 4:36 pm
by TGT
Hi,
I already tried something like that, but I had problems with the EventHandling.

Code: Select all

// (...)
    EVT_SIZE( new EventListener( OnSize ) );
  }

  public void OnSize( object sender, Event e )
  {
    // do something
  }
// (...)


After adding my own EventListener (OnSize in this case) not even one widget is displayed correctly.
Am I forgetting something!?
Positioning the gauge works on this way.... but it seems that the EventHandler stops after my EventListener!?

Tom.

Posted: Sun Dec 18, 2005 7:53 pm
by TGT
...You have to skip the event! :?

Code: Select all

  public void OnSize( object sender, Event e )
  {
    // do something
    e.Skip( );
  }


Tom.