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

📄 dxcore.pas

📁 delphi控件可以很好实现应用程序的界面设计
💻 PAS
字号:

{*******************************************************************}
{                                                                   }
{   dxCore (Design eXperience)                                      }
{                                                                   }
{   Copyright (c) 2002 APRIORI business solutions AG                }
{   (W)ritten by M. Hoffmann - ALL RIGHTS RESERVED.                 }
{                                                                   }
{   DEVELOPER NOTES:                                                }
{   ==========================================================      }
{   This file is part of a component suite called Design            }
{   eXperience and may be used in freeware- or commercial           }
{   applications. The package itself is distributed as              }
{   freeware with full sourcecodes.                                 }
{                                                                   }
{   Feel free to fix bugs or include new features if you are        }
{   familiar with component programming. If so, please email        }
{   me your modifications, so it will be possible for me to         }
{   include nice improvements in further releases:                  }
{                                                                   }
{   Contact: mhoffmann@apriori.de                                   }
{                                                                   }
{   HISTORY:                                                        }
{   =============================================================== }
{   Version 2.0.0 (2003/02/06)                                      }
{     + Second Release (major update).                              }
{                                                                   }
{   Hint:                                                           }
{     Earlier versions are not reported.                            }
{                                                                   }
{*******************************************************************}

unit dxCore;

interface

uses
  Windows, Messages, Classes, Controls, Graphics, Forms;

const
  { color constants.

    these constants are used as default colors for descendant controls
    and may be replaced with other (common) values.

    syntax: dxColor_[Control]_[Enabled: Enb, Dis]_[Type]_[Theme: WXP, OXP]     }

  { button colors - WindowsXP }
  dxColor_Btn_Enb_Border_WXP   = $00733800; // border line
  dxColor_Btn_Dis_Border_WXP   = $00BDC7CE; // border line (disabled)
  dxColor_Btn_Enb_Edges_WXP    = $00AD9E7B; // border edges
  dxColor_Btn_Dis_Edges_WXP    = $00BDC7CE; // border edges (disabled)
  dxColor_Btn_Enb_BgFrom_WXP   = $00FFFFFF; // background from
  dxColor_Btn_Enb_BgTo_WXP     = $00E7EBEF; // background to
  dxColor_Btn_Enb_CkFrom_WXP   = $00C6CFD6; // clicked from
  dxColor_Btn_Enb_CkTo_WXP     = $00EBF3F7; // clicked to
  dxColor_Btn_Enb_FcFrom_WXP   = $00FFE7CE; // focused from
  dxColor_Btn_Enb_FcTo_WXP     = $00EF846D; // focused to
  dxColor_Btn_Enb_HlFrom_WXP   = $00CEF3FF; // highlight from
  dxColor_Btn_Enb_HlTo_WXP     = $000096E7; // highlight to

  { checkbox colors - WindowsXP }
  dxColor_Chk_Enb_Border_WXP   = $00845118; // border line
  dxColor_Chk_Enb_NmSymb_WXP   = $0021A621; // symbol normal

  { misc colors - WindowsXP }
  dxColor_Msc_Dis_Caption_WXP  = $0094A6A5; // caption color (disabled)

  dxColor_DotNetFrame          = $00F7FBFF; // $00E7EBEF;
  dxColor_BorderLineOXP        = $00663300;
  dxColor_BgOXP                = $00D6BEB5;
  dxColor_BgCkOXP              = $00CC9999;

type
{ forward declarations }

  TdxCustomStyleControl = class;

{ TdxBoundLines }

  TdxBoundLines = set of (
    blLeft,                             // left line
    blTop,                              // top line
    blRight,                            // right line
    blBottom                            // bottom line
  );

{ TdxControlStyle }

  TdxControlStyle = set of (
    csRedrawCaptionChanged,             // (default)
    csRedrawBorderChanged,              //
    csRedrawEnabledChanged,             // (default)
    csRedrawFocusedChanged,             // (default)
    csRedrawMouseDown,                  // (default)
    csRedrawMouseEnter,                 // (default)
    csRedrawMouseLeave,                 // (default)
    csRedrawMouseMove,                  //
    csRedrawMouseUp,                    // (default)
    csRedrawParentColorChanged,         // (default)
    csRedrawParentFontChanged,          //
    csRedrawPosChanged,                 //
    csRedrawResized                     //
  );

{ TdxDrawState }

  TdxDrawState = set of (
    dsDefault,                          // default
    dsHighlight,                        // highlighted
    dsClicked,                          // clicked
    dsFocused                           // focused
  );

{ TdxGlyphLayout }

  TdxGlyphLayout = (
    glBottom,                           // bottom glyph
    glCenter,                           // centered glyph
    glTop                               // top glyph
  );

{ TdxTheme }

  TdxTheme = (
    WindowsXP,                          // WindowsXP theme
    OfficeXP                            // OfficeXP theme
  );

{ TdxCustomComponent

  baseclass for non-focusable component descendants. }

  TdxCustomComponent = class(TComponent)
  private
    { Private desclarations }
    FVersion: string;
    procedure SetVersion(Value: string);
  protected
    { Protected desclarations }
  public
    { Public desclarations }
    constructor Create(AOwner: TComponent); override;
  published
    { Published desclarations }
    property Version: string read FVersion write SetVersion stored False;
  end;

{ TdxWinControl }

  TdxWinControl = class(TWinControl)
  published
    { Published declarations }
    property Color;
  end;

{ TdxCustomControl

  baseclass for focusable control descendants. }

  TdxCustomControl = class(TCustomControl)
  private
    { Private desclarations }
    FClicking: Boolean;
    FDrawState: TdxDrawState;
    FIsLocked: Boolean;
    FIsSibling: Boolean;
    FModalResult: TModalResult;
    FVersion: string;
    FOnMouseLeave: TNotifyEvent;
    FOnMouseEnter: TNotifyEvent;
    procedure SetVersion(Value: string);
    procedure CMDialogChar(var Message: TCMDialogChar); message CM_DIALOGCHAR;
    procedure CMBorderChanged(var Message: TMessage); message CM_BORDERCHANGED;
    procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
    procedure CMFocusChanged(var Message: TMessage); message CM_FOCUSCHANGED;
    procedure CMMouseEnter(var Message: TMessage); message CM_MOUSEENTER;
    procedure CMMouseLeave(var Message: TMessage); message CM_MOUSELEAVE;
    procedure CMParentColorChanged(var Message: TMessage); message CM_PARENTCOLORCHANGED;
    procedure CMParentFontChanged(var Message: TMessage); message CM_PARENTFONTCHANGED;
    procedure CMTextChanged(var Message: TMessage); message CM_TEXTCHANGED;
    procedure WMMouseMove(var Message: TWMMouse); message WM_MOUSEMOVE;
    procedure WMSize(var Message: TWMSize); message WM_SIZE;
    procedure WMWindowPosChanged(var Message: TWMWindowPosChanged); message WM_WINDOWPOSCHANGED;
  protected
    { Protected desclarations }
    ExControlStyle: TdxControlStyle;
    procedure InternalRedraw; dynamic;
    procedure HookBorderChanged; dynamic;
    procedure HookEnabledChanged; dynamic;
    procedure HookFocusedChanged; dynamic;
    procedure HookMouseDown; dynamic;
    procedure HookMouseEnter; dynamic;
    procedure HookMouseLeave; dynamic;
    procedure HookMouseMove(X: Integer = 0; Y: Integer = 0); dynamic;
    procedure HookMouseUp; dynamic;
    procedure HookParentColorChanged; dynamic;
    procedure HookParentFontChanged; dynamic;
    procedure HookPosChanged; dynamic;
    procedure HookResized; dynamic;
    procedure HookTextChanged; dynamic;
    procedure MouseDown(Button:TMouseButton; Shift: TShiftState; X, Y: Integer); override;
    procedure MouseUp(Button:TMouseButton; Shift:TShiftState; X, Y: Integer); override;
    property ModalResult: TModalResult read FModalResult write FModalResult default 0;
  public
    { Public desclarations }
    constructor Create(AOwner: TComponent); override;
    procedure Click; override;
    procedure BeginUpdate; dynamic;
    procedure EndUpdate; dynamic;
    property Canvas;
    property DrawState: TdxDrawState read FDrawState write FDrawState;
    property IsLocked: Boolean read FIsLocked write FIsLocked;
    property IsSibling: Boolean read FIsSibling write FIsSibling;
  published
    { Published declarations }
    //property BevelInner;
    //property BevelOuter;
    //property BevelWidth;
    //property BiDiMode;
    //property Ctl3D;
    //property DockSite;
    //property ParentBiDiMode;
    //property ParentCtl3D;
    //property TabOrder;
    //property TabStop;
    //property UseDockManager default True;
    property Align;
    property Anchors;
    //property AutoSize;
    property Constraints;
    property DragCursor;
    property DragKind;
    property DragMode;
    //property Enabled;
    property Font;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property Version: string read FVersion write SetVersion stored False;
    property Visible;
    //property OnDockDrop;
    //property OnDockOver;
    //property OnEndDock;
    //property OnGetSiteInfo;
    //property OnStartDock;
    //property OnUnDock;
    property OnCanResize;
    property OnClick;
    property OnConstrainedResize;
  {$IFDEF VER140} // Borland Delphi 6.0
    property OnContextPopup;
  {$ENDIF}
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnEnter;
    property OnExit;
    property OnKeyDown;
    property OnKeyPress;
    property OnKeyUp;
    property OnMouseDown;
    property OnMouseEnter: TNotifyEvent read FOnMouseEnter write FOnMouseEnter;
    property OnMouseLeave: TNotifyEvent read FOnMouseLeave write FOnMouseLeave;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDrag;
  end;

{ TdxUnlimitedControl }

  TdxUnlimitedControl = class(TdxCustomControl);

{ TdxStyle }

  TdxStyle = class(TPersistent)
  private
    { Private declarations }
    FTheme: TdxTheme;
    FUseStyleManager: Boolean;
  protected
    { Protected declarations }
    Parent: TdxCustomStyleControl;
    procedure SetTheme(Value: TdxTheme); virtual;
    procedure SetUseStyleManager(Value: Boolean); virtual;
  public
    { Public declarations }
    constructor Create(AOwner: TComponent);
    function GetTheme: TdxTheme;
  published
    { Published declarations }
    property Theme: TdxTheme read FTheme write SetTheme default WindowsXP;
    property UseStyleManager: Boolean read FUseStyleManager write SetUseStyleManager default True;
  end;

{ TdxStyleManager }

  TdxStyleManager = class(TdxCustomComponent)
  private
    { Private desclarations }
    FControls: TList;
    FTheme: TdxTheme;
    FOnThemeChanged: TNotifyEvent;
    procedure InvalidateControls;
  protected
    { Protected desclarations }
    procedure SetTheme(Value: TdxTheme); virtual;
  public
    { Public desclarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure RegisterControls(const AControls: array of TdxCustomControl);
    procedure UnregisterControls(const AControls: array of TdxCustomControl);
  published
    { Published desclarations }
    property Theme: TdxTheme read FTheme write SetTheme default WindowsXP;
    property OnThemeChanged: TNotifyEvent read FOnThemeChanged write FOnThemeChanged;
  end;

{ TdxCustomStyleControl }

  TdxCustomStyleControl = class(TdxCustomControl)
  private
    { Private desclarations }
    FStyle: TdxStyle;
    FStyleManager: TdxStyleManager;
  public
    { Public desclarations }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  protected
    { Protected desclarations }
    procedure SetStyleManager(Value: TdxStyleManager); virtual;
    procedure Notification(AComponent: TComponent; Operation: TOperation); override;
  published
    { Published desclarations }
    property Style: TdxStyle read FStyle write FStyle;
    property StyleManager: TdxStyleManager read FStyleManager write SetStyleManager;
  end;

{ TdxGradient }

  TdxGradientColors = 2..255;

  TdxGradientStyle = (gsLeft, gsTop, gsRight, gsBottom);

  TdxGradient = class(TPersistent)
  private
    { Private-Deklarationen }
    FColors: TdxGradientColors;
    FDithered: Boolean;
    FEnabled: Boolean;
    FEndColor: TColor;
    FStartColor: TColor;
    FGradientStyle: TdxGradientStyle;
  protected
    { Protected declarations }
    Parent: TdxCustomControl;
    procedure SetDithered(Value: Boolean); virtual;
    procedure SetColors(Value: TdxGradientColors); virtual;
    procedure SetEnabled(Value: Boolean); virtual;
    procedure SetEndColor(Value: TColor); virtual;
    procedure SetGradientStyle(Value: TdxGradientStyle); virtual;
    procedure SetStartColor(Value: TColor); virtual;
  public
    { Public declarations }
    Bitmap: TBitmap;
    constructor Create(AOwner: TControl);
    destructor Destroy; override;
    procedure RecreateBands; virtual;
  published
    { Published-Deklarationen }
    property Dithered: Boolean read FDithered write SetDithered default True;
    property Colors: TdxGradientColors read FColors write SetColors default 16;
    property Enabled: Boolean read FEnabled write SetEnabled default False;
    property EndColor: TColor read FEndColor write SetEndColor default clSilver;
    property StartColor: TColor read FStartColor write SetStartColor default clGray;
    property Style: TdxGradientStyle read FGradientStyle write SetGradientStyle default gsLeft;
  end;

{$R dxCore.res}

procedure Register;

implementation

uses
  dxCoreUtils;

resourcestring
  SVersion = '2.0.1'; // always increase version number on new releases!

{-----------------------------------------------------------------------------
  Procedure: Register
  Author:    mh
  Date:      24-Jun-2002
  Arguments: None
  Result:    None
-----------------------------------------------------------------------------}
procedure Register;
begin
  RegisterComponents('Design eXperience II', [TdxStyleManager]);
end;

{ TdxCustomComponent }

{-----------------------------------------------------------------------------
  Procedure: TdxCustomComponent.Create
  Author:    mh
  Date:      24-Jun-2002
  Arguments: AOwner: TComponent
  Result:    None
-----------------------------------------------------------------------------}

constructor TdxCustomComponent.Create(AOwner: TComponent);
begin
  inherited;
  FVersion := 'Design eXperience. 

⌨️ 快捷键说明

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