1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
10 #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
11 #pragma implementation "combobox.h"
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
17 #include "wx/combobox.h"
21 #include "wx/settings.h"
24 #include "wx/textctrl.h" // for wxEVT_COMMAND_TEXT_UPDATED
26 #include "wx/gtk/private.h"
28 //-----------------------------------------------------------------------------
30 //-----------------------------------------------------------------------------
32 extern void wxapp_install_idle_handler();
35 //-----------------------------------------------------------------------------
37 //-----------------------------------------------------------------------------
39 extern bool g_blockEventsOnDrag
;
41 //-----------------------------------------------------------------------------
42 // "select-child" - click/cursor get select-child, changed, select-child
43 //-----------------------------------------------------------------------------
46 gtk_combo_select_child_callback( GtkList
*WXUNUSED(list
), GtkWidget
*WXUNUSED(widget
), wxComboBox
*combo
)
48 if (g_isIdle
) wxapp_install_idle_handler();
50 if (!combo
->m_hasVMT
) return;
52 if (g_blockEventsOnDrag
) return;
54 int curSelection
= combo
->GetSelection();
56 if (combo
->m_prevSelection
!= curSelection
)
58 GtkWidget
*list
= GTK_COMBO(combo
->m_widget
)->list
;
59 gtk_list_unselect_item( GTK_LIST(list
), combo
->m_prevSelection
);
61 combo
->m_prevSelection
= curSelection
;
63 wxCommandEvent
event( wxEVT_COMMAND_COMBOBOX_SELECTED
, combo
->GetId() );
64 event
.SetInt( curSelection
);
65 event
.SetString( combo
->GetStringSelection() );
66 event
.SetEventObject( combo
);
68 combo
->GetEventHandler()->ProcessEvent( event
);
71 //-----------------------------------------------------------------------------
72 // "changed" - typing and list item matches get changed, select-child
73 // if it doesn't match an item then just get a single changed
74 //-----------------------------------------------------------------------------
77 gtk_text_changed_callback( GtkWidget
*WXUNUSED(widget
), wxComboBox
*combo
)
79 if (g_isIdle
) wxapp_install_idle_handler();
81 if (!combo
->m_hasVMT
) return;
83 wxCommandEvent
event( wxEVT_COMMAND_TEXT_UPDATED
, combo
->GetId() );
84 event
.SetString( combo
->GetValue() );
85 event
.SetEventObject( combo
);
86 combo
->GetEventHandler()->ProcessEvent( event
);
90 gtk_dummy_callback(GtkEntry
*WXUNUSED(entry
), GtkCombo
*WXUNUSED(combo
))
94 //-----------------------------------------------------------------------------
96 //-----------------------------------------------------------------------------
98 IMPLEMENT_DYNAMIC_CLASS(wxComboBox
,wxControl
)
100 BEGIN_EVENT_TABLE(wxComboBox
, wxControl
)
101 EVT_SIZE(wxComboBox::OnSize
)
102 EVT_CHAR(wxComboBox::OnChar
)
105 bool wxComboBox::Create( wxWindow
*parent
, wxWindowID id
, const wxString
& value
,
106 const wxPoint
& pos
, const wxSize
& size
,
107 int n
, const wxString choices
[],
108 long style
, const wxValidator
& validator
,
109 const wxString
& name
)
111 m_alreadySent
= FALSE
;
113 m_acceptsFocus
= TRUE
;
116 if (!PreCreation( parent
, pos
, size
) ||
117 !CreateBase( parent
, id
, pos
, size
, style
, validator
, name
))
119 wxFAIL_MSG( wxT("wxComboBox creation failed") );
123 m_widget
= gtk_combo_new();
124 GtkCombo
*combo
= GTK_COMBO(m_widget
);
126 // Disable GTK's broken events ...
127 gtk_signal_disconnect( GTK_OBJECT(combo
->entry
), combo
->entry_change_id
);
128 // ... and add surogate handler.
129 combo
->entry_change_id
= gtk_signal_connect (GTK_OBJECT (combo
->entry
), "changed",
130 (GtkSignalFunc
) gtk_dummy_callback
, combo
);
132 // make it more useable
133 gtk_combo_set_use_arrows_always( GTK_COMBO(m_widget
), TRUE
);
135 // and case-sensitive
136 gtk_combo_set_case_sensitive( GTK_COMBO(m_widget
), TRUE
);
138 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
141 // gtk_list_set_selection_mode( GTK_LIST(list), GTK_SELECTION_MULTIPLE );
144 for (int i
= 0; i
< n
; i
++)
146 GtkWidget
*list_item
= gtk_list_item_new_with_label( wxGTK_CONV( choices
[i
] ) );
148 m_clientDataList
.Append( (wxObject
*)NULL
);
149 m_clientObjectList
.Append( (wxObject
*)NULL
);
151 gtk_container_add( GTK_CONTAINER(list
), list_item
);
153 gtk_widget_show( list_item
);
156 m_parent
->DoAddChild( this );
158 m_focusWidget
= combo
->entry
;
162 ConnectWidget( combo
->button
);
164 // MSW's combo box shows the value and the selection is -1
165 gtk_entry_set_text( GTK_ENTRY(combo
->entry
), wxGTK_CONV(value
) );
166 gtk_list_unselect_all( GTK_LIST(combo
->list
) );
168 if (style
& wxCB_READONLY
)
169 gtk_entry_set_editable( GTK_ENTRY( combo
->entry
), FALSE
);
171 gtk_signal_connect( GTK_OBJECT(combo
->entry
), "changed",
172 GTK_SIGNAL_FUNC(gtk_text_changed_callback
), (gpointer
)this );
174 gtk_signal_connect( GTK_OBJECT(combo
->list
), "select-child",
175 GTK_SIGNAL_FUNC(gtk_combo_select_child_callback
), (gpointer
)this );
177 wxSize
size_best( DoGetBestSize() );
178 wxSize
new_size( size
);
179 if (new_size
.x
== -1)
180 new_size
.x
= size_best
.x
;
181 if (new_size
.y
== -1)
182 new_size
.y
= size_best
.y
;
183 if (new_size
.y
> size_best
.y
)
184 new_size
.y
= size_best
.y
;
185 if ((new_size
.x
!= size
.x
) || (new_size
.y
!= size
.y
))
187 SetSize( new_size
.x
, new_size
.y
);
189 // This is required for tool bar support
190 gtk_widget_set_usize( m_widget
, new_size
.x
, new_size
.y
);
193 SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW
) );
194 SetForegroundColour( parent
->GetForegroundColour() );
201 wxComboBox::~wxComboBox()
203 wxList::compatibility_iterator node
= m_clientObjectList
.GetFirst();
206 wxClientData
*cd
= (wxClientData
*)node
->GetData();
208 node
= node
->GetNext();
210 m_clientObjectList
.Clear();
212 m_clientDataList
.Clear();
215 void wxComboBox::SetFocus()
219 // don't do anything if we already have focus
223 gtk_widget_grab_focus( m_focusWidget
);
226 void wxComboBox::AppendCommon( const wxString
&item
)
228 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
232 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
234 GtkWidget
*list_item
= gtk_list_item_new_with_label( wxGTK_CONV( item
) );
236 gtk_container_add( GTK_CONTAINER(list
), list_item
);
238 if (GTK_WIDGET_REALIZED(m_widget
))
240 gtk_widget_realize( list_item
);
241 gtk_widget_realize( GTK_BIN(list_item
)->child
);
243 if (m_widgetStyle
) ApplyWidgetStyle();
246 gtk_widget_show( list_item
);
251 void wxComboBox::Append( const wxString
&item
)
253 m_clientDataList
.Append( (wxObject
*) NULL
);
254 m_clientObjectList
.Append( (wxObject
*) NULL
);
256 AppendCommon( item
);
259 void wxComboBox::Append( const wxString
&item
, void *clientData
)
261 m_clientDataList
.Append( (wxObject
*) clientData
);
262 m_clientObjectList
.Append( (wxObject
*)NULL
);
264 AppendCommon( item
);
267 void wxComboBox::Append( const wxString
&item
, wxClientData
*clientData
)
269 m_clientDataList
.Append( (wxObject
*) NULL
);
270 m_clientObjectList
.Append( (wxObject
*) clientData
);
272 AppendCommon( item
);
275 void wxComboBox::InsertCommon( const wxString
&item
, int pos
)
277 wxCHECK_RET(!(GetWindowStyle() & wxCB_SORT
), wxT("can't insert into sorted list"));
278 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
280 int count
= GetCount();
281 wxCHECK_RET((pos
>=0) && (pos
<=count
), wxT("invalid index"));
290 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
292 GtkWidget
*list_item
= gtk_list_item_new_with_label( wxGTK_CONV( item
) );
294 GList
*gitem_list
= g_list_alloc ();
295 gitem_list
->data
= list_item
;
296 gtk_list_insert_items( GTK_LIST (list
), gitem_list
, pos
);
298 if (GTK_WIDGET_REALIZED(m_widget
))
300 gtk_widget_realize( list_item
);
301 gtk_widget_realize( GTK_BIN(list_item
)->child
);
303 if (m_widgetStyle
) ApplyWidgetStyle();
306 gtk_widget_show( list_item
);
311 void wxComboBox::Insert( const wxString
&item
, int pos
)
313 wxCHECK_RET(!(GetWindowStyle() & wxCB_SORT
), wxT("can't insert into sorted list"));
314 int count
= GetCount();
315 wxCHECK_RET((pos
>=0) && (pos
<=count
), wxT("invalid index"));
322 m_clientDataList
.Insert( pos
, (wxObject
*) NULL
);
323 m_clientObjectList
.Insert( pos
, (wxObject
*) NULL
);
325 InsertCommon( item
, pos
);
328 void wxComboBox::Insert( const wxString
&item
, int pos
, void *clientData
)
330 wxCHECK_RET(!(GetWindowStyle() & wxCB_SORT
), wxT("can't insert into sorted list"));
331 int count
= GetCount();
332 wxCHECK_RET((pos
>=0) && (pos
<=count
), wxT("invalid index"));
335 Append(item
, clientData
);
339 m_clientDataList
.Insert( pos
, (wxObject
*) clientData
);
340 m_clientObjectList
.Insert( pos
, (wxObject
*)NULL
);
342 InsertCommon( item
, pos
);
345 void wxComboBox::Insert( const wxString
&item
, int pos
, wxClientData
*clientData
)
347 wxCHECK_RET(!(GetWindowStyle() & wxCB_SORT
), wxT("can't insert into sorted list"));
348 int count
= GetCount();
349 wxCHECK_RET((pos
>=0) && (pos
<=count
), wxT("invalid index"));
352 Append(item
, clientData
);
356 m_clientDataList
.Insert( pos
, (wxObject
*) NULL
);
357 m_clientObjectList
.Insert( pos
, (wxObject
*) clientData
);
359 InsertCommon( item
, pos
);
362 void wxComboBox::SetClientData( int n
, void* clientData
)
364 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
366 wxList::compatibility_iterator node
= m_clientDataList
.Item( n
);
369 node
->SetData( (wxObject
*) clientData
);
372 void* wxComboBox::GetClientData( int n
) const
374 wxCHECK_MSG( m_widget
!= NULL
, NULL
, wxT("invalid combobox") );
376 wxList::compatibility_iterator node
= m_clientDataList
.Item( n
);
378 return node
? node
->GetData() : NULL
;
381 void wxComboBox::SetClientObject( int n
, wxClientData
* clientData
)
383 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
385 wxList::compatibility_iterator node
= m_clientObjectList
.Item( n
);
388 wxClientData
*cd
= (wxClientData
*) node
->GetData();
391 node
->SetData( (wxObject
*) clientData
);
394 wxClientData
* wxComboBox::GetClientObject( int n
) const
396 wxCHECK_MSG( m_widget
!= NULL
, (wxClientData
*)NULL
, wxT("invalid combobox") );
398 wxList::compatibility_iterator node
= m_clientObjectList
.Item( n
);
400 return node
? (wxClientData
*) node
->GetData() : NULL
;
403 void wxComboBox::Clear()
405 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
409 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
410 gtk_list_clear_items( GTK_LIST(list
), 0, Number() );
412 wxList::compatibility_iterator node
= m_clientObjectList
.GetFirst();
415 wxClientData
*cd
= (wxClientData
*)node
->GetData();
417 node
= node
->GetNext();
419 m_clientObjectList
.Clear();
421 m_clientDataList
.Clear();
426 void wxComboBox::Delete( int n
)
428 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
430 GtkList
*listbox
= GTK_LIST( GTK_COMBO(m_widget
)->list
);
432 GList
*child
= g_list_nth( listbox
->children
, n
);
436 wxFAIL_MSG(wxT("wrong index"));
442 GList
*list
= g_list_append( (GList
*) NULL
, child
->data
);
443 gtk_list_remove_items( listbox
, list
);
446 wxList::compatibility_iterator node
= m_clientObjectList
.Item( n
);
449 wxClientData
*cd
= (wxClientData
*)node
->GetData();
451 m_clientObjectList
.Erase( node
);
454 node
= m_clientDataList
.Item( n
);
456 m_clientDataList
.Erase( node
);
461 void wxComboBox::SetString(int n
, const wxString
&text
)
463 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
465 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
467 GList
*child
= g_list_nth( GTK_LIST(list
)->children
, n
);
470 GtkBin
*bin
= GTK_BIN( child
->data
);
471 GtkLabel
*label
= GTK_LABEL( bin
->child
);
472 gtk_label_set_text(label
, wxGTK_CONV(text
));
476 wxFAIL_MSG( wxT("wxComboBox: wrong index") );
480 int wxComboBox::FindString( const wxString
&item
)
482 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid combobox") );
484 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
486 GList
*child
= GTK_LIST(list
)->children
;
490 GtkBin
*bin
= GTK_BIN( child
->data
);
491 GtkLabel
*label
= GTK_LABEL( bin
->child
);
493 wxString
str( wxGTK_CONV_BACK( gtk_label_get_text(label
) ) );
495 wxString
str( label
->label
);
507 int wxComboBox::GetSelection() const
509 wxCHECK_MSG( m_widget
!= NULL
, -1, wxT("invalid combobox") );
511 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
513 GList
*selection
= GTK_LIST(list
)->selection
;
516 GList
*child
= GTK_LIST(list
)->children
;
520 if (child
->data
== selection
->data
) return count
;
529 wxString
wxComboBox::GetString( int n
) const
531 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid combobox") );
533 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
536 GList
*child
= g_list_nth( GTK_LIST(list
)->children
, n
);
539 GtkBin
*bin
= GTK_BIN( child
->data
);
540 GtkLabel
*label
= GTK_LABEL( bin
->child
);
542 str
= wxGTK_CONV_BACK( gtk_label_get_text(label
) );
544 str
= wxString( label
->label
);
549 wxFAIL_MSG( wxT("wxComboBox: wrong index") );
555 wxString
wxComboBox::GetStringSelection() const
557 wxCHECK_MSG( m_widget
!= NULL
, wxT(""), wxT("invalid combobox") );
559 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
561 GList
*selection
= GTK_LIST(list
)->selection
;
564 GtkBin
*bin
= GTK_BIN( selection
->data
);
565 GtkLabel
*label
= GTK_LABEL( bin
->child
);
567 wxString
tmp( wxGTK_CONV_BACK( gtk_label_get_text(label
) ) );
569 wxString
tmp( label
->label
);
574 wxFAIL_MSG( wxT("wxComboBox: no selection") );
579 int wxComboBox::Number() const
581 wxCHECK_MSG( m_widget
!= NULL
, 0, wxT("invalid combobox") );
583 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
585 GList
*child
= GTK_LIST(list
)->children
;
587 while (child
) { count
++; child
= child
->next
; }
591 void wxComboBox::SetSelection( int n
)
593 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
597 GtkWidget
*list
= GTK_COMBO(m_widget
)->list
;
598 gtk_list_unselect_item( GTK_LIST(list
), m_prevSelection
);
599 gtk_list_select_item( GTK_LIST(list
), n
);
605 void wxComboBox::SetStringSelection( const wxString
&string
)
607 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
609 int res
= FindString( string
);
610 if (res
== -1) return;
614 wxString
wxComboBox::GetValue() const
616 GtkEntry
*entry
= GTK_ENTRY( GTK_COMBO(m_widget
)->entry
);
617 wxString
tmp( wxGTK_CONV_BACK( gtk_entry_get_text( entry
) ) );
620 for (int i
= 0; i
< wxStrlen(tmp
.c_str()) +1; i
++)
623 printf( "%d ", (int) (c
) );
631 void wxComboBox::SetValue( const wxString
& value
)
633 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
635 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
636 wxString tmp
= wxT("");
637 if (!value
.IsNull()) tmp
= value
;
638 gtk_entry_set_text( GTK_ENTRY(entry
), wxGTK_CONV( tmp
) );
641 void wxComboBox::Copy()
643 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
645 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
646 gtk_editable_copy_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
649 void wxComboBox::Cut()
651 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
653 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
654 gtk_editable_cut_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
657 void wxComboBox::Paste()
659 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
661 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
662 gtk_editable_paste_clipboard( GTK_EDITABLE(entry
) DUMMY_CLIPBOARD_ARG
);
665 void wxComboBox::SetInsertionPoint( long pos
)
667 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
669 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
670 gtk_entry_set_position( GTK_ENTRY(entry
), (int)pos
);
673 void wxComboBox::SetInsertionPointEnd()
675 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
677 SetInsertionPoint( -1 );
680 long wxComboBox::GetInsertionPoint() const
682 return (long) GET_EDITABLE_POS( GTK_COMBO(m_widget
)->entry
);
685 long wxComboBox::GetLastPosition() const
687 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
688 int pos
= GTK_ENTRY(entry
)->text_length
;
692 void wxComboBox::Replace( long from
, long to
, const wxString
& value
)
694 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
696 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
697 gtk_editable_delete_text( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
698 if (value
.IsNull()) return;
702 wxCharBuffer buffer
= wxConvUTF8
.cWX2MB( value
);
703 gtk_editable_insert_text( GTK_EDITABLE(entry
), (const char*) buffer
, strlen( (const char*) buffer
), &pos
);
705 gtk_editable_insert_text( GTK_EDITABLE(entry
), value
.c_str(), value
.Length(), &pos
);
709 void wxComboBox::Remove(long from
, long to
)
711 wxCHECK_RET( m_widget
!= NULL
, wxT("invalid combobox") );
713 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
714 gtk_editable_delete_text( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
717 void wxComboBox::SetSelection( long from
, long to
)
719 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
720 gtk_editable_select_region( GTK_EDITABLE(entry
), (gint
)from
, (gint
)to
);
723 void wxComboBox::SetEditable( bool editable
)
725 GtkWidget
*entry
= GTK_COMBO(m_widget
)->entry
;
726 gtk_entry_set_editable( GTK_ENTRY(entry
), editable
);
729 void wxComboBox::OnChar( wxKeyEvent
&event
)
731 if ( event
.GetKeyCode() == WXK_RETURN
)
733 // GTK automatically selects an item if its in the list
734 wxCommandEvent
event(wxEVT_COMMAND_TEXT_ENTER
, GetId());
735 event
.SetString( GetValue() );
736 event
.SetInt( GetSelection() );
737 event
.SetEventObject( this );
739 if (!GetEventHandler()->ProcessEvent( event
))
741 // This will invoke the dialog default action, such
742 // as the clicking the default button.
744 wxWindow
*top_frame
= m_parent
;
745 while (top_frame
->GetParent() && !(top_frame
->IsTopLevel()))
746 top_frame
= top_frame
->GetParent();
748 if (top_frame
&& GTK_IS_WINDOW(top_frame
->m_widget
))
750 GtkWindow
*window
= GTK_WINDOW(top_frame
->m_widget
);
752 if (window
->default_widget
)
753 gtk_widget_activate (window
->default_widget
);
757 // Catch GTK event so that GTK doesn't open the drop
758 // down list upon RETURN.
765 void wxComboBox::DisableEvents()
767 gtk_signal_disconnect_by_func( GTK_OBJECT(GTK_COMBO(m_widget
)->list
),
768 GTK_SIGNAL_FUNC(gtk_combo_select_child_callback
), (gpointer
)this );
769 gtk_signal_disconnect_by_func( GTK_OBJECT(GTK_COMBO(m_widget
)->entry
),
770 GTK_SIGNAL_FUNC(gtk_text_changed_callback
), (gpointer
)this );
773 void wxComboBox::EnableEvents()
775 gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget
)->list
), "select-child",
776 GTK_SIGNAL_FUNC(gtk_combo_select_child_callback
), (gpointer
)this );
777 gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget
)->entry
), "changed",
778 GTK_SIGNAL_FUNC(gtk_text_changed_callback
), (gpointer
)this );
781 void wxComboBox::OnSize( wxSizeEvent
&event
)
787 gtk_widget_set_usize( GTK_COMBO(m_widget
)->entry
, m_width
-w
-1, m_height
);
789 gtk_widget_set_uposition( GTK_COMBO(m_widget
)->button
, m_x
+m_width
-w
, m_y
);
790 gtk_widget_set_usize( GTK_COMBO(m_widget
)->button
, w
, m_height
);
794 void wxComboBox::ApplyWidgetStyle()
798 // gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
799 gtk_widget_set_style( GTK_COMBO(m_widget
)->entry
, m_widgetStyle
);
800 gtk_widget_set_style( GTK_COMBO(m_widget
)->list
, m_widgetStyle
);
802 GtkList
*list
= GTK_LIST( GTK_COMBO(m_widget
)->list
);
803 GList
*child
= list
->children
;
806 gtk_widget_set_style( GTK_WIDGET(child
->data
), m_widgetStyle
);
808 GtkBin
*bin
= GTK_BIN(child
->data
);
809 gtk_widget_set_style( bin
->child
, m_widgetStyle
);
815 GtkWidget
* wxComboBox::GetConnectWidget()
817 return GTK_COMBO(m_widget
)->entry
;
820 bool wxComboBox::IsOwnGtkWindow( GdkWindow
*window
)
822 return ( (window
== GTK_ENTRY( GTK_COMBO(m_widget
)->entry
)->text_area
) ||
823 (window
== GTK_COMBO(m_widget
)->button
->window
) );
826 wxSize
wxComboBox::DoGetBestSize() const
828 wxSize
ret( wxControl::DoGetBestSize() );
830 // we know better our horizontal extent: it depends on the longest string
836 size_t count
= GetCount();
837 for ( size_t n
= 0; n
< count
; n
++ )
839 GetTextExtent( GetString(n
), &width
, NULL
, NULL
, NULL
, &m_font
);
845 // empty combobox should have some reasonable default size too