Attributes and Behavior for Windows

What information does a WinMgr object maintain? Should it store the positions of the windows? No, because it's more appropriate for each window itself to know that. However, in keeping with the guideline that objects shouldn't know too much about their context, a window shouldn't know whether it lies above or below other windows. Instead, WinMgr should maintain the stacking order of the windows. Since the topmost window is always the active one, WinMgr always knows which window is active.

What can a WinMgr object do? It directs user-generated events to the active window, but it can't pass all of them to that window. For example, the user can click on an inactive window to make it active; such an event cannot be sent to the active window. WinMgr must respond to that event and restack the windows, so that a newly active window moves from its previous position in the stack to the top.

What information does a Win object maintain? It knows its size and position on the screen. It stores all the text that it must display, which, for a scrollable window, includes the text that is outside the window's bounds. The window knows where the displayed section is located relative to the entire text, so it can position the slider on the scroll bar.

What can a Win object do? It can display itself on the screen. It can respond to the keyboard by moving its cursor, and, if it's an editing window, by modifying its text. It can also respond to the mouse. It can position the cursor if the mouse is clicked on the text and scroll the text if the mouse is clicked on the scroll bar.