Page 1 of 1

Skinnable scrollbars

Posted: Sat Apr 17, 2021 8:13 pm
by bertolino
Hello everyone,

I've noticed that regularly, wxWidgets users are looking for a way to change their scrollbar style.
Last year I started something about this, then the time passed, I forgot this piece of code until recently
where I came across one of these articles. So I decided to share what I did in the case it could help (see example below).

Image

It's not a miracle solution, it's not production-ready code, I even do not claim it's a good solution.
But it may help people as a base to do something better.

It is based on the wxScrolled<wxWindow>::SetTargetWindow that is able to redirect scrolling to a given window.

The code is reasonably commented so I guess it can be handled and modified without too much difficulties.
I have tested it under Windows only, using wxWidgets 3.1.

You will find a zip archive of it here http://www.gipsa-lab.grenoble-inp.fr/~p ... dow_v2.zip that includes:
- 1 file for the toy program
- 2 files (cpp and .h) for the scrolled window class
- 2 files (cpp and .h) for the scrollbar class

my_scrolled_window.h explains with a small graphic the way the panels are embedded in each other.

In the main file, a #define among 5 allows to see the scrolled window in different contexts :
- to scroll a panel
- to scroll a toolbar (in this case, horizontal or vertical scroll can be disabled)
- to scroll a dialog

One can tune:
- the scroll direction (horizontal, vertical or both)
- the thumb color, the margin color and the tip color (not sure it's the right terms)
- the size of these items

All the events are not managed but the thumbs work well with the mouse. it still needs some work....
I hope you will enjoy it.

By the way, thanks to the wxWidgets team for such a great tool and thank you to the forum team for their valuable support all year long.

Kind regard,

Pascal

Re: Skinnable scrollbars

Posted: Tue May 04, 2021 12:58 am
by AmadeusK525
This is a nice solution to it! A lot of people have wanted a way to customize the scrollbars, so I think this is a very good contribution :)
I've made a custom solution to this as well, but it works in a different way and it's restricted to wxRichTextCtrl. Interesting to see how different your method of implementation was compared to mine.

Re: Skinnable scrollbars

Posted: Fri Aug 27, 2021 12:43 pm
by papillon68
Hi Pascal, thanks for this precious widget implementation. It would work really great, but in my case as I use the scrollbar, the panel contents get deleted. Do you know how to fix that? Thanks.

Re: Skinnable scrollbars

Posted: Fri Aug 27, 2021 9:20 pm
by papillon68
My bad, after accessing the window using GetPanel() it works really great. Thanks a lot for making this great addon!

Re: Skinnable scrollbars

Posted: Sat Sep 18, 2021 1:54 pm
by bertolino
papillon68 wrote: Fri Aug 27, 2021 9:20 pm My bad, after accessing the window using GetPanel() it works really great. Thanks a lot for making this great addon!
Hi papillon68, I'm really glad it can help and be useful. Many thanks for your feedback

Re: Skinnable scrollbars

Posted: Sun Nov 05, 2023 3:53 pm
by giuse
Hello,

I'm here since I'm looking for a way to customize the color of the scrollbars. The solution proposed in this thread seems to be very promising, but unfortunately the link to access the code seems no longer valid, is it possible for you to embed the code directly in the post or provide the link again?

Thank you very much!

Re: Skinnable scrollbars

Posted: Sun Nov 05, 2023 4:04 pm
by doublemax
giuse wrote: Sun Nov 05, 2023 3:53 pm Hello,

I'm here since I'm looking for a way to customize the color of the scrollbars. The solution proposed in this thread seems to be very promising, but unfortunately the link to access the code seems no longer valid, is it possible for you to embed the code directly in the post or provide the link again?

Thank you very much!
I happened to have a copy of the original archive on my HD.

Re: Skinnable scrollbars

Posted: Sun Nov 05, 2023 5:00 pm
by papillon68
Thank you!

Re: Skinnable scrollbars

Posted: Sun Nov 05, 2023 5:09 pm
by giuse
Oh that's great, thank you!!