Recent

Author Topic: Virtual scrollcontrol that works on OSX (or all)  (Read 7179 times)

wotanica

  • Guest
Virtual scrollcontrol that works on OSX (or all)
« on: September 18, 2010, 09:43:53 pm »
In Delphi i have a generic base class that enables scrollbars on a control, but where no actual scrolling of pixels takes place - but i can repaint the clientarea as i wish. Im unsure if this class can be ported to lazarus because it used windows messages to obtain scrollbar info, and also the winapi to set the position/max values of the scrollbar range (I realize lazarus has some winapi emulation, but how deept it goes i have no idea).

Does lazarus have an equi. of this? It will not contain any components so TScrollBox cannot be used (and would be overkill).
On Delphi the scrolling win control uses to much messages and private procedures to be suitable.

Any help would do. The closest thing to what i need is the TrvScroll from the lazarus port of RichView, but i found a lot of message stuff there to, so i was unsure if it is truly platform independent. I just want to be able to show/hide the scrollbars, be able to set their ranges and be notified when they are moved to new positions.
« Last Edit: September 18, 2010, 09:45:52 pm by wotanica »

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Virtual scrollcontrol that works on OSX (or all)
« Reply #1 on: September 19, 2010, 06:25:27 am »
The very idea that any control can have scrollbars attached to it by sending some messages to the operating system is Windows-specific. Porting this will just end in a hack.

It is much simpler to simply add TScrollBar components inside your control. Something like this:

VerticalScrollBar := TScrollBar.Create(MyControl);
VerticalScrollBar.Parent := MyControl;
// also set the style, I don't remember which property
VerticalScrollBar.Align := alRight;

And similar for the horizontal scrollbar.

Then you can handle the TScrollBar events to execute the desired behavior.

You can also find TScrollBar in the Standard Palette of the Components Palette in Lazarus.

wotanica

  • Guest
Re: Virtual scrollcontrol that works on OSX (or all)
« Reply #2 on: September 19, 2010, 02:41:40 pm »
I tried that in Delphi, but it caused so much flicker and redraw overhead that it became useless. I did notice however that the Lazarus TScrollingWin Control implements winapi emulation of size messages assoc. with scrollbars.
I will try to override the scrollBy() method and the autocalcrange method to see if it will do the trick.

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: Virtual scrollcontrol that works on OSX (or all)
« Reply #3 on: September 20, 2010, 06:46:36 am »
If you use the technique explained here to build a control which draws itself:

http://wiki.lazarus.freepascal.org/Developing_with_Graphics#Create_a_custom_control_which_draws_itself

Then I am pretty sure that it won't flicker, regardless of any other controls placed on top of it. I've never tested this in Delphi. It does, however, work fine with all Lazarus platforms.

Modifying TScrollingWinControl might also work, although I find it a less robust solution.

wotanica

  • Guest
Re: Virtual scrollcontrol that works on OSX (or all)
« Reply #4 on: September 20, 2010, 05:16:40 pm »
I figured it out.
The lazarus implementation of TScrollingWinControl is actually far better than Delphi! I'll post the class later if someone wants it.
« Last Edit: September 20, 2010, 09:01:30 pm by wotanica »

wotanica

  • Guest
Re: Virtual scrollcontrol that works on OSX (or all)
« Reply #5 on: September 23, 2010, 02:21:24 am »
Modifying TScrollingWinControl might also work, although I find it a less robust solution.

hmm... beginning to see what you mean.
It worked fine on the mac, but i tested it on windows - and the implementation works somewhat different there. On the mac widgetset the ScrollBy() call is not issued (see http://delphimax.wordpress.com/2010/09/20/platform-independent-image-component-for-lazarus/) after i overrride some calls -- but on windows it is.

I had to translate the coordinates for it to work identically on both windows & mac (basically add scroll:left/top pos to the clientrect).

It works now, but not exactly how i imagined it to be. It is also quite slow on the mac, but very fast on windows.

 

TinyPortal © 2005-2018