📄 utype.pas
字号:
end;
function TProxyDesigner.GetIsDormant: Boolean;
begin
Result:= False;
end;
function TProxyDesigner.HasInterface: Boolean;
begin
Result:= False;
end;
function TProxyDesigner.HasInterfaceMember(const Name: string): Boolean;
begin
Result:= False;
end;
procedure TProxyDesigner.PaintGrid;
var
i, j, HStart, HEnd, VStart, VEnd, HCount, VCount, X, Y, SizeX,SizeY: integer;
begin
if not IniFile.ReadBool('SYSTEM','DisplayGrid',True) then Exit;
SizeX:= IniFile.ReadInteger('SYSTEM','GridSizeX',8);
SizeY:= IniFile.ReadInteger('SYSTEM','GridSizeY',8);
with Form do
begin
Canvas.Pen.color := clBlack;
Canvas.Pen.width := 1;
VStart := (Canvas.ClipRect.Top div SizeY) * SizeY;
VEnd := (Canvas.ClipRect.Bottom div SizeY) * SizeY;
HStart := (Canvas.ClipRect.Left div SizeX) * SizeX;
HEnd := (Canvas.ClipRect.Right div SizeX) * SizeX;
HCount := (HEnd - HStart) div SizeX + 1;
VCount := (VEnd - VStart) div SizeY + 1;
Y := VStart;
for i := 1 to VCount do
begin
X := HStart;
for j := 1 to HCount do
begin
Canvas.moveto(X, Y);
Canvas.LineTo(X+1, Y+1);
X := X + SizeX;
end;
Y := Y + SizeY;
end;
end;
end;
procedure TProxyDesigner.ValidateRename(AComponent: TComponent;
const CurName, NewName: string);
begin
end;
{ Create a new method called Name, whose type is TypeData. Assign a unique
identifier for the method by using its index in the string list. Offset the
index by 1, so that index 0 can be interpreted as a nil pointer. Thus, the
first method in the list has index 1. After creating the method, show it
to the user. }
function TProxyDesigner.CreateMethod(const Name: string; TypeData: PTypeData): TMethod;
begin
if not MethodExists(Name) then
Methods.AddObject(Name, TObject(TypeData));
Result.Data := Form;
Result.Code := Pointer(Methods.IndexOf(Name) + 1);
ShowMethod(Name);
end;
{ Call Proc for each method whose type matches TypeData. }
procedure TProxyDesigner.GetMethods(TypeData: PTypeData; Proc: TGetStrProc);
var
I: Integer;
begin
with Methods do
for I := 0 to Count-1 do
if Objects[I] = TObject(TypeData) then
Proc(Strings[I]);
end;
{ Get the name of a method whose pointer is TMethod. Look up the
method name by its index in the method's Code field. Remember that
indexes are offset by one. }
function TProxyDesigner.GetMethodName(const Method: TMethod): string;
var
I:integer;
begin
I:= Methods.IndexOfObject(Method.code);
if Method.Code = nil then Result := ''
else if I <> -1 then Result := Methods.Strings[I]
else Result:= Form.MethodName(Method.Code)
// else Result := Methods.Strings[Integer(Method.Code) - 1];
end;
{ Return whether a method exists with the given Name. }
function TProxyDesigner.MethodExists(const Name: string): Boolean;
begin
Result := Methods.IndexOf(Name) >= 0;
end;
{ Rename a method from CurName to NewName. }
procedure TProxyDesigner.RenameMethod(const CurName, NewName: string);
var
Index: Integer;
begin
Index := Methods.IndexOf(CurName);
if Index = -1 then Exit;
Methods.Strings[Index] := NewName;
end;
{ Show a method to the user by highlighting it in the list box. }
procedure TProxyDesigner.ShowMethod(const Name: string);
begin
//ComponentForm.MethodList.ItemIndex := Methods.IndexOf(Name);
end;
function TProxyDesigner.GetPrivateDirectory: string;
begin
end;
{$ifndef VER80}
{ No form inheritance in the debugging designer. }
function TProxyDesigner.MethodFromAncestor(const Method: TMethod): Boolean;
begin
Result := False;
end;
{$endif}
// Set focus to next control when deleted selected components
procedure TProxyDesigner.FindNextControl;
var
Name:string;
Index:Integer;
begin
if TProxyForm(Form).ComponentList.Count <= 0 then
begin
ObjectInspector.ComponentList.ItemIndex:=0;
ObjectInspector.ComponentListClick(self);
Exit;
end;
Name:= TProxyForm(Form).ComponentList[TProxyForm(Form).ComponentList.Count - 1];
Index:= ObjectInspector.ComponentList.Items.IndexOf(Name);
if Index <> -1 then
ObjectInspector.ComponentList.ItemIndex:= Index
else ObjectInspector.ComponentList.ItemIndex:=0;
ObjectInspector.ComponentListClick(self);
end;
// Delete Control
procedure TProxyDesigner.DeleteControl(Control: TControl;Next:Boolean);
var
Name:string;
Index:Integer;
begin
if (Control = nil) or (Control = Form) then Exit;
Name:= Control.Name + ':' + Control.ClassName;
Index:= TProxyForm(Form).ComponentList.IndexOf(Name);
if Index <> -1 then TProxyForm(Form).ComponentList.Delete(Index);
ObjectInspector.ComponentList.Items.Delete(ObjectInspector.ComponentList.Items.IndexOf(Name));
EditorForm.WriteComponentCode(Control.Name,
TComponentClass(Control.ClassType),wrDelete);
Control.Free;
if Next then FindNextControl; // 急琶且 哪欺惩飘甫 茫酒 急琶茄促.
end;
// Delete selected component list
procedure TProxyDesigner.DeleteSelectList;
var
I:Integer;
begin
TProxyForm(Form).SelectControl:= nil;
for I:= 0 to fSelectList.Count - 1 do
DeleteControl(fSelectList[I], False);
fSelectList.Clear;
ClearSelectList;
FindNextControl;
FMainForm.UpdateControl(psChange);
end;
procedure TProxyDesigner.ClearSelectList;
var
I:Integer;
begin
for I:=fGrabList.Count-1 downto 0 do
TGrabHandles(fGrabList[I]).Free;
fGrabList.Clear;
fSelectList.Clear;
if TProxyForm(Form).DragRectList <> nil then
TProxyForm(Form).DragRectList.Clear;
end;
procedure TProxyDesigner.SelectComponent(Instance: TPersistent);
// Select component
var
I,Index:Integer;
begin
if Instance = nil then Exit;
if IsSelected(TControl(Instance)) then Exit;
if not fMultiSelected then ClearSelectList;
fGrabHandles:= TGrabHandles.Create(TControl(Instance));
if fMultiSelected then
begin
// 促吝 哪欺惩飘 急琶矫 急琶等 哪欺惩飘狼 祸惑,困摹 殿殿 汲沥茄促.
if fGrabList.Count >= 1 then
TGrabHandles(fGrabList[0]).MultiSelected:= True;
fGrabHandles.MultiSelected:= True;
end;
if TProxyForm(Form).DragRectList <> nil then
TProxyForm(Form).DragRectList.Add(TControl(Instance));
Index:= fSelectList.IndexOf(Instance);
fGrabList.Add(TPersistent(fGrabHandles));
// 急琶 哪欺惩飘 格废俊 绝绰 版快 , 格废俊 哪欺惩飘甫 眠啊茄促.
if Index = -1 then fSelectList.Add(Instance);
TProxyForm(Form).SelectControl:= TControl(Instance);
end;
// Create new component
// ComponentClass: component's class
// Parent: component's parent
// Left,Top,Width,Height: component's position
function TProxyDesigner.CreateComponent(ComponentClass: TComponentClass;Parent:TComponent;
Left,Top,Width,Height:Integer):TComponent;
var
Component: TComponent;
Control :TControl;
Po: TPoint;
LeftTop: LongInt;
procedure SetControlPosition;
begin
if IniFile.ReadBool('SYSTEM','SnapGrid',True) then
begin
GetNearestGridPoint(Point(Left, Top), Po);
if Left > 0 then Control.Left := Po.X;
if Top > 0 then Control.Top := Po.Y;
if Width > 0 then Control.Width := Width;
if Height > 0 then Control.Height:= Height;
end
else
begin
if Left > 0 then Control.Left := Left;
if Top > 0 then Control.Top := Top;
if Width > 0 then Control.Width := Width;
if Height > 0 then Control.Height:= Height;
end;
end;
begin
Result:= nil;
if ComponentClass = nil then Exit;
Component:= ComponentClass.Create(Form);
if Component is TControl then // Create a control for visual component
begin
Control:= TControl(Component);
Control.Name:= UniqueName(ComponentClass.ClassName);
SetControlPosition;
Control.Parent:= TWinControl(Parent);
end
else
begin // Create a wrapper control for nonvisual components.
Control:= TWrapperControl.Create(Form, Component);
// Wrapper's name = 'wrapper' + component name
Component.Name:= UniqueName(ComponentClass.ClassName);
Control.Name:= 'Wrapper' + Component.Name;
SetControlPosition;
LongRec(LeftTop).Lo := Control.Left;
LongRec(LeftTop).Hi := Control.Top;
Component.DesignInfo:= LeftTop;
Control.Parent := TWinControl(Parent);
end;
EditorForm.CheckUseUnit(Control);
// 积己茄 哪欺惩飘啊 皋技瘤甫 罐瘤 臼档废 csDesigning flag甫 True肺 汲沥茄促.
TExposeComponent(Control).SetDesigning(True);
// Create component's code at editor
EditorForm.WriteComponentCode(Component.Name,ComponentClass,wrInsert);
TProxyForm(Form).SelectControl:= Control;
TProxyForm(Form).GrabHandles := fGrabHandles;
FMainForm.UpdateControl(psChange);
AddComponentList(Component);
// Display component's property and value at object inspector
if Control.ClassType = TWrapperControl then
ObjectInspector.DisplayProperty(Control,(Control as TWrapperControl).Component)
else ObjectInspector.DisplayProperty(nil,Control);
// 哪欺惩飘狼 迫饭飘 其捞瘤俊辑 拳混钎 滚瓢阑 急琶茄促.
if not FMainForm.ShiftKeyed then
TSpeedButton(FMainForm.PageControl1.ActivePage.Controls[0]).Down:= True;
Result:= Component;
end;
function TProxyDesigner.CreateWrapperComponent(Component: TComponent;
Left,Top:Integer):TComponent;
var
Control :TControl;
Po: TPoint;
begin
Result:= nil;
if Component = nil then Exit;
Control := TWrapperControl.Create(Form, Component);
// Wrapper狼 捞抚篮 Wrapper+哪欺惩飘狼 捞抚栏肺 沥茄促.
Control.Name := 'Wrapper'+Component.Name;
Control.Left := Left;
Control.Top := Top;
Control.Parent := TWinControl(Form);
EditorForm.CheckUseUnit(Control);
// 积己茄 哪欺惩飘啊 皋技瘤甫 罐瘤 臼档废 csDesigning flag甫 True肺 汲沥茄促.
TExposeComponent(Control).SetDesigning(True);
TProxyForm(Form).GrabHandles := fGrabHandles;
AddComponentList(Component);
Result:= Component;
end;
{钎霖 胆颇捞狼 盔蘑阑 荤侩窍咯 哪欺惩飘俊 措茄 蜡老茄 捞抚阑 积己茄促. 溜 <鸥涝><箭磊>
屈侥阑 荤侩窍绰单, <鸥涝>篮 哪欺惩飘狼 努贰胶 捞抚俊辑 'T'甫 猾 巴捞绊, <箭磊>绰
捞抚阑 窜老窍霸 父甸扁 困茄 沥荐捞促.}
function TProxyDesigner.UniqueName(const BaseName:string):string;
var
I:Integer;
Fmt:string;
begin
if BaseName[1] in ['t','T'] then Fmt:= Copy(BaseName,2,255)+'%d'
else Fmt:= BaseName + '%d';
{蜡老茄 捞抚捞 唱棵 锭鳖瘤 , 啊瓷茄 箭磊甫 葛滴 矫氰茄促.}
for I:=1 to High(Integer) do
begin
Result:= Format(Fmt,[I]);
if Form.FindComponent(Result)= nil then Exit;
end;
end;
// 汽俊 乐绰 哪欺惩飘狼 格废阑 炼荤茄促.
procedure TProxyDesigner.GetComponentList;
var
I:integer;
begin
ObjectInspector.ComponentList.Clear;
ObjectInspector.ComponentList.Items.Add(Form.Name+':TForm');
with Form do begin
for I:=0 to ComponentCount-1 do
if (Components[I].ClassType<>TGrabHandle) and (Components[I].ClassType<>TWrapperControl) then
ObjectInspector.ComponentList.Items.Add(Components[I].Name+':'+Components[I].ClassName)
end;
end;
// 橇废矫 汽俊辑 急琶茄 牧飘费捞 公均牢瘤 炼荤茄促.
function TProxyDesigner.GetFocusedControl(Msg: TMsg): TControl;
var
FocusControl: TControl;
I:Integer;
P:TPoint;
begin
FocusControl:=nil;
if Msg.HWnd=Form.Handle then
begin
// 汽 肚绰 WinControl牢 酒囱 促弗 哪欺惩飘甫 急琶茄 版快
FocusControl:=Form.ControlAtPos(Form.ScreenToClient(Msg.Pt),True);
if FocusControl = nil then FocusControl:=Form;
end
else
begin
for I:=0 to Form.ComponentCount-1 do
if (Form.Components[I] is TWinControl) and
(Msg.HWnd=TWinControl(Form.Components[I]).Handle) then
FocusControl:=TControl(Form.Components[I]);
end;
Result:=FocusControl;
end;
// 货肺款 哪欺惩飘甫 Object Inspector狼 哪欺惩飘 格废俊 眠啊茄促.
procedure TProxyDesigner.AddComponentList(Component:TComponent);
begin
if Component = nil then Exit;
ObjectInspector.ComponentList.Items.Add(Component.Name+':'+Component.ClassName);
TProxyForm(Form).ComponentList.Add(Component.Name+':'+Component.ClassName);
ComponentList.Add(Component);
end;
// 橇废矫 汽俊辑 惯积窍绰 葛电 皋技瘤甫 贸府茄促.
function TProxyDesigner.IsDesignMsg(Sender: TControl;var Message: TMessage): Boolean;
begin
Result := True;
case Message.Msg of
WM_KEYDOWN : ProcessKeyDown (Message);
WM_KEYUP : ProcessKeyUp (Message);
WM_LBUTTONDOWN : ProcessMouseDown (Sender, Message);
WM_RBUTTONDOWN : ProcessRMouseDown(Sender, Message);
WM_MOUSEMOVE : ProcessMouseMove (Sender, Message);
WM_LBUTTONDBLCLK: ProcessDblClick (Sender, Message);
WM_LBUTTONUP : ProcessMouseUp (Sender, Message);
else Result:= False;
end;
end;
function TProxyDesigner.CreatePopupMenu : TPopupMenu;
var
Menu:TPopupMenu;
Po:TPoint;
Component:TComponent;
// 扑诀 皋春俊 皋春 亲格阑 眠啊茄促.
procedure AddMenuItem(Menu:TPopupMenu;ItemName:string;Name:string;Enable:Boolean; ImgIndex: Integer);
var
NewMenuItem:TMenuItem;
begin
NewMenuItem := TMenuItem.Create(Application);
NewMenuItem.Name := Name;
NewMenuItem.Caption:= ItemName;
NewMenuItem.Enabled:= Enable;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -