mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2026-01-04 18:30:32 +01:00
added showing all four sides to AnchorEditor
git-svn-id: trunk@6620 -
This commit is contained in:
parent
e44cb55cf6
commit
be9331e1ba
@ -140,6 +140,8 @@ type
|
||||
FSelection: TPersistentSelectionList;
|
||||
protected
|
||||
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
|
||||
procedure FillComboBoxWithSiblings(AComboBox: TComboBox);
|
||||
function AnchorDesignerNoSiblingText: string;
|
||||
public
|
||||
SrcTypeImageList: TImageList;
|
||||
procedure Refresh(Force: boolean);
|
||||
@ -151,7 +153,7 @@ type
|
||||
procedure OnSetSelection(const ASelection: TPersistentSelectionList);
|
||||
property Selection: TPersistentSelectionList read FSelection;
|
||||
end;
|
||||
|
||||
|
||||
var
|
||||
AnchorDesigner: TAnchorDesigner;
|
||||
|
||||
@ -243,18 +245,15 @@ begin
|
||||
end;
|
||||
|
||||
// autosizing
|
||||
BottomSiblingLabel.AnchorSide[akLeft].Side:=asrRight;
|
||||
BottomSiblingLabel.BorderSpacing.Left:=10;
|
||||
BottomSiblingLabel.AnchorSide[akLeft].Control:=BottomAnchoredCheckBox;
|
||||
BottomSiblingComboBox.AnchorSide[akLeft].Side:=asrRight;
|
||||
BottomSiblingComboBox.AnchorSide[akLeft].Control:=BottomSiblingLabel;
|
||||
TopSiblingLabel.AnchorSide[akLeft].Side:=asrRight;
|
||||
TopSiblingLabel.BorderSpacing.Left:=BottomSiblingLabel.BorderSpacing.Left;
|
||||
TopSiblingLabel.AnchorSide[akLeft].Control:=TopAnchoredCheckBox;
|
||||
TopSiblingComboBox.AnchorSide[akLeft].Side:=asrRight;
|
||||
TopSiblingComboBox.AnchorSide[akLeft].Control:=TopSiblingLabel;
|
||||
|
||||
|
||||
BottomSiblingLabel.AnchorToNeighbour(akLeft,10,BottomAnchoredCheckBox);
|
||||
BottomSiblingComboBox.AnchorToNeighbour(akLeft,5,BottomSiblingLabel);
|
||||
BottomSiblingLabel.AnchorVerticalCenterTo(BottomSiblingComboBox);
|
||||
BottomAnchoredCheckBox.AnchorVerticalCenterTo(BottomSiblingComboBox);
|
||||
TopSiblingLabel.AnchorToNeighbour(akLeft,10,TopAnchoredCheckBox);
|
||||
TopSiblingComboBox.AnchorToNeighbour(akLeft,5,TopSiblingLabel);
|
||||
TopSiblingLabel.AnchorVerticalCenterTo(TopSiblingComboBox);
|
||||
TopAnchoredCheckBox.AnchorVerticalCenterTo(TopSiblingComboBox);
|
||||
|
||||
GlobalDesignHook.AddHandlerRefreshPropertyValues(@OnRefreshPropertyValues);
|
||||
GlobalDesignHook.AddHandlerSetSelection(@OnSetSelection);
|
||||
end;
|
||||
@ -262,7 +261,7 @@ end;
|
||||
procedure TAnchorDesigner.AnchorDesignerDestroy(Sender: TObject);
|
||||
begin
|
||||
GlobalDesignHook.RemoveAllHandlersForObject(Self);
|
||||
FreeThenNil(FSelection);
|
||||
FreeAndNil(FSelection);
|
||||
end;
|
||||
|
||||
procedure TAnchorDesigner.AnchorDesignerShow(Sender: TObject);
|
||||
@ -276,6 +275,40 @@ begin
|
||||
ExecuteIDECommand(Self,Key,Shift,caMenuOnly);
|
||||
end;
|
||||
|
||||
procedure TAnchorDesigner.FillComboBoxWithSiblings(AComboBox: TComboBox);
|
||||
var
|
||||
sl: TStringList;
|
||||
i: Integer;
|
||||
CurControl: TControl;
|
||||
j: Integer;
|
||||
Sibling: TControl;
|
||||
begin
|
||||
sl:=TStringList.Create;
|
||||
sl.Add(AnchorDesignerNoSiblingText);
|
||||
if FSelection<>nil then begin
|
||||
for i:=0 to FSelection.Count-1 do begin
|
||||
if FSelection[i] is TControl then begin
|
||||
CurControl:=TControl(FSelection[i]);
|
||||
if CurControl.Parent<>nil then begin
|
||||
for j:=0 to CurControl.Parent.ControlCount-1 do begin
|
||||
Sibling:=CurControl.Parent.Controls[j];
|
||||
if Sibling<>CurControl then
|
||||
sl.Add(ControlToStr(Sibling));
|
||||
end;
|
||||
end;
|
||||
break;
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
AComboBox.Items.Assign(sl);
|
||||
sl.Free;
|
||||
end;
|
||||
|
||||
function TAnchorDesigner.AnchorDesignerNoSiblingText: string;
|
||||
begin
|
||||
Result:='(parent borders)';
|
||||
end;
|
||||
|
||||
procedure TAnchorDesigner.Refresh(Force: boolean);
|
||||
var
|
||||
SelectedControlCount: Integer;
|
||||
@ -294,17 +327,25 @@ begin
|
||||
CollectValues(FSelection,Values,SelectedControlCount);
|
||||
debugln('TAnchorDesigner.Refresh B ',dbgs(SelectedControlCount));
|
||||
|
||||
LeftGroupBox.Enabled:=false;
|
||||
RightGroupBox.Enabled:=false;
|
||||
BottomGroupBox.Enabled:=false;
|
||||
|
||||
if (Values=nil) then begin
|
||||
Caption:='Anchor Editor - no control selected';
|
||||
TopGroupBox.Enabled:=false;
|
||||
LeftGroupBox.Enabled:=false;
|
||||
RightGroupBox.Enabled:=false;
|
||||
BottomGroupBox.Enabled:=false;
|
||||
end else begin
|
||||
Caption:='Anchors of selected controls';
|
||||
|
||||
// all
|
||||
if Values.AmbigiousBorderspaceAround then
|
||||
AroundBorderSpaceSpinEdit.Value:=-1
|
||||
else
|
||||
AroundBorderSpaceSpinEdit.Value:=Values.BorderspaceAround;
|
||||
|
||||
// Top
|
||||
TopGroupBox.Enabled:=true;
|
||||
CurSide:=Values.Sides[akTop];
|
||||
TopAnchoredCheckBox.AllowGrayed:=CurSide.AmbigiousEnabled;
|
||||
if CurSide.AmbigiousEnabled then
|
||||
TopAnchoredCheckBox.State:=cbGrayed
|
||||
else
|
||||
@ -313,14 +354,85 @@ begin
|
||||
TopBorderSpaceSpinEdit.Value:=-1
|
||||
else
|
||||
TopBorderSpaceSpinEdit.Value:=CurSide.BorderSpace;
|
||||
TopBorderSpaceSpinEdit.ValueEmpty:=CurSide.AmbigiousBorderSpace;
|
||||
Sibling:=CurSide.Sibling;
|
||||
TopSiblingComboBox.Text:=Sibling;
|
||||
FillComboBoxWithSiblings(TopSiblingComboBox);
|
||||
TopRefBottomSpeedButton.Enabled:=Sibling<>'';
|
||||
TopRefBottomSpeedButton.Down:=(CurSide.Side=asrBottom);
|
||||
TopRefCenterSpeedButton.Enabled:=Sibling<>'';
|
||||
TopRefCenterSpeedButton.Down:=(CurSide.Side=asrCenter);
|
||||
TopRefTopSpeedButton.Enabled:=Sibling<>'';
|
||||
TopRefTopSpeedButton.Down:=(CurSide.Side=asrTop);
|
||||
|
||||
// Bottom
|
||||
BottomGroupBox.Enabled:=true;
|
||||
CurSide:=Values.Sides[akBottom];
|
||||
BottomAnchoredCheckBox.AllowGrayed:=CurSide.AmbigiousEnabled;
|
||||
if CurSide.AmbigiousEnabled then
|
||||
BottomAnchoredCheckBox.State:=cbGrayed
|
||||
else
|
||||
BottomAnchoredCheckBox.Checked:=CurSide.Enabled;
|
||||
if CurSide.AmbigiousBorderSpace then
|
||||
BottomBorderSpaceSpinEdit.Value:=-1
|
||||
else
|
||||
BottomBorderSpaceSpinEdit.Value:=CurSide.BorderSpace;
|
||||
BottomBorderSpaceSpinEdit.ValueEmpty:=CurSide.AmbigiousBorderSpace;
|
||||
Sibling:=CurSide.Sibling;
|
||||
BottomSiblingComboBox.Text:=Sibling;
|
||||
FillComboBoxWithSiblings(BottomSiblingComboBox);
|
||||
BottomRefBottomSpeedButton.Enabled:=Sibling<>'';
|
||||
BottomRefBottomSpeedButton.Down:=(CurSide.Side=asrBottom);
|
||||
BottomRefCenterSpeedButton.Enabled:=Sibling<>'';
|
||||
BottomRefCenterSpeedButton.Down:=(CurSide.Side=asrCenter);
|
||||
BottomRefTopSpeedButton.Enabled:=Sibling<>'';
|
||||
BottomRefTopSpeedButton.Down:=(CurSide.Side=asrTop);
|
||||
|
||||
// Left
|
||||
LeftGroupBox.Enabled:=true;
|
||||
CurSide:=Values.Sides[akLeft];
|
||||
LeftAnchoredCheckBox.AllowGrayed:=CurSide.AmbigiousEnabled;
|
||||
if CurSide.AmbigiousEnabled then
|
||||
LeftAnchoredCheckBox.State:=cbGrayed
|
||||
else
|
||||
LeftAnchoredCheckBox.Checked:=CurSide.Enabled;
|
||||
if CurSide.AmbigiousBorderSpace then
|
||||
LeftBorderSpaceSpinEdit.Value:=-1
|
||||
else
|
||||
LeftBorderSpaceSpinEdit.Value:=CurSide.BorderSpace;
|
||||
LeftBorderSpaceSpinEdit.ValueEmpty:=CurSide.AmbigiousBorderSpace;
|
||||
Sibling:=CurSide.Sibling;
|
||||
LeftSiblingComboBox.Text:=Sibling;
|
||||
FillComboBoxWithSiblings(LeftSiblingComboBox);
|
||||
LeftRefRightSpeedButton.Enabled:=Sibling<>'';
|
||||
LeftRefRightSpeedButton.Down:=(CurSide.Side=asrBottom);
|
||||
LeftRefCenterSpeedButton.Enabled:=Sibling<>'';
|
||||
LeftRefCenterSpeedButton.Down:=(CurSide.Side=asrCenter);
|
||||
LeftRefLeftSpeedButton.Enabled:=Sibling<>'';
|
||||
LeftRefLeftSpeedButton.Down:=(CurSide.Side=asrTop);
|
||||
|
||||
// Right
|
||||
RightGroupBox.Enabled:=true;
|
||||
CurSide:=Values.Sides[akRight];
|
||||
RightAnchoredCheckBox.AllowGrayed:=CurSide.AmbigiousEnabled;
|
||||
if CurSide.AmbigiousEnabled then
|
||||
RightAnchoredCheckBox.State:=cbGrayed
|
||||
else
|
||||
RightAnchoredCheckBox.Checked:=CurSide.Enabled;
|
||||
if CurSide.AmbigiousBorderSpace then
|
||||
RightBorderSpaceSpinEdit.Value:=-1
|
||||
else
|
||||
RightBorderSpaceSpinEdit.Value:=CurSide.BorderSpace;
|
||||
RightBorderSpaceSpinEdit.ValueEmpty:=CurSide.AmbigiousBorderSpace;
|
||||
Sibling:=CurSide.Sibling;
|
||||
RightSiblingComboBox.Text:=Sibling;
|
||||
FillComboBoxWithSiblings(RightSiblingComboBox);
|
||||
RightRefRightSpeedButton.Enabled:=Sibling<>'';
|
||||
RightRefRightSpeedButton.Down:=(CurSide.Side=asrBottom);
|
||||
RightRefCenterSpeedButton.Enabled:=Sibling<>'';
|
||||
RightRefCenterSpeedButton.Down:=(CurSide.Side=asrCenter);
|
||||
RightRefLeftSpeedButton.Enabled:=Sibling<>'';
|
||||
RightRefLeftSpeedButton.Down:=(CurSide.Side=asrTop);
|
||||
end;
|
||||
finally
|
||||
Values.Free;
|
||||
|
||||
@ -1134,6 +1134,10 @@ type
|
||||
ExceptionOnInvalid: boolean): boolean;
|
||||
procedure CheckNewParent(AParent: TWinControl); virtual;
|
||||
procedure SendToBack;
|
||||
procedure AnchorToNeighbour(Side: TAnchorKind; Space: integer;
|
||||
Sibling: TControl);
|
||||
procedure AnchorHorizontalCenterTo(Sibling: TControl);
|
||||
procedure AnchorVerticalCenterTo(Sibling: TControl);
|
||||
procedure SetTempCursor(Value: TCursor);
|
||||
procedure UpdateRolesForForm; virtual;
|
||||
procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); virtual;
|
||||
@ -2816,6 +2820,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.267 2005/01/17 11:53:39 mattias
|
||||
added showing all four sides to AnchorEditor
|
||||
|
||||
Revision 1.266 2005/01/13 22:07:10 mattias
|
||||
added mouse cursors for 8 uni directions, imlemented for gtk
|
||||
|
||||
|
||||
@ -4,8 +4,8 @@
|
||||
graphtype.pp
|
||||
------------
|
||||
Graphic related platform independent types
|
||||
and utility functions.
|
||||
Initial Revision : Sat Feb 02 0:02:58 2002
|
||||
and utility functions.
|
||||
Initial Revision : Sat Feb 02 0:02:58 2002
|
||||
|
||||
***************************************************************************/
|
||||
|
||||
@ -775,6 +775,9 @@ end.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.35 2005/01/17 11:53:39 mattias
|
||||
added showing all four sides to AnchorEditor
|
||||
|
||||
Revision 1.34 2004/12/11 01:28:58 mattias
|
||||
implemented bvSpace of TBevelCut
|
||||
|
||||
|
||||
@ -3285,6 +3285,51 @@ begin
|
||||
SetZOrder(false);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TControl.AnchorToNeighbour(Side: TAnchorKind; Space: integer;
|
||||
Sibling: TControl);
|
||||
|
||||
Setup AnchorSide to anchor one side to the side of a neighbour sibling.
|
||||
For example Right side to Left side, or Top side to Bottom.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.AnchorToNeighbour(Side: TAnchorKind; Space: integer;
|
||||
Sibling: TControl);
|
||||
begin
|
||||
case Side of
|
||||
akLeft: BorderSpacing.Left:=Space;
|
||||
akTop: BorderSpacing.Top:=Space;
|
||||
akRight: BorderSpacing.Right:=Space;
|
||||
akBottom: BorderSpacing.Bottom:=Space;
|
||||
end;
|
||||
AnchorSide[Side].Side:=DefaultSideForAnchorKind[Side];
|
||||
AnchorSide[Side].Control:=Sibling;
|
||||
Anchors:=Anchors+[Side];
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TControl.AnchorHorizontalCenterTo(Sibling: TControl);
|
||||
|
||||
Setup AnchorSide to center the control horizontally relative to a sibling.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.AnchorHorizontalCenterTo(Sibling: TControl);
|
||||
begin
|
||||
AnchorSide[akLeft].Side:=asrCenter;
|
||||
AnchorSide[akLeft].Control:=Sibling;
|
||||
Anchors:=Anchors+[akLeft]-[akRight];
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
procedure TControl.AnchorVerticalCenterTo(Sibling: TControl);
|
||||
|
||||
Setup AnchorSide to center the control vertically relative to a sibling.
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TControl.AnchorVerticalCenterTo(Sibling: TControl);
|
||||
begin
|
||||
AnchorSide[akTop].Side:=asrCenter;
|
||||
AnchorSide[akTop].Control:=Sibling;
|
||||
Anchors:=Anchors+[akTop]-[akBottom];
|
||||
end;
|
||||
|
||||
procedure TControl.SetInitialBounds(aLeft, aTop, aWidth, aHeight: integer);
|
||||
begin
|
||||
//DebugLn('TControl.SetInitialBounds A ',Name,':',ClassName,' ',aLeft,',',aTop,',',aWidth,',',aHeight);
|
||||
@ -3432,6 +3477,9 @@ end;
|
||||
|
||||
{ =============================================================================
|
||||
$Log$
|
||||
Revision 1.236 2005/01/17 11:53:39 mattias
|
||||
added showing all four sides to AnchorEditor
|
||||
|
||||
Revision 1.235 2005/01/13 20:21:41 mattias
|
||||
added desgntime check for TControl.Width/Height for high values
|
||||
|
||||
|
||||
@ -41,6 +41,7 @@ begin
|
||||
if Value=fLastValueOnChange then exit;
|
||||
fLastValueOnChange:=Value;
|
||||
Modified := True;
|
||||
FValueEmpty:=false;
|
||||
if HandleAllocated and (not (csLoading in ComponentState)) then Change;
|
||||
end;
|
||||
|
||||
@ -129,7 +130,14 @@ begin
|
||||
Text:=NewText;
|
||||
end;
|
||||
|
||||
procedure TCustomSpinEdit.SetClimbRate(Num : Single);
|
||||
procedure TCustomSpinEdit.SetValueEmpty(const AValue: boolean);
|
||||
begin
|
||||
if FValueEmpty=AValue then exit;
|
||||
FValueEmpty:=AValue;
|
||||
UpdateControl;
|
||||
end;
|
||||
|
||||
procedure TCustomSpinEdit.SetClimbRate(const Num : Single);
|
||||
begin
|
||||
if fClimbRate = Num then exit;
|
||||
fClimbRate := Num;
|
||||
@ -164,7 +172,7 @@ begin
|
||||
end;
|
||||
|
||||
{-----------------------------------------------------------------------------}
|
||||
Procedure TCustomSpinEdit.SetValue(num : Single);
|
||||
Procedure TCustomSpinEdit.SetValue(const num : Single);
|
||||
begin
|
||||
if FValue = Num then exit;
|
||||
FValue := Num;
|
||||
|
||||
@ -81,6 +81,9 @@ end;
|
||||
|
||||
{ TGtkWSCustomSpinEdit }
|
||||
|
||||
//const
|
||||
// GtkValueEmpty: array[boolean] of integer = (0,1);
|
||||
|
||||
function TGtkWSCustomSpinEdit.GetSelStart(const ACustomSpinEdit: TCustomSpinEdit
|
||||
): integer;
|
||||
begin
|
||||
@ -118,10 +121,11 @@ procedure TGtkWSCustomSpinEdit.UpdateControl(
|
||||
var
|
||||
AnAdjustment: PGtkAdjustment;
|
||||
wHandle: HWND;
|
||||
SpinWidget: PGtkSpinButton;
|
||||
begin
|
||||
wHandle := ACustomSpinEdit.Handle;
|
||||
AnAdjustment:=
|
||||
gtk_spin_button_get_adjustment(GTK_SPIN_BUTTON(Pointer(wHandle)));
|
||||
SpinWidget:=GTK_SPIN_BUTTON(Pointer(wHandle));
|
||||
AnAdjustment:=gtk_spin_button_get_adjustment(SpinWidget);
|
||||
if (AnAdjustment^.lower<>ACustomSpinEdit.MinValue)
|
||||
or (AnAdjustment^.upper<>ACustomSpinEdit.MaxValue) then
|
||||
begin
|
||||
@ -129,11 +133,11 @@ begin
|
||||
AnAdjustment^.upper:=ACustomSpinEdit.MaxValue;
|
||||
gtk_adjustment_changed(AnAdjustment);
|
||||
end;
|
||||
gtk_spin_button_set_digits(GTK_SPIN_BUTTON(Pointer(wHandle)),
|
||||
ACustomSpinEdit.Decimal_Places);
|
||||
gtk_spin_button_set_value(GTK_SPIN_BUTTON(Pointer(wHandle)),
|
||||
ACustomSpinEdit.Value);
|
||||
GTK_SPIN_BUTTON(Pointer(wHandle))^.climb_rate:=ACustomSpinEdit.Climb_Rate;
|
||||
gtk_spin_button_set_digits(SpinWidget,ACustomSpinEdit.Decimal_Places);
|
||||
gtk_spin_button_set_value(SpinWidget,ACustomSpinEdit.Value);
|
||||
//gtk_object_set_data(PGtkObject(SpinWidget), 'Empty',
|
||||
// Pointer(GtkValueEmpty[ACustomSpinEdit.ValueEmpty]));
|
||||
SpinWidget^.climb_rate:=ACustomSpinEdit.Climb_Rate;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
@ -47,6 +47,7 @@ type
|
||||
FSelLength: integer;
|
||||
FSelStart: integer;
|
||||
fValue: Single;
|
||||
FValueEmpty: boolean;
|
||||
fValueNeedsUpdate: boolean;
|
||||
function Climb_RateIsStored: boolean;
|
||||
function GetModified: Boolean;
|
||||
@ -61,14 +62,15 @@ type
|
||||
procedure SetSelLength(const AValue: integer);
|
||||
procedure SetSelStart(const AValue: integer);
|
||||
procedure SetSelText(const AValue: String);
|
||||
procedure SetValueEmpty(const AValue: boolean);
|
||||
Procedure UpdateControl;
|
||||
function ValueIsStored: boolean;
|
||||
protected
|
||||
procedure CMTextChanged(Var Message: TLMessage); message CM_TextChanged;
|
||||
procedure SetDecimals(Num: Integer);
|
||||
Function GetValue: Single;
|
||||
procedure SetValue(Num: Single);
|
||||
procedure SetClimbRate(Num: Single);
|
||||
procedure SetValue(const Num: Single);
|
||||
procedure SetClimbRate(const Num: Single);
|
||||
procedure InitializeWnd; override;
|
||||
procedure Loaded; override;
|
||||
procedure Change; dynamic;
|
||||
@ -87,12 +89,13 @@ type
|
||||
property Modified: Boolean read GetModified write SetModified;
|
||||
property OnChange: TNotifyEvent read FOnChange write FOnChange;
|
||||
property Text;
|
||||
published
|
||||
public
|
||||
property Decimal_Places: Integer read fDecimals write SetDecimals default 2;
|
||||
property Climb_Rate : Single read fClimbRate write SetClimbRate stored Climb_RateIsStored;
|
||||
property MinValue: single read FMinValue write SetMinValue stored MinValueIsStored;
|
||||
property MaxValue: single read FMaxValue write SetMaxValue stored MaxValueIsStored;
|
||||
property Value: Single read GetValue write SetValue stored ValueIsStored;
|
||||
property ValueEmpty: boolean read FValueEmpty write SetValueEmpty default False;
|
||||
end;
|
||||
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user