X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/2b5f62a0b2db198609b45dec622a018dae37008e..b478e7a71c67064e6a87abf476574c1331c4c906:/contrib/src/stc/stc.cpp.in?ds=inline diff --git a/contrib/src/stc/stc.cpp.in b/contrib/src/stc/stc.cpp.in index 0ab9afdc5e..8952840b6c 100644 --- a/contrib/src/stc/stc.cpp.in +++ b/contrib/src/stc/stc.cpp.in @@ -20,7 +20,11 @@ #include "wx/stc/stc.h" #include "ScintillaWX.h" +#include #include +#include +#include +#include //---------------------------------------------------------------------- @@ -82,6 +86,10 @@ DEFINE_EVENT_TYPE( wxEVT_STC_START_DRAG ) DEFINE_EVENT_TYPE( wxEVT_STC_DRAG_OVER ) DEFINE_EVENT_TYPE( wxEVT_STC_DO_DROP ) DEFINE_EVENT_TYPE( wxEVT_STC_ZOOM ) +DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_CLICK ) +DEFINE_EVENT_TYPE( wxEVT_STC_HOTSPOT_DCLICK ) +DEFINE_EVENT_TYPE( wxEVT_STC_CALLTIP_CLICK ) + BEGIN_EVENT_TABLE(wxStyledTextCtrl, wxControl) @@ -300,15 +308,52 @@ void wxStyledTextCtrl::ScrollToColumn(int column) { } +bool wxStyledTextCtrl::SaveFile(const wxString& filename) +{ + wxFile file(filename, wxFile::write); + + if (!file.IsOpened()) + return FALSE; + + bool success = file.Write(GetText()); + + if (success) + SetSavePoint(); + + return success; +} + +bool wxStyledTextCtrl::LoadFile(const wxString& filename) +{ + wxFile file(filename, wxFile::read); + + if (!file.IsOpened()) + return FALSE; + + wxString contents; + off_t len = file.Length(); + + wxChar *buf = contents.GetWriteBuf(len); + bool success = (file.Read(buf, len) == len); + contents.UngetWriteBuf(); + + if (success) + { + SetText(contents); + EmptyUndoBuffer(); + SetSavePoint(); + } + + return success; +} + //---------------------------------------------------------------------- // Event handlers void wxStyledTextCtrl::OnPaint(wxPaintEvent& evt) { wxPaintDC dc(this); - wxRegion region = GetUpdateRegion(); - - m_swx->DoPaint(&dc, region.GetBox()); + m_swx->DoPaint(&dc, GetUpdateRegion().GetBox()); } void wxStyledTextCtrl::OnScrollWin(wxScrollWinEvent& evt) { @@ -574,6 +619,18 @@ void wxStyledTextCtrl::NotifyParent(SCNotification* _scn) { evt.SetEventType(wxEVT_STC_ZOOM); break; + case SCN_HOTSPOTCLICK: + evt.SetEventType(wxEVT_STC_HOTSPOT_CLICK); + break; + + case SCN_HOTSPOTDOUBLECLICK: + evt.SetEventType(wxEVT_STC_HOTSPOT_DCLICK); + break; + + case SCN_CALLTIPCLICK: + evt.SetEventType(wxEVT_STC_CALLTIP_CLICK); + break; + default: return; }