Browse Source

Added bgraresizespeedbutton
Added Align and Anchors for bgragraphiccontrol

lainz 11 years ago
parent
commit
4a54d1fd83
5 changed files with 86 additions and 3 deletions
  1. 6 1
      bgracontrols.lpk
  2. 2 1
      bgracontrols.pas
  3. 2 0
      bgragraphiccontrol.pas
  4. 71 0
      bgraresizespeedbutton.pas
  5. 5 1
      docs/readme.txt

+ 6 - 1
bgracontrols.lpk

@@ -27,7 +27,7 @@
       </Other>
     </CompilerOptions>
     <Version Major="3" Minor="1"/>
-    <Files Count="21">
+    <Files Count="22">
       <Item1>
         <Filename Value="bcbasectrls.pas"/>
         <UnitName Value="BCBaseCtrls"/>
@@ -127,6 +127,11 @@
         <HasRegisterProc Value="True"/>
         <UnitName Value="BGRAVirtualScreen"/>
       </Item21>
+      <Item22>
+        <Filename Value="bgraresizespeedbutton.pas"/>
+        <HasRegisterProc Value="True"/>
+        <UnitName Value="bgraresizespeedbutton"/>
+      </Item22>
     </Files>
     <Type Value="RunAndDesignTime"/>
     <RequiredPkgs Count="2">

+ 2 - 1
bgracontrols.pas

@@ -11,7 +11,7 @@ uses
   BCLabel, BCPanel, BCRTTI, BCStylesForm, BCTools, BGRAFlashProgressBar, 
   BGRAGraphicControl, BGRAImageList, BGRAImageManipulation, BGRAKnob, 
   BGRAShape, BGRASpeedButton, BGRASpriteAnimation, BGRAVirtualScreen, 
-  LazarusPackageIntf;
+  BGRAResizeSpeedButton, LazarusPackageIntf;
 
 implementation
 
@@ -31,6 +31,7 @@ begin
   RegisterUnit('BGRASpeedButton', @BGRASpeedButton.Register);
   RegisterUnit('BGRASpriteAnimation', @BGRASpriteAnimation.Register);
   RegisterUnit('BGRAVirtualScreen', @BGRAVirtualScreen.Register);
+  RegisterUnit('BGRAResizeSpeedButton', @BGRAResizeSpeedButton.Register);
 end;
 
 initialization

+ 2 - 0
bgragraphiccontrol.pas

@@ -45,6 +45,8 @@ type
     destructor Destroy; override;
   published
     { Published declarations }
+    property Align;
+    property Anchors;
     property OnRedraw: TBGRARedrawEvent Read FOnRedraw Write FOnRedraw;
     property Bitmap: TBGRABitmap Read FBGRA;
     property BorderWidth: TBorderWidth Read FBorderWidth Write SetBorderWidth default 0;

+ 71 - 0
bgraresizespeedbutton.pas

@@ -0,0 +1,71 @@
+unit BGRAResizeSpeedButton;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, Buttons, LResources, Forms,
+  Controls, Graphics, Dialogs, BGRASpeedButton, BGRABitmap;
+
+type
+  TBGRAResizeSpeedButton = class(TBGRASpeedButton)
+  private
+    { Private declarations }
+    FBGRA: TBGRABitmap;
+  protected
+    { Protected declarations }
+    function DrawGlyph(ACanvas: TCanvas; const AClient: TRect;
+      const AOffset: TPoint; AState: TButtonState; ATransparent: boolean;
+      BiDiFlags: longint): TRect; override;
+  public
+    { Public declarations }
+    constructor Create(AOwner: TComponent); override;
+    destructor Destroy; override;
+  published
+    { Published declarations }
+  end;
+
+procedure Register;
+
+implementation
+
+function TBGRAResizeSpeedButton.DrawGlyph(ACanvas: TCanvas;
+  const AClient: TRect; const AOffset: TPoint; AState: TButtonState;
+  ATransparent: boolean; BiDiFlags: longint): TRect;
+
+begin
+  if Glyph = nil then
+    Exit;
+
+  Result := AClient;
+  if Assigned(Glyph) and not Glyph.Empty then
+  begin
+    FBGRA.Assign(Glyph);
+    BGRAReplace(FBGRA, FBGRA.Resample(Self.Width - 6, Self.Height - 6));
+    if (AState = bsDown) or (Down = True) then
+      FBGRA.Draw(ACanvas, 4, 4, False)
+    else
+      FBGRA.Draw(ACanvas, 3, 3, False);
+  end;
+end;
+
+constructor TBGRAResizeSpeedButton.Create(AOwner: TComponent);
+begin
+  inherited Create(AOwner);
+  FBGRA := TBGRABitmap.Create;
+end;
+
+destructor TBGRAResizeSpeedButton.Destroy;
+begin
+  FBGRA.Free;
+  inherited Destroy;
+end;
+
+procedure Register;
+begin
+  // {$I bgraresizespeedbutton_icon.lrs}
+  RegisterComponents('BGRA Controls', [TBGRAResizeSpeedButton]);
+end;
+
+end.

+ 5 - 1
docs/readme.txt

@@ -36,6 +36,7 @@ Contributor and package mantainer.
 
 BC Controls
 - TBCImageButton
+- TBCXButton
 - TBCGameGrid
 
 BGRA Controls
@@ -45,4 +46,7 @@ BGRA Controls
 - TBGRAImageManipulation
 
 == Author: mora ==
-- Contributor to BCButton functionality.
+- Contributor to BCButton functionality.
+
+== Author: helix2001 ==
+- TBGRAResizeSpeedButton.