Graphics Reference
In-Depth Information
void
CTutorialDlg::OnTimer(UINT nIDEvent) {
A:
when enabled, update the circle's radius
if
(m
_
controls.m
_
bSliderControl)
theApp.GetModel().SetCircleRadius( m
_
controls.m
_
CircleRadiusBar.GetSliderValue() );
B:
Redraw the entire model
m
_
view.DrawGraphics();
}
Listing 5.11.
CTutorialDlg::OnTimer()
(Tutorial 5.1).
Source files.
TutorialDlg.cpp
file in the
Source Files
•
CTutorialDlg::OnTimer()
. Listing 5.11 shows that when the timer goes
off, our application must do the following.
folder
of
the
D3D
_
ModelView
project.
-
(A) Update the
CModel
according to the user's action during the pre-
vious timer period (25 millisecond).
-
(B) Invoke the
CDrawOnlyHandler
to display the updated
CModel
.
This tutorial is a very simple MVC implementation. Notice the following.
•
Model.
Defined in the
CModel
class, a simple model with simple interface
methods.
•
Controllers.
There are two controllers objects and a view/controller pair.
The two controllers are the main application window (
CTutorialDlg
)and
the circle radius controls (
CCircleRadiusControls
). Both of these con-
trollers are capable of generating events for the model.
•
View/controller pair.
We get experience with subclassing from the
Window
Handler
abstraction. We see that in the simplest form, we must define a
GUI area for drawing (
UIWindow
), and we must define the drawing routine
(
DrawGraphics()
).
•
Collaborations of the components.
The main application window con-
tains components. However, the components do not have knowledge of
each other. The only collaboration comes during the timer event, where the
main application window (
CTutorialDlg
) polls the controllers, updates
the application model, and triggers redraws. We continue to keep the com-
ponents clean from each other. In this way, it becomes straightforward to
insert/remove components from the main application window.
Search WWH ::
Custom Search