Graphics Reference
In-Depth Information
(A) System Initialization:
(A1): Define Application State:
AllWorldBalls: A set of defined Balls, initialze to empty
HeroBall: current active ball, initialize to null
(A2): Register Event Service Routines:
Register for :
Left Mouse Button Down Event
Register for :
Left Mouse Button Drag Event
Register for :
Left Mouse Button Up Event
(D) Events Services:
// We care about these events, inform us if these events happen
// service routine left mouse button click-down
(D1): Left Mouse Button Down
HeroBall = Create a new ball at current mouse position
// Draw all balls (including HeroBall)
DrawAllBalls(AllWorldBalls, HeroBall)
// service routine for left mouse button drag
(D2): Left Mouse Button Drag
RefineRadiusAndVelocityOfHeroBall()
// Draw all balls (including HeroBall)
DrawAllBalls(AllWorldBalls, HeroBall)
// service routine for left mouse button release
(D3): Left Mouse Button Up
InsertHeroBallToAllWorldBalls()
// Draw all balls
DrawAllBalls(AllWorldBalls, null)
Listing 1.4. A simple event-driven program specification.
user applications to override the default behavior. During SystemInitiali
zation() , the user application can register an alternate service routine for
an event by toggling the override.
To develop an event-driven solution, our program must first register event ser-
vice routines with the GUI system. After that, our entire program solution is
based on waiting for and servicing user events. While control-driven program-
Search WWH ::




Custom Search