diff options
author | sekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-11 13:49:55 +0000 |
---|---|---|
committer | sekelsenmat <sekelsenmat@ae50a9b5-8222-0410-bf8d-8a13f76226bf> | 2007-07-11 13:49:55 +0000 |
commit | e46f903dbd1d219adb13aafacaa7cfc797f46367 (patch) | |
tree | 3f1dbdbca4c78873303e0422db6d23c7b93baa64 /gfx | |
parent | 72446666f43418b9dde9a6163a176ce6b3e088e4 (diff) | |
download | fpGUI-e46f903dbd1d219adb13aafacaa7cfc797f46367.tar.xz |
Freed the EvPaint method for use by descendent components and implemented a EvInternalPaint for internal painting
Diffstat (limited to 'gfx')
-rw-r--r-- | gfx/gdi/gfx_gdi.pas | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/gfx/gdi/gfx_gdi.pas b/gfx/gdi/gfx_gdi.pas index a691f319..022867c3 100644 --- a/gfx/gdi/gfx_gdi.pas +++ b/gfx/gdi/gfx_gdi.pas @@ -188,6 +188,7 @@ type function GetHandle: PtrUInt; override; procedure UpdateWindowButtons; function DoMouseEnterLeaveCheck(uMsg, wParam, lParam: Cardinal): Boolean; + procedure EvInternalPaint; public { Constructors / Destructors } constructor Create(AParent: TFCustomWindow; AWindowOptions: TFWindowOptions); override; @@ -1160,7 +1161,7 @@ begin begin Windows.BeginPaint(Window.Handle, @PaintStruct); Window.FPaintStruct := PaintStruct; - Window.EvPaint(); + Window.EvInternalPaint(); Windows.EndPaint(Window.Handle, @PaintStruct); end; WM_ShowWindow: @@ -1200,7 +1201,6 @@ begin Windows.GetClientRect(Window.Handle, @r); Window.FClientWidth := LoWord(lParam); Window.FClientHeight := HiWord(lParam); -// TGDICanvas(Window.Canvas).Resized(Window.FWidth, Window.FHeight); Window.EvResize(); end; @@ -1638,7 +1638,13 @@ begin else if Assigned(Parent) then Parent.EvMouseWheel(AWheelDelta, AMousePos); end; -procedure TGDIWindow.EvPaint; +{ Because the painting code is executed on the middle of the processing + of the event, we have an internal paint method, which allows descending + objects to override the EvPaint function like they would do with other + event functions. + + This frees the OnPaint event for use by the users of the components } +procedure TGDIWindow.EvInternalPaint; var rect: TRect; OldBitmap, NewBitmap: HBITMAP; @@ -1649,7 +1655,7 @@ begin { It is necessary to create a bitmap and select it to implement double buffering. If we just create a DC and don't select a bitmap, there is no memory where to store the painting } - + hdcMem := CreateCompatibleDC(FPaintStruct.hdc); NewBitmap := Windows.CreateCompatibleBitmap(FPaintStruct.hdc, Width, Height); @@ -1660,10 +1666,10 @@ begin { Execution of user paint code } - if Assigned(OnPaint) then OnPaint(Self); + EvPaint(); { Flushes the result to the screen } - + Windows.BitBlt( FPaintStruct.hdc, // handle to destination DC rect.Left, // x-coord of destination upper-left corner @@ -1676,27 +1682,22 @@ begin SRCCOPY // raster operation code ); -{ Windows.BitBlt( - FPaintStruct.hdc, // handle to destination DC - 0, // x-coord of destination upper-left corner - 0, // y-coord of destination upper-left corner - Width, // width of destination rectangle - Height, // height of destination rectangle - FCanvas.Handle, // handle to source DC - 0, // x-coordinate of source upper-left corner - 0, // y-coordinate of source upper-left corner - SRCCOPY // raster operation code - ); } - { Clean up } SelectObject(hdcMem, OldBitmap); DeleteDC(hdcMem); DeleteObject(NewBitmap); + { Resets the canvas handle } + FCanvas.SetHandle(0); end; +procedure TGDIWindow.EvPaint; +begin + if Assigned(OnPaint) then OnPaint(Self); +end; + procedure TGDIWindow.EvMove; begin if Assigned(OnMove) then OnMove(Self); |