Exemple #1
0
void wxFindReplaceDialogBase::Send(wxFindDialogEvent& event)
{
    // we copy the data to dialog->GetData() as well

    m_FindReplaceData->m_Flags = event.GetFlags();
    m_FindReplaceData->m_FindWhat = event.GetFindString();
    if ( HasFlag(wxFR_REPLACEDIALOG) &&
         (event.GetEventType() == wxEVT_FIND_REPLACE ||
          event.GetEventType() == wxEVT_FIND_REPLACE_ALL) )
    {
        m_FindReplaceData->m_ReplaceWith = event.GetReplaceString();
    }

    // translate wxEVT_FIND_NEXT to wxEVT_FIND if needed
    if ( event.GetEventType() == wxEVT_FIND_NEXT )
    {
        if ( m_FindReplaceData->m_FindWhat != m_lastSearch )
        {
            event.SetEventType(wxEVT_FIND);

            m_lastSearch = m_FindReplaceData->m_FindWhat;
        }
    }

    if ( !GetEventHandler()->ProcessEvent(event) )
    {
        // the event is not propagated upwards to the parent automatically
        // because the dialog is a top level window, so do it manually as
        // in 9 cases of 10 the message must be processed by the dialog
        // owner and not the dialog itself
        (void)GetParent()->GetEventHandler()->ProcessEvent(event);
    }
}
Exemple #2
0
void wxSTEditorFindReplacePanel::Send(wxFindDialogEvent& event)
{
    // we copy the data to dialog->GetData() as well
    m_findReplaceData->SetFlags(event.GetFlags());

    m_findReplaceData->SetFindString(event.GetFindString());
    if (!event.GetFindString().IsEmpty())
        m_findReplaceData->AddFindString(event.GetFindString());

    if ( HasFlag(wxFR_REPLACEDIALOG) &&
         (event.GetEventType() == wxEVT_COMMAND_FIND_REPLACE ||
          event.GetEventType() == wxEVT_COMMAND_FIND_REPLACE_ALL) )
    {
        m_findReplaceData->SetReplaceString(event.GetReplaceString());
        m_findReplaceData->AddReplaceString(event.GetReplaceString());
    }

    // translate wxEVT_COMMAND_FIND_NEXT to wxEVT_COMMAND_FIND if needed
    if ( event.GetEventType() == wxEVT_COMMAND_FIND_NEXT )
    {
        if ( m_findReplaceData->GetFindString() != m_lastSearch )
        {
            event.SetEventType(wxEVT_COMMAND_FIND);
            m_lastSearch = m_findReplaceData->GetFindString();
        }
    }

    // ExtraLong is the line number pressed in the find all editor
    //  when -1 it means that we want a new find all search
    if (m_findReplaceData->HasFlag(STE_FR_FINDALL) && m_resultEditor &&
        (event.GetExtraLong() == -1) &&
        ((event.GetEventType() == wxEVT_COMMAND_FIND) ||
         (event.GetEventType() == wxEVT_COMMAND_FIND_NEXT)))
    {
        m_findReplaceData->GetFindAllStrings()->Clear();
        m_resultEditor->SetReadOnly(false);
        m_resultEditor->SetText(wxEmptyString);
        m_resultEditor->SetReadOnly(true);
    }

    wxWindow *target = GetTargetWindow();

    // first send event to ourselves then to the target
    if ( !GetEventHandler()->ProcessEvent(event) && target )
    {
        // the event is not propagated upwards to the parent automatically
        // because the dialog is a top level window, so do it manually as
        // in 9 cases of 10 the message must be processed by the dialog
        // owner and not the dialog itself
        (void)target->GetEventHandler()->ProcessEvent(event);
    }

    if (m_findReplaceData->HasFlag(STE_FR_FINDALL) && m_resultEditor &&
        (event.GetExtraLong() == -1) &&
        ((event.GetEventType() == wxEVT_COMMAND_FIND) ||
         (event.GetEventType() == wxEVT_COMMAND_FIND_NEXT)))
    {
        wxSTEditor* edit = GetEditor();
        if (edit)
        {
            m_resultEditor->SetLanguage(edit->GetLanguageId());
        }

        wxArrayString* findAllStrings = m_findReplaceData->GetFindAllStrings();
        size_t n, count = findAllStrings->GetCount();
        wxString str;
        for (n = 0; n < count; n++)
            str += findAllStrings->Item(n).AfterFirst(wxT('|'));

        m_resultEditor->Clear();
        m_resultEditor->ClearAllIndicators();

        m_resultEditor->SetReadOnly(false);
        m_resultEditor->SetText(str);
        m_resultEditor->SetReadOnly(true);
        m_resultEditor->Colourise(0, -1);

        wxSTEditorStyles::GetGlobalEditorStyles().SetEditorStyle( 3, STE_STYLE_STRING,
                                                                m_resultEditor, false);
        wxSTEditorStyles::GetGlobalEditorStyles().SetEditorStyle( 4, STE_STYLE_NUMBER,
                                                                m_resultEditor, false);

        for (n = 0; n < count; n++)
        {
            str = findAllStrings->Item(n).AfterFirst(wxT('|'));
            int pos = m_resultEditor->PositionFromLine(n);
            m_resultEditor->StartStyling(pos, 31);
            int length = str.BeforeFirst(wxT('(')).Length() - 1;
            m_resultEditor->SetStyling(length, 3);

            pos = pos + length + 1;
            m_resultEditor->StartStyling(pos, 31);
            length = str.AfterFirst(wxT('(')).BeforeFirst(wxT(')')).Length() + 2;
            m_resultEditor->SetStyling(length, 4);
        }

        m_resultEditor->IndicateAllStrings(m_findReplaceData->GetFindString(),
                                           m_findReplaceData->GetFlags(),
                                           wxSTC_INDIC0_MASK);
    }

    UpdateButtons();
}