fixed TRadioButton updating sibling buttons, when no handles are created

git-svn-id: trunk@9579 -
This commit is contained in:
mattias 2006-07-10 00:31:40 +00:00
parent f6cb3fb257
commit 909bde3051
8 changed files with 71 additions and 20 deletions

View File

@ -313,6 +313,7 @@ begin
OkButton.Caption:=lisMenuFind ;
CancelButton.AnchorSideRight.Control := OKButton;
end;
DebugLn(['TLazFindReplaceDialog.SetOptions END ssoSelectedOnly=',ssoSelectedOnly in NewOptions,' SelectedRadioButton.Checked=',SelectedRadioButton.Checked]);
end;
function TLazFindReplaceDialog.GetOptions:TSynSearchOptions;

View File

@ -1104,7 +1104,8 @@ begin
FSourceNoteBook.DoIncrementalSearch;
end else begin
OldOptions:=FindReplaceDlg.Options;
FindReplaceDlg.Options:=FindReplaceDlg.Options-[ssoEntireScope];
FindReplaceDlg.Options:=FindReplaceDlg.Options
-[ssoEntireScope,ssoReplace,ssoReplaceAll];
DoFindAndReplace;
FindReplaceDlg.Options:=OldOptions;
end;
@ -1140,7 +1141,7 @@ begin
else
EditorComponent.LogicalCaretXY:=EditorComponent.BlockEnd
end;
debugln('TSourceEditor.DoFindAndReplace A FindReplaceDlg.FindText="',dbgstr(FindReplaceDlg.FindText),'" ssoEntireScope=',dbgs(ssoEntireScope in FindReplaceDlg.Options),' ssoBackwards=',dbgs(ssoBackwards in FindReplaceDlg.Options));
//debugln('TSourceEditor.DoFindAndReplace A FindReplaceDlg.FindText="',dbgstr(FindReplaceDlg.FindText),'" ssoEntireScope=',dbgs(ssoEntireScope in FindReplaceDlg.Options),' ssoBackwards=',dbgs(ssoBackwards in FindReplaceDlg.Options));
try
Result:=EditorComponent.SearchReplace(
FindReplaceDlg.FindText,FindReplaceDlg.ReplaceText,FindReplaceDlg.Options);

View File

@ -329,7 +329,7 @@ type
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure Click; override;
function FindDownButton: TCustomSpeedButton;
public
property AllowAllUp: Boolean read FAllowAllUp write SetAllowAllUp default false;
property Down: Boolean read FDown write SetDown default false;

View File

@ -1244,6 +1244,7 @@ var
OnGetDesignerForm: TGetDesignerFormEvent;
function GetParentForm(Control:TControl): TCustomForm;
function GetFirstParentForm(Control:TControl): TCustomForm;
function GetDesignerForm(AComponent: TComponent): TCustomForm;
function FindRootDesigner(AComponent: TComponent): TIDesigner;
@ -1434,6 +1435,13 @@ begin
Result:=Form.Designer;
end;
function GetFirstParentForm(Control: TControl): TCustomForm;
begin
while (Control<>nil) and (not (Control is TCustomForm)) do
Control:=Control.Parent;
Result:=TCustomForm(Control);
end;
function GetDesignerForm(AComponent: TComponent): TCustomForm;
var
OwnerComponent: TComponent;

View File

@ -34,7 +34,6 @@ begin
if FState <> Value then
begin
FState := Value;
//debugln('TCustomCheckBox.SetState ',dbgsname(Self),' ',dbgs(ord(FState)));
ApplyChanges;
end;
end;
@ -179,7 +178,6 @@ procedure TCustomCheckBox.Loaded;
begin
// Send first the FState to the interface before calling inherited,
// otherwise the FState will be lost and the default interface State is taken.
// TODO: MWE, remove this, it should be handled by InitializeWnd
if HandleAllocated
then TWSCustomCheckBoxClass(WidgetSetClass).SetState(Self, FState);
inherited Loaded;

View File

@ -70,6 +70,22 @@ begin
AdjustSize;
end;
procedure TRadioButton.ApplyChanges;
var
i: Integer;
Sibling: TControl;
begin
inherited ApplyChanges;
if (not (csLoading in ComponentState))
and (Parent<>nil) and (FState=cbChecked) then begin
for i:=0 to Parent.ControlCount-1 do begin
Sibling:=Parent.Controls[i];
if (Sibling is TRadioButton) and (Sibling<>Self) then
TRadioButton(Sibling).Checked:=false;
end;
end;
end;
function TRadioButton.DialogChar(var Message: TLMKey): boolean;
begin
if IsAccel(Message.CharCode, Caption) and CanFocus then

View File

@ -67,14 +67,38 @@ begin
end;
{------------------------------------------------------------------------------
Method: TCustomSpeedButton.Click
Params:
Returns: nothing
Method: TCustomSpeedButton.FindDownButton: TCustomSpeedButton;
Searches the speed button with Down=true and the same GroupIndex.
------------------------------------------------------------------------------}
procedure TCustomSpeedButton.Click;
function TCustomSpeedButton.FindDownButton: TCustomSpeedButton;
function FindDown(AWinControl: TWinControl): TCustomSpeedButton;
var
i: Integer;
Child: TControl;
Button: TCustomSpeedButton;
begin
if AWinControl=nil then exit(nil);
for i:=0 to AWinControl.ControlCount-1 do begin
Child:=AWinControl.Controls[i];
if Child is TCustomSpeedButton then begin
Button:=TCustomSpeedButton(Child);
if (Button.GroupIndex=GroupIndex)
and (Button.Down) then
exit(Button);
end;
if Child is TWinControl then begin
Result:=FindDown(TWinControl(Child));
if Result<>nil then exit;
end;
end;
Result:=nil;
end;
begin
inherited Click;
if Down or (GroupIndex=0) then exit(Self);
Result:=FindDown(GetFirstParentForm(Self));
end;
{------------------------------------------------------------------------------
@ -169,8 +193,7 @@ end;
------------------------------------------------------------------------------}
procedure TCustomSpeedButton.SetGroupIndex(const Value : Integer);
begin
if FGroupIndex <> Value
then begin
if FGroupIndex <> Value then begin
FGroupIndex := Value;
UpdateExclusive;
end;
@ -287,12 +310,13 @@ begin
inc(Result,DFCS_PUSHED);
if not Enabled then
inc(Result,DFCS_INACTIVE)
else if fMouseInControl then inc(Result,DFCS_CHECKED);
else if fMouseInControl then
inc(Result,DFCS_CHECKED);
end;
end;
procedure TCustomSpeedButton.ActionChange(Sender: TObject; CheckDefaults: Boolean);
procedure TCustomSpeedButton.ActionChange(Sender: TObject;
CheckDefaults: Boolean);
procedure CopyImage(ImageList: TCustomImageList; Index: Integer);
begin
@ -328,10 +352,11 @@ var
msg : TLMessage;
begin
if (FGroupIndex <> 0) and (Parent <> nil)
and (not (csLoading in ComponentState))
then begin
MSg.MSg := CM_ButtonPressed;
Msg.Msg := CM_ButtonPressed;
Msg.WParam := FGroupIndex;
Msg.LParam := PtrInt(self);
Msg.LParam := PtrInt(Self);
Msg.Result := 0;
Parent.Broadcast(Msg);
end;
@ -696,6 +721,7 @@ procedure TCustomSpeedButton.CMButtonPressed(var Message : TLMessage);
var
Sender : TCustomSpeedButton;
begin
if csDestroying in ComponentState then exit;
if Message.WParam = WParam(FGroupIndex)
then begin
Sender := TCustomSpeedButton(Message.LParam);
@ -715,10 +741,10 @@ end;
procedure TCustomSpeedButton.Loaded;
begin
inherited Loaded;
UpdateExclusive;
if FDownBuffered then SetDown(FDownBuffered);
end;
{------------------------------------------------------------------------------
Method: TCustomSpeedButton.CMEnabledChanged
Params: Message:
@ -761,10 +787,10 @@ begin
if csDesigning in ComponentState then exit;
if FMouseInControl
and Enabled {and not FDragging}
then begin
FMouseInControl := False;
UpdateState(true);
if Enabled then
UpdateState(true);
end;
end;

View File

@ -1097,6 +1097,7 @@ type
protected
function DialogChar(var Message: TLMKey): boolean; override;
procedure RealSetText(const Value: TCaption); override;
procedure ApplyChanges; override;
public
constructor Create(TheOwner: TComponent); override;
published