unit PropertyUnit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, StdCtrls, Buttons,ComCtrls,TypInfo, Grids,
DBGrids,DesignerUnit,NativeXml,EacButton,EacListBox,EacDbGrid,EacLabel,
EacEdit,EacMemo,EacComboBox,EacCheckBox,EacImage,EacDateTime,EacEditBtn,EacTreeView,
ObjectNameManagerUnit,ActionDesignUnit;
type
//执行触发编辑
TEventType=(etNone,etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnShow,etOnActivate,etOnClose,etOnCloseQuery,etOnChange,etOnKeyDown,
etOnKeyPress,etOnKeyUp,etOnDblClick,etOnBtnClick,etOnCellClick,
{表格增加事件}
etAfterCancel,
etAfterClose,
etAfterDelete,
etAfterEdit,
etAfterInsert,
etAfterOpen,
etAfterPost,
etAfterRefresh,
etAfterScroll,
etBeforeCancel,
etBeforeClose,
etBeforeDelete,
etBeforeEdit,
etBeforeInsert,
etBeforeOpen,
etBeforePost,
etBeforeRefresh,
etBeforeScroll,
etEnterKeyPress,
etDataChange,
etSelectChange);
TEventValue=class(TObject)
private
public
name:string;
//事件名称
Text:string;
//显示触发事件名
EventType:TEventType;
//触发事件类型
EventTypeText:string;
//事件类型文字
OpenActionForm:boolean;
//是否已经打开自己的属性的ActionForm
constructor Create(Aowner:TObject);virtual;
destructor Destroy;
override;
end;
TEventList=class
public
FList:TList;
procedure LoadEventList(CurClass:TClass);
procedure UnLoadEventList;
constructor Create(Aowner:TObject);virtual;
destructor Destroy;
override;
end;
//属性编辑
TpopType=(ptName,ptCaption,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptText,ptHint,ptShowHint,ptTransparent,ptWordWrap,ptBorderStyle,
pt3D,ptReadOnly,ptAutoScroll,ptFormBorderStyle,ptFormStyle,ptPosition,
ptWindowState,ptLines,ptItems,ptPicture,ptChecked,ptDate,ptTime,ptDateFormat,
ptFormat,ptMaxDate,ptMinDate,ptKind,ptShowCheckBox,ptAutoSize,ptCenter,
ptStretch,ptDataSourceType,ptFlat,ptAutoFitColWidths,ptRowSelect,ptMultiSelect,
ptClassFieldName,ptClassStep,ptLabelFieldName,ptValueFieldName,ptPasswordChar,
ptIsLoadFromDict,ptAFocusControl,ptCancel,ptDefault,ptStyle,ptShape,
ptBevelInner,ptBevelOuter,ptAlign);
TEditType=(etEdit,etBtnEdit,etCom,etColor);
TPopValue=Class(TObject)
private
procedure SetValue(Value: Variant);
public
PopName:string;
//属性的英文名,用来和类的实际属性名对应
Name:string;
//中文属性名
//EacName:string;
//组件中文名(标识,为的是不让用户修改Name)
FValue:Variant;
//属性值
Text:String;
//属性值显示内容
DataType:TEditType;
//属性类型
DefaultValue:variant;
//缺省值
IsDefaultValue:boolean;
//是不是缺省值
Index:integer;
//枚举类型的索引
ReadOnly:boolean;
//是否属性值可del
PopType:TPopType;
//属性类型
ChildObject:TObject;
//存储子类
constructor Create(Aowner:TObject);virtual;
destructor Destroy;
override;
property Value: Variant read FValue write SetValue;
end;
TPopList=class
public
FList:TList;
procedure LoadPopList(CurClass:TClass);
procedure UnLoadPopList;
constructor Create(Aowner:TObject);virtual;
destructor Destroy;
override;
end;
TPropertyForm = class(TForm)
Status: TStatusBar;
FontDialog: TFontDialog;
PanelBack: TPanel;
ObjectList: TComboBox;
ObjectPropTab: TPageControl;
TabSheet1: TTabSheet;
TabSheet2: TTabSheet;
SB1: TScrollBox;
Pb: TPaintBox;
BtnEdit: TSpeedButton;
PL: TPanel;
EditInput: TEdit;
ComInput: TComboBox;
ColorBtn: TColorBox;
Sb2: TScrollBox;
Pb2: TPaintBox;
Pl2: TPanel;
ComEvent: TComboBox;
procedure FormCreate(Sender: TObject);
procedure PbPaint(Sender: TObject);
procedure PbMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure SB1Resize(Sender: TObject);
procedure PLMouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure PLMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure PLMouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure FormShow(Sender: TObject);
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure FormDestroy(Sender: TObject);
procedure ComInputChange(Sender: TObject);
procedure ColorBtnChange(Sender: TObject);
procedure EditInputKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure ComInputKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure ColorBtnKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
procedure FormMouseWheel(Sender: TObject;
Shift: TShiftState;
WheelDelta: Integer;
MousePos: TPoint;
var Handled: Boolean);
procedure BtnEditClick(Sender: TObject);
procedure EditInputKeyPress(Sender: TObject;
var Key: Char);
procedure FormDeactivate(Sender: TObject);
procedure PanelBackResize(Sender: TObject);
procedure ObjectListChange(Sender: TObject);
procedure FormResize(Sender: TObject);
procedure Pb2Paint(Sender: TObject);
procedure Pb2MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure ComEventChange(Sender: TObject);
procedure Sb2Resize(Sender: TObject);
procedure Pl2MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure Pl2MouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
procedure Pl2MouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
procedure ObjectPropTabChange(Sender: TObject);
procedure ComEventDblClick(Sender: TObject);
procedure ComInputDblClick(Sender: TObject);
private
{ Private declarations }
public
//当前属性列表
CurPopList:TPopList;
//属性行高度
PopHeight:integer;
//当前选种属性行
CurItem:Integer;
//事件行
CurEventItem:Integer;
//按下移动
MouseDown:boolean;
OldX:integer;
CurIdeObject
ointer;
//当前编辑的组件(或者窗体)的指针
IsForm:Boolean;
//当前编辑的是否为窗体
Loaded:boolean;
//装载属性,true刚装载,不能够往回刷新
//当前事件行
CurEventList:TEventList;
//未修改前的EditInput的内容
OldValue:String;
//画当前活动属性
procedure DrawPropertyItem(CurItem:integer);
Procedure Loadproperty;
procedure ShowHelp(CurId:integer);
//对编辑中的组件进行刷新
procedure RefreshIdeObject;
//当前活动事件
procedure DrawEventItem(CurEventItem:integer);
Procedure LoadEvent;
{ Public declarations }
end;
var
PropertyForm: TPropertyForm;
implementation
uses PictureEditor,IdeUnit, StringsEditorUnit, ScriptUnit, ModelDesignUnit;
{$R *.dfm}
//事件触发
//属性
constructor TEventValue.Create(Aowner:TObject);
begin
inherited Create;
end;
destructor TEventValue.Destroy;
begin
inherited Destroy;
end;
//属性
constructor TPopValue.Create(Aowner:TObject);
begin
inherited Create;
end;
destructor TPopValue.Destroy;
begin
inherited Destroy;
end;
procedure TPopValue.SetValue(Value: Variant);
begin
FValue:=Value;
end;
//属性列表
procedure TPopList.LoadPopList(CurClass:TClass);
var
PopSet:Set of TpopType;
PopValue:TPopValue;
begin
if CurClass=TEacButton then
PopSet:=[ptName,ptCaption,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptFont,ptHint,ptShowHint,ptWordWrap,ptCancel,ptDefault];
if CurClass=TEacEdit then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,ptAutoSize,
ptColor,ptText,ptHint,ptShowHint,ptFont,ptBorderStyle,
pt3D,ptReadOnly,ptPasswordChar];
if CurClass=TEacEditBtn then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,ptAutoSize,
ptColor,ptText,ptHint,ptShowHint,ptFont,ptBorderStyle,
pt3D,ptReadOnly,ptDataSourceType];
if CurClass=TForm then
PopSet:=[ptName,ptCaption,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptHint,ptShowHint,ptFont,ptAutoSize,
ptAutoScroll,ptFormBorderStyle,ptFormStyle,ptPosition,ptWindowState];
if CurClass=TEacLabel then
PopSet:=[ptName,ptCaption,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptHint,ptShowHint,ptTransparent,ptWordWrap,ptAutoSize,
ptAFocusControl];
if CurClass=TEacPanel then
PopSet:=[ptName,ptCaption,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptHint,ptShowHint,ptAutoSize,ptBevelInner,ptBevelOuter,
ptBorderStyle,ptAlign];
if CurClass=TEacBevel then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptHint,ptShowHint,
ptStyle,ptShape,ptAlign];
if CurClass=TEacMemo then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptHint,ptShowHint,ptBorderStyle,pt3D,ptReadOnly,
ptLines,ptAlign];
if CurClass=TEacComboBox then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptText,ptHint,ptShowHint,ptItems];
if CurClass=TEacCheckBox then
PopSet:=[ptName,ptCaption,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptHint,ptShowHint,ptWordWrap,pt3D,ptChecked];
if CurClass=TEacImage then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptHint,ptShowHint,ptTransparent,ptPicture,ptAutoSize,ptCenter,
ptStretch,ptAlign];
if CurClass=TEacDateTime then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptHint,ptShowHint,ptChecked,ptDate,ptTime,ptDateFormat,
ptFormat,ptKind,ptShowCheckBox];
if CurClass=TEacListBox then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptHint,ptShowHint,ptItems,ptAlign];
if CurClass=TEacTreeView then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,
ptColor,ptFont,ptHint,ptShowHint,ptClassFieldName,ptLabelFieldName,
ptClassStep,ptValueFieldName,ptAlign];
if CurClass=TEacDbGrid then
PopSet:=[ptName,ptLeft,ptTop,ptWidth,ptHeight,ptVisible,ptEnabled,ptFlat,
ptColor,ptFont,ptHint,ptShowHint,ptBorderStyle,pt3D,ptReadOnly,
ptAutoFitColWidths,ptRowSelect,ptMultiSelect,ptIsLoadFromDict,
ptAlign];
//根据指定的组件类装载属性列表
if ptName in PopSet then
begin
//EacName
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='EacName';
Name:='名称';
Value:='Name1';
//if CurClass=TForm then
Text:='' else
Text:='';
DataType:=etEdit;
PopType:=ptName;
//ReadOnly:=true;
FList.Add(PopValue);
end;
end;
if ptCaption in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Caption';
Name:='标题';
Value:='Caption';
Text:='Caption';
DataType:=etEdit;
Index:=0;
PopType:=ptCaption;
FList.Add(PopValue);
end;
end;
if ptClassFieldName in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='ClassFieldName';
Name:='分级字段';
Value:='ClassFieldName';
Text:='';
DataType:=etEdit;
Index:=0;
PopType:=ptClassFieldName;
FList.Add(PopValue);
end;
end;
if ptPasswordChar in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='PasswordChar';
Name:='密码字符';
Value:='PasswordChar';
Text:='';
DataType:=etEdit;
Index:=0;
PopType:=ptPasswordChar;
FList.Add(PopValue);
end;
end;
if ptLabelFieldName in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='LabelFieldName';
Name:='显示字段';
Value:='LabelFieldName';
Text:='LabelFieldName';
DataType:=etEdit;
Index:=0;
PopType:=ptLabelFieldName;
FList.Add(PopValue);
end;
end;
if ptValueFieldName in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='ValueFieldName';
Name:='关联字段';
Value:='ValueFieldName';
Text:='ValueFieldName';
DataType:=etEdit;
Index:=0;
PopType:=ptValueFieldName;
FList.Add(PopValue);
end;
end;
if ptClassStep in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='ClassStep';
Name:='级别长度';
Value:='4';
Text:='4';
DataType:=etEdit;
Index:=0;
PopType:=ptClassStep;
FList.Add(PopValue);
end;
end;
if ptAlign in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Align';
Name:='对齐方式';
Value:='alNone';
Text:='alNone';
DataType:=etCom;
Index:=0;
PopType:=ptAlign;
FList.Add(PopValue);
end;
end;
if ptFlat in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Flat';
Name:='扁平样式';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=0;
PopType:=ptFlat;
FList.Add(PopValue);
end;
end;
if ptAutoFitColWidths in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='AutoFitColWidths';
Name:='自动宽度';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=0;
PopType:=ptAutoFitColWidths;
FList.Add(PopValue);
end;
end;
if ptRowSelect in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='RowSelect';
Name:='选择行';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=0;
PopType:=ptRowSelect;
FList.Add(PopValue);
end;
end;
if ptMultiSelect in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='MultiSelect';
Name:='行多选';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=0;
PopType:=ptMultiSelect;
FList.Add(PopValue);
end;
end;
if ptVisible in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Visible';
Name:='可见性';
Value:=True;
Text:='True';
DataType:=etCom;
Index:=0;
PopType:=ptVisible;
FList.Add(PopValue);
end;
end;
if ptEnabled in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Enabled';
Name:='有效性';
Value:=True;
Text:='True';
DataType:=etCom;
Index:=0;
PopType:=ptEnabled;
FList.Add(PopValue);
end;
end;
if ptCancel in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Cancel';
Name:='取消';
Value:=True;
Text:='True';
DataType:=etCom;
Index:=0;
PopType:=ptCancel;
FList.Add(PopValue);
end;
end;
if ptDefault in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Default';
Name:='缺省';
Value:=True;
Text:='True';
DataType:=etCom;
Index:=0;
PopType:=ptDefault;
FList.Add(PopValue);
end;
end;
if ptFont in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Font';
Name:='字体';
ChildObject:=PropertyForm.FontDialog.Font;
Text:='(TFont)';
DataType:=etBtnEdit;
Index:=0;
ReadOnly:=true;
PopType:=ptFont;
FList.Add(PopValue);
end;
end;
if ptLeft in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Left';
Name:='左边界';
Value:='0';
Text:='0';
DataType:=etEdit;
Index:=0;
PopType:=ptLeft;
FList.Add(PopValue);
end;
end;
if ptTop in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Top';
Name:='上边界';
Value:='0';
Text:='0';
DataType:=etEdit;
Index:=0;
PopType:=ptTop;
FList.Add(PopValue);
end;
end;
if ptWidth in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Width';
Name:='宽度';
Value:='0';
Text:='0';
DataType:=etEdit;
Index:=0;
PopType:=ptWidth;
FList.Add(PopValue);
end;
end;
if ptHeight in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Height';
Name:='高度';
Value:='0';
Text:='0';
DataType:=etEdit;
Index:=0;
PopType:=ptHeight;
//ReadOnly:=true;
FList.Add(PopValue);
end;
end;
if ptColor in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Color';
Name:='颜色';
Value:=ClBlack;
Text:='clBlack';
DataType:=etColor;
Index:=0;
ReadOnly:=true;
PopType:=ptColor;
FList.Add(PopValue);
end;
end;
if ptText in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Text';
Name:='文本';
Value:='';
Text:='';
DataType:=etEdit;
Index:=0;
PopType:=ptText;
FList.Add(PopValue);
end;
end;
if ptHint in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Hint';
Name:='提示文本';
Value:='';
Text:='';
DataType:=etEdit;
Index:=0;
PopType:=ptHint;
FList.Add(PopValue);
end;
end;
if ptShowHint in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='ShowHint';
Name:='显示提示';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptShowHint;
FList.Add(PopValue);
end;
end;
if ptAFocusControl in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='AFocusControl';
Name:='聚焦组件';
Value:='';
Text:='';
DataType:=etCom;
Index:=0;
PopType:=ptAFocusControl;
FList.Add(PopValue);
end;
end;
if ptIsLoadFromDict in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='IsLoadFromDict';
Name:='从字典装载列';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptIsLoadFromDict;
FList.Add(PopValue);
end;
end;
if ptTransparent in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Transparent';
Name:='透明效果';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptTransparent;
FList.Add(PopValue);
end;
end;
if ptWordWrap in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='WordWrap';
Name:='自动换行';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptWordWrap;
FList.Add(PopValue);
end;
end;
if pt3D in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Ctl3D';
Name:='立体效果';
Value:=True;
Text:='True';
DataType:=etCom;
Index:=0;
PopType:=pt3D;
FList.Add(PopValue);
end;
end;
if ptReadOnly in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='ReadOnly';
Name:='只读';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptReadOnly;
FList.Add(PopValue);
end;
end;
if ptBorderStyle in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='BorderStyle';
Name:='边框类型';
Value:=bsSingle;
Text:='bsSingle';
DataType:=etCom;
Index:=1;
PopType:=ptBorderStyle;
FList.Add(PopValue);
end;
end;
if ptStyle in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Style';
Name:='立体效果';
Value:='';
Text:='';
DataType:=etCom;
Index:=0;
PopType:=ptStyle;
FList.Add(PopValue);
end;
end;
if ptShape in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Shape';
Name:='形状';
Value:='';
Text:='';
DataType:=etCom;
Index:=0;
PopType:=ptShape;
FList.Add(PopValue);
end;
end;
if ptBevelInner in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='BevelInner';
Name:='内边缘';
Value:='';
Text:='';
DataType:=etCom;
Index:=0;
PopType:=ptBevelInner;
FList.Add(PopValue);
end;
end;
if ptBevelOuter in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='BevelOuter';
Name:='外边缘';
Value:='';
Text:='';
DataType:=etCom;
Index:=0;
PopType:=ptBevelOuter;
FList.Add(PopValue);
end;
end;
if ptAutoScroll in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='AutoScroll';
Name:='滚动条';
Value:=True;
Text:='True';
DataType:=etCom;
Index:=0;
PopType:=ptAutoScroll;
FList.Add(PopValue);
end;
end;
if ptFormBorderStyle in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='BorderStyle';
Name:='边框类型';
Value:=bsSizeable;
Text:='bsSizeable';
DataType:=etCom;
Index:=2;
PopType:=ptFormBorderStyle;
FList.Add(PopValue);
end;
end;
if ptFormStyle in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='FormStyle';
Name:='窗体类型';
Value:=fsNormal;
Text:='fsNormal';
DataType:=etCom;
Index:=0;
PopType:=ptFormStyle;
FList.Add(PopValue);
end;
end;
if ptPosition in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Position';
Name:='窗体位置';
Value:=poDesigned;
Text:='poDesigned';
DataType:=etCom;
Index:=0;
PopType:=ptPosition;
FList.Add(PopValue);
end;
end;
if ptWindowState in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='WindowState';
Name:='窗体状态';
Value:=wsNormal;
Text:='wsNormal';
DataType:=etCom;
Index:=0;
PopType:=ptWindowState;
FList.Add(PopValue);
end;
end;
if ptLines in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Lines';
Name:='文本行';
Value:='';
Text:='(TStrings)';
DataType:=etBtnEdit;
Index:=0;
PopType:=ptLines;
ReadOnly:=True;
FList.Add(PopValue);
end;
end;
if ptItems in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Items';
Name:='项目';
Value:='';
Text:='(TStrings)';
DataType:=etBtnEdit;
Index:=0;
PopType:=ptItems;
ReadOnly:=True;
FList.Add(PopValue);
end;
end;
if ptPicture in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Picture';
Name:='图形';
Value:=null;
Text:='(None)';
DataType:=etBtnEdit;
Index:=0;
PopType:=ptPicture;
ReadOnly:=true;
FList.Add(PopValue);
end;
end;
if ptChecked in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Checked';
Name:='选择';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptChecked;
FList.Add(PopValue);
end;
end;
if ptDate in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Date';
Name:='日期';
Value:=now;
Text:=DateTostr(Now);
DataType:=etEdit;
Index:=0;
PopType:=ptDate;
FList.Add(PopValue);
end;
end;
if ptTime in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Time';
Name:='时间';
Value:=now;
Text:=TimeTostr(Now);
DataType:=etEdit;
Index:=0;
PopType:=ptTime;
FList.Add(PopValue);
end;
end;
if ptDateFormat in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='DateFormat';
Name:='日期格式';
Value:=dfShort;
Text:='dfShort';
DataType:=etCom;
Index:=0;
PopType:=ptDateFormat;
FList.Add(PopValue);
end;
end;
if ptFormat in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Format';
Name:='显示格式';
Value:='';
Text:='';
DataType:=etEdit;
Index:=0;
PopType:=ptFormat;
FList.Add(PopValue);
end;
end;
if ptMaxDate in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='MaxDate';
Name:='最大日期';
Value:='';
Text:='';
DataType:=etEdit;
Index:=0;
PopType:=ptMaxDate;
FList.Add(PopValue);
end;
end;
if ptMinDate in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='MinDate';
Name:='最小日期';
Value:='';
Text:='';
DataType:=etEdit;
Index:=0;
PopType:=ptMinDate;
FList.Add(PopValue);
end;
end;
if ptKind in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Kind';
Name:='显示内容';
Value:=dtkDate;
Text:='dtkDate';
DataType:=etCom;
Index:=0;
PopType:=ptKind;
FList.Add(PopValue);
end;
end;
if ptShowCheckBox in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='ShowCheckBox';
Name:='显示选择框';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptShowCheckBox;
FList.Add(PopValue);
end;
end;
if ptAutoSize in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='AutoSize';
Name:='自动大小';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptAutoSize;
FList.Add(PopValue);
end;
end;
if ptCenter in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Center';
Name:='居中';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptCenter;
FList.Add(PopValue);
end;
end;
if ptStretch in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='Stretch';
Name:='自动缩放';
Value:=False;
Text:='False';
DataType:=etCom;
Index:=1;
PopType:=ptStretch;
FList.Add(PopValue);
end;
end;
if ptDataSourceType in PopSet then
begin
PopValue:=TPopValue.Create(Self);
with PopValuedo
begin
PopName:='DataSourceType';
Name:='数据类型';
Text:='dtCustom';
DataType:=etCom;
Index:=0;
PopType:=ptDataSourceType;
FList.Add(PopValue);
end;
end;
end;
procedure TPopList.UnLoadPopList;
var
i:integer;
begin
//根据指定的组件卸载属性列表
for i:=FList.Count-1do
wnto 0do
begin
TPopValue(FList
).Free;
FList.Delete(i);
end;
end;
constructor TPopList.Create(Aowner:TObject);
begin
inherited Create;
FList:=TList.Create;
end;
destructor TPopList.Destroy;
var
i:integer;
begin
for i:=0 to FList.Count-1do
begin
TPopValue(FList).Free;
end;
FList.Free;
inherited Destroy;
end;
//事件列表
constructor TEventList.Create(Aowner:TObject);
begin
inherited Create;
FList:=TList.Create;
end;
destructor TEventList.Destroy;
var
i:integer;
begin
for i:=0 to FList.Count-1do
begin
TEventValue(FList).Free;
end;
FList.Free;
inherited Destroy;
end;
//装载事件列表
procedure TEventList.LoadEventList(CurClass:TClass);
var
EventSet:Set of TEventType;
EventValue:TEventValue;
{etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnShow,etOnActive,etOnClose,etOnCloseQuery,etOnChange,etOnKeyDown,
etKeyPress,etKeyUp,etOnDblClick}
begin
if CurClass=TEacButton then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit];
if CurClass=TEacEdit then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnChange,etOnKeyDown,etOnKeyPress,etOnKeyUp,etOnDblClick,etEnterKeyPress];
if CurClass=TEacEditBtn then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnChange,etOnKeyDown,etOnKeyPress,etOnKeyUp,etOnDblClick,etOnBtnClick];
if CurClass=TForm then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnShow,etOnActivate,etOnClose,etOnCloseQuery,etOnKeyDown,
etOnKeyPress,etOnKeyUp,etOnDblClick];
if CurClass=TEacLabel then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnDblClick];
if CurClass=TEacPanel then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnDblClick];
if CurClass=TEacBevel then
EventSet:=[];
if CurClass=TEacMemo then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnChange,etOnKeyDown,etOnKeyPress,etOnKeyUp,etOnDblClick];
if CurClass=TEacComboBox then
EventSet:=[etOnClick,etOnEnter,etOnExit,etOnChange,etOnKeyDown,
etOnKeyPress,etOnKeyUp,etOnDblClick];
if CurClass=TEacCheckBox then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit];
if CurClass=TEacImage then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnDblClick];
if CurClass=TEacDateTime then
EventSet:=[etOnClick,etOnEnter,etOnExit,etOnChange,etOnKeyDown,
etOnKeyPress,etOnKeyUp,etOnDblClick];
if CurClass=TEacListBox then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit
,etOnKeyDown,etOnKeyPress,etOnKeyUp,etOnDblClick];
if CurClass=TEacTreeView then
EventSet:=[etOnClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit
,etOnKeyDown,etOnKeyPress,etOnKeyUp,etOnDblClick,etSelectChange];
if CurClass=TEacDbGrid then
EventSet:=[etOnCellClick,etOnMouseDown,etOnMouseMove,etOnMouseUp,etOnEnter,etOnExit,
etOnKeyDown,etOnKeyPress,etOnKeyUp,etOnDblClick,etAfterScroll,
etDataChange,{etAfterCancel,etAfterPost,
etAfterClose,
etAfterDelete,
etAfterEdit,
etAfterInsert,
etAfterOpen,
etAfterRefresh,
etAfterScroll,
etBeforeCancel,
etBeforeClose,
etBeforeDelete,
etBeforeEdit,
etBeforeInsert,
etBeforeOpen,
etBeforePost,
etBeforeRefresh,
etBeforeScroll,}
etEnterKeyPress];
//根据指定的组件类装载属性列表
//表格事件
if etAfterCancel in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='取消之后';
Text:='';
EventType:=etAfterCancel;
EventTypeText:='AfterCancel';
FList.Add(EventValue);
end;
end;
if etAfterClose in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='关闭之后';
Text:='';
EventType:=etAfterClose;
EventTypeText:='AfterClose';
FList.Add(EventValue);
end;
end;
if etAfterDelete in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='删除之后';
Text:='';
EventType:=etAfterDelete;
EventTypeText:='AfterDelete';
FList.Add(EventValue);
end;
end;
if etAfterEdit in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='编辑之后';
Text:='';
EventType:=etAfterEdit;
EventTypeText:='AfterEdit';
FList.Add(EventValue);
end;
end;
if etAfterInsert in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='插入之后';
Text:='';
EventType:=etAfterInsert;
EventTypeText:='AfterInsert';
FList.Add(EventValue);
end;
end;
if etAfterOpen in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='打开之后';
Text:='';
EventType:=etAfterOpen;
EventTypeText:='AfterOpen';
FList.Add(EventValue);
end;
end;
if etAfterPost in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='提交之后';
Text:='';
EventType:=etAfterPost;
EventTypeText:='AfterPost';
FList.Add(EventValue);
end;
end;
if etSelectChange in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='选择变化';
Text:='';
EventType:=etSelectChange;
EventTypeText:='SelectChange';
FList.Add(EventValue);
end;
end;
if etDataChange in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='数据变动';
Text:='';
EventType:=etDataChange;
EventTypeText:='DataChange';
FList.Add(EventValue);
end;
end;
if etAfterRefresh in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='刷新之后';
Text:='';
EventType:=etAfterRefresh;
EventTypeText:='AfterRefresh';
FList.Add(EventValue);
end;
end;
if etAfterScroll in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='滚动之后';
Text:='';
EventType:=etAfterScroll;
EventTypeText:='AfterScroll';
FList.Add(EventValue);
end;
end;
if etBeforeCancel in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='取消之前';
Text:='';
EventType:=etBeforeCancel;
EventTypeText:='BeforeCancel';
FList.Add(EventValue);
end;
end;
if etBeforeClose in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='关闭之前';
Text:='';
EventType:=etBeforeClose;
EventTypeText:='BeforeClose';
FList.Add(EventValue);
end;
end;
if etBeforeDelete in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='删除之前';
Text:='';
EventType:=etBeforeDelete;
EventTypeText:='BeforeDelete';
FList.Add(EventValue);
end;
end;
if etBeforeEdit in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='编辑之前';
Text:='';
EventType:=etBeforeEdit;
EventTypeText:='BeforeEdit';
FList.Add(EventValue);
end;
end;
if etBeforeInsert in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='插入之前';
Text:='';
EventType:=etBeforeInsert;
EventTypeText:='BeforeInsert';
FList.Add(EventValue);
end;
end;
if etBeforeOpen in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='打开之前';
Text:='';
EventType:=etBeforeOpen;
EventTypeText:='BeforeOpen';
FList.Add(EventValue);
end;
end;
if etBeforePost in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='提交之前';
Text:='';
EventType:=etBeforePost;
EventTypeText:='BeforePost';
FList.Add(EventValue);
end;
end;
if etBeforeRefresh in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='刷新之前';
Text:='';
EventType:=etBeforeRefresh;
EventTypeText:='BeforeRefresh';
FList.Add(EventValue);
end;
end;
if etBeforeScroll in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='滚动之前';
Text:='';
EventType:=etBeforeScroll;
EventTypeText:='BeforeScroll';
FList.Add(EventValue);
end;
end;
if etEnterKeyPress in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='敲击回车';
Text:='';
EventType:=etEnterKeyPress;
EventTypeText:='EnterKeyPress';
FList.Add(EventValue);
end;
end;
if etOnClick in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='鼠标点击';
Text:='';
EventType:=etOnClick;
EventTypeText:='OnClick';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnCellClick in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='点击单元格';
Text:='';
EventType:=etOnCellClick;
EventTypeText:='OnCellClick';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnMouseDown in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='鼠标按下';
Text:='';
EventType:=etOnMouseDown;
EventTypeText:='OnMouseDown';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnMouseMove in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='鼠标移动';
Text:='';
EventType:=etOnMouseMove;
EventTypeText:='OnMouseMove';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnMouseUp in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='鼠标松开';
Text:='';
EventType:=etOnMouseUp;
EventTypeText:='OnMouseUp';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnEnter in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='进入区域';
Text:='';
EventType:=etOnEnter;
EventTypeText:='OnEnter';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnExit in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='离开区域';
Text:='';
EventType:=etOnExit;
EventTypeText:='OnExit';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnShow in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='窗口打开';
Text:='';
EventType:=etOnShow;
EventTypeText:='OnShow';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnActivate in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='窗口活动';
Text:='';
EventType:=etOnActivate;
EventTypeText:='OnActivate';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnClose in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='窗口关闭';
Text:='';
EventType:=etOnClose;
EventTypeText:='OnClose';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnCloseQuery in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='窗口请求关闭';
Text:='';
EventType:=etOnCloseQuery;
EventTypeText:='OnCloseQuery';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnChange in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='内容变化';
Text:='';
EventType:=etOnChange;
EventTypeText:='OnChange';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnKeyDown in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='键盘按下';
Text:='';
EventType:=etOnKeyDown;
EventTypeText:='OnKeyDown';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnKeyPress in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='键盘敲击';
Text:='';
EventType:=etOnKeyPress;
EventTypeText:='OnKeyPress';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnKeyUp in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='按键弹起';
Text:='';
EventType:=etOnKeyUp;
EventTypeText:='OnKeyUp';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnDblClick in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='鼠标双击';
Text:='';
EventType:=etOnDblClick;
EventTypeText:='OnDblClick';
//OpenActionForm:=False;
FList.Add(EventValue);
end;
end;
if etOnBtnClick in EventSet then
begin
EventValue:=TEventValue.Create(Self);
with EventValuedo
begin
Name:='按钮点击';
Text:='';
EventType:=etOnBtnClick;
EventTypeText:='OnBtnClick';
FList.Add(EventValue);
end;
end;
end;
procedure TEventList.UnLoadEventList;
var
i:integer;
begin
//根据指定的组件卸载属性列表
for i:=FList.Count-1do
wnto 0do
begin
TEventValue(FList).Free;
FList.Delete(i);
end;
end;
//属性窗口
procedure TPropertyForm.FormCreate(Sender: TObject);
begin
CurItem:=1;
CurEventItem:=1;
MouseDown:=False;
Sb1.DoubleBuffered:=true;
Sb2.DoubleBuffered:=true;
Self.DoubleBuffered:=true;
ComInput.DoubleBuffered:=True;
EditInput.DoubleBuffered:=True;
ColorBtn.DoubleBuffered:=True;
ComEvent.DoubleBuffered:=True;
PopHeight:=21;
CurPopList:=TPopList.Create(self);
CurEventList:=TEventList.Create(self);
Loaded:=True;
OldValue:='';
end;
//装载属性个数
Procedure TPropertyForm.LoadEvent;
begin
Pb2.Height:=PopHeight*Self.CurEventList.FList.Count;
Pl2.Top:=-Sb2.VertScrollBar.ScrollPos;
Pl2.Height:=Pb2.Height;
Pb2.Left:=0;
if Pb2.Height>Sb2.Height then
Pb2.Width:=Sb2.Width-21
else
Pb2.Width:=Sb2.ClientWidth;
end;
procedure TPropertyForm.DrawEventItem(CurEventItem:integer);
begin
ComEvent.Visible:=False;
if ObjectPropTab.TabIndex<>1 then
exit;
if CurEventList.FList.Count=0 then
exit;
//加载选项,根据类型加载
ComEvent.Items.Clear;
//ComEvent.itemindex:=TPopValue(CurPopList.FList[CurItem-1]).index;
ComEvent.Text:=TEventValue(CurEventList.FList[CurEventItem-1]).Text;
ComEvent.Visible:=False;
ComEvent.Left:=Pl2.Left+2;
ComEvent.Top:=(CurEventItem-1)*PopHeight-Sb2.VertScrollBar.ScrollPos+1;
ComEvent.Width:=Pb2.Width-Pl2.Left-2;
ComEvent.Height:=PopHeight-2;
ComEvent.Visible:=true;
if Self.Active then
ComEvent.SetFocus;
ComEvent.SelectAll;
end;
Procedure TPropertyForm.Loadproperty;
begin
Pb.Height:=PopHeight*Self.CurPopList.FList.Count;
Pl.Top:=-Sb1.VertScrollBar.ScrollPos;
Pl.Height:=Pb.Height;
Pb.Left:=0;
if Pb.Height>Sb1.Height then
Pb.Width:=Sb1.Width-21
else
Pb.Width:=Sb1.ClientWidth;
end;
//画线,写属性值
procedure TPropertyForm.PbPaint(Sender: TObject);
var
i:integer;
PopNum:integer;
begin
//if ObjectProptab.TabIndex=0 then
begin
Pb.Canvas.FillRect(Pb.Canvas.ClipRect);
PopNum:=Self.CurPopList.FList.Count;
//循环写入属性列表和属性值
for i:=0 to PopNum-1do
begin
Pb.Canvas.Pen.Color:=clGrayText;
pb.Canvas.MoveTo(0,PopHeight*(i+1)-1);
Pb.Canvas.LineTo(Pb.Width,PopHeight*(i+1)-1);
//名字
Pb.Canvas.TextRect(Rect(4,PopHeight*(i)+1,Pl.Left,PopHeight*(i+1)-1),
4,PopHeight*(i)+4,TPopValue(Self.CurPopList.FList).Name);
//内容,如果是内容就绘text,是颜色就画牙色
if TPopValue(Self.CurPopList.FList).DataType<>etColor then
Pb.Canvas.TextRect(Rect(Pl.Left+3,PopHeight*(i)+1,Sb1.ClientWidth-1,PopHeight*(i+1)-1),
Pl.Left+3,PopHeight*(i)+4,TPopValue(Self.CurPopList.FList).Text)
else
begin
//色块
Pb.Canvas.Pen.Color:=clBlack;
pb.Canvas.Brush.Color:=TPopValue(Self.CurPopList.FList).Value;
Pb.Canvas.Rectangle(Pl.Left+4,PopHeight*(i)+3,Pl.Left+18,PopHeight*(i+1)-4);
//文字
Pb.Canvas.Brush.Style:=bsClear;
Pb.Canvas.Pen.Color:=clBlack;
Pb.Canvas.TextRect(Rect(Pl.Left+22,PopHeight*(i)+1,Sb1.ClientWidth-1,PopHeight*(i+1)-1),
Pl.Left+22,PopHeight*(i)+4,TPopValue(Self.CurPopList.FList).Text)
end;
end;
//标注当前选择的属性
Pb.Canvas.Pen.Color:=clBlack;
pb.Canvas.MoveTo(0,PopHeight*(CurItem-1));
Pb.Canvas.LineTo(Pb.Width,PopHeight*(CurItem-1));
Pb.Canvas.Pen.Color:=ClWhite;
pb.Canvas.MoveTo(0,PopHeight*CurItem-1);
Pb.Canvas.LineTo(Pb.Width,PopHeight*CurItem-1);
end;
end;
//显示属性值的编辑框
procedure TPropertyForm.DrawPropertyItem(CurItem:integer);
var
i:integer;
begin
ComInput.Visible:=False;
BtnEdit.Visible:=False;
EditInPut.Visible:=False;
if ObjectPropTab.TabIndex<>0 then
exit;
if CurPopList.FList.Count=0 then
exit;
if CurItem<1 then
Exit;
//根据不同的类型显示不同的编辑框
//打开对话框编辑的
if TPopValue(CurPopList.FList[CurItem-1]).DataType=etBtnEdit then
begin
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
//隐藏
ComInput.Visible:=False;
BtnEdit.Visible:=False;
EditInPut.Visible:=False;
ColorBtn.Visible:=False;
BtnEdit.Visible:=False;
EditInPut.Left:=Pl.Left+2;
EditInput.Top:=(CurItem-1)*PopHeight-Sb1.VertScrollBar.ScrollPos+1;
EditInput.Width:=Pb.Width-Pl.Left-BtnEdit.Width-2;
EditInput.Height:=PopHeight-2;
BtnEdit.Top:=EditInput.Top;
BtnEdit.Left:=EditInput.Left+EditInput.Width;
BtnEdit.Visible:=True;
EditInput.Visible:=true;
if TPopValue(CurPopList.FList[CurItem-1]).ReadOnly then
begin
EditInput.ReadOnly:=True;
EditInput.Color:=clBtnFace;
end else
begin
EditInput.ReadOnly:=False;
EditInput.Color:=clWhite;
end;
if Self.Active then
EditInput.SetFocus;
EditInput.SelectAll;
end;
//无对话框直接输入的
if TPopValue(CurPopList.FList[CurItem-1]).DataType=etEdit then
begin
//if ObjectList.ItemIndex=0 then
EditInput.Text:=CurIdeForm.EacName
//showmessage(TPopValue(CurPopList.FList[CurItem-1]).text);
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
ComInput.Visible:=False;
BtnEdit.Visible:=False;
ColorBtn.Visible:=False;
EditInPut.Visible:=False;
EditInPut.Left:=Pl.Left+2;
EditInput.Top:=(CurItem-1)*PopHeight-Sb1.VertScrollBar.ScrollPos+1;
EditInput.Width:=Pb.Width-Pl.Left-2;
EditInput.Height:=PopHeight-2;
EditInput.Visible:=true;
if TPopValue(CurPopList.FList[CurItem-1]).ReadOnly then
begin
EditInput.ReadOnly:=True;
EditInput.Color:=clBtnFace;
end else
begin
EditInput.ReadOnly:=False;
EditInput.Color:=clWhite;
end;
if Self.Active then
EditInput.SetFocus;
EditInput.SelectAll;
//OldValue:=EditInput.Text;
end;
//选择的,枚举类型,布尔类型等
if TPopValue(CurPopList.FList[CurItem-1]).DataType=etCom then
begin
//加载选项,根据类型加载
ComInPut.Items.Clear;
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptBorderStyle then
begin
ComInPut.Items.Add('bsNone');
ComInPut.Items.Add('bsSingle');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptFormBorderStyle then
begin
ComInPut.Items.Add('bsNone');
ComInPut.Items.Add('bsSingle');
ComInPut.Items.Add('bsSizeable');
ComInPut.Items.Add('bsDialog');
ComInPut.Items.Add('bsToolWindow');
ComInPut.Items.Add('bsSizeToolWin');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptDataSourceType then
begin
ComInPut.Items.Add('dtCustom');
ComInPut.Items.Add('dtDataBase');
ComInPut.Items.Add('dtCalculate');
ComInPut.Items.Add('dtDir');
ComInPut.Items.Add('dtFile');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptAlign then
begin
ComInPut.Items.Add('alNone');
ComInPut.Items.Add('alTop');
ComInPut.Items.Add('alBottom');
ComInPut.Items.Add('alLeft');
ComInPut.Items.Add('alRight');
ComInPut.Items.Add('alClient');
ComInPut.Items.Add('alCustom');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptFormStyle then
begin
ComInPut.Items.Add('fsNormal');
ComInPut.Items.Add('fsMDIChild');
ComInPut.Items.Add('fsMDIForm');
ComInPut.Items.Add('fsStayOnTop');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptPosition then
begin
ComInPut.Items.Add('poDesigned');
ComInPut.Items.Add('poDefault');
ComInPut.Items.Add('poDefaultPosOnly');
ComInPut.Items.Add('poDefaultSizeOnly');
ComInPut.Items.Add('poScreenCenter');
ComInPut.Items.Add('poDesktopCenter');
ComInPut.Items.Add('poMainFormCenter');
ComInPut.Items.Add('poOwnerFormCenter');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptWindowState then
begin
ComInPut.Items.Add('wsNormal');
ComInPut.Items.Add('wsMinimized');
ComInPut.Items.Add('wsMaximized');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptKind then
begin
ComInPut.Items.Add('dtkDate');
ComInPut.Items.Add('dtkTime');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptStyle then
begin
ComInPut.Items.Add('bsLowered');
ComInPut.Items.Add('bsRaised');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptShape then
begin
ComInPut.Items.Add('bsBox');
ComInPut.Items.Add('bsFrame');
ComInPut.Items.Add('bsTopLine');
ComInPut.Items.Add('bsBottomLine');
ComInPut.Items.Add('bsLeftLine');
ComInPut.Items.Add('bsRightLine');
ComInPut.Items.Add('bsSpacer');
end else
if (TPopValue(CurPopList.FList[CurItem-1]).PopType=ptBevelInner)or
(TPopValue(CurPopList.FList[CurItem-1]).PopType=ptBevelOuter) then
begin
ComInPut.Items.Add('bvNone');
ComInPut.Items.Add('bvLowered');
ComInPut.Items.Add('bvRaised');
ComInPut.Items.Add('bvSpace');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptDateFormat then
begin
ComInPut.Items.Add('dfShort');
ComInPut.Items.Add('dfLong');
end else
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptAFocusControl then
begin
//增加当前窗体的所有的
For i:=0 to CurIdeForm.FIdeObList.Count-1do
begin
if TIdeObject(CurIdeForm.FIdeObList.Objects).CanTabOrder then
begin
ComInPut.Items.Add(
GetStrProp(TIdeObject(CurIdeForm.FIdeObList.Objects).ObjectCon.Components[0],'EacName'));
end;
end;
end else
begin
ComInPut.Items.Add('True');
ComInPut.Items.Add('False');
end;
////////
ComInPut.Text:='';
if TPopValue(CurPopList.FList[CurItem-1]).PopType=ptAFocusControl then
ComInPut.itemindex:=ComInPut.Items.IndexOf(TPopValue(CurPopList.FList[CurItem-1]).Text)
else
ComInPut.itemindex:=TPopValue(CurPopList.FList[CurItem-1]).index;
BtnEdit.Visible:=False;
EditInPut.Visible:=False;
ColorBtn.Visible:=False;
ComInPut.Visible:=False;
ComInPut.Left:=Pl.Left+2;
ComInPut.Top:=(CurItem-1)*PopHeight-Sb1.VertScrollBar.ScrollPos+1;
ComInPut.Width:=Pb.Width-Pl.Left-2;
ComInPut.Height:=PopHeight-2;
ComInPut.Visible:=true;
if Self.Active then
ComInPut.SetFocus;
ComInPut.SelectAll;
end;
//选择的颜色
if TPopValue(CurPopList.FList[CurItem-1]).DataType=etColor then
begin
ColorBtn.Selected:=TPopValue(CurPopList.FList[CurItem-1]).FValue;
EditInPut.Visible:=False;
ComInPut.Visible:=False;
ColorBtn.Visible:=False;
ColorBtn.Left:=Pl.Left+2;
ColorBtn.Top:=(CurItem-1)*PopHeight-Sb1.VertScrollBar.ScrollPos+1;
ColorBtn.Width:=Pb.Width-Pl.Left-2;
ColorBtn.Height:=PopHeight-2;
ColorBtn.Visible:=true;
if Self.Active then
ColorBtn.SetFocus;
ColorBtn.SelectAll;
end;
end;
procedure TPropertyForm.ShowHelp(CurId:integer);
begin
if ObjectPropTab.TabIndex=0 then
Status.Panels[0].Text:=TPopValue(CurPopList.FList[CurItem-1]).Name
else
Status.Panels[0].Text:=TEventValue(CurEventList.FList[CurEventItem-1]).Name;
end;
//刷新编辑中的组件
procedure TPropertyForm.RefreshIdeObject;
var
PopValue:TPopValue;
vis:variant;
begin
if Self.CurIdeObject=nil then
exit;
//if Self.Loaded then
Exit;
//for i:=0 to Self.CurPopList.FList.Count-1do
begin
PopValue:=PropertyForm.CurPopList.FList[CurItem-1];
if not IsForm then
begin
//组件属性刷新
if PopValue.PopType in [ptDateFormat,ptKind,ptBorderStyle,ptDataSourceType,
ptStyle,ptShape,ptBevelInner,ptBevelOuter] then
SetOrdProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,PopValue.Index);
if PopValue.PopType in [ptAlign] then
SetOrdProp(TIdeObject(CurIdeObject),PopValue.PopName,PopValue.Index);
if PopValue.PopType in [ptVisible,ptEnabled,ptShowHint,ptTransparent,ptWordWrap,
pt3D,ptReadOnly,ptAutoScroll,ptChecked,ptShowCheckBox,ptAutoSize,ptCenter,ptFlat,
ptStretch,ptAutoFitColWidths,ptRowSelect,ptMultiSelect,ptIsLoadFromDict,ptCancel,
ptDefault] then
begin
SetOrdProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,PopValue.FValue);
if TIdeObject(CurIdeObject).SelfClass=TEacDbGrid then
TEacDbGrid(TIdeObject(CurIdeObject).ObjectCon.Components[0]).Options:=
TEacDbGrid(TIdeObject(CurIdeObject).ObjectCon.Components[0]).Options+[dgEditing];
end;
if PopValue.PopType in [ptCaption,ptText,ptHint,ptName,ptFormat,
ptClassFieldName,ptLabelFieldName,ptValueFieldName,
ptAFocusControl] then
begin
SetStrProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,PopValue.Text);
end;
if PopValue.PopType in [ptDate,ptTime,ptMaxDate,ptMinDate] then
begin
SetPropValue(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,StrToDateTime(PopValue.Text));
end;
{if PopValue.PopType in [ptName] then
begin
//TIdeObject(CurIdeObject).EacName:=PopValue.Text;
SetStrProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,PopValue.Text);
end;
}
if PopValue.PopType in [ptItems,ptLines] then
begin
if PopValue.ChildObject<>nil then
SetObjectProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,PopValue.ChildObject);
end;
if PopValue.PopType in [ptWidth,ptHeight] then
SetOrdProp(TIdeObject(CurIdeObject),PopValue.PopName,strtoint(PopValue.Text));
if PopValue.PopType in [ptLeft,ptTop] then
SetOrdProp(TIdeObject(CurIdeObject),PopValue.PopName,strtoint(PopValue.Text));
if PopValue.PopType in [ptClassStep] then
SetOrdProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,strtoint(PopValue.Text));
if PopValue.PopType in [ptPasswordChar] then
begin
if PopValue.Text='#0' then
SetOrdProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,Ord(#0))
else
SetOrdProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,
Ord(PopValue.Text[1]));
end;
if PopValue.PopType in [ptColor] then
begin
SetOrdProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,PopValue.FValue);
end;
if PopValue.PopType in [ptFont,ptPicture] then
setObjectProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],PopValue.PopName,PopValue.ChildObject);
//刷新设计的组件的显示
TIdeObject(CurIdeObject).UnSelect;
TIdeObject(CurIdeObject).Select;
//隐藏组件
vis:=GetOrdProp(TIdeObject(CurIdeObject).ObjectCon.Components[0],
GetPropInfo(TIdeObject(CurIdeObject).SelfClass,'Visible'));
if vis then
SetstrProp(TIdeObject(CurIdeObject).ObjectCon,'Caption','')
else
SetstrProp(TIdeObject(CurIdeObject).ObjectCon,'Caption','隐藏组件');
//////////////
//按钮的Action标题刷新
if (TIdeObject(CurIdeObject).SelfClass=TEacButton)and (PopValue.PopType in [ptCaption]) then
begin
if TIdeObject(CurIdeObject).SelfActionForm<>nil then
TIdeObject(CurIdeObject).SelfActionForm.Caption:=PopValue.Text;
end;
end else
begin
//窗体
if PopValue.PopType in [ptVisible,ptEnabled,ptShowHint,ptTransparent,ptWordWrap,
pt3D,ptReadOnly,ptAutoScroll,ptChecked,ptShowCheckBox,ptAutoSize,ptCenter,
ptStretch] then
begin
SetOrdProp(CurIdeForm,PopValue.PopName,PopValue.FValue);
end;
//if PopValue.PopType in [ptCaption,ptText,ptHint,ptName] then
if PopValue.PopType in [ptCaption,ptText,ptHint,ptName] then
begin
SetStrProp(CurIdeForm,PopValue.PopName,PopValue.Text);
//showmessage(CurIdeForm.Name);
end;
{if PopValue.PopType in [ptName] then
begin
CurIdeForm.EacName:=PopValue.Text;
end;
}
if PopValue.PopType in [ptWidth,ptHeight,ptLeft,ptTop] then
SetOrdProp(CurIdeForm,PopValue.PopName,strtoint(PopValue.Text));
if PopValue.PopType in [ptColor] then
begin
SetOrdProp(CurIdeForm,PopValue.PopName,PopValue.FValue);
end;
if PopValue.PopType in [ptFont,ptPicture] then
setObjectProp(CurIdeForm,PopValue.PopName,PopValue.ChildObject);
if PopValue.PopType in [ptFormBorderStyle,ptFormStyle,ptPosition,ptWindowState,ptAlign] then
SetOrdProp(CurIdeForm,PopValue.PopName,PopValue.Index);
end;
end;
CurIdeForm.RefreshObjectList;
end;
//选择属性
procedure TPropertyForm.PbMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
if CurItem<>(y div PopHeight)+1 then
begin
if (TPopValue(CurPopList.FList[CurItem-1]).DataType=etEdit) then
begin
//变化后,改变原来属性的值
//Showmessage(TPopValue(CurPopList.FList[CurItem-1]).text);
TPopValue(CurPopList.FList[CurItem-1]).text:=EditInput.Text;
//刷新组件
Self.RefreshIdeObject;
end;
end;
CurItem:=(y div PopHeight)+1;
Self.Pb.Repaint;
//Showmessage(TPopValue(CurPopList.FList[CurItem-1]).text);
Self.DrawPropertyItem(CurItem);
if (TPopValue(CurPopList.FList[CurItem-1]).DataType=etEdit) then
begin
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
if EditInput.Visible then
EditInput.SelectAll;
end;
//Showmessage(TPopValue(CurPopList.FList[CurItem-1]).text);
ShowHelp(CurItem);
Loaded:=False;
//记录当前的值
if TPopValue(CurPopList.FList[CurItem-1]).DataType=etEdit then
begin
//记录当前的值,为了以后输入错误的恢复
OldValue:=EditInput.Text;
end;
end;
//属性窗口变化
procedure TPropertyForm.SB1Resize(Sender: TObject);
begin
Pb.Width:=Sb1.ClientWidth;
Self.Pb.Repaint;
DrawPropertyItem(CurItem);
end;
//分割线移动
procedure TPropertyForm.PLMouseMove(Sender: TObject;
Shift: TShiftState;
X,
Y: Integer);
var
pp:TPoint;
begin
if MouseDown then
begin
GetCurSorPos(pp);
Pl.Left:=Pl.Left+(pp.X-Oldx);
Oldx:=pp.X;
Self.Pb.Repaint;
DrawPropertyItem(CurItem);
end;
end;
//按下分割线
procedure TPropertyForm.PLMouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
PP:TPoint;
begin
GetCurSorPos(PP);
OldX:=pp.X;
MouseDown:=true;
end;
//松开分割线
procedure TPropertyForm.PLMouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
MouseDown:=False;
if Pl.Left<40 then
Pl.Left:=40;
if Pl.Left>Self.SB1.ClientWidth-40 then
Pl.Left:=Self.SB1.ClientWidth-40;
Self.Pb.Repaint;
DrawPropertyItem(CurItem);
end;
//显示属性
procedure TPropertyForm.FormShow(Sender: TObject);
begin
//属性
Self.Loadproperty;
Self.Pb.Repaint;
Self.DrawPropertyItem(1);
//事件
Self.LoadEvent;
Self.Pb2.Repaint;
Self.DrawEventItem(1);
end;
procedure TPropertyForm.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
{if key=38 then
begin
Dec(CurItem);
if CurItem<1 then
CurItem:=1;
Self.Pb.Repaint;
DrawPropertyItem(CurItem);
ShowHelp(CurItem);
end;
if key=40 then
begin
Inc(CurItem);
if CurItem>Self.CurPopList.FList.Count then
CurItem:=Self.CurPopList.FList.Count;
Self.Pb.Repaint;
DrawPropertyItem(CurItem);
ShowHelp(CurItem);
end;
}
{if CurItem<>(y div PopHeight)+1 then
begin
if (TPopValue(CurPopList.FList[CurItem-1]).DataType=etEdit) then
begin
//变化后,改变原来属性的值
//Showmessage(TPopValue(CurPopList.FList[CurItem-1]).text);
TPopValue(CurPopList.FList[CurItem-1]).text:=EditInput.Text;
//刷新组件
Self.RefreshIdeObject;
end;
end;
CurItem:=(y div PopHeight)+1;
Self.Pb.Repaint;
//Showmessage(TPopValue(CurPopList.FList[CurItem-1]).text);
Self.DrawPropertyItem(CurItem);
if (TPopValue(CurPopList.FList[CurItem-1]).DataType=etEdit) then
begin
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
if EditInput.Visible then
EditInput.SelectAll;
end;
//Showmessage(TPopValue(CurPopList.FList[CurItem-1]).text);
ShowHelp(CurItem);
Loaded:=False;
//记录当前的值
if TPopValue(CurPopList.FList[CurItem-1]).DataType=etEdit then
begin
//记录当前的值,为了以后输入错误的恢复
OldValue:=EditInput.Text;
end;
}
end;
procedure TPropertyForm.FormDestroy(Sender: TObject);
begin
CurPopList.Free;
CurEventList.Free;
end;
procedure TPropertyForm.ComInputChange(Sender: TObject);
begin
//变化后,改变原来属性的值
TPopValue(CurPopList.FList[CurItem-1]).text:=ComInput.Text;
TPopValue(CurPopList.FList[CurItem-1]).Value:=ComInput.Text;
TPopValue(CurPopList.FList[CurItem-1]).Index:=ComInput.ItemIndex;
//刷新组件
Self.RefreshIdeObject;
end;
procedure TPropertyForm.ColorBtnChange(Sender: TObject);
begin
//变化后,改变原来属性的值
TPopValue(CurPopList.FList[CurItem-1]).Text:=ColorBtn.ColorNames[ColorBtn.itemIndex];
TPopValue(CurPopList.FList[CurItem-1]).Value:=ColorBtn.Selected;
TPopValue(CurPopList.FList[CurItem-1]).Index:=ColorBtn.ItemIndex;
//刷新组件
Self.RefreshIdeObject;
end;
procedure TPropertyForm.EditInputKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
Self.FormKeyDown(Sender,Key,Shift);
end;
procedure TPropertyForm.ComInputKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
Self.FormKeyDown(Sender,Key,Shift);
end;
procedure TPropertyForm.ColorBtnKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
Self.FormKeyDown(Sender,Key,Shift);
end;
procedure TPropertyForm.FormMouseWheel(Sender: TObject;
Shift: TShiftState;
WheelDelta: Integer;
MousePos: TPoint;
var Handled: Boolean);
begin
Sb1.VertScrollBar.Position:=Sb1.VertScrollBar.Position-Trunc(WheelDelta/20);
end;
procedure TPropertyForm.BtnEditClick(Sender: TObject);
var
mr:TModalResult;
begin
//子对象编辑窗口
//字体类型
if TPopValue(Self.CurPopList.FList[CurItem-1]).PopType=ptFont then
begin
FontDialog.Font:=TFont(TPopValue(Self.CurPopList.FList[CurItem-1]).ChildObject);
if FontDialog.Execute then
begin
TPopValue(Self.CurPopList.FList[CurItem-1]).ChildObject:=FontDialog.Font;
end;
end;
if TPopValue(Self.CurPopList.FList[CurItem-1]).PopType=ptPicture then
begin
//打开图形浏览界面
PictureEditorForm.YImage.Picture:=TPicture(TPopValue(Self.CurPopList.FList[CurItem-1]).ChildObject);
mr:=PictureEditorForm.showmodal;
if mr=mrok then
begin
TPopValue(Self.CurPopList.FList[CurItem-1]).ChildObject:=PictureEditorForm.YImage.Picture;
if PictureEditorForm.Loaded then
begin
TPopValue(Self.CurPopList.FList[CurItem-1]).Text:='(Picture)';
end else
begin
TPopValue(Self.CurPopList.FList[CurItem-1]).Text:='(None)';
end;
end;
end;
if TPopValue(Self.CurPopList.FList[CurItem-1]).PopType in [ptLines,ptItems] then
begin
//打开图形浏览界面
if self.CurIdeObject<>nil then
begin
if TIdeObject(CurIdeObject).SelfClass=TEacMemo then
StringsEditorForm.LineMemo.Lines.Assign(TEacMemo(TIdeObject(CurIdeObject).ObjectCon.Components[0]).Lines);
if TIdeObject(CurIdeObject).SelfClass=TEacComboBox then
StringsEditorForm.LineMemo.Lines.Assign(TEacComboBox(TIdeObject(CurIdeObject).ObjectCon.Components[0]).Items);
if TIdeObject(CurIdeObject).SelfClass=TEacListBox then
StringsEditorForm.LineMemo.Lines.Assign(TEacListBox(TIdeObject(CurIdeObject).ObjectCon.Components[0]).Items);
end else
StringsEditorForm.LineMemo.Lines.Text:='';
mr:=StringsEditorForm.showmodal;
if mr=mrok then
begin
TPopValue(Self.CurPopList.FList[CurItem-1]).ChildObject:=StringsEditorForm.LineMemo.Lines;
end;
end;
Self.Pb.Repaint;
Self.DrawPropertyItem(CurItem);
//回显组件
Self.RefreshIdeObject;
end;
procedure TPropertyForm.EditInputKeyPress(Sender: TObject;
var Key: Char);
var
i:integer;
FormsNode,ANode:TXmlNode;
OldEacName:string;
begin
if key=#13 then
begin
OldEacName:='';
//变化后,改变原来属性的值
//首先不能够为空
if TPopValue(CurPopList.FList[CurItem-1]).PopName='EacName' then
begin
{if not(EditInput.Text[1] in ['a'..'z','A'..'Z','_']) then
begin
showmessage('名称设定不正确!');
Exit;
end;
}
if length(trim(EditInput.Text))=0 then
begin
showmessage('名称不能够为空!');
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
Exit;
end;
if CurIdeForm.CurSelectedOb<>nil then
begin
//showmessage(GetStrProp(CurIdeForm.CurSelectedOb.ObjectCon.Components[0],'EacName'));
{if not CurIdeForm.NameManager.SetObjectEacName(CurIdeForm.CurSelectedOb.SelfClass,
CurIdeForm.CurSelectedOb.ObName,EditInput.Text) then
}
OldEacName:=GetStrProp(CurIdeForm.CurSelectedOb.ObjectCon.Components[0],'EacName');
if not CurIdeForm.NameManager.SetObjectEacName(OldEacName,EditInput.Text) then
begin
showmessage('名称不能够重复或者不合法!');
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
exit;
end;
//修改其对应的ActionName
for i:=0 to CurIdeForm.XmlScript.Root.NodeCount-1do
begin
ANode:=CurIdeForm.XmlScript.Root.Nodes;
if SameText(ANode.AttributeByName['Name'],OldEacName) then
begin
//存在,替换
ANode.AttributeByName['Name']:=EditInput.Text;
end;
end;
end else
begin
//循环应用程序节点,判断有无重复的,可以修改的话就修改EacName
//showmessage(Main_Form.XmlScript.WriteToString);
FormsNode:=Main_Form.XmlScript.Root.NodeByName('Forms');
if FormsNode<>nil then
begin
for i:=0 to FormsNode.NodeCount-1do
begin
if (FormsNode.Nodes<>CurIdeForm.SelfFormNode)and
(FormsNode.Nodes.AttributeByName['EacName']=EditInput.Text) then
begin
showmessage('名称不能够重复或者不合法!');
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
exit;
end;
end;
//OldEacName
OldEacName:=CurIdeForm.EacName;
if not Main_Form.FormNameManager.SetObjectEacName(
OldEacName,EditInput.Text) then
begin
showmessage('名称不能够重复或者不合法!');
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
exit;
end;
//允许的情况下,修改EacName
CurIdeForm.SelfFormNode.AttributeByName['EacName']:=EditInput.Text;
//判断是否为MainForm和FlashForm
if FormsNode.AttributeByName['MainForm']=OldEacName then
FormsNode.AttributeByName['MainForm']:=EditInput.Text;
if FormsNode.AttributeByName['FlashForm']=OldEacName then
FormsNode.AttributeByName['FlashForm']:=EditInput.Text;
//修改逻辑节点
CurIdeForm.XmlScript.Root.AttributeByName['Name']:=EditInput.Text;
//修改AppFormList的EacName
TFormBuffer(Main_Form.AppFormList.Objects[
Main_Form.AppFormList.IndexOf(CurIdeForm.Name)]).EacName:=EditInput.Text;
end;
//修改其对应的ActionName
for i:=0 to CurIdeForm.XmlScript.Root.NodeCount-1do
begin
ANode:=CurIdeForm.XmlScript.Root.Nodes;
if SameText(ANode.AttributeByName['Name'],OldEacName) then
begin
//存在,替换
ANode.AttributeByName['Name']:=EditInput.Text;
end;
end;
end;
end;
TPopValue(CurPopList.FList[CurItem-1]).text:=EditInput.Text;
//刷新组件
Self.RefreshIdeObject;
EditInput.SetFocus;
EditInput.SelectAll;
//刷新Script
//if ScriptForm.Visible then
ScriptForm.OnShow(Sender);
//ScriptForm.FormScript.Text:=CurIdeForm.XmlScript.WriteToString;
end;
end;
procedure TPropertyForm.FormDeactivate(Sender: TObject);
var
I:integer;
FormsNode:TXmlNode;
begin
//Exit;
if CurPopList.FList.Count=0 then
Exit;
if ObjectPropTab.TabIndex=1 then
Exit;
if (TPopValue(CurPopList.FList[CurItem-1]).DataType=etEdit) then
begin
//变化后,改变原来属性的值
//首先不能够为空
if TPopValue(CurPopList.FList[CurItem-1]).PopName='EacName' then
begin
{if not(EditInput.Text[1] in ['a'..'z','A'..'Z','_']) then
begin
showmessage('名称设定不正确!');
Exit;
end;
}
if length(trim(EditInput.Text))=0 then
begin
showmessage('名称不能够为空!');
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
Exit;
end;
if CurIdeForm.CurSelectedOb<>nil then
begin
//showmessage(GetStrProp(CurIdeForm.CurSelectedOb.ObjectCon.Components[0],'EacName'));
if not CurIdeForm.NameManager.SetObjectEacName(
GetStrProp(CurIdeForm.CurSelectedOb.ObjectCon.Components[0],'EacName'),
EditInput.Text) then
begin
showmessage('名称不能够重复或者不合法!');
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
exit;
end;
end else
begin
if not Main_Form.FormNameManager.SetObjectEacName(
CurIdeForm.EacName,EditInput.Text) then
begin
showmessage('名称不能够重复或者不合法!');
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
exit;
end;
//循环应用程序节点,判断有无重复的,可以修改的话就修改EacName
FormsNode:=Main_Form.XmlScript.Root.NodeByName('Forms');
//showmessage(CurIdeForm.SelfFormNode.WriteToString);
for i:=0 to FormsNode.NodeCount-1do
begin
if (FormsNode.Nodes<>CurIdeForm.SelfFormNode)and
(FormsNode.Nodes.AttributeByName['EacName']=EditInput.Text) then
begin
showmessage('名称不能够重复或者不合法!');
EditInput.Text:=TPopValue(CurPopList.FList[CurItem-1]).text;
exit;
end;
end;
//允许的情况下,修改EacName
CurIdeForm.SelfFormNode.AttributeByName['EacName']:=EditInput.Text;
end;
end;
//变化后,改变原来属性的值
TPopValue(CurPopList.FList[CurItem-1]).text:=EditInput.Text;
//刷新组件
Self.RefreshIdeObject;
end;
end;
procedure TPropertyForm.PanelBackResize(Sender: TObject);
begin
//对象列表设置位置大小
ObjectList.Left:=0;
ObjectList.Top:=0;
ObjectList.Width:=PanelBack.ClientWidth;
end;
procedure TPropertyForm.ObjectListChange(Sender: TObject);
begin
//改变对组件的选择
if ObjectList.ItemIndex=0 then
CurIdeForm.UnSelect else
begin
CurIdeForm.UnSelect;
TIdeObject(CurIdeForm.FIdeObList.Objects[ObjectList.ItemIndex-1]).Select;
end;
//显示属性
CurIdeForm.ShowProperty(CurIdeForm.CurSelectedOb);
//属性显示到编辑器
CurIdeForm.LoadFromObject(CurIdeForm.CurSelectedOb);
//事件
CurIdeForm.LoadEventFromObject(CurIdeForm.CurSelectedOb);
end;
procedure TPropertyForm.FormResize(Sender: TObject);
begin
//刷新
if CurIdeForm<>nil then
CurIdeForm.RefreshObjectList;
end;
procedure TPropertyForm.Pb2Paint(Sender: TObject);
var
i:integer;
EventNum:integer;
begin
begin
Pb2.Canvas.FillRect(Pb2.Canvas.ClipRect);
EventNum:=Self.CurEventList.FList.Count;
//循环写入事件列表和事件内容
for i:=0 to EventNum-1do
begin
Pb2.Canvas.Pen.Color:=clGrayText;
pb2.Canvas.MoveTo(0,PopHeight*(i+1)-1);
Pb2.Canvas.LineTo(Pb2.Width,PopHeight*(i+1)-1);
//名字
Pb2.Canvas.TextRect(Rect(4,PopHeight*(i)+1,Pl2.Left,PopHeight*(i+1)-1),
4,PopHeight*(i)+4,TEventValue(Self.CurEventList.FList).Name);
//内容
Pb2.Canvas.TextRect(Rect(Pl2.Left+3,PopHeight*(i)+1,Sb2.ClientWidth-1,PopHeight*(i+1)-1),
Pl2.Left+3,PopHeight*(i)+4,TEventValue(Self.CurEventList.FList).Text);
end;
//标注当前选择的事件
Pb2.Canvas.Pen.Color:=clBlack;
pb2.Canvas.MoveTo(0,PopHeight*(CurEventItem-1));
Pb2.Canvas.LineTo(Pb2.Width,PopHeight*(CurEventItem-1));
Pb2.Canvas.Pen.Color:=ClWhite;
pb2.Canvas.MoveTo(0,PopHeight*CurEventItem-1);
Pb2.Canvas.LineTo(Pb2.Width,PopHeight*CurEventItem-1);
end;
end;
procedure TPropertyForm.Pb2MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
CurEventItem:=(y div PopHeight)+1;
ComEvent.Text:=TEventValue(CurEventList.FList[CurEventItem-1]).text;
Self.Pb2.Repaint;
Self.DrawEventItem(CurEventItem);
ShowHelp(CurEventItem);
Loaded:=False;
end;
procedure TPropertyForm.ComEventChange(Sender: TObject);
begin
//变化后,改变原来属性的值
TEventValue(CurEventList.FList[CurEventItem-1]).text:=ComEvent.Text;
end;
procedure TPropertyForm.Sb2Resize(Sender: TObject);
begin
Pb2.Width:=Sb2.ClientWidth;
Self.Pb2.Repaint;
DrawEventItem(CurEventItem);
end;
procedure TPropertyForm.Pl2MouseDown(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
var
PP:TPoint;
begin
GetCurSorPos(PP);
OldX:=pp.X;
MouseDown:=true;
end;
procedure TPropertyForm.Pl2MouseMove(Sender: TObject;
Shift: TShiftState;
X, Y: Integer);
var
pp:TPoint;
begin
if MouseDown then
begin
GetCurSorPos(pp);
Pl2.Left:=Pl2.Left+(pp.X-Oldx);
Oldx:=pp.X;
Self.Pb2.Repaint;
DrawEventItem(CurEventItem);
end;
end;
procedure TPropertyForm.Pl2MouseUp(Sender: TObject;
Button: TMouseButton;
Shift: TShiftState;
X, Y: Integer);
begin
MouseDown:=False;
if Pl2.Left<40 then
Pl2.Left:=40;
if Pl2.Left>Self.SB2.ClientWidth-40 then
Pl2.Left:=Self.SB2.ClientWidth-40;
Self.Pb2.Repaint;
DrawEventItem(CurEventItem);
end;
procedure TPropertyForm.ObjectPropTabChange(Sender: TObject);
begin
if ObjectPropTab.TabIndex=0 then
DrawPropertyItem(CurItem);
if ObjectPropTab.TabIndex=1 then
DrawEventItem(CurEventItem);
end;
procedure TPropertyForm.ComEventDblClick(Sender: TObject);
var
i:integer;
XmlNode:TXmlNode;
Cz:boolean;
begin
//打开Action设计
if Self.ObjectList.ItemIndex>0 then
begin
Cz:=false;
for i:=0 to CurIdeForm.XmlScript.Root.NodeCount-1do
begin
XmlNode:=CurIdeForm.XmlScript.Root.Nodes;
if (XmlNode.AttributeByName['Name']=
getStrProp(TIdeObject(Self.CurIdeObject).ObjectCon.Components[0],'EacName'))and
(XmlNode.AttributeByName['Event']=
TEventValue(Self.CurEventList.FList[CurEventItem-1]).EventTypeText) then
begin
//存在按钮对应的节点
ActionDesignForm.SelfNode:=XmlNode;
ActionDesignForm.SourceActionObject:=nil;
ActionDesignForm.SourceDesignerForm:=CurIdeForm;
ActionDesignForm.ActionNode:=XmlNode;
ActionDesignForm.Show;
ActionDesignForm.OnShow(nil);
cz:=true;
Break;
end;
end;
if not Cz then
begin
CurIdeForm.CurNode:=CurIdeForm.XmlScript.Root.NodeNew('Action');
CurIdeForm.CurNode.AttributeAdd('Name',
GetStrProp(TIdeObject(Self.CurIdeObject).ObjectCon.Components[0],'EacName'));
CurIdeForm.CurNode.AttributeAdd('Event',
TEventValue(Self.CurEventList.FList[CurEventItem-1]).EventTypeText);
TEventValue(Self.CurEventList.FList[CurEventItem-1]).Text:=
GetStrProp(TIdeObject(Self.CurIdeObject).ObjectCon.Components[0],'EacName')+
TEventValue(Self.CurEventList.FList[CurEventItem-1]).EventTypeText;
ActionDesignForm.SelfNode:=CurIdeForm.CurNode;
ActionDesignForm.SourceActionObject:=nil;
ActionDesignForm.SourceDesignerForm:=CurIdeForm;
ActionDesignForm.ActionNode:=ActionDesignForm.SelfNode;
ActionDesignForm.Show;
ActionDesignForm.OnShow(nil);
//创建新的Action事件就要刷新结构
if ModelDesignForm.Visible then
ModelDesignForm.LoadActions;
end;
ActionDesignForm.EventValue:=TEventValue(Self.CurEventList.FList[CurEventItem-1]);
//读取xml文档,并画出图形
ActionDesignForm.DrawChart(ActionDesignForm.SelfNode);
TEventValue(Self.CurEventList.FList[CurEventItem-1]).OpenActionForm:=True;
ActionDesignForm.SourceDesignerObject:=TIdeObject(Self.CurIdeObject);
ActionDesignForm.SourceDesignerForm:=CurIdeForm;
ActionDesignForm.SourceType:=1;
end else
begin
Cz:=false;
for i:=0 to CurIdeForm.XmlScript.Root.NodeCount-1do
begin
XmlNode:=CurIdeForm.XmlScript.Root.Nodes;
if (XmlNode.AttributeByName['Name']=CurIdeForm.EacName)and
(XmlNode.AttributeByName['Event']=
TEventValue(Self.CurEventList.FList[CurEventItem-1]).EventTypeText) then
begin
//存在按钮对应的节点
CurIdeForm.CurNode:=XmlNode;
ActionDesignForm.SelfNode:=CurIdeForm.CurNode;
ActionDesignForm.SourceActionObject:=nil;
ActionDesignForm.SourceDesignerForm:=CurIdeForm;
ActionDesignForm.ActionNode:=XmlNode;
ActionDesignForm.Show;
ActionDesignForm.OnShow(nil);
cz:=true;
Break;
end;
end;
if not Cz then
begin
CurIdeForm.CurNode:=CurIdeForm.XmlScript.Root.NodeNew('Action');
CurIdeForm.CurNode.AttributeAdd('Name',CurIdeForm.EacName);
CurIdeForm.CurNode.AttributeAdd('Event',
TEventValue(Self.CurEventList.FList[CurEventItem-1]).EventTypeText);
TEventValue(Self.CurEventList.FList[CurEventItem-1]).Text:=
CurIdeForm.EacName+TEventValue(Self.CurEventList.FList[CurEventItem-1]).EventTypeText;
ActionDesignForm.SelfNode:=CurIdeForm.CurNode;
ActionDesignForm.SourceActionObject:=nil;
ActionDesignForm.SourceDesignerForm:=CurIdeForm;
ActionDesignForm.ActionNode:=CurIdeForm.CurNode;
ActionDesignForm.Show;
ActionDesignForm.OnShow(nil);
//创建新的Action事件就要刷新结构
if ModelDesignForm.Visible then
ModelDesignForm.LoadActions;
end;
ActionDesignForm.EventValue:=TEventValue(Self.CurEventList.FList[CurEventItem-1]);
//读取xml文档,并画出图形
ActionDesignForm.DrawChart(ActionDesignForm.SelfNode);
ActionDesignForm.EventValue:=TEventValue(Self.CurEventList.FList[CurEventItem-1]);
TEventValue(Self.CurEventList.FList[CurEventItem-1]).OpenActionForm:=True;
ActionDesignForm.SourceType:=0;
end;
ActionDesignForm.SourceDesignerForm:=CurIdeForm;
ComEvent.Text:=TEventValue(Self.CurEventList.FList[CurEventItem-1]).Text;
Self.pb2.Repaint;
Self.DrawEventItem(CurEventItem);
end;
procedure TPropertyForm.ComInputDblClick(Sender: TObject);
begin
if ComInput.Items.Count>0 then
begin
if ComInput.ItemIndex=ComInput.Items.Count-1 then
ComInput.ItemIndex:=0 else
ComInput.ItemIndex:=ComInput.ItemIndex+1;
ComInput.OnChange(nil);
end;
end;
end.