+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+// translate the key or mouse event flags to the type of selection we're
+// dealing with
+static void EventFlagsToSelType(long style,
+ bool shiftDown,
+ bool ctrlDown,
+ bool *is_multiple,
+ bool *extended_select,
+ bool *unselect_others)
+{
+ *is_multiple = (style & wxTR_MULTIPLE) != 0;
+ *extended_select = shiftDown && is_multiple;
+ *unselect_others = !(extended_select || (ctrlDown && is_multiple));
+}
+
+// -----------------------------------------------------------------------------
+// wxTreeRenameTimer (internal)
+// -----------------------------------------------------------------------------
+
+wxTreeRenameTimer::wxTreeRenameTimer( wxTreeCtrl *owner )
+{
+ m_owner = owner;
+}
+
+void wxTreeRenameTimer::Notify()
+{
+ m_owner->OnRenameTimer();
+}
+
+//-----------------------------------------------------------------------------
+// wxTreeTextCtrl (internal)
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxTreeTextCtrl,wxTextCtrl);
+
+BEGIN_EVENT_TABLE(wxTreeTextCtrl,wxTextCtrl)
+ EVT_CHAR (wxTreeTextCtrl::OnChar)
+ EVT_KILL_FOCUS (wxTreeTextCtrl::OnKillFocus)
+END_EVENT_TABLE()
+
+wxTreeTextCtrl::wxTreeTextCtrl( wxWindow *parent,
+ const wxWindowID id,
+ bool *accept,
+ wxString *res,
+ wxTreeCtrl *owner,
+ const wxString &value,
+ const wxPoint &pos,
+ const wxSize &size,
+ int style,
+ const wxValidator& validator,
+ const wxString &name )
+ : wxTextCtrl( parent, id, value, pos, size, style, validator, name )
+{
+ m_res = res;
+ m_accept = accept;
+ m_owner = owner;
+ (*m_accept) = FALSE;
+ (*m_res) = wxEmptyString;
+ m_startValue = value;
+}
+
+void wxTreeTextCtrl::OnChar( wxKeyEvent &event )
+{
+ if (event.m_keyCode == WXK_RETURN)
+ {
+ (*m_accept) = TRUE;
+ (*m_res) = GetValue();
+
+ if (!wxPendingDelete.Member(this))
+ wxPendingDelete.Append(this);
+
+ if ((*m_accept) && ((*m_res) != m_startValue))
+ m_owner->OnRenameAccept();
+
+ return;
+ }
+ if (event.m_keyCode == WXK_ESCAPE)
+ {
+ (*m_accept) = FALSE;
+ (*m_res) = "";
+
+ if (!wxPendingDelete.Member(this))
+ wxPendingDelete.Append(this);
+
+ return;
+ }
+ event.Skip();
+}
+
+void wxTreeTextCtrl::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
+{
+ if (!wxPendingDelete.Member(this))
+ wxPendingDelete.Append(this);
+
+ if ((*m_accept) && ((*m_res) != m_startValue))
+ m_owner->OnRenameAccept();
+}
+