void ClangPlugin::OnClangSyncTaskFinished( wxEvent& event ) { #ifdef CLANGPLUGIN_TRACE_FUNCTIONS //fprintf(stdout,"%s\n", __PRETTY_FUNCTION__); #endif ClangProxy::SyncJob* pJob = static_cast<ClangProxy::SyncJob*>(event.GetEventObject()); if (event.GetId() == idClangCodeCompleteTask) { ClangProxy::CodeCompleteAtJob* pCCJob = dynamic_cast<ClangProxy::CodeCompleteAtJob*>(pJob); ClangEvent evt( clEVT_GETCODECOMPLETE_FINISHED, pCCJob->GetTranslationUnitId(), pCCJob->GetFilename(), pCCJob->GetLocation(), pCCJob->GetResults()); ProcessEvent(evt); if ( HasEventSink(clEVT_DIAGNOSTICS_UPDATED) ) { ClangEvent evt( clEVT_DIAGNOSTICS_UPDATED, pCCJob->GetTranslationUnitId(), pCCJob->GetFilename(), pCCJob->GetLocation(), pCCJob->GetDiagnostics()); ProcessEvent(evt); } } else if (event.GetId() == idClangGetOccurrencesTask) { ClangProxy::GetOccurrencesOfJob* pOCJob = dynamic_cast<ClangProxy::GetOccurrencesOfJob*>(pJob); ClangEvent evt( clEVT_GETOCCURRENCES_FINISHED, pOCJob->GetTranslationUnitId(), pOCJob->GetFilename(), pOCJob->GetLocation(), pOCJob->GetResults()); ProcessEvent(evt); } else if (event.GetId() == idClangGetCCDocumentationTask) { ClangProxy::DocumentCCTokenJob* pCCDocJob = dynamic_cast<ClangProxy::DocumentCCTokenJob*>(pJob); ClangEvent evt( clEVT_GETOCCURRENCES_FINISHED, pCCDocJob->GetTranslationUnitId(), pCCDocJob->GetFilename(), pCCDocJob->GetLocation(), pCCDocJob->GetResult()); ProcessEvent(evt); } pJob->Finalize(); }
bool AudioView::ProcessEvent(wxEvent& event) { if (event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED && event.GetId() >= FirstEffectID && event.GetId() < FirstEffectID + numEffects) { Effect *f = Effect::GetEffect(event.GetId() - FirstEffectID); TrackList *tracks = GetTracks(); VTrack *t = tracks->First(); while(t) { if (t->selected && t->GetKind() == (VTrack::Wave)) { f->DoInPlaceEffect((WaveTrack *)t, sel0, sel1); } t = tracks->Next(); } PushState(); FixScrollbars(); REDRAW(trackPanel); REDRAW(rulerPanel); // This indicates we handled the event. return true; } return wxView::ProcessEvent(event); }
void CONTEXT_MENU::CMEventHandler::onEvent( wxEvent& aEvent ) { TOOL_EVENT evt; wxEventType type = aEvent.GetEventType(); // When the currently chosen item in the menu is changed, an update event is issued. // For example, the selection tool can use this to dynamically highlight the current item // from selection clarification popup. if( type == wxEVT_MENU_HIGHLIGHT ) evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_UPDATE, aEvent.GetId() ); // One of menu entries was selected.. else if( type == wxEVT_COMMAND_MENU_SELECTED ) { // Store the selected position m_menu->m_selected = aEvent.GetId(); // Check if there is a TOOL_ACTION for the given ID if( m_menu->m_toolActions.count( aEvent.GetId() ) == 1 ) { evt = m_menu->m_toolActions[aEvent.GetId()]->MakeEvent(); } else { // Handling non-action menu entries (e.g. items in clarification list) evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, aEvent.GetId() ); } } // forward the action/update event to the TOOL_MANAGER if( m_menu->m_tool ) m_menu->m_tool->GetManager()->ProcessEvent( evt ); }
virtual bool OnEvent(wxPropertyGrid* propGrid, wxPGProperty* prop, wxWindow* ctrl, wxEvent& evt) const override { if (evt.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) { wxPGMultiButton* buttons = (wxPGMultiButton*)propGrid->GetEditorControlSecondary(); if (evt.GetId() == buttons->GetButtonId(0)) { auto bprop = dynamic_cast<BtnProperty*>(prop); if (bprop && bprop->mFunc) { OnBtnFunc& f = bprop->mFunc; return f(prop); } return false; //auto it = mBtnPropMap.find(prop); //if (mBtnPropMap.end() != it) // return (it->second) ? it->second(prop) : false; }//if (evt.GetId() == buttons->GetButtonId(0)) }//if (evt.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED) return false; // всё что не выбрано кнопкой "..." не принимаем return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event); }
int AbstractApp::FilterEvent(wxEvent& event) { if (event.GetEventType() == wxEVT_SET_FOCUS) { wxObject* object = event.GetEventObject(); wxWindow* window = wxDynamicCast(object, wxWindow); if (window != NULL) { wxFrame* frame = wxDynamicCast(window, wxFrame); wxWindow* parent = window->GetParent(); while (frame == NULL && parent != NULL) { frame = wxDynamicCast(parent, wxFrame); parent = parent->GetParent(); } // If we found a frame, and window is not a menu, then send a command event to the frame // that will cause it to rebuild its menu. The frame must keep track of whether the menu actually needs // to be rebuilt (only if MapGLCanvas previously had focus and just lost it or vice versa). // make sure the command is sent via QueueEvent to give wxWidgets a chance to update the focus states! if (frame != NULL) { //bool isMenu = wxDynamicCast(window, wxMenu) || wxDynamicCast(window, wxMenuItem); //if (!isMenu) { wxCommandEvent focusEvent(TrenchBroom::View::EditorFrame::EVT_SET_FOCUS); focusEvent.SetClientData(event.GetEventObject()); focusEvent.SetEventObject(frame); focusEvent.SetId(event.GetId()); AddPendingEvent(focusEvent); //} } } } else if (event.GetEventType() == TrenchBroom::View::EditorFrame::EVT_SET_FOCUS) { wxFrame* frame = wxStaticCast(event.GetEventObject(), wxFrame); frame->ProcessWindowEventLocally(event); return 1; } return wxApp::FilterEvent(event); }
bool AudacityProject::ProcessEvent(wxEvent & event) { int numEffects = Effect::GetNumEffects(false); int numPlugins = Effect::GetNumEffects(true); Effect *f = NULL; if (event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED && event.GetId() >= FirstEffectID && event.GetId() < FirstEffectID + numEffects) f = Effect::GetEffect(event.GetId() - FirstEffectID, false); if (event.GetEventType() == wxEVT_COMMAND_MENU_SELECTED && event.GetId() >= FirstPluginID && event.GetId() < FirstPluginID + numPlugins) f = Effect::GetEffect(event.GetId() - FirstPluginID, true); if (f) { TrackListIterator iter(mTracks); VTrack *t = iter.First(); int count = 0; while (t) { if (t->GetSelected() && t->GetKind() == (VTrack::Wave)) count++; t = iter.Next(); } if (count == 0 || mViewInfo.sel0 == mViewInfo.sel1) { wxMessageBox(_("No audio data is selected.")); return true; } if (f->DoEffect(this, mTracks, mViewInfo.sel0, mViewInfo.sel1)) { PushState(_("Applied an effect.")); // maybe more specific? FixScrollbars(); mTrackPanel->Refresh(false); } else { // TODO: undo the effect if necessary? } // This indicates we handled the event. return true; } return wxFrame::ProcessEvent(event); }
void MaterialManager::OnPopupClick(wxEvent &evt) { int id = evt.GetId(); if( id == 1000 ) { g_pMaterialManager->CreateMaterial( "new" ); // the new material will only exist in the material manager. // TODO: this material will cause an assert on shutdown, unless released by some other code. } }
bool AudacityProject::HandleMenuEvent(wxEvent & event) { int idz = (event.GetId() - MenuBaseID); if ((idz >= 0) && (idz < GetNumCommands())) { (this->*((audEventFunction) (this->GetCommandFunc(idz)))) (event); } return true; //handled message }
bool wxDialogEx::ProcessEvent(wxEvent& event) { if(event.GetEventType() != wxEVT_MENU) { return wxDialog::ProcessEvent(event); } wxTextEntry* e = GetSpecialTextEntry(FindFocus(), 'V'); if( e && event.GetId() == pasteId ) { e->Paste(); return true; } else if( e && event.GetId() == selectAllId ) { e->SelectAll(); return true; } else { return wxDialog::ProcessEvent(event); } }
void ComponentAnimationPlayer2D::OnRightClickOptionClicked(wxEvent &evt, int baseid) { int id = evt.GetId(); if( id == baseid + 1 ) { My2DAnimInfo* p2DAnimInfo = Get2DAnimInfoObject(); p2DAnimInfo->FillPropertiesWindow( true ); } }
// This is always the first to handle an event ! int MyApp::FilterEvent(wxEvent& event) { if ( event.GetEventType() == wxEVT_BUTTON && event.GetId() == MyEvtTestButton::BUTTON_ID ) { wxLogMessage("Step 0 in \"How Events are Processed\":\n" "App::FilterEvent"); } return wxApp::FilterEvent(event); }
bool AudacityProject::HandleMenuEvent(wxEvent & event) { for(int i = 0; i < mCommandIDs.GetCount(); i++) { if((mCommandIDs[i] == (int *)event.GetId()) && (GetCommandState(i))) { (this->*((wxEventFunction) (this->GetCommandFunc(i))))(event); } } return true; //handled message }
bool ProcessEvent(wxEvent& evt) { if (evt.GetEventType() == wxEVT_COMMAND_MENU_SELECTED) { m_last_id = evt.GetId(); return true; } if (GetNextHandler()) return GetNextHandler()->ProcessEvent(evt); return false; }
bool ProcessEvent(wxEvent& evt) { if (evt.GetEventType() == wxEVT_MENU) { m_lastId = evt.GetId(); return true; } if (GetNextHandler()) return GetNextHandler()->ProcessEvent(evt); return false; }
// Prevent recursive entry of CMainDocument::RequestRPC() int CBOINCGUIApp::FilterEvent(wxEvent &event) { int theEventType; wxDialog* theRPCWaitDialog; wxObject* theObject; if (!m_pDocument) return -1; theEventType = event.GetEventType(); if (m_pDocument->WaitingForRPC()) { // If in RPC Please Wait dialog, reject all command // and timer events except: // - RPC Finished // - those for that dialog or its children // - Open Manager menu item from system tray icon if ((theEventType == wxEVT_COMMAND_MENU_SELECTED) && (event.GetId() == wxID_OPEN)) { return -1; } theRPCWaitDialog = m_pDocument->GetRPCWaitDialog(); theObject = event.GetEventObject(); while (theObject) { if (!theObject->IsKindOf(CLASSINFO(wxWindow))) break; if (theObject == theRPCWaitDialog) return -1; theObject = ((wxWindow*)theObject)->GetParent(); } // Continue with rest of filtering below } else { // Do limited filtering if shutting down to allow RPC // completion events but not events which start new RPCs if (!m_bFilterEvents) return -1; } // Allow all except Command, Timer and Mouse Moved events if (event.IsCommandEvent()) { return false; } if (theEventType == wxEVT_TIMER) { return false; } #ifdef __WXMSW__ if (theEventType == wxEVT_TASKBAR_MOVE) { return false; } #endif return -1; }
// Forward command events to the current rich text control, if any bool IceNoteFrame::ProcessEvent(wxEvent& event) { if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxChildFocusEvent))) { // Problem: we can get infinite recursion because the events // climb back up to this frame, and repeat. // Assume that command events don't cause another command event // to be called, so we can rely on inCommand not being overwritten static int s_eventType = 0; static wxWindowID s_id = 0; if (s_id != event.GetId() && s_eventType != event.GetEventType()) { s_eventType = event.GetEventType(); s_id = event.GetId(); wxWindow* focusWin = wxFindFocusDescendant(this); if (focusWin && focusWin->GetEventHandler()->ProcessEvent(event)) { //s_command = NULL; s_eventType = 0; s_id = 0; return true; } s_eventType = 0; s_id = 0; } else { return false; } } return wxFrame::ProcessEvent(event); }
// Extend event processing to search the view's event table bool MutApp::ProcessEvent(wxEvent& event) { bool retval = wxApp::ProcessEvent(event); #ifdef DEBUG if (!retval) { DEBUGLOG(eventqueue, _T("Unhandled event %p, id=%d, type=%d"), static_cast<void *>(&event), (int)(event.GetId()), (int)(event.GetEventType()) ); } #endif return retval; }
int ProgressDialog::ShowModalDetector::FilterEvent(wxEvent &event) { const auto type = event.GetEventType(); if (wxEVT_SHOW == type || wxEVT_TIMER == type && ID_SHOW_TIMER == event.GetId()) { if (!m_progressDialog.m_isClosed) { m_isShow = true; } } else if (wxEVT_ASYNC_METHOD_CALL == type) { return Event_Skip; } return Event_Ignore; }
void CViewProjects::OnProjectWebsiteClicked( wxEvent& event ) { wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectWebsiteClicked - Function Begin")); CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame); wxASSERT(pFrame); wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame)); int website_task_index = event.GetId() - ID_TASK_PROJECT_WEB_PROJDEF_MIN; wxLaunchDefaultBrowser( m_TaskGroups[1]->m_Tasks[website_task_index]->m_strWebSiteLink ); UpdateSelection(); pFrame->FireRefreshView(); wxLogTrace(wxT("Function Start/End"), wxT("CViewProjects::OnProjectWebsiteClicked - Function End")); }
//----------------------------------------------------------------------------- bool wxStringButtonEditor::OnEvent( wxPropertyGrid* propGrid, wxPGProperty* property, wxWindow* ctrl, wxEvent& event ) const { if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) { wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary(); if ( event.GetId() == buttons->GetButtonId(0) ) { if (mButtonDownCallback) mButtonDownCallback (mProperty); return false; } } return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event); }
void CViewWork::OnProjectWebsiteClicked( wxEvent& event ) { wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnProjectWebsiteClicked - Function Begin")); CAdvancedFrame* pFrame = wxDynamicCast(GetParent()->GetParent()->GetParent(), CAdvancedFrame); wxASSERT(pFrame); wxASSERT(wxDynamicCast(pFrame, CAdvancedFrame)); wxASSERT(m_pTaskPane); wxASSERT(m_pListPane); pFrame->UpdateStatusText(_("Launching browser...")); int website_task_index = event.GetId() - ID_TASK_PROJECT_WEB_PROJDEF_MIN; pFrame->ExecuteBrowserLink( m_TaskGroups[1]->m_Tasks[website_task_index]->m_strWebSiteLink ); pFrame->UpdateStatusText(wxT("")); UpdateSelection(); pFrame->FireRefreshView(); wxLogTrace(wxT("Function Start/End"), wxT("CViewWork::OnProjectWebsiteClicked - Function End")); }
int PwsafeApp::FilterEvent(wxEvent& evt) { const wxEventType et = evt.GetEventType(); // Clear idle flag for lock-on-idle timer // We need a whitelist rather than a blacklist because // undocumented events are passed through here as well... if ((et == wxEVT_COMMAND_BUTTON_CLICKED) || (et == wxEVT_COMMAND_CHECKBOX_CLICKED) || (et == wxEVT_COMMAND_CHOICE_SELECTED) || (et == wxEVT_COMMAND_LISTBOX_SELECTED) || (et == wxEVT_COMMAND_LISTBOX_DOUBLECLICKED) || (et == wxEVT_COMMAND_TEXT_UPDATED) || (et == wxEVT_COMMAND_TEXT_ENTER) || (et == wxEVT_COMMAND_MENU_SELECTED) || (et == wxEVT_COMMAND_SLIDER_UPDATED) || (et == wxEVT_COMMAND_RADIOBOX_SELECTED) || (et == wxEVT_COMMAND_RADIOBUTTON_SELECTED) || (et == wxEVT_COMMAND_SCROLLBAR_UPDATED) || (et == wxEVT_COMMAND_VLBOX_SELECTED) || (et == wxEVT_COMMAND_COMBOBOX_SELECTED) || (et == wxEVT_COMMAND_TOOL_RCLICKED) || (et == wxEVT_COMMAND_TOOL_ENTER) || (et == wxEVT_COMMAND_SPINCTRL_UPDATED) || (et == wxEVT_LEFT_DOWN) || (et == wxEVT_LEFT_UP) || (et == wxEVT_MIDDLE_DOWN) || (et == wxEVT_MIDDLE_UP) || (et == wxEVT_RIGHT_DOWN) || (et == wxEVT_RIGHT_UP) || (et == wxEVT_MOTION) || (et == wxEVT_ENTER_WINDOW) || (et == wxEVT_LEAVE_WINDOW) || (et == wxEVT_LEFT_DCLICK) || (et == wxEVT_MIDDLE_DCLICK) || (et == wxEVT_RIGHT_DCLICK) || (et == wxEVT_SET_FOCUS) || (et == wxEVT_MOUSEWHEEL) || (et == wxEVT_NAVIGATION_KEY) || (et == wxEVT_KEY_DOWN) || (et == wxEVT_KEY_UP) || (et == wxEVT_SCROLL_TOP) || (et == wxEVT_SCROLL_BOTTOM) || (et == wxEVT_SCROLL_LINEUP) || (et == wxEVT_SCROLL_LINEDOWN) || (et == wxEVT_SCROLL_PAGEUP) || (et == wxEVT_SCROLL_PAGEDOWN) || (et == wxEVT_SCROLL_THUMBTRACK) || (et == wxEVT_SCROLL_THUMBRELEASE) || (et == wxEVT_SCROLL_CHANGED) || (et == wxEVT_SIZE) || (et == wxEVT_MOVE) || (et == wxEVT_ACTIVATE_APP) || (et == wxEVT_ACTIVATE) || (et == wxEVT_SHOW) || (et == wxEVT_ICONIZE) || (et == wxEVT_MAXIMIZE) || (et == wxEVT_MENU_OPEN) || (et == wxEVT_MENU_CLOSE) || (et == wxEVT_MENU_HIGHLIGHT) || (et == wxEVT_CONTEXT_MENU) || (et == wxEVT_JOY_BUTTON_DOWN) || (et == wxEVT_JOY_BUTTON_UP) || (et == wxEVT_JOY_MOVE) || (et == wxEVT_JOY_ZMOVE) || (et == wxEVT_DROP_FILES) || (et == wxEVT_COMMAND_TEXT_COPY) || (et == wxEVT_COMMAND_TEXT_CUT) || (et == wxEVT_COMMAND_TEXT_PASTE) || (et == wxEVT_COMMAND_LEFT_CLICK) || (et == wxEVT_COMMAND_LEFT_DCLICK) || (et == wxEVT_COMMAND_RIGHT_CLICK) || (et == wxEVT_COMMAND_RIGHT_DCLICK) || (et == wxEVT_COMMAND_ENTER) || (et == wxEVT_HELP) || (et == wxEVT_DETAILED_HELP)) { RestartIdleTimer(); } if (evt.IsCommandEvent() && evt.GetId() == wxID_HELP && (et == wxEVT_COMMAND_BUTTON_CLICKED || et == wxEVT_COMMAND_MENU_SELECTED)) { OnHelp(*wxDynamicCast(&evt, wxCommandEvent)); return int(true); } return wxApp::FilterEvent(evt); }
bool wxArrayPropertyEditor::OnEvent( wxPropertyGrid* propGrid, wxPGProperty* property, wxWindow* ctrl, wxEvent& event ) const { if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) { wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary(); wxArrayProperty* pArrayProperty = static_cast<wxArrayProperty*>(property); if(event.GetId() == buttons->GetButtonId(0)) // + - add element { if(pArrayProperty->GetMaxElems() < 0 || pArrayProperty->GetChildCount() < u32(pArrayProperty->GetMaxElems())) { // determine new property name IProperty* pNewProperty = pArrayProperty->GetSubPropertyTemplate(); std::stringstream ss; ss << "[" << property->GetChildCount() << "]"; pNewProperty->SetName(ss.str()); // create a new wxPGProperty out of it and insert it wxPGProperty* pWxProperty = PropertyList::GetWxProperty(pNewProperty, pArrayProperty->GetParent()); property->InsertChild(-1, pWxProperty); if(pNewProperty->GetType() == PT_Reference) { pArrayProperty->GetParent()->FillArrayProperties(pNewProperty, pWxProperty); } pArrayProperty->UpdateValue(); propGrid->RefreshProperty(property); // update the corresponding property in the property stream wxPropertyGridEvent PGEvent; PGEvent.SetProperty(property); pArrayProperty->SetEventType(wxArrayProperty::E_PropertyAdded); pArrayProperty->GetParent()->OnPropertyGridChange(PGEvent); } } else if(event.GetId() == buttons->GetButtonId(1)) // - remove element { int childCount = property->GetChildCount(); if(childCount > 0) { // remove the wx property wxPGProperty* pChild = property->Item(childCount-1); propGrid->DeleteProperty(pChild); pArrayProperty->UpdateValue(); propGrid->RefreshProperty(property); // update the corresponding property in the property stream wxPropertyGridEvent PGEvent; PGEvent.SetProperty(property); pArrayProperty->SetEventType(wxArrayProperty::E_PropertyRemoved); pArrayProperty->GetParent()->OnPropertyGridChange(PGEvent); } } return true; } else { return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event); } }
wxString CREventCaptureManager::GetEventDetails (wxEvent& event) const { wxString evtObjName, evtObjHierarchy; // Print name of event object - is this XRC string ID? wxObject *obj = event.GetEventObject (); if ((event.GetEventType () == wxEVT_COMMAND_MENU_SELECTED) || (event.GetEventType () == wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED)) { wxWindow *wdw = wxDynamicCast (obj, wxWindow); if (wdw != NULL) { evtObjName = wdw->GetName (); //wxASSERT (event.GetId () == XRCID (evtObjName)); wxWindow *parent = wdw->GetParent (); if (parent) { evtObjHierarchy += "-> " + parent->GetName (); } parent = wdw->GetGrandParent (); if (parent) { evtObjHierarchy += " -> " + parent->GetName (); } } else { // Menus are different, they do not inherit from wxWindow: wxMenu *menu = wxDynamicCast (obj, wxMenu); if (menu != NULL) { evtObjName = menu->GetTitle (); } } } else if (obj != NULL) { wxWindow *wdw = wxDynamicCast (obj, wxWindow); if (wdw != NULL) { evtObjName = wdw->GetName (); // For command events this assertion is too strong, the event object // can also be a parent component! //wxASSERT (event.GetId () == XRCID (evtObjName)); if (event.IsCommandEvent ()) { //wxWindow *child = wxWindow::FindWindowById (event.GetId (), wdw); wxWindow *child = wxWindow::FindWindowById (event.GetId ()); wxASSERT ((event.GetId () == XRCID (evtObjName)) || (child != NULL)); } else { wxASSERT (event.GetId () == XRCID (evtObjName)); } wxWindow *parent = wdw->GetParent (); if (parent) { evtObjHierarchy += "-> " + parent->GetName (); } parent = wdw->GetGrandParent (); if (parent) { evtObjHierarchy += " -> " + parent->GetName (); } } else { // Menus are different, they do not inherit from wxWindow: wxMenu *menu = wxDynamicCast (obj, wxMenu); if (menu != NULL) { evtObjName = menu->GetTitle (); } } } // Timestamp is mostly 0 and therefore irrelevant; if it is a command event // or not is not important: //wxString evtInfo = wxString::Format ("[%d]: id %d cmd %d - EvtObj '%s' %s", wxString evtInfo = wxString::Format ("id %d, EvtObj '%s' %s", //event.GetTimestamp (), event.GetId (), //event.IsCommandEvent (), evtObjName.c_str (), evtObjHierarchy.c_str ()); return evtInfo; }
bool wxPtrButtonEditor::OnEvent( wxPropertyGrid* propGrid, wxPGProperty* property, wxWindow* ctrl, wxEvent& event ) const { if ( event.GetEventType() == wxEVT_COMMAND_BUTTON_CLICKED ) { wxPGMultiButton* buttons = (wxPGMultiButton*) propGrid->GetEditorControlSecondary(); CWxwidgetsPropertyBase* pPropertyDescription = static_cast<CWxwidgetsPropertyBase*>(property->GetClientData()); CBDTWxFrame* pMainFrame = static_cast<CBDTWxApp*>(wxApp::GetInstance())->GetMainFrame(); const wxWindow* pButton = NULL; for (uint32_t i = 0; i < buttons->GetCount(); ++i) { if (event.GetId() == buttons->GetButtonId(i)) { pButton = buttons->GetButton(i); break; } } if (pButton != NULL) { if (pPropertyDescription->GetType() == eRPT_Ptr) { CPtrPropertyDescription* pPtrPropertyDescription = static_cast<CPtrPropertyDescription*>(pPropertyDescription); wxString valueStr = property->GetValueAsString(); bool bValueChanged = false; if (pButton->GetLabel().CmpNoCase(_T("+")) == 0) { uint32_t ptrGuid = pPtrPropertyDescription->GetPtrGuid(); std::vector<uint32_t> instanceClassGuid; CComponentProxyManager::GetInstance()->QueryDerivedClass(ptrGuid, instanceClassGuid, true); bValueChanged = instanceClassGuid.size() == 0; if (!bValueChanged) { instanceClassGuid.insert(instanceClassGuid.begin(), ptrGuid); wxPGChoices choice; for (auto i : instanceClassGuid) { CComponentBase* pBase = CComponentProxyManager::GetInstance()->GetComponentTemplate(i); if (pBase != NULL)//If it is NULL, it must be an abstract class. { choice.Add(pBase->GetClassStr(), pBase->GetGuid()); } BEATS_ASSERT(pBase != NULL || CComponentProxyManager::GetInstance()->GetAbstractComponentNameMap().find(i) != CComponentProxyManager::GetInstance()->GetAbstractComponentNameMap().end(), _T("We can't get a template component with guid %d while it can't be found in abstract class map!"), i); } wxString strSelectItem = ::wxGetSingleChoice(wxT("TypeChoice"), wxT("Caption"), choice.GetLabels(), NULL, wxDefaultCoord, wxDefaultCoord, false, wxCHOICE_WIDTH, wxCHOICE_HEIGHT); if ( !strSelectItem.empty() ) { int nSelectIndex = choice.Index(strSelectItem); uint32_t uDerivedGuid = choice.GetValue(nSelectIndex); pPtrPropertyDescription->SetDerivedGuid(uDerivedGuid); bValueChanged = true; } } if (bValueChanged) { bool bCreateInstance = pPtrPropertyDescription->CreateInstance(); BEATS_ASSERT(bCreateInstance); CComponentProxy* pCompBase = static_cast<CComponentProxy*>(pPtrPropertyDescription->GetInstanceComponent()); BEATS_ASSERT(pCompBase != NULL); BEATS_ASSERT(pMainFrame != NULL); TString* pStrValue = (TString*)pPtrPropertyDescription->GetValue(eVT_CurrentValue); property->SetValueFromString(pStrValue->c_str()); pMainFrame->InsertComponentsInPropertyGrid(pCompBase, property); buttons->GetButton(0)->SetLabel(_T("-")); valueStr.insert(0, _T("+")); } } else if (pButton->GetLabel().CmpNoCase(_T("-")) == 0) { property->DeleteChildren(); bool bDeleteInstance = pPtrPropertyDescription->DestroyInstance(true); // Destroy instance may cause the value changed, so we fetch it again. char szTmp[MAX_PATH]; pPtrPropertyDescription->GetValueAsChar(eVT_CurrentValue, szTmp); valueStr = szTmp; pPtrPropertyDescription->GetChildren().clear(); BEATS_ASSERT(bDeleteInstance); buttons->GetButton(0)->SetLabel(_T("+")); bValueChanged = true; } if (bValueChanged) { wxVariant newValue(valueStr); pPtrPropertyDescription->SetValue(newValue, false); property->SetValue(newValue); propGrid->Refresh(); } } if (pPropertyDescription->IsContainerProperty()) { if (pButton->GetLabel().CmpNoCase(_T("+")) == 0) { CPropertyDescriptionBase* pNewChild = pPropertyDescription->AddChild(NULL); if (pNewChild != NULL) { std::vector<CPropertyDescriptionBase*> value; value.push_back(pNewChild); pMainFrame->InsertInPropertyGrid(value, property); } } else if (pButton->GetLabel().CmpNoCase(_T("-")) == 0) { pPropertyDescription->DeleteAllChild(); property->DeleteChildren(); } char valueStr[256]; pPropertyDescription->GetValueAsChar(eVT_CurrentValue, valueStr); property->SetValue(valueStr); property->SetModifiedStatus(pPropertyDescription->GetChildrenCount() > 0); property->RecreateEditor(); } if (pButton->GetLabel().CmpNoCase(_T("x")) == 0) { BEATS_ASSERT(pPropertyDescription->GetParent() != NULL); CPropertyDescriptionBase* pParent = pPropertyDescription->GetParent(); pParent->DeleteChild(pPropertyDescription); // NOTICE: We have deleted this already! pPropertyDescription = NULL; property->SetClientData(NULL); char valueStr[256]; pParent->GetValueAsChar(eVT_CurrentValue, valueStr); property->GetParent()->SetValue(valueStr); //TODO: I can't refresh property here, because we are trying to delete property of which callback we are in. pMainFrame->RequestToUpdatePropertyGrid(); } return true; } } return wxPGTextCtrlEditor::OnEvent(propGrid, property, ctrl, event); }