StatusBar +BoxSizer

Questions about wxWidgets running on MS.NET, mono or Portable.NET ? Ask it here !
Post Reply
TGT
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Dec 15, 2005 8:09 pm

StatusBar +BoxSizer

Post 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
upCASE
Moderator
Moderator
Posts: 3176
Joined: Mon Aug 30, 2004 6:55 am
Location: Germany, Cologne

Re: StatusBar +BoxSizer

Post 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.
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4

"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
TGT
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Dec 15, 2005 8:09 pm

Post 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.
Last edited by TGT on Thu Dec 29, 2005 4:11 pm, edited 1 time in total.
TGT
Earned a small fee
Earned a small fee
Posts: 17
Joined: Thu Dec 15, 2005 8:09 pm

Post by TGT »

...You have to skip the event! :?

Code: Select all

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