📄 objectinspec.~pas
字号:
LineTo(Rect.Left+1, Rect.Top+1);
LineTo(Rect.Left+1, Rect.Bottom-1);
end
else
begin
Pen.Color := clBtnShadow;
MoveTo(Halfway, Rect.Top+1);
LineTo(Halfway, Rect.Bottom);
Pen.Color := clBtnHighLight;
MoveTo(HalfWay + 1, Rect.Top+1);
LineTo(Halfway + 1, Rect.Bottom);
end;
SR.Left := Rect.Left+2 ; SR.Right := HalfWay;
SR.Top := Rect.Top+1; SR.Bottom := Rect.Bottom-1;
if (odFocused in State) then
begin
Inc(SR.Left);
Inc(SR.Top);
Inc(SR.Right);
end;
// Item狼 加己疙苞 加己蔼阑 免仿
Font.Color := clBlack;
setbkMode(PropertyBox.Canvas.Handle, Transparent);
PropName:= Copy(PropertyBox.Items[Index],1,20);
PropValue:= Copy(PropertyBox.Items[Index],21,255);
if PropName[1] = '+' then
TextRect(SR, Sr.Left, SR.Top+1, PropName )
else TextRect(SR, Sr.Left+10, SR.Top+1, PropName );
Font.Color := clNavy;
TextOut(HalfWay + 4, SR.Top+1, PropValue );
DR.Left:= Rect.Left+2; DR.Right := Rect.Left+13+2; {DestRect}
DR.Top := Rect.Top+1; DR.Bottom := Rect.Top+13+1;
if (odSelected in State) then
begin { To give 3D look to inspector.}
Inc(DR.Left); Inc(DR.Right);
Inc(DR.Top); Inc(DR.Bottom);
if edProperty.Visible then
begin
with Rect do
begin
if (Top <= 0) and (PropertyBox.ItemIndex <> 0) then
edProperty.Visible:= False
else if (Bottom > PropertyBox.Height) then
edProperty.Visible:= False
else edProperty.SetBounds(HalfWay+4, Top+2, Right-HalfWay, Bottom-Top);
end;
end
else if cbValue.Visible then
begin
// PropertyBox甫 胶农费矫 cbValue狼 困摹甫 犁炼沥茄促.
with Rect do
begin
if (Top <= 0) and (PropertyBox.ItemIndex <> 0) then
cbValue.Visible:= False
else if (Bottom > PropertyBox.Height) then
cbValue.Visible:= False
else cbValue.SetBounds(HalfWay+4, Top+2, Right-HalfWay, Bottom-Top);
end;
end
else if Browse.Visible then
begin
with Rect do
begin
if (Top <= 0) and (PropertyBox.ItemIndex <> 0) then
Browse.Visible:= False
else if (Bottom > PropertyBox.Height) then
Browse.Visible:= False
else Browse.SetBounds(Right-Browse.Width, Top+1, Browse.Width, PropertyBox.ItemHeight - 2);
end;
end
end;
end;
if (not edProperty.Focused) and (odFocused in state) then
begin
edProperty.Visible:= False;
with PropertyBox.Canvas do
begin
EditRect := PropertyBox.ItemRect(PropertyBox.ItemIndex);
EditRect.Left := HalfWay + 4;
Dec(EditRect.Bottom, 2);
Inc(EditRect.Top,3);
Brush.Color := clWhite;
FillRect(EditRect);
setbkColor(PropertyBox.Canvas.Handle, GetsysColor(color_HighLight));
setbkMode(PropertyBox.Canvas.Handle, Opaque);
Font.Color := clhighlightText;
Canvas.Brush.Color := clHighlight;
TextOut(EditRect.Left, EditRect.Top, PropValue);
end;
end;
{if (odFocused in State) and (odselected in state) then
(Control as TListbox).Canvas.DrawFocusRect(rect);}
end;
procedure TObjectInspector.PropertyBoxMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
R,sr : TRect;
begin
if Abs(X - Halfway) <= 3 then SplitDrag := True
else
if (X >= EditRect.left) and (X <= EditRect.Right) and
(y >= EditRect.Top) and (Y <= EditRect.Bottom) then
begin
PropertyBox.Cursor := crDefault;
// SetEditor(PropertyList.Objects[PropertyBox.ItemIndex] as TPropertyEditor)
end;
end;
procedure TObjectInspector.PropertyBoxMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
var
TempR : TRect;
LB : TListBox;
begin
if PageControl1.ActivePage = TabProperty then Lb := PropertyBox
else lb := EventBox;
if SplitDrag then
begin
if X > Lb.ClientWidth - 20 then X := Lb.ClientWidth - 20;
if X < 20 then X := 20;
if Halfway < X then TempR:= Rect(Halfway, 0, lb.ClientWidth, lb.ClientHeight)
else TempR:= Rect(X, 0, lb.ClientWidth, lb.ClientHeight);
HalfWay := X;
InvalidateRect(lb.Handle, @TempR, False);
InvalidateRect(lb.Handle, @EditRect, False);
PostMessage(lb.Handle, WM_Paint, 0, 0);
Exit;
end;
if Abs(x - Halfway) <= 3 then lb.Cursor := crHSplit
else
if (X >= EditRect.left) and (X <= EditRect.Right) and
(Y >= EditRect.Top) and (Y <= EditRect.Bottom) then
lb.Cursor := crIBeam else lb.Cursor := crDefault;
end;
procedure TObjectInspector.PropertyBoxMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
SplitDrag := False;
end;
procedure TObjectInspector.FormShow(Sender: TObject);
begin
Halfway := PropertyBox.Width div 2;
end;
procedure TObjectInspector.EventBoxDrawItem(Control: TWinControl;
Index: Integer; Rect: TRect; State: TOwnerDrawState);
var
SR,DR: TRect;
EventName,EventValue:string;
begin
with (Control as TListBox).Canvas do
begin
Brush.Color := EventBox.Color; {Won't use Windows Selected color.}
FillRect(Rect);
// 啊肺急阑 弊覆
if (odSelected in State) then Pen.Color := clBtnHighLight else {for 3D look}
Pen.Color := clBtnShadow;
Pen.Mode := pmCopy;
Pen.Width := 1;
Pen.Style := psSolid;
MoveTo(rect.Left, Rect.Bottom-1);
LineTo(rect.Right, Rect.Bottom-1);
// Item狼 吝埃俊 靛贰弊甫 困茄 荐流急阑 弊覆
if (odSelected in State) then
begin
Pen.Color := clBtnHighLight;
MoveTo(HalfWay + 2, Rect.Top+1);
LineTo(Halfway + 2, Rect.Bottom);
Pen.Color := clBtnShadow;
MoveTo(Halfway+1, rect.Top+2);
LineTo(Halfway+1, rect.Bottom);
MoveTo(Rect.Right, Rect.Top);
LineTo(Rect.Left, Rect.Top);
LineTo(Rect.Left, Rect.Bottom);
Pen.Color := clBlack;
MoveTo(Rect.Right-1, Rect.Top+1);
LineTo(Rect.Left+1, Rect.Top+1);
LineTo(Rect.Left+1, Rect.Bottom-1);
end
else begin
Pen.Color := clBtnShadow;
MoveTo(Halfway, rect.Top+1);
LineTo(Halfway, rect.Bottom);
Pen.Color := clBtnHighLight;
MoveTo(HalfWay + 1, Rect.Top+1);
LineTo(Halfway + 1, Rect.Bottom);
end;
SR.Left := Rect.Left+2 ; SR.Right := HalfWay;
SR.Top := Rect.Top+1; SR.Bottom := Rect.Bottom-1;
if (odSelected in State) then
begin
Inc(SR.Left);
Inc(SR.Top);
Inc(SR.Right);
end;
// Item狼 捞亥飘疙苞 捞亥飘蔼阑 免仿
Font.Color := clBlack;
setbkMode(EventBox.Canvas.Handle, Transparent);
EventName:= Copy(EventBox.Items[Index],1,20);
EventValue:= Copy(EventBox.Items[Index],21,255);
TextRect(SR, Sr.Left + 10, SR.Top, EventName);
Font.Color := clNavy;
TextOut(HalfWay + 4, SR.Top, EventValue );
DR.Left:= Rect.Left+2; DR.Right := Rect.Left+13+2; {DestRect}
DR.Top := Rect.Top+1; DR.Bottom := Rect.Top+13+1;
if (odSelected in State) then
begin { To give 3D look to inspector.}
Inc(DR.Left); Inc(DR.Right);
Inc(DR.Top); Inc(DR.Bottom);
end;
end;
if (not cbEvent.Focused) and (odselected in state) then
with EventBox.Canvas do
begin
EditRect := EventBox.ItemRect(EventBox.ItemIndex);
EditRect.Left := HalfWay + 2;
Brush.Color := clWhite;
Inc(EditRect.Top,4);
Fillrect(EditRect);
setbkColor(EventBox.Canvas.Handle, GetsysColor(color_HighLight));
setbkMode(EventBox.Canvas.Handle, Opaque);
Font.Color := clhighlightText;
Canvas.Brush.Color := clHighlight;
TextOut(EditRect.Left, EditRect.Top, EventValue);
end;
if (odFocused in State) and (odselected in state) then
(Control as TListbox).Canvas.DrawFocusRect(Rect);
end;
procedure TObjectInspector.EventBoxMouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var
P : TPoint;
begin
if Abs(X - Halfway) <= 3 then SplitDrag := True
else
if (X >= EditRect.Left) and (X <= EditRect.Right) and
(y >= EditRect.Top) and (Y <= EditRect.Bottom) then
begin
P:= Point(X,Y);
EventBox.Cursor := crDefault;
MapWindowPoints(EventBox.Handle, cbEvent.Handle, P, 1);
PostMessage(cbEvent.Handle, WM_LButtonDown, mk_lbutton, P.Y shl 16 + P.X);
end;
end;
procedure TObjectInspector.EventBoxMouseMove(Sender: TObject;
Shift: TShiftState; X, Y: Integer);
var
TempR : TRect;
LB : TListBox;
begin
if PageControl1.ActivePage = TabProperty then Lb := PropertyBox
else lb := EventBox;
if SplitDrag then
begin
if X > Lb.ClientWidth - 20 then X := Lb.ClientWidth - 20;
if X < 20 then X := 20;
if Halfway < X then TempR:= Rect(Halfway, 0, lb.ClientWidth, lb.ClientHeight)
else TempR:= Rect(X, 0, lb.ClientWidth, lb.ClientHeight);
HalfWay := X;
InvalidateRect(lb.Handle, @TempR, False);
InvalidateRect(lb.Handle, @EditRect, False);
PostMessage(lb.Handle, WM_Paint, 0, 0);
Exit;
end;
if Abs(x - Halfway) <= 3 then lb.Cursor := crHSplit
else
if (X >= EditRect.left) and (X <= EditRect.Right) and
(Y >= EditRect.Top) and (Y <= EditRect.Bottom) then
lb.Cursor := crIBeam else lb.Cursor := crDefault;
end;
procedure TObjectInspector.EventBoxMouseUp(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if SplitDrag then
begin // 靛贰弊啊 场唱搁 牧飘费狼 困摹甫 犁炼沥
cbEvent.Left := EditRect.left;
cbEvent.Top := EditRect.Top;
cbEvent.Width := EditRect.Right - EditRect.Left;
cbEvent.Height := EditRect.Bottom - EditRect.Top;
end;
SplitDrag := False;
end;
function TObjectInspector.GetPropertyName: string ;
// ListBox狼 ItemIndex狼 加己疙阑 倒妨霖促.
begin
Result:='';
if PropertyBox.ItemIndex = -1 then Exit;
Result:= Trim(Copy(PropertyBox.Items[PropertyBox.ItemIndex],1,20));
end;
function TObjectInspector.GetEventName: string ;
// ListBox狼 ItemIndex狼 捞亥飘疙阑 倒妨霖促.
begin
Result:='';
if EventBox.ItemIndex = -1 then Exit;
Result:= Trim(Copy(EventBox.Items[EventBox.ItemIndex],1,20));
end;
function TObjectInspector.GetPropertyValueName: string ;
// ListBox狼 ItemIndex狼 加己蔼阑 倒妨霖促.
begin
Result:='';
if PropertyBox.ItemIndex = -1 then Exit;
Result:= Trim(Copy(PropertyBox.Items[PropertyBox.ItemIndex],21,255));
end;
function TObjectInspector.GetEventValueName: string ;
// ListBox狼 ItemIndex狼 捞亥飘蔼阑 倒妨霖促.
begin
Result:='';
if EventBox.ItemIndex = -1 then Exit;
Result:= Trim(Copy(EventBox.Items[EventBox.ItemIndex],21,255));
end;
procedure TObjectInspector.SetPropertyValueName(Value:string) ;
// ListBox狼 ItemIndex狼 加己蔼阑 汲沥茄促.
begin
if PropertyBox.ItemIndex = -1 then Exit;
with PropertyBox do
Items[ItemIndex]:= Copy(Items[ItemIndex],1,20)+ Value;
end;
procedure TObjectInspector.PropertyBoxClick(Sender: TObject);
// 努腐茄 加己狼 加己 祈笼扁甫 汲沥茄促.
begin
with PropertyList do
if PropertyList.Count>0 then
SetEditor(Objects[PropertyBox.ItemIndex] as TPropertyEditor)
else SetEditor(nil);
end;
function TObjectInspector.GetPropertyBoxValue(DBName:string): string ;
// 加己疙捞 Name牢 加己狼 加己蔼阑 倒妨霖促.
var
I:Integer;
S:string;
begin
Result:='';
with PropertyBox do
begin
for I:=0 to Items.Count - 1 do
begin
S:= Trim(Copy(Items[I],1,20));
if S = DBName then
begin
Result:= Trim(Copy(Items[I],21,255));
Break;
end;
end;
end;
end;
procedure TObjectInspector.PropertyBoxKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
if Key = vk_return then
begin
Key := 0;
exit;
end;
if Key = VK_F1 then ShowHelp;
if not (Key in [vk_up, vk_down, vk_prior, vk_next]) then
begin
edProperty.Left := EditRect.Left;
edProperty.Top := EditRect.Top;
edProperty.Width := EditRect.Right - EditRect.Left;
edProperty.Height := EditRect.Bottom - EditRect.Top;
edProperty.Visible := True;
edProperty.SetFocus;
edProperty.SelectAll;
PostMessage(edProperty.Handle, WM_KeyDown, Key, 0);
Key := 0;
end;
end;
procedure TObjectInspector.EventBoxClick(Sender: TObject);
begin
with EventList do
if Count>0 then
SetEditor(Objects[EventBox.ItemIndex] as TPropertyEditor)
else SetEditor(nil);
end;
// 加己蔼狼 格废阑 歹喉努腐窍绰 版快, 蔼阑 瞒肥肺 官操绊, 加己蔼阑 盎脚茄促.
// ListBox狼 Style 加己捞 csDropDown栏肺 汲沥登绢 乐绰 版快俊父 啊瓷窃
procedure TObjectInspector.cbValueDblClick(Sender: TObject);
begin
with cbValue do begin
if ItemIndex<0 then ItemIndex:=0
else if ItemIndex=(Items.Count-1) then ItemIndex:=0
else ItemIndex:=ItemIndex+1;
cbValueChange(self);
end;
end;
procedure TObjectInspector.BrowseClick(Sender: TObject);
begin
EditorProperty;
end;
procedure TObjectInspector.edPropertyKeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
case Key of
VK_DOWN:
if PropertyBox.ItemIndex< (PropertyBox.Items.Count-1) then
begin
if edProperty.Modified then
begin //Edit狼 郴侩捞 荐沥登菌栏搁
PropSetValue(edProperty.Text);
with PropertyBox do
Items[ItemIndex]:= Format('%-20s',[GetPropertyName]) + edProperty.Text;
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -