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

📄 jvglabeleditorform.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 2 页
字号:
        FLabel.Colors.BackgroundActive := GetItemsColor(Items, ItemIndex, FLabel.Colors.BackgroundActive);
      8:
        FLabel.Colors.Delineate := GetItemsColor(Items, ItemIndex, FLabel.Colors.Delineate);
      9:
        FLabel.Colors.DelineateActive := GetItemsColor(Items, ItemIndex, FLabel.Colors.DelineateActive);
    end;
  end;
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.sbarGradientPercentFillingChange(Sender: TObject);
begin
  if Sender is TScrollBar then
  begin
    FLabel.Gradient.PercentFilling := TScrollBar(Sender).Position;
    lblGradientPercentFilling.Caption := IntToStr(TScrollBar(Sender).Position);
    LabelChanged;
  end;
end;

procedure TJvgLabelEditorDlg.cbtnGradientColorFromChange(Sender: TObject);
begin
  with TComboBox(Sender)do
    case Tag of
    1:
      FLabel.Gradient.FromColor := GetItemsColor(Items, ItemIndex, FLabel.Gradient.FromColor);
    2:
      FLabel.Gradient.ToColor := GetItemsColor(Items, ItemIndex, FLabel.Gradient.ToColor);
  end;
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxGradientActiveClick(Sender: TObject);
begin
  FLabel.Gradient.Active := TCheckBox(Sender).Checked;
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxGradientBufferedDrawClick(Sender: TObject);
begin
  FLabel.Gradient.BufferedDraw := TCheckBox(Sender).Checked;
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxGradientOrientationChange(Sender: TObject);
begin
  with FLabel.Gradient do
    case TComboBox(Sender).ItemIndex of
      0:
        Orientation := fgdHorizontal;
      1:
        Orientation := fgdVertical;
      2:
        Orientation := fgdLeftBias;
      3:
        Orientation := fgdRightBias;
      4:
        Orientation := fgdRectangle;
      5:
        Orientation := fgdVertConvergent;
      6:
        Orientation := fgdVertConvergent;
    end;
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.sbtnLabelDirectionRightClick(Sender: TObject);
begin
  FLabel.Direction := TglLabelDir(TSpeedButton(Sender).Tag);
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxBrushStyleChange(Sender: TObject);
begin
  FLabel.Gradient.BrushStyle := TBrushStyle(TComboBox(Sender).ItemIndex);
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.btnNewTextureImageClick(Sender: TObject);
begin
  if OpenPictureDialog1.Execute then
  begin
    case TSpeedButton(Sender).Tag of
      0:
        begin
          imgBackground.Picture.LoadFromFile(OpenPictureDialog1.FileName);
          if cbxActiveBackground.Checked then
            FLabel.Background := imgBackground.Picture.Bitmap;
        end;
      1:
        begin
          imgTexture.Picture.LoadFromFile(OpenPictureDialog1.FileName);
          if cbxActiveTexture.Checked then
            FLabel.Texture := imgTexture.Picture.Bitmap;
        end;
    end;
  end;
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxActiveBackgroundClick(Sender: TObject);
begin
  case TCheckBox(Sender).Tag of
    0:
      if TCheckBox(Sender).Checked then
        FLabel.Background := imgBackground.Picture.Bitmap
      else
        FLabel.Background := nil;
    1:
      if TCheckBox(Sender).Checked then
        FLabel.Texture := imgTexture.Picture.Bitmap
      else
        FLabel.Texture := nil;
  end;
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.sbarShadowDepthChange(Sender: TObject);
begin
  FLabel.Illumination.ShadowDepth := sbarShadowDepth.Position;
  lblShadowDepth.Caption := IntToStr(sbarShadowDepth.Position);
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxFontChange(Sender: TObject);
begin
  FLabel.Font.Name := TFontName(cbxFont.Items[cbxFont.ItemIndex]);
  LabelChanged;
end;

function TJvgLabelEditorDlg.UpdateComponent: Boolean;
begin
  inherited UpdateComponent;
  with FLabelSource do
  begin
    if (FLabel.Background <> nil) and (cbxActiveBackground.Checked) then
      Background.Assign(FLabel.Background)
    else
      Background := nil;

    if (imgTexture.Picture <> nil) and (cbxActiveTexture.Checked) then
      Texture.Assign(FLabel.Texture)
    else
      Texture := nil;

    Colors.Background := FLabel.Colors.Background;
    Colors.BackgroundActive := FLabel.Colors.BackgroundActive;
    Colors.Delineate := FLabel.Colors.Delineate;
    Colors.DelineateActive := FLabel.Colors.DelineateActive;
    Colors.HighLight := FLabel.Colors.HighLight;
    Colors.Shadow := FLabel.Colors.Shadow;
    Colors.Text := FLabel.Colors.Text;
    Colors.TextActive := FLabel.Colors.TextActive;
    Colors.TextDisabled := FLabel.Colors.TextDisabled;

    Direction := FLabel.Direction;

    Font.Name := FLabel.Font.Name;
    Font.Size := FLabel.Font.Size;
    Font.Style := FLabel.Font.Style;

    Gradient.Active := FLabel.Gradient.Active;
    Gradient.BrushStyle := FLabel.Gradient.BrushStyle;
    Gradient.BufferedDraw := FLabel.Gradient.BufferedDraw;
    Gradient.FromColor := FLabel.Gradient.FromColor;
    Gradient.Orientation := FLabel.Gradient.Orientation;
    Gradient.PercentFilling := FLabel.Gradient.PercentFilling;
    Gradient.ToColor := FLabel.Gradient.ToColor;

    Illumination.ShadowDepth := FLabel.Illumination.ShadowDepth;
    TextStyles.Active := FLabel.TextStyles.Active;
    TextStyles.Disabled := FLabel.TextStyles.Disabled;
    TextStyles.Passive := FLabel.TextStyles.Passive;
  end;
  Result := True;
end;

constructor TJvgLabelEditorDlg.Create(AOwner: TComponent; LabelSource: TJvgLabel);
begin
  inherited Create(AOwner);
  FLabel := TJvgLabel.Create(Self);
  FLabel.Align := alClient;
  FLabel.Caption := 'JvLabelTest';
  FLabel.Parent := pnlPanel1;
  FLabelSource := LabelSource;
end;

procedure TJvgLabelEditorDlg.InitializeEditor;
begin
  inherited InitializeEditor;
  // loading from Resource file save ~ 200K in DFM file
  imglBrushes.ResInstLoad(HInstance, rtBitmap, 'JvgLabelEditorDlgBRUSH', clFuchsia);
  sbtnLabelDirectionDown.Glyph.LoadFromResourceName(HInstance, 'JvgLabelEditorDlgDOWN');
  sbtnLabelDirectionUp.Glyph.LoadFromResourceName(HInstance, 'JvgLabelEditorDlgUP');
  sbtnLabelDirectionRight.Glyph.LoadFromResourceName(HInstance, 'JvgLabelEditorDlgRIGHT');
  sbtnLabelDirectionLeft.Glyph.LoadFromResourceName(HInstance, 'JvgLabelEditorDlgLEFT');

  // Square Checkboxes

  sbarFontSize.Position := FLabelSource.Font.Size;
  sbarShadowDepth.Position := FLabelSource.Illumination.ShadowDepth;
  with FLabelSource.Colors do
  begin
    cbtnText.ItemIndex := SetItemsColor(cbtnText.Items, Text);
    cbtnTextActive.ItemIndex := SetItemsColor(cbtnTextActive.Items, TextActive);
    cbtnTextDisabled.ItemIndex := SetItemsColor(cbtnTextDisabled.Items, TextDisabled);
    cbtnHighlight.ItemIndex := SetItemsColor(cbtnHighlight.Items, HighLight);
    cbtnShadow.ItemIndex := SetItemsColor(cbtnShadow.Items, Shadow);
    cbtnBackground.ItemIndex := SetItemsColor(cbtnBackground.Items, Background);
    cbtnBackgroundActive.ItemIndex := SetItemsColor(cbtnBackgroundActive.Items, BackgroundActive);
    cbtnDelineate.ItemIndex := SetItemsColor(cbtnDelineate.Items, Delineate);
    cbtnDelineateActive.ItemIndex := SetItemsColor(cbtnDelineateActive.Items, DelineateActive);
  end;
  cbxBold.Checked := fsBold in FLabelSource.Font.Style;
  cbxItalic.Checked := fsItalic in FLabelSource.Font.Style;
  cbxUnderline.Checked := fsUnderline in FLabelSource.Font.Style;
  cbxStrikeOut.Checked := fsStrikeOut in FLabelSource.Font.Style;

  case Integer(FLabelSource.TextStyles.Active) of
    0:
      cbxActiveNormal.Checked := True;
    1:
      cbxActiveRaised.Checked := True;
    2:
      cbxActiveRecessed.Checked := True;
    3:
      cbxActivePushed.Checked := True;
    4:
      cbxActiveShadow.Checked := True;
    5:
      cbxActiveVolumetric.Checked := True;
  end;

  case Integer(FLabelSource.TextStyles.Passive) of
    0:
      cbxPassiveNormal.Checked := True;
    1:
      cbxPassiveRaised.Checked := True;
    2:
      cbxPassiveRecessed.Checked := True;
    3:
      cbxPassivePushed.Checked := True;
    4:
      cbxPassiveShadow.Checked := True;
    5:
      cbxPassiveVolumentric.Checked := True;
  end;

  case Integer(FLabelSource.TextStyles.Disabled) of
    0:
      cbxDisabledNormal.Checked := True;
    1:
      cbxDisabledRaised.Checked := True;
    2:
      cbxDisabledRecessed.Checked := True;
    3:
      cbxDisabledPushed.Checked := True;
    4:
      cbxDisabledShadow.Checked := True;
    5:
      cbxDisabledVolumentric.Checked := True;
  end;

  cbxGradientActive.Checked := FLabelSource.Gradient.Active;
  cbxGradientBufferedDraw.Checked := FLabelSource.Gradient.BufferedDraw;
  cbxBrushStyle.ItemIndex := Integer(FLabelSource.Gradient.BrushStyle);

  cbtnGradientColorFrom.ItemIndex := SetItemsColor(cbtnGradientColorFrom.Items,FLabelSource.Gradient.FromColor);
  cbtnGradientColorTo.ItemIndex := SetItemsColor(cbtnGradientColorFrom.Items,FLabelSource.Gradient.ToColor);
  cbxGradientOrientation.ItemIndex := Integer(FLabelSource.Gradient.Orientation);
  sbarGradientPercentFilling.Position := Integer(FLabelSource.Gradient.PercentFilling);
  cbxFont.ItemIndex := cbxFont.Items.IndexOf(FLabelSource.Font.Name);

  if FLabelSource.Background <> nil then
  begin
    imgBackground.Picture.Bitmap.Assign(FLabelSource.Background);
    FLabel.Background.Assign(imgBackground.Picture.Bitmap);
  end;

  if FLabelSource.Texture <> nil then
  begin
    imgTexture.Picture.Bitmap.Assign(FLabelSource.Texture);
    FLabel.Texture.Assign(imgTexture.Picture.Bitmap);
  end;

  LabelChanged;
end;

procedure TJvgLabelEditorDlg.FormCreate(Sender: TObject);
begin
  cbxFont.Items := Screen.Fonts;
  cbxFont.Sorted := True;
end;

procedure TJvgLabelEditorDlg.AfterConstruction;
var
  I: Integer;
begin
  for I := 0 to ComponentCount - 1 do
    if (Components[I].Tag > 0) and (Components[I] is TComboBox) then
      SetColors(TComboBox(Components[I]).Items);
end;

procedure TJvgLabelEditorDlg.GetColorValuesProc(const S: string);
var
  AColor: Longint;
begin
  if FColorItems <> nil then
  begin
    IdentToColor(S, AColor);
    FColorItems.AddObject(Copy(S, 3, MaxInt), TObject(AColor));
  end;
end;

procedure TJvgLabelEditorDlg.SetColors(Items: TStrings);
begin
  FColorItems := Items;
  try
    GetColorValues(GetColorValuesProc);
  finally
    FColorItems := nil;
  end;
end;

function TJvgLabelEditorDlg.SetItemsColor(Items: TStrings;
  AColor: TColor): Integer;
var
  AIdent: string;
begin
  Result := Items.IndexOfObject(TObject(AColor));
  if Result < 0 then
  begin
    ColorToIdent(AColor, AIdent);
    Result := Items.IndexOf(Copy(AIdent, 3, MaxInt));
  end;
end;

function TJvgLabelEditorDlg.GetItemsColor(Items: TStrings;
  ItemIndex: Integer; ADefault: TColor): TColor;
begin
  if ItemIndex < 0 then
    Result := ADefault
  else
    Result := TColor(Items.Objects[ItemIndex]);
end;

end.

⌨️ 快捷键说明

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