Graphics Reference
In-Depth Information
class
CViewController {
private
:
CApplicationModel
TheModel = null
// Reference to the application state
CApplicationView
TheView
= null
// for drawing to the desirable region
public
:
void
Initialize(CApplicationMode aModel, CUIDrawArea anArea) {
// anArea on the application window for drawing
TheView =
new
CApplicationView( anArea )
TheModel = aModel
// Register Event Service Routines
GUISystem
::RegisterServiceRoutine(
GUISystem
::LMBDown, LMBDownRoutine)
GUISystem
::RegisterServiceRoutine(
GUISystem
::LMBDrag, LMBDragRoutine)
GUISystem
::RegisterServiceRoutine(
GUISystem
::LMBUp, LMBUpRoutine)
GUISystem
::RegisterServiceRoutine(
GUISystem
::RMBDown, RMBDownRoutine)
GUISystem
::RegisterServiceRoutine(
GUISystem
::RedrawEvent, RedrawRoutine)
}
}
Source file.
Pseudocode; no
corresponding source file.
class
CMainAppController {
private
:
CViewController
aViewController;
// For drawing and mouse interaction
public
:
void
Initialize(CApplicationModel aModel)
{
TheModel = aModel
// initialize the drawing area
aViewController.Initialize(aModel, areaForDrawing)
// Register Event Service Routines
GUISystem
::DefineTimerPeriod(SimulationUpdateInterval)
GUISystem
::RegisterServiceRoutine(
GUISystem
:: SliderBar, SliderBarRoutine)
GUISystem
::RegisterServiceRoutine(
GUISystem
:: TimerEvent, ServiceTimer)
}
}
SystemInitialization
() {
CApplicationModel
aModel =
new
CApplicationModel();
CMainAppController
mainApp =
new
CAppController()
mainApp.Initialize(aModel)
}
Listing 5.3.
The controller of the ball-shooting program.
Search WWH ::
Custom Search