ClipRect( drawRect );
EraseRect( drawRect );
+ wxFontRefData * font = (wxFontRefData*) list->GetFont().GetRefData() ;
+
+ if ( font )
+ {
+ ::TextFont( font->m_macFontNum ) ;
+ ::TextSize( short(font->m_macFontSize) ) ;
+ ::TextFace( font->m_macFontStyle ) ;
+ }
+ else
+ {
+ ::TextFont( kFontIDMonaco ) ;
+ ::TextSize( 9 );
+ ::TextFace( 0 ) ;
+ }
+
#if TARGET_CARBON
bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ;
if ( useDrawThemeText )
{
Rect frame = { drawRect->top, drawRect->left + 4,
- drawRect->top + kwxMacListItemHeight, drawRect->right} ;
- CFStringRef mString = CFStringCreateWithBytes( NULL , (UInt8*) text.c_str(), text.Length(), CFStringGetSystemEncoding(), false ) ;
+ drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ;
+ CFStringRef sString = CFStringCreateWithBytes( NULL , (UInt8*) text.c_str(), text.Length(), CFStringGetSystemEncoding(), false ) ;
+ CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , sString ) ;
+ CFRelease( sString ) ;
+ ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ;
::DrawThemeTextBox( mString,
- kThemeViewsFont,
+ kThemeCurrentPortFont,
kThemeStateActive,
false,
&frame,
#endif
{
MoveTo(drawRect->left + 4 , drawRect->top + 10 );
- ::TextFont( kFontIDMonaco ) ;
- ::TextSize( 9 );
- ::TextFace( 0 ) ;
DrawText(text, 0 , text.Length());
}
}
listDef.u.userProc = macListDefUPP ;
+ Str255 fontName ;
+ SInt16 fontSize ;
+ Style fontStyle ;
+#if TARGET_CARBON
+ GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
+#else
+ GetFontName( kFontIDMonaco , fontName ) ;
+ fontSize = 9 ;
+ fontStyle = normal ;
+#endif
+ CopyPascalStringToC( fontName , (char*) fontName ) ;
+ SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , fontName ) ) ;
#if TARGET_CARBON
Size asize;
}
else
{
- options = lOnlyOne ;
+ options = (OptionBits) lOnlyOne ;
}
SetListSelectionFlags((ListHandle)m_macList, options);
- MacPostControlCreate() ;
-
for ( int i = 0 ; i < n ; i++ )
{
Append( choices[i] ) ;
}
+ MacPostControlCreate() ;
+
LSetDrawingMode( true , (ListHandle)m_macList ) ;
return TRUE;
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
}
#endif // wxUSE_OWNER_DRAWN
- wxASSERT_MSG( m_dataArray.GetCount() >= N , "invalid client_data array" ) ;
+ wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , "invalid client_data array" ) ;
- if ( m_dataArray.GetCount() > N )
+ if ( m_dataArray.GetCount() > (size_t) N )
{
m_dataArray[N] = (char*) Client_data ;
}
wxSize wxListBox::DoGetBestSize() const
{
- return wxSize(100, 100);
+ int lbWidth = 100; // some defaults
+ int lbHeight = 110;
+ int wLine;
+
+ {
+ wxMacPortStateHelper st( UMAGetWindowPort( (WindowRef) MacGetRootWindow() ) ) ;
+
+ wxFontRefData * font = (wxFontRefData*) m_font.GetRefData() ;
+
+ if ( font )
+ {
+ ::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 scrollbar
+ lbWidth += wxSystemSettings::GetMetric(wxSYS_VSCROLL_X);
+
+ // And just a bit more
+ int cy = 12 ;
+ int cx = ::TextWidth( "X" , 0 , 1 ) ;
+ lbWidth += cx ;
+
+ // don't make the listbox too tall (limit height to around 10 items) but don't
+ // make it too small neither
+ lbHeight = (cy+4) * wxMin(wxMax(GetCount(), 3), 10);
+ }
+ return wxSize(lbWidth, lbHeight);
}
int wxListBox::GetCount() const
// list box control implementation
// ============================================================================
+/*
void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon)
{
wxListBox* list;
DrawText(text, 0 , text.Length());
}
-
+*/
void wxListBox::MacDelete( int N )
{
LDelRow( 1 , N , (ListHandle)m_macList) ;
void wxListBox::MacDoClick()
{
wxArrayInt aSelections;
- int n, count = GetSelections(aSelections);
+ int n ;
+ size_t count = GetSelections(aSelections);
if ( count == m_selectionPreImage.GetCount() )
{
bool hasChanged = false ;
- for ( int i = 0 ; i < count ; ++i )
+ for ( size_t i = 0 ; i < count ; ++i )
{
if ( aSelections[i] != m_selectionPreImage[i] )
{
GetEventHandler()->ProcessEvent(event) ;
}
-static long sLastTypeIn = 0 ;
-
void wxListBox::OnChar(wxKeyEvent& event)
{
if ( event.KeyCode() == WXK_RETURN || event.KeyCode() == WXK_NUMPAD_ENTER)