| 557 | } |
| 558 | |
| 559 | void ObjectEditor::SetObject( VObject *obj ) |
| 560 | { |
| 561 | m_curObject = 0; |
| 562 | |
| 563 | m_duplicate->Hide(); |
| 564 | m_delete->Hide(); |
| 565 | |
| 566 | // clear the property grid |
| 567 | m_curProps.clear(); |
| 568 | m_propGrid->Clear(); |
| 569 | m_objList->SetSelection( m_objList->GetSelection(), false ); |
| 570 | |
| 571 | if ( obj == 0 ) |
| 572 | { |
| 573 | Layout(); |
| 574 | return; |
| 575 | } |
| 576 | |
| 577 | m_curObject = obj; |
| 578 | |
| 579 | if ( m_view != 0 ) |
| 580 | { |
| 581 | int index = m_view->GetObjectIndex( obj ); |
| 582 | if ( m_objList->GetSelection() != index ) |
| 583 | m_objList->SetSelection( index ); |
| 584 | } |
| 585 | |
| 586 | wxArrayString list = obj->Properties(); |
| 587 | for ( size_t i=0; i<list.Count();i++ ) |
| 588 | { |
| 589 | VProperty &p = obj->Property( list[i] ); |
| 590 | |
| 591 | wxPGProperty *pg = 0; |
| 592 | switch( p.GetType() ) |
| 593 | { |
| 594 | case VProperty::DOUBLE: |
| 595 | pg = new wxFloatProperty( list[i], wxPG_LABEL ); |
| 596 | break; |
| 597 | case VProperty::INTEGER: |
| 598 | if ( p.GetChoices().size() == 0 ) |
| 599 | pg = new wxIntProperty( list[i], wxPG_LABEL ); |
| 600 | else |
| 601 | pg = new wxEnumProperty( list[i], wxPG_LABEL, p.GetChoices() ); |
| 602 | break; |
| 603 | case VProperty::STRING: |
| 604 | pg = new wxStringProperty( list[i], wxPG_LABEL); |
| 605 | break; |
| 606 | case VProperty::BOOLEAN: |
| 607 | pg = new wxBoolProperty( list[i], wxPG_LABEL ); |
| 608 | break; |
| 609 | case VProperty::COLOUR: |
| 610 | pg = new wxColourProperty( list[i], wxPG_LABEL ); |
| 611 | pg->SetAttribute( "HasAlpha", true ); |
| 612 | break; |
| 613 | } |
| 614 | |
| 615 | if ( pg != 0 ) |
| 616 | { |
no test coverage detected