1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "listctrl.h"
12 #pragma implementation "listctrlbase.h"
15 // For compilers that support precompilation, includes "wx.h".
16 #include "wx/wxprec.h"
22 #include "wx/dcscreen.h"
24 #include "wx/listctrl.h"
25 #include "wx/generic/imaglist.h"
27 #ifndef wxUSE_GENERIC_LIST_EXTENSIONS
28 #define wxUSE_GENERIC_LIST_EXTENSIONS 1
31 // ============================================================================
33 // ============================================================================
35 //-----------------------------------------------------------------------------
36 // wxListItemData (internal)
37 //-----------------------------------------------------------------------------
39 class WXDLLEXPORT wxListItemData
: public wxObject
48 wxListItemAttr
*m_attr
;
52 ~wxListItemData() { delete m_attr
; }
54 wxListItemData( const wxListItem
&info
);
55 void SetItem( const wxListItem
&info
);
56 void SetText( const wxString
&s
);
57 void SetImage( int image
);
58 void SetData( long data
);
59 void SetPosition( int x
, int y
);
60 void SetSize( int width
, int height
);
61 bool HasImage() const;
63 bool IsHit( int x
, int y
) const;
64 void GetText( wxString
&s
);
65 const wxString
& GetText() { return m_text
; }
66 int GetX( void ) const;
67 int GetY( void ) const;
69 int GetHeight() const;
71 void GetItem( wxListItem
&info
) const;
73 wxListItemAttr
*GetAttributes() const { return m_attr
; }
76 DECLARE_DYNAMIC_CLASS(wxListItemData
);
79 //-----------------------------------------------------------------------------
80 // wxListHeaderData (internal)
81 //-----------------------------------------------------------------------------
83 class WXDLLEXPORT wxListHeaderData
: public wxObject
96 wxListHeaderData( const wxListItem
&info
);
97 void SetItem( const wxListItem
&item
);
98 void SetPosition( int x
, int y
);
99 void SetWidth( int w
);
100 void SetFormat( int format
);
101 void SetHeight( int h
);
102 bool HasImage() const;
103 bool HasText() const;
104 bool IsHit( int x
, int y
) const;
105 void GetItem( wxListItem
&item
);
106 void GetText( wxString
&s
);
107 int GetImage() const;
108 int GetWidth() const;
109 int GetFormat() const;
112 DECLARE_DYNAMIC_CLASS(wxListHeaderData
);
115 //-----------------------------------------------------------------------------
116 // wxListLineData (internal)
117 //-----------------------------------------------------------------------------
119 class WXDLLEXPORT wxListLineData
: public wxObject
124 wxRect m_bound_label
;
126 wxRect m_bound_hilight
;
129 wxBrush
*m_hilightBrush
;
131 wxListMainWindow
*m_owner
;
133 void DoDraw( wxDC
*dc
, bool hilight
, bool paintBG
);
137 wxListLineData( wxListMainWindow
*owner
, int mode
, wxBrush
*hilightBrush
);
138 void CalculateSize( wxDC
*dc
, int spacing
);
139 void SetPosition( wxDC
*dc
, int x
, int y
, int window_width
);
140 void SetColumnPosition( int index
, int x
);
141 void GetSize( int &width
, int &height
);
142 void GetExtent( int &x
, int &y
, int &width
, int &height
);
143 void GetLabelExtent( int &x
, int &y
, int &width
, int &height
);
144 long IsHit( int x
, int y
);
145 void InitItems( int num
);
146 void SetItem( int index
, const wxListItem
&info
);
147 void GetItem( int index
, wxListItem
&info
);
148 void GetText( int index
, wxString
&s
);
149 void SetText( int index
, const wxString s
);
150 int GetImage( int index
);
151 void GetRect( wxRect
&rect
);
152 void Hilight( bool on
);
153 void ReverseHilight();
154 void DrawRubberBand( wxDC
*dc
, bool on
);
155 void Draw( wxDC
*dc
);
156 bool IsInRect( int x
, int y
, const wxRect
&rect
);
158 void AssignRect( wxRect
&dest
, int x
, int y
, int width
, int height
);
159 void AssignRect( wxRect
&dest
, const wxRect
&source
);
162 void SetAttributes(wxDC
*dc
,
163 const wxListItemAttr
*attr
,
164 const wxColour
& colText
, const wxFont
& font
,
167 DECLARE_DYNAMIC_CLASS(wxListLineData
);
170 //-----------------------------------------------------------------------------
171 // wxListHeaderWindow (internal)
172 //-----------------------------------------------------------------------------
174 class WXDLLEXPORT wxListHeaderWindow
: public wxWindow
177 wxListMainWindow
*m_owner
;
178 wxCursor
*m_currentCursor
;
179 wxCursor
*m_resizeCursor
;
186 wxListHeaderWindow();
187 ~wxListHeaderWindow();
188 wxListHeaderWindow( wxWindow
*win
, wxWindowID id
, wxListMainWindow
*owner
,
189 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
190 long style
= 0, const wxString
&name
= "wxlistctrlcolumntitles" );
191 void DoDrawRect( wxDC
*dc
, int x
, int y
, int w
, int h
);
192 void OnPaint( wxPaintEvent
&event
);
194 void OnMouse( wxMouseEvent
&event
);
195 void OnSetFocus( wxFocusEvent
&event
);
198 DECLARE_DYNAMIC_CLASS(wxListHeaderWindow
)
199 DECLARE_EVENT_TABLE()
202 //-----------------------------------------------------------------------------
203 // wxListRenameTimer (internal)
204 //-----------------------------------------------------------------------------
206 class WXDLLEXPORT wxListRenameTimer
: public wxTimer
209 wxListMainWindow
*m_owner
;
212 wxListRenameTimer( wxListMainWindow
*owner
);
216 //-----------------------------------------------------------------------------
217 // wxListTextCtrl (internal)
218 //-----------------------------------------------------------------------------
220 class WXDLLEXPORT wxListTextCtrl
: public wxTextCtrl
225 wxListMainWindow
*m_owner
;
226 wxString m_startValue
;
230 wxListTextCtrl( wxWindow
*parent
, const wxWindowID id
,
231 bool *accept
, wxString
*res
, wxListMainWindow
*owner
,
232 const wxString
&value
= "",
233 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
235 const wxValidator
& validator
= wxDefaultValidator
,
236 const wxString
&name
= "listctrltextctrl" );
237 void OnChar( wxKeyEvent
&event
);
238 void OnKillFocus( wxFocusEvent
&event
);
241 DECLARE_DYNAMIC_CLASS(wxListTextCtrl
);
242 DECLARE_EVENT_TABLE()
245 //-----------------------------------------------------------------------------
246 // wxListMainWindow (internal)
247 //-----------------------------------------------------------------------------
249 class WXDLLEXPORT wxListMainWindow
: public wxScrolledWindow
255 wxListLineData
*m_current
;
256 wxListLineData
*m_currentEdit
;
258 wxBrush
*m_hilightBrush
;
259 wxColour
*m_hilightColour
;
260 int m_xScroll
,m_yScroll
;
262 wxImageList
*m_small_image_list
;
263 wxImageList
*m_normal_image_list
;
265 int m_normal_spacing
;
269 wxTimer
*m_renameTimer
;
271 wxString m_renameRes
;
276 // for double click logic
277 wxListLineData
*m_lineLastClicked
,
278 *m_lineBeforeLastClicked
;
282 wxListMainWindow( wxWindow
*parent
, wxWindowID id
,
283 const wxPoint
&pos
= wxDefaultPosition
, const wxSize
&size
= wxDefaultSize
,
284 long style
= 0, const wxString
&name
= "listctrlmainwindow" );
286 void RefreshLine( wxListLineData
*line
);
287 void OnPaint( wxPaintEvent
&event
);
288 void HilightAll( bool on
);
289 void SendNotify( wxListLineData
*line
, wxEventType command
);
290 void FocusLine( wxListLineData
*line
);
291 void UnfocusLine( wxListLineData
*line
);
292 void SelectLine( wxListLineData
*line
);
293 void DeselectLine( wxListLineData
*line
);
294 void DeleteLine( wxListLineData
*line
);
296 void EditLabel( long item
);
297 void Edit( long item
) { EditLabel(item
); } // deprecated
298 void OnRenameTimer();
299 void OnRenameAccept();
301 void OnMouse( wxMouseEvent
&event
);
303 void OnArrowChar( wxListLineData
*newCurrent
, bool shiftDown
);
304 void OnChar( wxKeyEvent
&event
);
305 void OnKeyDown( wxKeyEvent
&event
);
306 void OnSetFocus( wxFocusEvent
&event
);
307 void OnKillFocus( wxFocusEvent
&event
);
308 void OnSize( wxSizeEvent
&event
);
309 void OnScroll(wxScrollWinEvent
& event
) ;
311 void DrawImage( int index
, wxDC
*dc
, int x
, int y
);
312 void GetImageSize( int index
, int &width
, int &height
);
313 int GetIndexOfLine( const wxListLineData
*line
);
314 int GetTextLength( wxString
&s
); // should be const
316 void SetImageList( wxImageList
*imageList
, int which
);
317 void SetItemSpacing( int spacing
, bool isSmall
= FALSE
);
318 int GetItemSpacing( bool isSmall
= FALSE
);
319 void SetColumn( int col
, wxListItem
&item
);
320 void SetColumnWidth( int col
, int width
);
321 void GetColumn( int col
, wxListItem
&item
);
322 int GetColumnWidth( int vol
);
323 int GetColumnCount();
324 int GetCountPerPage();
325 void SetItem( wxListItem
&item
);
326 void GetItem( wxListItem
&item
);
327 void SetItemState( long item
, long state
, long stateMask
);
328 int GetItemState( long item
, long stateMask
);
330 void GetItemRect( long index
, wxRect
&rect
);
331 bool GetItemPosition( long item
, wxPoint
& pos
);
332 int GetSelectedItemCount();
333 void SetMode( long mode
);
334 long GetMode() const;
335 void CalculatePositions();
336 void RealizeChanges();
337 long GetNextItem( long item
, int geometry
, int state
);
338 void DeleteItem( long index
);
339 void DeleteAllItems();
340 void DeleteColumn( int col
);
341 void DeleteEverything();
342 void EnsureVisible( long index
);
343 long FindItem( long start
, const wxString
& str
, bool partial
= FALSE
);
344 long FindItem( long start
, long data
);
345 long HitTest( int x
, int y
, int &flags
);
346 void InsertItem( wxListItem
&item
);
347 // void AddItem( wxListItem &item );
348 void InsertColumn( long col
, wxListItem
&item
);
349 // void AddColumn( wxListItem &item );
350 void SortItems( wxListCtrlCompare fn
, long data
);
353 DECLARE_DYNAMIC_CLASS(wxListMainWindow
);
354 DECLARE_EVENT_TABLE()
357 // ============================================================================
359 // ============================================================================
361 //-----------------------------------------------------------------------------
363 //-----------------------------------------------------------------------------
365 IMPLEMENT_DYNAMIC_CLASS(wxListItemData
,wxObject
);
367 wxListItemData::wxListItemData()
378 wxListItemData::wxListItemData( const wxListItem
&info
)
387 void wxListItemData::SetItem( const wxListItem
&info
)
389 if (info
.m_mask
& wxLIST_MASK_TEXT
) m_text
= info
.m_text
;
390 if (info
.m_mask
& wxLIST_MASK_IMAGE
) m_image
= info
.m_image
;
391 if (info
.m_mask
& wxLIST_MASK_DATA
) m_data
= info
.m_data
;
393 if ( info
.HasAttributes() )
396 *m_attr
= *info
.GetAttributes();
398 m_attr
= new wxListItemAttr(*info
.GetAttributes());
403 m_width
= info
.m_width
;
407 void wxListItemData::SetText( const wxString
&s
)
412 void wxListItemData::SetImage( int image
)
417 void wxListItemData::SetData( long data
)
422 void wxListItemData::SetPosition( int x
, int y
)
428 void wxListItemData::SetSize( int width
, int height
)
430 if (width
!= -1) m_width
= width
;
431 if (height
!= -1) m_height
= height
;
434 bool wxListItemData::HasImage() const
436 return (m_image
>= 0);
439 bool wxListItemData::HasText() const
441 return (!m_text
.IsNull());
444 bool wxListItemData::IsHit( int x
, int y
) const
446 return ((x
>= m_xpos
) && (x
<= m_xpos
+m_width
) && (y
>= m_ypos
) && (y
<= m_ypos
+m_height
));
449 void wxListItemData::GetText( wxString
&s
)
454 int wxListItemData::GetX() const
459 int wxListItemData::GetY() const
464 int wxListItemData::GetWidth() const
469 int wxListItemData::GetHeight() const
474 int wxListItemData::GetImage() const
479 void wxListItemData::GetItem( wxListItem
&info
) const
481 info
.m_text
= m_text
;
482 info
.m_image
= m_image
;
483 info
.m_data
= m_data
;
487 if ( m_attr
->HasTextColour() )
488 info
.SetTextColour(m_attr
->GetTextColour());
489 if ( m_attr
->HasBackgroundColour() )
490 info
.SetBackgroundColour(m_attr
->GetBackgroundColour());
491 if ( m_attr
->HasFont() )
492 info
.SetFont(m_attr
->GetFont());
496 //-----------------------------------------------------------------------------
498 //-----------------------------------------------------------------------------
500 IMPLEMENT_DYNAMIC_CLASS(wxListHeaderData
,wxObject
);
502 wxListHeaderData::wxListHeaderData()
513 wxListHeaderData::wxListHeaderData( const wxListItem
&item
)
521 void wxListHeaderData::SetItem( const wxListItem
&item
)
523 m_mask
= item
.m_mask
;
524 m_text
= item
.m_text
;
525 m_image
= item
.m_image
;
526 m_format
= item
.m_format
;
527 m_width
= item
.m_width
;
528 if (m_width
< 0) m_width
= 80;
529 if (m_width
< 6) m_width
= 6;
532 void wxListHeaderData::SetPosition( int x
, int y
)
538 void wxListHeaderData::SetHeight( int h
)
543 void wxListHeaderData::SetWidth( int w
)
546 if (m_width
< 0) m_width
= 80;
547 if (m_width
< 6) m_width
= 6;
550 void wxListHeaderData::SetFormat( int format
)
555 bool wxListHeaderData::HasImage() const
557 return (m_image
!= 0);
560 bool wxListHeaderData::HasText() const
562 return (m_text
.Length() > 0);
565 bool wxListHeaderData::IsHit( int x
, int y
) const
567 return ((x
>= m_xpos
) && (x
<= m_xpos
+m_width
) && (y
>= m_ypos
) && (y
<= m_ypos
+m_height
));
570 void wxListHeaderData::GetItem( wxListItem
&item
)
572 item
.m_mask
= m_mask
;
573 item
.m_text
= m_text
;
574 item
.m_image
= m_image
;
575 item
.m_format
= m_format
;
576 item
.m_width
= m_width
;
579 void wxListHeaderData::GetText( wxString
&s
)
584 int wxListHeaderData::GetImage() const
589 int wxListHeaderData::GetWidth() const
594 int wxListHeaderData::GetFormat() const
599 //-----------------------------------------------------------------------------
601 //-----------------------------------------------------------------------------
603 IMPLEMENT_DYNAMIC_CLASS(wxListLineData
,wxObject
);
605 wxListLineData::wxListLineData( wxListMainWindow
*owner
, int mode
, wxBrush
*hilightBrush
)
610 m_hilightBrush
= hilightBrush
;
611 m_items
.DeleteContents( TRUE
);
615 void wxListLineData::CalculateSize( wxDC
*dc
, int spacing
)
622 m_bound_all
.width
= m_spacing
;
623 wxNode
*node
= m_items
.First();
626 wxListItemData
*item
= (wxListItemData
*)node
->Data();
627 wxString s
= item
->GetText();
628 if (s
.IsEmpty()) s
= wxT("H");
630 dc
->GetTextExtent( s
, &lw
, &lh
);
631 if (lh
< 15) lh
= 15;
635 m_bound_all
.height
= m_spacing
+lh
;
636 if (lw
> m_spacing
) m_bound_all
.width
= lw
;
637 m_bound_label
.width
= lw
;
638 m_bound_label
.height
= lh
;
640 if (item
->HasImage())
644 m_owner
->GetImageSize( item
->GetImage(), w
, h
);
645 m_bound_icon
.width
= w
+ 8;
646 m_bound_icon
.height
= h
+ 8;
649 if (!item
->HasText())
651 m_bound_hilight
.width
= m_bound_icon
.width
;
652 m_bound_hilight
.height
= m_bound_icon
.height
;
656 m_bound_hilight
.width
= m_bound_label
.width
;
657 m_bound_hilight
.height
= m_bound_label
.height
;
664 wxNode
*node
= m_items
.First();
667 wxListItemData
*item
= (wxListItemData
*)node
->Data();
669 wxString s
= item
->GetText();
670 if (s
.IsEmpty()) s
= wxT("H");
672 dc
->GetTextExtent( s
, &lw
, &lh
);
673 if (lh
< 15) lh
= 15;
676 m_bound_label
.width
= lw
;
677 m_bound_label
.height
= lh
;
679 m_bound_all
.width
= lw
;
680 m_bound_all
.height
= lh
;
682 if (item
->HasImage())
686 m_owner
->GetImageSize( item
->GetImage(), w
, h
);
687 m_bound_icon
.width
= w
;
688 m_bound_icon
.height
= h
;
690 m_bound_all
.width
+= 4 + w
;
691 if (h
> m_bound_all
.height
) m_bound_all
.height
= h
;
694 m_bound_hilight
.width
= m_bound_all
.width
;
695 m_bound_hilight
.height
= m_bound_all
.height
;
701 m_bound_all
.width
= 0;
702 m_bound_all
.height
= 0;
703 wxNode
*node
= m_items
.First();
706 wxListItemData
*item
= (wxListItemData
*)node
->Data();
707 wxString s
= item
->GetText();
708 if (s
.IsEmpty()) s
= wxT("H");
710 dc
->GetTextExtent( s
, &lw
, &lh
);
711 if (lh
< 15) lh
= 15;
715 item
->SetSize( item
->GetWidth(), lh
);
716 m_bound_all
.width
+= lw
;
717 m_bound_all
.height
= lh
;
725 void wxListLineData::SetPosition( wxDC
*dc
, int x
, int y
, int window_width
)
733 wxNode
*node
= m_items
.First();
736 wxListItemData
*item
= (wxListItemData
*)node
->Data();
737 if (item
->HasImage())
739 m_bound_icon
.x
= m_bound_all
.x
+ 4 + (m_spacing
/2) - (m_bound_icon
.width
/2);
740 m_bound_icon
.y
= m_bound_all
.y
+ 4;
744 if (m_bound_all
.width
> m_spacing
)
745 m_bound_label
.x
= m_bound_all
.x
+ 2;
747 m_bound_label
.x
= m_bound_all
.x
+ 2 + (m_spacing
/2) - (m_bound_label
.width
/2);
748 m_bound_label
.y
= m_bound_all
.y
+ m_bound_all
.height
+ 2 - m_bound_label
.height
;
749 m_bound_hilight
.x
= m_bound_label
.x
- 2;
750 m_bound_hilight
.y
= m_bound_label
.y
- 2;
754 m_bound_hilight
.x
= m_bound_icon
.x
- 4;
755 m_bound_hilight
.y
= m_bound_icon
.y
- 4;
762 m_bound_hilight
.x
= m_bound_all
.x
;
763 m_bound_hilight
.y
= m_bound_all
.y
;
764 m_bound_label
.y
= m_bound_all
.y
+ 2;
765 wxNode
*node
= m_items
.First();
768 wxListItemData
*item
= (wxListItemData
*)node
->Data();
769 if (item
->HasImage())
771 m_bound_icon
.x
= m_bound_all
.x
+ 2;
772 m_bound_icon
.y
= m_bound_all
.y
+ 2;
773 m_bound_label
.x
= m_bound_all
.x
+ 6 + m_bound_icon
.width
;
777 m_bound_label
.x
= m_bound_all
.x
+ 2;
785 m_bound_all
.width
= window_width
;
786 AssignRect( m_bound_hilight
, m_bound_all
);
787 m_bound_label
.x
= m_bound_all
.x
+ 2;
788 m_bound_label
.y
= m_bound_all
.y
+ 2;
789 wxNode
*node
= m_items
.First();
792 wxListItemData
*item
= (wxListItemData
*)node
->Data();
793 if (item
->HasImage())
795 m_bound_icon
.x
= m_bound_all
.x
+ 2;
796 m_bound_icon
.y
= m_bound_all
.y
+ 2;
797 m_bound_label
.x
+= 4 + m_bound_icon
.width
;
805 void wxListLineData::SetColumnPosition( int index
, int x
)
807 wxNode
*node
= m_items
.Nth( (size_t)index
);
810 wxListItemData
*item
= (wxListItemData
*)node
->Data();
811 item
->SetPosition( x
, m_bound_all
.y
+1 );
815 void wxListLineData::GetSize( int &width
, int &height
)
817 width
= m_bound_all
.width
;
818 height
= m_bound_all
.height
;
821 void wxListLineData::GetExtent( int &x
, int &y
, int &width
, int &height
)
825 width
= m_bound_all
.width
;
826 height
= m_bound_all
.height
;
829 void wxListLineData::GetLabelExtent( int &x
, int &y
, int &width
, int &height
)
833 width
= m_bound_label
.width
;
834 height
= m_bound_label
.height
;
837 void wxListLineData::GetRect( wxRect
&rect
)
839 AssignRect( rect
, m_bound_all
);
842 long wxListLineData::IsHit( int x
, int y
)
844 wxNode
*node
= m_items
.First();
847 wxListItemData
*item
= (wxListItemData
*)node
->Data();
848 if (item
->HasImage() && IsInRect( x
, y
, m_bound_icon
)) return wxLIST_HITTEST_ONITEMICON
;
849 if (item
->HasText() && IsInRect( x
, y
, m_bound_label
)) return wxLIST_HITTEST_ONITEMLABEL
;
850 // if (!(item->HasImage() || item->HasText())) return 0;
852 // if there is no icon or text = empty
853 if (IsInRect( x
, y
, m_bound_all
)) return wxLIST_HITTEST_ONITEMICON
;
857 void wxListLineData::InitItems( int num
)
859 for (int i
= 0; i
< num
; i
++) m_items
.Append( new wxListItemData() );
862 void wxListLineData::SetItem( int index
, const wxListItem
&info
)
864 wxNode
*node
= m_items
.Nth( index
);
867 wxListItemData
*item
= (wxListItemData
*)node
->Data();
868 item
->SetItem( info
);
872 void wxListLineData::GetItem( int index
, wxListItem
&info
)
875 wxNode
*node
= m_items
.Nth( i
);
878 wxListItemData
*item
= (wxListItemData
*)node
->Data();
879 item
->GetItem( info
);
883 void wxListLineData::GetText( int index
, wxString
&s
)
886 wxNode
*node
= m_items
.Nth( i
);
890 wxListItemData
*item
= (wxListItemData
*)node
->Data();
895 void wxListLineData::SetText( int index
, const wxString s
)
898 wxNode
*node
= m_items
.Nth( i
);
901 wxListItemData
*item
= (wxListItemData
*)node
->Data();
906 int wxListLineData::GetImage( int index
)
909 wxNode
*node
= m_items
.Nth( i
);
912 wxListItemData
*item
= (wxListItemData
*)node
->Data();
913 return item
->GetImage();
918 void wxListLineData::SetAttributes(wxDC
*dc
,
919 const wxListItemAttr
*attr
,
920 const wxColour
& colText
,
924 // don't use foregroud colour for drawing highlighted items - this might
925 // make them completely invisible (and there is no way to do bit
926 // arithmetics on wxColour, unfortunately)
927 if ( !hilight
&& attr
&& attr
->HasTextColour() )
929 dc
->SetTextForeground(attr
->GetTextColour());
933 dc
->SetTextForeground(colText
);
936 if ( attr
&& attr
->HasFont() )
938 dc
->SetFont(attr
->GetFont());
946 void wxListLineData::DoDraw( wxDC
*dc
, bool hilight
, bool paintBG
)
950 m_owner
->CalcScrolledPosition( m_bound_all
.x
, m_bound_all
.y
, &dev_x
, &dev_y
);
951 wxCoord dev_w
= m_bound_all
.width
;
952 wxCoord dev_h
= m_bound_all
.height
;
954 if (!m_owner
->IsExposed( dev_x
, dev_y
, dev_w
, dev_h
))
957 wxWindow
*listctrl
= m_owner
->GetParent();
959 // default foreground colour
963 colText
= wxSystemSettings::GetSystemColour( wxSYS_COLOUR_HIGHLIGHTTEXT
);
967 colText
= listctrl
->GetForegroundColour();
971 wxFont font
= listctrl
->GetFont();
973 // VZ: currently we set the colours/fonts only once, but like this (i.e.
974 // using SetAttributes() inside the loop), it will be trivial to
975 // customize the subitems (in report mode) too.
976 wxListItemData
*item
= (wxListItemData
*)m_items
.First()->Data();
977 wxListItemAttr
*attr
= item
->GetAttributes();
978 SetAttributes(dc
, attr
, colText
, font
, hilight
);
980 bool hasBgCol
= attr
&& attr
->HasBackgroundColour();
981 if ( paintBG
|| hasBgCol
)
985 dc
->SetBrush( * m_hilightBrush
);
990 dc
->SetBrush(wxBrush(attr
->GetBackgroundColour(), wxSOLID
));
992 dc
->SetBrush( * wxWHITE_BRUSH
);
995 dc
->SetPen( * wxTRANSPARENT_PEN
);
996 dc
->DrawRectangle( m_bound_hilight
.x
, m_bound_hilight
.y
,
997 m_bound_hilight
.width
, m_bound_hilight
.height
);
1000 if (m_mode
== wxLC_REPORT
)
1002 wxNode
*node
= m_items
.First();
1005 wxListItemData
*item
= (wxListItemData
*)node
->Data();
1006 int x
= item
->GetX();
1007 if (item
->HasImage())
1010 m_owner
->DrawImage( item
->GetImage(), dc
, x
, item
->GetY() );
1011 m_owner
->GetImageSize( item
->GetImage(), x
, y
);
1012 x
+= item
->GetX() + 5;
1014 dc
->SetClippingRegion( item
->GetX(), item
->GetY(), item
->GetWidth()-3, item
->GetHeight() );
1015 if (item
->HasText())
1017 dc
->DrawText( item
->GetText(), x
, item
->GetY()+1 );
1019 dc
->DestroyClippingRegion();
1020 node
= node
->Next();
1025 wxNode
*node
= m_items
.First();
1028 wxListItemData
*item
= (wxListItemData
*)node
->Data();
1029 if (item
->HasImage())
1031 m_owner
->DrawImage( item
->GetImage(), dc
, m_bound_icon
.x
, m_bound_icon
.y
);
1033 if (item
->HasText())
1035 dc
->DrawText( item
->GetText(), m_bound_label
.x
, m_bound_label
.y
);
1041 void wxListLineData::Hilight( bool on
)
1043 if (on
== m_hilighted
) return;
1046 m_owner
->SelectLine( this );
1048 m_owner
->DeselectLine( this );
1051 void wxListLineData::ReverseHilight( void )
1053 m_hilighted
= !m_hilighted
;
1055 m_owner
->SelectLine( this );
1057 m_owner
->DeselectLine( this );
1060 void wxListLineData::DrawRubberBand( wxDC
*dc
, bool on
)
1064 dc
->SetPen( * wxBLACK_PEN
);
1065 dc
->SetBrush( * wxTRANSPARENT_BRUSH
);
1066 dc
->DrawRectangle( m_bound_hilight
.x
, m_bound_hilight
.y
,
1067 m_bound_hilight
.width
, m_bound_hilight
.height
);
1071 void wxListLineData::Draw( wxDC
*dc
)
1073 DoDraw( dc
, m_hilighted
, m_hilighted
);
1076 bool wxListLineData::IsInRect( int x
, int y
, const wxRect
&rect
)
1078 return ((x
>= rect
.x
) && (x
<= rect
.x
+rect
.width
) &&
1079 (y
>= rect
.y
) && (y
<= rect
.y
+rect
.height
));
1082 bool wxListLineData::IsHilighted( void )
1087 void wxListLineData::AssignRect( wxRect
&dest
, int x
, int y
, int width
, int height
)
1092 dest
.height
= height
;
1095 void wxListLineData::AssignRect( wxRect
&dest
, const wxRect
&source
)
1099 dest
.width
= source
.width
;
1100 dest
.height
= source
.height
;
1103 //-----------------------------------------------------------------------------
1104 // wxListHeaderWindow
1105 //-----------------------------------------------------------------------------
1107 IMPLEMENT_DYNAMIC_CLASS(wxListHeaderWindow
,wxWindow
);
1109 BEGIN_EVENT_TABLE(wxListHeaderWindow
,wxWindow
)
1110 EVT_PAINT (wxListHeaderWindow::OnPaint
)
1111 EVT_MOUSE_EVENTS (wxListHeaderWindow::OnMouse
)
1112 EVT_SET_FOCUS (wxListHeaderWindow::OnSetFocus
)
1115 wxListHeaderWindow::wxListHeaderWindow( void )
1117 m_owner
= (wxListMainWindow
*) NULL
;
1118 m_currentCursor
= (wxCursor
*) NULL
;
1119 m_resizeCursor
= (wxCursor
*) NULL
;
1120 m_isDragging
= FALSE
;
1123 wxListHeaderWindow::wxListHeaderWindow( wxWindow
*win
, wxWindowID id
, wxListMainWindow
*owner
,
1124 const wxPoint
&pos
, const wxSize
&size
,
1125 long style
, const wxString
&name
) :
1126 wxWindow( win
, id
, pos
, size
, style
, name
)
1129 // m_currentCursor = wxSTANDARD_CURSOR;
1130 m_currentCursor
= (wxCursor
*) NULL
;
1131 m_resizeCursor
= new wxCursor( wxCURSOR_SIZEWE
);
1132 m_isDragging
= FALSE
;
1133 SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNFACE
) );
1136 wxListHeaderWindow::~wxListHeaderWindow( void )
1138 delete m_resizeCursor
;
1141 void wxListHeaderWindow::DoDrawRect( wxDC
*dc
, int x
, int y
, int w
, int h
)
1143 const int m_corner
= 1;
1145 dc
->SetBrush( *wxTRANSPARENT_BRUSH
);
1147 dc
->SetPen( *wxBLACK_PEN
);
1148 dc
->DrawLine( x
+w
-m_corner
+1, y
, x
+w
, y
+h
); // right (outer)
1149 dc
->DrawRectangle( x
, y
+h
, w
+1, 1 ); // bottom (outer)
1151 wxPen
pen( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_BTNSHADOW
), 1, wxSOLID
);
1154 dc
->DrawLine( x
+w
-m_corner
, y
, x
+w
-1, y
+h
); // right (inner)
1155 dc
->DrawRectangle( x
+1, y
+h
-1, w
-2, 1 ); // bottom (inner)
1157 dc
->SetPen( *wxWHITE_PEN
);
1158 dc
->DrawRectangle( x
, y
, w
-m_corner
+1, 1 ); // top (outer)
1159 dc
->DrawRectangle( x
, y
, 1, h
); // left (outer)
1160 dc
->DrawLine( x
, y
+h
-1, x
+1, y
+h
-1 );
1161 dc
->DrawLine( x
+w
-1, y
, x
+w
-1, y
+1 );
1164 void wxListHeaderWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
1166 wxPaintDC
dc( this );
1168 #if wxUSE_GENERIC_LIST_EXTENSIONS
1169 if ( m_owner
->GetMode() & wxLC_REPORT
)
1174 m_owner
->GetScrollPixelsPerUnit( &xpix
, &ypix
) ;
1175 m_owner
->ViewStart( &x
, &y
) ;
1176 dc
.SetDeviceOrigin( -x
* xpix
, 0 );
1181 dc
.SetFont( GetFont() );
1187 GetClientSize( &w
, &h
);
1189 dc
.SetBackgroundMode(wxTRANSPARENT
);
1190 dc
.SetTextForeground( *wxBLACK
);
1192 // do *not* use the listctrl colour for headers - one day we will have a
1193 // function to set it separately
1197 int numColumns
= m_owner
->GetColumnCount();
1199 for (int i
= 0; i
< numColumns
; i
++)
1201 m_owner
->GetColumn( i
, item
);
1202 int cw
= item
.m_width
-2;
1203 #if wxUSE_GENERIC_LIST_EXTENSIONS
1204 if ((i
+1 == numColumns
) || ( dc
.LogicalToDeviceX(x
+item
.m_width
) > w
-5))
1205 cw
= dc
.DeviceToLogicalX(w
)-x
-1;
1207 if ((i
+1 == numColumns
) || (x
+item
.m_width
> w
-5))
1210 dc
.SetPen( *wxWHITE_PEN
);
1212 DoDrawRect( &dc
, x
, y
, cw
, h
-2 );
1213 dc
.SetClippingRegion( x
, y
, cw
-5, h
-4 );
1214 dc
.DrawText( item
.m_text
, x
+4, y
+3 );
1215 dc
.DestroyClippingRegion();
1217 #if wxUSE_GENERIC_LIST_EXTENSIONS
1218 if (dc
.LogicalToDeviceX(x
) > w
+5) break;
1226 void wxListHeaderWindow::DrawCurrent()
1228 int x1
= m_currentX
;
1230 int x2
= m_currentX
-1;
1233 m_owner
->GetClientSize( &dummy
, &y2
);
1234 ClientToScreen( &x1
, &y1
);
1235 m_owner
->ClientToScreen( &x2
, &y2
);
1238 dc
.SetLogicalFunction( wxINVERT
);
1239 dc
.SetPen( wxPen( *wxBLACK
, 2, wxSOLID
) );
1240 dc
.SetBrush( *wxTRANSPARENT_BRUSH
);
1242 dc
.DrawLine( x1
, y1
, x2
, y2
);
1244 dc
.SetLogicalFunction( wxCOPY
);
1246 dc
.SetPen( wxNullPen
);
1247 dc
.SetBrush( wxNullBrush
);
1250 void wxListHeaderWindow::OnMouse( wxMouseEvent
&event
)
1252 wxCoord x
= (wxCoord
)event
.GetX();
1253 wxCoord y
= (wxCoord
)event
.GetY();
1257 if (event
.ButtonUp())
1260 m_isDragging
= FALSE
;
1261 m_owner
->SetColumnWidth( m_column
, m_currentX
-m_minX
);
1267 GetClientSize( &size_x
, & dummy
);
1271 m_currentX
= m_minX
+7;
1272 if (m_currentX
> size_x
-7) m_currentX
= size_x
-7;
1279 bool hit_border
= FALSE
;
1281 for (int j
= 0; j
< m_owner
->GetColumnCount(); j
++)
1283 xpos
+= m_owner
->GetColumnWidth( j
);
1285 if ((abs(x
-xpos
) < 3) && (y
< 22) && (m_column
< m_owner
->GetColumnCount()-1))
1297 if (event
.LeftDown())
1301 m_isDragging
= TRUE
;
1309 wxListEvent
le( wxEVT_COMMAND_LIST_COL_CLICK
, GetParent()->GetId() );
1310 le
.SetEventObject( GetParent() );
1311 le
.m_col
= m_column
;
1312 GetParent()->GetEventHandler()->ProcessEvent( le
);
1321 if (m_currentCursor
== wxSTANDARD_CURSOR
) SetCursor( * m_resizeCursor
);
1322 m_currentCursor
= m_resizeCursor
;
1326 if (m_currentCursor
!= wxSTANDARD_CURSOR
) SetCursor( * wxSTANDARD_CURSOR
);
1327 m_currentCursor
= wxSTANDARD_CURSOR
;
1332 void wxListHeaderWindow::OnSetFocus( wxFocusEvent
&WXUNUSED(event
) )
1334 m_owner
->SetFocus();
1337 //-----------------------------------------------------------------------------
1338 // wxListRenameTimer (internal)
1339 //-----------------------------------------------------------------------------
1341 wxListRenameTimer::wxListRenameTimer( wxListMainWindow
*owner
)
1346 void wxListRenameTimer::Notify()
1348 m_owner
->OnRenameTimer();
1351 //-----------------------------------------------------------------------------
1352 // wxListTextCtrl (internal)
1353 //-----------------------------------------------------------------------------
1355 IMPLEMENT_DYNAMIC_CLASS(wxListTextCtrl
,wxTextCtrl
);
1357 BEGIN_EVENT_TABLE(wxListTextCtrl
,wxTextCtrl
)
1358 EVT_CHAR (wxListTextCtrl::OnChar
)
1359 EVT_KILL_FOCUS (wxListTextCtrl::OnKillFocus
)
1362 wxListTextCtrl::wxListTextCtrl( wxWindow
*parent
,
1363 const wxWindowID id
,
1366 wxListMainWindow
*owner
,
1367 const wxString
&value
,
1371 const wxValidator
& validator
,
1372 const wxString
&name
)
1373 : wxTextCtrl( parent
, id
, value
, pos
, size
, style
, validator
, name
)
1378 (*m_accept
) = FALSE
;
1380 m_startValue
= value
;
1383 void wxListTextCtrl::OnChar( wxKeyEvent
&event
)
1385 if (event
.m_keyCode
== WXK_RETURN
)
1388 (*m_res
) = GetValue();
1390 if (!wxPendingDelete
.Member(this))
1391 wxPendingDelete
.Append(this);
1393 if ((*m_accept
) && ((*m_res
) != m_startValue
))
1394 m_owner
->OnRenameAccept();
1398 if (event
.m_keyCode
== WXK_ESCAPE
)
1400 (*m_accept
) = FALSE
;
1403 if (!wxPendingDelete
.Member(this))
1404 wxPendingDelete
.Append(this);
1412 void wxListTextCtrl::OnKillFocus( wxFocusEvent
&WXUNUSED(event
) )
1414 if (!wxPendingDelete
.Member(this))
1415 wxPendingDelete
.Append(this);
1417 if ((*m_accept
) && ((*m_res
) != m_startValue
))
1418 m_owner
->OnRenameAccept();
1421 //-----------------------------------------------------------------------------
1423 //-----------------------------------------------------------------------------
1425 IMPLEMENT_DYNAMIC_CLASS(wxListMainWindow
,wxScrolledWindow
);
1427 BEGIN_EVENT_TABLE(wxListMainWindow
,wxScrolledWindow
)
1428 EVT_PAINT (wxListMainWindow::OnPaint
)
1429 EVT_SIZE (wxListMainWindow::OnSize
)
1430 EVT_MOUSE_EVENTS (wxListMainWindow::OnMouse
)
1431 EVT_CHAR (wxListMainWindow::OnChar
)
1432 EVT_KEY_DOWN (wxListMainWindow::OnKeyDown
)
1433 EVT_SET_FOCUS (wxListMainWindow::OnSetFocus
)
1434 EVT_KILL_FOCUS (wxListMainWindow::OnKillFocus
)
1435 EVT_SCROLLWIN (wxListMainWindow::OnScroll
)
1438 wxListMainWindow::wxListMainWindow()
1441 m_lines
.DeleteContents( TRUE
);
1442 m_columns
.DeleteContents( TRUE
);
1443 m_current
= (wxListLineData
*) NULL
;
1445 m_hilightBrush
= (wxBrush
*) NULL
;
1449 m_small_image_list
= (wxImageList
*) NULL
;
1450 m_normal_image_list
= (wxImageList
*) NULL
;
1451 m_small_spacing
= 30;
1452 m_normal_spacing
= 40;
1455 m_lastOnSame
= FALSE
;
1456 m_renameTimer
= new wxListRenameTimer( this );
1457 m_isCreated
= FALSE
;
1461 m_lineBeforeLastClicked
= (wxListLineData
*)NULL
;
1464 wxListMainWindow::wxListMainWindow( wxWindow
*parent
, wxWindowID id
,
1465 const wxPoint
&pos
, const wxSize
&size
,
1466 long style
, const wxString
&name
) :
1467 wxScrolledWindow( parent
, id
, pos
, size
, style
|wxHSCROLL
|wxVSCROLL
, name
)
1470 m_lines
.DeleteContents( TRUE
);
1471 m_columns
.DeleteContents( TRUE
);
1472 m_current
= (wxListLineData
*) NULL
;
1475 m_hilightBrush
= new wxBrush( wxSystemSettings::GetSystemColour(wxSYS_COLOUR_HIGHLIGHT
), wxSOLID
);
1476 m_small_image_list
= (wxImageList
*) NULL
;
1477 m_normal_image_list
= (wxImageList
*) NULL
;
1478 m_small_spacing
= 30;
1479 m_normal_spacing
= 40;
1482 m_isCreated
= FALSE
;
1486 if (m_mode
& wxLC_REPORT
)
1488 #if wxUSE_GENERIC_LIST_EXTENSIONS
1500 SetScrollbars( m_xScroll
, m_yScroll
, 0, 0, 0, 0 );
1503 m_lastOnSame
= FALSE
;
1504 m_renameTimer
= new wxListRenameTimer( this );
1505 m_renameAccept
= FALSE
;
1507 SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX
) );
1510 wxListMainWindow::~wxListMainWindow()
1514 if (m_hilightBrush
) delete m_hilightBrush
;
1516 delete m_renameTimer
;
1519 void wxListMainWindow::RefreshLine( wxListLineData
*line
)
1521 if (m_dirty
) return;
1529 line
->GetExtent( x
, y
, w
, h
);
1530 CalcScrolledPosition( x
, y
, &x
, &y
);
1531 wxRect
rect( x
, y
, w
, h
);
1532 Refresh( TRUE
, &rect
);
1535 void wxListMainWindow::OnPaint( wxPaintEvent
&WXUNUSED(event
) )
1537 // Note: a wxPaintDC must be constructed even if no drawing is
1538 // done (a Windows requirement).
1539 wxPaintDC
dc( this );
1542 if (m_dirty
) return;
1544 if (m_lines
.GetCount() == 0) return;
1548 dc
.SetFont( GetFont() );
1550 if (m_mode
& wxLC_REPORT
)
1552 int lineSpacing
= 0;
1553 wxListLineData
*line
= (wxListLineData
*)m_lines
.First()->Data();
1555 line
->GetSize( dummy
, lineSpacing
);
1558 int y_s
= m_yScroll
*GetScrollPos( wxVERTICAL
);
1560 wxNode
*node
= m_lines
.Nth( y_s
/ lineSpacing
);
1561 for (int i
= 0; i
< m_visibleLines
+2; i
++)
1565 line
= (wxListLineData
*)node
->Data();
1567 node
= node
->Next();
1572 wxNode
*node
= m_lines
.First();
1575 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1577 node
= node
->Next();
1581 if (m_current
) m_current
->DrawRubberBand( &dc
, m_hasFocus
);
1586 void wxListMainWindow::HilightAll( bool on
)
1588 wxNode
*node
= m_lines
.First();
1591 wxListLineData
*line
= (wxListLineData
*)node
->Data();
1592 if (line
->IsHilighted() != on
)
1594 line
->Hilight( on
);
1595 RefreshLine( line
);
1597 node
= node
->Next();
1601 void wxListMainWindow::SendNotify( wxListLineData
*line
, wxEventType command
)
1603 wxListEvent
le( command
, GetParent()->GetId() );
1604 le
.SetEventObject( GetParent() );
1605 le
.m_itemIndex
= GetIndexOfLine( line
);
1606 line
->GetItem( 0, le
.m_item
);
1607 GetParent()->GetEventHandler()->ProcessEvent( le
);
1608 // GetParent()->GetEventHandler()->AddPendingEvent( le );
1611 void wxListMainWindow::FocusLine( wxListLineData
*WXUNUSED(line
) )
1613 // SendNotify( line, wxEVT_COMMAND_LIST_ITEM_FOCUSSED );
1616 void wxListMainWindow::UnfocusLine( wxListLineData
*WXUNUSED(line
) )
1618 // SendNotify( line, wxEVT_COMMAND_LIST_ITEM_UNFOCUSSED );
1621 void wxListMainWindow::SelectLine( wxListLineData
*line
)
1623 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_SELECTED
);
1626 void wxListMainWindow::DeselectLine( wxListLineData
*line
)
1628 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_DESELECTED
);
1631 void wxListMainWindow::DeleteLine( wxListLineData
*line
)
1633 SendNotify( line
, wxEVT_COMMAND_LIST_DELETE_ITEM
);
1638 void wxListMainWindow::EditLabel( long item
)
1640 wxNode
*node
= m_lines
.Nth( (size_t)item
);
1641 wxCHECK_RET( node
, wxT("wrong index in wxListCtrl::Edit()") );
1643 m_currentEdit
= (wxListLineData
*) node
->Data();
1645 wxListEvent
le( wxEVT_COMMAND_LIST_BEGIN_LABEL_EDIT
, GetParent()->GetId() );
1646 le
.SetEventObject( GetParent() );
1647 le
.m_itemIndex
= GetIndexOfLine( m_currentEdit
);
1648 m_currentEdit
->GetItem( 0, le
.m_item
);
1649 GetParent()->GetEventHandler()->ProcessEvent( le
);
1651 if (!le
.IsAllowed())
1654 // We have to call this here because the label in
1655 // question might just have been added and no screen
1656 // update taken place.
1657 if (m_dirty
) wxYield();
1660 m_currentEdit
->GetText( 0, s
);
1665 m_currentEdit
->GetLabelExtent( x
, y
, w
, h
);
1667 wxClientDC
dc(this);
1669 x
= dc
.LogicalToDeviceX( x
);
1670 y
= dc
.LogicalToDeviceY( y
);
1672 wxListTextCtrl
*text
= new wxListTextCtrl(
1673 this, -1, &m_renameAccept
, &m_renameRes
, this, s
, wxPoint(x
-4,y
-4), wxSize(w
+11,h
+8) );
1677 void wxListMainWindow::OnRenameTimer()
1679 wxCHECK_RET( m_current
, wxT("invalid m_current") );
1681 Edit( m_lines
.IndexOf( m_current
) );
1684 void wxListMainWindow::OnRenameAccept()
1686 wxListEvent
le( wxEVT_COMMAND_LIST_END_LABEL_EDIT
, GetParent()->GetId() );
1687 le
.SetEventObject( GetParent() );
1688 le
.m_itemIndex
= GetIndexOfLine( m_currentEdit
);
1689 m_currentEdit
->GetItem( 0, le
.m_item
);
1690 le
.m_item
.m_text
= m_renameRes
;
1691 GetParent()->GetEventHandler()->ProcessEvent( le
);
1693 if (!le
.IsAllowed()) return;
1696 info
.m_mask
= wxLIST_MASK_TEXT
;
1697 info
.m_itemId
= le
.m_itemIndex
;
1698 info
.m_text
= m_renameRes
;
1699 info
.SetTextColour(le
.m_item
.GetTextColour());
1703 void wxListMainWindow::OnMouse( wxMouseEvent
&event
)
1705 if (GetParent()->GetEventHandler()->ProcessEvent( event
)) return;
1707 if (!m_current
) return;
1708 if (m_dirty
) return;
1709 if ( !(event
.Dragging() || event
.ButtonDown() || event
.LeftUp() || event
.ButtonDClick()) ) return;
1711 wxClientDC
dc(this);
1713 wxCoord x
= dc
.DeviceToLogicalX( (wxCoord
)event
.GetX() );
1714 wxCoord y
= dc
.DeviceToLogicalY( (wxCoord
)event
.GetY() );
1716 /* Did we actually hit an item ? */
1718 wxNode
*node
= m_lines
.First();
1719 wxListLineData
*line
= (wxListLineData
*) NULL
;
1722 line
= (wxListLineData
*)node
->Data();
1723 hitResult
= line
->IsHit( x
, y
);
1724 if (hitResult
) break;
1725 line
= (wxListLineData
*) NULL
;
1726 node
= node
->Next();
1729 if (event
.Dragging())
1731 if (m_dragCount
== 0)
1732 m_dragStart
= wxPoint(x
,y
);
1736 if (m_dragCount
!= 3) return;
1738 int command
= wxEVT_COMMAND_LIST_BEGIN_DRAG
;
1739 if (event
.RightIsDown()) command
= wxEVT_COMMAND_LIST_BEGIN_RDRAG
;
1741 wxListEvent
le( command
, GetParent()->GetId() );
1742 le
.SetEventObject( GetParent() );
1743 le
.m_pointDrag
= m_dragStart
;
1744 GetParent()->GetEventHandler()->ProcessEvent( le
);
1755 bool forceClick
= FALSE
;
1756 if (event
.ButtonDClick())
1758 m_renameTimer
->Stop();
1759 m_lastOnSame
= FALSE
;
1761 if ( line
== m_lineBeforeLastClicked
)
1765 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_ACTIVATED
);
1771 // the first click was on another item, so don't interpret this as
1772 // a double click, but as a simple click instead
1777 if (event
.LeftUp() && m_lastOnSame
)
1780 if ((line
== m_current
) &&
1781 (hitResult
== wxLIST_HITTEST_ONITEMLABEL
) &&
1782 (m_mode
& wxLC_EDIT_LABELS
) )
1784 m_renameTimer
->Start( 100, TRUE
);
1786 m_lastOnSame
= FALSE
;
1790 if (event
.RightDown())
1792 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_RIGHT_CLICK
);
1796 if (event
.MiddleDown())
1798 SendNotify( line
, wxEVT_COMMAND_LIST_ITEM_MIDDLE_CLICK
);
1802 if ( event
.LeftDown() || forceClick
)
1804 m_lineBeforeLastClicked
= m_lineLastClicked
;
1805 m_lineLastClicked
= line
;
1808 wxListLineData
*oldCurrent
= m_current
;
1809 if (m_mode
& wxLC_SINGLE_SEL
)
1812 HilightAll( FALSE
);
1813 m_current
->ReverseHilight();
1814 RefreshLine( m_current
);
1818 if (event
.ControlDown())
1821 m_current
->ReverseHilight();
1822 RefreshLine( m_current
);
1824 else if (event
.ShiftDown())
1828 int numOfCurrent
= -1;
1829 node
= m_lines
.First();
1832 wxListLineData
*test_line
= (wxListLineData
*)node
->Data();
1834 if (test_line
== oldCurrent
) break;
1835 node
= node
->Next();
1839 node
= m_lines
.First();
1842 wxListLineData
*test_line
= (wxListLineData
*)node
->Data();
1844 if (test_line
== line
) break;
1845 node
= node
->Next();
1848 if (numOfLine
< numOfCurrent
)
1851 numOfLine
= numOfCurrent
;
1855 wxNode
*node
= m_lines
.Nth( numOfCurrent
);
1856 for (int i
= 0; i
<= numOfLine
-numOfCurrent
; i
++)
1858 wxListLineData
*test_line
= (wxListLineData
*)node
->Data();
1859 test_line
->Hilight(TRUE
);
1860 RefreshLine( test_line
);
1861 node
= node
->Next();
1867 HilightAll( FALSE
);
1868 m_current
->ReverseHilight();
1869 RefreshLine( m_current
);
1872 if (m_current
!= oldCurrent
)
1874 RefreshLine( oldCurrent
);
1875 UnfocusLine( oldCurrent
);
1876 FocusLine( m_current
);
1879 // forceClick is only set if the previous click was on another item
1880 m_lastOnSame
= !forceClick
&& (m_current
== oldCurrent
);
1886 void wxListMainWindow::MoveToFocus()
1888 if (!m_current
) return;
1894 m_current
->GetExtent( item_x
, item_y
, item_w
, item_h
);
1898 GetClientSize( &client_w
, &client_h
);
1900 int view_x
= m_xScroll
*GetScrollPos( wxHORIZONTAL
);
1901 int view_y
= m_yScroll
*GetScrollPos( wxVERTICAL
);
1903 if (m_mode
& wxLC_REPORT
)
1905 if (item_y
-5 < view_y
)
1906 Scroll( -1, (item_y
-5)/m_yScroll
);
1907 if (item_y
+item_h
+5 > view_y
+client_h
)
1908 Scroll( -1, (item_y
+item_h
-client_h
+15)/m_yScroll
);
1912 if (item_x
-view_x
< 5)
1913 Scroll( (item_x
-5)/m_xScroll
, -1 );
1914 if (item_x
+item_w
-5 > view_x
+client_w
)
1915 Scroll( (item_x
+item_w
-client_w
+15)/m_xScroll
, -1 );
1919 void wxListMainWindow::OnArrowChar( wxListLineData
*newCurrent
, bool shiftDown
)
1921 if ((m_mode
& wxLC_SINGLE_SEL
) || (m_usedKeys
== FALSE
)) m_current
->Hilight( FALSE
);
1922 wxListLineData
*oldCurrent
= m_current
;
1923 m_current
= newCurrent
;
1924 if (shiftDown
|| (m_mode
& wxLC_SINGLE_SEL
)) m_current
->Hilight( TRUE
);
1925 RefreshLine( m_current
);
1926 RefreshLine( oldCurrent
);
1927 FocusLine( m_current
);
1928 UnfocusLine( oldCurrent
);
1932 void wxListMainWindow::OnKeyDown( wxKeyEvent
&event
)
1934 wxWindow
*parent
= GetParent();
1936 /* we propagate the key event up */
1937 wxKeyEvent
ke( wxEVT_KEY_DOWN
);
1938 ke
.m_shiftDown
= event
.m_shiftDown
;
1939 ke
.m_controlDown
= event
.m_controlDown
;
1940 ke
.m_altDown
= event
.m_altDown
;
1941 ke
.m_metaDown
= event
.m_metaDown
;
1942 ke
.m_keyCode
= event
.m_keyCode
;
1945 ke
.SetEventObject( parent
);
1946 if (parent
->GetEventHandler()->ProcessEvent( ke
)) return;
1951 void wxListMainWindow::OnChar( wxKeyEvent
&event
)
1953 wxWindow
*parent
= GetParent();
1955 /* we send a list_key event up */
1956 wxListEvent
le( wxEVT_COMMAND_LIST_KEY_DOWN
, GetParent()->GetId() );
1957 le
.m_code
= (int)event
.KeyCode();
1958 le
.SetEventObject( parent
);
1959 parent
->GetEventHandler()->ProcessEvent( le
);
1961 /* we propagate the char event up */
1962 wxKeyEvent
ke( wxEVT_CHAR
);
1963 ke
.m_shiftDown
= event
.m_shiftDown
;
1964 ke
.m_controlDown
= event
.m_controlDown
;
1965 ke
.m_altDown
= event
.m_altDown
;
1966 ke
.m_metaDown
= event
.m_metaDown
;
1967 ke
.m_keyCode
= event
.m_keyCode
;
1970 ke
.SetEventObject( parent
);
1971 if (parent
->GetEventHandler()->ProcessEvent( ke
)) return;
1973 if (event
.KeyCode() == WXK_TAB
)
1975 wxNavigationKeyEvent nevent
;
1976 nevent
.SetWindowChange( event
.ControlDown() );
1977 nevent
.SetDirection( !event
.ShiftDown() );
1978 nevent
.SetEventObject( GetParent()->GetParent() );
1979 nevent
.SetCurrentFocus( m_parent
);
1980 if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent
)) return;
1983 /* no item -> nothing to do */
1990 switch (event
.KeyCode())
1994 wxNode
*node
= m_lines
.Member( m_current
)->Previous();
1995 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
2000 wxNode
*node
= m_lines
.Member( m_current
)->Next();
2001 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
2006 wxNode
*node
= m_lines
.Last();
2007 OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
2012 wxNode
*node
= m_lines
.First();
2013 OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
2019 if (m_mode
& wxLC_REPORT
)
2021 steps
= m_visibleLines
-1;
2026 wxNode
*node
= m_lines
.First();
2027 for (;;) { if (m_current
== (wxListLineData
*)node
->Data()) break; pos
++; node
= node
->Next(); }
2028 steps
= pos
% m_visibleLines
;
2030 wxNode
*node
= m_lines
.Member( m_current
);
2031 for (int i
= 0; i
< steps
; i
++) if (node
->Previous()) node
= node
->Previous();
2032 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
2038 if (m_mode
& wxLC_REPORT
)
2040 steps
= m_visibleLines
-1;
2044 int pos
= 0; wxNode
*node
= m_lines
.First();
2045 for (;;) { if (m_current
== (wxListLineData
*)node
->Data()) break; pos
++; node
= node
->Next(); }
2046 steps
= m_visibleLines
-(pos
% m_visibleLines
)-1;
2048 wxNode
*node
= m_lines
.Member( m_current
);
2049 for (int i
= 0; i
< steps
; i
++) if (node
->Next()) node
= node
->Next();
2050 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
2055 if (!(m_mode
& wxLC_REPORT
))
2057 wxNode
*node
= m_lines
.Member( m_current
);
2058 for (int i
= 0; i
<m_visibleLines
; i
++) if (node
->Previous()) node
= node
->Previous();
2059 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
2065 if (!(m_mode
& wxLC_REPORT
))
2067 wxNode
*node
= m_lines
.Member( m_current
);
2068 for (int i
= 0; i
<m_visibleLines
; i
++) if (node
->Next()) node
= node
->Next();
2069 if (node
) OnArrowChar( (wxListLineData
*)node
->Data(), event
.ShiftDown() );
2075 if (m_mode
& wxLC_SINGLE_SEL
)
2077 wxListEvent
le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
, GetParent()->GetId() );
2078 le
.SetEventObject( GetParent() );
2079 le
.m_itemIndex
= GetIndexOfLine( m_current
);
2080 m_current
->GetItem( 0, le
.m_item
);
2081 GetParent()->GetEventHandler()->ProcessEvent( le
);
2085 m_current
->ReverseHilight();
2086 RefreshLine( m_current
);
2092 if (!(m_mode
& wxLC_SINGLE_SEL
))
2094 wxListLineData
*oldCurrent
= m_current
;
2095 m_current
->ReverseHilight();
2096 wxNode
*node
= m_lines
.Member( m_current
)->Next();
2097 if (node
) m_current
= (wxListLineData
*)node
->Data();
2098 RefreshLine( oldCurrent
);
2099 RefreshLine( m_current
);
2100 UnfocusLine( oldCurrent
);
2101 FocusLine( m_current
);
2109 wxListEvent
le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED
, GetParent()->GetId() );
2110 le
.SetEventObject( GetParent() );
2111 le
.m_itemIndex
= GetIndexOfLine( m_current
);
2112 m_current
->GetItem( 0, le
.m_item
);
2113 GetParent()->GetEventHandler()->ProcessEvent( le
);
2126 extern wxWindow
*g_focusWindow
;
2129 void wxListMainWindow::OnSetFocus( wxFocusEvent
&WXUNUSED(event
) )
2132 RefreshLine( m_current
);
2134 if (!GetParent()) return;
2137 g_focusWindow
= GetParent();
2140 wxFocusEvent
event( wxEVT_SET_FOCUS
, GetParent()->GetId() );
2141 event
.SetEventObject( GetParent() );
2142 GetParent()->GetEventHandler()->ProcessEvent( event
);
2145 void wxListMainWindow::OnKillFocus( wxFocusEvent
&WXUNUSED(event
) )
2148 RefreshLine( m_current
);
2151 void wxListMainWindow::OnSize( wxSizeEvent
&WXUNUSED(event
) )
2154 We don't even allow the wxScrolledWindow::AdjustScrollbars() call
2159 void wxListMainWindow::DrawImage( int index
, wxDC
*dc
, int x
, int y
)
2161 if ((m_mode
& wxLC_ICON
) && (m_normal_image_list
))
2163 m_normal_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
2166 if ((m_mode
& wxLC_SMALL_ICON
) && (m_small_image_list
))
2168 m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
2170 if ((m_mode
& wxLC_LIST
) && (m_small_image_list
))
2172 m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
2174 if ((m_mode
& wxLC_REPORT
) && (m_small_image_list
))
2176 m_small_image_list
->Draw( index
, *dc
, x
, y
, wxIMAGELIST_DRAW_TRANSPARENT
);
2181 void wxListMainWindow::GetImageSize( int index
, int &width
, int &height
)
2183 if ((m_mode
& wxLC_ICON
) && (m_normal_image_list
))
2185 m_normal_image_list
->GetSize( index
, width
, height
);
2188 if ((m_mode
& wxLC_SMALL_ICON
) && (m_small_image_list
))
2190 m_small_image_list
->GetSize( index
, width
, height
);
2193 if ((m_mode
& wxLC_LIST
) && (m_small_image_list
))
2195 m_small_image_list
->GetSize( index
, width
, height
);
2198 if ((m_mode
& wxLC_REPORT
) && (m_small_image_list
))
2200 m_small_image_list
->GetSize( index
, width
, height
);
2207 int wxListMainWindow::GetTextLength( wxString
&s
)
2209 wxClientDC
dc( this );
2212 dc
.GetTextExtent( s
, &lw
, &lh
);
2216 int wxListMainWindow::GetIndexOfLine( const wxListLineData
*line
)
2219 wxNode
*node
= m_lines
.First();
2222 if (line
== (wxListLineData
*)node
->Data()) return i
;
2224 node
= node
->Next();
2229 void wxListMainWindow::SetImageList( wxImageList
*imageList
, int which
)
2232 if (which
== wxIMAGE_LIST_NORMAL
) m_normal_image_list
= imageList
;
2233 if (which
== wxIMAGE_LIST_SMALL
) m_small_image_list
= imageList
;
2236 void wxListMainWindow::SetItemSpacing( int spacing
, bool isSmall
)
2241 m_small_spacing
= spacing
;
2245 m_normal_spacing
= spacing
;
2249 int wxListMainWindow::GetItemSpacing( bool isSmall
)
2251 if (isSmall
) return m_small_spacing
; else return m_normal_spacing
;
2254 void wxListMainWindow::SetColumn( int col
, wxListItem
&item
)
2257 wxNode
*node
= m_columns
.Nth( col
);
2260 if (item
.m_width
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width
= GetTextLength( item
.m_text
)+7;
2261 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
2262 column
->SetItem( item
);
2264 wxListCtrl
*lc
= (wxListCtrl
*) GetParent();
2265 if (lc
->m_headerWin
) lc
->m_headerWin
->Refresh();
2268 void wxListMainWindow::SetColumnWidth( int col
, int width
)
2270 if (!(m_mode
& wxLC_REPORT
)) return;
2274 wxNode
*node
= (wxNode
*) NULL
;
2276 if (width
== wxLIST_AUTOSIZE_USEHEADER
) width
= 80;
2277 if (width
== wxLIST_AUTOSIZE
)
2279 wxClientDC
dc(this);
2280 dc
.SetFont( GetFont() );
2282 node
= m_lines
.First();
2285 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2286 wxNode
*n
= line
->m_items
.Nth( col
);
2289 wxListItemData
*item
= (wxListItemData
*)n
->Data();
2290 int current
= 0, ix
= 0, iy
= 0;
2291 wxCoord lx
= 0, ly
= 0;
2292 if (item
->HasImage())
2294 GetImageSize( item
->GetImage(), ix
, iy
);
2297 if (item
->HasText())
2300 item
->GetText( str
);
2301 dc
.GetTextExtent( str
, &lx
, &ly
);
2304 if (current
> max
) max
= current
;
2306 node
= node
->Next();
2311 node
= m_columns
.Nth( col
);
2314 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
2315 column
->SetWidth( width
);
2318 node
= m_lines
.First();
2321 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2322 wxNode
*n
= line
->m_items
.Nth( col
);
2325 wxListItemData
*item
= (wxListItemData
*)n
->Data();
2326 item
->SetSize( width
, -1 );
2328 node
= node
->Next();
2331 wxListCtrl
*lc
= (wxListCtrl
*) GetParent();
2332 if (lc
->m_headerWin
) lc
->m_headerWin
->Refresh();
2335 void wxListMainWindow::GetColumn( int col
, wxListItem
&item
)
2337 wxNode
*node
= m_columns
.Nth( col
);
2340 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
2341 column
->GetItem( item
);
2353 int wxListMainWindow::GetColumnWidth( int col
)
2355 wxNode
*node
= m_columns
.Nth( col
);
2358 wxListHeaderData
*column
= (wxListHeaderData
*)node
->Data();
2359 return column
->GetWidth();
2367 int wxListMainWindow::GetColumnCount()
2369 return m_columns
.Number();
2372 int wxListMainWindow::GetCountPerPage()
2374 return m_visibleLines
;
2377 void wxListMainWindow::SetItem( wxListItem
&item
)
2380 wxNode
*node
= m_lines
.Nth( (size_t)item
.m_itemId
);
2383 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2384 if (m_mode
& wxLC_REPORT
) item
.m_width
= GetColumnWidth( item
.m_col
)-3;
2385 line
->SetItem( item
.m_col
, item
);
2389 void wxListMainWindow::SetItemState( long item
, long state
, long stateMask
)
2391 // m_dirty = TRUE; no recalcs needed
2393 wxListLineData
*oldCurrent
= m_current
;
2395 if (stateMask
& wxLIST_STATE_FOCUSED
)
2397 wxNode
*node
= m_lines
.Nth( (size_t)item
);
2400 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2401 UnfocusLine( m_current
);
2403 FocusLine( m_current
);
2404 RefreshLine( m_current
);
2405 if (oldCurrent
) RefreshLine( oldCurrent
);
2409 if (stateMask
& wxLIST_STATE_SELECTED
)
2411 bool on
= (state
& wxLIST_STATE_SELECTED
) != 0;
2412 if (!on
&& (m_mode
& wxLC_SINGLE_SEL
)) return;
2414 wxNode
*node
= m_lines
.Nth( (size_t)item
);
2417 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2418 if (m_mode
& wxLC_SINGLE_SEL
)
2420 UnfocusLine( m_current
);
2422 FocusLine( m_current
);
2423 if (oldCurrent
) oldCurrent
->Hilight( FALSE
);
2424 RefreshLine( m_current
);
2425 if (oldCurrent
) RefreshLine( oldCurrent
);
2427 bool on
= (state
& wxLIST_STATE_SELECTED
) != 0;
2428 if (on
!= line
->IsHilighted())
2430 line
->Hilight( on
);
2431 RefreshLine( line
);
2437 int wxListMainWindow::GetItemState( long item
, long stateMask
)
2439 int ret
= wxLIST_STATE_DONTCARE
;
2440 if (stateMask
& wxLIST_STATE_FOCUSED
)
2442 wxNode
*node
= m_lines
.Nth( (size_t)item
);
2445 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2446 if (line
== m_current
) ret
|= wxLIST_STATE_FOCUSED
;
2449 if (stateMask
& wxLIST_STATE_SELECTED
)
2451 wxNode
*node
= m_lines
.Nth( (size_t)item
);
2454 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2455 if (line
->IsHilighted()) ret
|= wxLIST_STATE_FOCUSED
;
2461 void wxListMainWindow::GetItem( wxListItem
&item
)
2463 wxNode
*node
= m_lines
.Nth( (size_t)item
.m_itemId
);
2466 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2467 line
->GetItem( item
.m_col
, item
);
2478 int wxListMainWindow::GetItemCount()
2480 return m_lines
.Number();
2483 void wxListMainWindow::GetItemRect( long index
, wxRect
&rect
)
2485 wxNode
*node
= m_lines
.Nth( (size_t)index
);
2488 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2489 line
->GetRect( rect
);
2500 bool wxListMainWindow::GetItemPosition(long item
, wxPoint
& pos
)
2502 wxNode
*node
= m_lines
.Nth( (size_t)item
);
2506 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2507 line
->GetRect( rect
);
2519 int wxListMainWindow::GetSelectedItemCount()
2522 wxNode
*node
= m_lines
.First();
2525 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2526 if (line
->IsHilighted()) ret
++;
2527 node
= node
->Next();
2532 void wxListMainWindow::SetMode( long mode
)
2539 if (m_mode
& wxLC_REPORT
)
2541 #if wxUSE_GENERIC_LIST_EXTENSIONS
2555 long wxListMainWindow::GetMode() const
2560 void wxListMainWindow::CalculatePositions()
2562 if (!m_lines
.First()) return;
2564 wxClientDC
dc( this );
2565 dc
.SetFont( GetFont() );
2567 int iconSpacing
= 0;
2568 if (m_mode
& wxLC_ICON
) iconSpacing
= m_normal_spacing
;
2569 if (m_mode
& wxLC_SMALL_ICON
) iconSpacing
= m_small_spacing
;
2571 // we take the first line (which also can be an icon or
2572 // an a text item in wxLC_ICON and wxLC_LIST modes) to
2573 // measure the size of the line
2577 int lineSpacing
= 0;
2579 wxListLineData
*line
= (wxListLineData
*)m_lines
.First()->Data();
2580 line
->CalculateSize( &dc
, iconSpacing
);
2582 line
->GetSize( dummy
, lineSpacing
);
2585 int clientWidth
= 0;
2586 int clientHeight
= 0;
2588 if (m_mode
& wxLC_REPORT
)
2592 int entireHeight
= m_lines
.Number() * lineSpacing
+ 2;
2593 int scroll_pos
= GetScrollPos( wxVERTICAL
);
2594 #if wxUSE_GENERIC_LIST_EXTENSIONS
2595 int x_scroll_pos
= GetScrollPos( wxHORIZONTAL
);
2597 SetScrollbars( m_xScroll
, m_yScroll
, 0, (entireHeight
+15) / m_yScroll
, 0, scroll_pos
, TRUE
);
2599 GetClientSize( &clientWidth
, &clientHeight
);
2601 wxNode
* node
= m_lines
.First();
2602 int entireWidth
= 0 ;
2605 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2606 line
->CalculateSize( &dc
, iconSpacing
);
2607 line
->SetPosition( &dc
, x
, y
, clientWidth
);
2609 for (int i
= 0; i
< GetColumnCount(); i
++)
2611 line
->SetColumnPosition( i
, col_x
);
2612 col_x
+= GetColumnWidth( i
);
2614 entireWidth
= wxMax( entireWidth
, col_x
) ;
2615 #if wxUSE_GENERIC_LIST_EXTENSIONS
2616 line
->SetPosition( &dc
, x
, y
, col_x
);
2618 y
+= lineSpacing
; // one pixel blank line between items
2619 node
= node
->Next();
2621 m_visibleLines
= clientHeight
/ lineSpacing
;
2622 #if wxUSE_GENERIC_LIST_EXTENSIONS
2623 SetScrollbars( m_xScroll
, m_yScroll
, entireWidth
/ m_xScroll
, (entireHeight
+15) / m_yScroll
, x_scroll_pos
, scroll_pos
, TRUE
);
2628 // at first we try without any scrollbar. if the items don't
2629 // fit into the window, we recalculate after subtracting an
2630 // approximated 15 pt for the horizontal scrollbar
2632 GetSize( &clientWidth
, &clientHeight
);
2633 clientHeight
-= 4; // sunken frame
2635 int entireWidth
= 0;
2637 for (int tries
= 0; tries
< 2; tries
++)
2644 int m_currentVisibleLines
= 0;
2645 wxNode
*node
= m_lines
.First();
2648 m_currentVisibleLines
++;
2649 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2650 line
->CalculateSize( &dc
, iconSpacing
);
2651 line
->SetPosition( &dc
, x
, y
, clientWidth
);
2652 line
->GetSize( lineWidth
, lineHeight
);
2653 if (lineWidth
> maxWidth
) maxWidth
= lineWidth
;
2655 if (m_currentVisibleLines
> m_visibleLines
)
2656 m_visibleLines
= m_currentVisibleLines
;
2657 if (y
+lineSpacing
-6 >= clientHeight
) // -6 for earlier "line breaking"
2659 m_currentVisibleLines
= 0;
2662 entireWidth
+= maxWidth
+6;
2665 node
= node
->Next();
2666 if (!node
) entireWidth
+= maxWidth
;
2667 if ((tries
== 0) && (entireWidth
> clientWidth
))
2669 clientHeight
-= 15; // scrollbar height
2671 m_currentVisibleLines
= 0;
2674 if (!node
) tries
= 1; // everything fits, no second try required
2678 int scroll_pos
= GetScrollPos( wxHORIZONTAL
);
2679 SetScrollbars( m_xScroll
, m_yScroll
, (entireWidth
+15) / m_xScroll
, 0, scroll_pos
, 0, TRUE
);
2683 void wxListMainWindow::RealizeChanges( void )
2687 wxNode
*node
= m_lines
.First();
2688 if (node
) m_current
= (wxListLineData
*)node
->Data();
2692 FocusLine( m_current
);
2693 if (m_mode
& wxLC_SINGLE_SEL
) m_current
->Hilight( TRUE
);
2697 long wxListMainWindow::GetNextItem( long item
,
2698 int WXUNUSED(geometry
),
2702 max
= GetItemCount();
2703 wxCHECK_MSG( (ret
== -1) || (ret
< max
), -1,
2704 _T("invalid listctrl index in GetNextItem()") );
2706 // notice that we start with the next item (or the first one if item == -1)
2707 // and this is intentional to allow writing a simple loop to iterate over
2708 // all selected items
2712 // this is not an error because the index was ok initially, just no
2717 wxNode
*node
= m_lines
.Nth( (size_t)ret
);
2720 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2721 if ((state
& wxLIST_STATE_FOCUSED
) && (line
== m_current
))
2723 if ((state
& wxLIST_STATE_SELECTED
) && (line
->IsHilighted()))
2729 node
= node
->Next();
2735 void wxListMainWindow::DeleteItem( long index
)
2738 wxNode
*node
= m_lines
.Nth( (size_t)index
);
2741 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2742 if (m_current
== line
) m_current
= (wxListLineData
*) NULL
;
2744 m_lines
.DeleteNode( node
);
2748 void wxListMainWindow::DeleteColumn( int col
)
2750 wxCHECK_RET( col
< (int)m_columns
.GetCount(),
2751 wxT("attempting to delete inexistent column in wxListView") );
2754 wxNode
*node
= m_columns
.Nth( col
);
2755 if (node
) m_columns
.DeleteNode( node
);
2758 void wxListMainWindow::DeleteAllItems()
2761 m_current
= (wxListLineData
*) NULL
;
2763 // to make the deletion of all items faster, we don't send the
2764 // notifications in this case: this is compatible with wxMSW and
2765 // documented in DeleteAllItems() description
2767 wxListEvent
event( wxEVT_COMMAND_LIST_DELETE_ALL_ITEMS
, GetParent()->GetId() );
2768 event
.SetEventObject( GetParent() );
2769 GetParent()->GetEventHandler()->ProcessEvent( event
);
2774 void wxListMainWindow::DeleteEverything()
2781 void wxListMainWindow::EnsureVisible( long index
)
2783 // We have to call this here because the label in
2784 // question might just have been added and no screen
2785 // update taken place.
2786 if (m_dirty
) wxYield();
2788 wxListLineData
*oldCurrent
= m_current
;
2789 m_current
= (wxListLineData
*) NULL
;
2790 wxNode
*node
= m_lines
.Nth( (size_t)index
);
2791 if (node
) m_current
= (wxListLineData
*)node
->Data();
2792 if (m_current
) MoveToFocus();
2793 m_current
= oldCurrent
;
2796 long wxListMainWindow::FindItem(long start
, const wxString
& str
, bool WXUNUSED(partial
) )
2800 if (pos
< 0) pos
= 0;
2801 wxNode
*node
= m_lines
.Nth( (size_t)pos
);
2804 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2806 line
->GetText( 0, s
);
2807 if (s
== tmp
) return pos
;
2808 node
= node
->Next();
2814 long wxListMainWindow::FindItem(long start
, long data
)
2817 if (pos
< 0) pos
= 0;
2818 wxNode
*node
= m_lines
.Nth( (size_t)pos
);
2821 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2823 line
->GetItem( 0, item
);
2824 if (item
.m_data
== data
) return pos
;
2825 node
= node
->Next();
2831 long wxListMainWindow::HitTest( int x
, int y
, int &flags
)
2833 wxNode
*node
= m_lines
.First();
2837 wxListLineData
*line
= (wxListLineData
*)node
->Data();
2838 long ret
= line
->IsHit( x
, y
);
2844 node
= node
->Next();
2850 void wxListMainWindow::InsertItem( wxListItem
&item
)
2854 if (m_mode
& wxLC_REPORT
) mode
= wxLC_REPORT
;
2855 else if (m_mode
& wxLC_LIST
) mode
= wxLC_LIST
;
2856 else if (m_mode
& wxLC_ICON
) mode
= wxLC_ICON
;
2857 else if (m_mode
& wxLC_SMALL_ICON
) mode
= wxLC_ICON
; // no typo
2859 wxListLineData
*line
= new wxListLineData( this, mode
, m_hilightBrush
);
2861 if (m_mode
& wxLC_REPORT
)
2863 line
->InitItems( GetColumnCount() );
2864 item
.m_width
= GetColumnWidth( 0 )-3;
2868 line
->InitItems( 1 );
2871 line
->SetItem( 0, item
);
2872 if ((item
.m_itemId
>= 0) && (item
.m_itemId
< (int)m_lines
.GetCount()))
2874 wxNode
*node
= m_lines
.Nth( (size_t)item
.m_itemId
);
2875 if (node
) m_lines
.Insert( node
, line
);
2879 m_lines
.Append( line
);
2883 void wxListMainWindow::InsertColumn( long col
, wxListItem
&item
)
2886 if (m_mode
& wxLC_REPORT
)
2888 if (item
.m_width
== wxLIST_AUTOSIZE_USEHEADER
) item
.m_width
= GetTextLength( item
.m_text
);
2889 wxListHeaderData
*column
= new wxListHeaderData( item
);
2890 if ((col
>= 0) && (col
< (int)m_columns
.GetCount()))
2892 wxNode
*node
= m_columns
.Nth( (size_t)col
);
2894 m_columns
.Insert( node
, column
);
2898 m_columns
.Append( column
);
2903 wxListCtrlCompare list_ctrl_compare_func_2
;
2904 long list_ctrl_compare_data
;
2906 int LINKAGEMODE
list_ctrl_compare_func_1( const void *arg1
, const void *arg2
)
2908 wxListLineData
*line1
= *((wxListLineData
**)arg1
);
2909 wxListLineData
*line2
= *((wxListLineData
**)arg2
);
2911 line1
->GetItem( 0, item
);
2912 long data1
= item
.m_data
;
2913 line2
->GetItem( 0, item
);
2914 long data2
= item
.m_data
;
2915 return list_ctrl_compare_func_2( data1
, data2
, list_ctrl_compare_data
);
2918 void wxListMainWindow::SortItems( wxListCtrlCompare fn
, long data
)
2920 list_ctrl_compare_func_2
= fn
;
2921 list_ctrl_compare_data
= data
;
2922 m_lines
.Sort( list_ctrl_compare_func_1
);
2926 void wxListMainWindow::OnScroll(wxScrollWinEvent
& event
)
2928 wxScrolledWindow::OnScroll( event
) ;
2929 #if wxUSE_GENERIC_LIST_EXTENSIONS
2931 if (event
.GetOrientation() == wxHORIZONTAL
&& ( m_mode
& wxLC_REPORT
))
2933 wxListCtrl
* lc
= wxDynamicCast( GetParent() , wxListCtrl
) ;
2936 lc
->m_headerWin
->Refresh() ;
2938 lc
->m_headerWin
->MacUpdateImmediately() ;
2945 // -------------------------------------------------------------------------------------
2947 // -------------------------------------------------------------------------------------
2949 IMPLEMENT_DYNAMIC_CLASS(wxListItem
, wxObject
)
2951 wxListItem::wxListItem()
2960 m_format
= wxLIST_FORMAT_CENTRE
;
2966 void wxListItem::Clear()
2975 m_format
= wxLIST_FORMAT_CENTRE
;
2977 m_text
= wxEmptyString
;
2979 if (m_attr
) delete m_attr
;
2983 void wxListItem::ClearAttributes()
2985 if (m_attr
) delete m_attr
;
2989 // -------------------------------------------------------------------------------------
2991 // -------------------------------------------------------------------------------------
2993 IMPLEMENT_DYNAMIC_CLASS(wxListEvent
, wxNotifyEvent
)
2995 wxListEvent::wxListEvent( wxEventType commandType
, int id
):
2996 wxNotifyEvent( commandType
, id
)
3002 m_cancelled
= FALSE
;
3007 void wxListEvent::CopyObject(wxObject
& object_dest
) const
3009 wxListEvent
*obj
= (wxListEvent
*)&object_dest
;
3011 wxNotifyEvent::CopyObject(object_dest
);
3013 obj
->m_code
= m_code
;
3014 obj
->m_itemIndex
= m_itemIndex
;
3015 obj
->m_oldItemIndex
= m_oldItemIndex
;
3017 obj
->m_cancelled
= m_cancelled
;
3018 obj
->m_pointDrag
= m_pointDrag
;
3019 obj
->m_item
.m_mask
= m_item
.m_mask
;
3020 obj
->m_item
.m_itemId
= m_item
.m_itemId
;
3021 obj
->m_item
.m_col
= m_item
.m_col
;
3022 obj
->m_item
.m_state
= m_item
.m_state
;
3023 obj
->m_item
.m_stateMask
= m_item
.m_stateMask
;
3024 obj
->m_item
.m_text
= m_item
.m_text
;
3025 obj
->m_item
.m_image
= m_item
.m_image
;
3026 obj
->m_item
.m_data
= m_item
.m_data
;
3027 obj
->m_item
.m_format
= m_item
.m_format
;
3028 obj
->m_item
.m_width
= m_item
.m_width
;
3030 if ( m_item
.HasAttributes() )
3032 obj
->m_item
.SetTextColour(m_item
.GetTextColour());
3036 // -------------------------------------------------------------------------------------
3038 // -------------------------------------------------------------------------------------
3040 IMPLEMENT_DYNAMIC_CLASS(wxListCtrl
, wxControl
)
3042 BEGIN_EVENT_TABLE(wxListCtrl
,wxControl
)
3043 EVT_SIZE (wxListCtrl::OnSize
)
3044 EVT_IDLE (wxListCtrl::OnIdle
)
3047 wxListCtrl::wxListCtrl()
3049 m_imageListNormal
= (wxImageList
*) NULL
;
3050 m_imageListSmall
= (wxImageList
*) NULL
;
3051 m_imageListState
= (wxImageList
*) NULL
;
3052 m_mainWin
= (wxListMainWindow
*) NULL
;
3053 m_headerWin
= (wxListHeaderWindow
*) NULL
;
3056 wxListCtrl::~wxListCtrl()
3060 bool wxListCtrl::Create(wxWindow
*parent
,
3065 const wxValidator
&validator
,
3066 const wxString
&name
)
3068 m_imageListNormal
= (wxImageList
*) NULL
;
3069 m_imageListSmall
= (wxImageList
*) NULL
;
3070 m_imageListState
= (wxImageList
*) NULL
;
3071 m_mainWin
= (wxListMainWindow
*) NULL
;
3072 m_headerWin
= (wxListHeaderWindow
*) NULL
;
3074 if ( !(style
& (wxLC_REPORT
| wxLC_LIST
| wxLC_ICON
)) )
3076 style
= style
| wxLC_LIST
;
3079 bool ret
= wxControl::Create( parent
, id
, pos
, size
, style
, validator
, name
);
3082 if (style
& wxSUNKEN_BORDER
)
3083 style
-= wxSUNKEN_BORDER
;
3085 m_mainWin
= new wxListMainWindow( this, -1, wxPoint(0,0), size
, style
);
3087 if (HasFlag(wxLC_REPORT
))
3089 m_headerWin
= new wxListHeaderWindow( this, -1, m_mainWin
, wxPoint(0,0), wxSize(size
.x
,23), wxTAB_TRAVERSAL
);
3090 if (HasFlag(wxLC_NO_HEADER
))
3091 m_headerWin
->Show( FALSE
);
3095 m_headerWin
= (wxListHeaderWindow
*) NULL
;
3098 SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX
) );
3103 void wxListCtrl::OnSize( wxSizeEvent
&WXUNUSED(event
) )
3105 /* handled in OnIdle */
3107 if (m_mainWin
) m_mainWin
->m_dirty
= TRUE
;
3110 void wxListCtrl::SetSingleStyle( long style
, bool add
)
3112 long flag
= GetWindowStyle();
3116 if (style
& wxLC_MASK_TYPE
) flag
= flag
& ~wxLC_MASK_TYPE
;
3117 if (style
& wxLC_MASK_ALIGN
) flag
= flag
& ~wxLC_MASK_ALIGN
;
3118 if (style
& wxLC_MASK_SORT
) flag
= flag
& ~wxLC_MASK_SORT
;
3127 if (flag
& style
) flag
-= style
;
3130 SetWindowStyleFlag( flag
);
3133 void wxListCtrl::SetWindowStyleFlag( long flag
)
3137 m_mainWin
->DeleteEverything();
3141 GetClientSize( &width
, &height
);
3143 m_mainWin
->SetMode( flag
);
3145 if (flag
& wxLC_REPORT
)
3147 if (!HasFlag(wxLC_REPORT
))
3151 m_headerWin
= new wxListHeaderWindow( this, -1, m_mainWin
,
3152 wxPoint(0,0), wxSize(width
,23), wxTAB_TRAVERSAL
);
3153 if (HasFlag(wxLC_NO_HEADER
))
3154 m_headerWin
->Show( FALSE
);
3158 if (flag
& wxLC_NO_HEADER
)
3159 m_headerWin
->Show( FALSE
);
3161 m_headerWin
->Show( TRUE
);
3167 if (HasFlag(wxLC_REPORT
) && !(HasFlag(wxLC_NO_HEADER
)))
3169 m_headerWin
->Show( FALSE
);
3174 wxWindow::SetWindowStyleFlag( flag
);
3177 bool wxListCtrl::GetColumn(int col
, wxListItem
&item
) const
3179 m_mainWin
->GetColumn( col
, item
);
3183 bool wxListCtrl::SetColumn( int col
, wxListItem
& item
)
3185 m_mainWin
->SetColumn( col
, item
);
3189 int wxListCtrl::GetColumnWidth( int col
) const
3191 return m_mainWin
->GetColumnWidth( col
);
3194 bool wxListCtrl::SetColumnWidth( int col
, int width
)
3196 m_mainWin
->SetColumnWidth( col
, width
);
3200 int wxListCtrl::GetCountPerPage() const
3202 return m_mainWin
->GetCountPerPage(); // different from Windows ?
3205 bool wxListCtrl::GetItem( wxListItem
&info
) const
3207 m_mainWin
->GetItem( info
);
3211 bool wxListCtrl::SetItem( wxListItem
&info
)
3213 m_mainWin
->SetItem( info
);
3217 long wxListCtrl::SetItem( long index
, int col
, const wxString
& label
, int imageId
)
3220 info
.m_text
= label
;
3221 info
.m_mask
= wxLIST_MASK_TEXT
;
3222 info
.m_itemId
= index
;
3226 info
.m_image
= imageId
;
3227 info
.m_mask
|= wxLIST_MASK_IMAGE
;
3229 m_mainWin
->SetItem(info
);
3233 int wxListCtrl::GetItemState( long item
, long stateMask
) const
3235 return m_mainWin
->GetItemState( item
, stateMask
);
3238 bool wxListCtrl::SetItemState( long item
, long state
, long stateMask
)
3240 m_mainWin
->SetItemState( item
, state
, stateMask
);
3244 bool wxListCtrl::SetItemImage( long item
, int image
, int WXUNUSED(selImage
) )
3247 info
.m_image
= image
;
3248 info
.m_mask
= wxLIST_MASK_IMAGE
;
3249 info
.m_itemId
= item
;
3250 m_mainWin
->SetItem( info
);
3254 wxString
wxListCtrl::GetItemText( long item
) const
3257 info
.m_itemId
= item
;
3258 m_mainWin
->GetItem( info
);
3262 void wxListCtrl::SetItemText( long item
, const wxString
&str
)
3265 info
.m_mask
= wxLIST_MASK_TEXT
;
3266 info
.m_itemId
= item
;
3268 m_mainWin
->SetItem( info
);
3271 long wxListCtrl::GetItemData( long item
) const
3274 info
.m_itemId
= item
;
3275 m_mainWin
->GetItem( info
);
3279 bool wxListCtrl::SetItemData( long item
, long data
)
3282 info
.m_mask
= wxLIST_MASK_DATA
;
3283 info
.m_itemId
= item
;
3285 m_mainWin
->SetItem( info
);
3289 bool wxListCtrl::GetItemRect( long item
, wxRect
&rect
, int WXUNUSED(code
) ) const
3291 m_mainWin
->GetItemRect( item
, rect
);
3295 bool wxListCtrl::GetItemPosition( long item
, wxPoint
& pos
) const
3297 m_mainWin
->GetItemPosition( item
, pos
);
3301 bool wxListCtrl::SetItemPosition( long WXUNUSED(item
), const wxPoint
& WXUNUSED(pos
) )
3306 int wxListCtrl::GetItemCount() const
3308 return m_mainWin
->GetItemCount();
3311 int wxListCtrl::GetColumnCount() const
3313 return m_mainWin
->GetColumnCount();
3316 void wxListCtrl::SetItemSpacing( int spacing
, bool isSmall
)
3318 m_mainWin
->SetItemSpacing( spacing
, isSmall
);
3321 int wxListCtrl::GetItemSpacing( bool isSmall
) const
3323 return m_mainWin
->GetItemSpacing( isSmall
);
3326 int wxListCtrl::GetSelectedItemCount() const
3328 return m_mainWin
->GetSelectedItemCount();
3331 wxColour
wxListCtrl::GetTextColour() const
3333 return GetForegroundColour();
3336 void wxListCtrl::SetTextColour(const wxColour
& col
)
3338 SetForegroundColour(col
);
3341 long wxListCtrl::GetTopItem() const
3346 long wxListCtrl::GetNextItem( long item
, int geom
, int state
) const
3348 return m_mainWin
->GetNextItem( item
, geom
, state
);
3351 wxImageList
*wxListCtrl::GetImageList(int which
) const
3353 if (which
== wxIMAGE_LIST_NORMAL
)
3355 return m_imageListNormal
;
3357 else if (which
== wxIMAGE_LIST_SMALL
)
3359 return m_imageListSmall
;
3361 else if (which
== wxIMAGE_LIST_STATE
)
3363 return m_imageListState
;
3365 return (wxImageList
*) NULL
;
3368 void wxListCtrl::SetImageList( wxImageList
*imageList
, int which
)
3370 m_mainWin
->SetImageList( imageList
, which
);
3373 bool wxListCtrl::Arrange( int WXUNUSED(flag
) )
3378 bool wxListCtrl::DeleteItem( long item
)
3380 m_mainWin
->DeleteItem( item
);
3384 bool wxListCtrl::DeleteAllItems()
3386 m_mainWin
->DeleteAllItems();
3390 bool wxListCtrl::DeleteAllColumns()
3392 for ( size_t n
= 0; n
< m_mainWin
->m_columns
.GetCount(); n
++ )
3398 void wxListCtrl::ClearAll()
3400 m_mainWin
->DeleteEverything();
3403 bool wxListCtrl::DeleteColumn( int col
)
3405 m_mainWin
->DeleteColumn( col
);
3409 void wxListCtrl::Edit( long item
)
3411 m_mainWin
->Edit( item
);
3414 bool wxListCtrl::EnsureVisible( long item
)
3416 m_mainWin
->EnsureVisible( item
);
3420 long wxListCtrl::FindItem( long start
, const wxString
& str
, bool partial
)
3422 return m_mainWin
->FindItem( start
, str
, partial
);
3425 long wxListCtrl::FindItem( long start
, long data
)
3427 return m_mainWin
->FindItem( start
, data
);
3430 long wxListCtrl::FindItem( long WXUNUSED(start
), const wxPoint
& WXUNUSED(pt
),
3431 int WXUNUSED(direction
))
3436 long wxListCtrl::HitTest( const wxPoint
&point
, int &flags
)
3438 return m_mainWin
->HitTest( (int)point
.x
, (int)point
.y
, flags
);
3441 long wxListCtrl::InsertItem( wxListItem
& info
)
3443 m_mainWin
->InsertItem( info
);
3444 return info
.m_itemId
;
3447 long wxListCtrl::InsertItem( long index
, const wxString
&label
)
3450 info
.m_text
= label
;
3451 info
.m_mask
= wxLIST_MASK_TEXT
;
3452 info
.m_itemId
= index
;
3453 return InsertItem( info
);
3456 long wxListCtrl::InsertItem( long index
, int imageIndex
)
3459 info
.m_mask
= wxLIST_MASK_IMAGE
;
3460 info
.m_image
= imageIndex
;
3461 info
.m_itemId
= index
;
3462 return InsertItem( info
);
3465 long wxListCtrl::InsertItem( long index
, const wxString
&label
, int imageIndex
)
3468 info
.m_text
= label
;
3469 info
.m_image
= imageIndex
;
3470 info
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_IMAGE
;
3471 info
.m_itemId
= index
;
3472 return InsertItem( info
);
3475 long wxListCtrl::InsertColumn( long col
, wxListItem
&item
)
3477 wxASSERT( m_headerWin
);
3478 m_mainWin
->InsertColumn( col
, item
);
3479 m_headerWin
->Refresh();
3484 long wxListCtrl::InsertColumn( long col
, const wxString
&heading
,
3485 int format
, int width
)
3488 item
.m_mask
= wxLIST_MASK_TEXT
| wxLIST_MASK_FORMAT
;
3489 item
.m_text
= heading
;
3492 item
.m_mask
|= wxLIST_MASK_WIDTH
;
3493 item
.m_width
= width
;
3495 item
.m_format
= format
;
3497 return InsertColumn( col
, item
);
3500 bool wxListCtrl::ScrollList( int WXUNUSED(dx
), int WXUNUSED(dy
) )
3506 // fn is a function which takes 3 long arguments: item1, item2, data.
3507 // item1 is the long data associated with a first item (NOT the index).
3508 // item2 is the long data associated with a second item (NOT the index).
3509 // data is the same value as passed to SortItems.
3510 // The return value is a negative number if the first item should precede the second
3511 // item, a positive number of the second item should precede the first,
3512 // or zero if the two items are equivalent.
3513 // data is arbitrary data to be passed to the sort function.
3515 bool wxListCtrl::SortItems( wxListCtrlCompare fn
, long data
)
3517 m_mainWin
->SortItems( fn
, data
);
3521 void wxListCtrl::OnIdle( wxIdleEvent
&WXUNUSED(event
) )
3523 if (!m_mainWin
->m_dirty
) return;
3527 GetClientSize( &cw
, &ch
);
3534 if (HasFlag(wxLC_REPORT
) && !HasFlag(wxLC_NO_HEADER
))
3536 m_headerWin
->GetPosition( &x
, &y
);
3537 m_headerWin
->GetSize( &w
, &h
);
3538 if ((x
!= 0) || (y
!= 0) || (w
!= cw
) || (h
!= 23))
3539 m_headerWin
->SetSize( 0, 0, cw
, 23 );
3541 m_mainWin
->GetPosition( &x
, &y
);
3542 m_mainWin
->GetSize( &w
, &h
);
3543 if ((x
!= 0) || (y
!= 24) || (w
!= cw
) || (h
!= ch
-24))
3544 m_mainWin
->SetSize( 0, 24, cw
, ch
-24 );
3548 m_mainWin
->GetPosition( &x
, &y
);
3549 m_mainWin
->GetSize( &w
, &h
);
3550 if ((x
!= 0) || (y
!= 24) || (w
!= cw
) || (h
!= ch
))
3551 m_mainWin
->SetSize( 0, 0, cw
, ch
);
3554 m_mainWin
->CalculatePositions();
3555 m_mainWin
->RealizeChanges();
3556 m_mainWin
->m_dirty
= FALSE
;
3557 m_mainWin
->Refresh();
3560 bool wxListCtrl::SetBackgroundColour( const wxColour
&colour
)
3562 if ( !wxWindow::SetBackgroundColour( colour
) )
3567 m_mainWin
->SetBackgroundColour( colour
);
3568 m_mainWin
->m_dirty
= TRUE
;
3573 // m_headerWin->SetBackgroundColour( colour );
3579 bool wxListCtrl::SetForegroundColour( const wxColour
&colour
)
3581 if ( !wxWindow::SetForegroundColour( colour
) )
3586 m_mainWin
->SetForegroundColour( colour
);
3587 m_mainWin
->m_dirty
= TRUE
;
3592 m_headerWin
->SetForegroundColour( colour
);
3598 bool wxListCtrl::SetFont( const wxFont
&font
)
3600 if ( !wxWindow::SetFont( font
) )
3605 m_mainWin
->SetFont( font
);
3606 m_mainWin
->m_dirty
= TRUE
;
3611 m_headerWin
->SetFont( font
);
3617 #if wxUSE_DRAG_AND_DROP
3619 void wxListCtrl::SetDropTarget( wxDropTarget
*dropTarget
)
3621 m_mainWin
->SetDropTarget( dropTarget
);
3624 wxDropTarget
*wxListCtrl::GetDropTarget() const
3626 return m_mainWin
->GetDropTarget();
3629 #endif // wxUSE_DRAG_AND_DROP
3631 bool wxListCtrl::SetCursor( const wxCursor
&cursor
)
3633 return m_mainWin
? m_mainWin
->wxWindow::SetCursor(cursor
) : FALSE
;
3636 wxColour
wxListCtrl::GetBackgroundColour() const
3638 return m_mainWin
? m_mainWin
->GetBackgroundColour() : wxColour();
3641 wxColour
wxListCtrl::GetForegroundColour() const
3643 return m_mainWin
? m_mainWin
->GetForegroundColour() : wxColour();
3646 bool wxListCtrl::DoPopupMenu( wxMenu
*menu
, int x
, int y
)
3648 return m_mainWin
->PopupMenu( menu
, x
, y
);
3651 void wxListCtrl::SetFocus()
3653 /* The test in window.cpp fails as we are a composite
3654 window, so it checks against "this", but not m_mainWin. */
3655 if ( FindFocus() != this )
3656 m_mainWin
->SetFocus();