void SectionBar::ButtonClick( Button& sender, bool checked ) { if ( m_section != nullptr && sender == Title_ToolButton ) { if ( !m_handlers.IsNull() ) if ( m_handlers->onToggleSection != nullptr ) (m_handlers->onToggleSectionReceiver->*m_handlers->onToggleSection)( *this, *m_section, true ); bool visible = m_section->IsVisible(); Control* p = &m_section->Parent(); if ( !p->IsNull() ) { while ( !p->Parent().IsNull() ) p = &p->Parent(); p->DisableUpdates(); } if ( visible ) m_section->Hide(); else m_section->Show(); // On OS X, forcing event processing here causes a lot of flickering. // On X11 and Windows, it's just the opposite... #ifndef __PCL_MACOSX Module->ProcessEvents(); #endif if ( !p->IsNull() ) { bool fixedWidth = p->IsFixedWidth(); if ( !fixedWidth ) p->SetFixedWidth(); bool fixedHeight = p->IsFixedHeight(); if ( fixedHeight ) p->SetVariableHeight(); p->AdjustToContents(); Module->ProcessEvents(); if ( !fixedWidth ) p->SetVariableWidth(); if ( fixedHeight ) p->SetFixedHeight(); p->EnableUpdates(); } if ( !m_handlers.IsNull() ) if ( m_handlers->onToggleSection != nullptr ) (m_handlers->onToggleSectionReceiver->*m_handlers->onToggleSection)( *this, *m_section, false ); } else if ( !Title_CheckBox.IsNull() && sender == *Title_CheckBox ) { if ( m_section != nullptr ) m_section->Enable( checked ); if ( !m_handlers.IsNull() ) if ( m_handlers->onCheck != nullptr ) (m_handlers->onCheckReceiver->*m_handlers->onCheck)( *this, checked ); } }
void Container::Realize(Container* parent) { if ( IsRealized() ) { for ( V_Control::iterator itr = m_Controls.begin(), end = m_Controls.end(); itr != end; ++itr ) { (*itr)->Realize( this ); } return; } if ( m_Window == NULL ) { INSPECT_SCOPE_TIMER( ( "" ) ); m_Window = new wxPanel( parent->GetWindow(), wxID_ANY ); } if ( m_Window->GetSizer() == NULL ) { m_Window->SetSizer( new wxBoxSizer( wxHORIZONTAL ) ); wxSizer* sizer = m_Window->GetSizer(); V_Sizer sizerList; std::vector< i32 > proportionList; int proportionMultiplier = 1000; int remainingProportion = proportionMultiplier; int numRemainingProportions = 0; wxSizer* unboundedProportionSizer = NULL; V_Control::const_iterator itr = m_Controls.begin(); V_Control::const_iterator end = m_Controls.end(); for( ; itr != end; ++itr ) { Control* c = *itr; c->Realize( this ); if ( c->GetProportionalWidth() > 0.0f ) { int proportion = (int) ( c->GetProportionalWidth() * (f32) proportionMultiplier ); remainingProportion -= proportion; sizerList.push_back( new wxBoxSizer( wxHORIZONTAL ) ); proportionList.push_back( proportion ); unboundedProportionSizer = NULL; } else { if ( unboundedProportionSizer == NULL ) { unboundedProportionSizer = new wxBoxSizer( wxHORIZONTAL ); ++numRemainingProportions; } sizerList.push_back( unboundedProportionSizer ); proportionList.push_back( -1 ); } } if ( numRemainingProportions > 1 ) { remainingProportion = (int) ( (f32) remainingProportion / (f32) numRemainingProportions + 0.5f ); } int index = 0; int spacing = GetCanvas()->GetPad(); itr = m_Controls.begin(); end = m_Controls.end(); for( ; itr != end; ++index, ++itr ) { Control* c = *itr; int proportion = proportionList[ index ]; wxSizer* currentSizer = sizerList[ index ]; if ( sizer->GetItem( currentSizer ) == NULL ) { sizer->Add( currentSizer, proportion > 0 ? proportion : remainingProportion, wxEXPAND | wxTOP | wxBOTTOM, spacing ); } int flags = wxALIGN_CENTER_VERTICAL; proportion = 0; if ( !c->IsFixedWidth() ) { proportion = 1; flags |= wxEXPAND; } currentSizer->Add( spacing, 0, 0 ); currentSizer->Add( c->GetWindow(), proportion, flags ); } sizer->Add(spacing, 0, 0); m_Window->Layout(); } __super::Realize(parent); }