Scrolling In Windowsexample - Casio ClassPad 300 Programming Manual

Sdk programming guide
Hide thumbs Also See for ClassPad 300:
Table of Contents

Advertisement

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 function. 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.

Scrolling in WindowsExample

The WindowsExample add-in is a good example of using the automatic scrolling
provided with PEG. We know that once PanWindow is resized or moved, it will need to
scroll within ExampleWindow. To support scrolling we need to make sure that the
following are all true:
• ExampleWindow is a scrollable window
• ExampleWindow is the parent of the window we want to scroll (PanWindow)
• ExampleWindow sets the correct scrolling mode
These three tasks are easily accomplished, most without any thought about scrolling.
ExampleWindow is derived from a CPModuleWindow, which is a scrollable window.
When we add PanWindow to ExampleWindow, ExampleWindow becomes
PanWindow's parent. Finally, we need to set ExampleWindow's scroll mode to be
WSM_AUTOSCROLL in its constructor:
41

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents