cxpc.pas

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

PAS
1,633
字号
    function GetTopOrLeftPartRowCount: Integer;
    function GetColor: TColor;
    function GetHideTabs: Boolean;
    function GetShowFrame: Boolean;
    function GetRotate: Boolean;
    function GetImageBorder: Integer;
  protected
    property Pages[ATabVisibleIndex: Integer]: TcxTabSheet read GetPage;
  public
    constructor Create(AParent: TcxCustomTabControl);
    property ActivePage: TcxTabSheet read GetActivePage; 
    property Canvas: TcxCanvas read GetCanvas;
    property Color: TColor read GetColor;
    property ExtendedBottomOrRightTabsRect: TRect read GetExtendedBottomOrRightTabsRect;
    property ExtendedTopOrLeftTabsRect: TRect read GetExtendedTopOrLeftTabsRect;
    property Font: TFont read GetFont;
    property Height: Integer read GetHeight;
    property HideTabs: Boolean read GetHideTabs;
    property ImageBorder: Integer read GetImageBorder;
    property IsTabsContainer: Boolean read GetIsTabsContainer;
    property MainTabVisibleIndex: Integer read GetMainTabVisibleIndex;
    property MultiLine: Boolean read GetMultiLine;
    property NavigatorButtonsState[Index: TcxPCNavigatorButton]: TcxPCNavigatorButtonState read GetNavigatorButtonState;
    property NavigatorButtons: TcxPCNavigatorButtons read GetNavigatorButtons;
    property NavigatorPosition: TcxPCNavigatorPosition read GetNavigatorPositione;
    property Options: TcxPCOptions read GetOptions;
    property PageColors[ATabVisibleIndex: Integer]: TColor read GetPageColor;
    property RaggedRight: Boolean read GetRaggedRight;
    property Rotate: Boolean read GetRotate;
    property RowCount: Integer read GetRowCount;
    property ScrollOpposite: Boolean read GetScrollOpposite;
    property ShowFrame: Boolean read GetShowFrame;
    property TabColors[ATabVisibleIndex: Integer]: TColor read GetTabColor;
    property TabHeight: Smallint read GetTabHeight;
    property TabPosition: TcxTabPosition read GetTabPosition;
    property TabSlants: TcxTabSlants read GetTabSlants;
    property TabsOnBothSides: Boolean read GetTabsOnBothSides;
    property TabWidth: Smallint read GetTabWidth;
    property TopOrLeftPartRowCount: Integer read GetTopOrLeftPartRowCount;
    property VisibleTabs[TabVisibleIndex: Integer]: TcxTab read GetVisibleTab;
    property Width: Integer read GetWidth;
  end;

  TcxPCCustomPainter = class
  private
    FParentInfo: TcxPCPainterParentInfo;
    FParentControl: TcxCustomTabControl;
    function GetDisabledTextFaceColor: TColor;
    function GetDisabledTextShadowColor: TColor;
    function GetHighlightedTabBodyColor: TColor;
    procedure PrepareTabControlImagesBitmapBackground(ABitmap: TBitmap);
  protected
    FOutTabImageAndTextData: TcxPCOutTabImageAndTextData;
    class function AllowRotate: Boolean; virtual;
    function CalculateTabNormalWidth(Tab: TcxTab): Integer; virtual; abstract;
    procedure CorrectTabRect(TabVisibleIndex: Integer; var TabRectCorrection: TcxPCRectCorrection); virtual;
    function CreateNewTabVerticalTextBitmap(TabVisibleIndex: Integer): TBitmap;
    procedure DirectionalPolyline(const R: TRect; APoints: array of TPoint;
      ATabPosition: TcxTabPosition; AColor: TColor);
    function DoCustomDraw(TabVisibleIndex: Integer): Boolean;
    procedure DrawNativeTabBackground(DC: HDC; ATab: TcxTabSheet); virtual;
    procedure DrawTabImageAndText(ATab: TcxTab; ATabVisibleIndex: Integer); virtual;
    procedure ExcludeTabContentClipRegion(ATabVisibleIndex: Integer);
    procedure FillDisplayRect; virtual;
    procedure FillTabPaneContent; virtual;
    function GetButtonsDistance(AButton1, AButton2: TcxPCNavigatorButton): Integer; virtual;
    function GetButtonsRegionFromTabsOffset: Integer; virtual;
    function GetButtonsRegionHOffset: Integer; virtual;
    function GetButtonsRegionWOffset: Integer; virtual;
    function GetClientColor: TColor; virtual;
    function GetClientRect: TRect;
    function GetClientRectOffset: TRect; virtual;
    function GetDefaultClientColor: TColor; virtual;
    function GetDisplayRect: TRect;
    function GetDisplayRectOffset: TRect; virtual;
    function GetDrawImageOffset(TabVisibleIndex: Integer): TRect; virtual; abstract;
    function GetDrawImageWithoutTextWOffset(TabVisibleIndex: Integer): TcxPCWOffset; virtual; abstract;
    function GetDrawTextHOffset(TabVisibleIndex: Integer): TRect; virtual; abstract;

    function GetExtendedRect(const ARect, AExtension: TRect; ATabPosition: TcxTabPosition): TRect;
    function GetFrameWidth: Integer; virtual;

    procedure AfterPaintTab(ATabVisibleIndex: Integer); virtual;
    function AlwaysColoredTabs: Boolean; virtual;
    function GetGoDialogPosition(GoDialogSize: TSize): TPoint; virtual; abstract;
    function GetHighlightedTextColor(ATabVisibleIndex: Integer;
      ATextColor: TColor): TColor;
    function GetHotTrackColor: TColor;
    function GetImageTextDistance(ATabVisibleIndex: Integer): Integer; virtual; abstract;
    function GetMaxTabCaptionHeight: Integer;
    function GetMinTabNormalWidth(ATabVisibleIndex: Integer): Integer; virtual; abstract;
    function GetMinTabSelectionDistance: TcxPCDistance; virtual; abstract;
    function GetNativeContentOffset: TRect; virtual;
    function GetTabBaseImageSize: TSize;
    function GetTabBodyColor(TabVisibleIndex: Integer): TColor; virtual; abstract;
    function GetTabColor(ATabVisibleIndex: Integer): TColor; virtual;
    function GetTabClipRgn(ATabVisibleIndex: Integer): TcxRegion; virtual;
    function GetTabClipRgnOperation(ATabVisibleIndex: Integer): TcxRegionOperation; virtual;
    function GetTabContentWOffset(ATabVisibleIndex: Integer): TcxPCWOffset; virtual; abstract;
    procedure GetTabNativePartAndState(ATabVisibleIndex: Integer;
      out PartId, StateId: Integer); virtual;
    function GetTabNativeState(ATabVisibleIndex: Integer): Integer;
    function GetTabRotatedImageSize: TSize;
    function GetTabsContainerOffsets: TRect; virtual;
    function GetTabsNormalDistance: TcxPCDistance; virtual;
    function GetTabsPosition(NavigatorButtons: TcxPCNavigatorButtons): TcxPCTabsPosition; virtual; abstract;
    function GetTabVerticalTextBitmap(TabVisibleIndex: Integer): TBitmap;
    function GetTextColor(ATabVisibleIndex: Integer): TColor; virtual;
    function GetTooNarrowTabContentWOffset(ATabVisibleIndex: Integer): TcxPCWOffset; virtual; abstract;
    procedure Init; virtual;
    procedure InternalDrawText(ACanvas: TCanvas; const ACaption: string;
      ARect: TRect; ATabVisibleIndex: Integer); virtual;
    procedure InternalInvalidateRect(Rect: TRect);
    procedure InternalPaint; virtual;
    procedure InternalPolyLine(const APoints: array of TPoint; AColor: TColor;
      ACanvas: TCanvas = nil);
    procedure InternalPrepareOutTabImageAndTextData(ATabVisibleIndex: Integer;
      var AImageRect, ATextRect: TRect); virtual; abstract;
    procedure InternalResetClipRegion;
    function InternalSetClipRect(ClipR: TRect; IntersectWithCurrentClipRegion: Boolean = True): Boolean;
    procedure InvalidateTabExtendedTabsRect(TabVisibleIndex: Integer);
    procedure InvalidateTabRect(ATabVisibleIndex: Integer); virtual;
    function IsAssignedImages: Boolean;
    function IsCustomDraw: Boolean;
    function IsEnableHotTrack: Boolean; virtual;
    function IsNativePainting: Boolean; virtual;
    function IsOverButton(X, Y: Integer; var Button: TcxPCNavigatorButton): Boolean; virtual; abstract;
    function IsOverTab(TabVisibleIndex: Integer; X, Y: Integer): Boolean; virtual;
    function IsTabHasImage(ATabVisibleIndex: Integer): Boolean;
    function IsTabBorderThick(ATabVisibleIndex: Integer): Boolean; virtual; abstract;
    function IsTabTransparent(ATabVisibleIndex: Integer): Boolean; virtual;
    function NeedDisabledTextShadow: Boolean; virtual;
    function NeedRedrawOnResize: Boolean; virtual;
    function NeedShowFrame: Boolean; virtual;
    procedure Paint; virtual;
    procedure PaintButtonsRegion; virtual; abstract;
    procedure PaintClientArea; virtual;
    procedure PaintFrame; virtual; abstract;
    procedure PaintTabsRegion; virtual; abstract;
    procedure PrepareTabCanvasFont(ATab: TcxTab; ACanvas: TcxCanvas);
    procedure PrepareDrawTabContentBitmapBackground(ABitmap: TBitmap;
      const ABitmapPos: TPoint; ATabVisibleIndex: Integer); virtual;
    procedure RepaintButton(Button: TcxPCNavigatorButton; OldButtonState: TcxPCNavigatorButtonState); virtual;
    procedure RepaintButtonsRegion; virtual;
    procedure RepaintTab(TabVisibleIndex: Integer; TabPropertyChanged: TcxPCTabPropertyChanged); virtual;
    procedure RotatePoint(const R: TRect; var P: TPoint;
      ATabPosition: TcxTabPosition);
    procedure RotatePolyline(const R: TRect; var APoints: array of TPoint;
      ATabPosition: TcxTabPosition);
    procedure StandardPainterPrepareOutTabImageAndTextData(TabVisibleIndex: Integer);

    procedure SaveClipRgn;
    procedure RestoreClipRgn;

    property DisabledTextFaceColor: TColor read GetDisabledTextFaceColor;
    property DisabledTextShadowColor: TColor read GetDisabledTextShadowColor;
    property HighlightedTabBodyColor: TColor read GetHighlightedTabBodyColor;

    property ParentControl: TcxCustomTabControl read FParentControl;
    property ParentInfo: TcxPCPainterParentInfo read FParentInfo;
  public
    constructor Create(AParent: TcxCustomTabControl); virtual;
    destructor Destroy; override;

    function CalculateTabNormalHeight: Integer; virtual; abstract;
    function GetGoDialogButtonBounds: TRect; virtual; abstract;
    class function GetStandardStyle: TcxPCStandardStyle; virtual;
    class function GetStyleID: TcxPCStyleID; virtual;
    class function GetStyleName: TCaption; virtual;
    class function HasLookAndFeel(ALookAndFeel: TcxLookAndFeel): Boolean; virtual;
    class function IsDefault(ALookAndFeel: TcxLookAndFeel): Boolean; virtual;
    class function IsMainTabBoundWithClient: Boolean; virtual;
    class function IsMultiSelectionAccepted: Boolean; virtual;
    class function IsStandardStyle: Boolean; virtual;
    class function IsTabPressable: Boolean; virtual;
  end;

  TcxPCPainterClass = class of TcxPCCustomPainter;

  TcxPCImageListPrepareBitmapBackgroundEvent = procedure(ABitmap: TBitmap) of object;

  TcxPCImageList = class
  private
    FBaseImageChangeLink: TChangeLink;
    FBaseImages: TCustomImageList;
    FFreeNotificator: TcxFreeNotificator;
    FImageRotationAngle: TcxRotationAngle;
    FParent: TcxCustomTabControl;
    FRotatedImages: TcxPCImageListRotatedImagesElementArray;
    FOnChange: TNotifyEvent;
    FOnPrepareBitmapBackground: TcxPCImageListPrepareBitmapBackgroundEvent;
    procedure BaseImageListChange(Sender: TObject);
    procedure Change;
    procedure ClearRotatedImages;
    procedure DoPrepareBitmapBackground(ABitmap: TBitmap);
    procedure FreeNotification(AComponent: TComponent);
    class procedure OutError(SourceMethodName, Msg: TCaption);
    procedure RotateImage(Index: Integer; BackgroundColor: TColor; Enabled: Boolean);
    procedure RotateImages;
    procedure SetImageRotationAngle(const Value: TcxRotationAngle);
    procedure SetBaseImages(const Value: TCustomImageList);
    function GetBaseImageSize: TSize;
    function GetRotatedImageSize: TSize;
  public
    constructor Create(AParent: TcxCustomTabControl);
    destructor Destroy; override;
    procedure Draw(Canvas: TCanvas; X, Y, Index: Integer; BackgroundColor: TColor;
      Enabled: Boolean = True);

    property BaseImages: TCustomImageList read FBaseImages write SetBaseImages;
    property BaseImageSize: TSize read GetBaseImageSize;
    property ImageRotationAngle: TcxRotationAngle read FImageRotationAngle write SetImageRotationAngle default ra0;
    property RotatedImageSize: TSize read GetRotatedImageSize;
    property OnChange: TNotifyEvent read FOnChange write FOnChange;
    property OnPrepareBitmapBackground: TcxPCImageListPrepareBitmapBackgroundEvent
      read FOnPrepareBitmapBackground write FOnPrepareBitmapBackground;
  end;

  { TcxTabSlants }

  TcxTabSlants = class(TPersistent)
  private
    FKind: TcxTabSlantKind;
    FOwner: TPersistent;
    FPositions: TcxTabSlantPositions;
    FOnChange: TNotifyEvent;
    procedure Changed;
    procedure SetKind(Value: TcxTabSlantKind);
    procedure SetPositions(Value: TcxTabSlantPositions);
  protected
    function GetOwner: TPersistent; override;
  public
    constructor Create(AOwner: TPersistent);
    procedure Assign(Source: TPersistent); override;
    property OnChange: TNotifyEvent read FOnChange write FOnChange;
  published
    property Kind: TcxTabSlantKind read FKind write SetKind default skSlant;
    property Positions: TcxTabSlantPositions read FPositions write SetPositions
      default [spLeft];
  end;

  { TcxCustomTabControl }

  TcxCustomTabControl = class(TcxControl, IdxSkinSupport)
  private
    FChangeEventLockCount: Integer;
    FClientRect: TRect;
    FExtendedBottomOrRightTabsRect: TRect;
    FExtendedTopOrLeftTabsRect: TRect;
    FFirstVisibleTab, FLastVisibleTab: Integer;
    FFocusable: Boolean;
    FGoDialog: TcxPCGoDialog;
    FHideTabs: Boolean;
    FHotTrack: Boolean;
    FHotTrackNavigatorButton: TcxPCNavigatorButtonIndex;
    FHotTrackTabVisibleIndex: Integer;
    FImageBorder: Integer;
    FImages: TcxPCImageList;
    FIsClientRectLoaded: Boolean;
    FIsGoDialogShowing: Boolean;
    FIsLastTabFullyVisible: Boolean;
    FIsTabsContainer: Boolean;
    FMainTabVisibleIndex: Integer;
    FMaxRotatedTabWidth: Integer;
    FMaxTabCaptionWidth: Integer;
    FMultiLine: Boolean;
    FMultiSelect: Boolean;
    FNavigatorButtons: TcxPCNavigatorButtons;
    FNavigatorButtonStates: array[TcxPCNavigatorButton] of TcxPCNavigatorButtonState;
    FNavigatorPosition: TcxPCNavigatorPosition;
    FOptions: TcxPCOptions;
    FOwnerDraw: Boolean;
    FPainter: TcxPCCustomPainter;
    FPressedNavigatorButton: TcxPCNavigatorButtonIndex;
    FPressedTabVisibleIndex: Integer;
    FRaggedRight: Boolean;
    FRotate: Boolean;
    FRowCount: Integer;
    FRowHeight: Integer;
    FScrollOpposite: Boolean;
    FShowFrame: Boolean;
    FStyle: TcxPCStyleID;
    FTabCaptionAlignment: TAlignment;
    FTabIndex: Integer;
    FTabPosition: TcxTabPosition;
    FTabs: TcxTabs;
    FTabSize: TSmallPoint;
    FTabSlants: TcxTabSlants;
    FTabsPosition: TcxPCTabsPosition;
    FTimer: TcxTimer;
    FTopOrLeftPartRowCount: Integer;
    FTracking: Integer;
    FUpdating: Boolean;
    FVisibleTabList: TcxVisibleTabList;
    FOnCanClose: TcxPCCanCloseEvent;
    FOnChange: TNotifyEvent;
    FOnChanging: TcxTabChangingEvent;
    FOnDrawTab: TcxDrawTabEvent;
    FOnDrawTabEx: TcxDrawTabExEvent;
    FOnGetImageIndex: TcxGetTabImageEvent;
    procedure ArrowButtonClick(NavigatorButton: TcxPCNavigatorButton);
    procedure Calculate;
    procedure CalculateLongitudinalTabPositions;
    procedure CalculateRowHeight;
    procedure CalculateRowPositions;
    procedure CalculateTabNormalSize(Tab: TcxTab);
    procedure CalculateTabNormalSizes;
    function CanMouseWheel(const AMouseScreenPos: TPoint): Boolean;
    function CanPressButton(AButton: TcxPCNavigatorButton): Boolean;
    procedure CloseButtonClick;
    procedure CorrectMaxRotatedTabWidth;
    procedure CorrectTabRect(TabVisibleIndex: Integer);
    procedure CreateGoDialog;
    procedure CreateTimer;
    procedure DoDrawTabEx(ATabVisibleIndex: Integer; AFont: TFont);
    function GetDisplayRect: TRect;
    function GetImages: TCustomImageList;
    function GetLineWidth(const ALineIndexBoundsA: TcxPCLineIndexBoundsArray;
      ALineNumber, ATabsDistance: Integer): Integer;
    function GetMainTabIndex: Integer;
    function GetMaxRotatedTabWidth: Integer;
    function GetNavigatorButton(NavigatorButtonIndex: TcxPCNavigatorButtonIndex): TcxPCNavigatorButton;
    function GetNavigatorButtons(OnlyObligatoryButtons: Boolean): TcxPCNavigatorButtons;
    function GetOptions: TcxPCOptions;
    function GetStyle: TcxPCStyleID;
    function GetTabExtendedTabsRect(TabVisibleIndex: Integer): TRect;
    function GetTabsTab(TabIndex: Integer): TcxTab;

⌨️ 快捷键说明

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