Changing A Pegthing's Size Or Location - Casio ClassPad 300 Programming Manual

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

Advertisement

PegThing* PegThing::Remove(PegThing *Who, BOOL bDraw = TRUE);
void Destroy(PegThing *Who);
The PegThing member function Remove() is used to detach an object from the object's
parent. This removes the object from the tree, but does not remove the object from
memory. The PegThing member function Destroy() is similar to Remove(), although
Destroy() both removes the object from the tree and deletes the object from memory.
As long as items belong to the PegPresentationManager, all memory will be freed
automatically. However, once you use Remove() to remove an object from the tree you
are in charge of deleting its memory.

Changing a PegThing's Size or Location

PegThing has two member functions that deal with resizing or relocating itself. These
functions are:
virtual void Resize(PegRect Rect);
virtual void Center(PegThing *Who);
Any PEG object can resize itself or any other object at any time by calling the Resize()
function. The new screen coordinates for the objects are passed in the parameter Rect. If
you maintain or find a pointer to another object, you can also resize that object by calling
the same function. The following example illustrates this concept:
PegRect Rect(10, 10, 40, 40);
PegButton *MyButton = new PegTextButton(Rect, 0, "Hello");
.
. // at any time, to resize MyButton:
.
Rect.Set(20, 20, 60, 60);
MyButton->Resize(Rect);
If an object is visible when it is resized, it will automatically perform the necessary
invalidation and drawing. It is perfectly acceptable to resize an object that is not visible,
in fact in many cases this is the best time to do it. Note that passing a rectangle of the
same size as your PegThing, but at different location will cause the Resize() function to
move your PegThing's without changing its size.
Center() will adjust the screen coordinates of Who such that Who is horizontally and
vertically centered over the client area of this. Who does not necessarily have to be a
child of this, although that is the most common case. The following example
demonstrates centering an object on the screen:
PegRect Rect;
Rect.Set(0, 0, 100, 100); // create 100x100 pixel window
PegWindow *MyWin = new PegWindow(Rect);
Presentation()->Center(MyWin); // center window on the screen
Presentation()->Add(MyWin); // make the window visible
11

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents