Bounding Rectangles In Onpointermove(); Scrollbars; How Scrolling Works - Casio ClassPad 300 Programming Manual

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

Advertisement

rectangle is passed to Resize() to set PanWindow's mReal to the new rectangle. Make
sure you do not set mReal and mClient explicitly. You can end up in an invalid state
where mClient is larger than mReal. By using the function Resize() it will make sure that
if mClient grows that mReal will also grow if necessary.

Bounding Rectangles in OnPointerMove()

In OnPointerMove(), PanWindow's mReal is being moved by the amount that the pen
has been dragged. The ideas used here are very similar to what we did in AddText().
Again we will pass Resize() a rectangle representing where PanWindow's new mReal is
located. However, this time the window will not change size, just location. Here is the
code that accomplishes this:
BeginDraw();
PegRect rect;
// find the difference in x and y from this point p, to the lastPoint
diffx += p.x - m_lastPoint.x;
diffy += p.y - m_lastPoint.y;
// Set rect to mReal and then shift it by the difference in x and y
rect = mReal;
rect.Shift(diffx,diffy);
// Resize invalidates the old rect and new one for us
// It also shifts all children in the window (so we don't
// have to worry about repositioning the PegPrompts)
Resize(rect);
// Calling Resize with the same size is used as a "trick" to
// force the parent to check for and add or remove scrollbars
Parent()->Resize(Parent()->mReal);
Parent()->Draw();
EndDraw();
First we find how much the pen has moved in both the x and y direction by subtracting
the current point from the previous point. We then take a rectangle equal to mReal and
shift it by the x and y deltas. Finally, we pass this rectangle to Resize(). This time
Resize() does not change the size of PanWindow, just its location. Since we are using
Resize() there is no reason to call invalidate.

Scrollbars

How Scrolling Works

PegWindow provides the capability of adding scroll bars, and using these scroll bars to
pan or move the client area of the window. Scroll bars are added by calling the
SetScrollMode() PegWindow member function.
40

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents