+bool wxStyledTextCtrl::SaveFile(const wxString& filename)
+{
+ wxFile file(filename, wxFile::write);
+
+ if (!file.IsOpened())
+ return false;
+
+ bool success = file.Write(GetText(), *wxConvCurrent);
+
+ if (success)
+ SetSavePoint();
+
+ return success;
+}
+
+bool wxStyledTextCtrl::LoadFile(const wxString& filename)
+{
+ bool success = false;
+ wxFile file(filename, wxFile::read);
+
+ if (file.IsOpened())
+ {
+ wxString contents;
+ // get the file size (assume it is not huge file...)
+ ssize_t len = (ssize_t)file.Length();
+
+ if (len > 0)
+ {
+#if wxUSE_UNICODE
+ wxMemoryBuffer buffer(len+1);
+ success = (file.Read(buffer.GetData(), len) == len);
+ if (success) {
+ ((char*)buffer.GetData())[len] = 0;
+ contents = wxString(buffer, *wxConvCurrent, len);
+ }
+#else
+ wxString buffer;
+ success = (file.Read(wxStringBuffer(buffer, len), len) == len);
+ contents = buffer;
+#endif
+ }
+ else
+ {
+ if (len == 0)
+ success = true; // empty file is ok
+ else
+ success = false; // len == wxInvalidOffset
+ }
+
+ if (success)
+ {
+ SetText(contents);
+ EmptyUndoBuffer();
+ SetSavePoint();
+ }
+ }
+
+ return success;
+}
+
+
+#if wxUSE_DRAG_AND_DROP
+wxDragResult wxStyledTextCtrl::DoDragOver(wxCoord x, wxCoord y, wxDragResult def) {
+ return m_swx->DoDragOver(x, y, def);
+}
+
+
+bool wxStyledTextCtrl::DoDropText(long x, long y, const wxString& data) {
+ return m_swx->DoDropText(x, y, data);
+}
+#endif
+
+
+void wxStyledTextCtrl::SetUseAntiAliasing(bool useAA) {
+ m_swx->SetUseAntiAliasing(useAA);
+}
+
+bool wxStyledTextCtrl::GetUseAntiAliasing() {
+ return m_swx->GetUseAntiAliasing();
+}
+
+
+
+
+
+void wxStyledTextCtrl::AddTextRaw(const char* text)
+{
+ SendMsg(SCI_ADDTEXT, strlen(text), (long)text);
+}
+
+void wxStyledTextCtrl::InsertTextRaw(int pos, const char* text)
+{
+ SendMsg(SCI_INSERTTEXT, pos, (long)text);
+}
+
+wxCharBuffer wxStyledTextCtrl::GetCurLineRaw(int* linePos)
+{
+ int len = LineLength(GetCurrentLine());
+ if (!len) {
+ if (linePos) *linePos = 0;
+ wxCharBuffer empty;
+ return empty;
+ }
+
+ wxCharBuffer buf(len);
+ int pos = SendMsg(SCI_GETCURLINE, len, (long)buf.data());
+ if (linePos) *linePos = pos;
+ return buf;
+}
+
+wxCharBuffer wxStyledTextCtrl::GetLineRaw(int line)
+{
+ int len = LineLength(line);
+ if (!len) {
+ wxCharBuffer empty;
+ return empty;
+ }
+
+ wxCharBuffer buf(len);
+ SendMsg(SCI_GETLINE, line, (long)buf.data());
+ return buf;
+}
+
+wxCharBuffer wxStyledTextCtrl::GetSelectedTextRaw()
+{
+ int start;
+ int end;
+
+ GetSelection(&start, &end);
+ int len = end - start;
+ if (!len) {
+ wxCharBuffer empty;
+ return empty;
+ }
+
+ wxCharBuffer buf(len);
+ SendMsg(SCI_GETSELTEXT, 0, (long)buf.data());
+ return buf;
+}
+
+wxCharBuffer wxStyledTextCtrl::GetTextRangeRaw(int startPos, int endPos)
+{
+ if (endPos < startPos) {
+ int temp = startPos;
+ startPos = endPos;
+ endPos = temp;
+ }
+ int len = endPos - startPos;
+ if (!len) {
+ wxCharBuffer empty;
+ return empty;
+ }
+
+ wxCharBuffer buf(len);
+ TextRange tr;
+ tr.lpstrText = buf.data();
+ tr.chrg.cpMin = startPos;
+ tr.chrg.cpMax = endPos;
+ SendMsg(SCI_GETTEXTRANGE, 0, (long)&tr);
+ return buf;
+}
+
+void wxStyledTextCtrl::SetTextRaw(const char* text)
+{
+ SendMsg(SCI_SETTEXT, 0, (long)text);
+}
+
+wxCharBuffer wxStyledTextCtrl::GetTextRaw()
+{
+ int len = GetTextLength();
+ wxCharBuffer buf(len);
+ SendMsg(SCI_GETTEXT, len, (long)buf.data());
+ return buf;
+}
+
+void wxStyledTextCtrl::AppendTextRaw(const char* text)
+{
+ SendMsg(SCI_APPENDTEXT, strlen(text), (long)text);
+}
+
+
+
+