#include "wx/stc/stc.h"
#include "ScintillaWX.h"
+#include <wx/wx.h>
#include <wx/tokenzr.h>
+#include <wx/mstream.h>
+#include <wx/image.h>
+#include <wx/file.h>
//----------------------------------------------------------------------
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)
}
+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) {
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;
}