lcl: formatting

git-svn-id: trunk@28393 -
This commit is contained in:
paul 2010-11-22 06:13:31 +00:00
parent f716b70688
commit a2e75a4b8d
2 changed files with 64 additions and 56 deletions

View File

@ -1149,7 +1149,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.DblClick; procedure TControl.DblClick;
begin begin
If Assigned(FOnDblClick) then FOnDblClick(Self); if Assigned(FOnDblClick) then FOnDblClick(Self);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1157,7 +1157,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.TripleClick; procedure TControl.TripleClick;
begin begin
If Assigned(FOnTripleClick) then FOnTripleClick(Self); if Assigned(FOnTripleClick) then FOnTripleClick(Self);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -1165,7 +1165,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TControl.QuadClick; procedure TControl.QuadClick;
begin begin
If Assigned(FOnQuadClick) then FOnQuadClick(Self); if Assigned(FOnQuadClick) then FOnQuadClick(Self);
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------

View File

@ -88,26 +88,28 @@ function TCustomSpeedButton.FindDownButton: TCustomSpeedButton;
Child: TControl; Child: TControl;
Button: TCustomSpeedButton; Button: TCustomSpeedButton;
begin begin
if AWinControl=nil then exit(nil); if AWinControl = nil then Exit(nil);
for i:=0 to AWinControl.ControlCount-1 do begin for i := 0 to AWinControl.ControlCount-1 do
Child:=AWinControl.Controls[i]; begin
if Child is TCustomSpeedButton then begin Child := AWinControl.Controls[i];
Button:=TCustomSpeedButton(Child); if Child is TCustomSpeedButton then
if (Button.GroupIndex=GroupIndex) begin
and (Button.Down) then Button := TCustomSpeedButton(Child);
exit(Button); if (Button.GroupIndex=GroupIndex) and (Button.Down) then
Exit(Button);
end; end;
if Child is TWinControl then begin if Child is TWinControl then
Result:=FindDown(TWinControl(Child)); begin
if Result<>nil then exit; Result := FindDown(TWinControl(Child));
if Result <> nil then Exit;
end; end;
end; end;
Result:=nil; Result := nil;
end; end;
begin begin
if Down or (GroupIndex=0) then exit(Self); if Down or (GroupIndex=0) then exit(Self);
Result:=FindDown(GetFirstParentForm(Self)); Result := FindDown(GetFirstParentForm(Self));
end; end;
procedure TCustomSpeedButton.Click; procedure TCustomSpeedButton.Click;
@ -123,8 +125,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomSpeedButton.SetAllowAllUp(Value : Boolean); procedure TCustomSpeedButton.SetAllowAllUp(Value : Boolean);
begin begin
if FAllowAllUp <> Value if FAllowAllUp <> Value then
then begin begin
FAllowAllUp := Value; FAllowAllUp := Value;
UpdateExclusive; UpdateExclusive;
end; end;
@ -205,7 +207,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomSpeedButton.SetGroupIndex(const Value : Integer); procedure TCustomSpeedButton.SetGroupIndex(const Value : Integer);
begin begin
if FGroupIndex <> Value then begin if FGroupIndex <> Value then
begin
FGroupIndex := Value; FGroupIndex := Value;
UpdateExclusive; UpdateExclusive;
end; end;
@ -219,7 +222,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomSpeedButton.SetMargin(const Value : Integer); procedure TCustomSpeedButton.SetMargin(const Value : Integer);
begin begin
if FMargin <> Value then begin if FMargin <> Value then
begin
FMargin := Value; FMargin := Value;
Invalidate; Invalidate;
end; end;
@ -232,12 +236,12 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomSpeedButton.SetNumGlyphs(Value : integer); procedure TCustomSpeedButton.SetNumGlyphs(Value : integer);
Begin begin
if Value < 0 then Value := 1; if Value < 0 then Value := 1;
if Value > High(TNumGlyphs) then Value := High(TNumGlyphs); if Value > High(TNumGlyphs) then Value := High(TNumGlyphs);
if Value <> TButtonGlyph(fGlyph).NumGlyphs then if Value <> TButtonGlyph(fGlyph).NumGlyphs then
Begin begin
TButtonGlyph(fGlyph).NumGlyphs := TNumGlyphs(Value); TButtonGlyph(fGlyph).NumGlyphs := TNumGlyphs(Value);
Invalidate; Invalidate;
end; end;
@ -251,7 +255,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomSpeedButton.SetSpacing(const Value : Integer); procedure TCustomSpeedButton.SetSpacing(const Value : Integer);
begin begin
if FSpacing <> Value then begin if FSpacing <> Value then
begin
FSpacing := Value; FSpacing := Value;
Invalidate; Invalidate;
end; end;
@ -259,7 +264,8 @@ end;
procedure TCustomSpeedButton.SetShowAccelChar(Value : Boolean); procedure TCustomSpeedButton.SetShowAccelChar(Value : Boolean);
begin begin
If FShowAccelChar <> Value then begin If FShowAccelChar <> Value then
begin
FShowAccelChar := Value; FShowAccelChar := Value;
Invalidate; Invalidate;
end; end;
@ -383,12 +389,14 @@ procedure TCustomSpeedButton.ActionChange(Sender: TObject;
CheckDefaults: Boolean); CheckDefaults: Boolean);
begin begin
inherited ActionChange(Sender,CheckDefaults); inherited ActionChange(Sender,CheckDefaults);
if Sender is TCustomAction then begin if Sender is TCustomAction then
with TCustomAction(Sender) do begin begin
with TCustomAction(Sender) do
begin
if CheckDefaults or (Self.GroupIndex = 0) then if CheckDefaults or (Self.GroupIndex = 0) then
Self.GroupIndex := GroupIndex; Self.GroupIndex := GroupIndex;
if (Glyph.Empty) and (ActionList <> nil) and (ActionList.Images <> nil) if (Glyph.Empty) and (ActionList <> nil) and (ActionList.Images <> nil) and
and (ImageIndex >= 0) and (ImageIndex < ActionList.Images.Count) then (ImageIndex >= 0) and (ImageIndex < ActionList.Images.Count) then
ActionList.Images.GetBitmap(ImageIndex, Glyph); ActionList.Images.GetBitmap(ImageIndex, Glyph);
end; end;
end; end;
@ -415,9 +423,8 @@ procedure TCustomSpeedButton.UpdateExclusive;
var 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
and (not (csLoading in ComponentState)) 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);
@ -674,9 +681,7 @@ begin
NewState := bsExclusive NewState := bsExclusive
else else
begin begin
if (X >= 0) and (X < Width) if (X >= 0) and (X < Width) and (Y >= 0) and (Y < Height) then
and (Y >= 0) and (Y < Height)
then
NewState := bsDown NewState := bsDown
else else
NewState := UpState[FMouseInControl]; NewState := UpState[FMouseInControl];
@ -709,9 +714,9 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomSpeedButton.DoMouseUp(var Message: TLMMouse; Button: TMouseButton); procedure TCustomSpeedButton.DoMouseUp(var Message: TLMMouse; Button: TMouseButton);
begin begin
if not (csNoStdEvents in ControlStyle) if not (csNoStdEvents in ControlStyle) then
then with Message do with Message do
MouseUp(Button, KeysToShiftState(Keys), XPos, YPos); MouseUp(Button, KeysToShiftState(Keys), XPos, YPos);
end; end;
procedure TCustomSpeedButton.WMLButtonDown(var Message: TLMLButtonDown); procedure TCustomSpeedButton.WMLButtonDown(var Message: TLMLButtonDown);
@ -725,11 +730,11 @@ end;
procedure TCustomSpeedButton.WMLButtonDBLCLK(var Message: TLMLButtonDblClk); procedure TCustomSpeedButton.WMLButtonDBLCLK(var Message: TLMLButtonDblClk);
begin begin
inherited; inherited;
// if in a group, raise dblclick event, otherwise translate to click event // if in a group, raise dblclick event, otherwise translate to click event
if Down if Down then
then DblClick DblClick
else Click; else
Click;
end; end;
class procedure TCustomSpeedButton.WSRegisterClass; class procedure TCustomSpeedButton.WSRegisterClass;
@ -769,9 +774,11 @@ begin
if OldState <> FState then if OldState <> FState then
Invalidate; Invalidate;
end end
else if (Message.XPos >= 0) and (Message.XPos < Width) else
and (Message.YPos >= 0) and (Message.YPos < Height) then if (Message.XPos >= 0) and (Message.XPos < Width) and (Message.YPos >= 0) and (Message.YPos < Height) then
begin
SetDown(not FDown); SetDown(not FDown);
end;
end; end;
DoMouseUp(Message, mbLeft); DoMouseUp(Message, mbLeft);
@ -780,15 +787,14 @@ begin
begin begin
Exclude(FControlState, csClicked); Exclude(FControlState, csClicked);
//DebugLn('TCustomSpeedButton.WMLButtonUp B ',dbgs(ClientRect.Left),',',dbgs(ClientRect.Top),',',dbgs(ClientRect.Right),',',dbgs(ClientRect.Bottom),' ',dbgs(Message.Pos.X),',',dbgs(Message.Pos.Y)); //DebugLn('TCustomSpeedButton.WMLButtonUp B ',dbgs(ClientRect.Left),',',dbgs(ClientRect.Top),',',dbgs(ClientRect.Right),',',dbgs(ClientRect.Bottom),' ',dbgs(Message.Pos.X),',',dbgs(Message.Pos.Y));
if PtInRect(ClientRect, SmallPointToPoint(Message.Pos)) if PtInRect(ClientRect, SmallPointToPoint(Message.Pos)) then
then begin begin
//DebugLn('TCustomSpeedButton.WMLButtonUp C'); //DebugLn('TCustomSpeedButton.WMLButtonUp C');
// Important: Calling Click can invoke modal dialogs, so call this as last // Important: Calling Click can invoke modal dialogs, so call this as last
Click; Click;
end; end;
end; end;
//DebugLn('TCustomSpeedButton.WMLButtonUp END'); //DebugLn('TCustomSpeedButton.WMLButtonUp END');
end; end;
@ -800,7 +806,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomSpeedButton.SetLayout(const Value : TButtonLayout); procedure TCustomSpeedButton.SetLayout(const Value : TButtonLayout);
begin begin
if Value <> FLayout then begin if Value <> FLayout then
begin
FLayout:= Value; FLayout:= Value;
Invalidate; Invalidate;
end; end;
@ -838,13 +845,13 @@ var
Sender : TCustomSpeedButton; Sender : TCustomSpeedButton;
begin begin
if csDestroying in ComponentState then exit; if csDestroying in ComponentState then exit;
if Message.WParam = WParam(FGroupIndex) if Message.WParam = WParam(FGroupIndex) then
then begin begin
Sender := TCustomSpeedButton(Message.LParam); Sender := TCustomSpeedButton(Message.LParam);
if Sender <> Self if Sender <> Self then
then begin begin
if Sender.Down and FDown if Sender.Down and FDown then
then begin begin
FDown := False; FDown := False;
FState := UpState[FMouseInControl]; FState := UpState[FMouseInControl];
Invalidate; Invalidate;
@ -908,9 +915,10 @@ end;
function TCustomSpeedButton.GetTransparent: Boolean; function TCustomSpeedButton.GetTransparent: Boolean;
begin begin
if FGlyph.TransparentMode = gtmGlyph if FGlyph.TransparentMode = gtmGlyph then
then Result := FGlyph.FOriginal.Transparent Result := FGlyph.FOriginal.Transparent
else Result := FGlyph.TransparentMode = gtmTransparent; else
Result := FGlyph.TransparentMode = gtmTransparent;
end; end;
function TCustomSpeedButton.DrawGlyph(ACanvas: TCanvas; const AClient: TRect; function TCustomSpeedButton.DrawGlyph(ACanvas: TCanvas; const AClient: TRect;