]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/choice.cpp
gtk version check should be runtime, not compile time
[wxWidgets.git] / src / gtk / choice.cpp
CommitLineData
c801d85f 1/////////////////////////////////////////////////////////////////////////////
11e62fe6 2// Name: src/gtk/choice.cpp
c801d85f
KB
3// Purpose:
4// Author: Robert Roebling
dbf858b5 5// Id: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
65571936 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
8228b893 10#include "wx/wxprec.h"
c801d85f 11
ce4169a4
RR
12#if wxUSE_CHOICE
13
1e6feb95 14#include "wx/choice.h"
aaa6d89a
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/arrstr.h"
18#endif
1e6feb95 19
1efb5db8
MR
20// FIXME: We use GtkOptionMenu which has been deprecated since GTK+ 2.3.0 in
21// favour of GtkComboBox.
22// Later use GtkComboBox if GTK+ runtime version is new enough.
23#include <gtk/gtkversion.h>
24#if defined(GTK_DISABLE_DEPRECATED) && GTK_CHECK_VERSION(2,3,0)
25#undef GTK_DISABLE_DEPRECATED
26#endif
27
9e691f46 28#include "wx/gtk/private.h"
83624f79 29
66bd6b93
RR
30//-----------------------------------------------------------------------------
31// data
32//-----------------------------------------------------------------------------
33
34extern bool g_blockEventsOnDrag;
35
c801d85f 36//-----------------------------------------------------------------------------
e1e955e1 37// "activate"
c801d85f
KB
38//-----------------------------------------------------------------------------
39
865bb325 40extern "C" {
66bd6b93 41static void gtk_choice_clicked_callback( GtkWidget *WXUNUSED(widget), wxChoice *choice )
c801d85f 42{
a2053b27 43 if (!choice->m_hasVMT) return;
29006414 44
acfd422a 45 if (g_blockEventsOnDrag) return;
29006414 46
5f3565a2
RR
47 int selection = wxNOT_FOUND;
48
5f3565a2 49 selection = gtk_option_menu_get_history( GTK_OPTION_MENU(choice->GetHandle()) );
5f3565a2 50
5f3565a2
RR
51 choice->m_selection_hack = selection;
52
acfd422a 53 wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, choice->GetId() );
6c8a980f
VZ
54 int n = choice->GetSelection();
55
56 event.SetInt( n );
acfd422a
RR
57 event.SetString( choice->GetStringSelection() );
58 event.SetEventObject(choice);
6c8a980f
VZ
59
60 if ( choice->HasClientObjectData() )
61 event.SetClientObject( choice->GetClientObject(n) );
62 else if ( choice->HasClientUntypedData() )
63 event.SetClientData( choice->GetClientData(n) );
64
acfd422a 65 choice->GetEventHandler()->ProcessEvent(event);
6de97a3b 66}
865bb325 67}
c801d85f 68
e1e955e1
RR
69//-----------------------------------------------------------------------------
70// wxChoice
c801d85f
KB
71//-----------------------------------------------------------------------------
72
7f4dc78d 73IMPLEMENT_DYNAMIC_CLASS(wxChoice,wxControl)
c801d85f 74
fd0eed64 75wxChoice::wxChoice()
c801d85f 76{
e01c8145 77 m_strings = (wxSortedArrayString *)NULL;
6de97a3b 78}
c801d85f 79
584ad2a3
MB
80bool wxChoice::Create( wxWindow *parent, wxWindowID id,
81 const wxPoint &pos, const wxSize &size,
82 const wxArrayString& choices,
83 long style, const wxValidator& validator,
84 const wxString &name )
85{
86 wxCArrayString chs(choices);
87
88 return Create( parent, id, pos, size, chs.GetCount(), chs.GetStrings(),
89 style, validator, name );
90}
91
debe6624 92bool wxChoice::Create( wxWindow *parent, wxWindowID id,
fd0eed64
RR
93 const wxPoint &pos, const wxSize &size,
94 int n, const wxString choices[],
95 long style, const wxValidator& validator, const wxString &name )
c801d85f 96{
4dcaf11a
RR
97 if (!PreCreation( parent, pos, size ) ||
98 !CreateBase( parent, id, pos, size, style, validator, name ))
99 {
223d09f6 100 wxFAIL_MSG( wxT("wxChoice creation failed") );
0a164d4c 101 return false;
4dcaf11a 102 }
6de97a3b 103
fd0eed64 104 m_widget = gtk_option_menu_new();
29006414 105
e01c8145
VZ
106 if ( style & wxCB_SORT )
107 {
108 // if our m_strings != NULL, DoAppend() will check for it and insert
109 // items in the correct order
110 m_strings = new wxSortedArrayString;
111 }
112
16edee16
RR
113 // begin with no selection
114 m_selection_hack = wxNOT_FOUND;
115
fd0eed64 116 GtkWidget *menu = gtk_menu_new();
29006414 117
aa61d352 118 for (unsigned int i = 0; i < (unsigned int)n; i++)
fd0eed64 119 {
243dbf1a 120 GtkAddHelper(menu, i, choices[i]);
fd0eed64 121 }
e01c8145 122
fd0eed64 123 gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
29006414 124
f03fc89f 125 m_parent->DoAddChild( this );
29006414 126
abdeb9e7 127 PostCreation(size);
170acdc9 128 SetInitialSize(size); // need this too because this is a wxControlWithItems
29006414 129
0a164d4c 130 return true;
6de97a3b 131}
29006414 132
fd0eed64
RR
133wxChoice::~wxChoice()
134{
f5e27805 135 Clear();
e01c8145
VZ
136
137 delete m_strings;
fd0eed64
RR
138}
139
9abe166a 140int wxChoice::DoAppend( const wxString &item )
fd0eed64 141{
2ee3ee1b 142 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") );
29006414 143
fd0eed64 144 GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
29006414 145
243dbf1a
VZ
146 return GtkAddHelper(menu, GetCount(), item);
147}
148
aa61d352 149int wxChoice::DoInsert(const wxString &item, unsigned int pos)
243dbf1a
VZ
150{
151 wxCHECK_MSG( m_widget != NULL, -1, wxT("invalid choice control") );
8228b893 152 wxCHECK_MSG( IsValidInsert(pos), -1, wxT("invalid index"));
243dbf1a 153
aa61d352 154 if (pos == GetCount())
243dbf1a
VZ
155 return DoAppend(item);
156
157 GtkWidget *menu = gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) );
158
16edee16 159 // if the item to insert is at or before the selection, and the selection is valid
aa61d352 160 if (((int)pos <= m_selection_hack) && (m_selection_hack != wxNOT_FOUND))
16edee16
RR
161 {
162 // move the selection forward one
163 m_selection_hack++;
164 }
165
aa61d352 166 return GtkAddHelper(menu, pos, item);
fd0eed64 167}
f96aa4d9 168
aa61d352 169void wxChoice::DoSetItemClientData(unsigned int n, void* clientData)
fd0eed64 170{
2ee3ee1b 171 wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") );
29006414 172
222ed1d6 173 wxList::compatibility_iterator node = m_clientList.Item( n );
6c8a980f 174 wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientData") );
29006414 175
f5e27805 176 node->SetData( (wxObject*) clientData );
fd0eed64
RR
177}
178
aa61d352 179void* wxChoice::DoGetItemClientData(unsigned int n) const
fd0eed64 180{
2ee3ee1b 181 wxCHECK_MSG( m_widget != NULL, NULL, wxT("invalid choice control") );
29006414 182
222ed1d6 183 wxList::compatibility_iterator node = m_clientList.Item( n );
6c8a980f 184 wxCHECK_MSG( node, NULL, wxT("invalid index in wxChoice::DoGetItemClientData") );
29006414 185
b1d4dd7a 186 return node->GetData();
6de97a3b 187}
fd0eed64 188
aa61d352 189void wxChoice::DoSetItemClientObject(unsigned int n, wxClientData* clientData)
fd0eed64 190{
2ee3ee1b 191 wxCHECK_RET( m_widget != NULL, wxT("invalid choice control") );
29006414 192
222ed1d6 193 wxList::compatibility_iterator node = m_clientList.Item( n );
6c8a980f 194 wxCHECK_RET( node, wxT("invalid index in wxChoice::DoSetItemClientObject") );
29006414 195
edc973b1 196 // wxItemContainer already deletes data for us
29006414 197
fd0eed64
RR
198 node->SetData( (wxObject*) clientData );
199}
200
aa61d352 201wxClientData* wxChoice::DoGetItemClientObject(unsigned int n) const
fd0eed64 202{
2ee3ee1b 203 wxCHECK_MSG( m_widget != NULL, (wxClientData*) NULL, wxT("invalid choice control") );
29006414 204
222ed1d6 205 wxList::compatibility_iterator node = m_clientList.Item( n );
9abe166a 206 wxCHECK_MSG( node, (wxClientData *)NULL,
6c8a980f 207 wxT("invalid index in wxChoice::DoGetItemClientObject") );
29006414 208
b1d4dd7a 209 return (wxClientData*) node->GetData();
fd0eed64 210}
29006414 211
fd0eed64 212void wxChoice::Clear()
c801d85f 213{
223d09f6 214 wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
f96aa4d9 215
fd0eed64
RR
216 gtk_option_menu_remove_menu( GTK_OPTION_MENU(m_widget) );
217 GtkWidget *menu = gtk_menu_new();
218 gtk_option_menu_set_menu( GTK_OPTION_MENU(m_widget), menu );
29006414 219
6c8a980f
VZ
220 if ( HasClientObjectData() )
221 {
222 // destroy the data (due to Robert's idea of using wxList<wxObject>
223 // and not wxList<wxClientData> we can't just say
0a164d4c 224 // m_clientList.DeleteContents(true) - this would crash!
222ed1d6 225 wxList::compatibility_iterator node = m_clientList.GetFirst();
6c8a980f
VZ
226 while ( node )
227 {
b1d4dd7a
RL
228 delete (wxClientData *)node->GetData();
229 node = node->GetNext();
6c8a980f
VZ
230 }
231 }
d6538e2c 232 m_clientList.Clear();
2ee3ee1b
VZ
233
234 if ( m_strings )
235 m_strings->Clear();
16edee16
RR
236
237 // begin with no selection
238 m_selection_hack = wxNOT_FOUND;
6de97a3b 239}
c801d85f 240
aa61d352 241void wxChoice::Delete(unsigned int n)
2f6407b9 242{
645420d8 243 wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
8228b893 244 wxCHECK_RET( IsValid(n), _T("invalid index in wxChoice::Delete") );
645420d8
VZ
245
246 // VZ: apparently GTK+ doesn't have a built-in function to do it (not even
e2380ce1 247 // in 2.0), hence this dumb implementation -- still better than nothing
aa61d352
VZ
248 unsigned int i;
249 const unsigned int count = GetCount();
645420d8 250
16edee16 251 // if the item to delete is before the selection, and the selection is valid
aa61d352 252 if (((int)n < m_selection_hack) && (m_selection_hack != wxNOT_FOUND))
16edee16
RR
253 {
254 // move the selection back one
255 m_selection_hack--;
256 }
aa61d352 257 else if ((int)n == m_selection_hack)
16edee16
RR
258 {
259 // invalidate the selection
260 m_selection_hack = wxNOT_FOUND;
261 }
262
e2380ce1
VZ
263 const bool hasClientData = m_clientDataItemsType != wxClientData_None;
264 const bool hasObjectData = m_clientDataItemsType == wxClientData_Object;
265
266 wxList::compatibility_iterator node = m_clientList.GetFirst();
267
645420d8 268 wxArrayString items;
e2380ce1 269 wxArrayPtrVoid itemsData;
645420d8
VZ
270 items.Alloc(count);
271 for ( i = 0; i < count; i++ )
272 {
aa61d352 273 if ( i != n )
e2380ce1 274 {
645420d8 275 items.Add(GetString(i));
e2380ce1
VZ
276 if ( hasClientData )
277 {
278 // also save the client data
279 itemsData.Add(node->GetData());
280 }
281 }
282 else // need to delete the client object too
283 {
284 if ( hasObjectData )
285 {
286 delete (wxClientData *)node->GetData();
287 }
288 }
289
290 if ( hasClientData )
291 {
292 node = node->GetNext();
293 }
294 }
295
296 if ( hasObjectData )
297 {
298 // prevent Clear() from destroying all client data
299 m_clientDataItemsType = wxClientData_None;
645420d8
VZ
300 }
301
302 Clear();
303
304 for ( i = 0; i < count - 1; i++ )
305 {
306 Append(items[i]);
e2380ce1
VZ
307
308 if ( hasObjectData )
309 SetClientObject(i, (wxClientData *)itemsData[i]);
310 else if ( hasClientData )
f6bc4102 311 SetClientData(i, itemsData[i]);
645420d8 312 }
2f6407b9
RR
313}
314
11e62fe6 315int wxChoice::FindString( const wxString &string, bool bCase ) const
c801d85f 316{
11e62fe6 317 wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid choice") );
fd0eed64
RR
318
319 // If you read this code once and you think you understand
320 // it, then you are very wrong. Robert Roebling.
29006414 321
fd0eed64
RR
322 GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
323 int count = 0;
324 GList *child = menu_shell->children;
325 while (child)
326 {
327 GtkBin *bin = GTK_BIN( child->data );
328 GtkLabel *label = (GtkLabel *) NULL;
9e691f46
VZ
329 if (bin->child)
330 label = GTK_LABEL(bin->child);
331 if (!label)
afa7bd1e 332 label = GTK_LABEL(GTK_BIN(m_widget)->child);
29006414 333
223d09f6 334 wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
e2380ce1 335
2e1d7104 336 wxString tmp( wxGTK_CONV_BACK( gtk_label_get_text( label) ) );
11e62fe6 337 if (string.IsSameAs( tmp, bCase ))
9e691f46 338 return count;
29006414 339
9e691f46
VZ
340 child = child->next;
341 count++;
fd0eed64 342 }
29006414 343
0a164d4c 344 return wxNOT_FOUND;
6de97a3b 345}
c801d85f 346
9abe166a 347int wxChoice::GetSelection() const
c801d85f 348{
11e62fe6 349 wxCHECK_MSG( m_widget != NULL, wxNOT_FOUND, wxT("invalid choice") );
e2380ce1 350
16edee16
RR
351 return m_selection_hack;
352
6de97a3b 353}
c801d85f 354
aa61d352 355void wxChoice::SetString(unsigned int n, const wxString& str)
6c8a980f
VZ
356{
357 wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
358
34b5e560 359 GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
aa61d352 360 unsigned int count = 0;
34b5e560
RR
361 GList *child = menu_shell->children;
362 while (child)
363 {
364 GtkBin *bin = GTK_BIN( child->data );
365 if (count == n)
366 {
367 GtkLabel *label = (GtkLabel *) NULL;
368 if (bin->child)
369 label = GTK_LABEL(bin->child);
370 if (!label)
afa7bd1e 371 label = GTK_LABEL(GTK_BIN(m_widget)->child);
34b5e560
RR
372
373 wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
374
0a164d4c
WS
375 gtk_label_set_text( label, wxGTK_CONV( str ) );
376
34b5e560
RR
377 return;
378 }
379 child = child->next;
380 count++;
381 }
6c8a980f
VZ
382}
383
aa61d352 384wxString wxChoice::GetString(unsigned int n) const
c801d85f 385{
0a164d4c 386 wxCHECK_MSG( m_widget != NULL, wxEmptyString, wxT("invalid choice") );
fd0eed64
RR
387
388 GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
aa61d352 389 unsigned int count = 0;
fd0eed64
RR
390 GList *child = menu_shell->children;
391 while (child)
c801d85f 392 {
fd0eed64
RR
393 GtkBin *bin = GTK_BIN( child->data );
394 if (count == n)
395 {
396 GtkLabel *label = (GtkLabel *) NULL;
9e691f46
VZ
397 if (bin->child)
398 label = GTK_LABEL(bin->child);
399 if (!label)
afa7bd1e 400 label = GTK_LABEL(GTK_BIN(m_widget)->child);
29006414 401
223d09f6 402 wxASSERT_MSG( label != NULL , wxT("wxChoice: invalid label") );
29006414 403
2e1d7104 404 return wxString( wxGTK_CONV_BACK( gtk_label_get_text( label) ) );
fd0eed64
RR
405 }
406 child = child->next;
407 count++;
6de97a3b 408 }
29006414 409
223d09f6 410 wxFAIL_MSG( wxT("wxChoice: invalid index in GetString()") );
29006414 411
0a164d4c 412 return wxEmptyString;
6de97a3b 413}
c801d85f 414
aa61d352 415unsigned int wxChoice::GetCount() const
c801d85f 416{
223d09f6 417 wxCHECK_MSG( m_widget != NULL, 0, wxT("invalid choice") );
fd0eed64
RR
418
419 GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
aa61d352 420 unsigned int count = 0;
fd0eed64
RR
421 GList *child = menu_shell->children;
422 while (child)
423 {
424 count++;
425 child = child->next;
426 }
427 return count;
6de97a3b 428}
c801d85f 429
debe6624 430void wxChoice::SetSelection( int n )
c801d85f 431{
223d09f6 432 wxCHECK_RET( m_widget != NULL, wxT("invalid choice") );
f96aa4d9 433
fd0eed64
RR
434 int tmp = n;
435 gtk_option_menu_set_history( GTK_OPTION_MENU(m_widget), (gint)tmp );
16edee16
RR
436
437 // set the local selection variable manually
aa61d352 438 if ((n >= 0) && ((unsigned int)n < GetCount()))
16edee16
RR
439 {
440 // a valid selection has been made
441 m_selection_hack = n;
442 }
443 else if ((n == wxNOT_FOUND) || (GetCount() == 0))
444 {
445 // invalidates the selection if there are no items
446 // or if it is specifically set to wxNOT_FOUND
447 m_selection_hack = wxNOT_FOUND;
448 }
449 else
450 {
451 // this selects the first item by default if the selection is out of bounds
452 m_selection_hack = 0;
453 }
6de97a3b 454}
c801d85f 455
f40fdaa3 456void wxChoice::DoApplyWidgetStyle(GtkRcStyle *style)
868a2826 457{
fd0eed64 458 GtkMenuShell *menu_shell = GTK_MENU_SHELL( gtk_option_menu_get_menu( GTK_OPTION_MENU(m_widget) ) );
29006414 459
f40fdaa3
VS
460 gtk_widget_modify_style( m_widget, style );
461 gtk_widget_modify_style( GTK_WIDGET( menu_shell ), style );
29006414 462
fd0eed64
RR
463 GList *child = menu_shell->children;
464 while (child)
465 {
f40fdaa3 466 gtk_widget_modify_style( GTK_WIDGET( child->data ), style );
29006414 467
fd0eed64
RR
468 GtkBin *bin = GTK_BIN( child->data );
469 GtkWidget *label = (GtkWidget *) NULL;
9e691f46
VZ
470 if (bin->child)
471 label = bin->child;
472 if (!label)
afa7bd1e 473 label = GTK_BIN(m_widget)->child;
29006414 474
f40fdaa3 475 gtk_widget_modify_style( label, style );
29006414 476
fd0eed64
RR
477 child = child->next;
478 }
f96aa4d9
RR
479}
480
aa61d352 481int wxChoice::GtkAddHelper(GtkWidget *menu, unsigned int pos, const wxString& item)
e01c8145 482{
aa61d352 483 wxCHECK_MSG(pos<=m_clientList.GetCount(), -1, wxT("invalid index"));
243dbf1a 484
fab591c5 485 GtkWidget *menu_item = gtk_menu_item_new_with_label( wxGTK_CONV( item ) );
e01c8145 486
aa61d352 487 unsigned int index;
e01c8145
VZ
488 if ( m_strings )
489 {
490 // sorted control, need to insert at the correct index
491 index = m_strings->Add(item);
492
1ab9e06d 493 gtk_menu_shell_insert( GTK_MENU_SHELL(menu), menu_item, index );
e01c8145
VZ
494
495 if ( index )
496 {
497 m_clientList.Insert( m_clientList.Item(index - 1),
498 (wxObject*) NULL );
499 }
500 else
501 {
6c8a980f 502 m_clientList.Insert( (wxObject*) NULL );
e01c8145
VZ
503 }
504 }
505 else
506 {
243dbf1a
VZ
507 // don't call wxChoice::GetCount() from here because it doesn't work
508 // if we're called from ctor (and GtkMenuShell is still NULL)
509
e01c8145 510 // normal control, just append
8228b893 511 if (pos == m_clientList.GetCount())
243dbf1a 512 {
1ab9e06d 513 gtk_menu_shell_append( GTK_MENU_SHELL(menu), menu_item );
0a164d4c
WS
514 m_clientList.Append( (wxObject*) NULL );
515 index = m_clientList.GetCount() - 1;
243dbf1a
VZ
516 }
517 else
518 {
1ab9e06d 519 gtk_menu_shell_insert( GTK_MENU_SHELL(menu), menu_item, pos );
243dbf1a
VZ
520 m_clientList.Insert( pos, (wxObject*) NULL );
521 index = pos;
522 }
e01c8145
VZ
523 }
524
525 if (GTK_WIDGET_REALIZED(m_widget))
526 {
527 gtk_widget_realize( menu_item );
528 gtk_widget_realize( GTK_BIN(menu_item)->child );
529
f40fdaa3 530 ApplyWidgetStyle();
e01c8145
VZ
531 }
532
9ddf4854
RR
533 // The best size of a wxChoice should probably
534 // be changed everytime the control has been
535 // changed, but at least after adding an item
536 // it has to change. Adapted from Matt Ownby.
537 InvalidateBestSize();
0a164d4c 538
9fa72bd2
MR
539 g_signal_connect_after (menu_item, "activate",
540 G_CALLBACK (gtk_choice_clicked_callback),
541 this);
e01c8145
VZ
542
543 gtk_widget_show( menu_item );
544
545 // return the index of the item in the control
546 return index;
547}
548
f68586e5
VZ
549wxSize wxChoice::DoGetBestSize() const
550{
db434467 551 wxSize ret( wxControl::DoGetBestSize() );
29f54b9b
VZ
552
553 // we know better our horizontal extent: it depends on the longest string
554 // we have
555 ret.x = 0;
556 if ( m_widget )
557 {
60d85ccb 558 int width;
aa61d352
VZ
559 unsigned int count = GetCount();
560 for ( unsigned int n = 0; n < count; n++ )
29f54b9b 561 {
2b1ff57f 562 GetTextExtent( GetString(n), &width, NULL, NULL, NULL );
29f54b9b
VZ
563 if ( width > ret.x )
564 ret.x = width;
565 }
566
df336b7f
VZ
567 // add extra for the choice "=" button
568
569 // VZ: I don't know how to get the right value, it seems to be in
570 // GtkOptionMenuProps struct from gtkoptionmenu.c but we can't get
571 // to it - maybe we can use gtk_option_menu_size_request() for this
572 // somehow?
573 //
574 // This default value works only for the default GTK+ theme (i.e.
575 // no theme at all) (FIXME)
576 static const int widthChoiceIndicator = 35;
577 ret.x += widthChoiceIndicator;
29f54b9b
VZ
578 }
579
580 // but not less than the minimal width
581 if ( ret.x < 80 )
582 ret.x = 80;
583
ebbb22bd
RR
584 // If this request_size is called with no entries then
585 // the returned height is wrong. Give it a reasonable
586 // default value.
587 if (ret.y <= 18)
588 ret.y = 8 + GetCharHeight();
9e691f46 589
9f884528 590 CacheBestSize(ret);
db434467 591 return ret;
f68586e5
VZ
592}
593
ef5c70f9 594GdkWindow *wxChoice::GTKGetWindow(wxArrayGdkWindows& WXUNUSED(windows)) const
2b904684 595{
2b904684 596 return GTK_BUTTON(m_widget)->event_window;
2b904684
RR
597}
598
9d522606
RD
599// static
600wxVisualAttributes
601wxChoice::GetClassDefaultAttributes(wxWindowVariant WXUNUSED(variant))
602{
603 return GetDefaultAttributesFromGTKWidget(gtk_option_menu_new);
604}
605
a73554d4 606
df336b7f 607#endif // wxUSE_CHOICE