⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dxstatusbar.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 5 页
字号:
    except
      on EComponentError do //Ignore rename errors
        Inc(I);
    end;
end;

{ TdxStatusBarPanelStyle }

constructor TdxStatusBarPanelStyle.Create(AOwner: TdxStatusBarPanel);
begin
  inherited Create;
  FOwner := AOwner;
  FFont := TFont.Create;
  FFont.OnChange := FontChanged;
  ParentFont := True;
end;

destructor TdxStatusBarPanelStyle.Destroy;
begin
  FOwner := nil;
  FreeAndNil(FFont);
  inherited;
end;

procedure TdxStatusBarPanelStyle.Assign(Source: TPersistent);
begin
  if Source is TdxStatusBarPanelStyle then
  begin
    BeginUpdate;
    try
      DoAssign(Source);
    finally
      EndUpdate;
    end;
  end
  else
    inherited Assign(Source);
end;

procedure TdxStatusBarPanelStyle.BeginUpdate;                      
begin
  if Assigned(Owner) and Assigned(Owner.Collection) then
    Owner.Collection.BeginUpdate;
end;

procedure TdxStatusBarPanelStyle.EndUpdate;
begin
  if Assigned(Owner) and Assigned(Owner.Collection) then
    Owner.Collection.EndUpdate;
end;

procedure TdxStatusBarPanelStyle.RestoreDefaults;
begin
  FAlignment := taLeftJustify;
  FIsColorAssigned := False;
  ParentFont := True;
  Owner.Changed(False);
end;

procedure TdxStatusBarPanelStyle.AdjustTextColor(var AColor: TColor;
  Active: Boolean);
begin
  if AColor = clDefault then
    StatusBarControl.AdjustTextColor(AColor, Active);
end;

function TdxStatusBarPanelStyle.CanDelete: Boolean;
begin
  Result := True;
end;

function TdxStatusBarPanelStyle.CanSizing: Boolean;
begin
  Result := True;
end;

procedure TdxStatusBarPanelStyle.Changed;
begin
  if Assigned(FOwner) then
    FOwner.StatusBarPanelStyleChanged;
end;

procedure TdxStatusBarPanelStyle.CheckSizeGripRect(var R: TRect);
begin
  if (Owner.Index = (StatusBarControl.Panels.Count - 1)) and StatusBarControl.SizeGripAllocated then
    Dec(R.Right, StatusBarControl.Painter.GripAreaSize.cx);
end;

function TdxStatusBarPanelStyle.DefaultColor: TColor;
begin
  Result := StatusBarControl.Color;
end;

procedure TdxStatusBarPanelStyle.DoAssign(ASource: TPersistent);
var
  AStyle: TdxStatusBarPanelStyle;
begin
  AStyle := TdxStatusBarPanelStyle(ASource);
  RestoreDefaults;
  Alignment := AStyle.Alignment;
  if AStyle.IsColorStored then
    Color := AStyle.Color;
  if AStyle.IsFontStored then
    Font.Assign(AStyle.Font)
  else
    ParentFontChanged;
end;

procedure TdxStatusBarPanelStyle.DrawContent(ACanvas: TcxCanvas; R: TRect;
  APainter: TdxStatusBarPainterClass);
begin
  APainter.FillBackground(Self.StatusBarControl, Owner, ACanvas, R);
end;

function TdxStatusBarPanelStyle.GetMinWidth: Integer;
begin
  Result := 20;
end;

function TdxStatusBarPanelStyle.GetPanelFixed: Boolean;
begin
  Result := Owner.FFixed;
end;

class function TdxStatusBarPanelStyle.GetVersion: Integer;
begin
  Result := 0;
end;

function TdxStatusBarPanelStyle.InternalBevel: Boolean;
begin
  Result := False;
end;

procedure TdxStatusBarPanelStyle.Loaded;
begin
end;

procedure TdxStatusBarPanelStyle.PanelVisibleChanged;
begin
end;

procedure TdxStatusBarPanelStyle.ParentFontChanged;
begin
  if ParentFont then
  begin
    Font.Assign(StatusBarControl.Font);
    FParentFont := True;
  end;
end;

procedure TdxStatusBarPanelStyle.FontChanged(Sender: TObject);
begin
  FParentFont := False;
  Owner.Changed(False);
end;

function TdxStatusBarPanelStyle.GetColor: TColor;
begin
  if FIsColorAssigned then
    Result := FColor
  else
    Result := DefaultColor;
end;

function TdxStatusBarPanelStyle.GetStatusBarControl: TdxCustomStatusBar;
begin
  Result := TdxStatusBarPanels(Owner.Collection).FStatusBarControl;
end;

function TdxStatusBarPanelStyle.IsColorStored: Boolean;
begin
  Result := FIsColorAssigned;
end;

function TdxStatusBarPanelStyle.IsFontStored: Boolean;
begin
  Result := not ParentFont;
end;

procedure TdxStatusBarPanelStyle.SetAlignment(Value: TAlignment);
begin
  if FAlignment <> Value then
  begin
    FAlignment := Value;
    Owner.Changed(False);
  end;
end;

procedure TdxStatusBarPanelStyle.SetColor(Value: TColor);
begin
  if FColor <> Value then
  begin
    FColor := Value;
    FIsColorAssigned := True;
    Owner.Changed(False);
  end;
end;

procedure TdxStatusBarPanelStyle.SetFont(Value: TFont);
begin
  FFont.Assign(Value);
end;

procedure TdxStatusBarPanelStyle.SetParentFont(Value: Boolean);
begin
  if FParentFont <> Value then
  begin
    FParentFont := Value;
    ParentFontChanged;
  end;
end;

{ TdxStatusBarTextPanelStyle }

constructor TdxStatusBarTextPanelStyle.Create(AOwner: TdxStatusBarPanel);
begin
  inherited Create(AOwner);
  FImageIndex := -1;
end;

procedure TdxStatusBarTextPanelStyle.RestoreDefaults;
begin
  FAutoHint := False;
  FImageIndex := -1;
  FEllipsisType := dxetNone;
  inherited RestoreDefaults;
end;

procedure TdxStatusBarTextPanelStyle.DoAssign(ASource: TPersistent);
var
  AStyle: TdxStatusBarTextPanelStyle;
begin
  inherited;
  if ASource is TdxStatusBarTextPanelStyle then
  begin
    AStyle := TdxStatusBarTextPanelStyle(ASource);
    AutoHint := AStyle.AutoHint;
    ImageIndex := AStyle.ImageIndex;
    EllipsisType := AStyle.EllipsisType;
  end;
end;

procedure TdxStatusBarTextPanelStyle.DrawContent(ACanvas: TcxCanvas;
  R: TRect; APainter: TdxStatusBarPainterClass);
const
  AShowEndEllipsis: array[TdxStatusBarEllipsisType] of Integer = (0, cxShowEndEllipsis,
    cxShowPathEllipsis);
var
  ALeft, ATop: Integer;
  ATextColor: TColor;
  S: string;
begin
  inherited;
  if Assigned(StatusBarControl.Images) and
    (0 <= ImageIndex) and (ImageIndex < StatusBarControl.Images.Count) then
  begin
    ALeft := R.Left + 1;
    ATop := ((R.Top + R.Bottom) div 2) - (StatusBarControl.Images.Height div 2);
    R.Left := ALeft + StatusBarControl.Images.Width + 1;
    StatusBarControl.Images.Draw(ACanvas.Canvas, ALeft, ATop,
      ImageIndex, StatusBarControl.Enabled);
  end;
  ACanvas.Brush.Style := bsClear;
  ATextColor := Font.Color;
  APainter.AdjustTextColor(Owner.GetStatusBarControl, ATextColor, True);  
  AdjustTextColor(ATextColor, True);
  ACanvas.Font.Assign(Font);
  ACanvas.Font.Color := ATextColor;
  InflateRect(R, -2, 0);
  S := Owner.Text;
  R := APainter.ValidatePanelTextRect(StatusBarControl, Owner, R);
  if Assigned(FOnGetText) then
    FOnGetText(Self, R, S);
  ACanvas.DrawText(S, R, cxSingleLine or cxAlignVCenter or cxAlignmentsHorz[Alignment] or
    AShowEndEllipsis[EllipsisType], StatusBarControl.Enabled);
  ACanvas.Brush.Style := bsSolid;
end;

procedure TdxStatusBarTextPanelStyle.SetAutoHint(Value: Boolean);
var
  I: Integer;
begin
  if FAutoHint <> Value then
  begin
    for I := 0 to StatusBarControl.Panels.Count - 1 do
      if StatusBarControl.Panels[I].PanelStyle is TdxStatusBarTextPanelStyle then
        TdxStatusBarTextPanelStyle(StatusBarControl.Panels[I].PanelStyle).FAutoHint := False;
    FAutoHint := Value;
  end;
end;

procedure TdxStatusBarTextPanelStyle.SetEllipsisType(Value: TdxStatusBarEllipsisType);
begin
  if FEllipsisType <> Value then
  begin
    FEllipsisType := Value;
    Owner.Changed(False);
  end;
end;

procedure TdxStatusBarTextPanelStyle.SetImageIndex(Value: TImageIndex);
begin
  if FImageIndex <> Value then
  begin
    FImageIndex := Value;
    Owner.Changed(False);
  end;
end;

{ TdxStatusBarStateIndicatorItem }

constructor TdxStatusBarStateIndicatorItem.Create(Collection: TCollection);
begin
  inherited Create(Collection);
  FVisible := True;
  FIndicatorBitmap := TBitmap.Create;
  FIndicatorBitmap.LoadFromResourceName(HInstance, 'DXSTATUSBAR_GRAY');
end;

destructor TdxStatusBarStateIndicatorItem.Destroy;
begin
  FreeAndNil(FIndicatorBitmap);
  inherited Destroy;
end;

procedure TdxStatusBarStateIndicatorItem.Assign(Source: TPersistent);
begin
  if Source is TdxStatusBarStateIndicatorItem then
  begin
    IndicatorType := TdxStatusBarStateIndicatorItem(Source).IndicatorType;
    Visible := TdxStatusBarStateIndicatorItem(Source).Visible;
  end
  else
    inherited Assign(Source);
end;

procedure TdxStatusBarStateIndicatorItem.SetIndicatorType(Value: TdxStatusBarStateIndicatorType);
begin
  if FIndicatorType <> Value then
  begin
    FIndicatorType := Value;
    LoadIndicatorBitmap(FIndicatorBitmap, FIndicatorType);
    Changed(False);
  end;
end;

procedure TdxStatusBarStateIndicatorItem.SetVisible(Value: Boolean);
begin
  if FVisible <> Value then
  begin
    FVisible := Value;
    Changed(False);
  end;
end;

{ TdxStatusBarStateIndicators }

constructor TdxStatusBarStateIndicators.Create;
begin
  inherited Create(TdxStatusBarStateIndicatorItem);
end;

function TdxStatusBarStateIndicators.Add: TdxStatusBarStateIndicatorItem;
begin
  Result := TdxStatusBarStateIndicatorItem.Create(Self);
end;

function TdxStatusBarStateIndicators.Insert(Index: Integer): TdxStatusBarStateIndicatorItem;
begin
  BeginUpdate;
  try
    if Index < 0 then Index := 0;
    if Index > Count then Index := Count;
    Result := Add;
    Result.Index := Index;
  finally
    EndUpdate;
  end;
end;

procedure TdxStatusBarStateIndicators.Update(Item: TCollectionItem);
begin
  if Assigned(OnChange) then
    OnChange(Self);
end;

function TdxStatusBarStateIndicators.GetItem(Index: Integer): TdxStatusBarStateIndicatorItem;
begin
  Result := TdxStatusBarStateIndicatorItem(inherited GetItem(Index));
end;

procedure TdxStatusBarStateIndicators.SetItem(Index: Integer; Value: TdxStatusBarStateIndicatorItem);
begin

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -