Exemplo n.º 1
0
void SearchPanel::OnReplace(wxCommandEvent& WXUNUSED(evt)) {
	Replace();
	UpdateReplaceHistory();
}
Exemplo n.º 2
0
myFindReplaceDlg::myFindReplaceDlg (wxWindow *parent,
                                    const wxString &findstr,
                                    const wxString &replacestr,
                                    wxUint32 flags,
                                    long style)
               : wxScrollingDialog (parent, -1, _("Dialog"),
                           wxDefaultPosition, wxDefaultSize,
                           style | wxDEFAULT_DIALOG_STYLE) {

    m_style = 0;

    //accelerators (for help)
    const int nEntries = 1 ;
    wxAcceleratorEntry entries[nEntries];
    entries[0].Set (wxACCEL_NORMAL, WXK_F1, wxID_HELP);
    wxAcceleratorTable accel (nEntries, entries);
    SetAcceleratorTable (accel);

    // layout the dialog
    m_findpane = new wxBoxSizer (wxVERTICAL);

    // find, replace text and options, direction
    wxBoxSizer *findsizer = new wxBoxSizer (wxHORIZONTAL);
    findsizer->Add (new wxStaticText (this, -1, _("Search for:"),
                                      wxDefaultPosition, wxSize(80, -1)),
                    0, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 6);
    m_findstr = new wxComboBox (this, myID_DLG_FIND_TEXT, findstr,
                                 wxDefaultPosition, wxSize(200, -1));
    findsizer->Add (m_findstr, 1, wxALIGN_CENTRE_VERTICAL);
    m_findpane->Add (findsizer, 0, wxEXPAND | wxBOTTOM, 6);

    m_fdirsizer = new wxBoxSizer (wxHORIZONTAL);
    m_fdirsizer->Add (new wxStaticText (this, -1, _("In directories:"),
                                        wxDefaultPosition, wxSize(80, -1)),
                      0, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 6);
    wxString finddir;
    m_finddir = new wxComboBox (this, -1, finddir,
                                wxDefaultPosition, wxSize(200, -1),
                                //0, NULL); //AMD64 ambiguity betw int vs wxArray
                                (int)0, (const wxString*) NULL);
    m_fdirsizer->Add (m_finddir, 1, wxALIGN_CENTRE_VERTICAL);
    m_findpane->Show (m_fdirsizer, false);
    m_findpane->Add (m_fdirsizer, 0, wxEXPAND | wxBOTTOM, 6);

    m_specsizer = new wxBoxSizer (wxHORIZONTAL);
    m_specsizer->Add (new wxStaticText (this, -1, _("With filespec:"),
                                        wxDefaultPosition, wxSize(80, -1)),
                      0, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 6);
    m_findspec = new wxTextCtrl (this, -1, wxEmptyString,
                                 wxDefaultPosition, wxSize(200, -1));
    m_specsizer->Add (m_findspec, 1, wxALIGN_CENTRE_VERTICAL);
    m_findpane->Show (m_specsizer, false);
    m_findpane->Add (m_specsizer, 0, wxEXPAND | wxBOTTOM, 6);

    m_replsizer = new wxBoxSizer (wxHORIZONTAL);
    m_replsizer->Add (new wxStaticText (this, -1, _("Replace with:"),
                                        wxDefaultPosition, wxSize(80, -1)),
                      0, wxALIGN_CENTRE_VERTICAL | wxRIGHT, 6);
    m_replacestr = new wxComboBox (this, -1, replacestr,
                                    wxDefaultPosition, wxSize(200, -1));
    m_replsizer->Add (m_replacestr, 1, wxALIGN_CENTRE_VERTICAL);
    m_findpane->Show (m_replsizer, false);
    m_findpane->Add (m_replsizer, 0, wxEXPAND | wxBOTTOM, 6);

    // options
    m_optionsizer = new wxBoxSizer (wxVERTICAL);
    m_matchcase = new wxCheckBox (this, -1, _("Match &case"));
    m_matchcase->SetValue ((flags & myFR_MATCHCASE) > 0);
    m_optionsizer->Add (m_matchcase, 0, wxBOTTOM, 6);
    m_wholeword = new wxCheckBox (this, -1, _("Whole &word"));
    m_wholeword->SetValue ((flags & myFR_WHOLEWORD) > 0);
    m_wholeword->Enable (false);
    m_optionsizer->Add (m_wholeword, 0, wxBOTTOM, 6);
    m_findregex = new wxCheckBox (this, -1, _("Regular &expression"));
    m_findregex->SetValue ((flags & myFR_FINDREGEX) > 0);
    m_optionsizer->Add (m_findregex, 0, wxBOTTOM, 6);
    m_subfolder = new wxCheckBox (this, -1, _("Sub &directories"));
    m_subfolder->SetValue ((flags & myFR_SUBFOLDER) > 0);
    m_optionsizer->Add (m_subfolder, 0);

    // directions
    m_dirssizer = new wxBoxSizer (wxVERTICAL);
    static const wxString directions[] = {_("&Upwards"), _("&Downwards")};
    m_direction = new wxRadioBox (this, -1, _("Direction"),
                                  wxDefaultPosition, wxDefaultSize,
                                  WXSIZEOF(directions), directions,
                                  1, wxRA_SPECIFY_COLS);
    m_direction->SetSelection(1);
    m_dirssizer->Add (m_direction, 0);

    // options and directions
    m_optionpane = new wxBoxSizer (wxHORIZONTAL);
    m_optionpane->Add (m_optionsizer, 1, wxALIGN_TOP|wxALIGN_LEFT);
    m_optionpane->Add (m_dirssizer, 0, wxALIGN_TOP|wxALIGN_RIGHT);
    m_findpane->Add (0, 6);
    m_findpane->Add (m_optionpane, 0, wxEXPAND);

    // buttons
    m_buttonpane = new wxBoxSizer (wxVERTICAL);
    m_findButton = new wxButton (this, wxID_OK, _("&Find"));
    m_findButton->SetDefault();
    m_buttonpane->Add (m_findButton, 0, wxEXPAND|wxALIGN_TOP|wxBOTTOM, 6);
    m_replaceButton = new wxButton (this, myID_REPLACE, _("&Replace"));
    m_buttonpane->Add (m_replaceButton, 0, wxEXPAND|wxALIGN_TOP|wxBOTTOM, 6);
    m_buttonpane->Show (m_replaceButton, false);
    m_replaceAllButton = new wxButton (this, myID_REPLACEALL, _("Replace &all"));
    m_buttonpane->Add (m_replaceAllButton, 0, wxEXPAND|wxALIGN_TOP|wxBOTTOM, 6);
    m_buttonpane->Show (m_replaceAllButton, false);
    m_cancelButton = new wxButton (this, wxID_CANCEL, _("Cancel"));
    m_buttonpane->Add (m_cancelButton, 0, wxEXPAND|wxALIGN_BOTTOM);

    m_totalpane = new wxBoxSizer (wxHORIZONTAL);
    m_totalpane->Add (m_findpane, 0, wxEXPAND | wxALL, 10);
    m_totalpane->Add (m_buttonpane, 0, wxEXPAND | wxALL, 10);

    m_findstr->SetFocus();
    m_findstr->SetSelection (-1, -1);
    SetSizerAndFit (m_totalpane);

    // load history
    LoadDirHistory ();
    LoadFindHistory ();
    LoadReplaceHistory ();
    UpdateDirHistory ();
    UpdateFindHistory ();
    UpdateReplaceHistory ();

}