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

📄 dcoutpanel.pas

📁 XP风格的outbar.rar.有DELPHI,C++BULIDER的例子及源码
💻 PAS
📖 第 1 页 / 共 5 页
字号:
{**************************************************}
{                                                  }
{  Dream OutBar                                    }
{  Copyright (c) 1997-2001 Dream Company           }
{  http://www.dream-com.com                        }
{  e-mail: contact@dream-com.com                   }
{                                                  }
{**************************************************}
unit dcOutPanel;

interface

{$I outbar.Inc}
Uses Classes, Controls, Forms, Messages, Windows, Graphics, SysUtils
     {$IFDEF D4},ImgList{$ENDIF}, ExtCtrls, Menus, dcOutConst{$IFNDEF D3},d2Canvas{$ENDIF},
     dcOutCommon, CommCtrl;

Const
{
  SPalDreamOutCtrl='Dream OutPanel';
}  
  WM_MOUSEDOWN=WM_USER+1;
  WM_APPLOSTFOCUS=WM_MOUSEDOWN+1;

Type
  TBackgroundPanelMode=bkmNone..bkmGradientVert;
  TBorderSide=(bdLeft,bdTop,bdRight,bdBottom);
  TBorderSides=Set Of TBorderSide;
  TPositiveInteger=1..MaxInt;

  TDCCustomHeaderPanel=Class;

  { TDCHotButton }

  TButtonType=(btStandard,btPin,btCustom);

  TDCCustomHotButton=Class(TGraphicControl)
  Private
    FButtonDownGlyph:TBitmap;
    FButtonType:TButtonType;
    FButtonUpGlyph:TBitmap;
    FCloseButton:TBitmap;
    FDowned:Boolean;
    FMouseDown:Boolean;
    FInternalButtonClick:TNotifyEvent;
    FOnButtonClick:TNotifyEvent;
    FPinDown:TBitmap;
    FPinUp:TBitmap;
    FSelected:Boolean;
    Procedure OnGlyphsChange(Sender:TObject);
    Procedure SetButtonDownGlyph(Value:TBitmap);
    Procedure SetButtonType(Value:TButtonType);
    Procedure SetButtonUpGlyph(Value:TBitmap);
    Procedure UpdateButton;
  Protected
    Procedure CMMouseLeave(Var Message:TMessage);message CM_MOUSELEAVE;
    Procedure DoButtonClick;virtual;
    Procedure MouseDown(Button:TMouseButton;Shift:TShiftState;X,Y:Integer);override;
    Procedure MouseMove(Shift:TShiftState;X,Y:Integer);override;
    Procedure MouseUp(Button:TMouseButton;Shift:TShiftState;X,Y:Integer);override;
    Procedure Paint;override;

    Property ButtonDownGlyph:TBitmap read FButtonDownGlyph write SetButtonDownGlyph;
    Property ButtonType:TButtonType read FButtonType write SetButtonType;
    Property ButtonUpGlyph:TBitmap read FButtonUpGlyph write SetButtonUpGlyph;
    Property OnButtonClick:TNotifyEvent read FOnButtonClick write FOnButtonClick;
  Public
    Constructor Create(AOwner:TComponent);override;
    Destructor Destroy;override;

    Procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer);override;
  End;

  TDCHotButton=Class(TDCCustomHotButton)
  Published
    Property ButtonDownGlyph;
    Property ButtonType;
    Property ButtonUpGlyph;
    Property OnButtonClick;
    Property Color;
  End;

  TImageAlignment=(iaLeft,iaRight);
  TArrowAlignment=(aaCenter,aaBottom);
  TSelectType=(stAll,stShrink);
  TTrackMouseEvent=Procedure(Sender:TObject;Var IsClose:Boolean) Of Object;

  TDCCustomHeaderButton=Class(TGraphicControl)
  Private
    FArrowAlignment:TArrowAlignment;
    FArrowDown:Boolean;
    FArrowFontSize:Integer;
    FArrowRect:TRect;
    FArrowSize:TSize;
    FBitmap:TBitmap;
    FButtonInCaption:Boolean;
    FChangeLink:TChangeLink;
    FDropDownMenu:TPopupMenu;
    FImageAlignment:TImageAlignment;
    FImageList:TImageList;
    FImageIndex:Integer;
    FIsDown:Boolean;
    FIsMenuShowing:Boolean;
    FOnButtonClick:TNotifyEvent;
    FOnTrackMouse:TTrackMouseEvent;
    FSelectBorderColor:TColor;
    FSelected:Boolean;
    FSelectType:TSelectType;
    FSeparateArrow:Boolean;
    FTotalRect:TRect;
    FTrackMouse:Boolean;

    fOnChanged : TNotifyEvent;

    Procedure PaintButton;
    Procedure DrawButtonImage(const ARect:TRect;IsFill:Boolean);
    Function GetCalcWidth:Integer;
    Function GetButtonImageSize:TSize;
    Function IsOnArrowButton(X,Y:Integer):Boolean;
    Procedure OnFontChange(Sender:TObject);
    Procedure OnImagesChange(Sender:TObject);
    Procedure PaintSelection;
    Procedure SetArrowButtonDown(Value:Boolean);
    Procedure SetArrowFontSize(Value:Integer);
    Procedure SetArrowAlignment(Value:TArrowAlignment);
    Procedure SetBitmap(const Value:TBitmap);
    Procedure SetButtonDown(Value:Boolean);
    Procedure SetButtonInCaption(Value:Boolean);
    Procedure SetDropDownMenu(Value:TPopupMenu);
    Procedure SetImageAlignment(Value:TImageAlignment);
    Procedure SetImageIndex(const Value:Integer);
    Procedure SetImageList(const Value:TImageList);
    Procedure SetSeparateArrow(Value:Boolean);
    Procedure SetTrackMouse(Value:Boolean);
    Procedure UpdateButton;
    Procedure UpdateSelection;
    procedure DoChanged;
  Protected
    Procedure Notification(Component:TComponent;Operation:TOperation);override;

    Procedure Click;override;
    Procedure CMMouseLeave(Var Message:TMessage);message CM_MOUSELEAVE;
    Procedure CMTextChanged(Var Message:TMessage);message CM_TEXTCHANGED;
    procedure DblClick;override;
    Procedure DoButtonClick;
    Procedure Loaded;override;
    Procedure MouseDown(Button:TMouseButton;Shift:TShiftState;X,Y:Integer);override;
    Procedure MouseMove(Shift:TShiftState;X,Y:Integer);override;
    Procedure MouseUp(Button :TMouseButton;Shift:TShiftState;X,Y:Integer);override;
    Procedure WMEraseBkgnd(Var Message:TMessage);message WM_ERASEBKGND;
    Procedure WMAppLostFocus(Var Message:TMessage);message WM_APPLOSTFOCUS;//app lost focus
    Procedure WMMouseDown(Var Message:TMessage);message WM_MOUSEDOWN;//query on mouse click
    Procedure Paint;override;

    Property ArrowAlignment:TArrowAlignment read FArrowAlignment write SetArrowAlignment;
    Property ArrowButtonDown:Boolean read FArrowDown write SetArrowButtonDown;
    Property ArrowFontSize:Integer read FArrowFontSize write SetArrowFontSize;
    Property Bitmap:TBitmap read FBitmap write SetBitmap;
    Property ButtonDown:Boolean read FIsDown write SetButtonDown;
    Property ButtonInCaption:Boolean read FButtonInCaption
                                     write SetButtonInCaption;
    Property DropDownMenu:TPopupMenu read FDropDownMenu write SetDropDownMenu;
    Property ImageAlignment:TImageAlignment read FImageAlignment
                                            write SetImageAlignment;
    Property ImageIndex:Integer read FImageIndex write SetImageIndex;
    Property ImageList:TImageList read FImageList write SetImageList;
    Property OnButtonClick:TNotifyEvent read FOnButtonClick write FOnButtonClick;
    Property OnTrackMouse:TTrackMouseEvent read FOnTrackMouse write FOnTrackMouse;
    Property SeparateArrow:Boolean read FSeparateArrow write SetSeparateArrow;
    Property TrackMouse:Boolean read FTrackMouse write SetTrackMouse;

    property OnChanged : TNotifyEvent read fOnChanged write fOnChanged;
  Public
    Constructor Create(AOwner:TComponent);override;
    Destructor Destroy;override;

    Procedure SetBounds(ALeft, ATop, AWidth, AHeight: Integer);override;
  End;

  TDCHeaderButton=Class(TDCCustomHeaderButton)
  Published
    Property ArrowAlignment;
    Property ArrowButtonDown;
    Property ArrowFontSize;
    Property Bitmap;
    Property ButtonDown;
    Property ButtonInCaption;
    Property ImageAlignment;
    Property ImageIndex;
    Property ImageList;
    Property OnButtonClick;
    Property OnTrackMouse;
    Property SeparateArrow;
    Property TrackMouse;

    property Align;
    Property Caption;
    property Color;
    property DragCursor;
    property DragMode;
    property Enabled;
    property Font;
    property ParentColor;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property Visible;
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDrag;

    {$IFDEF D4}
    property Anchors;
    property BiDiMode;
    property Constraints;
    property DragKind;
    property OnCanResize;
    property OnConstrainedResize;
    property OnEndDock;
    property OnStartDock;
    property ParentBiDiMode;
    property OnResize;
    {$ENDIF}
  End;

  TDropHeaderPanelEvent=Procedure(Sender:TObject;Var HeaderPanelPosition:TPoint) Of Object;

  { TDCCustomOutHeader }

  TDCCustomOutHeader=Class(TCustomControl)
  Private
    FBackgroundMode:TBackgroundPanelMode;
    FBorderColor:TColor;
    FBorderSides:TBorderSides;
    FBorderSideSize:Integer;
    FGradientBeginColor:TColor;
    FGradientEndColor:TColor;
    FHeaderPanel:TDCCustomHeaderPanel;
    FHeaderPanelAlign:TAlign;
    FHeaderPanelBevelInner:{$IFNDEF D4}TPanelBevel{$ELSE}TBevelCut{$ENDIF};
    FHeaderPanelBevelOuter:{$IFNDEF D4}TPanelBevel{$ELSE}TBevelCut{$ENDIF};
    FHeaderPanelBorderWidth:Integer;
    FHeaderPanelButtonType:TButtonType;
    FHeaderPanelBounds:TRect;
    FHeaderPanelParent:TWinControl;
    FImageAlignment:TImageAlignment;
    FImageButton:TDCHeaderButton;
    FLeftButton:TDCHeaderButton;
    FLeftButtonClick:TNotifyEvent;
    FOnDropHeaderPanel:TDropHeaderPanelEvent;
    FParentRightFont:Boolean;
    FRightButton:TDCHeaderButton;
    FStreamedHeaderPanel:TDCCustomHeaderPanel;
    FTrackMouse:TTrackMouseEvent;
    fDisableAlign : boolean;
    FVersion:TDCVersion;

    Procedure DrawHeader;
    Function GetBitmap:TBitmap;
    Function GetButtonDown:Boolean;
    Function GetButtonInCaption:Boolean;
    Function GetImageIndex:Integer;
    Function GetImageList:TImageList;
    Function GetRightCaption:TCaption;
    Function GetRightCaptionFont:TFont;
    Function GetTrackMouse:Boolean;
    Procedure HeaderPanelButtonClick(Sender:TObject);
    Procedure SetBackgroundMode(Value:TBackgroundPanelMode);
    Procedure SetBitmap(Value:TBitmap);
    Procedure SetBorderColor(Value:TColor);
    Procedure SetBorderSides(const Value:TBorderSides);
    Procedure SetBorderSideSize(Value:Integer);
    Procedure SetButtonDown(Value:Boolean);
    Procedure SetButtonInCaption(Value:Boolean);
    Procedure SetGradientBeginColor(Value:TColor);
    Procedure SetGradientEndColor(Value:TColor);
    Procedure SetHeaderPanel(Value:TDCCustomHeaderPanel);
    Procedure SetImageAlignment(Value:TImageAlignment);
    Procedure SetImageIndex(Value:Integer);
    Procedure SetImageList(Value:TImageList);
    Procedure SetParentRightFont(Value:Boolean);
    Procedure SetRightCaption(const Value:TCaption);
    Procedure SetRightCaptionFont(Value:TFont);
    Procedure SetTrackMouse(Value:Boolean);
    Procedure ShrinkRect(Var Rect:TRect);
    Procedure UpdateHeaderPanel;
    Procedure UpdateStateByHeaderPanel(ButtonInCaption:Boolean);
    Procedure UpdateStateHeaderPanel;
    procedure RePositionButtons;
    procedure ButtonChanged(Sender : TObject);
  Protected
    Procedure AlignControls(AControl: TControl; var Rect: TRect);override;
    Procedure CMColorChanged(Var Message:TMessage);message CM_COLORCHANGED;
    Procedure CMParentFontChanged(Var Message:TMessage);message CM_PARENTFONTCHANGED;
    Procedure CMTextChanged(Var Message:TMessage);message CM_TEXTCHANGED;
    Procedure DoLeftButtonClick(Sender:TObject);virtual;
    Procedure DoTrackMouse(Sender:TObject;Var IsClose:Boolean);virtual;
    Procedure DrawBackground;virtual;
    Procedure Notification(Component:TComponent;Operation:TOperation);override;
    Procedure KeyDown(Var Key:Word;Shift:TShiftState);override;
    Procedure Loaded;override;
    Procedure MouseDown(Button : TMouseButton ; Shift : TShiftState ; X , Y : Integer);override;
    Procedure WMEraseBkgnd(Var Message:TMessage);message WM_ERASEBKGND;
    Procedure WMPaint(Var Message:TMessage);message WM_PAINT;
    Procedure WMSize(Var Message:TMessage);message WM_SIZE;

    Property BackgroundMode:TBackgroundPanelMode read FBackgroundMode write SetBackgroundMode default bkmNone;
    Property Bitmap:TBitmap read GetBitmap write SetBitmap;
    Property BorderColor:TColor read FBorderColor write SetBorderColor default clBtnFace;
    Property BorderSides:TBorderSides read FBorderSides write SetBorderSides default [bdLeft, bdTop, bdRight, bdBottom];
    Property BorderSideSize:Integer read FBorderSideSize write SetBorderSideSize default 0;
    Property ButtonDown:Boolean read GetButtonDown write SetButtonDown default False;
    Property ButtonInCaption:Boolean read GetButtonInCaption write SetButtonInCaption default False;
    Property GradientBeginColor:TColor read FGradientBeginColor write SetGradientBeginColor default clBlue;
    Property GradientEndColor:TColor read FGradientEndColor write SetGradientEndColor default clBlack;
    Property HeaderPanel:TDCCustomHeaderPanel read FHeaderPanel write SetHeaderPanel;
    Property ImageAlignment:TImageAlignment read FImageAlignment write SetImageAlignment default iaRight;
    Property ImageIndex:Integer read GetImageIndex write SetImageIndex;
    Property ImageList:TImageList read GetImageList write SetImageList;
    Property OnButtonClick:TNotifyEvent read FLeftButtonClick write FLeftButtonClick;
    Property OnDropHeaderPanel:TDropHeaderPanelEvent read FOnDropHeaderPanel write FOnDropHeaderPanel;
    Property OnTrackMouse:TTrackMouseEvent read FTrackMouse write FTrackMouse;
    Property ParentRightFont:Boolean read FParentRightFont write SetParentRightFont default False;
    Property RightCaption:TCaption read GetRightCaption write SetRightCaption;
    Property RightCaptionFont:TFont read GetRightCaptionFont write SetRightCaptionFont;
    Property TrackMouse:Boolean read GetTrackMouse write SetTrackMouse default False;
  Public
    Constructor Create(AOwner:TComponent);override;
    Destructor Destroy;override;
  Published
    Property Version:TDCVersion read FVersion write FVersion stored False;
  End;

  { TDCOutHeader }

  TDCOutHeader=Class(TDCCustomOutHeader)
  Published
    Property BackgroundMode;
    Property Bitmap;
    Property BorderColor;
    Property BorderSides;
    Property BorderSideSize;
    Property ButtonDown;
    Property ButtonInCaption;
    Property GradientBeginColor;
    Property GradientEndColor;
    Property HeaderPanel;
    Property ImageAlignment;
    Property ImageIndex;
    Property ImageList;
    Property OnButtonClick;
    Property OnDropHeaderPanel;
    Property OnTrackMouse;
    Property ParentRightFont;
    Property RightCaption;
    Property RightCaptionFont;
    Property TrackMouse;

    property Align;
    Property Caption;
    property Color;
    property DragCursor;
    property DragMode;
    property Enabled;
    property Font;
    property ParentColor;
    property ParentFont;
    property ParentShowHint;
    property PopupMenu;
    property ShowHint;
    property TabOrder;
    property TabStop;
    property Visible;
    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    Property OnEnter;
    Property OnExit;
    property OnMouseDown;
    property OnMouseMove;
    property OnMouseUp;
    property OnStartDrag;

    {$IFDEF D4}
    property Anchors;
    property BiDiMode;
    property Constraints;
    property DragKind;
    property OnCanResize;
    property OnConstrainedResize;
    property OnEndDock;
    property OnStartDock;
    property ParentBiDiMode;
    property OnResize;
    {$ENDIF}
  End;

  { TDCCustomHeaderPanel }

  TDCCustomHeaderPanel=Class(TCustomPanel)
  Private
    FCanvas:TCanvas;
    FCaption:TCaption;
    FHeaderHeight:Integer;
    FHeaderVisible:Boolean;
    FInternalHeaderHeight:Integer;
    FLeftButton:TDCHeaderButton;

⌨️ 快捷键说明

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