Example #1
0
 void OnTestEvent(wxEvent& evt)
 {
     if ( evt.GetEventObject() == gs_psrc1 )
         gs_value += 1;
     else if ( evt.GetEventObject() == gs_psrc2 )
         gs_value += 0x10000;
 }
Example #2
0
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);
}
Example #3
0
bool wxBackgroundBitmap::ProcessEvent(wxEvent &Event)
{
    if(Event.GetEventType() == wxEVT_ERASE_BACKGROUND)
    {
        if(Bitmap.IsOk())
        {
        }
        else
            Event.Skip();
    }
    else if(Event.GetEventType() == wxEVT_PAINT)
    {

        bool TransactionIsOk = false;
        if(Bitmap.IsOk())
        {
            wxWindow * TempWindow = wxDynamicCast(Event.GetEventObject(),wxWindow);
            if(TempWindow)
            {
                wxAutoBufferedPaintDC DC(TempWindow);
                int w, h;
                TempWindow->GetClientSize(&w, &h);
				wxSize current( w,h);
				if ( current != m_lastSize )
				{
					wxImage TempImage = Bitmap.ConvertToImage();
					TempImage.Rescale(w,h);
					Bitmap = wxBitmap( TempImage );
				}
				DC.DrawBitmap(Bitmap, 0, 0, false);
				m_lastSize = current;
                TransactionIsOk = true;
            }
        }
        if(TransactionIsOk == false)
            Event.Skip();
    }
    else if(Event.GetEventType() ==  wxEVT_SIZE)
    {
        wxWindow * TempWindow = wxDynamicCast(Event.GetEventObject(),wxWindow);
        if(TempWindow)
        {
            TempWindow->Refresh();
        }
        Event.Skip();
    }
    else
        return Inherited::ProcessEvent(Event);
    return true;
}
Example #4
0
void ClangPlugin::OnClangReparseFinished( wxEvent& event )
{
//#ifdef CLANGPLUGIN_TRACE_FUNCTIONS
    fprintf(stdout,"%s\n", __PRETTY_FUNCTION__);
//#endif
    ClangProxy::ReparseJob* pJob = static_cast<ClangProxy::ReparseJob*>(event.GetEventObject());
    if ( HasEventSink(clEVT_DIAGNOSTICS_UPDATED ) )
    {
        ClangProxy::GetDiagnosticsJob job( cbEVT_CLANG_ASYNCTASK_FINISHED, idClangGetDiagnostics, pJob->GetTranslationUnitId(), pJob->GetFilename() );
        m_Proxy.AppendPendingJob(job);
    }
    ClangEvent evt( clEVT_REPARSE_FINISHED, pJob->GetTranslationUnitId(), pJob->GetFilename());
    ProcessEvent(evt);
#if 0
    if (pJob->m_TranslId != this->m_TranslUnitId)
    {
        std::cout<<" Reparse finished but another file was loaded"<<std::endl;
        return;
    }
    if (m_ReparseNeeded)
    {
        fprintf(stdout,"%s: Reparsing again, was modified while we were busy...\n", __PRETTY_FUNCTION__);
        wxCommandEvent evt(cbEVT_COMMAND_REPARSE, idReparse);
        AddPendingEvent(evt);
    }
    else
    {
        //m_DiagnosticTimer.Stop();
        //m_DiagnosticTimer.Start(DIAGNOSTIC_DELAY, wxTIMER_ONE_SHOT);
    }
#endif
}
Example #5
0
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();
}
Example #6
0
bool wxAuiMDIParentFrame::ProcessEvent(wxEvent& event)
{
    // stops the same event being processed repeatedly
    if (m_pLastEvt == &event)
        return false;
    m_pLastEvt = &event;

    // let the active child (if any) process the event first.
    bool res = false;
    if (m_pActiveChild &&
            event.IsCommandEvent() &&
            event.GetEventObject() != m_pClientWindow &&
            !(event.GetEventType() == wxEVT_ACTIVATE ||
              event.GetEventType() == wxEVT_SET_FOCUS ||
              event.GetEventType() == wxEVT_KILL_FOCUS ||
              event.GetEventType() == wxEVT_CHILD_FOCUS ||
              event.GetEventType() == wxEVT_COMMAND_SET_FOCUS ||
              event.GetEventType() == wxEVT_COMMAND_KILL_FOCUS )
       )
    {
        res = m_pActiveChild->GetEventHandler()->ProcessEvent(event);
    }

    if (!res)
    {
        // if the event was not handled this frame will handle it,
        // which is why we need the protection code at the beginning
        // of this method
        res = wxEvtHandler::ProcessEvent(event);
    }

    m_pLastEvt = NULL;

    return res;
}
Example #7
0
void GamepadPage::ConfigControl(wxEvent& event)
{
	m_control_dialog = new ControlDialog(this, m_plugin, ((ControlButton*)event.GetEventObject())->control_reference);
	m_control_dialog->ShowModal();
	m_control_dialog->Destroy();

	// update changes that were made in the dialog
	UpdateGUI();
}
void wxRadioBox::OnRadioButton(wxEvent& event)
{
    int n = m_buttons.Index((wxRadioButton *)event.GetEventObject());
    wxCHECK_RET( n != wxNOT_FOUND, _T("click from alien radio button") );

    m_selection = n;

    SendRadioEvent();
}
Example #9
0
void GamepadPage::ClearControl(wxEvent& event)
{
  ControlButton* const btn = (ControlButton*)event.GetEventObject();
  btn->control_reference->expression.clear();
  btn->control_reference->range = 1.0;

  controller->UpdateReferences(g_controller_interface);

  // update changes
  UpdateGUI();
}
Example #10
0
// Extend event processing to call OnCommand
bool wxPropertyFormView::ProcessEvent(wxEvent& event)
{
    if (wxEvtHandler::ProcessEvent(event))
        return true;
    else if (event.IsCommandEvent() && !event.IsKindOf(CLASSINFO(wxUpdateUIEvent)) && event.GetEventObject())
    {
        OnCommand(* ((wxWindow*) event.GetEventObject()), (wxCommandEvent&) event);
        return true;
    }
    else
        return false;
}
Example #11
0
void GamepadPage::ClearControl(wxEvent& event)
{
	ControlButton* const btn = (ControlButton*)event.GetEventObject();
	btn->control_reference->expression.clear();
	btn->control_reference->range = 1.0f;

	std::lock_guard<std::recursive_mutex> lk(m_plugin.controls_lock);
	controller->UpdateReferences(g_controller_interface);

	// update changes
	UpdateGUI();
}
Example #12
0
// 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;
}
Example #13
0
// ----------------------------------------------------------------------------
void MouseSap::OnWindowOpen(wxEvent& event)
// ----------------------------------------------------------------------------
{
    // wxEVT_CREATE entry
    // Have to do this especially for split windows since CodeBlocks does not have
    // events when opening/closing split windows

    wxWindow* pWindow = (wxWindow*)(event.GetEventObject());

    // Some code (at times) is not issuing event EVT_APP_STARTUP_DONE
    // so here we do it ourselves. If not initialized and this is the first
    // scintilla window, initialize now.
    if ( (not m_bEditorsAttached)
        && ( pWindow->GetName().Lower() == wxT("sciwindow")) )
        OnAppStartupDoneInit();

    // Attach a split window (or any other window)
    if ( m_bEditorsAttached )
    {
        wxWindow* pWindow = (wxWindow*)(event.GetEventObject());
        cbEditor* ed = 0;
        ed  = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
        if (ed)
        {
            if (pWindow->GetParent() ==  ed)
            {   Attach(pWindow);
                #ifdef LOGGING
                    LOGIT( _T("OnWindowOpen Attached:%p name: %s"),
                            pWindow, pWindow->GetName().GetData() );
                #endif //LOGGING
            }
        }//fi (ed)
    }//fi m_bNote...

    event.Skip();
}//OnWindowOpen
Example #14
0
int mmGUIApp::FilterEvent(wxEvent &event)
{
    int ret = wxApp::FilterEvent(event);

    if (event.GetEventType() == wxEVT_SHOW)
    {
        wxWindow *win = (wxWindow*)event.GetEventObject();

        if (win && win->IsTopLevel() && win != this->m_frame) // wxDialog & wxFrame http://docs.wxwidgets.org/trunk/classwx_top_level_window.html
        {
            Model_Usage::instance().pageview(win);
        }
    }

    return ret;
}
Example #15
0
// ----------------------------------------------------------------------------
void MouseSap::OnWindowClose(wxEvent& event)
// ----------------------------------------------------------------------------
{
    // wxEVT_DESTROY entry

    wxWindow* pWindow = (wxWindow*)(event.GetEventObject());

    if ( (pWindow) && (m_EditorPtrs.Index(pWindow) != wxNOT_FOUND))
    {   // window is one of ours
        Detach(pWindow);
        #ifdef LOGGING
         LOGIT( _T("OnWindowClose Detached %p"), pWindow);
        #endif //LOGGING
    }
    event.Skip();
}//OnWindowClose
Example #16
0
// ----------------------------------------------------------------------------
void ThreadSearchFrame::OnWindowDestroy(wxEvent& event)
// ----------------------------------------------------------------------------
{
    // wxEVT_DESTROY entry

    wxWindow* pWindow = (wxWindow*)(event.GetEventObject());

    if ( (pWindow) && (pWindow->GetName() == _T("SCIwindow")))
    {
        #ifdef LOGGING
         LOGIT( _T("ThreadSearchFrame::OnWindowDestroy [%p]"), pWindow);
        #endif //LOGGING
        int count = GetConfig()->GetEditorManager(this)->GetEditorsCount();
        if (count == 1) //closing last window
            GetConfig()->GetThreadSearchPlugin()->UnsplitThreadSearchWindow();
    }
    event.Skip();
}//OnWindowClose
Example #17
0
int retcon::FilterEvent(wxEvent& event) {
	static unsigned int antirecursion = 0;
	if(antirecursion) return -1;

	antirecursion++;
	#ifdef __WINDOWS__
	if(event.GetEventType() == wxEVT_MOUSEWHEEL) {
		if(GetMainframeAncestor((wxWindow *) event.GetEventObject())) {
			if(RedirectMouseWheelEvent((wxMouseEvent &) event)) {
				antirecursion--;
				return 1;
			}
		}
	}
	#endif
	antirecursion--;

	return -1;
}
Example #18
0
void ClangPlugin::OnClangCreateTUFinished( wxEvent& event )
{
#ifdef CLANGPLUGIN_TRACE_FUNCTIONS
    //fprintf(stdout,"%s\n", __PRETTY_FUNCTION__);
#endif

    cbEditor* ed = Manager::Get()->GetEditorManager()->GetBuiltinActiveEditor();
    if (!ed)
    {
        fprintf(stdout,"%s No editor ???\n", __PRETTY_FUNCTION__);
        return;
    }

    ClangProxy::CreateTranslationUnitJob* obj = static_cast<ClangProxy::CreateTranslationUnitJob*>(event.GetEventObject());
    if (!obj)
    {
        fprintf(stdout,"%s No passed job ???\n", __PRETTY_FUNCTION__);
        return;
    }
    if ( HasEventSink(clEVT_DIAGNOSTICS_UPDATED ) )
    {
        ClangProxy::GetDiagnosticsJob job( cbEVT_CLANG_ASYNCTASK_FINISHED, idClangGetDiagnostics, obj->GetTranslationUnitId(), obj->GetFilename() );
        m_Proxy.AppendPendingJob(job);
    }
    ClangEvent evt( clEVT_REPARSE_FINISHED, obj->GetTranslationUnitId(), obj->GetFilename());
    ProcessEvent(evt);
    if (obj->GetFilename() != ed->GetFilename())
    {
        fprintf(stdout,"%s: Filename mismatch, probably another file was loaded while we were busy parsing. TU filename: '%s', current filename: '%s'\n", __PRETTY_FUNCTION__, (const char*)obj->m_Filename.mb_str(), (const char*)ed->GetFilename().mb_str());
        return;
    }
    m_TranslUnitId = obj->GetTranslationUnitId();
    m_pLastEditor = ed;
}
Example #19
0
void ClangPlugin::OnClangGetDiagnosticsFinished( wxEvent& event )
{
#ifdef CLANGPLUGIN_TRACE_FUNCTIONS
    //fprintf(stdout,"%s\n", __PRETTY_FUNCTION__);
#endif
    ClDiagnosticLevel diagLv = dlFull; // TODO
    ClangProxy::GetDiagnosticsJob* pJob = static_cast<ClangProxy::GetDiagnosticsJob*>(event.GetEventObject());

    ClangEvent evt( clEVT_DIAGNOSTICS_UPDATED, pJob->GetTranslationUnitId(), pJob->GetFilename(), ClTokenPosition(0,0), pJob->GetResults());
    ProcessEvent(evt);

#if 0
    EditorManager* edMgr = Manager::Get()->GetEditorManager();
    cbEditor* ed = edMgr->GetBuiltinActiveEditor();
    if (!ed)
    {
        std::cout<<"No editor..."<<std::endl;
        return;
    }
    if ((pJob->m_TranslId != m_TranslUnitId)||(ed != m_pLastEditor))
    {
        // No longer the current editor
        std::cout<<"Diagnostics requested but another file was loaded..."<<std::endl;
        return;
    }
    cbStyledTextCtrl* stc = ed->GetControl();
    if (diagLv == dlFull)
        stc->AnnotationClearAll();
    const int warningIndicator = 0; // predefined
    const int errorIndicator = 15; // hopefully we do not clash with someone else...
    stc->SetIndicatorCurrent(warningIndicator);
    stc->IndicatorClearRange(0, stc->GetLength());
    stc->IndicatorSetStyle(errorIndicator, wxSCI_INDIC_SQUIGGLE);
    stc->IndicatorSetForeground(errorIndicator, *wxRED);
    stc->SetIndicatorCurrent(errorIndicator);
    stc->IndicatorClearRange(0, stc->GetLength());
    const wxString& fileNm = ed->GetFilename();
    for ( std::vector<ClDiagnostic>::const_iterator dgItr = pJob->m_Diagnostic.begin();
            dgItr != pJob->m_Diagnostic.end(); ++dgItr )
    {
        //Manager::Get()->GetLogManager()->Log(dgItr->file + wxT(" ") + dgItr->message + F(wxT(" %d, %d"), dgItr->range.first, dgItr->range.second));
        if (dgItr->file != fileNm)
            continue;
        if (diagLv == dlFull)
        {
            wxString str = stc->AnnotationGetText(dgItr->line - 1);
            if (!str.IsEmpty())
                str += wxT('\n');
            stc->AnnotationSetText(dgItr->line - 1, str + dgItr->message);
            stc->AnnotationSetStyle(dgItr->line - 1, 50);
        }
        int pos = stc->PositionFromLine(dgItr->line - 1) + dgItr->range.first - 1;
        int range = dgItr->range.second - dgItr->range.first;
        if (range == 0)
        {
            range = stc->WordEndPosition(pos, true) - pos;
            if (range == 0)
            {
                pos = stc->WordStartPosition(pos, true);
                range = stc->WordEndPosition(pos, true) - pos;
            }
        }
        if (dgItr->severity == sError)
            stc->SetIndicatorCurrent(errorIndicator);
        else if (  dgItr != pJob->m_Diagnostics.begin()
                && dgItr->line == (dgItr - 1)->line
                && dgItr->range.first <= (dgItr - 1)->range.second )
        {
            continue; // do not overwrite the last indicator
        }
        else
            stc->SetIndicatorCurrent(warningIndicator);
        stc->IndicatorFillRange(pos, range);
    }
    if (diagLv == dlFull)
        stc->AnnotationSetVisible(wxSCI_ANNOTATION_BOXED);
#endif
}
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;
}