implemented IsModified() and DiscardEdits()
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@23291 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
6841d412ae
commit
1fa29bdc25
@ -28,16 +28,18 @@ class WXDLLEXPORT wxTextCtrl: public wxTextCtrlBase
|
|||||||
public:
|
public:
|
||||||
// creation
|
// creation
|
||||||
// --------
|
// --------
|
||||||
wxTextCtrl();
|
wxTextCtrl() { Init(); }
|
||||||
~wxTextCtrl();
|
~wxTextCtrl();
|
||||||
inline wxTextCtrl(wxWindow *parent, wxWindowID id,
|
wxTextCtrl(wxWindow *parent, wxWindowID id,
|
||||||
const wxString& value = wxEmptyString,
|
const wxString& value = wxEmptyString,
|
||||||
const wxPoint& pos = wxDefaultPosition,
|
const wxPoint& pos = wxDefaultPosition,
|
||||||
const wxSize& size = wxDefaultSize, long style = 0,
|
const wxSize& size = wxDefaultSize, long style = 0,
|
||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString& name = wxTextCtrlNameStr)
|
const wxString& name = wxTextCtrlNameStr)
|
||||||
{
|
{
|
||||||
Create(parent, id, value, pos, size, style, validator, name);
|
Init();
|
||||||
|
|
||||||
|
Create(parent, id, value, pos, size, style, validator, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Create(wxWindow *parent, wxWindowID id,
|
bool Create(wxWindow *parent, wxWindowID id,
|
||||||
@ -157,9 +159,16 @@ public:
|
|||||||
virtual bool Show(bool show = TRUE) ;
|
virtual bool Show(bool show = TRUE) ;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
// common part of all ctors
|
||||||
|
void Init();
|
||||||
|
|
||||||
virtual wxSize DoGetBestSize() const;
|
virtual wxSize DoGetBestSize() const;
|
||||||
|
|
||||||
bool m_editable ;
|
bool m_editable ;
|
||||||
|
|
||||||
|
// flag is set to true when the user edits the controls contents
|
||||||
|
bool m_dirty;
|
||||||
|
|
||||||
// one of the following objects is used for representation, the other one is NULL
|
// one of the following objects is used for representation, the other one is NULL
|
||||||
void* m_macTE ;
|
void* m_macTE ;
|
||||||
void* m_macTXN ;
|
void* m_macTXN ;
|
||||||
|
@ -637,13 +637,16 @@ END_EVENT_TABLE()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Text item
|
// Text item
|
||||||
wxTextCtrl::wxTextCtrl()
|
void wxTextCtrl::Init()
|
||||||
{
|
{
|
||||||
m_macTE = NULL ;
|
m_macTE = NULL ;
|
||||||
m_macTXN = NULL ;
|
m_macTXN = NULL ;
|
||||||
m_macTXNvars = NULL ;
|
m_macTXNvars = NULL ;
|
||||||
m_macUsesTXN = false ;
|
m_macUsesTXN = false ;
|
||||||
|
|
||||||
m_editable = true ;
|
m_editable = true ;
|
||||||
|
m_dirty = false;
|
||||||
|
|
||||||
m_maxLength = TE_UNLIMITED_LENGTH ;
|
m_maxLength = TE_UNLIMITED_LENGTH ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,7 +1305,7 @@ void wxTextCtrl::Clear()
|
|||||||
|
|
||||||
bool wxTextCtrl::IsModified() const
|
bool wxTextCtrl::IsModified() const
|
||||||
{
|
{
|
||||||
return TRUE;
|
return m_dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::IsEditable() const
|
bool wxTextCtrl::IsEditable() const
|
||||||
@ -1404,7 +1407,7 @@ bool wxTextCtrl::CanRedo() const
|
|||||||
// Makes 'unmodified'
|
// Makes 'unmodified'
|
||||||
void wxTextCtrl::DiscardEdits()
|
void wxTextCtrl::DiscardEdits()
|
||||||
{
|
{
|
||||||
// TODO
|
m_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxTextCtrl::GetNumberOfLines() const
|
int wxTextCtrl::GetNumberOfLines() const
|
||||||
@ -1531,6 +1534,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
// eat it
|
// eat it
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assume that any key not processed yet is going to modify the control
|
||||||
|
m_dirty = true;
|
||||||
|
|
||||||
if ( key == 'v' && event.MetaDown() )
|
if ( key == 'v' && event.MetaDown() )
|
||||||
{
|
{
|
||||||
if ( CanPaste() )
|
if ( CanPaste() )
|
||||||
|
@ -637,13 +637,16 @@ END_EVENT_TABLE()
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
// Text item
|
// Text item
|
||||||
wxTextCtrl::wxTextCtrl()
|
void wxTextCtrl::Init()
|
||||||
{
|
{
|
||||||
m_macTE = NULL ;
|
m_macTE = NULL ;
|
||||||
m_macTXN = NULL ;
|
m_macTXN = NULL ;
|
||||||
m_macTXNvars = NULL ;
|
m_macTXNvars = NULL ;
|
||||||
m_macUsesTXN = false ;
|
m_macUsesTXN = false ;
|
||||||
|
|
||||||
m_editable = true ;
|
m_editable = true ;
|
||||||
|
m_dirty = false;
|
||||||
|
|
||||||
m_maxLength = TE_UNLIMITED_LENGTH ;
|
m_maxLength = TE_UNLIMITED_LENGTH ;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1302,7 +1305,7 @@ void wxTextCtrl::Clear()
|
|||||||
|
|
||||||
bool wxTextCtrl::IsModified() const
|
bool wxTextCtrl::IsModified() const
|
||||||
{
|
{
|
||||||
return TRUE;
|
return m_dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxTextCtrl::IsEditable() const
|
bool wxTextCtrl::IsEditable() const
|
||||||
@ -1404,7 +1407,7 @@ bool wxTextCtrl::CanRedo() const
|
|||||||
// Makes 'unmodified'
|
// Makes 'unmodified'
|
||||||
void wxTextCtrl::DiscardEdits()
|
void wxTextCtrl::DiscardEdits()
|
||||||
{
|
{
|
||||||
// TODO
|
m_dirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxTextCtrl::GetNumberOfLines() const
|
int wxTextCtrl::GetNumberOfLines() const
|
||||||
@ -1531,6 +1534,10 @@ void wxTextCtrl::OnChar(wxKeyEvent& event)
|
|||||||
// eat it
|
// eat it
|
||||||
return ;
|
return ;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// assume that any key not processed yet is going to modify the control
|
||||||
|
m_dirty = true;
|
||||||
|
|
||||||
if ( key == 'v' && event.MetaDown() )
|
if ( key == 'v' && event.MetaDown() )
|
||||||
{
|
{
|
||||||
if ( CanPaste() )
|
if ( CanPaste() )
|
||||||
|
Loading…
Reference in New Issue
Block a user