Buttons scrolling without scrollbar Topic is solved

If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
Post Reply
Nelson Joseph
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sun Oct 26, 2008 5:15 am
Location: Chennai, India
Contact:

Buttons scrolling without scrollbar

Post by Nelson Joseph »

Hi All,

Is it possible to scroll a set of buttons inside the pannel without using scroll bar(similar to jQuery sliding effect)
Instead of scroll bar I will have left and right navigation buttons.

Thanks in advance
Regards,
Nelson Joseph
User avatar
doublemax
Moderator
Moderator
Posts: 19158
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Buttons scrolling without scrollbar

Post by doublemax »

I don't know exactly what you mean, but the answer is probably no. If you want to animate the position of any control, you need to do it yourself.
Use the source, Luke!
Mikey Boy
In need of some credit
In need of some credit
Posts: 7
Joined: Wed Jun 13, 2012 5:02 pm

Re: Buttons scrolling without scrollbar

Post by Mikey Boy »

If the buttons are drawn inside their own wxPanel, then it should be possible to scroll the contents of the panel left and right using the wxWindow::ScrollWindow method. You can call this method on receiving a button-press event from your navigation buttons.

Or am I missing something?
Nelson Joseph
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sun Oct 26, 2008 5:15 am
Location: Chennai, India
Contact:

Re: Buttons scrolling without scrollbar

Post by Nelson Joseph »

@doublemax

Thanks for your reply.
Please find attached picture. Is there any built-in class?
I tried with wxSHOW_EFFECT_SLIDE_TO_RIGHT But I need the scrolling effect. Totally I have 10 buttons.

Thanks
Attachments
sample.jpg
sample.jpg (15.06 KiB) Viewed 3790 times
Regards,
Nelson Joseph
Mikey Boy
In need of some credit
In need of some credit
Posts: 7
Joined: Wed Jun 13, 2012 5:02 pm

Re: Buttons scrolling without scrollbar

Post by Mikey Boy »

Maybe I'm thinking about this too simplistically, but as far as I can see, it should be possible to do this as follows:

1) create a wxPanel which contains just the buttons 1 - 10 - we'll call this myButtonPanel
2) create a wxBoxSizer with a horizontal orientation - we'll call this myButtonSizer,
3) set myButtonSizer to be the top-level sizer for myButtonWindow

Code: Select all

myButtonWindow->SetSizer(myButtonSizer);
4) add the buttons to the sizer

Code: Select all

myButtonSizer->Add(buttonOne);
myButtonSizer->Add(buttonTwo);
// etc
3) call FitInside to ensure that the virtual window for myButtonPanel expands to be big enough to hold all the buttons:

Code: Select all

myButtonSizer->FitInside(myButtonWindow);
4) Create an event handler method in an appropriate class to handle the button-click events from your navigation buttons. In that event handler, call:

Code: Select all

myButtonWindow->ScrollWindow(20, 0);
Replace "20" with the number of pixels you want to scroll the buttons by.

I've been doing something similar myself (not using buttons to scroll controls, but using scrollbars from a different window) and it works for me.
Hope this helps!
Last edited by Mikey Boy on Tue Jun 19, 2012 4:30 pm, edited 1 time in total.
Nelson Joseph
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sun Oct 26, 2008 5:15 am
Location: Chennai, India
Contact:

Re: Buttons scrolling without scrollbar

Post by Nelson Joseph »

@Mikey:

Thank you Mikey. I have applied your suggestion. but still I am trying to get the effect something like wxSHOW_EFFECT_SLIDE_TO_RIGHT
Any suggestions?
Regards,
Nelson Joseph
Mikey Boy
In need of some credit
In need of some credit
Posts: 7
Joined: Wed Jun 13, 2012 5:02 pm

Re: Buttons scrolling without scrollbar

Post by Mikey Boy »

Nelson Joseph wrote:@Mikey:

Thank you Mikey. I have applied your suggestion. but still I am trying to get the effect something like wxSHOW_EFFECT_SLIDE_TO_RIGHT
Any suggestions?
I'm afraid I'm not familiar with the wxWindow effects, so I can't help you - sorry!
Nelson Joseph
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sun Oct 26, 2008 5:15 am
Location: Chennai, India
Contact:

Re: Buttons scrolling without scrollbar

Post by Nelson Joseph »

Mikey Boy wrote:
Nelson Joseph wrote:@Mikey:

Thank you Mikey. I have applied your suggestion. but still I am trying to get the effect something like wxSHOW_EFFECT_SLIDE_TO_RIGHT
Any suggestions?
I'm afraid I'm not familiar with the wxWindow effects, so I can't help you - sorry!
@Mikey:

Thank you for your help. Is there any way to move the buttons slowly (cool effects)
Thanks.
Regards,
Nelson Joseph
Mikey Boy
In need of some credit
In need of some credit
Posts: 7
Joined: Wed Jun 13, 2012 5:02 pm

Re: Buttons scrolling without scrollbar

Post by Mikey Boy »

Nelson Joseph wrote:Thank you for your help. Is there any way to move the buttons slowly (cool effects)
Thanks.
Ah, so you want it to slowly slide to its new scroll position, rather than jumping instantly?

The only way I can think of is a real brute force method, like looping 20 (say) times, and each time scrolling by 1 pixel, possibly adding some sort of delay after each scroll to achieve the desired speed. I don't know if there's any more sophisticated built-in way of doing it.
Nelson Joseph
Experienced Solver
Experienced Solver
Posts: 65
Joined: Sun Oct 26, 2008 5:15 am
Location: Chennai, India
Contact:

Re: Buttons scrolling without scrollbar

Post by Nelson Joseph »

Mikey Boy wrote: like looping 20 (say) times, and each time scrolling by 1 pixel, possibly adding some sort of delay after each scroll to achieve the desired speed.
Thanks MiKey. Problem solved. :D
Regards,
Nelson Joseph
Mikey Boy
In need of some credit
In need of some credit
Posts: 7
Joined: Wed Jun 13, 2012 5:02 pm

Re: Buttons scrolling without scrollbar

Post by Mikey Boy »

Nelson Joseph wrote:
Mikey Boy wrote: like looping 20 (say) times, and each time scrolling by 1 pixel, possibly adding some sort of delay after each scroll to achieve the desired speed.
Thanks MiKey. Problem solved. :D
Glad I could help :)
Post Reply