diff --git a/designer/anchoreditor.lfm b/designer/anchoreditor.lfm index e8b0b6a4eb..3d80c8d2d0 100644 --- a/designer/anchoreditor.lfm +++ b/designer/anchoreditor.lfm @@ -9,10 +9,10 @@ object AnchorDesigner: TAnchorDesigner ClientWidth = 544 Constraints.MinHeight = 361 Constraints.MinWidth = 544 - OnCreate = AnchorDesignerCreate + OnCreate = FormCreate OnDeactivate = FormDeactivate - OnDestroy = AnchorDesignerDestroy - OnShow = AnchorDesignerShow + OnDestroy = FormDestroy + OnShow = FormShow LCLVersion = '1.7' object BorderSpaceGroupBox: TGroupBox AnchorSideLeft.Control = Owner @@ -21,22 +21,22 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = BottomGroupBox Left = 174 - Height = 137 - Top = 111 + Height = 139 + Top = 110 Width = 196 Anchors = [akTop, akLeft, akBottom] BorderSpacing.Top = 2 BorderSpacing.Bottom = 2 Caption = 'BorderSpaceGroupBox' - ClientHeight = 118 - ClientWidth = 194 + ClientHeight = 121 + ClientWidth = 192 TabOrder = 2 object LeftBorderSpaceSpinEdit: TSpinEdit AnchorSideTop.Control = AroundBorderSpaceSpinEdit AnchorSideRight.Control = AroundBorderSpaceSpinEdit - Left = 7 - Height = 28 - Top = 45 + Left = 6 + Height = 21 + Top = 50 Width = 56 Anchors = [akTop, akRight] BorderSpacing.Right = 6 @@ -51,9 +51,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideLeft.Control = AroundBorderSpaceSpinEdit AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = AroundBorderSpaceSpinEdit - Left = 131 - Height = 28 - Top = 45 + Left = 130 + Height = 21 + Top = 50 Width = 56 BorderSpacing.Left = 6 MaxValue = 2048 @@ -66,9 +66,9 @@ object AnchorDesigner: TAnchorDesigner object TopBorderSpaceSpinEdit: TSpinEdit AnchorSideLeft.Control = AroundBorderSpaceSpinEdit AnchorSideBottom.Control = AroundBorderSpaceSpinEdit - Left = 69 - Height = 28 - Top = 11 + Left = 68 + Height = 21 + Top = 23 Width = 56 Anchors = [akLeft, akBottom] BorderSpacing.Bottom = 6 @@ -83,9 +83,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideLeft.Control = AroundBorderSpaceSpinEdit AnchorSideTop.Control = AroundBorderSpaceSpinEdit AnchorSideTop.Side = asrBottom - Left = 69 - Height = 28 - Top = 79 + Left = 68 + Height = 21 + Top = 77 Width = 56 BorderSpacing.Top = 6 MaxValue = 2048 @@ -100,9 +100,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideLeft.Side = asrCenter AnchorSideTop.Control = BorderSpaceGroupBox AnchorSideTop.Side = asrCenter - Left = 69 - Height = 28 - Top = 45 + Left = 68 + Height = 21 + Top = 50 Width = 56 MaxValue = 2048 OnChange = BorderSpaceSpinEditChange @@ -115,7 +115,7 @@ object AnchorDesigner: TAnchorDesigner object TopGroupBox: TGroupBox AnchorSideTop.Control = Owner Left = 174 - Height = 107 + Height = 106 Top = 2 Width = 196 Anchors = [akTop, akLeft, akRight] @@ -123,29 +123,18 @@ object AnchorDesigner: TAnchorDesigner BorderSpacing.Top = 2 Caption = 'TopGroupBox' ClientHeight = 88 - ClientWidth = 194 + ClientWidth = 192 TabOrder = 0 - object TopShape: TShape - AnchorSideRight.Side = asrBottom - Left = 130 - Height = 24 - Top = 2 - Width = 24 - Anchors = [akTop, akRight] - Brush.Color = clNone - Brush.Style = bsClear - Pen.Color = clGreen - Pen.Style = psDot - end object TopRefTopSpeedButton: TSpeedButton AnchorSideTop.Control = TopGroupBox AnchorSideRight.Control = TopGroupBox AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom - Left = 164 + Left = 162 Height = 24 Top = 2 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Top = 2 BorderSpacing.Right = 6 @@ -161,14 +150,15 @@ object AnchorDesigner: TAnchorDesigner AnchorSideRight.Control = TopRefTopSpeedButton AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom - Left = 164 + Left = 162 Height = 24 Top = 58 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Top = 4 BorderSpacing.Bottom = 6 - GroupIndex = 1 + GroupIndex = 3 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -180,13 +170,14 @@ object AnchorDesigner: TAnchorDesigner AnchorSideRight.Control = TopRefTopSpeedButton AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom - Left = 164 + Left = 162 Height = 24 Top = 30 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Top = 4 - GroupIndex = 1 + GroupIndex = 2 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -197,9 +188,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrCenter AnchorSideBottom.Control = TopSiblingComboBox Left = 6 - Height = 18 - Top = 37 - Width = 40 + Height = 13 + Top = 47 + Width = 30 Anchors = [akLeft, akBottom] Caption = 'Sibling' ParentColor = False @@ -209,9 +200,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Control = TopRefTopSpeedButton AnchorSideTop.Side = asrCenter Left = 6 - Height = 21 - Top = 4 - Width = 72 + Height = 17 + Top = 6 + Width = 56 Caption = 'Enabled' OnChange = AnchorEnabledCheckBoxChange TabOrder = 0 @@ -222,13 +213,13 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrCenter AnchorSideRight.Control = TopRefTopSpeedButton Left = 6 - Height = 30 - Top = 55 - Width = 152 + Height = 21 + Top = 60 + Width = 150 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Right = 6 - ItemHeight = 0 + ItemHeight = 13 OnEditingDone = SiblingComboBoxChange ParentShowHint = False ShowHint = True @@ -240,40 +231,29 @@ object AnchorDesigner: TAnchorDesigner AnchorSideBottom.Control = Owner AnchorSideBottom.Side = asrBottom Left = 174 - Height = 107 - Top = 250 + Height = 106 + Top = 251 Width = 196 Anchors = [akLeft, akRight, akBottom] AutoSize = True BorderSpacing.Bottom = 4 Caption = 'BottomGroupBox' ClientHeight = 88 - ClientWidth = 194 + ClientWidth = 192 TabOrder = 4 - object BottomShape: TShape - AnchorSideRight.Side = asrBottom - Left = 130 - Height = 24 - Top = 0 - Width = 24 - Anchors = [akTop, akRight] - Brush.Color = clNone - Brush.Style = bsClear - Pen.Color = clGreen - Pen.Style = psDot - end object BottomRefTopSpeedButton: TSpeedButton AnchorSideTop.Control = BottomGroupBox AnchorSideRight.Control = BottomGroupBox AnchorSideRight.Side = asrBottom - Left = 162 + Left = 160 Height = 24 Top = 2 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Top = 2 BorderSpacing.Right = 8 - GroupIndex = 3 + GroupIndex = 1 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -284,10 +264,11 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrBottom AnchorSideRight.Control = BottomRefTopSpeedButton AnchorSideRight.Side = asrBottom - Left = 162 + Left = 160 Height = 24 Top = 58 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Top = 4 BorderSpacing.Bottom = 6 @@ -303,13 +284,14 @@ object AnchorDesigner: TAnchorDesigner AnchorSideRight.Control = BottomRefTopSpeedButton AnchorSideRight.Side = asrBottom AnchorSideBottom.Side = asrBottom - Left = 162 + Left = 160 Height = 24 Top = 30 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Top = 4 - GroupIndex = 3 + GroupIndex = 2 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -320,9 +302,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = BottomSiblingComboBox Left = 6 - Height = 18 - Top = 37 - Width = 40 + Height = 13 + Top = 47 + Width = 30 Anchors = [akLeft, akBottom] Caption = 'Sibling' ParentColor = False @@ -332,9 +314,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Control = BottomRefTopSpeedButton AnchorSideTop.Side = asrCenter Left = 6 - Height = 21 - Top = 4 - Width = 72 + Height = 17 + Top = 6 + Width = 56 Caption = 'Enabled' OnChange = AnchorEnabledCheckBoxChange TabOrder = 0 @@ -345,13 +327,13 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrCenter AnchorSideRight.Control = BottomRefTopSpeedButton Left = 6 - Height = 30 - Top = 55 - Width = 150 + Height = 21 + Top = 60 + Width = 148 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Right = 6 - ItemHeight = 0 + ItemHeight = 13 OnEditingDone = SiblingComboBoxChange ParentShowHint = False ShowHint = True @@ -368,39 +350,27 @@ object AnchorDesigner: TAnchorDesigner AnchorSideBottom.Control = BorderSpaceGroupBox AnchorSideBottom.Side = asrBottom Left = 374 - Height = 137 - Top = 111 + Height = 139 + Top = 110 Width = 166 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Left = 4 BorderSpacing.Right = 4 Caption = 'RightGroupBox' - ClientHeight = 118 - ClientWidth = 164 + ClientHeight = 121 + ClientWidth = 162 TabOrder = 3 - object RightShape: TShape - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Side = asrBottom - Left = 98 - Height = 24 - Top = 92 - Width = 24 - Anchors = [akRight, akBottom] - Brush.Color = clNone - Brush.Style = bsClear - Pen.Color = clGreen - Pen.Style = psDot - end object RightRefLeftSpeedButton: TSpeedButton AnchorSideLeft.Control = RightSiblingComboBox AnchorSideTop.Control = RightSiblingComboBox AnchorSideTop.Side = asrBottom Left = 6 Height = 24 - Top = 78 + Top = 75 Width = 24 + AllowAllUp = True BorderSpacing.Top = 4 - GroupIndex = 4 + GroupIndex = 1 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -412,10 +382,11 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Control = RightRefLeftSpeedButton Left = 62 Height = 24 - Top = 78 + Top = 75 Width = 24 + AllowAllUp = True BorderSpacing.Left = 4 - GroupIndex = 4 + GroupIndex = 3 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -428,10 +399,11 @@ object AnchorDesigner: TAnchorDesigner AnchorSideRight.Side = asrBottom Left = 34 Height = 24 - Top = 78 + Top = 75 Width = 24 + AllowAllUp = True BorderSpacing.Left = 4 - GroupIndex = 4 + GroupIndex = 2 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -442,9 +414,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = RightSiblingComboBox Left = 6 - Height = 18 - Top = 26 - Width = 40 + Height = 13 + Top = 37 + Width = 30 Anchors = [akLeft, akBottom] Caption = 'Sibling' ParentColor = False @@ -454,9 +426,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrBottom AnchorSideBottom.Control = RightSiblingLabel Left = 6 - Height = 21 - Top = 1 - Width = 72 + Height = 17 + Top = 16 + Width = 56 Anchors = [akLeft, akBottom] BorderSpacing.Bottom = 4 Caption = 'Enabled' @@ -470,13 +442,13 @@ object AnchorDesigner: TAnchorDesigner AnchorSideRight.Control = RightGroupBox AnchorSideRight.Side = asrBottom Left = 6 - Height = 30 - Top = 44 - Width = 152 + Height = 21 + Top = 50 + Width = 150 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Right = 6 - ItemHeight = 0 + ItemHeight = 13 OnEditingDone = SiblingComboBoxChange ParentShowHint = False ShowHint = True @@ -491,39 +463,27 @@ object AnchorDesigner: TAnchorDesigner AnchorSideBottom.Control = BorderSpaceGroupBox AnchorSideBottom.Side = asrBottom Left = 4 - Height = 137 - Top = 111 + Height = 139 + Top = 110 Width = 166 Anchors = [akTop, akLeft, akRight, akBottom] BorderSpacing.Left = 4 BorderSpacing.Right = 4 Caption = 'LeftGroupBox' - ClientHeight = 118 - ClientWidth = 164 + ClientHeight = 121 + ClientWidth = 162 TabOrder = 1 - object LeftShape: TShape - AnchorSideRight.Side = asrBottom - AnchorSideBottom.Side = asrBottom - Left = 42 - Height = 24 - Top = 92 - Width = 24 - Anchors = [akRight, akBottom] - Brush.Color = clNone - Brush.Style = bsClear - Pen.Color = clGreen - Pen.Style = psDot - end object LeftRefLeftSpeedButton: TSpeedButton AnchorSideTop.Control = LeftRefRightSpeedButton AnchorSideRight.Control = LeftRefCenterSpeedButton - Left = 78 + Left = 76 Height = 24 - Top = 78 + Top = 75 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Right = 4 - GroupIndex = 2 + GroupIndex = 1 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -535,13 +495,14 @@ object AnchorDesigner: TAnchorDesigner AnchorSideTop.Side = asrBottom AnchorSideRight.Control = LeftSiblingComboBox AnchorSideRight.Side = asrBottom - Left = 134 + Left = 132 Height = 24 - Top = 78 + Top = 75 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Top = 4 - GroupIndex = 2 + GroupIndex = 3 Transparent = False OnClick = ReferenceSideButtonClicked ShowHint = True @@ -551,10 +512,11 @@ object AnchorDesigner: TAnchorDesigner AnchorSideLeft.Side = asrBottom AnchorSideTop.Control = LeftRefRightSpeedButton AnchorSideRight.Control = LeftRefRightSpeedButton - Left = 106 + Left = 104 Height = 24 - Top = 78 + Top = 75 Width = 24 + AllowAllUp = True Anchors = [akTop, akRight] BorderSpacing.Right = 4 GroupIndex = 2 @@ -567,9 +529,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideLeft.Control = LeftSiblingComboBox AnchorSideBottom.Control = LeftSiblingComboBox Left = 6 - Height = 18 - Top = 26 - Width = 40 + Height = 13 + Top = 37 + Width = 30 Anchors = [akLeft, akBottom] Caption = 'Sibling' ParentColor = False @@ -578,9 +540,9 @@ object AnchorDesigner: TAnchorDesigner AnchorSideLeft.Control = LeftSiblingComboBox AnchorSideBottom.Control = LeftSiblingLabel Left = 6 - Height = 21 - Top = 1 - Width = 72 + Height = 17 + Top = 16 + Width = 56 Anchors = [akLeft, akBottom] BorderSpacing.Bottom = 4 Caption = 'Enabled' @@ -594,13 +556,13 @@ object AnchorDesigner: TAnchorDesigner AnchorSideRight.Control = LeftGroupBox AnchorSideRight.Side = asrBottom Left = 6 - Height = 30 - Top = 44 - Width = 152 + Height = 21 + Top = 50 + Width = 150 Anchors = [akTop, akLeft, akRight] BorderSpacing.Left = 6 BorderSpacing.Right = 6 - ItemHeight = 0 + ItemHeight = 13 OnEditingDone = SiblingComboBoxChange ParentShowHint = False ShowHint = True diff --git a/designer/anchoreditor.pas b/designer/anchoreditor.pas index 7ec9642f04..271890edb9 100644 --- a/designer/anchoreditor.pas +++ b/designer/anchoreditor.pas @@ -41,19 +41,22 @@ uses type + TAnchorSideRefSet = set of TAnchorSideReference; + { TAnchorDesignerSideValues } TAnchorDesignerSideValues = class - private - FAmbiguousBorderSpace: boolean; - FAmbiguousEnabled: boolean; - FAmbiguousSide: boolean; - FAmbiguousSibling: boolean; + strict private + FBorderSpace_IsAmbiguous: boolean; + FEnabled_IsAmbiguous: boolean; + FSibling_IsAmbiguous: boolean; FAnchorKind: TAnchorKind; - FBorderSpace: integer; - FEnabled: boolean; + FBorderSpace: Integer; + FCount: Integer; + FEnabled: Boolean; FSibling: string; - FSide: TAnchorSideReference; + FSideRefs: TAnchorSideRefSet; + function GetSideRef_IsAmbiguous: Boolean; public constructor Create(TheKind: TAnchorKind); procedure SetValues(AControl: TControl); @@ -61,20 +64,20 @@ type public property AnchorKind: TAnchorKind read FAnchorKind; property Enabled: boolean read FEnabled write FEnabled; - property AmbiguousEnabled: boolean read FAmbiguousEnabled write FAmbiguousEnabled; + property Enabled_IsAmbiguous: boolean read FEnabled_IsAmbiguous write FEnabled_IsAmbiguous; property Sibling: string read FSibling write FSibling; - property AmbiguousSibling: boolean read FAmbiguousSibling write FAmbiguousSibling; - property Side: TAnchorSideReference read FSide write FSide; - property AmbiguousSide: boolean read FAmbiguousSide write FAmbiguousSide; + property Sibling_IsAmbiguous: boolean read FSibling_IsAmbiguous write FSibling_IsAmbiguous; + property SideRef_IsAmbiguous: Boolean read GetSideRef_IsAmbiguous; property BorderSpace: integer read FBorderSpace write FBorderSpace; - property AmbiguousBorderSpace: boolean read FAmbiguousBorderSpace write FAmbiguousBorderSpace; + property BorderSpace_IsAmbiguous: boolean read FBorderSpace_IsAmbiguous write FBorderSpace_IsAmbiguous; + property SideRefs: TAnchorSideRefSet read FSideRefs; + property Count: Integer read FCount; end; - { TAnchorDesignerValues } TAnchorDesignerValues = class - private + strict private FAmbiguousBorderspaceAround: boolean; FBorderspaceAround: integer; FSides: array[TAnchorKind] of TAnchorDesignerSideValues; @@ -91,7 +94,33 @@ type property BorderspaceAround: integer read FBorderspaceAround write SetBorderspaceAround; property AmbiguousBorderspaceAround: boolean read FAmbiguousBorderspaceAround write SetAmbiguousBorderspaceAround; end; - + + { TAnchorDesignerSideControls } + + TAnchorDesigner = class; + + TAnchorDesignerSideControls = class + strict private + FForm: TAnchorDesigner; + {Controls} + FEnabled_CheckBox: TCheckBox; + FSibling_ComboBox: TComboBox; + FSideRef_SButtons: array [TAnchorSideReference] of TSpeedButton; + FBorderSpace_SpinEdit: TSpinEdit; + {Frames} + FEnabled_Frame: TShape; + FSibling_Frame: TShape; + FSideRef_Frames: array [TAnchorSideReference] of TShape; + FBorderSpace_Frame: TShape; + public + constructor Create( + AEnabled: TCheckBox; + ASibling: TComboBox; + ABorderSpace_SpinEdit: TSpinEdit; + ASideRefTop{Left}, ASideRefCenter, ASideRefBottom{Right}: TSpeedButton; + AForm: TAnchorDesigner); + procedure Refresh(ASideValues: TAnchorDesignerSideValues); + end; { TAnchorDesigner } @@ -122,10 +151,6 @@ type RightRefRightSpeedButton: TSpeedButton; RightSiblingComboBox: TComboBox; RightSiblingLabel: TLabel; - TopShape: TShape; - LeftShape: TShape; - BottomShape: TShape; - RightShape: TShape; TopAnchoredCheckBox: TCheckBox; TopBorderSpaceSpinEdit: TSpinEdit; TopGroupBox: TGroupBox; @@ -134,9 +159,9 @@ type TopRefTopSpeedButton: TSpeedButton; TopSiblingComboBox: TComboBox; TopSiblingLabel: TLabel; - procedure AnchorDesignerCreate(Sender: TObject); - procedure AnchorDesignerDestroy(Sender: TObject); - procedure AnchorDesignerShow(Sender: TObject); + procedure FormCreate(Sender: TObject); + procedure FormDestroy(Sender: TObject); + procedure FormShow(Sender: TObject); procedure AnchorEnabledCheckBoxChange(Sender: TObject); procedure BorderSpaceSpinEditChange(Sender: TObject); procedure FormDeactivate(Sender: TObject); @@ -147,7 +172,8 @@ type FSelection: TPersistentSelectionList; FSelectedControlsList: TList; FUpdating: Boolean; - fNeedUpdate: boolean; + FNeedUpdate: boolean; + FSideControls: array[TAnchorKind] of TAnchorDesignerSideControls; procedure Refresh; procedure OnRefreshPropertyValues; procedure OnSetSelection(const ASelection: TPersistentSelectionList); @@ -159,7 +185,9 @@ type procedure CollectValues(const ASelection: TList; out TheValues: TAnchorDesignerValues; out SelectedControlCount: integer); - procedure UpdateFrames; + procedure SetCaptionsAndHints; + procedure LoadGlyphs; + procedure CreateSideControls; protected procedure KeyUp(var Key: Word; Shift: TShiftState); override; procedure UpdateShowing; override; @@ -185,45 +213,211 @@ implementation {$R *.lfm} -procedure UpdateFrame(AShape: TShape; ACheckBox: TCheckBox; ASpeedButtons: array of TSpeedButton); +type + TFrameStyle=(fsNormal, fsAmbigous, fsIgnored, fsNone); + const - sm = 2; // shape margin (should be enough place in designer) + FrameMargin = 1; + + clNormal=clRed; // color for fsNormal + clAmbigous=clRed; // color for fsAmbigous + clIgnored=clBtnShadow; // color for fsIgnored + + psNormal=psSolid; // pen style for fsNormal + psAmbigous=psDot; // pen style for fsAmbigous + psIgnored=psSolid; // pen style for fsIgnored + + +function CreateFrameForControl(AControl: TControl; AFrameMargin: Integer=FrameMargin): TShape; +begin + Result:=TShape.Create(AControl.Owner); + with Result do + begin + Brush.Style:=bsClear; + Brush.Color:=clNone; + Shape:=stRectangle; + Pen.Cosmetic:=True; + Height:=AControl.Height+AFrameMargin*2; + Width:=AControl.Width+AFrameMargin*2; + Parent:=AControl.Parent; + AnchorVerticalCenterTo(AControl); + AnchorHorizontalCenterTo(AControl); + SendToBack; + Visible:=False; + end; +end; + +procedure SetEnabledControls(AEnabled: Boolean; AControls: array of TControl); var i: Integer; begin - case ACheckBox.State of - cbChecked: AShape.Pen.Style:=psSolid; - cbGrayed: AShape.Pen.Style:=psDot; - else - AShape.Visible:=False; - Exit; - end; + for i:=Low(AControls) to High(AControls) do + AControls[i].Enabled:=AEnabled; +end; - for i:=Low(ASpeedButtons) to High(ASpeedButtons) do - begin - if not ASpeedButtons[i].Down then - Continue; - AShape.Height:=ASpeedButtons[i].Height+sm*2; - AShape.Width:=ASpeedButtons[i].Width+sm*2; - AShape.AnchorVerticalCenterTo(ASpeedButtons[i]); - AShape.AnchorHorizontalCenterTo(ASpeedButtons[i]); - AShape.Visible:=True ; - Exit; +procedure SetFrameStyle(AFrame: TShape; AStyle: TFrameStyle); +begin + case AStyle of + fsNormal: + begin + AFrame.Pen.Color:=clNormal; + AFrame.Pen.Style:=psNormal; + AFrame.Visible:=True; + end; + + fsAmbigous: + begin + AFrame.Pen.Color:=clAmbigous; + AFrame.Pen.Style:=psAmbigous; + AFrame.Visible:=True; + end; + + fsIgnored: + begin + AFrame.Pen.Color:=clIgnored; + AFrame.Pen.Style:=psIgnored; + AFrame.Visible:=True; + end; + + fsNone: + begin + AFrame.Visible:=False; + end; + end; +end; + +{ TAnchorDesignerSideControls } + +constructor TAnchorDesignerSideControls.Create( + AEnabled: TCheckBox; + ASibling: TComboBox; + ABorderSpace_SpinEdit: TSpinEdit; + ASideRefTop{Left}, ASideRefCenter, ASideRefBottom{Right}: TSpeedButton; + AForm: TAnchorDesigner); +var + SideRefIndex: TAnchorSideReference; +begin + inherited Create; + FForm:=AForm; + // Assign controls + FEnabled_CheckBox:=AEnabled; + FSibling_ComboBox:=ASibling; + FBorderSpace_SpinEdit:=ABorderSpace_SpinEdit; + FSideRef_SButtons[asrTop]:=ASideRefTop; + FSideRef_SButtons[asrCenter]:=ASideRefCenter; + FSideRef_SButtons[asrBottom]:=ASideRefBottom; + // Create and assign frames + FEnabled_Frame:=CreateFrameForControl(FEnabled_CheckBox); + FSibling_Frame:=CreateFrameForControl(FSibling_ComboBox); + FBorderSpace_Frame:=CreateFrameForControl(FBorderSpace_SpinEdit); + for SideRefIndex:=Low(SideRefIndex) to High(SideRefIndex) do + FSideRef_Frames[SideRefIndex]:=CreateFrameForControl(FSideRef_SButtons[SideRefIndex]); +end; + +procedure TAnchorDesignerSideControls.Refresh(ASideValues: TAnchorDesignerSideValues); +var + SiblingText: String; + SideRefIndex: TAnchorSideReference; +begin + // Enabled + FEnabled_CheckBox.AllowGrayed:=ASideValues.Enabled_IsAmbiguous; + if ASideValues.Enabled_IsAmbiguous then + FEnabled_CheckBox.State:=cbGrayed + else + FEnabled_CheckBox.Checked:=ASideValues.Enabled; + + // BorderSpace + if ASideValues.BorderSpace_IsAmbiguous then + FBorderSpace_SpinEdit.Value:=-1 + else + FBorderSpace_SpinEdit.Value:=ASideValues.BorderSpace; + FBorderSpace_SpinEdit.ValueEmpty:=ASideValues.BorderSpace_IsAmbiguous; + + // Sibling + SiblingText:=ASideValues.Sibling; + FSibling_ComboBox.Text:=SiblingText; + FForm.FillComboBoxWithSiblings(FSibling_ComboBox); + + // SideRefs (after Enabled & Sibling) + for SideRefIndex:=Low(SideRefIndex) to High(SideRefIndex) do + begin + // Set Down + FSideRef_SButtons[SideRefIndex].Down:=(SideRefIndex in ASideValues.SideRefs); + + // Not Down => fsNone + if not FSideRef_SButtons[SideRefIndex].Down then + begin + SetFrameStyle(FSideRef_Frames[SideRefIndex], fsNone); + Continue; + end; + + // Single select + if ASideValues.Count=1 then + if FEnabled_CheckBox.Checked and (FSibling_ComboBox.Text<>'') then + begin + SetFrameStyle(FSideRef_Frames[SideRefIndex], fsNormal); + Continue; + end + else + begin + SetFrameStyle(FSideRef_Frames[SideRefIndex], fsIgnored); + Continue; + end; + + // Multiselect + if ASideValues.SideRef_IsAmbiguous then + begin + SetFrameStyle(FSideRef_Frames[SideRefIndex], fsAmbigous); + Continue; + end + else + if (FEnabled_CheckBox.State<>cbUnchecked) then + begin + SetFrameStyle(FSideRef_Frames[SideRefIndex], fsNormal); + Continue; + end + else + begin + SetFrameStyle(FSideRef_Frames[SideRefIndex], fsIgnored); + Continue; + end; end; - AShape.Visible:=False ; end; { TAnchorDesigner } -procedure TAnchorDesigner.AnchorDesignerCreate(Sender: TObject); -var - AnchorEnabledHint: String; +procedure TAnchorDesigner.FormCreate(Sender: TObject); begin Name:=NonModalIDEWindowNames[nmiwAnchorEditor]; KeyPreview:=true; FSelection:=TPersistentSelectionList.Create; FSelectedControlsList := TList.Create; + SetCaptionsAndHints; + LoadGlyphs; + CreateSideControls; + + GlobalDesignHook.AddHandlerRefreshPropertyValues(@OnRefreshPropertyValues); + GlobalDesignHook.AddHandlerSetSelection(@OnSetSelection); +end; + +procedure TAnchorDesigner.FormDestroy(Sender: TObject); + var + i: TAnchorKind; +begin + FreeAndNil(Values); + GlobalDesignHook.RemoveAllHandlersForObject(Self); + FreeAndNil(FSelection); + FreeAndNil(FSelectedControlsList); + + for i:=Low(i) to High(i) do + FSideControls[i].Free; +end; + +procedure TAnchorDesigner.SetCaptionsAndHints; +var + AnchorEnabledHint: String; +begin AnchorEnabledHint:=lisAnchorEnabledHint; AroundBorderSpaceSpinEdit.Hint:=lisAroundBorderSpaceHint; @@ -268,7 +462,10 @@ begin TopRefTopSpeedButton.Hint:= lisAnchorTopToTopSide; TopSiblingComboBox.Hint:=lisTopSiblingComboBoxHint; TopSiblingLabel.Caption:=lisSibling; +end; +procedure TAnchorDesigner.LoadGlyphs; +begin LeftRefLeftSpeedButton.LoadGlyphFromResourceName(HInstance, 'anchor_left'); LeftRefCenterSpeedButton.LoadGlyphFromResourceName(HInstance, 'anchor_center_horizontal'); LeftRefRightSpeedButton.LoadGlyphFromResourceName(HInstance, 'anchor_left_right'); @@ -281,20 +478,48 @@ begin BottomRefTopSpeedButton.LoadGlyphFromResourceName(HInstance, 'anchor_top_bottom'); BottomRefCenterSpeedButton.LoadGlyphFromResourceName(HInstance, 'anchor_center_vertical'); BottomRefBottomSpeedButton.LoadGlyphFromResourceName(HInstance, 'anchor_bottom'); - - GlobalDesignHook.AddHandlerRefreshPropertyValues(@OnRefreshPropertyValues); - GlobalDesignHook.AddHandlerSetSelection(@OnSetSelection); end; -procedure TAnchorDesigner.AnchorDesignerDestroy(Sender: TObject); +procedure TAnchorDesigner.CreateSideControls; begin - FreeAndNil(Values); - GlobalDesignHook.RemoveAllHandlersForObject(Self); - FreeAndNil(FSelection); - FreeAndNil(FSelectedControlsList); + FSideControls[akTop]:=TAnchorDesignerSideControls.Create( + TopAnchoredCheckBox, + TopSiblingComboBox, + TopBorderSpaceSpinEdit, + TopRefTopSpeedButton, + TopRefCenterSpeedButton, + TopRefBottomSpeedButton, + Self); + + FSideControls[akBottom]:=TAnchorDesignerSideControls.Create( + BottomAnchoredCheckBox, + BottomSiblingComboBox, + BottomBorderSpaceSpinEdit, + BottomRefTopSpeedButton, + BottomRefCenterSpeedButton, + BottomRefBottomSpeedButton, + Self); + + FSideControls[akLeft]:=TAnchorDesignerSideControls.Create( + LeftAnchoredCheckBox, + LeftSiblingComboBox, + LeftBorderSpaceSpinEdit, + LeftRefLeftSpeedButton, // Left <-> Top + LeftRefCenterSpeedButton, + LeftRefRightSpeedButton, // Right <-> Bottom + Self); + + FSideControls[akRight]:=TAnchorDesignerSideControls.Create( + RightAnchoredCheckBox, + RightSiblingComboBox, + RightBorderSpaceSpinEdit, + RightRefLeftSpeedButton, // Left <-> Top + RightRefCenterSpeedButton, + RightRefRightSpeedButton, // Right <-> Bottom + Self); end; -procedure TAnchorDesigner.AnchorDesignerShow(Sender: TObject); +procedure TAnchorDesigner.FormShow(Sender: TObject); begin Refresh; end; @@ -311,7 +536,6 @@ var ReferenceSide: TAnchorSideReference; CheckPosition: Integer; begin - //debugln('TAnchorDesigner.AnchorEnabledCheckBoxChange ',DbgSName(Sender),' ',dbgs(TCheckBox(Sender).Checked)); if FUpdating or (Values=nil) then exit; if Sender=LeftAnchoredCheckBox then Kind:=akLeft @@ -325,9 +549,7 @@ begin exit; NewValue:=TCheckBox(Sender).Checked; CurSide:=Values.Sides[Kind]; - //debugln('TAnchorDesigner.AnchorEnabledCheckBoxChange CurSide.AmbiguousEnabled=',dbgs(CurSide.AmbiguousEnabled),' CurSide.Enabled=',dbgs(CurSide.Enabled),' NewValue=',dbgs(NewValue)); - if CurSide.AmbiguousEnabled or (CurSide.Enabled<>NewValue) then begin - //debugln('TAnchorDesigner.AnchorEnabledCheckBoxChange ',DbgSName(Sender),' NewValue=',dbgs(NewValue)); + if CurSide.Enabled_IsAmbiguous or (CurSide.Enabled<>NewValue) then begin // user changed an anchor SelectedControls:=GetSelectedControls; if SelectedControls=nil then exit; @@ -374,7 +596,6 @@ var CurControl: TControl; Kind: TAnchorKind; begin - //debugln('TAnchorDesigner.BorderSpaceSpinEditChange ',DbgSName(Sender),' ',dbgs(TSpinEdit(Sender).Value)); if FUpdating or (Values=nil) then exit; Around:=false; if Sender=LeftBorderSpaceSpinEdit then @@ -394,10 +615,9 @@ begin CurSide:=Values.Sides[Kind]; if (Around and (Values.AmbiguousBorderspaceAround or (Values.BorderspaceAround<>NewValue))) - or ((not Around) and (CurSide.AmbiguousBorderSpace + or ((not Around) and (CurSide.BorderSpace_IsAmbiguous or (CurSide.BorderSpace<>NewValue))) then begin - //debugln('TAnchorDesigner.BorderSpaceSpinEditChange ',DbgSName(Sender),' NewValue=',dbgs(NewValue)); // user changed a BorderSpace SelectedControls:=GetSelectedControls; if SelectedControls=nil then exit; @@ -496,7 +716,6 @@ var ReferenceSide: TAnchorSideReference; CheckPosition: Integer; begin - //debugln('TAnchorDesigner.SiblingComboBoxChange ',DbgSName(Sender),' ',TComboBox(Sender).Text); if FUpdating or (Values=nil) then exit; if Sender=LeftSiblingComboBox then Kind:=akLeft @@ -510,9 +729,8 @@ begin exit; NewValue:=TComboBox(Sender).Caption; CurSide:=Values.Sides[Kind]; - if CurSide.AmbiguousSibling or (CompareText(CurSide.Sibling,NewValue)<>0) then + if CurSide.Sibling_IsAmbiguous or (CompareText(CurSide.Sibling,NewValue)<>0) then begin - //debugln('TAnchorDesigner.SiblingComboBoxChange ',DbgSName(Sender),' NewSibling=',DbgSName(NewSibling)); // user changed a sibling SelectedControls:=GetSelectedControls; if SelectedControls=nil then exit; @@ -602,9 +820,8 @@ end; procedure TAnchorDesigner.ReferenceSideButtonClicked(Sender: TObject); var - CurSide: TAnchorDesignerSideValues; Kind: TAnchorKind; - Side: TAnchorSideReference; + SideRef: TAnchorSideReference; SelectedControls: TList; i: Integer; CurControl: TControl; @@ -612,90 +829,89 @@ var ReferenceSide: TAnchorSideReference; CheckPosition: Integer; begin - //debugln('TAnchorDesigner.ReferenceSideButtonClicked ',DbgSName(Sender),' ',dbgs(TSpeedButton(Sender).Down)); - if FUpdating or (Values=nil) then exit; + if FUpdating or (Values=nil) then Exit; + + // Get Kind and SideRef if Sender=LeftRefCenterSpeedButton then begin Kind:=akLeft; - Side:=asrCenter; + SideRef:=asrCenter; end else if Sender=LeftRefLeftSpeedButton then begin Kind:=akLeft; - Side:=asrLeft; + SideRef:=asrLeft; end else if Sender=LeftRefRightSpeedButton then begin Kind:=akLeft; - Side:=asrRight; + SideRef:=asrRight; end else if Sender=RightRefCenterSpeedButton then begin Kind:=akRight; - Side:=asrCenter; + SideRef:=asrCenter; end else if Sender=RightRefLeftSpeedButton then begin Kind:=akRight; - Side:=asrLeft; + SideRef:=asrLeft; end else if Sender=RightRefRightSpeedButton then begin Kind:=akRight; - Side:=asrRight; + SideRef:=asrRight; end else if Sender=TopRefCenterSpeedButton then begin Kind:=akTop; - Side:=asrCenter; + SideRef:=asrCenter; end else if Sender=TopRefTopSpeedButton then begin Kind:=akTop; - Side:=asrTop; + SideRef:=asrTop; end else if Sender=TopRefBottomSpeedButton then begin Kind:=akTop; - Side:=asrBottom; + SideRef:=asrBottom; end else if Sender=BottomRefCenterSpeedButton then begin Kind:=akBottom; - Side:=asrCenter; + SideRef:=asrCenter; end else if Sender=BottomRefTopSpeedButton then begin Kind:=akBottom; - Side:=asrTop; + SideRef:=asrTop; end else if Sender=BottomRefBottomSpeedButton then begin Kind:=akBottom; - Side:=asrBottom; + SideRef:=asrBottom; end else - exit; - CurSide:=Values.Sides[Kind]; - if CurSide.AmbiguousSide or (CurSide.Side<>Side) then - begin - //debugln('TAnchorDesigner.ReferenceSideButtonClicked ',DbgSName(Sender)); - // user changed a sibling + Exit; + + // User changed a sibling SelectedControls:=GetSelectedControls; - if SelectedControls=nil then exit; - // check - for i:=0 to SelectedControls.Count-1 do begin + if SelectedControls=nil then Exit; + // Check + for i:=0 to SelectedControls.Count-1 do + begin CurControl:=TControl(SelectedControls[i]); if (Kind in CurControl.Anchors) - and (not CurControl.AnchorSide[Kind].CheckSidePosition( - CurControl.AnchorSide[Kind].Control,Side, - ReferenceControl,ReferenceSide,CheckPosition)) - then begin + and (not CurControl.AnchorSide[Kind].CheckSidePosition( + CurControl.AnchorSide[Kind].Control, SideRef, + ReferenceControl, ReferenceSide, CheckPosition)) then + begin if IDEMessageDialog(lisCCOWarningCaption, - lisThisWillCreateACircularDependency, mtWarning, [mbIgnore, mbCancel])<> - mrIgnore - then begin + lisThisWillCreateACircularDependency, + mtWarning, [mbIgnore, mbCancel]) <> mrIgnore then + begin Refresh; - exit; + Exit; end; - break; + Break; end; end; - // commit - for i:=0 to SelectedControls.Count-1 do begin + // Commit + for i:=0 to SelectedControls.Count-1 do + begin CurControl:=TControl(SelectedControls[i]); - CurControl.AnchorSide[Kind].Side:=Side; + CurControl.AnchorSide[Kind].Side:=SideRef; end; GlobalDesignHook.Modified(Self); GlobalDesignHook.RefreshPropertyValues; - end; end; procedure TAnchorDesigner.KeyUp(var Key: Word; Shift: TShiftState); @@ -707,7 +923,7 @@ end; procedure TAnchorDesigner.UpdateShowing; begin inherited UpdateShowing; - if IsVisible and fNeedUpdate then + if IsVisible and FNeedUpdate then Refresh; end; @@ -732,7 +948,6 @@ var if SelectedControls.IndexOf(AControl)>=0 then exit; NewControlStr:=ControlToStr(AControl); if sl.IndexOf(NewControlStr)>=0 then exit; - //debugln('TAnchorDesigner.FillComboBoxWithSiblings.AddSibling ',NewControlStr); sl.Add(NewControlStr); Result:=true; end; @@ -766,7 +981,6 @@ begin if HasSelectedSiblings then for Kind:=akTop to akBottom do sl.add(AnchorDesignerNeighbourText(Kind)); - //debugln('TAnchorDesigner.FillComboBoxWithSiblings ',sl.Text); OldText:=AComboBox.Text; AComboBox.Items.Assign(sl); AComboBox.Text:=OldText; @@ -797,134 +1011,50 @@ end; procedure TAnchorDesigner.Refresh; var SelectedControlCount: Integer; - CurSide: TAnchorDesignerSideValues; - Sibling: String; CurSelection: TList; + AnchorKindIndex: TAnchorKind; begin - //debugln('TAnchorDesigner.Refresh A '); - // check if update is needed - if not IsVisible then begin - fNeedUpdate:=true; - exit; + // Check if update is needed + if not IsVisible then + begin + FNeedUpdate:=True; + Exit; end; - if FUpdating then exit; - FUpdating:=true; - fNeedUpdate:=false; + if FUpdating then Exit; + FUpdating:=True; + FNeedUpdate:=False; try FreeAndNil(Values); CurSelection:=GetSelectedControls; - {if (CurSelection<>nil) and (CurSelection.Count>0) then - debugln(['TAnchorDesigner.Refresh Item0=',DbgSName(TObject(CurSelection[0]))]) - else - debugln(['TAnchorDesigner.Refresh empty selection']);} - CollectValues(CurSelection,Values,SelectedControlCount); - //debugln('TAnchorDesigner.Refresh B ',dbgs(SelectedControlCount)); + CollectValues(CurSelection,Values,SelectedControlCount); // out TheValues - if (Values=nil) then begin + SetEnabledControls(Assigned(Values), [BorderSpaceGroupBox, TopGroupBox, + LeftGroupBox, RightGroupBox, BottomGroupBox]); + + if (Values=nil) then + begin Caption:=lisAnchorEditorNoControlSelected; - BorderSpaceGroupBox.Enabled:=false; - TopGroupBox.Enabled:=false; - LeftGroupBox.Enabled:=false; - RightGroupBox.Enabled:=false; - BottomGroupBox.Enabled:=false; - end else begin + end + else + begin if CurSelection.Count=1 then Caption:=Format(lisAnchorsOf,[TControl(CurSelection[0]).Name]) else Caption:=lisAnchorsOfSelectedControls; - // all + // All BorderSpaceGroupBox.Enabled:=true; if Values.AmbiguousBorderspaceAround then AroundBorderSpaceSpinEdit.Value:=-1 else AroundBorderSpaceSpinEdit.Value:=Values.BorderspaceAround; - // Top - TopGroupBox.Enabled:=true; - CurSide:=Values.Sides[akTop]; - TopAnchoredCheckBox.AllowGrayed:=CurSide.AmbiguousEnabled; - if CurSide.AmbiguousEnabled then - TopAnchoredCheckBox.State:=cbGrayed - else - TopAnchoredCheckBox.Checked:=CurSide.Enabled; - if CurSide.AmbiguousBorderSpace then - TopBorderSpaceSpinEdit.Value:=-1 - else - TopBorderSpaceSpinEdit.Value:=CurSide.BorderSpace; - TopBorderSpaceSpinEdit.ValueEmpty:=CurSide.AmbiguousBorderSpace; - Sibling:=CurSide.Sibling; - TopSiblingComboBox.Text:=Sibling; - //debugln('TAnchorDesigner.Refresh A TopSiblingComboBox.Text=',TopSiblingComboBox.Text,' Sibling=',Sibling); - FillComboBoxWithSiblings(TopSiblingComboBox); - //debugln('TAnchorDesigner.Refresh B TopSiblingComboBox.Text=',TopSiblingComboBox.Text,' Sibling=',Sibling); - TopRefBottomSpeedButton.Down:=(CurSide.Side=asrBottom); - TopRefCenterSpeedButton.Down:=(CurSide.Side=asrCenter); - TopRefTopSpeedButton.Down:=(CurSide.Side=asrTop); - - // Bottom - BottomGroupBox.Enabled:=true; - CurSide:=Values.Sides[akBottom]; - BottomAnchoredCheckBox.AllowGrayed:=CurSide.AmbiguousEnabled; - if CurSide.AmbiguousEnabled then - BottomAnchoredCheckBox.State:=cbGrayed - else - BottomAnchoredCheckBox.Checked:=CurSide.Enabled; - if CurSide.AmbiguousBorderSpace then - BottomBorderSpaceSpinEdit.Value:=-1 - else - BottomBorderSpaceSpinEdit.Value:=CurSide.BorderSpace; - BottomBorderSpaceSpinEdit.ValueEmpty:=CurSide.AmbiguousBorderSpace; - Sibling:=CurSide.Sibling; - BottomSiblingComboBox.Text:=Sibling; - FillComboBoxWithSiblings(BottomSiblingComboBox); - BottomRefBottomSpeedButton.Down:=(CurSide.Side=asrBottom); - BottomRefCenterSpeedButton.Down:=(CurSide.Side=asrCenter); - BottomRefTopSpeedButton.Down:=(CurSide.Side=asrTop); - - // Left - LeftGroupBox.Enabled:=true; - CurSide:=Values.Sides[akLeft]; - LeftAnchoredCheckBox.AllowGrayed:=CurSide.AmbiguousEnabled; - if CurSide.AmbiguousEnabled then - LeftAnchoredCheckBox.State:=cbGrayed - else - LeftAnchoredCheckBox.Checked:=CurSide.Enabled; - if CurSide.AmbiguousBorderSpace then - LeftBorderSpaceSpinEdit.Value:=-1 - else - LeftBorderSpaceSpinEdit.Value:=CurSide.BorderSpace; - LeftBorderSpaceSpinEdit.ValueEmpty:=CurSide.AmbiguousBorderSpace; - Sibling:=CurSide.Sibling; - LeftSiblingComboBox.Text:=Sibling; - FillComboBoxWithSiblings(LeftSiblingComboBox); - LeftRefRightSpeedButton.Down:=(CurSide.Side=asrBottom); - LeftRefCenterSpeedButton.Down:=(CurSide.Side=asrCenter); - LeftRefLeftSpeedButton.Down:=(CurSide.Side=asrTop); - - // Right - RightGroupBox.Enabled:=true; - CurSide:=Values.Sides[akRight]; - RightAnchoredCheckBox.AllowGrayed:=CurSide.AmbiguousEnabled; - if CurSide.AmbiguousEnabled then - RightAnchoredCheckBox.State:=cbGrayed - else - RightAnchoredCheckBox.Checked:=CurSide.Enabled; - if CurSide.AmbiguousBorderSpace then - RightBorderSpaceSpinEdit.Value:=-1 - else - RightBorderSpaceSpinEdit.Value:=CurSide.BorderSpace; - RightBorderSpaceSpinEdit.ValueEmpty:=CurSide.AmbiguousBorderSpace; - Sibling:=CurSide.Sibling; - RightSiblingComboBox.Text:=Sibling; - FillComboBoxWithSiblings(RightSiblingComboBox); - RightRefRightSpeedButton.Down:=(CurSide.Side=asrBottom); - RightRefCenterSpeedButton.Down:=(CurSide.Side=asrCenter); - RightRefLeftSpeedButton.Down:=(CurSide.Side=asrTop); + // Sides + for AnchorKindIndex:=Low(AnchorKindIndex) to High(AnchorKindIndex) do + FSideControls[AnchorKindIndex].Refresh(Values.Sides[AnchorKindIndex]); end; - UpdateFrames; finally - FUpdating:=false; + FUpdating:=False; end; end; @@ -942,7 +1072,7 @@ begin Result:=nil; GlobalDesignHook.GetSelection(FSelection); if FSelection=nil then exit; - // collect values of selected controls + // Collect values of selected controls for i:=0 to FSelection.Count-1 do begin CurPersistent:=FSelection[i]; if CurPersistent is TControl then begin @@ -1003,12 +1133,10 @@ var begin TheValues:=nil; SelectedControlCount:=0; - //debugln('TAnchorDesigner.CollectValues A '); if ASelection=nil then exit; - // collect values of selected controls + // Collect values of selected controls for i:=0 to ASelection.Count-1 do begin CurObject:=TObject(ASelection[i]); - //debugln('TAnchorDesigner.CollectValues B ',dbgs(i),' ',DbgSName(CurObject)); if CurObject is TControl then begin AControl:=TControl(CurObject); if SelectedControlCount=0 then begin @@ -1022,18 +1150,6 @@ begin end; end; -procedure TAnchorDesigner.UpdateFrames; -begin - UpdateFrame(TopShape, TopAnchoredCheckBox, - [TopRefTopSpeedButton, TopRefCenterSpeedButton, TopRefBottomSpeedButton]); - UpdateFrame(LeftShape, LeftAnchoredCheckBox, - [LeftRefLeftSpeedButton, LeftRefCenterSpeedButton, LeftRefRightSpeedButton]); - UpdateFrame(BottomShape, BottomAnchoredCheckBox, - [BottomRefTopSpeedButton, BottomRefCenterSpeedButton, BottomRefBottomSpeedButton]); - UpdateFrame(RightShape, RightAnchoredCheckBox, - [RightRefLeftSpeedButton, RightRefCenterSpeedButton, RightRefRightSpeedButton]); -end; - procedure TAnchorDesigner.OnSetSelection( const ASelection: TPersistentSelectionList); begin @@ -1100,6 +1216,18 @@ end; { TAnchorDesignerSideValues } +function TAnchorDesignerSideValues.GetSideRef_IsAmbiguous: Boolean; +var + SideRefIndex: TAnchorSideReference; + n: Integer; +begin + n:=0; + for SideRefIndex:=Low(SideRefIndex) to High(SideRefIndex) do + if (SideRefIndex in FSideRefs) + then Inc(n); + Result:=(n>1); +end; + constructor TAnchorDesignerSideValues.Create(TheKind: TAnchorKind); begin FAnchorKind:=TheKind; @@ -1109,14 +1237,14 @@ procedure TAnchorDesignerSideValues.SetValues(AControl: TControl); var CurSide: TAnchorSide; begin - FAmbiguousBorderSpace:=false; + FCount:=1; + FBorderSpace_IsAmbiguous:=false; FBorderSpace:=AControl.BorderSpacing.GetSpace(FAnchorKind); - FAmbiguousEnabled:=false; + FEnabled_IsAmbiguous:=false; FEnabled:=(FAnchorKind in AControl.Anchors); CurSide:=AControl.AnchorSide[FAnchorKind]; - FAmbiguousSide:=false; - FSide:=CurSide.Side; - FAmbiguousSibling:=false; + FSideRefs:=[CurSide.Side]; + FSibling_IsAmbiguous:=false; FSibling:=TAnchorDesigner.ControlToStr(CurSide.Control); end; @@ -1124,14 +1252,15 @@ procedure TAnchorDesignerSideValues.MergeValues(AControl: TControl); var CurSide: TAnchorSide; begin - FAmbiguousBorderSpace:=FAmbiguousBorderSpace - or (FBorderSpace<>AControl.BorderSpacing.GetSpace(FAnchorKind)); - FAmbiguousEnabled:=FAmbiguousEnabled - or (FEnabled<>(FAnchorKind in AControl.Anchors)); + Inc(FCount); + FBorderSpace_IsAmbiguous:=FBorderSpace_IsAmbiguous + or (FBorderSpace<>AControl.BorderSpacing.GetSpace(FAnchorKind)); + FEnabled_IsAmbiguous:=FEnabled_IsAmbiguous + or (FEnabled<>(FAnchorKind in AControl.Anchors)); CurSide:=AControl.AnchorSide[FAnchorKind]; - FAmbiguousSide:=FAmbiguousSide or (CurSide.Side<>FSide); - FAmbiguousSibling:=FAmbiguousSibling - or (TAnchorDesigner.ControlToStr(CurSide.Control)<>FSibling); + FSibling_IsAmbiguous:=FSibling_IsAmbiguous + or (TAnchorDesigner.ControlToStr(CurSide.Control)<>FSibling); + FSideRefs:=FSideRefs+[CurSide.Side]; end; { TAnchorPropertyEditor } @@ -1148,7 +1277,7 @@ end; initialization RegisterPropertyEditor(TypeInfo(TAnchors), TControl, 'Anchors', - TAnchorPropertyEditor); + TAnchorPropertyEditor); end.