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 wxNode
*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 wxNode
*node
= m_clientDataList
.Item( n
);
366 node
->SetData( (wxObject
*) clientData
);
369 void* wxComboBox::GetClientData( int n
)
371 wxCHECK_MSG( m_widget
!= NULL
, NULL
, wxT("invalid combobox") );
373 wxNode
*node
= m_clientDataList
.Item( n
);
374 if (!node
) return NULL
;
376 return node
->GetData();
379 void wxComboBox::SetClientObject( int n
, wxClientData
* clientData
)
381 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
383 wxNode
*node
= m_clientObjectList
.Item( n
);
386 wxClientData
*cd
= (wxClientData
*) node
->GetData();
389 node
->SetData( (wxObject
*) clientData
);
392 wxClientData
* wxComboBox::GetClientObject( int n
)
394 wxCHECK_MSG( m_widget
!= NULL
, (wxClientData
*)NULL
, wxT("invalid combobox") );
396 wxNode
*node
= m_clientObjectList
.Item( n
);
397 if (!node
) return (wxClientData
*) NULL
;
399 return (wxClientData
*) node
->GetData();
402 void wxComboBox::Clear()
404 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
408 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
409 gtk_list_clear_items( GTK_LIST(list
), 0, Number() );
411 wxNode
*node
= m_clientObjectList
.GetFirst();
414 wxClientData
*cd
= (wxClientData
*)node
->GetData();
416 node
= node
->GetNext();
418 m_clientObjectList
.Clear();
420 m_clientDataList
.Clear();
425 void wxComboBox::Delete( int n
)
427 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
429 GtkList
*listbox
= GTK_LIST( GTK_COMBO(m_widget
)->list
);
431 GList
*child
= g_list_nth( listbox
->children
, n
);
435 wxFAIL_MSG(wxT("wrong index"));
441 GList
*list
= g_list_append( (GList
*) NULL
, child
->data
);
442 gtk_list_remove_items( listbox
, list
);
445 wxNode
*node
= m_clientObjectList
.Item( n
);
448 wxClientData
*cd
= (wxClientData
*)node
->GetData();
450 m_clientObjectList
.DeleteNode( node
);
453 node
= m_clientDataList
.Item( n
);
455 m_clientDataList
.DeleteNode( node
);
460 void wxComboBox::SetString(int n
, const wxString
&text
)
462 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
464 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
466 GList
*child
= g_list_nth( GTK_LIST(list
)->children
, n
);
469 GtkBin
*bin
= GTK_BIN( child
->data
);
470 GtkLabel
*label
= GTK_LABEL( bin
->child
);
471 gtk_label_set_text(label
, wxGTK_CONV(text
));
475 wxFAIL_MSG( wxT("wxComboBox: wrong index") );
479 int wxComboBox::FindString( const wxString
&item
)
481 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid combobox") );
483 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
485 GList
*child
= GTK_LIST(list
)->children
;
489 GtkBin
*bin
= GTK_BIN( child
->data
);
490 GtkLabel
*label
= GTK_LABEL( bin
->child
);
492 wxString
str( wxGTK_CONV_BACK( gtk_label_get_text(label
) ) );
494 wxString
str( label
->label
);
506 int wxComboBox::GetSelection() const
508 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid combobox") );
510 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
512 GList
*selection
= GTK_LIST(list
)->selection
;
515 GList
*child
= GTK_LIST(list
)->children
;
519 if (child
->data
== selection
->data
) return count
;
528 wxString
wxComboBox::GetString( int n
) const
530 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid combobox") );
532 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
535 GList
*child
= g_list_nth( GTK_LIST(list
)->children
, n
);
538 GtkBin
*bin
= GTK_BIN( child
->data
);
539 GtkLabel
*label
= GTK_LABEL( bin
->child
);
541 str
= wxGTK_CONV_BACK( gtk_label_get_text(label
) );
543 str
= wxString( label
->label
);
548 wxFAIL_MSG( wxT("wxComboBox: wrong index") );
554 wxString
wxComboBox::GetStringSelection() const
556 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid combobox") );
558 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
560 GList
*selection
= GTK_LIST(list
)->selection
;
563 GtkBin
*bin
= GTK_BIN( selection
->data
);
564 GtkLabel
*label
= GTK_LABEL( bin
->child
);
566 wxString
tmp( wxGTK_CONV_BACK( gtk_label_get_text(label
) ) );
568 wxString
tmp( label
->label
);
573 wxFAIL_MSG( wxT("wxComboBox: no selection") );
578 int wxComboBox::Number() const
580 wxCHECK_MSG( m_widget
!= NULL
, 0, wxT("invalid combobox") );
582 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
584 GList
*child
= GTK_LIST(list
)->children
;
586 while (child
) { count
++; child
= child
->next
; }
590 void wxComboBox::SetSelection( int n
)
592 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
596 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
597 gtk_list_unselect_item( GTK_LIST(list
), m_prevSelection
);
598 gtk_list_select_item( GTK_LIST(list
), n
);
604 void wxComboBox::SetStringSelection( const wxString
&string
)
606 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
608 int res
= FindString( string
);
609 if (res
== -1) return;
613 wxString
wxComboBox::GetValue() const
615 GtkEntry
*entry
= GTK_ENTRY( GTK_COMBO(m_widget
)->entry
);
616 wxString
tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry
) ) );
619 for (int i
= 0; i
< wxStrlen(tmp
.c_str()) +1; i
++)
622 printf( "%d ", (int) (c
) );
630 void wxComboBox::SetValue( const wxString
& value
)
632 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
634 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
635 wxString tmp
= wxT("");
636 if (!value
.IsNull()) tmp
= value
;
637 gtk_entry_set_text( GTK_ENTRY(entry
), wxGTK_CONV( tmp
) );
640 void wxComboBox::Copy()
642 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
644 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
645 gtk_editable_copy_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
648 void wxComboBox::Cut()
650 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
652 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
653 gtk_editable_cut_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
656 void wxComboBox::Paste()
658 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
660 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
661 gtk_editable_paste_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
664 void wxComboBox::SetInsertionPoint( long pos
)
666 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
668 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
669 gtk_entry_set_position( GTK_ENTRY(entry
), (int)pos
);
672 void wxComboBox::SetInsertionPointEnd()
674 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
676 SetInsertionPoint( -1 );
679 long wxComboBox::GetInsertionPoint() const
681 return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget
)->entry
);
684 long wxComboBox::GetLastPosition() const
686 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
687 int pos
= GTK_ENTRY(entry
)->text_length
;
691 void wxComboBox::Replace( long from
, long to
, const wxString
& value
)
693 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
695 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
696 gtk_editable_delete_text( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
697 if (value
.IsNull()) return;
701 wxCharBuffer buffer
= wxConvUTF8
.cWX2MB( value
);
702 gtk_editable_insert_text( GTK_EDITABLE(entry
), (const char*) buffer
, strlen( (const char*) buffer
), &pos
);
704 gtk_editable_insert_text( GTK_EDITABLE(entry
), value
.c_str(), value
.Length(), &pos
);
708 void wxComboBox::Remove(long from
, long to
)
710 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
712 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
713 gtk_editable_delete_text( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
716 void wxComboBox::SetSelection( long from
, long to
)
718 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
719 gtk_editable_select_region( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
722 void wxComboBox::SetEditable( bool editable
)
724 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
725 gtk_entry_set_editable( GTK_ENTRY(entry
), editable
);
728 void wxComboBox::OnChar( wxKeyEvent
&event
)
730 if ( event
.GetKeyCode() == WXK_RETURN
)
732 // GTK automatically selects an item if its in the list
733 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, GetId());
734 event
.SetString( GetValue() );
735 event
.SetInt( GetSelection() );
736 event
.SetEventObject( this );
738 if (!GetEventHandler()->ProcessEvent( event
))
740 // This will invoke the dialog default action, such
741 // as the clicking the default button.
743 wxWindow
*top_frame
= m_parent
;
744 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
745 top_frame
= top_frame
->GetParent();
747 if (top_frame
&& GTK_IS_WINDOW(top_frame
->m_widget
))
749 GtkWindow
*window
= GTK_WINDOW(top_frame
->m_widget
);
751 if (window
->default_widget
)
752 gtk_widget_activate (window
->default_widget
);
756 // Catch GTK event so that GTK doesn't open the drop
757 // down list upon RETURN.
764 void wxComboBox::DisableEvents()
766 gtk_signal_disconnect_by_func( GTK_OBJECT(GTK_COMBO(m_widget
)->list
),
767 GTK_SIGNAL_FUNC(gtk_combo_select_child_callback
), (gpointer
)this );
768 gtk_signal_disconnect_by_func( GTK_OBJECT(GTK_COMBO(m_widget
)->entry
),
769 GTK_SIGNAL_FUNC(gtk_text_changed_callback
), (gpointer
)this );
772 void wxComboBox::EnableEvents()
774 gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget
)->list
), "select-child",
775 GTK_SIGNAL_FUNC(gtk_combo_select_child_callback
), (gpointer
)this );
776 gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget
)->entry
), "changed",
777 GTK_SIGNAL_FUNC(gtk_text_changed_callback
), (gpointer
)this );
780 void wxComboBox::OnSize( wxSizeEvent
&event
)
786 gtk_widget_set_usize( GTK_COMBO(m_widget
)->entry
, m_width
-w
-1, m_height
);
788 gtk_widget_set_uposition( GTK_COMBO(m_widget
)->button
, m_x
+m_width
-w
, m_y
);
789 gtk_widget_set_usize( GTK_COMBO(m_widget
)->button
, w
, m_height
);
793 void wxComboBox::ApplyWidgetStyle()
797 // gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
798 gtk_widget_set_style( GTK_COMBO(m_widget
)->entry
, m_widgetStyle
);
799 gtk_widget_set_style( GTK_COMBO(m_widget
)->list
, m_widgetStyle
);
801 GtkList
*list
= GTK_LIST( GTK_COMBO(m_widget
)->list
);
802 GList
*child
= list
->children
;
805 gtk_widget_set_style( GTK_WIDGET(child
->data
), m_widgetStyle
);
807 GtkBin
*bin
= GTK_BIN(child
->data
);
808 gtk_widget_set_style( bin
->child
, m_widgetStyle
);
814 GtkWidget
* wxComboBox::GetConnectWidget()
816 return GTK_COMBO(m_widget
)->entry
;
819 bool wxComboBox::IsOwnGtkWindow( GdkWindow
*window
)
821 return ( (window
== GTK_ENTRY( GTK_COMBO(m_widget
)->entry
)->text_area
) ||
822 (window
== GTK_COMBO(m_widget
)->button
->window
) );
825 wxSize
wxComboBox::DoGetBestSize() const
827 wxSize
ret( wxControl::DoGetBestSize() );
829 // we know better our horizontal extent: it depends on the longest string
835 size_t count
= GetCount();
836 for ( size_t n
= 0; n
< count
; n
++ )
838 GetTextExtent( GetString(n
), &width
, NULL
, NULL
, NULL
, &m_font
);
844 // empty combobox should have some reasonable default size too