📄 ieditorbasiccomponents.pas
字号:
begin
AOwner := Owner as TCustomForm;
if GetShiftDown then
TWinControlAccess(AOwner).SelectNext(AOwner.ActiveControl, False, True)
else
TWinControlAccess(AOwner).SelectNext(AOwner.ActiveControl, True, True);
end;
end;
if Key = #27 then
begin
Key := #0;
Text := FOriginalText;
SelectAll;
end;
inherited;
end;
//****************************************************************************************************************************************************
procedure TiComponentEditorEdit.DoUpdate;
begin
if FOriginalText <> Text then
begin
FOriginalText := Text;
if Assigned(FOnUpdate) then FOnUpdate(Self);
if not FBlockingEvents then if (Owner is TiCustomEditorForm) then (Owner as TiCustomEditorForm).UserChange;
end;
end;
//****************************************************************************************************************************************************
{$ifdef iVCL}
procedure TiComponentEditorEdit.WMGetDLGCode(var Message: TMessage);
begin
inherited;
Message.Result := Message.Result + DLGC_WANTTAB + DLGC_WANTARROWS;
end;
//****************************************************************************************************************************************************
procedure TiComponentEditorEdit.CMWantSpecialKey(var Message: TCMWantSpecialKey);
begin
if Message.CharCode in [VK_LEFT, VK_RIGHT] then Message.Result := 1 else Message.Result := 0;
end;
//****************************************************************************************************************************************************
procedure TiComponentEditorEdit.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
{$IFDEF iActiveX}
Params.Style := Params.Style and not WS_TABSTOP;
Params.Style := Params.Style and not WS_GROUP;
{$ENDIF}
end;
{$endif}
//****************************************************************************************************************************************************
procedure TiComponentEditorEdit.DoExit;
begin
inherited;
DoUpdate;
end;
//****************************************************************************************************************************************************
procedure TiComponentEditorEdit.DoEnter;
begin
inherited;
SetParentsToTopMost(Self);
end;
//****************************************************************************************************************************************************
{$ifdef iVCL}procedure TiComponentEditorEdit.SetEnabled( Value: Boolean);{$endif}
{$ifdef iCLX}procedure TiComponentEditorEdit.SetEnabled(const Value: Boolean);{$endif}
begin
inherited;
if Enabled then Color := clWindow else Color := clBtnFace;
end;
//****************************************************************************************************************************************************
constructor TiUpDown.Create(AOwner:TComponent);
begin
inherited Create(AOwner);
Width := 15;
Height := 21;
FMax := 100;
FIncrement := 1;
FTimer := TTimer.Create(Self);
FTimer.Enabled := False;
FTimer.OnTimer := TimerEvent;
end;
//****************************************************************************************************************************************************
destructor TiUpDown.Destroy;
begin
FTimer.Free;
inherited;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.SetPosition(const Value: Integer);
var
TempPosition : Integer;
begin
if not Assigned(FAssociate) then exit;
TempPosition := Value;
if (FMax <> 0) or (FMin <> 0) then
begin
if TempPosition > FMax then TempPosition := FMax;
if TempPosition < FMin then TempPosition := FMin;
end;
if FUserGenerated then FAssociate.SetIntegerWithEvent(TempPosition)
else FAssociate.AsInteger := TempPosition;
end;
//****************************************************************************************************************************************************
function TiUpDown.GetPosition: Integer;
begin
if Assigned(FAssociate) then Result := FAssociate.AsInteger else Result := 0;
end;
//****************************************************************************************************************************************************
function TiUpDown.GetAsInteger: Integer;
begin
Result := GetPosition;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.SetAsInteger(const Value: Integer);
begin
SetPosition(Value);
end;
//****************************************************************************************************************************************************
procedure TiUpDown.Notification(AComponent: TComponent; Operation: TOperation);
begin
inherited Notification(AComponent, Operation);
if (Operation = opRemove) and (AComponent = FAssociate) then FAssociate := nil;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.SetAssociate(const Value: TiComponentEditorEdit);
begin
FAssociate := Value;
if Assigned(FAssociate) then
begin
Left := FAssociate.Left + FAssociate.Width;
Top := FAssociate.Top;
Height := FAssociate.Height;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.SetIncrement(const Value: Integer);
begin
if FIncrement <> Value then
begin
FIncrement := Value;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.SetMax(const Value: SmallInt);
begin
if FMax <> Value then
begin
FMax := Value;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.SetMin(const Value: SmallInt);
begin
if FMin <> Value then
begin
FMin := Value;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.DrawButton(DrawRect: TRect; ShowDown: Boolean);
begin
with Canvas, DrawRect do
begin
if ShowDown then
begin
iDrawEdge(Canvas, DrawRect, idesSunken);
end
else
begin
iDrawEdge(Canvas, DrawRect, idesRaised);
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.Paint;
var
MaxSize : Integer;
Length : Integer;
CenterPoint : TPoint;
begin
CalcButtons;
DrawButton(FUpButtonRect, FUpButtonPressed);
DrawButton(FDownButtonRect, FDownButtonPressed);
if Width > (Height div 2) then MaxSize := (Height div 2) else MaxSize := Width;
Length := MaxSize div 7;
if Enabled then
begin
Canvas.Brush.Color := clBlack;
Canvas.Pen.Color := clBlack;
end
else
begin
Canvas.Brush.Color := clGray;
Canvas.Pen.Color := clGray;
end;
CenterPoint := Point((FUpButtonRect.Right + FUpButtonRect.Left) div 2, (FUpButtonRect.Bottom + FUpButtonRect.Top) div 2);
Canvas.Polygon([Point(CenterPoint.X - 2*Length, CenterPoint.Y + Length),
Point(CenterPoint.X , CenterPoint.Y - Length),
Point(CenterPoint.X + 2*Length, CenterPoint.Y + Length)]);
CenterPoint := Point((FDownButtonRect.Right + FDownButtonRect.Left) div 2, (FDownButtonRect.Bottom + FDownButtonRect.Top) div 2);
Canvas.Polygon([Point(CenterPoint.X - 2*Length, CenterPoint.Y - Length),
Point(CenterPoint.X + 2*Length, CenterPoint.Y - Length),
Point(CenterPoint.X , CenterPoint.Y + Length)]);
end;
//****************************************************************************************************************************************************
procedure TiUpDown.CalcButtons;
var
DrawRect : TRect;
ButtonHeight : Integer;
begin
with DrawRect do
begin
DrawRect := GetClientRect;
ButtonHeight := (DrawRect.Bottom - 1) div 2;
FUpButtonRect := Rect(0, 0, Right, ButtonHeight);
FDownButtonRect := Rect(0, Bottom - ButtonHeight, Right, Bottom);
if FMouseDown then
begin
if PtInRect(FUpButtonRect, Point(FMouseDownX,FMouseDownY)) then FUpButtonPressed := True else FUpButtonPressed := False;
if PtInRect(FDownButtonRect, Point(FMouseDownX,FMouseDownY)) then FDownButtonPressed := True else FDownButtonPressed := False;
end
else
begin
FUpButtonPressed := False;
FDownButtonPressed := False;
end;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
inherited MouseDown(Button, Shift, X, Y);
if Button = mbLeft then
begin
FMouseDown := True;
FMouseDownX := X;
FMouseDownY := Y;
CalcButtons;
FTimer.Interval := 500;
FTimer.Enabled := True;
FFirstTimerMessage := True;
FUserGenerated := True;
try
if FUpButtonPressed then SetPosition(GetPosition + FIncrement) else SetPosition(GetPosition - FIncrement);
finally
FUserGenerated := False;
end;
Invalidate;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.MouseMove(Shift: TShiftState; X, Y: Integer);
begin
FMouseDownX := X;
FMouseDownY := Y;
if FMouseDown then Invalidate;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
inherited MouseUp(Button, Shift, X, Y);
if FMouseDown then
begin
FMouseDown := False;
FTimer.Enabled := False;
Invalidate;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.TimerEvent(Sender: TObject);
begin
if FFirstTimerMessage then
begin
FTimer.Interval := 50;
FFirstTimerMessage := False;
end;
FUserGenerated := True;
try
if FUpButtonPressed then SetPosition(GetPosition + FIncrement) else SetPosition(GetPosition - FIncrement);
finally
FUserGenerated := False;
end;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.Disable;
begin
Enabled := False;
if Assigned(FAssociate) then FAssociate.Disable;
Invalidate;
end;
//****************************************************************************************************************************************************
procedure TiUpDown.Enable;
begin
Enabled := True;
if Assigned(FAssociate) then FAssociate.Enable;
Invalidate;
end;
//****************************************************************************************************************************************************
procedure TiComponentEditorPageControl.KeyPress(var Key: Char);
var
AOwner : TCustomForm;
begin
if Key = #9 then
begin
Key := #0;
if Owner is TCustomForm then
begin
AOwner := Owner as TCustomForm;
if GetShiftDown then
TWinControlAccess(AOwner).SelectNext(AOwner.ActiveControl, False, True)
else
TWinControlAccess(AOwner).SelectNext(AOwner.ActiveControl, True, True);
end;
end;
inherited;
end;
//****************************************************************************************************************************************************
{$IFDEF iVCL}
procedure TiComponentEditorPageControl.WMGetDLGCode(var Message: TMessage);
begin
inherited;
Message.Result := DLGC_WANTALLKEYS + DLGC_WANTTAB;
end;
//****************************************************************************************************************************************************
procedure TiComponentEditorPageControl.CreateParams(var Params: TCreateParams);
begin
inherited CreateParams(Params);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -