1 ///////////////////////////////////////////////////////////////////////////// 
   4 // Author:      Robert Roebling 
   7 // Copyright:   (c) 1998 Robert Roebling, Julian Smart and Markus Holzem 
   8 // Licence:     wxWindows licence 
   9 ///////////////////////////////////////////////////////////////////////////// 
  12 #pragma implementation "listctrl.h" 
  15 #include "wx/listctrl.h" 
  17 //----------------------------------------------------------------------------- 
  19 //----------------------------------------------------------------------------- 
  21 IMPLEMENT_DYNAMIC_CLASS(wxListItemData
,wxObject
); 
  23 wxListItemData::wxListItemData(void) 
  34 wxListItemData::wxListItemData( const wxListItem 
&info 
) 
  38   m_colour 
= info
.m_colour
; 
  42 void wxListItemData::SetItem( const wxListItem 
&info 
) 
  44   if (info
.m_mask 
& wxLIST_MASK_TEXT
) m_text 
= info
.m_text
; 
  45   if (info
.m_mask 
& wxLIST_MASK_IMAGE
) m_image 
= info
.m_image
; 
  46   if (info
.m_mask 
& wxLIST_MASK_DATA
) m_data 
= info
.m_data
; 
  47   m_colour 
= info
.m_colour
; 
  50   m_width 
= info
.m_width
; 
  54 void wxListItemData::SetText( const wxString 
&s 
) 
  59 void wxListItemData::SetImage( int image 
) 
  64 void wxListItemData::SetData( long data 
) 
  69 void wxListItemData::SetPosition( int x
, int y 
) 
  75 void wxListItemData::SetSize( int const width
, int height 
) 
  81 void wxListItemData::SetColour( wxColour 
*col 
) 
  86 bool wxListItemData::HasImage(void) const 
  88   return (m_image 
>= 0); 
  91 bool wxListItemData::HasText(void) const 
  93   return (!m_text
.IsNull()); 
  96 bool wxListItemData::IsHit( int x
, int y 
) const 
  98   return ((x 
>= m_xpos
) && (x 
<= m_xpos
+m_width
) && (y 
>= m_ypos
) && (y 
<= m_ypos
+m_height
)); 
 101 void wxListItemData::GetText( wxString 
&s 
) 
 106 int wxListItemData::GetX( void ) const 
 111 int wxListItemData::GetY( void ) const 
 116 int wxListItemData::GetWidth(void) const 
 121 int wxListItemData::GetHeight(void) const 
 126 int wxListItemData::GetImage(void) const 
 131 void wxListItemData::GetItem( wxListItem 
&info 
) 
 133   info
.m_text 
= m_text
; 
 134   info
.m_image 
= m_image
; 
 135   info
.m_data 
= m_data
; 
 138 wxColour 
*wxListItemData::GetColour(void) 
 143 //----------------------------------------------------------------------------- 
 145 //----------------------------------------------------------------------------- 
 147 IMPLEMENT_DYNAMIC_CLASS(wxListHeaderData
,wxObject
); 
 149 wxListHeaderData::wxListHeaderData(void) 
 160 wxListHeaderData::wxListHeaderData( const wxListItem 
&item 
) 
 168 void wxListHeaderData::SetItem( const wxListItem 
&item 
) 
 170   m_mask 
= item
.m_mask
; 
 171   m_text 
= item
.m_text
; 
 172   m_image 
= item
.m_image
; 
 173   m_format 
= item
.m_format
; 
 174   m_width 
= item
.m_width
; 
 175   if (m_width 
< 0) m_width 
= 80; 
 176   if (m_width 
< 6) m_width 
= 6; 
 179 void wxListHeaderData::SetPosition( int x
, int y 
) 
 185 void wxListHeaderData::SetHeight( int h 
) 
 190 void wxListHeaderData::SetWidth( int w 
) 
 193   if (m_width 
< 0) m_width 
= 80; 
 194   if (m_width 
< 6) m_width 
= 6; 
 197 void wxListHeaderData::SetFormat( int format 
) 
 202 bool wxListHeaderData::HasImage(void) const 
 204   return (m_image 
!= 0); 
 207 bool wxListHeaderData::HasText(void) const 
 209   return (m_text
.Length() > 0); 
 212 bool wxListHeaderData::IsHit( int x
, int y 
) const 
 214   return ((x 
>= m_xpos
) && (x 
<= m_xpos
+m_width
) && (y 
>= m_ypos
) && (y 
<= m_ypos
+m_height
)); 
 217 void wxListHeaderData::GetItem( wxListItem 
&item 
) 
 219   item
.m_mask 
= m_mask
; 
 220   item
.m_text 
= m_text
; 
 221   item
.m_image 
= m_image
; 
 222   item
.m_format 
= m_format
; 
 223   item
.m_width 
= m_width
; 
 226 void wxListHeaderData::GetText( wxString 
&s 
) 
 231 int wxListHeaderData::GetImage(void) const 
 236 int wxListHeaderData::GetWidth(void) const 
 241 int wxListHeaderData::GetFormat(void) const 
 246 //----------------------------------------------------------------------------- 
 248 //----------------------------------------------------------------------------- 
 250 IMPLEMENT_DYNAMIC_CLASS(wxListLineData
,wxObject
); 
 252 wxListLineData::wxListLineData( wxListMainWindow 
*owner
, int mode
, wxBrush 
*hilightBrush 
) 
 257   m_hilightBrush 
= hilightBrush
; 
 258   m_items
.DeleteContents( TRUE 
); 
 262 void wxListLineData::CalculateSize( wxPaintDC 
*dc
, int spacing 
) 
 269       m_bound_all
.width 
= m_spacing
; 
 270       m_bound_all
.height 
= m_spacing
+13; 
 271       wxNode 
*node 
= m_items
.First(); 
 274         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 278         dc
->GetTextExtent( s
, &lw
, &lh 
); 
 279         if (lw 
> m_spacing
) m_bound_all
.width 
= lw
; 
 285       wxNode 
*node 
= m_items
.First(); 
 288         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 292         dc
->GetTextExtent( s
, &lw
, &lh 
); 
 293         m_bound_all
.width 
= lw
; 
 294         m_bound_all
.height 
= lh
; 
 300       m_bound_all
.width 
= 0; 
 301       m_bound_all
.height 
= 0; 
 302       wxNode 
*node 
= m_items
.First(); 
 305         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 308         if (s
.IsNull()) s 
= "H"; 
 310         dc
->GetTextExtent( s
, &lw
, &lh 
); 
 311         item
->SetSize( item
->GetWidth(), lh 
); 
 312         m_bound_all
.width 
+= lw
; 
 313         m_bound_all
.height 
= lh
; 
 321 void wxListLineData::SetPosition( wxPaintDC 
*dc
, int x
, int y
, int window_width 
) 
 329       AssignRect( m_bound_icon
, 0, 0, 0, 0 ); 
 330       AssignRect( m_bound_label
, 0, 0, 0, 0 ); 
 331       AssignRect( m_bound_hilight
, m_bound_all 
); 
 332       wxNode 
*node 
= m_items
.First(); 
 335         wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 336         if (item
->HasImage()) 
 338           wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 341           m_owner
->GetImageSize( item
->GetImage(), w
, h 
); 
 342           m_bound_icon
.x 
= m_bound_all
.x 
+ (m_spacing
/2) - (w
/2); 
 343           m_bound_icon
.y 
= m_bound_all
.y 
+ m_spacing 
- h 
- 5; 
 344           m_bound_icon
.width 
= w
; 
 345           m_bound_icon
.height 
= h
; 
 346           if (!item
->HasText()) 
 348             AssignRect( m_bound_hilight
, m_bound_icon 
); 
 349             m_bound_hilight
.x 
-= 3; 
 350             m_bound_hilight
.y 
-= 3; 
 351             m_bound_hilight
.width 
+= 7; 
 352             m_bound_hilight
.height 
+= 7; 
 360           dc
->GetTextExtent( s
, &lw
, &lh 
); 
 361           if (m_bound_all
.width 
> m_spacing
) 
 362             m_bound_label
.x 
= m_bound_all
.x
; 
 364             m_bound_label
.x 
= m_bound_all
.x 
+  (m_spacing
/2) - lw
/2; 
 365           m_bound_label
.y 
= m_bound_all
.y 
+ m_bound_all
.height 
- lh
; 
 366           m_bound_label
.width 
= lw
; 
 367           m_bound_label
.height 
= lh
; 
 368           AssignRect( m_bound_hilight
, m_bound_label 
); 
 375       AssignRect( m_bound_label
, m_bound_all 
); 
 376       AssignRect( m_bound_hilight
, m_bound_all 
); 
 377       AssignRect( m_bound_icon
, 0, 0, 0, 0 ); 
 383       dc
->GetTextExtent( "H", &lw
, &lh 
); 
 384       m_bound_all
.height 
= lh
; 
 385       m_bound_all
.width 
= window_width
; 
 386       AssignRect( m_bound_label
, m_bound_all 
); 
 387       AssignRect( m_bound_hilight
, m_bound_all 
); 
 388       AssignRect( m_bound_icon
, 0, 0, 0, 0 ); 
 389       m_bound_hilight
.width 
= window_width
-10; 
 390       m_bound_label
.width 
= window_width
-10; 
 396 void wxListLineData::SetColumnPosition( int index
, int x 
) 
 399   wxNode 
*node 
= m_items
.Nth( i 
); 
 402     wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 403     item
->SetPosition( x
, m_bound_all
.y 
); 
 407 void wxListLineData::GetSize( int &width
, int &height 
) 
 409   width 
= m_bound_all
.width
; 
 410   height 
= m_bound_all
.height
; 
 413 void wxListLineData::GetExtent( int &x
, int &y
, int &width
, int &height 
) 
 417   width 
= m_bound_all
.width
; 
 418   height 
= m_bound_all
.height
; 
 421 void wxListLineData::GetLabelExtent( int &x
, int &y
, int &width
, int &height 
) 
 425   width 
= m_bound_label
.width
; 
 426   height 
= m_bound_label
.height
; 
 429 void wxListLineData::GetRect( wxRectangle 
&rect 
) 
 431   AssignRect( rect
, m_bound_all 
); 
 434 long wxListLineData::IsHit( int x
, int y 
) 
 436   wxNode 
*node 
= m_items
.First(); 
 439     wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 440     if (item
->HasImage() && IsInRect( x
, y
, m_bound_icon 
)) return wxLIST_HITTEST_ONITEMICON
; 
 441     if (item
->HasText() && IsInRect( x
, y
, m_bound_label 
)) return wxLIST_HITTEST_ONITEMLABEL
; 
 442 //    if (!(item->HasImage() || item->HasText())) return 0; 
 444   // if there is no icon or text = empty 
 445   if (IsInRect( x
, y
, m_bound_all 
)) return wxLIST_HITTEST_ONITEMICON
; 
 449 void wxListLineData::InitItems( int num 
) 
 451   for (int i 
= 0; i 
< num
; i
++) m_items
.Append( new wxListItemData() ); 
 454 void wxListLineData::SetItem( int index
, const wxListItem 
&info 
) 
 456   wxNode 
*node 
= m_items
.Nth( index 
); 
 459     wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 460     item
->SetItem( info 
); 
 464 void wxListLineData::GetItem( int const index
, wxListItem 
&info 
) 
 467   wxNode 
*node 
= m_items
.Nth( i 
); 
 470     wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 471     item
->GetItem( info 
); 
 475 void wxListLineData::GetText( int index
, wxString 
&s 
) 
 478   wxNode 
*node 
= m_items
.Nth( i 
); 
 482     wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 487 void wxListLineData::SetText( int index
, const wxString s 
) 
 490   wxNode 
*node 
= m_items
.Nth( i 
); 
 493     wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 498 int wxListLineData::GetImage( int index 
) 
 501   wxNode 
*node 
= m_items
.Nth( i 
); 
 504     wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 505     return item
->GetImage(); 
 510 void wxListLineData::DoDraw( wxPaintDC 
*dc
, bool hilight
, bool paintBG 
) 
 512   long dev_x 
= dc
->LogicalToDeviceX( m_bound_all
.x
-2 ); 
 513   long dev_y 
= dc
->LogicalToDeviceY( m_bound_all
.y
-2 ); 
 514   long dev_w 
= dc
->LogicalToDeviceXRel( m_bound_all
.width
+4 ); 
 515   long dev_h 
= dc
->LogicalToDeviceYRel( m_bound_all
.height
+4 ); 
 516   if (!m_owner
->IsExposed( dev_x
, dev_y
, dev_w
, dev_h 
) ) return; 
 522       dc
->SetBrush( m_hilightBrush 
); 
 523       dc
->SetPen( wxTRANSPARENT_PEN 
); 
 527       dc
->SetBrush( wxWHITE_BRUSH 
); 
 528       dc
->SetPen( wxTRANSPARENT_PEN 
); 
 530     dc
->DrawRectangle( m_bound_hilight
.x
-2, m_bound_hilight
.y
-2, 
 531                        m_bound_hilight
.width
+4, m_bound_hilight
.height
+4 ); 
 533   if (m_mode 
== wxLC_REPORT
) 
 536     wxNode 
*node 
= m_items
.First(); 
 539       wxListItemData 
*info 
= (wxListItemData
*)node
->Data(); 
 540       dc
->SetClippingRegion( info
->GetX(), info
->GetY(), info
->GetWidth(), info
->GetHeight() ); 
 543           dc
->SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT 
) ); 
 545           dc
->SetTextForeground( info
->GetColour() ); 
 546       dc
->DrawText( s
, info
->GetX()+2, info
->GetY() ); 
 547       dc
->DestroyClippingRegion(); 
 553     wxNode 
*node 
= m_items
.First(); 
 556       wxListItemData 
*item 
= (wxListItemData
*)node
->Data(); 
 557       if (item
->HasImage()) 
 559         m_owner
->DrawImage( item
->GetImage(), dc
, m_bound_icon
.x
, m_bound_icon
.y 
); 
 566           dc
->SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT 
) ); 
 568           dc
->SetTextForeground( item
->GetColour() ); 
 569         dc
->DrawText( s
, m_bound_label
.x
, m_bound_label
.y 
); 
 575 void wxListLineData::Hilight( bool on 
) 
 577   if (on 
== m_hilighted
) return; 
 579     m_owner
->SelectLine( this ); 
 581     m_owner
->DeselectLine( this ); 
 585 void wxListLineData::ReverseHilight( void ) 
 587   m_hilighted 
= !m_hilighted
; 
 589     m_owner
->SelectLine( this ); 
 591     m_owner
->DeselectLine( this ); 
 594 void wxListLineData::DrawRubberBand( wxPaintDC 
*dc
, bool on 
) 
 598     dc
->SetPen( wxBLACK_PEN 
); 
 599     dc
->SetBrush( wxTRANSPARENT_BRUSH 
); 
 600     dc
->DrawRectangle( m_bound_hilight
.x
-2, m_bound_hilight
.y
-2, 
 601                        m_bound_hilight
.width
+4, m_bound_hilight
.height
+4 ); 
 605 void wxListLineData::Draw( wxPaintDC 
*dc 
) 
 607   DoDraw( dc
, m_hilighted
, m_hilighted 
); 
 610 bool wxListLineData::IsInRect( int x
, int y
, const wxRectangle 
&rect 
) 
 612   return ((x 
>= rect
.x
) && (x 
<= rect
.x
+rect
.width
) && (y 
>= rect
.y
) && (y 
<= rect
.y
+rect
.height
)); 
 615 bool wxListLineData::IsHilighted( void ) 
 620 void wxListLineData::AssignRect( wxRectangle 
&dest
, int x
, int y
, int width
, int height 
) 
 625   dest
.height 
= height
; 
 628 void wxListLineData::AssignRect( wxRectangle 
&dest
, const wxRectangle 
&source 
) 
 632   dest
.width 
= source
.width
; 
 633   dest
.height 
= source
.height
; 
 636 //----------------------------------------------------------------------------- 
 637 //  wxListHeaderWindow 
 638 //----------------------------------------------------------------------------- 
 640 IMPLEMENT_DYNAMIC_CLASS(wxListHeaderWindow
,wxWindow
); 
 642 BEGIN_EVENT_TABLE(wxListHeaderWindow
,wxWindow
) 
 643   EVT_PAINT         (wxListHeaderWindow::OnPaint
) 
 644   EVT_MOUSE_EVENTS  (wxListHeaderWindow::OnMouse
) 
 645   EVT_SET_FOCUS     (wxListHeaderWindow::OnSetFocus
) 
 648 wxListHeaderWindow::wxListHeaderWindow( void ) 
 650   m_owner 
= (wxListMainWindow 
*) NULL
; 
 651   m_currentCursor 
= (wxCursor 
*) NULL
; 
 652   m_resizeCursor 
= (wxCursor 
*) NULL
; 
 655 wxListHeaderWindow::wxListHeaderWindow( wxWindow 
*win
, wxWindowID id
, wxListMainWindow 
*owner
,  
 656       const wxPoint 
&pos
, const wxSize 
&size
, 
 657       long style
, const wxString 
&name 
) : 
 658   wxWindow( win
, id
, pos
, size
, style
, name 
) 
 661 //  m_currentCursor = wxSTANDARD_CURSOR; 
 662   m_currentCursor 
= (wxCursor 
*) NULL
; 
 663   m_resizeCursor 
= new wxCursor( wxCURSOR_SIZEWE 
); 
 666 void wxListHeaderWindow::DoDrawRect( wxPaintDC 
*dc
, int x
, int y
, int w
, int h 
) 
 668   const int m_corner 
= 1; 
 670   dc
->SetBrush( *wxTRANSPARENT_BRUSH 
); 
 672   dc
->SetPen( *wxBLACK_PEN 
); 
 673   dc
->DrawLine( x
+w
-m_corner
+1, y
, x
+w
, y
+h 
);  // right (outer) 
 674   dc
->DrawRectangle( x
, y
+h
, w
, 1 );            // bottom (outer) 
 676   dc
->SetPen( *wxMEDIUM_GREY_PEN 
); 
 677   dc
->DrawLine( x
+w
-m_corner
, y
, x
+w
-1, y
+h 
);  // right (inner) 
 678   dc
->DrawRectangle( x
+1, y
+h
-1, w
-2, 1 );      // bottom (inner) 
 680   dc
->SetPen( *wxWHITE_PEN 
); 
 681   dc
->DrawRectangle( x
, y
, w
-m_corner
+1, 1 );   // top (outer) 
 682 //  dc->DrawRectangle( x, y+1, w-m_corner, 1 );   // top (inner) 
 683   dc
->DrawRectangle( x
, y
, 1, h 
);              // left (outer) 
 684 //  dc->DrawRectangle( x+1, y, 1, h-1 );          // left (inner) 
 687 void wxListHeaderWindow::OnPaint( wxPaintEvent 
&WXUNUSED(event
) ) 
 689   wxPaintDC 
dc( this ); 
 694   dc
.SetFont( wxSystemSettings::GetSystemFont( wxSYS_SYSTEM_FONT 
) ); 
 700   GetClientSize( &w
, &h 
); 
 702   dc
.SetTextForeground( *wxBLACK 
); 
 706   int numColumns 
= m_owner
->GetColumnCount(); 
 708   for (int i 
= 0; i 
< numColumns
; i
++) 
 710     m_owner
->GetColumn( i
, item 
); 
 711     int cw 
= item
.m_width
-2; 
 712     if ((i
+1 == numColumns
) || (x
+item
.m_width 
> w
-5)) cw 
= w
-x
-1; 
 713     dc
.SetPen( *wxWHITE_PEN 
); 
 715     DoDrawRect( &dc
, x
, y
, cw
, h
-2 ); 
 716     dc
.SetClippingRegion( x
, y
, cw
-5, h
-4 ); 
 717     dc
.DrawText( item
.m_text
, x
+4, y
+3 ); 
 718     dc
.DestroyClippingRegion(); 
 725 void wxListHeaderWindow::OnMouse( wxMouseEvent 
&event 
) 
 729   event
.Position( &fx
, &fy 
); 
 736     for (int j 
= 0; j 
< m_owner
->GetColumnCount(); j
++) 
 738       xpos 
+= m_owner
->GetColumnWidth( j 
); 
 739       if ((abs(x
-xpos
) < 2) && (y 
< 14)) { hit 
= TRUE
; break; } 
 743       if (m_currentCursor 
== wxSTANDARD_CURSOR
) SetCursor( m_resizeCursor 
); 
 744       m_currentCursor 
= m_resizeCursor
; 
 748       if (m_currentCursor 
!= wxSTANDARD_CURSOR
) SetCursor( wxSTANDARD_CURSOR 
); 
 749       m_currentCursor 
= wxSTANDARD_CURSOR
; 
 754 void wxListHeaderWindow::OnSetFocus( wxFocusEvent 
&WXUNUSED(event
) ) 
 759 //----------------------------------------------------------------------------- 
 760 // wxListRenameTimer (internal) 
 761 //----------------------------------------------------------------------------- 
 763 wxListRenameTimer::wxListRenameTimer( wxListMainWindow 
*owner 
)  
 768 void wxListRenameTimer::Notify()  
 770   m_owner
->OnRenameTimer(); 
 773 //----------------------------------------------------------------------------- 
 774 // wxListTextCtrl (internal) 
 775 //----------------------------------------------------------------------------- 
 777 IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl
,wxTextCtrl
); 
 779 BEGIN_EVENT_TABLE(wxListTextCtrl
,wxTextCtrl
) 
 780   EVT_CHAR           (wxListTextCtrl::OnChar
) 
 781   EVT_KILL_FOCUS     (wxListTextCtrl::OnKillFocus
) 
 784 wxListTextCtrl::wxListTextCtrl( wxWindow 
*parent
, const wxWindowID id
,  
 785     bool *accept
, wxString 
*res
, wxListMainWindow 
*owner
, 
 786     const wxString 
&value
, const wxPoint 
&pos
, const wxSize 
&size
, 
 787     int style
, const wxValidator
& validator
, const wxString 
&name 
) : 
 788   wxTextCtrl( parent
, id
, value
, pos
, size
, style
, validator
, name 
) 
 795 void wxListTextCtrl::OnChar( wxKeyEvent 
&event 
) 
 797   if (event
.m_keyCode 
== WXK_RETURN
) 
 800     (*m_res
) = GetValue(); 
 801     m_owner
->OnRenameAccept(); 
 806   if (event
.m_keyCode 
== WXK_ESCAPE
) 
 817 void wxListTextCtrl::OnKillFocus( wxFocusEvent 
&WXUNUSED(event
) ) 
 826 //----------------------------------------------------------------------------- 
 828 //----------------------------------------------------------------------------- 
 830 IMPLEMENT_DYNAMIC_CLASS(wxListMainWindow
,wxScrolledWindow
); 
 832 BEGIN_EVENT_TABLE(wxListMainWindow
,wxScrolledWindow
) 
 833   EVT_PAINT          (wxListMainWindow::OnPaint
) 
 834   EVT_SIZE           (wxListMainWindow::OnSize
) 
 835   EVT_MOUSE_EVENTS   (wxListMainWindow::OnMouse
) 
 836   EVT_CHAR           (wxListMainWindow::OnChar
) 
 837   EVT_SET_FOCUS      (wxListMainWindow::OnSetFocus
) 
 838   EVT_KILL_FOCUS     (wxListMainWindow::OnKillFocus
) 
 841 wxListMainWindow::wxListMainWindow( void ) 
 844   m_lines
.DeleteContents( TRUE 
); 
 845   m_columns
.DeleteContents( TRUE 
); 
 846   m_current 
= (wxListLineData 
*) NULL
; 
 848   m_hilightBrush 
= (wxBrush 
*) NULL
; 
 849   m_myFont 
= (wxFont 
*) NULL
; 
 853   m_small_image_list 
= (wxImageList 
*) NULL
; 
 854   m_normal_image_list 
= (wxImageList 
*) NULL
; 
 855   m_small_spacing 
= 30; 
 856   m_normal_spacing 
= 40; 
 859   m_lastOnSame 
= FALSE
; 
 860   m_renameTimer 
= new wxListRenameTimer( this ); 
 865 wxListMainWindow::wxListMainWindow( wxWindow 
*parent
, wxWindowID id
,  
 866       const wxPoint 
&pos
, const wxSize 
&size
, 
 867       long style
, const wxString 
&name 
) : 
 868   wxScrolledWindow( parent
, id
, pos
, size
, style
, name 
) 
 871   m_lines
.DeleteContents( TRUE 
); 
 872   m_columns
.DeleteContents( TRUE 
); 
 873   m_current 
= (wxListLineData 
*) NULL
; 
 876   m_hilightBrush 
= new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT
), wxSOLID 
); 
 877   m_small_image_list 
= (wxImageList 
*) NULL
; 
 878   m_normal_image_list 
= (wxImageList 
*) NULL
; 
 879   m_small_spacing 
= 30; 
 880   m_normal_spacing 
= 40; 
 881 //  AllowDoubleClick( TRUE ); 
 882   m_myFont 
= wxNORMAL_FONT
; 
 889   if (m_mode 
& wxLC_REPORT
) 
 899   SetScrollbars( m_xScroll
, m_yScroll
, 0, 0, 0, 0 ); 
 902   m_lastOnSame 
= FALSE
; 
 903   m_renameTimer 
= new wxListRenameTimer( this ); 
 904   m_renameAccept 
= FALSE
; 
 905 //  m_text = new wxRawListTextCtrl( GetParent(), "", &m_renameAccept, &m_renameRes, this, 10, 10, 40, 10 ); 
 906 //  m_text->Show( FALSE ); 
 908   SetBackgroundColour( *wxWHITE 
); 
 911 wxListMainWindow::~wxListMainWindow( void ) 
 913 //  if (m_hilightColour) delete m_hilightColour; 
 914 //  if (m_hilightBrush) delete m_hilightBrush; 
 915 //  if (m_myFont) delete m_myFont; 
 916   delete m_renameTimer
; 
 920 void wxListMainWindow::RefreshLine( wxListLineData 
*line 
) 
 930     line
->GetExtent( x
, y
, w
, h 
); 
 932       dc
.LogicalToDeviceX(x
-3),  
 933       dc
.LogicalToDeviceY(y
-3),  
 934       dc
.LogicalToDeviceXRel(w
+6),  
 935       dc
.LogicalToDeviceXRel(h
+6) ); 
 936     Refresh( TRUE
, &rect 
); 
 940 void wxListMainWindow::OnPaint( wxPaintEvent 
&WXUNUSED(event
) ) 
 944   wxPaintDC 
dc( this ); 
 949 //  dc.SetFont( *m_myFont ); 
 950   dc
.SetFont( wxSystemSettings::GetSystemFont( wxSYS_SYSTEM_FONT 
) ); 
 952   wxNode 
*node 
= m_lines
.First(); 
 955     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
 959   if (m_current
) m_current
->DrawRubberBand( &dc
, m_hasFocus 
); 
 964 void wxListMainWindow::HilightAll( bool on 
) 
 966   wxNode 
*node 
= m_lines
.First(); 
 969     wxListLineData 
*line 
= (wxListLineData 
*)node
->Data(); 
 970     if (line
->IsHilighted() != on
) 
 979 void wxListMainWindow::ActivateLine( wxListLineData 
*line 
) 
 981   if (!m_parent
) return; 
 982   wxListEvent 
le( wxEVT_COMMAND_LIST_KEY_DOWN
, m_parent
->GetId() ); 
 983   le
.SetEventObject( m_parent 
); 
 985   le
.m_itemIndex 
= GetIndexOfLine( line 
); 
 987   line
->GetItem( 0, le
.m_item 
); 
 991 void wxListMainWindow::SendNotify( wxListLineData 
*line
, wxEventType command 
) 
 993   if (!m_parent
) return; 
 994   wxListEvent 
le( command
, m_parent
->GetId() ); 
 995   le
.SetEventObject( m_parent 
); 
 997   le
.m_itemIndex 
= GetIndexOfLine( line 
); 
 999   line
->GetItem( 0, le
.m_item 
); 
1003 void wxListMainWindow::FocusLine( wxListLineData 
*WXUNUSED(line
) ) 
1005 //  SendNotify( line, wxEVT_COMMAND_LIST_ITEM_FOCUSSED ); 
1008 void wxListMainWindow::UnfocusLine( wxListLineData 
*WXUNUSED(line
) ) 
1010 //  SendNotify( line, wxEVT_COMMAND_LIST_ITEM_UNFOCUSSED ); 
1013 void wxListMainWindow::SelectLine( wxListLineData 
*line 
) 
1015   SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_SELECTED 
); 
1018 void wxListMainWindow::DeselectLine( wxListLineData 
*line 
) 
1020   SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_DESELECTED 
); 
1023 void wxListMainWindow::DeleteLine( wxListLineData 
*line 
) 
1025   SendNotify( line
, wxEVT_COMMAND_LIST_DELETE_ITEM 
); 
1028 void wxListMainWindow::StartLabelEdit( wxListLineData 
*line 
) 
1030   SendNotify( line
, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT 
); 
1033 void wxListMainWindow::RenameLine( wxListLineData 
*line
, const wxString 
&newName 
) 
1035   if (!m_parent
) return; 
1037   wxListEvent 
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, m_parent
->GetId() ); 
1038   le
.SetEventObject( m_parent 
); 
1040   le
.m_itemIndex 
= GetIndexOfLine( line 
); 
1042   line
->GetItem( 0, le
.m_item 
); 
1043   le
.m_item
.m_text 
= newName
; 
1047 void wxListMainWindow::OnRenameTimer() 
1049   StartLabelEdit( m_current 
); 
1051   m_current
->GetText( 0, s 
); 
1056   m_current
->GetLabelExtent( x
, y
, w
, h 
); 
1058   wxClientDC 
dc(this); 
1060   x 
= dc
.LogicalToDeviceX( x 
); 
1061   y 
= dc
.LogicalToDeviceY( y 
); 
1063   wxListTextCtrl 
*text 
= new wxListTextCtrl(  
1064     this, -1, &m_renameAccept
, &m_renameRes
, this, s
, wxPoint(x
-4,y
-4), wxSize(w
+11,h
+8) ); 
1067   m_text->SetSize( x+3, y+3, w+6, h+6 ); 
1068   m_text->SetValue( s ); 
1069   m_text->Show( TRUE ); 
1073   char *res = wxGetTextFromUser( _("Enter new name:"), "", s ); 
1078     RenameLine( m_current, s ); 
1083 void wxListMainWindow::OnRenameAccept() 
1085   RenameLine( m_current
, m_renameRes 
); 
1088 void wxListMainWindow::OnMouse( wxMouseEvent 
&event 
) 
1090   if (m_parent
->ProcessEvent( event
)) return; 
1092   if (!m_current
) return; 
1093   if (m_dirty
) return; 
1095   wxClientDC 
dc(this); 
1097   long x 
= dc
.DeviceToLogicalX( (long)event
.GetX() ); 
1098   long y 
= dc
.DeviceToLogicalY( (long)event
.GetY() ); 
1101   wxNode 
*node 
= m_lines
.First(); 
1102   wxListLineData 
*line 
= (wxListLineData 
*) NULL
; 
1105     line 
= (wxListLineData
*)node
->Data(); 
1106     hitResult 
= line
->IsHit( x
, y 
); 
1107     if (hitResult
) break; 
1108     line 
= (wxListLineData 
*) NULL
; 
1109     node 
= node
->Next(); 
1112   if (!event
.Dragging()) 
1117   if (event
.Dragging() && (m_dragCount 
> 3)) 
1120     wxListEvent 
le( wxEVT_COMMAND_LIST_BEGIN_DRAG
, m_parent
->GetId() ); 
1121     le
.SetEventObject( this ); 
1130   if (event
.ButtonDClick()) 
1133     m_lastOnSame 
= FALSE
; 
1134     m_renameTimer
->Stop(); 
1135     ActivateLine( line 
); 
1139   if (event
.LeftUp() && m_lastOnSame
) 
1142     if ((line 
== m_current
) && 
1143         (hitResult 
== wxLIST_HITTEST_ONITEMLABEL
) &&  
1144 //      (m_mode & wxLC_ICON) &&  
1145         (m_mode 
& wxLC_EDIT_LABELS
)  ) 
1147       m_renameTimer
->Start( 100, TRUE 
); 
1149     m_lastOnSame 
= FALSE
; 
1153   if (event
.LeftDown()) 
1156     wxListLineData 
*oldCurrent 
= m_current
; 
1157     if (m_mode 
& wxLC_SINGLE_SEL
) 
1160       HilightAll( FALSE 
); 
1161       m_current
->ReverseHilight(); 
1162       RefreshLine( m_current 
); 
1166       if (event
.ShiftDown()) 
1169         m_current
->ReverseHilight(); 
1170         RefreshLine( m_current 
); 
1172       else if (event
.ControlDown()) 
1175         int numOfCurrent 
= -1; 
1176         node 
= m_lines
.First(); 
1179           wxListLineData 
*test_line 
= (wxListLineData
*)node
->Data(); 
1181           if (test_line 
== oldCurrent
) break; 
1182           node 
= node
->Next(); 
1185         node 
= m_lines
.First(); 
1188           wxListLineData 
*test_line 
= (wxListLineData
*)node
->Data(); 
1190           if (test_line 
== line
) break; 
1191           node 
= node
->Next(); 
1194         if (numOfLine 
< numOfCurrent
)  
1195           { int i 
= numOfLine
; numOfLine 
= numOfCurrent
; numOfCurrent 
= i
; } 
1196         wxNode 
*node 
= m_lines
.Nth( numOfCurrent 
); 
1197         for (int i 
= 0; i 
<= numOfLine
-numOfCurrent
; i
++) 
1199           wxListLineData 
*test_line
= (wxListLineData
*)node
->Data(); 
1200           test_line
->Hilight(TRUE
); 
1201           RefreshLine( test_line 
); 
1202           node 
= node
->Next(); 
1208         HilightAll( FALSE 
); 
1209         m_current
->ReverseHilight(); 
1210         RefreshLine( m_current 
); 
1213     if (m_current 
!= oldCurrent
) 
1215       RefreshLine( oldCurrent 
); 
1216       UnfocusLine( oldCurrent 
); 
1217       FocusLine( m_current 
); 
1219     m_lastOnSame 
= (m_current 
== oldCurrent
); 
1225 void wxListMainWindow::MoveToFocus( void ) 
1227   if (!m_current
) return; 
1233   m_current->GetExtent( x, y, w, h ); 
1236   GetClientSize( &w_p, &h_p ); 
1237   if (m_mode & wxLC_REPORT) 
1239     if (GetScrollPos( wxHORIZONTAL ) != 0) SetScrollPos( wxHORIZONTAL, 0); 
1240     int y_s = m_yScroll*GetScrollPos( wxVERTICAL ); 
1241     if ((y > y_s) && (y+h < y_s+h_p)) return;  
1242     if (y-y_s < 5) SetScrollPos( wxVERTICAL, (y-5)/m_yScroll ); 
1243     if (y+h+5 > y_s+h_p) SetScrollPos( wxVERTICAL, (y+h-h_p+h+5)/m_yScroll ); 
1247     if (GetScrollPos( wxVERTICAL ) != 0) SetScrollPos( wxVERTICAL, 0); 
1248     int x_s = m_xScroll*GetScrollPos( wxHORIZONTAL ); 
1249     if ((x > x_s) && (x+w < x_s+w_p)) return; 
1250     if (x-x_s < 5) SetScrollPos( wxHORIZONTAL, (x-5)/m_xScroll ); 
1251     if (x+w > x_s+w_p)  SetScrollPos( wxHORIZONTAL, (x+w-w_p+5)/m_xScroll ); 
1256 void wxListMainWindow::OnArrowChar( wxListLineData 
*newCurrent
, bool shiftDown 
) 
1258   if ((m_mode 
& wxLC_SINGLE_SEL
) || (m_usedKeys 
== FALSE
)) m_current
->Hilight( FALSE 
); 
1259   wxListLineData 
*oldCurrent 
= m_current
; 
1260   m_current 
= newCurrent
; 
1262   if (shiftDown 
|| (m_mode 
& wxLC_SINGLE_SEL
)) m_current
->Hilight( TRUE 
); 
1263   RefreshLine( m_current 
); 
1264   RefreshLine( oldCurrent 
); 
1265   FocusLine( m_current 
); 
1266   UnfocusLine( oldCurrent 
); 
1269 void wxListMainWindow::OnChar( wxKeyEvent 
&event 
) 
1272   if (event.KeyCode() == WXK_TAB) 
1274     if (event.ShiftDown()) 
1281   if (!m_current
) return; 
1282   switch (event
.KeyCode()) 
1286       wxNode 
*node 
= m_lines
.Member( m_current 
)->Previous(); 
1287       if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1292       wxNode 
*node 
= m_lines
.Member( m_current 
)->Next(); 
1293       if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1298       wxNode 
*node 
= m_lines
.Last(); 
1299       OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1304       wxNode 
*node 
= m_lines
.First(); 
1305       OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1311       if (m_mode 
& wxLC_REPORT
) { steps 
= m_visibleLines
-1; } 
1315         wxNode 
*node 
= m_lines
.First(); 
1316         for (;;) { if (m_current 
== (wxListLineData
*)node
->Data()) break; pos
++; node 
= node
->Next(); } 
1317         steps 
= pos 
% m_visibleLines
; 
1319       wxNode 
*node 
= m_lines
.Member( m_current 
); 
1320       for (int i 
= 0; i 
< steps
; i
++) if (node
->Previous()) node 
= node
->Previous(); 
1321       if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1327       if (m_mode 
& wxLC_REPORT
) { steps 
= m_visibleLines
-1; } 
1330         int pos 
= 0; wxNode 
*node 
= m_lines
.First(); 
1331         for (;;) { if (m_current 
== (wxListLineData
*)node
->Data()) break; pos
++; node 
= node
->Next(); } 
1332         steps 
= m_visibleLines
-(pos 
% m_visibleLines
)-1; 
1334       wxNode 
*node 
= m_lines
.Member( m_current 
); 
1335       for (int i 
= 0; i 
< steps
; i
++) if (node
->Next()) node 
= node
->Next(); 
1336       if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1341       if (!(m_mode 
& wxLC_REPORT
)) 
1343         wxNode 
*node 
= m_lines
.Member( m_current 
); 
1344         for (int i 
= 0; i 
<m_visibleLines
; i
++) if (node
->Previous()) node 
= node
->Previous(); 
1345         if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1351       if (!(m_mode 
& wxLC_REPORT
)) 
1353         wxNode 
*node 
= m_lines
.Member( m_current 
); 
1354         for (int i 
= 0; i 
<m_visibleLines
; i
++) if (node
->Next()) node 
= node
->Next(); 
1355         if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() ); 
1361       m_current
->ReverseHilight(); 
1362       RefreshLine( m_current 
); 
1367       if (!(m_mode 
& wxLC_SINGLE_SEL
)) 
1369         wxListLineData 
*oldCurrent 
= m_current
; 
1370         m_current
->ReverseHilight(); 
1371         wxNode 
*node 
= m_lines
.Member( m_current 
)->Next();        
1372         if (node
) m_current 
= (wxListLineData
*)node
->Data(); 
1374         RefreshLine( oldCurrent 
); 
1375         RefreshLine( m_current 
); 
1376         UnfocusLine( oldCurrent 
); 
1377         FocusLine( m_current 
); 
1384       ActivateLine( m_current 
); 
1396 void wxListMainWindow::OnSetFocus( wxFocusEvent 
&WXUNUSED(event
) ) 
1399   RefreshLine( m_current 
); 
1401   if (!m_parent
) return; 
1403   wxFocusEvent 
event( wxEVT_SET_FOCUS
, m_parent
->GetId() ); 
1404   event
.SetEventObject( m_parent 
); 
1405   m_parent
->ProcessEvent( event 
); 
1408 void wxListMainWindow::OnKillFocus( wxFocusEvent 
&WXUNUSED(event
) ) 
1411   RefreshLine( m_current 
); 
1414 void wxListMainWindow::OnSize( wxSizeEvent 
&WXUNUSED(event
) ) 
1417   We don't even allow the wxScrolledWindow::AdjustScrollbars() call 
1419   CalculatePositions(); 
1420   printf( "OnSize::Refresh.\n" ); 
1426 wxFont 
*wxListMainWindow::GetMyFont( void ) 
1431 void wxListMainWindow::DrawImage( int index
, wxPaintDC 
*dc
, int x
, int y 
) 
1433   if ((m_mode 
& wxLC_ICON
) && (m_normal_image_list
)) 
1435     m_normal_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT 
); 
1438   if ((m_mode 
& wxLC_SMALL_ICON
) && (m_small_image_list
)) 
1440     m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT 
); 
1444 void wxListMainWindow::GetImageSize( int index
, int &width
, int &height 
) 
1446   if ((m_mode 
& wxLC_ICON
) && (m_normal_image_list
)) 
1448     m_normal_image_list
->GetSize( index
, width
, height 
); 
1451   if ((m_mode 
& wxLC_SMALL_ICON
) && (m_small_image_list
)) 
1453     m_small_image_list
->GetSize( index
, width
, height 
); 
1460 int wxListMainWindow::GetTextLength( wxString 
&s 
) 
1462   wxPaintDC 
dc( this ); 
1465   dc
.GetTextExtent( s
, &lw
, &lh 
); 
1469 int wxListMainWindow::GetIndexOfLine( const wxListLineData 
*line 
) 
1472   wxNode 
*node 
= m_lines
.First(); 
1475     if (line 
== (wxListLineData
*)node
->Data()) return i
; 
1477     node 
= node
->Next(); 
1482 void wxListMainWindow::SetImageList( wxImageList 
*imageList
, int which 
) 
1485   if (which 
== wxIMAGE_LIST_NORMAL
) m_normal_image_list 
= imageList
; 
1486   if (which 
== wxIMAGE_LIST_SMALL
) m_small_image_list 
= imageList
; 
1489 void wxListMainWindow::SetItemSpacing( int spacing
, bool isSmall 
) 
1494     m_small_spacing 
= spacing
; 
1498     m_normal_spacing 
= spacing
; 
1502 int wxListMainWindow::GetItemSpacing( bool isSmall 
) 
1504   if (isSmall
) return m_small_spacing
; else return m_normal_spacing
; 
1507 void wxListMainWindow::SetColumn( int col
, wxListItem 
&item 
) 
1510   wxNode 
*node 
= m_columns
.Nth( col 
); 
1513     if (item
.m_width 
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width 
= GetTextLength( item
.m_text 
)+7; 
1514     wxListHeaderData 
*column 
= (wxListHeaderData
*)node
->Data(); 
1515     column
->SetItem( item 
); 
1519 void wxListMainWindow::SetColumnWidth( int col
, int width 
) 
1522   wxNode 
*node 
= m_columns
.Nth( col 
); 
1525     wxListHeaderData 
*column 
= (wxListHeaderData
*)node
->Data(); 
1526     column
->SetWidth( width 
); 
1530 void wxListMainWindow::GetColumn( int col
, wxListItem 
&item 
) 
1532   wxNode 
*node 
= m_columns
.Nth( col 
); 
1535     wxListHeaderData 
*column 
= (wxListHeaderData
*)node
->Data(); 
1536     column
->GetItem( item 
); 
1548 int wxListMainWindow::GetColumnWidth( int col 
)  
1550   wxNode 
*node 
= m_columns
.Nth( col 
); 
1553     wxListHeaderData 
*column 
= (wxListHeaderData
*)node
->Data(); 
1554     return column
->GetWidth(); 
1560 int wxListMainWindow::GetColumnCount( void ) 
1562   return m_columns
.Number(); 
1565 int wxListMainWindow::GetCountPerPage( void ) 
1567   return m_visibleLines
; 
1570 void wxListMainWindow::SetItem( wxListItem 
&item 
) 
1573   wxNode 
*node 
= m_lines
.Nth( item
.m_itemId 
); 
1576     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1577     if (m_mode 
& wxLC_REPORT
) item
.m_width 
= GetColumnWidth( item
.m_col 
)-3; 
1578     line
->SetItem( item
.m_col
, item 
); 
1582 void wxListMainWindow::SetItemState( long item
, long state
, long stateMask 
) 
1584   // m_dirty = TRUE; no recalcs needed 
1586   wxListLineData 
*oldCurrent 
= m_current
; 
1588   if (stateMask 
& wxLIST_STATE_FOCUSED
)  
1590     wxNode 
*node 
= m_lines
.Nth( item 
); 
1593       wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1594       UnfocusLine( m_current 
); 
1596       FocusLine( m_current 
); 
1597       RefreshLine( m_current 
); 
1598       RefreshLine( oldCurrent 
); 
1602   if (stateMask 
& wxLIST_STATE_SELECTED
) 
1604     bool on 
= state 
& wxLIST_STATE_SELECTED
; 
1605     if (!on 
&& (m_mode 
& wxLC_SINGLE_SEL
)) return;  
1607     wxNode 
*node 
= m_lines
.Nth( item 
); 
1610       wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1611       if (m_mode 
& wxLC_SINGLE_SEL
) 
1613         UnfocusLine( m_current 
); 
1615         FocusLine( m_current 
); 
1616         oldCurrent
->Hilight( FALSE 
); 
1617         RefreshLine( m_current 
); 
1618         RefreshLine( oldCurrent 
); 
1620       bool on 
= state 
& wxLIST_STATE_SELECTED
; 
1621       line
->Hilight( on 
); 
1622       RefreshLine( line 
); 
1627 int wxListMainWindow::GetItemState( long item
, long stateMask 
) 
1629   int ret 
= wxLIST_STATE_DONTCARE
; 
1630   if (stateMask 
& wxLIST_STATE_FOCUSED
) 
1632     wxNode 
*node 
= m_lines
.Nth( item 
); 
1635       wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1636       if (line 
== m_current
) ret 
|= wxLIST_STATE_FOCUSED
; 
1639   if (stateMask 
& wxLIST_STATE_SELECTED
) 
1641     wxNode 
*node 
= m_lines
.Nth( item 
); 
1644       wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1645       if (line
->IsHilighted()) ret 
|= wxLIST_STATE_FOCUSED
; 
1651 void wxListMainWindow::GetItem( wxListItem 
&item 
) 
1653   wxNode 
*node 
= m_lines
.Nth( item
.m_itemId 
); 
1656     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1657     line
->GetItem( item
.m_col
, item 
); 
1668 int wxListMainWindow::GetItemCount( void ) 
1670   return m_lines
.Number(); 
1673 void wxListMainWindow::GetItemRect( long index
, wxRectangle 
&rect 
) 
1675   wxNode 
*node 
= m_lines
.Nth( index 
); 
1678     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1679     line
->GetRect( rect 
); 
1690 bool wxListMainWindow::GetItemPosition(long item
, wxPoint
& pos
) 
1692   wxNode 
*node 
= m_lines
.Nth( item 
); 
1696     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1697     line
->GetRect( rect 
); 
1709 int wxListMainWindow::GetSelectedItemCount( void ) 
1712   wxNode 
*node 
= m_lines
.First(); 
1715     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1716     if (line
->IsHilighted()) ret
++; 
1717     node 
= node
->Next(); 
1722 void wxListMainWindow::SetMode( long mode 
) 
1729   if (m_mode 
& wxLC_REPORT
) 
1741 long wxListMainWindow::GetMode( void ) const 
1746 void wxListMainWindow::CalculatePositions( void ) 
1748   wxPaintDC 
dc( this ); 
1749   dc
.SetFont( wxSystemSettings::GetSystemFont( wxSYS_SYSTEM_FONT 
) ); 
1751   int iconSpacing 
= 0; 
1752   if (m_mode 
& wxLC_ICON
) iconSpacing 
= m_normal_spacing
; 
1753   if (m_mode 
& wxLC_SMALL_ICON
) iconSpacing 
= m_small_spacing
; 
1754   wxNode 
*node 
= m_lines
.First(); 
1757     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1758     line
->CalculateSize( &dc
, iconSpacing 
); 
1759     node 
= node
->Next(); 
1764   int lineSpacing 
= 0;   
1766   node 
= m_lines
.First(); 
1769     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1771     line
->GetSize( dummy
, lineSpacing 
); 
1777     lineSpacing 
= 6 + (int)dc
.GetCharHeight();   
1780   int clientWidth 
= 0; 
1781   int clientHeight 
= 0; 
1783   if (m_mode 
& wxLC_REPORT
) 
1787     int entireHeight 
= m_lines
.Number() * lineSpacing 
+ 10; 
1788     SetScrollbars( m_xScroll
, m_yScroll
, 0, (entireHeight
+10) / m_yScroll
, 0, 0, TRUE 
); 
1789     GetClientSize( &clientWidth
, &clientHeight 
); 
1790     node 
= m_lines
.First(); 
1793       wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1794       line
->SetPosition( &dc
, x
, y
, clientWidth 
); 
1796       for (int i 
= 0; i 
< GetColumnCount(); i
++) 
1798         line
->SetColumnPosition( i
, col_x 
); 
1799         col_x 
+= GetColumnWidth( i 
); 
1802       node 
= node
->Next(); 
1807     // At first, we try without any scrollbar 
1808     GetSize( &clientWidth
, &clientHeight 
); 
1810     int entireWidth 
= 0; 
1812     for (int tries 
= 0; tries 
< 2; tries
++) 
1818       node 
= m_lines
.First(); 
1821         wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1822         line
->SetPosition( &dc
, x
, y
, clientWidth 
); 
1823         line
->GetSize( lineWidth
, lineHeight 
); 
1824         if (lineWidth 
> maxWidth
) maxWidth 
= lineWidth
; 
1826         if (y
+lineHeight 
> clientHeight
-4)  
1830           entireWidth 
+= maxWidth
+13; 
1833         node 
= node
->Next(); 
1834         if (!node
) entireWidth 
+= maxWidth
; 
1835         if ((tries 
== 0) && (entireWidth 
> clientWidth
)) 
1837           clientHeight 
-= 14; // scrollbar height 
1840         if (!node
) tries 
= 1; 
1843     SetScrollbars( m_xScroll
, m_yScroll
, (entireWidth
+15) / m_xScroll
, 0, 0, 0, TRUE 
); 
1845   m_visibleLines 
= (clientHeight
-4) / (lineSpacing
); 
1848 void wxListMainWindow::RealizeChanges( void ) 
1852     wxNode 
*node 
= m_lines
.First(); 
1853     if (node
) m_current 
= (wxListLineData
*)node
->Data(); 
1857     FocusLine( m_current 
); 
1858     if (m_mode 
& wxLC_SINGLE_SEL
) m_current
->Hilight( TRUE 
); 
1862 long wxListMainWindow::GetNextItem( long item
, int WXUNUSED(geometry
), int state 
) 
1865   if (item 
> 0) ret 
= item
; 
1866   wxNode 
*node 
= m_lines
.Nth( ret 
); 
1869     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1870     if ((state 
& wxLIST_STATE_FOCUSED
) && (line 
== m_current
)) return ret
; 
1871     if ((state 
& wxLIST_STATE_SELECTED
) && (line
->IsHilighted())) return ret
; 
1872     if (!state
) return ret
; 
1874     node 
= node
->Next(); 
1879 void wxListMainWindow::DeleteItem( long index 
) 
1882   wxNode 
*node 
= m_lines
.Nth( index 
); 
1885     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1886     if (m_current 
== line
) m_current 
= (wxListLineData 
*) NULL
; 
1888     m_lines
.DeleteNode( node 
); 
1892 void wxListMainWindow::DeleteColumn( int col 
) 
1895   wxNode 
*node 
= m_columns
.Nth( col 
); 
1896   if (node
) m_columns
.DeleteNode( node 
); 
1899 void wxListMainWindow::DeleteAllItems( void ) 
1902   m_current 
= (wxListLineData 
*) NULL
; 
1903   wxNode 
*node 
= m_lines
.First(); 
1906     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1908     node 
= node
->Next(); 
1913 void wxListMainWindow::DeleteEverything( void ) 
1916   m_current 
= (wxListLineData 
*) NULL
; 
1917   wxNode 
*node 
= m_lines
.First(); 
1920     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1922     node 
= node
->Next(); 
1925   m_current 
= (wxListLineData 
*) NULL
; 
1929 void wxListMainWindow::EnsureVisible( long index 
) 
1931   wxListLineData 
*oldCurrent 
= m_current
; 
1932   m_current 
= (wxListLineData 
*) NULL
; 
1934   wxNode 
*node 
= m_lines
.Nth( i 
); 
1935   if (node
) m_current 
= (wxListLineData
*)node
->Data(); 
1936   if (m_current
) MoveToFocus(); 
1937   m_current 
= oldCurrent
; 
1940 long wxListMainWindow::FindItem(long start
, const wxString
& str
, bool WXUNUSED(partial
) ) 
1944   if (pos 
< 0) pos 
= 0; 
1945   wxNode 
*node 
= m_lines
.Nth( pos 
); 
1948     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1950     line
->GetText( 0, s 
); 
1951     if (s 
== tmp
) return pos
; 
1952     node 
= node
->Next(); 
1958 long wxListMainWindow::FindItem(long start
, long data
) 
1961   if (pos 
< 0) pos 
= 0; 
1962   wxNode 
*node 
= m_lines
.Nth( pos 
); 
1965     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1967     line
->GetItem( 0, item 
); 
1968     if (item
.m_data 
== data
) return pos
; 
1969     node 
= node
->Next(); 
1975 long wxListMainWindow::HitTest( int x
, int y
, int &flags 
) 
1977   wxNode 
*node 
= m_lines
.First(); 
1981     wxListLineData 
*line 
= (wxListLineData
*)node
->Data(); 
1982     long ret 
= line
->IsHit( x
, y 
); 
1988     node 
= node
->Next(); 
1994 void wxListMainWindow::InsertItem( wxListItem 
&item 
) 
1998   if (m_mode 
& wxLC_REPORT
) mode 
= wxLC_REPORT
; 
1999   else if (m_mode 
& wxLC_LIST
) mode 
= wxLC_LIST
; 
2000   else if (m_mode 
& wxLC_ICON
) mode 
= wxLC_ICON
; 
2001   else if (m_mode 
& wxLC_SMALL_ICON
) mode 
= wxLC_ICON
;  // no typo 
2002   wxListLineData 
*line 
= new wxListLineData( this, mode
, m_hilightBrush 
); 
2003   if (m_mode 
& wxLC_REPORT
) 
2005     line
->InitItems( GetColumnCount() ); 
2006     item
.m_width 
= GetColumnWidth( 0 )-3; 
2009     line
->InitItems( 1 ); 
2010   line
->SetItem( 0, item 
); 
2011   wxNode 
*node 
= m_lines
.Nth( item
.m_itemId 
); 
2013     m_lines
.Insert( node
, line 
); 
2015     m_lines
.Append( line 
); 
2018 void wxListMainWindow::InsertColumn( long col
, wxListItem 
&item 
) 
2021   if (m_mode 
& wxLC_REPORT
) 
2023     if (item
.m_width 
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width 
= GetTextLength( item
.m_text 
); 
2024     wxListHeaderData 
*column 
= new wxListHeaderData( item 
); 
2025     wxNode 
*node 
= m_columns
.Nth( col 
); 
2027       m_columns
.Insert( node
, column 
); 
2029       m_columns
.Append( column 
); 
2033 wxListCtrlCompare list_ctrl_compare_func_2
; 
2034 long              list_ctrl_compare_data
; 
2036 int list_ctrl_compare_func_1( const void *arg1
, const void *arg2 
) 
2038   wxListLineData 
*line1 
= *((wxListLineData
**)arg1
); 
2039   wxListLineData 
*line2 
= *((wxListLineData
**)arg2
); 
2041   line1
->GetItem( 0, item 
); 
2042   long data1 
= item
.m_data
; 
2043   line2
->GetItem( 0, item 
); 
2044   long data2 
= item
.m_data
; 
2045   return list_ctrl_compare_func_2( data1
, data2
, list_ctrl_compare_data 
); 
2048 void wxListMainWindow::SortItems( wxListCtrlCompare fn
, long data 
) 
2050   list_ctrl_compare_func_2 
= fn
; 
2051   list_ctrl_compare_data 
= data
; 
2052   m_lines
.Sort( list_ctrl_compare_func_1 
); 
2055 bool wxListMainWindow::OnListNotify( wxListEvent 
&event 
) 
2057   if (m_parent
) m_parent
->ProcessEvent( event 
); 
2061 // ------------------------------------------------------------------------------------- 
2063 // ------------------------------------------------------------------------------------- 
2065 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
) 
2067 wxListItem::wxListItem(void) 
2076   m_format 
= wxLIST_FORMAT_CENTRE
; 
2081 // ------------------------------------------------------------------------------------- 
2083 // ------------------------------------------------------------------------------------- 
2085 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxCommandEvent
) 
2087 wxListEvent::wxListEvent( wxEventType commandType
, int id 
): 
2088   wxCommandEvent( commandType
, id 
) 
2093   m_cancelled 
= FALSE
; 
2096 // ------------------------------------------------------------------------------------- 
2098 // ------------------------------------------------------------------------------------- 
2100 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
) 
2102 BEGIN_EVENT_TABLE(wxListCtrl
,wxControl
) 
2103   EVT_SIZE          (wxListCtrl::OnSize
) 
2104   EVT_IDLE          (wxListCtrl::OnIdle
) 
2107 wxListCtrl::wxListCtrl(void) 
2109   m_imageListNormal 
= (wxImageList 
*) NULL
; 
2110   m_imageListSmall 
= (wxImageList 
*) NULL
; 
2111   m_imageListState 
= (wxImageList 
*) NULL
; 
2114 wxListCtrl::wxListCtrl( wxWindow 
*parent
, wxWindowID id
,  
2115       const wxPoint 
&pos
, const wxSize 
&size
, 
2116       long style
, const wxString 
&name 
) 
2119   Create( parent
, id
, pos
, size
, style
, name 
); 
2122 wxListCtrl::~wxListCtrl(void) 
2126 bool wxListCtrl::Create( wxWindow 
*parent
, wxWindowID id
,  
2127       const wxPoint 
&pos
, const wxSize 
&size
, 
2128       long style
, const wxString 
&name 
) 
2130   m_imageListNormal 
= (wxImageList 
*) NULL
; 
2131   m_imageListSmall 
= (wxImageList 
*) NULL
; 
2132   m_imageListState 
= (wxImageList 
*) NULL
; 
2136   if ((s 
& wxLC_REPORT 
== 0) && 
2137       (s 
& wxLC_LIST 
== 0) && 
2138       (s 
& wxLC_ICON 
== 0)) 
2141   bool ret 
= wxControl::Create( parent
, id
, pos
, size
, s
, name 
); 
2143   m_mainWin 
= new wxListMainWindow( this, -1, wxPoint(0,0), size
, s 
); 
2145   if (GetWindowStyleFlag() & wxLC_REPORT
) 
2146     m_headerWin 
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(size
.x
,23) ); 
2148     m_headerWin 
= (wxListHeaderWindow 
*) NULL
; 
2153 void wxListCtrl::OnSize( wxSizeEvent 
&WXUNUSED(event
) ) 
2155   // handled in OnIdle 
2157   if (m_mainWin
) m_mainWin
->m_dirty 
= TRUE
; 
2160 void wxListCtrl::SetSingleStyle( long style
, bool add 
) 
2162   long flag 
= GetWindowStyleFlag(); 
2166     if (style 
& wxLC_MASK_TYPE
) flag 
= flag 
& ~wxLC_MASK_TYPE
; 
2167     if (style 
& wxLC_MASK_ALIGN
) flag 
= flag 
& ~wxLC_MASK_ALIGN
; 
2168     if (style 
& wxLC_MASK_SORT
) flag 
= flag 
& ~wxLC_MASK_SORT
; 
2177     if (flag 
& style
) flag 
-= style
; 
2180   SetWindowStyleFlag( flag 
); 
2183 void wxListCtrl::SetWindowStyleFlag( long flag 
) 
2185   m_mainWin
->DeleteEverything(); 
2189   GetClientSize( &width
, &height 
); 
2191   m_mainWin
->SetMode( flag 
); 
2193   if (flag 
& wxLC_REPORT
) 
2195     if (!(GetWindowStyleFlag() & wxLC_REPORT
)) 
2197 //      m_mainWin->SetSize( 0, 24, width, height-24 ); 
2200         m_headerWin 
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(width
,23) ); 
2204 //        m_headerWin->SetSize( 0, 0, width, 23 ); 
2205         m_headerWin
->Show( TRUE 
); 
2211     if (GetWindowStyleFlag() & wxLC_REPORT
) 
2213 //      m_mainWin->SetSize( 0, 0, width, height ); 
2214       m_headerWin
->Show( FALSE 
); 
2218   wxWindow::SetWindowStyleFlag( flag 
); 
2221 bool wxListCtrl::GetColumn(int col
, wxListItem 
&item
)  
2223   m_mainWin
->GetColumn( col
, item 
); 
2227 bool wxListCtrl::SetColumn( int col
, wxListItem
& item 
) 
2229   m_mainWin
->SetColumn( col
, item 
); 
2233 int wxListCtrl::GetColumnWidth( int col 
)  
2235   return m_mainWin
->GetColumnWidth( col 
); 
2238 bool wxListCtrl::SetColumnWidth( int col
, int width 
) 
2240   m_mainWin
->SetColumnWidth( col
, width 
); 
2244 int wxListCtrl::GetCountPerPage(void)  
2246   return m_mainWin
->GetCountPerPage();  // different from Windows ? 
2250 wxText& wxListCtrl::GetEditControl(void) const 
2255 bool wxListCtrl::GetItem( wxListItem 
&info 
)  
2257   m_mainWin
->GetItem( info 
); 
2261 bool wxListCtrl::SetItem( wxListItem 
&info 
) 
2263   m_mainWin
->SetItem( info 
); 
2267 long wxListCtrl::SetItem( long index
, int col
, const wxString
& label
, int imageId 
) 
2270   info
.m_text 
= label
; 
2271   info
.m_mask 
= wxLIST_MASK_TEXT
; 
2272   info
.m_itemId 
= index
; 
2276     info
.m_image 
= imageId
; 
2277     info
.m_mask 
|= wxLIST_MASK_IMAGE
; 
2280   m_mainWin
->SetItem(info
); 
2284 int wxListCtrl::GetItemState( long item
, long stateMask 
) 
2286   return m_mainWin
->GetItemState( item
, stateMask 
);   
2289 bool wxListCtrl::SetItemState( long item
, long state
, long stateMask 
) 
2291   m_mainWin
->SetItemState( item
, state
, stateMask 
); 
2295 bool wxListCtrl::SetItemImage( long item
, int image
, int WXUNUSED(selImage
) ) 
2298   info
.m_image 
= image
; 
2299   info
.m_mask 
= wxLIST_MASK_IMAGE
; 
2300   info
.m_itemId 
= item
; 
2301   m_mainWin
->SetItem( info 
); 
2305 wxString 
wxListCtrl::GetItemText( long item 
)  
2308   info
.m_itemId 
= item
; 
2309   m_mainWin
->GetItem( info 
); 
2313 void wxListCtrl::SetItemText( long item
, const wxString 
&str 
) 
2316   info
.m_mask 
= wxLIST_MASK_TEXT
; 
2317   info
.m_itemId 
= item
; 
2319   m_mainWin
->SetItem( info 
); 
2322 long wxListCtrl::GetItemData( long item 
) 
2325   info
.m_itemId 
= item
; 
2326   m_mainWin
->GetItem( info 
); 
2330 bool wxListCtrl::SetItemData( long item
, long data 
) 
2333   info
.m_mask 
= wxLIST_MASK_DATA
; 
2334   info
.m_itemId 
= item
; 
2336   m_mainWin
->SetItem( info 
); 
2340 bool wxListCtrl::GetItemRect( long item
, wxRectangle 
&rect
,  int WXUNUSED(code
) ) 
2342   m_mainWin
->GetItemRect( item
, rect 
); 
2346 bool wxListCtrl::GetItemPosition( long item
, wxPoint
& pos 
) 
2348   m_mainWin
->GetItemPosition( item
, pos 
); 
2352 bool wxListCtrl::SetItemPosition( long WXUNUSED(item
), const wxPoint
& WXUNUSED(pos
) ) 
2357 int wxListCtrl::GetItemCount(void)  
2359   return m_mainWin
->GetItemCount(); 
2362 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall 
) 
2364   m_mainWin
->SetItemSpacing( spacing
, isSmall 
); 
2367 int wxListCtrl::GetItemSpacing( bool isSmall 
) 
2369   return m_mainWin
->GetItemSpacing( isSmall 
); 
2372 int wxListCtrl::GetSelectedItemCount(void)  
2374   return m_mainWin
->GetSelectedItemCount(); 
2378 wxColour wxListCtrl::GetTextColour(void) const 
2382 void wxListCtrl::SetTextColour(const wxColour& WXUNUSED(col)) 
2387 long wxListCtrl::GetTopItem(void) 
2392 long wxListCtrl::GetNextItem( long item
, int geom
, int state 
) const 
2394   return m_mainWin
->GetNextItem( item
, geom
, state 
); 
2397 wxImageList 
*wxListCtrl::GetImageList(int which
) 
2399   if (which 
== wxIMAGE_LIST_NORMAL
) 
2401     return m_imageListNormal
; 
2403   else if (which 
== wxIMAGE_LIST_SMALL
) 
2405     return m_imageListSmall
; 
2407   else if (which 
== wxIMAGE_LIST_STATE
) 
2409     return m_imageListState
; 
2411   return (wxImageList 
*) NULL
; 
2414 void wxListCtrl::SetImageList( wxImageList 
*imageList
, int which 
) 
2416   m_mainWin
->SetImageList( imageList
, which 
); 
2419 bool wxListCtrl::Arrange( int WXUNUSED(flag
) ) 
2424 bool wxListCtrl::DeleteItem( long item 
) 
2426   m_mainWin
->DeleteItem( item 
); 
2430 bool wxListCtrl::DeleteAllItems(void) 
2432   m_mainWin
->DeleteAllItems(); 
2436 bool wxListCtrl::DeleteColumn( int col 
) 
2438   m_mainWin
->DeleteColumn( col 
); 
2443 wxText& wxListCtrl::Edit( long WXUNUSED(item ) ) 
2448 bool wxListCtrl::EnsureVisible( long item 
) 
2450   m_mainWin
->EnsureVisible( item 
); 
2454 long wxListCtrl::FindItem( long start
, const wxString
& str
,  bool partial 
) 
2456   return m_mainWin
->FindItem( start
, str
, partial 
); 
2459 long wxListCtrl::FindItem( long start
, long data 
) 
2461   return m_mainWin
->FindItem( start
, data 
); 
2464 long wxListCtrl::FindItem( long WXUNUSED(start
), const wxPoint
& WXUNUSED(pt
),  
2465                            int WXUNUSED(direction
)) 
2470 long wxListCtrl::HitTest( const wxPoint 
&point
, int &flags 
) 
2472   return m_mainWin
->HitTest( (int)point
.x
, (int)point
.y
, flags 
); 
2475 long wxListCtrl::InsertItem( wxListItem
& info 
) 
2477   m_mainWin
->InsertItem( info 
); 
2481 long wxListCtrl::InsertItem( long index
, const wxString 
&label 
) 
2484   info
.m_text 
= label
; 
2485   info
.m_mask 
= wxLIST_MASK_TEXT
; 
2486   info
.m_itemId 
= index
; 
2487   return InsertItem( info 
); 
2490 long wxListCtrl::InsertItem( long index
, int imageIndex 
) 
2493   info
.m_mask 
= wxLIST_MASK_IMAGE
; 
2494   info
.m_image 
= imageIndex
; 
2495   info
.m_itemId 
= index
; 
2496   return InsertItem( info 
); 
2499 long wxListCtrl::InsertItem( long index
, const wxString 
&label
, int imageIndex 
) 
2502   info
.m_text 
= label
; 
2503   info
.m_image 
= imageIndex
; 
2504   info
.m_mask 
= wxLIST_MASK_TEXT 
| wxLIST_MASK_IMAGE
; 
2505   info
.m_itemId 
= index
; 
2506   return InsertItem( info 
); 
2509 long wxListCtrl::InsertColumn( long col
, wxListItem 
&item 
) 
2511   m_mainWin
->InsertColumn( col
, item 
); 
2515 long wxListCtrl::InsertColumn( long col
, const wxString 
&heading
, 
2516                                int format
, int width 
) 
2519   item
.m_mask 
= wxLIST_MASK_TEXT 
| wxLIST_MASK_FORMAT
; 
2520   item
.m_text 
= heading
; 
2523     item
.m_mask 
|= wxLIST_MASK_WIDTH
; 
2524     item
.m_width 
= width
; 
2527   item
.m_format 
= format
; 
2529   return InsertColumn( col
, item 
); 
2532 bool wxListCtrl::ScrollList( int WXUNUSED(dx
), int WXUNUSED(dy
) ) 
2538 // fn is a function which takes 3 long arguments: item1, item2, data. 
2539 // item1 is the long data associated with a first item (NOT the index). 
2540 // item2 is the long data associated with a second item (NOT the index). 
2541 // data is the same value as passed to SortItems. 
2542 // The return value is a negative number if the first item should precede the second 
2543 // item, a positive number of the second item should precede the first, 
2544 // or zero if the two items are equivalent. 
2545 // data is arbitrary data to be passed to the sort function. 
2547 bool wxListCtrl::SortItems( wxListCtrlCompare fn
, long data 
) 
2549   m_mainWin
->SortItems( fn
, data 
); 
2553 void wxListCtrl::OnIdle( wxIdleEvent 
&WXUNUSED(event
) ) 
2555   if (!m_mainWin
->m_dirty
) return; 
2559   GetClientSize( &cw
, &ch 
); 
2566   if (GetWindowStyleFlag() & wxLC_REPORT
) 
2568     m_headerWin
->GetPosition( &x
, &y 
); 
2569     m_headerWin
->GetSize( &w
, &h 
); 
2570     if ((x 
!= 0) || (y 
!= 0) || (w 
!= cw
) || (h 
!= 23)) 
2571       m_headerWin
->SetSize( 0, 0, cw
, 23 ); 
2573     m_mainWin
->GetPosition( &x
, &y 
); 
2574     m_mainWin
->GetSize( &w
, &h 
); 
2575     if ((x 
!= 0) || (y 
!= 24) || (w 
!= cw
) || (h 
!= ch
-24)) 
2576       m_mainWin
->SetSize( 0, 24, cw
, ch
-24 ); 
2580     m_mainWin
->GetPosition( &x
, &y 
); 
2581     m_mainWin
->GetSize( &w
, &h 
); 
2582     if ((x 
!= 0) || (y 
!= 24) || (w 
!= cw
) || (h 
!= ch
)) 
2583       m_mainWin
->SetSize( 0, 0, cw
, ch 
); 
2586   m_mainWin
->CalculatePositions(); 
2587   m_mainWin
->RealizeChanges(); 
2588   m_mainWin
->m_dirty 
= FALSE
; 
2589   m_mainWin
->Refresh();