1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
|
{
*****************************************************************************
See the file COPYING.modifiedLGPL.txt, included in this distribution,
for details about the license.
*****************************************************************************
Author: Maciej Izak
DaThoX 2004-2015
FreeSparta.com
}
unit sparta_FakeFrame;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils,
// LCL
Controls, Forms,
// Sparta
sparta_FakeCustom;
type
TFakeFrame = class(TFakeCustomFrame)
end;
{ THookFrame - temporary name need refactoring }
THookFrame = class(TFrame)
private
FHackAlign: TAlign;
FHackAnchors: TAnchors;
function IsAnchorsStored: Boolean;
function GetAlign: TAlign;
procedure SetAlign(Value: TAlign);
function GetAnchors: TAnchors;
procedure SetAnchors(const AValue: TAnchors);
public
constructor Create(TheOwner: TComponent); override;
published
property Align: TAlign read GetAlign write SetAlign default alNone;
property Anchors: TAnchors read GetAnchors write SetAnchors stored IsAnchorsStored default [akLeft, akTop];
end;
implementation
{ THookFrame }
function THookFrame.IsAnchorsStored: Boolean;
begin
Result:=(Anchors<>AnchorAlign[Align]);
end;
function THookFrame.GetAlign: TAlign;
begin
if not (csDesignInstance in ComponentState) then
Result := inherited Align
else
Result := FHackAlign;
end;
procedure THookFrame.SetAlign(Value: TAlign);
var
OldAlign: TAlign;
a: TAnchorKind;
begin
if not (csDesignInstance in ComponentState) then
inherited Align := Value
else begin
if FHackAlign = Value then exit;
OldAlign := FHackAlign;
FHackAlign := Value;
if (not (csLoading in ComponentState))
and (Align in [alLeft,alTop,alRight,alBottom,alClient]) then begin
// Align for alLeft,alTop,alRight,alBottom,alClient takes precedence
// over AnchorSides => clean up
for a:=low(TAnchorKind) to High(TAnchorKind) do
begin
if not (a in AnchorAlign[FHackAlign]) then continue;
AnchorSide[a].Control:=nil;
AnchorSide[a].Side:=asrTop;
end;
end;
// Notes:
// - if anchors had default values then change them to new default values
// This is done for Delphi compatibility.
// - Anchors are not stored if they are AnchorAlign[Align]
if (Anchors = AnchorAlign[OldAlign]) and (Anchors <> AnchorAlign[FHackAlign]) then
Anchors := AnchorAlign[FHackAlign];
end;
end;
function THookFrame.GetAnchors: TAnchors;
begin
if not (csDesignInstance in ComponentState) then
Result := inherited Anchors
else
Result := FHackAnchors;
end;
procedure THookFrame.SetAnchors(const AValue: TAnchors);
var
NewAnchors: TAnchors;
a: TAnchorKind;
begin
if not (csDesignInstance in ComponentState) then
inherited Anchors := AValue
else begin
if Anchors = AValue then Exit;
NewAnchors:=AValue-FHackAnchors;
FHackAnchors := AValue;
for a:=Low(TAnchorKind) to high(TAnchorKind) do
if (a in NewAnchors) and (AnchorSide[a].Side=asrCenter) then
AnchorSide[a].FixCenterAnchoring;
end;
end;
constructor THookFrame.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FHackAnchors := [akLeft,akTop];
FHackAlign := alNone;
end;
end.
|