Fix SetItemCount bug with adding items, a blind fix for generic control dnd issues, native control impls for GetTopItem and GetScrollPos, and improve the code paths of the drawing color code.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@43701 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
9fe25f1329
commit
02095058ef
@ -339,6 +339,11 @@ class WXDLLEXPORT wxListCtrl: public wxControl
|
|||||||
SetFocus();
|
SetFocus();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual int GetScrollPos(int orient) const;
|
||||||
|
|
||||||
|
virtual void SetDropTarget( wxDropTarget *dropTarget );
|
||||||
|
virtual wxDropTarget* GetDropTarget() const;
|
||||||
|
|
||||||
// with CG, we need to get the context from an kEventControlDraw event
|
// with CG, we need to get the context from an kEventControlDraw event
|
||||||
// unfortunately, the DataBrowser callbacks don't provide the context
|
// unfortunately, the DataBrowser callbacks don't provide the context
|
||||||
// and we need it, so we need to set/remove it before and after draw
|
// and we need it, so we need to set/remove it before and after draw
|
||||||
@ -347,6 +352,7 @@ class WXDLLEXPORT wxListCtrl: public wxControl
|
|||||||
void* MacGetDrawingContext() { return m_cgContext; }
|
void* MacGetDrawingContext() { return m_cgContext; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
// protected overrides needed for pimpl approach
|
// protected overrides needed for pimpl approach
|
||||||
virtual void DoSetSize(int x, int y,
|
virtual void DoSetSize(int x, int y,
|
||||||
int width, int height,
|
int width, int height,
|
||||||
|
@ -1464,6 +1464,14 @@ long wxListCtrl::GetTopItem() const
|
|||||||
if (m_genericImpl)
|
if (m_genericImpl)
|
||||||
return m_genericImpl->GetTopItem();
|
return m_genericImpl->GetTopItem();
|
||||||
|
|
||||||
|
if (m_dbImpl)
|
||||||
|
{
|
||||||
|
int flags = 0;
|
||||||
|
long item = HitTest( wxPoint(1, 1), flags);
|
||||||
|
if (flags == wxLIST_HITTEST_ONITEM)
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1810,6 +1818,23 @@ wxListCtrl::HitTest(const wxPoint& point, int& flags, long *ptrSubItem) const
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int wxListCtrl::GetScrollPos(int orient) const
|
||||||
|
{
|
||||||
|
if (m_genericImpl)
|
||||||
|
return m_genericImpl->GetScrollPos(orient);
|
||||||
|
|
||||||
|
if (m_dbImpl)
|
||||||
|
{
|
||||||
|
UInt32 offsetX, offsetY;
|
||||||
|
m_dbImpl->GetScrollPosition( &offsetY, &offsetX );
|
||||||
|
if ( orient == wxHORIZONTAL )
|
||||||
|
return offsetX;
|
||||||
|
else
|
||||||
|
return offsetY;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
// Inserts an item, returning the index of the new item if successful,
|
// Inserts an item, returning the index of the new item if successful,
|
||||||
// -1 otherwise.
|
// -1 otherwise.
|
||||||
@ -2063,6 +2088,10 @@ void wxListCtrl::SetItemCount(long count)
|
|||||||
// we need to temporarily disable the new item creation notification
|
// we need to temporarily disable the new item creation notification
|
||||||
// procedure to speed things up
|
// procedure to speed things up
|
||||||
// FIXME: Even this doesn't seem to help much...
|
// FIXME: Even this doesn't seem to help much...
|
||||||
|
|
||||||
|
// FIXME: Find a more efficient way to do this.
|
||||||
|
m_dbImpl->MacClear();
|
||||||
|
|
||||||
DataBrowserCallbacks callbacks;
|
DataBrowserCallbacks callbacks;
|
||||||
DataBrowserItemNotificationUPP itemUPP;
|
DataBrowserItemNotificationUPP itemUPP;
|
||||||
GetDataBrowserCallbacks(m_dbImpl->GetControlRef(), &callbacks);
|
GetDataBrowserCallbacks(m_dbImpl->GetControlRef(), &callbacks);
|
||||||
@ -2108,6 +2137,28 @@ void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
|
|||||||
RefreshRect(rect);
|
RefreshRect(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListCtrl::SetDropTarget( wxDropTarget *dropTarget )
|
||||||
|
{
|
||||||
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
if (m_genericImpl)
|
||||||
|
m_genericImpl->SetDropTarget( dropTarget );
|
||||||
|
|
||||||
|
if (m_dbImpl)
|
||||||
|
wxWindow::SetDropTarget( dropTarget );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDropTarget *wxListCtrl::GetDropTarget() const
|
||||||
|
{
|
||||||
|
#if wxUSE_DRAG_AND_DROP
|
||||||
|
if (m_genericImpl)
|
||||||
|
return m_genericImpl->GetDropTarget();
|
||||||
|
|
||||||
|
if (m_dbImpl)
|
||||||
|
return wxWindow::GetDropTarget();
|
||||||
|
#endif
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
// wxMac internal data structures
|
// wxMac internal data structures
|
||||||
|
|
||||||
@ -2428,6 +2479,14 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
|
|||||||
ThemeDrawingState savedState = NULL;
|
ThemeDrawingState savedState = NULL;
|
||||||
CGContextRef context = (CGContextRef)list->MacGetDrawingContext();
|
CGContextRef context = (CGContextRef)list->MacGetDrawingContext();
|
||||||
RGBColor labelColor;
|
RGBColor labelColor;
|
||||||
|
labelColor.red = 0;
|
||||||
|
labelColor.green = 0;
|
||||||
|
labelColor.blue = 0;
|
||||||
|
|
||||||
|
RGBColor backgroundColor;
|
||||||
|
backgroundColor.red = 255;
|
||||||
|
backgroundColor.green = 255;
|
||||||
|
backgroundColor.blue = 255;
|
||||||
|
|
||||||
GetDataBrowserItemPartBounds(GetControlRef(), itemID, property, kDataBrowserPropertyEnclosingPart,
|
GetDataBrowserItemPartBounds(GetControlRef(), itemID, property, kDataBrowserPropertyEnclosingPart,
|
||||||
&enclosingRect);
|
&enclosingRect);
|
||||||
@ -2447,18 +2506,17 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
|
|||||||
}
|
}
|
||||||
if (itemState == kDataBrowserItemIsSelected)
|
if (itemState == kDataBrowserItemIsSelected)
|
||||||
{
|
{
|
||||||
RGBColor foregroundColor;
|
|
||||||
|
|
||||||
GetThemeDrawingState(&savedState);
|
GetThemeDrawingState(&savedState);
|
||||||
|
|
||||||
GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &foregroundColor);
|
GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &backgroundColor);
|
||||||
GetThemeTextColor(kThemeTextColorWhite, gdDepth, colorDevice, &labelColor);
|
GetThemeTextColor(kThemeTextColorWhite, gdDepth, colorDevice, &labelColor);
|
||||||
|
|
||||||
CGContextSaveGState(context);
|
CGContextSaveGState(context);
|
||||||
|
|
||||||
CGContextSetRGBFillColor(context, (float)foregroundColor.red / (float)USHRT_MAX,
|
CGContextSetRGBFillColor(context, (float)backgroundColor.red / (float)USHRT_MAX,
|
||||||
(float)foregroundColor.green / (float)USHRT_MAX,
|
(float)backgroundColor.green / (float)USHRT_MAX,
|
||||||
(float)foregroundColor.blue / (float)USHRT_MAX, 1.0);
|
(float)backgroundColor.blue / (float)USHRT_MAX, 1.0);
|
||||||
CGContextFillRect(context, enclosingCGRect);
|
CGContextFillRect(context, enclosingCGRect);
|
||||||
|
|
||||||
CGContextRestoreGState(context);
|
CGContextRestoreGState(context);
|
||||||
@ -2470,21 +2528,15 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
|
|||||||
labelColor = MAC_WXCOLORREF( color.GetPixel() );
|
labelColor = MAC_WXCOLORREF( color.GetPixel() );
|
||||||
else if (list->GetTextColour().Ok())
|
else if (list->GetTextColour().Ok())
|
||||||
labelColor = MAC_WXCOLORREF( list->GetTextColour().GetPixel() );
|
labelColor = MAC_WXCOLORREF( list->GetTextColour().GetPixel() );
|
||||||
else
|
|
||||||
{
|
|
||||||
labelColor.red = 0;
|
|
||||||
labelColor.green = 0;
|
|
||||||
labelColor.blue = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bgColor.Ok())
|
if (bgColor.Ok())
|
||||||
{
|
{
|
||||||
RGBColor foregroundColor = MAC_WXCOLORREF( bgColor.GetPixel() );
|
backgroundColor = MAC_WXCOLORREF( bgColor.GetPixel() );
|
||||||
CGContextSaveGState(context);
|
CGContextSaveGState(context);
|
||||||
|
|
||||||
CGContextSetRGBFillColor(context, (float)foregroundColor.red / (float)USHRT_MAX,
|
CGContextSetRGBFillColor(context, (float)backgroundColor.red / (float)USHRT_MAX,
|
||||||
(float)foregroundColor.green / (float)USHRT_MAX,
|
(float)backgroundColor.green / (float)USHRT_MAX,
|
||||||
(float)foregroundColor.blue / (float)USHRT_MAX, 1.0);
|
(float)backgroundColor.blue / (float)USHRT_MAX, 1.0);
|
||||||
CGContextFillRect(context, enclosingCGRect);
|
CGContextFillRect(context, enclosingCGRect);
|
||||||
|
|
||||||
CGContextRestoreGState(context);
|
CGContextRestoreGState(context);
|
||||||
@ -2500,16 +2552,11 @@ void wxMacDataBrowserListCtrlControl::DrawItem(
|
|||||||
wxBitmap bmp = imageList->GetBitmap(imgIndex);
|
wxBitmap bmp = imageList->GetBitmap(imgIndex);
|
||||||
IconRef icon = bmp.GetBitmapData()->GetIconRef();
|
IconRef icon = bmp.GetBitmapData()->GetIconRef();
|
||||||
|
|
||||||
RGBColor iconLabel;
|
|
||||||
iconLabel.red = 0;
|
|
||||||
iconLabel.green = 0;
|
|
||||||
iconLabel.blue = 0;
|
|
||||||
|
|
||||||
CGContextSaveGState(context);
|
CGContextSaveGState(context);
|
||||||
CGContextTranslateCTM(context, 0,iconCGRect.origin.y + CGRectGetMaxY(iconCGRect));
|
CGContextTranslateCTM(context, 0,iconCGRect.origin.y + CGRectGetMaxY(iconCGRect));
|
||||||
CGContextScaleCTM(context,1.0f,-1.0f);
|
CGContextScaleCTM(context,1.0f,-1.0f);
|
||||||
PlotIconRefInContext(context, &iconCGRect, kAlignNone,
|
PlotIconRefInContext(context, &iconCGRect, kAlignNone,
|
||||||
active ? kTransformNone : kTransformDisabled, &iconLabel,
|
active ? kTransformNone : kTransformDisabled, NULL,
|
||||||
kPlotIconRefNormalFlags, icon);
|
kPlotIconRefNormalFlags, icon);
|
||||||
|
|
||||||
CGContextRestoreGState(context);
|
CGContextRestoreGState(context);
|
||||||
@ -2771,15 +2818,16 @@ Boolean wxMacDataBrowserListCtrlControl::CompareItems(DataBrowserItemID itemOneI
|
|||||||
{
|
{
|
||||||
wxMacListCtrlItem* item = (wxMacListCtrlItem*)itemOneID;
|
wxMacListCtrlItem* item = (wxMacListCtrlItem*)itemOneID;
|
||||||
wxMacListCtrlItem* otherItem = (wxMacListCtrlItem*)itemTwoID;
|
wxMacListCtrlItem* otherItem = (wxMacListCtrlItem*)itemTwoID;
|
||||||
wxListCtrlCompare func = list->GetCompareFunc();
|
|
||||||
long item1 = GetLineFromItem(item);
|
|
||||||
long item2 = GetLineFromItem(otherItem);
|
|
||||||
|
|
||||||
// FIXME: This code causes a crash in wxPython for some reason
|
// FIXME: This code causes a crash in wxPython for some reason
|
||||||
// and moreover, further testing shows that the column click event
|
// and moreover, further testing shows that the column click event
|
||||||
// is only sent to the list ctrl after the native control has finished
|
// is only sent to the list ctrl after the native control has finished
|
||||||
// sorting items anyway. So just disable this for now.
|
// sorting items anyway. So just disable this for now.
|
||||||
|
|
||||||
|
//wxListCtrlCompare func = list->GetCompareFunc();
|
||||||
|
//long item1 = GetLineFromItem(item);
|
||||||
|
//long item2 = GetLineFromItem(otherItem);
|
||||||
|
|
||||||
//if (func != NULL && item->HasColumnInfo(colId) && otherItem->HasColumnInfo(colId))
|
//if (func != NULL && item->HasColumnInfo(colId) && otherItem->HasColumnInfo(colId))
|
||||||
// return func(item1, item2, list->GetCompareFuncData()) >= 0;
|
// return func(item1, item2, list->GetCompareFuncData()) >= 0;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user