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"
31 #include "gdk/gdkkeysyms.h"
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
;
74 extern wxCursor g_globalCursor
;
76 static bool g_hasDoubleClicked
= FALSE
;
78 //-----------------------------------------------------------------------------
79 // "button_release_event"
80 //-----------------------------------------------------------------------------
82 /* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once
83 a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the
84 listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event.
85 this can lead to race conditions so that we emit the dclick event
86 after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */
89 gtk_listbox_button_release_callback( GtkWidget
* WXUNUSED(widget
),
90 GdkEventButton
* WXUNUSED(gdk_event
),
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 n
, count
= listbox
->GetSelections(aSelections
);
110 if ( listbox
->HasClientObjectData() )
111 event
.SetClientObject( listbox
->GetClientObject(n
) );
112 else if ( listbox
->HasClientUntypedData() )
113 event
.SetClientData( listbox
->GetClientData(n
) );
114 event
.SetString( listbox
->GetString(n
) );
121 event
.m_commandInt
= n
;
123 listbox
->GetEventHandler()->ProcessEvent( event
);
128 //-----------------------------------------------------------------------------
129 // "button_press_event"
130 //-----------------------------------------------------------------------------
133 gtk_listbox_button_press_callback( GtkWidget
*widget
,
134 GdkEventButton
*gdk_event
,
137 if (g_isIdle
) wxapp_install_idle_handler();
139 if (g_blockEventsOnDrag
) return FALSE
;
140 if (g_blockEventsOnScroll
) return FALSE
;
142 if (!listbox
->m_hasVMT
) return FALSE
;
144 int sel
= listbox
->GtkGetIndex( widget
);
146 #if wxUSE_CHECKLISTBOX
147 if ((listbox
->m_hasCheckBoxes
) && (gdk_event
->x
< 15) && (gdk_event
->type
!= GDK_2BUTTON_PRESS
))
149 wxCheckListBox
*clb
= (wxCheckListBox
*)listbox
;
151 clb
->Check( sel
, !clb
->IsChecked(sel
) );
153 wxCommandEvent
event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, listbox
->GetId() );
154 event
.SetEventObject( listbox
);
156 listbox
->GetEventHandler()->ProcessEvent( event
);
158 #endif // wxUSE_CHECKLISTBOX
160 /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
161 g_hasDoubleClicked
= (gdk_event
->type
== GDK_2BUTTON_PRESS
);
166 //-----------------------------------------------------------------------------
168 //-----------------------------------------------------------------------------
171 gtk_listbox_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxListBox
*listbox
)
174 wxapp_install_idle_handler();
176 if (g_blockEventsOnDrag
)
181 if ((gdk_event
->keyval
== GDK_Tab
) || (gdk_event
->keyval
== GDK_ISO_Left_Tab
))
183 wxNavigationKeyEvent new_event
;
184 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
185 new_event
.SetDirection( (gdk_event
->keyval
== GDK_Tab
) );
186 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
187 new_event
.SetWindowChange( (gdk_event
->state
& GDK_CONTROL_MASK
) );
188 new_event
.SetCurrentFocus( listbox
);
189 ret
= listbox
->GetEventHandler()->ProcessEvent( new_event
);
192 #if wxUSE_CHECKLISTBOX
193 if ((gdk_event
->keyval
!= ' ') && (listbox
->m_hasCheckBoxes
) && (!ret
))
195 int sel
= listbox
->GtkGetIndex( widget
);
197 wxCheckListBox
*clb
= (wxCheckListBox
*)listbox
;
199 clb
->Check( sel
, !clb
->IsChecked(sel
) );
201 wxCommandEvent
new_event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, listbox
->GetId() );
202 new_event
.SetEventObject( listbox
);
203 new_event
.SetInt( sel
);
204 ret
= listbox
->GetEventHandler()->ProcessEvent( new_event
);
206 #endif // wxUSE_CHECKLISTBOX
210 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_press_event" );
217 //-----------------------------------------------------------------------------
218 // "select" and "deselect"
219 //-----------------------------------------------------------------------------
221 static void gtk_listitem_select_callback( GtkWidget
*WXUNUSED(widget
), wxListBox
*listbox
);
223 static void gtk_listitem_deselect_callback( GtkWidget
*widget
, wxListBox
*listbox
)
225 gtk_listitem_select_callback( widget
, listbox
);
228 static void gtk_listitem_select_callback( GtkWidget
*WXUNUSED(widget
), wxListBox
*listbox
)
230 if (g_isIdle
) wxapp_install_idle_handler();
232 if (!listbox
->m_hasVMT
) return;
233 if (g_blockEventsOnDrag
) return;
235 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, listbox
->GetId() );
236 event
.SetEventObject( listbox
);
238 wxArrayInt aSelections
;
239 int n
, count
= listbox
->GetSelections(aSelections
);
243 if ( listbox
->HasClientObjectData() )
244 event
.SetClientObject( listbox
->GetClientObject(n
) );
245 else if ( listbox
->HasClientUntypedData() )
246 event
.SetClientData( listbox
->GetClientData(n
) );
247 event
.SetString( listbox
->GetString(n
) );
254 event
.m_commandInt
= n
;
256 listbox
->GetEventHandler()->ProcessEvent( event
);
259 //-----------------------------------------------------------------------------
261 //-----------------------------------------------------------------------------
263 IMPLEMENT_DYNAMIC_CLASS(wxListBox
,wxControl
)
265 // ----------------------------------------------------------------------------
267 // ----------------------------------------------------------------------------
269 wxListBox::wxListBox()
271 m_list
= (GtkList
*) NULL
;
272 #if wxUSE_CHECKLISTBOX
273 m_hasCheckBoxes
= FALSE
;
274 #endif // wxUSE_CHECKLISTBOX
277 bool wxListBox::Create( wxWindow
*parent
, wxWindowID id
,
278 const wxPoint
&pos
, const wxSize
&size
,
279 int n
, const wxString choices
[],
280 long style
, const wxValidator
& validator
,
281 const wxString
&name
)
284 m_acceptsFocus
= TRUE
;
286 if (!PreCreation( parent
, pos
, size
) ||
287 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
289 wxFAIL_MSG( wxT("wxListBox creation failed") );
293 m_widget
= gtk_scrolled_window_new( (GtkAdjustment
*) NULL
, (GtkAdjustment
*) NULL
);
294 if (style
& wxLB_ALWAYS_SB
)
296 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
297 GTK_POLICY_AUTOMATIC
, GTK_POLICY_ALWAYS
);
301 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
302 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
305 m_list
= GTK_LIST( gtk_list_new() );
307 GtkSelectionMode mode
= GTK_SELECTION_BROWSE
;
308 if (style
& wxLB_MULTIPLE
)
309 mode
= GTK_SELECTION_MULTIPLE
;
310 else if (style
& wxLB_EXTENDED
)
311 mode
= GTK_SELECTION_EXTENDED
;
313 gtk_list_set_selection_mode( GTK_LIST(m_list
), mode
);
315 #ifdef NEW_GTK_SCROLL_CODE
316 gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget
), GTK_WIDGET(m_list
) );
318 gtk_container_add( GTK_CONTAINER(m_widget
), GTK_WIDGET(m_list
) );
321 /* make list scroll when moving the focus down using cursor keys */
322 gtk_container_set_focus_vadjustment(
323 GTK_CONTAINER(m_list
),
324 gtk_scrolled_window_get_vadjustment(
325 GTK_SCROLLED_WINDOW(m_widget
)));
327 gtk_widget_show( GTK_WIDGET(m_list
) );
329 wxSize newSize
= size
;
334 SetSize( newSize
.x
, newSize
.y
);
336 if ( style
& wxLB_SORT
)
338 // this will change DoAppend() behaviour
339 m_strings
= new wxSortedArrayString
;
343 m_strings
= (wxSortedArrayString
*)NULL
;
346 for (int i
= 0; i
< n
; i
++)
349 DoAppend(choices
[i
]);
352 m_parent
->DoAddChild( this );
356 SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_WINDOW
) );
357 SetForegroundColour( parent
->GetForegroundColour() );
358 SetFont( parent
->GetFont() );
365 wxListBox::~wxListBox()
370 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
372 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
374 // VZ: notice that InsertItems knows nothing about sorting, so calling it
375 // from outside (and not from our own Append) is likely to break
378 // code elsewhere supposes we have as many items in m_clientList as items
380 wxASSERT_MSG( m_clientList
.GetCount() == (size_t)GetCount(),
381 wxT("bug in client data management") );
383 GList
*children
= m_list
->children
;
384 int length
= g_list_length(children
);
386 wxCHECK_RET( pos
<= length
, wxT("invalid index in wxListBox::InsertItems") );
388 size_t nItems
= items
.GetCount();
392 for ( size_t n
= 0; n
< nItems
; n
++ )
394 GtkAddItem( items
[n
] );
396 m_clientList
.Append((wxObject
*)NULL
);
401 wxNode
*node
= m_clientList
.Nth( pos
);
402 for ( size_t n
= 0; n
< nItems
; n
++ )
404 GtkAddItem( items
[n
], pos
+n
);
406 m_clientList
.Insert( node
, (wxObject
*)NULL
);
410 wxASSERT_MSG( m_clientList
.GetCount() == (size_t)GetCount(),
411 wxT("bug in client data management") );
414 int wxListBox::DoAppend( const wxString
& item
)
418 // need to determine the index
419 int index
= m_strings
->Add( item
);
421 // only if not at the end anyway
422 if (index
!= GetCount())
424 GtkAddItem( item
, index
);
426 wxNode
*node
= m_clientList
.Nth( index
);
427 m_clientList
.Insert( node
, (wxObject
*)NULL
);
435 m_clientList
.Append((wxObject
*)NULL
);
437 return GetCount() - 1;
440 void wxListBox::GtkAddItem( const wxString
&item
, int pos
)
442 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
444 GtkWidget
*list_item
;
446 wxString
label(item
);
447 #if wxUSE_CHECKLISTBOX
450 label
.Prepend(CHECKBOX_STRING
);
452 #endif // wxUSE_CHECKLISTBOX
454 list_item
= gtk_list_item_new_with_label( label
.mbc_str() );
456 GList
*gitem_list
= g_list_alloc ();
457 gitem_list
->data
= list_item
;
460 gtk_list_append_items( GTK_LIST (m_list
), gitem_list
);
462 gtk_list_insert_items( GTK_LIST (m_list
), gitem_list
, pos
);
464 gtk_signal_connect( GTK_OBJECT(list_item
), "select",
465 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
467 if (HasFlag(wxLB_MULTIPLE
))
468 gtk_signal_connect( GTK_OBJECT(list_item
), "deselect",
469 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
471 gtk_signal_connect( GTK_OBJECT(list_item
),
472 "button_press_event",
473 (GtkSignalFunc
)gtk_listbox_button_press_callback
,
476 gtk_signal_connect_after( GTK_OBJECT(list_item
),
477 "button_release_event",
478 (GtkSignalFunc
)gtk_listbox_button_release_callback
,
481 gtk_signal_connect( GTK_OBJECT(list_item
),
483 (GtkSignalFunc
)gtk_listbox_key_press_callback
,
486 gtk_widget_show( list_item
);
488 ConnectWidget( list_item
);
490 if (GTK_WIDGET_REALIZED(m_widget
))
492 gtk_widget_realize( list_item
);
493 gtk_widget_realize( GTK_BIN(list_item
)->child
);
495 // Apply current widget style to the new list_item
498 gtk_widget_set_style( GTK_WIDGET( list_item
), m_widgetStyle
);
499 GtkBin
*bin
= GTK_BIN( list_item
);
500 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
501 gtk_widget_set_style( label
, m_widgetStyle
);
505 if (m_tooltip
) m_tooltip
->Apply( this );
510 void wxListBox::DoSetItems( const wxArrayString
& items
,
515 DoInsertItems(items
, 0);
519 size_t count
= items
.GetCount();
520 for ( size_t n
= 0; n
< count
; n
++ )
522 SetClientData(n
, clientData
[n
]);
527 // ----------------------------------------------------------------------------
529 // ----------------------------------------------------------------------------
531 void wxListBox::DoSetItemClientData( int n
, void* clientData
)
533 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid listbox control") );
535 wxNode
*node
= m_clientList
.Nth( n
);
536 wxCHECK_RET( node
, wxT("invalid index in wxListBox::DoSetItemClientData") );
538 node
->SetData( (wxObject
*) clientData
);
541 void* wxListBox::DoGetItemClientData( int n
) const
543 wxCHECK_MSG( m_widget
!= NULL
, NULL
, wxT("invalid listbox control") );
545 wxNode
*node
= m_clientList
.Nth( n
);
546 wxCHECK_MSG( node
, NULL
, wxT("invalid index in wxListBox::DoGetItemClientData") );
551 void wxListBox::DoSetItemClientObject( int n
, wxClientData
* clientData
)
553 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid listbox control") );
555 wxNode
*node
= m_clientList
.Nth( n
);
556 wxCHECK_RET( node
, wxT("invalid index in wxListBox::DoSetItemClientObject") );
558 wxClientData
*cd
= (wxClientData
*) node
->Data();
561 node
->SetData( (wxObject
*) clientData
);
564 wxClientData
* wxListBox::DoGetItemClientObject( int n
) const
566 wxCHECK_MSG( m_widget
!= NULL
, (wxClientData
*) NULL
, wxT("invalid listbox control") );
568 wxNode
*node
= m_clientList
.Nth( n
);
569 wxCHECK_MSG( node
, (wxClientData
*)NULL
,
570 wxT("invalid index in wxListBox::DoGetItemClientObject") );
572 return (wxClientData
*) node
->Data();
575 void wxListBox::Clear()
577 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
579 gtk_list_clear_items( m_list
, 0, Number() );
581 if ( HasClientObjectData() )
583 // destroy the data (due to Robert's idea of using wxList<wxObject>
584 // and not wxList<wxClientData> we can't just say
585 // m_clientList.DeleteContents(TRUE) - this would crash!
586 wxNode
*node
= m_clientList
.First();
589 delete (wxClientData
*)node
->Data();
593 m_clientList
.Clear();
599 void wxListBox::Delete( int n
)
601 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
603 GList
*child
= g_list_nth( m_list
->children
, n
);
605 wxCHECK_RET( child
, wxT("wrong listbox index") );
607 GList
*list
= g_list_append( (GList
*) NULL
, child
->data
);
608 gtk_list_remove_items( m_list
, list
);
611 wxNode
*node
= m_clientList
.Nth( n
);
614 if ( m_clientDataItemsType
== ClientData_Object
)
616 wxClientData
*cd
= (wxClientData
*)node
->Data();
620 m_clientList
.DeleteNode( node
);
624 m_strings
->Remove(n
);
627 // ----------------------------------------------------------------------------
628 // string list access
629 // ----------------------------------------------------------------------------
631 void wxListBox::SetString( int n
, const wxString
&string
)
633 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
635 GList
*child
= g_list_nth( m_list
->children
, n
);
638 GtkBin
*bin
= GTK_BIN( child
->data
);
639 GtkLabel
*label
= GTK_LABEL( bin
->child
);
642 #if wxUSE_CHECKLISTBOX
644 str
+= CHECKBOX_STRING
;
645 #endif // wxUSE_CHECKLISTBOX
648 gtk_label_set( label
, str
.mbc_str() );
652 wxFAIL_MSG(wxT("wrong listbox index"));
656 wxString
wxListBox::GetString( int n
) const
658 wxCHECK_MSG( m_list
!= NULL
, wxT(""), wxT("invalid listbox") );
660 GList
*child
= g_list_nth( m_list
->children
, n
);
663 GtkBin
*bin
= GTK_BIN( child
->data
);
664 GtkLabel
*label
= GTK_LABEL( bin
->child
);
666 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
671 wxFAIL_MSG(wxT("wrong listbox index"));
676 int wxListBox::GetCount() const
678 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
680 GList
*children
= m_list
->children
;
681 return g_list_length(children
);
684 int wxListBox::FindString( const wxString
&item
) const
686 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
688 GList
*child
= m_list
->children
;
692 GtkBin
*bin
= GTK_BIN( child
->data
);
693 GtkLabel
*label
= GTK_LABEL( bin
->child
);
695 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
704 // it's not an error if the string is not found -> no wxCHECK
709 // ----------------------------------------------------------------------------
711 // ----------------------------------------------------------------------------
713 int wxListBox::GetSelection() const
715 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
717 GList
*child
= m_list
->children
;
721 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
) return count
;
728 int wxListBox::GetSelections( wxArrayInt
& aSelections
) const
730 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
732 // get the number of selected items first
733 GList
*child
= m_list
->children
;
735 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
)
737 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
746 aSelections
.Alloc(count
); // optimization attempt
748 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
, i
++)
750 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
758 bool wxListBox::IsSelected( int n
) const
760 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid listbox") );
762 GList
*target
= g_list_nth( m_list
->children
, n
);
765 GList
*child
= m_list
->selection
;
768 if (child
->data
== target
->data
) return TRUE
;
773 wxFAIL_MSG(wxT("wrong listbox index"));
778 void wxListBox::SetSelection( int n
, bool select
)
780 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
785 gtk_list_select_item( m_list
, n
);
787 gtk_list_unselect_item( m_list
, n
);
792 void wxListBox::DoSetFirstItem( int WXUNUSED(n
) )
794 wxFAIL_MSG(wxT("wxListBox::SetFirstItem not implemented"));
797 // ----------------------------------------------------------------------------
799 // ----------------------------------------------------------------------------
801 int wxListBox::GtkGetIndex( GtkWidget
*item
) const
805 GList
*child
= m_list
->children
;
809 if (GTK_WIDGET(child
->data
) == item
) return count
;
818 void wxListBox::ApplyToolTip( GtkTooltips
*tips
, const wxChar
*tip
)
820 GList
*child
= m_list
->children
;
823 gtk_tooltips_set_tip( tips
, GTK_WIDGET( child
->data
), wxConvCurrent
->cWX2MB(tip
), (gchar
*) NULL
);
827 #endif // wxUSE_TOOLTIPS
829 void wxListBox::GtkDisableEvents()
831 GList
*child
= m_list
->children
;
834 gtk_signal_disconnect_by_func( GTK_OBJECT(child
->data
),
835 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
837 if (HasFlag(wxLB_MULTIPLE
))
838 gtk_signal_disconnect_by_func( GTK_OBJECT(child
->data
),
839 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
845 void wxListBox::GtkEnableEvents()
847 GList
*child
= m_list
->children
;
850 gtk_signal_connect( GTK_OBJECT(child
->data
), "select",
851 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
853 if (HasFlag(wxLB_MULTIPLE
))
854 gtk_signal_connect( GTK_OBJECT(child
->data
), "deselect",
855 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
861 GtkWidget
*wxListBox::GetConnectWidget()
863 return GTK_WIDGET(m_list
);
866 bool wxListBox::IsOwnGtkWindow( GdkWindow
*window
)
868 if (wxWindow::IsOwnGtkWindow( window
)) return TRUE
;
870 GList
*child
= m_list
->children
;
873 GtkWidget
*bin
= GTK_WIDGET( child
->data
);
874 if (bin
->window
== window
) return TRUE
;
881 void wxListBox::ApplyWidgetStyle()
885 if (m_backgroundColour
.Ok())
887 GdkWindow
*window
= GTK_WIDGET(m_list
)->window
;
890 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( window
) );
891 gdk_window_set_background( window
, m_backgroundColour
.GetColor() );
892 gdk_window_clear( window
);
896 GList
*child
= m_list
->children
;
899 gtk_widget_set_style( GTK_WIDGET(child
->data
), m_widgetStyle
);
901 GtkBin
*bin
= GTK_BIN( child
->data
);
902 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
903 gtk_widget_set_style( label
, m_widgetStyle
);
909 void wxListBox::OnInternalIdle()
911 wxCursor cursor
= m_cursor
;
912 if (g_globalCursor
.Ok()) cursor
= g_globalCursor
;
914 if (GTK_WIDGET(m_list
)->window
&& cursor
.Ok())
916 /* I now set the cursor the anew in every OnInternalIdle call
917 as setting the cursor in a parent window also effects the
918 windows above so that checking for the current cursor is
921 gdk_window_set_cursor( GTK_WIDGET(m_list
)->window
, cursor
.GetCursor() );
923 GList
*child
= m_list
->children
;
926 GtkBin
*bin
= GTK_BIN( child
->data
);
927 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
932 gdk_window_set_cursor( label
->window
, cursor
.GetCursor() );