37 #define CONF_GROUP _T("/replace_options")    44 DEFINE_EVENT_TYPE(wxDEFERRED_FOCUS_EVENT)
    64                        bool findMode, 
bool findReplaceInFilesOnly, 
bool findReplaceInFilesActive)
    66     m_findReplaceInFilesActive(findReplaceInFilesActive),
    86     XRCCTRL(*
this, 
"cmbFind1", 
wxComboBox)->SetValue(initial);
    91     XRCCTRL(*
this, 
"chkLimitTo1", 
wxCheckBox)->SetValue(flgWholeWord || flgStartWord || flgStartFile);
    92     XRCCTRL(*
this, 
"rbLimitTo1",  
wxRadioBox)->Enable(flgWholeWord || flgStartWord || flgStartFile);
    93     XRCCTRL(*
this, 
"rbLimitTo1",  
wxRadioBox)->SetSelection(flgStartFile ? 2 : (flgStartWord ? 1 : 0));
    98     XRCCTRL(*
this, 
"rbDirection",   
wxRadioBox)->Enable(!XRCCTRL(*
this, 
"chkRegEx1", 
wxCheckBox)->GetValue()); 
   100     XRCCTRL(*
this, 
"rbScope1",      
wxRadioBox)->SetSelection(hasSelection);
   102     XRCCTRL(*
this, 
"chkAutoWrapSearch", 
wxCheckBox)->SetValue(cfg->
ReadBool(
_T(
"/find_options/auto_wrap_search"), 
true));
   108     XRCCTRL(*
this, 
"chkLimitTo2", 
wxCheckBox)->SetValue(flgWholeWord || flgStartWord || flgStartFile);
   109     XRCCTRL(*
this, 
"rbLimitTo2",  
wxRadioBox)->Enable(flgWholeWord || flgStartWord || flgStartFile);
   110     XRCCTRL(*
this, 
"rbLimitTo2",  
wxRadioBox)->SetSelection(flgStartFile ? 2 : (flgStartWord ? 1 : 0));
   112     XRCCTRL(*
this, 
"cmbFind2",      
wxComboBox)->SetValue(initial);
   117     XRCCTRL(*
this, 
"chkMultiLine1", 
wxCheckBox)->SetValue(
false);
   119     XRCCTRL(*
this, 
"chkFixEOLs1",   
wxCheckBox)->Enable(XRCCTRL(*
this, 
"chkMultiLine1", 
wxCheckBox)->GetValue());
   121     XRCCTRL(*
this, 
"chkMultiLine2",       
wxCheckBox)->SetValue(
false);
   123     XRCCTRL(*
this, 
"chkFixEOLs2",         
wxCheckBox)->Enable(XRCCTRL(*
this, 
"chkMultiLine2", 
wxCheckBox)->GetValue());
   126     wxSize szReplaceMulti = XRCCTRL(*
this, 
"nbReplaceMulti", 
wxPanel)->GetEffectiveMinSize();
   127     XRCCTRL(*
this, 
"nbReplaceSingle", 
wxPanel)->SetMinSize(szReplaceMulti);
   128     XRCCTRL(*
this, 
"nbReplaceMulti",  
wxPanel)->SetMinSize(szReplaceMulti);
   130     wxSize szReplaceInFilesMulti = XRCCTRL(*
this, 
"nbReplaceInFilesMulti", 
wxPanel)->GetEffectiveMinSize();
   131     XRCCTRL(*
this, 
"nbReplaceInFilesSingle", 
wxPanel)->SetMinSize(szReplaceInFilesMulti);
   132     XRCCTRL(*
this, 
"nbReplaceInFilesMulti",  
wxPanel)->SetMinSize(szReplaceInFilesMulti);
   134     wxSize szFindMulti = XRCCTRL(*
this, 
"nbFindMulti", 
wxPanel)->GetEffectiveMinSize();
   135     XRCCTRL(*
this, 
"nbFindSingle", 
wxPanel)->SetMinSize(szFindMulti);
   136     XRCCTRL(*
this, 
"nbFindMulti",  
wxPanel)->SetMinSize(szFindMulti);
   138     wxSize szFindInFilesMulti = XRCCTRL(*
this, 
"nbFindInFilesMulti", 
wxPanel)->GetEffectiveMinSize();
   139     XRCCTRL(*
this, 
"nbFindInFilesSingle", 
wxPanel)->SetMinSize(szFindInFilesMulti);
   140     XRCCTRL(*
this, 
"nbFindInFilesMulti",  
wxPanel)->SetMinSize(szFindInFilesMulti);
   142     wxSize szSearchPath = XRCCTRL(*
this, 
"pnSearchPath", 
wxPanel)->GetEffectiveMinSize();
   143     XRCCTRL(*
this, 
"pnSearchProject", 
wxPanel)->SetMinSize(szSearchPath);
   144     XRCCTRL(*
this, 
"pnSearchPath",  
wxPanel)->SetMinSize(szSearchPath);
   162         FillComboWithLastValues(cmbSearchMask, 
CONF_GROUP _T(
"/search_masks"));
   164     if (cmbSearchMask->GetCount() > 0)
   165         XRCCTRL(*
this, 
"cmbSearchMask", 
wxComboBox)->SetSelection(0);
   172     for(
unsigned int i=0;i<pa->size();++i)
   174         chProject->AppendString((*pa)[i]->GetTitle());
   175         if ((*pa)[i] == active_project)
   179             chTarget->AppendString(
_(
"All project files"));
   184             if (targetCount < maxTargetCount)
   189                 chTarget->Append(targetNames);
   191                 chTarget->
SetSelection((selectScopeAll || targIdx < 0) ? 0 : targIdx );
   202                 chTarget->Enable(
false);
   209     bool filesOpen = 
false;
   222         rbScope->
Enable(0, 
false);
   234         rbScope->
Enable(1, 
false);
   235         rbScope->
Enable(2, 
false);
   241             XRCCTRL(*
this, 
"pnSearchPath",    
wxPanel)->Hide();
   242             XRCCTRL(*
this, 
"pnSearchPath",    
wxPanel)->Disable();
   243             XRCCTRL(*
this, 
"pnSearchProject", 
wxPanel)->Show();
   246             XRCCTRL(*
this, 
"pnSearchPath",    
wxPanel)->Show();
   247             XRCCTRL(*
this, 
"pnSearchPath",    
wxPanel)->Enable();
   248             XRCCTRL(*
this, 
"pnSearchProject", 
wxPanel)->Hide();
   251             XRCCTRL(*
this, 
"pnSearchPath",    
wxPanel)->Show();
   252             XRCCTRL(*
this, 
"pnSearchPath",    
wxPanel)->Disable();
   253             XRCCTRL(*
this, 
"pnSearchProject", 
wxPanel)->Hide();
   256     (XRCCTRL(*
this, 
"nbReplace", 
wxNotebook)->GetPage(1))->Layout();
   260         SetTitle(
_T(
"Find"));
   261         XRCCTRL(*
this, 
"nbReplaceSingle",        
wxPanel)->Hide();
   262         XRCCTRL(*
this, 
"nbReplaceInFilesSingle", 
wxPanel)->Hide();
   263         XRCCTRL(*
this, 
"nbReplace",              
wxNotebook)->SetPageText(0,
_T(
"Find"));
   264         XRCCTRL(*
this, 
"nbReplace",              
wxNotebook)->SetPageText(1,
_T(
"Find in files"));
   265         XRCCTRL(*
this, 
"wxID_OK",                
wxButton)->SetLabel(
_T(
"&Find"));
   266         XRCCTRL(*
this, 
"chkFixEOLs1",            
wxCheckBox)->Hide();
   267         XRCCTRL(*
this, 
"chkFixEOLs2",            
wxCheckBox)->Hide();
   268         XRCCTRL(*
this, 
"chkDelOldSearchRes2",    
wxCheckBox)->Show();
   271     m_findPage = 
nullptr;
   272     if (findReplaceInFilesOnly)
   275         XRCCTRL(*
this,  
"nbReplace", 
wxNotebook)->SetSelection(1);
   276         m_findPage = (XRCCTRL(*
this, 
"nbReplace", 
wxNotebook)->GetPage(0)); 
   277         (XRCCTRL(*
this, 
"nbReplace", 
wxNotebook)->RemovePage(0)); 
   278         XRCCTRL(*
this,  
"cmbFind2",  
wxComboBox)->SetFocus();
   279         m_findReplaceInFilesActive = 
true;
   281     else if (m_findReplaceInFilesActive)
   283         XRCCTRL(*
this, 
"nbReplace", 
wxNotebook)->SetSelection(1); 
   284         XRCCTRL(*
this, 
"cmbFind2",  
wxComboBox)->SetFocus();
   287         XRCCTRL(*
this, 
"cmbFind1",  
wxComboBox)->SetFocus();
   289     GetSizer()->SetSizeHints(
this);
   328         bool flgLimitTo = XRCCTRL(*
this, 
"chkLimitTo1", 
wxCheckBox)->GetValue();
   329         int  valLimitTo = XRCCTRL(*
this, 
"rbLimitTo1",  
wxRadioBox)->GetSelection();
   336         cfg->
Write(
_T(
"/find_options/auto_wrap_search"), XRCCTRL(*
this, 
"chkAutoWrapSearch", 
wxCheckBox)->GetValue());
   340     bool flgLimitTo = XRCCTRL(*
this, 
"chkLimitTo2", 
wxCheckBox)->GetValue();
   341     int  valLimitTo = XRCCTRL(*
this, 
"rbLimitTo2",  
wxRadioBox)->GetSelection();
   370             return XRCCTRL(*
this, 
"txtMultiLineFind2", 
wxTextCtrl)->GetValue();
   371         return XRCCTRL(*
this, 
"txtMultiLineFind1", 
wxTextCtrl)->GetValue();
   374         return XRCCTRL(*
this, 
"cmbFind2", 
wxComboBox)->GetValue();
   376     return XRCCTRL(*
this, 
"cmbFind1", 
wxComboBox)->GetValue();
   386             return XRCCTRL(*
this, 
"txtMultiLineReplace2", 
wxTextCtrl)->GetValue();
   387         return XRCCTRL(*
this, 
"txtMultiLineReplace1", 
wxTextCtrl)->GetValue();
   390         return XRCCTRL(*
this, 
"cmbReplace2", 
wxComboBox)->GetValue();
   392     return XRCCTRL(*
this, 
"cmbReplace1", 
wxComboBox)->GetValue();
   403         return XRCCTRL(*
this, 
"chkDelOldSearchRes2", 
wxCheckBox)->GetValue();
   417         bool flgLimitTo = XRCCTRL(*
this, 
"chkLimitTo2", 
wxCheckBox)->GetValue();
   418         return flgLimitTo && XRCCTRL(*
this, 
"rbLimitTo2", 
wxRadioBox)->GetSelection() == 0;
   421     bool flgLimitTo = XRCCTRL(*
this, 
"chkLimitTo1", 
wxCheckBox)->GetValue();
   422     return flgLimitTo && XRCCTRL(*
this, 
"rbLimitTo1", 
wxRadioBox)->GetSelection() == 0;
   429         bool flgLimitTo = XRCCTRL(*
this, 
"chkLimitTo2", 
wxCheckBox)->GetValue();
   430         return flgLimitTo && XRCCTRL(*
this, 
"rbLimitTo2", 
wxRadioBox)->GetSelection() == 1;
   432     bool flgLimitTo = XRCCTRL(*
this, 
"chkLimitTo1", 
wxCheckBox)->GetValue();
   433     return flgLimitTo && XRCCTRL(*
this, 
"rbLimitTo1", 
wxRadioBox)->GetSelection() == 1;
   439         return XRCCTRL(*
this, 
"chkMatchCase2", 
wxCheckBox)->GetValue();
   440     return XRCCTRL(*
this, 
"chkMatchCase1", 
wxCheckBox)->GetValue();
   446         return XRCCTRL(*
this, 
"chkRegEx2", 
wxCheckBox)->GetValue();
   447     return XRCCTRL(*
this, 
"chkRegEx1", 
wxCheckBox)->GetValue();
   454     return XRCCTRL(*
this, 
"chkAutoWrapSearch", 
wxCheckBox)->GetValue();
   466         bool flgLimitTo = XRCCTRL(*
this, 
"chkLimitTo2", 
wxCheckBox)->GetValue();
   467         return flgLimitTo && XRCCTRL(*
this, 
"rbLimitTo2", 
wxRadioBox)->GetSelection() == 2;
   469     bool flgLimitTo = XRCCTRL(*
this, 
"chkLimitTo1", 
wxCheckBox)->GetValue();
   470     return flgLimitTo && XRCCTRL(*
this, 
"rbLimitTo1", 
wxRadioBox)->GetSelection() == 2;
   476         return XRCCTRL(*
this, 
"chkMultiLine2", 
wxCheckBox)->GetValue();
   477     return XRCCTRL(*
this, 
"chkMultiLine1", 
wxCheckBox)->GetValue();
   483         return XRCCTRL(*
this, 
"chkFixEOLs2", 
wxCheckBox)->GetValue();
   484     return XRCCTRL(*
this, 
"chkFixEOLs1", 
wxCheckBox)->GetValue();
   491     return XRCCTRL(*
this, 
"rbDirection", 
wxRadioBox)->GetSelection();
   498     return XRCCTRL(*
this, 
"rbOrigin", 
wxRadioBox)->GetSelection();
   504         return XRCCTRL(*
this, 
"rbScope2", 
wxRadioBox)->GetSelection();
   505     return XRCCTRL(*
this, 
"rbScope1", 
wxRadioBox)->GetSelection();
   510     return XRCCTRL(*
this, 
"chkSearchRecursively", 
wxCheckBox)->IsChecked();
   515     return XRCCTRL(*
this, 
"chkSearchHidden", 
wxCheckBox)->IsChecked();
   520     return XRCCTRL(*
this, 
"txtSearchPath", 
wxTextCtrl)->GetValue();
   525     return XRCCTRL(*
this, 
"cmbSearchMask", 
wxComboBox)->GetValue();
   530     return XRCCTRL(*
this, 
"chProject", 
wxChoice)->GetSelection();
   544     for(
int ii = 0; ii < targetCount; ++ii)
   556         return XRCCTRL(*
this, 
"chkMultiLine2", 
wxCheckBox)->GetValue();
   557     return XRCCTRL(*
this, 
"chkMultiLine1", 
wxCheckBox)->GetValue();
   568             XRCCTRL(*
this, 
"pnSearchPath", 
wxPanel)->Hide();
   569             XRCCTRL(*
this, 
"pnSearchPath", 
wxPanel)->Disable();
   570             XRCCTRL(*
this, 
"pnSearchProject", 
wxPanel)->Show();
   573             XRCCTRL(*
this, 
"pnSearchPath", 
wxPanel)->Show();
   574             XRCCTRL(*
this, 
"pnSearchPath", 
wxPanel)->Enable();
   575             XRCCTRL(*
this, 
"pnSearchProject", 
wxPanel)->Hide();
   578             XRCCTRL(*
this, 
"pnSearchPath", 
wxPanel)->Show();
   579             XRCCTRL(*
this, 
"pnSearchPath", 
wxPanel)->Disable();
   580             XRCCTRL(*
this, 
"pnSearchProject", 
wxPanel)->Hide();
   584         (XRCCTRL(*
this, 
"nbReplace", 
wxNotebook)->GetPage(1))->Layout();
   586         (XRCCTRL(*
this, 
"nbReplace", 
wxNotebook)->GetPage(0))->Layout();
   591     const wxString txtSearchPath = XRCCTRL(*
this, 
"txtSearchPath", 
wxTextCtrl)->GetValue();
   594         XRCCTRL(*
this, 
"txtSearchPath", 
wxTextCtrl)->SetValue(dir);
   607     chTarget->AppendString(
_(
"All project files"));
   611     chTarget->
SetSelection(targAll || targIdx < 0 ? 0 : targIdx);
   624     if (txtFind1 && txtFind2 && cmbFind1 && cmbFind2 && cmbReplace1 && cmbReplace2)
   626         if (event.GetSelection() == 0)
   629             txtFind1->SetValue(txtFind2->GetValue());
   630             cmbFind1->SetValue(cmbFind2->GetValue());
   631             cmbReplace1->SetValue(cmbReplace2->GetValue());
   634         else if (event.GetSelection() == 1)
   637             txtFind2->SetValue(txtFind1->GetValue());
   638             cmbFind2->SetValue(cmbFind1->GetValue());
   639             cmbReplace2->SetValue(cmbReplace1->GetValue());
   640             cmbFind1->SetFocus();
   655                                            : XRCCTRL(*
this, 
"txtMultiLineFind1", 
wxTextCtrl) );
   656         if (tc) tc->SetFocus();
   662         if (cb) cb->SetFocus();
   668     XRCCTRL(*
this, 
"rbDirection", 
wxRadioBox)->Enable(!XRCCTRL(*
this, 
"chkRegEx1", 
wxCheckBox)->GetValue());
   676                                             : XRCCTRL(*
this, 
"txtMultiLineFind1", 
wxTextCtrl) );
   677         if (tcp) tcp->SetFocus();
   683         if (cbp) cbp->SetFocus();
   702     bool      enabledMultiLine = 
false;
   704     if (event.GetId() == XRCID(
"chkMultiLine1"))
   706         enabledMultiLine = chkMultiLine1->
GetValue();
   707         if (chkMultiLine2) chkMultiLine2->
SetValue(enabledMultiLine);
   708         ctrlToFocus = enabledMultiLine ? 
dynamic_cast<wxWindow*
>(txtFind1) : dynamic_cast<wxWindow*>(cmbFind1);
   710     else if (event.GetId() == XRCID(
"chkMultiLine2"))
   712         enabledMultiLine = chkMultiLine2->
GetValue();
   713         if (chkMultiLine1) chkMultiLine1->
SetValue(enabledMultiLine);
   714         ctrlToFocus = enabledMultiLine ? 
dynamic_cast<wxWindow*
>(txtFind2) : dynamic_cast<wxWindow*>(cmbFind2);
   719     XRCCTRL(*
this, 
"nbFindSingle", 
wxPanel)->Show(!enabledMultiLine);
   720     XRCCTRL(*
this, 
"nbFindInFilesSingle", 
wxPanel)->Show(!enabledMultiLine);
   721     XRCCTRL(*
this, 
"nbFindMulti", 
wxPanel)->Show(enabledMultiLine);
   722     XRCCTRL(*
this, 
"nbFindInFilesMulti", 
wxPanel)->Show(enabledMultiLine);
   726         XRCCTRL(*
this, 
"nbReplaceSingle", 
wxPanel)->Show(!enabledMultiLine);
   727         XRCCTRL(*
this, 
"nbReplaceInFilesSingle", 
wxPanel)->Show(!enabledMultiLine);
   728         XRCCTRL(*
this, 
"nbReplaceMulti", 
wxPanel)->Show(enabledMultiLine);
   729         XRCCTRL(*
this, 
"nbReplaceInFilesMulti", 
wxPanel)->Show(enabledMultiLine);
   732     if (chkFixEOLs1) chkFixEOLs1->Enable(enabledMultiLine);
   733     if (chkFixEOLs2) chkFixEOLs2->Enable(enabledMultiLine);
   734     if (ctrlToFocus) ctrlToFocus->SetFocus();
   737     (XRCCTRL(*
this, 
"nbReplace", 
wxNotebook)->GetPage(0))->Layout();
   739         (XRCCTRL(*
this, 
"nbReplace", 
wxNotebook)->GetPage(1))->Layout();
   747     if (event.GetId() == XRCID(
"chkLimitTo1"))
   748         XRCCTRL(*
this, 
"rbLimitTo1", 
wxRadioBox)->Enable(XRCCTRL(*
this, 
"chkLimitTo1", 
wxCheckBox)->GetValue());
   750         XRCCTRL(*
this, 
"rbLimitTo2", 
wxRadioBox)->Enable(XRCCTRL(*
this, 
"chkLimitTo2", 
wxCheckBox)->GetValue());
   760     combo->Append(values);
   768     static const unsigned int max_value = 10u;
   772     values.
Add(combo->GetValue());
   774     const unsigned int item_count = std::min(combo->GetCount(), max_value);
   775     for (
unsigned int i = 0; i < item_count; ++i)
   777         const wxString item = combo->GetString(i);
   796     const wxString strAllProjectFiles = 
_(
"All project files");
   797     targetNames.push_back(strAllProjectFiles);
   800     for(
int ii = 0; ii < targetCount; ++ii)
   809         if (targetCount < maxTargetCount)
   817                 chTarget->Append(targetNames[0]);
   822                 chTarget->Append(strAllProjectFiles);
   823                 chTarget->Append(targetNames[selection]);
 
void OnActivate(wxActivateEvent &event)
int GetOrigin() const override
bool GetAutoWrapSearch() const override
bool GetMultiLine() const override
ConfigManager * GetConfigManager(const wxString &name_space) const
int ReadInt(const wxString &name, int defaultVal=0)
static Manager * Get()
Use Manager::Get() to get a pointer to its instance Manager::Get() is guaranteed to never return an i...
void OnLimitToChange(wxCommandEvent &event)
void OnBrowsePath(wxCommandEvent &event)
void SaveComboValues(wxComboBox *combo, const wxString &configKey)
virtual int GetSelection() const
virtual wxString GetString(unsigned int n) const
bool GetMatchWord() const override
bool GetStartWord() const override
bool ReadBool(const wxString &name, bool defaultVal=false)
DLLIMPORT wxString ChooseDirectory(wxWindow *parent, const wxString &message=_("Select directory"), const wxString &initialPath=_T(""), const wxString &basePath=_T(""), bool askToMakeRelative=false, bool showCreateDirButton=false)
int Index(const wxString &sz, bool bCase=true, bool bFromEnd=false) const
bool GetStartFile() const override
virtual bool IsItemEnabled(unsigned int n) const
bool GetFixEOLs() const override
wxString GetReplaceString() const override
bool GetRecursive() const override
void OnSelectTarget(wxCommandEvent &event)
bool GetRegEx() const override
bool GetDeleteOldSearches() const override
EditorManager * GetEditorManager() const
void OnMultiChange(wxCommandEvent &event)
void OnScopeChange(wxCommandEvent &event)
void UnSet(const wxString &name)
virtual void SetSelection(int n)
ProjectManager * GetProjectManager() const
Functions returning pointers to the respective sub-manager instances. 
void Write(const wxString &name, const wxString &value, bool ignoreEmpty=false)
Represents a Code::Blocks project. 
const wxString & GetActiveBuildTarget() const
bool GetFindUsesSelectedText() const override
virtual bool Enable(unsigned int n, bool enable=true)
virtual const wxString & GetTitle() const
Read the target's title. 
bool Exists(const wxString &name)
void OnReplaceChange(wxNotebookEvent &event)
cbProject * GetActiveProject()
Retrieve the active project. 
wxString Read(const wxString &key, const wxString &defaultVal=wxEmptyString)
virtual wxString GetBasePath() const
Read the target's base path, e.g. if GetFilename() returns "/usr/local/bin/xxx", base path will retur...
bool m_findReplaceInFilesActive
wxString GetSearchMask() const override
wxString GetSearchPath() const override
const wxString & _(const wxString &string)
cbEditor * GetBuiltinEditor(EditorBase *eb)
int GetBuildTargetsCount()
ProjectBuildTarget * GetBuildTarget(int index)
Access a build target. 
void OnSearchProject(wxCommandEvent &event)
bool GetMatchCase() const override
void OnDeferredFocus(wxCommandEvent &event)
The entry point singleton for working with projects. 
bool IsFindInFiles() const override
~FindReplaceDlg() override
wxString GetFindString() const override
void OnRegEx(wxCommandEvent &event)
int GetTarget() const override
size_t Add(const wxString &str, size_t copies=1)
Simple iterator that uses wxArrayString as data source. 
static wxXmlResource * Get()
Simple incremental select dialog that shows a single column and doesn't have much ui elements...
ProjectsArray * GetProjects()
Retrieve an array of all the opened projects. 
int GetScope() const override
int GetDirection() const override
virtual bool GetValue() const
bool GetSortSearchResult() const override
int GetProject() const override
void FillComboWithLastValues(wxComboBox *combo, const wxString &configKey)
virtual void SetSelection(int n)
bool GetHidden() const override
virtual void SetValue(bool state)
virtual int GetSelection() const
wxObject * LoadObject(wxWindow *parent, const wxString &name, const wxString &classname)
virtual int FindString(const wxString &s, bool bCase=false) const