1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   6 // Copyright:   (c) 1998 Robert Roebling 
   7 // Licence:     wxWindows licence 
   8 ///////////////////////////////////////////////////////////////////////////// 
  11 #pragma implementation "listctrl.h" 
  14 #include "wx/dcscreen.h" 
  16 #include "wx/listctrl.h" 
  18 //----------------------------------------------------------------------------- 
  20 //----------------------------------------------------------------------------- 
  22 IMPLEMENT_DYNAMIC_CLASS(wxListItemData
,wxObject
); 
  24 wxListItemData::wxListItemData(void) 
  35 wxListItemData::wxListItemData( const wxListItem 
&info 
) 
  39     m_colour 
= info
.m_colour
; 
  43 void wxListItemData::SetItem( const wxListItem 
&info 
) 
  45     if (info
.m_mask 
& wxLIST_MASK_TEXT
) m_text 
= info
.m_text
; 
  46     if (info
.m_mask 
& wxLIST_MASK_IMAGE
) m_image 
= info
.m_image
; 
  47     if (info
.m_mask 
& wxLIST_MASK_DATA
) m_data 
= info
.m_data
; 
  48     m_colour 
= info
.m_colour
; 
  51     m_width 
= info
.m_width
; 
  55 void wxListItemData::SetText( const wxString 
&s 
) 
  60 void wxListItemData::SetImage( int image 
) 
  65 void wxListItemData::SetData( long data 
) 
  70 void wxListItemData::SetPosition( int x
, int y 
) 
  76 void wxListItemData::SetSize( int const width
, int height 
) 
  78     if (width 
!= -1) m_width 
= width
; 
  79     if (height 
!= -1) m_height 
= height
; 
  82 void wxListItemData::SetColour( wxColour 
*col 
) 
  87 bool wxListItemData::HasImage(void) const 
  89     return (m_image 
>= 0); 
  92 bool wxListItemData::HasText(void) const 
  94     return (!m_text
.IsNull()); 
  97 bool wxListItemData::IsHit( int x
, int y 
) const 
  99     return ((x 
>= m_xpos
) && (x 
<= m_xpos
+m_width
) && (y 
>= m_ypos
) && (y 
<= m_ypos
+m_height
)); 
 102 void wxListItemData::GetText( wxString 
&s 
) 
 107 int wxListItemData::GetX( void ) const 
 112 int wxListItemData::GetY( void ) const 
 117 int wxListItemData::GetWidth(void) const 
 122 int wxListItemData::GetHeight(void) const 
 127 int wxListItemData::GetImage(void) const 
 132 void wxListItemData::GetItem( wxListItem 
&info 
) 
 134     info
.m_text 
= m_text
; 
 135     info
.m_image 
= m_image
; 
 136     info
.m_data 
= m_data
; 
 139 wxColour 
*wxListItemData::GetColour(void) 
 144 //----------------------------------------------------------------------------- 
 146 //----------------------------------------------------------------------------- 
 148 IMPLEMENT_DYNAMIC_CLASS(wxListHeaderData
,wxObject
); 
 150 wxListHeaderData::wxListHeaderData(void) 
 161 wxListHeaderData::wxListHeaderData( const wxListItem 
&item 
) 
 169 void wxListHeaderData::SetItem( const wxListItem 
&item 
) 
 171     m_mask 
= item
.m_mask
; 
 172     m_text 
= item
.m_text
; 
 173     m_image 
= item
.m_image
; 
 174     m_format 
= item
.m_format
; 
 175     m_width 
= item
.m_width
; 
 176     if (m_width 
< 0) m_width 
= 80; 
 177     if (m_width 
< 6) m_width 
= 6; 
 180 void wxListHeaderData::SetPosition( int x
, int y 
) 
 186 void wxListHeaderData::SetHeight( int h 
) 
 191 void wxListHeaderData::SetWidth( int w 
) 
 194     if (m_width 
< 0) m_width 
= 80; 
 195     if (m_width 
< 6) m_width 
= 6; 
 198 void wxListHeaderData::SetFormat( int format 
) 
 203 bool wxListHeaderData::HasImage(void) const 
 205     return (m_image 
!= 0); 
 208 bool wxListHeaderData::HasText(void) const 
 210     return (m_text
.Length() > 0); 
 213 bool wxListHeaderData::IsHit( int x
, int y 
) const 
 215     return ((x 
>= m_xpos
) && (x 
<= m_xpos
+m_width
) && (y 
>= m_ypos
) && (y 
<= m_ypos
+m_height
)); 
 218 void wxListHeaderData::GetItem( wxListItem 
&item 
) 
 220     item
.m_mask 
= m_mask
; 
 221     item
.m_text 
= m_text
; 
 222     item
.m_image 
= m_image
; 
 223     item
.m_format 
= m_format
; 
 224     item
.m_width 
= m_width
; 
 227 void wxListHeaderData::GetText( wxString 
&s 
) 
 232 int wxListHeaderData::GetImage(void) const 
 237 int wxListHeaderData::GetWidth(void) const 
 242 int wxListHeaderData::GetFormat(void) const 
 247 //----------------------------------------------------------------------------- 
 249 //----------------------------------------------------------------------------- 
 251 IMPLEMENT_DYNAMIC_CLASS(wxListLineData
,wxObject
); 
 253 wxListLineData::wxListLineData( wxListMainWindow 
*owner
, int mode
, wxBrush 
*hilightBrush 
) 
 258     m_hilightBrush 
= hilightBrush
; 
 259     m_items
.DeleteContents( TRUE 
); 
 263 void wxListLineData::CalculateSize( wxPaintDC 
*dc
, int spacing 
) 
 270             m_bound_all
.width 
= m_spacing
; 
 271             m_bound_all
.height 
= m_spacing
+13; 
 272             wxNode 
*node 
= m_items
.First(); 
 275                 wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 279                 dc
->GetTextExtent( s
, &lw
, &lh 
); 
 280                 if (lw 
> m_spacing
) m_bound_all
.width 
= lw
; 
 286             wxNode 
*node 
= m_items
.First(); 
 289                 wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 293                 dc
->GetTextExtent( s
, &lw
, &lh 
); 
 294                 m_bound_all
.width 
= lw
; 
 295                 m_bound_all
.height 
= lh
; 
 301             m_bound_all
.width 
= 0; 
 302             m_bound_all
.height 
= 0; 
 303             wxNode 
*node 
= m_items
.First(); 
 306                 wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 309                 if (s
.IsNull()) s 
= "H"; 
 311                 dc
->GetTextExtent( s
, &lw
, &lh 
); 
 312                 item
->SetSize( item
->GetWidth(), lh 
); 
 313                 m_bound_all
.width 
+= lw
; 
 314                 m_bound_all
.height 
= lh
; 
 322 void wxListLineData::SetPosition( wxPaintDC 
*dc
, int x
, int y
, int window_width 
) 
 330       AssignRect( m_bound_icon
, 0, 0, 0, 0 ); 
 331       AssignRect( m_bound_label
, 0, 0, 0, 0 ); 
 332       AssignRect( m_bound_hilight
, m_bound_all 
); 
 333       wxNode 
*node 
= m_items
.First(); 
 336         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 337         if (item
->HasImage()) 
 339           wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 342           m_owner
->GetImageSize( item
->GetImage(), w
, h 
); 
 343           m_bound_icon
.x 
= m_bound_all
.x 
+ (m_spacing
/2) - (w
/2); 
 344           m_bound_icon
.y 
= m_bound_all
.y 
+ m_spacing 
- h 
- 5; 
 345           m_bound_icon
.width 
= w
; 
 346           m_bound_icon
.height 
= h
; 
 347           if (!item
->HasText()) 
 349             AssignRect( m_bound_hilight
, m_bound_icon 
); 
 350             m_bound_hilight
.x 
-= 5; 
 351             m_bound_hilight
.y 
-= 5; 
 352             m_bound_hilight
.width 
+= 9; 
 353             m_bound_hilight
.height 
+= 9; 
 361           dc
->GetTextExtent( s
, &lw
, &lh 
); 
 362           if (m_bound_all
.width 
> m_spacing
) 
 363             m_bound_label
.x 
= m_bound_all
.x
; 
 365             m_bound_label
.x 
= m_bound_all
.x 
+  (m_spacing
/2) - lw
/2; 
 366           m_bound_label
.y 
= m_bound_all
.y 
+ m_bound_all
.height 
- lh
; 
 367           m_bound_label
.width 
= lw
; 
 368           m_bound_label
.height 
= lh
; 
 369           AssignRect( m_bound_hilight
, m_bound_label 
); 
 370           m_bound_hilight
.x 
-= 2; 
 371           m_bound_hilight
.y 
-= 2; 
 372           m_bound_hilight
.width 
+= 4; 
 373           m_bound_hilight
.height 
+= 4; 
 380       AssignRect( m_bound_label
, m_bound_all 
); 
 383       m_bound_all
.width 
+= 4; 
 384       m_bound_all
.height 
+= 3; 
 385       AssignRect( m_bound_hilight
, m_bound_all 
); 
 386       AssignRect( m_bound_icon
, 0, 0, 0, 0 ); 
 392       dc
->GetTextExtent( "H", &lw
, &lh 
); 
 395       m_bound_all
.height 
= lh
+3; 
 396       m_bound_all
.width 
= window_width
; 
 397       AssignRect( m_bound_hilight
, m_bound_all 
); 
 398       AssignRect( m_bound_label
, 0, 0, 0 ,0 ); 
 399       AssignRect( m_bound_icon
, 0, 0, 0, 0 ); 
 405 void wxListLineData::SetColumnPosition( int index
, int x 
) 
 408     wxNode 
*node 
= m_items
.Nth( i 
); 
 411         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 412         item
->SetPosition( x
, m_bound_all
.y
+1 ); 
 416 void wxListLineData::GetSize( int &width
, int &height 
) 
 418     width 
= m_bound_all
.width
; 
 419     height 
= m_bound_all
.height
; 
 422 void wxListLineData::GetExtent( int &x
, int &y
, int &width
, int &height 
) 
 426     width 
= m_bound_all
.width
; 
 427     height 
= m_bound_all
.height
; 
 430 void wxListLineData::GetLabelExtent( int &x
, int &y
, int &width
, int &height 
) 
 434     width 
= m_bound_label
.width
; 
 435     height 
= m_bound_label
.height
; 
 438 void wxListLineData::GetRect( wxRectangle 
&rect 
) 
 440     AssignRect( rect
, m_bound_all 
); 
 443 long wxListLineData::IsHit( int x
, int y 
) 
 445     wxNode 
*node 
= m_items
.First(); 
 448         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 449         if (item
->HasImage() && IsInRect( x
, y
, m_bound_icon 
)) return wxLIST_HITTEST_ONITEMICON
; 
 450         if (item
->HasText() && IsInRect( x
, y
, m_bound_label 
)) return wxLIST_HITTEST_ONITEMLABEL
; 
 451 //      if (!(item->HasImage() || item->HasText())) return 0; 
 453     // if there is no icon or text = empty 
 454     if (IsInRect( x
, y
, m_bound_all 
)) return wxLIST_HITTEST_ONITEMICON
; 
 458 void wxListLineData::InitItems( int num 
) 
 460     for (int i 
= 0; i 
< num
; i
++) m_items
.Append( new wxListItemData() ); 
 463 void wxListLineData::SetItem( int index
, const wxListItem 
&info 
) 
 465     wxNode 
*node 
= m_items
.Nth( index 
); 
 468        wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 469        item
->SetItem( info 
); 
 473 void wxListLineData::GetItem( int const index
, wxListItem 
&info 
) 
 476     wxNode 
*node 
= m_items
.Nth( i 
); 
 479         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 480         item
->GetItem( info 
); 
 484 void wxListLineData::GetText( int index
, wxString 
&s 
) 
 487     wxNode 
*node 
= m_items
.Nth( i 
); 
 491         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 496 void wxListLineData::SetText( int index
, const wxString s 
) 
 499     wxNode 
*node 
= m_items
.Nth( i 
); 
 502         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 507 int wxListLineData::GetImage( int index 
) 
 510     wxNode 
*node 
= m_items
.Nth( i 
); 
 513         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 514         return item
->GetImage(); 
 519 void wxListLineData::DoDraw( wxPaintDC 
*dc
, bool hilight
, bool paintBG 
) 
 521     long dev_x 
= dc
->LogicalToDeviceX( m_bound_all
.x
-2 ); 
 522     long dev_y 
= dc
->LogicalToDeviceY( m_bound_all
.y
-2 ); 
 523     long dev_w 
= dc
->LogicalToDeviceXRel( m_bound_all
.width
+4 ); 
 524     long dev_h 
= dc
->LogicalToDeviceYRel( m_bound_all
.height
+4 ); 
 526     if (!m_owner
->IsExposed( dev_x
, dev_y
, dev_w
, dev_h 
)) 
 535       dc
->SetBrush( * m_hilightBrush 
); 
 536       dc
->SetPen( * wxTRANSPARENT_PEN 
); 
 540       dc
->SetBrush( * wxWHITE_BRUSH 
); 
 541       dc
->SetPen( * wxTRANSPARENT_PEN 
); 
 543     dc
->DrawRectangle( m_bound_hilight
.x
, m_bound_hilight
.y
, 
 544                        m_bound_hilight
.width
, m_bound_hilight
.height 
); 
 546   if (m_mode 
== wxLC_REPORT
) 
 549     wxNode 
*node 
= m_items
.First(); 
 552       wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 553       dc
->SetClippingRegion( item
->GetX(), item
->GetY(), item
->GetWidth()-3, item
->GetHeight() ); 
 554       int x 
= item
->GetX(); 
 555       if (item
->HasImage()) 
 558         m_owner
->DrawImage( item
->GetImage(), dc
, x
, item
->GetY() ); 
 559   m_owner
->GetImageSize( item
->GetImage(), x
, y 
); 
 560   x 
+= item
->GetX() + 5; 
 566     dc
->SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT 
) ); 
 568           dc
->SetTextForeground( *item
->GetColour() ); 
 569         dc
->DrawText( s
, x
, item
->GetY() ); 
 571       dc
->DestroyClippingRegion(); 
 577     wxNode 
*node 
= m_items
.First(); 
 580       wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 581       if (item
->HasImage()) 
 583         m_owner
->DrawImage( item
->GetImage(), dc
, m_bound_icon
.x
, m_bound_icon
.y 
); 
 590     dc
->SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT 
) ); 
 592           dc
->SetTextForeground( * item
->GetColour() ); 
 593         dc
->DrawText( s
, m_bound_label
.x
, m_bound_label
.y 
); 
 599 void wxListLineData::Hilight( bool on 
) 
 601   if (on 
== m_hilighted
) return; 
 603     m_owner
->SelectLine( this ); 
 605     m_owner
->DeselectLine( this ); 
 609 void wxListLineData::ReverseHilight( void ) 
 611   m_hilighted 
= !m_hilighted
; 
 613     m_owner
->SelectLine( this ); 
 615     m_owner
->DeselectLine( this ); 
 618 void wxListLineData::DrawRubberBand( wxPaintDC 
*dc
, bool on 
) 
 622     dc
->SetPen( * wxBLACK_PEN 
); 
 623     dc
->SetBrush( * wxTRANSPARENT_BRUSH 
); 
 624     dc
->DrawRectangle( m_bound_hilight
.x
, m_bound_hilight
.y
, 
 625                        m_bound_hilight
.width
, m_bound_hilight
.height 
); 
 629 void wxListLineData::Draw( wxPaintDC 
*dc 
) 
 631   DoDraw( dc
, m_hilighted
, m_hilighted 
); 
 634 bool wxListLineData::IsInRect( int x
, int y
, const wxRectangle 
&rect 
) 
 636   return ((x 
>= rect
.x
) && (x 
<= rect
.x
+rect
.width
) && (y 
>= rect
.y
) && (y 
<= rect
.y
+rect
.height
)); 
 639 bool wxListLineData::IsHilighted( void ) 
 644 void wxListLineData::AssignRect( wxRectangle 
&dest
, int x
, int y
, int width
, int height 
) 
 649   dest
.height 
= height
; 
 652 void wxListLineData::AssignRect( wxRectangle 
&dest
, const wxRectangle 
&source 
) 
 656   dest
.width 
= source
.width
; 
 657   dest
.height 
= source
.height
; 
 660 //----------------------------------------------------------------------------- 
 661 //  wxListHeaderWindow 
 662 //----------------------------------------------------------------------------- 
 664 IMPLEMENT_DYNAMIC_CLASS(wxListHeaderWindow
,wxWindow
); 
 666 BEGIN_EVENT_TABLE(wxListHeaderWindow
,wxWindow
) 
 667   EVT_PAINT         (wxListHeaderWindow::OnPaint
) 
 668   EVT_MOUSE_EVENTS  (wxListHeaderWindow::OnMouse
) 
 669   EVT_SET_FOCUS     (wxListHeaderWindow::OnSetFocus
) 
 672 wxListHeaderWindow::wxListHeaderWindow( void ) 
 674   m_owner 
= (wxListMainWindow 
*) NULL
; 
 675   m_currentCursor 
= (wxCursor 
*) NULL
; 
 676   m_resizeCursor 
= (wxCursor 
*) NULL
; 
 680 wxListHeaderWindow::wxListHeaderWindow( wxWindow 
*win
, wxWindowID id
, wxListMainWindow 
*owner
, 
 681       const wxPoint 
&pos
, const wxSize 
&size
, 
 682       long style
, const wxString 
&name 
) : 
 683   wxWindow( win
, id
, pos
, size
, style
, name 
) 
 686 //  m_currentCursor = wxSTANDARD_CURSOR; 
 687   m_currentCursor 
= (wxCursor 
*) NULL
; 
 688   m_resizeCursor 
= new wxCursor( wxCURSOR_SIZEWE 
); 
 692 wxListHeaderWindow::~wxListHeaderWindow( void ) 
 694   delete m_resizeCursor
; 
 697 void wxListHeaderWindow::DoDrawRect( wxPaintDC 
*dc
, int x
, int y
, int w
, int h 
) 
 699   const int m_corner 
= 1; 
 701   dc
->SetBrush( *wxTRANSPARENT_BRUSH 
); 
 703   dc
->SetPen( *wxBLACK_PEN 
); 
 704   dc
->DrawLine( x
+w
-m_corner
+1, y
, x
+w
, y
+h 
);  // right (outer) 
 705   dc
->DrawRectangle( x
, y
+h
, w
, 1 );            // bottom (outer) 
 707   wxPen 
pen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW 
), 1, wxSOLID 
); 
 710   dc
->DrawLine( x
+w
-m_corner
, y
, x
+w
-1, y
+h 
);  // right (inner) 
 711   dc
->DrawRectangle( x
+1, y
+h
-1, w
-2, 1 );      // bottom (inner) 
 713   dc
->SetPen( *wxWHITE_PEN 
); 
 714   dc
->DrawRectangle( x
, y
, w
-m_corner
+1, 1 );   // top (outer) 
 715   dc
->DrawRectangle( x
, y
, 1, h 
);              // left (outer) 
 716   dc
->DrawLine( x
, y
+h
-1, x
+1, y
+h
-1 ); 
 717   dc
->DrawLine( x
+w
-1, y
, x
+w
-1, y
+1 ); 
 720 void wxListHeaderWindow::OnPaint( wxPaintEvent 
&WXUNUSED(event
) ) 
 722   wxPaintDC 
dc( this ); 
 727   dc
.SetFont( GetFont() ); 
 733   GetClientSize( &w
, &h 
); 
 735   dc
.SetTextForeground( *wxBLACK 
); 
 736   if (m_foregroundColour
.Ok()) dc
.SetTextForeground( m_foregroundColour 
); 
 740   int numColumns 
= m_owner
->GetColumnCount(); 
 742   for (int i 
= 0; i 
< numColumns
; i
++) 
 744     m_owner
->GetColumn( i
, item 
); 
 745     int cw 
= item
.m_width
-2; 
 746     if ((i
+1 == numColumns
) || (x
+item
.m_width 
> w
-5)) cw 
= w
-x
-1; 
 747     dc
.SetPen( *wxWHITE_PEN 
); 
 749     DoDrawRect( &dc
, x
, y
, cw
, h
-2 ); 
 750     dc
.SetClippingRegion( x
, y
, cw
-5, h
-4 ); 
 751     dc
.DrawText( item
.m_text
, x
+4, y
+3 ); 
 752     dc
.DestroyClippingRegion(); 
 759 void wxListHeaderWindow::DrawCurrent() 
 763   int x2 
= m_currentX
-1; 
 766   m_owner
->GetClientSize( &dummy
, &y2 
); 
 767   ClientToScreen( &x1
, &y1 
); 
 768   m_owner
->ClientToScreen( &x2
, &y2 
); 
 771   dc
.SetLogicalFunction( wxXOR 
); 
 772   dc
.SetPen( wxPen( *wxBLACK
, 2, wxSOLID 
) ); 
 773   dc
.SetBrush( *wxTRANSPARENT_BRUSH 
); 
 775   dc
.DrawLine( x1
, y1
, x2
, y2 
); 
 777   dc
.SetLogicalFunction( wxCOPY 
); 
 779   dc
.SetPen( wxNullPen 
); 
 780   dc
.SetBrush( wxNullBrush 
); 
 783 void wxListHeaderWindow::OnMouse( wxMouseEvent 
&event 
) 
 785   int x 
= event
.GetX(); 
 786   int y 
= event
.GetY(); 
 790     if (event
.ButtonUp()) 
 794       m_owner
->SetColumnWidth( m_column
, m_currentX
-m_minX 
); 
 800       GetClientSize( &size_x
, & dummy 
); 
 804         m_currentX 
= m_minX
+7; 
 805       if (m_currentX 
> size_x
-7) m_currentX 
= size_x
-7; 
 812   bool hit_border 
= FALSE
; 
 814   for (int j 
= 0; j 
< m_owner
->GetColumnCount(); j
++) 
 816     xpos 
+= m_owner
->GetColumnWidth( j 
); 
 817     if ((abs(x
-xpos
) < 3) && (y 
< 22)) 
 826   if (event
.LeftDown() && hit_border
) 
 839       if (m_currentCursor 
== wxSTANDARD_CURSOR
) SetCursor( * m_resizeCursor 
); 
 840       m_currentCursor 
= m_resizeCursor
; 
 844       if (m_currentCursor 
!= wxSTANDARD_CURSOR
) SetCursor( * wxSTANDARD_CURSOR 
); 
 845       m_currentCursor 
= wxSTANDARD_CURSOR
; 
 850 void wxListHeaderWindow::OnSetFocus( wxFocusEvent 
&WXUNUSED(event
) ) 
 855 //----------------------------------------------------------------------------- 
 856 // wxListRenameTimer (internal) 
 857 //----------------------------------------------------------------------------- 
 859 wxListRenameTimer::wxListRenameTimer( wxListMainWindow 
*owner 
) 
 864 void wxListRenameTimer::Notify() 
 866   m_owner
->OnRenameTimer(); 
 869 //----------------------------------------------------------------------------- 
 870 // wxListTextCtrl (internal) 
 871 //----------------------------------------------------------------------------- 
 873 IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl
,wxTextCtrl
); 
 875 BEGIN_EVENT_TABLE(wxListTextCtrl
,wxTextCtrl
) 
 876   EVT_CHAR           (wxListTextCtrl::OnChar
) 
 877   EVT_KILL_FOCUS     (wxListTextCtrl::OnKillFocus
) 
 880 wxListTextCtrl::wxListTextCtrl( wxWindow 
*parent
, const wxWindowID id
, 
 881     bool *accept
, wxString 
*res
, wxListMainWindow 
*owner
, 
 882     const wxString 
&value
, const wxPoint 
&pos
, const wxSize 
&size
, 
 883     int style
, const wxValidator
& validator
, const wxString 
&name 
) : 
 884   wxTextCtrl( parent
, id
, value
, pos
, size
, style
, validator
, name 
) 
 891 void wxListTextCtrl::OnChar( wxKeyEvent 
&event 
) 
 893   if (event
.m_keyCode 
== WXK_RETURN
) 
 896     (*m_res
) = GetValue(); 
 897     m_owner
->OnRenameAccept(); 
 902   if (event
.m_keyCode 
== WXK_ESCAPE
) 
 913 void wxListTextCtrl::OnKillFocus( wxFocusEvent 
&WXUNUSED(event
) ) 
 922 //----------------------------------------------------------------------------- 
 924 //----------------------------------------------------------------------------- 
 926 IMPLEMENT_DYNAMIC_CLASS(wxListMainWindow
,wxScrolledWindow
); 
 928 BEGIN_EVENT_TABLE(wxListMainWindow
,wxScrolledWindow
) 
 929   EVT_PAINT          (wxListMainWindow::OnPaint
) 
 930   EVT_SIZE           (wxListMainWindow::OnSize
) 
 931   EVT_MOUSE_EVENTS   (wxListMainWindow::OnMouse
) 
 932   EVT_CHAR           (wxListMainWindow::OnChar
) 
 933   EVT_SET_FOCUS      (wxListMainWindow::OnSetFocus
) 
 934   EVT_KILL_FOCUS     (wxListMainWindow::OnKillFocus
) 
 937 wxListMainWindow::wxListMainWindow( void ) 
 940     m_lines
.DeleteContents( TRUE 
); 
 941     m_columns
.DeleteContents( TRUE 
); 
 942     m_current 
= (wxListLineData 
*) NULL
; 
 944     m_hilightBrush 
= (wxBrush 
*) NULL
; 
 948     m_small_image_list 
= (wxImageList 
*) NULL
; 
 949     m_normal_image_list 
= (wxImageList 
*) NULL
; 
 950     m_small_spacing 
= 30; 
 951     m_normal_spacing 
= 40; 
 954     m_lastOnSame 
= FALSE
; 
 955     m_renameTimer 
= new wxListRenameTimer( this ); 
 960 wxListMainWindow::wxListMainWindow( wxWindow 
*parent
, wxWindowID id
, 
 961       const wxPoint 
&pos
, const wxSize 
&size
, 
 962       long style
, const wxString 
&name 
) : 
 963   wxScrolledWindow( parent
, id
, pos
, size
, style
|wxHSCROLL
|wxVSCROLL
, name 
) 
 966     m_lines
.DeleteContents( TRUE 
); 
 967     m_columns
.DeleteContents( TRUE 
); 
 968     m_current 
= (wxListLineData 
*) NULL
; 
 971     m_hilightBrush 
= new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT
), wxSOLID 
); 
 972     m_small_image_list 
= (wxImageList 
*) NULL
; 
 973     m_normal_image_list 
= (wxImageList 
*) NULL
; 
 974     m_small_spacing 
= 30; 
 975     m_normal_spacing 
= 40; 
 982     if (m_mode 
& wxLC_REPORT
) 
 992     SetScrollbars( m_xScroll
, m_yScroll
, 0, 0, 0, 0 ); 
 995     m_lastOnSame 
= FALSE
; 
 996     m_renameTimer 
= new wxListRenameTimer( this ); 
 997     m_renameAccept 
= FALSE
; 
 999     SetBackgroundColour( *wxWHITE 
); 
1002 wxListMainWindow::~wxListMainWindow( void ) 
1004     if (m_hilightBrush
) delete m_hilightBrush
; 
1006     delete m_renameTimer
; 
1009 void wxListMainWindow::RefreshLine( wxListLineData 
*line 
) 
1017         wxClientDC 
dc(this); 
1019         line
->GetExtent( x
, y
, w
, h 
); 
1021           dc
.LogicalToDeviceX(x
-3), 
1022           dc
.LogicalToDeviceY(y
-3), 
1023           dc
.LogicalToDeviceXRel(w
+6), 
1024           dc
.LogicalToDeviceXRel(h
+6) ); 
1025         Refresh( TRUE
, &rect 
); 
1029 void wxListMainWindow::OnPaint( wxPaintEvent 
&WXUNUSED(event
) ) 
1031     if (m_dirty
) return; 
1033     if (m_lines
.GetCount() == 0) return; 
1035     wxPaintDC 
dc( this ); 
1040     dc
.SetFont( GetFont() ); 
1042     if (m_mode 
& wxLC_REPORT
) 
1044         int lineSpacing 
= 0; 
1045         wxListLineData 
*line 
= (wxListLineData
*)m_lines
.First()->Data(); 
1047         line
->GetSize( dummy
, lineSpacing 
); 
1050         int y_s 
= m_yScroll
*GetScrollPos( wxVERTICAL 
); 
1052         wxNode 
*node 
= m_lines
.Nth( y_s 
/ lineSpacing 
); 
1053         for (int i 
= 0; i 
< m_visibleLines
+2; i
++) 
1057             line 
= (wxListLineData
*)node
->Data(); 
1059             node 
= node
->Next(); 
1064         wxNode 
*node 
= m_lines
.First(); 
1067             wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1069             node 
= node
->Next(); 
1073     if (m_current
) m_current
->DrawRubberBand( &dc
, m_hasFocus 
); 
1078 void wxListMainWindow::HilightAll( bool on 
) 
1080     wxNode 
*node 
= m_lines
.First(); 
1083         wxListLineData 
*line 
= (wxListLineData 
*)node
->Data(); 
1084         if (line
->IsHilighted() != on
) 
1086             line
->Hilight( on 
); 
1087             RefreshLine( line 
); 
1089         node 
= node
->Next(); 
1093 void wxListMainWindow::SendNotify( wxListLineData 
*line
, wxEventType command 
) 
1095     wxListEvent 
le( command
, GetParent()->GetId() ); 
1096     le
.SetEventObject( GetParent() ); 
1097     le
.m_itemIndex 
= GetIndexOfLine( line 
); 
1098     line
->GetItem( 0, le
.m_item 
); 
1099     GetParent()->GetEventHandler()->ProcessEvent( le 
); 
1102 void wxListMainWindow::FocusLine( wxListLineData 
*WXUNUSED(line
) ) 
1104 //  SendNotify( line, wxEVT_COMMAND_LIST_ITEM_FOCUSSED ); 
1107 void wxListMainWindow::UnfocusLine( wxListLineData 
*WXUNUSED(line
) ) 
1109 //  SendNotify( line, wxEVT_COMMAND_LIST_ITEM_UNFOCUSSED ); 
1112 void wxListMainWindow::SelectLine( wxListLineData 
*line 
) 
1114     SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_SELECTED 
); 
1117 void wxListMainWindow::DeselectLine( wxListLineData 
*line 
) 
1119     SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_DESELECTED 
); 
1122 void wxListMainWindow::DeleteLine( wxListLineData 
*line 
) 
1124     SendNotify( line
, wxEVT_COMMAND_LIST_DELETE_ITEM 
); 
1127 void wxListMainWindow::StartLabelEdit( wxListLineData 
*line 
) 
1129     SendNotify( line
, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT 
); 
1132 void wxListMainWindow::RenameLine( wxListLineData 
*line
, const wxString 
&newName 
) 
1134     wxListEvent 
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetParent()->GetId() ); 
1135     le
.SetEventObject( GetParent() ); 
1136     le
.m_itemIndex 
= GetIndexOfLine( line 
); 
1137     line
->GetItem( 0, le
.m_item 
); 
1138     le
.m_item
.m_text 
= newName
; 
1139     GetParent()->GetEventHandler()->ProcessEvent( le 
); 
1142 void wxListMainWindow::OnRenameTimer() 
1144     StartLabelEdit( m_current 
); 
1146     m_current
->GetText( 0, s 
); 
1151     m_current
->GetLabelExtent( x
, y
, w
, h 
); 
1153     wxClientDC 
dc(this); 
1155     x 
= dc
.LogicalToDeviceX( x 
); 
1156     y 
= dc
.LogicalToDeviceY( y 
); 
1158     wxListTextCtrl 
*text 
= new wxListTextCtrl( 
1159       this, -1, &m_renameAccept
, &m_renameRes
, this, s
, wxPoint(x
-4,y
-4), wxSize(w
+11,h
+8) ); 
1163 void wxListMainWindow::OnRenameAccept() 
1165     RenameLine( m_current
, m_renameRes 
); 
1168 void wxListMainWindow::OnMouse( wxMouseEvent 
&event 
) 
1170     if (GetParent()->GetEventHandler()->ProcessEvent( event
)) return; 
1172     if (!m_current
) return; 
1173     if (m_dirty
) return; 
1175     wxClientDC 
dc(this); 
1177     long x 
= dc
.DeviceToLogicalX( (long)event
.GetX() ); 
1178     long y 
= dc
.DeviceToLogicalY( (long)event
.GetY() ); 
1180     // Did we actually hit an item ? 
1182     wxNode 
*node 
= m_lines
.First(); 
1183     wxListLineData 
*line 
= (wxListLineData 
*) NULL
; 
1186         line 
= (wxListLineData
*)node
->Data(); 
1187         hitResult 
= line
->IsHit( x
, y 
); 
1188         if (hitResult
) break; 
1189         line 
= (wxListLineData 
*) NULL
; 
1190         node 
= node
->Next(); 
1193     if (!event
.Dragging()) 
1198     if (event
.Dragging() && (m_dragCount 
> 3)) 
1202         wxListEvent 
le( wxEVT_COMMAND_LIST_BEGIN_DRAG
, GetParent()->GetId() ); 
1203         le
.SetEventObject( GetParent() ); 
1204         le
.m_pointDrag
.x 
= x
; 
1205         le
.m_pointDrag
.y 
= y
; 
1206         GetParent()->GetEventHandler()->ProcessEvent( le 
); 
1213     if (event
.ButtonDClick()) 
1216         m_lastOnSame 
= FALSE
; 
1217         m_renameTimer
->Stop(); 
1219         SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_ACTIVATED 
); 
1224     if (event
.LeftUp() && m_lastOnSame
) 
1227         if ((line 
== m_current
) && 
1228             (hitResult 
== wxLIST_HITTEST_ONITEMLABEL
) && 
1229             (m_mode 
& wxLC_EDIT_LABELS
)  ) 
1231             m_renameTimer
->Start( 100, TRUE 
); 
1233         m_lastOnSame 
= FALSE
; 
1237     if (event
.RightDown()) 
1239         SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK 
); 
1243     if (event
.MiddleDown()) 
1245         SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK 
); 
1249     if (event
.LeftDown()) 
1252         wxListLineData 
*oldCurrent 
= m_current
; 
1253         if (m_mode 
& wxLC_SINGLE_SEL
) 
1256             HilightAll( FALSE 
); 
1257             m_current
->ReverseHilight(); 
1258             RefreshLine( m_current 
); 
1262             if (event
.ShiftDown()) 
1265                 m_current
->ReverseHilight(); 
1266                 RefreshLine( m_current 
); 
1268             else if (event
.ControlDown()) 
1272                 int numOfCurrent 
= -1; 
1273                 node 
= m_lines
.First(); 
1276                     wxListLineData 
*test_line 
= (wxListLineData
*)node
->Data(); 
1278                     if (test_line 
== oldCurrent
) break; 
1279                     node 
= node
->Next(); 
1283                 node 
= m_lines
.First(); 
1286                     wxListLineData 
*test_line 
= (wxListLineData
*)node
->Data(); 
1288                     if (test_line 
== line
) break; 
1289                     node 
= node
->Next(); 
1292                 if (numOfLine 
< numOfCurrent
) 
1295                     numOfLine 
= numOfCurrent
;  
1299                 wxNode 
*node 
= m_lines
.Nth( numOfCurrent 
); 
1300                 for (int i 
= 0; i 
<= numOfLine
-numOfCurrent
; i
++) 
1302                     wxListLineData 
*test_line
= (wxListLineData
*)node
->Data(); 
1303                     test_line
->Hilight(TRUE
); 
1304                     RefreshLine( test_line 
); 
1305                     node 
= node
->Next(); 
1311                 HilightAll( FALSE 
); 
1312                 m_current
->ReverseHilight(); 
1313                 RefreshLine( m_current 
); 
1316         if (m_current 
!= oldCurrent
) 
1318             RefreshLine( oldCurrent 
); 
1319             UnfocusLine( oldCurrent 
); 
1320             FocusLine( m_current 
); 
1322         m_lastOnSame 
= (m_current 
== oldCurrent
); 
1327 void wxListMainWindow::MoveToFocus( void ) 
1329     if (!m_current
) return; 
1335     m_current
->GetExtent( x
, y
, w
, h 
); 
1339     GetClientSize( &w_p
, &h_p 
); 
1341     if (m_mode 
& wxLC_REPORT
) 
1343         int y_s 
= m_yScroll
*GetScrollPos( wxVERTICAL 
); 
1344         if ((y 
> y_s
) && (y
+h 
< y_s
+h_p
)) return; 
1345         if (y
-y_s 
< 5) Scroll( -1, (y
-5-h_p
/2)/m_yScroll 
); 
1346         if (y
+h
+5 > y_s
+h_p
) Scroll( -1, (y
+h
-h_p
/2+h
+15)/m_yScroll 
); 
1350         int x_s 
= m_xScroll
*GetScrollPos( wxHORIZONTAL 
); 
1351         if ((x 
> x_s
) && (x
+w 
< x_s
+w_p
)) return; 
1352         if (x
-x_s 
< 5) Scroll( (x
-5)/m_xScroll
, -1 ); 
1353         if (x
+w
-5 > x_s
+w_p
) Scroll( (x
+w
-w_p
+15)/m_xScroll
, -1 ); 
1357 void wxListMainWindow::OnArrowChar( wxListLineData 
*newCurrent
, bool shiftDown 
) 
1359     if ((m_mode 
& wxLC_SINGLE_SEL
) || (m_usedKeys 
== FALSE
)) m_current
->Hilight( FALSE 
); 
1360     wxListLineData 
*oldCurrent 
= m_current
; 
1361     m_current 
= newCurrent
; 
1363     if (shiftDown 
|| (m_mode 
& wxLC_SINGLE_SEL
)) m_current
->Hilight( TRUE 
); 
1364     RefreshLine( m_current 
); 
1365     RefreshLine( oldCurrent 
); 
1366     FocusLine( m_current 
); 
1367     UnfocusLine( oldCurrent 
); 
1370 void wxListMainWindow::OnChar( wxKeyEvent 
&event 
) 
1372   wxListEvent 
le( wxEVT_COMMAND_LIST_KEY_DOWN
, m_parent
->GetId() ); 
1373   le
.m_code 
= event
.KeyCode(); 
1374   le
.SetEventObject( m_parent 
); 
1375   m_parent
->GetEventHandler()->ProcessEvent( le 
); 
1378   if (event.KeyCode() == WXK_TAB) 
1380     if (event.ShiftDown()) 
1387   if (!m_current
) return; 
1388   switch (event
.KeyCode()) 
1392       wxNode 
*node 
= m_lines
.Member( m_current 
)->Previous(); 
1393       if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1398       wxNode 
*node 
= m_lines
.Member( m_current 
)->Next(); 
1399       if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1404       wxNode 
*node 
= m_lines
.Last(); 
1405       OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1410       wxNode 
*node 
= m_lines
.First(); 
1411       OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1417       if (m_mode 
& wxLC_REPORT
) { steps 
= m_visibleLines
-1; } 
1421         wxNode 
*node 
= m_lines
.First(); 
1422         for (;;) { if (m_current 
== (wxListLineData
*)node
->Data()) break; pos
++; node 
= node
->Next(); } 
1423         steps 
= pos 
% m_visibleLines
; 
1425       wxNode 
*node 
= m_lines
.Member( m_current 
); 
1426       for (int i 
= 0; i 
< steps
; i
++) if (node
->Previous()) node 
= node
->Previous(); 
1427       if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1433       if (m_mode 
& wxLC_REPORT
) { steps 
= m_visibleLines
-1; } 
1436         int pos 
= 0; wxNode 
*node 
= m_lines
.First(); 
1437         for (;;) { if (m_current 
== (wxListLineData
*)node
->Data()) break; pos
++; node 
= node
->Next(); } 
1438         steps 
= m_visibleLines
-(pos 
% m_visibleLines
)-1; 
1440       wxNode 
*node 
= m_lines
.Member( m_current 
); 
1441       for (int i 
= 0; i 
< steps
; i
++) if (node
->Next()) node 
= node
->Next(); 
1442       if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1447       if (!(m_mode 
& wxLC_REPORT
)) 
1449         wxNode 
*node 
= m_lines
.Member( m_current 
); 
1450         for (int i 
= 0; i 
<m_visibleLines
; i
++) if (node
->Previous()) node 
= node
->Previous(); 
1451         if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1457       if (!(m_mode 
& wxLC_REPORT
)) 
1459         wxNode 
*node 
= m_lines
.Member( m_current 
); 
1460         for (int i 
= 0; i 
<m_visibleLines
; i
++) if (node
->Next()) node 
= node
->Next(); 
1461         if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1467       m_current
->ReverseHilight(); 
1468       RefreshLine( m_current 
); 
1473       if (!(m_mode 
& wxLC_SINGLE_SEL
)) 
1475         wxListLineData 
*oldCurrent 
= m_current
; 
1476         m_current
->ReverseHilight(); 
1477         wxNode 
*node 
= m_lines
.Member( m_current 
)->Next(); 
1478         if (node
) m_current 
= (wxListLineData
*)node
->Data(); 
1480         RefreshLine( oldCurrent 
); 
1481         RefreshLine( m_current 
); 
1482         UnfocusLine( oldCurrent 
); 
1483         FocusLine( m_current 
); 
1490       wxListEvent 
le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
, GetParent()->GetId() ); 
1491       le
.SetEventObject( GetParent() ); 
1492       le
.m_itemIndex 
= GetIndexOfLine( m_current 
); 
1493       m_current
->GetItem( 0, le
.m_item 
); 
1494       GetParent()->GetEventHandler()->ProcessEvent( le 
); 
1506 void wxListMainWindow::OnSetFocus( wxFocusEvent 
&WXUNUSED(event
) ) 
1509   RefreshLine( m_current 
); 
1511   if (!GetParent()) return; 
1513   wxFocusEvent 
event( wxEVT_SET_FOCUS
, GetParent()->GetId() ); 
1514   event
.SetEventObject( GetParent() ); 
1515   GetParent()->GetEventHandler()->ProcessEvent( event 
); 
1518 void wxListMainWindow::OnKillFocus( wxFocusEvent 
&WXUNUSED(event
) ) 
1521   RefreshLine( m_current 
); 
1524 void wxListMainWindow::OnSize( wxSizeEvent 
&WXUNUSED(event
) ) 
1527   We don't even allow the wxScrolledWindow::AdjustScrollbars() call 
1529   CalculatePositions(); 
1530   printf( "OnSize::Refresh.\n" ); 
1536 void wxListMainWindow::DrawImage( int index
, wxPaintDC 
*dc
, int x
, int y 
) 
1538   if ((m_mode 
& wxLC_ICON
) && (m_normal_image_list
)) 
1540     m_normal_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT 
); 
1543   if ((m_mode 
& wxLC_SMALL_ICON
) && (m_small_image_list
)) 
1545     m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT 
); 
1547   if ((m_mode 
& wxLC_REPORT
) && (m_small_image_list
)) 
1549     m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT 
); 
1554 void wxListMainWindow::GetImageSize( int index
, int &width
, int &height 
) 
1556   if ((m_mode 
& wxLC_ICON
) && (m_normal_image_list
)) 
1558     m_normal_image_list
->GetSize( index
, width
, height 
); 
1561   if ((m_mode 
& wxLC_SMALL_ICON
) && (m_small_image_list
)) 
1563     m_small_image_list
->GetSize( index
, width
, height 
); 
1566   if ((m_mode 
& wxLC_REPORT
) && (m_small_image_list
)) 
1568     m_small_image_list
->GetSize( index
, width
, height 
); 
1575 int wxListMainWindow::GetTextLength( wxString 
&s 
) 
1577     wxPaintDC 
dc( this ); 
1580     dc
.GetTextExtent( s
, &lw
, &lh 
); 
1584 int wxListMainWindow::GetIndexOfLine( const wxListLineData 
*line 
) 
1587     wxNode 
*node 
= m_lines
.First(); 
1590         if (line 
== (wxListLineData
*)node
->Data()) return i
; 
1592         node 
= node
->Next(); 
1597 void wxListMainWindow::SetImageList( wxImageList 
*imageList
, int which 
) 
1600     if (which 
== wxIMAGE_LIST_NORMAL
) m_normal_image_list 
= imageList
; 
1601     if (which 
== wxIMAGE_LIST_SMALL
) m_small_image_list 
= imageList
; 
1604 void wxListMainWindow::SetItemSpacing( int spacing
, bool isSmall 
) 
1609         m_small_spacing 
= spacing
; 
1613         m_normal_spacing 
= spacing
; 
1617 int wxListMainWindow::GetItemSpacing( bool isSmall 
) 
1619     if (isSmall
) return m_small_spacing
; else return m_normal_spacing
; 
1622 void wxListMainWindow::SetColumn( int col
, wxListItem 
&item 
) 
1625   wxNode 
*node 
= m_columns
.Nth( col 
); 
1628     if (item
.m_width 
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width 
= GetTextLength( item
.m_text 
)+7; 
1629     wxListHeaderData 
*column 
= (wxListHeaderData
*)node
->Data(); 
1630     column
->SetItem( item 
); 
1632   wxListCtrl 
*lc 
= (wxListCtrl
*) GetParent(); 
1633   if (lc
->m_headerWin
) lc
->m_headerWin
->Refresh(); 
1636 void wxListMainWindow::SetColumnWidth( int col
, int width 
) 
1638   if (!(m_mode 
& wxLC_REPORT
)) return; 
1642   wxNode 
*node 
= m_columns
.Nth( col 
); 
1645     wxListHeaderData 
*column 
= (wxListHeaderData
*)node
->Data(); 
1646     column
->SetWidth( width 
); 
1649   node 
= m_lines
.First(); 
1652     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1653     wxNode 
*n 
= line
->m_items
.Nth( col 
); 
1656       wxListItemData 
*item 
= (wxListItemData
*)n
->Data(); 
1657       item
->SetSize( width
, -1 ); 
1659     node 
= node
->Next(); 
1662   wxListCtrl 
*lc 
= (wxListCtrl
*) GetParent(); 
1663   if (lc
->m_headerWin
) lc
->m_headerWin
->Refresh(); 
1666 void wxListMainWindow::GetColumn( int col
, wxListItem 
&item 
) 
1668   wxNode 
*node 
= m_columns
.Nth( col 
); 
1671     wxListHeaderData 
*column 
= (wxListHeaderData
*)node
->Data(); 
1672     column
->GetItem( item 
); 
1684 int wxListMainWindow::GetColumnWidth( int col 
) 
1686     wxNode 
*node 
= m_columns
.Nth( col 
); 
1689         wxListHeaderData 
*column 
= (wxListHeaderData
*)node
->Data(); 
1690         return column
->GetWidth(); 
1698 int wxListMainWindow::GetColumnCount( void ) 
1700     return m_columns
.Number(); 
1703 int wxListMainWindow::GetCountPerPage( void ) 
1705     return m_visibleLines
; 
1708 void wxListMainWindow::SetItem( wxListItem 
&item 
) 
1711     wxNode 
*node 
= m_lines
.Nth( item
.m_itemId 
); 
1714         wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1715         if (m_mode 
& wxLC_REPORT
) item
.m_width 
= GetColumnWidth( item
.m_col 
)-3; 
1716         line
->SetItem( item
.m_col
, item 
); 
1720 void wxListMainWindow::SetItemState( long item
, long state
, long stateMask 
) 
1722     // m_dirty = TRUE; no recalcs needed 
1724     wxListLineData 
*oldCurrent 
= m_current
; 
1726     if (stateMask 
& wxLIST_STATE_FOCUSED
) 
1728         wxNode 
*node 
= m_lines
.Nth( item 
); 
1731             wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1732             UnfocusLine( m_current 
); 
1734             FocusLine( m_current 
); 
1735             RefreshLine( m_current 
); 
1736             RefreshLine( oldCurrent 
); 
1740     if (stateMask 
& wxLIST_STATE_SELECTED
) 
1742         bool on 
= state 
& wxLIST_STATE_SELECTED
; 
1743         if (!on 
&& (m_mode 
& wxLC_SINGLE_SEL
)) return; 
1745         wxNode 
*node 
= m_lines
.Nth( item 
); 
1748             wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1749             if (m_mode 
& wxLC_SINGLE_SEL
) 
1751                 UnfocusLine( m_current 
); 
1753                 FocusLine( m_current 
); 
1754                 oldCurrent
->Hilight( FALSE 
); 
1755                 RefreshLine( m_current 
); 
1756                 RefreshLine( oldCurrent 
); 
1758             bool on 
= state 
& wxLIST_STATE_SELECTED
; 
1759             if (on 
!= line
->IsHilighted()) 
1761                 line
->Hilight( on 
); 
1762                 RefreshLine( line 
); 
1768 int wxListMainWindow::GetItemState( long item
, long stateMask 
) 
1770     int ret 
= wxLIST_STATE_DONTCARE
; 
1771     if (stateMask 
& wxLIST_STATE_FOCUSED
) 
1773         wxNode 
*node 
= m_lines
.Nth( item 
); 
1776             wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1777             if (line 
== m_current
) ret 
|= wxLIST_STATE_FOCUSED
; 
1780     if (stateMask 
& wxLIST_STATE_SELECTED
) 
1782         wxNode 
*node 
= m_lines
.Nth( item 
); 
1785             wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1786             if (line
->IsHilighted()) ret 
|= wxLIST_STATE_FOCUSED
; 
1792 void wxListMainWindow::GetItem( wxListItem 
&item 
) 
1794     wxNode 
*node 
= m_lines
.Nth( item
.m_itemId 
); 
1797         wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1798         line
->GetItem( item
.m_col
, item 
); 
1809 int wxListMainWindow::GetItemCount( void ) 
1811     return m_lines
.Number(); 
1814 void wxListMainWindow::GetItemRect( long index
, wxRectangle 
&rect 
) 
1816     wxNode 
*node 
= m_lines
.Nth( index 
); 
1819         wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1820         line
->GetRect( rect 
); 
1831 bool wxListMainWindow::GetItemPosition(long item
, wxPoint
& pos
) 
1833     wxNode 
*node 
= m_lines
.Nth( item 
); 
1837         wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1838         line
->GetRect( rect 
); 
1850 int wxListMainWindow::GetSelectedItemCount( void ) 
1853     wxNode 
*node 
= m_lines
.First(); 
1856         wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1857         if (line
->IsHilighted()) ret
++; 
1858         node 
= node
->Next(); 
1863 void wxListMainWindow::SetMode( long mode 
) 
1870     if (m_mode 
& wxLC_REPORT
) 
1882 long wxListMainWindow::GetMode( void ) const 
1887 void wxListMainWindow::CalculatePositions( void ) 
1889     if (!m_lines
.First()) return; 
1891     wxPaintDC 
dc( this ); 
1892     dc
.SetFont( GetFont() ); 
1894     int iconSpacing 
= 0; 
1895     if (m_mode 
& wxLC_ICON
) iconSpacing 
= m_normal_spacing
; 
1896     if (m_mode 
& wxLC_SMALL_ICON
) iconSpacing 
= m_small_spacing
; 
1898     // we take the first line (which also can be an icon or 
1899     // an a text item in wxLC_ICON and wxLC_LIST modes) to 
1900     // measure the size of the line 
1904     int lineSpacing 
= 0; 
1906     wxListLineData 
*line 
= (wxListLineData
*)m_lines
.First()->Data(); 
1907     line
->CalculateSize( &dc
, iconSpacing 
); 
1909     line
->GetSize( dummy
, lineSpacing 
); 
1912     int clientWidth 
= 0; 
1913     int clientHeight 
= 0; 
1915     if (m_mode 
& wxLC_REPORT
) 
1919         int entireHeight 
= m_lines
.Number() * lineSpacing 
+ 2; 
1920         int scroll_pos 
= GetScrollPos( wxVERTICAL 
); 
1921         SetScrollbars( m_xScroll
, m_yScroll
, 0, (entireHeight
+15) / m_yScroll
, 0, scroll_pos
, TRUE 
); 
1922         GetClientSize( &clientWidth
, &clientHeight 
); 
1924         wxNode
* node 
= m_lines
.First(); 
1927             wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1928             line
->CalculateSize( &dc
, iconSpacing 
); 
1929             line
->SetPosition( &dc
, x
, y
, clientWidth 
); 
1931             for (int i 
= 0; i 
< GetColumnCount(); i
++) 
1933                 line
->SetColumnPosition( i
, col_x 
); 
1934                 col_x 
+= GetColumnWidth( i 
); 
1936             y 
+= lineSpacing
;  // one pixel blank line between items 
1937             node 
= node
->Next(); 
1939         m_visibleLines 
= clientHeight 
/ lineSpacing
; 
1943         // at first we try without any scrollbar. if the items don't 
1944         // fit into the window, we recalculate after subtracting an 
1945         // approximated 15 pt for the horizontal scrollbar 
1947         GetSize( &clientWidth
, &clientHeight 
); 
1948         clientHeight 
-= 4;  // sunken frame 
1950         int entireWidth 
= 0; 
1952         for (int tries 
= 0; tries 
< 2; tries
++) 
1955             int x 
= 5;  // painting is done at x-2 
1956             int y 
= 5;  // painting is done at y-2 
1958             wxNode 
*node 
= m_lines
.First(); 
1961                 wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1962                 line
->CalculateSize( &dc
, iconSpacing 
); 
1963                 line
->SetPosition( &dc
, x
, y
, clientWidth 
); 
1964                 line
->GetSize( lineWidth
, lineHeight 
); 
1965                 if (lineWidth 
> maxWidth
) maxWidth 
= lineWidth
; 
1967                 if (y
+lineSpacing
-6 >= clientHeight
) // -6 for earlier "line breaking" 
1971                     entireWidth 
+= maxWidth
+6; 
1974                 node 
= node
->Next(); 
1975                 if (!node
) entireWidth 
+= maxWidth
; 
1976                 if ((tries 
== 0) && (entireWidth 
> clientWidth
)) 
1978                     clientHeight 
-= 15; // scrollbar height 
1981                 if (!node
) tries 
= 1;  // everything fits, no second try required 
1984         m_visibleLines 
= (clientHeight
+6) / (lineSpacing
); // +6 for earlier "line breaking" 
1986         int scroll_pos 
= GetScrollPos( wxHORIZONTAL 
); 
1987         SetScrollbars( m_xScroll
, m_yScroll
, (entireWidth
+15) / m_xScroll
, 0, scroll_pos
, 0, TRUE 
); 
1991 void wxListMainWindow::RealizeChanges( void ) 
1995         wxNode 
*node 
= m_lines
.First(); 
1996         if (node
) m_current 
= (wxListLineData
*)node
->Data(); 
2000         FocusLine( m_current 
); 
2001         if (m_mode 
& wxLC_SINGLE_SEL
) m_current
->Hilight( TRUE 
); 
2005 long wxListMainWindow::GetNextItem( long item
, int WXUNUSED(geometry
), int state 
) 
2008   if (item 
> 0) ret 
= item
; 
2009   wxNode 
*node 
= m_lines
.Nth( ret 
); 
2012     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
2013     if ((state 
& wxLIST_STATE_FOCUSED
) && (line 
== m_current
)) return ret
; 
2014     if ((state 
& wxLIST_STATE_SELECTED
) && (line
->IsHilighted())) return ret
; 
2015     if (!state
) return ret
; 
2017     node 
= node
->Next(); 
2022 void wxListMainWindow::DeleteItem( long index 
) 
2025   wxNode 
*node 
= m_lines
.Nth( index 
); 
2028     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
2029     if (m_current 
== line
) m_current 
= (wxListLineData 
*) NULL
; 
2031     m_lines
.DeleteNode( node 
); 
2035 void wxListMainWindow::DeleteColumn( int col 
) 
2037   wxCHECK_RET( col 
< (int)m_columns
.GetCount(), 
2038                "attempting to delete inexistent column in wxListView" ); 
2041   wxNode 
*node 
= m_columns
.Nth( col 
); 
2042   if (node
) m_columns
.DeleteNode( node 
); 
2045 void wxListMainWindow::DeleteAllItems( void ) 
2048   m_current 
= (wxListLineData 
*) NULL
; 
2049   wxNode 
*node 
= m_lines
.First(); 
2052     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
2054     node 
= node
->Next(); 
2059 void wxListMainWindow::DeleteEverything( void ) 
2062   m_current 
= (wxListLineData 
*) NULL
; 
2063   wxNode 
*node 
= m_lines
.First(); 
2066     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
2068     node 
= node
->Next(); 
2071   m_current 
= (wxListLineData 
*) NULL
; 
2075 void wxListMainWindow::EnsureVisible( long index 
) 
2077   wxListLineData 
*oldCurrent 
= m_current
; 
2078   m_current 
= (wxListLineData 
*) NULL
; 
2080   wxNode 
*node 
= m_lines
.Nth( i 
); 
2081   if (node
) m_current 
= (wxListLineData
*)node
->Data(); 
2082   if (m_current
) MoveToFocus(); 
2083   m_current 
= oldCurrent
; 
2086 long wxListMainWindow::FindItem(long start
, const wxString
& str
, bool WXUNUSED(partial
) ) 
2090   if (pos 
< 0) pos 
= 0; 
2091   wxNode 
*node 
= m_lines
.Nth( pos 
); 
2094     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
2096     line
->GetText( 0, s 
); 
2097     if (s 
== tmp
) return pos
; 
2098     node 
= node
->Next(); 
2104 long wxListMainWindow::FindItem(long start
, long data
) 
2107   if (pos 
< 0) pos 
= 0; 
2108   wxNode 
*node 
= m_lines
.Nth( pos 
); 
2111     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
2113     line
->GetItem( 0, item 
); 
2114     if (item
.m_data 
== data
) return pos
; 
2115     node 
= node
->Next(); 
2121 long wxListMainWindow::HitTest( int x
, int y
, int &flags 
) 
2123   wxNode 
*node 
= m_lines
.First(); 
2127     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
2128     long ret 
= line
->IsHit( x
, y 
); 
2134     node 
= node
->Next(); 
2140 void wxListMainWindow::InsertItem( wxListItem 
&item 
) 
2144   if (m_mode 
& wxLC_REPORT
) mode 
= wxLC_REPORT
; 
2145   else if (m_mode 
& wxLC_LIST
) mode 
= wxLC_LIST
; 
2146   else if (m_mode 
& wxLC_ICON
) mode 
= wxLC_ICON
; 
2147   else if (m_mode 
& wxLC_SMALL_ICON
) mode 
= wxLC_ICON
;  // no typo 
2148   wxListLineData 
*line 
= new wxListLineData( this, mode
, m_hilightBrush 
); 
2149   if (m_mode 
& wxLC_REPORT
) 
2151     line
->InitItems( GetColumnCount() ); 
2152     item
.m_width 
= GetColumnWidth( 0 )-3; 
2155     line
->InitItems( 1 ); 
2156   line
->SetItem( 0, item 
); 
2157   if ((item
.m_itemId 
>= 0) && (item
.m_itemId 
< (int)m_lines
.GetCount())) 
2159      wxNode 
*node 
= m_lines
.Nth( item
.m_itemId 
); 
2160      if (node
) m_lines
.Insert( node
, line 
); 
2164     m_lines
.Append( line 
); 
2168 void wxListMainWindow::InsertColumn( long col
, wxListItem 
&item 
) 
2171   if (m_mode 
& wxLC_REPORT
) 
2173     if (item
.m_width 
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width 
= GetTextLength( item
.m_text 
); 
2174     wxListHeaderData 
*column 
= new wxListHeaderData( item 
); 
2175     if ((col 
>= 0) && (col 
< (int)m_columns
.GetCount())) 
2177       wxNode 
*node 
= m_columns
.Nth( col 
); 
2179         m_columns
.Insert( node
, column 
); 
2183       m_columns
.Append( column 
); 
2188 wxListCtrlCompare list_ctrl_compare_func_2
; 
2189 long              list_ctrl_compare_data
; 
2191 int list_ctrl_compare_func_1( const void *arg1
, const void *arg2 
) 
2193   wxListLineData 
*line1 
= *((wxListLineData
**)arg1
); 
2194   wxListLineData 
*line2 
= *((wxListLineData
**)arg2
); 
2196   line1
->GetItem( 0, item 
); 
2197   long data1 
= item
.m_data
; 
2198   line2
->GetItem( 0, item 
); 
2199   long data2 
= item
.m_data
; 
2200   return list_ctrl_compare_func_2( data1
, data2
, list_ctrl_compare_data 
); 
2203 void wxListMainWindow::SortItems( wxListCtrlCompare fn
, long data 
) 
2205   list_ctrl_compare_func_2 
= fn
; 
2206   list_ctrl_compare_data 
= data
; 
2207   m_lines
.Sort( list_ctrl_compare_func_1 
); 
2210 // ------------------------------------------------------------------------------------- 
2212 // ------------------------------------------------------------------------------------- 
2214 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
) 
2216 wxListItem::wxListItem(void) 
2225   m_format 
= wxLIST_FORMAT_CENTRE
; 
2230 // ------------------------------------------------------------------------------------- 
2232 // ------------------------------------------------------------------------------------- 
2234 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
) 
2236 wxListEvent::wxListEvent( wxEventType commandType
, int id 
): 
2237   wxNotifyEvent( commandType
, id 
) 
2243   m_cancelled 
= FALSE
; 
2248 // ------------------------------------------------------------------------------------- 
2250 // ------------------------------------------------------------------------------------- 
2252 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
) 
2254 BEGIN_EVENT_TABLE(wxListCtrl
,wxControl
) 
2255   EVT_SIZE          (wxListCtrl::OnSize
) 
2256   EVT_IDLE          (wxListCtrl::OnIdle
) 
2259 wxListCtrl::wxListCtrl(void) 
2261   m_imageListNormal 
= (wxImageList 
*) NULL
; 
2262   m_imageListSmall 
= (wxImageList 
*) NULL
; 
2263   m_imageListState 
= (wxImageList 
*) NULL
; 
2264   m_mainWin 
= (wxListMainWindow
*) NULL
; 
2265   m_headerWin 
= (wxListHeaderWindow
*) NULL
; 
2268 wxListCtrl::~wxListCtrl(void) 
2272 bool wxListCtrl::Create( wxWindow 
*parent
, wxWindowID id
, 
2273       const wxPoint 
&pos
, const wxSize 
&size
, 
2274       long style
, const wxValidator 
&validator
, 
2275       const wxString 
&name 
) 
2277   m_imageListNormal 
= (wxImageList 
*) NULL
; 
2278   m_imageListSmall 
= (wxImageList 
*) NULL
; 
2279   m_imageListState 
= (wxImageList 
*) NULL
; 
2280   m_mainWin 
= (wxListMainWindow
*) NULL
; 
2281   m_headerWin 
= (wxListHeaderWindow
*) NULL
; 
2285   if ((s 
& wxLC_REPORT 
== 0) && 
2286       (s 
& wxLC_LIST 
== 0) && 
2287       (s 
& wxLC_ICON 
== 0)) 
2290   bool ret 
= wxControl::Create( parent
, id
, pos
, size
, s
, name 
); 
2292   SetValidator( validator 
); 
2294   if (s 
& wxSUNKEN_BORDER
) s 
-= wxSUNKEN_BORDER
; 
2296   m_mainWin 
= new wxListMainWindow( this, -1, wxPoint(0,0), size
, s 
); 
2298   if (GetWindowStyleFlag() & wxLC_REPORT
) 
2299     m_headerWin 
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(size
.x
,23) ); 
2301     m_headerWin 
= (wxListHeaderWindow 
*) NULL
; 
2306 void wxListCtrl::OnSize( wxSizeEvent 
&WXUNUSED(event
) ) 
2308   // handled in OnIdle 
2310   if (m_mainWin
) m_mainWin
->m_dirty 
= TRUE
; 
2313 void wxListCtrl::SetSingleStyle( long style
, bool add 
) 
2315   long flag 
= GetWindowStyleFlag(); 
2319     if (style 
& wxLC_MASK_TYPE
)  flag 
= flag 
& ~wxLC_MASK_TYPE
; 
2320     if (style 
& wxLC_MASK_ALIGN
) flag 
= flag 
& ~wxLC_MASK_ALIGN
; 
2321     if (style 
& wxLC_MASK_SORT
) flag 
= flag 
& ~wxLC_MASK_SORT
; 
2330     if (flag 
& style
) flag 
-= style
; 
2333   SetWindowStyleFlag( flag 
); 
2336 void wxListCtrl::SetWindowStyleFlag( long flag 
) 
2338   m_mainWin
->DeleteEverything(); 
2342   GetClientSize( &width
, &height 
); 
2344   m_mainWin
->SetMode( flag 
); 
2346   if (flag 
& wxLC_REPORT
) 
2348     if (!(GetWindowStyleFlag() & wxLC_REPORT
)) 
2350 //      m_mainWin->SetSize( 0, 24, width, height-24 ); 
2353         m_headerWin 
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(width
,23) ); 
2357 //        m_headerWin->SetSize( 0, 0, width, 23 ); 
2358         m_headerWin
->Show( TRUE 
); 
2364     if (GetWindowStyleFlag() & wxLC_REPORT
) 
2366 //      m_mainWin->SetSize( 0, 0, width, height ); 
2367       m_headerWin
->Show( FALSE 
); 
2371   wxWindow::SetWindowStyleFlag( flag 
); 
2374 bool wxListCtrl::GetColumn(int col
, wxListItem 
&item
) const 
2376   m_mainWin
->GetColumn( col
, item 
); 
2380 bool wxListCtrl::SetColumn( int col
, wxListItem
& item 
) 
2382   m_mainWin
->SetColumn( col
, item 
); 
2386 int wxListCtrl::GetColumnWidth( int col 
) const 
2388   return m_mainWin
->GetColumnWidth( col 
); 
2391 bool wxListCtrl::SetColumnWidth( int col
, int width 
) 
2393   m_mainWin
->SetColumnWidth( col
, width 
); 
2397 int wxListCtrl::GetCountPerPage(void) const 
2399   return m_mainWin
->GetCountPerPage();  // different from Windows ? 
2403 wxText& wxListCtrl::GetEditControl(void) const 
2408 bool wxListCtrl::GetItem( wxListItem 
&info 
) const 
2410   m_mainWin
->GetItem( info 
); 
2414 bool wxListCtrl::SetItem( wxListItem 
&info 
) 
2416   m_mainWin
->SetItem( info 
); 
2420 long wxListCtrl::SetItem( long index
, int col
, const wxString
& label
, int imageId 
) 
2423   info
.m_text 
= label
; 
2424   info
.m_mask 
= wxLIST_MASK_TEXT
; 
2425   info
.m_itemId 
= index
; 
2429     info
.m_image 
= imageId
; 
2430     info
.m_mask 
|= wxLIST_MASK_IMAGE
; 
2433   m_mainWin
->SetItem(info
); 
2437 int wxListCtrl::GetItemState( long item
, long stateMask 
) const 
2439   return m_mainWin
->GetItemState( item
, stateMask 
); 
2442 bool wxListCtrl::SetItemState( long item
, long state
, long stateMask 
) 
2444   m_mainWin
->SetItemState( item
, state
, stateMask 
); 
2448 bool wxListCtrl::SetItemImage( long item
, int image
, int WXUNUSED(selImage
) ) 
2451   info
.m_image 
= image
; 
2452   info
.m_mask 
= wxLIST_MASK_IMAGE
; 
2453   info
.m_itemId 
= item
; 
2454   m_mainWin
->SetItem( info 
); 
2458 wxString 
wxListCtrl::GetItemText( long item 
) const 
2461   info
.m_itemId 
= item
; 
2462   m_mainWin
->GetItem( info 
); 
2466 void wxListCtrl::SetItemText( long item
, const wxString 
&str 
) 
2469   info
.m_mask 
= wxLIST_MASK_TEXT
; 
2470   info
.m_itemId 
= item
; 
2472   m_mainWin
->SetItem( info 
); 
2475 long wxListCtrl::GetItemData( long item 
) const 
2478   info
.m_itemId 
= item
; 
2479   m_mainWin
->GetItem( info 
); 
2483 bool wxListCtrl::SetItemData( long item
, long data 
) 
2486   info
.m_mask 
= wxLIST_MASK_DATA
; 
2487   info
.m_itemId 
= item
; 
2489   m_mainWin
->SetItem( info 
); 
2493 bool wxListCtrl::GetItemRect( long item
, wxRectangle 
&rect
,  int WXUNUSED(code
) ) const 
2495   m_mainWin
->GetItemRect( item
, rect 
); 
2499 bool wxListCtrl::GetItemPosition( long item
, wxPoint
& pos 
) const 
2501   m_mainWin
->GetItemPosition( item
, pos 
); 
2505 bool wxListCtrl::SetItemPosition( long WXUNUSED(item
), const wxPoint
& WXUNUSED(pos
) ) 
2510 int wxListCtrl::GetItemCount(void) const 
2512   return m_mainWin
->GetItemCount(); 
2515 int wxListCtrl::GetColumnCount(void) const 
2517   return m_mainWin
->GetColumnCount(); 
2520 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall 
) 
2522   m_mainWin
->SetItemSpacing( spacing
, isSmall 
); 
2525 int wxListCtrl::GetItemSpacing( bool isSmall 
) const 
2527   return m_mainWin
->GetItemSpacing( isSmall 
); 
2530 int wxListCtrl::GetSelectedItemCount(void) const 
2532   return m_mainWin
->GetSelectedItemCount(); 
2536 wxColour wxListCtrl::GetTextColour(void) const 
2540 void wxListCtrl::SetTextColour(const wxColour& WXUNUSED(col)) 
2545 long wxListCtrl::GetTopItem(void) const 
2550 long wxListCtrl::GetNextItem( long item
, int geom
, int state 
) const 
2552   return m_mainWin
->GetNextItem( item
, geom
, state 
); 
2555 wxImageList 
*wxListCtrl::GetImageList(int which
) const 
2557   if (which 
== wxIMAGE_LIST_NORMAL
) 
2559     return m_imageListNormal
; 
2561   else if (which 
== wxIMAGE_LIST_SMALL
) 
2563     return m_imageListSmall
; 
2565   else if (which 
== wxIMAGE_LIST_STATE
) 
2567     return m_imageListState
; 
2569   return (wxImageList 
*) NULL
; 
2572 void wxListCtrl::SetImageList( wxImageList 
*imageList
, int which 
) 
2574   m_mainWin
->SetImageList( imageList
, which 
); 
2577 bool wxListCtrl::Arrange( int WXUNUSED(flag
) ) 
2582 bool wxListCtrl::DeleteItem( long item 
) 
2584   m_mainWin
->DeleteItem( item 
); 
2588 bool wxListCtrl::DeleteAllItems(void) 
2590   m_mainWin
->DeleteAllItems(); 
2594 void wxListCtrl::DeleteAllColumns() 
2596     for ( size_t n 
= 0; n 
< m_mainWin
->m_columns
.GetCount(); n
++ ) 
2600 bool wxListCtrl::DeleteColumn( int col 
) 
2602   m_mainWin
->DeleteColumn( col 
); 
2607 wxText& wxListCtrl::Edit( long WXUNUSED(item ) ) 
2612 bool wxListCtrl::EnsureVisible( long item 
) 
2614   m_mainWin
->EnsureVisible( item 
); 
2618 long wxListCtrl::FindItem( long start
, const wxString
& str
,  bool partial 
) 
2620   return m_mainWin
->FindItem( start
, str
, partial 
); 
2623 long wxListCtrl::FindItem( long start
, long data 
) 
2625   return m_mainWin
->FindItem( start
, data 
); 
2628 long wxListCtrl::FindItem( long WXUNUSED(start
), const wxPoint
& WXUNUSED(pt
), 
2629                            int WXUNUSED(direction
)) 
2634 long wxListCtrl::HitTest( const wxPoint 
&point
, int &flags 
) 
2636   return m_mainWin
->HitTest( (int)point
.x
, (int)point
.y
, flags 
); 
2639 long wxListCtrl::InsertItem( wxListItem
& info 
) 
2641   m_mainWin
->InsertItem( info 
); 
2645 long wxListCtrl::InsertItem( long index
, const wxString 
&label 
) 
2648   info
.m_text 
= label
; 
2649   info
.m_mask 
= wxLIST_MASK_TEXT
; 
2650   info
.m_itemId 
= index
; 
2651   return InsertItem( info 
); 
2654 long wxListCtrl::InsertItem( long index
, int imageIndex 
) 
2657   info
.m_mask 
= wxLIST_MASK_IMAGE
; 
2658   info
.m_image 
= imageIndex
; 
2659   info
.m_itemId 
= index
; 
2660   return InsertItem( info 
); 
2663 long wxListCtrl::InsertItem( long index
, const wxString 
&label
, int imageIndex 
) 
2666   info
.m_text 
= label
; 
2667   info
.m_image 
= imageIndex
; 
2668   info
.m_mask 
= wxLIST_MASK_TEXT 
| wxLIST_MASK_IMAGE
; 
2669   info
.m_itemId 
= index
; 
2670   return InsertItem( info 
); 
2673 long wxListCtrl::InsertColumn( long col
, wxListItem 
&item 
) 
2675   m_mainWin
->InsertColumn( col
, item 
); 
2679 long wxListCtrl::InsertColumn( long col
, const wxString 
&heading
, 
2680                                int format
, int width 
) 
2683   item
.m_mask 
= wxLIST_MASK_TEXT 
| wxLIST_MASK_FORMAT
; 
2684   item
.m_text 
= heading
; 
2687     item
.m_mask 
|= wxLIST_MASK_WIDTH
; 
2688     item
.m_width 
= width
; 
2691   item
.m_format 
= format
; 
2693   return InsertColumn( col
, item 
); 
2696 bool wxListCtrl::ScrollList( int WXUNUSED(dx
), int WXUNUSED(dy
) ) 
2702 // fn is a function which takes 3 long arguments: item1, item2, data. 
2703 // item1 is the long data associated with a first item (NOT the index). 
2704 // item2 is the long data associated with a second item (NOT the index). 
2705 // data is the same value as passed to SortItems. 
2706 // The return value is a negative number if the first item should precede the second 
2707 // item, a positive number of the second item should precede the first, 
2708 // or zero if the two items are equivalent. 
2709 // data is arbitrary data to be passed to the sort function. 
2711 bool wxListCtrl::SortItems( wxListCtrlCompare fn
, long data 
) 
2713   m_mainWin
->SortItems( fn
, data 
); 
2717 void wxListCtrl::OnIdle( wxIdleEvent 
&WXUNUSED(event
) ) 
2719   if (!m_mainWin
->m_dirty
) return; 
2723   GetClientSize( &cw
, &ch 
); 
2730   if (GetWindowStyleFlag() & wxLC_REPORT
) 
2732     m_headerWin
->GetPosition( &x
, &y 
); 
2733     m_headerWin
->GetSize( &w
, &h 
); 
2734     if ((x 
!= 0) || (y 
!= 0) || (w 
!= cw
) || (h 
!= 23)) 
2735       m_headerWin
->SetSize( 0, 0, cw
, 23 ); 
2737     m_mainWin
->GetPosition( &x
, &y 
); 
2738     m_mainWin
->GetSize( &w
, &h 
); 
2739     if ((x 
!= 0) || (y 
!= 24) || (w 
!= cw
) || (h 
!= ch
-24)) 
2740       m_mainWin
->SetSize( 0, 24, cw
, ch
-24 ); 
2744     m_mainWin
->GetPosition( &x
, &y 
); 
2745     m_mainWin
->GetSize( &w
, &h 
); 
2746     if ((x 
!= 0) || (y 
!= 24) || (w 
!= cw
) || (h 
!= ch
)) 
2747       m_mainWin
->SetSize( 0, 0, cw
, ch 
); 
2750   m_mainWin
->CalculatePositions(); 
2751   m_mainWin
->RealizeChanges(); 
2752   m_mainWin
->m_dirty 
= FALSE
; 
2753   m_mainWin
->Refresh(); 
2756 void wxListCtrl::SetBackgroundColour( const wxColour 
&colour 
) 
2760     m_mainWin
->SetBackgroundColour( colour 
); 
2761     m_mainWin
->m_dirty 
= TRUE
; 
2764     m_headerWin
->SetBackgroundColour( colour 
); 
2767 void wxListCtrl::SetForegroundColour( const wxColour 
&colour 
) 
2771     m_mainWin
->SetForegroundColour( colour 
); 
2772     m_mainWin
->m_dirty 
= TRUE
; 
2775     m_headerWin
->SetForegroundColour( colour 
); 
2778 void wxListCtrl::SetFont( const wxFont 
&font 
) 
2782     m_mainWin
->SetFont( font 
); 
2783     m_mainWin
->m_dirty 
= TRUE
; 
2786     m_headerWin
->SetFont( font 
);