📄 speedbar.pas
字号:
function TSpeedItem.GetCaption: TCaption;
begin
Result := TCaption(FCaption);
end;
procedure TSpeedItem.SetCaption(const Value: TCaption);
var
ChangeHint: Boolean;
begin
ChangeHint := (Owner = nil) or not (Owner is TControl) or
not (csLoading in TControl(Owner).ComponentState) and
(Caption = GetShortHint(Hint));
FCaption := Value;
if ChangeHint then begin
if Pos('|', Value) = 0 then begin
if Pos('|', Hint) = 0 then Hint := Value + '|'
else Hint := Value + '|' + GetLongHint(Hint);
end
else begin
if GetLongHint(Value) = '' then
Hint := GetShortHint(Value) + '|' + GetLongHint(Hint)
else Hint := Value;
end;
end;
end;
procedure TSpeedItem.SetName(const Value: TComponentName);
var
ChangeText: Boolean;
begin
ChangeText := (Name = Caption) and
((Owner = nil) or not (Owner is TControl) or
not (csLoading in TControl(Owner).ComponentState));
inherited SetName(Value);
if ChangeText then Caption := Value;
end;
procedure TSpeedItem.SetEditing(Value: Boolean);
begin
FEditing := Value;
if FEditing then begin
FButton.Enabled := True;
FButton.Flat := False;
end
else begin
SetEnabled(FEnabled);
if SpeedBar <> nil then
FButton.Flat := (sbFlatBtns in SpeedBar.Options);
end;
end;
function TSpeedItem.HasParent: Boolean;
begin
Result := True;
end;
procedure TSpeedItem.DefineProperties(Filer: TFiler);
{$IFDEF WIN32}
function DoWrite: Boolean;
begin
if Assigned(Filer.Ancestor) then
Result := GetSectionName <> TSpeedItem(Filer.Ancestor).GetSectionName
else Result := True;
end;
{$ENDIF}
begin
inherited DefineProperties(Filer);
Filer.DefineProperty('Section', ReadSection, WriteSection, False);
Filer.DefineProperty('SectionName', ReadSectionName, WriteSectionName,
{$IFDEF WIN32} DoWrite {$ELSE} True {$ENDIF});
end;
procedure TSpeedItem.ReadSectionName(Reader: TReader);
begin
FSectionName := Reader.ReadString;
end;
procedure TSpeedItem.WriteSectionName(Writer: TWriter);
begin
Writer.WriteString(GetSectionName);
end;
procedure TSpeedItem.ReadSection(Reader: TReader);
begin
FSection := Reader.ReadInteger;
end;
procedure TSpeedItem.WriteSection(Writer: TWriter);
begin
UpdateSection;
Writer.WriteInteger(FSection);
end;
{$IFDEF WIN32}
function TSpeedItem.GetParentComponent: TComponent;
begin
Result := FParent;
end;
procedure TSpeedItem.SetParentComponent(Value: TComponent);
var
I: Integer;
begin
if not (csLoading in ComponentState) then begin
if FParent <> nil then FParent.RemoveItem(Self);
if (Value <> nil) and (Value is TSpeedBar) then begin
I := TSpeedBar(Value).SearchSection(FSectionName);
if I >= 0 then FSection := I;
TSpeedBar(Value).AddItem(FSection, Self);
end;
end;
end;
procedure TSpeedItem.SetImageIndex(Value: Integer);
begin
if Value <> FImageIndex then begin
FImageIndex := Value;
TSpeedbarButton(FButton).InvalidateGlyph;
FButton.Invalidate;
end;
end;
{$ENDIF}
procedure TSpeedItem.ReadState(Reader: TReader);
begin
inherited ReadState(Reader);
if Reader.Parent is TSpeedBar then begin
if FSectionName <> '' then
FSection := TSpeedBar(Reader.Parent).SearchSection(FSectionName);
TSpeedBar(Reader.Parent).AddItem(Max(FSection, 0), Self);
end;
end;
function TSpeedItem.GetSection: Integer;
begin
UpdateSection;
Result := FSection;
end;
procedure TSpeedItem.SetSection(Value: Integer);
begin
if Speedbar = nil then FSection := Value;
end;
function TSpeedItem.GetSectionName: string;
begin
UpdateSection;
if FSection >= 0 then Result := FParent.Sections[FSection].Caption
else Result := FSectionName;
end;
{
procedure TSpeedItem.SetSectionName(const Value: string);
begin
if FParent <> nil then FSection := FParent.SearchSection(Value)
else FSection := -1;
FSectionName := Value;
end;
}
procedure TSpeedItem.InvalidateItem;
begin
FSection := -1;
end;
procedure TSpeedItem.UpdateSection;
var
I: Integer;
begin
if FParent <> nil then FParent.FindItem(Self, FSection, I)
else FSection := -1;
end;
procedure TSpeedItem.SetEnabled(Value: Boolean);
begin
if ((FButton.Enabled <> Value) or (FEnabled <> Value)) then begin
FEnabled := Value;
if not FEditing then begin
if (SpeedBar <> nil) and Value then
FButton.Enabled := (Value and SpeedBar.Enabled)
else FButton.Enabled := Value;
end;
end;
end;
procedure TSpeedItem.SetVisible(Value: Boolean);
begin
if (FButton.Visible <> Value) or (FVisible <> Value) or
(Value and (FButton.Parent = nil)) then
begin
FVisible := Value;
if (SpeedBar <> nil) and Value then
FButton.Visible := Value and SpeedBar.Visible
else FButton.Visible := Value;
if Value then FButton.Parent := Speedbar;
end;
end;
function TSpeedItem.GetAllowAllUp: Boolean;
begin
Result := FButton.AllowAllUp;
end;
procedure TSpeedItem.SetAllowAllUp(Value: Boolean);
begin
FButton.AllowAllUp := Value;
end;
function TSpeedItem.GetAllowTimer: Boolean;
begin
Result := FButton.AllowTimer;
end;
procedure TSpeedItem.SetAllowTimer(Value: Boolean);
begin
FButton.AllowTimer := Value;
end;
function TSpeedItem.GetBtnCaption: TCaption;
begin
Result := FButton.Caption;
end;
procedure TSpeedItem.SetBtnCaption(const Value: TCaption);
begin
FButton.Caption := Value;
end;
function TSpeedItem.GetGroupIndex: Integer;
begin
Result := FButton.GroupIndex;
end;
procedure TSpeedItem.SetGroupIndex(Value: Integer);
begin
FButton.GroupIndex := Value;
end;
function TSpeedItem.GetOnClick: TNotifyEvent;
begin
Result := FButton.OnClick;
end;
procedure TSpeedItem.SetOnClick(Value: TNotifyEvent);
begin
FButton.OnClick := Value;
end;
function TSpeedItem.GetOnDblClick: TNotifyEvent;
begin
Result := FButton.OnDblClick;
end;
procedure TSpeedItem.SetOnDblClick(Value: TNotifyEvent);
begin
FButton.OnDblClick := Value;
end;
function TSpeedItem.GetOnMouseDown: TMouseEvent;
begin
Result := FButton.OnMouseDown;
end;
procedure TSpeedItem.SetOnMouseDown(Value: TMouseEvent);
begin
FButton.OnMouseDown := Value;
end;
function TSpeedItem.GetOnMouseMove: TMouseMoveEvent;
begin
Result := FButton.OnMouseMove;
end;
procedure TSpeedItem.SetOnMouseMove(Value: TMouseMoveEvent);
begin
FButton.OnMouseMove := Value;
end;
function TSpeedItem.GetOnMouseUp: TMouseEvent;
begin
Result := FButton.OnMouseUp;
end;
procedure TSpeedItem.SetOnMouseUp(Value: TMouseEvent);
begin
FButton.OnMouseUp := Value;
end;
function TSpeedItem.GetOnMouseEnter: TNotifyEvent;
begin
Result := FButton.OnMouseEnter;
end;
procedure TSpeedItem.SetOnMouseEnter(Value: TNotifyEvent);
begin
FButton.OnMouseEnter := Value;
end;
function TSpeedItem.GetOnMouseLeave: TNotifyEvent;
begin
Result := FButton.OnMouseLeave;
end;
procedure TSpeedItem.SetOnMouseLeave(Value: TNotifyEvent);
begin
FButton.OnMouseLeave := Value;
end;
function TSpeedItem.GetDown: Boolean;
begin
Result := FButton.Down;
end;
procedure TSpeedItem.SetDown(Value: Boolean);
begin
FButton.Down := Value;
end;
function TSpeedItem.GetGlyph: TBitmap;
begin
Result := FButton.Glyph;
end;
procedure TSpeedItem.SetGlyph(Value: TBitmap);
begin
FButton.Glyph := Value;
end;
function TSpeedItem.GetLayout: TButtonLayout;
begin
Result := FButton.Layout;
end;
procedure TSpeedItem.SetLayout(Value: TButtonLayout);
begin
FButton.Layout := Value;
end;
function TSpeedItem.GetMargin: Integer;
begin
Result := FButton.Margin;
end;
procedure TSpeedItem.SetMargin(Value: Integer);
begin
FButton.Margin := Value;
end;
function TSpeedItem.GetNumGlyphs: TRxNumGlyphs;
begin
Result := FButton.NumGlyphs;
end;
procedure TSpeedItem.SetNumGlyphs(Value: TRxNumGlyphs);
begin
FButton.NumGlyphs := Value;
end;
function TSpeedItem.GetParentShowHint: Boolean;
begin
Result := FButton.ParentShowHint;
end;
procedure TSpeedItem.SetParentShowHint(Value: Boolean);
begin
FButton.ParentShowHint := Value;
end;
function TSpeedItem.GetShowHint: Boolean;
begin
Result := FButton.ShowHint;
end;
procedure TSpeedItem.SetShowHint(Value: Boolean);
begin
FButton.ShowHint := Value;
end;
function TSpeedItem.GetFont: TFont;
begin
Result := FButton.Font;
end;
procedure TSpeedItem.SetFont(Value: TFont);
begin
FButton.Font := Value;
end;
function TSpeedItem.GetParentFont: Boolean;
begin
Result := FButton.ParentFont;
end;
procedure TSpeedItem.SetParentFont(Value: Boolean);
begin
FButton.ParentFont := Value;
end;
function TSpeedItem.IsFontStored: Boolean;
begin
Result := not ParentFont;
end;
function TSpeedItem.IsShowHintStored: Boolean;
begin
Result := not ParentShowHint;
end;
function TSpeedItem.GetSpacing: Integer;
begin
Result := FButton.Spacing;
end;
procedure TSpeedItem.SetSpacing(Value: Integer);
begin
FButton.Spacing := Value;
end;
function TSpeedItem.GetCursor: TCursor;
begin
Result := FButton.Cursor;
end;
procedure TSpeedItem.SetCursor(Value: TCursor);
begin
FButton.Cursor := Value;
end;
function TSpeedItem.GetHint: string;
begin
Result := FButton.Hint;
end;
procedure TSpeedItem.SetHint(const Value: string);
begin
FButton.Hint := Value;
end;
{$IFDEF RX_D4}
function TSpeedItem.GetAction: TBasicAction;
begin
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -