#AM TCL Lists
Burt,
> That is, the instance variable is not global, so what do I refer to when
> I want to say "x->addrow()"? What is 'x' and where do I get it from if
> it is not a 'gX' global?
There are two "x"s. One is the list pane (usually a subclass of CArrayPane),
the other is its data. We'll call the pane the AddressesList, and we'll call
the data the AddressesArray. AppMaker generates an instance variable for the
pane. It's in your window class, so within that class you can call (e.g.)
AddressesList->AddRow(…). The data for your list you'll normally define in
the Data class. In the initialization method for your list pane subclass you'll
call AddressesList->SetArray(AddressesArray).
As a matter of good programming practice, you normally don't refer directly to
another class's instance variables. You instead call a member function (aka
method) in that class that accesses its instance variables (aka data members).
So in your data class, you'll have functions for manipulating (adding,
removing, etc.) the AddressesArray. The TCL uses the Collaborator mechanism to
keep the array and the pane in sync. As you add elements to AddressesArray, the
TCL automatically adds rows to AddressesList by
BroadcastChange/ProviderChanged.
Most of your classes will have an instance variable, itsData, that is a pointer
to your data class object. If necessary, you'll pass itsData to other classes
so that they can store a copy in their own instance variables. You'll call such
things as itsData->AddAddress(anAddress). The functions in the data class will
access the AddressesArray to add, remove, etc. entries.
Spec