1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "listctrl.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
21 #include "wx/dcscreen.h"
23 #include "wx/generic/listctrl.h"
24 #include "wx/generic/imaglist.h"
26 //-----------------------------------------------------------------------------
28 //-----------------------------------------------------------------------------
30 IMPLEMENT_DYNAMIC_CLASS(wxListItemData
,wxObject
);
32 wxListItemData::wxListItemData(void)
43 wxListItemData::wxListItemData( const wxListItem
&info
)
47 m_colour
= info
.m_colour
;
51 void wxListItemData::SetItem( const wxListItem
&info
)
53 if (info
.m_mask
& wxLIST_MASK_TEXT
) m_text
= info
.m_text
;
54 if (info
.m_mask
& wxLIST_MASK_IMAGE
) m_image
= info
.m_image
;
55 if (info
.m_mask
& wxLIST_MASK_DATA
) m_data
= info
.m_data
;
56 m_colour
= info
.m_colour
;
59 m_width
= info
.m_width
;
63 void wxListItemData::SetText( const wxString
&s
)
68 void wxListItemData::SetImage( int image
)
73 void wxListItemData::SetData( long data
)
78 void wxListItemData::SetPosition( int x
, int y
)
84 void wxListItemData::SetSize( int width
, int height
)
86 if (width
!= -1) m_width
= width
;
87 if (height
!= -1) m_height
= height
;
90 void wxListItemData::SetColour( wxColour
*col
)
95 bool wxListItemData::HasImage(void) const
97 return (m_image
>= 0);
100 bool wxListItemData::HasText(void) const
102 return (!m_text
.IsNull());
105 bool wxListItemData::IsHit( int x
, int y
) const
107 return ((x
>= m_xpos
) && (x
<= m_xpos
+m_width
) && (y
>= m_ypos
) && (y
<= m_ypos
+m_height
));
110 void wxListItemData::GetText( wxString
&s
)
115 int wxListItemData::GetX( void ) const
120 int wxListItemData::GetY( void ) const
125 int wxListItemData::GetWidth(void) const
130 int wxListItemData::GetHeight(void) const
135 int wxListItemData::GetImage(void) const
140 void wxListItemData::GetItem( wxListItem
&info
)
142 info
.m_text
= m_text
;
143 info
.m_image
= m_image
;
144 info
.m_data
= m_data
;
147 wxColour
*wxListItemData::GetColour(void)
152 //-----------------------------------------------------------------------------
154 //-----------------------------------------------------------------------------
156 IMPLEMENT_DYNAMIC_CLASS(wxListHeaderData
,wxObject
);
158 wxListHeaderData::wxListHeaderData(void)
169 wxListHeaderData::wxListHeaderData( const wxListItem
&item
)
177 void wxListHeaderData::SetItem( const wxListItem
&item
)
179 m_mask
= item
.m_mask
;
180 m_text
= item
.m_text
;
181 m_image
= item
.m_image
;
182 m_format
= item
.m_format
;
183 m_width
= item
.m_width
;
184 if (m_width
< 0) m_width
= 80;
185 if (m_width
< 6) m_width
= 6;
188 void wxListHeaderData::SetPosition( int x
, int y
)
194 void wxListHeaderData::SetHeight( int h
)
199 void wxListHeaderData::SetWidth( int w
)
202 if (m_width
< 0) m_width
= 80;
203 if (m_width
< 6) m_width
= 6;
206 void wxListHeaderData::SetFormat( int format
)
211 bool wxListHeaderData::HasImage(void) const
213 return (m_image
!= 0);
216 bool wxListHeaderData::HasText(void) const
218 return (m_text
.Length() > 0);
221 bool wxListHeaderData::IsHit( int x
, int y
) const
223 return ((x
>= m_xpos
) && (x
<= m_xpos
+m_width
) && (y
>= m_ypos
) && (y
<= m_ypos
+m_height
));
226 void wxListHeaderData::GetItem( wxListItem
&item
)
228 item
.m_mask
= m_mask
;
229 item
.m_text
= m_text
;
230 item
.m_image
= m_image
;
231 item
.m_format
= m_format
;
232 item
.m_width
= m_width
;
235 void wxListHeaderData::GetText( wxString
&s
)
240 int wxListHeaderData::GetImage(void) const
245 int wxListHeaderData::GetWidth(void) const
250 int wxListHeaderData::GetFormat(void) const
255 //-----------------------------------------------------------------------------
257 //-----------------------------------------------------------------------------
259 IMPLEMENT_DYNAMIC_CLASS(wxListLineData
,wxObject
);
261 wxListLineData::wxListLineData( wxListMainWindow
*owner
, int mode
, wxBrush
*hilightBrush
)
266 m_hilightBrush
= hilightBrush
;
267 m_items
.DeleteContents( TRUE
);
271 void wxListLineData::CalculateSize( wxDC
*dc
, int spacing
)
278 m_bound_all
.width
= m_spacing
;
279 m_bound_all
.height
= m_spacing
+13;
280 wxNode
*node
= m_items
.First();
283 wxListItemData
*item
= (wxListItemData
*)node
->Data();
287 dc
->GetTextExtent( s
, &lw
, &lh
);
288 if (lw
> m_spacing
) m_bound_all
.width
= lw
;
294 wxNode
*node
= m_items
.First();
297 wxListItemData
*item
= (wxListItemData
*)node
->Data();
301 dc
->GetTextExtent( s
, &lw
, &lh
);
302 m_bound_all
.width
= lw
;
303 m_bound_all
.height
= lh
;
309 m_bound_all
.width
= 0;
310 m_bound_all
.height
= 0;
311 wxNode
*node
= m_items
.First();
314 wxListItemData
*item
= (wxListItemData
*)node
->Data();
317 if (s
.IsNull()) s
= "H";
319 dc
->GetTextExtent( s
, &lw
, &lh
);
320 item
->SetSize( item
->GetWidth(), lh
);
321 m_bound_all
.width
+= lw
;
322 m_bound_all
.height
= lh
;
330 void wxListLineData::SetPosition( wxDC
*dc
, int x
, int y
, int window_width
)
338 AssignRect( m_bound_icon
, 0, 0, 0, 0 );
339 AssignRect( m_bound_label
, 0, 0, 0, 0 );
340 AssignRect( m_bound_hilight
, m_bound_all
);
341 wxNode
*node
= m_items
.First();
344 wxListItemData
*item
= (wxListItemData
*)node
->Data();
345 if (item
->HasImage())
347 wxListItemData
*item
= (wxListItemData
*)node
->Data();
350 m_owner
->GetImageSize( item
->GetImage(), w
, h
);
351 m_bound_icon
.x
= m_bound_all
.x
+ (m_spacing
/2) - (w
/2);
352 m_bound_icon
.y
= m_bound_all
.y
+ m_spacing
- h
- 5;
353 m_bound_icon
.width
= w
;
354 m_bound_icon
.height
= h
;
355 if (!item
->HasText())
357 AssignRect( m_bound_hilight
, m_bound_icon
);
358 m_bound_hilight
.x
-= 5;
359 m_bound_hilight
.y
-= 5;
360 m_bound_hilight
.width
+= 9;
361 m_bound_hilight
.height
+= 9;
369 dc
->GetTextExtent( s
, &lw
, &lh
);
370 if (m_bound_all
.width
> m_spacing
)
371 m_bound_label
.x
= m_bound_all
.x
;
373 m_bound_label
.x
= m_bound_all
.x
+ (m_spacing
/2) - lw
/2;
374 m_bound_label
.y
= m_bound_all
.y
+ m_bound_all
.height
- lh
;
375 m_bound_label
.width
= lw
;
376 m_bound_label
.height
= lh
;
377 AssignRect( m_bound_hilight
, m_bound_label
);
378 m_bound_hilight
.x
-= 2;
379 m_bound_hilight
.y
-= 2;
380 m_bound_hilight
.width
+= 4;
381 m_bound_hilight
.height
+= 4;
388 AssignRect( m_bound_label
, m_bound_all
);
391 m_bound_all
.width
+= 4;
392 m_bound_all
.height
+= 3;
393 AssignRect( m_bound_hilight
, m_bound_all
);
394 AssignRect( m_bound_icon
, 0, 0, 0, 0 );
400 dc
->GetTextExtent( "H", &lw
, &lh
);
403 m_bound_all
.height
= lh
+3;
404 m_bound_all
.width
= window_width
;
405 AssignRect( m_bound_hilight
, m_bound_all
);
406 AssignRect( m_bound_label
, 0, 0, 0 ,0 );
407 AssignRect( m_bound_icon
, 0, 0, 0, 0 );
413 void wxListLineData::SetColumnPosition( int index
, int x
)
416 wxNode
*node
= m_items
.Nth( i
);
419 wxListItemData
*item
= (wxListItemData
*)node
->Data();
420 item
->SetPosition( x
, m_bound_all
.y
+1 );
424 void wxListLineData::GetSize( int &width
, int &height
)
426 width
= m_bound_all
.width
;
427 height
= m_bound_all
.height
;
430 void wxListLineData::GetExtent( int &x
, int &y
, int &width
, int &height
)
434 width
= m_bound_all
.width
;
435 height
= m_bound_all
.height
;
438 void wxListLineData::GetLabelExtent( int &x
, int &y
, int &width
, int &height
)
442 width
= m_bound_label
.width
;
443 height
= m_bound_label
.height
;
446 void wxListLineData::GetRect( wxRectangle
&rect
)
448 AssignRect( rect
, m_bound_all
);
451 long wxListLineData::IsHit( int x
, int y
)
453 wxNode
*node
= m_items
.First();
456 wxListItemData
*item
= (wxListItemData
*)node
->Data();
457 if (item
->HasImage() && IsInRect( x
, y
, m_bound_icon
)) return wxLIST_HITTEST_ONITEMICON
;
458 if (item
->HasText() && IsInRect( x
, y
, m_bound_label
)) return wxLIST_HITTEST_ONITEMLABEL
;
459 // if (!(item->HasImage() || item->HasText())) return 0;
461 // if there is no icon or text = empty
462 if (IsInRect( x
, y
, m_bound_all
)) return wxLIST_HITTEST_ONITEMICON
;
466 void wxListLineData::InitItems( int num
)
468 for (int i
= 0; i
< num
; i
++) m_items
.Append( new wxListItemData() );
471 void wxListLineData::SetItem( int index
, const wxListItem
&info
)
473 wxNode
*node
= m_items
.Nth( index
);
476 wxListItemData
*item
= (wxListItemData
*)node
->Data();
477 item
->SetItem( info
);
481 void wxListLineData::GetItem( int index
, wxListItem
&info
)
484 wxNode
*node
= m_items
.Nth( i
);
487 wxListItemData
*item
= (wxListItemData
*)node
->Data();
488 item
->GetItem( info
);
492 void wxListLineData::GetText( int index
, wxString
&s
)
495 wxNode
*node
= m_items
.Nth( i
);
499 wxListItemData
*item
= (wxListItemData
*)node
->Data();
504 void wxListLineData::SetText( int index
, const wxString s
)
507 wxNode
*node
= m_items
.Nth( i
);
510 wxListItemData
*item
= (wxListItemData
*)node
->Data();
515 int wxListLineData::GetImage( int index
)
518 wxNode
*node
= m_items
.Nth( i
);
521 wxListItemData
*item
= (wxListItemData
*)node
->Data();
522 return item
->GetImage();
527 void wxListLineData::DoDraw( wxDC
*dc
, bool hilight
, bool paintBG
)
529 long dev_x
= dc
->LogicalToDeviceX( m_bound_all
.x
-2 );
530 long dev_y
= dc
->LogicalToDeviceY( m_bound_all
.y
-2 );
531 long dev_w
= dc
->LogicalToDeviceXRel( m_bound_all
.width
+4 );
532 long dev_h
= dc
->LogicalToDeviceYRel( m_bound_all
.height
+4 );
534 if (!m_owner
->IsExposed( dev_x
, dev_y
, dev_w
, dev_h
))
543 dc
->SetBrush( * m_hilightBrush
);
544 dc
->SetPen( * wxTRANSPARENT_PEN
);
548 dc
->SetBrush( * wxWHITE_BRUSH
);
549 dc
->SetPen( * wxTRANSPARENT_PEN
);
551 dc
->DrawRectangle( m_bound_hilight
.x
, m_bound_hilight
.y
,
552 m_bound_hilight
.width
, m_bound_hilight
.height
);
555 dc
->SetBackgroundMode(wxTRANSPARENT
);
556 if (m_mode
== wxLC_REPORT
)
559 wxNode
*node
= m_items
.First();
562 wxListItemData
*item
= (wxListItemData
*)node
->Data();
563 dc
->SetClippingRegion( item
->GetX(), item
->GetY(), item
->GetWidth()-3, item
->GetHeight() );
564 int x
= item
->GetX();
565 if (item
->HasImage())
568 m_owner
->DrawImage( item
->GetImage(), dc
, x
, item
->GetY() );
569 m_owner
->GetImageSize( item
->GetImage(), x
, y
);
570 x
+= item
->GetX() + 5;
576 dc
->SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT
) );
578 dc
->SetTextForeground( *item
->GetColour() );
579 dc
->DrawText( s
, x
, item
->GetY() );
581 dc
->DestroyClippingRegion();
587 wxNode
*node
= m_items
.First();
590 wxListItemData
*item
= (wxListItemData
*)node
->Data();
591 if (item
->HasImage())
593 m_owner
->DrawImage( item
->GetImage(), dc
, m_bound_icon
.x
, m_bound_icon
.y
);
600 dc
->SetTextForeground( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT
) );
602 dc
->SetTextForeground( * item
->GetColour() );
603 dc
->DrawText( s
, m_bound_label
.x
, m_bound_label
.y
);
609 void wxListLineData::Hilight( bool on
)
611 if (on
== m_hilighted
) return;
613 m_owner
->SelectLine( this );
615 m_owner
->DeselectLine( this );
619 void wxListLineData::ReverseHilight( void )
621 m_hilighted
= !m_hilighted
;
623 m_owner
->SelectLine( this );
625 m_owner
->DeselectLine( this );
628 void wxListLineData::DrawRubberBand( wxDC
*dc
, bool on
)
632 dc
->SetPen( * wxBLACK_PEN
);
633 dc
->SetBrush( * wxTRANSPARENT_BRUSH
);
634 dc
->DrawRectangle( m_bound_hilight
.x
, m_bound_hilight
.y
,
635 m_bound_hilight
.width
, m_bound_hilight
.height
);
639 void wxListLineData::Draw( wxDC
*dc
)
641 DoDraw( dc
, m_hilighted
, m_hilighted
);
644 bool wxListLineData::IsInRect( int x
, int y
, const wxRectangle
&rect
)
646 return ((x
>= rect
.x
) && (x
<= rect
.x
+rect
.width
) &&
647 (y
>= rect
.y
) && (y
<= rect
.y
+rect
.height
));
650 bool wxListLineData::IsHilighted( void )
655 void wxListLineData::AssignRect( wxRectangle
&dest
, int x
, int y
, int width
, int height
)
660 dest
.height
= height
;
663 void wxListLineData::AssignRect( wxRectangle
&dest
, const wxRectangle
&source
)
667 dest
.width
= source
.width
;
668 dest
.height
= source
.height
;
671 //-----------------------------------------------------------------------------
672 // wxListHeaderWindow
673 //-----------------------------------------------------------------------------
675 IMPLEMENT_DYNAMIC_CLASS(wxListHeaderWindow
,wxWindow
);
677 BEGIN_EVENT_TABLE(wxListHeaderWindow
,wxWindow
)
678 EVT_PAINT (wxListHeaderWindow::OnPaint
)
679 EVT_MOUSE_EVENTS (wxListHeaderWindow::OnMouse
)
680 EVT_SET_FOCUS (wxListHeaderWindow::OnSetFocus
)
683 wxListHeaderWindow::wxListHeaderWindow( void )
685 m_owner
= (wxListMainWindow
*) NULL
;
686 m_currentCursor
= (wxCursor
*) NULL
;
687 m_resizeCursor
= (wxCursor
*) NULL
;
691 wxListHeaderWindow::wxListHeaderWindow( wxWindow
*win
, wxWindowID id
, wxListMainWindow
*owner
,
692 const wxPoint
&pos
, const wxSize
&size
,
693 long style
, const wxString
&name
) :
694 wxWindow( win
, id
, pos
, size
, style
, name
)
697 // m_currentCursor = wxSTANDARD_CURSOR;
698 m_currentCursor
= (wxCursor
*) NULL
;
699 m_resizeCursor
= new wxCursor( wxCURSOR_SIZEWE
);
703 wxListHeaderWindow::~wxListHeaderWindow( void )
705 delete m_resizeCursor
;
708 void wxListHeaderWindow::DoDrawRect( wxDC
*dc
, int x
, int y
, int w
, int h
)
710 const int m_corner
= 1;
712 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
714 dc
->SetPen( *wxBLACK_PEN
);
715 dc
->DrawLine( x
+w
-m_corner
+1, y
, x
+w
, y
+h
); // right (outer)
716 dc
->DrawRectangle( x
, y
+h
, w
, 1 ); // bottom (outer)
718 wxPen
pen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW
), 1, wxSOLID
);
721 dc
->DrawLine( x
+w
-m_corner
, y
, x
+w
-1, y
+h
); // right (inner)
722 dc
->DrawRectangle( x
+1, y
+h
-1, w
-2, 1 ); // bottom (inner)
724 dc
->SetPen( *wxWHITE_PEN
);
725 dc
->DrawRectangle( x
, y
, w
-m_corner
+1, 1 ); // top (outer)
726 dc
->DrawRectangle( x
, y
, 1, h
); // left (outer)
727 dc
->DrawLine( x
, y
+h
-1, x
+1, y
+h
-1 );
728 dc
->DrawLine( x
+w
-1, y
, x
+w
-1, y
+1 );
731 void wxListHeaderWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
733 wxPaintDC
dc( this );
738 dc
.SetFont( GetFont() );
744 GetClientSize( &w
, &h
);
746 dc
.SetBackgroundMode(wxTRANSPARENT
);
747 dc
.SetTextForeground( *wxBLACK
);
748 if (m_foregroundColour
.Ok()) dc
.SetTextForeground( m_foregroundColour
);
752 int numColumns
= m_owner
->GetColumnCount();
754 for (int i
= 0; i
< numColumns
; i
++)
756 m_owner
->GetColumn( i
, item
);
757 int cw
= item
.m_width
-2;
758 if ((i
+1 == numColumns
) || (x
+item
.m_width
> w
-5)) cw
= w
-x
-1;
759 dc
.SetPen( *wxWHITE_PEN
);
761 DoDrawRect( &dc
, x
, y
, cw
, h
-2 );
762 dc
.SetClippingRegion( x
, y
, cw
-5, h
-4 );
763 dc
.DrawText( item
.m_text
, x
+4, y
+3 );
764 dc
.DestroyClippingRegion();
771 void wxListHeaderWindow::DrawCurrent()
775 int x2
= m_currentX
-1;
778 m_owner
->GetClientSize( &dummy
, &y2
);
779 ClientToScreen( &x1
, &y1
);
780 m_owner
->ClientToScreen( &x2
, &y2
);
783 dc
.SetLogicalFunction( wxXOR
);
784 dc
.SetPen( wxPen( *wxBLACK
, 2, wxSOLID
) );
785 dc
.SetBrush( *wxTRANSPARENT_BRUSH
);
787 dc
.DrawLine( x1
, y1
, x2
, y2
);
789 dc
.SetLogicalFunction( wxCOPY
);
791 dc
.SetPen( wxNullPen
);
792 dc
.SetBrush( wxNullBrush
);
795 void wxListHeaderWindow::OnMouse( wxMouseEvent
&event
)
797 int x
= event
.GetX();
798 int y
= event
.GetY();
802 if (event
.ButtonUp())
806 m_owner
->SetColumnWidth( m_column
, m_currentX
-m_minX
);
812 GetClientSize( &size_x
, & dummy
);
816 m_currentX
= m_minX
+7;
817 if (m_currentX
> size_x
-7) m_currentX
= size_x
-7;
824 bool hit_border
= FALSE
;
826 for (int j
= 0; j
< m_owner
->GetColumnCount(); j
++)
828 xpos
+= m_owner
->GetColumnWidth( j
);
829 if ((abs(x
-xpos
) < 3) && (y
< 22))
838 if (event
.LeftDown() && hit_border
)
851 if (m_currentCursor
== wxSTANDARD_CURSOR
) SetCursor( * m_resizeCursor
);
852 m_currentCursor
= m_resizeCursor
;
856 if (m_currentCursor
!= wxSTANDARD_CURSOR
) SetCursor( * wxSTANDARD_CURSOR
);
857 m_currentCursor
= wxSTANDARD_CURSOR
;
862 void wxListHeaderWindow::OnSetFocus( wxFocusEvent
&WXUNUSED(event
) )
867 //-----------------------------------------------------------------------------
868 // wxListRenameTimer (internal)
869 //-----------------------------------------------------------------------------
871 wxListRenameTimer::wxListRenameTimer( wxListMainWindow
*owner
)
876 void wxListRenameTimer::Notify()
878 m_owner
->OnRenameTimer();
881 //-----------------------------------------------------------------------------
882 // wxListTextCtrl (internal)
883 //-----------------------------------------------------------------------------
885 IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl
,wxTextCtrl
);
887 BEGIN_EVENT_TABLE(wxListTextCtrl
,wxTextCtrl
)
888 EVT_CHAR (wxListTextCtrl::OnChar
)
889 EVT_KILL_FOCUS (wxListTextCtrl::OnKillFocus
)
892 wxListTextCtrl::wxListTextCtrl( wxWindow
*parent
, const wxWindowID id
,
893 bool *accept
, wxString
*res
, wxListMainWindow
*owner
,
894 const wxString
&value
, const wxPoint
&pos
, const wxSize
&size
,
895 int style
, const wxValidator
& validator
, const wxString
&name
) :
896 wxTextCtrl( parent
, id
, value
, pos
, size
, style
, validator
, name
)
903 void wxListTextCtrl::OnChar( wxKeyEvent
&event
)
905 if (event
.m_keyCode
== WXK_RETURN
)
908 (*m_res
) = GetValue();
909 m_owner
->OnRenameAccept();
914 if (event
.m_keyCode
== WXK_ESCAPE
)
925 void wxListTextCtrl::OnKillFocus( wxFocusEvent
&WXUNUSED(event
) )
934 //-----------------------------------------------------------------------------
936 //-----------------------------------------------------------------------------
938 IMPLEMENT_DYNAMIC_CLASS(wxListMainWindow
,wxScrolledWindow
);
940 BEGIN_EVENT_TABLE(wxListMainWindow
,wxScrolledWindow
)
941 EVT_PAINT (wxListMainWindow::OnPaint
)
942 EVT_SIZE (wxListMainWindow::OnSize
)
943 EVT_MOUSE_EVENTS (wxListMainWindow::OnMouse
)
944 EVT_CHAR (wxListMainWindow::OnChar
)
945 EVT_SET_FOCUS (wxListMainWindow::OnSetFocus
)
946 EVT_KILL_FOCUS (wxListMainWindow::OnKillFocus
)
949 wxListMainWindow::wxListMainWindow( void )
952 m_lines
.DeleteContents( TRUE
);
953 m_columns
.DeleteContents( TRUE
);
954 m_current
= (wxListLineData
*) NULL
;
956 m_hilightBrush
= (wxBrush
*) NULL
;
960 m_small_image_list
= (wxImageList
*) NULL
;
961 m_normal_image_list
= (wxImageList
*) NULL
;
962 m_small_spacing
= 30;
963 m_normal_spacing
= 40;
966 m_lastOnSame
= FALSE
;
967 m_renameTimer
= new wxListRenameTimer( this );
972 wxListMainWindow::wxListMainWindow( wxWindow
*parent
, wxWindowID id
,
973 const wxPoint
&pos
, const wxSize
&size
,
974 long style
, const wxString
&name
) :
975 wxScrolledWindow( parent
, id
, pos
, size
, style
|wxHSCROLL
|wxVSCROLL
, name
)
978 m_lines
.DeleteContents( TRUE
);
979 m_columns
.DeleteContents( TRUE
);
980 m_current
= (wxListLineData
*) NULL
;
983 m_hilightBrush
= new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT
), wxSOLID
);
984 m_small_image_list
= (wxImageList
*) NULL
;
985 m_normal_image_list
= (wxImageList
*) NULL
;
986 m_small_spacing
= 30;
987 m_normal_spacing
= 40;
994 if (m_mode
& wxLC_REPORT
)
1004 SetScrollbars( m_xScroll
, m_yScroll
, 0, 0, 0, 0 );
1007 m_lastOnSame
= FALSE
;
1008 m_renameTimer
= new wxListRenameTimer( this );
1009 m_renameAccept
= FALSE
;
1011 SetBackgroundColour( *wxWHITE
);
1014 wxListMainWindow::~wxListMainWindow( void )
1016 if (m_hilightBrush
) delete m_hilightBrush
;
1018 delete m_renameTimer
;
1021 void wxListMainWindow::RefreshLine( wxListLineData
*line
)
1029 wxClientDC
dc(this);
1031 line
->GetExtent( x
, y
, w
, h
);
1033 dc
.LogicalToDeviceX(x
-3),
1034 dc
.LogicalToDeviceY(y
-3),
1035 dc
.LogicalToDeviceXRel(w
+6),
1036 dc
.LogicalToDeviceXRel(h
+6) );
1037 Refresh( TRUE
, &rect
);
1041 void wxListMainWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
1043 // Note: a wxPaintDC must be constructed even if no drawing is
1044 // done (a Windows requirement).
1045 wxPaintDC
dc( this );
1048 if (m_dirty
) return;
1050 if (m_lines
.GetCount() == 0) return;
1054 dc
.SetFont( GetFont() );
1056 if (m_mode
& wxLC_REPORT
)
1058 int lineSpacing
= 0;
1059 wxListLineData
*line
= (wxListLineData
*)m_lines
.First()->Data();
1061 line
->GetSize( dummy
, lineSpacing
);
1064 int y_s
= m_yScroll
*GetScrollPos( wxVERTICAL
);
1066 wxNode
*node
= m_lines
.Nth( y_s
/ lineSpacing
);
1067 for (int i
= 0; i
< m_visibleLines
+2; i
++)
1071 line
= (wxListLineData
*)node
->Data();
1073 node
= node
->Next();
1078 wxNode
*node
= m_lines
.First();
1081 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1083 node
= node
->Next();
1087 if (m_current
) m_current
->DrawRubberBand( &dc
, m_hasFocus
);
1092 void wxListMainWindow::HilightAll( bool on
)
1094 wxNode
*node
= m_lines
.First();
1097 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1098 if (line
->IsHilighted() != on
)
1100 line
->Hilight( on
);
1101 RefreshLine( line
);
1103 node
= node
->Next();
1107 void wxListMainWindow::SendNotify( wxListLineData
*line
, wxEventType command
)
1109 wxListEvent
le( command
, GetParent()->GetId() );
1110 le
.SetEventObject( GetParent() );
1111 le
.m_itemIndex
= GetIndexOfLine( line
);
1112 line
->GetItem( 0, le
.m_item
);
1113 GetParent()->GetEventHandler()->ProcessEvent( le
);
1116 void wxListMainWindow::FocusLine( wxListLineData
*WXUNUSED(line
) )
1118 // SendNotify( line, wxEVT_COMMAND_LIST_ITEM_FOCUSSED );
1121 void wxListMainWindow::UnfocusLine( wxListLineData
*WXUNUSED(line
) )
1123 // SendNotify( line, wxEVT_COMMAND_LIST_ITEM_UNFOCUSSED );
1126 void wxListMainWindow::SelectLine( wxListLineData
*line
)
1128 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_SELECTED
);
1131 void wxListMainWindow::DeselectLine( wxListLineData
*line
)
1133 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1136 void wxListMainWindow::DeleteLine( wxListLineData
*line
)
1138 SendNotify( line
, wxEVT_COMMAND_LIST_DELETE_ITEM
);
1141 void wxListMainWindow::StartLabelEdit( wxListLineData
*line
)
1143 SendNotify( line
, wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
);
1146 void wxListMainWindow::RenameLine( wxListLineData
*line
, const wxString
&newName
)
1148 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetParent()->GetId() );
1149 le
.SetEventObject( GetParent() );
1150 le
.m_itemIndex
= GetIndexOfLine( line
);
1151 line
->GetItem( 0, le
.m_item
);
1152 le
.m_item
.m_text
= newName
;
1153 GetParent()->GetEventHandler()->ProcessEvent( le
);
1156 void wxListMainWindow::OnRenameTimer()
1158 StartLabelEdit( m_current
);
1160 m_current
->GetText( 0, s
);
1165 m_current
->GetLabelExtent( x
, y
, w
, h
);
1167 wxClientDC
dc(this);
1169 x
= dc
.LogicalToDeviceX( x
);
1170 y
= dc
.LogicalToDeviceY( y
);
1172 wxListTextCtrl
*text
= new wxListTextCtrl(
1173 this, -1, &m_renameAccept
, &m_renameRes
, this, s
, wxPoint(x
-4,y
-4), wxSize(w
+11,h
+8) );
1177 void wxListMainWindow::OnRenameAccept()
1179 RenameLine( m_current
, m_renameRes
);
1182 void wxListMainWindow::OnMouse( wxMouseEvent
&event
)
1184 if (GetParent()->GetEventHandler()->ProcessEvent( event
)) return;
1186 if (!m_current
) return;
1187 if (m_dirty
) return;
1189 wxClientDC
dc(this);
1191 long x
= dc
.DeviceToLogicalX( (long)event
.GetX() );
1192 long y
= dc
.DeviceToLogicalY( (long)event
.GetY() );
1194 // Did we actually hit an item ?
1196 wxNode
*node
= m_lines
.First();
1197 wxListLineData
*line
= (wxListLineData
*) NULL
;
1200 line
= (wxListLineData
*)node
->Data();
1201 hitResult
= line
->IsHit( x
, y
);
1202 if (hitResult
) break;
1203 line
= (wxListLineData
*) NULL
;
1204 node
= node
->Next();
1207 if (!event
.Dragging())
1212 if (event
.Dragging() && (m_dragCount
> 3))
1216 wxListEvent
le( wxEVT_COMMAND_LIST_BEGIN_DRAG
, GetParent()->GetId() );
1217 le
.SetEventObject( GetParent() );
1218 le
.m_pointDrag
.x
= x
;
1219 le
.m_pointDrag
.y
= y
;
1220 GetParent()->GetEventHandler()->ProcessEvent( le
);
1227 if (event
.ButtonDClick())
1230 m_lastOnSame
= FALSE
;
1231 m_renameTimer
->Stop();
1233 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
1238 if (event
.LeftUp() && m_lastOnSame
)
1241 if ((line
== m_current
) &&
1242 (hitResult
== wxLIST_HITTEST_ONITEMLABEL
) &&
1243 (m_mode
& wxLC_EDIT_LABELS
) )
1245 m_renameTimer
->Start( 100, TRUE
);
1247 m_lastOnSame
= FALSE
;
1251 if (event
.RightDown())
1253 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
);
1257 if (event
.MiddleDown())
1259 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
);
1263 if (event
.LeftDown())
1266 wxListLineData
*oldCurrent
= m_current
;
1267 if (m_mode
& wxLC_SINGLE_SEL
)
1270 HilightAll( FALSE
);
1271 m_current
->ReverseHilight();
1272 RefreshLine( m_current
);
1276 if (event
.ShiftDown())
1279 m_current
->ReverseHilight();
1280 RefreshLine( m_current
);
1282 else if (event
.ControlDown())
1286 int numOfCurrent
= -1;
1287 node
= m_lines
.First();
1290 wxListLineData
*test_line
= (wxListLineData
*)node
->Data();
1292 if (test_line
== oldCurrent
) break;
1293 node
= node
->Next();
1297 node
= m_lines
.First();
1300 wxListLineData
*test_line
= (wxListLineData
*)node
->Data();
1302 if (test_line
== line
) break;
1303 node
= node
->Next();
1306 if (numOfLine
< numOfCurrent
)
1309 numOfLine
= numOfCurrent
;
1313 wxNode
*node
= m_lines
.Nth( numOfCurrent
);
1314 for (int i
= 0; i
<= numOfLine
-numOfCurrent
; i
++)
1316 wxListLineData
*test_line
= (wxListLineData
*)node
->Data();
1317 test_line
->Hilight(TRUE
);
1318 RefreshLine( test_line
);
1319 node
= node
->Next();
1325 HilightAll( FALSE
);
1326 m_current
->ReverseHilight();
1327 RefreshLine( m_current
);
1330 if (m_current
!= oldCurrent
)
1332 RefreshLine( oldCurrent
);
1333 UnfocusLine( oldCurrent
);
1334 FocusLine( m_current
);
1336 m_lastOnSame
= (m_current
== oldCurrent
);
1341 void wxListMainWindow::MoveToFocus( void )
1343 if (!m_current
) return;
1349 m_current
->GetExtent( x
, y
, w
, h
);
1353 GetClientSize( &w_p
, &h_p
);
1355 if (m_mode
& wxLC_REPORT
)
1357 int y_s
= m_yScroll
*GetScrollPos( wxVERTICAL
);
1358 if ((y
> y_s
) && (y
+h
< y_s
+h_p
)) return;
1359 if (y
-y_s
< 5) Scroll( -1, (y
-5-h_p
/2)/m_yScroll
);
1360 if (y
+h
+5 > y_s
+h_p
) Scroll( -1, (y
+h
-h_p
/2+h
+15)/m_yScroll
);
1364 int x_s
= m_xScroll
*GetScrollPos( wxHORIZONTAL
);
1365 if ((x
> x_s
) && (x
+w
< x_s
+w_p
)) return;
1366 if (x
-x_s
< 5) Scroll( (x
-5)/m_xScroll
, -1 );
1367 if (x
+w
-5 > x_s
+w_p
) Scroll( (x
+w
-w_p
+15)/m_xScroll
, -1 );
1371 void wxListMainWindow::OnArrowChar( wxListLineData
*newCurrent
, bool shiftDown
)
1373 if ((m_mode
& wxLC_SINGLE_SEL
) || (m_usedKeys
== FALSE
)) m_current
->Hilight( FALSE
);
1374 wxListLineData
*oldCurrent
= m_current
;
1375 m_current
= newCurrent
;
1377 if (shiftDown
|| (m_mode
& wxLC_SINGLE_SEL
)) m_current
->Hilight( TRUE
);
1378 RefreshLine( m_current
);
1379 RefreshLine( oldCurrent
);
1380 FocusLine( m_current
);
1381 UnfocusLine( oldCurrent
);
1384 void wxListMainWindow::OnChar( wxKeyEvent
&event
)
1386 wxListEvent
le( wxEVT_COMMAND_LIST_KEY_DOWN
, GetParent()->GetId() );
1387 le
.m_code
= event
.KeyCode();
1388 le
.SetEventObject( GetParent() );
1389 GetParent()->GetEventHandler()->ProcessEvent( le
);
1392 if (event.KeyCode() == WXK_TAB)
1394 if (event.ShiftDown())
1407 switch (event
.KeyCode())
1411 wxNode
*node
= m_lines
.Member( m_current
)->Previous();
1412 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1417 wxNode
*node
= m_lines
.Member( m_current
)->Next();
1418 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1423 wxNode
*node
= m_lines
.Last();
1424 OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1429 wxNode
*node
= m_lines
.First();
1430 OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1436 if (m_mode
& wxLC_REPORT
) { steps
= m_visibleLines
-1; }
1440 wxNode
*node
= m_lines
.First();
1441 for (;;) { if (m_current
== (wxListLineData
*)node
->Data()) break; pos
++; node
= node
->Next(); }
1442 steps
= pos
% m_visibleLines
;
1444 wxNode
*node
= m_lines
.Member( m_current
);
1445 for (int i
= 0; i
< steps
; i
++) if (node
->Previous()) node
= node
->Previous();
1446 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1452 if (m_mode
& wxLC_REPORT
) { steps
= m_visibleLines
-1; }
1455 int pos
= 0; wxNode
*node
= m_lines
.First();
1456 for (;;) { if (m_current
== (wxListLineData
*)node
->Data()) break; pos
++; node
= node
->Next(); }
1457 steps
= m_visibleLines
-(pos
% m_visibleLines
)-1;
1459 wxNode
*node
= m_lines
.Member( m_current
);
1460 for (int i
= 0; i
< steps
; i
++) if (node
->Next()) node
= node
->Next();
1461 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1466 if (!(m_mode
& wxLC_REPORT
))
1468 wxNode
*node
= m_lines
.Member( m_current
);
1469 for (int i
= 0; i
<m_visibleLines
; i
++) if (node
->Previous()) node
= node
->Previous();
1470 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1476 if (!(m_mode
& wxLC_REPORT
))
1478 wxNode
*node
= m_lines
.Member( m_current
);
1479 for (int i
= 0; i
<m_visibleLines
; i
++) if (node
->Next()) node
= node
->Next();
1480 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1486 m_current
->ReverseHilight();
1487 RefreshLine( m_current
);
1492 if (!(m_mode
& wxLC_SINGLE_SEL
))
1494 wxListLineData
*oldCurrent
= m_current
;
1495 m_current
->ReverseHilight();
1496 wxNode
*node
= m_lines
.Member( m_current
)->Next();
1497 if (node
) m_current
= (wxListLineData
*)node
->Data();
1499 RefreshLine( oldCurrent
);
1500 RefreshLine( m_current
);
1501 UnfocusLine( oldCurrent
);
1502 FocusLine( m_current
);
1509 wxListEvent
le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
, GetParent()->GetId() );
1510 le
.SetEventObject( GetParent() );
1511 le
.m_itemIndex
= GetIndexOfLine( m_current
);
1512 m_current
->GetItem( 0, le
.m_item
);
1513 GetParent()->GetEventHandler()->ProcessEvent( le
);
1525 void wxListMainWindow::OnSetFocus( wxFocusEvent
&WXUNUSED(event
) )
1528 RefreshLine( m_current
);
1530 if (!GetParent()) return;
1532 wxFocusEvent
event( wxEVT_SET_FOCUS
, GetParent()->GetId() );
1533 event
.SetEventObject( GetParent() );
1534 GetParent()->GetEventHandler()->ProcessEvent( event
);
1537 void wxListMainWindow::OnKillFocus( wxFocusEvent
&WXUNUSED(event
) )
1540 RefreshLine( m_current
);
1543 void wxListMainWindow::OnSize( wxSizeEvent
&WXUNUSED(event
) )
1546 We don't even allow the wxScrolledWindow::AdjustScrollbars() call
1551 void wxListMainWindow::DrawImage( int index
, wxDC
*dc
, int x
, int y
)
1553 if ((m_mode
& wxLC_ICON
) && (m_normal_image_list
))
1555 m_normal_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
1558 if ((m_mode
& wxLC_SMALL_ICON
) && (m_small_image_list
))
1560 m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
1562 if ((m_mode
& wxLC_REPORT
) && (m_small_image_list
))
1564 m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
1569 void wxListMainWindow::GetImageSize( int index
, int &width
, int &height
)
1571 if ((m_mode
& wxLC_ICON
) && (m_normal_image_list
))
1573 m_normal_image_list
->GetSize( index
, width
, height
);
1576 if ((m_mode
& wxLC_SMALL_ICON
) && (m_small_image_list
))
1578 m_small_image_list
->GetSize( index
, width
, height
);
1581 if ((m_mode
& wxLC_REPORT
) && (m_small_image_list
))
1583 m_small_image_list
->GetSize( index
, width
, height
);
1590 int wxListMainWindow::GetTextLength( wxString
&s
)
1592 wxClientDC
dc( this );
1595 dc
.GetTextExtent( s
, &lw
, &lh
);
1599 int wxListMainWindow::GetIndexOfLine( const wxListLineData
*line
)
1602 wxNode
*node
= m_lines
.First();
1605 if (line
== (wxListLineData
*)node
->Data()) return i
;
1607 node
= node
->Next();
1612 void wxListMainWindow::SetImageList( wxImageList
*imageList
, int which
)
1615 if (which
== wxIMAGE_LIST_NORMAL
) m_normal_image_list
= imageList
;
1616 if (which
== wxIMAGE_LIST_SMALL
) m_small_image_list
= imageList
;
1619 void wxListMainWindow::SetItemSpacing( int spacing
, bool isSmall
)
1624 m_small_spacing
= spacing
;
1628 m_normal_spacing
= spacing
;
1632 int wxListMainWindow::GetItemSpacing( bool isSmall
)
1634 if (isSmall
) return m_small_spacing
; else return m_normal_spacing
;
1637 void wxListMainWindow::SetColumn( int col
, wxListItem
&item
)
1640 wxNode
*node
= m_columns
.Nth( col
);
1643 if (item
.m_width
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width
= GetTextLength( item
.m_text
)+7;
1644 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
1645 column
->SetItem( item
);
1647 wxListCtrl
*lc
= (wxListCtrl
*) GetParent();
1648 if (lc
->m_headerWin
) lc
->m_headerWin
->Refresh();
1651 void wxListMainWindow::SetColumnWidth( int col
, int width
)
1653 if (!(m_mode
& wxLC_REPORT
)) return;
1657 wxNode
*node
= m_columns
.Nth( col
);
1660 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
1661 column
->SetWidth( width
);
1664 node
= m_lines
.First();
1667 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1668 wxNode
*n
= line
->m_items
.Nth( col
);
1671 wxListItemData
*item
= (wxListItemData
*)n
->Data();
1672 item
->SetSize( width
, -1 );
1674 node
= node
->Next();
1677 wxListCtrl
*lc
= (wxListCtrl
*) GetParent();
1678 if (lc
->m_headerWin
) lc
->m_headerWin
->Refresh();
1681 void wxListMainWindow::GetColumn( int col
, wxListItem
&item
)
1683 wxNode
*node
= m_columns
.Nth( col
);
1686 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
1687 column
->GetItem( item
);
1699 int wxListMainWindow::GetColumnWidth( int col
)
1701 wxNode
*node
= m_columns
.Nth( col
);
1704 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
1705 return column
->GetWidth();
1713 int wxListMainWindow::GetColumnCount( void )
1715 return m_columns
.Number();
1718 int wxListMainWindow::GetCountPerPage( void )
1720 return m_visibleLines
;
1723 void wxListMainWindow::SetItem( wxListItem
&item
)
1726 wxNode
*node
= m_lines
.Nth( item
.m_itemId
);
1729 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1730 if (m_mode
& wxLC_REPORT
) item
.m_width
= GetColumnWidth( item
.m_col
)-3;
1731 line
->SetItem( item
.m_col
, item
);
1735 void wxListMainWindow::SetItemState( long item
, long state
, long stateMask
)
1737 // m_dirty = TRUE; no recalcs needed
1739 wxListLineData
*oldCurrent
= m_current
;
1741 if (stateMask
& wxLIST_STATE_FOCUSED
)
1743 wxNode
*node
= m_lines
.Nth( item
);
1746 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1747 UnfocusLine( m_current
);
1749 FocusLine( m_current
);
1750 RefreshLine( m_current
);
1751 RefreshLine( oldCurrent
);
1755 if (stateMask
& wxLIST_STATE_SELECTED
)
1757 bool on
= state
& wxLIST_STATE_SELECTED
;
1758 if (!on
&& (m_mode
& wxLC_SINGLE_SEL
)) return;
1760 wxNode
*node
= m_lines
.Nth( item
);
1763 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1764 if (m_mode
& wxLC_SINGLE_SEL
)
1766 UnfocusLine( m_current
);
1768 FocusLine( m_current
);
1769 oldCurrent
->Hilight( FALSE
);
1770 RefreshLine( m_current
);
1771 RefreshLine( oldCurrent
);
1773 bool on
= state
& wxLIST_STATE_SELECTED
;
1774 if (on
!= line
->IsHilighted())
1776 line
->Hilight( on
);
1777 RefreshLine( line
);
1783 int wxListMainWindow::GetItemState( long item
, long stateMask
)
1785 int ret
= wxLIST_STATE_DONTCARE
;
1786 if (stateMask
& wxLIST_STATE_FOCUSED
)
1788 wxNode
*node
= m_lines
.Nth( item
);
1791 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1792 if (line
== m_current
) ret
|= wxLIST_STATE_FOCUSED
;
1795 if (stateMask
& wxLIST_STATE_SELECTED
)
1797 wxNode
*node
= m_lines
.Nth( item
);
1800 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1801 if (line
->IsHilighted()) ret
|= wxLIST_STATE_FOCUSED
;
1807 void wxListMainWindow::GetItem( wxListItem
&item
)
1809 wxNode
*node
= m_lines
.Nth( item
.m_itemId
);
1812 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1813 line
->GetItem( item
.m_col
, item
);
1824 int wxListMainWindow::GetItemCount( void )
1826 return m_lines
.Number();
1829 void wxListMainWindow::GetItemRect( long index
, wxRectangle
&rect
)
1831 wxNode
*node
= m_lines
.Nth( index
);
1834 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1835 line
->GetRect( rect
);
1846 bool wxListMainWindow::GetItemPosition(long item
, wxPoint
& pos
)
1848 wxNode
*node
= m_lines
.Nth( item
);
1852 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1853 line
->GetRect( rect
);
1865 int wxListMainWindow::GetSelectedItemCount( void )
1868 wxNode
*node
= m_lines
.First();
1871 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1872 if (line
->IsHilighted()) ret
++;
1873 node
= node
->Next();
1878 void wxListMainWindow::SetMode( long mode
)
1885 if (m_mode
& wxLC_REPORT
)
1897 long wxListMainWindow::GetMode( void ) const
1902 void wxListMainWindow::CalculatePositions( void )
1904 if (!m_lines
.First()) return;
1906 wxClientDC
dc( this );
1907 dc
.SetFont( GetFont() );
1909 int iconSpacing
= 0;
1910 if (m_mode
& wxLC_ICON
) iconSpacing
= m_normal_spacing
;
1911 if (m_mode
& wxLC_SMALL_ICON
) iconSpacing
= m_small_spacing
;
1913 // we take the first line (which also can be an icon or
1914 // an a text item in wxLC_ICON and wxLC_LIST modes) to
1915 // measure the size of the line
1919 int lineSpacing
= 0;
1921 wxListLineData
*line
= (wxListLineData
*)m_lines
.First()->Data();
1922 line
->CalculateSize( &dc
, iconSpacing
);
1924 line
->GetSize( dummy
, lineSpacing
);
1927 int clientWidth
= 0;
1928 int clientHeight
= 0;
1930 if (m_mode
& wxLC_REPORT
)
1934 int entireHeight
= m_lines
.Number() * lineSpacing
+ 2;
1935 int scroll_pos
= GetScrollPos( wxVERTICAL
);
1936 SetScrollbars( m_xScroll
, m_yScroll
, 0, (entireHeight
+15) / m_yScroll
, 0, scroll_pos
, TRUE
);
1937 GetClientSize( &clientWidth
, &clientHeight
);
1939 wxNode
* node
= m_lines
.First();
1942 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1943 line
->CalculateSize( &dc
, iconSpacing
);
1944 line
->SetPosition( &dc
, x
, y
, clientWidth
);
1946 for (int i
= 0; i
< GetColumnCount(); i
++)
1948 line
->SetColumnPosition( i
, col_x
);
1949 col_x
+= GetColumnWidth( i
);
1951 y
+= lineSpacing
; // one pixel blank line between items
1952 node
= node
->Next();
1954 m_visibleLines
= clientHeight
/ lineSpacing
;
1958 // at first we try without any scrollbar. if the items don't
1959 // fit into the window, we recalculate after subtracting an
1960 // approximated 15 pt for the horizontal scrollbar
1962 GetSize( &clientWidth
, &clientHeight
);
1963 clientHeight
-= 4; // sunken frame
1965 int entireWidth
= 0;
1967 for (int tries
= 0; tries
< 2; tries
++)
1970 int x
= 5; // painting is done at x-2
1971 int y
= 5; // painting is done at y-2
1973 wxNode
*node
= m_lines
.First();
1976 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1977 line
->CalculateSize( &dc
, iconSpacing
);
1978 line
->SetPosition( &dc
, x
, y
, clientWidth
);
1979 line
->GetSize( lineWidth
, lineHeight
);
1980 if (lineWidth
> maxWidth
) maxWidth
= lineWidth
;
1982 if (y
+lineSpacing
-6 >= clientHeight
) // -6 for earlier "line breaking"
1986 entireWidth
+= maxWidth
+6;
1989 node
= node
->Next();
1990 if (!node
) entireWidth
+= maxWidth
;
1991 if ((tries
== 0) && (entireWidth
> clientWidth
))
1993 clientHeight
-= 15; // scrollbar height
1996 if (!node
) tries
= 1; // everything fits, no second try required
1999 m_visibleLines
= (clientHeight
+6) / (lineSpacing
); // +6 for earlier "line breaking"
2001 int scroll_pos
= GetScrollPos( wxHORIZONTAL
);
2002 SetScrollbars( m_xScroll
, m_yScroll
, (entireWidth
+15) / m_xScroll
, 0, scroll_pos
, 0, TRUE
);
2006 void wxListMainWindow::RealizeChanges( void )
2010 wxNode
*node
= m_lines
.First();
2011 if (node
) m_current
= (wxListLineData
*)node
->Data();
2015 FocusLine( m_current
);
2016 if (m_mode
& wxLC_SINGLE_SEL
) m_current
->Hilight( TRUE
);
2020 long wxListMainWindow::GetNextItem( long item
, int WXUNUSED(geometry
), int state
)
2023 if (item
> 0) ret
= item
;
2024 wxNode
*node
= m_lines
.Nth( ret
);
2027 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2028 if ((state
& wxLIST_STATE_FOCUSED
) && (line
== m_current
)) return ret
;
2029 if ((state
& wxLIST_STATE_SELECTED
) && (line
->IsHilighted())) return ret
;
2030 if (!state
) return ret
;
2032 node
= node
->Next();
2037 void wxListMainWindow::DeleteItem( long index
)
2040 wxNode
*node
= m_lines
.Nth( index
);
2043 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2044 if (m_current
== line
) m_current
= (wxListLineData
*) NULL
;
2046 m_lines
.DeleteNode( node
);
2050 void wxListMainWindow::DeleteColumn( int col
)
2052 wxCHECK_RET( col
< (int)m_columns
.GetCount(),
2053 "attempting to delete inexistent column in wxListView" );
2056 wxNode
*node
= m_columns
.Nth( col
);
2057 if (node
) m_columns
.DeleteNode( node
);
2060 void wxListMainWindow::DeleteAllItems( void )
2063 m_current
= (wxListLineData
*) NULL
;
2064 wxNode
*node
= m_lines
.First();
2067 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2069 node
= node
->Next();
2074 void wxListMainWindow::DeleteEverything( void )
2077 m_current
= (wxListLineData
*) NULL
;
2078 wxNode
*node
= m_lines
.First();
2081 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2083 node
= node
->Next();
2086 m_current
= (wxListLineData
*) NULL
;
2090 void wxListMainWindow::EnsureVisible( long index
)
2092 wxListLineData
*oldCurrent
= m_current
;
2093 m_current
= (wxListLineData
*) NULL
;
2095 wxNode
*node
= m_lines
.Nth( i
);
2096 if (node
) m_current
= (wxListLineData
*)node
->Data();
2097 if (m_current
) MoveToFocus();
2098 m_current
= oldCurrent
;
2101 long wxListMainWindow::FindItem(long start
, const wxString
& str
, bool WXUNUSED(partial
) )
2105 if (pos
< 0) pos
= 0;
2106 wxNode
*node
= m_lines
.Nth( pos
);
2109 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2111 line
->GetText( 0, s
);
2112 if (s
== tmp
) return pos
;
2113 node
= node
->Next();
2119 long wxListMainWindow::FindItem(long start
, long data
)
2122 if (pos
< 0) pos
= 0;
2123 wxNode
*node
= m_lines
.Nth( pos
);
2126 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2128 line
->GetItem( 0, item
);
2129 if (item
.m_data
== data
) return pos
;
2130 node
= node
->Next();
2136 long wxListMainWindow::HitTest( int x
, int y
, int &flags
)
2138 wxNode
*node
= m_lines
.First();
2142 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2143 long ret
= line
->IsHit( x
, y
);
2149 node
= node
->Next();
2155 void wxListMainWindow::InsertItem( wxListItem
&item
)
2159 if (m_mode
& wxLC_REPORT
) mode
= wxLC_REPORT
;
2160 else if (m_mode
& wxLC_LIST
) mode
= wxLC_LIST
;
2161 else if (m_mode
& wxLC_ICON
) mode
= wxLC_ICON
;
2162 else if (m_mode
& wxLC_SMALL_ICON
) mode
= wxLC_ICON
; // no typo
2164 wxListLineData
*line
= new wxListLineData( this, mode
, m_hilightBrush
);
2166 if (m_mode
& wxLC_REPORT
)
2168 line
->InitItems( GetColumnCount() );
2169 item
.m_width
= GetColumnWidth( 0 )-3;
2173 line
->InitItems( 1 );
2176 line
->SetItem( 0, item
);
2177 if ((item
.m_itemId
>= 0) && (item
.m_itemId
< (int)m_lines
.GetCount()))
2179 wxNode
*node
= m_lines
.Nth( item
.m_itemId
);
2180 if (node
) m_lines
.Insert( node
, line
);
2184 m_lines
.Append( line
);
2188 void wxListMainWindow::InsertColumn( long col
, wxListItem
&item
)
2191 if (m_mode
& wxLC_REPORT
)
2193 if (item
.m_width
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width
= GetTextLength( item
.m_text
);
2194 wxListHeaderData
*column
= new wxListHeaderData( item
);
2195 if ((col
>= 0) && (col
< (int)m_columns
.GetCount()))
2197 wxNode
*node
= m_columns
.Nth( col
);
2199 m_columns
.Insert( node
, column
);
2203 m_columns
.Append( column
);
2208 wxListCtrlCompare list_ctrl_compare_func_2
;
2209 long list_ctrl_compare_data
;
2211 int list_ctrl_compare_func_1( const void *arg1
, const void *arg2
)
2213 wxListLineData
*line1
= *((wxListLineData
**)arg1
);
2214 wxListLineData
*line2
= *((wxListLineData
**)arg2
);
2216 line1
->GetItem( 0, item
);
2217 long data1
= item
.m_data
;
2218 line2
->GetItem( 0, item
);
2219 long data2
= item
.m_data
;
2220 return list_ctrl_compare_func_2( data1
, data2
, list_ctrl_compare_data
);
2223 void wxListMainWindow::SortItems( wxListCtrlCompare fn
, long data
)
2225 list_ctrl_compare_func_2
= fn
;
2226 list_ctrl_compare_data
= data
;
2227 m_lines
.Sort( list_ctrl_compare_func_1
);
2230 // -------------------------------------------------------------------------------------
2232 // -------------------------------------------------------------------------------------
2234 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
2236 wxListItem::wxListItem(void)
2245 m_format
= wxLIST_FORMAT_CENTRE
;
2250 // -------------------------------------------------------------------------------------
2252 // -------------------------------------------------------------------------------------
2254 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
)
2256 wxListEvent::wxListEvent( wxEventType commandType
, int id
):
2257 wxNotifyEvent( commandType
, id
)
2263 m_cancelled
= FALSE
;
2268 // -------------------------------------------------------------------------------------
2270 // -------------------------------------------------------------------------------------
2272 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
2274 BEGIN_EVENT_TABLE(wxListCtrl
,wxControl
)
2275 EVT_SIZE (wxListCtrl::OnSize
)
2276 EVT_IDLE (wxListCtrl::OnIdle
)
2279 wxListCtrl::wxListCtrl(void)
2281 m_imageListNormal
= (wxImageList
*) NULL
;
2282 m_imageListSmall
= (wxImageList
*) NULL
;
2283 m_imageListState
= (wxImageList
*) NULL
;
2284 m_mainWin
= (wxListMainWindow
*) NULL
;
2285 m_headerWin
= (wxListHeaderWindow
*) NULL
;
2288 wxListCtrl::~wxListCtrl(void)
2292 bool wxListCtrl::Create( wxWindow
*parent
, wxWindowID id
,
2293 const wxPoint
&pos
, const wxSize
&size
,
2294 long style
, const wxValidator
&validator
,
2295 const wxString
&name
)
2297 m_imageListNormal
= (wxImageList
*) NULL
;
2298 m_imageListSmall
= (wxImageList
*) NULL
;
2299 m_imageListState
= (wxImageList
*) NULL
;
2300 m_mainWin
= (wxListMainWindow
*) NULL
;
2301 m_headerWin
= (wxListHeaderWindow
*) NULL
;
2305 if ((s
& wxLC_REPORT
== 0) &&
2306 (s
& wxLC_LIST
== 0) &&
2307 (s
& wxLC_ICON
== 0))
2312 bool ret
= wxControl::Create( parent
, id
, pos
, size
, s
, name
);
2314 SetValidator( validator
);
2316 if (s
& wxSUNKEN_BORDER
) s
-= wxSUNKEN_BORDER
;
2318 m_mainWin
= new wxListMainWindow( this, -1, wxPoint(0,0), size
, s
);
2320 if (GetWindowStyleFlag() & wxLC_REPORT
)
2321 m_headerWin
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(size
.x
,23), wxTAB_TRAVERSAL
);
2323 m_headerWin
= (wxListHeaderWindow
*) NULL
;
2328 void wxListCtrl::OnSize( wxSizeEvent
&WXUNUSED(event
) )
2330 /* handled in OnIdle */
2332 if (m_mainWin
) m_mainWin
->m_dirty
= TRUE
;
2335 void wxListCtrl::SetSingleStyle( long style
, bool add
)
2337 long flag
= GetWindowStyleFlag();
2341 if (style
& wxLC_MASK_TYPE
) flag
= flag
& ~wxLC_MASK_TYPE
;
2342 if (style
& wxLC_MASK_ALIGN
) flag
= flag
& ~wxLC_MASK_ALIGN
;
2343 if (style
& wxLC_MASK_SORT
) flag
= flag
& ~wxLC_MASK_SORT
;
2352 if (flag
& style
) flag
-= style
;
2355 SetWindowStyleFlag( flag
);
2358 void wxListCtrl::SetWindowStyleFlag( long flag
)
2360 m_mainWin
->DeleteEverything();
2364 GetClientSize( &width
, &height
);
2366 m_mainWin
->SetMode( flag
);
2368 if (flag
& wxLC_REPORT
)
2370 if (!(GetWindowStyleFlag() & wxLC_REPORT
))
2372 // m_mainWin->SetSize( 0, 24, width, height-24 );
2375 m_headerWin
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(width
,23), wxTAB_TRAVERSAL
);
2379 // m_headerWin->SetSize( 0, 0, width, 23 );
2380 m_headerWin
->Show( TRUE
);
2386 if (GetWindowStyleFlag() & wxLC_REPORT
)
2388 // m_mainWin->SetSize( 0, 0, width, height );
2389 m_headerWin
->Show( FALSE
);
2393 wxWindow::SetWindowStyleFlag( flag
);
2396 bool wxListCtrl::GetColumn(int col
, wxListItem
&item
) const
2398 m_mainWin
->GetColumn( col
, item
);
2402 bool wxListCtrl::SetColumn( int col
, wxListItem
& item
)
2404 m_mainWin
->SetColumn( col
, item
);
2408 int wxListCtrl::GetColumnWidth( int col
) const
2410 return m_mainWin
->GetColumnWidth( col
);
2413 bool wxListCtrl::SetColumnWidth( int col
, int width
)
2415 m_mainWin
->SetColumnWidth( col
, width
);
2419 int wxListCtrl::GetCountPerPage(void) const
2421 return m_mainWin
->GetCountPerPage(); // different from Windows ?
2425 wxText& wxListCtrl::GetEditControl(void) const
2430 bool wxListCtrl::GetItem( wxListItem
&info
) const
2432 m_mainWin
->GetItem( info
);
2436 bool wxListCtrl::SetItem( wxListItem
&info
)
2438 m_mainWin
->SetItem( info
);
2442 long wxListCtrl::SetItem( long index
, int col
, const wxString
& label
, int imageId
)
2445 info
.m_text
= label
;
2446 info
.m_mask
= wxLIST_MASK_TEXT
;
2447 info
.m_itemId
= index
;
2451 info
.m_image
= imageId
;
2452 info
.m_mask
|= wxLIST_MASK_IMAGE
;
2454 m_mainWin
->SetItem(info
);
2458 int wxListCtrl::GetItemState( long item
, long stateMask
) const
2460 return m_mainWin
->GetItemState( item
, stateMask
);
2463 bool wxListCtrl::SetItemState( long item
, long state
, long stateMask
)
2465 m_mainWin
->SetItemState( item
, state
, stateMask
);
2469 bool wxListCtrl::SetItemImage( long item
, int image
, int WXUNUSED(selImage
) )
2472 info
.m_image
= image
;
2473 info
.m_mask
= wxLIST_MASK_IMAGE
;
2474 info
.m_itemId
= item
;
2475 m_mainWin
->SetItem( info
);
2479 wxString
wxListCtrl::GetItemText( long item
) const
2482 info
.m_itemId
= item
;
2483 m_mainWin
->GetItem( info
);
2487 void wxListCtrl::SetItemText( long item
, const wxString
&str
)
2490 info
.m_mask
= wxLIST_MASK_TEXT
;
2491 info
.m_itemId
= item
;
2493 m_mainWin
->SetItem( info
);
2496 long wxListCtrl::GetItemData( long item
) const
2499 info
.m_itemId
= item
;
2500 m_mainWin
->GetItem( info
);
2504 bool wxListCtrl::SetItemData( long item
, long data
)
2507 info
.m_mask
= wxLIST_MASK_DATA
;
2508 info
.m_itemId
= item
;
2510 m_mainWin
->SetItem( info
);
2514 bool wxListCtrl::GetItemRect( long item
, wxRectangle
&rect
, int WXUNUSED(code
) ) const
2516 m_mainWin
->GetItemRect( item
, rect
);
2520 bool wxListCtrl::GetItemPosition( long item
, wxPoint
& pos
) const
2522 m_mainWin
->GetItemPosition( item
, pos
);
2526 bool wxListCtrl::SetItemPosition( long WXUNUSED(item
), const wxPoint
& WXUNUSED(pos
) )
2531 int wxListCtrl::GetItemCount(void) const
2533 return m_mainWin
->GetItemCount();
2536 int wxListCtrl::GetColumnCount(void) const
2538 return m_mainWin
->GetColumnCount();
2541 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
2543 m_mainWin
->SetItemSpacing( spacing
, isSmall
);
2546 int wxListCtrl::GetItemSpacing( bool isSmall
) const
2548 return m_mainWin
->GetItemSpacing( isSmall
);
2551 int wxListCtrl::GetSelectedItemCount(void) const
2553 return m_mainWin
->GetSelectedItemCount();
2557 wxColour wxListCtrl::GetTextColour(void) const
2561 void wxListCtrl::SetTextColour(const wxColour& WXUNUSED(col))
2566 long wxListCtrl::GetTopItem(void) const
2571 long wxListCtrl::GetNextItem( long item
, int geom
, int state
) const
2573 return m_mainWin
->GetNextItem( item
, geom
, state
);
2576 wxImageList
*wxListCtrl::GetImageList(int which
) const
2578 if (which
== wxIMAGE_LIST_NORMAL
)
2580 return m_imageListNormal
;
2582 else if (which
== wxIMAGE_LIST_SMALL
)
2584 return m_imageListSmall
;
2586 else if (which
== wxIMAGE_LIST_STATE
)
2588 return m_imageListState
;
2590 return (wxImageList
*) NULL
;
2593 void wxListCtrl::SetImageList( wxImageList
*imageList
, int which
)
2595 m_mainWin
->SetImageList( imageList
, which
);
2598 bool wxListCtrl::Arrange( int WXUNUSED(flag
) )
2603 bool wxListCtrl::DeleteItem( long item
)
2605 m_mainWin
->DeleteItem( item
);
2609 bool wxListCtrl::DeleteAllItems(void)
2611 m_mainWin
->DeleteAllItems();
2615 bool wxListCtrl::DeleteAllColumns()
2617 for ( size_t n
= 0; n
< m_mainWin
->m_columns
.GetCount(); n
++ )
2623 void wxListCtrl::ClearAll()
2625 m_mainWin
->DeleteEverything();
2628 bool wxListCtrl::DeleteColumn( int col
)
2630 m_mainWin
->DeleteColumn( col
);
2635 wxText& wxListCtrl::Edit( long WXUNUSED(item ) )
2640 bool wxListCtrl::EnsureVisible( long item
)
2642 m_mainWin
->EnsureVisible( item
);
2646 long wxListCtrl::FindItem( long start
, const wxString
& str
, bool partial
)
2648 return m_mainWin
->FindItem( start
, str
, partial
);
2651 long wxListCtrl::FindItem( long start
, long data
)
2653 return m_mainWin
->FindItem( start
, data
);
2656 long wxListCtrl::FindItem( long WXUNUSED(start
), const wxPoint
& WXUNUSED(pt
),
2657 int WXUNUSED(direction
))
2662 long wxListCtrl::HitTest( const wxPoint
&point
, int &flags
)
2664 return m_mainWin
->HitTest( (int)point
.x
, (int)point
.y
, flags
);
2667 long wxListCtrl::InsertItem( wxListItem
& info
)
2669 m_mainWin
->InsertItem( info
);
2673 long wxListCtrl::InsertItem( long index
, const wxString
&label
)
2676 info
.m_text
= label
;
2677 info
.m_mask
= wxLIST_MASK_TEXT
;
2678 info
.m_itemId
= index
;
2679 return InsertItem( info
);
2682 long wxListCtrl::InsertItem( long index
, int imageIndex
)
2685 info
.m_mask
= wxLIST_MASK_IMAGE
;
2686 info
.m_image
= imageIndex
;
2687 info
.m_itemId
= index
;
2688 return InsertItem( info
);
2691 long wxListCtrl::InsertItem( long index
, const wxString
&label
, int imageIndex
)
2694 info
.m_text
= label
;
2695 info
.m_image
= imageIndex
;
2696 info
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_IMAGE
;
2697 info
.m_itemId
= index
;
2698 return InsertItem( info
);
2701 long wxListCtrl::InsertColumn( long col
, wxListItem
&item
)
2703 m_mainWin
->InsertColumn( col
, item
);
2707 long wxListCtrl::InsertColumn( long col
, const wxString
&heading
,
2708 int format
, int width
)
2711 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
2712 item
.m_text
= heading
;
2715 item
.m_mask
|= wxLIST_MASK_WIDTH
;
2716 item
.m_width
= width
;
2719 item
.m_format
= format
;
2721 return InsertColumn( col
, item
);
2724 bool wxListCtrl::ScrollList( int WXUNUSED(dx
), int WXUNUSED(dy
) )
2730 // fn is a function which takes 3 long arguments: item1, item2, data.
2731 // item1 is the long data associated with a first item (NOT the index).
2732 // item2 is the long data associated with a second item (NOT the index).
2733 // data is the same value as passed to SortItems.
2734 // The return value is a negative number if the first item should precede the second
2735 // item, a positive number of the second item should precede the first,
2736 // or zero if the two items are equivalent.
2737 // data is arbitrary data to be passed to the sort function.
2739 bool wxListCtrl::SortItems( wxListCtrlCompare fn
, long data
)
2741 m_mainWin
->SortItems( fn
, data
);
2745 void wxListCtrl::OnIdle( wxIdleEvent
&WXUNUSED(event
) )
2747 if (!m_mainWin
->m_dirty
) return;
2751 GetClientSize( &cw
, &ch
);
2758 if (GetWindowStyleFlag() & wxLC_REPORT
)
2760 m_headerWin
->GetPosition( &x
, &y
);
2761 m_headerWin
->GetSize( &w
, &h
);
2762 if ((x
!= 0) || (y
!= 0) || (w
!= cw
) || (h
!= 23))
2763 m_headerWin
->SetSize( 0, 0, cw
, 23 );
2765 m_mainWin
->GetPosition( &x
, &y
);
2766 m_mainWin
->GetSize( &w
, &h
);
2767 if ((x
!= 0) || (y
!= 24) || (w
!= cw
) || (h
!= ch
-24))
2768 m_mainWin
->SetSize( 0, 24, cw
, ch
-24 );
2772 m_mainWin
->GetPosition( &x
, &y
);
2773 m_mainWin
->GetSize( &w
, &h
);
2774 if ((x
!= 0) || (y
!= 24) || (w
!= cw
) || (h
!= ch
))
2775 m_mainWin
->SetSize( 0, 0, cw
, ch
);
2778 m_mainWin
->CalculatePositions();
2779 m_mainWin
->RealizeChanges();
2780 m_mainWin
->m_dirty
= FALSE
;
2781 m_mainWin
->Refresh();
2784 void wxListCtrl::SetBackgroundColour( const wxColour
&colour
)
2788 m_mainWin
->SetBackgroundColour( colour
);
2789 m_mainWin
->m_dirty
= TRUE
;
2792 m_headerWin
->SetBackgroundColour( colour
);
2795 void wxListCtrl::SetForegroundColour( const wxColour
&colour
)
2799 m_mainWin
->SetForegroundColour( colour
);
2800 m_mainWin
->m_dirty
= TRUE
;
2803 m_headerWin
->SetForegroundColour( colour
);
2806 void wxListCtrl::SetFont( const wxFont
&font
)
2810 m_mainWin
->SetFont( font
);
2811 m_mainWin
->m_dirty
= TRUE
;
2814 m_headerWin
->SetFont( font
);