// 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 )
{
event.SetInt( cb->GetSelection() );
event.SetString( cb->GetStringSelection() );
event.SetEventObject( cb );
event.SetInt( cb->GetSelection() );
event.SetString( cb->GetStringSelection() );
event.SetEventObject( cb );
event.SetInt( m_cb->GetCount() - 1 );
event.SetString( value );
event.SetEventObject( m_cb );
event.SetInt( m_cb->GetCount() - 1 );
event.SetString( value );
event.SetEventObject( m_cb );
}
// 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
#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(this) ;
- 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
- HIComboBoxCopyTextItemAtIndex( *m_peer, (CFIndex)GetSelection(), &myString );
- return wxMacCFStringHolder( myString, m_font.GetEncoding() ).AsString();
+ HIComboBoxCopyTextItemAtIndex( m_peer->GetControlRef(), (CFIndex)GetSelection(), &myString );
+ return wxMacCFStringHolder( myString, GetFont().GetEncoding() ).AsString();
-int wxComboBox::DoAppend(const wxString& item)
-{
-#if USE_HICOMBOBOX
- 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)
+int wxComboBox::DoInsertItems(const wxArrayStringsAdapter& items,
+ unsigned int pos,
+ void **clientData, wxClientDataType type)
- 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],
+ GetFont().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 );
-wxClientData* wxComboBox::DoGetItemClientObject(int n) const
-{
-#if USE_HICOMBOBOX
- return NULL;
-#else
- return m_choice->DoGetItemClientObject( n ) ;
-#endif
-}
-
-void wxComboBox::FreeData()
-{
- if ( HasClientObjectData() )
- {
- size_t count = GetCount();
- for ( size_t n = 0; n < count; n++ )
- {
- SetClientObject( n, NULL );
- }
- }
-}
-
-int wxComboBox::GetCount() const {
+unsigned int wxComboBox::GetCount() const {
- 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 ) );
- verify_noerr ( HIComboBoxInsertTextItemAtIndex( *m_peer, (CFIndex) n,
- wxMacCFStringHolder(s, m_font.GetEncoding()) ) );
- verify_noerr ( HIComboBoxRemoveItemAtIndex( *m_peer, (CFIndex) n + 1 ) );
+ verify_noerr ( HIComboBoxInsertTextItemAtIndex( m_peer->GetControlRef(), (CFIndex) n,
+ wxMacCFStringHolder(s, GetFont().GetEncoding()) ) );
+ verify_noerr ( HIComboBoxRemoveItemAtIndex( m_peer->GetControlRef(), (CFIndex) n + 1 ) );