void VisualEditor::SetupWizard( PObjectBase obj, wxWindow *window, bool pageAdding ) { WizardPageSimple *wizpage = wxDynamicCast( window, WizardPageSimple ); if ( pageAdding ) { m_wizard->AddPage( wizpage ); m_wizard->Connect( wxID_ANY, wxFB_EVT_WIZARD_PAGE_CHANGED, WizardEventHandler( VisualEditor::OnWizardPageChanged ) ); } else { WizardEvent eventChanged( wxFB_EVT_WIZARD_PAGE_CHANGED, m_wizard->GetId(), false, wizpage ); eventChanged.SetInt( 1 ); wizpage->GetEventHandler()->ProcessEvent( eventChanged ); bool wizBmpOk = !obj->GetParent()->GetProperty( wxT("bitmap") )->IsNull(); bool pgeBmpOk = !obj->GetProperty( wxT("bitmap") )->IsNull(); wxBitmap wizBmp = obj->GetParent()->GetPropertyAsBitmap( wxT("bitmap") ); wxBitmap pgeBmp = obj->GetPropertyAsBitmap( wxT("bitmap") ); if ( pgeBmpOk && pgeBmp.IsOk() ) { m_wizard->SetBitmap( pgeBmp ); } else if ( wizBmpOk && wizBmp.IsOk() ) { m_wizard->SetBitmap( wizBmp ); } size_t selection = m_wizard->GetPageIndex( wizpage ); m_wizard->SetSelection( selection ); } }
wxMenu* DesignerWindow::GetMenuFromObject(PObjectBase menu) { int lastMenuId = wxID_HIGHEST + 1; wxMenu* menuWidget = new wxMenu(); for ( unsigned int j = 0; j < menu->GetChildCount(); j++ ) { PObjectBase menuItem = menu->GetChild( j ); if ( menuItem->GetObjectTypeName() == wxT("submenu") ) { menuWidget->Append( lastMenuId++, menuItem->GetPropertyAsString( wxT("label") ), GetMenuFromObject( menuItem ) ); } else if ( menuItem->GetClassName() == wxT("separator") ) { menuWidget->AppendSeparator(); } else { wxString label = menuItem->GetPropertyAsString( wxT("label") ); wxString shortcut = menuItem->GetPropertyAsString( wxT("shortcut") ); if ( !shortcut.IsEmpty() ) { label = label + wxChar('\t') + shortcut; } wxMenuItem *item = new wxMenuItem( menuWidget, lastMenuId++, label, menuItem->GetPropertyAsString( wxT("help") ), ( wxItemKind ) menuItem->GetPropertyAsInteger( wxT("kind") ) ); if ( !menuItem->GetProperty( wxT("bitmap") )->IsNull() ) { wxBitmap unchecked = wxNullBitmap; if ( !menuItem->GetProperty( wxT("unchecked_bitmap") )->IsNull() ) { unchecked = menuItem->GetPropertyAsBitmap( wxT("unchecked_bitmap") ); } #ifdef __WXMSW__ item->SetBitmaps( menuItem->GetPropertyAsBitmap( wxT("bitmap") ), unchecked ); #elif defined( __WXGTK__ ) item->SetBitmap( menuItem->GetPropertyAsBitmap( wxT("bitmap") ) ); #endif } else { if ( !menuItem->GetProperty( wxT("unchecked_bitmap") )->IsNull() ) { #ifdef __WXMSW__ item->SetBitmaps( wxNullBitmap, menuItem->GetPropertyAsBitmap( wxT("unchecked_bitmap") ) ); #endif } } menuWidget->Append( item ); if ( item->GetKind() == wxITEM_CHECK && menuItem->GetPropertyAsInteger( wxT("checked") ) ) { item->Check( true ); } item->Enable( ( menuItem->GetPropertyAsInteger( wxT("enabled") ) != 0 ) ); } } return menuWidget; }