コード例 #1
0
//----------------------------------------------------------------------------------------------
int ObjectSerializer::DeserializeContainerSet(char* p_fieldAddress, TypeNode* p_type, fstream& p_eye)
{
    // Pointer to set is not supported
    _ASSERTE(p_type->Indirection == false);

    Container* container = reinterpret_cast<Container*>(p_fieldAddress);
    int count;

    p_eye.read(reinterpret_cast<char*>(&count), sizeof(int));
    container->Clear();
    char* tempStorage0 = container->GetTemp();

    for(int i = 0; i < count; ++i)
    {
        DeserializeType(tempStorage0, p_type->TemplateArguments[0], p_eye);
        container->AddTemp();
    }

    return container->TypeSize();
}
コード例 #2
0
ファイル: Container.cpp プロジェクト: pthiben/Helium
void Container::RemoveControl(Control* control)
{
  // This is annoying... it looks like there might be a bug in wx having
  // to do with wxButtons being the "TmpDefaultItem".  The destructor of
  // wxButton usually takes care of this, but because we remove the button
  // before destroying it, the top level window is left holding a dead
  // pointer.  Therefore, we have to clean up that pointer manually.
  // Update: Apparently the same problem occurs with wxTopLevelWindowMSW::m_winLastFocused.
  // Therefore, we will also store and clear it ourselves.
  wxTopLevelWindow* topWindow = wxDynamicCast( wxGetTopLevelParent( m_Window ), wxTopLevelWindow );
  wxWindow* defaultItem = NULL;
  wxWindow* lastFocus = NULL;
  if ( topWindow )
  {
    defaultItem = topWindow->GetTmpDefaultItem();
    lastFocus = topWindow->GetLastFocus();
  }

  // our child's internal window
  wxWindow* window = NULL;

  // hold a reference on the stack
  ControlPtr referenceHolder = control;

  // if the child is realized
  if (control->GetWindow())
  {
    // If the child is a container, clear it before we break the window hierarchy
    if ( control->HasType( Reflect::GetType<Container>() ) )
    {
      Container* container = static_cast< Container* >( control );
      container->Clear();
    }

    // save the child window pointer
    window = control->GetWindow();

    // The item we are about to remove is stored on the frame, so 
    // clear it (see comments at top of this function).
    if ( defaultItem && defaultItem == window )
    {
      topWindow->SetTmpDefaultItem( NULL );
    }

    // The item we are about to remove is stored on the frame (as
    // the item last having focus), so clear it (see comments at 
    // top of this function).
    if ( lastFocus && lastFocus == window )
    {
      topWindow->SetLastFocus( NULL );
    }

    // unhook the child from the nested control
    if ( window->GetParent() == m_Window )
    {
      m_Window->RemoveChild(window);
    }
  }

  // remove our reference to the control
  const i32 numControls = static_cast< i32 >( m_Controls.size() ) - 1;
  for ( i32 controlIndex = numControls; controlIndex > -1; --controlIndex )
  {
    if ( control == m_Controls.at( controlIndex ) )
    {
      // remove control from our list
      m_Controls.erase( m_Controls.begin() + controlIndex );
      break;
    }
  }

  // unrealize the control
  control->UnRealize();
}