MG: fixed client rectangles, TRadioGroup, RecreateWnd

git-svn-id: trunk@1676 -
This commit is contained in:
lazarus 2002-05-13 14:47:01 +00:00
parent 55c755f6f0
commit c01f402583
8 changed files with 153 additions and 115 deletions

View File

@ -1657,6 +1657,8 @@ endif
tools: lcl components tools_all tools: lcl components tools_all
all: lcl components ide all: lcl components ide
cleanide: cleanide:
$(DEL) $(wildcard *$(OEXT))
$(DEL) $(wildcard *$(PPUEXT))
$(DEL) $(wildcard ./designer/*$(OEXT)) $(DEL) $(wildcard ./designer/*$(OEXT))
$(DEL) $(wildcard ./designer/*$(PPUEXT)) $(DEL) $(wildcard ./designer/*$(PPUEXT))
$(DEL) $(wildcard ./debugger/*$(OEXT)) $(DEL) $(wildcard ./debugger/*$(OEXT))

View File

@ -60,6 +60,8 @@ tools: lcl components tools_all
all: lcl components ide all: lcl components ide
cleanide: cleanide:
$(DEL) $(wildcard *$(OEXT))
$(DEL) $(wildcard *$(PPUEXT))
$(DEL) $(wildcard ./designer/*$(OEXT)) $(DEL) $(wildcard ./designer/*$(OEXT))
$(DEL) $(wildcard ./designer/*$(PPUEXT)) $(DEL) $(wildcard ./designer/*$(PPUEXT))
$(DEL) $(wildcard ./debugger/*$(OEXT)) $(DEL) $(wildcard ./debugger/*$(OEXT))

View File

@ -34,6 +34,9 @@ unit EnvironmentOpts;
interface interface
uses uses
{$IFDEF IDE_MEM_CHECK}
MemCheck,
{$ENDIF}
Classes, SysUtils, Forms, Controls, Buttons, XMLCfg, ObjectInspector, Classes, SysUtils, Forms, Controls, Buttons, XMLCfg, ObjectInspector,
ExtCtrls, StdCtrls, EditorOptions, LResources, LazConf, Dialogs, ExtCtrls, StdCtrls, EditorOptions, LResources, LazConf, Dialogs,
ExtToolDialog, IDEProcs, IDEOptionDefs; ExtToolDialog, IDEProcs, IDEOptionDefs;

View File

@ -296,11 +296,6 @@ type
(currently) maintained by Stefan Hille (stoppok@osibisa.ms.sub.org) (currently) maintained by Stefan Hille (stoppok@osibisa.ms.sub.org)
} }
TCustomRadioGroup = class(TCustomGroupBox) TCustomRadioGroup = class(TCustomGroupBox)
public
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
function CanModify : boolean; virtual;
procedure CreateWnd; override;
private private
FButtonList : TList; // list of TRadioButton FButtonList : TList; // list of TRadioButton
FCreatingWnd: boolean; FCreatingWnd: boolean;
@ -311,12 +306,19 @@ type
FOnClick : TNotifyEvent; FOnClick : TNotifyEvent;
procedure ItemsChanged (Sender : TObject); procedure ItemsChanged (Sender : TObject);
procedure Clicked(Sender : TObject); virtual; procedure Clicked(Sender : TObject); virtual;
procedure DoPositionButtons;
public
constructor Create (AOwner : TComponent); override;
destructor Destroy; override;
function CanModify : boolean; virtual;
procedure CreateWnd; override;
protected protected
procedure ReadState(Reader: TReader); override; procedure ReadState(Reader: TReader); override;
procedure SetItem (value : TStrings); procedure SetItem (value : TStrings);
procedure SetColumns (value : integer); procedure SetColumns (value : integer);
procedure SetItemIndex (value : integer); procedure SetItemIndex (value : integer);
function GetItemIndex : integer; function GetItemIndex : integer;
procedure WMSize(var Message: TLMSize); message LM_SIZE;
property ItemIndex : integer read GetItemIndex write SetItemIndex default -1; property ItemIndex : integer read GetItemIndex write SetItemIndex default -1;
property Items : TStrings read FItems write SetItem; property Items : TStrings read FItems write SetItem;
property Columns : integer read FColumns write SetColumns default 1; property Columns : integer read FColumns write SetColumns default 1;
@ -441,6 +443,9 @@ end.
{ {
$Log$ $Log$
Revision 1.24 2002/05/13 14:47:00 lazarus
MG: fixed client rectangles, TRadioGroup, RecreateWnd
Revision 1.23 2002/05/10 06:05:50 lazarus Revision 1.23 2002/05/10 06:05:50 lazarus
MG: changed license to LGPL MG: changed license to LGPL

View File

@ -97,62 +97,40 @@ procedure TCustomRadioGroup.CreateWnd;
var var
i : integer; i : integer;
temp : TRadioButton; temp : TRadioButton;
nextTop : integer;
nextLeft: integer;
vertDist: integer;
horzDist: integer;
rbWidth : integer;
begin begin
if FCreatingWnd then exit; if FCreatingWnd then exit;
FCreatingWnd := true; FCreatingWnd := true;
//writeln('[TCustomRadioGroup.CreateWnd] A ',FItems.Count); //writeln('[TCustomRadioGroup.CreateWnd] A ',Name,':',ClassName,' ',FItems.Count);
// destroy radiobuttons, if there are too many
while FButtonList.Count>FItems.Count do begin
TRadioButton(FButtonList[FButtonList.Count-1]).Free;
FButtonList.Delete(FButtonList.Count-1);
end;
if FItems.Count>0 then begin if FItems.Count>0 then begin
if (FItemIndex>=FItems.Count) or (FItemIndex<0) then FItemIndex:=0;
vertDist := (Height - 20) DIV (((FItems.Count-1) DIV FColumns)+1);
horzDist := (Width - 20) DIV FColumns;
nextTop := 0;
nextLeft := 10;
rbWidth := horzDist;
// destroy if there are too many
for i:=0 to FButtonList.Count-1 do
TRadioButton(FButtonList[i]).Free;
FButtonList.Clear;
{while (FButtonList.Count>FItems.Count) do begin
Temp:=TRadioButton(FButtonList[FButtonList.Count-1]);
Temp.Free;
FButtonList.Delete(FButtonList.Count-1);
end;}
// create as many TRadioButton as needed // create as many TRadioButton as needed
while (FButtonList.Count<FItems.Count) do begin while (FButtonList.Count<FItems.Count) do begin
Temp := TRadioButton.Create (self); Temp := TRadioButton.Create (self);
Temp.Parent := self; Temp.Parent := Self;
Temp.OnClick := @Clicked; Temp.OnClick := @Clicked;
FButtonList.Add(Temp); FButtonList.Add(Temp);
end; end;
// position in rows and columns
if (FItemIndex>=FItems.Count) or (FItemIndex<0) then FItemIndex:=0;
DoPositionButtons;
i := 0; i := 0;
while i < FItems.Count do begin while i < FItems.Count do begin
Temp := TRadioButton(FButtonList[i]); Temp := TRadioButton(FButtonList[i]);
Temp.Top := nextTop;
Temp.Left := nextLeft;
Temp.Width := rbWidth;
Temp.Height := vertDist;
Temp.Caption := FItems.Strings[i]; Temp.Caption := FItems.Strings[i];
Temp.Checked := (i = FItemIndex); Temp.Checked := (i = FItemIndex);
inc (i);
if (i MOD FColumns) = 0 then begin
inc(nextTop, vertDist);
nextLeft := 10;
end else begin
inc(nextLeft, horzDist);
end;
Temp.Visible:=true; Temp.Visible:=true;
inc(i);
end; end;
end; end;
//writeln('[TCustomRadioGroup.CreateWnd] B ',FItems.Count); //writeln('[TCustomRadioGroup.CreateWnd] B ',Name,':',ClassName,' ',FItems.Count);
inherited CreateWnd; inherited CreateWnd;
//writeln('[TCustomRadioGroup.CreateWnd] C ',FItems.Count); //writeln('[TCustomRadioGroup.CreateWnd] C ',Name,':',ClassName,' ',FItems.Count);
FCreatingWnd := false; FCreatingWnd := false;
end; end;
@ -199,7 +177,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TCustomRadioGroup.SetItem (value : TStrings); procedure TCustomRadioGroup.SetItem (value : TStrings);
begin begin
if Value <> FItems then if (Value <> FItems) then
begin begin
FItems.Assign(Value); FItems.Assign(Value);
if HandleAllocated then RecreateWnd; if HandleAllocated then RecreateWnd;
@ -253,9 +231,9 @@ begin
// when a button is pressed // when a button is pressed
while (i < FButtonList.Count) and (Result = -1) do while (i < FButtonList.Count) and (Result = -1) do
begin // find the actice button begin // find the actice button
if TRadioButton (FButtonList [i]).Checked if TRadioButton (FButtonList [i]).Checked
then result := i; then result := i;
inc (i); inc (i);
end; end;
FItemIndex := Result; FItemIndex := Result;
end end
@ -263,6 +241,19 @@ begin
Result := FItemIndex; Result := FItemIndex;
end; end;
{------------------------------------------------------------------------------
Method: TCustomRadioGroup.WMSize
Params: Message: TLMSize
Returns: none
Reposition buttons on resize
------------------------------------------------------------------------------}
procedure TCustomRadioGroup.WMSize(var Message: TLMSize);
begin
if HandleAllocated then DoPositionButtons;
inherited;
end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
Method: TCustomRadioGroup.CanModify Method: TCustomRadioGroup.CanModify
Params: none Params: none
@ -303,8 +294,50 @@ Begin
if Assigned (FOnClick) then FOnClick(Self); if Assigned (FOnClick) then FOnClick(Self);
end; end;
{------------------------------------------------------------------------------
Method: TCustomRadioGroup.DoPositionButtons
Params: none
Set bounds of radio buttons
------------------------------------------------------------------------------}
procedure TCustomRadioGroup.DoPositionButtons;
var
i : integer;
temp : TRadioButton;
nextTop : integer;
nextLeft: integer;
vertDist: integer;
horzDist: integer;
rbWidth : integer;
begin
if FItems.Count>0 then begin
// position in rows and columns
vertDist := (Height - 20) DIV (((FItems.Count-1) DIV FColumns)+1);
horzDist := (Width - 20) DIV FColumns;
nextTop := 0;
nextLeft := 10;
rbWidth := horzDist;
i := 0;
while i < FItems.Count do begin
Temp := TRadioButton(FButtonList[i]);
Temp.SetBounds(nextLeft,nextTop,rbWidth,vertDist);
inc (i);
if (i MOD FColumns) = 0 then begin
inc(nextTop, vertDist);
nextLeft := 10;
end else begin
inc(nextLeft, horzDist);
end;
end;
end;
end;
{ {
$Log$ $Log$
Revision 1.11 2002/05/13 14:47:00 lazarus
MG: fixed client rectangles, TRadioGroup, RecreateWnd
Revision 1.10 2002/05/13 06:12:57 lazarus Revision 1.10 2002/05/13 06:12:57 lazarus
MG: fixed saving unitlinks after changing fpc soure path MG: fixed saving unitlinks after changing fpc soure path

View File

@ -48,15 +48,12 @@
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
constructor TRadioButton.Create(AOwner : TComponent); constructor TRadioButton.Create(AOwner : TComponent);
begin begin
if assigned(AOwner) then inherited Create(AOwner);
begin fCompStyle := csRadioButton;
inherited Create(AOwner); Visible := False;
fCompStyle := csRadioButton; Hint := 'Radiobutton';
Visible := False; ShowHint := True;
Hint := 'Radiobutton'; fGroup := 0;
ShowHint := True;
fGroup := 0;
end;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -73,23 +70,54 @@ end;
property will be 0. property will be 0.
In the interface we can then use the group property to decide if In the interface we can then use the group property to decide if
a new group has to be created or which radiobutton is the a new group has to be created or which radiobutton is the
predecessor. predecessor. The first radiobutton, which handle is created, will get as Group
the group handle.
This behaviour is especially neccessary for the GTK bindings. This behaviour is especially neccessary for the GTK bindings.
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TRadioButton.CreateWnd; procedure TRadioButton.CreateWnd;
var var
i : integer; i : integer;
temp : TComponent; temp : TComponent;
begin begin
i := Owner.ComponentCount-1; fGroup:=0;
while (i >= 0) and (fGroup = 0) do i := Owner.ComponentCount-1;
begin // search for radiobutton which is predecessor while (i >= 0) and (fGroup = 0) do
Temp := Owner.Components [i]; begin // search for radiobutton which is predecessor
if (Temp is TRadioButton) and (TRadioButton (temp).fGroup <> 0) Temp := Owner.Components [i];
then fGroup := THandle (TRadioButton(Temp).Handle); // set group to our predecessor if (Temp is TRadioButton) and (TRadioButton (temp).fGroup <> 0) then
dec (i); fGroup := THandle (TRadioButton(Temp).Handle); // set group to our predecessor
end; dec (i);
inherited CreateWnd; end;
inherited CreateWnd;
end;
{------------------------------------------------------------------------------
Method: TRadioButton.DestroyWnd
Params: none
Returns: Nothing
The handle is destroyed, and therefore the radiobutton does not belong any
longer to a group. The Group property is the handle of the predecessor
TRadioButton.
-> Bind the successor TRadioButton to our predecessor
------------------------------------------------------------------------------}
procedure TRadioButton.DestroyWnd;
var
i: integer;
ARadioButton: TRadioButton;
begin
if fGroup<>0 then begin
if HandleAllocated then begin
for i:=0 to Owner.ComponentCount-1 do
if (Owner.Components[i] is TRadioButton) then begin
ARadioButton:=TRadioButton(Owner.Components[i]);
if ARadioButton.fGroup=Handle then
ARadioButton.fGroup:=fGroup;
end;
end;
fGroup:=0;
end;
inherited DestroyWnd;
end; end;
{------------------------------------------------------------------------------ {------------------------------------------------------------------------------
@ -101,8 +129,8 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
procedure TRadioButton.SetGroup(Value : THandle); procedure TRadioButton.SetGroup(Value : THandle);
begin begin
Assert(False, 'Trace:IN SETGROUP. Caption = '+ Self.Caption); Assert(False, 'Trace:IN SETGROUP. Caption = '+ Self.Caption);
FGroup := Value; FGroup := Value;
//SH? ReCreate; //SH? ReCreate;
end; end;
@ -115,7 +143,7 @@ end;
------------------------------------------------------------------------------} ------------------------------------------------------------------------------}
function TRadioButton.GetGroup : THandle; function TRadioButton.GetGroup : THandle;
begin begin
GetGroup := FGroup; GetGroup := FGroup;
end; end;
// included by stdctrls.pp // included by stdctrls.pp
@ -153,6 +181,9 @@ end;
{ {
$Log$ $Log$
Revision 1.5 2002/05/13 14:47:00 lazarus
MG: fixed client rectangles, TRadioGroup, RecreateWnd
Revision 1.4 2002/05/13 06:12:57 lazarus Revision 1.4 2002/05/13 06:12:57 lazarus
MG: fixed saving unitlinks after changing fpc soure path MG: fixed saving unitlinks after changing fpc soure path

View File

@ -834,43 +834,6 @@ end;
function gtksize_allocateCB(widget: PGtkWidget; size :pGtkAllocation; function gtksize_allocateCB(widget: PGtkWidget; size :pGtkAllocation;
data: gPointer) : GBoolean; cdecl; data: gPointer) : GBoolean; cdecl;
{$IFDEF ClientRectBugFix}
procedure UpdateParentSizes(AParent: TWinControl);
var
OldLeft, OldTop, OldWidth, OldHeight: integer;
NewLeft, NewTop, NewWidth, NewHeight: integer;
ParentWidget: PGtkWidget;
begin
if AParent=nil then exit;
AParent.InvalidateClientRectCache;
UpdateParentSizes(AParent.Parent);
if (not AParent.HandleAllocated) then exit;
// update size
OldLeft:=AParent.Left;
OldTop:=AParent.Top;
OldWidth:=AParent.Width;
OldHeight:=AParent.Height;
ParentWidget:=PGtkWidget(AParent.Handle);
NewLeft:=ParentWidget^.Allocation.x;
NewTop:=ParentWidget^.Allocation.y;
NewWidth:=ParentWidget^.Allocation.Width;
NewHeight:=ParentWidget^.Allocation.Height;
{$IFDEF VerboseSizeMsg}
writeln(' UpdateParentSizes ',AParent.Name,':',AParent.ClassName,
' LCL=',OldLeft,',',OldTop,',',OldWidth,',',OldHeight,
' GTK=',NewLeft,',',NewTop,',',NewWidth,',',NewHeight
);
{$ENDIF}
// update client rectangle
if AParent is TWinControl then
TWinControl(AParent).DoAdjustClientRectChange;
end;
{$ENDIF}
var var
PosMsg : TLMWindowPosChanged; PosMsg : TLMWindowPosChanged;
SizeMsg: TLMSize; SizeMsg: TLMSize;
@ -914,8 +877,6 @@ begin
SaveSizeNotification(Widget); SaveSizeNotification(Widget);
Result:=true; Result:=true;
exit; exit;
UpdateParentSizes(TControl(Data).Parent);
{$ENDIF} {$ENDIF}
OldLeft:=TControl(Data).Left; OldLeft:=TControl(Data).Left;
@ -1027,13 +988,9 @@ end;}
end; end;
end; end;
{$IFDEF ClientRectBugFix}
{$ELSE}
if not (TopLeftChanged or WidthHeightChanged) if not (TopLeftChanged or WidthHeightChanged)
and (TObject(Data) is TWinControl) then and (TObject(Data) is TWinControl) then
TWinControl(Data).DoAdjustClientRectChange; TWinControl(Data).DoAdjustClientRectChange;
{$ENDIF}
end; end;
{$IFDEF ClientRectBugFix} {$IFDEF ClientRectBugFix}
@ -1757,6 +1714,9 @@ end;
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.74 2002/05/13 14:47:01 lazarus
MG: fixed client rectangles, TRadioGroup, RecreateWnd
Revision 1.73 2002/05/10 06:05:56 lazarus Revision 1.73 2002/05/10 06:05:56 lazarus
MG: changed license to LGPL MG: changed license to LGPL

View File

@ -483,8 +483,6 @@ type
{TRadioButton} {TRadioButton}
TRadioButton = Class; //Forward Declaration
TRadioButton = class(TCustomCheckBox) TRadioButton = class(TCustomCheckBox)
private private
fGroup : THandle; // handle to the previous button in the group this button belongs to fGroup : THandle; // handle to the previous button in the group this button belongs to
@ -492,6 +490,7 @@ type
function GetGroup : THandle; function GetGroup : THandle;
protected protected
procedure CreateWnd; override; procedure CreateWnd; override;
procedure DestroyWnd; override;
public public
constructor Create (AOwner: TComponent); override; constructor Create (AOwner: TComponent); override;
property group : THandle read GetGroup write SetGroup; property group : THandle read GetGroup write SetGroup;
@ -594,6 +593,9 @@ end.
{ ============================================================================= { =============================================================================
$Log$ $Log$
Revision 1.29 2002/05/13 14:47:00 lazarus
MG: fixed client rectangles, TRadioGroup, RecreateWnd
Revision 1.28 2002/05/10 06:05:50 lazarus Revision 1.28 2002/05/10 06:05:50 lazarus
MG: changed license to LGPL MG: changed license to LGPL