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

📄 cxvgridviewinfo.pas

📁 delphi的的三方控件
💻 PAS
📖 第 1 页 / 共 3 页
字号:
{********************************************************************}
{                                                                    }
{       Developer Express Visual Component Library                   }
{       ExpressVerticalGrid                                          }
{                                                                    }
{       Copyright (c) 1998-2007 Developer Express Inc.               }
{       ALL RIGHTS RESERVED                                          }
{                                                                    }
{   The entire contents of this file is protected by U.S. and        }
{   International Copyright Laws. Unauthorized reproduction,         }
{   reverse-engineering, and distribution of all or any portion of   }
{   the code contained in this file is strictly prohibited and may   }
{   result in severe civil and criminal penalties and will be        }
{   prosecuted to the maximum extent possible under the law.         }
{                                                                    }
{   RESTRICTIONS                                                     }
{                                                                    }
{   THIS SOURCE CODE AND ALL RESULTING INTERMEDIATE FILES            }
{   (DCU, OBJ, DLL, ETC.) ARE CONFIDENTIAL AND PROPRIETARY TRADE     }
{   SECRETS OF DEVELOPER EXPRESS INC. THE REGISTERED DEVELOPER IS    }
{   LICENSED TO DISTRIBUTE THE EXPRESSVERTICALGRID AND ALL           }
{   ACCOMPANYING VCL CONTROLS AS PART OF AN EXECUTABLE PROGRAM ONLY. }
{                                                                    }
{   THE SOURCE CODE CONTAINED WITHIN THIS FILE AND ALL RELATED       }
{   FILES OR ANY PORTION OF ITS CONTENTS SHALL AT NO TIME BE         }
{   COPIED, TRANSFERRED, SOLD, DISTRIBUTED, OR OTHERWISE MADE        }
{   AVAILABLE TO OTHER INDIVIDUALS WITHOUT EXPRESS WRITTEN CONSENT   }
{   AND PERMISSION FROM DEVELOPER EXPRESS INC.                       }
{                                                                    }
{   CONSULT THE END USER LICENSE AGREEMENT FOR INFORMATION ON        }
{   ADDITIONAL RESTRICTIONS.                                         }
{                                                                    }
{********************************************************************}
unit cxVGridViewInfo;

{$I cxVer.inc}

interface

uses
  Classes, Graphics,
{$IFDEF VCL}
  Windows, Controls,
{$ELSE}
  QImgList,
{$ENDIF}
  cxGraphics, cxVGrid, cxVGridUtils, cxEdit, cxInplaceContainer, cxStyles;

type
  { TcxCategoryRowHeaderInfo }

  TcxCategoryRowHeaderInfo = class(TcxCustomRowHeaderInfo)
  private
    function GetRow: TcxCategoryRow;
  protected
    procedure AddBottomHorzLine(const R: TRect); override;
    procedure AddRightVertLine(const R: TRect); override;
    procedure CalcRowCaptionsInfo; override;
    procedure CalcViewParams(AAllowFocus: Boolean); override;
    procedure DoCalcExpandButton; override;
    function GetCaptionViewParams: TcxViewParams; override;
    function GetButtonColor: TColor; override;
    function GetFocusRect: TRect; override;
    function IncreaseBoundsByLastVertLine: Boolean; override;
    function LeftViewPoint: Integer; override;
  public
    property Row: TcxCategoryRow read GetRow;
  end;

  { TcxCategoryRowViewInfo }

  TcxCategoryRowViewInfo = class(TcxCustomRowViewInfo)
  private
    function GetRow: TcxCategoryRow;
  protected
    procedure CalcRowHeaderInfo(ANextRow: TcxCustomRow); override;
    procedure CalcValuesInfo; override;
  public
    property Row: TcxCategoryRow read GetRow;
  end;

  { TcxEditorRowHeaderInfo }

  TcxEditorRowHeaderInfo = class(TcxCustomRowHeaderInfo)
  private
    function GetRow: TcxEditorRow;
  public
    property Row: TcxEditorRow read GetRow;
  end;

  { TcxEditorRowViewInfo }

  TcxEditorRowViewInfo = class(TcxCustomRowViewInfo)
  private
    function GetRow: TcxEditorRow;
  protected
    procedure CalcValuesInfo; override;
    function GetValueHeight(ARecordIndex: Integer; AWidth: Integer;
      AViewInfo: TcxvgCustomViewInfo): Integer; override;
  public
    property Row: TcxEditorRow read GetRow;
  end;

  { TcxMultiEditorRowHeaderInfo }

  TcxMultiEditorRowHeaderInfo = class(TcxCustomRowHeaderInfo)
  private
		FSeparatorRects: TcxRectList;
		FSeparatorInfo: TSeparatorInfo;
    function GetRow: TcxMultiEditorRow;
  protected
    procedure CalcRowCaptionsInfo; override;
    procedure CalcSeparatorRects(AHeaderCells: TcxRectList); virtual;
    procedure CalcSeparatorWidth(ASeparatorWidth: Integer); virtual;
    procedure CalcSeparatorStyle; virtual;
    procedure Clear; override;
  public
    constructor Create(ARow: TcxCustomRow); override;
    destructor Destroy; override;
    property Row: TcxMultiEditorRow read GetRow;
		property SeparatorInfo: TSeparatorInfo read FSeparatorInfo;
    property SeparatorRects: TcxRectList read FSeparatorRects;
  end;

  { TcxMultiEditorRowViewInfo }

  TcxMultiEditorRowViewInfo = class(TcxCustomRowViewInfo)
  private
    FSeparatorRects: TcxRectList;
    function GetHeaderInfo: TcxMultiEditorRowHeaderInfo;
    function GetRow: TcxMultiEditorRow;
    function GetSeparatorRects: TcxRectList;
  protected
    procedure AddSeparatorRects(AHeader: Boolean; ASepRects: TcxRectList;
      ASeparatorKind: TSeparatorKind; AValueCells: TcxRectList;
      const ABounds: TRect);
    procedure CalcValuesInfo; override;
    procedure CheckEmptyValuesInfo; virtual;
    function GetValueHeight(ARecordIndex: Integer; AWidth: Integer;
      AViewInfo: TcxvgCustomViewInfo): Integer; override;
  public
    constructor Create(ARow: TcxCustomRow); override;
    destructor Destroy; override;
    class function GetCellRects(ARow: TcxMultiEditorRow; const R: TRect;
      ASepWidth: Integer): TcxRectList;
    property HeaderInfo: TcxMultiEditorRowHeaderInfo read GetHeaderInfo;
    property Row: TcxMultiEditorRow read GetRow;
    property SeparatorRects: TcxRectList read GetSeparatorRects;
  end;

  { TcxInspectorViewInfo }

  TcxInspectorViewInfo = class(TcxvgCustomViewInfo)
  protected
    procedure AddEmptyRects; override;
    procedure CheckMaxRowHeaderWidth(var Value: Integer; AValueMinWidth: Integer); override;
    function GetViewValueWidth: Integer; override;
    function GetVisibleValueCount: Integer; override;
  end;

  { TcxBandsViewInfo }

  TcxBandsViewInfo = class(TcxvgCustomViewInfo)
  private
    FBandsIndent: Integer;
    FAutoScaleBands: Boolean;
    FLock: Boolean;
    procedure UpdateBandsWidth;
  protected
    procedure AddEmptyRects; override;
    procedure CalcBandRects; override;
    procedure CalcBandWidth; override;
    procedure CalcLayoutGeneral; override;
    function CanAddRowToBand(const ARowRect, ABandRect: TRect; ABandRowIndex: Integer): Boolean; override;
    procedure CreateBand(ABandHeight, ABandWidth: Integer); override;
    function GetBandSizeableRect(const ABandRect: TRect): TRect; override;
    function GetMinViewBandWidth: Integer;
    function GetRowAutoHeight(ARow: TcxCustomRow): Boolean; override;
    function GetViewBandWidth: Integer; override;
    function GetViewValueWidth: Integer; override;
    function GetVisibleValueCount: Integer; override;
    procedure LayoutStyleChanged; override;
    procedure SetDividerPos(APos: Integer); override;
    property BandsIndent: Integer read FBandsIndent;
    property AutoScaleBands: Boolean read FAutoScaleBands;
  end;

  { TcxMultiRecordViewInfo }

  TcxMultiRecordViewInfo = class(TcxvgCustomViewInfo)
  private
		FCommonWidth: Integer;
    FRecordsInterval: Integer;
    FVisibleValueCount: Integer;
    function CalcVisibleValueCount: Integer;
    function GetRecordCount: Integer;
  protected
    procedure AddBandRowsLines(const R: TRect); override;
    procedure AddEmptyRects; override;
    procedure AddRightValueSide(const R: TRect; ALast: Boolean); override;
    procedure CalcBandWidth; override;
    procedure CalcLayoutGeneral; override;
    procedure Clear; override;
    function GetBandSizeableRect(const ABandRect: TRect): TRect; override;
    function GetRowHeight(ARowViewInfo: TcxCustomRowViewInfo; ABandWidth: Integer): Integer; override;
    function GetVisibleValueCount: Integer; override;
    procedure Reset; override;
    procedure SetDividerPos(APos: Integer); override;
    property RecordCount: Integer read GetRecordCount;
  public
    constructor Create(AOwner: TcxEditingControl); override;
    function GetDefaultGridModeBufferCount: Integer; override;
    function GetValueRect(AValueIndex: Integer; ARowViewInfo: TcxCustomRowViewInfo): TRect; override;
    procedure UpdateRecord(ARecordIndex: Integer); override;
    property RecordsInterval: Integer read FRecordsInterval;
  end;

implementation

uses
{$IFNDEF DELPHI5}
  cxClasses,
{$ENDIF}
  SysUtils, cxControls, cxGeometry, cxEditUtils;

type
  TcxCustomEditorRowPropertiesAccess = class(TcxCustomEditorRowProperties);
  TcxCustomRowAccess = class(TcxCustomRow);
  TcxCustomRowViewInfoAccess = class(TcxCustomRowViewInfo);
  TcxCustomVerticalGridAccess = class(TcxCustomVerticalGrid);
  TcxCollectionItemEditorRowPropertiesAccess = class(TcxCollectionItemEditorRowProperties);
  TcxRowValueInfoAccess = class(TcxRowValueInfo);
  TcxVerticalGridRowsAccess = class(TcxVerticalGridRows);

{ TcxCategoryRowHeaderInfo }

procedure TcxCategoryRowHeaderInfo.AddBottomHorzLine(const R: TRect);
begin
  with ViewInfo, R do
    if HorzLineWidth > 0 then
      Self.LinesInfo.Add(Left - VertLineWidth, Bottom,
        Right - Left + 2 * VertLineWidth, HorzLineWidth, HorzLineBrush);
end;

procedure TcxCategoryRowHeaderInfo.AddRightVertLine(const R: TRect);
begin
  with ViewInfo, Row.ViewInfo.RowRect do
    if VertLineWidth > 0 then
      Self.LinesInfo.Add(Right, Top, VertLineWidth,
        Bottom - Top + HorzLineWidth, BandBorderColor);
end;

procedure TcxCategoryRowHeaderInfo.CalcRowCaptionsInfo;
begin
  if ViewInfo.UseCategoryExplorerStyle and not cxRectIsEmpty(ButtonRect) then
    FHeaderCellsRect.Right := FButtonRect.Left;
  inherited CalcRowCaptionsInfo;
end;

procedure TcxCategoryRowHeaderInfo.CalcViewParams(AAllowFocus: Boolean);
begin
  FIndentViewParams := VerticalGrid.Styles.GetCategoryParams(Row);
  ViewParams := IndentViewParams;
end;

procedure TcxCategoryRowHeaderInfo.DoCalcExpandButton;
begin
  if Row.HasVisibleChildren then
    if ViewInfo.UseCategoryExplorerStyle then
      with HeaderRect, ViewInfo.ExplorerButtonSize do
        FButtonRect := cxRectCenter(cxRect(Right - cx - 2, Top, Right, Bottom), cx, cy)
    else
      inherited DoCalcExpandButton;
end;

function TcxCategoryRowHeaderInfo.GetCaptionViewParams: TcxViewParams;
begin
  Result := ViewParams;
end;

function TcxCategoryRowHeaderInfo.GetButtonColor: TColor;
begin
  if PaintStyle = psDotNet then
    Result := ViewParams.Color
  else
    Result := inherited GetButtonColor;
end;

function TcxCategoryRowHeaderInfo.GetFocusRect: TRect;
begin
  Result := ViewInfo.CalcHelper.GetCategoryFocusRect(Self);
end;

function TcxCategoryRowHeaderInfo.IncreaseBoundsByLastVertLine: Boolean;
begin
  Result := True;
end;

function TcxCategoryRowHeaderInfo.LeftViewPoint: Integer;
begin
  if PaintStyle = psDotNet then
    Result := IndentBounds.Right
  else
    Result := inherited LeftViewPoint;
end;

function TcxCategoryRowHeaderInfo.GetRow: TcxCategoryRow;
begin
  Result := TcxCategoryRow(FRow);
end;

{ TcxCategoryRowViewInfo }

procedure TcxCategoryRowViewInfo.CalcRowHeaderInfo(ANextRow: TcxCustomRow);
begin
  HeaderInfo.HeaderRect := RowRect;
  with ValuesRect do
    ValuesRect := cxNullRect;
  inherited CalcRowHeaderInfo(ANextRow);
end;

procedure TcxCategoryRowViewInfo.CalcValuesInfo;
begin
end;

function TcxCategoryRowViewInfo.GetRow: TcxCategoryRow;
begin
  Result := TcxCategoryRow(inherited Row);
end;

{ TcxEditorRowHeaderInfo }

function TcxEditorRowHeaderInfo.GetRow: TcxEditorRow;
begin
  Result := TcxEditorRow(FRow);
end;

{ TcxEditorRowViewInfo }

procedure TcxEditorRowViewInfo.CalcValuesInfo;
var
  I, ACount: Integer;
  R: TRect;
  ARowValueInfo: TcxRowValueInfo;
begin
  with ViewInfo do
  begin
    ACount := VisibleValueCount;
    for I := 0 to ACount - 1 do
    begin
      R := GetValueRect(I, Self);
      AddRectValueLines(R, (I = ACount - 1) or (R.Right >= ClipRect.Right));
      ARowValueInfo := CalcRowValueInfo(Row.Properties, ViewInfo, FirstVisibleRecordIndex + I, 0);
      CalcEditCell(R, ARowValueInfo);
    end;
  end;
  ValuesInfo.Trunc(ACount);
end;

function TcxEditorRowViewInfo.GetValueHeight(ARecordIndex: Integer;
  AWidth: Integer; AViewInfo: TcxvgCustomViewInfo): Integer;
var
  ARowValueInfo: TcxRowValueInfoAccess;
begin
  with AViewInfo do
  begin

⌨️ 快捷键说明

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