Adding To And Removing From The Tree - Casio ClassPad 300 Programming Manual

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

Advertisement

PegPresentationManager. Next() would return PegWindow2. Since all lists are
terminated with a NULL, Previous() would return NULL. So, if we wanted traverse all
of the children of an object, we could use the following code:
PegThing *pTest = Parent()->First(); // first child of my parent
int iSiblings = 0;
// Since all lists are NULL terminated,
// we can loop on while ptest!=NULL
while(pTest)
{
if (pTest != this)
{
iSiblings++;
}
pTest = pTest->Next();
}

Adding to and Removing from the Tree

PEG provides two functions to add PegThings to the presentation tree:
void PegThing::Add(PegThing *Who, BOOL bDraw = TRUE);
void PegThing::AddToEnd(PegThing *Who, BOOL bDraw = TRUE);
Add() always adds the child to the beginning of the linked list of children. If you would
like to add to the end, use AddToEnd().
Let's look at some example code and see what the tree it creates will look like:
PegRect Rect(10, 10, 40, 40);
PegWindow *child_window = new PegWindow(Rect);
PegWindow *parent_window = new PegWindow(Rect + 50);
PegPrompt *prompt1 = new PegPrompt(0, 0, "Prompt1");
PegPrompt *prompt2 = new PegPrompt(0,30, ""Prompt2");
prent_window->Add(child_window);
child_window->Add(prompt1);
child_window->AddToEnd(prompt2);
parent_window
child_window
prompt1
There are also two functions to remove an object from the tree:
prompt2
10

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents