wGui - Coordinate Systems

wGui uses a coordinate system that can be a little confusing without some explanation.

All the coordinate systems within wGui assume X increases as you move from left to right, and Y increases as you move from top to bottom on the screen. Negative coordinates are allowed.

Every window in wGui has two coordinate systems associated with it. The first is called the "Window Coordinates", and is relative to the top left corner of the window (the top left corner of the window is always (0, 0)). This comes in handy when drawing the window, since the control doesn't need to calculate where it is on the screen before it can draw to the correct place. It only draws in reference to itself, and lets the rest of the system worry about where it will be placed. "Window Coordinates" are used for logic surrounding a window.

The other major coordinate system is "Client Coordinates". These are relative to the top left corner of the window's client rect. The client rect itself is always in window coordinates. "Client Coordinates" are used when defining the position of any child windows of the window. All child window's Window Rects are defined using these coordinates. The purpose of this is most easily seen when considering a CView window. Since all child windows (which is what any controls in the view are), are defined in terms of the view's client coordinate system, we can move them all just by redefining the CView's client rect. This is done when a menu is attached to the view to make room for it.

wGui also defines a special "View Coordinates" system. Because of the limitations of SDL, wGui cannot draw outside of it's view, so there isn't anything in screen coordinates. "View Coordinates" is as close as we can get. This is simply the "Window Coordinates" for the view, but it also represents the coordinate system that directly relates to the pixels you see on the screen. In the end, everything is essentially translated to "View Coordinates".

The CWindow class defines several methods to help translating between View and Client Coordinates, or View and Window Coordinates. A method for translating directly between Window and Client coordinates was not added, as it only requires the addition or subtraction of the Client Rect's TopLeft() point.