32
32
//(*IdInit(regex_dialog)
35
BEGIN_EVENT_TABLE(RegExDlg,wxDialog)
35
BEGIN_EVENT_TABLE(RegExDlg,wxScrollingDialog)
36
36
EVT_INIT_DIALOG(RegExDlg::OnInit)
37
37
EVT_UPDATE_UI(-1, RegExDlg::OnUpdateUI)
40
RegExDlg::VisibleDialogs RegExDlg::m_visible_dialogs;
40
42
RegExDlg::RegExDlg(wxWindow* parent,wxWindowID id)
42
44
//(*Initialize(regex_dialog)
43
wxXmlResource::Get()->LoadObject(this,parent,_T("regex_dialog"),_T("wxDialog"));
45
wxXmlResource::Get()->LoadObject(this,parent,_T("regex_dialog"),_T("wxScrollingDialog"));
44
46
m_regex = (wxTextCtrl*)FindWindow(XRCID("ID_REGEX"));
45
47
m_quoted = (wxTextCtrl*)FindWindow(XRCID("ID_QUOTED"));
46
48
m_library = (wxChoice*)FindWindow(XRCID("ID_LIBRARY"));
65
m_text->MoveAfterInTabOrder(m_quoted);
61
67
m_library->SetSelection(0);
62
68
m_output->SetBorders(0);
63
69
m_quoted->SetEditable(false);
71
m_visible_dialogs.insert(this);
66
74
RegExDlg::~RegExDlg()
78
void RegExDlg::OnClose(wxCloseEvent& event)
80
VisibleDialogs::iterator it = m_visible_dialogs.find(this);
81
if(it != m_visible_dialogs.end())
84
m_visible_dialogs.erase(it);
89
void RegExDlg::ReleaseAll()
91
for(VisibleDialogs::iterator it = m_visible_dialogs.begin(); it != m_visible_dialogs.end(); ++it)
93
m_visible_dialogs.clear();
97
@brief Makes the input string to be valid html string (replaces <,>,&," with <,>,&," respectively)
98
@param [inout] s - string that will be escaped
100
void cbEscapeHtml(wxString &s)
102
s.Replace(wxT("&"), wxT("&"));
103
s.Replace(wxT("<"), wxT("<"));
104
s.Replace(wxT(">"), wxT(">"));
105
s.Replace(wxT("\""), wxT("""));
71
108
void RegExDlg::OnUpdateUI(wxUpdateUIEvent& event)
73
110
static wxString regex;
74
111
static wxString text;
76
if(event.GetId() == XRCID("ID_NOCASE") || event.GetId() == XRCID("ID_NEWLINES"))
77
regex = _T("$^"); // bullshit
79
if(regex == m_regex->GetValue() && text == m_text->GetValue())
113
static bool newlines;
116
// if(event.GetId() == XRCID("ID_NOCASE") || event.GetId() == XRCID("ID_NEWLINES"))
117
// regex = _T("$^"); // bullshit
118
// all UI elements send events quite often (on linux on every mouse mouve, if the parent window
119
// has the focus, on windows even without any user action). So we can not use the event Id to force a new
120
// run of GetBuiltinMatches(), because every time the value of m_quoted and m_output gets upadeted a selection of text in m_quoted
121
// will be reset and therefore the user can not copy it's content (linux) and m_output jumps to the top, so that the user
122
// cannot scroll the text (windows and linux).
125
if( regex == m_regex->GetValue() &&
126
text == m_text->GetValue() &&
127
nocase == m_nocase->GetValue() &&
128
newlines == m_newlines->GetValue() &&
129
library == m_library->GetSelection())
82
134
regex = m_regex->GetValue();
83
135
text = m_text->GetValue();
136
nocase = m_nocase->GetValue();
137
newlines = m_newlines->GetValue();
138
library = m_library->GetSelection();
85
140
wxString tmp(regex);