mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-07 14:16:03 +02:00
MUI: fixed position of Checkmark and radio button label
git-svn-id: trunk@54471 -
This commit is contained in:
parent
d5881ef02e
commit
63a3095b0d
@ -50,6 +50,7 @@ type
|
|||||||
|
|
||||||
TMuiCheckMark = class(TMuiArea)
|
TMuiCheckMark = class(TMuiArea)
|
||||||
protected
|
protected
|
||||||
|
FCheckWidth: Integer;
|
||||||
FullWidth: Integer;
|
FullWidth: Integer;
|
||||||
CheckLabel: TMuiText;
|
CheckLabel: TMuiText;
|
||||||
procedure SetParent(const AValue: TMUIObject); override;
|
procedure SetParent(const AValue: TMUIObject); override;
|
||||||
@ -66,6 +67,7 @@ type
|
|||||||
public
|
public
|
||||||
constructor Create(const Params: TAParamList); overload; reintroduce; virtual;
|
constructor Create(const Params: TAParamList); overload; reintroduce; virtual;
|
||||||
destructor Destroy; override;
|
destructor Destroy; override;
|
||||||
|
procedure SetOwnSize; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TMuiRadioButton }
|
{ TMuiRadioButton }
|
||||||
@ -845,9 +847,15 @@ var
|
|||||||
ObjType: LongInt;
|
ObjType: LongInt;
|
||||||
begin
|
begin
|
||||||
if self is TMUIRadioButton then
|
if self is TMUIRadioButton then
|
||||||
|
begin
|
||||||
|
FCheckWidth := 16;
|
||||||
ObjType := MUIO_Radio
|
ObjType := MUIO_Radio
|
||||||
|
end
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
|
FCheckWidth := 20;
|
||||||
ObjType := MUIO_Checkmark;
|
ObjType := MUIO_Checkmark;
|
||||||
|
end;
|
||||||
if ObjType = MUIO_Radio then
|
if ObjType = MUIO_Radio then
|
||||||
begin
|
begin
|
||||||
Tags.AddTags([
|
Tags.AddTags([
|
||||||
@ -912,37 +920,23 @@ procedure TMuiCheckMark.SetTop(ATop: Integer);
|
|||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
if Assigned(CheckLabel) then
|
if Assigned(CheckLabel) then
|
||||||
begin
|
CheckLabel.Top := Top + (FCheckWidth div 2 - CheckLabel.Height div 2);
|
||||||
CheckLabel.Top := Top;
|
|
||||||
end;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMuiCheckMark.SetWidth(AWidth: Integer);
|
procedure TMuiCheckMark.SetWidth(AWidth: Integer);
|
||||||
begin
|
begin
|
||||||
FullWidth := AWidth;
|
FullWidth := AWidth;
|
||||||
if Self is TMUIRadioButton then
|
inherited SetWidth(FCheckWidth);
|
||||||
begin
|
|
||||||
inherited SetWidth(16);
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
inherited SetWidth(20);
|
|
||||||
end;
|
|
||||||
if Assigned(CheckLabel) and (CheckLabel.Visible) then
|
if Assigned(CheckLabel) and (CheckLabel.Visible) then
|
||||||
begin
|
begin
|
||||||
CheckLabel.Left := Left + Height + 2;
|
CheckLabel.Left := Left + FCheckWidth + 2;
|
||||||
CheckLabel.Width := FullWidth - (Height + 2);
|
CheckLabel.Width := FullWidth - (FCheckWidth + 2);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TMuiCheckMark.SetHeight(AHeight: Integer);
|
procedure TMuiCheckMark.SetHeight(AHeight: Integer);
|
||||||
begin
|
begin
|
||||||
if Self is TMUIRadioButton then
|
inherited SetHeight(FCheckWidth);
|
||||||
begin
|
|
||||||
inherited SetHeight(16);
|
|
||||||
end else
|
|
||||||
begin
|
|
||||||
inherited SetHeight(20);
|
|
||||||
end;
|
|
||||||
SetWidth(FullWidth);
|
SetWidth(FullWidth);
|
||||||
if Assigned(CheckLabel) and (CheckLabel.Visible) then
|
if Assigned(CheckLabel) and (CheckLabel.Visible) then
|
||||||
CheckLabel.Height := Height;
|
CheckLabel.Height := Height;
|
||||||
@ -953,6 +947,44 @@ begin
|
|||||||
Result := FullWidth;
|
Result := FullWidth;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TMuiCheckMark.SetOwnSize;
|
||||||
|
var
|
||||||
|
w: Integer;
|
||||||
|
MinMax: TMUI_MinMax;
|
||||||
|
begin
|
||||||
|
// try to get current Width from the Item
|
||||||
|
w := GetAttribute(MUIA_Width);
|
||||||
|
// ups Width is zero -> inital Size so we ask for min max
|
||||||
|
if w = 0 then
|
||||||
|
begin
|
||||||
|
// ask the checkmark for min max
|
||||||
|
FillChar(MinMax, SizeOf(MinMax), 0);
|
||||||
|
DoMethod([MUIM_AskMinMax, NativeUInt(@MinMax)]);
|
||||||
|
// in principle we only want the width
|
||||||
|
w := MinMax.DefWidth;
|
||||||
|
end;
|
||||||
|
// better recheck if the width and height is really set
|
||||||
|
if w > 0 then
|
||||||
|
begin
|
||||||
|
// strange on Amiga the height is sometimes the Height = 0
|
||||||
|
// sadly read the MinMax does not work always return 0, so we just put a default here
|
||||||
|
if CheckLabel.Height = 0 then
|
||||||
|
CheckLabel.Height := 16;
|
||||||
|
FCheckWidth := w;
|
||||||
|
// set the coords for the label
|
||||||
|
if Assigned(CheckLabel) and (CheckLabel.Visible) then
|
||||||
|
begin
|
||||||
|
CheckLabel.Left := Left + FCheckWidth + 2;
|
||||||
|
CheckLabel.Width := FullWidth - (FCheckWidth + 2);
|
||||||
|
CheckLabel.Top := Top + w div 2 - CheckLabel.Height div 2;
|
||||||
|
// lets do it :-)
|
||||||
|
CheckLabel.SetOwnSize;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
// let the checkmark set its size
|
||||||
|
inherited;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TMuiCheckMark.SetVisible(const AValue: Boolean);
|
procedure TMuiCheckMark.SetVisible(const AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
inherited;
|
inherited;
|
||||||
|
Loading…
Reference in New Issue
Block a user