From 202848fe9e424cd3a9fa9a23ff7e6fdd78dbe4cf Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Fri, 23 Aug 2002 14:35:44 +0000 Subject: [PATCH] removed WXK_SPACE as duplicating the selection event, added theme text drawing patch git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16708 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/mac/carbon/listbox.cpp | 43 ++++++++++++++++++++++++++++++-------- src/mac/listbox.cpp | 43 ++++++++++++++++++++++++++++++-------- 2 files changed, 68 insertions(+), 18 deletions(-) diff --git a/src/mac/carbon/listbox.cpp b/src/mac/carbon/listbox.cpp index dc3f4d20bb..899cc62cb2 100644 --- a/src/mac/carbon/listbox.cpp +++ b/src/mac/carbon/listbox.cpp @@ -54,6 +54,12 @@ typedef struct { #pragma pack() #endif +#if TARGET_CARBON +const short kwxMacListItemHeight = 19 ; +#else +const short kwxMacListItemHeight = 14 ; +#endif + extern "C" { static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect, @@ -98,12 +104,33 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect ClipRect( drawRect ); EraseRect( drawRect ); - MoveTo(drawRect->left + 4 , drawRect->top + 10 ); - ::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 ) ; + ::DrawThemeTextBox( mString, + kThemeViewsFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + } + else +#endif + { + MoveTo(drawRect->left + 4 , drawRect->top + 10 ); + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + DrawText(text, 0 , text.Length()); + } - DrawText(text, 0 , text.Length()); // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. @@ -139,7 +166,6 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ; const short kwxMacListWithVerticalScrollbar = 128 ; -const short kwxMacListItemHeight = 14 ; // ============================================================================ // list box control implementation @@ -881,11 +907,10 @@ void wxListBox::OnChar(wxKeyEvent& event) if ( !GetEventHandler()->ProcessEvent( new_event ) ) event.Skip() ; } - else if ( event.KeyCode() == WXK_SPACE || event.KeyCode() == WXK_DOWN || event.KeyCode() == WXK_UP ) + else if ( event.KeyCode() == WXK_DOWN || event.KeyCode() == WXK_UP ) { // perform the default key handling first - if ( event.KeyCode() == WXK_DOWN || event.KeyCode() == WXK_UP ) - wxControl::OnKeyDown( event ) ; + wxControl::OnKeyDown( event ) ; wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); event.SetEventObject( this ); diff --git a/src/mac/listbox.cpp b/src/mac/listbox.cpp index dc3f4d20bb..899cc62cb2 100644 --- a/src/mac/listbox.cpp +++ b/src/mac/listbox.cpp @@ -54,6 +54,12 @@ typedef struct { #pragma pack() #endif +#if TARGET_CARBON +const short kwxMacListItemHeight = 19 ; +#else +const short kwxMacListItemHeight = 14 ; +#endif + extern "C" { static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect *drawRect, @@ -98,12 +104,33 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect ClipRect( drawRect ); EraseRect( drawRect ); - MoveTo(drawRect->left + 4 , drawRect->top + 10 ); - ::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 ) ; + ::DrawThemeTextBox( mString, + kThemeViewsFont, + kThemeStateActive, + false, + &frame, + teJustLeft, + nil ); + CFRelease( mString ) ; + } + else +#endif + { + MoveTo(drawRect->left + 4 , drawRect->top + 10 ); + ::TextFont( kFontIDMonaco ) ; + ::TextSize( 9 ); + ::TextFace( 0 ) ; + DrawText(text, 0 , text.Length()); + } - DrawText(text, 0 , text.Length()); // If the cell is hilited, do the hilite now. Paint the cell contents with the // appropriate QuickDraw transform mode. @@ -139,7 +166,6 @@ static pascal void wxMacListDefinition( short message, Boolean isSelected, Rect extern "C" void MacDrawStringCell(Rect *cellRect, Cell lCell, ListHandle theList, long refCon) ; const short kwxMacListWithVerticalScrollbar = 128 ; -const short kwxMacListItemHeight = 14 ; // ============================================================================ // list box control implementation @@ -881,11 +907,10 @@ void wxListBox::OnChar(wxKeyEvent& event) if ( !GetEventHandler()->ProcessEvent( new_event ) ) event.Skip() ; } - else if ( event.KeyCode() == WXK_SPACE || event.KeyCode() == WXK_DOWN || event.KeyCode() == WXK_UP ) + else if ( event.KeyCode() == WXK_DOWN || event.KeyCode() == WXK_UP ) { // perform the default key handling first - if ( event.KeyCode() == WXK_DOWN || event.KeyCode() == WXK_UP ) - wxControl::OnKeyDown( event ) ; + wxControl::OnKeyDown( event ) ; wxCommandEvent event(wxEVT_COMMAND_LISTBOX_SELECTED, m_windowId); event.SetEventObject( this ); -- 2.47.2