]> git.saurik.com Git - wxWidgets.git/blobdiff - src/mac/carbon/listctrl_mac.cpp
typo
[wxWidgets.git] / src / mac / carbon / listctrl_mac.cpp
index 1c2878f868bd120a1508cc08489814dcd27b21c6..e8d3445065fdd896ad9327048067025046bcf677 100644 (file)
@@ -154,10 +154,13 @@ static pascal OSStatus wxMacListCtrlEventHandler( EventHandlerCallRef handler ,
                 break; 
             }
         case kEventControlDraw:
-            CGContextRef context = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, typeCGContextRef) ;
-            window->MacSetDrawingContext(context);
-            result = CallNextEventHandler(handler, event);
-            window->MacSetDrawingContext(NULL);
+            {
+                CGContextRef context = cEvent.GetParameter<CGContextRef>(kEventParamCGContextRef, typeCGContextRef) ;
+                window->MacSetDrawingContext(context);
+                result = CallNextEventHandler(handler, event);
+                window->MacSetDrawingContext(NULL);
+                break;
+            }
         default :
             break ;
     }
@@ -293,6 +296,11 @@ bool wxMacListCtrlEventDelegate::ProcessEvent( wxEvent& event )
     event.SetEventObject( m_list );
     event.SetId( m_id );
     
+    if ( !event.IsKindOf( CLASSINFO( wxCommandEvent ) ) )
+    {
+        if (m_list->GetEventHandler()->ProcessEvent( event ))
+            return true;
+    } 
     return wxEvtHandler::ProcessEvent(event);
 }
 
@@ -718,7 +726,22 @@ bool wxListCtrl::GetItem(wxListItem& info) const
         return m_genericImpl->GetItem(info);
 
     if (m_dbImpl)
-        m_dbImpl->MacGetColumnInfo(info.m_itemId, info.m_col, info);
+    {
+        if (!IsVirtual())
+            m_dbImpl->MacGetColumnInfo(info.m_itemId, info.m_col, info);
+        else
+        {
+            info.SetText( OnGetItemText(info.m_itemId, info.m_col) );
+            info.SetImage( OnGetItemColumnImage(info.m_itemId, info.m_col) );
+            wxListItemAttr* attrs = OnGetItemAttr( info.m_itemId );
+            if (attrs)
+            {
+                info.SetFont( attrs->GetFont() );
+                info.SetBackgroundColour( attrs->GetBackgroundColour() );
+                info.SetTextColour( attrs->GetTextColour() );
+            }
+        }
+    }
     bool success = true;
     return success;
 }
@@ -888,6 +911,33 @@ bool wxListCtrl::GetItemRect(long item, wxRect& rect, int code) const
     if (m_genericImpl)
         return m_genericImpl->GetItemRect(item, rect, code);
 
+
+    if (m_dbImpl)
+    {
+        DataBrowserItemID id;
+        DataBrowserPropertyID col = kMinColumnId;
+        Rect bounds;
+        DataBrowserPropertyPart part = kDataBrowserPropertyEnclosingPart;
+        if ( code == wxLIST_RECT_LABEL )
+            part = kDataBrowserPropertyTextPart;
+        else if ( code == wxLIST_RECT_ICON )
+            part = kDataBrowserPropertyIconPart;
+            
+        if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL) )
+        {
+            wxMacDataItem* thisItem = m_dbImpl->GetItemFromLine(item);
+            id = (DataBrowserItemID) thisItem;
+        }
+        else
+            id = item;
+            
+        GetDataBrowserItemPartBounds( m_dbImpl->GetControlRef(), id, col, part, &bounds );
+        
+        rect.x = bounds.left;
+        rect.y = bounds.top;
+        rect.width = GetClientSize().x; // we need the width of the whole row, not just the item.
+        rect.height = bounds.bottom - bounds.top;
+    }
     return true;
 }
 
@@ -898,6 +948,14 @@ bool wxListCtrl::GetItemPosition(long item, wxPoint& pos) const
         return m_genericImpl->GetItemPosition(item, pos);
 
     bool success = false;
+    
+    if (m_dbImpl)
+    {
+        wxRect itemRect;
+        GetItemRect(item, itemRect);
+        pos = itemRect.GetPosition();
+        success = true;
+    }
 
     return success;
 }
@@ -1347,6 +1405,42 @@ wxListCtrl::HitTest(const wxPoint& point, int& flags, long *ptrSubItem) const
     if (m_genericImpl)
         return m_genericImpl->HitTest(point, flags, ptrSubItem);
 
+    flags = wxLIST_HITTEST_NOWHERE;
+    if (m_dbImpl)
+    {
+        int colHeaderHeight = 22; // TODO: Find a way to get this value from the db control?
+        UInt16 rowHeight = 0;
+        m_dbImpl->GetDefaultRowHeight(&rowHeight);
+        
+        int y = point.y;
+        if ( !(GetWindowStyleFlag() & wxLC_NO_HEADER) )
+            y -= colHeaderHeight;
+        
+        int row = y / rowHeight;
+        DataBrowserItemID id;
+        m_dbImpl->GetItemID( (DataBrowserTableViewRowIndex) row, &id );
+        
+        // TODO: Use GetDataBrowserItemPartBounds to return if we are in icon or label
+        if ( !(GetWindowStyleFlag() & wxLC_VIRTUAL ) )
+        {
+            wxMacListCtrlItem* lcItem;
+            lcItem = (wxMacListCtrlItem*) id;
+            if (lcItem)
+            {
+                flags = wxLIST_HITTEST_ONITEM;
+                return row;
+            }
+        }
+        else
+        {
+            if (row < GetItemCount() )
+            {
+                flags = wxLIST_HITTEST_ONITEM;
+                return row;
+            }
+        }
+    
+    }
     return -1;
 }
 
@@ -2011,9 +2105,14 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
             iconLabel.green = 0;
             iconLabel.blue = 0;
             
+            CGContextSaveGState(context);
+            CGContextTranslateCTM(context, 0,iconCGRect.origin.y + CGRectGetMaxY(iconCGRect));
+            CGContextScaleCTM(context,1.0f,-1.0f);
             PlotIconRefInContext(context, &iconCGRect, kAlignNone, 
               active ? kTransformNone : kTransformDisabled, &iconLabel, 
               kPlotIconRefNormalFlags, icon);
+              
+            CGContextRestoreGState(context);
         }
     }