1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
11 #pragma implementation "combobox.h"
14 #include "wx/combobox.h"
18 #include "wx/settings.h"
21 #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED
23 #include "wx/gtk/private.h"
25 //-----------------------------------------------------------------------------
27 //-----------------------------------------------------------------------------
29 extern void wxapp_install_idle_handler();
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 extern bool g_blockEventsOnDrag
;
38 //-----------------------------------------------------------------------------
39 // "select-child" - click/cursor get select-child, changed, select-child
40 //-----------------------------------------------------------------------------
43 gtk_combo_select_child_callback( GtkList
*WXUNUSED(list
), GtkWidget
*WXUNUSED(widget
), wxComboBox
*combo
)
45 if (g_isIdle
) wxapp_install_idle_handler();
47 if (!combo
->m_hasVMT
) return;
49 if (g_blockEventsOnDrag
) return;
51 int curSelection
= combo
->GetSelection();
53 if (combo
->m_prevSelection
!= curSelection
)
55 GtkWidget
*list
= GTK_COMBO(combo
->m_widget
)->list
;
56 gtk_list_unselect_item( GTK_LIST(list
), combo
->m_prevSelection
);
58 combo
->m_prevSelection
= curSelection
;
60 wxCommandEvent
event( wxEVT_COMMAND_COMBOBOX_SELECTED
, combo
->GetId() );
61 event
.SetInt( curSelection
);
62 event
.SetString( combo
->GetStringSelection() );
63 event
.SetEventObject( combo
);
65 combo
->GetEventHandler()->ProcessEvent( event
);
68 //-----------------------------------------------------------------------------
69 // "changed" - typing and list item matches get changed, select-child
70 // if it doesn't match an item then just get a single changed
71 //-----------------------------------------------------------------------------
74 gtk_text_changed_callback( GtkWidget
*WXUNUSED(widget
), wxComboBox
*combo
)
76 if (g_isIdle
) wxapp_install_idle_handler();
78 if (!combo
->m_hasVMT
) return;
80 wxCommandEvent
event( wxEVT_COMMAND_TEXT_UPDATED
, combo
->GetId() );
81 event
.SetString( combo
->GetValue() );
82 event
.SetEventObject( combo
);
83 combo
->GetEventHandler()->ProcessEvent( event
);
87 gtk_dummy_callback(GtkEntry
*WXUNUSED(entry
), GtkCombo
*WXUNUSED(combo
))
91 //-----------------------------------------------------------------------------
93 //-----------------------------------------------------------------------------
95 IMPLEMENT_DYNAMIC_CLASS(wxComboBox
,wxControl
)
97 BEGIN_EVENT_TABLE(wxComboBox
, wxControl
)
98 EVT_SIZE(wxComboBox::OnSize
)
99 EVT_CHAR(wxComboBox::OnChar
)
102 bool wxComboBox::Create( wxWindow
*parent
, wxWindowID id
, const wxString
& value
,
103 const wxPoint
& pos
, const wxSize
& size
,
104 int n
, const wxString choices
[],
105 long style
, const wxValidator
& validator
,
106 const wxString
& name
)
108 m_alreadySent
= FALSE
;
110 m_acceptsFocus
= TRUE
;
113 if (!PreCreation( parent
, pos
, size
) ||
114 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
116 wxFAIL_MSG( wxT("wxComboBox creation failed") );
120 m_widget
= gtk_combo_new();
121 GtkCombo
*combo
= GTK_COMBO(m_widget
);
123 // Disable GTK's broken events ...
124 gtk_signal_disconnect( GTK_OBJECT(combo
->entry
), combo
->entry_change_id
);
125 // ... and add surogate handler.
126 combo
->entry_change_id
= gtk_signal_connect (GTK_OBJECT (combo
->entry
), "changed",
127 (GtkSignalFunc
) gtk_dummy_callback
, combo
);
129 // make it more useable
130 gtk_combo_set_use_arrows_always( GTK_COMBO(m_widget
), TRUE
);
132 // and case-sensitive
133 gtk_combo_set_case_sensitive( GTK_COMBO(m_widget
), TRUE
);
135 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
138 // gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
141 for (int i
= 0; i
< n
; i
++)
143 GtkWidget
*list_item
= gtk_list_item_new_with_label( wxGTK_CONV( choices
[i
] ) );
145 m_clientDataList
.Append( (wxObject
*)NULL
);
146 m_clientObjectList
.Append( (wxObject
*)NULL
);
148 gtk_container_add( GTK_CONTAINER(list
), list_item
);
150 gtk_widget_show( list_item
);
153 m_parent
->DoAddChild( this );
155 m_focusWidget
= combo
->entry
;
159 ConnectWidget( combo
->button
);
161 // MSW's combo box shows the value and the selection is -1
162 gtk_entry_set_text( GTK_ENTRY(combo
->entry
), wxGTK_CONV(value
) );
163 gtk_list_unselect_all( GTK_LIST(combo
->list
) );
165 if (style
& wxCB_READONLY
)
166 gtk_entry_set_editable( GTK_ENTRY( combo
->entry
), FALSE
);
168 gtk_signal_connect( GTK_OBJECT(combo
->entry
), "changed",
169 GTK_SIGNAL_FUNC(gtk_text_changed_callback
), (gpointer
)this );
171 gtk_signal_connect( GTK_OBJECT(combo
->list
), "select-child",
172 GTK_SIGNAL_FUNC(gtk_combo_select_child_callback
), (gpointer
)this );
174 wxSize
size_best( DoGetBestSize() );
175 wxSize
new_size( size
);
176 if (new_size
.x
== -1)
177 new_size
.x
= size_best
.x
;
178 if (new_size
.y
== -1)
179 new_size
.y
= size_best
.y
;
180 if (new_size
.y
> size_best
.y
)
181 new_size
.y
= size_best
.y
;
182 if ((new_size
.x
!= size
.x
) || (new_size
.y
!= size
.y
))
184 SetSize( new_size
.x
, new_size
.y
);
186 // This is required for tool bar support
187 gtk_widget_set_usize( m_widget
, new_size
.x
, new_size
.y
);
190 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW
) );
191 SetForegroundColour( parent
->GetForegroundColour() );
198 wxComboBox::~wxComboBox()
200 wxList::compatibility_iterator node
= m_clientObjectList
.GetFirst();
203 wxClientData
*cd
= (wxClientData
*)node
->GetData();
205 node
= node
->GetNext();
207 m_clientObjectList
.Clear();
209 m_clientDataList
.Clear();
212 void wxComboBox::SetFocus()
216 // don't do anything if we already have focus
220 gtk_widget_grab_focus( m_focusWidget
);
223 void wxComboBox::AppendCommon( const wxString
&item
)
225 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
229 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
231 GtkWidget
*list_item
= gtk_list_item_new_with_label( wxGTK_CONV( item
) );
233 gtk_container_add( GTK_CONTAINER(list
), list_item
);
235 if (GTK_WIDGET_REALIZED(m_widget
))
237 gtk_widget_realize( list_item
);
238 gtk_widget_realize( GTK_BIN(list_item
)->child
);
240 if (m_widgetStyle
) ApplyWidgetStyle();
243 gtk_widget_show( list_item
);
248 void wxComboBox::Append( const wxString
&item
)
250 m_clientDataList
.Append( (wxObject
*) NULL
);
251 m_clientObjectList
.Append( (wxObject
*) NULL
);
253 AppendCommon( item
);
256 void wxComboBox::Append( const wxString
&item
, void *clientData
)
258 m_clientDataList
.Append( (wxObject
*) clientData
);
259 m_clientObjectList
.Append( (wxObject
*)NULL
);
261 AppendCommon( item
);
264 void wxComboBox::Append( const wxString
&item
, wxClientData
*clientData
)
266 m_clientDataList
.Append( (wxObject
*) NULL
);
267 m_clientObjectList
.Append( (wxObject
*) clientData
);
269 AppendCommon( item
);
272 void wxComboBox::InsertCommon( const wxString
&item
, int pos
)
274 wxCHECK_RET(!(GetWindowStyle() & wxCB_SORT
), wxT("can't insert into sorted list"));
275 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
277 int count
= GetCount();
278 wxCHECK_RET((pos
>=0) && (pos
<=count
), wxT("invalid index"));
287 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
289 GtkWidget
*list_item
= gtk_list_item_new_with_label( wxGTK_CONV( item
) );
291 GList
*gitem_list
= g_list_alloc ();
292 gitem_list
->data
= list_item
;
293 gtk_list_insert_items( GTK_LIST (list
), gitem_list
, pos
);
295 if (GTK_WIDGET_REALIZED(m_widget
))
297 gtk_widget_realize( list_item
);
298 gtk_widget_realize( GTK_BIN(list_item
)->child
);
300 if (m_widgetStyle
) ApplyWidgetStyle();
303 gtk_widget_show( list_item
);
308 void wxComboBox::Insert( const wxString
&item
, int pos
)
310 wxCHECK_RET(!(GetWindowStyle() & wxCB_SORT
), wxT("can't insert into sorted list"));
311 int count
= GetCount();
312 wxCHECK_RET((pos
>=0) && (pos
<=count
), wxT("invalid index"));
319 m_clientDataList
.Insert( pos
, (wxObject
*) NULL
);
320 m_clientObjectList
.Insert( pos
, (wxObject
*) NULL
);
322 InsertCommon( item
, pos
);
325 void wxComboBox::Insert( const wxString
&item
, int pos
, void *clientData
)
327 wxCHECK_RET(!(GetWindowStyle() & wxCB_SORT
), wxT("can't insert into sorted list"));
328 int count
= GetCount();
329 wxCHECK_RET((pos
>=0) && (pos
<=count
), wxT("invalid index"));
332 Append(item
, clientData
);
336 m_clientDataList
.Insert( pos
, (wxObject
*) clientData
);
337 m_clientObjectList
.Insert( pos
, (wxObject
*)NULL
);
339 InsertCommon( item
, pos
);
342 void wxComboBox::Insert( const wxString
&item
, int pos
, wxClientData
*clientData
)
344 wxCHECK_RET(!(GetWindowStyle() & wxCB_SORT
), wxT("can't insert into sorted list"));
345 int count
= GetCount();
346 wxCHECK_RET((pos
>=0) && (pos
<=count
), wxT("invalid index"));
349 Append(item
, clientData
);
353 m_clientDataList
.Insert( pos
, (wxObject
*) NULL
);
354 m_clientObjectList
.Insert( pos
, (wxObject
*) clientData
);
356 InsertCommon( item
, pos
);
359 void wxComboBox::SetClientData( int n
, void* clientData
)
361 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
363 wxList::compatibility_iterator node
= m_clientDataList
.Item( n
);
366 node
->SetData( (wxObject
*) clientData
);
369 void* wxComboBox::GetClientData( int n
) const
371 wxCHECK_MSG( m_widget
!= NULL
, NULL
, wxT("invalid combobox") );
373 wxList::compatibility_iterator node
= m_clientDataList
.Item( n
);
375 return node
? node
->GetData() : NULL
;
378 void wxComboBox::SetClientObject( int n
, wxClientData
* clientData
)
380 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
382 wxList::compatibility_iterator node
= m_clientObjectList
.Item( n
);
385 wxClientData
*cd
= (wxClientData
*) node
->GetData();
388 node
->SetData( (wxObject
*) clientData
);
391 wxClientData
* wxComboBox::GetClientObject( int n
) const
393 wxCHECK_MSG( m_widget
!= NULL
, (wxClientData
*)NULL
, wxT("invalid combobox") );
395 wxList::compatibility_iterator node
= m_clientObjectList
.Item( n
);
397 return node
? (wxClientData
*) node
->GetData() : NULL
;
400 void wxComboBox::Clear()
402 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
406 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
407 gtk_list_clear_items( GTK_LIST(list
), 0, Number() );
409 wxList::compatibility_iterator node
= m_clientObjectList
.GetFirst();
412 wxClientData
*cd
= (wxClientData
*)node
->GetData();
414 node
= node
->GetNext();
416 m_clientObjectList
.Clear();
418 m_clientDataList
.Clear();
423 void wxComboBox::Delete( int n
)
425 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
427 GtkList
*listbox
= GTK_LIST( GTK_COMBO(m_widget
)->list
);
429 GList
*child
= g_list_nth( listbox
->children
, n
);
433 wxFAIL_MSG(wxT("wrong index"));
439 GList
*list
= g_list_append( (GList
*) NULL
, child
->data
);
440 gtk_list_remove_items( listbox
, list
);
443 wxList::compatibility_iterator node
= m_clientObjectList
.Item( n
);
446 wxClientData
*cd
= (wxClientData
*)node
->GetData();
448 m_clientObjectList
.Erase( node
);
451 node
= m_clientDataList
.Item( n
);
453 m_clientDataList
.Erase( node
);
458 void wxComboBox::SetString(int n
, const wxString
&text
)
460 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
462 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
464 GList
*child
= g_list_nth( GTK_LIST(list
)->children
, n
);
467 GtkBin
*bin
= GTK_BIN( child
->data
);
468 GtkLabel
*label
= GTK_LABEL( bin
->child
);
469 gtk_label_set_text(label
, wxGTK_CONV(text
));
473 wxFAIL_MSG( wxT("wxComboBox: wrong index") );
477 int wxComboBox::FindString( const wxString
&item
)
479 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid combobox") );
481 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
483 GList
*child
= GTK_LIST(list
)->children
;
487 GtkBin
*bin
= GTK_BIN( child
->data
);
488 GtkLabel
*label
= GTK_LABEL( bin
->child
);
490 wxString
str( wxGTK_CONV_BACK( gtk_label_get_text(label
) ) );
492 wxString
str( label
->label
);
504 int wxComboBox::GetSelection() const
506 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid combobox") );
508 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
510 GList
*selection
= GTK_LIST(list
)->selection
;
513 GList
*child
= GTK_LIST(list
)->children
;
517 if (child
->data
== selection
->data
) return count
;
526 wxString
wxComboBox::GetString( int n
) const
528 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid combobox") );
530 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
533 GList
*child
= g_list_nth( GTK_LIST(list
)->children
, n
);
536 GtkBin
*bin
= GTK_BIN( child
->data
);
537 GtkLabel
*label
= GTK_LABEL( bin
->child
);
539 str
= wxGTK_CONV_BACK( gtk_label_get_text(label
) );
541 str
= wxString( label
->label
);
546 wxFAIL_MSG( wxT("wxComboBox: wrong index") );
552 wxString
wxComboBox::GetStringSelection() const
554 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid combobox") );
556 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
558 GList
*selection
= GTK_LIST(list
)->selection
;
561 GtkBin
*bin
= GTK_BIN( selection
->data
);
562 GtkLabel
*label
= GTK_LABEL( bin
->child
);
564 wxString
tmp( wxGTK_CONV_BACK( gtk_label_get_text(label
) ) );
566 wxString
tmp( label
->label
);
571 wxFAIL_MSG( wxT("wxComboBox: no selection") );
576 int wxComboBox::Number() const
578 wxCHECK_MSG( m_widget
!= NULL
, 0, wxT("invalid combobox") );
580 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
582 GList
*child
= GTK_LIST(list
)->children
;
584 while (child
) { count
++; child
= child
->next
; }
588 void wxComboBox::SetSelection( int n
)
590 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
594 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
595 gtk_list_unselect_item( GTK_LIST(list
), m_prevSelection
);
596 gtk_list_select_item( GTK_LIST(list
), n
);
602 void wxComboBox::SetStringSelection( const wxString
&string
)
604 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
606 int res
= FindString( string
);
607 if (res
== -1) return;
611 wxString
wxComboBox::GetValue() const
613 GtkEntry
*entry
= GTK_ENTRY( GTK_COMBO(m_widget
)->entry
);
614 wxString
tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry
) ) );
617 for (int i
= 0; i
< wxStrlen(tmp
.c_str()) +1; i
++)
620 printf( "%d ", (int) (c
) );
628 void wxComboBox::SetValue( const wxString
& value
)
630 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
632 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
633 wxString tmp
= wxT("");
634 if (!value
.IsNull()) tmp
= value
;
635 gtk_entry_set_text( GTK_ENTRY(entry
), wxGTK_CONV( tmp
) );
638 void wxComboBox::Copy()
640 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
642 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
643 gtk_editable_copy_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
646 void wxComboBox::Cut()
648 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
650 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
651 gtk_editable_cut_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
654 void wxComboBox::Paste()
656 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
658 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
659 gtk_editable_paste_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
662 void wxComboBox::SetInsertionPoint( long pos
)
664 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
666 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
667 gtk_entry_set_position( GTK_ENTRY(entry
), (int)pos
);
670 void wxComboBox::SetInsertionPointEnd()
672 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
674 SetInsertionPoint( -1 );
677 long wxComboBox::GetInsertionPoint() const
679 return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget
)->entry
);
682 long wxComboBox::GetLastPosition() const
684 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
685 int pos
= GTK_ENTRY(entry
)->text_length
;
689 void wxComboBox::Replace( long from
, long to
, const wxString
& value
)
691 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
693 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
694 gtk_editable_delete_text( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
695 if (value
.IsNull()) return;
699 wxCharBuffer buffer
= wxConvUTF8
.cWX2MB( value
);
700 gtk_editable_insert_text( GTK_EDITABLE(entry
), (const char*) buffer
, strlen( (const char*) buffer
), &pos
);
702 gtk_editable_insert_text( GTK_EDITABLE(entry
), value
.c_str(), value
.Length(), &pos
);
706 void wxComboBox::Remove(long from
, long to
)
708 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
710 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
711 gtk_editable_delete_text( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
714 void wxComboBox::SetSelection( long from
, long to
)
716 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
717 gtk_editable_select_region( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
720 void wxComboBox::SetEditable( bool editable
)
722 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
723 gtk_entry_set_editable( GTK_ENTRY(entry
), editable
);
726 void wxComboBox::OnChar( wxKeyEvent
&event
)
728 if ( event
.GetKeyCode() == WXK_RETURN
)
730 // GTK automatically selects an item if its in the list
731 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, GetId());
732 event
.SetString( GetValue() );
733 event
.SetInt( GetSelection() );
734 event
.SetEventObject( this );
736 if (!GetEventHandler()->ProcessEvent( event
))
738 // This will invoke the dialog default action, such
739 // as the clicking the default button.
741 wxWindow
*top_frame
= m_parent
;
742 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
743 top_frame
= top_frame
->GetParent();
745 if (top_frame
&& GTK_IS_WINDOW(top_frame
->m_widget
))
747 GtkWindow
*window
= GTK_WINDOW(top_frame
->m_widget
);
749 if (window
->default_widget
)
750 gtk_widget_activate (window
->default_widget
);
754 // Catch GTK event so that GTK doesn't open the drop
755 // down list upon RETURN.
762 void wxComboBox::DisableEvents()
764 gtk_signal_disconnect_by_func( GTK_OBJECT(GTK_COMBO(m_widget
)->list
),
765 GTK_SIGNAL_FUNC(gtk_combo_select_child_callback
), (gpointer
)this );
766 gtk_signal_disconnect_by_func( GTK_OBJECT(GTK_COMBO(m_widget
)->entry
),
767 GTK_SIGNAL_FUNC(gtk_text_changed_callback
), (gpointer
)this );
770 void wxComboBox::EnableEvents()
772 gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget
)->list
), "select-child",
773 GTK_SIGNAL_FUNC(gtk_combo_select_child_callback
), (gpointer
)this );
774 gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget
)->entry
), "changed",
775 GTK_SIGNAL_FUNC(gtk_text_changed_callback
), (gpointer
)this );
778 void wxComboBox::OnSize( wxSizeEvent
&event
)
784 gtk_widget_set_usize( GTK_COMBO(m_widget
)->entry
, m_width
-w
-1, m_height
);
786 gtk_widget_set_uposition( GTK_COMBO(m_widget
)->button
, m_x
+m_width
-w
, m_y
);
787 gtk_widget_set_usize( GTK_COMBO(m_widget
)->button
, w
, m_height
);
791 void wxComboBox::ApplyWidgetStyle()
795 // gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
796 gtk_widget_set_style( GTK_COMBO(m_widget
)->entry
, m_widgetStyle
);
797 gtk_widget_set_style( GTK_COMBO(m_widget
)->list
, m_widgetStyle
);
799 GtkList
*list
= GTK_LIST( GTK_COMBO(m_widget
)->list
);
800 GList
*child
= list
->children
;
803 gtk_widget_set_style( GTK_WIDGET(child
->data
), m_widgetStyle
);
805 GtkBin
*bin
= GTK_BIN(child
->data
);
806 gtk_widget_set_style( bin
->child
, m_widgetStyle
);
812 GtkWidget
* wxComboBox::GetConnectWidget()
814 return GTK_COMBO(m_widget
)->entry
;
817 bool wxComboBox::IsOwnGtkWindow( GdkWindow
*window
)
819 return ( (window
== GTK_ENTRY( GTK_COMBO(m_widget
)->entry
)->text_area
) ||
820 (window
== GTK_COMBO(m_widget
)->button
->window
) );
823 wxSize
wxComboBox::DoGetBestSize() const
825 wxSize
ret( wxControl::DoGetBestSize() );
827 // we know better our horizontal extent: it depends on the longest string
833 size_t count
= GetCount();
834 for ( size_t n
= 0; n
< count
; n
++ )
836 GetTextExtent( GetString(n
), &width
, NULL
, NULL
, NULL
, &m_font
);
842 // empty combobox should have some reasonable default size too