当前位置: 首页>>代码示例>>C++>>正文


C++ Control::Realize方法代码示例

本文整理汇总了C++中Control::Realize方法的典型用法代码示例。如果您正苦于以下问题:C++ Control::Realize方法的具体用法?C++ Control::Realize怎么用?C++ Control::Realize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Control的用法示例。


在下文中一共展示了Control::Realize方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Realize

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);
}
开发者ID:pthiben,项目名称:Helium,代码行数:100,代码来源:Container.cpp


注:本文中的Control::Realize方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。