]> git.saurik.com Git - wxWidgets.git/blame - src/mac/carbon/combobxc.cpp
1945421 applied
[wxWidgets.git] / src / mac / carbon / combobxc.cpp
CommitLineData
46cc7c4e 1/////////////////////////////////////////////////////////////////////////////
3c24dad6
SC
2// Name: src/mac/carbon/combobxc.cpp
3// Purpose: wxComboBox class using HIView ComboBox
46cc7c4e
SC
4// Author: Stefan Csomor
5// Modified by:
6// Created: 1998-01-01
7// RCS-ID: $Id$
8// Copyright: (c) Stefan Csomor
65571936 9// Licence: wxWindows licence
46cc7c4e
SC
10/////////////////////////////////////////////////////////////////////////////
11
3d1a4878
SC
12#include "wx/wxprec.h"
13
46cc7c4e 14#include "wx/combobox.h"
f1e01716
WS
15
16#ifndef WX_PRECOMP
17 #include "wx/button.h"
3b3dc801 18 #include "wx/menu.h"
f1e01716
WS
19#endif
20
46cc7c4e 21#include "wx/mac/uma.h"
c829d62b 22#if TARGET_API_MAC_OSX
46cc7c4e 23#ifndef __HIVIEW__
7d8268a1 24 #include <HIToolbox/HIView.h>
46cc7c4e 25#endif
c829d62b 26#endif
46cc7c4e 27
46cc7c4e 28IMPLEMENT_DYNAMIC_CLASS(wxComboBox, wxControl)
46cc7c4e 29
c829d62b 30#if TARGET_API_MAC_OSX
46cc7c4e 31#define USE_HICOMBOBOX 1 //use hi combobox define
c829d62b
SC
32#else
33#define USE_HICOMBOBOX 0
34#endif
46cc7c4e 35
3c24dad6 36static int nextPopUpMenuId = 1000;
150e31d2 37MenuHandle NewUniqueMenu()
46cc7c4e 38{
3c24dad6
SC
39 MenuHandle handle = NewMenu( nextPopUpMenuId , "\pMenu" );
40 nextPopUpMenuId++;
41 return handle;
46cc7c4e
SC
42}
43
21fd5529
SC
44#if USE_HICOMBOBOX
45static const EventTypeSpec eventList[] =
46{
47 { kEventClassTextField , kEventTextAccepted } ,
3c24dad6 48};
21fd5529
SC
49
50static pascal OSStatus wxMacComboBoxEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
51{
3c24dad6
SC
52 OSStatus result = eventNotHandledErr;
53 wxComboBox* cb = (wxComboBox*) data;
150e31d2 54
3c24dad6 55 wxMacCarbonEvent cEvent( event );
21fd5529
SC
56
57 switch( cEvent.GetClass() )
58 {
59 case kEventClassTextField :
60 switch( cEvent.GetKind() )
61 {
62 case kEventTextAccepted :
63 {
64 wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, cb->GetId() );
65 event.SetInt( cb->GetSelection() );
66 event.SetString( cb->GetStringSelection() );
67 event.SetEventObject( cb );
937013e0 68 cb->HandleWindowEvent( event );
21fd5529 69 }
3c24dad6 70 break;
21fd5529 71 default :
3c24dad6 72 break;
21fd5529 73 }
3c24dad6 74 break;
21fd5529 75 default :
3c24dad6 76 break;
21fd5529 77 }
150e31d2 78
21fd5529 79
3c24dad6 80 return result;
21fd5529
SC
81}
82
83DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacComboBoxEventHandler )
84
85#endif
46cc7c4e
SC
86
87// ----------------------------------------------------------------------------
88// constants
89// ----------------------------------------------------------------------------
90
91// the margin between the text control and the choice
92static const wxCoord MARGIN = 2;
93#if TARGET_API_MAC_OSX
94static const int POPUPWIDTH = 24;
95#else
96static const int POPUPWIDTH = 18;
97#endif
98static const int POPUPHEIGHT = 23;
99
100// ----------------------------------------------------------------------------
101// wxComboBoxText: text control forwards events to combobox
102// ----------------------------------------------------------------------------
103
104class wxComboBoxText : public wxTextCtrl
105{
106public:
107 wxComboBoxText( wxComboBox * cb )
108 : wxTextCtrl( cb , 1 )
109 {
110 m_cb = cb;
111 }
112
113protected:
114 void OnChar( wxKeyEvent& event )
115 {
116 if ( event.GetKeyCode() == WXK_RETURN )
117 {
118 wxString value = GetValue();
119
120 if ( m_cb->GetCount() == 0 )
121 {
122 // make Enter generate "selected" event if there is only one item
123 // in the combobox - without it, it's impossible to select it at
124 // all!
125 wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, m_cb->GetId() );
126 event.SetInt( 0 );
127 event.SetString( value );
128 event.SetEventObject( m_cb );
937013e0 129 m_cb->HandleWindowEvent( event );
46cc7c4e
SC
130 }
131 else
132 {
133 // add the item to the list if it's not there yet
134 if ( m_cb->FindString(value) == wxNOT_FOUND )
135 {
136 m_cb->Append(value);
137 m_cb->SetStringSelection(value);
138
139 // and generate the selected event for it
140 wxCommandEvent event( wxEVT_COMMAND_COMBOBOX_SELECTED, m_cb->GetId() );
141 event.SetInt( m_cb->GetCount() - 1 );
142 event.SetString( value );
143 event.SetEventObject( m_cb );
937013e0 144 m_cb->HandleWindowEvent( event );
46cc7c4e
SC
145 }
146
147 // This will invoke the dialog default action, such
148 // as the clicking the default button.
149
6c20e8f8
VZ
150 wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
151 if ( tlw && tlw->GetDefaultItem() )
46cc7c4e 152 {
6c20e8f8 153 wxButton *def = wxDynamicCast(tlw->GetDefaultItem(), wxButton);
46cc7c4e
SC
154 if ( def && def->IsEnabled() )
155 {
156 wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
157 event.SetEventObject(def);
158 def->Command(event);
3c24dad6 159 return;
3dee36ae 160 }
46cc7c4e
SC
161 }
162
163 return;
164 }
165 }
150e31d2 166
46cc7c4e
SC
167 event.Skip();
168 }
169private:
170 wxComboBox *m_cb;
171
172 DECLARE_EVENT_TABLE()
173};
174
175BEGIN_EVENT_TABLE(wxComboBoxText, wxTextCtrl)
176 EVT_CHAR( wxComboBoxText::OnChar)
177END_EVENT_TABLE()
178
179class wxComboBoxChoice : public wxChoice
180{
181public:
182 wxComboBoxChoice(wxComboBox *cb, int style)
183 : wxChoice( cb , 1 )
184 {
185 m_cb = cb;
186 }
187
188protected:
189 void OnChoice( wxCommandEvent& e )
190 {
191 wxString s = e.GetString();
192
193 m_cb->DelegateChoice( s );
194 wxCommandEvent event2(wxEVT_COMMAND_COMBOBOX_SELECTED, m_cb->GetId() );
195 event2.SetInt(m_cb->GetSelection());
196 event2.SetEventObject(m_cb);
197 event2.SetString(m_cb->GetStringSelection());
198 m_cb->ProcessCommand(event2);
199 }
200 virtual wxSize DoGetBestSize() const
201 {
3c24dad6
SC
202 wxSize sz = wxChoice::DoGetBestSize();
203 sz.x = POPUPWIDTH;
204 return sz;
150e31d2 205 }
46cc7c4e
SC
206
207private:
208 wxComboBox *m_cb;
209
210 DECLARE_EVENT_TABLE()
211};
212
213BEGIN_EVENT_TABLE(wxComboBoxChoice, wxChoice)
3dee36ae 214 EVT_CHOICE(wxID_ANY, wxComboBoxChoice::OnChoice)
46cc7c4e
SC
215END_EVENT_TABLE()
216
217wxComboBox::~wxComboBox()
218{
46cc7c4e
SC
219 // delete the controls now, don't leave them alive even though they would
220 // still be eventually deleted by our parent - but it will be too late, the
221 // user code expects them to be gone now
222 if (m_text != NULL) {
223 delete m_text;
224 m_text = NULL;
225 }
226 if (m_choice != NULL) {
227 delete m_choice;
228 m_choice = NULL;
229 }
230}
231
232
233// ----------------------------------------------------------------------------
234// geometry
235// ----------------------------------------------------------------------------
236
237wxSize wxComboBox::DoGetBestSize() const
238{
239#if USE_HICOMBOBOX
7d8268a1 240 return wxControl::DoGetBestSize();
46cc7c4e
SC
241#else
242 wxSize size = m_choice->GetBestSize();
150e31d2 243
46cc7c4e
SC
244 if ( m_text != NULL )
245 {
246 wxSize sizeText = m_text->GetBestSize();
150e31d2 247
46cc7c4e
SC
248 size.x = POPUPWIDTH + sizeText.x + MARGIN;
249 }
250
251 return size;
252#endif
253}
254
255void wxComboBox::DoMoveWindow(int x, int y, int width, int height) {
256#if USE_HICOMBOBOX
7d8268a1 257 wxControl::DoMoveWindow(x, y, width, height);
46cc7c4e
SC
258#else
259 height = POPUPHEIGHT;
150e31d2 260
46cc7c4e
SC
261 wxControl::DoMoveWindow(x, y, width, height);
262
263 if ( m_text == NULL )
264 {
265 // we might not be fully constructed yet, therefore watch out...
266 if ( m_choice )
3dee36ae 267 m_choice->SetSize(0, 0 , width, wxDefaultCoord);
46cc7c4e
SC
268 }
269 else
270 {
271 wxCoord wText = width - POPUPWIDTH - MARGIN;
272 m_text->SetSize(0, 0, wText, height);
3dee36ae 273 m_choice->SetSize(0 + wText + MARGIN, 0, POPUPWIDTH, wxDefaultCoord);
46cc7c4e 274 }
150e31d2 275#endif
46cc7c4e
SC
276}
277
278
279
280// ----------------------------------------------------------------------------
281// operations forwarded to the subcontrols
282// ----------------------------------------------------------------------------
283
284bool wxComboBox::Enable(bool enable)
285{
286 if ( !wxControl::Enable(enable) )
7d8268a1 287 return false;
46cc7c4e 288
7d8268a1 289 return true;
46cc7c4e
SC
290}
291
292bool wxComboBox::Show(bool show)
293{
294 if ( !wxControl::Show(show) )
7d8268a1 295 return false;
46cc7c4e 296
7d8268a1 297 return true;
46cc7c4e
SC
298}
299
300void wxComboBox::SetFocus()
301{
302#if USE_HICOMBOBOX
7d8268a1 303 wxControl::SetFocus();
46cc7c4e
SC
304#else
305 if ( m_text != NULL) {
306 m_text->SetFocus();
307 }
308#endif
309}
310
311
312void wxComboBox::DelegateTextChanged( const wxString& value )
313{
314 SetStringSelection( value );
315}
316
317
318void wxComboBox::DelegateChoice( const wxString& value )
319{
320 SetStringSelection( value );
321}
322
323
324bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
325 const wxString& value,
326 const wxPoint& pos,
327 const wxSize& size,
328 const wxArrayString& choices,
329 long style,
330 const wxValidator& validator,
331 const wxString& name)
332{
333 wxCArrayString chs( choices );
334
335 return Create( parent, id, value, pos, size, chs.GetCount(),
336 chs.GetStrings(), style, validator, name );
337}
338
339
340bool wxComboBox::Create(wxWindow *parent, wxWindowID id,
341 const wxString& value,
342 const wxPoint& pos,
343 const wxSize& size,
344 int n, const wxString choices[],
345 long style,
346 const wxValidator& validator,
347 const wxString& name)
348{
349 m_text = NULL;
350 m_choice = NULL;
351#if USE_HICOMBOBOX
3c24dad6 352 m_macIsUserPane = false;
46cc7c4e
SC
353#endif
354 if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
355 wxDefaultValidator, name) )
356 {
7d8268a1 357 return false;
46cc7c4e
SC
358 }
359#if USE_HICOMBOBOX
3c24dad6 360 Rect bounds = wxMacGetBoundsForControl( this , pos , size );
46cc7c4e 361 HIRect hiRect;
150e31d2 362
46cc7c4e
SC
363 hiRect.origin.x = 20; //bounds.left;
364 hiRect.origin.y = 25; //bounds.top;
365 hiRect.size.width = 120;// bounds.right - bounds.left;
150e31d2
JS
366 hiRect.size.height = 24;
367
46cc7c4e
SC
368 //For some reason, this code causes the combo box not to be displayed at all.
369 //hiRect.origin.x = bounds.left;
370 //hiRect.origin.y = bounds.top;
371 //hiRect.size.width = bounds.right - bounds.left;
372 //hiRect.size.height = bounds.bottom - bounds.top;
373 //printf("left = %d, right = %d, top = %d, bottom = %d\n", bounds.left, bounds.right, bounds.top, bounds.bottom);
7d8268a1 374 //printf("x = %d, y = %d, width = %d, height = %d\n", hibounds.origin.x, hibounds.origin.y, hibounds.size.width, hibounds.size.height);
3c24dad6
SC
375 m_peer = new wxMacControl(this);
376 verify_noerr( HIComboBoxCreate( &hiRect, CFSTR(""), NULL, NULL, kHIComboBoxStandardAttributes, m_peer->GetControlRefAddr() ) );
150e31d2 377
46cc7c4e 378
3c24dad6
SC
379 m_peer->SetMinimum( 0 );
380 m_peer->SetMaximum( 100);
46cc7c4e 381 if ( n > 0 )
3c24dad6 382 m_peer->SetValue( 1 );
150e31d2 383
3c24dad6 384 MacPostControlCreate(pos,size);
150e31d2 385
a236aa20 386 Append( choices[ i ] );
150e31d2 387
3c24dad6 388 HIViewSetVisible( m_peer->GetControlRef(), true );
46cc7c4e 389 SetSelection(0);
3c24dad6
SC
390 EventHandlerRef comboEventHandler;
391 InstallControlEventHandler( m_peer->GetControlRef(), GetwxMacComboBoxEventHandlerUPP(),
150e31d2 392 GetEventTypeCount(eventList), eventList, this,
21fd5529 393 (EventHandlerRef *)&comboEventHandler);
46cc7c4e
SC
394#else
395 m_choice = new wxComboBoxChoice(this, style );
cecf69f3 396 m_choice->SetMinSize( wxSize( POPUPWIDTH , POPUPHEIGHT ) );
150e31d2 397
46cc7c4e
SC
398 wxSize csize = size;
399 if ( style & wxCB_READONLY )
400 {
401 m_text = NULL;
402 }
403 else
404 {
405 m_text = new wxComboBoxText(this);
3dee36ae 406 if ( size.y == wxDefaultCoord ) {
3c24dad6 407 csize.y = m_text->GetSize().y;
46cc7c4e
SC
408 }
409 }
150e31d2 410
46cc7c4e 411 DoSetSize(pos.x, pos.y, csize.x, csize.y);
150e31d2 412
a236aa20 413 m_choice->Append( n, choices );
170acdc9 414 SetInitialSize(csize); // Needed because it is a wxControlWithItems
46cc7c4e
SC
415#endif
416
7d8268a1 417 return true;
46cc7c4e
SC
418}
419
420wxString wxComboBox::GetValue() const
421{
422#if USE_HICOMBOBOX
423 CFStringRef myString;
3c24dad6 424 HIComboBoxCopyTextItemAtIndex( m_peer->GetControlRef(), (CFIndex)GetSelection(), &myString );
34a3ed01 425 return wxMacCFStringHolder( myString, GetFont().GetEncoding() ).AsString();
46cc7c4e
SC
426#else
427 wxString result;
150e31d2 428
46cc7c4e
SC
429 if ( m_text == NULL )
430 {
431 result = m_choice->GetString( m_choice->GetSelection() );
432 }
433 else
434 {
435 result = m_text->GetValue();
436 }
150e31d2 437
46cc7c4e
SC
438 return result;
439#endif
440}
441
442void wxComboBox::SetValue(const wxString& value)
443{
444#if USE_HICOMBOBOX
150e31d2 445
46cc7c4e
SC
446#else
447 int s = FindString (value);
448 if (s == wxNOT_FOUND && !HasFlag(wxCB_READONLY) )
449 {
3c24dad6 450 m_choice->Append(value);
46cc7c4e 451 }
3c24dad6 452 SetStringSelection( value );
46cc7c4e
SC
453#endif
454}
455
456// Clipboard operations
457void wxComboBox::Copy()
458{
459 if ( m_text != NULL )
460 {
461 m_text->Copy();
462 }
463}
464
465void wxComboBox::Cut()
466{
467 if ( m_text != NULL )
468 {
469 m_text->Cut();
470 }
471}
472
473void wxComboBox::Paste()
474{
475 if ( m_text != NULL )
476 {
477 m_text->Paste();
478 }
479}
480
481void wxComboBox::SetEditable(bool editable)
482{
483 if ( ( m_text == NULL ) && editable )
484 {
485 m_text = new wxComboBoxText( this );
486 }
487 else if ( ( m_text != NULL ) && !editable )
488 {
489 delete m_text;
490 m_text = NULL;
491 }
492
493 int currentX, currentY;
494 GetPosition( &currentX, &currentY );
150e31d2 495
46cc7c4e
SC
496 int currentW, currentH;
497 GetSize( &currentW, &currentH );
498
499 DoMoveWindow( currentX, currentY, currentW, currentH );
500}
501
502void wxComboBox::SetInsertionPoint(long pos)
503{
504 // TODO
505}
506
507void wxComboBox::SetInsertionPointEnd()
508{
509 // TODO
510}
511
512long wxComboBox::GetInsertionPoint() const
513{
514 // TODO
515 return 0;
516}
517
7d8268a1 518wxTextPos wxComboBox::GetLastPosition() const
46cc7c4e
SC
519{
520 // TODO
521 return 0;
522}
523
524void wxComboBox::Replace(long from, long to, const wxString& value)
525{
526 // TODO
527}
528
529void wxComboBox::Remove(long from, long to)
530{
531 // TODO
532}
533
534void wxComboBox::SetSelection(long from, long to)
535{
536 // TODO
537}
538
a236aa20
VZ
539int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
540 unsigned int pos,
541 void **clientData, wxClientDataType type)
46cc7c4e
SC
542{
543#if USE_HICOMBOBOX
a236aa20
VZ
544 const unsigned int count = items.GetCount();
545 for ( unsigned int i = 0; i < count; ++i, ++pos )
546 {
547 HIComboBoxInsertTextItemAtIndex(m_peer->GetControlRef(),
548 (CFIndex)pos,
549 wxMacCFStringHolder(items[i],
34a3ed01 550 GetFont().GetEncoding()));
a236aa20
VZ
551 AssignNewItemClientData(pos, clientData, i, type);
552 }
150e31d2 553
3c24dad6 554 //SetControl32BitMaximum( m_peer->GetControlRef(), GetCount() );
150e31d2 555
a236aa20 556 return pos - 1;
46cc7c4e 557#else
a236aa20 558 return m_choice->DoInsertItems( items, pos, clientData, type );
46cc7c4e
SC
559#endif
560}
561
aa61d352 562void wxComboBox::DoSetItemClientData(unsigned int n, void* clientData)
46cc7c4e
SC
563{
564#if USE_HICOMBOBOX
565 return; //TODO
566#else
3c24dad6 567 return m_choice->DoSetItemClientData( n , clientData );
46cc7c4e
SC
568#endif
569}
570
aa61d352 571void* wxComboBox::DoGetItemClientData(unsigned int n) const
46cc7c4e
SC
572{
573#if USE_HICOMBOBOX
574 return NULL; //TODO
575#else
3c24dad6 576 return m_choice->DoGetItemClientData( n );
46cc7c4e
SC
577#endif
578}
579
aa61d352 580unsigned int wxComboBox::GetCount() const {
46cc7c4e 581#if USE_HICOMBOBOX
3c24dad6 582 return (unsigned int) HIComboBoxGetItemCount( m_peer->GetControlRef() );
46cc7c4e 583#else
3c24dad6 584 return m_choice->GetCount();
46cc7c4e
SC
585#endif
586}
587
a236aa20 588void wxComboBox::DoDeleteOneItem(unsigned int n)
46cc7c4e
SC
589{
590#if USE_HICOMBOBOX
3c24dad6 591 HIComboBoxRemoveItemAtIndex( m_peer->GetControlRef(), (CFIndex)n );
46cc7c4e 592#else
46cc7c4e
SC
593 m_choice->Delete( n );
594#endif
595}
596
a236aa20 597void wxComboBox::DoClear()
46cc7c4e
SC
598{
599#if USE_HICOMBOBOX
3c24dad6
SC
600 for ( CFIndex i = GetCount() - 1; i >= 0; ++ i )
601 verify_noerr( HIComboBoxRemoveItemAtIndex( m_peer->GetControlRef(), i ) );
21fd5529 602 m_peer->SetData<CFStringRef>(kHIComboBoxEditTextPart,kControlEditTextCFStringTag,CFSTR(""));
46cc7c4e 603#else
46cc7c4e
SC
604 m_choice->Clear();
605#endif
606}
607
608int wxComboBox::GetSelection() const
609{
610#if USE_HICOMBOBOX
3c24dad6 611 return FindString( GetStringSelection() );
46cc7c4e
SC
612#else
613 return m_choice->GetSelection();
614#endif
615}
616
617void wxComboBox::SetSelection(int n)
618{
619#if USE_HICOMBOBOX
3c24dad6 620 SetControl32BitValue( m_peer->GetControlRef() , n + 1 );
46cc7c4e
SC
621#else
622 m_choice->SetSelection( n );
150e31d2 623
46cc7c4e
SC
624 if ( m_text != NULL )
625 {
aa61d352 626 m_text->SetValue(GetString(n));
46cc7c4e
SC
627 }
628#endif
629}
630
11e62fe6 631int wxComboBox::FindString(const wxString& s, bool bCase) const
46cc7c4e
SC
632{
633#if USE_HICOMBOBOX
aa61d352 634 for( unsigned int i = 0 ; i < GetCount() ; i++ )
46cc7c4e 635 {
aa61d352 636 if (GetString(i).IsSameAs(s, bCase) )
46cc7c4e
SC
637 return i ;
638 }
3c24dad6 639 return wxNOT_FOUND;
46cc7c4e 640#else
11e62fe6 641 return m_choice->FindString( s, bCase );
46cc7c4e
SC
642#endif
643}
644
aa61d352 645wxString wxComboBox::GetString(unsigned int n) const
46cc7c4e
SC
646{
647#if USE_HICOMBOBOX
648 CFStringRef itemText;
3c24dad6 649 HIComboBoxCopyTextItemAtIndex( m_peer->GetControlRef(), (CFIndex)n, &itemText );
46cc7c4e
SC
650 return wxMacCFStringHolder(itemText).AsString();
651#else
652 return m_choice->GetString( n );
653#endif
654}
655
656wxString wxComboBox::GetStringSelection() const
657{
b310cebd 658#if USE_HICOMBOBOX
3c24dad6 659 return wxMacCFStringHolder(m_peer->GetData<CFStringRef>(kHIComboBoxEditTextPart,kControlEditTextCFStringTag)).AsString();
b310cebd 660#else
46cc7c4e 661 int sel = GetSelection ();
aa61d352
VZ
662 if (sel != wxNOT_FOUND)
663 return wxString(this->GetString((unsigned int)sel));
46cc7c4e
SC
664 else
665 return wxEmptyString;
b310cebd 666#endif
46cc7c4e
SC
667}
668
aa61d352 669void wxComboBox::SetString(unsigned int n, const wxString& s)
46cc7c4e
SC
670{
671#if USE_HICOMBOBOX
3c24dad6 672 verify_noerr ( HIComboBoxInsertTextItemAtIndex( m_peer->GetControlRef(), (CFIndex) n,
34a3ed01 673 wxMacCFStringHolder(s, GetFont().GetEncoding()) ) );
3c24dad6 674 verify_noerr ( HIComboBoxRemoveItemAtIndex( m_peer->GetControlRef(), (CFIndex) n + 1 ) );
46cc7c4e 675#else
3c24dad6 676 m_choice->SetString( n , s );
46cc7c4e
SC
677#endif
678}
679
150e31d2
JS
680bool wxComboBox::IsEditable() const
681{
682#if USE_HICOMBOBOX
7d8268a1
WS
683 // TODO
684 return !HasFlag(wxCB_READONLY);
150e31d2 685#else
7d8268a1 686 return m_text != NULL && !HasFlag(wxCB_READONLY);
150e31d2
JS
687#endif
688}
689
690void wxComboBox::Undo()
691{
692#if USE_HICOMBOBOX
7d8268a1 693 // TODO
150e31d2
JS
694#else
695 if (m_text != NULL)
696 m_text->Undo();
697#endif
698}
699
700void wxComboBox::Redo()
701{
702#if USE_HICOMBOBOX
7d8268a1 703 // TODO
150e31d2
JS
704#else
705 if (m_text != NULL)
706 m_text->Redo();
707#endif
708}
709
710void wxComboBox::SelectAll()
711{
712#if USE_HICOMBOBOX
7d8268a1 713 // TODO
150e31d2
JS
714#else
715 if (m_text != NULL)
716 m_text->SelectAll();
717#endif
718}
719
720bool wxComboBox::CanCopy() const
721{
722#if USE_HICOMBOBOX
7d8268a1
WS
723 // TODO
724 return false;
150e31d2
JS
725#else
726 if (m_text != NULL)
727 return m_text->CanCopy();
728 else
729 return false;
730#endif
731}
732
733bool wxComboBox::CanCut() const
734{
735#if USE_HICOMBOBOX
7d8268a1
WS
736 // TODO
737 return false;
150e31d2
JS
738#else
739 if (m_text != NULL)
740 return m_text->CanCut();
741 else
742 return false;
743#endif
744}
745
746bool wxComboBox::CanPaste() const
747{
748#if USE_HICOMBOBOX
7d8268a1
WS
749 // TODO
750 return false;
150e31d2
JS
751#else
752 if (m_text != NULL)
753 return m_text->CanPaste();
754 else
755 return false;
756#endif
757}
758
759bool wxComboBox::CanUndo() const
760{
761#if USE_HICOMBOBOX
7d8268a1
WS
762 // TODO
763 return false;
150e31d2
JS
764#else
765 if (m_text != NULL)
766 return m_text->CanUndo();
767 else
768 return false;
769#endif
770}
771
772bool wxComboBox::CanRedo() const
773{
774#if USE_HICOMBOBOX
7d8268a1
WS
775 // TODO
776 return false;
150e31d2
JS
777#else
778 if (m_text != NULL)
779 return m_text->CanRedo();
780 else
781 return false;
782#endif
783}
46cc7c4e 784
150e31d2 785wxInt32 wxComboBox::MacControlHit(WXEVENTHANDLERREF WXUNUSED(handler) , WXEVENTREF WXUNUSED(event) )
46cc7c4e 786{
46cc7c4e
SC
787 wxCommandEvent event(wxEVT_COMMAND_COMBOBOX_SELECTED, m_windowId );
788 event.SetInt(GetSelection());
789 event.SetEventObject(this);
790 event.SetString(GetStringSelection());
791 ProcessCommand(event);
3c24dad6 792 return noErr;
46cc7c4e 793}