]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/combobox.cpp
log messages given during program initialization are not discarded any more
[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 {
93c5dd39 109 GtkWidget *list_item = gtk_list_item_new_with_label( choices[i].mbc_str() );
805dd538 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
a260fe6a
RR
139 if (style & wxCB_READONLY)
140 gtk_entry_set_editable( GTK_ENTRY( GTK_COMBO(m_widget)->entry ), FALSE );
141
0c77152e
RR
142 gtk_signal_connect( GTK_OBJECT(GTK_COMBO(m_widget)->entry), "changed",
143 GTK_SIGNAL_FUNC(gtk_text_changed_callback), (gpointer)this);
805dd538 144
fd0eed64
RR
145 SetBackgroundColour( parent->GetBackgroundColour() );
146 SetForegroundColour( parent->GetForegroundColour() );
a7ac4461 147 SetFont( parent->GetFont() );
f96aa4d9 148
fd0eed64 149 Show( TRUE );
805dd538 150
fd0eed64
RR
151 return TRUE;
152}
153
154wxComboBox::~wxComboBox()
155{
156 wxNode *node = m_clientDataList.First();
157 while (node)
158 {
159 wxClientData *cd = (wxClientData*)node->Data();
160 if (cd) delete cd;
161 node = node->Next();
162 }
163 m_clientDataList.Clear();
6de97a3b 164}
53010e52 165
fd0eed64 166void wxComboBox::AppendCommon( const wxString &item )
53010e52 167{
93c5dd39 168 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 169
fd0eed64 170 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 171
93c5dd39 172 GtkWidget *list_item = gtk_list_item_new_with_label( item.mbc_str() );
805dd538
VZ
173
174 gtk_signal_connect( GTK_OBJECT(list_item), "select",
fd0eed64 175 GTK_SIGNAL_FUNC(gtk_combo_clicked_callback), (gpointer)this );
805dd538 176
fd0eed64 177 gtk_container_add( GTK_CONTAINER(list), list_item );
805dd538 178
fd0eed64 179 if (m_widgetStyle) ApplyWidgetStyle();
805dd538 180
fd0eed64 181 gtk_widget_show( list_item );
6de97a3b 182}
53010e52
RR
183
184void wxComboBox::Append( const wxString &item )
47908e25 185{
f5e27805
RR
186 m_clientDataList.Append( (wxObject*) NULL );
187 m_clientObjectList.Append( (wxObject*) NULL );
805dd538 188
fd0eed64 189 AppendCommon( item );
6de97a3b 190}
47908e25 191
fd0eed64 192void wxComboBox::Append( const wxString &item, void *clientData )
53010e52 193{
f5e27805
RR
194 m_clientDataList.Append( (wxObject*) clientData );
195 m_clientObjectList.Append( (wxObject*)NULL );
805dd538 196
fd0eed64 197 AppendCommon( item );
6de97a3b 198}
53010e52 199
fd0eed64 200void wxComboBox::Append( const wxString &item, wxClientData *clientData )
53010e52 201{
f5e27805
RR
202 m_clientDataList.Append( (wxObject*) NULL );
203 m_clientObjectList.Append( (wxObject*) clientData );
805dd538 204
fd0eed64
RR
205 AppendCommon( item );
206}
207
208void wxComboBox::SetClientData( int n, void* clientData )
209{
93c5dd39 210 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 211
fd0eed64
RR
212 wxNode *node = m_clientDataList.Nth( n );
213 if (!node) return;
805dd538 214
f5e27805 215 node->SetData( (wxObject*) clientData );
6de97a3b 216}
53010e52 217
fd0eed64 218void* wxComboBox::GetClientData( int n )
53010e52 219{
93c5dd39 220 wxCHECK_MSG( m_widget != NULL, NULL, _T("invalid combobox") );
805dd538 221
fd0eed64
RR
222 wxNode *node = m_clientDataList.Nth( n );
223 if (!node) return NULL;
805dd538 224
f5e27805 225 return node->Data();
fd0eed64
RR
226}
227
228void wxComboBox::SetClientObject( int n, wxClientData* clientData )
229{
93c5dd39 230 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 231
f5e27805 232 wxNode *node = m_clientObjectList.Nth( n );
fd0eed64 233 if (!node) return;
805dd538 234
fd0eed64
RR
235 wxClientData *cd = (wxClientData*) node->Data();
236 if (cd) delete cd;
805dd538 237
fd0eed64 238 node->SetData( (wxObject*) clientData );
6de97a3b 239}
53010e52 240
fd0eed64 241wxClientData* wxComboBox::GetClientObject( int n )
53010e52 242{
93c5dd39 243 wxCHECK_MSG( m_widget != NULL, (wxClientData*)NULL, _T("invalid combobox") );
805dd538 244
fd0eed64
RR
245 wxNode *node = m_clientDataList.Nth( n );
246 if (!node) return (wxClientData*) NULL;
805dd538 247
fd0eed64
RR
248 return (wxClientData*) node->Data();
249}
250
251void wxComboBox::Clear()
252{
93c5dd39 253 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 254
fd0eed64
RR
255 GtkWidget *list = GTK_COMBO(m_widget)->list;
256 gtk_list_clear_items( GTK_LIST(list), 0, Number() );
805dd538 257
f5e27805 258 wxNode *node = m_clientObjectList.First();
fd0eed64
RR
259 while (node)
260 {
261 wxClientData *cd = (wxClientData*)node->Data();
262 if (cd) delete cd;
263 node = node->Next();
264 }
f5e27805 265 m_clientObjectList.Clear();
805dd538 266
fd0eed64 267 m_clientDataList.Clear();
6de97a3b 268}
53010e52 269
fd0eed64 270void wxComboBox::Delete( int n )
53010e52 271{
93c5dd39 272 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 273
fd0eed64 274 GtkList *listbox = GTK_LIST( GTK_COMBO(m_widget)->list );
805dd538 275
fd0eed64 276 GList *child = g_list_nth( listbox->children, n );
805dd538 277
fd0eed64
RR
278 if (!child)
279 {
93c5dd39 280 wxFAIL_MSG(_T("wrong index"));
fd0eed64
RR
281 return;
282 }
805dd538 283
bbe0af5b 284 GList *list = g_list_append( (GList*) NULL, child->data );
fd0eed64
RR
285 gtk_list_remove_items( listbox, list );
286 g_list_free( list );
805dd538 287
f5e27805
RR
288 wxNode *node = m_clientObjectList.Nth( n );
289 if (node)
fd0eed64
RR
290 {
291 wxClientData *cd = (wxClientData*)node->Data();
292 if (cd) delete cd;
f5e27805
RR
293 m_clientObjectList.DeleteNode( node );
294 }
805dd538 295
f5e27805
RR
296 node = m_clientDataList.Nth( n );
297 if (node)
298 {
fd0eed64
RR
299 m_clientDataList.DeleteNode( node );
300 }
6de97a3b 301}
53010e52 302
fd0eed64 303int wxComboBox::FindString( const wxString &item )
53010e52 304{
93c5dd39 305 wxCHECK_MSG( m_widget != NULL, -1, _T("invalid combobox") );
805dd538 306
fd0eed64 307 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 308
53010e52
RR
309 GList *child = GTK_LIST(list)->children;
310 int count = 0;
311 while (child)
312 {
fd0eed64
RR
313 GtkBin *bin = GTK_BIN( child->data );
314 GtkLabel *label = GTK_LABEL( bin->child );
7cf8cb48
VZ
315 if (item == label->label)
316 return count;
fd0eed64
RR
317 count++;
318 child = child->next;
319 }
805dd538 320
7cf8cb48 321 return wxNOT_FOUND;
fd0eed64
RR
322}
323
324int wxComboBox::GetSelection() const
325{
93c5dd39 326 wxCHECK_MSG( m_widget != NULL, -1, _T("invalid combobox") );
805dd538 327
fd0eed64 328 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 329
fd0eed64
RR
330 GList *selection = GTK_LIST(list)->selection;
331 if (selection)
332 {
333 GList *child = GTK_LIST(list)->children;
334 int count = 0;
335 while (child)
336 {
337 if (child->data == selection->data) return count;
338 count++;
339 child = child->next;
340 }
6de97a3b 341 }
805dd538 342
93c5dd39 343 wxFAIL_MSG( _T("wxComboBox: no selection") );
805dd538 344
fd0eed64 345 return -1;
6de97a3b 346}
53010e52 347
debe6624 348wxString wxComboBox::GetString( int n ) const
53010e52 349{
93c5dd39 350 wxCHECK_MSG( m_widget != NULL, _T(""), _T("invalid combobox") );
805dd538 351
fd0eed64 352 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 353
7cf8cb48 354 wxString str;
fd0eed64
RR
355 GList *child = g_list_nth( GTK_LIST(list)->children, n );
356 if (child)
357 {
358 GtkBin *bin = GTK_BIN( child->data );
359 GtkLabel *label = GTK_LABEL( bin->child );
7cf8cb48
VZ
360 str = label->label;
361 }
362 else
363 {
93c5dd39 364 wxFAIL_MSG( _T("wxComboBox: wrong index") );
fd0eed64 365 }
805dd538 366
7cf8cb48 367 return str;
6de97a3b 368}
53010e52 369
fd0eed64 370wxString wxComboBox::GetStringSelection() const
53010e52 371{
93c5dd39 372 wxCHECK_MSG( m_widget != NULL, _T(""), _T("invalid combobox") );
805dd538 373
fd0eed64 374 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 375
fd0eed64
RR
376 GList *selection = GTK_LIST(list)->selection;
377 if (selection)
378 {
379 GtkBin *bin = GTK_BIN( selection->data );
380 wxString tmp = GTK_LABEL( bin->child )->label;
381 return tmp;
382 }
805dd538 383
93c5dd39 384 wxFAIL_MSG( _T("wxComboBox: no selection") );
805dd538 385
93c5dd39 386 return _T("");
6de97a3b 387}
53010e52 388
fd0eed64 389int wxComboBox::Number() const
53010e52 390{
93c5dd39 391 wxCHECK_MSG( m_widget != NULL, 0, _T("invalid combobox") );
805dd538 392
fd0eed64 393 GtkWidget *list = GTK_COMBO(m_widget)->list;
805dd538 394
fd0eed64
RR
395 GList *child = GTK_LIST(list)->children;
396 int count = 0;
397 while (child) { count++; child = child->next; }
398 return count;
6de97a3b 399}
53010e52 400
debe6624 401void wxComboBox::SetSelection( int n )
53010e52 402{
93c5dd39 403 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 404
fd0eed64
RR
405 GtkWidget *list = GTK_COMBO(m_widget)->list;
406 gtk_list_select_item( GTK_LIST(list), n );
6de97a3b 407}
53010e52 408
47908e25
RR
409void wxComboBox::SetStringSelection( const wxString &string )
410{
93c5dd39 411 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 412
fd0eed64
RR
413 int res = FindString( string );
414 if (res == -1) return;
415 SetSelection( res );
6de97a3b 416}
47908e25 417
fd0eed64 418wxString wxComboBox::GetValue() const
53010e52 419{
fd0eed64
RR
420 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
421 wxString tmp = gtk_entry_get_text( GTK_ENTRY(entry) );
422 return tmp;
6de97a3b 423}
53010e52
RR
424
425void wxComboBox::SetValue( const wxString& value )
426{
93c5dd39 427 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 428
fd0eed64 429 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
93c5dd39 430 wxString tmp = _T("");
fd0eed64 431 if (!value.IsNull()) tmp = value;
93c5dd39 432 gtk_entry_set_text( GTK_ENTRY(entry), tmp.mbc_str() );
6de97a3b 433}
53010e52 434
fd0eed64 435void wxComboBox::Copy()
53010e52 436{
93c5dd39 437 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 438
fd0eed64 439 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
d345e841 440#if (GTK_MINOR_VERSION > 0)
fd0eed64 441 gtk_editable_copy_clipboard( GTK_EDITABLE(entry) );
75ed1d15 442#else
fd0eed64 443 gtk_editable_copy_clipboard( GTK_EDITABLE(entry), 0 );
75ed1d15 444#endif
6de97a3b 445}
53010e52 446
fd0eed64 447void wxComboBox::Cut()
53010e52 448{
93c5dd39 449 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 450
fd0eed64 451 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
d345e841 452#if (GTK_MINOR_VERSION > 0)
fd0eed64 453 gtk_editable_cut_clipboard( GTK_EDITABLE(entry) );
75ed1d15 454#else
fd0eed64 455 gtk_editable_cut_clipboard( GTK_EDITABLE(entry), 0 );
75ed1d15 456#endif
6de97a3b 457}
53010e52 458
fd0eed64 459void wxComboBox::Paste()
53010e52 460{
93c5dd39 461 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 462
fd0eed64 463 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
d345e841 464#if (GTK_MINOR_VERSION > 0)
fd0eed64 465 gtk_editable_paste_clipboard( GTK_EDITABLE(entry) );
75ed1d15 466#else
fd0eed64 467 gtk_editable_paste_clipboard( GTK_EDITABLE(entry), 0 );
75ed1d15 468#endif
6de97a3b 469}
53010e52 470
debe6624 471void wxComboBox::SetInsertionPoint( long pos )
53010e52 472{
93c5dd39 473 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 474
fd0eed64 475 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
073c8fe9 476 gtk_entry_set_position( GTK_ENTRY(entry), (int)pos );
6de97a3b 477}
53010e52 478
fd0eed64 479void wxComboBox::SetInsertionPointEnd()
53010e52 480{
93c5dd39 481 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538
VZ
482
483 SetInsertionPoint( -1 );
6de97a3b 484}
53010e52 485
fd0eed64 486long wxComboBox::GetInsertionPoint() const
53010e52 487{
fd0eed64
RR
488 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
489 return (long) GTK_EDITABLE(entry)->current_pos;
6de97a3b 490}
53010e52 491
fd0eed64 492long wxComboBox::GetLastPosition() const
53010e52 493{
fd0eed64
RR
494 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
495 int pos = GTK_ENTRY(entry)->text_length;
496 return (long) pos-1;
6de97a3b 497}
53010e52 498
debe6624 499void wxComboBox::Replace( long from, long to, const wxString& value )
53010e52 500{
93c5dd39
OK
501 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
502 // FIXME: not quite sure how to do this method right in multibyte mode
805dd538 503
fd0eed64
RR
504 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
505 gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
506 if (value.IsNull()) return;
507 gint pos = (gint)to;
93c5dd39 508 gtk_editable_insert_text( GTK_EDITABLE(entry), value.mbc_str(), value.Length(), &pos );
6de97a3b 509}
53010e52 510
debe6624 511void wxComboBox::Remove(long from, long to)
53010e52 512{
93c5dd39 513 wxCHECK_RET( m_widget != NULL, _T("invalid combobox") );
805dd538 514
fd0eed64
RR
515 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
516 gtk_editable_delete_text( GTK_EDITABLE(entry), (gint)from, (gint)to );
6de97a3b 517}
53010e52 518
20d10ee1 519void wxComboBox::SetSelection( long from, long to )
53010e52 520{
20d10ee1
VZ
521 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
522 gtk_editable_select_region( GTK_EDITABLE(entry), (gint)from, (gint)to );
6de97a3b 523}
53010e52 524
20d10ee1 525void wxComboBox::SetEditable( bool editable )
53010e52 526{
20d10ee1
VZ
527 GtkWidget *entry = GTK_COMBO(m_widget)->entry;
528 gtk_entry_set_editable( GTK_ENTRY(entry), editable );
b4071e91
RR
529}
530
8a85884a
VZ
531void wxComboBox::OnChar( wxKeyEvent &event )
532{
7cf8cb48 533 if ( event.KeyCode() == WXK_RETURN )
8a85884a 534 {
7cf8cb48 535 wxString value = GetValue();
8a85884a 536
7cf8cb48
VZ
537 if ( Number() == 0 )
538 {
539 // make Enter generate "selected" event if there is only one item
540 // in the combobox - without it, it's impossible to select it at
541 // all!
542 wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, GetId() );
543 event.SetInt( 0 );
29006414 544 event.SetString( value );
7cf8cb48
VZ
545 event.SetEventObject( this );
546 GetEventHandler()->ProcessEvent( event );
547 }
548 else
549 {
550 // add the item to the list if it's not there yet
551 if ( FindString(value) == wxNOT_FOUND )
552 {
553 Append(value);
554
555 // and generate the selected event for it
556 wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, GetId() );
557 event.SetInt( Number() - 1 );
29006414 558 event.SetString( value );
7cf8cb48
VZ
559 event.SetEventObject( this );
560 GetEventHandler()->ProcessEvent( event );
561 }
562 //else: do nothing, this will open the listbox
563 }
8a85884a 564 }
7cf8cb48
VZ
565
566 event.Skip();
8a85884a
VZ
567}
568
b4071e91
RR
569void wxComboBox::OnSize( wxSizeEvent &event )
570{
fd0eed64 571 wxControl::OnSize( event );
805dd538 572
fd0eed64
RR
573 int w = 21;
574 gtk_widget_set_usize( GTK_COMBO(m_widget)->entry, m_width-w-1, m_height );
805dd538 575
fd0eed64
RR
576 gtk_widget_set_uposition( GTK_COMBO(m_widget)->button, m_x+m_width-w, m_y );
577 gtk_widget_set_usize( GTK_COMBO(m_widget)->button, w, m_height );
6de97a3b 578}
53010e52 579
58614078 580void wxComboBox::ApplyWidgetStyle()
868a2826 581{
fd0eed64 582 SetWidgetStyle();
805dd538 583
fd0eed64
RR
584 gtk_widget_set_style( GTK_COMBO(m_widget)->button, m_widgetStyle );
585 gtk_widget_set_style( GTK_COMBO(m_widget)->entry, m_widgetStyle );
586 gtk_widget_set_style( GTK_COMBO(m_widget)->list, m_widgetStyle );
805dd538 587
fd0eed64
RR
588 GtkList *list = GTK_LIST( GTK_COMBO(m_widget)->list );
589 GList *child = list->children;
590 while (child)
591 {
592 gtk_widget_set_style( GTK_WIDGET(child->data), m_widgetStyle );
805dd538 593
fd0eed64
RR
594 GtkBin *bin = GTK_BIN(child->data);
595 gtk_widget_set_style( bin->child, m_widgetStyle );
805dd538 596
fd0eed64
RR
597 child = child->next;
598 }
868a2826 599}
b4071e91 600
fd0eed64 601GtkWidget* wxComboBox::GetConnectWidget()
97b3455a 602{
fd0eed64 603 return GTK_COMBO(m_widget)->entry;
97b3455a
RR
604}
605
b4071e91
RR
606bool wxComboBox::IsOwnGtkWindow( GdkWindow *window )
607{
fd0eed64
RR
608 return ( (window == GTK_ENTRY( GTK_COMBO(m_widget)->entry )->text_area) ||
609 (window == GTK_COMBO(m_widget)->button->window ) );
b4071e91 610}
ac57418f 611