Class TExplorerButton (unit ExplBtn)

Inherits from

TCustomControl

Constructors


constructor Create(aOwner: TComponent);

* TExplorerButton implementation


Functions

procedure Click;


destructor Destroy;


procedure Regenerate;


procedure WMExplorerPopupOpen(var msg: TMessage);


procedure BitmapChange(Sender: TObject);


procedure CMDialogChar(var Message: TCMDialogChar);


procedure CMMouseEnter(var msg: TMessage);

If the popup is not defined, activate the click event

procedure CMMouseLeave(var msg: TMessage);


procedure CMSysColorChange(var msg: TMessage);

Needed to avoir recursive opens (could quickly lead to stack space exhaustion)

procedure ComputeExtent(TempCaption: PChar; var TempRect: TRect; theCanvas: TCanvas);


procedure CreateGrayscaleBitmap(outputbmp, bmp: TBitmap);

* These thresholds are used for the grayscaling and were experimentaly * determined

procedure CreateParams(var Params: TCreateParams);


procedure DefineProperties(Filer: TFiler);


procedure DisabledBitmapChange(Sender: TObject);


procedure DrawDisabledBitmap(Canvas: TCanvas; x, y: Integer; bmp: TBitmap);

Work with a copy of the bitmap as it is modified by addmasked

procedure DrawDisabledText(theCanvas: TCanvas; TempRect: TRect; TempCaption: PChar);

* Drawing of a disabled text (Win95 style)

procedure DrawOutline(theCanvas: TCanvas; pushed: Boolean);


procedure DrawPopupMark(theCanvas: TCanvas; x, y: Integer);


procedure DrawTheText(theCanvas: TCanvas; TempRect: TRect; TempCaption: PChar);


procedure DrawTransparentBitmap(theCanvas: TCanvas; bmp: TBitmap; xStart, yStart: Integer);


procedure GetLost;


procedure Loaded;

* After the loading of the properties, the grayscale version can be * safely created

procedure NoFocusBitmapChange(Sender: TObject);


procedure Notification(AComponent: TComponent; Operation: TOperation);

if not FBitmap.

function Obscured: boolean;

Space between the bitmap and the caption

procedure Paint;

Transparency with TWinControl-derived controls is a real headache.

procedure ReadIBitmap(Stream: TStream);


procedure SetAlignment(value: TAlignment);

Disabled state

procedure SetAllowAllUp(value: Boolean);


procedure SetBevelStyle(value: TBevelStyle);


procedure SetBitmap(value: TBitmap);


procedure SetButtonSize(value: TExplorerButtonButtonSize);


procedure SetCaption(value: TCaption);


procedure SetCustomHeight(value: Integer);


procedure SetCustomWidth(value: Integer);


procedure SetDisabledBitmap(value: TBitmap);


procedure SetDown(value: Boolean);


procedure SetDropDown(value: TPopupMenu);


procedure SetDropDownStyle(value: TExplorerButtonDropDownStyle);


procedure SetEnabled(value: Boolean);


procedure SetExplorerPopup(value: TExplorerPopup);


procedure SetGroupIndex(value: Integer);


procedure SetLargeHeight(value: Integer);


procedure SetLargeWidth(value: Integer);


procedure SetLayout(value: TExplorerButtonLayout);


procedure SetNoFocusBitmap(value: TBitmap);


procedure SetOptions(value: TExplorerButtonOptions);


procedure SetShadingType(value: TExplorerButtonShadingType);


procedure SetSmallHeight(value: Integer);


procedure SetSmallWidth(value: Integer);


procedure SetUnselectedFontColor(value: TColor);


procedure WMEraseBkgnd(var msg: TWMEraseBkgnd);


procedure WMLButtonDblClk(var msg: TWMLButtonDblClk);


procedure WMLButtonDown(var msg: TWMLButtonDown);


procedure WMLButtonUp(var msg: TWMLButtonUp);


procedure WMMove(var msg: TWMMove);


procedure WMRButtonUp(var msg: TWMRButtonUp);


procedure WMSize(var msg: TWMSize);


procedure WriteIBitmap(Stream: TStream);


Properties

property Alignment : TAlignment

new properties

property AllowAllUp : Boolean


property BevelStyle : TBevelStyle


property Bitmap : TBitmap


property ButtonSize : TExplorerButtonButtonSize


property Caption : TCaption


property CustomHeight : Integer


property CustomWidth : Integer


property DisabledBitmap : TBitmap


property Down : Boolean


property DropDownMenu : TPopupMenu


property DropDownStyle : TExplorerButtonDropDownStyle


property Enabled : Boolean


property ExplorerPopup : TExplorerPopup


property Font :

republished properties

property GroupIndex : Integer


property HelpContext :


property LargeHeight : Integer


property LargeWidth : Integer


property Layout : TExplorerButtonLayout


property NoFocusBitmap : TBitmap


property Options : TExplorerButtonOptions


property ParentFont :


property ParentShowHint :


property PopupMenu :


property ShadingType : TExplorerButtonShadingType


property ShowHint :


property SmallHeight : Integer


property SmallWidth : Integer


property UnselectedFontColor : TColor


property Visible :


Events

event OnClick :


event OnDblClick :


event OnDragDrop :


event OnDragOver :


event OnDropDownClick : TNotifyEvent


event OnEnter : TNotifyEvent


event OnExit : TNotifyEvent


event OnMouseDown :


event OnMouseMove :


event OnMouseUp :


Variables

backBitmap : TBitmap;


backBitmapCreated : Boolean;


fakeResize : Boolean;


FAlignment : TAlignment;


FAllowAllUp : Boolean;


FBevelStyle : TBevelStyle;


FBitmap : TBitmap;


FButtonSize : TExplorerButtonButtonSize;


FCaption : TCaption;


FCustomHeight : Integer;


FCustomWidth : Integer;


FDisabledBitmap : TBitmap;


FDown : Boolean;


FDropDown : TPopupMenu;


FDropDownStyle : TExplorerButtonDropDownStyle;


FEnabled : Boolean;


FExplorerPopup : TExplorerPopup;


FGroupIndex : Integer;


FLargeHeight : Integer;


FLargeWidth : Integer;


FLayout : TExplorerButtonLayout;


FNoFocusBitmap : TBitmap;


FOnDropDownClick : TNotifyEvent;


FOnEnter : TNotifyEvent;


FOnExit : TNotifyEvent;


FOptions : TExplorerButtonOptions;


FShadingType : TExplorerButtonShadingType;


FSmallHeight : Integer;


FSmallWidth : Integer;


FUnselectedFontColor : TColor;


IBitmap : TBitmap;


initialized : Boolean;


MouseIn : Boolean;


painted : Boolean;


popupOpened : Boolean;


popupPushed : Boolean;

state flags

Pushed : Boolean;


regenerating : Boolean;


updatingSize : Boolean;


wasObscured : Boolean;



Constructors


constructor Create(aOwner: TComponent);

* TExplorerButton implementation


Functions


procedure Click;


destructor Destroy;


procedure Regenerate;


procedure WMExplorerPopupOpen(var msg: TMessage);


procedure BitmapChange(Sender: TObject);


procedure CMDialogChar(var Message: TCMDialogChar);


procedure CMMouseEnter(var msg: TMessage);

If the popup is not defined, activate the click event


procedure CMMouseLeave(var msg: TMessage);


procedure CMSysColorChange(var msg: TMessage);

Needed to avoir recursive opens (could quickly lead to stack space exhaustion)


procedure ComputeExtent(TempCaption: PChar; var TempRect: TRect; theCanvas: TCanvas);


procedure CreateGrayscaleBitmap(outputbmp, bmp: TBitmap);

* These thresholds are used for the grayscaling and were experimentaly * determined


procedure CreateParams(var Params: TCreateParams);


procedure DefineProperties(Filer: TFiler);


procedure DisabledBitmapChange(Sender: TObject);


procedure DrawDisabledBitmap(Canvas: TCanvas; x, y: Integer; bmp: TBitmap);

Work with a copy of the bitmap as it is modified by addmasked


procedure DrawDisabledText(theCanvas: TCanvas; TempRect: TRect; TempCaption: PChar);

* Drawing of a disabled text (Win95 style)


procedure DrawOutline(theCanvas: TCanvas; pushed: Boolean);


procedure DrawPopupMark(theCanvas: TCanvas; x, y: Integer);


procedure DrawTheText(theCanvas: TCanvas; TempRect: TRect; TempCaption: PChar);


procedure DrawTransparentBitmap(theCanvas: TCanvas; bmp: TBitmap; xStart, yStart: Integer);


procedure GetLost;


procedure Loaded;

* After the loading of the properties, the grayscale version can be * safely created


procedure NoFocusBitmapChange(Sender: TObject);


procedure Notification(AComponent: TComponent; Operation: TOperation);

if not FBitmap.Empty and FNoFocusBitmap.Empty and not (csLoading in ComponentState) then CreateGrayscaleBitmap(IBitmap, FBitmap);


function Obscured: boolean;

Space between the bitmap and the caption


procedure Paint;

Transparency with TWinControl-derived controls is a real headache. * This is the *only* way the transparency is correctly regenerated.... * And I can ensure you I spent tens of hours on this particular point :)


procedure ReadIBitmap(Stream: TStream);


procedure SetAlignment(value: TAlignment);

Disabled state


procedure SetAllowAllUp(value: Boolean);


procedure SetBevelStyle(value: TBevelStyle);


procedure SetBitmap(value: TBitmap);


procedure SetButtonSize(value: TExplorerButtonButtonSize);


procedure SetCaption(value: TCaption);


procedure SetCustomHeight(value: Integer);


procedure SetCustomWidth(value: Integer);


procedure SetDisabledBitmap(value: TBitmap);


procedure SetDown(value: Boolean);


procedure SetDropDown(value: TPopupMenu);


procedure SetDropDownStyle(value: TExplorerButtonDropDownStyle);


procedure SetEnabled(value: Boolean);


procedure SetExplorerPopup(value: TExplorerPopup);


procedure SetGroupIndex(value: Integer);


procedure SetLargeHeight(value: Integer);


procedure SetLargeWidth(value: Integer);


procedure SetLayout(value: TExplorerButtonLayout);


procedure SetNoFocusBitmap(value: TBitmap);


procedure SetOptions(value: TExplorerButtonOptions);


procedure SetShadingType(value: TExplorerButtonShadingType);


procedure SetSmallHeight(value: Integer);


procedure SetSmallWidth(value: Integer);


procedure SetUnselectedFontColor(value: TColor);


procedure WMEraseBkgnd(var msg: TWMEraseBkgnd);


procedure WMLButtonDblClk(var msg: TWMLButtonDblClk);


procedure WMLButtonDown(var msg: TWMLButtonDown);


procedure WMLButtonUp(var msg: TWMLButtonUp);


procedure WMMove(var msg: TWMMove);


procedure WMRButtonUp(var msg: TWMRButtonUp);


procedure WMSize(var msg: TWMSize);


procedure WriteIBitmap(Stream: TStream);


Properties


property Alignment : TAlignment

new properties


property AllowAllUp : Boolean


property BevelStyle : TBevelStyle


property Bitmap : TBitmap


property ButtonSize : TExplorerButtonButtonSize


property Caption : TCaption


property CustomHeight : Integer


property CustomWidth : Integer


property DisabledBitmap : TBitmap


property Down : Boolean


property DropDownMenu : TPopupMenu


property DropDownStyle : TExplorerButtonDropDownStyle


property Enabled : Boolean


property ExplorerPopup : TExplorerPopup


property Font :

republished properties


property GroupIndex : Integer


property HelpContext :


property LargeHeight : Integer


property LargeWidth : Integer


property Layout : TExplorerButtonLayout


property NoFocusBitmap : TBitmap


property Options : TExplorerButtonOptions


property ParentFont :


property ParentShowHint :


property PopupMenu :


property ShadingType : TExplorerButtonShadingType


property ShowHint :


property SmallHeight : Integer


property SmallWidth : Integer


property UnselectedFontColor : TColor


property Visible :


Events


event OnClick :


event OnDblClick :


event OnDragDrop :


event OnDragOver :


event OnDropDownClick : TNotifyEvent


event OnEnter : TNotifyEvent


event OnExit : TNotifyEvent


event OnMouseDown :


event OnMouseMove :


event OnMouseUp :


Variables


backBitmap : TBitmap;


backBitmapCreated : Boolean;


fakeResize : Boolean;


FAlignment : TAlignment;


FAllowAllUp : Boolean;


FBevelStyle : TBevelStyle;


FBitmap : TBitmap;


FButtonSize : TExplorerButtonButtonSize;


FCaption : TCaption;


FCustomHeight : Integer;


FCustomWidth : Integer;


FDisabledBitmap : TBitmap;


FDown : Boolean;


FDropDown : TPopupMenu;


FDropDownStyle : TExplorerButtonDropDownStyle;


FEnabled : Boolean;


FExplorerPopup : TExplorerPopup;


FGroupIndex : Integer;


FLargeHeight : Integer;


FLargeWidth : Integer;


FLayout : TExplorerButtonLayout;


FNoFocusBitmap : TBitmap;


FOnDropDownClick : TNotifyEvent;


FOnEnter : TNotifyEvent;


FOnExit : TNotifyEvent;


FOptions : TExplorerButtonOptions;


FShadingType : TExplorerButtonShadingType;


FSmallHeight : Integer;


FSmallWidth : Integer;


FUnselectedFontColor : TColor;


IBitmap : TBitmap;


initialized : Boolean;


MouseIn : Boolean;


painted : Boolean;


popupOpened : Boolean;


popupPushed : Boolean;

state flags


Pushed : Boolean;


regenerating : Boolean;


updatingSize : Boolean;


wasObscured : Boolean;