+ verify_noerr( DataBrowserChangeAttributes(m_controlRef, kDataBrowserAttributeListViewDrawColumnDividers, kDataBrowserAttributeNone) );
+ }
+
+ verify_noerr( SetHiliteStyle(kDataBrowserTableViewFillHilite ) );
+ verify_noerr( SetHasScrollBars( (style & wxHSCROLL) != 0 , true ) );
+}
+
+pascal Boolean wxMacDataBrowserListCtrlControl::DataBrowserEditTextProc(
+ ControlRef browser,
+ DataBrowserItemID itemID,
+ DataBrowserPropertyID property,
+ CFStringRef theString,
+ Rect *maxEditTextRect,
+ Boolean *shrinkToFit)
+{
+ Boolean result = false;
+ wxMacDataBrowserListCtrlControl* ctl = wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser ), wxMacDataBrowserListCtrlControl);
+ if ( ctl != 0 )
+ {
+ result = ctl->ConfirmEditText(itemID, property, theString, maxEditTextRect, shrinkToFit);
+ theString = CFSTR("Hello!");
+ }
+ return result;
+}
+
+bool wxMacDataBrowserListCtrlControl::ConfirmEditText(
+ DataBrowserItemID WXUNUSED(itemID),
+ DataBrowserPropertyID WXUNUSED(property),
+ CFStringRef WXUNUSED(theString),
+ Rect *WXUNUSED(maxEditTextRect),
+ Boolean *WXUNUSED(shrinkToFit))
+{
+ return false;
+}
+
+pascal void wxMacDataBrowserListCtrlControl::DataBrowserDrawItemProc(
+ ControlRef browser,
+ DataBrowserItemID itemID,
+ DataBrowserPropertyID property,
+ DataBrowserItemState itemState,
+ const Rect *itemRect,
+ SInt16 gdDepth,
+ Boolean colorDevice)
+{
+ wxMacDataBrowserListCtrlControl* ctl = wxDynamicCast(wxMacControl::GetReferenceFromNativeControl( browser ), wxMacDataBrowserListCtrlControl);
+ if ( ctl != 0 )
+ {
+ ctl->DrawItem(itemID, property, itemState, itemRect, gdDepth, colorDevice);
+ }
+}
+
+// routines needed for DrawItem
+enum
+{
+ kIconWidth = 16,
+ kIconHeight = 16,
+ kTextBoxHeight = 14,
+ kIconTextSpacingV = 2,
+ kItemPadding = 4,
+ kContentHeight = kIconHeight + kTextBoxHeight + kIconTextSpacingV
+};
+
+static void calculateCGDrawingBounds(CGRect inItemRect, CGRect *outIconRect, CGRect *outTextRect, bool hasIcon = false)
+{
+ float textBottom;
+ float iconH, iconW = 0;
+ float padding = kItemPadding;
+ if (hasIcon)
+ {
+ iconH = kIconHeight;
+ iconW = kIconWidth;
+ padding = padding*2;
+ }
+
+ textBottom = inItemRect.origin.y;
+
+ *outIconRect = CGRectMake(inItemRect.origin.x + kItemPadding,
+ textBottom + kIconTextSpacingV, kIconWidth,
+ kIconHeight);
+
+ *outTextRect = CGRectMake(inItemRect.origin.x + padding + iconW,
+ textBottom + kIconTextSpacingV, inItemRect.size.width - padding - iconW,
+ inItemRect.size.height - kIconTextSpacingV);
+}
+
+void wxMacDataBrowserListCtrlControl::DrawItem(
+ DataBrowserItemID itemID,
+ DataBrowserPropertyID property,
+ DataBrowserItemState itemState,
+ const Rect *WXUNUSED(itemRect),
+ SInt16 gdDepth,
+ Boolean colorDevice)
+{
+ wxString text;
+ wxFont font = wxNullFont;
+ int imgIndex = -1;
+ short listColumn = property - kMinColumnId;
+
+ wxListCtrl* list = wxDynamicCast( GetPeer() , wxListCtrl );
+ wxMacListCtrlItem* lcItem;
+ wxColour color = *wxBLACK;
+ wxColour bgColor = wxNullColour;
+
+ if (listColumn >= 0)
+ {
+ if (!m_isVirtual)
+ {
+ lcItem = (wxMacListCtrlItem*) itemID;
+ if (lcItem->HasColumnInfo(listColumn)){
+ wxListItem* item = lcItem->GetColumnInfo(listColumn);
+
+ // we always use the 0 column to get font and text/background colors.
+ if (lcItem->HasColumnInfo(0))
+ {
+ wxListItem* firstItem = lcItem->GetColumnInfo(0);
+ color = firstItem->GetTextColour();
+ bgColor = firstItem->GetBackgroundColour();
+ font = firstItem->GetFont();
+ }
+
+ if (item->GetMask() & wxLIST_MASK_TEXT)
+ text = item->GetText();
+ if (item->GetMask() & wxLIST_MASK_IMAGE)
+ imgIndex = item->GetImage();
+ }
+
+ }
+ else
+ {
+ long itemNum = (long)itemID-1;
+ if (itemNum >= 0 && itemNum < list->GetItemCount())
+ {
+ text = list->OnGetItemText( itemNum, listColumn );
+ imgIndex = list->OnGetItemColumnImage( itemNum, listColumn );
+ wxListItemAttr* attrs = list->OnGetItemAttr( itemNum );
+ if (attrs)
+ {
+ if (attrs->HasBackgroundColour())
+ bgColor = attrs->GetBackgroundColour();
+ if (attrs->HasTextColour())
+ color = attrs->GetTextColour();
+ if (attrs->HasFont())
+ font = attrs->GetFont();
+ }
+ }
+ }
+ }
+
+ wxColour listBgColor = list->GetBackgroundColour();
+ if (bgColor == wxNullColour)
+ bgColor = listBgColor;
+
+ wxFont listFont = list->GetFont();
+ if (font == wxNullFont)
+ font = listFont;
+
+ wxMacCFStringHolder cfString;
+ cfString.Assign( text, wxLocale::GetSystemEncoding() );
+
+ Rect enclosingRect;
+ CGRect enclosingCGRect, iconCGRect, textCGRect;
+ Boolean active;
+ ThemeDrawingState savedState = NULL;
+ CGContextRef context = (CGContextRef)list->MacGetDrawingContext();
+ 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,
+ &enclosingRect);
+
+ enclosingCGRect = CGRectMake(enclosingRect.left,
+ enclosingRect.top,
+ enclosingRect.right - enclosingRect.left,
+ enclosingRect.bottom - enclosingRect.top);
+
+ bool hasFocus = (wxWindow::FindFocus() == list);
+ active = IsControlActive(GetControlRef());
+
+ // don't paint the background over the vertical rule line
+ if ( list->GetWindowStyleFlag() & wxLC_VRULES )
+ {
+ enclosingCGRect.origin.x += 1;
+ enclosingCGRect.size.width -= 1;
+ }
+ if (itemState == kDataBrowserItemIsSelected)
+ {
+
+ GetThemeDrawingState(&savedState);
+
+ if (active && hasFocus)
+ {
+ GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &backgroundColor);
+ GetThemeTextColor(kThemeTextColorWhite, gdDepth, colorDevice, &labelColor);
+ }
+ else
+ {
+ GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, 32, true, &backgroundColor);
+ GetThemeTextColor(kThemeTextColorBlack, gdDepth, colorDevice, &labelColor);
+ }
+ CGContextSaveGState(context);
+
+ CGContextSetRGBFillColor(context, (float)backgroundColor.red / (float)USHRT_MAX,
+ (float)backgroundColor.green / (float)USHRT_MAX,
+ (float)backgroundColor.blue / (float)USHRT_MAX, 1.0);
+ CGContextFillRect(context, enclosingCGRect);
+
+ CGContextRestoreGState(context);