Added LoadFile and SaveFile methods
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -2161,6 +2161,12 @@ public:
|
||||
bool GetLastKeydownProcessed() { return m_lastKeyDownConsumed; }
|
||||
void SetLastKeydownProcessed(bool val) { m_lastKeyDownConsumed = val; }
|
||||
|
||||
// Write the contents of the editor to filename
|
||||
bool SaveFile(const wxString& filename);
|
||||
|
||||
// Load the contents of filename into the editor
|
||||
bool LoadFile(const wxString& filename);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/file.h>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -2075,6 +2076,45 @@ 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
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/file.h>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -307,6 +308,45 @@ 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
|
||||
|
@@ -193,6 +193,12 @@ public:
|
||||
bool GetLastKeydownProcessed() { return m_lastKeyDownConsumed; }
|
||||
void SetLastKeydownProcessed(bool val) { m_lastKeyDownConsumed = val; }
|
||||
|
||||
// Write the contents of the editor to filename
|
||||
bool SaveFile(const wxString& filename);
|
||||
|
||||
// Load the contents of filename into the editor
|
||||
bool LoadFile(const wxString& filename);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@@ -2161,6 +2161,12 @@ public:
|
||||
bool GetLastKeydownProcessed() { return m_lastKeyDownConsumed; }
|
||||
void SetLastKeydownProcessed(bool val) { m_lastKeyDownConsumed = val; }
|
||||
|
||||
// Write the contents of the editor to filename
|
||||
bool SaveFile(const wxString& filename);
|
||||
|
||||
// Load the contents of filename into the editor
|
||||
bool LoadFile(const wxString& filename);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/file.h>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -2075,6 +2076,45 @@ 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
|
||||
|
@@ -24,6 +24,7 @@
|
||||
#include <wx/tokenzr.h>
|
||||
#include <wx/mstream.h>
|
||||
#include <wx/image.h>
|
||||
#include <wx/file.h>
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
@@ -307,6 +308,45 @@ 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
|
||||
|
@@ -193,6 +193,12 @@ public:
|
||||
bool GetLastKeydownProcessed() { return m_lastKeyDownConsumed; }
|
||||
void SetLastKeydownProcessed(bool val) { m_lastKeyDownConsumed = val; }
|
||||
|
||||
// Write the contents of the editor to filename
|
||||
bool SaveFile(const wxString& filename);
|
||||
|
||||
// Load the contents of filename into the editor
|
||||
bool LoadFile(const wxString& filename);
|
||||
|
||||
|
||||
//----------------------------------------------------------------------
|
||||
|
||||
|
Reference in New Issue
Block a user