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:
@@ -264,6 +264,7 @@ public:
|
|||||||
const wxValidator& validator = wxDefaultValidator,
|
const wxValidator& validator = wxDefaultValidator,
|
||||||
const wxString &name = "listctrltextctrl" );
|
const wxString &name = "listctrltextctrl" );
|
||||||
void OnChar( wxKeyEvent &event );
|
void OnChar( wxKeyEvent &event );
|
||||||
|
void OnKeyUp( wxKeyEvent &event );
|
||||||
void OnKillFocus( wxFocusEvent &event );
|
void OnKillFocus( wxFocusEvent &event );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -1469,6 +1470,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl,wxTextCtrl);
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxListTextCtrl,wxTextCtrl)
|
BEGIN_EVENT_TABLE(wxListTextCtrl,wxTextCtrl)
|
||||||
EVT_CHAR (wxListTextCtrl::OnChar)
|
EVT_CHAR (wxListTextCtrl::OnChar)
|
||||||
|
EVT_KEY_UP (wxListTextCtrl::OnKeyUp)
|
||||||
EVT_KILL_FOCUS (wxListTextCtrl::OnKillFocus)
|
EVT_KILL_FOCUS (wxListTextCtrl::OnKillFocus)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -1522,6 +1524,21 @@ void wxListTextCtrl::OnChar( wxKeyEvent &event )
|
|||||||
event.Skip();
|
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) )
|
void wxListTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
if (!wxPendingDelete.Member(this))
|
if (!wxPendingDelete.Member(this))
|
||||||
|
@@ -89,6 +89,7 @@ public:
|
|||||||
const wxString &name = wxTextCtrlNameStr );
|
const wxString &name = wxTextCtrlNameStr );
|
||||||
|
|
||||||
void OnChar( wxKeyEvent &event );
|
void OnChar( wxKeyEvent &event );
|
||||||
|
void OnKeyUp( wxKeyEvent &event );
|
||||||
void OnKillFocus( wxFocusEvent &event );
|
void OnKillFocus( wxFocusEvent &event );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@@ -266,6 +267,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxTreeTextCtrl,wxTextCtrl);
|
|||||||
|
|
||||||
BEGIN_EVENT_TABLE(wxTreeTextCtrl,wxTextCtrl)
|
BEGIN_EVENT_TABLE(wxTreeTextCtrl,wxTextCtrl)
|
||||||
EVT_CHAR (wxTreeTextCtrl::OnChar)
|
EVT_CHAR (wxTreeTextCtrl::OnChar)
|
||||||
|
EVT_KEY_UP (wxTreeTextCtrl::OnKeyUp)
|
||||||
EVT_KILL_FOCUS (wxTreeTextCtrl::OnKillFocus)
|
EVT_KILL_FOCUS (wxTreeTextCtrl::OnKillFocus)
|
||||||
END_EVENT_TABLE()
|
END_EVENT_TABLE()
|
||||||
|
|
||||||
@@ -318,6 +320,21 @@ void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
|
|||||||
event.Skip();
|
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) )
|
void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
|
||||||
{
|
{
|
||||||
if (!wxPendingDelete.Member(this))
|
if (!wxPendingDelete.Member(this))
|
||||||
|
Reference in New Issue
Block a user