Page 1 of 1

rotate a wxPanel

Posted: Tue Jan 28, 2020 10:52 am
by mael15
With the help of this wonderful forum I managed to draw rotated stuff on a wxGCDC, which is wonderful.
Now I have custom wxPanel "buttons" to select parts of an image, in this case the arrow buttons can be clicked to select a row/column of circles:
rotatePanel.jpg
rotatePanel.jpg (36.56 KiB) Viewed 709 times
The image can be rotated, as seen here, now how can I rotate the wxPanel buttons accordingly? I have a rotation center point from the image and I know how many degrees in which direction. I can calculate the right position with basic (co)sinus, but can I rotate the wxPanel itself?

Re: rotate a wxPanel

Posted: Tue Jan 28, 2020 11:26 am
by PB
I believe a wxPanel nor any other child window cannot be rotated, at least on MSW. AFAIK, only top level windows can have a shape where the window sides are not parallel with the screen sides but they still cannot be rotated.

I do not think I have ever seen a rotated window in my life. Aren't things like this usually done with custom drawing (including e.g. WPF controls with transforms) instead of using native windows?

Re: rotate a wxPanel

Posted: Tue Jan 28, 2020 11:32 am
by mael15
A custom drawing would be possible of course, but it would be quite an effort to incorporate button feeling with mouseover and cursor change to show the user that a certain area is clickable.

Re: rotate a wxPanel

Posted: Tue Jan 28, 2020 11:42 am
by PB
I understand that no one wants to re-invent a wxButton. But assuming I was not wrong, what is the alternative?

Re: rotate a wxPanel

Posted: Tue Jan 28, 2020 11:54 am
by mael15
PB wrote:
Tue Jan 28, 2020 11:42 am
I understand that no one wants to re-invent a wxButton. But assuming I was not wrong, what is the alternative?
Yeah, I guess this might be the only way. Bummer.

Re: rotate a wxPanel

Posted: Tue Jan 28, 2020 3:47 pm
by ONEEYEMAN
Hi,
You can also try using OpenGL.

Thank you.

Re: rotate a wxPanel

Posted: Wed Jan 29, 2020 7:48 am
by mael15
thank you for your tip!
while starting to implement a mouse sensitive bitmap with all the button images on it, I realized there is a performance advantage compared to having a lot of single buttons. It could happen in my case that I need to create and display >100 and that takes a while with wxPanel based controls. So I am happy with this new approach.

Re: rotate a wxPanel

Posted: Wed Jan 29, 2020 7:52 am
by mael15
PB wrote:
Tue Jan 28, 2020 11:26 am
Aren't things like this usually done with custom drawing (including e.g. WPF controls with transforms) instead of using native windows?
I did not read this properly the first time. What do you mean by "wpf controls"? My approach would be to calculate if the mouse is over a painted button area on the bitmap?

Re: rotate a wxPanel

Posted: Wed Jan 29, 2020 10:02 am
by PB
WPF is Microsoft's (not only) GUI library for Windows, available from .NET. It allows applying various transformations incl. rotation to the controls but all the controls are custom-drawn by the library, it does not use the native Win32 controls. I just used WPF as a rare GUI example where the controls can be rotated, but they are not the native Win32 controls wxWidgets uses.

Re: rotate a wxPanel

Posted: Wed Jan 29, 2020 3:46 pm
by mael15
PB wrote:
Wed Jan 29, 2020 10:02 am
WPF is Microsoft's (not only) GUI library for Windows, available from .NET. It allows applying various transformations incl. rotation to the controls but all the controls are custom-drawn by the library, it does not use the native Win32 controls. I just used WPF as a rare GUI example where the controls can be rotated, but they are not the native Win32 controls wxWidgets uses.
okay, good to know, thanx! i do not use .net though. :)