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