unit PButon;
interface uses SysUtils, Classes, Controls, ExtCtrls,Buttons, Types, Graphics; type TPButon = class(TPanel)
private FSmallBitmap:TBitmap; FBigOnclick:TNotifyEvent; FBigLabel:String;
FSmallOnclick:TNotifyEvent;
FTag:Integer;
procedure SetSmallBitmap (Value:TBitMap);
procedure settag (Value:Integer);
Procedure SetOnClick (Value: TNotifyEvent);
Procedure SmallSetOnClick (Value: TNotifyEvent);
procedure SetBigLabel (Value:String);
Function GetSmallBitmap:TBitMap;
procedure Resize; override;
protected public Big,Small:TSpeedbutton; constructor Create(AOWner: TComponent); override;
Destructor Destroy; override;
published property BigOnClick:TNotifyEvent read FBigOnclick write SetOnClick;
property SmallOnClick:TNotifyEvent read FSmallOnclick write SmallSetOnClick;
property SmallPicture:TBitmap read GetsmallBitmap write SetSmallBitmap;
property BigCaption:String read FBigLabel write setBigLabel;
property PanelTag:Integer read FTag write settag;
end;
procedure Register;
implementation procedure Register;
begin RegisterComponents('Samples', [TPButon]);
end;
procedure TPbuton.settag(Value:Integer);
begin FTag:=Value; end;
procedure TPButon.SetBigLabel (Value:String);
begin FBigLabel:=value; repaint; end;
procedure TPButon.SetSmallBitmap (Value:TBitMap);
begin FSmallBitmap:=Value; small.Glyph:=FSmallBitmap; end;
function TPButon.GetSmallBitmap:Tbitmap;
begin Result:=small.Glyph; end;
Procedure TPButon.SetOnClick (Value: TNotifyEvent);
begin FBigOnClick:=Value; Big.OnClick:=FBigOnClick; end;
Procedure TPButon.SmallSetOnClick (Value: TNotifyEvent);
begin FSmallOnClick:=Value; Small.OnClick:=FSmallOnClick; end;
constructor TPButon.Create(AOWner: TComponent);
var posicion : TPoint; begin inherited Create(AOWner);
FTag:=0;
caption:='';
width := 75;
height:= 16;
bevelouter := bvNone;
posicion.X := Left;
posicion.Y := Top;
Big := TSpeedButton.create(Self);
Big.Parent := Self;
big.ClientToParent(posicion);
big.Flat := True;
Big.Width := width;
Big.Height := Height;
Small := TSpeedButton.Create(Self);
Small.Parent := Self;
small.ClientToParent(posicion);
small.Flat := True;
small.Width := big.Height div 2;
small.Height := big.Height;
small.Top := big.Top;
small.Left := left + width - small.Width;
BigCaption:=FBigLabel;
small.NumGlyphs:=1;
big.NumGlyphs:=1;
caption:='';
resize;
end;
procedure TPButon.Resize;
begin inherited;
caption:='';
big.Height := height;
big.Width := width;
small.Width := big.Height div 2 + 2;
small.Height := big.Height;
small.Top:=big.Top;
small.Left := big.Left + big.Width - small.Width;
end;
destructor TPButon.Destroy;
begin big.Free; small.Free; inherited;
end;
end.