home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 26 / CD_ASCQ_26_1295.iso / vrac / ctrlkit.zip / GRAPHBTN.INT < prev    next >
Text File  |  1995-09-16  |  2KB  |  61 lines

  1. unit GraphBtn;
  2.  
  3. interface
  4.  
  5. uses
  6.   SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  7.   Forms, Dialogs, StdCtrls, Buttons, ExtCtrls;
  8.  
  9. const
  10.   IDX_BTNFACE    = 0;
  11.   IDX_BTNSHADOW  = 1;
  12.   IDX_BTNHILIGHT = 2;
  13.  
  14. type
  15.   TBtnDrawEvent = procedure (Sender: TObject;
  16.                              IsDown, IsDefault, IsFocused, IsNewStyle : Boolean;
  17.                              Canvas : TCanvas;
  18.                              Rect : TRect) of object;
  19.  
  20.   TBtnColors = Array[IDX_BTNFACE..IDX_BTNHILIGHT] of TColor;
  21.  
  22.   TGraphicButton = class(TButton)
  23.   private
  24.     FCanvas     : TCanvas;
  25.     FStyle      : TButtonStyle;
  26.     FColors     : TBtnColors;
  27.     IsFocused   : Boolean;
  28.     FOnDrawFace : TBtnDrawEvent;
  29.  
  30.     procedure CNMeasureItem(var Message: TWMMeasureItem); message CN_MEASUREITEM;
  31.     procedure CNDrawItem(var Message: TWMDrawItem); message CN_DRAWITEM;
  32.     procedure CMFontChanged(var Message: TMessage); message CM_FONTCHANGED;
  33.     procedure CMEnabledChanged(var Message: TMessage); message CM_ENABLEDCHANGED;
  34.     procedure SetStyle(AStyle : TButtonStyle);
  35.     procedure SetColor(Index : Integer; AColor : TColor);
  36.     function  GetColor(Index : Integer): TColor;
  37.  
  38.   protected
  39.     procedure CreateParams(var Params: TCreateParams); override;
  40.     procedure SetButtonStyle(ADefault: Boolean); override;
  41.     procedure DrawItem(const DrawItemStruct: TDrawItemStruct); virtual;
  42.     procedure DrawBtnFace(IsDown, IsDefault, IsFocused, IsNewStyle : Boolean;
  43.                           const ARect : TRect); virtual;
  44.  
  45.     property Canvas       : TCanvas read FCanvas; {do not publish}
  46.     property ColorFace    : TColor index IDX_BTNFACE read GetColor write SetColor default clBtnFace;
  47.     property ColorShadow  : TColor index IDX_BTNSHADOW read GetColor write SetColor default clBtnShadow;
  48.     property ColorHiLight : TColor index IDX_BTNHILIGHT read GetColor write SetColor default clBtnHighlight;
  49.  
  50.   public
  51.     constructor Create(AOwner: TComponent); override;
  52.     destructor Destroy; override;
  53.  
  54.   published
  55.     property Style : TButtonStyle read FStyle write SetStyle default bsAutoDetect;
  56.     property OnDrawFace: TBtnDrawEvent read FOnDrawFace write FOnDrawFace;
  57.   end;
  58.  
  59.  
  60. implementation
  61. end.