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

📄 jvglabeleditorform.pas

📁 East make Tray Icon in delphi
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{-----------------------------------------------------------------------------
The contents of this file are subject to the Mozilla Public License
Version 1.1 (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/MPL-1.1.html

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either expressed or implied. See the License for
the specific language governing rights and limitations under the License.

The Original Code is: JvgLabelEditor.PAS, released on 2003-01-15.

The Initial Developer of the Original Code is Michael Beck [mbeck att bigfoot dott com]
Portions created by Michael Beck are Copyright (C) 2003 Michael Beck
All Rights Reserved.

Contributor(s):

You may retrieve the latest version of this file at the Project JEDI's JVCL home page,
located at http://jvcl.sourceforge.net

Known Issues:
-----------------------------------------------------------------------------}
// $Id: JvgLabelEditorForm.pas,v 1.20 2005/02/07 07:51:09 marquardt Exp $

unit JvgLabelEditorForm;

{$I jvcl.inc}

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  ImgList, ExtDlgs, ExtCtrls, StdCtrls, Buttons, ComCtrls,
  {$IFDEF COMPILER6_UP}
  DesignIntf, DesignEditors, PropertyCategories,
  {$ELSE}
  DsgnIntf,
  {$ENDIF COMPILER6_UP}
  JvgCompEditorTemplateForm, JvgTypes, JvgLabel;

type
  TJvgLabelEditorDlg = class(TJvgCompEditorTemplate)
    pnlPanel1: TPanel;
    splJvgSplitter1: TSplitter;
    tbsTabSheet1: TTabSheet;
    OpenPictureDialog1: TOpenPictureDialog;
    JvColorDialog1: TColorDialog;
    gbxGradient: TGroupBox;
    JvgLabel11: TLabel;
    lblGradientPercentFilling: TLabel;
    JvgLabel12: TLabel;
    JvgLabel1: TLabel;
    JvgLabel6: TLabel;
    JvgLabel9: TLabel;
    cbxGradientActive: TCheckBox;
    cbxGradientBufferedDraw: TCheckBox;
    cbxGradientOrientation: TComboBox;
    cbtnGradientColorTo: TComboBox;
    cbtnGradientColorFrom: TComboBox;
    sbarGradientPercentFilling: TScrollBar;
    JvgGroupBox3: TGroupBox;
    sbtnBtnNewBackgroundImage: TSpeedButton;
    bvlBevel1: TBevel;
    imgBackground: TImage;
    cbxActiveBackground: TCheckBox;
    JvgGroupBox6: TGroupBox;
    sbtnBtnNewTextureImage: TSpeedButton;
    bvlBevel2: TBevel;
    imgTexture: TImage;
    cbxActiveTexture: TCheckBox;
    JvgGroupBox2: TGroupBox;
    JvgLabel20: TLabel;
    JvgLabel19: TLabel;
    JvgLabel18: TLabel;
    JvgLabel17: TLabel;
    JvgLabel16: TLabel;
    JvgLabel15: TLabel;
    JvgLabel14: TLabel;
    JvgLabel13: TLabel;
    JvgLabel10: TLabel;
    cbtnText: TComboBox;
    cbtnTextActive: TComboBox;
    cbtnTextDisabled: TComboBox;
    cbtnHighlight: TComboBox;
    cbtnShadow: TComboBox;
    cbtnBackground: TComboBox;
    cbtnBackgroundActive: TComboBox;
    cbtnDelineate: TComboBox;
    cbtnDelineateActive: TComboBox;
    gbxPassiveStyle: TGroupBox;
    cbxPassiveNormal: TCheckBox;
    cbxPassivePushed: TCheckBox;
    cbxPassiveRaised: TCheckBox;
    cbxPassiveShadow: TCheckBox;
    cbxPassiveRecessed: TCheckBox;
    cbxPassiveVolumentric: TCheckBox;
    gbxActiveStyle: TGroupBox;
    cbxActiveNormal: TCheckBox;
    cbxActivePushed: TCheckBox;
    cbxActiveRaised: TCheckBox;
    cbxActiveShadow: TCheckBox;
    cbxActiveRecessed: TCheckBox;
    cbxActiveVolumetric: TCheckBox;
    gbxDisabledStyle: TGroupBox;
    cbxDisabledNormal: TCheckBox;
    cbxDisabledPushed: TCheckBox;
    cbxDisabledRaised: TCheckBox;
    cbxDisabledShadow: TCheckBox;
    cbxDisabledRecessed: TCheckBox;
    cbxDisabledVolumentric: TCheckBox;
    JvgGroupBox1: TGroupBox;
    cbxBold: TCheckBox;
    cbxItalic: TCheckBox;
    cbxUnderline: TCheckBox;
    cbxStrikeOut: TCheckBox;
    gbxLabelDirection: TGroupBox;
    sbtnLabelDirectionDown: TSpeedButton;
    sbtnLabelDirectionUp: TSpeedButton;
    JvgLabel5: TLabel;
    sbtnLabelDirectionLeft: TSpeedButton;
    sbtnLabelDirectionRight: TSpeedButton;
    JvgGroupBox4: TGroupBox;
    lblFontSize: TLabel;
    lblShadowDepth: TLabel;
    JvgLabel2: TLabel;
    JvgLabel3: TLabel;
    sbarShadowDepth: TScrollBar;
    sbarFontSize: TScrollBar;
    cbxFont: TComboBox;
    imglBrushes: TImageList;
    cbxBrushStyle: TComboBox;
    procedure tbarFontSizeChange(Sender: TObject);
    procedure cbxBoldClick(Sender: TObject);
    procedure cbxItalicClick(Sender: TObject);
    procedure cbxUnderlineClick(Sender: TObject);
    procedure cbxStrikeOutClick(Sender: TObject);
    procedure cbxActiveNormalClick(Sender: TObject);
    procedure cbxPassiveNormalClick(Sender: TObject);
    procedure cbxDisabledNormalClick(Sender: TObject);
    procedure cLabelColorsChange(Sender: TObject);
    procedure sbarGradientPercentFillingChange(Sender: TObject);
    procedure cbtnGradientColorFromChange(Sender: TObject);
    procedure cbxGradientActiveClick(Sender: TObject);
    procedure cbxGradientBufferedDrawClick(Sender: TObject);
    procedure cbxGradientOrientationChange(Sender: TObject);
    procedure sbtnLabelDirectionRightClick(Sender: TObject);
    procedure cbxBrushStyleChange(Sender: TObject);
    procedure btnNewTextureImageClick(Sender: TObject);
    procedure cbxActiveBackgroundClick(Sender: TObject);
    procedure sbarShadowDepthChange(Sender: TObject);
    procedure cbxFontChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    FColorItems: TStrings;
    FLabelSource: TJvgLabel;
    FLabel:TJvgLabel;
    procedure LabelChanged;
    procedure SetTextStyle(TextKind: Integer; TextStyle: TglTextStyle);
    procedure GetColorValuesProc(const S: string);
    procedure SetColors(Items: TStrings);
    function SetItemsColor(Items: TStrings; AColor: TColor): Integer;
    function GetItemsColor(Items: TStrings; ItemIndex: Integer; ADefault: TColor): TColor;
  protected
    function UpdateComponent: Boolean; override;
    procedure InitializeEditor; override;
  public
    constructor Create(AOwner: TComponent; LabelSource: TJvgLabel); reintroduce; overload;
    procedure AfterConstruction; override;
  end;

  TJvgLabelEditor = class(TComponentEditor)
    function GetVerbCount: Integer; override;
    function GetVerb(Index: Integer): string; override;
    procedure ExecuteVerb(Index: Integer); override;
  end;

var
  JvgLabelEditorDlg: TJvgLabelEditorDlg;

implementation

{$IFDEF USEJVCL}
uses
  JvDsgnConsts;
{$ENDIF USEJVCL}

{$R *.dfm}

{$IFDEF MSWINDOWS}
{$R ..\Resources\JvgLabelEditorForm.res}
{$ENDIF MSWINDOWS}
{$IFDEF UNIX}
{$R ../Resources/JvgLabelEditorForm.res}
{$ENDIF UNIX}

{$IFNDEF USEJVCL}
resourcestring
  RsEditLabel = 'Edit &Label...';
{$ENDIF !USEJVCL}

function IntToTextStyle(Tag: Integer): TglTextStyle;
begin
  case Tag of
    0:
      Result := fstNone;
    1:
      Result := fstPushed;
    2:
      Result := fstRaised;
    3:
      Result := fstShadow;
    4:
      Result := fstRecessed;
    5:
      Result := fstVolumetric;
  else
    Result := fstNone;
  end;
end;

procedure TJvgLabelEditor.ExecuteVerb(Index: Integer);
var
  EditorDlg: TJvgLabelEditorDlg;
begin
  case Index of
    0:
      begin
        EditorDlg := TJvgLabelEditorDlg.Create(Application, Component as TJvgLabel);
        try
          if EditorDlg.ShowModal = mrOk then
            Designer.Modified;
        finally
          EditorDlg.Free;
        end;
      end;
  end;
end;

function TJvgLabelEditor.GetVerb(Index: Integer): string;
begin
  case Index of
    0:
      Result := RsEditLabel;
  end;
end;

function TJvgLabelEditor.GetVerbCount: Integer;
begin
  Result := 1;
end;

procedure TJvgLabelEditorDlg.tbarFontSizeChange(Sender: TObject);
begin
  FLabel.Font.Size := sbarFontSize.Position;
  lblFontSize.Caption := IntToStr(sbarFontSize.Position);
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.LabelChanged;
begin
  FLabel.Invalidate;
end;

procedure TJvgLabelEditorDlg.cbxBoldClick(Sender: TObject);
begin
  if cbxBold.Checked then
    FLabel.Font.Style := FLabel.Font.Style + [fsBold]
  else
    FLabel.Font.Style := FLabel.Font.Style - [fsBold];
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxItalicClick(Sender: TObject);
begin
  if cbxItalic.Checked then
    FLabel.Font.Style := FLabel.Font.Style + [fsItalic]
  else
    FLabel.Font.Style := FLabel.Font.Style - [fsItalic];
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxUnderlineClick(Sender: TObject);
begin
  if cbxUnderline.Checked then
    FLabel.Font.Style := FLabel.Font.Style + [fsUnderline]
  else
    FLabel.Font.Style := FLabel.Font.Style - [fsUnderline];
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxStrikeOutClick(Sender: TObject);
begin
  if cbxStrikeOut.Checked then
    FLabel.Font.Style := FLabel.Font.Style + [fsStrikeOut]
  else
    FLabel.Font.Style := FLabel.Font.Style - [fsStrikeOut];
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxActiveNormalClick(Sender: TObject);
begin
  SetTextStyle(0, IntToTextStyle(TCheckBox(Sender).Tag));
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.SetTextStyle(TextKind: Integer; TextStyle: TglTextStyle);
begin
  case Integer(TextKind) of
    0:
      FLabel.TextStyles.Active := TextStyle;
    1:
      FLabel.TextStyles.Disabled := TextStyle;
    2:
      FLabel.TextStyles.Passive := TextStyle;
  end;
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxPassiveNormalClick(Sender: TObject);
begin
  SetTextStyle(1, IntToTextStyle(TCheckBox(Sender).Tag));
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cbxDisabledNormalClick(Sender: TObject);
begin
  SetTextStyle(2, IntToTextStyle(TCheckBox(Sender).Tag));
  LabelChanged;
end;

procedure TJvgLabelEditorDlg.cLabelColorsChange(Sender: TObject);

begin
  with TComboBox(Sender) do
  begin
    case Tag of
      1:
        FLabel.Colors.Text := GetItemsColor(Items, ItemIndex, FLabel.Colors.Text);
      2:
        FLabel.Colors.TextActive := GetItemsColor(Items, ItemIndex, FLabel.Colors.TextActive);
      3:
        FLabel.Colors.TextDisabled := GetItemsColor(Items, ItemIndex, FLabel.Colors.TextDisabled);
      4:
        FLabel.Colors.HighLight := GetItemsColor(Items, ItemIndex, FLabel.Colors.HighLight);
      5:
        FLabel.Colors.Shadow := GetItemsColor(Items, ItemIndex, FLabel.Colors.Shadow);
      6:
        FLabel.Colors.Background := GetItemsColor(Items, ItemIndex, FLabel.Colors.Background);
      7:

⌨️ 快捷键说明

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