Recent

Author Topic: How to draw a ScrollBar on TCanvas?  (Read 3897 times)

Edson

  • Hero Member
  • *****
  • Posts: 1302
How to draw a ScrollBar on TCanvas?
« on: September 17, 2014, 10:18:25 pm »
In resume, I have some graphic objects that I draw using the TCanvas and I can correctly control the selection, resizing and movement.

Now I need to include a functional ScrolBar on these objects. 

I know I can draw all of it with graphic methods, and control the mouse events for to make it works. But I would like to know if there is a simpler way or if there is some graphic library that make it easy.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: How to draw a ScrollBar on TCanvas?
« Reply #1 on: September 17, 2014, 10:36:05 pm »
TScrollBar doesn't fit your needs?
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: How to draw a ScrollBar on TCanvas?
« Reply #2 on: September 17, 2014, 10:49:50 pm »
TScrollBar doesn't fit your needs?

My Objects are dinamically created and draw directly on the Canvas. They are not controls or containers for controls.

I know I can create a new TScrollBar for each or my objects and move and resize him when it needs. But I'm not sure if it is good mixing controls with drawing on Canvas.

Moreover, my objects accept Zoom in and Zoom Out, so I will probably need some scrollbar with accept zoom.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Blaazen

  • Hero Member
  • *****
  • Posts: 3237
  • POKE 54296,15
    • Eye-Candy Controls
Re: How to draw a ScrollBar on TCanvas?
« Reply #3 on: September 17, 2014, 11:05:22 pm »
Maybe it is possible via Themes. Use these details:
Code: [Select]
// 'ScrollBar' theme data
  TThemedScrollBar = (
    tsScrollBarDontCare,
    tsScrollBarRoot,
    tsArrowBtnUpNormal, tsArrowBtnUpHot, tsArrowBtnUpPressed, tsArrowBtnUpDisabled,  ...
If you have luck, you will paint whole scrollbar this way.

However, I still think you should rather use normal scrollbars. Rather than TScrollBar, use the built-in scroll bars, see this:
https://github.com/theo222/lazarus-thumbviewer/blob/master/scrollingcontrol.pas
Lazarus 2.3.0 (rev main-2_3-2863...) FPC 3.3.1 x86_64-linux-qt Chakra, Qt 4.8.7/5.13.2, Plasma 5.17.3
Lazarus 1.8.2 r57369 FPC 3.0.4 i386-win32-win32/win64 Wine 3.21

Try Eye-Candy Controls: https://sourceforge.net/projects/eccontrols/files/

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: How to draw a ScrollBar on TCanvas?
« Reply #4 on: September 17, 2014, 11:37:09 pm »
Thanks for the responses.

Maybe it is possible via Themes. Use these details:

Is there some example of using TThemedScrollBar ?. I can't find anything.

However, I still think you should rather use normal scrollbars.

I had a bad experience using Normal Controls with drawing on Canvas, with VB. I can remember this obstacles:

* They are slow for drawing. I need to refresh several times all the screen.
* They don't support zoom (FAIK).
* They are asociated with a control container not with any object.
* They draw always in front of the Canvas. It's not easy to draw over a control, hiding the control partially.

In fact I need buttons, checkbox and scrollbar for using on canvas. Probably I will  have to write a little widget library for my App.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Never

  • Sr. Member
  • ****
  • Posts: 409
  • OS:Win7 64bit / Lazarus 1.4
Re: How to draw a ScrollBar on TCanvas?
« Reply #5 on: September 18, 2014, 12:21:59 am »
Quote
Is there some example of using TThemedScrollBar ?. I can't find anything.

found this [http://sourceforge.net/p/jvcl/mailman/jvcl-checkins/?viewmonth=201209]
Νέπε Λάζαρε λάγγεψων οξωκά ο φίλοσ'ς αραεύσε

Edson

  • Hero Member
  • *****
  • Posts: 1302
Re: How to draw a ScrollBar on TCanvas?
« Reply #6 on: September 18, 2014, 04:03:05 am »
Thanks I will check.
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

 

TinyPortal © 2005-2018