Recent

Author Topic: TCustomListView: ownerdraw (custom drawing) seems to be not implemented  (Read 2338 times)

Dmitry24

  • New Member
  • *
  • Posts: 22
Gtk*, qt* and win* widgetsets call TCustomListView.IntfCustomDraw function directly in their code.

Neither Cocoa nor Carbon widgetsets contain references to the function IntfCustomDraw. This results in that underlying CustomDraw* functions are never called for these widgetsets.

That is the following TListView properties/functions are ignored (disregarding OwnerDraw property value):

OnDrawItem,
OnCustomDrawItem,
OnCustomDrawSubItem.


As I can see, for Cocoa wigetset Listviews are implemented through the TCellCocoaTableListView objcclass which seems simply not supporting custom drawing.


Is there any workaround? Or am I missing something?
Should I implement a list viewer control via some scrollable control which allows custom drawing? Is there something suitable?

Dmitry24

  • New Member
  • *
  • Posts: 22
Re: TCustomListView: ownerdraw (custom drawing) seems to be not implemented
« Reply #1 on: September 10, 2019, 04:54:01 pm »
Fortunatelly I found the callback method

IListViewCallBack.DrawRow(rowidx: Integer; ctx: TCocoaContext; const r: TRect; state: TOwnerDrawState);

which is called inside

procedure TCocoaTableListView.drawRow_clipRect(row: NSInteger; clipRect: NSRect)

So this required only some minor changes to Cocoa code to resolve my problem and enable custom drawing support. I can post some more details if somebody needs.

PhilC

  • New Member
  • *
  • Posts: 10
This still seems to be broken on Carbon at least.

Anyone know of the fix for Carbon to get this working?

Thanks

Phil

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
are you looking for TListView custom draw of cells?

PhilC

  • New Member
  • *
  • Posts: 10
Yes - currently I can't get TListView to call the OnCustomDrawXXX events :-(

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2770
    • havefunsoft.com
i might be able to help with that.
but you need to wait a day.

do you've any small test project ready? (it's not critical to have it, but it's a great timesaver)

PhilC

  • New Member
  • *
  • Posts: 10
No problems; I am not getting anywhere here, so a day or so will be faster than me sorting it :-)

Thanks

Manlio

  • Full Member
  • ***
  • Posts: 162
  • Pascal dev
i might be able to help with that.
but you need to wait a day.

Is there any progress on OwnerDraw for TListView?

And if that's not available, what would you kindly suggest as a replacement? (I'm using the TListView component for a dictionary with over 100,000 items. It works fine on Windows with OwnerData and OwnerDraw, but on the mac, without ownerdraw, just the creating of 100,000 items is extremely slow.)

Thanks
manlio mazzon gmail

wp

  • Hero Member
  • *****
  • Posts: 11855
You could try VirtualTreeView instead. In spite of its name, it is a mixture of TreeView and Listview. AFAIK it should be working in macOS because the Online Package Manager of Lazarus uses it. It is usually said that the learning curve of this component is quite steep, but since you seem to use TListview in virtual mode you have the steepest part of the ascent behind you.

Manlio

  • Full Member
  • ***
  • Posts: 162
  • Pascal dev
You could try VirtualTreeView instead.

Thanks. I used to be quite familiar with TVirtualTreeView in Delphi, and I tried the Lazarus version, but I find it full of Delphi- and Windows-related code, Ole stuff, etc. that I would need to work around for Mac. I need only very basic functionality. A simple list where I can draw the items, nothing more. Any other suggestions, some simpler components than VirtualTreeView?
manlio mazzon gmail

wp

  • Hero Member
  • *****
  • Posts: 11855
Another alternative would be TStringGrid or TDrawGrid. TDrawGrid is fully customdrawn because it does not own its data, but also the StringGrid cells can be custom-drawn as well.

Manlio

  • Full Member
  • ***
  • Posts: 162
  • Pascal dev
Another alternative would be TStringGrid or TDrawGrid. TDrawGrid is fully customdrawn [..]

Yes! TDrawGrid seems to be exactly what I needed. Thanks!
manlio mazzon gmail

 

TinyPortal © 2005-2018