Skinnable scrollbars

If you have a cool piece of software to share, but you are not hosting it officially yet, please dump it in here. If you have code snippets that are useful, please donate!
Post Reply
bertolino
Experienced Solver
Experienced Solver
Posts: 77
Joined: Wed Aug 14, 2013 8:07 am
Location: France
Contact:

Skinnable scrollbars

Post 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
AmadeusK525
Experienced Solver
Experienced Solver
Posts: 60
Joined: Wed Aug 19, 2020 12:04 am

Re: Skinnable scrollbars

Post 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.
User avatar
papillon68
Earned some good credits
Earned some good credits
Posts: 118
Joined: Tue Nov 06, 2007 11:19 pm

Re: Skinnable scrollbars

Post 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.
Windows 10, MS VC++ 2019 (vc142), WxWidgets 3.14
Designed with WxWidgets: https://www.facebook.com/clorofillaApp
User avatar
papillon68
Earned some good credits
Earned some good credits
Posts: 118
Joined: Tue Nov 06, 2007 11:19 pm

Re: Skinnable scrollbars

Post by papillon68 »

My bad, after accessing the window using GetPanel() it works really great. Thanks a lot for making this great addon!
Windows 10, MS VC++ 2019 (vc142), WxWidgets 3.14
Designed with WxWidgets: https://www.facebook.com/clorofillaApp
bertolino
Experienced Solver
Experienced Solver
Posts: 77
Joined: Wed Aug 14, 2013 8:07 am
Location: France
Contact:

Re: Skinnable scrollbars

Post 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
giuse
Earned a small fee
Earned a small fee
Posts: 16
Joined: Wed Jul 29, 2020 9:11 pm

Re: Skinnable scrollbars

Post 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!
User avatar
doublemax
Moderator
Moderator
Posts: 19102
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Skinnable scrollbars

Post 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.
Attachments
my_scroll_window_v2.zip
(7.95 KiB) Downloaded 69 times
Use the source, Luke!
User avatar
papillon68
Earned some good credits
Earned some good credits
Posts: 118
Joined: Tue Nov 06, 2007 11:19 pm

Re: Skinnable scrollbars

Post by papillon68 »

Thank you!
Windows 10, MS VC++ 2019 (vc142), WxWidgets 3.14
Designed with WxWidgets: https://www.facebook.com/clorofillaApp
giuse
Earned a small fee
Earned a small fee
Posts: 16
Joined: Wed Jul 29, 2020 9:11 pm

Re: Skinnable scrollbars

Post by giuse »

Oh that's great, thank you!!
Post Reply