Window Sizing

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
bandali99
Earned a small fee
Earned a small fee
Posts: 13
Joined: Fri Jul 05, 2019 3:58 pm

Window Sizing

Post by bandali99 » Fri Jul 12, 2019 5:14 pm

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
Attachments
update.PNG
update.PNG (5.59 KiB) Viewed 100 times

User avatar
doublemax
Moderator
Moderator
Posts: 13736
Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2

Re: Window Sizing

Post by doublemax » Fri Jul 12, 2019 6:39 pm

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)
Use the source, Luke!

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3320
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Window Sizing

Post by ONEEYEMAN » 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?

Kvaz1r
Earned some good credits
Earned some good credits
Posts: 109
Joined: Tue Jun 07, 2016 1:07 pm

Re: Window Sizing

Post by Kvaz1r » Fri Jul 12, 2019 6:42 pm

You should to handle wxSizeEvent.

bandali99
Earned a small fee
Earned a small fee
Posts: 13
Joined: Fri Jul 05, 2019 3:58 pm

Re: Window Sizing

Post by bandali99 » Fri Jul 12, 2019 7:16 pm

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

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3320
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Window Sizing

Post by ONEEYEMAN » Fri Jul 12, 2019 7:17 pm

Hi,
Are you asking about slider or a thumbnail?

Thank you.

bandali99
Earned a small fee
Earned a small fee
Posts: 13
Joined: Fri Jul 05, 2019 3:58 pm

Re: Window Sizing

Post by bandali99 » Fri Jul 12, 2019 10:44 pm

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
Last edited by bandali99 on Fri Jul 12, 2019 10:48 pm, edited 1 time in total.

bandali99
Earned a small fee
Earned a small fee
Posts: 13
Joined: Fri Jul 05, 2019 3:58 pm

Re: Window Sizing

Post by bandali99 » Fri Jul 12, 2019 10:45 pm

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

ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 3320
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: Window Sizing

Post by ONEEYEMAN » Fri Jul 12, 2019 10:54 pm

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.

Post Reply