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

📄 dxbarextitems.pas

📁 胜天进销存源码,国产优秀的进销存
💻 PAS
📖 第 1 页 / 共 5 页
字号:

{*******************************************************************}
{                                                                   }
{       Developer Express Visual Component Library                  }
{       ExpressBars extended items                                  }
{                                                                   }
{       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 EXPRESSBARS 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 dxBarExtItems;

{$I cxVer.inc}

interface

uses
{$IFDEF DELPHI6}
  Types,
{$ENDIF}
  Windows, Messages, CommCtrl, Classes, Controls, Forms, Graphics, Dialogs,
  StdCtrls, ComCtrls, ImgList, dxBar, dxBarAccessibility, dxCommon,
  dxBarSkinConsts, cxControls;

type
  TdxBarStatic = class(TdxBarItem)
  private
    FAlignment: TAlignment;
    FAllowClick: Boolean;
    FBorderStyle: TdxBarStaticBorderStyle;
    FHeight: Integer;
    FLeftIndent: Integer;
    FRightIndent: Integer;
    FWidth: Integer;
    procedure SetAlignment(Value: TAlignment);
    procedure SetBorderStyle(Value: TdxBarStaticBorderStyle);
    procedure SetSizeValue(Index: Integer; Value: Integer);
  protected
    function CanClicked: Boolean; override;
    function HasAccel(AItemLink: TdxBarItemLink): Boolean; override;
    function IsStyleColorSupported: Boolean; override;
  public
    constructor Create(AOwner: TComponent); override;
  published
    property Alignment: TAlignment read FAlignment write SetAlignment default taCenter;
    property AllowClick: Boolean read FAllowClick write FAllowClick default False;
    property BorderStyle: TdxBarStaticBorderStyle read FBorderStyle write SetBorderStyle
      default sbsNone;
    property Glyph;
    property Height: Integer index 4 read FHeight write SetSizeValue default 0;
    property ImageIndex;
    property LeftIndent: Integer index 1 read FLeftIndent write SetSizeValue default 0;
    property RightIndent: Integer index 2 read FRightIndent write SetSizeValue default 0;
    property ShowCaption default True;
    property Width: Integer index 3 read FWidth write SetSizeValue default 0;
    property OnClick;
  end;

  TdxBarStaticControl = class(TdxBarCustomStaticControl)
  private
    function GetBorderStyle: TdxBarStaticBorderStyle;
    function GetBorderOffsets: TRect;
    function GetItem: TdxBarStatic;
    function GetSizeValue(Index: Integer): Integer;
  protected
    procedure CalcDrawParams(AFull: Boolean = True); override;
    function CanClicked: Boolean; override;
    function CanHaveZeroSize: Boolean; virtual;
    function CanMouseSelect: Boolean; override;
    procedure CaptionChanged; override;
    procedure DoPaint(ARect: TRect; PaintType: TdxBarPaintType); override;
    procedure DrawInterior(ARect: TRect); override;
    function GetAlignment: TAlignment; virtual;
    function GetAutoHeight(ADefaultButtonSize: Integer): Integer;
    function GetAutoWidth(ADefaultButtonSize: Integer): Integer;
    function GetDefaultHeight: Integer; override;
    function GetDefaultWidth: Integer; override;
    function InternalGetDefaultHeight: Integer; override;
    function InternalGetDefaultWidth: Integer; override;
    function IsDestroyOnClick: Boolean; override;

    property Alignment: TAlignment read GetAlignment;
    property BorderStyle: TdxBarStaticBorderStyle read GetBorderStyle;
    property BorderOffsets: TRect read GetBorderOffsets;
    property Height: Integer index 4 read GetSizeValue;
    property LeftIndent: Integer index 1 read GetSizeValue;
    property RightIndent: Integer index 2 read GetSizeValue;
    property Width: Integer index 3 read GetSizeValue;
  public
    property Item: TdxBarStatic read GetItem;
  end;

  TdxBarLargeButton = class(TdxBarButton)
  private
    FAutoGrayScale: Boolean;
    FHeight: Integer;
    FHotImageIndex: Integer;
    FInSyncImageIndex: Boolean;
    FHotGlyph: TBitmap;
    FSyncImageIndex: Boolean;

    FSetImageIndex: Boolean;
    FSetLargeImageIndex: Boolean;
    FSetSyncImageIndex: Boolean;

    function IsImageIndexStored: Boolean;
    function IsLargeImageIndexStored: Boolean;
    procedure SetAutoGrayScale(Value: Boolean);
    procedure SetHeight(Value: Integer);
    procedure SetHotGlyph(Value: TBitmap);
    procedure SetHotImageIndex(Value: Integer);
    procedure SetSyncImageIndex(Value: Boolean);

    procedure OnHotGlyphChanged(Sender: TObject);
  protected
    procedure DefineProperties(Filer: TFiler); override;
    procedure Loaded; override;
    procedure ReadImageIndex(Reader: TReader);
    procedure WriteImageIndex(Writer: TWriter);

    function GetActionImageIndex: Integer; override;
    procedure SetActionImageIndex(Value: Integer); override;

    function HasAccel(AItemLink: TdxBarItemLink): Boolean; override;
    procedure HotGlyphChanged; override;
    function IsHotImageLinked: Boolean;
    function IsLargeImageLinked: Boolean;
    procedure LargeGlyphChanged; override;
    procedure SetImageIndex(Value: Integer); override;
    procedure SetLargeImageIndex(Value: Integer); override;   
    function UseHotImages: Boolean; override;
    function UseLargeImages: Boolean; override;
    procedure WidthChanged; override;

    // IdxBarSelectableItem
    function GetSupportedActions: TdxBarCustomizationActions; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property AutoGrayScale: Boolean read FAutoGrayScale write SetAutoGrayScale default True;
    property GlyphLayout default glTop;
    property Height: Integer read FHeight write SetHeight default 0;
    property HotGlyph: TBitmap read FHotGlyph write SetHotGlyph;
    property HotImageIndex: Integer read FHotImageIndex write SetHotImageIndex default -1;
    property LargeImageIndex stored IsLargeImageIndexStored;
    property ShowCaption default True;
    property Width default 0;
    property ImageIndex stored False{see DefineProperties: IsImageIndexStored};
    property SyncImageIndex: Boolean read FSyncImageIndex write SetSyncImageIndex default True;
  end;

  TdxBarLargeButtonControl = class(TdxBarButtonControl)
  private
    function GetHotGlyph: TBitmap;
    function GetItem: TdxBarLargeButton;

    function IsInheritedBehaviour: Boolean;
    function IsSizeAssigned: Boolean;
  protected
    function ArrowWidth: Integer; override;
    procedure HotGlyphChanged; override;
    procedure LargeGlyphChanged; override;

    function GetCurrentImage(AViewSize: TdxBarItemControlViewSize; ASelected: Boolean;
      out ACurrentGlyph: TBitmap; out ACurrentImages: TCustomImageList; out ACurrentImageIndex: Integer): Boolean; override;
    function GetDefaultViewStructure: TdxBarItemControlViewStructure; override;
    function GetDefaultViewSize: TdxBarItemControlViewSize; override;
    function GetPossibleViewLevels: TdxBarItemViewLevels; override;
    function GrayScale: Boolean; override;
    function InternalGetDefaultHeight: Integer; override;
    function InternalGetDefaultWidth: Integer; override;

    function IsRotated: Boolean; override;

    procedure PreparePaintStyleOnBar(var APaintStyle: TdxBarPaintStyle); override;

    property HotGlyph: TBitmap read GetHotGlyph;
  public
    property Item: TdxBarLargeButton read GetItem;
  end;

  TdxBarColorCombo = class(TdxBarCustomCombo)
  private
    FAutoColor: TColor;
    FAutoColorText: string;
    FColor: TColor;
    FCustomColorText: string;
    FExchangeColor: TColor;
    FHasExchangeColor: Boolean;
    FInRefreshColorNames: Boolean;
    FSettingColor: Boolean;
    FShowAutoColor: Boolean;
    FShowCustomColorButton: Boolean;

    function GetCurColor: TColor;
    procedure SetAutoColor(Value: TColor);
    procedure SetAutoColorText(Value: string);
    procedure SetColor(Value: TColor);
    procedure SetCurColor(Value: TColor);
    procedure SetCustomColorText(Value: string);
    procedure SetShowAutoColor(Value: Boolean);
    procedure SetShowCustomColorButton(Value: Boolean);

    procedure CreateItemsList;
    function GetColorByIndex(AIndex: Integer): TColor;
    function GetIndexOfColor(AColor: TColor): Integer;
    function IsAutoColorTextStored: Boolean;
    function IsCustomColorTextStored: Boolean;
    function IsDropDownCountStored: Boolean;
  protected
    procedure Change; override;
    procedure DrawItem(APainter: TdxBarPainter; AIndex: Integer; ARect: TRect;
      AState: TOwnerDrawState); override;
    procedure MeasureItem(AIndex: Integer; var AHeight: Integer); override;
    procedure MeasureItemWidth(AIndex: Integer; var AWidth: Integer); override;
    property ExchangeColor: TColor read FExchangeColor;
    property HasExchangeColor: Boolean read FHasExchangeColor;
  public
    constructor Create(AOwner: TComponent); override;
    procedure DoClick; override;
    procedure RefreshColorNames;
    property CurColor: TColor read GetCurColor write SetCurColor;
  published
    property AutoColor: TColor read FAutoColor write SetAutoColor default clWindowText;
    property AutoColorText: string read FAutoColorText write SetAutoColorText
      stored IsAutoColorTextStored;
    property Color: TColor read FColor write SetColor;
    property CustomColorText: string read FCustomColorText write SetCustomColorText
      stored IsCustomColorTextStored;
    property DropDownCount stored IsDropDownCountStored;
    property ShowAutoColor: Boolean read FShowAutoColor write SetShowAutoColor default False;
    property ShowCustomColorButton: Boolean read FShowCustomColorButton
      write SetShowCustomColorButton default False;
    property ShowEditor default False;
    property Text stored False;
  end;

  TdxBarColorComboControl = class(TdxBarComboControl)
  private
    function GetDrawParams: TdxBarColorComboControlDrawParams;
    function GetItem: TdxBarColorCombo;
  protected
    procedure CalcDrawParams(AFull: Boolean = True); override;
    procedure CalcParts; override;
    procedure CorrectFrameRect(var ARect: TRect); override;
    function DrawSelected: Boolean; override;
    procedure DrawTextField; override;
    function GetDrawParamsClass: TdxBarItemControlDrawParamsClass; override;
    function GetPartCount: Integer; override;
    procedure PressedChanged; override;
    procedure WndProc(var Message: TMessage); override;
    property DrawParams: TdxBarColorComboControlDrawParams read GetDrawParams;
  public
    property Item: TdxBarColorCombo read GetItem;
  end;

  TdxBarFontNameCombo = class(TdxBarCustomCombo)
  protected
    procedure DrawItem(APainter: TdxBarPainter; AIndex: Integer; ARect: TRect;
      AState: TOwnerDrawState); override;
    procedure LoadFontNames;
    procedure MeasureItemWidth(AIndex: Integer; var AWidth: Integer); override;
    procedure SetText(Value: string); override;
  public
    constructor Create(AOwner: TComponent); override;
    procedure DoClick; override;
  published
    property ShowEditor default False;
  end;

  TDayOfWeek = 0..6;
  TDay = (dSunday, dMonday, dTuesday, dWednesday, dThursday, dFriday, dSaturday);
  TDays = set of TDay;
  TdxBarCalendarStyle = (cs3D, csFlat, csUltraFlat);

  TdxBarCustomCalendar = class(TCustomControl)
  private
    FDragDate: TDateTime;
    FFirstDate: TDateTime;
    FSelStart: TDateTime;
    FSelFinish: TDateTime;
    FStyle: TdxBarCalendarStyle;

    FOnDateTimeChanged: TNotifyEvent;

    function GetFlat: Boolean;
    function GetUltraFlat: Boolean;
    procedure SetStyle(Value: TdxBarCalendarStyle);

    procedure WMCancelMode(var Message: TMessage); message WM_CANCELMODE;
    procedure WMCaptureChanged(var Message: TMessage); message WM_CAPTURECHANGED;
    procedure WMEraseBkgnd(var Message: TWMEraseBkgnd); message WM_ERASEBKGND;
  protected
    function GetStyle: TdxBarCalendarStyle; virtual;
    function GetRealFirstDate: TDateTime; virtual;
    function GetRealLastDate: TDateTime; virtual;
    function GetLastDate: TDateTime; virtual; abstract;
    function GetSelStart: TDateTime; virtual;
    function GetSelFinish: TDateTime; virtual;
    procedure SetFirstDate(Value: TDateTime); virtual;
    procedure SetSelStart(Value: TDateTime); virtual;
    procedure SetSelFinish(Value: TDateTime); virtual;

    procedure CancelAll; dynamic;
    procedure CheckFirstDate; virtual; abstract;
    procedure DoDateTimeChanged; dynamic;
    procedure DoInternalSelectPeriod(ADate: TDateTime);
    function PosToDateTime(P: TPoint): TDateTime; virtual; abstract;

    procedure CreateParams(var Params: TCreateParams); override;
    procedure CreateWnd; override;
    procedure MouseDown(Button: TMouseButton; Shift: TShiftState;
      X, Y: Integer); override;
    procedure MouseMove(Shift: TShiftState; X, Y: Integer); override;

    property Flat: Boolean read GetFlat;
    property UltraFlat: Boolean read GetUltraFlat;
    
    property RealFirstDate: TDateTime read GetRealFirstDate;
    property RealLastDate: TDateTime read GetRealLastDate;
  public
    constructor Create(AOwner: TComponent); override;

    property FirstDate: TDateTime read FFirstDate write SetFirstDate;
    property LastDate: TDateTime read GetLastDate;
    property SelStart: TDateTime read GetSelStart write SetSelStart;
    property SelFinish: TDateTime read GetSelFinish write SetSelFinish;
    property Style: TdxBarCalendarStyle read GetStyle write SetStyle;
    property OnDateTimeChanged: TNotifyEvent read FOnDateTimeChanged
      write FOnDateTimeChanged;
  end;

  TdxBarDateCombo = class;

  TdxBarDateNavigator = class(TdxBarCustomCalendar)
  private
    FCombo: TdxBarDateCombo;
    FColCount: Integer;
    FRowCount: Integer;
    FColWidth, FSideWidth,
    FRowHeight, FHeaderHeight, FDaysOfWeekHeight: Integer;
    FTodayButtonWidth, FClearButtonWidth, FButtonsOffset, FButtonsHeight,
    FButtonsRegionHeight: Integer;
    FListBox: TWinControl;
    FListBoxDelta: Integer;
    FTimer: UINT;
    FTodayButtonActive, FTodayButtonPressed: Boolean;
    FClearButtonActive, FClearButtonPressed: Boolean;

    procedure CheckSelection(MarginDate: TDateTime);
    function ColOfDate(ADate: TDateTime): Integer;
    function GetHeaderRect: TRect;

⌨️ 快捷键说明

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