+ /* we send a list_key event up */
+ wxListEvent le( wxEVT_COMMAND_LIST_KEY_DOWN, GetParent()->GetId() );
+ le.m_code = event.KeyCode();
+ le.SetEventObject( parent );
+ parent->GetEventHandler()->ProcessEvent( le );
+
+ /* we propagate the char event up */
+ wxKeyEvent ke( wxEVT_CHAR );
+ ke.m_shiftDown = event.m_shiftDown;
+ ke.m_controlDown = event.m_controlDown;
+ ke.m_altDown = event.m_altDown;
+ ke.m_metaDown = event.m_metaDown;
+ ke.m_keyCode = event.m_keyCode;
+ ke.m_x = event.m_x;
+ ke.m_y = event.m_y;
+ ke.SetEventObject( parent );
+ if (parent->GetEventHandler()->ProcessEvent( ke )) return;
+
+ if (event.KeyCode() == WXK_TAB)
+ {
+ wxNavigationKeyEvent nevent;
+ nevent.SetDirection( !event.ShiftDown() );
+ nevent.SetCurrentFocus( m_parent );
+ if (m_parent->GetEventHandler()->ProcessEvent( nevent )) return;
+ }
+
+ /* no item -> nothing to do */
+ if (!m_current)
+ {
+ event.Skip();
+ return;
+ }
+
+ switch (event.KeyCode())
+ {
+ case WXK_UP:
+ {
+ wxNode *node = m_lines.Member( m_current )->Previous();
+ if (node) OnArrowChar( (wxListLineData*)node->Data(), event.ShiftDown() );
+ break;
+ }
+ case WXK_DOWN:
+ {
+ wxNode *node = m_lines.Member( m_current )->Next();
+ if (node) OnArrowChar( (wxListLineData*)node->Data(), event.ShiftDown() );
+ break;
+ }
+ case WXK_END:
+ {
+ wxNode *node = m_lines.Last();
+ OnArrowChar( (wxListLineData*)node->Data(), event.ShiftDown() );
+ break;
+ }
+ case WXK_HOME:
+ {
+ wxNode *node = m_lines.First();
+ OnArrowChar( (wxListLineData*)node->Data(), event.ShiftDown() );
+ break;
+ }
+ case WXK_PRIOR:
+ {
+ int steps = 0;
+ if (m_mode & wxLC_REPORT)
+ {
+ steps = m_visibleLines-1;
+ }
+ else
+ {
+ int pos = 0;
+ wxNode *node = m_lines.First();
+ for (;;) { if (m_current == (wxListLineData*)node->Data()) break; pos++; node = node->Next(); }
+ steps = pos % m_visibleLines;
+ }
+ wxNode *node = m_lines.Member( m_current );
+ for (int i = 0; i < steps; i++) if (node->Previous()) node = node->Previous();
+ if (node) OnArrowChar( (wxListLineData*)node->Data(), event.ShiftDown() );
+ break;
+ }
+ case WXK_NEXT:
+ {
+ int steps = 0;
+ if (m_mode & wxLC_REPORT)
+ {
+ steps = m_visibleLines-1;
+ }
+ else
+ {
+ int pos = 0; wxNode *node = m_lines.First();
+ for (;;) { if (m_current == (wxListLineData*)node->Data()) break; pos++; node = node->Next(); }
+ steps = m_visibleLines-(pos % m_visibleLines)-1;
+ }
+ wxNode *node = m_lines.Member( m_current );
+ for (int i = 0; i < steps; i++) if (node->Next()) node = node->Next();
+ if (node) OnArrowChar( (wxListLineData*)node->Data(), event.ShiftDown() );
+ break;
+ }
+ case WXK_LEFT:
+ {
+ if (!(m_mode & wxLC_REPORT))
+ {
+ wxNode *node = m_lines.Member( m_current );
+ for (int i = 0; i <m_visibleLines; i++) if (node->Previous()) node = node->Previous();
+ if (node) OnArrowChar( (wxListLineData*)node->Data(), event.ShiftDown() );
+ }
+ break;
+ }
+ case WXK_RIGHT:
+ {
+ if (!(m_mode & wxLC_REPORT))
+ {
+ wxNode *node = m_lines.Member( m_current );
+ for (int i = 0; i <m_visibleLines; i++) if (node->Next()) node = node->Next();
+ if (node) OnArrowChar( (wxListLineData*)node->Data(), event.ShiftDown() );
+ }
+ break;
+ }
+ case WXK_SPACE:
+ {
+ m_current->ReverseHilight();
+ RefreshLine( m_current );
+ break;
+ }
+ case WXK_INSERT:
+ {
+ if (!(m_mode & wxLC_SINGLE_SEL))
+ {
+ wxListLineData *oldCurrent = m_current;
+ m_current->ReverseHilight();
+ wxNode *node = m_lines.Member( m_current )->Next();
+ if (node) m_current = (wxListLineData*)node->Data();
+ MoveToFocus();
+ RefreshLine( oldCurrent );
+ RefreshLine( m_current );
+ UnfocusLine( oldCurrent );
+ FocusLine( m_current );
+ }
+ break;
+ }
+ case WXK_RETURN:
+ case WXK_EXECUTE:
+ {
+ wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, GetParent()->GetId() );
+ le.SetEventObject( GetParent() );
+ le.m_itemIndex = GetIndexOfLine( m_current );
+ m_current->GetItem( 0, le.m_item );
+ GetParent()->GetEventHandler()->ProcessEvent( le );
+ break;
+ }
+ default:
+ {
+ event.Skip();
+ return;
+ }
+ }
+ m_usedKeys = TRUE;
+}
+
+#ifdef __WXGTK__
+extern wxWindow *g_focusWindow;
+#endif
+
+void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
+{
+ m_hasFocus = TRUE;
+ RefreshLine( m_current );
+
+ if (!GetParent()) return;
+
+#ifdef __WXGTK__
+ g_focusWindow = GetParent();
+#endif
+
+ wxFocusEvent event( wxEVT_SET_FOCUS, GetParent()->GetId() );
+ event.SetEventObject( GetParent() );
+ GetParent()->GetEventHandler()->ProcessEvent( event );
+}
+
+void wxListMainWindow::OnKillFocus( wxFocusEvent &WXUNUSED(event) )
+{
+ m_hasFocus = FALSE;
+ RefreshLine( m_current );
+}
+
+void wxListMainWindow::OnSize( wxSizeEvent &WXUNUSED(event) )
+{
+/*
+ We don't even allow the wxScrolledWindow::AdjustScrollbars() call