]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/combobox.cpp
added wxFrame::Command()
[wxWidgets.git] / src / gtk / combobox.cpp
CommitLineData
53010e52
RR
1/////////////////////////////////////////////////////////////////////////////
2// Name: combobox.cpp
3// Purpose:
4// Author: Robert Roebling
dbf858b5 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
805dd538 7// Licence: wxWindows licence
53010e52
RR
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "combobox.h"
12#endif
13
14#include "wx/combobox.h"
ac57418f 15
1a5a8367 16#include <wx/intl.h>
53010e52 17
83624f79
RR
18#include "gdk/gdk.h"
19#include "gtk/gtk.h"
20
47908e25
RR
21//-----------------------------------------------------------------------------
22// data
23//-----------------------------------------------------------------------------
24
25extern bool g_blockEventsOnDrag;
26
53010e52 27//-----------------------------------------------------------------------------
e1e955e1 28// "select"
47908e25 29//-----------------------------------------------------------------------------
47908e25 30
8a85884a
VZ
31static void
32gtk_combo_clicked_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
53010e52 33{
8a85884a
VZ
34 if (!combo->HasVMT())
35 return;
36
37 if (g_blockEventsOnDrag)
38 return;
805dd538 39
fd0eed64
RR
40 if (combo->m_alreadySent)
41 {
42 combo->m_alreadySent = FALSE;
43 return;
44 }
47908e25 45
fd0eed64 46 combo->m_alreadySent = TRUE;
805dd538 47
8a85884a 48 wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, combo->GetId() );
fd0eed64 49 event.SetInt( combo->GetSelection() );
29006414 50 event.SetString( combo->GetStringSelection() );
8a85884a
VZ
51 event.SetEventObject( combo );
52 combo->GetEventHandler()->ProcessEvent( event );
6de97a3b 53}
47908e25 54
0c77152e
RR
55//-----------------------------------------------------------------------------
56// "changed"
57//-----------------------------------------------------------------------------
58
eeccd5d9 59static void
0c77152e
RR
60gtk_text_changed_callback( GtkWidget *WXUNUSED(widget), wxComboBox *combo )
61{
8a85884a 62 wxCommandEvent event( wxEVT_COMMAND_TEXT_UPDATED, combo->GetId() );
29006414 63 event.SetString( combo->GetValue() );
0c77152e
RR
64 event.SetEventObject( combo );
65 combo->GetEventHandler()->ProcessEvent( event );
0c77152e
RR
66}
67
e1e955e1
RR
68//-----------------------------------------------------------------------------
69// wxComboBox
53010e52
RR
70//-----------------------------------------------------------------------------
71
72IMPLEMENT_DYNAMIC_CLASS(wxComboBox,wxControl)
73
b4071e91 74BEGIN_EVENT_TABLE(wxComboBox, wxControl)
fd0eed64 75 EVT_SIZE(wxComboBox::OnSize)
8a85884a 76 EVT_CHAR(wxComboBox::OnChar)
b4071e91
RR
77END_EVENT_TABLE()
78
fd0eed64
RR
79bool wxComboBox::Create( wxWindow *parent, wxWindowID id, const wxString& value,
80 const wxPoint& pos, const wxSize& size,
81 int n, const wxString choices[],
805dd538
VZ
82 long style, const wxValidator& validator,
83 const wxString& name )
53010e52 84{
fd0eed64
RR
85 m_alreadySent = FALSE;
86 m_needParent = TRUE;
b292e2f5 87 m_acceptsFocus = TRUE;
805dd538 88
fd0eed64 89 PreCreation( parent, id, pos, size, style, name );
805dd538 90
fd0eed64 91 SetValidator( validator );
6de97a3b 92
fd0eed64 93 m_widget = gtk_combo_new();
805dd538 94
8a85884a
VZ
95 // make it more useable
96 gtk_combo_set_use_arrows_always(GTK_COMBO(m_widget), TRUE);
97
fd0eed64 98 wxSize newSize = size;
8a85884a
VZ
99 if (newSize.x == -1)
100 newSize.x = 100;
101 if (newSize.y == -1)
102 newSize.y = 26;
fd0eed64 103 SetSize( newSize.x, newSize.y );
805dd538 104
fd0eed64 105 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 106
fd0eed64
RR
107 for (int i = 0; i < n; i++)
108 {
805dd538
VZ
109 GtkWidget *list_item = gtk_list_item_new_with_label( choices[i] );
110
fd0eed64 111 m_clientDataList.Append( (wxObject*)NULL );
f5e27805 112 m_clientObjectList.Append( (wxObject*)NULL );
805dd538 113
fd0eed64 114 gtk_container_add( GTK_CONTAINER(list), list_item );
805dd538 115
fd0eed64
RR
116 gtk_widget_realize( list_item );
117 gtk_widget_realize( GTK_BIN(list_item)->child );
805dd538 118
fd0eed64 119 gtk_widget_show( list_item );
805dd538
VZ
120
121 gtk_signal_connect( GTK_OBJECT(list_item), "select",
fd0eed64
RR
122 GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
123 }
805dd538 124
fd0eed64 125 m_parent->AddChild( this );
6ca41e57 126
fd0eed64 127 (m_parent->m_insertCallback)( m_parent, this );
805dd538 128
fd0eed64 129 PostCreation();
53010e52 130
fd0eed64 131 ConnectWidget( GTK_COMBO(m_widget)->button );
805dd538 132
fd0eed64 133 if (!value.IsNull()) SetValue( value );
805dd538 134
fd0eed64
RR
135 gtk_widget_realize( GTK_COMBO(m_widget)->list );
136 gtk_widget_realize( GTK_COMBO(m_widget)->entry );
137 gtk_widget_realize( GTK_COMBO(m_widget)->button );
805dd538 138
0c77152e
RR
139 gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed",
140 GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
805dd538 141
fd0eed64
RR
142 SetBackgroundColour( parent->GetBackgroundColour() );
143 SetForegroundColour( parent->GetForegroundColour() );
a7ac4461 144 SetFont( parent->GetFont() );
f96aa4d9 145
fd0eed64 146 Show( TRUE );
805dd538 147
fd0eed64
RR
148 return TRUE;
149}
150
151wxComboBox::~wxComboBox()
152{
153 wxNode *node = m_clientDataList.First();
154 while (node)
155 {
156 wxClientData *cd = (wxClientData*)node->Data();
157 if (cd) delete cd;
158 node = node->Next();
159 }
160 m_clientDataList.Clear();
6de97a3b 161}
53010e52 162
fd0eed64 163void wxComboBox::AppendCommon( const wxString &item )
53010e52 164{
fd0eed64 165 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 166
fd0eed64 167 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538
VZ
168
169 GtkWidget *list_item = gtk_list_item_new_with_label( item );
170
171 gtk_signal_connect( GTK_OBJECT(list_item), "select",
fd0eed64 172 GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
805dd538 173
fd0eed64 174 gtk_container_add( GTK_CONTAINER(list), list_item );
805dd538 175
fd0eed64 176 if (m_widgetStyle) ApplyWidgetStyle();
805dd538 177
fd0eed64 178 gtk_widget_show( list_item );
6de97a3b 179}
53010e52
RR
180
181void wxComboBox::Append( const wxString &item )
47908e25 182{
f5e27805
RR
183 m_clientDataList.Append( (wxObject*) NULL );
184 m_clientObjectList.Append( (wxObject*) NULL );
805dd538 185
fd0eed64 186 AppendCommon( item );
6de97a3b 187}
47908e25 188
fd0eed64 189void wxComboBox::Append( const wxString &item, void *clientData )
53010e52 190{
f5e27805
RR
191 m_clientDataList.Append( (wxObject*) clientData );
192 m_clientObjectList.Append( (wxObject*)NULL );
805dd538 193
fd0eed64 194 AppendCommon( item );
6de97a3b 195}
53010e52 196
fd0eed64 197void wxComboBox::Append( const wxString &item, wxClientData *clientData )
53010e52 198{
f5e27805
RR
199 m_clientDataList.Append( (wxObject*) NULL );
200 m_clientObjectList.Append( (wxObject*) clientData );
805dd538 201
fd0eed64
RR
202 AppendCommon( item );
203}
204
205void wxComboBox::SetClientData( int n, void* clientData )
206{
207 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 208
fd0eed64
RR
209 wxNode *node = m_clientDataList.Nth( n );
210 if (!node) return;
805dd538 211
f5e27805 212 node->SetData( (wxObject*) clientData );
6de97a3b 213}
53010e52 214
fd0eed64 215void* wxComboBox::GetClientData( int n )
53010e52 216{
fd0eed64 217 wxCHECK_MSG( m_widget != NULL, NULL, "invalid combobox" );
805dd538 218
fd0eed64
RR
219 wxNode *node = m_clientDataList.Nth( n );
220 if (!node) return NULL;
805dd538 221
f5e27805 222 return node->Data();
fd0eed64
RR
223}
224
225void wxComboBox::SetClientObject( int n, wxClientData* clientData )
226{
227 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 228
f5e27805 229 wxNode *node = m_clientObjectList.Nth( n );
fd0eed64 230 if (!node) return;
805dd538 231
fd0eed64
RR
232 wxClientData *cd = (wxClientData*) node->Data();
233 if (cd) delete cd;
805dd538 234
fd0eed64 235 node->SetData( (wxObject*) clientData );
6de97a3b 236}
53010e52 237
fd0eed64 238wxClientData* wxComboBox::GetClientObject( int n )
53010e52 239{
fd0eed64 240 wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, "invalid combobox" );
805dd538 241
fd0eed64
RR
242 wxNode *node = m_clientDataList.Nth( n );
243 if (!node) return (wxClientData*) NULL;
805dd538 244
fd0eed64
RR
245 return (wxClientData*) node->Data();
246}
247
248void wxComboBox::Clear()
249{
250 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 251
fd0eed64
RR
252 GtkWidget *list = GTK_COMBO(m_widget)->list;
253 gtk_list_clear_items( GTK_LIST(list), 0, Number() );
805dd538 254
f5e27805 255 wxNode *node = m_clientObjectList.First();
fd0eed64
RR
256 while (node)
257 {
258 wxClientData *cd = (wxClientData*)node->Data();
259 if (cd) delete cd;
260 node = node->Next();
261 }
f5e27805 262 m_clientObjectList.Clear();
805dd538 263
fd0eed64 264 m_clientDataList.Clear();
6de97a3b 265}
53010e52 266
fd0eed64 267void wxComboBox::Delete( int n )
53010e52 268{
fd0eed64 269 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 270
fd0eed64 271 GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
805dd538 272
fd0eed64 273 GList *child = g_list_nth( listbox->children, n );
805dd538 274
fd0eed64
RR
275 if (!child)
276 {
277 wxFAIL_MSG("wrong index");
278 return;
279 }
805dd538 280
bbe0af5b 281 GList *list = g_list_append( (GList*) NULL, child->data );
fd0eed64
RR
282 gtk_list_remove_items( listbox, list );
283 g_list_free( list );
805dd538 284
f5e27805
RR
285 wxNode *node = m_clientObjectList.Nth( n );
286 if (node)
fd0eed64
RR
287 {
288 wxClientData *cd = (wxClientData*)node->Data();
289 if (cd) delete cd;
f5e27805
RR
290 m_clientObjectList.DeleteNode( node );
291 }
805dd538 292
f5e27805
RR
293 node = m_clientDataList.Nth( n );
294 if (node)
295 {
fd0eed64
RR
296 m_clientDataList.DeleteNode( node );
297 }
6de97a3b 298}
53010e52 299
fd0eed64 300int wxComboBox::FindString( const wxString &item )
53010e52 301{
fd0eed64 302 wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
805dd538 303
fd0eed64 304 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 305
53010e52
RR
306 GList *child = GTK_LIST(list)->children;
307 int count = 0;
308 while (child)
309 {
fd0eed64
RR
310 GtkBin *bin = GTK_BIN( child->data );
311 GtkLabel *label = GTK_LABEL( bin->child );
7cf8cb48
VZ
312 if (item == label->label)
313 return count;
fd0eed64
RR
314 count++;
315 child = child->next;
316 }
805dd538 317
7cf8cb48 318 return wxNOT_FOUND;
fd0eed64
RR
319}
320
321int wxComboBox::GetSelection() const
322{
323 wxCHECK_MSG( m_widget != NULL, -1, "invalid combobox" );
805dd538 324
fd0eed64 325 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 326
fd0eed64
RR
327 GList *selection = GTK_LIST(list)->selection;
328 if (selection)
329 {
330 GList *child = GTK_LIST(list)->children;
331 int count = 0;
332 while (child)
333 {
334 if (child->data == selection->data) return count;
335 count++;
336 child = child->next;
337 }
6de97a3b 338 }
805dd538 339
fd0eed64 340 wxFAIL_MSG( "wxComboBox: no selection" );
805dd538 341
fd0eed64 342 return -1;
6de97a3b 343}
53010e52 344
debe6624 345wxString wxComboBox::GetString( int n ) const
53010e52 346{
fd0eed64 347 wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
805dd538 348
fd0eed64 349 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 350
7cf8cb48 351 wxString str;
fd0eed64
RR
352 GList *child = g_list_nth( GTK_LIST(list)->children, n );
353 if (child)
354 {
355 GtkBin *bin = GTK_BIN( child->data );
356 GtkLabel *label = GTK_LABEL( bin->child );
7cf8cb48
VZ
357 str = label->label;
358 }
359 else
360 {
361 wxFAIL_MSG( "wxComboBox: wrong index" );
fd0eed64 362 }
805dd538 363
7cf8cb48 364 return str;
6de97a3b 365}
53010e52 366
fd0eed64 367wxString wxComboBox::GetStringSelection() const
53010e52 368{
fd0eed64 369 wxCHECK_MSG( m_widget != NULL, "", "invalid combobox" );
805dd538 370
fd0eed64 371 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 372
fd0eed64
RR
373 GList *selection = GTK_LIST(list)->selection;
374 if (selection)
375 {
376 GtkBin *bin = GTK_BIN( selection->data );
377 wxString tmp = GTK_LABEL( bin->child )->label;
378 return tmp;
379 }
805dd538 380
fd0eed64 381 wxFAIL_MSG( "wxComboBox: no selection" );
805dd538 382
fd0eed64 383 return "";
6de97a3b 384}
53010e52 385
fd0eed64 386int wxComboBox::Number() const
53010e52 387{
fd0eed64 388 wxCHECK_MSG( m_widget != NULL, 0, "invalid combobox" );
805dd538 389
fd0eed64 390 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 391
fd0eed64
RR
392 GList *child = GTK_LIST(list)->children;
393 int count = 0;
394 while (child) { count++; child = child->next; }
395 return count;
6de97a3b 396}
53010e52 397
debe6624 398void wxComboBox::SetSelection( int n )
53010e52 399{
fd0eed64 400 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 401
fd0eed64
RR
402 GtkWidget *list = GTK_COMBO(m_widget)->list;
403 gtk_list_select_item( GTK_LIST(list), n );
6de97a3b 404}
53010e52 405
47908e25
RR
406void wxComboBox::SetStringSelection( const wxString &string )
407{
fd0eed64 408 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 409
fd0eed64
RR
410 int res = FindString( string );
411 if (res == -1) return;
412 SetSelection( res );
6de97a3b 413}
47908e25 414
fd0eed64 415wxString wxComboBox::GetValue() const
53010e52 416{
fd0eed64
RR
417 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
418 wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) );
419 return tmp;
6de97a3b 420}
53010e52
RR
421
422void wxComboBox::SetValue( const wxString& value )
423{
fd0eed64 424 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 425
fd0eed64
RR
426 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
427 wxString tmp = "";
428 if (!value.IsNull()) tmp = value;
429 gtk_entry_set_text( GTK_ENTRY(entry), tmp );
6de97a3b 430}
53010e52 431
fd0eed64 432void wxComboBox::Copy()
53010e52 433{
fd0eed64 434 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 435
fd0eed64 436 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
75ed1d15 437#if (GTK_MINOR_VERSION == 1)
fd0eed64 438 gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
75ed1d15 439#else
fd0eed64 440 gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
75ed1d15 441#endif
6de97a3b 442}
53010e52 443
fd0eed64 444void wxComboBox::Cut()
53010e52 445{
fd0eed64 446 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 447
fd0eed64 448 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
75ed1d15 449#if (GTK_MINOR_VERSION == 1)
fd0eed64 450 gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
75ed1d15 451#else
fd0eed64 452 gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
75ed1d15 453#endif
6de97a3b 454}
53010e52 455
fd0eed64 456void wxComboBox::Paste()
53010e52 457{
fd0eed64 458 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 459
fd0eed64 460 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
75ed1d15 461#if (GTK_MINOR_VERSION == 1)
fd0eed64 462 gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
75ed1d15 463#else
fd0eed64 464 gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
75ed1d15 465#endif
6de97a3b 466}
53010e52 467
debe6624 468void wxComboBox::SetInsertionPoint( long pos )
53010e52 469{
fd0eed64 470 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 471
fd0eed64 472 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
073c8fe9 473 gtk_entry_set_position( GTK_ENTRY(entry), (int)pos );
6de97a3b 474}
53010e52 475
fd0eed64 476void wxComboBox::SetInsertionPointEnd()
53010e52 477{
fd0eed64 478 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538
VZ
479
480 SetInsertionPoint( -1 );
6de97a3b 481}
53010e52 482
fd0eed64 483long wxComboBox::GetInsertionPoint() const
53010e52 484{
fd0eed64
RR
485 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
486 return (long) GTK_EDITABLE(entry)->current_pos;
6de97a3b 487}
53010e52 488
fd0eed64 489long wxComboBox::GetLastPosition() const
53010e52 490{
fd0eed64
RR
491 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
492 int pos = GTK_ENTRY(entry)->text_length;
493 return (long) pos-1;
6de97a3b 494}
53010e52 495
debe6624 496void wxComboBox::Replace( long from, long to, const wxString& value )
53010e52 497{
fd0eed64 498 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 499
fd0eed64
RR
500 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
501 gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
502 if (value.IsNull()) return;
503 gint pos = (gint)to;
504 gtk_editable_insert_text( GTK_EDITABLE(entry), value, value.Length(), &pos );
6de97a3b 505}
53010e52 506
debe6624 507void wxComboBox::Remove(long from, long to)
53010e52 508{
fd0eed64 509 wxCHECK_RET( m_widget != NULL, "invalid combobox" );
805dd538 510
fd0eed64
RR
511 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
512 gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
6de97a3b 513}
53010e52 514
20d10ee1 515void wxComboBox::SetSelection( long from, long to )
53010e52 516{
20d10ee1
VZ
517 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
518 gtk_editable_select_region( GTK_EDITABLE(entry), (gint)from, (gint)to );
6de97a3b 519}
53010e52 520
20d10ee1 521void wxComboBox::SetEditable( bool editable )
53010e52 522{
20d10ee1
VZ
523 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
524 gtk_entry_set_editable( GTK_ENTRY(entry), editable );
b4071e91
RR
525}
526
8a85884a
VZ
527void wxComboBox::OnChar( wxKeyEvent &event )
528{
7cf8cb48 529 if ( event.KeyCode() == WXK_RETURN )
8a85884a 530 {
7cf8cb48 531 wxString value = GetValue();
8a85884a 532
7cf8cb48
VZ
533 if ( Number() == 0 )
534 {
535 // make Enter generate "selected" event if there is only one item
536 // in the combobox - without it, it's impossible to select it at
537 // all!
538 wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, GetId() );
539 event.SetInt( 0 );
29006414 540 event.SetString( value );
7cf8cb48
VZ
541 event.SetEventObject( this );
542 GetEventHandler()->ProcessEvent( event );
543 }
544 else
545 {
546 // add the item to the list if it's not there yet
547 if ( FindString(value) == wxNOT_FOUND )
548 {
549 Append(value);
550
551 // and generate the selected event for it
552 wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, GetId() );
553 event.SetInt( Number() - 1 );
29006414 554 event.SetString( value );
7cf8cb48
VZ
555 event.SetEventObject( this );
556 GetEventHandler()->ProcessEvent( event );
557 }
558 //else: do nothing, this will open the listbox
559 }
8a85884a 560 }
7cf8cb48
VZ
561
562 event.Skip();
8a85884a
VZ
563}
564
b4071e91
RR
565void wxComboBox::OnSize( wxSizeEvent &event )
566{
fd0eed64 567 wxControl::OnSize( event );
805dd538 568
fd0eed64
RR
569 int w = 21;
570 gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
805dd538 571
fd0eed64
RR
572 gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y );
573 gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height );
6de97a3b 574}
53010e52 575
58614078 576void wxComboBox::ApplyWidgetStyle()
868a2826 577{
fd0eed64 578 SetWidgetStyle();
805dd538 579
fd0eed64
RR
580 gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
581 gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
582 gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
805dd538 583
fd0eed64
RR
584 GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
585 GList *child = list->children;
586 while (child)
587 {
588 gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
805dd538 589
fd0eed64
RR
590 GtkBin *bin = GTK_BIN(child->data);
591 gtk_widget_set_style( bin->child, m_widgetStyle );
805dd538 592
fd0eed64
RR
593 child = child->next;
594 }
868a2826 595}
b4071e91 596
fd0eed64 597GtkWidget* wxComboBox::GetConnectWidget()
97b3455a 598{
fd0eed64 599 return GTK_COMBO(m_widget)->entry;
97b3455a
RR
600}
601
b4071e91
RR
602bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
603{
fd0eed64
RR
604 return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) ||
605 (window == GTK_COMBO(m_widget)->button->window ) );
b4071e91 606}
ac57418f 607