📄 sgradeditor.pas
字号:
unit sGradEditor;
{$I sDefs.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ComCtrls, sConst, ExtCtrls, sGraphUtils, //ImgList,
Consts, ComStrs, CommCtrl, menus, //sFUnit,
{$IFDEF DELPHI5}dsgnintf, {$ELSE}DesignEditors, DesignIntf, VCLEditors, {$ENDIF}{sHintManager}sUtils;
type
TsStatusBarEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
TsPassiveGradEditor = class(TComponentEditor)
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
TsActiveGradEditor = class(TsPassiveGradEditor)
protected
public
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
TsGradDesigner = class(TStringProperty)
public
procedure Edit; override;
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
end;
procedure Register;
implementation
uses
{$IFNDEF ALITE}
sGauge, sTrackBar,
{$ENDIF}
sStyleUtil, sCustomButton, sGradBuilder, sButtonControl, sStyleActive,
sPanel, sStyleSimply, sStatusBar, ColnEdit;
{ TsGradEditor }
procedure TsPassiveGradEditor.ExecuteVerb(Index: Integer);
var
sg : TsGenStyle;
begin
inherited;
case Index of
0: begin
CreateEditorForm;
try
sg := GetsStyle(Component);
if Assigned(sg) and (sg is TsPassiveBGStyle) then begin
GradBuilder.CurrentGradient := TsPassiveBGStyle(sg).Background.Gradient;
GradBuilder.LoadFromArray(TsPassiveBGStyle(sg).Background.Gradient.FGradArray);
GradBuilder.ShowModal;
end;
finally
KillForm;
end;
end;
end;
if Designer <> nil then Designer.Modified;
end;
function TsPassiveGradEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: result := '&Gradient builder...';
1: result := '-';
end;
end;
function TsPassiveGradEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
procedure Register;
begin
RegisterComponentEditor(TsCustomPanel, TsPassiveGradEditor);
RegisterComponentEditor(TsStatusBar, TsStatusBarEditor);
{$IFNDEF ALITE}
RegisterComponentEditor(TsGauge, TsPassiveGradEditor);
RegisterComponentEditor(TsTrackBar, TsPassiveGradEditor);
{$ENDIF}
RegisterPropertyEditor(TypeInfo(TsGradientData), nil, '', TsGradDesigner);
end;
{ TsGradDesigner }
procedure TsGradDesigner.Edit;
begin
inherited;
if (GetComponent(0) is TsBGGradient) then begin
CreateEditorForm;
GradBuilder.CurrentGradient := TsBGGradient(GetComponent(0));
GradBuilder.LoadFromArray(TsBGGradient(GetComponent(0)).FGradArray);
GradBuilder.ShowModal;
SetValue(GradBuilder.AsString);
KillForm;
end;
end;
function TsGradDesigner.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog, paRevertable, paMultiSelect, paAutoUpdate];
end;
function TsGradDesigner.GetValue: string;
begin
if GetComponent(0) is TsBGGradient then begin
Result := TsBGGradient(GetComponent(0)).Data;
end;
end;
procedure TsGradDesigner.SetValue(const Value: string);
begin
inherited;
end;
{ TsActiveGradEditor }
procedure TsActiveGradEditor.ExecuteVerb(Index: Integer);
var
sg : TsGenStyle;
begin
inherited;
case Index of
1: begin
CreateEditorForm;
try
sg := GetsStyle(Component);
if Assigned(sg) and (sg is TsActiveBGStyle) then begin
GradBuilder.CurrentGradient := TsActiveBGStyle(sg).HotStyle.HotBackground.Gradient;
GradBuilder.LoadFromArray(TsActiveBGStyle(sg).HotStyle.HotBackground.Gradient.FGradArray);
GradBuilder.ShowModal;
if GradBuilder.ModalResult = mrOk then begin
TsActiveBGStyle(sg).HotStyle.HotBackground.Gradient.Data := GradBuilder.AsString;
end;
end;
finally
KillForm;
end;
end;
end;
end;
function TsActiveGradEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: result := '&Gradient builder...';
1: result := '&Hot gradient builder...';
2: result := '-';
end;
end;
function TsActiveGradEditor.GetVerbCount: Integer;
begin
Result := 3;
end;
{ TsStatusBarEditor }
procedure TsStatusBarEditor.ExecuteVerb(Index: Integer);
begin
inherited;
ShowCollectionEditorClass(Designer, TCollectionEditor,
Component, TsStatusBar(Component).Panels, 'Panels');
end;
function TsStatusBarEditor.GetVerb(Index: Integer): string;
begin
case Index of
0: result := '&Panels...';
1: result := '-';
end;
end;
function TsStatusBarEditor.GetVerbCount: Integer;
begin
Result := 2;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -