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