Download presentation
Presentation is loading. Please wait.
Published byVivien Griffith Modified over 9 years ago
1
Outline Event-driven programming paradigm Example: Event Handling
Class Array/Collection Graphics Double Buffering
2
Event Handling Source Object Receiver Object H_Func(Event) { } Event
Registration/delegate
3
Source vs. Receiver Source/Receiver Receiver Source Source
4
Mouse Event Handling in C++/CLI
Event: MouseEventArgs Mouse Event Handlers: Form1_MouseDown, Form1_MouseUp, Form1_MouseMove Registration (delegate): this->MouseDown += gcnew MouseEventHandler(…); this->MouseUp += gcnew MouseEventHandler(…); this->MouseMove += gcnew MouseEventHandler(…);
5
A look at Graphics using GDI+
GDI: Graphical Device Interface Paint event is associated with all controls. Triggered when create, resize, restore, etc. Graphics class PaintEventHandler () Invalidate() Manually trigger Paint event
6
Event-driven Programming
Programming paradigm State representation State presentation : Form1_Paint in C++/CLI Event handling and state change Request for presentation to reflect new state:Invalidate in C++/CLI invalidates the entire client area of a window, which indicates that the area is out of date, and should be repainted. You would typically call this on a control that needs to be redrawn.
7
Double Buffering Flicking problem with single buffering
Front buffer for display Back buffer for composition Triple buffering
8
Single Buffering Display Frame Buffer Composition
9
Double Buffering in Computer Graphics
Display Front Back Composition Swap Buffers Display Back Front Composition
10
Double Buffering in C++/CLI
Window Image Front Back Draw Composition
11
Double Buffering in C++/CLI
Step 1: Create the back buffer and its graphics Bitmap^ backBuffer = gcnew Bitmap(width, height); Graphics^ gBackBuffer = Graphics::FromImage(backBuffer); Step 2: Compose the scene in the back buffer gBackBuffer->Clear(Color::White); gBackBuffer->FillEllipse(…); .... Step 3: copy the back buffer to the front e->Graphics->DrawImageUnscaled(backBuffer, 0, 0);
12
An Example Event-driven programming paradigm Class Array/Clollection
Event Handling Double Buffering
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.