mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-14 12:00:02 +02:00
git-svn-id: trunk@8172 -
This commit is contained in:
parent
baf1edce64
commit
b30e640082
@ -641,9 +641,11 @@ type
|
|||||||
procedure Changed(Sender: TObject);
|
procedure Changed(Sender: TObject);
|
||||||
procedure ItemEnter(Sender: TObject);
|
procedure ItemEnter(Sender: TObject);
|
||||||
procedure DoPositionButtons;
|
procedure DoPositionButtons;
|
||||||
|
procedure DoSetTabStops;
|
||||||
procedure SetAutoFill(const AValue: Boolean);
|
procedure SetAutoFill(const AValue: Boolean);
|
||||||
procedure SetColumnLayout(const AValue: TColumnLayout);
|
procedure SetColumnLayout(const AValue: TColumnLayout);
|
||||||
procedure ItemExit(Sender: TObject);
|
procedure ItemExit(Sender: TObject);
|
||||||
|
procedure ItemKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
|
||||||
procedure ItemResize(Sender: TObject);
|
procedure ItemResize(Sender: TObject);
|
||||||
protected
|
protected
|
||||||
procedure UpdateRadioButtonStates; virtual;
|
procedure UpdateRadioButtonStates; virtual;
|
||||||
@ -667,6 +669,7 @@ type
|
|||||||
property Columns: integer read FColumns write SetColumns default 1;
|
property Columns: integer read FColumns write SetColumns default 1;
|
||||||
property ColumnLayout: TColumnLayout read FColumnLayout write SetColumnLayout default clHorizontalThenVertical;
|
property ColumnLayout: TColumnLayout read FColumnLayout write SetColumnLayout default clHorizontalThenVertical;
|
||||||
property OnClick: TNotifyEvent read FOnClick write FOnClick;
|
property OnClick: TNotifyEvent read FOnClick write FOnClick;
|
||||||
|
property TabStop default True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
@ -72,6 +72,7 @@ begin
|
|||||||
FColumns := 1;
|
FColumns := 1;
|
||||||
FColumnLayout := clHorizontalThenVertical;
|
FColumnLayout := clHorizontalThenVertical;
|
||||||
SetInitialBounds(0,0,250,200);
|
SetInitialBounds(0,0,250,200);
|
||||||
|
TabStop := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -122,6 +123,7 @@ begin
|
|||||||
Temp.OnChange := @Changed;
|
Temp.OnChange := @Changed;
|
||||||
Temp.OnEnter :=@ItemEnter;
|
Temp.OnEnter :=@ItemEnter;
|
||||||
Temp.OnExit :=@ItemExit;
|
Temp.OnExit :=@ItemExit;
|
||||||
|
Temp.OnKeyDown :=@ItemKeyDown;
|
||||||
Temp.OnResize := @ItemResize;
|
Temp.OnResize := @ItemResize;
|
||||||
include(temp.ControlStyle, csNoDesignSelectable);
|
include(temp.ControlStyle, csNoDesignSelectable);
|
||||||
FButtonList.Add(Temp);
|
FButtonList.Add(Temp);
|
||||||
@ -163,6 +165,7 @@ begin
|
|||||||
Temp.Visible := true;
|
Temp.Visible := true;
|
||||||
end;
|
end;
|
||||||
FHiddenButton.Checked:=(fItemIndex=-1);
|
FHiddenButton.Checked:=(fItemIndex=-1);
|
||||||
|
DoSetTabStops;
|
||||||
end;
|
end;
|
||||||
//DebugLn('[TCustomRadioGroup.CreateWnd] F ',Name,':',ClassName,' FItems.Count=',FItems.Count,' HandleAllocated=',HandleAllocated,' ItemIndex=',ItemIndex);
|
//DebugLn('[TCustomRadioGroup.CreateWnd] F ',Name,':',ClassName,' FItems.Count=',FItems.Count,' HandleAllocated=',HandleAllocated,' ItemIndex=',ItemIndex);
|
||||||
|
|
||||||
@ -192,6 +195,52 @@ begin
|
|||||||
DoPositionButtons;
|
DoPositionButtons;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomRadioGroup.ItemKeyDown(Sender: TObject; var Key: Word;
|
||||||
|
Shift: TShiftState);
|
||||||
|
|
||||||
|
procedure MoveSelection(HorzDiff, VertDiff: integer);
|
||||||
|
var
|
||||||
|
Count: integer;
|
||||||
|
StepSize: integer;
|
||||||
|
BlockSize : integer;
|
||||||
|
NewIndex : integer;
|
||||||
|
WrapOffset: integer;
|
||||||
|
begin
|
||||||
|
Count := FButtonList.Count;
|
||||||
|
if FColumnLayout=clHorizontalThenVertical then begin
|
||||||
|
//add a row for better wrapping
|
||||||
|
BlockSize := FColumns * (Rows+1);
|
||||||
|
StepSize := HorzDiff + VertDiff * FColumns;
|
||||||
|
WrapOffSet := VertDiff;
|
||||||
|
end
|
||||||
|
else begin
|
||||||
|
//add a column for better wrapping
|
||||||
|
BlockSize := (FColumns+1) * Rows;
|
||||||
|
StepSize := HorzDiff * Rows + VertDiff;
|
||||||
|
WrapOffSet := HorzDiff;
|
||||||
|
end;
|
||||||
|
NewIndex := ItemIndex + StepSize;
|
||||||
|
if (NewIndex>=Count) or (NewIndex<0) then begin
|
||||||
|
NewIndex := (NewIndex + WrapOffSet + BlockSize) mod BlockSize;
|
||||||
|
// Keep moving in the same direction until in valid range
|
||||||
|
while NewIndex>=Count do
|
||||||
|
NewIndex := (NewIndex + StepSize) mod BlockSize;
|
||||||
|
end;
|
||||||
|
ItemIndex := NewIndex;
|
||||||
|
TRadioButton(FButtonList[ItemIndex]).SetFocus;
|
||||||
|
Key := 0;
|
||||||
|
end;
|
||||||
|
begin
|
||||||
|
if Shift=[] then begin
|
||||||
|
case Key of
|
||||||
|
VK_LEFT: MoveSelection(-1,0);
|
||||||
|
VK_RIGHT: MoveSelection(1,0);
|
||||||
|
VK_UP: MoveSelection(0,-1);
|
||||||
|
VK_DOWN: MoveSelection(0,1);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
Method: TCustomRadioGroup.ItemsChanged
|
Method: TCustomRadioGroup.ItemsChanged
|
||||||
Params: sender : object calling this proc. (in fact the FItems instance)
|
Params: sender : object calling this proc. (in fact the FItems instance)
|
||||||
@ -211,7 +260,7 @@ end;
|
|||||||
Params: value - no of columns of the radiogroup
|
Params: value - no of columns of the radiogroup
|
||||||
Returns: Nothing
|
Returns: Nothing
|
||||||
|
|
||||||
Set the FColumns property which determines the no columns in
|
Set the FColumns property which determines the number of columns in
|
||||||
which the radiobuttons should be arranged.
|
which the radiobuttons should be arranged.
|
||||||
Range: 1 .. ???
|
Range: 1 .. ???
|
||||||
------------------------------------------------------------------------------}
|
------------------------------------------------------------------------------}
|
||||||
@ -289,6 +338,7 @@ begin
|
|||||||
// this has automatically unset the old button. But they do not recognize
|
// this has automatically unset the old button. But they do not recognize
|
||||||
// it. Update the states.
|
// it. Update the states.
|
||||||
CheckItemIndexChanged;
|
CheckItemIndexChanged;
|
||||||
|
DoSetTabStops;
|
||||||
|
|
||||||
OwnerFormDesignerModified(Self);
|
OwnerFormDesignerModified(Self);
|
||||||
end
|
end
|
||||||
@ -450,6 +500,19 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TCustomRadioGroup.DoSetTabStops;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
RadioBtn: TRadioButton;
|
||||||
|
begin
|
||||||
|
for i := 0 to FButtonList.Count-1 do begin
|
||||||
|
RadioBtn := TRadioButton(FButtonList[i]);
|
||||||
|
RadioBtn.TabStop := RadioBtn.Checked;
|
||||||
|
end;
|
||||||
|
if (FItemIndex=-1) and (Items.Count>0) then
|
||||||
|
TRadioButton(FButtonList[0]).TabStop := true;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TCustomRadioGroup.SetAutoFill(const AValue: Boolean);
|
procedure TCustomRadioGroup.SetAutoFill(const AValue: Boolean);
|
||||||
begin
|
begin
|
||||||
if FAutoFill=AValue then exit;
|
if FAutoFill=AValue then exit;
|
||||||
@ -478,5 +541,6 @@ begin
|
|||||||
FHiddenButton.Checked;
|
FHiddenButton.Checked;
|
||||||
for i:=0 to FButtonList.Count-1 do
|
for i:=0 to FButtonList.Count-1 do
|
||||||
if TRadioButton(FButtonList[i]).Checked then FItemIndex:=i;
|
if TRadioButton(FButtonList[i]).Checked then FItemIndex:=i;
|
||||||
|
DoSetTabStops;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user