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()->AddPendingEvent( event
);
257 // listbox->GetEventHandler()->ProcessEvent( event );
260 //-----------------------------------------------------------------------------
262 //-----------------------------------------------------------------------------
264 IMPLEMENT_DYNAMIC_CLASS(wxListBox
,wxControl
)
266 // ----------------------------------------------------------------------------
268 // ----------------------------------------------------------------------------
270 wxListBox::wxListBox()
272 m_list
= (GtkList
*) NULL
;
273 #if wxUSE_CHECKLISTBOX
274 m_hasCheckBoxes
= FALSE
;
275 #endif // wxUSE_CHECKLISTBOX
278 bool wxListBox::Create( wxWindow
*parent
, wxWindowID id
,
279 const wxPoint
&pos
, const wxSize
&size
,
280 int n
, const wxString choices
[],
281 long style
, const wxValidator
& validator
,
282 const wxString
&name
)
285 m_acceptsFocus
= TRUE
;
287 if (!PreCreation( parent
, pos
, size
) ||
288 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
290 wxFAIL_MSG( wxT("wxListBox creation failed") );
294 m_widget
= gtk_scrolled_window_new( (GtkAdjustment
*) NULL
, (GtkAdjustment
*) NULL
);
295 if (style
& wxLB_ALWAYS_SB
)
297 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
298 GTK_POLICY_AUTOMATIC
, GTK_POLICY_ALWAYS
);
302 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
303 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
306 m_list
= GTK_LIST( gtk_list_new() );
308 GtkSelectionMode mode
= GTK_SELECTION_BROWSE
;
309 if (style
& wxLB_MULTIPLE
)
310 mode
= GTK_SELECTION_MULTIPLE
;
311 else if (style
& wxLB_EXTENDED
)
312 mode
= GTK_SELECTION_EXTENDED
;
314 gtk_list_set_selection_mode( GTK_LIST(m_list
), mode
);
316 #ifdef NEW_GTK_SCROLL_CODE
317 gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget
), GTK_WIDGET(m_list
) );
319 gtk_container_add( GTK_CONTAINER(m_widget
), GTK_WIDGET(m_list
) );
322 /* make list scroll when moving the focus down using cursor keys */
323 gtk_container_set_focus_vadjustment(
324 GTK_CONTAINER(m_list
),
325 gtk_scrolled_window_get_vadjustment(
326 GTK_SCROLLED_WINDOW(m_widget
)));
328 gtk_widget_show( GTK_WIDGET(m_list
) );
330 SetSizeOrDefault( size
);
332 if ( style
& wxLB_SORT
)
334 // this will change DoAppend() behaviour
335 m_strings
= new wxSortedArrayString
;
339 m_strings
= (wxSortedArrayString
*)NULL
;
342 for (int i
= 0; i
< n
; i
++)
345 DoAppend(choices
[i
]);
348 m_parent
->DoAddChild( this );
352 SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX
) );
353 SetForegroundColour( parent
->GetForegroundColour() );
354 SetFont( parent
->GetFont() );
361 wxListBox::~wxListBox()
368 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
370 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
372 // VZ: notice that InsertItems knows nothing about sorting, so calling it
373 // from outside (and not from our own Append) is likely to break
376 // code elsewhere supposes we have as many items in m_clientList as items
378 wxASSERT_MSG( m_clientList
.GetCount() == (size_t)GetCount(),
379 wxT("bug in client data management") );
381 GList
*children
= m_list
->children
;
382 int length
= g_list_length(children
);
384 wxCHECK_RET( pos
<= length
, wxT("invalid index in wxListBox::InsertItems") );
386 size_t nItems
= items
.GetCount();
390 for ( size_t n
= 0; n
< nItems
; n
++ )
392 GtkAddItem( items
[n
] );
394 m_clientList
.Append((wxObject
*)NULL
);
399 wxNode
*node
= m_clientList
.Nth( pos
);
400 for ( size_t n
= 0; n
< nItems
; n
++ )
402 GtkAddItem( items
[n
], pos
+n
);
404 m_clientList
.Insert( node
, (wxObject
*)NULL
);
408 wxASSERT_MSG( m_clientList
.GetCount() == (size_t)GetCount(),
409 wxT("bug in client data management") );
412 int wxListBox::DoAppend( const wxString
& item
)
416 // need to determine the index
417 int index
= m_strings
->Add( item
);
419 // only if not at the end anyway
420 if (index
!= GetCount())
422 GtkAddItem( item
, index
);
424 wxNode
*node
= m_clientList
.Nth( index
);
425 m_clientList
.Insert( node
, (wxObject
*)NULL
);
433 m_clientList
.Append((wxObject
*)NULL
);
435 return GetCount() - 1;
438 void wxListBox::GtkAddItem( const wxString
&item
, int pos
)
440 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
442 GtkWidget
*list_item
;
444 wxString
label(item
);
445 #if wxUSE_CHECKLISTBOX
448 label
.Prepend(CHECKBOX_STRING
);
450 #endif // wxUSE_CHECKLISTBOX
452 list_item
= gtk_list_item_new_with_label( label
.mbc_str() );
454 GList
*gitem_list
= g_list_alloc ();
455 gitem_list
->data
= list_item
;
458 gtk_list_append_items( GTK_LIST (m_list
), gitem_list
);
460 gtk_list_insert_items( GTK_LIST (m_list
), gitem_list
, pos
);
462 gtk_signal_connect( GTK_OBJECT(list_item
), "select",
463 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
465 if (HasFlag(wxLB_MULTIPLE
))
466 gtk_signal_connect( GTK_OBJECT(list_item
), "deselect",
467 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
469 gtk_signal_connect( GTK_OBJECT(list_item
),
470 "button_press_event",
471 (GtkSignalFunc
)gtk_listbox_button_press_callback
,
474 gtk_signal_connect_after( GTK_OBJECT(list_item
),
475 "button_release_event",
476 (GtkSignalFunc
)gtk_listbox_button_release_callback
,
479 gtk_signal_connect( GTK_OBJECT(list_item
),
481 (GtkSignalFunc
)gtk_listbox_key_press_callback
,
484 ConnectWidget( list_item
);
486 gtk_widget_show( list_item
);
488 if (GTK_WIDGET_REALIZED(m_widget
))
490 gtk_widget_realize( list_item
);
491 gtk_widget_realize( GTK_BIN(list_item
)->child
);
493 // Apply current widget style to the new list_item
496 gtk_widget_set_style( GTK_WIDGET( list_item
), m_widgetStyle
);
497 GtkBin
*bin
= GTK_BIN( list_item
);
498 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
499 gtk_widget_set_style( label
, m_widgetStyle
);
503 if (m_tooltip
) m_tooltip
->Apply( this );
508 void wxListBox::DoSetItems( const wxArrayString
& items
,
513 DoInsertItems(items
, 0);
517 size_t count
= items
.GetCount();
518 for ( size_t n
= 0; n
< count
; n
++ )
520 SetClientData(n
, clientData
[n
]);
525 // ----------------------------------------------------------------------------
527 // ----------------------------------------------------------------------------
529 void wxListBox::DoSetItemClientData( int n
, void* clientData
)
531 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid listbox control") );
533 wxNode
*node
= m_clientList
.Nth( n
);
534 wxCHECK_RET( node
, wxT("invalid index in wxListBox::DoSetItemClientData") );
536 node
->SetData( (wxObject
*) clientData
);
539 void* wxListBox::DoGetItemClientData( int n
) const
541 wxCHECK_MSG( m_widget
!= NULL
, NULL
, wxT("invalid listbox control") );
543 wxNode
*node
= m_clientList
.Nth( n
);
544 wxCHECK_MSG( node
, NULL
, wxT("invalid index in wxListBox::DoGetItemClientData") );
549 void wxListBox::DoSetItemClientObject( int n
, wxClientData
* clientData
)
551 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid listbox control") );
553 wxNode
*node
= m_clientList
.Nth( n
);
554 wxCHECK_RET( node
, wxT("invalid index in wxListBox::DoSetItemClientObject") );
556 wxClientData
*cd
= (wxClientData
*) node
->Data();
559 node
->SetData( (wxObject
*) clientData
);
562 wxClientData
* wxListBox::DoGetItemClientObject( int n
) const
564 wxCHECK_MSG( m_widget
!= NULL
, (wxClientData
*) NULL
, wxT("invalid listbox control") );
566 wxNode
*node
= m_clientList
.Nth( n
);
567 wxCHECK_MSG( node
, (wxClientData
*)NULL
,
568 wxT("invalid index in wxListBox::DoGetItemClientObject") );
570 return (wxClientData
*) node
->Data();
573 void wxListBox::Clear()
575 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
577 gtk_list_clear_items( m_list
, 0, Number() );
579 if ( HasClientObjectData() )
581 // destroy the data (due to Robert's idea of using wxList<wxObject>
582 // and not wxList<wxClientData> we can't just say
583 // m_clientList.DeleteContents(TRUE) - this would crash!
584 wxNode
*node
= m_clientList
.First();
587 delete (wxClientData
*)node
->Data();
591 m_clientList
.Clear();
597 void wxListBox::Delete( int n
)
599 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
601 GList
*child
= g_list_nth( m_list
->children
, n
);
603 wxCHECK_RET( child
, wxT("wrong listbox index") );
605 GList
*list
= g_list_append( (GList
*) NULL
, child
->data
);
606 gtk_list_remove_items( m_list
, list
);
609 wxNode
*node
= m_clientList
.Nth( n
);
612 if ( m_clientDataItemsType
== ClientData_Object
)
614 wxClientData
*cd
= (wxClientData
*)node
->Data();
618 m_clientList
.DeleteNode( node
);
622 m_strings
->Remove(n
);
625 // ----------------------------------------------------------------------------
626 // string list access
627 // ----------------------------------------------------------------------------
629 void wxListBox::SetString( int n
, const wxString
&string
)
631 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
633 GList
*child
= g_list_nth( m_list
->children
, n
);
636 GtkBin
*bin
= GTK_BIN( child
->data
);
637 GtkLabel
*label
= GTK_LABEL( bin
->child
);
640 #if wxUSE_CHECKLISTBOX
642 str
+= CHECKBOX_STRING
;
643 #endif // wxUSE_CHECKLISTBOX
646 gtk_label_set( label
, str
.mbc_str() );
650 wxFAIL_MSG(wxT("wrong listbox index"));
654 wxString
wxListBox::GetString( int n
) const
656 wxCHECK_MSG( m_list
!= NULL
, wxT(""), wxT("invalid listbox") );
658 GList
*child
= g_list_nth( m_list
->children
, n
);
661 GtkBin
*bin
= GTK_BIN( child
->data
);
662 GtkLabel
*label
= GTK_LABEL( bin
->child
);
664 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
669 wxFAIL_MSG(wxT("wrong listbox index"));
674 int wxListBox::GetCount() const
676 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
678 GList
*children
= m_list
->children
;
679 return g_list_length(children
);
682 int wxListBox::FindString( const wxString
&item
) const
684 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
686 GList
*child
= m_list
->children
;
690 GtkBin
*bin
= GTK_BIN( child
->data
);
691 GtkLabel
*label
= GTK_LABEL( bin
->child
);
693 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
702 // it's not an error if the string is not found -> no wxCHECK
707 // ----------------------------------------------------------------------------
709 // ----------------------------------------------------------------------------
711 int wxListBox::GetSelection() const
713 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
715 GList
*child
= m_list
->children
;
719 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
) return count
;
726 int wxListBox::GetSelections( wxArrayInt
& aSelections
) const
728 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
730 // get the number of selected items first
731 GList
*child
= m_list
->children
;
733 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
)
735 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
744 aSelections
.Alloc(count
); // optimization attempt
746 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
, i
++)
748 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
756 bool wxListBox::IsSelected( int n
) const
758 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid listbox") );
760 GList
*target
= g_list_nth( m_list
->children
, n
);
762 wxCHECK_MSG( target
, FALSE
, wxT("invalid listbox index") );
764 return (GTK_WIDGET(target
->data
)->state
== GTK_STATE_SELECTED
) ;
767 void wxListBox::SetSelection( int n
, bool select
)
769 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
774 gtk_list_select_item( m_list
, n
);
776 gtk_list_unselect_item( m_list
, n
);
781 void wxListBox::DoSetFirstItem( int WXUNUSED(n
) )
783 wxFAIL_MSG(wxT("wxListBox::SetFirstItem not implemented"));
786 // ----------------------------------------------------------------------------
788 // ----------------------------------------------------------------------------
790 int wxListBox::GtkGetIndex( GtkWidget
*item
) const
794 GList
*child
= m_list
->children
;
798 if (GTK_WIDGET(child
->data
) == item
) return count
;
807 void wxListBox::ApplyToolTip( GtkTooltips
*tips
, const wxChar
*tip
)
809 GList
*child
= m_list
->children
;
812 gtk_tooltips_set_tip( tips
, GTK_WIDGET( child
->data
), wxConvCurrent
->cWX2MB(tip
), (gchar
*) NULL
);
816 #endif // wxUSE_TOOLTIPS
818 void wxListBox::GtkDisableEvents()
820 GList
*child
= m_list
->children
;
823 gtk_signal_disconnect_by_func( GTK_OBJECT(child
->data
),
824 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
826 if (HasFlag(wxLB_MULTIPLE
))
827 gtk_signal_disconnect_by_func( GTK_OBJECT(child
->data
),
828 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
834 void wxListBox::GtkEnableEvents()
836 GList
*child
= m_list
->children
;
839 gtk_signal_connect( GTK_OBJECT(child
->data
), "select",
840 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
842 if (HasFlag(wxLB_MULTIPLE
))
843 gtk_signal_connect( GTK_OBJECT(child
->data
), "deselect",
844 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
850 GtkWidget
*wxListBox::GetConnectWidget()
852 return GTK_WIDGET(m_list
);
855 bool wxListBox::IsOwnGtkWindow( GdkWindow
*window
)
857 if (GTK_WIDGET(m_list
)->window
== window
) return TRUE
;
859 GList
*child
= m_list
->children
;
862 GtkWidget
*bin
= GTK_WIDGET( child
->data
);
863 if (bin
->window
== window
) return TRUE
;
870 void wxListBox::ApplyWidgetStyle()
874 if (m_backgroundColour
.Ok())
876 GdkWindow
*window
= GTK_WIDGET(m_list
)->window
;
879 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( window
) );
880 gdk_window_set_background( window
, m_backgroundColour
.GetColor() );
881 gdk_window_clear( window
);
885 GList
*child
= m_list
->children
;
888 gtk_widget_set_style( GTK_WIDGET(child
->data
), m_widgetStyle
);
890 GtkBin
*bin
= GTK_BIN( child
->data
);
891 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
892 gtk_widget_set_style( label
, m_widgetStyle
);
898 void wxListBox::OnInternalIdle()
900 wxCursor cursor
= m_cursor
;
901 if (g_globalCursor
.Ok()) cursor
= g_globalCursor
;
903 if (GTK_WIDGET(m_list
)->window
&& cursor
.Ok())
905 /* I now set the cursor the anew in every OnInternalIdle call
906 as setting the cursor in a parent window also effects the
907 windows above so that checking for the current cursor is
910 gdk_window_set_cursor( GTK_WIDGET(m_list
)->window
, cursor
.GetCursor() );
912 GList
*child
= m_list
->children
;
915 GtkBin
*bin
= GTK_BIN( child
->data
);
916 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
921 gdk_window_set_cursor( label
->window
, cursor
.GetCursor() );
930 wxSize
wxListBox::DoGetBestSize() const
932 return wxSize(100, 110);