]> git.saurik.com Git - wxWidgets.git/commitdiff
Added LoadFile and SaveFile methods
authorRobin Dunn <robin@alldunn.com>
Thu, 29 May 2003 23:50:21 +0000 (23:50 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 29 May 2003 23:50:21 +0000 (23:50 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@20762 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

contrib/include/wx/stc/stc.h
contrib/src/stc/stc.cpp
contrib/src/stc/stc.cpp.in
contrib/src/stc/stc.h.in
include/wx/stc/stc.h
src/stc/stc.cpp
src/stc/stc.cpp.in
src/stc/stc.h.in

index 41e36f3e8b3dacb4147c06589acb6ccb8c73c96e..193376418ff38fe0b6e30f768b03508949d06e34 100644 (file)
@@ -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);
+
 
 //----------------------------------------------------------------------
 
index c4a9d0c4e13027df6e96c10123eb1b6b193c0c6c..d4fbcec50ccceca291efb7d6197645da14722e82 100644 (file)
@@ -24,6 +24,7 @@
 #include <wx/tokenzr.h>
 #include <wx/mstream.h>
 #include <wx/image.h>
+#include <wx/file.h>
 
 
 //----------------------------------------------------------------------
@@ -474,7 +475,7 @@ void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp)
         buff[len] = 0;
         SendMsg(2049, markerNumber, (long)buff);
         delete [] buff;
-        
+
 }
 
 // Set a margin to be either numeric or symbolic.
@@ -857,7 +858,7 @@ void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
         buff[len] = 0;
         SendMsg(2405, type, (long)buff);
         delete [] buff;
-     
+
 }
 
 // Clear all the registered images.
@@ -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
index 66434747989357d29e48838b585aff223876d947..8952840b6c732e742f087cb9f10723cce0250b05 100644 (file)
@@ -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
index baeaf0d437f4b2d890740316668fe2e6ad9504f4..70addc7abbc965c0a1bf532eba0e4136b3904b8f 100644 (file)
@@ -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);
+
 
 //----------------------------------------------------------------------
 
index 41e36f3e8b3dacb4147c06589acb6ccb8c73c96e..193376418ff38fe0b6e30f768b03508949d06e34 100644 (file)
@@ -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);
+
 
 //----------------------------------------------------------------------
 
index c4a9d0c4e13027df6e96c10123eb1b6b193c0c6c..d4fbcec50ccceca291efb7d6197645da14722e82 100644 (file)
@@ -24,6 +24,7 @@
 #include <wx/tokenzr.h>
 #include <wx/mstream.h>
 #include <wx/image.h>
+#include <wx/file.h>
 
 
 //----------------------------------------------------------------------
@@ -474,7 +475,7 @@ void wxStyledTextCtrl::MarkerDefineBitmap(int markerNumber, const wxBitmap& bmp)
         buff[len] = 0;
         SendMsg(2049, markerNumber, (long)buff);
         delete [] buff;
-        
+
 }
 
 // Set a margin to be either numeric or symbolic.
@@ -857,7 +858,7 @@ void wxStyledTextCtrl::RegisterImage(int type, const wxBitmap& bmp) {
         buff[len] = 0;
         SendMsg(2405, type, (long)buff);
         delete [] buff;
-     
+
 }
 
 // Clear all the registered images.
@@ -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
index 66434747989357d29e48838b585aff223876d947..8952840b6c732e742f087cb9f10723cce0250b05 100644 (file)
@@ -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
index baeaf0d437f4b2d890740316668fe2e6ad9504f4..70addc7abbc965c0a1bf532eba0e4136b3904b8f 100644 (file)
@@ -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);
+
 
 //----------------------------------------------------------------------