1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "listbox.h"
15 #include "wx/dynarray.h"
16 #include "wx/listbox.h"
19 #include "wx/checklst.h"
20 #include "wx/settings.h"
23 #include "wx/tooltip.h"
26 #if wxUSE_DRAG_AND_DROP
33 //-----------------------------------------------------------------------------
35 //-----------------------------------------------------------------------------
37 extern void wxapp_install_idle_handler();
40 //-------------------------------------------------------------------------
41 // conditional compilation
42 //-------------------------------------------------------------------------
44 #if (GTK_MINOR_VERSION > 0)
45 #define NEW_GTK_SCROLL_CODE
48 //-----------------------------------------------------------------------------
50 //-----------------------------------------------------------------------------
52 #if wxUSE_CHECKLISTBOX
54 #define CHECKBOX_STRING "[-] "
56 // checklistboxes have "[±] " prepended to their lables, this macro removes it
57 // (NB: 4 below is the length of CHECKBOX_STRING above)
59 // the argument to it is a "const char *" pointer
60 #define GET_REAL_LABEL(label) ((m_hasCheckBoxes)?(label)+4 : (label))
62 #else // !wxUSE_CHECKLISTBOX
64 #define GET_REAL_LABEL(label) (label)
66 #endif // wxUSE_CHECKLISTBOX
68 //-----------------------------------------------------------------------------
70 //-----------------------------------------------------------------------------
72 extern bool g_blockEventsOnDrag
;
73 extern bool g_blockEventsOnScroll
;
75 static bool g_hasDoubleClicked
= FALSE
;
77 //-----------------------------------------------------------------------------
78 // "button_release_event"
79 //-----------------------------------------------------------------------------
81 /* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once
82 a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the
83 listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event.
84 this can lead to race conditions so that we emit the dclick event
85 after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */
88 gtk_listbox_button_release_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxListBox
*listbox
)
90 if (g_isIdle
) wxapp_install_idle_handler();
92 if (g_blockEventsOnDrag
) return FALSE
;
93 if (g_blockEventsOnScroll
) return FALSE
;
95 if (!listbox
->m_hasVMT
) return FALSE
;
97 if (!g_hasDoubleClicked
) return FALSE
;
99 wxCommandEvent
event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, listbox
->GetId() );
100 event
.SetEventObject( listbox
);
102 wxArrayInt aSelections
;
103 int count
= listbox
->GetSelections(aSelections
);
106 event
.m_commandInt
= aSelections
[0] ;
107 event
.m_clientData
= listbox
->GetClientData( event
.m_commandInt
);
108 wxString
str(listbox
->GetString(event
.m_commandInt
));
109 if (!str
.IsEmpty()) event
.m_commandString
= str
;
113 event
.m_commandInt
= -1 ;
114 event
.m_commandString
.Empty();
117 listbox
->GetEventHandler()->ProcessEvent( event
);
122 //-----------------------------------------------------------------------------
123 // "button_press_event"
124 //-----------------------------------------------------------------------------
127 gtk_listbox_button_press_callback( GtkWidget
*widget
, GdkEventButton
*gdk_event
, wxListBox
*listbox
)
129 if (g_isIdle
) wxapp_install_idle_handler();
131 if (g_blockEventsOnDrag
) return FALSE
;
132 if (g_blockEventsOnScroll
) return FALSE
;
134 if (!listbox
->m_hasVMT
) return FALSE
;
136 int sel
= listbox
->GetIndex( widget
);
138 #if wxUSE_CHECKLISTBOX
139 if ((listbox
->m_hasCheckBoxes
) && (gdk_event
->x
< 15) && (gdk_event
->type
!= GDK_2BUTTON_PRESS
))
141 wxCheckListBox
*clb
= (wxCheckListBox
*)listbox
;
143 clb
->Check( sel
, !clb
->IsChecked(sel
) );
145 wxCommandEvent
event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, listbox
->GetId() );
146 event
.SetEventObject( listbox
);
148 listbox
->GetEventHandler()->ProcessEvent( event
);
150 #endif // wxUSE_CHECKLISTBOX
152 /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
153 g_hasDoubleClicked
= (gdk_event
->type
== GDK_2BUTTON_PRESS
);
158 //-----------------------------------------------------------------------------
160 //-----------------------------------------------------------------------------
163 gtk_listbox_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxListBox
*listbox
)
165 if (g_isIdle
) wxapp_install_idle_handler();
167 if (g_blockEventsOnDrag
) return FALSE
;
169 if (!listbox
->m_hasVMT
) return FALSE
;
171 if (gdk_event
->keyval
!= ' ') return FALSE
;
173 #if wxUSE_CHECKLISTBOX
174 int sel
= listbox
->GetIndex( widget
);
176 wxCheckListBox
*clb
= (wxCheckListBox
*)listbox
;
178 clb
->Check( sel
, !clb
->IsChecked(sel
) );
180 wxCommandEvent
event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, listbox
->GetId() );
181 event
.SetEventObject( listbox
);
183 listbox
->GetEventHandler()->ProcessEvent( event
);
184 #endif // wxUSE_CHECKLISTBOX
189 //-----------------------------------------------------------------------------
190 // "select" and "deselect"
191 //-----------------------------------------------------------------------------
193 static void gtk_listitem_select_callback( GtkWidget
*WXUNUSED(widget
), wxListBox
*listbox
)
195 if (g_isIdle
) wxapp_install_idle_handler();
197 if (!listbox
->m_hasVMT
) return;
198 if (g_blockEventsOnDrag
) return;
200 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, listbox
->GetId() );
202 wxArrayInt aSelections
;
203 int count
= listbox
->GetSelections(aSelections
);
206 event
.m_commandInt
= aSelections
[0] ;
207 event
.m_clientData
= listbox
->GetClientData( event
.m_commandInt
);
208 wxString
str(listbox
->GetString(event
.m_commandInt
));
209 if (!str
.IsEmpty()) event
.m_commandString
= str
;
213 event
.m_commandInt
= -1 ;
214 event
.m_commandString
.Empty();
217 event
.SetEventObject( listbox
);
219 listbox
->GetEventHandler()->ProcessEvent( event
);
222 //-----------------------------------------------------------------------------
224 //-----------------------------------------------------------------------------
226 IMPLEMENT_DYNAMIC_CLASS(wxListBox
,wxControl
)
228 wxListBox::wxListBox()
230 m_list
= (GtkList
*) NULL
;
231 #if wxUSE_CHECKLISTBOX
232 m_hasCheckBoxes
= FALSE
;
233 #endif // wxUSE_CHECKLISTBOX
236 bool wxListBox::Create( wxWindow
*parent
, wxWindowID id
,
237 const wxPoint
&pos
, const wxSize
&size
,
238 int n
, const wxString choices
[],
239 long style
, const wxValidator
& validator
, const wxString
&name
)
242 m_acceptsFocus
= TRUE
;
244 PreCreation( parent
, id
, pos
, size
, style
, name
);
246 SetValidator( validator
);
248 m_widget
= gtk_scrolled_window_new( (GtkAdjustment
*) NULL
, (GtkAdjustment
*) NULL
);
249 if (style
& wxLB_ALWAYS_SB
)
251 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
252 GTK_POLICY_AUTOMATIC
, GTK_POLICY_ALWAYS
);
256 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
257 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
260 m_list
= GTK_LIST( gtk_list_new() );
262 GtkSelectionMode mode
= GTK_SELECTION_BROWSE
;
263 if (style
& wxLB_MULTIPLE
)
264 mode
= GTK_SELECTION_MULTIPLE
;
265 else if (style
& wxLB_EXTENDED
)
266 mode
= GTK_SELECTION_EXTENDED
;
268 gtk_list_set_selection_mode( GTK_LIST(m_list
), mode
);
270 #ifdef NEW_GTK_SCROLL_CODE
271 gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget
), GTK_WIDGET(m_list
) );
273 gtk_container_add( GTK_CONTAINER(m_widget
), GTK_WIDGET(m_list
) );
276 gtk_widget_show( GTK_WIDGET(m_list
) );
278 wxSize newSize
= size
;
279 if (newSize
.x
== -1) newSize
.x
= 100;
280 if (newSize
.y
== -1) newSize
.y
= 110;
281 SetSize( newSize
.x
, newSize
.y
);
283 for (int i
= 0; i
< n
; i
++)
285 m_clientDataList
.Append( (wxObject
*) NULL
);
286 m_clientObjectList
.Append( (wxObject
*) NULL
);
288 GtkWidget
*list_item
;
290 wxString
str(choices
[i
]);
291 #if wxUSE_CHECKLISTBOX
294 str
.Prepend(CHECKBOX_STRING
);
296 #endif // wxUSE_CHECKLISTBOX
298 list_item
= gtk_list_item_new_with_label( str
.mbc_str() );
300 gtk_container_add( GTK_CONTAINER(m_list
), list_item
);
302 gtk_signal_connect( GTK_OBJECT(list_item
), "select",
303 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
305 if (style
& wxLB_MULTIPLE
)
306 gtk_signal_connect( GTK_OBJECT(list_item
), "deselect",
307 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
309 gtk_signal_connect( GTK_OBJECT(list_item
),
310 "button_press_event",
311 (GtkSignalFunc
)gtk_listbox_button_press_callback
,
314 gtk_signal_connect_after( GTK_OBJECT(list_item
),
315 "button_release_event",
316 (GtkSignalFunc
)gtk_listbox_button_release_callback
,
319 #if wxUSE_CHECKLISTBOX
322 gtk_signal_connect( GTK_OBJECT(list_item
),
324 (GtkSignalFunc
)gtk_listbox_key_press_callback
,
327 #endif // wxUSE_CHECKLISTBOX
329 ConnectWidget( list_item
);
331 gtk_widget_show( list_item
);
334 m_parent
->DoAddChild( this );
338 SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOW
) );
339 SetForegroundColour( parent
->GetForegroundColour() );
340 SetFont( parent
->GetFont() );
347 wxListBox::~wxListBox()
352 void wxListBox::InsertItems(int nItems
, const wxString items
[], int pos
)
354 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
356 GList
*children
= m_list
->children
;
357 int length
= g_list_length(children
);
358 wxCHECK_RET( pos
<= length
, _T("invalid index in wxListBox::InsertItems") );
360 // VZ: it seems that GTK 1.0.6 doesn't has a function to insert an item
361 // into a listbox at the given position, this is why we first delete
362 // all items after this position, then append these items and then
363 // reappend back the old ones.
365 // first detach the old items
370 // no need to do anything complicated
371 for ( n
= 0; n
< nItems
; n
++ )
379 wxArrayString deletedLabels
;
380 wxArrayPtrVoid deletedData
;
381 wxArrayInt deletedChecks
; // only for check list boxes
383 GList
*child
= g_list_nth( children
, pos
);
384 for ( n
= 0; child
!= NULL
; n
++, child
= child
->next
)
387 GtkBin
*bin
= GTK_BIN( child
->data
);
388 GtkLabel
*label
= GTK_LABEL( bin
->child
);
390 wxString
str(GET_REAL_LABEL(label
->label
));
391 deletedLabels
.Add(str
);
394 void *clientData
= NULL
;
397 if ( n
< (int)m_clientObjectList
.GetCount() )
398 node
= m_clientObjectList
.Nth( n
);
402 clientData
= node
->GetData();
403 m_clientObjectList
.DeleteNode( node
);
408 if ( n
< (int)m_clientDataList
.GetCount() )
409 node
= m_clientDataList
.Nth( n
);
413 clientData
= node
->GetData();
414 node
= m_clientDataList
.Nth( n
);
418 deletedData
.Add(clientData
);
420 #if wxUSE_CHECKLISTBOX
422 if ( m_hasCheckBoxes
)
424 deletedChecks
.Add(((wxCheckListBox
*)this)->IsChecked(pos
+ n
));
426 #endif // wxUSE_CHECKLISTBOX
429 int nDeletedCount
= n
;
431 gtk_list_clear_items( m_list
, pos
, length
);
433 // now append the new items
434 for ( n
= 0; n
< nItems
; n
++ )
439 // and append the old items too
440 pos
+= nItems
; // now the indices are shifter
441 for ( n
= 0; n
< nDeletedCount
; n
++ )
443 Append(deletedLabels
[n
], deletedData
[n
]);
445 #if wxUSE_CHECKLISTBOX
446 if ( m_hasCheckBoxes
)
448 ((wxCheckListBox
*)this)->Check(pos
+ n
, (bool)deletedChecks
[n
]);
450 #endif // wxUSE_CHECKLISTBOX
454 void wxListBox::AppendCommon( const wxString
&item
)
456 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
458 GtkWidget
*list_item
;
460 wxString
label(item
);
461 #if wxUSE_CHECKLISTBOX
464 label
.Prepend(CHECKBOX_STRING
);
466 #endif // wxUSE_CHECKLISTBOX
468 list_item
= gtk_list_item_new_with_label( label
.mbc_str() );
470 gtk_container_add( GTK_CONTAINER(m_list
), list_item
);
472 gtk_signal_connect( GTK_OBJECT(list_item
), "select",
473 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
475 if (HasFlag(wxLB_MULTIPLE
))
476 gtk_signal_connect( GTK_OBJECT(list_item
), "deselect",
477 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
479 gtk_signal_connect( GTK_OBJECT(list_item
),
480 "button_press_event",
481 (GtkSignalFunc
)gtk_listbox_button_press_callback
,
484 gtk_signal_connect_after( GTK_OBJECT(list_item
),
485 "button_release_event",
486 (GtkSignalFunc
)gtk_listbox_button_release_callback
,
489 #if wxUSE_CHECKLISTBOX
492 gtk_signal_connect( GTK_OBJECT(list_item
),
494 (GtkSignalFunc
)gtk_listbox_key_press_callback
,
497 #endif // wxUSE_CHECKLISTBOX
499 gtk_widget_show( list_item
);
501 ConnectWidget( list_item
);
503 if (GTK_WIDGET_REALIZED(m_widget
))
505 gtk_widget_realize( list_item
);
506 gtk_widget_realize( GTK_BIN(list_item
)->child
);
508 if (m_widgetStyle
) ApplyWidgetStyle();
510 #if wxUSE_DRAG_AND_DROP
511 #ifndef NEW_GTK_DND_CODE
512 if (m_dropTarget
) m_dropTarget
->RegisterWidget( list_item
);
517 if (m_tooltip
) m_tooltip
->Apply( this );
522 void wxListBox::Append( const wxString
&item
)
524 m_clientDataList
.Append( (wxObject
*) NULL
);
525 m_clientObjectList
.Append( (wxObject
*) NULL
);
527 AppendCommon( item
);
530 void wxListBox::Append( const wxString
&item
, void *clientData
)
532 m_clientDataList
.Append( (wxObject
*) clientData
);
533 m_clientObjectList
.Append( (wxObject
*) NULL
);
535 AppendCommon( item
);
538 void wxListBox::Append( const wxString
&item
, wxClientData
*clientData
)
540 m_clientObjectList
.Append( (wxObject
*) clientData
);
541 m_clientDataList
.Append( (wxObject
*) NULL
);
543 AppendCommon( item
);
546 void wxListBox::SetClientData( int n
, void* clientData
)
548 wxCHECK_RET( m_widget
!= NULL
, _T("invalid combobox") );
550 wxNode
*node
= m_clientDataList
.Nth( n
);
553 node
->SetData( (wxObject
*) clientData
);
556 void* wxListBox::GetClientData( int n
)
558 wxCHECK_MSG( m_widget
!= NULL
, NULL
, _T("invalid combobox") );
560 wxNode
*node
= m_clientDataList
.Nth( n
);
561 if (!node
) return NULL
;
566 void wxListBox::SetClientObject( int n
, wxClientData
* clientData
)
568 wxCHECK_RET( m_widget
!= NULL
, _T("invalid combobox") );
570 wxNode
*node
= m_clientObjectList
.Nth( n
);
573 wxClientData
*cd
= (wxClientData
*) node
->Data();
576 node
->SetData( (wxObject
*) clientData
);
579 wxClientData
* wxListBox::GetClientObject( int n
)
581 wxCHECK_MSG( m_widget
!= NULL
, (wxClientData
*)NULL
, _T("invalid combobox") );
583 wxNode
*node
= m_clientObjectList
.Nth( n
);
584 if (!node
) return (wxClientData
*) NULL
;
586 return (wxClientData
*) node
->Data();
589 void wxListBox::Clear()
591 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
593 gtk_list_clear_items( m_list
, 0, Number() );
595 wxNode
*node
= m_clientObjectList
.First();
598 wxClientData
*cd
= (wxClientData
*)node
->Data();
602 m_clientObjectList
.Clear();
604 m_clientDataList
.Clear();
607 void wxListBox::Delete( int n
)
609 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
611 GList
*child
= g_list_nth( m_list
->children
, n
);
613 wxCHECK_RET( child
, _T("wrong listbox index") );
615 GList
*list
= g_list_append( (GList
*) NULL
, child
->data
);
616 gtk_list_remove_items( m_list
, list
);
619 wxNode
*node
= m_clientObjectList
.Nth( n
);
622 wxClientData
*cd
= (wxClientData
*)node
->Data();
624 m_clientObjectList
.DeleteNode( node
);
627 node
= m_clientDataList
.Nth( n
);
630 m_clientDataList
.DeleteNode( node
);
634 void wxListBox::Deselect( int n
)
636 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
638 gtk_list_unselect_item( m_list
, n
);
641 int wxListBox::FindString( const wxString
&item
) const
643 wxCHECK_MSG( m_list
!= NULL
, -1, _T("invalid listbox") );
645 GList
*child
= m_list
->children
;
649 GtkBin
*bin
= GTK_BIN( child
->data
);
650 GtkLabel
*label
= GTK_LABEL( bin
->child
);
652 wxString str
= GET_REAL_LABEL(label
->label
);
661 // it's not an error if the string is not found -> no wxCHECK
666 int wxListBox::GetSelection() const
668 wxCHECK_MSG( m_list
!= NULL
, -1, _T("invalid listbox") );
670 GList
*child
= m_list
->children
;
674 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
) return count
;
681 int wxListBox::GetSelections( wxArrayInt
& aSelections
) const
683 wxCHECK_MSG( m_list
!= NULL
, -1, _T("invalid listbox") );
685 // get the number of selected items first
686 GList
*child
= m_list
->children
;
688 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
)
690 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
699 aSelections
.Alloc(count
); // optimization attempt
701 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
, i
++)
703 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
711 wxString
wxListBox::GetString( int n
) const
713 wxCHECK_MSG( m_list
!= NULL
, _T(""), _T("invalid listbox") );
715 GList
*child
= g_list_nth( m_list
->children
, n
);
718 GtkBin
*bin
= GTK_BIN( child
->data
);
719 GtkLabel
*label
= GTK_LABEL( bin
->child
);
721 wxString str
= GET_REAL_LABEL(label
->label
);
726 wxFAIL_MSG(_T("wrong listbox index"));
731 wxString
wxListBox::GetStringSelection() const
733 wxCHECK_MSG( m_list
!= NULL
, _T(""), _T("invalid listbox") );
735 GList
*selection
= m_list
->selection
;
738 GtkBin
*bin
= GTK_BIN( selection
->data
);
739 GtkLabel
*label
= GTK_LABEL( bin
->child
);
741 wxString str
= GET_REAL_LABEL(label
->label
);
746 wxFAIL_MSG(_T("no listbox selection available"));
750 int wxListBox::Number()
752 wxCHECK_MSG( m_list
!= NULL
, -1, _T("invalid listbox") );
754 GList
*child
= m_list
->children
;
756 while (child
) { count
++; child
= child
->next
; }
760 bool wxListBox::Selected( int n
)
762 wxCHECK_MSG( m_list
!= NULL
, FALSE
, _T("invalid listbox") );
764 GList
*target
= g_list_nth( m_list
->children
, n
);
767 GList
*child
= m_list
->selection
;
770 if (child
->data
== target
->data
) return TRUE
;
774 wxFAIL_MSG(_T("wrong listbox index"));
778 void wxListBox::Set( int WXUNUSED(n
), const wxString
*WXUNUSED(choices
) )
780 wxFAIL_MSG(_T("wxListBox::Set not implemented"));
783 void wxListBox::SetFirstItem( int WXUNUSED(n
) )
785 wxFAIL_MSG(_T("wxListBox::SetFirstItem not implemented"));
788 void wxListBox::SetFirstItem( const wxString
&WXUNUSED(item
) )
790 wxFAIL_MSG(_T("wxListBox::SetFirstItem not implemented"));
793 void wxListBox::SetSelection( int n
, bool select
)
795 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
798 gtk_list_select_item( m_list
, n
);
800 gtk_list_unselect_item( m_list
, n
);
803 void wxListBox::SetString( int n
, const wxString
&string
)
805 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
807 GList
*child
= g_list_nth( m_list
->children
, n
);
810 GtkBin
*bin
= GTK_BIN( child
->data
);
811 GtkLabel
*label
= GTK_LABEL( bin
->child
);
814 #if wxUSE_CHECKLISTBOX
816 str
+= CHECKBOX_STRING
;
817 #endif // wxUSE_CHECKLISTBOX
820 gtk_label_set( label
, str
.mbc_str() );
824 wxFAIL_MSG(_T("wrong listbox index"));
828 void wxListBox::SetStringSelection( const wxString
&string
, bool select
)
830 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
832 SetSelection( FindString(string
), select
);
835 int wxListBox::GetIndex( GtkWidget
*item
) const
839 GList
*child
= m_list
->children
;
843 if (GTK_WIDGET(child
->data
) == item
) return count
;
852 void wxListBox::ApplyToolTip( GtkTooltips
*tips
, const wxChar
*tip
)
854 GList
*child
= m_list
->children
;
857 gtk_tooltips_set_tip( tips
, GTK_WIDGET( child
->data
), wxConv_local
.cWX2MB(tip
), (gchar
*) NULL
);
861 #endif // wxUSE_TOOLTIPS
863 #if wxUSE_DRAG_AND_DROP
864 void wxListBox::SetDropTarget( wxDropTarget
*dropTarget
)
866 wxCHECK_RET( m_list
!= NULL
, _T("invalid listbox") );
868 #ifndef NEW_GTK_DND_CODE
871 GList
*child
= m_list
->children
;
874 m_dropTarget
->UnregisterWidget( GTK_WIDGET( child
->data
) );
880 wxWindow::SetDropTarget( dropTarget
);
882 #ifndef NEW_GTK_DND_CODE
885 GList
*child
= m_list
->children
;
888 m_dropTarget
->RegisterWidget( GTK_WIDGET( child
->data
) );
896 GtkWidget
*wxListBox::GetConnectWidget()
898 return GTK_WIDGET(m_list
);
901 bool wxListBox::IsOwnGtkWindow( GdkWindow
*window
)
903 if (wxWindow::IsOwnGtkWindow( window
)) return TRUE
;
905 GList
*child
= m_list
->children
;
908 GtkWidget
*bin
= GTK_WIDGET( child
->data
);
909 if (bin
->window
== window
) return TRUE
;
916 void wxListBox::ApplyWidgetStyle()
920 if (m_backgroundColour
.Ok())
922 GdkWindow
*window
= GTK_WIDGET(m_list
)->window
;
925 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( window
) );
926 gdk_window_set_background( window
, m_backgroundColour
.GetColor() );
927 gdk_window_clear( window
);
931 GList
*child
= m_list
->children
;
934 gtk_widget_set_style( GTK_WIDGET(child
->data
), m_widgetStyle
);
936 GtkBin
*bin
= GTK_BIN( child
->data
);
937 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
938 gtk_widget_set_style( label
, m_widgetStyle
);