⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 demoutils.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
字号:
unit DemoUtils;

{$I ..\cxVer.inc}

interface

uses
  {$IFDEF DELPHI6}Types,{$ENDIF} Windows, Graphics, DB;

type
  TCustomDrawingStyle = (cdsBkImage, cdsGradient, cdsDependOnData, cdsDefaultDrawing);
  TCustomDrawArea = (cdaCell, cdaColumnHeader, cdaFooterCell, cdaGroupCell, cdaIndicatorCell, cdaPartBackGround);
  TViewType = (vtMaster, vtDetail);
  TColorScheme = (csGrey, csGold, csBlue, csGreen);

  TBkImage = (bkiTile, bkiSky, bkiEgypt, bkiMyFace, bkiUserDefined);
  TBkImages = array [0..1, 0..5] of TBkImage;

  TColorSchemes = array [0..1, 0..5] of TColorScheme;
  TColorSchemeArr = array [0..3, 0..2] of TColor;
  TCustomDrawingStyleArr = array [0..1, 0..5] of TCustomDrawingStyle;
  TUserDefinedBitMaps = array [0..1, 0..5] of TBitmap;
  TFonts = array [0..1, 0..5] of TFont;
  TCustomDrawItem = class
    ViewType: TViewType;
    CustomDrawArea: TCustomDrawArea;
  end;

const
  clBlueDark = TColor($00C56A31);
  clBlueLight = TColor($00F7EAD9);
  clBlueBright = TColor($00FF953D);
  clBlueSky = TColor($00EBC4A4);

  clGold = TColor($0047D5FE);
  clGoldDark = TColor($0001BDF3);

  clGreyLight = TColor($00E2EFF1);
  clGreyDark = TColor($00B9D9DD);
  clYellowLight = TColor($00E1FFFF);

  clGreenBright = TColor($0082E887);
  clGreenLight = TColor($00C9F5CB);
  clGreenObscured = TColor($00ACF0AF);
  clGreenDark = TColor($0044DD4B);

  clSilverDark = TColor($00A6A6A6);

  ColorScheme : TColorSchemeArr  = ((clSilver, clWhite, clGray),(clGold, clGreyLight, clGoldDark),(clBlueDark, clBlueLight, clBlueDark),(clGreenDark, clGreenLight, clGreen));

procedure DrawGradient(Canvas: TCanvas; const ARect: TRect;
  FromColor, ToColor: TColor; AStepCount: Integer; IsVertical: Boolean = False);
procedure LoadImageFromRes(ABitmap: TBitMap; AResName: String);
procedure SetStringFieldValue(AField: TStringField; AValue: string);

implementation

uses
  SysUtils, Classes, cxEditPaintUtils;

procedure DrawGradient(Canvas: TCanvas; const ARect: TRect;
  FromColor, ToColor: TColor; AStepCount: Integer; IsVertical: Boolean = False);
var
  SR: TRect;
  H, I: Integer;
  R, G, B: Byte;
  FromR, ToR, FromG, ToG, FromB, ToB: Byte;
begin
  FromR := GetRValue(FromColor);
  FromG := GetGValue(FromColor);
  FromB := GetBValue(FromColor);
  ToR := GetRValue(ToColor);
  ToG := GetGValue(ToColor);
  ToB := GetBValue(ToColor);
  SR := ARect;
  with ARect do
    if IsVertical then
      H := Bottom - Top
    else
      H := Right - Left;

  for I := 0 to AStepCount - 1 do
  begin
    if IsVertical then
      SR.Bottom := ARect.Top + MulDiv(I + 1, H, AStepCount)
    else
      SR.Right := ARect.Left + MulDiv(I + 1, H, AStepCount);
    with Canvas do
    begin
      R := FromR + MulDiv(I, ToR - FromR, AStepCount - 1);
      G := FromG + MulDiv(I, ToG - FromG, AStepCount - 1);
      B := FromB + MulDiv(I, ToB - FromB, AStepCount - 1);
      Brush.Color := RGB(R, G, B);
      FillRect(SR);
    end;
    if IsVertical then
      SR.Top := SR.Bottom
    else
      SR.Left := SR.Right;
  end;
end;

procedure LoadImageFromRes(ABitmap: TBitMap; AResName: String);
var
  Rs: TResourceStream;
  BitMap: TBitMap;
begin
  BitMap := TBitMap.Create;
  Rs := TResourceStream.Create(hInstance, AResName, RT_RCDATA);
  try
    BitMap.LoadFromStream(Rs);
    ABitMap.Assign(BitMap);
  finally
    BitMap.Free;
    Rs.Free;
  end;
end;

procedure SetStringFieldValue(AField: TStringField; AValue: string);
begin
  AField.Value := AValue;
end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -