📄 ieditorbasiccomponents.pas
字号:
ItemIndex := -1;
Text := '';
finally
FBlockingEvents := False;
OnChange := TempOnChange;
end;
end;
//***********************************************************************************************************************************
procedure TiComponentEditorComboBox.Enable;
begin
Enabled := True;
Color := clWindow;
end;
//***********************************************************************************************************************************
function TiComponentEditorComboBox.GetAsInteger: Integer;
begin
Result := ItemIndex;
end;
//***********************************************************************************************************************************
procedure TiComponentEditorComboBox.SetAsInteger(const Value: Integer);
var
TempOnChange : TNotifyEvent;
begin
TempOnChange := OnChange;
OnChange := nil;
FBlockingEvents := True;
try
ItemIndex := Value;
finally
FBlockingEvents := False;
OnChange := TempOnChange;
end;
end;
//***********************************************************************************************************************************
function TiComponentEditorComboBox.GetAsString: String;
begin
Result := Text;
end;
//***********************************************************************************************************************************
procedure TiComponentEditorComboBox.SetAsString(const Value: String);
var
TempOnChange : TNotifyEvent;
begin
TempOnChange := OnChange;
OnChange := nil;
FBlockingEvents := True;
try
Text := Value;
finally
FBlockingEvents := False;
OnChange := TempOnChange;
end;
end;
//***********************************************************************************************************************************
procedure TiComponentEditorComboBox.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 TiComponentEditorComboBox.WMGetDLGCode(var Message: TMessage);
begin
inherited;
Message.Result := Message.Result + DLGC_WANTTAB + DLGC_WANTARROWS;
end;
{$endif}
//****************************************************************************************************************************************************
{$IFDEF iVCL}
procedure TiComponentEditorComboBox.CMWantSpecialKey(var Message: TCMWantSpecialKey);
begin
if Message.CharCode in [VK_LEFT, VK_RIGHT] then Message.Result := 1 else Message.Result := 0;
end;
{$endif}
//****************************************************************************************************************************************************
procedure TiComponentEditorComboBox.DoEnter;
begin
inherited;
SetParentsToTopMost(Self);
end;
//***********************************************************************************************************************************
constructor TiComponentEditorListBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Style := lbOwnerDrawFixed;
DragMode := dmAutomatic;
Sorted := False;
end;
//***********************************************************************************************************************************
procedure TiComponentEditorListBox.DragDrop(Source: TObject; X, Y: Integer);
var
Row : Integer;
begin
Row := (Y + TopIndex * ItemHeight)div ItemHeight;
if Row > (Items.Count - 1) then Row := Items.Count - 1;
if Row <> ItemIndex then
begin
Items.Move(ItemIndex, Row);
ItemIndex := Row;
if Assigned(FOnItemMove) then FOnItemMove(Self);
end;
end;
//****************************************************************************************************************************************************
procedure TiComponentEditorListBox.DragOver(Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean);
begin
if Source = Self then Accept := True else Accept := False;
end;
//****************************************************************************************************************************************************
{$ifdef iVCL}
procedure TiComponentEditorListBox.CreateWnd;
begin
inherited CreateWnd;
SetParentsToTopMost(Self);
end;
{$endif}
//****************************************************************************************************************************************************
{$ifdef iVCL}procedure TiComponentEditorListBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState); {$endif}
{$ifdef iCLX}function TiComponentEditorListBox.DrawItem(Index: Integer; Rect: TRect; State: TOwnerDrawState): Boolean;{$endif}
var
DrawColorBox : Boolean;
AColor : TColor;
AText : String;
begin
if Assigned(OnDrawItem) then
begin
{$ifdef iVCL} inherited;{$endif}
{$ifdef iCLX}Result := inherited DrawItem(Index, Rect, State);{$endif}
Exit;
end;
DrawColorBox := True;
AColor := clRed;
AText := Items.Strings[Index];
if Assigned(FOnGetData) then FOnGetData(Index, DrawColorBox, AColor, AText);
with Canvas, Rect do
begin
if odSelected in State then
begin
Brush.Color := clTeal;
Font.Color := clWhite;
end
else
begin
Brush.Color := clWindow;
Font.Color := clBlack;
end;
FillRect(Rect);
if DrawColorBox then
begin
TextOut(Left + 22, Top, AText);
Brush.Color := AColor;
Pen.Color := clBlack;
Rectangle(Left + 2, Top+1, Left + 18, Bottom-1);
end
else TextOut(Left + 2, Top, AText);
end;
{$ifdef iCLX}Result:= True;{$endif}
end;
//***********************************************************************************************************************************
procedure TiComponentEditorListBox.SelectLast;
begin
ItemIndex := Items.Count - 1;
end;
//***********************************************************************************************************************************
procedure TiComponentEditorListBox.DeleteSelectedObject;
var
LastIndex : Integer;
AObject : TObject;
begin
if Items.Count = 0 then exit;
LastIndex := ItemIndex;
AObject := Items.Objects[ItemIndex];
Items.Delete(ItemIndex);
AObject.Free;
if Items.Count <> 0 then
begin
if LastIndex > (Items.Count - 1) then ItemIndex := LastIndex - 1
else ItemIndex := LastIndex;
end;
end;
//***********************************************************************************************************************************
procedure TiComponentEditorListBox.DeleteObjectIndex(AObject: TObject);
var
LastIndex : Integer;
Index : Integer;
begin
Index := Items.IndexOfObject(AObject);
if Index = -1 then Exit;
LastIndex := ItemIndex;
Items.Delete(Index);
if Items.Count <> 0 then
begin
if LastIndex < Items.Count then ItemIndex := LastIndex
else ItemIndex := Items.Count-1;
end;
end;
//***********************************************************************************************************************************
{$ifdef iVCL}
procedure TiComponentEditorListBox.CNCommand(var Message: TWMCommand);
begin
case Message.NotifyCode of
LBN_SELCHANGE : Click;
LBN_DBLCLK : DblClick;
end;
end;
{$endif}
//***********************************************************************************************************************************
procedure TiComponentEditorListBox.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 TiComponentEditorListBox.WMGetDLGCode(var Message: TMessage);
begin
Message.Result := DLGC_WANTALLKEYS + DLGC_WANTTAB;
end;
{$endif}
//****************************************************************************************************************************************************
procedure TiComponentEditorListBox.DoEnter;
begin
inherited DoEnter;
SetParentsToTopMost(Self);
end;
//***********************************************************************************************************************************
constructor TiComponentEditorColorPicker.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := [csCaptureMouse, csClickEvents, csOpaque, csDoubleClicks, csReplicatable];
Width := 47;
Height := 21;
FColor := clRed;
FButton := TButton.Create(Self);
with FButton do
begin
Parent := Self;
Width := 21;
Height := 21;
Left := Self.Width - Width;
Caption := '...';
Font.Style := [fsBold];
OnClick := ButtonClick;
end;
end;
//****************************************************************************************************************************************************
{$ifdef iVCL}
procedure TiComponentEditorColorPicker.OpenVCL;
var
AControl : TWinControl;
ColorDialog : TiColorDialog;
begin
ColorDialog := TiColorDialog.Create(Self);
AControl := Self;
while (AControl is TWinControl) do
begin
SetWindowToControlParent(Handle, True);
AControl := AControl.Parent;
end;
try
ColorDialog.Color := FColor;
if ColorDialog.Execute then
begin
FColor := ColorDialog.Color;
if (Owner is TiCustomEditorForm) then (Owner as TiCustomEditorForm).UserChange;
Invalidate;
if Assigned(FOnChange) then FOnChange(Self);
end;
finally
ColorDialog.Free;
end;
SetWindowToControlParent(Handle, False);
end;
{$endif}
//****************************************************************************************************************************************************
{$ifdef iCLX}
procedure TiComponentEditorColorPicker.OpenCLX;
var
ColorDialog : TColorDialog;
begin
ColorDialog := TColorDialog.Create(Self);
try
ColorDialog.Color := FColor;
if ColorDialog.Execute then
begin
FColor := ColorDialog.Color;
if (Owner is TiCustomEditorForm) then (Owner as TiCustomEditorForm).UserChange;
Invalidate;
if Assigned(FOnChange) then FOnChange(Self);
end;
finally
ColorDialog.Free;
end;
end;
{$endif}
//***********************************************************************************************************************************
procedure TiComponentEditorColorPicker.ButtonClick(Sender: TObject);
begin
{$ifdef iVCL}OpenVCL;{$endif}
{$ifdef iCL
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -