Added DoLoadFile, DoSaveFile to wxTextCtrlBase

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41410 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2006-09-24 11:40:33 +00:00
parent 3bb918c097
commit 3306aec124
16 changed files with 102 additions and 85 deletions

View File

@@ -56,21 +56,27 @@ Major changes in 2.7 release
All:
- Added wxDir::FindFirst() (Francesco Montorsi)
- Added wxPlatformInfo class (Francesco Montorsi)
- Added wxLocale::IsAvailable() (Creighton)
- Added wxDir::FindFirst() (Francesco Montorsi).
- Added wxPlatformInfo class (Francesco Montorsi).
- Added wxLocale::IsAvailable() (Creighton).
All (GUI):
- Support for right-to-left text layout
(started by Diaa Sami during Google Summer of Code, with a lot of help from
Tim Kosse and others)
- Added wxID_PAGE_SETUP standard id
- Added wxSize::IncBy() and DecBy() methods
- Support for right-to-left text layout (started by Diaa Sami during Google Summer of
Code, with a lot of help from Tim Kosse and others).
- Added wxID_PAGE_SETUP standard id.
- Added wxSize::IncBy() and DecBy() methods.
- Added file type parameter to wxTextCtrl::LoadFile, wxTextCtrl::SaveFile for
consistency with wxRichTextCtrl.
- wxRichTextCtrl: fixed range out-by-one bug to be consistent with wxTextCtrl API,
fixed some attribute bugs and added wxRichTextStyleComboCtrl.
wxMSW:
- Implemented wxComboBox::SetEditable()
- Implemented wxComboBox::SetEditable().
- Fixed a bug whereby static controls didn't use the correct text colour if the
parent's background colour had been set (most noticeable when switching to a
high-contrast theme).
wxMac:
@@ -79,8 +85,8 @@ wxMac:
wxGTK:
- Automatically use stock items for the menu items with standard ids
- Setting cursor now works for all controls
- Automatically use stock items for menu items with standard ids.
- Setting cursor now works for all controls.
2.7.0
@@ -131,14 +137,14 @@ All:
Previously, only the buffer would be returned, even if more data was requested.
- Added wxPowerEvent (currently MSW-only).
- Make wx-config compatible with Bourne shells.
- Fixed wxDb::Open(wxDbConnectInf) when using connection string (Hellwolf Misty)
- Fixed crash in wxDb::Open() in Unicode build (Massimiliano Marretta)
- Fixed wxTimeSpan::Format() for negative time spans
- Optionally count repeating wxLog messages instead of logging all (Lauri Nurmi)
- Fixed wxDb::Open(wxDbConnectInf) when using connection string (Hellwolf Misty).
- Fixed crash in wxDb::Open() in Unicode build (Massimiliano Marretta).
- Fixed wxTimeSpan::Format() for negative time spans.
- Optionally count repeating wxLog messages instead of logging all (Lauri Nurmi).
All (GUI):
- New AUI (Advanced User Interface) library for docking windows and much more
- New AUI (Advanced User Interface) library for docking windows and much more.
- Added wxComboCtrl and wxOwnerDrawnComboBox (Jaakko Salli).
- Added wxTreebook (uses a wxTreeCtrl to control pages).
- Added wxColour/Dir/File/Font/PickerCtrls (Francesco Montorsi).
@@ -213,8 +219,8 @@ All (GUI):
- wxNB_HITTEST_* flags renamed to wxBK_HITTEST_* to serve all book controls.
- Added wxTopLevelWindow::SetTransparent and CanSetTransparent, with
implementations (so far) for wxMSW and wxMac.
- Allow customizing individual grid lines appearance (S<>ren Lassen)
- Fixed middle click events generation in generic wxTreeCtrl (Olly Betts)
- Allow customizing individual grid lines appearance (S<>ren Lassen).
- Fixed middle click events generation in generic wxTreeCtrl (Olly Betts).
- Added wxEVT_MOUSE_CAPTURE_LOST event that must be handled by all windows
that CaptureMouse() is called on.
@@ -225,7 +231,7 @@ wxMSW:
- Switching page of a hidden notebook doesn't lose focus (Jamie Gadd).
- Removed wxImageList *GetImageList(int) const.
- Fixed MDI context menu problem.
- Removed __WIN95__ define
- Removed __WIN95__ define.
- Create msw/rcdefs.h in setup.h's directory, which can be included by
resource files. It containts platform/compiler specific defines (such as
target cpu) which can be used in #ifs in .rc files.

View File

@@ -652,7 +652,7 @@ otherwise.
\membersection{wxTextCtrl::LoadFile}\label{wxtextctrlloadfile}
\func{bool}{LoadFile}{\param{const wxString\& }{ filename}}
\func{bool}{LoadFile}{\param{const wxString\& }{ filename}, \param{int }{fileType = wxTEXT\_TYPE\_ANY}}
Loads and displays the named file, if it exists.
@@ -660,6 +660,8 @@ Loads and displays the named file, if it exists.
\docparam{filename}{The filename of the file to load.}
\docparam{fileType}{The type of file to load. This is currently ignored in wxTextCtrl.}
\wxheading{Return value}
{\tt true} if successful, {\tt false} otherwise.
@@ -804,7 +806,7 @@ the character at the last position with the given text.
\membersection{wxTextCtrl::SaveFile}\label{wxtextctrlsavefile}
\func{bool}{SaveFile}{\param{const wxString\& }{ filename}}
\func{bool}{SaveFile}{\param{const wxString\& }{ filename}, \param{int }{fileType = wxTEXT\_TYPE\_ANY}}
Saves the contents of the control in a text file.
@@ -812,6 +814,8 @@ Saves the contents of the control in a text file.
\docparam{filename}{The name of the file in which to save the text.}
\docparam{fileType}{The type of file to save. This is currently ignored in wxTextCtrl.}
\wxheading{Return value}
{\tt true} if the operation was successful, {\tt false} otherwise.

View File

@@ -81,10 +81,6 @@ public:
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
// load the controls contents from the file
virtual bool LoadFile(const wxString& file);
virtual bool LoadFile(const wxString& file, int WXUNUSED(fileType)) { return LoadFile(file); }
// sets/clears the dirty flag
virtual void MarkDirty();
virtual void DiscardEdits();

View File

@@ -69,9 +69,6 @@ public:
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
// load the controls contents from the file
virtual bool LoadFile(const wxString& file);
// sets/clears the dirty flag
virtual void MarkDirty();
virtual void DiscardEdits();

View File

@@ -66,9 +66,8 @@ public:
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
// load the controls contents from the file
virtual bool LoadFile(const wxString& file);
virtual bool LoadFile(const wxString& file, int WXUNUSED(fileType)) { return LoadFile(file); }
// load the control's contents from the file
virtual bool DoLoadFile(const wxString& file, int fileType);
// clears the dirty flag
virtual void MarkDirty();

View File

@@ -72,7 +72,7 @@ public:
,long lTo
);
virtual bool LoadFile(const wxString& rsFile);
virtual bool DoLoadFile(const wxString& rsFile, int fileType);
virtual void MarkDirty();
virtual void DiscardEdits(void);

View File

@@ -64,8 +64,8 @@ public:
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
// load the controls contents from the file
virtual bool LoadFile(const wxString& file);
// load the control's contents from the file
virtual bool DoLoadFile(const wxString& file, int fileType);
// clears the dirty flag
virtual void MarkDirty();

View File

@@ -157,11 +157,14 @@ public:
virtual void Replace(long from, long to, const wxString& value);
virtual void Remove(long from, long to);
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
bool LoadFile(const wxString& file, int fileType = wxRICHTEXT_TYPE_ANY);
bool SaveFile(const wxString& file = wxEmptyString, int fileType = wxRICHTEXT_TYPE_ANY);
#endif
// load/save the controls contents from/to the file
virtual bool LoadFile(const wxString& file) { return LoadFile(file, wxRICHTEXT_TYPE_ANY); }
virtual bool LoadFile(const wxString& file, int type);
virtual bool SaveFile(const wxString& file = wxEmptyString) { return SaveFile(file, wxRICHTEXT_TYPE_ANY); }
virtual bool SaveFile(const wxString& file, int type);
virtual bool DoLoadFile(const wxString& file, int fileType);
virtual bool DoSaveFile(const wxString& file = wxEmptyString, int fileType = wxRICHTEXT_TYPE_ANY);
// sets/clears the dirty flag
virtual void MarkDirty();
@@ -735,8 +738,10 @@ private:
/// Text buffer
wxRichTextBuffer m_buffer;
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
/// Filename
wxString m_filename;
#endif
wxMenu* m_contextMenu;

View File

@@ -128,6 +128,12 @@ const wxTextCoord wxInvalidTextCoord = -2;
#define wxTE_CAPITALIZE 0
#endif
// ----------------------------------------------------------------------------
// wxTextCtrl file types
// ----------------------------------------------------------------------------
#define wxTEXT_TYPE_ANY 0
// ----------------------------------------------------------------------------
// wxTextCtrl::HitTest return values
// ----------------------------------------------------------------------------
@@ -320,11 +326,13 @@ public:
virtual void Replace(long from, long to, const wxString& value) = 0;
virtual void Remove(long from, long to) = 0;
// load/save the controls contents from/to the file
virtual bool LoadFile(const wxString& file);
virtual bool LoadFile(const wxString& file, int WXUNUSED(fileType)) { return LoadFile(file); }
virtual bool SaveFile(const wxString& file = wxEmptyString);
virtual bool SaveFile(const wxString& file, int WXUNUSED(fileType)) { return SaveFile(file); }
// load/save the control's contents from/to a file
bool LoadFile(const wxString& file, int fileType = wxTEXT_TYPE_ANY) { return DoLoadFile(file, fileType); }
bool SaveFile(const wxString& file = wxEmptyString, int fileType = wxTEXT_TYPE_ANY);
// implementation for loading/saving
virtual bool DoLoadFile(const wxString& file, int fileType);
virtual bool DoSaveFile(const wxString& file, int fileType);
// sets/clears the dirty flag
virtual void MarkDirty() = 0;

View File

@@ -196,7 +196,7 @@ const wxTextAttr& wxTextCtrlBase::GetDefaultStyle() const
// file IO functions
// ----------------------------------------------------------------------------
bool wxTextCtrlBase::LoadFile(const wxString& filename)
bool wxTextCtrlBase::DoLoadFile(const wxString& filename, int WXUNUSED(fileType))
{
#if wxUSE_FFILE
wxFFile file(filename);
@@ -221,7 +221,7 @@ bool wxTextCtrlBase::LoadFile(const wxString& filename)
return false;
}
bool wxTextCtrlBase::SaveFile(const wxString& filename)
bool wxTextCtrlBase::SaveFile(const wxString& filename, int fileType)
{
wxString filenameToUse = filename.empty() ? m_filename : filename;
if ( filenameToUse.empty() )
@@ -232,16 +232,21 @@ bool wxTextCtrlBase::SaveFile(const wxString& filename)
return false;
}
return DoSaveFile(filenameToUse, fileType);
}
bool wxTextCtrlBase::DoSaveFile(const wxString& filename, int WXUNUSED(fileType))
{
#if wxUSE_FFILE
wxFFile file(filenameToUse, _T("w"));
wxFFile file(filename, _T("w"));
if ( file.IsOpened() && file.Write(GetValue()) )
{
// if it worked, save for future calls
m_filename = filename;
// it's not modified any longer
DiscardEdits();
// if it worked, save for future calls
m_filename = filenameToUse;
return true;
}
#endif // wxUSE_FFILE

View File

@@ -705,11 +705,6 @@ void wxTextCtrl::SetSelection(long from, long to)
GetPeer()->SetSelection( from , to ) ;
}
bool wxTextCtrl::LoadFile(const wxString& file)
{
return wxTextCtrlBase::LoadFile( file );
}
void wxTextCtrl::WriteText(const wxString& str)
{
// TODO: this MPRemoting will be moved into a remoting peer proxy for any command

View File

@@ -1275,16 +1275,6 @@ void wxTextCtrl::SetSelection(long from, long to)
}
}
bool wxTextCtrl::LoadFile(const wxString& file)
{
if ( wxTextCtrlBase::LoadFile(file) )
{
return true;
}
return false;
}
void wxTextCtrl::WriteText(const wxString& str)
{
wxString st = str ;

View File

@@ -1405,9 +1405,9 @@ void wxTextCtrl::DoSetSelection(long from, long to, bool scrollCaret)
// Working with files
// ----------------------------------------------------------------------------
bool wxTextCtrl::LoadFile(const wxString& file)
bool wxTextCtrl::DoLoadFile(const wxString& file, int fileType)
{
if ( wxTextCtrlBase::LoadFile(file) )
if ( wxTextCtrlBase::DoLoadFile(file, fileType) )
{
// update the size limit if needed
AdjustSpaceLimit();

View File

@@ -680,10 +680,11 @@ void wxTextCtrl::SetSelection(
} // end of wxTextCtrl::SetSelection
bool wxTextCtrl::LoadFile(
const wxString& rsFile
const wxString& rsFile,
int fileType
)
{
if ( wxTextCtrlBase::LoadFile(rsFile) )
if ( wxTextCtrlBase::DoLoadFile(rsFile, fileType) )
{
//
// Update the size limit if needed
@@ -692,7 +693,7 @@ bool wxTextCtrl::LoadFile(
return true;
}
return false;
} // end of wxTextCtrl::LoadFile
} // end of wxTextCtrl::DoLoadFile
bool wxTextCtrl::IsModified() const
{

View File

@@ -390,7 +390,7 @@ void wxTextCtrl::DoSetSelection(long from, long to, bool scrollCaret)
// Working with files
// ----------------------------------------------------------------------------
bool wxTextCtrl::LoadFile(const wxString& file)
bool wxTextCtrl::DoLoadFile(const wxString& file, int fileType)
{
return false;
}

View File

@@ -1525,9 +1525,30 @@ bool wxRichTextCtrl::RecreateBuffer(const wxSize& size)
// file IO functions
// ----------------------------------------------------------------------------
bool wxRichTextCtrl::LoadFile(const wxString& filename, int type)
#if !wxRICHTEXT_DERIVES_FROM_TEXTCTRLBASE
bool wxRichTextCtrl::LoadFile(const wxString& filename, int fileType)
{
bool success = GetBuffer().LoadFile(filename, type);
return DoLoadFile(filename, fileType);
}
bool wxRichTextCtrl::SaveFile(const wxString& filename, int fileType)
{
wxString filenameToUse = filename.empty() ? m_filename : filename;
if ( filenameToUse.empty() )
{
// what kind of message to give? is it an error or a program bug?
wxLogDebug(wxT("Can't save textctrl to file without filename."));
return false;
}
return DoSaveFile(filenameToUse, fileType);
}
#endif
bool wxRichTextCtrl::DoLoadFile(const wxString& filename, int fileType)
{
bool success = GetBuffer().LoadFile(filename, fileType);
if (success)
m_filename = filename;
@@ -1549,25 +1570,15 @@ bool wxRichTextCtrl::LoadFile(const wxString& filename, int type)
}
}
bool wxRichTextCtrl::SaveFile(const wxString& filename, int type)
bool wxRichTextCtrl::DoSaveFile(const wxString& filename, int fileType)
{
wxString filenameToUse = filename.empty() ? m_filename : filename;
if ( filenameToUse.empty() )
if (GetBuffer().SaveFile(filename, fileType))
{
// what kind of message to give? is it an error or a program bug?
wxLogDebug(wxT("Can't save textctrl to file without filename."));
return false;
}
if (GetBuffer().SaveFile(filenameToUse, type))
{
m_filename = filenameToUse;
m_filename = filename;
DiscardEdits();
return true;
}
wxLogError(_("The text couldn't be saved."));