2 Star 1 Fork 0

wyrover/FlatStyle

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
FlatEditor.pas 8.49 KB
一键复制 编辑 原始数据 按行查看 历史
wyrover 提交于 2015-06-17 17:38 . + Init FlatStyle
unit FlatEditor;
interface
{$I FlatStyle.inc}
uses
Classes, MaskUtils, SysUtils, Controls, Forms, TypInfo,
{$IFDEF DELPHI_6_UP}
DesignIntf, DesignEditors,
{$ELSE}
DsgnIntf,
{$ENDIF}
ComCtrls;
procedure Register;
implementation
uses
FlatAttrib, FlatVersion, FlatUtils, FlatCtrls, FlatWatfm, FlatExcel, FlatPages;
{ TWaterEditor }
type TWaterEditor = class(TStringProperty)
public
procedure Edit; override;
function GetValue: string; override;
function GetWater: TDefineWater;
function GetAttributes: TPropertyAttributes; override;
property Water: TDefineWater read GetWater;
end;
procedure TWaterEditor.Edit;
begin
with TWaterForm.Create(WaterForm) do
begin
try
WaterList.Items.Assign(Water.Items);
FlatWater.Items.Assign(Water.Items);
ShowModal;
if ModalResult = mrOk then
begin
Water.Items.Assign(WaterList.Items);
TWaterEditor(self).Designer.Modified;
end;
finally
Free;
end;
end;
end;
function TWaterEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TWaterEditor.GetValue: string;
begin
Result := '(Editor)';
end;
function TWaterEditor.GetWater: TDefineWater;
begin
result := (GetComponent(0) as TDefineWater);
end;
{ TMaskEditor }
type TMaskEditor = class(TStringProperty)
public
procedure Edit; override;
function GetValue: string; override;
function GetMask: TDefineMask;
function GetAttributes: TPropertyAttributes; override;
property Mask: TDefineMask read GetMask;
end;
function TMaskEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TMaskEditor.GetValue: string;
begin
Result := Mask.Text;
end;
function TMaskEditor.GetMask: TDefineMask;
begin
result := (GetComponent(0) as TDefineMask);
end;
procedure TMaskEditor.Edit;
begin
with TMaskForm.Create(MaskForm) do
begin
try
Font.Assign(Screen.MenuFont);
EditText.EditMask := Mask.EditMask;
EditText.Text := Mask.Text;
if Mask.EditMask <> '' then
EditMask.Text := Mask.EditMask;
ShowModal;
if ModalResult = mrOk then
begin
Mask.Text := EditText.Text;
TMaskEditor(Self).Designer.Modified;
end;
finally
Free;
end;
end;
end;
{ TVersionEditor }
type TVersionEditor = class(TPropertyEditor)
private
function GetGropName: TComponent;
public
procedure Edit; override;
function GetValue: string; override;
function GetAttributes: TPropertyAttributes; override;
property GropName:TComponent read GetGropName;
end;
procedure TVersionEditor.Edit;
const
AboutStr = '1.Information:'+#13+
'Control: %s'+#13+
'Version: %s'+#13+
'In unit: %s.pas'+#13#13+
'2.Packages:'+#13+
'Version: %s'+#13+
'Copyright: ? 1998-2008'+#13+
'Platform: DELPHI7'+#13#13+
'3.Update:'+#13+
'This version by comerose update.';
var
vName,vUnit:String;
vInfo: PTypeData;
begin
with TVersionForm.Create(VersionForm) do
begin
try
Font.Assign(Screen.MenuFont);
Caption := 'About FlatStyle';
if GropName <> nil then
begin
vInfo := GetTypeData(PTypeInfo(GropName.ClassInfo));
vName := GropName.ClassName;
vUnit := vInfo.UnitName;
end
else
vName := 'Unkown class';
About.Caption := format(AboutStr,[vName,FileVersion,vUnit,FileVersion]);
Height := About.Top*2 + About.Height + OkBtn.Height*3;
Width := About.Left*2 + About.Width;
OkBtn.Top := About.Height + OkBtn.Height;
OkBtn.Left := (Width-OkBtn.Width) div 2;
ShowModal;
finally
Free;
end;
end;
end;
function TVersionEditor.GetAttributes: TPropertyAttributes;
begin
Result := [paDialog];
end;
function TVersionEditor.GetGropName: TComponent;
var
Vers:TPersistent;
begin
Vers := GetComponent(0);
if Vers is TVersionEdit then
result := TVersionEdit(Vers)
else if Vers is TVersionComboBox then
result := TVersionComboBox(Vers)
else if Vers is TVersionControl then
result := TVersionControl(Vers)
else if Vers is TVersionGraphic then
result := TVersionGraphic(Vers)
else if Vers is TVersionTreeView then
result := TVersionTreeView(Vers)
else if Vers is TVersionListView then
result := TVersionListView(Vers)
else if Vers is TVersionComponent then
result := TVersionComponent(Vers)
else if Vers is TVersionMemo then
result := TVersionMemo(Vers)
else if Vers is TVersionPages then
result := TVersionPages(Vers)
else if Vers is TVersionSheet then
result := TVersionSheet(Vers)
else
result := nil;
end;
function TVersionEditor.GetValue: string;
begin
result := FileVersion;
end;
type
TExcelEditor = class(TDefaultEditor)
private
function GetDefineExcel: TDefineExcel;
public
procedure ExecuteVerb(index: Integer); override;
function GetVerb(index: Integer): String; override;
function GetVerbCount: Integer; override;
property Excel:TDefineExcel read GetDefineExcel;
end;
procedure TExcelEditor.ExecuteVerb(index: Integer);
begin
case index of
0: Excel.InitFields;
1: Excel.RestoreFields;
2: Excel.ClearFields;
end;
TExcelEditor(self).Designer.Modified;
end;
function TExcelEditor.GetDefineExcel: TDefineExcel;
begin
result := (Component as TDefineExcel);
end;
function TExcelEditor.GetVerb(index: Integer): String;
begin
case index of
0: result := '添加全部字段';
1: result := '还原--->字段';
2: result := '清除全部字段';
end;
end;
function TExcelEditor.GetVerbCount: Integer;
begin
result := 3;
end;
type
TPagesEditor = class(TDefaultEditor)
procedure ExecuteVerb(Index: Integer); override;
function GetVerb(Index: Integer): string; override;
function GetVerbCount: Integer; override;
end;
procedure TPagesEditor.ExecuteVerb(Index: Integer);
var
PageControl: TFlatPages;
Page: TFlatSheet;
{$IFDEF DELPHI3}
ADesigner: TFormDesigner;
{$ELSE}
{$IFDEF DELPHI_6_UP}
ADesigner: IDesigner;
{$ELSE}
ADesigner: IFormDesigner;
{$ENDIF}
{$ENDIF}
begin
if Component is TTabSheet then
PageControl := TFlatSheet(Component).PageControl as TFlatPages
else
PageControl := TFlatPages(Component);
if PageControl <> nil then
begin
ADesigner := Self.Designer;
if Index = 0 then
begin
{$IFDEF DELPHI_6_UP}
Page := TFlatSheet.Create(ADesigner.Root);
{$ELSE}
Page := TFlatSheet.Create(ADesigner.Form);
{$ENDIF}
try
Page.Name := ADesigner.UniqueName(TFlatSheet.ClassName);
Page.Parent := PageControl;
Page.PageControl := PageControl
except
Page.Free;
raise
end;
PageControl.ActivePage := Page;
PageControl.UpdateGlyphs
end else begin
Page := PageControl.FindNextPage(PageControl.ActivePage,Index = 1, False) as TFlatSheet;
if (Page <> nil) and (Page <> PageControl.ActivePage) then
PageControl.ActivePage := Page
end;
ADesigner.SelectComponent(Page);
ADesigner.Modified
end
end;
function TPagesEditor.GetVerb(Index: Integer): string;
begin
case Index of
0 : Result := '新一页';
1 : Result := '下一页';
2 : Result := '上一页'
end
end;
function TPagesEditor.GetVerbCount: Integer;
begin
Result := 3
end;
procedure Register;
begin
RegisterClasses([TFlatSheet]);
RegisterComponentEditor(TFlatPages, TPagesEditor);
RegisterComponentEditor(TFlatSheet, TPagesEditor);
RegisterPropertyEditor(TypeInfo(TMaskedText), TDefineMask, 'Text', TMaskEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionEdit, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionMemo, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionComboBox, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionControl, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionGraphic, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionTreeView, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionListView, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionComponent, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionPages, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(String), TVersionSheet, 'Version', TVersionEditor);
RegisterPropertyEditor(TypeInfo(TStringList), TDefineWater, 'Items', TWaterEditor);
RegisterComponentEditor(TDefineExcel, TExcelEditor);
end;
end.
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Pascal
1
https://gitee.com/wyrover/FlatStyle.git
git@gitee.com:wyrover/FlatStyle.git
wyrover
FlatStyle
FlatStyle
master

搜索帮助