rotate a wxPanel 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
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

rotate a wxPanel

Post 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 1274 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?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: rotate a wxPanel

Post 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?
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: rotate a wxPanel

Post 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.
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: rotate a wxPanel

Post by PB »

I understand that no one wants to re-invent a wxButton. But assuming I was not wrong, what is the alternative?
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: rotate a wxPanel

Post 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.
ONEEYEMAN
Part Of The Furniture
Part Of The Furniture
Posts: 7458
Joined: Sat Apr 16, 2005 7:22 am
Location: USA, Ukraine

Re: rotate a wxPanel

Post by ONEEYEMAN »

Hi,
You can also try using OpenGL.

Thank you.
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: rotate a wxPanel

Post 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.
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: rotate a wxPanel

Post 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?
PB
Part Of The Furniture
Part Of The Furniture
Posts: 4193
Joined: Sun Jan 03, 2010 5:45 pm

Re: rotate a wxPanel

Post 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.
mael15
Ultimate wxWidgets Guru
Ultimate wxWidgets Guru
Posts: 539
Joined: Fri May 22, 2009 8:52 am
Location: Bremen, Germany

Re: rotate a wxPanel

Post 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. :)
Post Reply