Page 1 of 1

Window Sizing

Posted: Fri Jul 12, 2019 5:14 pm
by bandali99
Hi Im creating a double slider using wxwidgets

Im almost done but the main issue im having now is that the slider is not resizing with the window. My idea was to use a scaling function but that does not work. The slider is drawn using dc paint and the code is in https://github.com/fahadbandali/updatedmediaplayer and the files I have been using are myDoubleSlider and play

sorry about the code being messy

I have attached a photo of my custom widget, basically what I need to do is that the bar and the max slider needs to reach the end of the window

Re: Window Sizing

Posted: Fri Jul 12, 2019 6:39 pm
by doublemax
You should stop using absolute positions and sizer and start using sizers instead, both for the frame and inside the "myDoubleSlider" as well.
https://docs.wxwidgets.org/trunk/overview_sizer.html
http://neume.sourceforge.net/sizerdemo/

In the slider control, you should have a dedicated wxPanel for the area where you draw the custom slider. Then but this panel and the wxSpinCtrl next to each other into a horizontal boxsizer.

In the drawing code you should use the actual size of the drawing panel and scale everything accordingly. (At least for the width, you could use a fixed height)

Re: Window Sizing

Posted: Fri Jul 12, 2019 6:40 pm
by ONEEYEMAN
Hi,
It looks like from you description that you paint it yourself and you are using the hardocded values.
And you also didn't derive you control from the wxWindow.

Am I correct?

Re: Window Sizing

Posted: Fri Jul 12, 2019 6:42 pm
by Kvaz1r
You should to handle wxSizeEvent.

Re: Window Sizing

Posted: Fri Jul 12, 2019 7:16 pm
by bandali99
im using .GetLogicalPosition(dc) in order to get the value of a slider on a certain point on the bar, I dont think the slider will move if I were to make these changes

Re: Window Sizing

Posted: Fri Jul 12, 2019 7:17 pm
by ONEEYEMAN
Hi,
Are you asking about slider or a thumbnail?

Thank you.

Re: Window Sizing

Posted: Fri Jul 12, 2019 10:44 pm
by bandali99
ONEEYEMAN wrote:
Fri Jul 12, 2019 7:17 pm
Hi,
Are you asking about slider or a thumbnail?

Thank you.
by slider i mean the red slider at 1000

Re: Window Sizing

Posted: Fri Jul 12, 2019 10:45 pm
by bandali99
ONEEYEMAN wrote:
Fri Jul 12, 2019 6:40 pm
Hi,
It looks like from you description that you paint it yourself and you are using the hardocded values.
And you also didn't derive you control from the wxWindow.

Am I correct?
Yes they are hardcoded values and I did paint it myself

Re: Window Sizing

Posted: Fri Jul 12, 2019 10:54 pm
by ONEEYEMAN
Hi,
You should inherit from the wxControl (or even better from wxWindow) and use sizers to layout controls.
Or you could also try to re-use the generic implementation of the control.

wxWidgets is known to use native controls whenever possible, so if you want something that weird you should switch to something else.

Thank you.