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

📄 bscolorctrls.pas

📁 BusinessSkinForm.v5.60 网上能找到的最新版。
💻 PAS
📖 第 1 页 / 共 5 页
字号:
      HSLPSP := PSPColor.HSLPSP;
      HSLPSP.S := Round(255 * ((C_X - (PosCar + RectPSP.Left)) / (RectPSP.Right - RectPSP.Left)));
      HSLPSP.L := Round(255 * ((C_Y - RectPSP.Top) / (RectPSP.Bottom-RectPSP.Top)));
      DrawCursor;
      PSPColor.HSLPSP := HSLPSP;
      ChangeEdits;
      DrawCursor;
      PalettePSP.Repaint;
    end;
  end;
  ClickImg := czpspPnone;
end;

constructor TbsSkinCustomColorGrid.Create(AOwner: TComponent);
var
  i: Integer;
begin
  inherited;
  ControlStyle := ControlStyle - [csAcceptsControls];
  FForceBackground := False;
  CaptionMode := True;
  Caption := BS_CUSTOMCOLORGRID_CAP;
  BorderStyle := bvFrame;
  Width := 280;
  Height := 115;
  FColorValue := 0;
  FColCount := 6;
  FRowCount := 2;
  for i := 1 to 12 do CustomColorValues[I] := clWhite;
  FColorsCount := 0;
  FColorIndex := 0;
end;

destructor TbsSkinCustomColorGrid.Destroy;
begin
  inherited;
end;

procedure TbsSkinCustomColorGrid.PaintTransparent;
begin
  PaintGrid(C);
end;


procedure TbsSkinCustomColorGrid.WMEraseBkgnd;
begin
  if not FromWMPaint
  then
    begin
      PaintWindow(Msg.DC);
    end;
end;

procedure TbsSkinCustomColorGrid.AddColor(AColor: TColor);
begin
  if FColorsCount = 12 then FColorsCount := 0;
  Inc(FColorsCount);
  CustomColorValues[FColorsCount] := AColor;
  RePaint;
end;

procedure TbsSkinCustomColorGrid.SetColCount(Value: Integer);
begin
  if Value < 1 then Exit;
  FColCount := Value;
  RePaint;
end;

procedure TbsSkinCustomColorGrid.SetRowCount(Value: Integer);
begin
  FRowCount := Value;
  RePaint;
end;

procedure TbsSkinCustomColorGrid.DrawCursor;
var
  CX, CY, Rd: Integer;
begin
  CX := R.Left + RectWidth(R) div 2;
  CY := R.Top + RectHeight(R) div 2;
  if RectWidth(R) > RectHeight(R)
  then
    Rd := RectHeight(R) div 2 - 2
  else
    Rd := RectWidth(R) div 2 - 2;
  with Cnvs do
  begin
    if pmNotMode then Pen.Mode := pmNot else Pen.Color := 0;
    MoveTo(CX - rd, CY); LineTo(CX - 2, CY);
    MoveTo(CX + 3, CY); LineTo(CX + rd + 1, CY);
    MoveTo(CX, CY - rd); LineTo(CX, CY - 2);
    MoveTo(CX, CY + 3); LineTo(CX, CY + rd);
  end;
end;

procedure TbsSkinCustomColorGrid.PaintGrid(Cnvs: TCanvas);
var
  RX, RY, X, Y, CW, CH, i, j, k: Integer;
  R, R1, Rct: TRect;
begin
  R := Rect(0, 0, Width, Height);
  AdjustClientRect(R);
  CW := (RectWidth(R) - ColCount * 2) div ColCount;
  CH := (RectHeight(R) - RowCount * 2) div RowCount;

  R1 := Rect(0, 0, (CW + 2) * ColCount, (CH + 2) * RowCount);
  RX := R.Left + RectWidth(R) div 2 - RectWidth(R1) div 2;
  RY := R.Top + RectHeight(R) div 2 - RectHeight(R1) div 2;
  R := Rect(RX, RY, RX + RectWidth(R1), RectHeight(R1));

  Y := R.Top + 1;
  k := 0;
  for i := 1 to RowCount do
  begin
    X := R.Left + 1;
    for j := 1 to ColCount do
    begin
      Inc(k);
      with Cnvs do
      begin
        Brush.Color := CustomColorValues[k];
        Rct := Rect(X, Y, X + CW, Y + CH);
        InflateRect(Rct, -1, -1);
        FillRect(Rct);
        InflateRect(Rct, 1, 1);
        if k = FColorIndex  
        then
          begin
            if CustomColorValues[k] <> clGray
            then
              DrawCursor(Cnvs, Rct, True)
            else
              DrawCursor(Cnvs, Rct, False);
          end
      end;
      Inc(X, CW + 2);
    end;
    Inc(Y, CH + 2);
  end;
end;

procedure TbsSkinCustomColorGrid.CreateControlDefaultImage;
begin
  inherited;
  PaintGrid(B.Canvas);
end;

procedure TbsSkinCustomColorGrid.CreateControlSkinImage;
begin
  inherited;
  PaintGrid(B.Canvas);
end;

procedure TbsSkinCustomColorGrid.MouseDown(Button: TMouseButton; Shift: TShiftState;
                                     X, Y: Integer);
var
  RX, RY, X1, Y1, CW, CH, i, j, k: Integer;
  R, R1, Rct: TRect;
begin
  inherited;
  R := Rect(0, 0, Width, Height);
  AdjustClientRect(R);
  CW := (RectWidth(R) - ColCount * 2) div ColCount;
  CH := (RectHeight(R) - RowCount * 2) div RowCount;

  R1 := Rect(0, 0, (CW + 2) * ColCount, (CH + 2) * RowCount);
  RX := R.Left + RectWidth(R) div 2 - RectWidth(R1) div 2;
  RY := R.Top + RectHeight(R) div 2 - RectHeight(R1) div 2;
  R := Rect(RX, RY, RX + RectWidth(R1), RectHeight(R1));

  Y1 := R.Top + 1;
  k := 0;
  for i := 1 to RowCount do
  begin
    X1 := R.Left + 1;
    for j := 1 to ColCount do
    begin
      Inc(k);
      Rct := Rect(X1, Y1, X1 + CW, Y1 + CH);
      if PtInRect(Rct, Point(X, Y))
      then
        begin
          FColorValue := CustomColorValues[k];
          FColorIndex := k;
          RePaint;
          if Assigned(FOnChange) then FOnChange(Self);
          Break;
        end;
      Inc(X1, CW + 2);
    end;
    Inc(Y1, CH + 2);
  end;  
end;

constructor TbsSkinColorButton.Create(AOwner: TComponent);
begin
  inherited;
  FDrawColorMarker := True;
  ColorDialog := nil;
  FColorMarkerValue := 0;
  FColorImages := TCustomImageList.Create(Self);
  FColorMenu := TbsSkinImagesMenu.Create(Self);
  FColorMenu.Images := FColorImages;
  FColorMenu.OnItemClick := OnImagesMenuClick;
  FColorMenu.OnMenuPopup := OnImagesMenuPopup;
  FAutoColor := 0;
  FShowAutoColor := True;
  FShowMoreColor := True;
  InitColors;
end;

procedure TbsSkinColorButton.SetShowAutoColor(Value: Boolean);
begin
  if FShowAutoColor <> Value
  then
    begin
      FShowAutoColor := Value;
      if not (csDesigning in ComponentState) and
         not (csLoading in ComponentState)
      then
        InitColors;
    end;
end;

procedure TbsSkinColorButton.SetShowMoreColor(Value: Boolean);
begin
  if FShowMoreColor <> Value
  then
    begin
      FShowMoreColor := Value;
      if not (csDesigning in ComponentState) and
         not (csLoading in ComponentState)
      then
        InitColors;
    end;
end;


procedure TbsSkinColorButton.SetColorValue;
begin
  FColorMarkerValue := Value;
  RePaint;
  if not (csDesigning in ComponentState) and
     not (csLoading in ComponentState)
  then
    if Assigned(FOnChangeColor) then FOnChangeColor(Self);
end;

procedure TbsSkinColorButton.InitColors;
var
  B: TBitMap;
  Item: TbsImagesMenuItem;
  I: Integer;
begin
  //
  FSkinImagesMenu := FColorMenu;
  FSkinPopupMenu := nil;
  //
  if FColorImages.Count <> 0 then FColorImages.Clear;
  if FColorMenu.ImagesItems.Count <> 0 then FColorMenu.ImagesItems.Clear;
  // init menu
  FColorMenu.ColumnsCount := 8;
  FColorMenu.SkinData := Self.SkinData;
  FColorMenu.ItemIndex := 0;
  // 1
  if FShowAutoColor
  then
    begin
      Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
      with Item do
      begin
        ImageIndex := 0;
        FColor := FAutoColor;
        if (FColorMenu.SkinData <> nil) and
           (FColorMenu.SkinData.ResourceStrData <> nil)
        then
          Caption := FColorMenu.SkinData.ResourceStrData.GetResStr('AUTOCOLOR')
        else
          Caption := BS_AUTOCOLOR;
        Button := True;
      end;
    end;
  // 2
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 1;
    FColor := clBlack;
  end;
  // 3
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 2;
    FColor := $00003399;;
  end;
  // 4
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 3;
    FColor := $00003333;
  end;
  // 5
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 4;
    FColor := $00003300;
  end;
  // 6
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 5;
    FColor := $00663300;
  end;
  // 7
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 6;
    FColor := clNavy;
  end;
  // 8
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 7;
    FColor := $00353333;
  end;
  // 9
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 8;
    FColor := $00333333;
  end;
  // 10
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 9;
    FColor := RGB(128, 0, 0);
  end;
  // 11
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 10;
    FColor := RGB(255, 102, 0);
  end;
  // 12
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 11;
    FColor := RGB(128, 128, 0);
  end;
  // 13
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 12;
    FColor := RGB(0, 128, 0);
  end;
  // 14
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 13;
    FColor := RGB(0, 128, 128);
  end;
  // 15
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 14;
    FColor := RGB(0, 0, 255);
  end;
  // 16
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 15;
    FColor := RGB(102, 102, 153);
  end;
  // 17
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 16;
    FColor := RGB(128, 128, 128);
  end;
  // 18
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 17;
    FColor :=  RGB(255, 0, 0);
  end;
  // 19
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 18;
    FColor :=  RGB(255, 153, 0);
  end;
  // 20
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 19;
    FColor :=  RGB(153, 204, 0);
  end;
  // 21
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 20;
    FColor := RGB(51, 153, 102);
  end;
  // 22
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 21;
    FColor := RGB(51, 204, 204);
  end;
  // 23
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 22;
    FColor := RGB(51, 102, 255);
  end;
  // 24
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 23;
    FColor := RGB(128, 0, 128);
  end;
  // 25
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 24;
    FColor := RGB(153, 153, 153);
  end;
  // 26
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 25;
    FColor := RGB(255, 0, 255);
  end;
  // 27
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 26;
    FColor := RGB(255, 204, 0);
  end;
  // 28
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 27;
    FColor := RGB(255, 255, 0);
  end;
  // 29
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 28;
    FColor := RGB(0, 255, 0);
  end;
  // 30
  Item := TbsImagesMenuItem(FColorMenu.ImagesItems.Add);
  with Item do
  begin
    ImageIndex := 29;
    FColor := RGB(0, 255, 255);
  end;
  // 31
  Item := TbsImagesMenuItem(FColorMenu.ImagesI

⌨️ 快捷键说明

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