1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "listbox.h"
15 #include "wx/listbox.h"
19 #include "wx/dynarray.h"
22 #include "wx/checklst.h"
23 #include "wx/settings.h"
26 #include "wx/tooltip.h"
29 #if wxUSE_DRAG_AND_DROP
36 //-----------------------------------------------------------------------------
38 //-----------------------------------------------------------------------------
40 extern void wxapp_install_idle_handler();
43 //-------------------------------------------------------------------------
44 // conditional compilation
45 //-------------------------------------------------------------------------
47 #if (GTK_MINOR_VERSION > 0)
48 #define NEW_GTK_SCROLL_CODE
51 //-----------------------------------------------------------------------------
53 //-----------------------------------------------------------------------------
55 #if wxUSE_CHECKLISTBOX
57 #define CHECKBOX_STRING "[-] "
59 // checklistboxes have "[±] " prepended to their lables, this macro removes it
60 // (NB: 4 below is the length of CHECKBOX_STRING above)
62 // the argument to it is a "const char *" pointer
63 #define GET_REAL_LABEL(label) ((m_hasCheckBoxes)?(label)+4 : (label))
65 #else // !wxUSE_CHECKLISTBOX
67 #define GET_REAL_LABEL(label) (label)
69 #endif // wxUSE_CHECKLISTBOX
71 //-----------------------------------------------------------------------------
73 //-----------------------------------------------------------------------------
75 extern bool g_blockEventsOnDrag
;
76 extern bool g_blockEventsOnScroll
;
78 static bool g_hasDoubleClicked
= FALSE
;
80 //-----------------------------------------------------------------------------
81 // "button_release_event"
82 //-----------------------------------------------------------------------------
84 /* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once
85 a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the
86 listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event.
87 this can lead to race conditions so that we emit the dclick event
88 after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */
91 gtk_listbox_button_release_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxListBox
*listbox
)
93 if (g_isIdle
) wxapp_install_idle_handler();
95 if (g_blockEventsOnDrag
) return FALSE
;
96 if (g_blockEventsOnScroll
) return FALSE
;
98 if (!listbox
->m_hasVMT
) return FALSE
;
100 if (!g_hasDoubleClicked
) return FALSE
;
102 wxCommandEvent
event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, listbox
->GetId() );
103 event
.SetEventObject( listbox
);
105 wxArrayInt aSelections
;
106 int count
= listbox
->GetSelections(aSelections
);
109 event
.m_commandInt
= aSelections
[0] ;
110 event
.m_clientData
= listbox
->GetClientData( event
.m_commandInt
);
111 wxString
str(listbox
->GetString(event
.m_commandInt
));
112 if (!str
.IsEmpty()) event
.m_commandString
= str
;
116 event
.m_commandInt
= -1 ;
117 event
.m_commandString
.Empty();
120 listbox
->GetEventHandler()->ProcessEvent( event
);
125 //-----------------------------------------------------------------------------
126 // "button_press_event"
127 //-----------------------------------------------------------------------------
130 gtk_listbox_button_press_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxListBox
*listbox
)
132 if (g_isIdle
) wxapp_install_idle_handler();
134 if (g_blockEventsOnDrag
) return FALSE
;
135 if (g_blockEventsOnScroll
) return FALSE
;
137 if (!listbox
->m_hasVMT
) return FALSE
;
139 int sel
= listbox
->GetIndex( widget
);
141 #if wxUSE_CHECKLISTBOX
142 if ((listbox
->m_hasCheckBoxes
) && (gdk_event
->x
< 15) && (gdk_event
->type
!= GDK_2BUTTON_PRESS
))
144 wxCheckListBox
*clb
= (wxCheckListBox
*)listbox
;
146 clb
->Check( sel
, !clb
->IsChecked(sel
) );
148 wxCommandEvent
event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, listbox
->GetId() );
149 event
.SetEventObject( listbox
);
151 listbox
->GetEventHandler()->ProcessEvent( event
);
153 #endif // wxUSE_CHECKLISTBOX
155 /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
156 g_hasDoubleClicked
= (gdk_event
->type
== GDK_2BUTTON_PRESS
);
161 //-----------------------------------------------------------------------------
163 //-----------------------------------------------------------------------------
165 #if wxUSE_CHECKLISTBOX
167 gtk_listbox_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxListBox
*listbox
)
169 if (g_isIdle
) wxapp_install_idle_handler();
171 if (g_blockEventsOnDrag
) return FALSE
;
173 if (!listbox
->m_hasVMT
) return FALSE
;
175 if (gdk_event
->keyval
!= ' ') return FALSE
;
177 int sel
= listbox
->GetIndex( widget
);
179 wxCheckListBox
*clb
= (wxCheckListBox
*)listbox
;
181 clb
->Check( sel
, !clb
->IsChecked(sel
) );
183 wxCommandEvent
event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, listbox
->GetId() );
184 event
.SetEventObject( listbox
);
186 listbox
->GetEventHandler()->ProcessEvent( event
);
190 #endif // wxUSE_CHECKLISTBOX
192 //-----------------------------------------------------------------------------
193 // "select" and "deselect"
194 //-----------------------------------------------------------------------------
196 static void gtk_listitem_select_callback( GtkWidget
*WXUNUSED(widget
), wxListBox
*listbox
)
198 if (g_isIdle
) wxapp_install_idle_handler();
200 if (!listbox
->m_hasVMT
) return;
201 if (g_blockEventsOnDrag
) return;
203 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, listbox
->GetId() );
205 wxArrayInt aSelections
;
206 int count
= listbox
->GetSelections(aSelections
);
209 event
.m_commandInt
= aSelections
[0] ;
210 event
.m_clientData
= listbox
->GetClientData( event
.m_commandInt
);
211 wxString
str(listbox
->GetString(event
.m_commandInt
));
212 if (!str
.IsEmpty()) event
.m_commandString
= str
;
216 event
.m_commandInt
= -1 ;
217 event
.m_commandString
.Empty();
220 event
.SetEventObject( listbox
);
222 listbox
->GetEventHandler()->ProcessEvent( event
);
225 //-----------------------------------------------------------------------------
227 //-----------------------------------------------------------------------------
229 IMPLEMENT_DYNAMIC_CLASS(wxListBox
,wxControl
)
231 wxListBox::wxListBox()
233 m_list
= (GtkList
*) NULL
;
234 #if wxUSE_CHECKLISTBOX
235 m_hasCheckBoxes
= FALSE
;
236 #endif // wxUSE_CHECKLISTBOX
239 bool wxListBox::Create( wxWindow
*parent
, wxWindowID id
,
240 const wxPoint
&pos
, const wxSize
&size
,
241 int n
, const wxString choices
[],
242 long style
, const wxValidator
& validator
, const wxString
&name
)
245 m_acceptsFocus
= TRUE
;
247 PreCreation( parent
, id
, pos
, size
, style
, name
);
250 SetValidator( validator
);
253 m_widget
= gtk_scrolled_window_new( (GtkAdjustment
*) NULL
, (GtkAdjustment
*) NULL
);
254 if (style
& wxLB_ALWAYS_SB
)
256 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
257 GTK_POLICY_AUTOMATIC
, GTK_POLICY_ALWAYS
);
261 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
262 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
265 m_list
= GTK_LIST( gtk_list_new() );
267 GtkSelectionMode mode
= GTK_SELECTION_BROWSE
;
268 if (style
& wxLB_MULTIPLE
)
269 mode
= GTK_SELECTION_MULTIPLE
;
270 else if (style
& wxLB_EXTENDED
)
271 mode
= GTK_SELECTION_EXTENDED
;
273 gtk_list_set_selection_mode( GTK_LIST(m_list
), mode
);
275 #ifdef NEW_GTK_SCROLL_CODE
276 gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget
), GTK_WIDGET(m_list
) );
278 gtk_container_add( GTK_CONTAINER(m_widget
), GTK_WIDGET(m_list
) );
281 gtk_widget_show( GTK_WIDGET(m_list
) );
283 wxSize newSize
= size
;
284 if (newSize
.x
== -1) newSize
.x
= 100;
285 if (newSize
.y
== -1) newSize
.y
= 110;
286 SetSize( newSize
.x
, newSize
.y
);
288 for (int i
= 0; i
< n
; i
++)
290 m_clientDataList
.Append( (wxObject
*) NULL
);
291 m_clientObjectList
.Append( (wxObject
*) NULL
);
293 GtkWidget
*list_item
;
295 wxString
str(choices
[i
]);
296 #if wxUSE_CHECKLISTBOX
299 str
.Prepend(CHECKBOX_STRING
);
301 #endif // wxUSE_CHECKLISTBOX
303 list_item
= gtk_list_item_new_with_label( str
.mbc_str() );
305 gtk_container_add( GTK_CONTAINER(m_list
), list_item
);
307 gtk_signal_connect( GTK_OBJECT(list_item
), "select",
308 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
310 if (style
& wxLB_MULTIPLE
)
311 gtk_signal_connect( GTK_OBJECT(list_item
), "deselect",
312 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
314 gtk_signal_connect( GTK_OBJECT(list_item
),
315 "button_press_event",
316 (GtkSignalFunc
)gtk_listbox_button_press_callback
,
319 gtk_signal_connect_after( GTK_OBJECT(list_item
),
320 "button_release_event",
321 (GtkSignalFunc
)gtk_listbox_button_release_callback
,
324 #if wxUSE_CHECKLISTBOX
327 gtk_signal_connect( GTK_OBJECT(list_item
),
329 (GtkSignalFunc
)gtk_listbox_key_press_callback
,
332 #endif // wxUSE_CHECKLISTBOX
334 ConnectWidget( list_item
);
336 gtk_widget_show( list_item
);
339 m_parent
->DoAddChild( this );
343 SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOW
) );
344 SetForegroundColour( parent
->GetForegroundColour() );
345 SetFont( parent
->GetFont() );
352 wxListBox::~wxListBox()
357 void wxListBox::InsertItems(int nItems
, const wxString items
[], int pos
)
359 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
361 GList
*children
= m_list
->children
;
362 int length
= g_list_length(children
);
363 wxCHECK_RET( pos
<= length
, _T("invalid index in wxListBox::InsertItems") );
365 // VZ: it seems that GTK 1.0.6 doesn't has a function to insert an item
366 // into a listbox at the given position, this is why we first delete
367 // all items after this position, then append these items and then
368 // reappend back the old ones.
370 // first detach the old items
375 // no need to do anything complicated
376 for ( n
= 0; n
< nItems
; n
++ )
384 wxArrayString deletedLabels
;
385 wxArrayPtrVoid deletedData
;
386 wxArrayInt deletedChecks
; // only for check list boxes
388 GList
*child
= g_list_nth( children
, pos
);
389 for ( n
= 0; child
!= NULL
; n
++, child
= child
->next
)
392 GtkBin
*bin
= GTK_BIN( child
->data
);
393 GtkLabel
*label
= GTK_LABEL( bin
->child
);
395 wxString
str(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
396 deletedLabels
.Add(str
);
399 void *clientData
= NULL
;
402 if ( n
< (int)m_clientObjectList
.GetCount() )
403 node
= m_clientObjectList
.Nth( n
);
407 clientData
= node
->GetData();
408 m_clientObjectList
.DeleteNode( node
);
413 if ( n
< (int)m_clientDataList
.GetCount() )
414 node
= m_clientDataList
.Nth( n
);
418 clientData
= node
->GetData();
419 node
= m_clientDataList
.Nth( n
);
423 deletedData
.Add(clientData
);
425 #if wxUSE_CHECKLISTBOX
427 if ( m_hasCheckBoxes
)
429 deletedChecks
.Add(((wxCheckListBox
*)this)->IsChecked(pos
+ n
));
431 #endif // wxUSE_CHECKLISTBOX
434 int nDeletedCount
= n
;
436 gtk_list_clear_items( m_list
, pos
, length
);
438 // now append the new items
439 for ( n
= 0; n
< nItems
; n
++ )
444 // and append the old items too
445 pos
+= nItems
; // now the indices are shifter
446 for ( n
= 0; n
< nDeletedCount
; n
++ )
448 Append(deletedLabels
[n
], deletedData
[n
]);
450 #if wxUSE_CHECKLISTBOX
451 if ( m_hasCheckBoxes
)
453 ((wxCheckListBox
*)this)->Check(pos
+ n
, (bool)deletedChecks
[n
]);
455 #endif // wxUSE_CHECKLISTBOX
459 void wxListBox::AppendCommon( const wxString
&item
)
461 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
463 GtkWidget
*list_item
;
465 wxString
label(item
);
466 #if wxUSE_CHECKLISTBOX
469 label
.Prepend(CHECKBOX_STRING
);
471 #endif // wxUSE_CHECKLISTBOX
473 list_item
= gtk_list_item_new_with_label( label
.mbc_str() );
475 gtk_container_add( GTK_CONTAINER(m_list
), list_item
);
477 gtk_signal_connect( GTK_OBJECT(list_item
), "select",
478 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
480 if (HasFlag(wxLB_MULTIPLE
))
481 gtk_signal_connect( GTK_OBJECT(list_item
), "deselect",
482 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
484 gtk_signal_connect( GTK_OBJECT(list_item
),
485 "button_press_event",
486 (GtkSignalFunc
)gtk_listbox_button_press_callback
,
489 gtk_signal_connect_after( GTK_OBJECT(list_item
),
490 "button_release_event",
491 (GtkSignalFunc
)gtk_listbox_button_release_callback
,
494 #if wxUSE_CHECKLISTBOX
497 gtk_signal_connect( GTK_OBJECT(list_item
),
499 (GtkSignalFunc
)gtk_listbox_key_press_callback
,
502 #endif // wxUSE_CHECKLISTBOX
504 gtk_widget_show( list_item
);
506 ConnectWidget( list_item
);
508 if (GTK_WIDGET_REALIZED(m_widget
))
510 gtk_widget_realize( list_item
);
511 gtk_widget_realize( GTK_BIN(list_item
)->child
);
513 if (m_widgetStyle
) ApplyWidgetStyle();
515 #if wxUSE_DRAG_AND_DROP
516 #ifndef NEW_GTK_DND_CODE
517 if (m_dropTarget
) m_dropTarget
->RegisterWidget( list_item
);
522 if (m_tooltip
) m_tooltip
->Apply( this );
527 void wxListBox::Append( const wxString
&item
)
529 m_clientDataList
.Append( (wxObject
*) NULL
);
530 m_clientObjectList
.Append( (wxObject
*) NULL
);
532 AppendCommon( item
);
535 void wxListBox::Append( const wxString
&item
, void *clientData
)
537 m_clientDataList
.Append( (wxObject
*) clientData
);
538 m_clientObjectList
.Append( (wxObject
*) NULL
);
540 AppendCommon( item
);
543 void wxListBox::Append( const wxString
&item
, wxClientData
*clientData
)
545 m_clientObjectList
.Append( (wxObject
*) clientData
);
546 m_clientDataList
.Append( (wxObject
*) NULL
);
548 AppendCommon( item
);
551 void wxListBox::SetClientData( int n
, void* clientData
)
553 wxCHECK_RET( m_widget
!= NULL
, _T("invalid combobox") );
555 wxNode
*node
= m_clientDataList
.Nth( n
);
558 node
->SetData( (wxObject
*) clientData
);
561 void* wxListBox::GetClientData( int n
)
563 wxCHECK_MSG( m_widget
!= NULL
, NULL
, _T("invalid combobox") );
565 wxNode
*node
= m_clientDataList
.Nth( n
);
566 if (!node
) return NULL
;
571 void wxListBox::SetClientObject( int n
, wxClientData
* clientData
)
573 wxCHECK_RET( m_widget
!= NULL
, _T("invalid combobox") );
575 wxNode
*node
= m_clientObjectList
.Nth( n
);
578 wxClientData
*cd
= (wxClientData
*) node
->Data();
581 node
->SetData( (wxObject
*) clientData
);
584 wxClientData
* wxListBox::GetClientObject( int n
)
586 wxCHECK_MSG( m_widget
!= NULL
, (wxClientData
*)NULL
, _T("invalid combobox") );
588 wxNode
*node
= m_clientObjectList
.Nth( n
);
589 if (!node
) return (wxClientData
*) NULL
;
591 return (wxClientData
*) node
->Data();
594 void wxListBox::Clear()
596 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
598 gtk_list_clear_items( m_list
, 0, Number() );
600 wxNode
*node
= m_clientObjectList
.First();
603 wxClientData
*cd
= (wxClientData
*)node
->Data();
607 m_clientObjectList
.Clear();
609 m_clientDataList
.Clear();
612 void wxListBox::Delete( int n
)
614 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
616 GList
*child
= g_list_nth( m_list
->children
, n
);
618 wxCHECK_RET( child
, _T("wrong listbox index") );
620 GList
*list
= g_list_append( (GList
*) NULL
, child
->data
);
621 gtk_list_remove_items( m_list
, list
);
624 wxNode
*node
= m_clientObjectList
.Nth( n
);
627 wxClientData
*cd
= (wxClientData
*)node
->Data();
629 m_clientObjectList
.DeleteNode( node
);
632 node
= m_clientDataList
.Nth( n
);
635 m_clientDataList
.DeleteNode( node
);
639 void wxListBox::Deselect( int n
)
641 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
643 gtk_list_unselect_item( m_list
, n
);
646 int wxListBox::FindString( const wxString
&item
) const
648 wxCHECK_MSG( m_list
!= NULL
, -1, _T("invalid listbox") );
650 GList
*child
= m_list
->children
;
654 GtkBin
*bin
= GTK_BIN( child
->data
);
655 GtkLabel
*label
= GTK_LABEL( bin
->child
);
657 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
666 // it's not an error if the string is not found -> no wxCHECK
671 int wxListBox::GetSelection() const
673 wxCHECK_MSG( m_list
!= NULL
, -1, _T("invalid listbox") );
675 GList
*child
= m_list
->children
;
679 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
) return count
;
686 int wxListBox::GetSelections( wxArrayInt
& aSelections
) const
688 wxCHECK_MSG( m_list
!= NULL
, -1, _T("invalid listbox") );
690 // get the number of selected items first
691 GList
*child
= m_list
->children
;
693 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
)
695 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
704 aSelections
.Alloc(count
); // optimization attempt
706 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
, i
++)
708 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
716 wxString
wxListBox::GetString( int n
) const
718 wxCHECK_MSG( m_list
!= NULL
, _T(""), _T("invalid listbox") );
720 GList
*child
= g_list_nth( m_list
->children
, n
);
723 GtkBin
*bin
= GTK_BIN( child
->data
);
724 GtkLabel
*label
= GTK_LABEL( bin
->child
);
726 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
731 wxFAIL_MSG(_T("wrong listbox index"));
736 wxString
wxListBox::GetStringSelection() const
738 wxCHECK_MSG( m_list
!= NULL
, _T(""), _T("invalid listbox") );
740 GList
*selection
= m_list
->selection
;
743 GtkBin
*bin
= GTK_BIN( selection
->data
);
744 GtkLabel
*label
= GTK_LABEL( bin
->child
);
746 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
751 wxFAIL_MSG(_T("no listbox selection available"));
755 int wxListBox::Number()
757 wxCHECK_MSG( m_list
!= NULL
, -1, _T("invalid listbox") );
759 GList
*child
= m_list
->children
;
761 while (child
) { count
++; child
= child
->next
; }
765 bool wxListBox::Selected( int n
)
767 wxCHECK_MSG( m_list
!= NULL
, FALSE
, _T("invalid listbox") );
769 GList
*target
= g_list_nth( m_list
->children
, n
);
772 GList
*child
= m_list
->selection
;
775 if (child
->data
== target
->data
) return TRUE
;
779 wxFAIL_MSG(_T("wrong listbox index"));
783 void wxListBox::Set( int WXUNUSED(n
), const wxString
*WXUNUSED(choices
) )
785 wxFAIL_MSG(_T("wxListBox::Set not implemented"));
788 void wxListBox::SetFirstItem( int WXUNUSED(n
) )
790 wxFAIL_MSG(_T("wxListBox::SetFirstItem not implemented"));
793 void wxListBox::SetFirstItem( const wxString
&WXUNUSED(item
) )
795 wxFAIL_MSG(_T("wxListBox::SetFirstItem not implemented"));
798 void wxListBox::SetSelection( int n
, bool select
)
800 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
803 gtk_list_select_item( m_list
, n
);
805 gtk_list_unselect_item( m_list
, n
);
808 void wxListBox::SetString( int n
, const wxString
&string
)
810 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
812 GList
*child
= g_list_nth( m_list
->children
, n
);
815 GtkBin
*bin
= GTK_BIN( child
->data
);
816 GtkLabel
*label
= GTK_LABEL( bin
->child
);
819 #if wxUSE_CHECKLISTBOX
821 str
+= CHECKBOX_STRING
;
822 #endif // wxUSE_CHECKLISTBOX
825 gtk_label_set( label
, str
.mbc_str() );
829 wxFAIL_MSG(_T("wrong listbox index"));
833 void wxListBox::SetStringSelection( const wxString
&string
, bool select
)
835 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
837 SetSelection( FindString(string
), select
);
840 int wxListBox::GetIndex( GtkWidget
*item
) const
844 GList
*child
= m_list
->children
;
848 if (GTK_WIDGET(child
->data
) == item
) return count
;
857 void wxListBox::ApplyToolTip( GtkTooltips
*tips
, const wxChar
*tip
)
859 GList
*child
= m_list
->children
;
862 gtk_tooltips_set_tip( tips
, GTK_WIDGET( child
->data
), wxConvLocal
.cWX2MB(tip
), (gchar
*) NULL
);
866 #endif // wxUSE_TOOLTIPS
868 #if wxUSE_DRAG_AND_DROP
869 void wxListBox::SetDropTarget( wxDropTarget
*dropTarget
)
871 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
873 #ifndef NEW_GTK_DND_CODE
876 GList
*child
= m_list
->children
;
879 m_dropTarget
->UnregisterWidget( GTK_WIDGET( child
->data
) );
885 wxWindow::SetDropTarget( dropTarget
);
887 #ifndef NEW_GTK_DND_CODE
890 GList
*child
= m_list
->children
;
893 m_dropTarget
->RegisterWidget( GTK_WIDGET( child
->data
) );
901 GtkWidget
*wxListBox::GetConnectWidget()
903 return GTK_WIDGET(m_list
);
906 bool wxListBox::IsOwnGtkWindow( GdkWindow
*window
)
908 if (wxWindow::IsOwnGtkWindow( window
)) return TRUE
;
910 GList
*child
= m_list
->children
;
913 GtkWidget
*bin
= GTK_WIDGET( child
->data
);
914 if (bin
->window
== window
) return TRUE
;
921 void wxListBox::ApplyWidgetStyle()
925 if (m_backgroundColour
.Ok())
927 GdkWindow
*window
= GTK_WIDGET(m_list
)->window
;
930 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( window
) );
931 gdk_window_set_background( window
, m_backgroundColour
.GetColor() );
932 gdk_window_clear( window
);
936 GList
*child
= m_list
->children
;
939 gtk_widget_set_style( GTK_WIDGET(child
->data
), m_widgetStyle
);
941 GtkBin
*bin
= GTK_BIN( child
->data
);
942 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
943 gtk_widget_set_style( label
, m_widgetStyle
);