You've already forked lazarus-ccr
TGradButton: DropDownMenu Support
git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@1453 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
@ -16,11 +16,14 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils, Controls, graphics, LCLType,LResources,
|
Classes, SysUtils, Controls, graphics, LCLType,LResources,
|
||||||
LCLIntf ,Buttons, urotatebitmap, types;
|
LCLIntf ,Buttons, urotatebitmap, types, Menus;
|
||||||
|
|
||||||
type
|
type
|
||||||
TGradButton = class;
|
TGradButton = class;
|
||||||
|
|
||||||
|
|
||||||
|
TDropDownMarkDirection = (mdUp, mdLeft, mdDown, mdRight);
|
||||||
|
TDropDownMarkPosition = (mpLeft, mpRight);
|
||||||
TTextAlignment = (taLeftJustify, taRightJustify, taCenter);
|
TTextAlignment = (taLeftJustify, taRightJustify, taCenter);
|
||||||
TBorderSide = (bsTopLine, bsBottomLine, bsLeftLine, bsRightLine);
|
TBorderSide = (bsTopLine, bsBottomLine, bsLeftLine, bsRightLine);
|
||||||
TBorderSides = set of TBorderSide;
|
TBorderSides = set of TBorderSide;
|
||||||
@ -29,10 +32,53 @@ type
|
|||||||
TGBBackgroundPaintEvent = procedure(Sender: TGradButton;
|
TGBBackgroundPaintEvent = procedure(Sender: TGradButton;
|
||||||
TargetCanvas: TCanvas; R: TRect; BState : TButtonState) of object;
|
TargetCanvas: TCanvas; R: TRect; BState : TButtonState) of object;
|
||||||
|
|
||||||
|
|
||||||
|
{ TDropDownSettings }
|
||||||
|
|
||||||
|
TDropDownSettings = class(TPersistent)
|
||||||
|
private
|
||||||
|
FColor: TColor;
|
||||||
|
FMarkDirection: TDropDownMarkDirection;
|
||||||
|
FMarkPosition: TDropDownMarkPosition;
|
||||||
|
FOnlyOnMark: boolean;
|
||||||
|
FPopupMenu: TPopupMenu;
|
||||||
|
FPressedColor: TColor;
|
||||||
|
FShow: Boolean;
|
||||||
|
FSize: integer;
|
||||||
|
FNotify: TNotifyEvent;
|
||||||
|
procedure SetColor(const AValue: TColor);
|
||||||
|
procedure SetMarkDirection(const AValue: TDropDownMarkDirection);
|
||||||
|
procedure SetMarkPosition(const AValue: TDropDownMarkPosition);
|
||||||
|
procedure SetOnlyOnMark(const AValue: boolean);
|
||||||
|
procedure SetPopupMenu(const AValue: TPopupMenu);
|
||||||
|
procedure SetPressedColor(const AValue: TColor);
|
||||||
|
procedure SetShow(const AValue: Boolean);
|
||||||
|
procedure SetSize(const AValue: integer);
|
||||||
|
|
||||||
|
procedure Notify;
|
||||||
|
public
|
||||||
|
constructor Create(ANotify: TNotifyEvent);
|
||||||
|
procedure AssignTo(Dest: TPersistent); override;
|
||||||
|
function IsPopupStored: boolean;
|
||||||
|
published
|
||||||
|
property Color : TColor read FColor write SetColor default clSilver;
|
||||||
|
property MarkDirection : TDropDownMarkDirection read FMarkDirection
|
||||||
|
write SetMarkDirection default mdDown;
|
||||||
|
property MarkPosition : TDropDownMarkPosition read FMarkPosition
|
||||||
|
write SetMarkPosition default mpRight;
|
||||||
|
property OnlyOnMark: boolean read FOnlyOnMark write SetOnlyOnMark;
|
||||||
|
property PopupMenu : TPopupMenu read FPopupMenu write SetPopupMenu;
|
||||||
|
property PressedColor: TColor read FPressedColor write SetPressedColor default clBlack;
|
||||||
|
property Show : Boolean read FShow write SetShow;
|
||||||
|
property Size: integer read FSize write SetSize default 8;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TGradButton }
|
{ TGradButton }
|
||||||
|
|
||||||
TGradButton = class(TCustomControl)
|
TGradButton = class(TCustomControl)
|
||||||
private
|
private
|
||||||
|
FDropDownSettings: TDropDownSettings;
|
||||||
|
FPaintToActive: Boolean;
|
||||||
FAutoHeight: Boolean;
|
FAutoHeight: Boolean;
|
||||||
FAutoHeightBorderSpacing: Integer;
|
FAutoHeightBorderSpacing: Integer;
|
||||||
FAutoWidthBorderSpacing: Integer;
|
FAutoWidthBorderSpacing: Integer;
|
||||||
@ -40,8 +86,9 @@ type
|
|||||||
FRotateDirection : TRotateDirection;
|
FRotateDirection : TRotateDirection;
|
||||||
FTextAlignment : TTextAlignment;
|
FTextAlignment : TTextAlignment;
|
||||||
FButtonLayout: TButtonLayout;
|
FButtonLayout: TButtonLayout;
|
||||||
FTextPoint, FGlyphPoint : TPoint;
|
FDropdownMarkRect: TRect;
|
||||||
FTextSize, FGlyphSize : TSize;
|
FTextPoint, FGlyphPoint: TPoint;
|
||||||
|
FTextSize, FGlyphSize, FDropdownSize, FAutoSize : TSize;
|
||||||
FBackground, bm,
|
FBackground, bm,
|
||||||
FNormalBackgroundCache, FHotBackgroundCache,
|
FNormalBackgroundCache, FHotBackgroundCache,
|
||||||
FDownBackgroundCache, FDisabledBackgroundCache : TBitmap;
|
FDownBackgroundCache, FDisabledBackgroundCache : TBitmap;
|
||||||
@ -54,11 +101,15 @@ type
|
|||||||
FBorderSides: TBorderSides;
|
FBorderSides: TBorderSides;
|
||||||
FOnNormalBackgroundPaint, FOnHotBackgroundPaint,
|
FOnNormalBackgroundPaint, FOnHotBackgroundPaint,
|
||||||
FOnDownBackgroundPaint, FOnDisabledBackgroundPaint : TGBBackgroundPaintEvent;
|
FOnDownBackgroundPaint, FOnDisabledBackgroundPaint : TGBBackgroundPaintEvent;
|
||||||
|
procedure DrawDropDownArrow;
|
||||||
procedure PaintGradient(TrgCanvas: TCanvas; pr : TRect);
|
procedure PaintGradient(TrgCanvas: TCanvas; pr : TRect);
|
||||||
|
procedure SetDropDownSettings(const AValue: TDropDownSettings);
|
||||||
procedure UpdateBackground;
|
procedure UpdateBackground;
|
||||||
procedure PaintBackground(AState: TButtonState; TrgBitmap: TBitmap);
|
procedure PaintBackground(AState: TButtonState; TrgBitmap: TBitmap);
|
||||||
|
procedure ShowDropdownPopupMenu;
|
||||||
|
procedure DropDownSettingsChanged(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
FState, FOldState: TButtonState;
|
FState, FOldState, FDropDownState: TButtonState;
|
||||||
FNormalBlend,FOverBlend : Extended;
|
FNormalBlend,FOverBlend : Extended;
|
||||||
FBaseColor, FNormalBlendColor, FOverBlendColor, FDisabledColor,
|
FBaseColor, FNormalBlendColor, FOverBlendColor, FDisabledColor,
|
||||||
FBackgroundColor, FGlyphBackgroundColor, FClickColor: TColor;
|
FBackgroundColor, FGlyphBackgroundColor, FClickColor: TColor;
|
||||||
@ -69,7 +120,6 @@ type
|
|||||||
procedure InvPaint(StateCheck:Boolean=false);
|
procedure InvPaint(StateCheck:Boolean=false);
|
||||||
procedure FontChanged(Sender: TObject); override;
|
procedure FontChanged(Sender: TObject); override;
|
||||||
procedure GlyphChanged(Sender: TObject); virtual;
|
procedure GlyphChanged(Sender: TObject); virtual;
|
||||||
procedure GetBackgroundRect(var TheRect : TRect); virtual;
|
|
||||||
procedure GetContentRect(var TheRect: TRect); virtual;
|
procedure GetContentRect(var TheRect: TRect); virtual;
|
||||||
function GetGlyph : TBitmap;
|
function GetGlyph : TBitmap;
|
||||||
procedure SetEnabled(Value: Boolean); override;
|
procedure SetEnabled(Value: Boolean); override;
|
||||||
@ -98,8 +148,12 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(AOwner: TComponent); override;
|
constructor Create(AOwner: TComponent); override;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
//procedure CreateParams(var Params: TCreateParams); override;
|
|
||||||
|
procedure ChangeBounds(ALeft, ATop, AWidth, AHeight: integer;
|
||||||
|
KeepBase: boolean); override;
|
||||||
|
|
||||||
procedure Paint; override;
|
procedure Paint; override;
|
||||||
|
procedure PaintTo(ACanvas: TCanvas; X, Y: Integer); overload;
|
||||||
procedure MouseEnter; override;
|
procedure MouseEnter; override;
|
||||||
procedure MouseLeave; override;
|
procedure MouseLeave; override;
|
||||||
procedure MouseDown(Button: TMouseButton;
|
procedure MouseDown(Button: TMouseButton;
|
||||||
@ -113,12 +167,12 @@ type
|
|||||||
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
||||||
function GetBackground : TCanvas;
|
function GetBackground : TCanvas;
|
||||||
procedure Click; override;
|
procedure Click; override;
|
||||||
procedure Resize; override;
|
|
||||||
function Focused: Boolean; override;
|
function Focused: Boolean; override;
|
||||||
procedure UpdateButton;
|
procedure UpdateButton;
|
||||||
procedure UpdatePositions;
|
procedure UpdatePositions;
|
||||||
function GetAutoWidth : Integer;
|
function GetAutoWidth : Integer;
|
||||||
function GetAutoHeight : Integer;
|
function GetAutoHeight : Integer;
|
||||||
|
class function GetControlClassDefaultSize: TSize; override;
|
||||||
published
|
published
|
||||||
property Action;
|
property Action;
|
||||||
property Anchors;
|
property Anchors;
|
||||||
@ -126,6 +180,8 @@ type
|
|||||||
property BorderSpacing;
|
property BorderSpacing;
|
||||||
property Caption;
|
property Caption;
|
||||||
property Enabled;
|
property Enabled;
|
||||||
|
property DropDownSettings: TDropDownSettings read FDropDownSettings
|
||||||
|
write SetDropDownSettings;
|
||||||
property PopupMenu;
|
property PopupMenu;
|
||||||
property Font;
|
property Font;
|
||||||
property Visible;
|
property Visible;
|
||||||
@ -178,7 +234,8 @@ type
|
|||||||
function ColorBetween(C1, C2 : TColor; blend:Extended):TColor;
|
function ColorBetween(C1, C2 : TColor; blend:Extended):TColor;
|
||||||
function ColorsBetween(colors:array of TColor; blend:Extended):TColor;
|
function ColorsBetween(colors:array of TColor; blend:Extended):TColor;
|
||||||
function AlignItem(ItemLength, AreaLength,Spacing: Integer; ATextAlignment: TTextAlignment):Integer;
|
function AlignItem(ItemLength, AreaLength,Spacing: Integer; ATextAlignment: TTextAlignment):Integer;
|
||||||
|
function IfThen(ATest, ValA: Boolean; ValB: Boolean = false): Boolean; overload;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -186,6 +243,60 @@ implementation
|
|||||||
uses
|
uses
|
||||||
LCLProc, math;
|
LCLProc, math;
|
||||||
|
|
||||||
|
procedure PaintArrow(ACanvas: TCanvas; ARect: TRect; ADirection: TDropDownMarkDirection; AColor: TColor);
|
||||||
|
var
|
||||||
|
Points : Array of TPoint;
|
||||||
|
ASize: TSize;
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
SetLength(Points, 3);
|
||||||
|
|
||||||
|
ASize := Size(ARect);
|
||||||
|
|
||||||
|
case ADirection of
|
||||||
|
mdUp:
|
||||||
|
begin
|
||||||
|
Points[0] := Point(0, ASize.cy);
|
||||||
|
Points[1] := Point(ASize.cx, ASize.cy);
|
||||||
|
Points[2] := Point(ASize.cx div 2, 0);
|
||||||
|
end;
|
||||||
|
mdDown:
|
||||||
|
begin
|
||||||
|
Points[0] := Point(0, 0);
|
||||||
|
Points[1] := Point(ASize.cx, 0);
|
||||||
|
Points[2] := Point(ASize.cx div 2, ASize.cy);
|
||||||
|
end;
|
||||||
|
mdLeft:
|
||||||
|
begin
|
||||||
|
Points[0] := Point(ASize.cx, 0);
|
||||||
|
Points[1] := Point(ASize.cx, ASize.cy);
|
||||||
|
Points[2] := Point(0, ASize.cy div 2);
|
||||||
|
end;
|
||||||
|
mdRight:
|
||||||
|
begin
|
||||||
|
Points[0] := Point(0, 0);
|
||||||
|
Points[1] := Point(0, ASize.cy);
|
||||||
|
Points[2] := Point(ASize.cx, ASize.cy div 2);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
for i := 0 to 2 do
|
||||||
|
with Points[i] do
|
||||||
|
begin
|
||||||
|
Inc(X, ARect.Left);
|
||||||
|
Inc(Y, ARect.Top);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
ACanvas.Brush.Style:=bsSolid;
|
||||||
|
ACanvas.Brush.Color:=AColor;
|
||||||
|
ACanvas.Pen.Color:=AColor;
|
||||||
|
|
||||||
|
ACanvas.Polygon(Points);
|
||||||
|
|
||||||
|
SetLength(Points, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
function AlignItem(ItemLength, AreaLength,Spacing: Integer; ATextAlignment: TTextAlignment):Integer;
|
function AlignItem(ItemLength, AreaLength,Spacing: Integer; ATextAlignment: TTextAlignment):Integer;
|
||||||
begin
|
begin
|
||||||
case ATextAlignment of
|
case ATextAlignment of
|
||||||
@ -249,40 +360,24 @@ begin
|
|||||||
UpdateButton;
|
UpdateButton;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.Resize;
|
|
||||||
begin
|
|
||||||
inherited;
|
|
||||||
|
|
||||||
if (HasParent) then
|
|
||||||
begin
|
|
||||||
if FAutoWidth then
|
|
||||||
UpdateButton
|
|
||||||
else begin
|
|
||||||
UpdatePositions;
|
|
||||||
UpdateBackground;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TGradButton.UpdatePositions;
|
procedure TGradButton.UpdatePositions;
|
||||||
var
|
var
|
||||||
tempTS,tempGS : TSize;
|
tempTS,tempGS,Area : TSize;
|
||||||
p,t,midx, midy, textmidx, textmidy,
|
p,t,midx, midy, textmidx, textmidy,
|
||||||
groupwidth, groupheight, AreaWidth, AreaHeight :Integer;
|
groupwidth, groupheight, Offset1, Offset2 :Integer;
|
||||||
tempBL : TButtonLayout;
|
tempBL : TButtonLayout;
|
||||||
begin
|
begin
|
||||||
GetContentRect(FBackgroundRect);
|
GetContentRect(FBackgroundRect);
|
||||||
|
|
||||||
AreaWidth := FBackgroundRect.Right-FBackgroundRect.Left;
|
Area := Size(FBackgroundRect);
|
||||||
AreaHeight := FBackgroundRect.Bottom-FBackgroundRect.Top;
|
|
||||||
|
|
||||||
tempGS.cx:=0;
|
tempGS.cx:=0;
|
||||||
tempGS.cy:=0;
|
tempGS.cy:=0;
|
||||||
|
|
||||||
if FShowGlyph and not FRotatedGlyph.Empty then
|
if FShowGlyph and not FRotatedGlyph.Empty then
|
||||||
begin
|
begin
|
||||||
tempGS.cx:=FRotatedGlyph.Width;
|
tempGS.cx:=FRotatedGlyph.Width;
|
||||||
tempGS.cy:=FRotatedGlyph.Height;
|
tempGS.cy:=FRotatedGlyph.Height;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
tempTS := bm.Canvas.TextExtent(Caption);
|
tempTS := bm.Canvas.TextExtent(Caption);
|
||||||
@ -300,34 +395,34 @@ begin
|
|||||||
if FShowGlyph and not FRotatedGlyph.Empty then begin
|
if FShowGlyph and not FRotatedGlyph.Empty then begin
|
||||||
case tempBL of
|
case tempBL of
|
||||||
blGlyphLeft: begin
|
blGlyphLeft: begin
|
||||||
FGlyphPoint.x := AlignItem(tempGS.cx+FTextGlyphSpacing+tempTS.cx,AreaWidth,4,FTextAlignment);
|
FGlyphPoint.x := AlignItem(tempGS.cx+FTextGlyphSpacing+tempTS.cx,Area.cx,4,FTextAlignment);
|
||||||
FGlyphPoint.y := AlignItem(tempGS.cy,AreaHeight,0, taCenter);
|
FGlyphPoint.y := AlignItem(tempGS.cy,Area.cy,0, taCenter);
|
||||||
|
|
||||||
FTextPoint.x := FGlyphPoint.x+tempGS.cx+FTextGlyphSpacing;
|
FTextPoint.x := FGlyphPoint.x+tempGS.cx+FTextGlyphSpacing+FDropDownSettings.Size;
|
||||||
FTextPoint.y := AlignItem(tempTS.cy,AreaHeight,0, taCenter);
|
FTextPoint.y := AlignItem(tempTS.cy,Area.cy,0, taCenter);
|
||||||
end;
|
end;
|
||||||
blGlyphRight: begin
|
blGlyphRight: begin
|
||||||
//Glyph Right, Text Left
|
//Glyph Right, Text Left
|
||||||
FTextPoint.x := AlignItem(tempTS.cx+FTextGlyphSpacing+tempGS.cx,AreaWidth,4, FTextAlignment);
|
FTextPoint.x := AlignItem(tempTS.cx+FTextGlyphSpacing+tempGS.cx,Area.cx,4, FTextAlignment);
|
||||||
FTextPoint.y := AlignItem(tempTS.cy,AreaHeight,0, taCenter);
|
FTextPoint.y := AlignItem(tempTS.cy,Area.cy,0, taCenter);
|
||||||
|
|
||||||
FGlyphPoint.x := FTextPoint.x+tempTS.cx+FTextGlyphSpacing;
|
FGlyphPoint.x := FTextPoint.x+tempTS.cx+FTextGlyphSpacing+FDropDownSettings.Size;
|
||||||
FGlyphPoint.y := AlignItem(tempGS.cy,AreaHeight,0, taCenter);
|
FGlyphPoint.y := AlignItem(tempGS.cy,Area.cy,0, taCenter);
|
||||||
end;
|
end;
|
||||||
blGlyphTop: begin
|
blGlyphTop: begin
|
||||||
//Glyph Top, Text Bottom
|
//Glyph Top, Text Bottom
|
||||||
FGlyphPoint.x := AlignItem(tempGS.cx,AreaWidth, 0, FTextAlignment);
|
FGlyphPoint.x := AlignItem(tempGS.cx + FDropDownSettings.Size, Area.cx, 0, FTextAlignment);
|
||||||
FTextPoint.x := AlignItem(tempTS.cx, AreaWidth, 0, FTextAlignment);
|
FTextPoint.x := AlignItem(tempTS.cx + FDropDownSettings.Size, Area.cx, 0, FTextAlignment);
|
||||||
|
|
||||||
FGlyphPoint.y := AlignItem(tempGS.cy+FTextGlyphSpacing+tempTS.cy, AreaHeight, 4, taCenter);
|
FGlyphPoint.y := AlignItem(tempGS.cy+FTextGlyphSpacing+tempTS.cy, Area.cy, 4, taCenter);
|
||||||
FTextPoint.y := FGlyphPoint.y+tempGS.cy+FTextGlyphSpacing;
|
FTextPoint.y := FGlyphPoint.y+tempGS.cy+FTextGlyphSpacing;
|
||||||
end;
|
end;
|
||||||
blGlyphBottom: begin
|
blGlyphBottom: begin
|
||||||
//Glyph Bottom, Text Top
|
//Glyph Bottom, Text Top
|
||||||
FGlyphPoint.x := AlignItem(tempGS.cx,AreaWidth, 0, FTextAlignment);
|
FGlyphPoint.x := AlignItem(tempGS.cx+FDropDownSettings.Size, Area.cx, 0, FTextAlignment);
|
||||||
FTextPoint.x := AlignItem(tempTS.cx, AreaWidth, 0, FTextAlignment);
|
FTextPoint.x := AlignItem(tempTS.cx+FDropDownSettings.Size, Area.cx, 0, FTextAlignment);
|
||||||
|
|
||||||
FTextPoint.y := AlignItem(tempGS.cy+FTextGlyphSpacing+tempTS.cy, AreaHeight, 4, taCenter);
|
FTextPoint.y := AlignItem(tempGS.cy+FTextGlyphSpacing+tempTS.cy, Area.cy, 4, taCenter);
|
||||||
FGlyphPoint.y := FTextPoint.y+tempTS.cy+FTextGlyphSpacing;
|
FGlyphPoint.y := FTextPoint.y+tempTS.cy+FTextGlyphSpacing;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
@ -335,56 +430,52 @@ begin
|
|||||||
FGlyphPoint.x := 0;
|
FGlyphPoint.x := 0;
|
||||||
FGlyphPoint.y := 0;
|
FGlyphPoint.y := 0;
|
||||||
|
|
||||||
FTextPoint.x := AlignItem(tempTS.cx,AreaWidth,4, FTextAlignment);
|
FTextPoint.x := AlignItem(tempTS.cx+FDropDownSettings.Size,Area.cx,4, FTextAlignment);
|
||||||
FTextPoint.y := AlignItem(tempTS.cy,AreaHeight,0, taCenter);
|
FTextPoint.y := AlignItem(tempTS.cy,Area.cy,0, taCenter);
|
||||||
end;
|
end;
|
||||||
//WritePoints([TP^, GP^]);
|
|
||||||
|
Offset1 := IfThen(FDropDownSettings.MarkPosition=mpLeft, FDropDownSettings.Size);
|
||||||
|
|
||||||
{TP^.x := TP^.x + p;
|
FTextPoint.x := Offset1 + FTextPoint.x+FBackgroundRect.Left;
|
||||||
TP^.y := TP^.y + p;
|
|
||||||
|
|
||||||
GP^.x := GP^.x + p;
|
|
||||||
GP^.y := GP^.y + p; }
|
|
||||||
|
|
||||||
FTextPoint.x := FTextPoint.x+FBackgroundRect.Left;
|
|
||||||
FTextPoint.y := FTextPoint.y+FBackgroundRect.Top;
|
FTextPoint.y := FTextPoint.y+FBackgroundRect.Top;
|
||||||
|
|
||||||
FGlyphPoint.x := FGlyphPoint.x+FBackgroundRect.Left;
|
FGlyphPoint.x := Offset1 + FGlyphPoint.x+FBackgroundRect.Left;
|
||||||
FGlyphPoint.y := FGlyphPoint.y+FBackgroundRect.Top;
|
FGlyphPoint.y := FGlyphPoint.y+FBackgroundRect.Top;
|
||||||
|
|
||||||
|
Offset1 := IfThen(FDropDownSettings.MarkPosition<>mpLeft, FTextSize.cx, -FDropDownSettings.Size - 2);
|
||||||
{$IFDEF DEBUGGRADBUTTON}
|
Offset2 := IfThen(FDropDownSettings.MarkPosition<>mpLeft, FGlyphSize.cx, -FDropDownSettings.Size - 2);
|
||||||
WriteLn('Text');
|
|
||||||
WritePoint(FTextPoint);
|
FDropdownMarkRect.Left := Max(FTextPoint.X+Offset1, FGlyphPoint.X+Offset2);
|
||||||
WriteLn('Glyph');
|
FDropdownMarkRect.Top := AlignItem(FDropDownSettings.Size, Area.cy, 0, taCenter) + FBackgroundRect.Top;
|
||||||
WritePoint(FGlyphPoint);
|
FDropdownMarkRect.Right := FDropdownMarkRect.Left + FDropDownSettings.Size;
|
||||||
{$ENDIF}
|
FDropdownMarkRect.Bottom := FDropdownMarkRect.Top + FDropDownSettings.Size;
|
||||||
|
|
||||||
|
FAutoSize.cx := Max(FGlyphPoint.x + FGlyphSize.cx, FTextPoint.x + FTextSize.cx);
|
||||||
|
FAutoSize.cy := Max(FGlyphPoint.y + FGlyphSize.cy, FTextPoint.x + FTextSize.cx);
|
||||||
|
|
||||||
|
if FDropDownSettings.Show and FDropDownSettings.IsPopupStored then
|
||||||
|
begin
|
||||||
|
FAutoSize.cx := Max(FAutoSize.cx, FDropdownMarkRect.Right);
|
||||||
|
FAutoSize.cy := Max(FAutoSize.cy, FDropdownMarkRect.Bottom);
|
||||||
|
end;
|
||||||
|
|
||||||
FGlyphSize:=tempGS;
|
FGlyphSize:=tempGS;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGradButton.GetAutoWidth: Integer;
|
function TGradButton.GetAutoWidth: Integer;
|
||||||
begin
|
begin
|
||||||
if FShowGlyph then begin
|
Result := FAutoSize.cx + FAutoWidthBorderSpacing;
|
||||||
if FButtonLayout in [blGlyphLeft,blGlyphRight] then
|
|
||||||
Result := FTextSize.cx+ FRotatedGlyph.Width+FTextGlyphSpacing+FAutoWidthBorderSpacing
|
|
||||||
else
|
|
||||||
Result := Max(FTextSize.cx,FRotatedGlyph.Width)+FAutoWidthBorderSpacing;
|
|
||||||
end else begin
|
|
||||||
Result := FTextSize.cx+FAutoWidthBorderSpacing;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TGradButton.GetAutoHeight: Integer;
|
function TGradButton.GetAutoHeight: Integer;
|
||||||
begin
|
begin
|
||||||
if FShowGlyph then begin
|
Result := FAutoSize.cy + FAutoHeightBorderSpacing;
|
||||||
if FButtonLayout in [blGlyphTop,blGlyphBottom] then
|
end;
|
||||||
Result := FTextSize.cy+ FRotatedGlyph.Height+FTextGlyphSpacing+FAutoHeightBorderSpacing
|
|
||||||
else
|
class function TGradButton.GetControlClassDefaultSize: TSize;
|
||||||
Result := Max(FTextSize.cy,FRotatedGlyph.Height)+FAutoHeightBorderSpacing;
|
begin
|
||||||
end else begin
|
Result.CX := 80;
|
||||||
Result := FTextSize.cy+FAutoHeightBorderSpacing;
|
Result.CY := 25;
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.PaintBackground(AState: TButtonState; TrgBitmap: TBitmap);
|
procedure TGradButton.PaintBackground(AState: TButtonState; TrgBitmap: TBitmap);
|
||||||
@ -394,7 +485,7 @@ var
|
|||||||
begin
|
begin
|
||||||
FTempState:=FState;
|
FTempState:=FState;
|
||||||
|
|
||||||
GetBackgroundRect(FBackgroundRect);
|
GetContentRect(FBackgroundRect);
|
||||||
|
|
||||||
with TrgBitmap do
|
with TrgBitmap do
|
||||||
begin
|
begin
|
||||||
@ -418,7 +509,7 @@ begin
|
|||||||
|
|
||||||
if FOwnerBackgroundDraw AND (FOnBorderBackgroundPaint<>nil) then
|
if FOwnerBackgroundDraw AND (FOnBorderBackgroundPaint<>nil) then
|
||||||
begin
|
begin
|
||||||
FOnBorderBackgroundPaint(Self, Canvas, FBackgroundRect, AState);
|
//FOnBorderBackgroundPaint(Self, Canvas, FBackgroundRect, AState);
|
||||||
end else begin
|
end else begin
|
||||||
//Top
|
//Top
|
||||||
if (bsTopLine in BorderSides) then
|
if (bsTopLine in BorderSides) then
|
||||||
@ -499,6 +590,23 @@ begin
|
|||||||
FState:=FTempState;
|
FState:=FTempState;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGradButton.ShowDropdownPopupMenu;
|
||||||
|
var
|
||||||
|
lowerLeft: TPoint;
|
||||||
|
begin
|
||||||
|
if FDropDownSettings.Show and FDropDownSettings.IsPopupStored then Exit;
|
||||||
|
lowerLeft := Point(0, Height);
|
||||||
|
lowerLeft := ControlToScreen(lowerLeft);
|
||||||
|
FDropDownSettings.PopupMenu.Popup(lowerLeft.X, lowerLeft.Y);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TGradButton.DropDownSettingsChanged(Sender: TObject);
|
||||||
|
begin
|
||||||
|
UpdateButton;
|
||||||
|
|
||||||
|
InvPaint();
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGradButton.UpdateBackground;
|
procedure TGradButton.UpdateBackground;
|
||||||
var
|
var
|
||||||
FTempState : TButtonState;
|
FTempState : TButtonState;
|
||||||
@ -518,37 +626,6 @@ begin
|
|||||||
InvPaint;
|
InvPaint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.GetBackgroundRect(var TheRect: TRect);
|
|
||||||
begin
|
|
||||||
TheRect := Rect(0,0,Width,Height);
|
|
||||||
|
|
||||||
//Top
|
|
||||||
if (bsTopLine in BorderSides) then
|
|
||||||
begin
|
|
||||||
TheRect.Top := 2;
|
|
||||||
end else
|
|
||||||
TheRect.Top := 0;
|
|
||||||
|
|
||||||
//Left
|
|
||||||
if (bsLeftLine in BorderSides) then
|
|
||||||
begin
|
|
||||||
TheRect.Left := 2;
|
|
||||||
end else
|
|
||||||
TheRect.Left := 0;
|
|
||||||
|
|
||||||
//Right
|
|
||||||
if (bsRightLine in BorderSides) then
|
|
||||||
begin
|
|
||||||
TheRect.Right := TheRect.Right-{$IFDEF windows}2{$ELSE}3{$ENDIF};
|
|
||||||
end;
|
|
||||||
|
|
||||||
//Bottom
|
|
||||||
if (bsBottomLine in BorderSides) then
|
|
||||||
begin
|
|
||||||
TheRect.Bottom := TheRect.Bottom - 2;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure TGradButton.GetContentRect(var TheRect: TRect);
|
procedure TGradButton.GetContentRect(var TheRect: TRect);
|
||||||
begin
|
begin
|
||||||
TheRect := Rect(0,0,Width,Height);
|
TheRect := Rect(0,0,Width,Height);
|
||||||
@ -649,11 +726,7 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.UpdateButton;
|
procedure TGradButton.UpdateButton;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
if FAutoWidth then Width := GetAutoWidth;
|
|
||||||
if FAutoHeight then Height := GetAutoHeight;
|
|
||||||
|
|
||||||
UpdateBackground;
|
UpdateBackground;
|
||||||
UpdatePositions;
|
UpdatePositions;
|
||||||
end;
|
end;
|
||||||
@ -715,6 +788,25 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
procedure TGradButton.DrawDropDownArrow;
|
||||||
|
var
|
||||||
|
Points : Array of TPoint;
|
||||||
|
begin
|
||||||
|
SetLength(Points, 3);
|
||||||
|
|
||||||
|
// ArrowState
|
||||||
|
{if FDropDownState = bsUp then ArrowState:=ttbSplitButtonDropDownNormal;
|
||||||
|
if FDropDownState = bsDown then ArrowState:=ttbSplitButtonDropDownPressed;
|
||||||
|
if FDropDownState = bsHot then ArrowState:=ttbSplitButtonDropDownHot;
|
||||||
|
if FDropDownState = bsDisabled then ArrowState:=ttbSplitButtonDropDownDisabled;
|
||||||
|
|
||||||
|
if (FDropDownState = bsDown) and Enabled then
|
||||||
|
ArrowState := ttbSplitButtonDropDownPressed;
|
||||||
|
}
|
||||||
|
PaintArrow(bm.Canvas, FDropdownMarkRect, FDropDownSettings.FMarkDirection, clGray);
|
||||||
|
|
||||||
|
SetLength(Points, 0);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGradButton.PaintGradient(TrgCanvas: TCanvas; pr : TRect);
|
procedure TGradButton.PaintGradient(TrgCanvas: TCanvas; pr : TRect);
|
||||||
var
|
var
|
||||||
@ -794,6 +886,15 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGradButton.SetDropDownSettings(const AValue: TDropDownSettings);
|
||||||
|
begin
|
||||||
|
if FDropDownSettings=AValue then exit;
|
||||||
|
FDropDownSettings.Assign(AValue);
|
||||||
|
|
||||||
|
FDropDownSettings.Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
procedure TGradButton.SetAutoHeight(const AValue: Boolean);
|
procedure TGradButton.SetAutoHeight(const AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FAutoHeight=AValue then exit;
|
if FAutoHeight=AValue then exit;
|
||||||
@ -821,10 +922,9 @@ end;
|
|||||||
constructor TGradButton.Create(AOwner: TComponent);
|
constructor TGradButton.Create(AOwner: TComponent);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
Width:=80;
|
FDropDownSettings := TDropDownSettings.Create(@DropDownSettingsChanged);
|
||||||
Height:=25;
|
|
||||||
|
|
||||||
FAutoWidthBorderSpacing:=15;
|
FAutoWidthBorderSpacing:=15;
|
||||||
FAutoHeightBorderSpacing:=15;
|
FAutoHeightBorderSpacing:=15;
|
||||||
FNormalBlend:=0.5;
|
FNormalBlend:=0.5;
|
||||||
@ -900,6 +1000,28 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGradButton.ChangeBounds(ALeft, ATop, AWidth, AHeight: integer;
|
||||||
|
KeepBase: boolean);
|
||||||
|
begin
|
||||||
|
if FAutoWidth then
|
||||||
|
AWidth := GetAutoWidth;
|
||||||
|
|
||||||
|
if FAutoHeight then
|
||||||
|
AHeight := GetAutoHeight;
|
||||||
|
|
||||||
|
if (HasParent) then
|
||||||
|
begin
|
||||||
|
if FAutoWidth or FAutoHeight then
|
||||||
|
UpdateButton
|
||||||
|
else begin
|
||||||
|
UpdatePositions;
|
||||||
|
UpdateBackground;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
inherited ChangeBounds(ALeft, ATop, AWidth, AHeight, KeepBase);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGradButton.SetBorderSides(const Value: TBorderSides);
|
procedure TGradButton.SetBorderSides(const Value: TBorderSides);
|
||||||
begin
|
begin
|
||||||
FBorderSides:=Value;
|
FBorderSides:=Value;
|
||||||
@ -976,7 +1098,7 @@ begin
|
|||||||
|
|
||||||
if StateCheck then
|
if StateCheck then
|
||||||
begin
|
begin
|
||||||
doIt := (FOldState<>FState);
|
doIt := (FOldState<>FState);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
if doIt then
|
if doIt then
|
||||||
@ -1002,29 +1124,29 @@ end;
|
|||||||
|
|
||||||
procedure TGradButton.DoEnter;
|
procedure TGradButton.DoEnter;
|
||||||
begin
|
begin
|
||||||
FState:=bsHot;
|
FState:=bsHot;
|
||||||
FFocused:=true;
|
FFocused:=true;
|
||||||
InvPaint;
|
InvPaint;
|
||||||
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.KeyUp(var Key: Word; Shift: TShiftState);
|
procedure TGradButton.KeyUp(var Key: Word; Shift: TShiftState);
|
||||||
begin
|
begin
|
||||||
if Key in [VK_RETURN, VK_SPACE] then
|
if Key in [VK_RETURN, VK_SPACE] then
|
||||||
inherited Click;
|
inherited Click;
|
||||||
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.DoExit;
|
procedure TGradButton.DoExit;
|
||||||
begin
|
begin
|
||||||
FState:=bsUp;
|
FState:=bsUp;
|
||||||
FFocused:=false;
|
FFocused:=false;
|
||||||
|
|
||||||
InvPaint;
|
InvPaint;
|
||||||
|
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.Paint;
|
procedure TGradButton.Paint;
|
||||||
@ -1074,9 +1196,24 @@ begin
|
|||||||
FBackgroundRect.Right-2, FBackgroundRect.Bottom-2));
|
FBackgroundRect.Right-2, FBackgroundRect.Bottom-2));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Canvas.Draw(0,0,bm);
|
if FDropDownSettings.Show and FDropDownSettings.IsPopupStored then
|
||||||
|
DrawDropDownArrow;
|
||||||
|
|
||||||
|
if not FPaintToActive then
|
||||||
|
begin
|
||||||
|
Canvas.Draw(0,0,bm);
|
||||||
|
|
||||||
|
inherited Paint;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
inherited Paint;
|
procedure TGradButton.PaintTo(ACanvas: TCanvas; X, Y: Integer);
|
||||||
|
begin
|
||||||
|
FPaintToActive := true;
|
||||||
|
Paint;
|
||||||
|
ACanvas.CopyRect(Rect(X,Y, X+Width, Y+Height),
|
||||||
|
bm.Canvas, ClientRect);
|
||||||
|
FPaintToActive:= false;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.MouseEnter;
|
procedure TGradButton.MouseEnter;
|
||||||
@ -1092,22 +1229,32 @@ end;
|
|||||||
|
|
||||||
procedure TGradButton.MouseMove(Shift: TShiftState;
|
procedure TGradButton.MouseMove(Shift: TShiftState;
|
||||||
X, Y: Integer);
|
X, Y: Integer);
|
||||||
|
var
|
||||||
|
TempPoint: TPoint;
|
||||||
begin
|
begin
|
||||||
if ssLeft in Shift then
|
TempPoint := Point(X, Y);
|
||||||
FState := bsDown
|
|
||||||
else
|
if ssLeft in Shift then
|
||||||
FState := bsHot;
|
FState := bsDown
|
||||||
|
else
|
||||||
InvPaint(true);
|
FState := bsHot;
|
||||||
|
|
||||||
|
if PtInRect(FDropdownMarkRect, TempPoint) and (ssLeft in Shift) then
|
||||||
|
FDropDownState:= bsDown
|
||||||
|
else
|
||||||
|
FDropDownState:= bsHot;
|
||||||
|
|
||||||
//inherited MouseMove calls OnMouseMove
|
InvPaint(true);
|
||||||
inherited MouseMove(Shift, X, Y);
|
|
||||||
|
//inherited MouseMove calls OnMouseMove
|
||||||
|
inherited MouseMove(Shift, X, Y);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TGradButton.MouseLeave;
|
procedure TGradButton.MouseLeave;
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
//WriteLn('MouseLeave');
|
//WriteLn('MouseLeave');
|
||||||
|
FDropDownState:= bsUp;
|
||||||
FState:=bsUp;
|
FState:=bsUp;
|
||||||
//FFocused:=false;
|
//FFocused:=false;
|
||||||
InvPaint(true);
|
InvPaint(true);
|
||||||
@ -1120,7 +1267,19 @@ end;
|
|||||||
|
|
||||||
procedure TGradButton.MouseDown(Button: TMouseButton;
|
procedure TGradButton.MouseDown(Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
var
|
||||||
|
TempPoint : TPoint;
|
||||||
begin
|
begin
|
||||||
|
TempPoint:= Point(X,Y);
|
||||||
|
|
||||||
|
if PtInRect(FDropdownMarkRect, TempPoint) then
|
||||||
|
begin
|
||||||
|
FState := bsDown;
|
||||||
|
FDropDownState := bsDown;
|
||||||
|
InvPaint(true);
|
||||||
|
|
||||||
|
end
|
||||||
|
else
|
||||||
if PtInRect(Rect(0,0,Width,Height),Point(X,Y)) then
|
if PtInRect(Rect(0,0,Width,Height),Point(X,Y)) then
|
||||||
begin
|
begin
|
||||||
FState:=bsDown;
|
FState:=bsDown;
|
||||||
@ -1141,21 +1300,150 @@ end;
|
|||||||
|
|
||||||
procedure TGradButton.MouseUp(Button: TMouseButton;
|
procedure TGradButton.MouseUp(Button: TMouseButton;
|
||||||
Shift: TShiftState; X, Y: Integer);
|
Shift: TShiftState; X, Y: Integer);
|
||||||
|
var
|
||||||
|
TempPoint : TPoint;
|
||||||
begin
|
begin
|
||||||
if PtInRect(Rect(0,0,Width,Height),Point(X,Y)) then
|
TempPoint:= Point(X,Y);
|
||||||
|
|
||||||
|
if PtInRect(FDropdownMarkRect, TempPoint) then
|
||||||
begin
|
begin
|
||||||
FState:=bsHot;
|
FState := bsHot;
|
||||||
|
FDropDownState := bsHot;
|
||||||
InvPaint(true);
|
InvPaint(true);
|
||||||
|
|
||||||
if Button = mbLeft then
|
if Button = mbLeft then
|
||||||
inherited Click; //Faster, than the Overrided Click procedure
|
ShowDropdownPopupMenu;
|
||||||
end else begin
|
end
|
||||||
FState := bsUp;
|
else
|
||||||
FFocused:=false;
|
begin
|
||||||
InvPaint(true);
|
if PtInRect(Rect(0,0,Width,Height),TempPoint) then
|
||||||
|
begin
|
||||||
|
FState:=bsHot;
|
||||||
|
InvPaint(true);
|
||||||
|
|
||||||
|
if Button = mbLeft then
|
||||||
|
inherited Click; //Faster, than the Overrided Click procedure
|
||||||
|
end
|
||||||
|
else
|
||||||
|
begin
|
||||||
|
FState := bsUp;
|
||||||
|
FFocused:=false;
|
||||||
|
InvPaint(true);
|
||||||
|
end;
|
||||||
|
|
||||||
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
inherited;
|
{ TDropDownSettings }
|
||||||
|
|
||||||
|
procedure TDropDownSettings.SetMarkPosition(const AValue: TDropDownMarkPosition);
|
||||||
|
begin
|
||||||
|
if FMarkPosition=AValue then exit;
|
||||||
|
FMarkPosition:=AValue;
|
||||||
|
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.SetMarkDirection(
|
||||||
|
const AValue: TDropDownMarkDirection);
|
||||||
|
begin
|
||||||
|
if FMarkDirection=AValue then exit;
|
||||||
|
FMarkDirection:=AValue;
|
||||||
|
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.SetColor(const AValue: TColor);
|
||||||
|
begin
|
||||||
|
if FColor=AValue then exit;
|
||||||
|
FColor:=AValue;
|
||||||
|
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.SetOnlyOnMark(const AValue: boolean);
|
||||||
|
begin
|
||||||
|
if FOnlyOnMark=AValue then exit;
|
||||||
|
FOnlyOnMark:=AValue;
|
||||||
|
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.SetPopupMenu(const AValue: TPopupMenu);
|
||||||
|
begin
|
||||||
|
if FPopupMenu=AValue then exit;
|
||||||
|
FPopupMenu:=AValue;
|
||||||
|
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.SetPressedColor(const AValue: TColor);
|
||||||
|
begin
|
||||||
|
if FPressedColor=AValue then exit;
|
||||||
|
FPressedColor:=AValue;
|
||||||
|
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.SetShow(const AValue: Boolean);
|
||||||
|
begin
|
||||||
|
if FShow=AValue then exit;
|
||||||
|
FShow:=AValue;
|
||||||
|
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.SetSize(const AValue: integer);
|
||||||
|
begin
|
||||||
|
if FSize=AValue then exit;
|
||||||
|
FSize:=AValue;
|
||||||
|
|
||||||
|
Notify;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.Notify;
|
||||||
|
begin
|
||||||
|
if FNotify <> nil then
|
||||||
|
FNotify(Self);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TDropDownSettings.Create(ANotify: TNotifyEvent);
|
||||||
|
begin
|
||||||
|
FNotify := ANotify;
|
||||||
|
|
||||||
|
FColor:= clSilver;
|
||||||
|
FPressedColor:= clBlack;
|
||||||
|
FMarkDirection:= mdDown;
|
||||||
|
FMarkPosition:= mpRight;
|
||||||
|
FOnlyOnMark:= false;
|
||||||
|
FShow:= false;
|
||||||
|
FSize:= 8;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TDropDownSettings.AssignTo(Dest: TPersistent);
|
||||||
|
begin
|
||||||
|
if Dest is TDropDownSettings then
|
||||||
|
begin
|
||||||
|
with TDropDownSettings(Dest) do
|
||||||
|
begin
|
||||||
|
FNotify := Self.FNotify;
|
||||||
|
FColor:= Self.FColor;
|
||||||
|
FPressedColor:=Self.FPressedColor;
|
||||||
|
FMarkDirection:=Self.FMarkDirection;
|
||||||
|
FMarkPosition:=Self.FMarkPosition;
|
||||||
|
FOnlyOnMark:=Self.FOnlyOnMark;
|
||||||
|
FShow:=Self.FShow;
|
||||||
|
FSize:=Self.FSize;
|
||||||
|
end;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDropDownSettings.IsPopupStored: boolean;
|
||||||
|
begin
|
||||||
|
Result := FPopupMenu <> nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//Thx to: http://www.delphipraxis.net/topic67805_farbverlauf+berechnen.html
|
//Thx to: http://www.delphipraxis.net/topic67805_farbverlauf+berechnen.html
|
||||||
@ -1207,6 +1495,14 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function IfThen(ATest, ValA: Boolean; ValB: Boolean): Boolean;
|
||||||
|
begin
|
||||||
|
if ATest then
|
||||||
|
Result := ValA
|
||||||
|
else
|
||||||
|
Result := ValB;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure Register;
|
procedure Register;
|
||||||
begin
|
begin
|
||||||
RegisterComponents('Misc',[TGradButton]);
|
RegisterComponents('Misc',[TGradButton]);
|
||||||
|
Reference in New Issue
Block a user