Browse Source

added bgraflashprogressbar.pas OnRedraw event
added test_progressbar

lainz 10 years ago
parent
commit
a9a6e49ced

+ 6 - 0
bgraflashprogressbar.pas

@@ -10,6 +10,8 @@ uses
 
 type
 
+  TBGRAProgressBarRedrawEvent = procedure(Sender: TObject; Bitmap: TBGRABitmap; xpos: integer) of object;
+
   { TBGRAFlashProgressBar }
 
   TBGRAFlashProgressBar = class(TGraphicControl)
@@ -19,6 +21,7 @@ type
     FValue:    integer;
     FBmp:      TBGRABitmap;
     FRandSeed: integer;
+    FOnRedraw: TBGRAProgressBarRedrawEvent;
     procedure SetMaxValue(const AValue: integer);
     procedure SetMinValue(const AValue: integer);
     procedure SetValue(const AValue: integer);
@@ -55,6 +58,7 @@ type
     property OnMouseWheel;
     property OnMouseWheelUp;
     property OnMouseWheelDown;
+    property OnRedraw: TBGRAProgressBarRedrawEvent read FOnredraw write FOnRedraw;
     property Color;
   end;
 
@@ -185,6 +189,8 @@ begin
       end;
     end;
   end;
+  if Assigned(OnRedraw) then
+    OnRedraw(Self, FBmp, xpos);
   FBmp.Draw(Canvas, 0, 0, False);
 end;
 

+ 91 - 0
test/test_bccontrols/test_progressbar/test_progressbar.lpi

@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<CONFIG>
+  <ProjectOptions>
+    <Version Value="9"/>
+    <PathDelim Value="\"/>
+    <General>
+      <SessionStorage Value="InProjectDir"/>
+      <MainUnit Value="0"/>
+      <Title Value="test_progressbar"/>
+      <ResourceType Value="res"/>
+      <UseXPManifest Value="True"/>
+      <Icon Value="0"/>
+    </General>
+    <i18n>
+      <EnableI18N LFM="False"/>
+    </i18n>
+    <VersionInfo>
+      <StringTable ProductVersion=""/>
+    </VersionInfo>
+    <BuildModes Count="1">
+      <Item1 Name="Default" Default="True"/>
+    </BuildModes>
+    <PublishOptions>
+      <Version Value="2"/>
+    </PublishOptions>
+    <RunParams>
+      <local>
+        <FormatVersion Value="1"/>
+      </local>
+    </RunParams>
+    <RequiredPackages Count="2">
+      <Item1>
+        <PackageName Value="bgracontrols"/>
+      </Item1>
+      <Item2>
+        <PackageName Value="LCL"/>
+      </Item2>
+    </RequiredPackages>
+    <Units Count="2">
+      <Unit0>
+        <Filename Value="test_progressbar.lpr"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="test_progressbar"/>
+      </Unit0>
+      <Unit1>
+        <Filename Value="umain.pas"/>
+        <IsPartOfProject Value="True"/>
+        <ComponentName Value="Form1"/>
+        <ResourceBaseClass Value="Form"/>
+        <UnitName Value="umain"/>
+      </Unit1>
+    </Units>
+  </ProjectOptions>
+  <CompilerOptions>
+    <Version Value="11"/>
+    <PathDelim Value="\"/>
+    <Target>
+      <Filename Value="test_progressbar"/>
+    </Target>
+    <SearchPaths>
+      <IncludeFiles Value="$(ProjOutDir)"/>
+      <UnitOutputDirectory Value="lib\$(TargetCPU)-$(TargetOS)"/>
+    </SearchPaths>
+    <Linking>
+      <Options>
+        <Win32>
+          <GraphicApplication Value="True"/>
+        </Win32>
+      </Options>
+    </Linking>
+    <Other>
+      <CompilerMessages>
+        <MsgFileName Value=""/>
+      </CompilerMessages>
+      <CompilerPath Value="$(CompPath)"/>
+    </Other>
+  </CompilerOptions>
+  <Debugging>
+    <Exceptions Count="3">
+      <Item1>
+        <Name Value="EAbort"/>
+      </Item1>
+      <Item2>
+        <Name Value="ECodetoolError"/>
+      </Item2>
+      <Item3>
+        <Name Value="EFOpenError"/>
+      </Item3>
+    </Exceptions>
+  </Debugging>
+</CONFIG>

+ 21 - 0
test/test_bccontrols/test_progressbar/test_progressbar.lpr

@@ -0,0 +1,21 @@
+program test_progressbar;
+
+{$mode objfpc}{$H+}
+
+uses
+  {$IFDEF UNIX}{$IFDEF UseCThreads}
+  cthreads,
+  {$ENDIF}{$ENDIF}
+  Interfaces, // this includes the LCL widgetset
+  Forms, umain
+  { you can add units after this };
+
+{$R *.res}
+
+begin
+  RequireDerivedFormResource := True;
+  Application.Initialize;
+  Application.CreateForm(TForm1, Form1);
+  Application.Run;
+end.
+

+ 147 - 0
test/test_bccontrols/test_progressbar/umain.lfm

@@ -0,0 +1,147 @@
+object Form1: TForm1
+  Left = 357
+  Height = 240
+  Top = 179
+  Width = 320
+  Caption = 'Form1'
+  ClientHeight = 240
+  ClientWidth = 320
+  LCLVersion = '1.2.6.0'
+  object BGRAFlashProgressBar1: TBGRAFlashProgressBar
+    Left = 8
+    Height = 33
+    Top = 8
+    Width = 307
+    MinValue = 0
+    MaxValue = 100
+    Value = 30
+    Color = 14852966
+  end
+  object BGRAFlashProgressBar2: TBGRAFlashProgressBar
+    Left = 8
+    Height = 33
+    Top = 48
+    Width = 307
+    MinValue = 0
+    MaxValue = 100
+    Value = 30
+    OnClick = BGRAFlashProgressBar2Click
+    OnRedraw = BGRAFlashProgressBar2Redraw
+    Color = 14852966
+  end
+  object BCTrackbarUpdown1: TBCTrackbarUpdown
+    Left = 8
+    Height = 26
+    Top = 96
+    Width = 182
+    BarExponent = 1
+    Increment = 1
+    LongTimeInterval = 400
+    MinValue = 0
+    MaxValue = 100
+    OnChange = BCTrackbarUpdown1Change
+    Value = 50
+    ShortTimeInterval = 100
+    Background.Color = clWindow
+    Background.ColorOpacity = 255
+    Background.Gradient1.StartColor = clWhite
+    Background.Gradient1.StartColorOpacity = 255
+    Background.Gradient1.DrawMode = dmSet
+    Background.Gradient1.EndColor = clBlack
+    Background.Gradient1.EndColorOpacity = 255
+    Background.Gradient1.ColorCorrection = True
+    Background.Gradient1.GradientType = gtLinear
+    Background.Gradient1.Point1XPercent = 0
+    Background.Gradient1.Point1YPercent = 0
+    Background.Gradient1.Point2XPercent = 0
+    Background.Gradient1.Point2YPercent = 100
+    Background.Gradient1.Sinus = False
+    Background.Gradient2.StartColor = clWhite
+    Background.Gradient2.StartColorOpacity = 255
+    Background.Gradient2.DrawMode = dmSet
+    Background.Gradient2.EndColor = clBlack
+    Background.Gradient2.EndColorOpacity = 255
+    Background.Gradient2.ColorCorrection = True
+    Background.Gradient2.GradientType = gtLinear
+    Background.Gradient2.Point1XPercent = 0
+    Background.Gradient2.Point1YPercent = 0
+    Background.Gradient2.Point2XPercent = 0
+    Background.Gradient2.Point2YPercent = 100
+    Background.Gradient2.Sinus = False
+    Background.Gradient1EndPercent = 35
+    Background.Style = bbsColor
+    ButtonBackground.Color = clBlack
+    ButtonBackground.ColorOpacity = 255
+    ButtonBackground.Gradient1.StartColor = clBtnShadow
+    ButtonBackground.Gradient1.StartColorOpacity = 255
+    ButtonBackground.Gradient1.DrawMode = dmSet
+    ButtonBackground.Gradient1.EndColor = clBtnFace
+    ButtonBackground.Gradient1.EndColorOpacity = 255
+    ButtonBackground.Gradient1.ColorCorrection = True
+    ButtonBackground.Gradient1.GradientType = gtLinear
+    ButtonBackground.Gradient1.Point1XPercent = 0
+    ButtonBackground.Gradient1.Point1YPercent = -50
+    ButtonBackground.Gradient1.Point2XPercent = 0
+    ButtonBackground.Gradient1.Point2YPercent = 50
+    ButtonBackground.Gradient1.Sinus = False
+    ButtonBackground.Gradient2.StartColor = clBtnFace
+    ButtonBackground.Gradient2.StartColorOpacity = 255
+    ButtonBackground.Gradient2.DrawMode = dmSet
+    ButtonBackground.Gradient2.EndColor = clBtnShadow
+    ButtonBackground.Gradient2.EndColorOpacity = 255
+    ButtonBackground.Gradient2.ColorCorrection = True
+    ButtonBackground.Gradient2.GradientType = gtLinear
+    ButtonBackground.Gradient2.Point1XPercent = 0
+    ButtonBackground.Gradient2.Point1YPercent = 50
+    ButtonBackground.Gradient2.Point2XPercent = 0
+    ButtonBackground.Gradient2.Point2YPercent = 150
+    ButtonBackground.Gradient2.Sinus = False
+    ButtonBackground.Gradient1EndPercent = 50
+    ButtonBackground.Style = bbsGradient
+    ButtonDownBackground.Color = clBtnShadow
+    ButtonDownBackground.ColorOpacity = 255
+    ButtonDownBackground.Gradient1.StartColor = clWhite
+    ButtonDownBackground.Gradient1.StartColorOpacity = 255
+    ButtonDownBackground.Gradient1.DrawMode = dmSet
+    ButtonDownBackground.Gradient1.EndColor = clBlack
+    ButtonDownBackground.Gradient1.EndColorOpacity = 255
+    ButtonDownBackground.Gradient1.ColorCorrection = True
+    ButtonDownBackground.Gradient1.GradientType = gtLinear
+    ButtonDownBackground.Gradient1.Point1XPercent = 0
+    ButtonDownBackground.Gradient1.Point1YPercent = 0
+    ButtonDownBackground.Gradient1.Point2XPercent = 0
+    ButtonDownBackground.Gradient1.Point2YPercent = 100
+    ButtonDownBackground.Gradient1.Sinus = False
+    ButtonDownBackground.Gradient2.StartColor = clWhite
+    ButtonDownBackground.Gradient2.StartColorOpacity = 255
+    ButtonDownBackground.Gradient2.DrawMode = dmSet
+    ButtonDownBackground.Gradient2.EndColor = clBlack
+    ButtonDownBackground.Gradient2.EndColorOpacity = 255
+    ButtonDownBackground.Gradient2.ColorCorrection = True
+    ButtonDownBackground.Gradient2.GradientType = gtLinear
+    ButtonDownBackground.Gradient2.Point1XPercent = 0
+    ButtonDownBackground.Gradient2.Point1YPercent = 0
+    ButtonDownBackground.Gradient2.Point2XPercent = 0
+    ButtonDownBackground.Gradient2.Point2YPercent = 100
+    ButtonDownBackground.Gradient2.Sinus = False
+    ButtonDownBackground.Gradient1EndPercent = 35
+    ButtonDownBackground.Style = bbsColor
+    Border.Color = clWindowText
+    Border.ColorOpacity = 255
+    Border.LightColor = clWhite
+    Border.LightOpacity = 255
+    Border.LightWidth = 0
+    Border.Style = bboSolid
+    Border.Width = 1
+    Rounding.RoundX = 1
+    Rounding.RoundY = 1
+    Rounding.RoundOptions = []
+    Font.Color = clWindowText
+    Font.Name = 'Arial'
+    HasTrackBar = True
+    ArrowColor = clBtnText
+    TabOrder = 0
+    TabStop = True
+    UseDockManager = False
+  end
+end

+ 59 - 0
test/test_bccontrols/test_progressbar/umain.pas

@@ -0,0 +1,59 @@
+unit umain;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs,
+  BGRAFlashProgressBar, BCTrackbarUpdown, BGRABitmap, BGRABitmapTypes;
+
+type
+
+  { TForm1 }
+
+  TForm1 = class(TForm)
+    BCTrackbarUpdown1: TBCTrackbarUpdown;
+    BGRAFlashProgressBar1: TBGRAFlashProgressBar;
+    BGRAFlashProgressBar2: TBGRAFlashProgressBar;
+    procedure BCTrackbarUpdown1Change(Sender: TObject; AByUser: boolean);
+    procedure BGRAFlashProgressBar2Click(Sender: TObject);
+    procedure BGRAFlashProgressBar2Redraw(Sender: TObject; Bitmap: TBGRABitmap;
+      xpos: integer);
+  private
+    { private declarations }
+  public
+    { public declarations }
+  end;
+
+var
+  Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+
+procedure TForm1.BGRAFlashProgressBar2Redraw(Sender: TObject;
+  Bitmap: TBGRABitmap; xpos: integer);
+begin
+  { Draw the progressbar container }
+  Bitmap.Rectangle(0, 0, Bitmap.Width, Bitmap.Height, BGRABlack, BGRAWhite, dmSet);
+  { Draw the progressbar progress }
+  Bitmap.Rectangle(1, 1, xpos + 1, Bitmap.Height - 1, BGRAWhite, BGRABlack, dmSet);
+end;
+
+procedure TForm1.BCTrackbarUpdown1Change(Sender: TObject; AByUser: boolean);
+begin
+  BGRAFlashProgressBar1.Value := BCTrackbarUpdown1.Value;
+  BGRAFlashProgressBar2.Value := BCTrackbarUpdown1.Value;
+end;
+
+procedure TForm1.BGRAFlashProgressBar2Click(Sender: TObject);
+begin
+
+end;
+
+end.
+