Recent

Author Topic: DefaultItemHeight not accessible for TListView  (Read 4177 times)

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
DefaultItemHeight not accessible for TListView
« on: December 22, 2013, 02:06:39 pm »
DefaultItemHeight is defined as protected in TCustomListView and therefore not accessible for TListView. I need to figure out row height to show an edit control with proper size and position which I want to use to restrict editing for second column only. But I guess there are some other use cases too.
If there is no reason to hide this property I'd write a bug report.
Lazarus 1.7 (SVN) FPC 3.0.0

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: DefaultItemHeight not accessible for TListView
« Reply #1 on: December 22, 2013, 02:18:54 pm »
defaultItemHeight is used during creation to set the item height. This value is usually overiden by the underline widgetset and has no meaning in the listview as far as I can see that is because the listview is simple a wrapper (and bad one) around the underline widgetset.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: DefaultItemHeight not accessible for TListView
« Reply #2 on: December 22, 2013, 02:26:51 pm »
Sounds as you disagree with the idea to make the row height public, right?
Lazarus 1.7 (SVN) FPC 3.0.0

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: DefaultItemHeight not accessible for TListView
« Reply #3 on: December 22, 2013, 02:31:14 pm »
no not really I have no objection to it, just making sure that you know that has no weight on the final item height value that the component uses to draw an item.
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: DefaultItemHeight not accessible for TListView
« Reply #4 on: December 22, 2013, 02:37:27 pm »
Ah, you mean there is no way to determine the right value. And that's a good reason to hide it.
Lazarus 1.7 (SVN) FPC 3.0.0

howardpc

  • Hero Member
  • *****
  • Posts: 4144
Re: DefaultItemHeight not accessible for TListView
« Reply #5 on: December 22, 2013, 02:48:50 pm »
DefaultItemHeight is not much use to you: at runtime its value is always 0.
However, TListview has a public Canvas property so you can get dimensions of Captions etc. using Canvas.TextHeight etc.
Also each TListItem has a public Item.DisplayRect() function so you can know precisely where to position your editor.
The protected methods and properties are not needed in this case.
« Last Edit: December 22, 2013, 02:50:45 pm by howardpc »

taazz

  • Hero Member
  • *****
  • Posts: 5368
Re: DefaultItemHeight not accessible for TListView
« Reply #6 on: December 22, 2013, 02:51:52 pm »
No I think there is a way to determine the correct value something along the lines of font.height + 4 when the list is in list or grid mode if it is on icon or small icon mode then you have to add the icon height + the gap + the number of lines the caption is taking depending on the state (selected or not)...... well you get the point, the final item height can be calculated correctly it is just that the DefaultItemHeight plays no role on that value or at least I haven't find the code that it actually uses it so far.
« Last Edit: December 22, 2013, 02:54:52 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

 

TinyPortal © 2005-2018