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