// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
}
#if USE_HICOMBOBOX
static const EventTypeSpec eventList[] =
{
{ kEventClassTextField , kEventTextAccepted } ,
}
#if USE_HICOMBOBOX
static const EventTypeSpec eventList[] =
{
{ kEventClassTextField , kEventTextAccepted } ,
static pascal OSStatus wxMacComboBoxEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
static pascal OSStatus wxMacComboBoxEventHandler( EventHandlerCallRef handler , EventRef event , void *data )
{
// This will invoke the dialog default action, such
// as the clicking the default button.
// This will invoke the dialog default action, such
// as the clicking the default button.
- wxWindow *parent = GetParent();
- while( parent && !parent->IsTopLevel() && parent->GetDefaultItem() == NULL ) {
- parent = parent->GetParent() ;
- }
- if ( parent && parent->GetDefaultItem() )
+ wxTopLevelWindow *tlw = wxDynamicCast(wxGetTopLevelParent(this), wxTopLevelWindow);
+ if ( tlw && tlw->GetDefaultItem() )
if ( def && def->IsEnabled() )
{
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
event.SetEventObject(def);
def->Command(event);
if ( def && def->IsEnabled() )
{
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, def->GetId() );
event.SetEventObject(def);
def->Command(event);
// delete the controls now, don't leave them alive even though they would
// still be eventually deleted by our parent - but it will be too late, the
// user code expects them to be gone now
// delete the controls now, don't leave them alive even though they would
// still be eventually deleted by our parent - but it will be too late, the
// user code expects them to be gone now
- m_choice->SetSize(0, 0 , width, -1);
+ m_choice->SetSize(0, 0 , width, wxDefaultCoord);
}
else
{
wxCoord wText = width - POPUPWIDTH - MARGIN;
m_text->SetSize(0, 0, wText, height);
}
else
{
wxCoord wText = width - POPUPWIDTH - MARGIN;
m_text->SetSize(0, 0, wText, height);
- m_choice->SetSize(0 + wText + MARGIN, 0, POPUPWIDTH, -1);
+ m_choice->SetSize(0 + wText + MARGIN, 0, POPUPWIDTH, wxDefaultCoord);
#endif
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
wxDefaultValidator, name) )
#endif
if ( !wxControl::Create(parent, id, wxDefaultPosition, wxDefaultSize, style ,
wxDefaultValidator, name) )
//hiRect.size.height = bounds.bottom - bounds.top;
//printf("left = %d, right = %d, top = %d, bottom = %d\n", bounds.left, bounds.right, bounds.top, bounds.bottom);
//printf("x = %d, y = %d, width = %d, height = %d\n", hibounds.origin.x, hibounds.origin.y, hibounds.size.width, hibounds.size.height);
//hiRect.size.height = bounds.bottom - bounds.top;
//printf("left = %d, right = %d, top = %d, bottom = %d\n", bounds.left, bounds.right, bounds.top, bounds.bottom);
//printf("x = %d, y = %d, width = %d, height = %d\n", hibounds.origin.x, hibounds.origin.y, hibounds.size.width, hibounds.size.height);
- m_peer = new wxMacControl() ;
- verify_noerr( HIComboBoxCreate( &hiRect, CFSTR(""), NULL, NULL, kHIComboBoxStandardAttributes, *m_peer ) );
+ m_peer = new wxMacControl(this);
+ verify_noerr( HIComboBoxCreate( &hiRect, CFSTR(""), NULL, NULL, kHIComboBoxStandardAttributes, m_peer->GetControlRefAddr() ) );
- SetControl32BitMinimum( *m_peer , 0 ) ;
- SetControl32BitMaximum( *m_peer , 100) ;
+ m_peer->SetMinimum( 0 );
+ m_peer->SetMaximum( 100);
- EventHandlerRef comboEventHandler ;
- InstallControlEventHandler( *m_peer, GetwxMacComboBoxEventHandlerUPP(),
+ EventHandlerRef comboEventHandler;
+ InstallControlEventHandler( m_peer->GetControlRef(), GetwxMacComboBoxEventHandlerUPP(),
GetEventTypeCount(eventList), eventList, this,
(EventHandlerRef *)&comboEventHandler);
#else
m_choice = new wxComboBoxChoice(this, style );
GetEventTypeCount(eventList), eventList, this,
(EventHandlerRef *)&comboEventHandler);
#else
m_choice = new wxComboBoxChoice(this, style );
-
- m_choice = new wxComboBoxChoice(this, style );
- m_choice->SetSizeHints( wxSize( POPUPWIDTH , POPUPHEIGHT ) ) ;
+ m_choice->SetMinSize( wxSize( POPUPWIDTH , POPUPHEIGHT ) );
}
}
DoSetSize(pos.x, pos.y, csize.x, csize.y);
}
}
DoSetSize(pos.x, pos.y, csize.x, csize.y);
- for ( int i = 0 ; i < n ; i++ )
- {
- m_choice->DoAppend( choices[ i ] );
- }
- SetBestSize(csize); // Needed because it is a wxControlWithItems
+ m_choice->Append( n, choices );
+ SetInitialSize(csize); // Needed because it is a wxControlWithItems
- CFIndex outIndex;
- HIComboBoxAppendTextItem( *m_peer, wxMacCFStringHolder( item, m_font.GetEncoding() ), &outIndex );
- //SetControl32BitMaximum( *m_peer, GetCount() );
- return (int) outIndex;
-#else
- return m_choice->DoAppend( item ) ;
-#endif
-}
-
-int wxComboBox::DoInsert(const wxString& item, int pos)
-{
-#if USE_HICOMBOBOX
- HIComboBoxInsertTextItemAtIndex( *m_peer, (CFIndex)pos, wxMacCFStringHolder(item, m_font.GetEncoding()) );
+ const unsigned int count = items.GetCount();
+ for ( unsigned int i = 0; i < count; ++i, ++pos )
+ {
+ HIComboBoxInsertTextItemAtIndex(m_peer->GetControlRef(),
+ (CFIndex)pos,
+ wxMacCFStringHolder(items[i],
+ m_font.GetEncoding()));
+ AssignNewItemClientData(pos, clientData, i, type);
+ }
- return m_choice->DoGetItemClientData( n ) ;
-#endif
-}
-
-void wxComboBox::DoSetItemClientObject(int n, wxClientData* clientData)
-{
-#if USE_HICOMBOBOX
- return; //TODO
-#else
- return m_choice->DoSetItemClientObject( n , clientData ) ;
+ return m_choice->DoGetItemClientData( n );
- if ( HasClientObjectData() )
- {
- size_t count = GetCount();
- for ( size_t n = 0; n < count; n++ )
- {
- SetClientObject( n, NULL );
- }
- }
-}
-
-int wxComboBox::GetCount() const {
- return m_choice->GetCount() ;
-#endif
-}
-
-void wxComboBox::Delete(int n)
-{
-#if USE_HICOMBOBOX
- HIComboBoxRemoveItemAtIndex( *m_peer, (CFIndex)n );
-#else
- // force client object deletion
- if( HasClientObjectData() )
- SetClientObject( n, NULL );
- for ( CFIndex i = GetCount() - 1 ; i >= 0 ; ++ i )
- verify_noerr( HIComboBoxRemoveItemAtIndex( *m_peer, i ) );
+ for ( CFIndex i = GetCount() - 1; i >= 0; ++ i )
+ verify_noerr( HIComboBoxRemoveItemAtIndex( m_peer->GetControlRef(), i ) );
-bool wxComboBox::SetStringSelection(const wxString& sel)
-{
- int s = FindString (sel);
- if (s > -1)
- {
- SetSelection (s);
- return true;
- }
- else
- return false;
-}
-
-void wxComboBox::SetString(int n, const wxString& s)
+void wxComboBox::SetString(unsigned int n, const wxString& s)