瀏覽代碼

Added bctoolbar

lainz 10 年之前
父節點
當前提交
34a7cdbca9

+ 108 - 0
bctoolbar.pas

@@ -0,0 +1,108 @@
+unit BCToolBar;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, LResources, Forms, Controls, Graphics, Dialogs, ComCtrls,
+  BGRABitmap, BGRABitmapTypes, BGRAGradients, BCTypes;
+
+type
+
+  { TBCToolBar }
+
+  TBCToolBar = class(TToolBar)
+  private
+    { Private declarations }
+    FOnRedraw: TBGRARedrawEvent;
+    FBGRA: TBGRABitmap;
+  protected
+    { Protected declarations }
+    procedure Paint; override;
+  public
+    { Public declarations }
+    constructor Create(TheOwner: TComponent); override;
+    destructor Destroy; override;
+  published
+    { Published declarations }
+    property OnRedraw: TBGRARedrawEvent Read FOnRedraw Write FOnRedraw;
+  end;
+
+  procedure DrawWindows7ToolBar(Bitmap: TBGRABitmap);
+
+procedure Register;
+
+implementation
+
+procedure DrawWindows7ToolBar(Bitmap: TBGRABitmap);
+var
+  c1, c2, c3, c4: TBGRAPixel;
+  ARect, ARect2: TRect;
+begin
+  ARect := Rect(0, 0, Bitmap.Width, Bitmap.Height);
+  // Font: RGBToColor(30,57,91)
+  Bitmap.Canvas.Pen.Color := RGBToColor(169, 191, 214);
+  Bitmap.Canvas.Line(ARect.Left, ARect.Top, ARect.Right, ARect.Top);
+
+  Bitmap.Canvas.Pen.Color := RGBToColor(250, 252, 253);
+  Bitmap.Canvas.Line(ARect.Left, ARect.Top + 1, ARect.Right, ARect.Top + 1);
+
+  Bitmap.Canvas.Pen.Color := RGBToColor(253, 254, 255);
+  Bitmap.Canvas.Line(ARect.Left, ARect.Top + 2, ARect.Right, ARect.Top + 2);
+
+  c1 := BGRA(252, 254, 255);
+  c2 := BGRA(243, 248, 253);
+  c3 := BGRA(238, 243, 250);
+  c4 := BGRA(238, 244, 251);
+  ARect2 := Rect(ARect.Left, ARect.Top + 3, ARect.Right, ARect.Bottom - 3);
+  DoubleGradientAlphaFill(Bitmap, ARect2, c1, c2, c3, c4, gdVertical,
+    gdVertical, gdVertical, 0.5);
+
+  c1 := BGRA(249, 252, 255);
+  c2 := BGRA(230, 240, 250);
+  c3 := BGRA(220, 230, 244);
+  c4 := BGRA(221, 233, 247);
+  ARect2 := Rect(ARect.Left + 1, ARect.Top + 3, ARect.Right - 1, ARect.Bottom - 3);
+  DoubleGradientAlphaFill(Bitmap, ARect2, c1, c2, c3, c4, gdVertical,
+    gdVertical, gdVertical, 0.5);
+
+  Bitmap.Canvas.Pen.Color := RGBToColor(228, 239, 251);
+  Bitmap.Canvas.Line(ARect.Left, ARect.Bottom - 3, ARect.Right, ARect.Bottom - 3);
+
+  Bitmap.Canvas.Pen.Color := RGBToColor(205, 218, 234);
+  Bitmap.Canvas.Line(ARect.Left, ARect.Bottom - 2, ARect.Right, ARect.Bottom - 2);
+
+  Bitmap.Canvas.Pen.Color := RGBToColor(160, 175, 195);
+  Bitmap.Canvas.Line(ARect.Left, ARect.Bottom - 1, ARect.Right, ARect.Bottom - 1);
+end;
+
+procedure Register;
+begin
+  RegisterComponents('BGRA Controls',[TBCToolBar]);
+end;
+
+{ TBCToolBar }
+
+constructor TBCToolBar.Create(TheOwner: TComponent);
+begin
+  inherited Create(TheOwner);
+  FBGRA := TBGRABitmap.Create;
+end;
+
+destructor TBCToolBar.Destroy;
+begin
+  FBGRA.Free;
+  inherited Destroy;
+end;
+
+procedure TBCToolBar.Paint;
+begin
+  if (FBGRA.Width <> Width) or (FBGRA.Height <> Height) then
+    FBGRA.SetSize(Width, Height);
+  if Assigned(FOnRedraw) then
+    FOnRedraw(self, FBGRA);
+  FBGRA.Draw(Canvas, 0, 0);
+end;
+
+end.

+ 6 - 1
bgracontrols.lpk

@@ -27,7 +27,7 @@
       </Other>
       </Other>
     </CompilerOptions>
     </CompilerOptions>
     <Version Major="3" Minor="5"/>
     <Version Major="3" Minor="5"/>
-    <Files Count="39">
+    <Files Count="40">
       <Item1>
       <Item1>
         <Filename Value="bcbasectrls.pas"/>
         <Filename Value="bcbasectrls.pas"/>
         <UnitName Value="BCBaseCtrls"/>
         <UnitName Value="BCBaseCtrls"/>
@@ -213,6 +213,11 @@
         <HasRegisterProc Value="True"/>
         <HasRegisterProc Value="True"/>
         <UnitName Value="BCTrackbarUpdown"/>
         <UnitName Value="BCTrackbarUpdown"/>
       </Item39>
       </Item39>
+      <Item40>
+        <Filename Value="bctoolbar.pas"/>
+        <HasRegisterProc Value="True"/>
+        <UnitName Value="BCToolBar"/>
+      </Item40>
     </Files>
     </Files>
     <Type Value="RunAndDesignTime"/>
     <Type Value="RunAndDesignTime"/>
     <RequiredPkgs Count="3">
     <RequiredPkgs Count="3">

+ 2 - 1
bgracontrols.pas

@@ -15,7 +15,7 @@ uses
   BGRAVirtualScreen, DTAnalogClock, DTAnalogCommon, DTAnalogGauge, 
   BGRAVirtualScreen, DTAnalogClock, DTAnalogCommon, DTAnalogGauge, 
   dtthemedclock, dtthemedgauge, uEKnob, ueled, uEMultiTurn, uERotImage, 
   dtthemedclock, dtthemedgauge, uEKnob, ueled, uEMultiTurn, uERotImage, 
   uESelector, BGRAPascalScript, uPSI_BGRAPascalScript, BCTrackbarUpdown, 
   uESelector, BGRAPascalScript, uPSI_BGRAPascalScript, BCTrackbarUpdown, 
-  LazarusPackageIntf;
+  BCToolBar, LazarusPackageIntf;
 
 
 implementation
 implementation
 
 
@@ -49,6 +49,7 @@ begin
   RegisterUnit('uESelector', @uESelector.Register);
   RegisterUnit('uESelector', @uESelector.Register);
   RegisterUnit('uPSI_BGRAPascalScript', @uPSI_BGRAPascalScript.Register);
   RegisterUnit('uPSI_BGRAPascalScript', @uPSI_BGRAPascalScript.Register);
   RegisterUnit('BCTrackbarUpdown', @BCTrackbarUpdown.Register);
   RegisterUnit('BCTrackbarUpdown', @BCTrackbarUpdown.Register);
+  RegisterUnit('BCToolBar', @BCToolBar.Register);
 end;
 end;
 
 
 initialization
 initialization

+ 91 - 0
test/test_bccontrols/test_bctoolbar/test_bctoolbar.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_bctoolbar"/>
+      <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_bctoolbar.lpr"/>
+        <IsPartOfProject Value="True"/>
+        <UnitName Value="test_bctoolbar"/>
+      </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_bctoolbar"/>
+    </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_bctoolbar/test_bctoolbar.lpr

@@ -0,0 +1,21 @@
+program test_bctoolbar;
+
+{$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.
+

+ 25 - 0
test/test_bccontrols/test_bctoolbar/umain.lfm

@@ -0,0 +1,25 @@
+object Form1: TForm1
+  Left = 357
+  Height = 240
+  Top = 179
+  Width = 320
+  Caption = 'BCToolBar'
+  ClientHeight = 240
+  ClientWidth = 320
+  LCLVersion = '1.2.6.0'
+  object BCToolBar1: TBCToolBar
+    Left = 0
+    Height = 26
+    Top = 0
+    Width = 320
+    Caption = 'BCToolBar1'
+    ShowCaptions = True
+    TabOrder = 0
+    OnRedraw = BCToolBar1Redraw
+    object ToolButton1: TToolButton
+      Left = 1
+      Top = 2
+      Caption = 'ToolButton1'
+    end
+  end
+end

+ 39 - 0
test/test_bccontrols/test_bctoolbar/umain.pas

@@ -0,0 +1,39 @@
+unit umain;
+
+{$mode objfpc}{$H+}
+
+interface
+
+uses
+  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls,
+  BCToolBar, BGRABitmap;
+
+type
+
+  { TForm1 }
+
+  TForm1 = class(TForm)
+    BCToolBar1: TBCToolBar;
+    ToolButton1: TToolButton;
+    procedure BCToolBar1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
+  private
+    { private declarations }
+  public
+    { public declarations }
+  end;
+
+var
+  Form1: TForm1;
+
+implementation
+
+{$R *.lfm}
+
+{ TForm1 }
+
+procedure TForm1.BCToolBar1Redraw(Sender: TObject; Bitmap: TBGRABitmap);
+begin
+  DrawWindows7ToolBar(Bitmap);
+end;
+
+end.