]> git.saurik.com Git - wxWidgets.git/commitdiff
removed WXK_SPACE as duplicating the selection event, added theme text drawing patch
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 23 Aug 2002 14:35:44 +0000 (14:35 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 23 Aug 2002 14:35:44 +0000 (14:35 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@16708 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/listbox.cpp
src/mac/listbox.cpp

index dc3f4d20bbaaebcba79556a1085f7ba67e2ed57a..899cc62cb27772d97f141b12b9de28c1c3c1b0af 100644 (file)
@@ -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 );
index dc3f4d20bbaaebcba79556a1085f7ba67e2ed57a..899cc62cb27772d97f141b12b9de28c1c3c1b0af 100644 (file)
@@ -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 );