diff --git a/lcl/interfaces/cocoa/cocoatables.pas b/lcl/interfaces/cocoa/cocoatables.pas index 9fabe9b75e..b255965ac6 100644 --- a/lcl/interfaces/cocoa/cocoatables.pas +++ b/lcl/interfaces/cocoa/cocoatables.pas @@ -78,7 +78,7 @@ type isImagesInCell: Boolean; isFirstColumnCheckboxes: Boolean; - isCustomDraw : Boolean; + isOwnerDraw : Boolean; isDynamicRowHeight: Boolean; CustomRowHeight: Integer; @@ -97,6 +97,7 @@ type procedure resetCursorRects; override; procedure drawRow_clipRect(row: NSInteger; clipRect: NSRect); override; + procedure drawRect(dirtyRect: NSRect); override; // mouse procedure mouseDown(event: NSEvent); override; @@ -510,7 +511,6 @@ var ItemState: TOwnerDrawState; begin inherited; - if not isCustomDraw then Exit; if not Assigned(callback) then Exit; ctx := TCocoaContext.Create(NSGraphicsContext.currentContext); try @@ -526,6 +526,13 @@ begin end; end; +procedure TCocoaTableListView.drawRect(dirtyRect: NSRect); +begin + inherited drawRect(dirtyRect); + if CheckMainThread and Assigned(callback) then + callback.Draw(NSGraphicsContext.currentContext, bounds, dirtyRect); +end; + function TCocoaTableListView.getIndexOfColumn(ACol: NSTableColumn): Integer; var idx : NSUInteger; diff --git a/lcl/interfaces/cocoa/cocoawschecklst.pas b/lcl/interfaces/cocoa/cocoawschecklst.pas index be4df77939..20de989e51 100644 --- a/lcl/interfaces/cocoa/cocoawschecklst.pas +++ b/lcl/interfaces/cocoa/cocoawschecklst.pas @@ -230,7 +230,7 @@ begin list.readOnly := true; //todo: //list.AllowMixedState := TCustomCheckListBox(AWinControl).AllowGrayed; - list.isCustomDraw := TCustomCheckListBox(AWinControl).Style in [lbOwnerDrawFixed, lbOwnerDrawVariable]; + list.isOwnerDraw := TCustomCheckListBox(AWinControl).Style in [lbOwnerDrawFixed, lbOwnerDrawVariable]; scroll := EmbedInScrollView(list); if not Assigned(scroll) then diff --git a/lcl/interfaces/cocoa/cocoawsstdctrls.pas b/lcl/interfaces/cocoa/cocoawsstdctrls.pas index d4e88d38df..3e498ae352 100644 --- a/lcl/interfaces/cocoa/cocoawsstdctrls.pas +++ b/lcl/interfaces/cocoa/cocoawsstdctrls.pas @@ -648,6 +648,7 @@ procedure TLCLListBoxCallback.DrawRow(rowidx: Integer; ctx: TCocoaContext; var DrawStruct: TDrawListItemStruct; begin + if not listview.isOwnerDraw then Exit; DrawStruct.ItemState := state; DrawStruct.Area := r; DrawStruct.DC := HDC(ctx); @@ -2074,7 +2075,7 @@ end; procedure ListBoxSetStyle(list: TCocoaTableListView; AStyle: TListBoxStyle); begin if not Assigned(list) then Exit; - list.isCustomDraw := AStyle in [lbOwnerDrawFixed, lbOwnerDrawVariable]; + list.isOwnerDraw := AStyle in [lbOwnerDrawFixed, lbOwnerDrawVariable]; list.isDynamicRowHeight := AStyle = lbOwnerDrawVariable; //todo: if flag isCustomRowHeight changes in runtime // noteHeightOfRowsWithIndexesChanged, should be sent to listview