corrected generation of all event members (client data) and implemented DoGetBestSize
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_4_BRANCH@18502 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -206,22 +206,68 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const
|
|||||||
void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
|
void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
||||||
event.SetInt(GetSelection());
|
|
||||||
event.SetEventObject(this);
|
int n = GetSelection();
|
||||||
event.SetString(GetStringSelection());
|
// actually n should be made sure by the os to be a valid selection, but ...
|
||||||
ProcessCommand(event);
|
if ( n > -1 )
|
||||||
|
{
|
||||||
|
event.SetInt( n );
|
||||||
|
event.SetString(GetStringSelection());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
event.SetClientObject( GetClientObject(n) );
|
||||||
|
else if ( HasClientUntypedData() )
|
||||||
|
event.SetClientData( GetClientData(n) );
|
||||||
|
|
||||||
|
ProcessCommand(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxChoice::DoGetBestSize() const
|
wxSize wxChoice::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
// TODO should modify this to take into account string length ala wxGTK
|
int lbWidth = 100; // some defaults
|
||||||
return wxSize(100,20);
|
int lbHeight = 20;
|
||||||
}
|
int wLine;
|
||||||
|
#if TARGET_CARBON
|
||||||
|
long metric ;
|
||||||
|
GetThemeMetric(kThemeMetricPopupButtonHeight , &metric );
|
||||||
|
lbHeight = metric ;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;
|
||||||
|
Rect drawRect ;
|
||||||
|
|
||||||
/*
|
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
|
||||||
void wxChoice::Command(wxCommandEvent & event)
|
|
||||||
{
|
if ( font )
|
||||||
SetSelection (event.GetInt());
|
{
|
||||||
ProcessCommand (event);
|
::TextFont( font->m_macFontNum ) ;
|
||||||
|
::TextSize( short(font->m_macFontSize) ) ;
|
||||||
|
::TextFace( font->m_macFontStyle ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
::TextFont( kFontIDMonaco ) ;
|
||||||
|
::TextSize( 9 );
|
||||||
|
::TextFace( 0 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the widest line
|
||||||
|
for(int i = 0; i < GetCount(); i++) {
|
||||||
|
wxString str(GetString(i));
|
||||||
|
wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
|
||||||
|
lbWidth = wxMax(lbWidth, wLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add room for the popup arrow
|
||||||
|
lbWidth += 2 * lbHeight ;
|
||||||
|
|
||||||
|
// And just a bit more
|
||||||
|
int cy = 12 ;
|
||||||
|
int cx = ::TextWidth( "X" , 0 , 1 ) ;
|
||||||
|
lbWidth += cx ;
|
||||||
|
|
||||||
|
}
|
||||||
|
return wxSize(lbWidth, lbHeight);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
@@ -206,22 +206,68 @@ wxClientData* wxChoice::DoGetItemClientObject( int n ) const
|
|||||||
void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
|
void wxChoice::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
|
||||||
{
|
{
|
||||||
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
wxCommandEvent event(wxEVT_COMMAND_CHOICE_SELECTED, m_windowId );
|
||||||
event.SetInt(GetSelection());
|
|
||||||
event.SetEventObject(this);
|
int n = GetSelection();
|
||||||
event.SetString(GetStringSelection());
|
// actually n should be made sure by the os to be a valid selection, but ...
|
||||||
ProcessCommand(event);
|
if ( n > -1 )
|
||||||
|
{
|
||||||
|
event.SetInt( n );
|
||||||
|
event.SetString(GetStringSelection());
|
||||||
|
event.SetEventObject(this);
|
||||||
|
|
||||||
|
if ( HasClientObjectData() )
|
||||||
|
event.SetClientObject( GetClientObject(n) );
|
||||||
|
else if ( HasClientUntypedData() )
|
||||||
|
event.SetClientData( GetClientData(n) );
|
||||||
|
|
||||||
|
ProcessCommand(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSize wxChoice::DoGetBestSize() const
|
wxSize wxChoice::DoGetBestSize() const
|
||||||
{
|
{
|
||||||
// TODO should modify this to take into account string length ala wxGTK
|
int lbWidth = 100; // some defaults
|
||||||
return wxSize(100,20);
|
int lbHeight = 20;
|
||||||
}
|
int wLine;
|
||||||
|
#if TARGET_CARBON
|
||||||
|
long metric ;
|
||||||
|
GetThemeMetric(kThemeMetricPopupButtonHeight , &metric );
|
||||||
|
lbHeight = metric ;
|
||||||
|
#endif
|
||||||
|
{
|
||||||
|
wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;
|
||||||
|
Rect drawRect ;
|
||||||
|
|
||||||
/*
|
wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
|
||||||
void wxChoice::Command(wxCommandEvent & event)
|
|
||||||
{
|
if ( font )
|
||||||
SetSelection (event.GetInt());
|
{
|
||||||
ProcessCommand (event);
|
::TextFont( font->m_macFontNum ) ;
|
||||||
|
::TextSize( short(font->m_macFontSize) ) ;
|
||||||
|
::TextFace( font->m_macFontStyle ) ;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
::TextFont( kFontIDMonaco ) ;
|
||||||
|
::TextSize( 9 );
|
||||||
|
::TextFace( 0 ) ;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the widest line
|
||||||
|
for(int i = 0; i < GetCount(); i++) {
|
||||||
|
wxString str(GetString(i));
|
||||||
|
wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
|
||||||
|
lbWidth = wxMax(lbWidth, wLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add room for the popup arrow
|
||||||
|
lbWidth += 2 * lbHeight ;
|
||||||
|
|
||||||
|
// And just a bit more
|
||||||
|
int cy = 12 ;
|
||||||
|
int cx = ::TextWidth( "X" , 0 , 1 ) ;
|
||||||
|
lbWidth += cx ;
|
||||||
|
|
||||||
|
}
|
||||||
|
return wxSize(lbWidth, lbHeight);
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
Reference in New Issue
Block a user