40 const wxPoint& aPosition,
const wxSize& aSize ) :
44 m_htmlWindow->SetLayoutDirection( wxLayout_LeftToRight );
48 wxBoxSizer* searchSizer =
new wxBoxSizer( wxHORIZONTAL );
50 m_searchCtrl =
new wxTextCtrl(
m_searchPanel, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
51 m_prevBtn =
new wxButton(
m_searchPanel, wxID_ANY, wxS(
"∧" ), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE );
52 m_nextBtn =
new wxButton(
m_searchPanel, wxID_ANY, wxS(
"∨" ), wxDefaultPosition, wxDefaultSize, wxBORDER_NONE );
55 m_prevBtn->SetMinSize( wxSize( 25, -1 ) );
56 m_nextBtn->SetMinSize( wxSize( 25, -1 ) );
61 searchSizer->Add(
m_matchCount, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
62 searchSizer->Add(
m_searchCtrl, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT, 5 );
63 searchSizer->Add(
m_prevBtn, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT, 2 );
64 searchSizer->Add(
m_nextBtn, 0, wxALIGN_CENTER_VERTICAL );
67 GetSizer()->Insert( 0,
m_searchPanel, 0, wxALIGN_RIGHT|wxTOP|wxRIGHT, 5 );
75 if( aSize != wxDefaultSize )
84 Bind( wxEVT_SYS_COLOUR_CHANGED,
200 if( aEvent.GetKeyCode() == WXK_ESCAPE )
205 else if( aEvent.GetKeyCode() == WXK_RETURN || aEvent.GetKeyCode() == WXK_NUMPAD_ENTER )
211 else if( aEvent.GetKeyCode() == WXK_BACK )
223 else if( !aEvent.HasModifiers() && wxIsprint( aEvent.GetUnicodeKey() ) )
225 m_searchCtrl->AppendText( wxString( (wxChar) aEvent.GetUnicodeKey() ) );
229 else if( !aEvent.HasModifiers() && wxIsprint( aEvent.GetUnicodeKey() ) )
232 m_searchCtrl->SetValue( wxString( (wxChar) aEvent.GetUnicodeKey() ) );
238 if( aEvent.GetKeyCode() == WXK_ESCAPE )
240 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_OK ) );
243 else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() ==
'A' )
248 else if( aEvent.GetModifiers() == wxMOD_CONTROL && aEvent.GetKeyCode() ==
'C' )
252 if( wxTheClipboard->Open() )
254 wxTheClipboard->SetData(
new wxTextDataObject(
m_htmlWindow->SelectionToText() ) );
255 wxTheClipboard->Flush();
256 wxTheClipboard->Close();
330 wxString termLower = term.Lower();
332 bool insideTag =
false;
355 wxString candidate =
m_originalSource.Mid( pos, termLower.length() ).Lower();
356 if( candidate == termLower )
359 bool validMatch =
true;
360 for(
size_t i = 0; i < termLower.length(); i++ )
394 for(
size_t i = 0; i <
m_matchPos.size(); ++i )
401 wxString escapedMatchStr = matchStr;
402 escapedMatchStr.Replace( wxS(
"&" ), wxS(
"&" ) );
403 escapedMatchStr.Replace( wxS(
"<" ), wxS(
"<" ) );
404 escapedMatchStr.Replace( wxS(
">" ), wxS(
">" ) );
405 escapedMatchStr.Replace( wxS(
"\"" ), wxS(
""" ) );
410 wxString anchorName = wxString::Format( wxS(
"kicad_search_%d" ),
m_currentMatch );
411 out += wxString::Format( wxS(
"<a name=\"%s\"></a><span style=\"background-color:#DDAAFF;\">%s</span>" ),
412 anchorName, escapedMatchStr );
416 out += wxString::Format( wxS(
"<span style=\"background-color:#FFFFAA;\">%s</span>" ), escapedMatchStr );
419 start = idx + term.length();
433 wxString anchorName = wxString::Format( wxS(
"kicad_search_%d" ),
m_currentMatch );
442 if( totalLength > 0 )
445 double ratio = (double)matchPos / (
double)totalLength;
446 int scrollPos = (int)(ratio *
m_htmlWindow->GetScrollRange( wxVERTICAL ));
HTML_WINDOW * m_htmlWindow
wxStdDialogButtonSizer * m_sdbSizer1
DIALOG_DISPLAY_HTML_TEXT_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=wxEmptyString, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void wxStringSplit(const wxString &aText, wxArrayString &aStrings, wxChar aSplitter)
Split aString to a string list separated at aSplitter.