const
defLeftSpace = 35; { default left space }
defTopSpace = 18; { default top space }
{$IFDEF PAIDVERS}
SDLVersionInfo = 'onoffbut_r1210_full';
IsLightEd = false;
{$ELSE}
SDLVersionInfo = 'onoffbut_r1210_lighted';
IsLightEd = true;
{$ENDIF}
Release = 1210;
type
TOnOffButStyle = (oobsUser, oobsCheckbox, oobsRadioBut, oobsSlideTB,
oobsSlideLR, oobsColSlideTB, oobsColSlideLR, oobsLedRedGreen,
oobsArrowTopRgt, oobsArrowUpDown, oobsArrowLeftRight,
oobsTrafficLPed, oobsBeveledLed, oobsSmileyYellow,
oobsSmileyRedGrn, oobsBulb, oobsButLamp, oobsHDLeft,
oobsHDRight, oobsUser1, oobsUser2, oobsUser3,
oobsUser4, oobsUser5);
TOOButMouseAction = (oomaNone, oomaFocused, oomaPlain);
TOOButMode = (oobmNormalBut, oobmSpeedBut);
{$IFDEF GE_LEV29}
[ComponentPlatformsAttribute(pidWin32 or pidWin64 or pidWin64x)]
{$ENDIF}
TOnOffBut = class (TGraphicControl)
private
FOnOff : boolean; { state of button }
{ state images [on/off, enabled] }
FButImg : array[boolean, boolean] of TBitMap;
{ user defined state images [on/off, enabled] }
FUserImg : array[boolean, boolean] of TBitMap;
FMask : TBitMap;
FAutoCenter : boolean; { TRUE: button glyph is centered }
FButStyle : TOnOffButStyle; { visual appearance }
FGroupIndex : integer; { group index }
FMouseAction : TOObutMouseAction; { type of mouse action }
FAllowAllOff : boolean;{ TRUE: all grouped buttons may be off }
FColorBakG : TColor; { color of button background }
FColorTxt : TColor; { color of left/right text }
FGlyphWidth : integer; { width of glyph }
FGlyphHeight : integer; { height of glyph }
FLeftSpace : integer; { space for text left to the button }
FTopSpace : integer; { space for text above the button }
FLeftText : string; { text at left of button }
FTopText : string; { text above the button }
FBottomText : string; { text below the button }
FRightText : string; { text at right of button }
FMode : TOOButMode; { normal button / speed button }
FFrameStyle : TFrameStyle; { style of frame }
FTransParent : boolean; { TRUE: transparent background }
FLTAlignment : TAlignment; { alignment of left text }
FTTAlignment : TAlignment; { alignment of top text }
FBTAlignment : TAlignment; { alignment of bottom text }
FRTAlignment : TAlignment; { alignment of right label }
FEnabled : boolean; { TRUE: component is enabled }
FColBlackLine : TColor; { colors to draw the frame }
FColGrayLine : TColor; { -"- }
FColWhiteLine : TColor; { -"- }
FColorScheme : TColorScheme; { color scheme of frames }
procedure SetFrameStyle (value: TFrameStyle);
procedure SetLeftSpace (Value: integer);
procedure SetTopSpace (Value: integer);
procedure SetLTAlignment (value: TAlignment);
procedure SetTTAlignment (value: TAlignment);
procedure SetBTAlignment (value: TAlignment);
procedure SetRTAlignment (value: TAlignment);
procedure SetLeftText (value: string);
procedure SetTopText (value: string);
procedure SetBottomText (value: string);
procedure SetRightText (value: string);
procedure SetTransparent (value: boolean);
procedure SetOnOff (value: boolean);
procedure SetAllowAllOff (value: boolean);
procedure SetButMode (value: TOOButMode);
procedure SetEnabled (value: boolean);
procedure SetAutoCenter (value: boolean);
procedure SetMouseAction (value: TOOButMouseAction);
procedure SetColorScheme (Value: TColorScheme);
procedure SetButStyle (value: TOnOffButStyle);
procedure SetColorText (value: TColor);
procedure SetColorBakG (value: TColor);
procedure SetGroupIndex(Value: Integer);
{$IFDEF DOTNET}
procedure ButtonPressed(Group: Integer; Button: TOnOffBut);
{$ELSE}
procedure CMButtonPressed(var Message: TMessage);
message CM_BUTTONPRESSED;
{$ENDIF}
procedure UpdateExclusive;
procedure AdjustAutoCenter;
procedure ProcessResize(Sender: TObject);
protected
procedure ExtractGlyphs (Img: TBitMap);
procedure AssignTo (Dest: TPersistent); override;
procedure Loaded; override;
procedure LoadGlyphs;
procedure Click; override;
procedure Paint; override;
procedure MouseUp (Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure MouseDown (Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
public
procedure Assign(Source: TPersistent); override;
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure SetUserGlyph (Img: TBitMap);
procedure LoadUserGlyph (FName: string);
published
property AllowAllOff: boolean
read FAllowAllOff write SetAllowAllOff;
property AutoCenter: boolean
read FAutoCenter write SetAutoCenter;
property Anchors;
property BottomText: string
read FBottomText write SetBottomtext;
property BottomTextAlignment: TAlignment
read FBTAlignment write SetBTAlignment;
property ButtonStyle: TOnOffButStyle
read FButStyle write SetButStyle;
property ColorBackgnd: TColor read FColorBakG write SetColorBakG;
property ColorScheme: TColorScheme
read FColorScheme write SetColorScheme;
property ColorText: TColor read FColorTxt write SetColorText;
property Enabled read FEnabled write SetEnabled;
property Font;
property FrameStyle: TFrameStyle
read FFrameStyle write SetFrameStyle;
property GroupIndex: Integer
read FGroupIndex write SetGroupIndex default 0;
property LeftSpace: integer read FLeftSpace write SetLeftSpace;
property LeftText: string read FLeftText write SetLefttext;
property LeftTextAlignment: TAlignment
read FLTAlignment write SetLTAlignment;
property Mode: TOOButMode read FMode write SetButMode;
property MouseAction: TOObutMouseAction
read FMouseAction write SetMouseAction;
property OnOff: boolean read FOnOff write SetOnOff;
property ParentShowHint;
property PopupMenu;
property RightText: string read FRightText write SetRightText;
property RightTextAlignment: TAlignment
read FRTAlignment write SetRTAlignment;
property ShowHint;
{$IFDEF GE_LEV17}
(**) property StyleElements;
{$ENDIF}
property TopSpace: integer read FTopSpace write SetTopSpace;
property TopText: string read FTopText write SetToptext;
property TopTextAlignment: TAlignment
read FTTAlignment write SetTTAlignment;
property Transparent: boolean
read FTransparent write SetTransparent;
property Visible;
property OnClick;
property OnDblClick;
property OnMouseMove;
property OnMouseDown;
property OnMouseUp;
property OnResize;
end;
|