Aaron,
g is a Graphics object; usually it's the one passed into the Paint
event for a Canvas or Window object.
Correct, Paint is an event that is called by the framework when it's
time to repaint an item. It gets passed a Graphics handle that all
the drawing should happen on. So you can take that Graphics object
and use it when calling one of the Draw methods.
OK. Let me see if I'm following this. If "g is a Graphics object,
usually ... the one passed into the _Paint_ event for a Canvas or Window
object" and "_Paint_ is an event that is called by the framework when
it's time to repaint an item" and in that situation _Paint_ "gets passed
a Graphics handle that all the drawing should happen on" and in those
circumstances "you can take that Graphics object and use it when calling
one of the _Draw_ methods," does that mean that you can only use one of
the _Draw_ methods when a _Paint_ event for a Canvas or Window object
has somehow been triggered (since that is that is "usually" how it is done)?
If so, how to you trigger the Paint event (if that's required in order
to be able to use g in one of the Draw methods)? If not - i.e., if the
Paint event is only the "usual" way to get a meaningful value for g as a
passed parameter and not the "only" way - then how else can we
(figuratively speaking) get a "handle" on g?
Or, asking it a somewhat different way, does the Draw method itself
somehow have to be triggered by (or inside) a Paint event?
Or, to put it yet another way, how does one accomplish the simple act of
drawing a particular card face up at a particular location?
From your response, apparently I'm saying the "Correct" words, but I
don't have any confidence that I really have hold on what's happening,
and I still don't understand it well enough to accomplish what should be
a simple task, i.e., making a card appear where I want it to appear when
I want it to appear.
Since, as you said earlier, classes are "so powerful and really are the
crux of what object-oriented programming is all about," let me venture
for a moment to try my hand at classes (and OOP)....
Here's my idea of how a class and object-oriented programming _should_
work ideally. A programming object such as a "card" has attributes
that are as much as possible just like the real-world object, i.e., it
has suit, rank, x-location, y-location, visibility, side showing, etc..
If "card" is the class and "PlayerCard" is a specific object based on
that class, then to make that card into the Ace of Spades, it should be
a simple matter of saying PlayerCard.Rank = "Ace" and PlayerCard.Suit =
"Spades." And to put that card in the left-hand corner of the screen,
it should be a simple matter of saying PlayerCard.X = "0" and
PlayerCard.Y = 0. And to make that card visible, it should be a simple
matter of saying PlayerCard.Visible = True. And so on.
To give a slightly more complicated example (one using arrays), to deal
out a poker hand should be a simple matter of having five cards for each
player, e.g., for four players defining in the process
Player(1).Card(1).Rank, etc. through Player(4).Card(5).Rank, etc.
(including also definitions for Suit, X- and Y- positions, Visibility,
SideShowing, etc.), all the Properties needed for the twenty cards..
But it's apparently not that simple, at least in the graphics world,
where seemingly it is impossible to take such a common-sensible approach
(in my mind) to defining a class, because (1) getting a "handle" on a
graphical object is an arcane event, a well-kept secret known only to
the initiated, and (2) you can't change how something is pictured except
through some difficult contortions involving the Paint event.
Feel free to straighten me out on what a "class" is and what "OOP" is.
Please let me know where the preceding approach is wrong, because it's
my best attempt at present to think in terms of OOP and in terms of
"classes." (I hope what I've said shows that I _am_ seriously
attempting to do my best to make some progress in understanding such
things.)
Barry Traver
_______________________________________________
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>
|