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