Guidance
指路人
g.yi.org
Guidance Forums / wxWidgets (wxWindows) in C++ / sizer-troubles

Register 
注册
Search 搜索
首页 
Home Home
Software
Upload

  
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
Message1. sizer-troubles
#3626
Posted by: KaReL 2004-03-28 03:30:33
I'm having troubles with sizers :S...

I want to have a frame, with a listbox & 2 staticbox(sizers). Now when I change the size of my frame, the listbox needs to be reshaped, but the 2 staticboxes should keep the same size...

Currently I tried this (I am still freakin' around with it though ;)):

  wxStaticText * t;

  wxPanel *m_panel = new wxPanel( this );
  wxBoxSizer *topsizer = new wxBoxSizer( wxVERTICAL );

  topsizer->Add(
    new wxListView(m_panel, wxID_ANY),
    1,
    wxEXPAND|wxALL,
    4 );

              wxStaticBox * pBottomPane = new wxStaticBox( m_panel, wxID_ANY, wxEmptyString );
  wxStaticBoxSizer * st = new wxStaticBoxSizer(pBottomPane, wxHORIZONTAL );

  wxBoxSizer * s = new wxBoxSizer( wxVERTICAL );

  s->Add(
    t = new wxStaticText( m_panel, wxID_ANY, _("Consignee") ),
    0,
    0,
    0 );

  s->SetItemMinSize( t, wxSize(121, -1) );
  st -> Add( s, 0, wxSTRETCH_NOT, 0 );
  
  s = new wxBoxSizer( wxVERTICAL );
    s->Add( t = new wxStaticText( m_panel, wxID_ANY, _(": testje") ), 0, 0, 0 );
    s->SetItemMinSize( t, wxSize(144, -1) );

  st->Add( s, 0, wxSTRETCH_NOT, 0 );
  st->SetSizeHints(pBottomPane);
  topsizer->Add( st, 0, wxEXPAND, 0 );

  m_panel->SetSizer( topsizer );      // use the sizer for layout
  topsizer->SetSizeHints( m_panel );   // set size hints to honour minimum size
------------------------
Website: www.KaReLs0ft.be
Message2. Re: sizer-troubles
#3634
Posted by: upCASE 2004-03-28 18:55:46
Hi!
I hope I got it right. Check it out...

    panel = new wxPanel(this, -1);

    listView = new wxListView(panel, -1, wxDefaultPosition, wxDefaultSize);
    label1 = new wxStaticText(panel, -1, wxT("Consignee"));
    label2 = new wxStaticText(panel, -1, wxT(": testje"));

    wxBoxSizer* topmostSizer = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL);
    wxStaticBoxSizer* staticBoxSizer = new wxStaticBoxSizer(new wxStaticBox(panel, -1, wxT("Whatever")), wxHORIZONTAL);
    topSizer->Add(listView, 1, wxEXPAND, 0);
    staticBoxSizer->Add(label1, 1, 0, 0);
    staticBoxSizer->Add(label2, 1, 0, 0);
    topSizer->Add(staticBoxSizer, 0, wxEXPAND|wxALIGN_CENTER_HORIZONTAL, 0);
    panel->SetAutoLayout(true);
    panel->SetSizer(topSizer);
    topSizer->Fit(panel);
    topSizer->SetSizeHints(panel);
    topmostSizer->Add(panel, 1, wxEXPAND, 0);
    SetAutoLayout(true);
    SetSizer(topmostSizer);
    topmostSizer->Fit(this);
    topmostSizer->SetSizeHints(this);
    Layout();

Hmm...
seems to be broken...
upCASE
-----------------------------------
If it was hard to write, it should be hard to read!- Do. Or do not. There is no try!
Message3. Re: sizer-troubles
#3636
Posted by: KaReL 2004-03-29 01:19:02
Great! That's exactly what I need :D...

But now I need to understand why your code works and mine does not :p
------------------------
Website: www.KaReLs0ft.be
Forum List • Thread List • Refresh • New Topic • Search • Previous • Next First 1 Last
掌柜推荐
 
 
 
 
 
 
 
 
 
 
 
 
© Fri 2024-3-29  Guidance Laboratory Inc.
Email:webmaster1g.yi.org Hits:0