+ if (m_mode & wxLC_SINGLE_SEL)
+ {
+ m_current = line;
+ HilightAll( FALSE );
+ m_current->ReverseHilight();
+ RefreshLine( m_current );
+ }
+ else
+ {
+ if (event.ShiftDown())
+ {
+ m_current = line;
+ m_current->ReverseHilight();
+ RefreshLine( m_current );
+ }
+ else if (event.ControlDown())
+ {
+ m_current = line;
+
+ int numOfCurrent = -1;
+ node = m_lines.First();
+ while (node)
+ {
+ wxListLineData *test_line = (wxListLineData*)node->Data();
+ numOfCurrent++;
+ if (test_line == oldCurrent) break;
+ node = node->Next();
+ }
+
+ int numOfLine = -1;
+ node = m_lines.First();
+ while (node)
+ {
+ wxListLineData *test_line = (wxListLineData*)node->Data();
+ numOfLine++;
+ if (test_line == line) break;
+ node = node->Next();
+ }
+
+ if (numOfLine < numOfCurrent)
+ {
+ int i = numOfLine;
+ numOfLine = numOfCurrent;
+ numOfCurrent = i;
+ }
+
+ wxNode *node = m_lines.Nth( numOfCurrent );
+ for (int i = 0; i <= numOfLine-numOfCurrent; i++)
+ {
+ wxListLineData *test_line= (wxListLineData*)node->Data();
+ test_line->Hilight(TRUE);
+ RefreshLine( test_line );
+ node = node->Next();
+ }
+ }
+ else
+ {
+ m_current = line;
+ HilightAll( FALSE );
+ m_current->ReverseHilight();
+ RefreshLine( m_current );
+ }
+ }
+ if (m_current != oldCurrent)
+ {
+ RefreshLine( oldCurrent );
+ UnfocusLine( oldCurrent );
+ FocusLine( m_current );
+ }
+ m_lastOnSame = (m_current == oldCurrent);
+ return;
+ }
+}
+
+void wxListMainWindow::MoveToFocus()
+{
+ if (!m_current) return;
+
+ int x = 0;
+ int y = 0;
+ int w = 0;
+ int h = 0;
+ m_current->GetExtent( x, y, w, h );
+
+ int w_p = 0;
+ int h_p = 0;
+ GetClientSize( &w_p, &h_p );
+
+ if (m_mode & wxLC_REPORT)
+ {
+ int y_s = m_yScroll*GetScrollPos( wxVERTICAL );
+ if ((y > y_s) && (y+h < y_s+h_p)) return;
+ if (y-y_s < 5) { Scroll( -1, (y-5-h_p/2)/m_yScroll ); }
+ if (y+h+5 > y_s+h_p) { Scroll( -1, (y+h-h_p/2+h+15)/m_yScroll); }
+ }
+ else
+ {
+ int x_s = m_xScroll*GetScrollPos( wxHORIZONTAL );
+ if ((x > x_s) && (x+w < x_s+w_p)) return;
+ if (x-x_s < 5) { Scroll( (x-5)/m_xScroll, -1 ); }
+ if (x+w-5 > x_s+w_p) { Scroll( (x+w-w_p+15)/m_xScroll, -1 ); }
+ }
+}
+
+void wxListMainWindow::OnArrowChar( wxListLineData *newCurrent, bool shiftDown )
+{
+ if ((m_mode & wxLC_SINGLE_SEL) || (m_usedKeys == FALSE)) m_current->Hilight( FALSE );
+ wxListLineData *oldCurrent = m_current;
+ m_current = newCurrent;
+ MoveToFocus();
+ if (shiftDown || (m_mode & wxLC_SINGLE_SEL)) m_current->Hilight( TRUE );
+ RefreshLine( m_current );
+ RefreshLine( oldCurrent );
+ FocusLine( m_current );
+ UnfocusLine( oldCurrent );
+}
+
+void wxListMainWindow::OnKeyDown( wxKeyEvent &event )
+{
+ wxWindow *parent = GetParent();
+
+ /* we propagate the key event up */
+ wxKeyEvent ke( wxEVT_KEY_DOWN );
+ 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;
+
+ event.Skip();
+}
+
+void wxListMainWindow::OnChar( wxKeyEvent &event )
+{
+ wxWindow *parent = GetParent();
+
+ /* 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;