I don't know what use I will have for this new object that I added to my PtcGraph based GUI, but now I have it.
We've been babysitting our daughter's dog, Max, who is a labradoodle. He is much bigger than our two mini schnauzers, so my time on the computer has been cut back a bit so we can give him the exercise that he needs. I've been spending a lot of time in our backyard as a result and just running code in the back of my head. Initially I thought that to bring a window to the front I would have to check intersecting rectangles, figure out which was which and what was what and then I realized as I sat in my yard relaxing that it was nothing more than list management.
For this purpose I created a new non-modal frame for my GUI. The mouse events are just a pass through for the frame, if the left mouse is pressed and held on the title bar, then you can drag the frame around the screen. After that action the event handler just lets the flow go back to the application's main loop (a frame can have button controls too though and act on them if need be). Each frame has the ability to save the background before it is "painted" and "hide" itself by restoring the background.
Having that done, I made a new class of application object that has two arrays of frame pointers, a windowlist and a templist. I set the limit to 10 windows for demo. The application has a window counter, initially set at -1. Adding a frame to the application increases the window count and creates a new pointer to a frame object at the end of the window list. The last frame added to the list is the focused frame/window.
Left clicking on a frame that is not the focused frame will bring it to the top of the windowlist. The trick to this is to hide each frame in reverse order of creation, move all the frames in the windowlist to the templist, except for the new top frame, then make the new top frame the last in the windowlist (and set its focus to true). Then I just repaint the frames from the 1st to the last.
30 years ago on a 16 bit machine I never wouldn't have been able to get away with this, as it would have been too slow.
Here's the demo video:
https://www.youtube.com/watch?v=X3_CU1MjAhQ