+void wxListTextCtrl::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 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); // FIXME: MM??
+ 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))
+ wxPendingDelete.Append(this);
+
+ if ((*m_accept) && ((*m_res) != m_startValue))
+ m_owner->OnRenameAccept();
+}
+
+//-----------------------------------------------------------------------------
+// wxListMainWindow
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxListMainWindow,wxScrolledWindow);
+
+BEGIN_EVENT_TABLE(wxListMainWindow,wxScrolledWindow)
+ EVT_PAINT (wxListMainWindow::OnPaint)
+ EVT_MOUSE_EVENTS (wxListMainWindow::OnMouse)
+ EVT_CHAR (wxListMainWindow::OnChar)
+ EVT_KEY_DOWN (wxListMainWindow::OnKeyDown)
+ EVT_SET_FOCUS (wxListMainWindow::OnSetFocus)
+ EVT_KILL_FOCUS (wxListMainWindow::OnKillFocus)
+ EVT_SCROLLWIN (wxListMainWindow::OnScroll)
+END_EVENT_TABLE()
+
+void wxListMainWindow::Init()
+{
+ m_columns.DeleteContents( TRUE );
+ m_dirty = TRUE;
+ m_countVirt = 0;
+ m_lineFrom =
+ m_lineTo = (size_t)-1;
+ m_linesPerPage = 0;
+
+ m_headerWidth =
+ m_lineHeight = 0;
+
+ m_small_image_list = (wxImageList *) NULL;
+ m_normal_image_list = (wxImageList *) NULL;
+
+ m_small_spacing = 30;
+ m_normal_spacing = 40;
+
+ m_hasFocus = FALSE;
+ m_dragCount = 0;
+ m_isCreated = FALSE;
+
+ m_lastOnSame = FALSE;
+ m_renameTimer = new wxListRenameTimer( this );
+ m_renameAccept = FALSE;
+
+ m_current =
+ m_currentEdit =
+ m_lineLastClicked =
+ m_lineBeforeLastClicked = (size_t)-1;
+}
+
+void wxListMainWindow::InitScrolling()
+{
+ if ( HasFlag(wxLC_REPORT) )
+ {
+ m_xScroll = SCROLL_UNIT_X;
+ m_yScroll = SCROLL_UNIT_Y;
+ }
+ else
+ {
+ m_xScroll = SCROLL_UNIT_Y;
+ m_yScroll = 0;
+ }
+}
+
+wxListMainWindow::wxListMainWindow()
+{
+ Init();
+
+ m_highlightBrush = (wxBrush *) NULL;
+
+ m_xScroll =
+ m_yScroll = 0;
+}
+
+wxListMainWindow::wxListMainWindow( wxWindow *parent,
+ wxWindowID id,
+ const wxPoint& pos,
+ const wxSize& size,
+ long style,
+ const wxString &name )
+ : wxScrolledWindow( parent, id, pos, size,
+ style | wxHSCROLL | wxVSCROLL, name )
+{
+ Init();
+
+ m_highlightBrush = new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT), wxSOLID );
+ wxSize sz = size;
+ sz.y = 25;
+
+ InitScrolling();
+ SetScrollbars( m_xScroll, m_yScroll, 0, 0, 0, 0 );
+
+ SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX ) );
+}
+
+wxListMainWindow::~wxListMainWindow()
+{
+ DoDeleteAllItems();
+
+ delete m_highlightBrush;
+
+ delete m_renameTimer;
+}
+
+void wxListMainWindow::CacheLineData(size_t line)
+{
+ wxListCtrl *listctrl = GetListCtrl();
+
+ wxListLineData *ld = GetDummyLine();
+
+ size_t countCol = GetColumnCount();
+ for ( size_t col = 0; col < countCol; col++ )
+ {
+ ld->SetText(col, listctrl->OnGetItemText(line, col));
+ }
+
+ ld->SetImage(listctrl->OnGetItemImage(line));
+ ld->SetAttr(listctrl->OnGetItemAttr(line));
+}
+
+wxListLineData *wxListMainWindow::GetDummyLine() const
+{
+ wxASSERT_MSG( !IsEmpty(), _T("invalid line index") );
+
+ if ( m_lines.IsEmpty() )
+ {
+ // normal controls are supposed to have something in m_lines
+ // already if it's not empty
+ wxASSERT_MSG( IsVirtual(), _T("logic error") );
+
+ wxListMainWindow *self = wxConstCast(this, wxListMainWindow);
+ wxListLineData *line = new wxListLineData(self);
+ self->m_lines.Add(line);
+ }
+
+ return &m_lines[0];
+}
+
+// ----------------------------------------------------------------------------
+// line geometry (report mode only)
+// ----------------------------------------------------------------------------
+
+wxCoord wxListMainWindow::GetLineHeight() const