case lDrawMsg:
{
- const wxString text = list->m_stringArray[cell.v] ;
+ const wxString linetext = list->m_stringArray[cell.v] ;
// Save the current clip region, and set the clip region to the area we are about
// to draw.
}
#if TARGET_CARBON
- bool useDrawThemeText = ( DrawThemeTextBox != (void*) kUnresolvedCFragSymbolAddress ) ;
-
- if ( useDrawThemeText )
- {
- Rect frame = { drawRect->top, drawRect->left + 4,
- 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,
- kThemeCurrentPortFont,
- kThemeStateActive,
- false,
- &frame,
- teJustLeft,
- nil );
- CFRelease( mString ) ;
- }
- else
-#endif
- {
+ {
+ Rect frame = { drawRect->top, drawRect->left + 4,
+ drawRect->top + kwxMacListItemHeight, drawRect->right + 10000 } ;
+ CFMutableStringRef mString = CFStringCreateMutableCopy( NULL , 0 , wxMacCFStringHolder(linetext) ) ;
+ ::TruncateThemeText( mString , kThemeCurrentPortFont, kThemeStateActive, drawRect->right - drawRect->left , truncEnd , NULL ) ;
+ ::DrawThemeTextBox( mString,
+ kThemeCurrentPortFont,
+ kThemeStateActive,
+ false,
+ &frame,
+ teJustLeft,
+ nil );
+ CFRelease( mString ) ;
+ }
+#else
+ {
+ wxCharBuffer text = wxMacStringToCString( linetext ) ;
MoveTo(drawRect->left + 4 , drawRect->top + 10 );
- DrawText(text, 0 , text.Length());
+ DrawText(text, 0 , strlen(text) );
}
-
+#endif
// If the cell is hilited, do the hilite now. Paint the cell contents with the
// appropriate QuickDraw transform mode.
Rect bounds ;
Str255 title ;
- MacPreControlCreate( parent , id , "" , pos , size ,style, validator , name , &bounds , title ) ;
+ MacPreControlCreate( parent , id , wxEmptyString , pos , size ,style, validator , name , &bounds , title ) ;
ListDefSpec listDef;
listDef.defType = kListDefUserProcType;
Str255 fontName ;
SInt16 fontSize ;
Style fontStyle ;
- SInt16 fontNum ;
#if TARGET_CARBON
GetThemeFont(kThemeViewsFont , GetApplicationScript() , fontName , &fontSize , &fontStyle ) ;
#else
fontSize = 9 ;
fontStyle = normal ;
#endif
- CopyPascalStringToC( fontName , (char*) fontName ) ;
- SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , fontName ) ) ;
+ SetFont( wxFont (fontSize, wxSWISS, wxNORMAL, wxNORMAL , false , wxMacMakeStringFromPascal( fontName ) ) ) ;
#if TARGET_CARBON
Size asize;
int wxListBox::DoAppend(const wxString& item)
{
int index = m_noItems ;
- if( wxApp::s_macDefaultEncodingIsPC )
- {
- m_stringArray.Add( wxMacMakeMacStringFromPC( item ) ) ;
- m_dataArray.Add( NULL );
- }
- else {
- m_stringArray.Add( item ) ;
- m_dataArray.Add( NULL );
- }
+ m_stringArray.Add( item ) ;
+ m_dataArray.Add( NULL );
m_noItems ++;
DoSetItemClientData( index , NULL ) ;
MacAppend( item ) ;
return (m_windowStyle & wxLB_MULTIPLE) || (m_windowStyle & wxLB_EXTENDED);
}
-int wxListBox::FindString(const wxString& st) const
+int wxListBox::FindString(const wxString& s) const
{
- wxString s ;
- if( wxApp::s_macDefaultEncodingIsPC )
- {
- s = wxMacMakeMacStringFromPC( st ) ;
- }
- else
- s = st ;
- if ( s.Right(1) == "*" )
+ if ( s.Right(1) == wxT("*") )
{
wxString search = s.Left( s.Length() - 1 ) ;
int len = search.Length() ;
Str255 s1 , s2 ;
-
-#if TARGET_CARBON
- c2pstrcpy( (StringPtr) s2 , search.c_str() ) ;
-#else
- strcpy( (char *) s2 , search.c_str() ) ;
- c2pstr( (char *) s2 ) ;
-#endif
+ wxMacStringToPascal( search , s2 ) ;
for ( int i = 0 ; i < m_noItems ; ++ i )
{
-#if TARGET_CARBON
- c2pstrcpy( (StringPtr) s1 , m_stringArray[i].Left( len ).c_str() ) ;
-#else
- strcpy( (char *) s1 , m_stringArray[i].Left( len ).c_str() ) ;
- c2pstr( (char *) s1 ) ;
-#endif
+ wxMacStringToPascal( m_stringArray[i].Left( len ) , s1 ) ;
+
if ( EqualString( s1 , s2 , false , false ) )
return i ;
}
- if ( s.Left(1) == "*" && s.Length() > 1 )
+ if ( s.Left(1) == wxT("*") && s.Length() > 1 )
{
- s = st ;
- s.MakeLower() ;
+ wxString st = s ;
+ st.MakeLower() ;
for ( int i = 0 ; i < m_noItems ; ++i )
{
- if ( GetString(i).Lower().Matches(s) )
+ if ( GetString(i).Lower().Matches(st) )
return i ;
}
}
{
Str255 s1 , s2 ;
-#if TARGET_CARBON
- c2pstrcpy( (StringPtr) s2 , s.c_str() ) ;
-#else
- strcpy( (char *) s2 , s.c_str() ) ;
- c2pstr( (char *) s2 ) ;
-#endif
+ wxMacStringToPascal( s , s2 ) ;
for ( int i = 0 ; i < m_noItems ; ++ i )
{
-#if TARGET_CARBON
- c2pstrcpy( (StringPtr) s1 , m_stringArray[i].c_str() ) ;
-#else
- strcpy( (char *) s1 , m_stringArray[i].c_str() ) ;
- c2pstr( (char *) s1 ) ;
-#endif
+ wxMacStringToPascal( m_stringArray[i] , s1 ) ;
+
if ( EqualString( s1 , s2 , false , false ) )
return i ;
}
void wxListBox::SetSelection(int N, bool select)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
- "invalid index in wxListBox::SetSelection" );
+ wxT("invalid index in wxListBox::SetSelection") );
MacSetSelection( N , select ) ;
GetSelections( m_selectionPreImage ) ;
}
bool wxListBox::IsSelected(int N) const
{
wxCHECK_MSG( N >= 0 && N < m_noItems, FALSE,
- "invalid index in wxListBox::Selected" );
+ wxT("invalid index in wxListBox::Selected") );
return MacIsSelected( N ) ;
}
void wxListBox::DoSetItemClientData(int N, void *Client_data)
{
wxCHECK_RET( N >= 0 && N < m_noItems,
- "invalid index in wxListBox::SetClientData" );
+ wxT("invalid index in wxListBox::SetClientData") );
#if wxUSE_OWNER_DRAWN
if ( m_windowStyle & wxLB_OWNERDRAW )
wxFAIL_MSG(wxT("Can't use client data with owner-drawn listboxes"));
}
#endif // wxUSE_OWNER_DRAWN
- wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , "invalid client_data array" ) ;
+ wxASSERT_MSG( m_dataArray.GetCount() >= (size_t) N , wxT("invalid client_data array") ) ;
if ( m_dataArray.GetCount() > (size_t) N )
{
// Find string for position
wxString wxListBox::GetString(int N) const
{
- if( wxApp::s_macDefaultEncodingIsPC )
- {
- return wxMacMakePCStringFromMac( m_stringArray[N] ) ;
- }
- else
- return m_stringArray[N] ;
+ return m_stringArray[N] ;
}
void wxListBox::DoInsertItems(const wxArrayString& items, int pos)
void wxListBox::SetString(int N, const wxString& s)
{
- wxString str ;
- if( wxApp::s_macDefaultEncodingIsPC )
- {
- str = wxMacMakeMacStringFromPC( s ) ;
- }
- else
- str = s ;
- m_stringArray[N] = str ;
+ m_stringArray[N] = s ;
MacSet( N , s ) ;
}
// Find the widest line
for(int i = 0; i < GetCount(); i++) {
wxString str(GetString(i));
- wLine = ::TextWidth( str.c_str() , 0 , str.Length() ) ;
+ #if wxUSE_UNICODE
+ Point bounds={0,0} ;
+ SInt16 baseline ;
+ ::GetThemeTextDimensions( wxMacCFStringHolder( str ) ,
+ kThemeCurrentPortFont,
+ kThemeStateActive,
+ false,
+ &bounds,
+ &baseline );
+ wLine = bounds.h ;
+ #else
+ wxCharBuffer text = wxMacStringToCString( str ) ;
+ wLine = ::TextWidth( text , 0 , strlen(text) ) ;
+ #endif
lbWidth = wxMax(lbWidth, wLine);
}
Refresh();
}
-void wxListBox::MacInsert( int n , const char * text)
+void wxListBox::MacInsert( int n , const wxString& text)
{
Cell cell = { 0 , 0 } ;
cell.v = n ;
Refresh();
}
-void wxListBox::MacAppend( const char * text)
+void wxListBox::MacAppend( const wxString& text)
{
Cell cell = { 0 , 0 } ;
cell.v = (**(ListHandle)m_macList).dataBounds.bottom ;
return no_sel ;
}
-void wxListBox::MacSet( int n , const char * text )
+void wxListBox::MacSet( int n , const wxString& text )
{
// our implementation does not store anything in the list
// so we just have to redraw
LCellSize( pt , (ListHandle)m_macList ) ;
}
-void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart )
+void wxListBox::MacHandleControlClick( WXWidget control , wxInt16 controlpart , bool WXUNUSED(mouseStillDown))
{
Boolean wasDoubleClick = false ;
long result ;
/* generate wxID_CANCEL if command-. or <esc> has been pressed (typically in dialogs) */
else if (event.GetKeyCode() == WXK_ESCAPE || (event.GetKeyCode() == '.' && event.MetaDown() ) )
{
+ // FIXME: look in ancestors, not just parent.
wxWindow* win = GetParent()->FindWindow( wxID_CANCEL ) ;
- wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
- new_event.SetEventObject( win );
- win->GetEventHandler()->ProcessEvent( new_event );
+ if (win)
+ {
+ wxCommandEvent new_event(wxEVT_COMMAND_BUTTON_CLICKED,wxID_CANCEL);
+ new_event.SetEventObject( win );
+ win->GetEventHandler()->ProcessEvent( new_event );
+ }
}
else if ( event.GetKeyCode() == WXK_TAB )
{
{
if ( event.GetTimestamp() > m_lastTypeIn + 60 )
{
- m_typeIn = "" ;
+ m_typeIn = wxEmptyString ;
}
m_lastTypeIn = event.GetTimestamp() ;
m_typeIn += (char) event.GetKeyCode() ;
- int line = FindString("*"+m_typeIn+"*") ;
+ int line = FindString(wxT("*")+m_typeIn+wxT("*")) ;
if ( line >= 0 )
{
if ( GetSelection() != line )