X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/5b2c144640ca728577fc5787bb6e0c70f5a9b028..6e25bf0ffb33edf8d23ebeb9098510753b1fb6a8:/src/mac/carbon/listctrl_mac.cpp diff --git a/src/mac/carbon/listctrl_mac.cpp b/src/mac/carbon/listctrl_mac.cpp index 9eab50bd69..ad52f2a295 100644 --- a/src/mac/carbon/listctrl_mac.cpp +++ b/src/mac/carbon/listctrl_mac.cpp @@ -154,10 +154,13 @@ static pascal OSStatus wxMacListCtrlEventHandler( EventHandlerCallRef handler , break; } case kEventControlDraw: - CGContextRef context = cEvent.GetParameter(kEventParamCGContextRef, typeCGContextRef) ; - window->MacSetDrawingContext(context); - result = CallNextEventHandler(handler, event); - window->MacSetDrawingContext(NULL); + { + CGContextRef context = cEvent.GetParameter(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); } @@ -389,7 +397,7 @@ bool wxListCtrl::Create(wxWindow *parent, { m_macIsUserPane = true; - if ( !wxWindow::Create(parent, id, pos, size, style, name) ) + if ( !wxWindow::Create(parent, id, pos, size, style & wxNO_BORDER, name) ) return false; m_genericImpl = new wxGenericListCtrlHook(this, id, pos, size, style, validator, name); m_genericImpl->PushEventHandler( new wxMacListCtrlEventDelegate( this, GetId() ) ); @@ -482,6 +490,14 @@ void wxListCtrl::DoSetSize( int x, int y, int width, int height, int sizeFlags ) m_genericImpl->SetSize(x, y, width, height, sizeFlags); } +wxSize wxListCtrl::DoGetBestSize() const +{ + if (m_genericImpl) + return m_genericImpl->GetBestSize(); + + return wxWindow::DoGetBestSize(); +} + bool wxListCtrl::SetFont(const wxFont& font) { bool rv = true; @@ -903,6 +919,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; } @@ -913,6 +956,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; } @@ -1362,6 +1413,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; } @@ -2026,9 +2113,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); } }