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( wxRect
&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 wxRect
&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( wxRect
&dest
, int x
, int y
, int width
, int height
)
660 dest
.height
= height
;
663 void wxListLineData::AssignRect( wxRect
&dest
, const wxRect
&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 wxWindow
*parent
= GetParent();
1388 /* we send a list_key event up */
1389 wxListEvent
le( wxEVT_COMMAND_LIST_KEY_DOWN
, GetParent()->GetId() );
1390 le
.m_code
= event
.KeyCode();
1391 le
.SetEventObject( parent
);
1392 parent
->GetEventHandler()->ProcessEvent( le
);
1394 /* we propagate the key event up */
1395 wxKeyEvent
ke( wxEVT_KEY_DOWN
);
1396 ke
.m_shiftDown
= event
.m_shiftDown
;
1397 ke
.m_controlDown
= event
.m_controlDown
;
1398 ke
.m_altDown
= event
.m_altDown
;
1399 ke
.m_metaDown
= event
.m_metaDown
;
1400 ke
.m_keyCode
= event
.m_keyCode
;
1403 ke
.SetEventObject( parent
);
1404 if (parent
->GetEventHandler()->ProcessEvent( ke
)) return;
1406 /* no item -> nothing to do */
1413 switch (event
.KeyCode())
1417 wxNode
*node
= m_lines
.Member( m_current
)->Previous();
1418 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1423 wxNode
*node
= m_lines
.Member( m_current
)->Next();
1424 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1429 wxNode
*node
= m_lines
.Last();
1430 OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1435 wxNode
*node
= m_lines
.First();
1436 OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1442 if (m_mode
& wxLC_REPORT
)
1444 steps
= m_visibleLines
-1;
1449 wxNode
*node
= m_lines
.First();
1450 for (;;) { if (m_current
== (wxListLineData
*)node
->Data()) break; pos
++; node
= node
->Next(); }
1451 steps
= pos
% m_visibleLines
;
1453 wxNode
*node
= m_lines
.Member( m_current
);
1454 for (int i
= 0; i
< steps
; i
++) if (node
->Previous()) node
= node
->Previous();
1455 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1461 if (m_mode
& wxLC_REPORT
)
1463 steps
= m_visibleLines
-1;
1467 int pos
= 0; wxNode
*node
= m_lines
.First();
1468 for (;;) { if (m_current
== (wxListLineData
*)node
->Data()) break; pos
++; node
= node
->Next(); }
1469 steps
= m_visibleLines
-(pos
% m_visibleLines
)-1;
1471 wxNode
*node
= m_lines
.Member( m_current
);
1472 for (int i
= 0; i
< steps
; i
++) if (node
->Next()) node
= node
->Next();
1473 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1478 if (!(m_mode
& wxLC_REPORT
))
1480 wxNode
*node
= m_lines
.Member( m_current
);
1481 for (int i
= 0; i
<m_visibleLines
; i
++) if (node
->Previous()) node
= node
->Previous();
1482 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1488 if (!(m_mode
& wxLC_REPORT
))
1490 wxNode
*node
= m_lines
.Member( m_current
);
1491 for (int i
= 0; i
<m_visibleLines
; i
++) if (node
->Next()) node
= node
->Next();
1492 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
1498 m_current
->ReverseHilight();
1499 RefreshLine( m_current
);
1504 if (!(m_mode
& wxLC_SINGLE_SEL
))
1506 wxListLineData
*oldCurrent
= m_current
;
1507 m_current
->ReverseHilight();
1508 wxNode
*node
= m_lines
.Member( m_current
)->Next();
1509 if (node
) m_current
= (wxListLineData
*)node
->Data();
1511 RefreshLine( oldCurrent
);
1512 RefreshLine( m_current
);
1513 UnfocusLine( oldCurrent
);
1514 FocusLine( m_current
);
1521 wxListEvent
le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
, GetParent()->GetId() );
1522 le
.SetEventObject( GetParent() );
1523 le
.m_itemIndex
= GetIndexOfLine( m_current
);
1524 m_current
->GetItem( 0, le
.m_item
);
1525 GetParent()->GetEventHandler()->ProcessEvent( le
);
1537 void wxListMainWindow::OnSetFocus( wxFocusEvent
&WXUNUSED(event
) )
1540 RefreshLine( m_current
);
1542 if (!GetParent()) return;
1544 wxFocusEvent
event( wxEVT_SET_FOCUS
, GetParent()->GetId() );
1545 event
.SetEventObject( GetParent() );
1546 GetParent()->GetEventHandler()->ProcessEvent( event
);
1549 void wxListMainWindow::OnKillFocus( wxFocusEvent
&WXUNUSED(event
) )
1552 RefreshLine( m_current
);
1555 void wxListMainWindow::OnSize( wxSizeEvent
&WXUNUSED(event
) )
1558 We don't even allow the wxScrolledWindow::AdjustScrollbars() call
1563 void wxListMainWindow::DrawImage( int index
, wxDC
*dc
, int x
, int y
)
1565 if ((m_mode
& wxLC_ICON
) && (m_normal_image_list
))
1567 m_normal_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
1570 if ((m_mode
& wxLC_SMALL_ICON
) && (m_small_image_list
))
1572 m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
1574 if ((m_mode
& wxLC_REPORT
) && (m_small_image_list
))
1576 m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
1581 void wxListMainWindow::GetImageSize( int index
, int &width
, int &height
)
1583 if ((m_mode
& wxLC_ICON
) && (m_normal_image_list
))
1585 m_normal_image_list
->GetSize( index
, width
, height
);
1588 if ((m_mode
& wxLC_SMALL_ICON
) && (m_small_image_list
))
1590 m_small_image_list
->GetSize( index
, width
, height
);
1593 if ((m_mode
& wxLC_REPORT
) && (m_small_image_list
))
1595 m_small_image_list
->GetSize( index
, width
, height
);
1602 int wxListMainWindow::GetTextLength( wxString
&s
)
1604 wxClientDC
dc( this );
1607 dc
.GetTextExtent( s
, &lw
, &lh
);
1611 int wxListMainWindow::GetIndexOfLine( const wxListLineData
*line
)
1614 wxNode
*node
= m_lines
.First();
1617 if (line
== (wxListLineData
*)node
->Data()) return i
;
1619 node
= node
->Next();
1624 void wxListMainWindow::SetImageList( wxImageList
*imageList
, int which
)
1627 if (which
== wxIMAGE_LIST_NORMAL
) m_normal_image_list
= imageList
;
1628 if (which
== wxIMAGE_LIST_SMALL
) m_small_image_list
= imageList
;
1631 void wxListMainWindow::SetItemSpacing( int spacing
, bool isSmall
)
1636 m_small_spacing
= spacing
;
1640 m_normal_spacing
= spacing
;
1644 int wxListMainWindow::GetItemSpacing( bool isSmall
)
1646 if (isSmall
) return m_small_spacing
; else return m_normal_spacing
;
1649 void wxListMainWindow::SetColumn( int col
, wxListItem
&item
)
1652 wxNode
*node
= m_columns
.Nth( col
);
1655 if (item
.m_width
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width
= GetTextLength( item
.m_text
)+7;
1656 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
1657 column
->SetItem( item
);
1659 wxListCtrl
*lc
= (wxListCtrl
*) GetParent();
1660 if (lc
->m_headerWin
) lc
->m_headerWin
->Refresh();
1663 void wxListMainWindow::SetColumnWidth( int col
, int width
)
1665 if (!(m_mode
& wxLC_REPORT
)) return;
1669 wxNode
*node
= m_columns
.Nth( col
);
1672 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
1673 column
->SetWidth( width
);
1676 node
= m_lines
.First();
1679 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1680 wxNode
*n
= line
->m_items
.Nth( col
);
1683 wxListItemData
*item
= (wxListItemData
*)n
->Data();
1684 item
->SetSize( width
, -1 );
1686 node
= node
->Next();
1689 wxListCtrl
*lc
= (wxListCtrl
*) GetParent();
1690 if (lc
->m_headerWin
) lc
->m_headerWin
->Refresh();
1693 void wxListMainWindow::GetColumn( int col
, wxListItem
&item
)
1695 wxNode
*node
= m_columns
.Nth( col
);
1698 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
1699 column
->GetItem( item
);
1711 int wxListMainWindow::GetColumnWidth( int col
)
1713 wxNode
*node
= m_columns
.Nth( col
);
1716 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
1717 return column
->GetWidth();
1725 int wxListMainWindow::GetColumnCount( void )
1727 return m_columns
.Number();
1730 int wxListMainWindow::GetCountPerPage( void )
1732 return m_visibleLines
;
1735 void wxListMainWindow::SetItem( wxListItem
&item
)
1738 wxNode
*node
= m_lines
.Nth( item
.m_itemId
);
1741 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1742 if (m_mode
& wxLC_REPORT
) item
.m_width
= GetColumnWidth( item
.m_col
)-3;
1743 line
->SetItem( item
.m_col
, item
);
1747 void wxListMainWindow::SetItemState( long item
, long state
, long stateMask
)
1749 // m_dirty = TRUE; no recalcs needed
1751 wxListLineData
*oldCurrent
= m_current
;
1753 if (stateMask
& wxLIST_STATE_FOCUSED
)
1755 wxNode
*node
= m_lines
.Nth( item
);
1758 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1759 UnfocusLine( m_current
);
1761 FocusLine( m_current
);
1762 RefreshLine( m_current
);
1763 RefreshLine( oldCurrent
);
1767 if (stateMask
& wxLIST_STATE_SELECTED
)
1769 bool on
= state
& wxLIST_STATE_SELECTED
;
1770 if (!on
&& (m_mode
& wxLC_SINGLE_SEL
)) return;
1772 wxNode
*node
= m_lines
.Nth( item
);
1775 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1776 if (m_mode
& wxLC_SINGLE_SEL
)
1778 UnfocusLine( m_current
);
1780 FocusLine( m_current
);
1781 oldCurrent
->Hilight( FALSE
);
1782 RefreshLine( m_current
);
1783 RefreshLine( oldCurrent
);
1785 bool on
= state
& wxLIST_STATE_SELECTED
;
1786 if (on
!= line
->IsHilighted())
1788 line
->Hilight( on
);
1789 RefreshLine( line
);
1795 int wxListMainWindow::GetItemState( long item
, long stateMask
)
1797 int ret
= wxLIST_STATE_DONTCARE
;
1798 if (stateMask
& wxLIST_STATE_FOCUSED
)
1800 wxNode
*node
= m_lines
.Nth( item
);
1803 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1804 if (line
== m_current
) ret
|= wxLIST_STATE_FOCUSED
;
1807 if (stateMask
& wxLIST_STATE_SELECTED
)
1809 wxNode
*node
= m_lines
.Nth( item
);
1812 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1813 if (line
->IsHilighted()) ret
|= wxLIST_STATE_FOCUSED
;
1819 void wxListMainWindow::GetItem( wxListItem
&item
)
1821 wxNode
*node
= m_lines
.Nth( item
.m_itemId
);
1824 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1825 line
->GetItem( item
.m_col
, item
);
1836 int wxListMainWindow::GetItemCount( void )
1838 return m_lines
.Number();
1841 void wxListMainWindow::GetItemRect( long index
, wxRect
&rect
)
1843 wxNode
*node
= m_lines
.Nth( index
);
1846 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1847 line
->GetRect( rect
);
1858 bool wxListMainWindow::GetItemPosition(long item
, wxPoint
& pos
)
1860 wxNode
*node
= m_lines
.Nth( item
);
1864 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1865 line
->GetRect( rect
);
1877 int wxListMainWindow::GetSelectedItemCount( void )
1880 wxNode
*node
= m_lines
.First();
1883 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1884 if (line
->IsHilighted()) ret
++;
1885 node
= node
->Next();
1890 void wxListMainWindow::SetMode( long mode
)
1897 if (m_mode
& wxLC_REPORT
)
1909 long wxListMainWindow::GetMode( void ) const
1914 void wxListMainWindow::CalculatePositions( void )
1916 if (!m_lines
.First()) return;
1918 wxClientDC
dc( this );
1919 dc
.SetFont( GetFont() );
1921 int iconSpacing
= 0;
1922 if (m_mode
& wxLC_ICON
) iconSpacing
= m_normal_spacing
;
1923 if (m_mode
& wxLC_SMALL_ICON
) iconSpacing
= m_small_spacing
;
1925 // we take the first line (which also can be an icon or
1926 // an a text item in wxLC_ICON and wxLC_LIST modes) to
1927 // measure the size of the line
1931 int lineSpacing
= 0;
1933 wxListLineData
*line
= (wxListLineData
*)m_lines
.First()->Data();
1934 line
->CalculateSize( &dc
, iconSpacing
);
1936 line
->GetSize( dummy
, lineSpacing
);
1939 int clientWidth
= 0;
1940 int clientHeight
= 0;
1942 if (m_mode
& wxLC_REPORT
)
1946 int entireHeight
= m_lines
.Number() * lineSpacing
+ 2;
1947 int scroll_pos
= GetScrollPos( wxVERTICAL
);
1948 SetScrollbars( m_xScroll
, m_yScroll
, 0, (entireHeight
+15) / m_yScroll
, 0, scroll_pos
, TRUE
);
1949 GetClientSize( &clientWidth
, &clientHeight
);
1951 wxNode
* node
= m_lines
.First();
1954 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1955 line
->CalculateSize( &dc
, iconSpacing
);
1956 line
->SetPosition( &dc
, x
, y
, clientWidth
);
1958 for (int i
= 0; i
< GetColumnCount(); i
++)
1960 line
->SetColumnPosition( i
, col_x
);
1961 col_x
+= GetColumnWidth( i
);
1963 y
+= lineSpacing
; // one pixel blank line between items
1964 node
= node
->Next();
1966 m_visibleLines
= clientHeight
/ lineSpacing
;
1970 // at first we try without any scrollbar. if the items don't
1971 // fit into the window, we recalculate after subtracting an
1972 // approximated 15 pt for the horizontal scrollbar
1974 GetSize( &clientWidth
, &clientHeight
);
1975 clientHeight
-= 4; // sunken frame
1977 int entireWidth
= 0;
1979 for (int tries
= 0; tries
< 2; tries
++)
1982 int x
= 5; // painting is done at x-2
1983 int y
= 5; // painting is done at y-2
1985 wxNode
*node
= m_lines
.First();
1988 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1989 line
->CalculateSize( &dc
, iconSpacing
);
1990 line
->SetPosition( &dc
, x
, y
, clientWidth
);
1991 line
->GetSize( lineWidth
, lineHeight
);
1992 if (lineWidth
> maxWidth
) maxWidth
= lineWidth
;
1994 if (y
+lineSpacing
-6 >= clientHeight
) // -6 for earlier "line breaking"
1998 entireWidth
+= maxWidth
+6;
2001 node
= node
->Next();
2002 if (!node
) entireWidth
+= maxWidth
;
2003 if ((tries
== 0) && (entireWidth
> clientWidth
))
2005 clientHeight
-= 15; // scrollbar height
2008 if (!node
) tries
= 1; // everything fits, no second try required
2011 m_visibleLines
= (clientHeight
+6) / (lineSpacing
); // +6 for earlier "line breaking"
2013 int scroll_pos
= GetScrollPos( wxHORIZONTAL
);
2014 SetScrollbars( m_xScroll
, m_yScroll
, (entireWidth
+15) / m_xScroll
, 0, scroll_pos
, 0, TRUE
);
2018 void wxListMainWindow::RealizeChanges( void )
2022 wxNode
*node
= m_lines
.First();
2023 if (node
) m_current
= (wxListLineData
*)node
->Data();
2027 FocusLine( m_current
);
2028 if (m_mode
& wxLC_SINGLE_SEL
) m_current
->Hilight( TRUE
);
2032 long wxListMainWindow::GetNextItem( long item
, int WXUNUSED(geometry
), int state
)
2035 if (item
> 0) ret
= item
;
2036 wxNode
*node
= m_lines
.Nth( ret
);
2039 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2040 if ((state
& wxLIST_STATE_FOCUSED
) && (line
== m_current
)) return ret
;
2041 if ((state
& wxLIST_STATE_SELECTED
) && (line
->IsHilighted())) return ret
;
2042 if (!state
) return ret
;
2044 node
= node
->Next();
2049 void wxListMainWindow::DeleteItem( long index
)
2052 wxNode
*node
= m_lines
.Nth( index
);
2055 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2056 if (m_current
== line
) m_current
= (wxListLineData
*) NULL
;
2058 m_lines
.DeleteNode( node
);
2062 void wxListMainWindow::DeleteColumn( int col
)
2064 wxCHECK_RET( col
< (int)m_columns
.GetCount(),
2065 "attempting to delete inexistent column in wxListView" );
2068 wxNode
*node
= m_columns
.Nth( col
);
2069 if (node
) m_columns
.DeleteNode( node
);
2072 void wxListMainWindow::DeleteAllItems( void )
2075 m_current
= (wxListLineData
*) NULL
;
2076 wxNode
*node
= m_lines
.First();
2079 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2081 node
= node
->Next();
2086 void wxListMainWindow::DeleteEverything( void )
2089 m_current
= (wxListLineData
*) NULL
;
2090 wxNode
*node
= m_lines
.First();
2093 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2095 node
= node
->Next();
2098 m_current
= (wxListLineData
*) NULL
;
2102 void wxListMainWindow::EnsureVisible( long index
)
2104 wxListLineData
*oldCurrent
= m_current
;
2105 m_current
= (wxListLineData
*) NULL
;
2107 wxNode
*node
= m_lines
.Nth( i
);
2108 if (node
) m_current
= (wxListLineData
*)node
->Data();
2109 if (m_current
) MoveToFocus();
2110 m_current
= oldCurrent
;
2113 long wxListMainWindow::FindItem(long start
, const wxString
& str
, bool WXUNUSED(partial
) )
2117 if (pos
< 0) pos
= 0;
2118 wxNode
*node
= m_lines
.Nth( pos
);
2121 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2123 line
->GetText( 0, s
);
2124 if (s
== tmp
) return pos
;
2125 node
= node
->Next();
2131 long wxListMainWindow::FindItem(long start
, long data
)
2134 if (pos
< 0) pos
= 0;
2135 wxNode
*node
= m_lines
.Nth( pos
);
2138 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2140 line
->GetItem( 0, item
);
2141 if (item
.m_data
== data
) return pos
;
2142 node
= node
->Next();
2148 long wxListMainWindow::HitTest( int x
, int y
, int &flags
)
2150 wxNode
*node
= m_lines
.First();
2154 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2155 long ret
= line
->IsHit( x
, y
);
2161 node
= node
->Next();
2167 void wxListMainWindow::InsertItem( wxListItem
&item
)
2171 if (m_mode
& wxLC_REPORT
) mode
= wxLC_REPORT
;
2172 else if (m_mode
& wxLC_LIST
) mode
= wxLC_LIST
;
2173 else if (m_mode
& wxLC_ICON
) mode
= wxLC_ICON
;
2174 else if (m_mode
& wxLC_SMALL_ICON
) mode
= wxLC_ICON
; // no typo
2176 wxListLineData
*line
= new wxListLineData( this, mode
, m_hilightBrush
);
2178 if (m_mode
& wxLC_REPORT
)
2180 line
->InitItems( GetColumnCount() );
2181 item
.m_width
= GetColumnWidth( 0 )-3;
2185 line
->InitItems( 1 );
2188 line
->SetItem( 0, item
);
2189 if ((item
.m_itemId
>= 0) && (item
.m_itemId
< (int)m_lines
.GetCount()))
2191 wxNode
*node
= m_lines
.Nth( item
.m_itemId
);
2192 if (node
) m_lines
.Insert( node
, line
);
2196 m_lines
.Append( line
);
2200 void wxListMainWindow::InsertColumn( long col
, wxListItem
&item
)
2203 if (m_mode
& wxLC_REPORT
)
2205 if (item
.m_width
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width
= GetTextLength( item
.m_text
);
2206 wxListHeaderData
*column
= new wxListHeaderData( item
);
2207 if ((col
>= 0) && (col
< (int)m_columns
.GetCount()))
2209 wxNode
*node
= m_columns
.Nth( col
);
2211 m_columns
.Insert( node
, column
);
2215 m_columns
.Append( column
);
2220 wxListCtrlCompare list_ctrl_compare_func_2
;
2221 long list_ctrl_compare_data
;
2223 int list_ctrl_compare_func_1( const void *arg1
, const void *arg2
)
2225 wxListLineData
*line1
= *((wxListLineData
**)arg1
);
2226 wxListLineData
*line2
= *((wxListLineData
**)arg2
);
2228 line1
->GetItem( 0, item
);
2229 long data1
= item
.m_data
;
2230 line2
->GetItem( 0, item
);
2231 long data2
= item
.m_data
;
2232 return list_ctrl_compare_func_2( data1
, data2
, list_ctrl_compare_data
);
2235 void wxListMainWindow::SortItems( wxListCtrlCompare fn
, long data
)
2237 list_ctrl_compare_func_2
= fn
;
2238 list_ctrl_compare_data
= data
;
2239 m_lines
.Sort( list_ctrl_compare_func_1
);
2242 // -------------------------------------------------------------------------------------
2244 // -------------------------------------------------------------------------------------
2246 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
2248 wxListItem::wxListItem(void)
2257 m_format
= wxLIST_FORMAT_CENTRE
;
2262 // -------------------------------------------------------------------------------------
2264 // -------------------------------------------------------------------------------------
2266 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
)
2268 wxListEvent::wxListEvent( wxEventType commandType
, int id
):
2269 wxNotifyEvent( commandType
, id
)
2275 m_cancelled
= FALSE
;
2280 // -------------------------------------------------------------------------------------
2282 // -------------------------------------------------------------------------------------
2284 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
2286 BEGIN_EVENT_TABLE(wxListCtrl
,wxControl
)
2287 EVT_SIZE (wxListCtrl::OnSize
)
2288 EVT_IDLE (wxListCtrl::OnIdle
)
2291 wxListCtrl::wxListCtrl(void)
2293 m_imageListNormal
= (wxImageList
*) NULL
;
2294 m_imageListSmall
= (wxImageList
*) NULL
;
2295 m_imageListState
= (wxImageList
*) NULL
;
2296 m_mainWin
= (wxListMainWindow
*) NULL
;
2297 m_headerWin
= (wxListHeaderWindow
*) NULL
;
2300 wxListCtrl::~wxListCtrl(void)
2304 bool wxListCtrl::Create( wxWindow
*parent
, wxWindowID id
,
2305 const wxPoint
&pos
, const wxSize
&size
,
2306 long style
, const wxValidator
&validator
,
2307 const wxString
&name
)
2309 m_imageListNormal
= (wxImageList
*) NULL
;
2310 m_imageListSmall
= (wxImageList
*) NULL
;
2311 m_imageListState
= (wxImageList
*) NULL
;
2312 m_mainWin
= (wxListMainWindow
*) NULL
;
2313 m_headerWin
= (wxListHeaderWindow
*) NULL
;
2317 if ((s
& wxLC_REPORT
== 0) &&
2318 (s
& wxLC_LIST
== 0) &&
2319 (s
& wxLC_ICON
== 0))
2324 bool ret
= wxControl::Create( parent
, id
, pos
, size
, s
, name
);
2326 SetValidator( validator
);
2328 if (s
& wxSUNKEN_BORDER
) s
-= wxSUNKEN_BORDER
;
2330 m_mainWin
= new wxListMainWindow( this, -1, wxPoint(0,0), size
, s
);
2332 if (GetWindowStyleFlag() & wxLC_REPORT
)
2333 m_headerWin
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(size
.x
,23), wxTAB_TRAVERSAL
);
2335 m_headerWin
= (wxListHeaderWindow
*) NULL
;
2340 void wxListCtrl::OnSize( wxSizeEvent
&WXUNUSED(event
) )
2342 /* handled in OnIdle */
2344 if (m_mainWin
) m_mainWin
->m_dirty
= TRUE
;
2347 void wxListCtrl::SetSingleStyle( long style
, bool add
)
2349 long flag
= GetWindowStyleFlag();
2353 if (style
& wxLC_MASK_TYPE
) flag
= flag
& ~wxLC_MASK_TYPE
;
2354 if (style
& wxLC_MASK_ALIGN
) flag
= flag
& ~wxLC_MASK_ALIGN
;
2355 if (style
& wxLC_MASK_SORT
) flag
= flag
& ~wxLC_MASK_SORT
;
2364 if (flag
& style
) flag
-= style
;
2367 SetWindowStyleFlag( flag
);
2370 void wxListCtrl::SetWindowStyleFlag( long flag
)
2372 m_mainWin
->DeleteEverything();
2376 GetClientSize( &width
, &height
);
2378 m_mainWin
->SetMode( flag
);
2380 if (flag
& wxLC_REPORT
)
2382 if (!(GetWindowStyleFlag() & wxLC_REPORT
))
2384 // m_mainWin->SetSize( 0, 24, width, height-24 );
2387 m_headerWin
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(width
,23), wxTAB_TRAVERSAL
);
2391 // m_headerWin->SetSize( 0, 0, width, 23 );
2392 m_headerWin
->Show( TRUE
);
2398 if (GetWindowStyleFlag() & wxLC_REPORT
)
2400 // m_mainWin->SetSize( 0, 0, width, height );
2401 m_headerWin
->Show( FALSE
);
2405 wxWindow::SetWindowStyleFlag( flag
);
2408 bool wxListCtrl::GetColumn(int col
, wxListItem
&item
) const
2410 m_mainWin
->GetColumn( col
, item
);
2414 bool wxListCtrl::SetColumn( int col
, wxListItem
& item
)
2416 m_mainWin
->SetColumn( col
, item
);
2420 int wxListCtrl::GetColumnWidth( int col
) const
2422 return m_mainWin
->GetColumnWidth( col
);
2425 bool wxListCtrl::SetColumnWidth( int col
, int width
)
2427 m_mainWin
->SetColumnWidth( col
, width
);
2431 int wxListCtrl::GetCountPerPage(void) const
2433 return m_mainWin
->GetCountPerPage(); // different from Windows ?
2437 wxText& wxListCtrl::GetEditControl(void) const
2442 bool wxListCtrl::GetItem( wxListItem
&info
) const
2444 m_mainWin
->GetItem( info
);
2448 bool wxListCtrl::SetItem( wxListItem
&info
)
2450 m_mainWin
->SetItem( info
);
2454 long wxListCtrl::SetItem( long index
, int col
, const wxString
& label
, int imageId
)
2457 info
.m_text
= label
;
2458 info
.m_mask
= wxLIST_MASK_TEXT
;
2459 info
.m_itemId
= index
;
2463 info
.m_image
= imageId
;
2464 info
.m_mask
|= wxLIST_MASK_IMAGE
;
2466 m_mainWin
->SetItem(info
);
2470 int wxListCtrl::GetItemState( long item
, long stateMask
) const
2472 return m_mainWin
->GetItemState( item
, stateMask
);
2475 bool wxListCtrl::SetItemState( long item
, long state
, long stateMask
)
2477 m_mainWin
->SetItemState( item
, state
, stateMask
);
2481 bool wxListCtrl::SetItemImage( long item
, int image
, int WXUNUSED(selImage
) )
2484 info
.m_image
= image
;
2485 info
.m_mask
= wxLIST_MASK_IMAGE
;
2486 info
.m_itemId
= item
;
2487 m_mainWin
->SetItem( info
);
2491 wxString
wxListCtrl::GetItemText( long item
) const
2494 info
.m_itemId
= item
;
2495 m_mainWin
->GetItem( info
);
2499 void wxListCtrl::SetItemText( long item
, const wxString
&str
)
2502 info
.m_mask
= wxLIST_MASK_TEXT
;
2503 info
.m_itemId
= item
;
2505 m_mainWin
->SetItem( info
);
2508 long wxListCtrl::GetItemData( long item
) const
2511 info
.m_itemId
= item
;
2512 m_mainWin
->GetItem( info
);
2516 bool wxListCtrl::SetItemData( long item
, long data
)
2519 info
.m_mask
= wxLIST_MASK_DATA
;
2520 info
.m_itemId
= item
;
2522 m_mainWin
->SetItem( info
);
2526 bool wxListCtrl::GetItemRect( long item
, wxRect
&rect
, int WXUNUSED(code
) ) const
2528 m_mainWin
->GetItemRect( item
, rect
);
2532 bool wxListCtrl::GetItemPosition( long item
, wxPoint
& pos
) const
2534 m_mainWin
->GetItemPosition( item
, pos
);
2538 bool wxListCtrl::SetItemPosition( long WXUNUSED(item
), const wxPoint
& WXUNUSED(pos
) )
2543 int wxListCtrl::GetItemCount(void) const
2545 return m_mainWin
->GetItemCount();
2548 int wxListCtrl::GetColumnCount(void) const
2550 return m_mainWin
->GetColumnCount();
2553 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
2555 m_mainWin
->SetItemSpacing( spacing
, isSmall
);
2558 int wxListCtrl::GetItemSpacing( bool isSmall
) const
2560 return m_mainWin
->GetItemSpacing( isSmall
);
2563 int wxListCtrl::GetSelectedItemCount(void) const
2565 return m_mainWin
->GetSelectedItemCount();
2569 wxColour wxListCtrl::GetTextColour(void) const
2573 void wxListCtrl::SetTextColour(const wxColour& WXUNUSED(col))
2578 long wxListCtrl::GetTopItem(void) const
2583 long wxListCtrl::GetNextItem( long item
, int geom
, int state
) const
2585 return m_mainWin
->GetNextItem( item
, geom
, state
);
2588 wxImageList
*wxListCtrl::GetImageList(int which
) const
2590 if (which
== wxIMAGE_LIST_NORMAL
)
2592 return m_imageListNormal
;
2594 else if (which
== wxIMAGE_LIST_SMALL
)
2596 return m_imageListSmall
;
2598 else if (which
== wxIMAGE_LIST_STATE
)
2600 return m_imageListState
;
2602 return (wxImageList
*) NULL
;
2605 void wxListCtrl::SetImageList( wxImageList
*imageList
, int which
)
2607 m_mainWin
->SetImageList( imageList
, which
);
2610 bool wxListCtrl::Arrange( int WXUNUSED(flag
) )
2615 bool wxListCtrl::DeleteItem( long item
)
2617 m_mainWin
->DeleteItem( item
);
2621 bool wxListCtrl::DeleteAllItems(void)
2623 m_mainWin
->DeleteAllItems();
2627 bool wxListCtrl::DeleteAllColumns()
2629 for ( size_t n
= 0; n
< m_mainWin
->m_columns
.GetCount(); n
++ )
2635 void wxListCtrl::ClearAll()
2637 m_mainWin
->DeleteEverything();
2640 bool wxListCtrl::DeleteColumn( int col
)
2642 m_mainWin
->DeleteColumn( col
);
2647 wxText& wxListCtrl::Edit( long WXUNUSED(item ) )
2652 bool wxListCtrl::EnsureVisible( long item
)
2654 m_mainWin
->EnsureVisible( item
);
2658 long wxListCtrl::FindItem( long start
, const wxString
& str
, bool partial
)
2660 return m_mainWin
->FindItem( start
, str
, partial
);
2663 long wxListCtrl::FindItem( long start
, long data
)
2665 return m_mainWin
->FindItem( start
, data
);
2668 long wxListCtrl::FindItem( long WXUNUSED(start
), const wxPoint
& WXUNUSED(pt
),
2669 int WXUNUSED(direction
))
2674 long wxListCtrl::HitTest( const wxPoint
&point
, int &flags
)
2676 return m_mainWin
->HitTest( (int)point
.x
, (int)point
.y
, flags
);
2679 long wxListCtrl::InsertItem( wxListItem
& info
)
2681 m_mainWin
->InsertItem( info
);
2685 long wxListCtrl::InsertItem( long index
, const wxString
&label
)
2688 info
.m_text
= label
;
2689 info
.m_mask
= wxLIST_MASK_TEXT
;
2690 info
.m_itemId
= index
;
2691 return InsertItem( info
);
2694 long wxListCtrl::InsertItem( long index
, int imageIndex
)
2697 info
.m_mask
= wxLIST_MASK_IMAGE
;
2698 info
.m_image
= imageIndex
;
2699 info
.m_itemId
= index
;
2700 return InsertItem( info
);
2703 long wxListCtrl::InsertItem( long index
, const wxString
&label
, int imageIndex
)
2706 info
.m_text
= label
;
2707 info
.m_image
= imageIndex
;
2708 info
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_IMAGE
;
2709 info
.m_itemId
= index
;
2710 return InsertItem( info
);
2713 long wxListCtrl::InsertColumn( long col
, wxListItem
&item
)
2715 m_mainWin
->InsertColumn( col
, item
);
2719 long wxListCtrl::InsertColumn( long col
, const wxString
&heading
,
2720 int format
, int width
)
2723 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
2724 item
.m_text
= heading
;
2727 item
.m_mask
|= wxLIST_MASK_WIDTH
;
2728 item
.m_width
= width
;
2730 item
.m_format
= format
;
2732 return InsertColumn( col
, item
);
2735 bool wxListCtrl::ScrollList( int WXUNUSED(dx
), int WXUNUSED(dy
) )
2741 // fn is a function which takes 3 long arguments: item1, item2, data.
2742 // item1 is the long data associated with a first item (NOT the index).
2743 // item2 is the long data associated with a second item (NOT the index).
2744 // data is the same value as passed to SortItems.
2745 // The return value is a negative number if the first item should precede the second
2746 // item, a positive number of the second item should precede the first,
2747 // or zero if the two items are equivalent.
2748 // data is arbitrary data to be passed to the sort function.
2750 bool wxListCtrl::SortItems( wxListCtrlCompare fn
, long data
)
2752 m_mainWin
->SortItems( fn
, data
);
2756 void wxListCtrl::OnIdle( wxIdleEvent
&WXUNUSED(event
) )
2758 if (!m_mainWin
->m_dirty
) return;
2762 GetClientSize( &cw
, &ch
);
2769 if (GetWindowStyleFlag() & wxLC_REPORT
)
2771 m_headerWin
->GetPosition( &x
, &y
);
2772 m_headerWin
->GetSize( &w
, &h
);
2773 if ((x
!= 0) || (y
!= 0) || (w
!= cw
) || (h
!= 23))
2774 m_headerWin
->SetSize( 0, 0, cw
, 23 );
2776 m_mainWin
->GetPosition( &x
, &y
);
2777 m_mainWin
->GetSize( &w
, &h
);
2778 if ((x
!= 0) || (y
!= 24) || (w
!= cw
) || (h
!= ch
-24))
2779 m_mainWin
->SetSize( 0, 24, cw
, ch
-24 );
2783 m_mainWin
->GetPosition( &x
, &y
);
2784 m_mainWin
->GetSize( &w
, &h
);
2785 if ((x
!= 0) || (y
!= 24) || (w
!= cw
) || (h
!= ch
))
2786 m_mainWin
->SetSize( 0, 0, cw
, ch
);
2789 m_mainWin
->CalculatePositions();
2790 m_mainWin
->RealizeChanges();
2791 m_mainWin
->m_dirty
= FALSE
;
2792 m_mainWin
->Refresh();
2795 void wxListCtrl::SetBackgroundColour( const wxColour
&colour
)
2799 m_mainWin
->SetBackgroundColour( colour
);
2800 m_mainWin
->m_dirty
= TRUE
;
2805 m_headerWin
->SetBackgroundColour( colour
);
2809 void wxListCtrl::SetForegroundColour( const wxColour
&colour
)
2813 m_mainWin
->SetForegroundColour( colour
);
2814 m_mainWin
->m_dirty
= TRUE
;
2819 m_headerWin
->SetForegroundColour( colour
);
2823 void wxListCtrl::SetFont( const wxFont
&font
)
2827 m_mainWin
->SetFont( font
);
2828 m_mainWin
->m_dirty
= TRUE
;
2833 m_headerWin
->SetFont( font
);