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).
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
Skinnable scrollbars
-
- Experienced Solver
- Posts: 61
- Joined: Wed Aug 19, 2020 12:04 am
Re: Skinnable scrollbars
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.
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.
- papillon68
- Earned some good credits
- Posts: 118
- Joined: Tue Nov 06, 2007 11:19 pm
Re: Skinnable scrollbars
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
Designed with WxWidgets: https://www.facebook.com/clorofillaApp
- papillon68
- Earned some good credits
- Posts: 118
- Joined: Tue Nov 06, 2007 11:19 pm
Re: Skinnable scrollbars
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
Designed with WxWidgets: https://www.facebook.com/clorofillaApp
Re: Skinnable scrollbars
Hi papillon68, I'm really glad it can help and be useful. Many thanks for your feedbackpapillon68 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!
Re: Skinnable scrollbars
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'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
I happened to have a copy of the original archive on my HD.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!
- Attachments
-
- my_scroll_window_v2.zip
- (7.95 KiB) Downloaded 70 times
Use the source, Luke!
- papillon68
- Earned some good credits
- Posts: 118
- Joined: Tue Nov 06, 2007 11:19 pm
Re: Skinnable scrollbars
Thank you!
Windows 10, MS VC++ 2019 (vc142), WxWidgets 3.14
Designed with WxWidgets: https://www.facebook.com/clorofillaApp
Designed with WxWidgets: https://www.facebook.com/clorofillaApp
Re: Skinnable scrollbars
Oh that's great, thank you!!