Note that this is an excellent example of a situation where a Class
Interface will let you treat either the canvas, or the container it
is in, as the same kind of thing. This means: define a class
interface with your GetText and SetText operations, and assign the
class interface to both the container and canvas class. Now, you
can declare a variable to be of the type of the class interface,
and use it to access either.
That's a thought...
But how would that apply? The container control isn't really getting
any variables set - it is just passing the variables through to the
canvas, so I really don't want to treat them the same. Or do I?
I could see where for example, you had a list of items (array) that
you wanted to be able to populate either a listbox or popuplist with.
You define the class interface with governing functions to populate
the control depending on its type -> if control isA Listbox
then.... etc
I am a total newb as far a class interfaces go - I have rarely used
them, except in the above example.
- Jay
On Jun 3, 2006, at 5:11 AM, Guyren Howe wrote:
On Jun 2, 2006, at 2:09 PM, Charles Yeomans wrote:
On Jun 2, 2006, at 2:58 PM, Jay Wooten wrote:
Suppose you create a custom canvas:
That canvas has a Getter/Setter pair to retrieve/store a string
in a property. Assume the canvas control is called myCanvas.
Sub SetText( theText as string)
MyText = theText
End Sub
and
Sub GetText() as string
return MyText
End Sub
You call the methods externally as such
myCanvas.SetText("some text")
and
someText = myCanvas.GetText()
Now lets say you make the daring decision to put the canvas
control inside a Containercontrol, but you still need to be able
to set/get the string stored in the canvas externally to the
Container.
Is it most appropriate to create a Getter/Setter pair of methods
for the Container Control that passes on the values on to the
myCanvas control?
i.e.
Container control methods:
Sub SetText( theText as string )
myCanvas.SetText(theText)
End Sub
Sub GetText() as string
return myCanvas.GetText()
End Sub
Or is there a better way to do this?
I think that this is precisely what you should do. You'll
appreciate it if, for instance, you decide to rename the canvas.
Computed properties are great for this sort of thing.
Note that this is an excellent example of a situation where a Class
Interface will let you treat either the canvas, or the container it
is in, as the same kind of thing. This means: define a class
interface with your GetText and SetText operations, and assign the
class interface to both the container and canvas class. Now, you
can declare a variable to be of the type of the class interface,
and use it to access either.
Guyren G Howe
guyren-at-relevantlogic.com
http://relevantlogic.com
REALbasic, PHP, Python programming
PostgreSQL, MySQL database design and consulting
Technical writing and training
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>