Home |
Obtaining a Pointer to PegPresentationManager Determining the Position of an Object Overriding the Message() Method Scrolling |
ScrollingPegWindow provides the capability of adding scroll bars and using those scroll bars to pan or move the client area of the window. Scroll bars are added by calling the SetScrollMode() PegWindow member function. The scroll bars added to the window make use of two virtual PegWindow functions: GetHScrollInfo and GetVScrollInfo. When a scroll bar needs to update itself, it calls these parent window member functions to learn the scroll bar limit, current setting, and percentage visible data. GetHScrollInfo() and GetVScrollInfo() receive a pointer to a PegScrollInfo structure. It is the job of these functions to fill in the PegScrollInfo wMin, wMax, wCurrent, wStep, and wVisible values so that the scroll bar is correctly positioned. The PegWindow class provides default implementations of GetHScrollInfo and GetVScrollInfo. These implementations examine all client-area children of the window to determine the outer limits that the scroll bars should allow scrolling to. This default implementation also uses the window client area width and height as the scroll bar 'visible' value. The default implementation works well in most cases, and makes it very easy to create scrolling client areas. All you need to do is add a child window to a scrolling parent that is much larger than the parent client area. The default implementation will adjust the scroll bars such that the entire child window can be viewed by moving the horizontal and/or vertical scroll bars. In some cases the default operation does not provide the required functionality. In these cases you can override the GetHScrollInfo and GetVScrollInfo functions to return custom scrolling information. For example, suppose you want to create a continuous-time plot of data values, and use a horizontal scroll bar to move back and forth in the time period displayed. In this case you would create a derived PegWindow class in order to draw the chart data in the window client area. You would also provide an overridden version of the GetHScrollInfo function to make the horizontal scroll bar reflect the accumulated time values. In this case, the ScrollInfo minimum value might be the starting time of data recording, the maximum value would be the current time, and the visible amount would be the time period visible in the window client area.
|