Fixed Panning window draw

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@141 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
blikblum
2007-04-06 00:57:17 +00:00
parent 28313808a3
commit 213e0cc3b1
2 changed files with 16 additions and 20 deletions

View File

@@ -23205,20 +23205,21 @@ procedure TBaseVirtualTree.StartWheelPanning(Position: TPoint);
// Since we only work on a very small image (32x32 pixels) this is acceptable. // Since we only work on a very small image (32x32 pixels) this is acceptable.
var var
Start, X, Y: Integer; Start, X, Y, ImageHeight, ImageWidth: Integer;
Temp: HRGN; Temp: HRGN;
begin begin
Assert(not FPanningWindow.Image.Empty, 'Invalid wheel panning image.'); Assert(not FPanningWindow.Image.Empty, 'Invalid wheel panning image.');
ImageWidth:= FPanningWindow.Image.Width;
ImageHeight:= FPanningWindow.Image.Height;
// Create an initial region on which we operate. // Create an initial region on which we operate.
Result := CreateRectRgn(0, 0, 0, 0); Result := CreateRectRgn(0, 0, 0, 0);
with FPanningWindow.Image, Canvas do with FPanningWindow.Image.Canvas do
begin begin
for Y := 0 to Height - 1 do for Y := 0 to ImageHeight - 1 do
begin begin
Start := -1; Start := -1;
for X := 0 to Width - 1 do for X := 0 to ImageWidth - 1 do
begin begin
// Start a new span if we found a non-transparent pixel and no span is currently started. // Start a new span if we found a non-transparent pixel and no span is currently started.
if (Start = -1) and (Pixels[X, Y] <> clFuchsia) then if (Start = -1) and (Pixels[X, Y] <> clFuchsia) then
@@ -23236,7 +23237,7 @@ procedure TBaseVirtualTree.StartWheelPanning(Position: TPoint);
// If there is an open span then add this also to the result region. // If there is an open span then add this also to the result region.
if Start > -1 then if Start > -1 then
begin begin
Temp := CreateRectRgn(Start, Y, Width, Y + 1); Temp := CreateRectRgn(Start, Y, ImageWidth, Y + 1);
CombineRgn(Result, Result, Temp, RGN_OR); CombineRgn(Result, Result, Temp, RGN_OR);
DeleteObject(Temp); DeleteObject(Temp);
end; end;

View File

@@ -1,5 +1,7 @@
unit virtualpanningwindow; unit virtualpanningwindow;
{Adapted from VirtualTrees by Luiz Am�rico to work in LCL/Lazarus}
{$mode objfpc}{$H+} {$mode objfpc}{$H+}
interface interface
@@ -8,7 +10,6 @@ uses
Windows, Graphics, Classes, SysUtils; Windows, Graphics, Classes, SysUtils;
type type
{ TVirtualPanningWindow } { TVirtualPanningWindow }
TVirtualPanningWindow = class TVirtualPanningWindow = class
@@ -63,19 +64,11 @@ var
procedure TVirtualPanningWindow.HandlePaintMessage; procedure TVirtualPanningWindow.HandlePaintMessage;
var var
PS: PaintStruct; PS: PaintStruct;
Canvas: TCanvas;
begin begin
BeginPaint(FHandle, PS); BeginPaint(FHandle, PS);
Canvas := TCanvas.Create; BitBlt(PS.hdc,0,0,FImage.Width,FImage.Height,FImage.Canvas.Handle,0,0,SRCCOPY);
Canvas.Handle := PS.hdc;
try
Canvas.Draw(0, 0, FImage);
finally
Canvas.Handle := 0;
Canvas.Free;
EndPaint(FHandle, PS); EndPaint(FHandle, PS);
end; end;
end;
procedure TVirtualPanningWindow.Start(OwnerHandle: THandle; const Position: TPoint); procedure TVirtualPanningWindow.Start(OwnerHandle: THandle; const Position: TPoint);
@@ -83,9 +76,11 @@ var
TempClass: TWndClass; TempClass: TWndClass;
begin begin
// Register the helper window class. // Register the helper window class.
PanningWindowClass.hInstance := HInstance;
if not GetClassInfo(HInstance, PanningWindowClass.lpszClassName, TempClass) then if not GetClassInfo(HInstance, PanningWindowClass.lpszClassName, TempClass) then
begin
PanningWindowClass.hInstance := HInstance;
Windows.RegisterClass(PanningWindowClass); Windows.RegisterClass(PanningWindowClass);
end;
// Create the helper window and show it at the given position without activating it. // Create the helper window and show it at the given position without activating it.
with Position do with Position do
@@ -101,7 +96,6 @@ procedure TVirtualPanningWindow.Stop;
begin begin
// Destroy the helper window. // Destroy the helper window.
DestroyWindow(FHandle); DestroyWindow(FHandle);
FHandle := 0;
FImage.Free; FImage.Free;
FImage := nil; FImage := nil;
end; end;
@@ -109,6 +103,7 @@ end;
procedure TVirtualPanningWindow.Show(ClipRegion: HRGN); procedure TVirtualPanningWindow.Show(ClipRegion: HRGN);
begin begin
Logger.SendBitmap([lcPanning],'Panning Image',FImage); Logger.SendBitmap([lcPanning],'Panning Image',FImage);
//todo: move SetWindowRgn to DelphiCompat
SetWindowRgn(FHandle, ClipRegion, False); SetWindowRgn(FHandle, ClipRegion, False);
ShowWindow(FHandle, SW_SHOWNOACTIVATE); ShowWindow(FHandle, SW_SHOWNOACTIVATE);
end; end;