Outline Eventdriven programming paradigm Example Event Handling Class
- Slides: 11
Outline • Event-driven programming paradigm • Example: – Event Handling – Class – Array/Collection – Double Buffering
Event Handling Source Object Receiver Object Event H_Func(Event) { } Registration/delegate
Source vs. Receiver Source/Receiver Source
Mouse Event Handling in C++/CLI • Event: Mouse. Event. Args • Mouse Event Handlers: Form 1_Mouse. Down, Form 1_Mouse. Up, Form 1_Mouse. Move • Registration (delegate): – this->Mouse. Down += gcnew Mouse. Event. Handler(…); – this->Mouse. Up += gcnew Mouse. Event. Handler(…); – this->Mouse. Move += gcnew Mouse. Event. Handler(…);
Event-driven Programming • Programming paradigm • State representation • State presentation : Form 1_Paint in C++/CLI • Event handling and state change • Request for presentation to reflect new state: Invalidate in C++/CLI
Double Buffering • Flicking problem with single buffering • Double buffering – Front buffer for display – Back buffer for composition • Triple buffering
Single Buffering Display Frame Buffer Composition
Double Buffering in Computer Graphics Display Front Back Composition Swap Buffers Display Back Composition Front
Double Buffering in C++/CLI Window Image Front Back Draw Composition
Double Buffering in C++/CLI • Step 1: Create the back buffer and its graphics • Bitmap^ back. Buffer = gcnew Bitmap(width, height); • Graphics^ g. Back. Buffer = Graphics: : From. Image(back. Buffer); • Step 2: Compose the scene in the back buffer • g. Back. Buffer->Clear(Color: : White); • g. Back. Buffer->Fill. Ellipse(…); • . . • Step 3: copy the back buffer to the front • e->Graphics->Draw. Image. Unscaled(back. Buffer, 0, 0);
An Example • • • Event-driven programming paradigm Class Array/Clollection Event Handling Double Buffering
- Event driven programming paradigm
- Old paradigm
- Lua programming language paradigm
- Dynamic programming paradigm
- Generic subroutines
- Dynamic programming paradigm
- Event-driven programming in java
- Quotation sandwich examples
- Gui event handling
- Event handling in android
- Java gui event handling
- Exception handling in ada