1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
| Index: gifanim.pas
===================================================================
--- gifanim.pas (revision none)
+++ gifanim.pas (working copy)
@@ -26,7 +26,7 @@
uses
Classes, LCLProc, Lresources, SysUtils, Controls, Graphics, ExtCtrls,
- IntfGraphics, FPimage, Contnrs, GraphType, dialogs;
+ IntfGraphics, FPimage, Contnrs, GraphType, dialogs, types;
const
@@ -193,7 +193,7 @@
procedure DoAutoSize; override;
procedure DoStartAnim;
procedure DoStopAnim;
- class function GetControlClassDefaultSize: TPoint; override;
+ class function GetControlClassDefaultSize: TSize; override;
procedure GifChanged;
procedure LoadFromFile(const Filename: string); virtual;
procedure Paint; override;
@@ -203,6 +203,8 @@
{ Public declarations }
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
+ procedure NextFrame;
+ procedure PriorFrame;
property Empty: boolean Read FEmpty;
property GifBitmaps: TGifList Read FGifBitmaps;
property GifIndex: integer Read FCurrentImage;
@@ -268,7 +270,7 @@
inherited Create(AOwner);
ControlStyle := [csCaptureMouse, csClickEvents, csDoubleClicks];
AutoSize := True;
- SetInitialBounds(0, 0, GetControlClassDefaultSize.X, GetControlClassDefaultSize.Y);
+ SetInitialBounds(0, 0, GetControlClassDefaultSize.CX, GetControlClassDefaultSize.CY);
FEmpty := True;
FCurrentImage := 0;
CurrentView := TBitmap.Create;
@@ -295,6 +297,59 @@
CurrentView.Free;
end;
+procedure TGifAnim.NextFrame;
+begin
+ if (not FEmpty) and Visible and (not FAnimate) then
+ begin
+ if FCurrentImage >= GifBitmaps.Count - 1 then
+ FCurrentImage := 0
+ else
+ Inc(FCurrentImage);
+ if Assigned(FOnFrameChanged) then
+ FOnFrameChanged(Self);
+ Repaint;
+ end;
+end;
+
+procedure TGifAnim.PriorFrame;
+var
+ DesiredImage: Integer;
+begin
+ if (not FEmpty) and Visible and (not FAnimate) then
+ begin
+ if FCurrentImage = 0 then
+ DesiredImage:= GifBitmaps.Count - 1
+ else
+ DesiredImage:= FCurrentImage - 1;
+ // For proper display repaint image from first frame to desired frame
+ FCurrentImage:= 0;
+ while FCurrentImage < DesiredImage do
+ begin
+ with GifBitmaps.Items[FCurrentImage] do
+ begin
+ BufferImg.Canvas.Brush.Color := (Self.Color);
+ if FCurrentImage = 0 then
+ BufferImg.Canvas.FillRect(Rect(0, 0, Width, Height));
+ if Delay <> 0 then
+ FWait.Interval := Delay * 10;
+ BufferImg.Canvas.Draw(PosX, PosY, Bitmap);
+ case Method of
+ //0 : Not specified...
+ //1 : No change Background
+ 2: BufferImg.Canvas.FillRect(
+ Rect(PosX, PosY, Bitmap.Width + PosX, Bitmap.Height + PosY));
+
+ 3: BufferImg.Canvas.FillRect(Rect(0, 0, Width, Height));
+ end;
+ end;
+ Inc(FCurrentImage);
+ end;
+ if Assigned(FOnFrameChanged) then
+ FOnFrameChanged(Self);
+ Repaint;
+ end;
+end;
+
function TGifAnim.LoadFromLazarusResource(const ResName: String): boolean;
var
GifLoader: TGifLoader;
@@ -340,12 +395,13 @@
begin
if (not Empty) and Visible then
begin
- if FCurrentImage > GifBitmaps.Count - 1 then
- FCurrentImage := 0;
- if assigned(FOnFrameChanged) then
- FOnFrameChanged(self);
- Paint;
- Inc(FCurrentImage);
+ if FCurrentImage >= GifBitmaps.Count - 1 then
+ FCurrentImage := 0
+ else
+ Inc(FCurrentImage);
+ if Assigned(FOnFrameChanged) then
+ FOnFrameChanged(Self);
+ Repaint;
end;
end;
@@ -368,7 +424,6 @@
var
fn: string;
begin
-
if (FFileName = AValue) then
exit;
FFileName := AValue;
@@ -441,10 +496,10 @@
end;
end;
-class function TGifAnim.GetControlClassDefaultSize: TPoint;
+class function TGifAnim.GetControlClassDefaultSize: TSize;
begin
- Result.X := 90;
- Result.Y := 90;
+ Result.CX := 90;
+ Result.CY := 90;
end;
procedure TGifAnim.GifChanged;
Index: pkg_gifanim.lpk
===================================================================
--- pkg_gifanim.lpk (revision none)
+++ pkg_gifanim.lpk (working copy)
@@ -1,15 +1,26 @@
<?xml version="1.0"?>
<CONFIG>
- <Package Version="3">
+ <Package Version="4">
<PathDelim Value="\"/>
<Name Value="pkg_gifanim"/>
+ <AddToProjectUsesSection Value="True"/>
<Author Value="Laurent Jacques"/>
<CompilerOptions>
- <Version Value="8"/>
+ <Version Value="11"/>
<PathDelim Value="\"/>
<SearchPaths>
- <OtherUnitFiles Value="$(LazarusDir)\ide\"/>
+ <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
</SearchPaths>
+ <Conditionals Value="if LCLWidgetType <> GetIDEValue('LCLWidgetType') then
+begin
+ UnitPath += '$(FallbackOutputRoot)/IDEIntf/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType);';
+ UsageUnitPath += '$(FallbackOutputRoot)/IDEIntf/units/$(TargetCPU)-$(TargetOS)/$(LCLWidgetType);';
+end;"/>
+ <Linking>
+ <Debugging>
+ <DebugInfoType Value="dsDwarf2Set"/>
+ </Debugging>
+ </Linking>
<Other>
<CompilerPath Value="$(CompPath)"/>
</Other>
@@ -41,7 +52,7 @@
</Item2>
</RequiredPkgs>
<UsageOptions>
- <UnitPath Value="$(PkgOutDir)\"/>
+ <UnitPath Value="$(PkgOutDir)"/>
</UsageOptions>
<PublishOptions>
<Version Value="2"/> |
Partager