added automatic growing of in-place wxTextCtrls for generic wxListCtrl and wxTreeCtrl

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@8574 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Václav Slavík 2000-10-17 22:14:35 +00:00
parent 7328394a2a
commit c13cace125
2 changed files with 34 additions and 0 deletions

View File

@ -264,6 +264,7 @@ public:
const wxValidator& validator = wxDefaultValidator,
const wxString &name = "listctrltextctrl" );
void OnChar( wxKeyEvent &event );
void OnKeyUp( wxKeyEvent &event );
void OnKillFocus( wxFocusEvent &event );
private:
@ -1469,6 +1470,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl,wxTextCtrl);
BEGIN_EVENT_TABLE(wxListTextCtrl,wxTextCtrl)
EVT_CHAR (wxListTextCtrl::OnChar)
EVT_KEY_UP (wxListTextCtrl::OnKeyUp)
EVT_KILL_FOCUS (wxListTextCtrl::OnKillFocus)
END_EVENT_TABLE()
@ -1522,6 +1524,21 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
event.Skip();
}
void wxListTextCtrl::OnKeyUp( wxKeyEvent &event )
{
// auto-grow the textctrl:
wxSize parentSize = m_owner->GetSize();
wxPoint myPos = GetPosition();
wxSize mySize = GetSize();
int sx, sy;
GetTextExtent(GetValue() + _T("MM"), &sx, &sy);
if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x;
if (mySize.x > sx) sx = mySize.x;
SetSize(sx, -1);
event.Skip();
}
void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
{
if (!wxPendingDelete.Member(this))

View File

@ -89,6 +89,7 @@ public:
const wxString &name = wxTextCtrlNameStr );
void OnChar( wxKeyEvent &event );
void OnKeyUp( wxKeyEvent &event );
void OnKillFocus( wxFocusEvent &event );
private:
@ -266,6 +267,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxTreeTextCtrl,wxTextCtrl);
BEGIN_EVENT_TABLE(wxTreeTextCtrl,wxTextCtrl)
EVT_CHAR (wxTreeTextCtrl::OnChar)
EVT_KEY_UP (wxTreeTextCtrl::OnKeyUp)
EVT_KILL_FOCUS (wxTreeTextCtrl::OnKillFocus)
END_EVENT_TABLE()
@ -318,6 +320,21 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
event.Skip();
}
void wxTreeTextCtrl::OnKeyUp( wxKeyEvent &event )
{
// auto-grow the textctrl:
wxSize parentSize = m_owner->GetSize();
wxPoint myPos = GetPosition();
wxSize mySize = GetSize();
int sx, sy;
GetTextExtent(GetValue() + _T("MM"), &sx, &sy);
if (myPos.x + sx > parentSize.x) sx = parentSize.x - myPos.x;
if (mySize.x > sx) sx = mySize.x;
SetSize(sx, -1);
event.Skip();
}
void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
{
if (!wxPendingDelete.Member(this))