Invalidating And Drawing Outside Of The Draw() Method - Casio ClassPad 300 Programming Manual

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

Advertisement

to appear 'on-top' (which is usually the case), you should call the base-class draw
function before you do your own drawing. In some cases you may not want to invoke the
base-class Draw() function at all. This is perfectly OK, as long as you remember a few
rules:
1) Start your draw function with a call to BeginDraw().
2) After you have done your custom drawing, call DrawChildren() to insure child
objects get their chance to draw.
3) After everything is done, call EndDraw().
The calls to BeginDraw() and EndDraw() should actually be included regardless of
whether or not you call the base-class draw function. These calls inform the PegScreen
driver when a drawing sequence begins and ends. When you override the Draw()
function, and call the base-class draw function during your drawing routine, the
BeginDraw() calls become nested. This is expected by the PegScreen driver, which
keeps track of the nesting level and recognizes when the total drawing operation is
complete by tracking this BeginDraw()-EndDraw() nesting.
The Draw() method in ExampleWindow.cpp does not call its base-class Draw(), but
instead the previously stated three rules are followed properly.
void ExampleWindow::Draw()
{
BeginDraw();
DrawFrame();
DrawLines();
DrawChildren();
EndDraw();
}
First the function starts with BeginDraw(). Next, the custom drawing is done by
functions DrawFrame() and DrawLines(). After that the custom drawing is finished,
PanWindow is drawn by calling the DrawChildren() function. Finally, we finish the
Draw() method with a call to EndDraw().

Invalidating and Drawing outside of the Draw() Method

You can also write functions that draw on the screen outside of the Draw() function.
These functions must be members of a PegThing derived class, or at least have access to
a PegThing object, since all of the PegScreen drawing functions require as a parameter a
pointer to the PegThing object calling the drawing function. PegScreen requires this
pointer to insure that an object is not allowed to draw outside of the area it 'owns' on the
screen.
PegScreen only allows drawing to occur to areas of the screen that have been invalidated.
Areas of the screen are invalidated by calling the Invalidate() function. If all of your
drawing is done with an overridden Draw() function, you don't need to worry about
35

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents