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 ; OkButton.Caption:=lisMenuFind ;
CancelButton.AnchorSideRight.Control := OKButton; CancelButton.AnchorSideRight.Control := OKButton;
end; end;
DebugLn(['TLazFindReplaceDialog.SetOptions END ssoSelectedOnly=',ssoSelectedOnly in NewOptions,' SelectedRadioButton.Checked=',SelectedRadioButton.Checked]);
end; end;
function TLazFindReplaceDialog.GetOptions:TSynSearchOptions; function TLazFindReplaceDialog.GetOptions:TSynSearchOptions;

View File

@ -1104,7 +1104,8 @@ begin
FSourceNoteBook.DoIncrementalSearch; FSourceNoteBook.DoIncrementalSearch;
end else begin end else begin
OldOptions:=FindReplaceDlg.Options; OldOptions:=FindReplaceDlg.Options;
FindReplaceDlg.Options:=FindReplaceDlg.Options-[ssoEntireScope]; FindReplaceDlg.Options:=FindReplaceDlg.Options
-[ssoEntireScope,ssoReplace,ssoReplaceAll];
DoFindAndReplace; DoFindAndReplace;
FindReplaceDlg.Options:=OldOptions; FindReplaceDlg.Options:=OldOptions;
end; end;
@ -1140,7 +1141,7 @@ begin
else else
EditorComponent.LogicalCaretXY:=EditorComponent.BlockEnd EditorComponent.LogicalCaretXY:=EditorComponent.BlockEnd
end; 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 try
Result:=EditorComponent.SearchReplace( Result:=EditorComponent.SearchReplace(
FindReplaceDlg.FindText,FindReplaceDlg.ReplaceText,FindReplaceDlg.Options); FindReplaceDlg.FindText,FindReplaceDlg.ReplaceText,FindReplaceDlg.Options);

View File

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

View File

@ -1244,6 +1244,7 @@ var
OnGetDesignerForm: TGetDesignerFormEvent; OnGetDesignerForm: TGetDesignerFormEvent;
function GetParentForm(Control:TControl): TCustomForm; function GetParentForm(Control:TControl): TCustomForm;
function GetFirstParentForm(Control:TControl): TCustomForm;
function GetDesignerForm(AComponent: TComponent): TCustomForm; function GetDesignerForm(AComponent: TComponent): TCustomForm;
function FindRootDesigner(AComponent: TComponent): TIDesigner; function FindRootDesigner(AComponent: TComponent): TIDesigner;
@ -1434,6 +1435,13 @@ begin
Result:=Form.Designer; Result:=Form.Designer;
end; 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; function GetDesignerForm(AComponent: TComponent): TCustomForm;
var var
OwnerComponent: TComponent; OwnerComponent: TComponent;

View File

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

View File

@ -70,6 +70,22 @@ begin
AdjustSize; AdjustSize;
end; 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; function TRadioButton.DialogChar(var Message: TLMKey): boolean;
begin begin
if IsAccel(Message.CharCode, Caption) and CanFocus then if IsAccel(Message.CharCode, Caption) and CanFocus then

View File

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

View File

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