1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
12 #pragma implementation "listbox.h"
16 #define gtk_scrolled_window_add_with_viewport gtk_scrolled_window_add_with_vi
17 #define gtk_container_set_focus_vadjustment gtk_container_set_focus_vadjust
18 #define gtk_scrolled_window_get_vadjustment gtk_scrolled_window_get_vadjust
21 #include "wx/listbox.h"
25 #include "wx/dynarray.h"
28 #include "wx/checklst.h"
29 #include "wx/settings.h"
32 #include "wx/tooltip.h"
37 #include <gdk/gdkkeysyms.h>
39 //-----------------------------------------------------------------------------
41 //-----------------------------------------------------------------------------
43 extern void wxapp_install_idle_handler();
46 //-------------------------------------------------------------------------
47 // conditional compilation
48 //-------------------------------------------------------------------------
50 #if (GTK_MINOR_VERSION > 0)
51 #define NEW_GTK_SCROLL_CODE
54 //-----------------------------------------------------------------------------
56 //-----------------------------------------------------------------------------
58 #if wxUSE_CHECKLISTBOX
60 #define CHECKBOX_STRING "[-] "
62 // checklistboxes have "[±] " prepended to their lables, this macro removes it
63 // (NB: 4 below is the length of CHECKBOX_STRING above)
65 // the argument to it is a "const char *" pointer
66 #define GET_REAL_LABEL(label) ((m_hasCheckBoxes)?(label)+4 : (label))
68 #else // !wxUSE_CHECKLISTBOX
70 #define GET_REAL_LABEL(label) (label)
72 #endif // wxUSE_CHECKLISTBOX
74 //-----------------------------------------------------------------------------
76 //-----------------------------------------------------------------------------
78 extern bool g_blockEventsOnDrag
;
79 extern bool g_blockEventsOnScroll
;
80 extern wxCursor g_globalCursor
;
82 static bool g_hasDoubleClicked
= FALSE
;
84 //-----------------------------------------------------------------------------
85 // "button_release_event"
86 //-----------------------------------------------------------------------------
88 /* we would normally emit a wxEVT_COMMAND_LISTBOX_DOUBLECLICKED event once
89 a GDK_2BUTTON_PRESS occurs, but this has the particular problem of the
90 listbox keeping the focus until it receives a GDK_BUTTON_RELEASE event.
91 this can lead to race conditions so that we emit the dclick event
92 after the GDK_BUTTON_RELEASE event after the GDK_2BUTTON_PRESS event */
95 gtk_listbox_button_release_callback( GtkWidget
* WXUNUSED(widget
),
96 GdkEventButton
* WXUNUSED(gdk_event
),
99 if (g_isIdle
) wxapp_install_idle_handler();
101 if (g_blockEventsOnDrag
) return FALSE
;
102 if (g_blockEventsOnScroll
) return FALSE
;
104 if (!listbox
->m_hasVMT
) return FALSE
;
106 if (!g_hasDoubleClicked
) return FALSE
;
108 wxCommandEvent
event( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED
, listbox
->GetId() );
109 event
.SetEventObject( listbox
);
111 wxArrayInt aSelections
;
112 int n
, count
= listbox
->GetSelections(aSelections
);
116 if ( listbox
->HasClientObjectData() )
117 event
.SetClientObject( listbox
->GetClientObject(n
) );
118 else if ( listbox
->HasClientUntypedData() )
119 event
.SetClientData( listbox
->GetClientData(n
) );
120 event
.SetString( listbox
->GetString(n
) );
127 event
.m_commandInt
= n
;
129 listbox
->GetEventHandler()->ProcessEvent( event
);
134 //-----------------------------------------------------------------------------
135 // "button_press_event"
136 //-----------------------------------------------------------------------------
139 gtk_listbox_button_press_callback( GtkWidget
*widget
,
140 GdkEventButton
*gdk_event
,
143 if (g_isIdle
) wxapp_install_idle_handler();
145 if (g_blockEventsOnDrag
) return FALSE
;
146 if (g_blockEventsOnScroll
) return FALSE
;
148 if (!listbox
->m_hasVMT
) return FALSE
;
150 int sel
= listbox
->GtkGetIndex( widget
);
152 #if wxUSE_CHECKLISTBOX
153 if ((listbox
->m_hasCheckBoxes
) && (gdk_event
->x
< 15) && (gdk_event
->type
!= GDK_2BUTTON_PRESS
))
155 wxCheckListBox
*clb
= (wxCheckListBox
*)listbox
;
157 clb
->Check( sel
, !clb
->IsChecked(sel
) );
159 wxCommandEvent
event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, listbox
->GetId() );
160 event
.SetEventObject( listbox
);
162 listbox
->GetEventHandler()->ProcessEvent( event
);
164 #endif // wxUSE_CHECKLISTBOX
166 /* emit wxEVT_COMMAND_LISTBOX_DOUBLECLICKED later */
167 g_hasDoubleClicked
= (gdk_event
->type
== GDK_2BUTTON_PRESS
);
172 //-----------------------------------------------------------------------------
174 //-----------------------------------------------------------------------------
177 gtk_listbox_key_press_callback( GtkWidget
*widget
, GdkEventKey
*gdk_event
, wxListBox
*listbox
)
180 wxapp_install_idle_handler();
182 if (g_blockEventsOnDrag
)
187 if ((gdk_event
->keyval
== GDK_Tab
) || (gdk_event
->keyval
== GDK_ISO_Left_Tab
))
189 wxNavigationKeyEvent new_event
;
190 /* GDK reports GDK_ISO_Left_Tab for SHIFT-TAB */
191 new_event
.SetDirection( (gdk_event
->keyval
== GDK_Tab
) );
192 /* CTRL-TAB changes the (parent) window, i.e. switch notebook page */
193 new_event
.SetWindowChange( (gdk_event
->state
& GDK_CONTROL_MASK
) );
194 new_event
.SetCurrentFocus( listbox
);
195 ret
= listbox
->GetEventHandler()->ProcessEvent( new_event
);
198 #if wxUSE_CHECKLISTBOX
199 if ((gdk_event
->keyval
== ' ') && (listbox
->m_hasCheckBoxes
) && (!ret
))
201 int sel
= listbox
->GtkGetIndex( widget
);
203 wxCheckListBox
*clb
= (wxCheckListBox
*)listbox
;
205 clb
->Check( sel
, !clb
->IsChecked(sel
) );
207 wxCommandEvent
new_event( wxEVT_COMMAND_CHECKLISTBOX_TOGGLED
, listbox
->GetId() );
208 new_event
.SetEventObject( listbox
);
209 new_event
.SetInt( sel
);
210 ret
= listbox
->GetEventHandler()->ProcessEvent( new_event
);
212 #endif // wxUSE_CHECKLISTBOX
216 gtk_signal_emit_stop_by_name( GTK_OBJECT(widget
), "key_press_event" );
223 //-----------------------------------------------------------------------------
224 // "select" and "deselect"
225 //-----------------------------------------------------------------------------
227 static void gtk_listitem_select_callback( GtkWidget
*WXUNUSED(widget
), wxListBox
*listbox
);
229 static void gtk_listitem_deselect_callback( GtkWidget
*widget
, wxListBox
*listbox
)
231 gtk_listitem_select_callback( widget
, listbox
);
234 static void gtk_listitem_select_callback( GtkWidget
*WXUNUSED(widget
), wxListBox
*listbox
)
236 if (g_isIdle
) wxapp_install_idle_handler();
238 if (!listbox
->m_hasVMT
) return;
239 if (g_blockEventsOnDrag
) return;
241 wxCommandEvent
event(wxEVT_COMMAND_LISTBOX_SELECTED
, listbox
->GetId() );
242 event
.SetEventObject( listbox
);
244 wxArrayInt aSelections
;
245 int n
, count
= listbox
->GetSelections(aSelections
);
249 if ( listbox
->HasClientObjectData() )
250 event
.SetClientObject( listbox
->GetClientObject(n
) );
251 else if ( listbox
->HasClientUntypedData() )
252 event
.SetClientData( listbox
->GetClientData(n
) );
253 event
.SetString( listbox
->GetString(n
) );
260 event
.m_commandInt
= n
;
262 listbox
->GetEventHandler()->AddPendingEvent( event
);
263 // listbox->GetEventHandler()->ProcessEvent( event );
266 //-----------------------------------------------------------------------------
268 //-----------------------------------------------------------------------------
270 IMPLEMENT_DYNAMIC_CLASS(wxListBox
,wxControl
)
272 // ----------------------------------------------------------------------------
274 // ----------------------------------------------------------------------------
276 wxListBox::wxListBox()
278 m_list
= (GtkList
*) NULL
;
279 #if wxUSE_CHECKLISTBOX
280 m_hasCheckBoxes
= FALSE
;
281 #endif // wxUSE_CHECKLISTBOX
284 bool wxListBox::Create( wxWindow
*parent
, wxWindowID id
,
285 const wxPoint
&pos
, const wxSize
&size
,
286 int n
, const wxString choices
[],
287 long style
, const wxValidator
& validator
,
288 const wxString
&name
)
291 m_acceptsFocus
= TRUE
;
293 if (!PreCreation( parent
, pos
, size
) ||
294 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
296 wxFAIL_MSG( wxT("wxListBox creation failed") );
300 m_widget
= gtk_scrolled_window_new( (GtkAdjustment
*) NULL
, (GtkAdjustment
*) NULL
);
301 if (style
& wxLB_ALWAYS_SB
)
303 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
304 GTK_POLICY_AUTOMATIC
, GTK_POLICY_ALWAYS
);
308 gtk_scrolled_window_set_policy( GTK_SCROLLED_WINDOW(m_widget
),
309 GTK_POLICY_AUTOMATIC
, GTK_POLICY_AUTOMATIC
);
312 m_list
= GTK_LIST( gtk_list_new() );
314 GtkSelectionMode mode
= GTK_SELECTION_BROWSE
;
315 if (style
& wxLB_MULTIPLE
)
316 mode
= GTK_SELECTION_MULTIPLE
;
317 else if (style
& wxLB_EXTENDED
)
318 mode
= GTK_SELECTION_EXTENDED
;
320 gtk_list_set_selection_mode( GTK_LIST(m_list
), mode
);
322 #ifdef NEW_GTK_SCROLL_CODE
323 gtk_scrolled_window_add_with_viewport( GTK_SCROLLED_WINDOW(m_widget
), GTK_WIDGET(m_list
) );
325 gtk_container_add( GTK_CONTAINER(m_widget
), GTK_WIDGET(m_list
) );
328 /* make list scroll when moving the focus down using cursor keys */
329 gtk_container_set_focus_vadjustment(
330 GTK_CONTAINER(m_list
),
331 gtk_scrolled_window_get_vadjustment(
332 GTK_SCROLLED_WINDOW(m_widget
)));
334 gtk_widget_show( GTK_WIDGET(m_list
) );
336 SetSizeOrDefault( size
);
338 if ( style
& wxLB_SORT
)
340 // this will change DoAppend() behaviour
341 m_strings
= new wxSortedArrayString
;
345 m_strings
= (wxSortedArrayString
*)NULL
;
348 for (int i
= 0; i
< n
; i
++)
351 DoAppend(choices
[i
]);
354 m_parent
->DoAddChild( this );
358 SetBackgroundColour( wxSystemSettings::GetSystemColour( wxSYS_COLOUR_LISTBOX
) );
359 SetForegroundColour( parent
->GetForegroundColour() );
360 SetFont( parent
->GetFont() );
367 wxListBox::~wxListBox()
372 void wxListBox::DoInsertItems(const wxArrayString
& items
, int pos
)
374 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
376 // VZ: notice that InsertItems knows nothing about sorting, so calling it
377 // from outside (and not from our own Append) is likely to break
380 // code elsewhere supposes we have as many items in m_clientList as items
382 wxASSERT_MSG( m_clientList
.GetCount() == (size_t)GetCount(),
383 wxT("bug in client data management") );
385 GList
*children
= m_list
->children
;
386 int length
= g_list_length(children
);
388 wxCHECK_RET( pos
<= length
, wxT("invalid index in wxListBox::InsertItems") );
390 size_t nItems
= items
.GetCount();
394 for ( size_t n
= 0; n
< nItems
; n
++ )
396 GtkAddItem( items
[n
] );
398 m_clientList
.Append((wxObject
*)NULL
);
403 wxNode
*node
= m_clientList
.Nth( pos
);
404 for ( size_t n
= 0; n
< nItems
; n
++ )
406 GtkAddItem( items
[n
], pos
+n
);
408 m_clientList
.Insert( node
, (wxObject
*)NULL
);
412 wxASSERT_MSG( m_clientList
.GetCount() == (size_t)GetCount(),
413 wxT("bug in client data management") );
416 int wxListBox::DoAppend( const wxString
& item
)
420 // need to determine the index
421 int index
= m_strings
->Add( item
);
423 // only if not at the end anyway
424 if (index
!= GetCount())
426 GtkAddItem( item
, index
);
428 wxNode
*node
= m_clientList
.Nth( index
);
429 m_clientList
.Insert( node
, (wxObject
*)NULL
);
437 m_clientList
.Append((wxObject
*)NULL
);
439 return GetCount() - 1;
442 void wxListBox::GtkAddItem( const wxString
&item
, int pos
)
444 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
446 GtkWidget
*list_item
;
448 wxString
label(item
);
449 #if wxUSE_CHECKLISTBOX
452 label
.Prepend(CHECKBOX_STRING
);
454 #endif // wxUSE_CHECKLISTBOX
456 list_item
= gtk_list_item_new_with_label( label
.mbc_str() );
458 GList
*gitem_list
= g_list_alloc ();
459 gitem_list
->data
= list_item
;
462 gtk_list_append_items( GTK_LIST (m_list
), gitem_list
);
464 gtk_list_insert_items( GTK_LIST (m_list
), gitem_list
, pos
);
466 gtk_signal_connect( GTK_OBJECT(list_item
), "select",
467 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
469 if (HasFlag(wxLB_MULTIPLE
))
470 gtk_signal_connect( GTK_OBJECT(list_item
), "deselect",
471 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
473 gtk_signal_connect( GTK_OBJECT(list_item
),
474 "button_press_event",
475 (GtkSignalFunc
)gtk_listbox_button_press_callback
,
478 gtk_signal_connect_after( GTK_OBJECT(list_item
),
479 "button_release_event",
480 (GtkSignalFunc
)gtk_listbox_button_release_callback
,
483 gtk_signal_connect( GTK_OBJECT(list_item
),
485 (GtkSignalFunc
)gtk_listbox_key_press_callback
,
488 ConnectWidget( list_item
);
490 gtk_widget_show( list_item
);
492 if (GTK_WIDGET_REALIZED(m_widget
))
494 gtk_widget_realize( list_item
);
495 gtk_widget_realize( GTK_BIN(list_item
)->child
);
497 // Apply current widget style to the new list_item
500 gtk_widget_set_style( GTK_WIDGET( list_item
), m_widgetStyle
);
501 GtkBin
*bin
= GTK_BIN( list_item
);
502 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
503 gtk_widget_set_style( label
, m_widgetStyle
);
507 if (m_tooltip
) m_tooltip
->Apply( this );
512 void wxListBox::DoSetItems( const wxArrayString
& items
,
517 DoInsertItems(items
, 0);
521 size_t count
= items
.GetCount();
522 for ( size_t n
= 0; n
< count
; n
++ )
524 SetClientData(n
, clientData
[n
]);
529 // ----------------------------------------------------------------------------
531 // ----------------------------------------------------------------------------
533 void wxListBox::DoSetItemClientData( int n
, void* clientData
)
535 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid listbox control") );
537 wxNode
*node
= m_clientList
.Nth( n
);
538 wxCHECK_RET( node
, wxT("invalid index in wxListBox::DoSetItemClientData") );
540 node
->SetData( (wxObject
*) clientData
);
543 void* wxListBox::DoGetItemClientData( int n
) const
545 wxCHECK_MSG( m_widget
!= NULL
, NULL
, wxT("invalid listbox control") );
547 wxNode
*node
= m_clientList
.Nth( n
);
548 wxCHECK_MSG( node
, NULL
, wxT("invalid index in wxListBox::DoGetItemClientData") );
553 void wxListBox::DoSetItemClientObject( int n
, wxClientData
* clientData
)
555 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid listbox control") );
557 wxNode
*node
= m_clientList
.Nth( n
);
558 wxCHECK_RET( node
, wxT("invalid index in wxListBox::DoSetItemClientObject") );
560 wxClientData
*cd
= (wxClientData
*) node
->Data();
563 node
->SetData( (wxObject
*) clientData
);
566 wxClientData
* wxListBox::DoGetItemClientObject( int n
) const
568 wxCHECK_MSG( m_widget
!= NULL
, (wxClientData
*) NULL
, wxT("invalid listbox control") );
570 wxNode
*node
= m_clientList
.Nth( n
);
571 wxCHECK_MSG( node
, (wxClientData
*)NULL
,
572 wxT("invalid index in wxListBox::DoGetItemClientObject") );
574 return (wxClientData
*) node
->Data();
577 void wxListBox::Clear()
579 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
581 gtk_list_clear_items( m_list
, 0, Number() );
583 if ( HasClientObjectData() )
585 // destroy the data (due to Robert's idea of using wxList<wxObject>
586 // and not wxList<wxClientData> we can't just say
587 // m_clientList.DeleteContents(TRUE) - this would crash!
588 wxNode
*node
= m_clientList
.First();
591 delete (wxClientData
*)node
->Data();
595 m_clientList
.Clear();
601 void wxListBox::Delete( int n
)
603 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
605 GList
*child
= g_list_nth( m_list
->children
, n
);
607 wxCHECK_RET( child
, wxT("wrong listbox index") );
609 GList
*list
= g_list_append( (GList
*) NULL
, child
->data
);
610 gtk_list_remove_items( m_list
, list
);
613 wxNode
*node
= m_clientList
.Nth( n
);
616 if ( m_clientDataItemsType
== ClientData_Object
)
618 wxClientData
*cd
= (wxClientData
*)node
->Data();
622 m_clientList
.DeleteNode( node
);
626 m_strings
->Remove(n
);
629 // ----------------------------------------------------------------------------
630 // string list access
631 // ----------------------------------------------------------------------------
633 void wxListBox::SetString( int n
, const wxString
&string
)
635 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
637 GList
*child
= g_list_nth( m_list
->children
, n
);
640 GtkBin
*bin
= GTK_BIN( child
->data
);
641 GtkLabel
*label
= GTK_LABEL( bin
->child
);
644 #if wxUSE_CHECKLISTBOX
646 str
+= CHECKBOX_STRING
;
647 #endif // wxUSE_CHECKLISTBOX
650 gtk_label_set( label
, str
.mbc_str() );
654 wxFAIL_MSG(wxT("wrong listbox index"));
658 wxString
wxListBox::GetString( int n
) const
660 wxCHECK_MSG( m_list
!= NULL
, wxT(""), wxT("invalid listbox") );
662 GList
*child
= g_list_nth( m_list
->children
, n
);
665 GtkBin
*bin
= GTK_BIN( child
->data
);
666 GtkLabel
*label
= GTK_LABEL( bin
->child
);
668 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
673 wxFAIL_MSG(wxT("wrong listbox index"));
678 int wxListBox::GetCount() const
680 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
682 GList
*children
= m_list
->children
;
683 return g_list_length(children
);
686 int wxListBox::FindString( const wxString
&item
) const
688 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
690 GList
*child
= m_list
->children
;
694 GtkBin
*bin
= GTK_BIN( child
->data
);
695 GtkLabel
*label
= GTK_LABEL( bin
->child
);
697 wxString str
= wxString(GET_REAL_LABEL(label
->label
),*wxConvCurrent
);
706 // it's not an error if the string is not found -> no wxCHECK
711 // ----------------------------------------------------------------------------
713 // ----------------------------------------------------------------------------
715 int wxListBox::GetSelection() const
717 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
719 GList
*child
= m_list
->children
;
723 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
) return count
;
730 int wxListBox::GetSelections( wxArrayInt
& aSelections
) const
732 wxCHECK_MSG( m_list
!= NULL
, -1, wxT("invalid listbox") );
734 // get the number of selected items first
735 GList
*child
= m_list
->children
;
737 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
)
739 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
748 aSelections
.Alloc(count
); // optimization attempt
750 for (child
= m_list
->children
; child
!= NULL
; child
= child
->next
, i
++)
752 if (GTK_WIDGET(child
->data
)->state
== GTK_STATE_SELECTED
)
760 bool wxListBox::IsSelected( int n
) const
762 wxCHECK_MSG( m_list
!= NULL
, FALSE
, wxT("invalid listbox") );
764 GList
*target
= g_list_nth( m_list
->children
, n
);
766 wxCHECK_MSG( target
, FALSE
, wxT("invalid listbox index") );
768 return (GTK_WIDGET(target
->data
)->state
== GTK_STATE_SELECTED
) ;
771 void wxListBox::SetSelection( int n
, bool select
)
773 wxCHECK_RET( m_list
!= NULL
, wxT("invalid listbox") );
778 gtk_list_select_item( m_list
, n
);
780 gtk_list_unselect_item( m_list
, n
);
785 void wxListBox::DoSetFirstItem( int WXUNUSED(n
) )
787 wxFAIL_MSG(wxT("wxListBox::SetFirstItem not implemented"));
790 // ----------------------------------------------------------------------------
792 // ----------------------------------------------------------------------------
794 int wxListBox::GtkGetIndex( GtkWidget
*item
) const
798 GList
*child
= m_list
->children
;
802 if (GTK_WIDGET(child
->data
) == item
) return count
;
811 void wxListBox::ApplyToolTip( GtkTooltips
*tips
, const wxChar
*tip
)
813 GList
*child
= m_list
->children
;
816 gtk_tooltips_set_tip( tips
, GTK_WIDGET( child
->data
), wxConvCurrent
->cWX2MB(tip
), (gchar
*) NULL
);
820 #endif // wxUSE_TOOLTIPS
822 void wxListBox::GtkDisableEvents()
824 GList
*child
= m_list
->children
;
827 gtk_signal_disconnect_by_func( GTK_OBJECT(child
->data
),
828 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
830 if (HasFlag(wxLB_MULTIPLE
))
831 gtk_signal_disconnect_by_func( GTK_OBJECT(child
->data
),
832 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
838 void wxListBox::GtkEnableEvents()
840 GList
*child
= m_list
->children
;
843 gtk_signal_connect( GTK_OBJECT(child
->data
), "select",
844 GTK_SIGNAL_FUNC(gtk_listitem_select_callback
), (gpointer
)this );
846 if (HasFlag(wxLB_MULTIPLE
))
847 gtk_signal_connect( GTK_OBJECT(child
->data
), "deselect",
848 GTK_SIGNAL_FUNC(gtk_listitem_deselect_callback
), (gpointer
)this );
854 GtkWidget
*wxListBox::GetConnectWidget()
856 return GTK_WIDGET(m_list
);
859 bool wxListBox::IsOwnGtkWindow( GdkWindow
*window
)
861 if (GTK_WIDGET(m_list
)->window
== window
) return TRUE
;
863 GList
*child
= m_list
->children
;
866 GtkWidget
*bin
= GTK_WIDGET( child
->data
);
867 if (bin
->window
== window
) return TRUE
;
874 void wxListBox::ApplyWidgetStyle()
878 if (m_backgroundColour
.Ok())
880 GdkWindow
*window
= GTK_WIDGET(m_list
)->window
;
883 m_backgroundColour
.CalcPixel( gdk_window_get_colormap( window
) );
884 gdk_window_set_background( window
, m_backgroundColour
.GetColor() );
885 gdk_window_clear( window
);
889 GList
*child
= m_list
->children
;
892 gtk_widget_set_style( GTK_WIDGET(child
->data
), m_widgetStyle
);
894 GtkBin
*bin
= GTK_BIN( child
->data
);
895 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
896 gtk_widget_set_style( label
, m_widgetStyle
);
902 void wxListBox::OnInternalIdle()
904 wxCursor cursor
= m_cursor
;
905 if (g_globalCursor
.Ok()) cursor
= g_globalCursor
;
907 if (GTK_WIDGET(m_list
)->window
&& cursor
.Ok())
909 /* I now set the cursor the anew in every OnInternalIdle call
910 as setting the cursor in a parent window also effects the
911 windows above so that checking for the current cursor is
914 gdk_window_set_cursor( GTK_WIDGET(m_list
)->window
, cursor
.GetCursor() );
916 GList
*child
= m_list
->children
;
919 GtkBin
*bin
= GTK_BIN( child
->data
);
920 GtkWidget
*label
= GTK_WIDGET( bin
->child
);
925 gdk_window_set_cursor( label
->window
, cursor
.GetCursor() );
934 wxSize
wxListBox::DoGetBestSize() const
936 return wxSize(100, 110);