cxgriddetailssite.pas

来自「胜天进销存源码,国产优秀的进销存」· PAS 代码 · 共 2,042 行 · 第 1/5 页

PAS
2,042
字号
{********************************************************************}
{                                                                    }
{       Developer Express Visual Component Library                   }
{       ExpressQuantumGrid                                           }
{                                                                    }
{       Copyright (c) 1998-2008 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 EXPRESSQUANTUMGRID 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 cxGridDetailsSite;

{$I cxVer.inc}
{$I cxGridVer.inc}

interface

uses
  Windows, Messages, Classes, Graphics, Controls,
  cxClasses, cxGraphics, cxControls, cxLookAndFeels, cxLookAndFeelPainters,
{$IFDEF USETABCONTROL}
  cxPC,
{$ENDIF}
  cxGridCommon, cxGridLevel, cxGridCustomView;

const
  htTab = 50;

  cxGridTabsRootSize: Integer = 1 + 3;

type
{$IFNDEF USETABCONTROL}
  TcxCustomGridDetailsSiteTabViewInfo = class;
{$ENDIF}  
  TcxCustomGridDetailsSiteTabsViewInfo = class;
  TcxCustomGridDetailsSiteViewInfo = class;

  { hit tests }

  TcxGridDetailsSiteTabHitTestClass = class of TcxGridDetailsSiteTabHitTest;

  TcxGridDetailsSiteTabHitTest = class(TcxCustomGridHitTest)
  private
    FLevel: TcxGridLevel;
    FOwner: TObject;
  protected
    class function GetHitTestCode: Integer; override;
  public
    property Level: TcxGridLevel read FLevel write FLevel;
    property Owner: TObject read FOwner write FOwner;
  end;

  { painters }

{$IFNDEF USETABCONTROL}

  TcxGridDetailsSiteTabPainter = class(TcxCustomGridCellPainter)
  private
    function GetViewInfo: TcxCustomGridDetailsSiteTabViewInfo;
  protected
    procedure DrawBorder(ABorder: TcxBorder); override;
    procedure DrawContent; override;
    property ViewInfo: TcxCustomGridDetailsSiteTabViewInfo read GetViewInfo;
  end;

{$ENDIF}  

  TcxGridDetailsSiteTabsPainterClass = class of TcxGridDetailsSiteTabsPainter;

  TcxGridDetailsSiteTabsPainter = class
  private
    FCanvas: TcxCanvas;
    FViewInfo: TcxCustomGridDetailsSiteTabsViewInfo;
  protected
  {$IFNDEF USETABCONTROL}
    procedure DrawBackground; virtual;
    procedure DrawItems; virtual;
    procedure DrawRoot; virtual;
  {$ENDIF}  
    procedure Paint; virtual;
    property Canvas: TcxCanvas read FCanvas;
    property ViewInfo: TcxCustomGridDetailsSiteTabsViewInfo read FViewInfo;
  public
    constructor Create(ACanvas: TcxCanvas; AViewInfo: TcxCustomGridDetailsSiteTabsViewInfo); virtual;
    procedure MainPaint;
  end;

  TcxGridDetailsSitePainterClass = class of TcxGridDetailsSitePainter;

  TcxGridDetailsSitePainter = class
  private
    FCanvas: TcxCanvas;
    FViewInfo: TcxCustomGridDetailsSiteViewInfo;
  protected
    procedure DrawBackground; virtual;
    procedure DrawFrame; virtual;
    procedure DrawTabs; virtual;
    property Canvas: TcxCanvas read FCanvas;
    property ViewInfo: TcxCustomGridDetailsSiteViewInfo read FViewInfo;
  public
    constructor Create(ACanvas: TcxCanvas; AViewInfo: TcxCustomGridDetailsSiteViewInfo); virtual;
    procedure Paint; virtual;
  end;

  { view infos }

  // custom tabs

{$IFNDEF USETABCONTROL}

  TcxCustomGridDetailsSiteTabViewInfoClass = class of TcxCustomGridDetailsSiteTabViewInfo;

  TcxCustomGridDetailsSiteTabViewInfo = class(TcxCustomGridCellViewInfo)
  private
    FIndex: Integer;
    FLevel: TcxGridLevel;
    FTabsViewInfo: TcxCustomGridDetailsSiteTabsViewInfo;
    function GetActive: Boolean;
    function GetCaption: string;
    function GetGrid: TcxControl;
    function GetIsVertical: Boolean;
    function GetLookAndFeelPainter: TcxCustomLookAndFeelPainterClass;
    function GetSiteViewInfo: TcxCustomGridDetailsSiteViewInfo;
  protected
    function CalculateHeight: Integer; override;
    function CalculateWidth: Integer; override;
    function GetBorderWidth(AIndex: TcxBorder): Integer; override;
    function GetCanvas: TcxCanvas; override;
    function GetHitTestClass: TcxCustomGridHitTestClass; override;
    function GetHotTrack: Boolean; override;
    function GetIsDesignSelected: Boolean; override;
    function GetPainterClass: TcxCustomGridCellPainterClass; override;
    function GetStateForPaint: TcxGridCellState; virtual;
    function GetText: string; override;
    function GetTextAreaBounds: TRect; override;
    function GetTextAttributes(AForPainting: Boolean): Integer; override;
    function GetTextForPainting: string; override;
    procedure GetViewParams(var AParams: TcxViewParams); override;
    function HasFirstBorder: Boolean;
    function HasLastBorder: Boolean;
    procedure InitHitTest(AHitTest: TcxCustomGridHitTest); override;

    property Grid: TcxControl read GetGrid;
    property Index: Integer read FIndex;
    property IsVertical: Boolean read GetIsVertical;
    property Level: TcxGridLevel read FLevel;
    property LookAndFeelPainter: TcxCustomLookAndFeelPainterClass read GetLookAndFeelPainter;
    property SiteViewInfo: TcxCustomGridDetailsSiteViewInfo read GetSiteViewInfo;
    property TabsViewInfo: TcxCustomGridDetailsSiteTabsViewInfo read FTabsViewInfo;
  public
    constructor Create(ATabsViewInfo: TcxCustomGridDetailsSiteTabsViewInfo;
      ALevel: TcxGridLevel); virtual;
    function MouseDown(AHitTest: TcxCustomGridHitTest; AButton: TMouseButton;
      AShift: TShiftState): Boolean; override;
    function ProcessDialogChar(ACharCode: Word): Boolean; virtual;
    property Active: Boolean read GetActive;
    property Caption: string read GetCaption;
    property StateForPaint: TcxGridCellState read GetStateForPaint;
  end;

{$ENDIF}  

{$IFDEF USETABCONTROL}

  TcxGridLevelTabControlClass = class of TcxGridLevelTabControl;

  TcxGridLevelTabControl = class(TcxTabControl)
  private
    FSiteViewInfo: TcxCustomGridDetailsSiteViewInfo;
    FUnderlineHotKeys: Boolean;
    function GetActiveLevel: TcxGridLevel;
    function GetLevel(Index: Integer): TcxGridLevel;
    function GetLevelCount: Integer;
    procedure SetActiveLevel(Value: TcxGridLevel);
    procedure SetUnderlineHotKeys(Value: Boolean);
    procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
    procedure CMDrag(var Message: TCMDrag); message CM_DRAG;
  protected
    FocusActiveViewOnChange: Boolean;
    procedure AfterPaintTab(ACanvas: TcxCanvas; ATab: TcxTab;
      AImageAndTextData: TcxPCOutTabImageAndTextData); override;
    procedure Change; override;
    function GetLevelDisplayText(ALevel: TcxGridLevel): string; virtual;
    function GetTabHitTestClass: TcxGridDetailsSiteTabHitTestClass; virtual;
    function HandleDialogChar(Key: Integer): Boolean; override;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure Notification(AComponent: TComponent; AOperation: TOperation); override;
    procedure PrepareTabCanvasFont(ATab: TcxTab; ACanvas: TcxCanvas); override;
    procedure WndProc(var Message: TMessage); override;

    procedure DblClick; override;
    function DoMouseWheel(Shift: TShiftState; WheelDelta: Integer; MousePos: TPoint): Boolean; override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;
    procedure MouseUp(Button: TMouseButton; Shift: TShiftState; X, Y: Integer); override;
  public
    constructor Create(ASiteViewInfo: TcxCustomGridDetailsSiteViewInfo); reintroduce; virtual;
    procedure AddLevel(ALevel: TcxGridLevel);
    function GetHitTest(const P: TPoint): TcxCustomGridHitTest; virtual;

    property ActiveLevel: TcxGridLevel read GetActiveLevel write SetActiveLevel;
    property LevelCount: Integer read GetLevelCount;
    property Levels[Index: Integer]: TcxGridLevel read GetLevel;
    property SiteViewInfo: TcxCustomGridDetailsSiteViewInfo read FSiteViewInfo;
    property UnderlineHotKeys: Boolean read FUnderlineHotKeys write SetUnderlineHotKeys;
  end;

{$ENDIF}  

  TcxCustomGridDetailsSiteTabsViewInfoClass = class of TcxCustomGridDetailsSiteTabsViewInfo;

  TcxCustomGridDetailsSiteTabsViewInfo = class
  private
    FHeight: Integer;
    FSiteViewInfo: TcxCustomGridDetailsSiteViewInfo;
  {$IFDEF USETABCONTROL}
    FTabControl: TcxGridLevelTabControl;
  {$ELSE}
    FItems: TList;
  {$ENDIF}
    FWidth: Integer;
    function GetActiveLevel: TcxGridLevel;
  {$IFNDEF USETABCONTROL}
    function GetCanvas: TcxCanvas;
    function GetCount: Integer;
    function GetItem(Index: Integer): TcxCustomGridDetailsSiteTabViewInfo;
    function GetLookAndFeelPainter: TcxCustomLookAndFeelPainterClass;
    function GetMainSize: Integer;
    function GetTabSize: Integer;
  {$ENDIF}
    function GetHeight: Integer;
    function GetLevel: TcxGridLevel;
    function GetWidth: Integer;
  {$IFNDEF USETABCONTROL}
    procedure CreateItems;
    procedure DestroyItems;
  {$ENDIF}
  protected
    procedure AdjustBounds; virtual; abstract;
    function CalculateHeight: Integer; virtual;
    function CalculateWidth: Integer; virtual;
    procedure CheckSiteViewInfoHeight(var AHeight: Integer); virtual;
    procedure CheckSiteViewInfoWidth(var AWidth: Integer); virtual;
    function GetBkColor: TColor; virtual;
    function GetFirstVisibleTabIndex: Integer; virtual;
    procedure SetFirstVisibleTabIndex(Value: Integer); virtual;
    function GetIsVertical: Boolean; virtual; abstract;
  {$IFNDEF USETABCONTROL}
    function GetActiveTabOffset: Integer; virtual; abstract;
    function GetItemClass: TcxCustomGridDetailsSiteTabViewInfoClass; virtual; abstract;
    function GetItemHeight(AItem: TcxCustomGridDetailsSiteTabViewInfo): Integer; virtual;
    function GetItemWidth(AItem: TcxCustomGridDetailsSiteTabViewInfo): Integer; virtual;
    function GetRootBorders: TcxBorders; virtual; abstract;
    function GetRootBounds: TRect; virtual; abstract;
  {$ENDIF}
    function GetPainterClass: TcxGridDetailsSiteTabsPainterClass; virtual;
  {$IFDEF USETABCONTROL}
    function AreTabsRotated: Boolean; virtual;
    function GetTabControlBounds: TRect; virtual;
    function GetTabControlClass: TcxGridLevelTabControlClass; virtual;
    function GetTabPosition: TcxTabPosition; virtual; abstract;
    procedure InitTabControl; virtual;
    procedure InitTabControlData; virtual;
    procedure InitTabControlHotKeyParams; virtual;
    procedure InitTabControlLayout; virtual;
    procedure InitTabControlStyle; virtual;
    procedure InitTabsStyle; virtual;
  {$ENDIF}

    property FirstVisibleTabIndex: Integer read GetFirstVisibleTabIndex write SetFirstVisibleTabIndex;
    property IsVertical: Boolean read GetIsVertical;
    property Level: TcxGridLevel read GetLevel;
  {$IFNDEF USETABCONTROL}
    property ActiveTabOffset: Integer read GetActiveTabOffset;
    property Canvas: TcxCanvas read GetCanvas;
    property LookAndFeelPainter: TcxCustomLookAndFeelPainterClass read GetLookAndFeelPainter;
    property MainSize: Integer read GetMainSize;
    property TabSize: Integer read GetTabSize;
  {$ENDIF}
  public
    Bounds: TRect;
    constructor Create(ASiteViewInfo: TcxCustomGridDetailsSiteViewInfo); virtual;
    destructor Destroy; override;
    procedure BeforeRecalculation; virtual;
    procedure Calculate(const ABounds: TRect); virtual;
    procedure GetClientBounds(var AClientBounds: TRect); virtual; abstract;
    function GetHitTest(const P: TPoint): TcxCustomGridHitTest; virtual;
    function ProcessDialogChar(ACharCode: Word): Boolean; virtual;

    property ActiveLevel: TcxGridLevel read GetActiveLevel;
    property BkColor: TColor read GetBkColor;
  {$IFDEF USETABCONTROL}
    property TabControl: TcxGridLevelTabControl read FTabControl;
  {$ELSE}
    property Count: Integer read GetCount;
    property Items[Index: Integer]: TcxCustomGridDetailsSiteTabViewInfo read GetItem;
    property RootBorders: TcxBorders read GetRootBorders;
    property RootBounds: TRect read GetRootBounds;
  {$ENDIF}
    property Height: Integer read GetHeight;
    property SiteViewInfo: TcxCustomGridDetailsSiteViewInfo read FSiteViewInfo;
    property Width: Integer read GetWidth;
  end;

  // left tabs

{$IFNDEF USETABCONTROL}

  TcxGridDetailsSiteLeftTabViewInfo = class(TcxCustomGridDetailsSiteTabViewInfo)
  protected
    function CalculateHeight: Integer; override;
    function CalculateWidth: Integer; override;
    function GetAlignmentVert: TcxAlignmentVert; override;
    function GetBorders: TcxBorders; override;
  public
    procedure Calculate(ALeftBound, ATopBound: Integer; AWidth: Integer = -1;
      AHeight: Integer = -1); override;
  end;

{$ENDIF}

  TcxGridDetailsSiteLeftTabsViewInfo = class(TcxCustomGridDetailsSiteTabsViewInfo)
  protected
    procedure AdjustBounds; override;
    procedure CheckSiteViewInfoHeight(var AHeight: Integer); override;
    function GetIsVertical: Boolean; override;
  {$IFDEF USETABCONTROL}
    function GetTabPosition: TcxTabPosition; override;
  {$ELSE}
    function GetActiveTabOffset: Integer; override;
    function GetItemClass: TcxCustomGridDetailsSiteTabViewInfoClass; override;
    function GetRootBorders: TcxBorders; override;
    function GetRootBounds: TRect; override;
  {$ENDIF}  
  public
    procedure GetClientBounds(var AClientBounds: TRect); override;
  end;

  // top tabs

{$IFNDEF USETABCONTROL}

  TcxGridDetailsSiteTopTabViewInfo = class(TcxCustomGridDetailsSiteTabViewInfo)
  protected
    function CalculateHeight: Integer; override;
    function CalculateWidth: Integer; override;
    function GetBorders: TcxBorders; override;
  public
    procedure Calculate(ALeftBound, ATopBound: Integer; AWidth: Integer = -1;
      AHeight: Integer = -1); override;
  end;

{$ENDIF}  

  TcxGridDetailsSiteTopTabsViewInfo = class(TcxCustomGridDetailsSiteTabsViewInfo)
  protected
    procedure AdjustBounds; override;
    procedure CheckSiteViewInfoWidth(var AWidth: Integer); override;
    function GetIsVertical: Boolean; override;
  {$IFDEF USETABCONTROL}
    function GetTabPosition: TcxTabPosition; override;
  {$ELSE}
    function CalculateHeight: Integer; override;
    function CalculateWidth: Integer; override;
    function GetActiveTabOffset: Integer; override;
    function GetItemClass: TcxCustomGridDetailsSiteTabViewInfoClass; override;
    function GetItemHeight(AItem: TcxCustomGridDetailsSiteTabViewInfo): Integer; override;
    function GetItemWidth(AItem: TcxCustomGridDetailsSiteTabViewInfo): Integer; override;
    function GetRootBorders: TcxBorders; override;
    function GetRootBounds: TRect; override;
  {$ENDIF}
  public
    procedure GetClientBounds(var AClientBounds: TRect); override;
  end;

  // custom details site

  TcxCustomGridDetailsSiteViewInfoCachedInfoClass = class of TcxCustomGridDetailsSiteViewInfoCachedInfo;

  TcxCustomGridDetailsSiteViewInfoCachedInfo = class
    FirstVisibleTabIndex: Integer;
  end;

  TcxCustomGridDetailsSiteViewInfo = class(TcxComponent)
  private
    FActiveGridView: TcxCustomGridView;

⌨️ 快捷键说明

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