LCL: fixed using parent borderspacing, fixed anchor spacing for parallel controls, fixed endless loop autosize interdependencies, implemented auto fixing anchor circles, implemented auto fixing center anchoring, fixed calculation of static childsizing layouts, fixed autosizing for controls without preferred size by providing default sizes also used in creation, fixed TSizeConstraints.MinMaxWidth/Height

git-svn-id: trunk@12461 -
This commit is contained in:
mattias 2007-10-14 12:54:29 +00:00
parent 9f052f558f
commit 6264aac23c
52 changed files with 1557 additions and 381 deletions

View File

@ -41,6 +41,8 @@ Type
TArrowType = (atUp, atDown, atLeft, atRight);
TShadowType = (stNone, stIn, stOut, stEtchedIn, stEtchedOut);
{ TArrow }
TArrow = class(TCustomControl)
private
FArrowType : TArrowType;
@ -52,6 +54,7 @@ Type
procedure SetProps;
protected
procedure Paint; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -97,7 +100,7 @@ begin
fCompStyle := csArrow;
fArrowType := atLeft;
fShadowType := stEtchedIn;
SetInitialBounds(0,0,10,10);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
destructor TArrow.Destroy;
@ -117,6 +120,12 @@ begin
inherited Paint;
end;
class function TArrow.GetControlClassDefaultSize: TPoint;
begin
Result.X:=10;
Result.Y:=10;
end;
procedure TArrow.InitializeWnd;
begin
inherited InitializeWnd;

View File

@ -122,6 +122,7 @@ type
procedure InitializeWnd; override;
procedure TextChanged; override;
function IsBorderSpacingInnerBorderStored: Boolean; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; Override;
@ -254,6 +255,7 @@ type
property MouseInControl: Boolean read FMouseInControl;
procedure ActionChange(Sender: TObject; CheckDefaults: Boolean); override;
function GetActionLinkClass: TControlActionLinkClass; override;
class function GetControlClassDefaultSize: TPoint; override;
procedure Loaded; override;
protected
function GetGlyphSize(PaintRect: TRect): TSize; virtual;

View File

@ -77,6 +77,7 @@ Type
procedure LMMonthChanged(var Message: TLMessage); message LM_MONTHCHANGED;
procedure LMYearChanged(var Message: TLMessage); message LM_YEARCHANGED;
procedure LMDayChanged(var Message: TLMessage); message LM_DAYCHANGED;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -147,7 +148,7 @@ constructor TCustomCalendar.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
fCompStyle := csCalendar;
SetInitialBounds(0,0,190,153);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
fDisplaySettings := [dsShowHeadings, dsShowDayNames];
ControlStyle:=ControlStyle-[csTripleClicks,csQuadClicks,csAcceptsControls];
Date := FormatDateTime(ShortDateFormat,Now);
@ -307,6 +308,12 @@ begin
if Assigned(OnChange) then OnChange(self);
end;
class function TCustomCalendar.GetControlClassDefaultSize: TPoint;
begin
Result.X:=190;
Result.Y:=153;
end;
procedure TCustomCalendar.LMMonthChanged(var Message: TLMessage);
begin
if Assigned(OnMonthChanged) then OnMonthChanged(self);

View File

@ -79,6 +79,7 @@ type
procedure SetLabelPosition(const AValue: TPosLabel);
protected
procedure Paint; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -157,7 +158,7 @@ begin
FBars:=TBarChartItems.Create(Self);
FDepth:=5;
FLabelPosition:=plLeft;
SetInitialBounds(0,0,150,120);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
destructor TCustomBarChart.Destroy;
@ -366,6 +367,12 @@ begin
Canvas.Pen.Style:=psSolid;
end;
class function TCustomBarChart.GetControlClassDefaultSize: TPoint;
begin
Result.X:=150;
Result.Y:=120;
end;
procedure TCustomBarChart.Clear;
begin
FBars.Clear;

View File

@ -445,6 +445,7 @@ type
procedure UpdateTabImages;
procedure ImageListChange(Sender: TObject);
procedure DoSetBounds(ALeft, ATop, AWidth, AHeight: integer); override;
class function GetControlClassDefaultSize: TPoint; override;
procedure Paint; override;
function GetDisplayRectWithBorder: TRect; virtual;
procedure AdjustClientRect(var ARect: TRect); override;
@ -1116,6 +1117,7 @@ type
procedure ApplyChanges;
procedure InitializeWnd; override;
procedure Loaded; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
procedure StepIt;
@ -1217,6 +1219,7 @@ type
Procedure AssociateKeyDown(Sender: TObject; var Key: Word; ShiftState : TShiftState);
procedure OnAssociateChangeBounds(Sender: TObject);
procedure DoOnResize; override;
class function GetControlClassDefaultSize: TPoint; override;
function CanChange: Boolean; dynamic;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure Click(Button: TUDBtnType); dynamic; overload;
@ -1359,6 +1362,7 @@ type
procedure CalculatePreferredSize(
var PreferredWidth, PreferredHeight: integer;
WithThemeSpace: Boolean); override;
class function GetControlClassDefaultSize: TPoint; override;
procedure Loaded; override;
procedure RefreshControl; virtual;
procedure SetToolBar(NewToolBar: TToolBar);
@ -1475,6 +1479,7 @@ type
procedure RemoveButton(Button: TToolButton);
protected
procedure AdjustClientRect(var ARect: TRect); override;
class function GetControlClassDefaultSize: TPoint; override;
function CanAutoSize(var NewWidth, NewHeight: Integer): Boolean; override;
function CheckMenuDropdown(Button: TToolButton): Boolean; dynamic;
procedure ClickButton(Button: TToolButton); dynamic;
@ -1598,6 +1603,7 @@ type
protected
procedure ApplyChanges;
procedure DoChange(var msg); message LM_CHANGED;
class function GetControlClassDefaultSize: TPoint; override;
procedure InitializeWnd; override;
procedure Loaded; override;
public
@ -2574,6 +2580,7 @@ type
procedure MouseUp(Button: TMouseButton; Shift: TShiftState;
X, Y: Integer); override;
procedure UpdateState;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;

View File

@ -652,7 +652,7 @@ type
tries to keep the distance between the left side of the control and the
right side of its parent client area.
With AnchorSide[akLeft] you can define a different reference side. The
kept distance is defined by the BorderSpacing.
kept distance is defined by the BorderSpacing and Parent.ChildSizing.
Example1:
+-----+ +-----+
@ -684,8 +684,6 @@ type
Or use this. It's equivalent:
A.AnchorSide[akBottom].Side:=arsCenter;
A.AnchorSide[akBottom].Control:=B;
}
TAnchorSideChangeOperation = (ascoAdd, ascoRemove, ascoChangeSide);
@ -760,7 +758,9 @@ type
cfClientHeightLoaded,
cfLastAlignedBoundsValid,
cfBoundsRectForNewParentValid,
cfBaseBoundsValid,
cfPreferredSizeValid,
cfPreferredMinSizeValid,
cfOnResizeNeeded,
cfOnChangeBoundsNeeded
);
@ -863,6 +863,8 @@ type
FParentFont: Boolean;
FParentShowHint: Boolean;
FPopupMenu: TPopupMenu;
FPreferredMinWidth: integer;// without theme space
FPreferredMinHeight: integer;// without theme space
FPreferredWidth: integer;// with theme space
FPreferredHeight: integer;// with theme space
FReadBounds: TRect;
@ -1172,6 +1174,10 @@ type
procedure GetPreferredSize(var PreferredWidth, PreferredHeight: integer;
Raw: boolean = false;
WithThemeSpace: boolean = true); virtual;
function GetDefaultWidth: integer;
function GetDefaultHeight: integer;
class function GetControlClassDefaultSize: TPoint; virtual;
function GetSidePosition(Side: TAnchorKind): integer;
procedure CNPreferredSizeChanged;
procedure InvalidatePreferredSize; virtual;
function GetAnchorsDependingOnParent(WithNormalAnchors: Boolean): TAnchors;
@ -1574,6 +1580,8 @@ type
protected
FWinControlFlags: TWinControlFlags;
procedure AdjustClientRect(var ARect: TRect); virtual;
procedure CreateControlAlignList(TheAlign: TAlign;
AlignList: TFPList; StartControl: TControl);
procedure AlignControls(AControl: TControl;
var RemainingClientRect: TRect); virtual;
function DoAlignChildControls(TheAlign: TAlign; AControl: TControl;
@ -1596,8 +1604,6 @@ type
procedure CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer;
WithThemeSpace: Boolean); override;
procedure GetChildBounds(var ChildBounds: TRect; WithBorderSpace,
FixateParentAnchors: boolean); virtual;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
function ChildClassAllowed(ChildClass: TClass): boolean; override;
procedure PaintControls(DC: HDC; First: TControl);
@ -2204,6 +2210,8 @@ procedure AdjustBorderSpace(var RemainingClientRect, CurBorderSpace: TRect;
function DbgS(a: TAnchorKind): string; overload;
function DbgS(Anchors: TAnchors): string; overload;
function DbgS(a: TAlign): string; overload;
function DbgS(a: TAnchorKind; Side: TAnchorSideReference): string;
// register (called by the package initialization in design mode)
procedure Register;
@ -2308,6 +2316,21 @@ begin
Result:='['+Result+']';
end;
function DbgS(a: TAlign): string;
begin
Result:=AlignNames[a];
end;
function DbgS(a: TAnchorKind; Side: TAnchorSideReference): string;
begin
case Side of
asrTop: if a in [akLeft,akRight] then Result:='asrLeft' else Result:='asrTop';
asrBottom: if a in [akLeft,akRight] then Result:='asrRight' else Result:='asrBottom';
asrCenter: Result:='asrCenter';
else Result:='asr???';
end;
end;
{------------------------------------------------------------------------------
RecreateWnd
This function was originally member of TWincontrol. From a VCL point of view
@ -3079,24 +3102,25 @@ begin
OwnerBorderSpacing:=FOwner.BorderSpacing.GetSpace(Kind);
case ReferenceSide of
asrTop:
asrTop: // asrTop = asrLeft
if Kind in [akLeft,akRight] then begin
// anchor to left side of ReferenceControl
if ReferenceControl=OwnerParent then
Position:=0
else
Position:=ReferenceControl.Left;
if ReferenceControl=OwnerParent then
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
OwnerParent.ChildSizing.LeftRightSpacing)
else if Kind=akRight then
OwnerBorderSpacing:=Max(Max(OwnerBorderSpacing,
ReferenceControl.BorderSpacing.GetSpace(OppositeAnchor[Kind])),
OwnerParent.ChildSizing.HorizontalSpacing);
if Kind=akLeft then begin
// anchor left of ReferenceControl and left of Owner
inc(Position,OwnerBorderSpacing);
end else begin
// anchor left of ReferenceControl and right of Owner
if ReferenceControl=OwnerParent then
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
OwnerParent.ChildSizing.LeftRightSpacing)
else
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
ReferenceControl.BorderSpacing.GetSpace(akLeft));
dec(Position,OwnerBorderSpacing);
end;
end else begin
@ -3105,36 +3129,38 @@ begin
Position:=0
else
Position:=ReferenceControl.Top;
if ReferenceControl=OwnerParent then
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
OwnerParent.ChildSizing.TopBottomSpacing)
else if Kind=akBottom then
OwnerBorderSpacing:=Max(Max(OwnerBorderSpacing,
ReferenceControl.BorderSpacing.GetSpace(OppositeAnchor[Kind])),
OwnerParent.ChildSizing.VerticalSpacing);
if Kind=akTop then begin
// anchor top of ReferenceControl and top of Owner
inc(Position,OwnerBorderSpacing);
end else begin
// anchor top of ReferenceControl and bottom of Owner
if ReferenceControl=OwnerParent then
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
OwnerParent.ChildSizing.TopBottomSpacing)
else
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
ReferenceControl.BorderSpacing.GetSpace(akTop));
dec(Position,OwnerBorderSpacing);
end;
end;
asrBottom:
asrBottom: // asrBottom = asrRight
if Kind in [akLeft,akRight] then begin
// anchor to right side of ReferenceControl
if ReferenceControl=OwnerParent then
Position:=OwnerParent.ClientWidth
else
Position:=ReferenceControl.Left+ReferenceControl.Width;
if ReferenceControl=OwnerParent then
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
OwnerParent.ChildSizing.LeftRightSpacing)
else if Kind=akLeft then
OwnerBorderSpacing:=Max(Max(OwnerBorderSpacing,
ReferenceControl.BorderSpacing.GetSpace(OppositeAnchor[Kind])),
OwnerParent.ChildSizing.HorizontalSpacing);
if Kind=akLeft then begin
// anchor right of ReferenceControl and left of Owner
if ReferenceControl=OwnerParent then
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
OwnerParent.ChildSizing.LeftRightSpacing)
else
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
ReferenceControl.BorderSpacing.GetSpace(akRight));
inc(Position,OwnerBorderSpacing);
end else begin
// anchor right of ReferenceControl and right of Owner
@ -3146,14 +3172,15 @@ begin
Position:=OwnerParent.ClientHeight
else
Position:=ReferenceControl.Top+ReferenceControl.Height;
if ReferenceControl=OwnerParent then
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
OwnerParent.ChildSizing.TopBottomSpacing)
else if Kind=akTop then
OwnerBorderSpacing:=Max(Max(OwnerBorderSpacing,
ReferenceControl.BorderSpacing.GetSpace(OppositeAnchor[Kind])),
OwnerParent.ChildSizing.VerticalSpacing);
if Kind=akTop then begin
// anchor bottom of ReferenceControl and top of Owner
if ReferenceControl=OwnerParent then
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
OwnerParent.ChildSizing.TopBottomSpacing)
else
OwnerBorderSpacing:=Max(OwnerBorderSpacing,
ReferenceControl.BorderSpacing.GetSpace(akBottom));
inc(Position,OwnerBorderSpacing);
end else begin
// anchor bottom of ReferenceControl and bottom of Owner

View File

@ -870,6 +870,7 @@ type
procedure HintsChanged(Sender: TObject); virtual;
procedure ButtonClickHandler(Sender: TObject); virtual;
procedure DoOnResize; override;
class function GetControlClassDefaultSize: TPoint; override;
procedure BeginUpdateButtons; virtual;
procedure EndUpdateButtons; virtual;
public

View File

@ -253,6 +253,7 @@ type
function GetGlyphSize(PaintRect: TRect): TSize; override;
function DrawGlyph(ACanvas: TCanvas; const AClient: TRect; const AOffset: TPoint;
AState: TButtonState; ATransparent: Boolean; BiDiFlags: Longint): TRect; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AnOwner: TComponent); override;
destructor Destroy; Override;

View File

@ -188,6 +188,7 @@ type
procedure ShowControl(APage: TControl); override;
procedure UpdateTabProperties; virtual;
function ChildClassAllowed(ChildClass: TClass): boolean; override;
class function GetControlClassDefaultSize: TPoint; override;
property ActivePageComponent: TCustomPage read GetActivePageComponent
write SetActivePageComponent;
property ActivePage: String read GetActivePage write SetActivePage
@ -356,6 +357,8 @@ type
procedure SetBrush(Value: TBrush);
procedure SetPen(Value: TPen);
procedure SetShape(Value: TShapeType);
protected
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -494,6 +497,7 @@ type
TPaintBox = class(TGraphicControl)
protected
procedure Paint; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
property Canvas;
@ -556,6 +560,7 @@ type
procedure CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer;
WithThemeSpace: Boolean); override;
class function GetControlClassDefaultSize: TPoint; override;
procedure DoAutoSize; override;
procedure Paint; override;
public
@ -994,6 +999,7 @@ type
procedure SetBorderWidth(const Value: TBorderWidth);
protected
procedure AdjustClientRect(var Rect: TRect); override;
class function GetControlClassDefaultSize: TPoint; override;
procedure CMParentColorChanged(var Message: TLMessage); message CM_PARENTCOLORCHANGED;
procedure Loaded; override;
procedure RealSetText(const Value: TCaption); override;

View File

@ -43,6 +43,7 @@ type
protected
procedure SetPreviewFileDialog(const AValue: TPreviewFileDialog);
procedure CreateParams(var Params: TCreateParams); override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(TheOwner: TComponent); override;
property PreviewFileDialog: TPreviewFileDialog read FPreviewFileDialog
@ -255,11 +256,17 @@ begin
Params.Style := Params.Style and DWORD(not WS_CHILD);
end;
class function TPreviewFileControl.GetControlClassDefaultSize: TPoint;
begin
Result.X:=200;
Result.Y:=200;
end;
constructor TPreviewFileControl.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
FCompStyle:=csPreviewFileControl;
SetInitialBounds(0,0,200,200);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
{ TPreviewFileDialog }

View File

@ -157,6 +157,7 @@ type
procedure CreateWnd; override;
function GetClientScrollOffset: TPoint; override;
procedure DoOnResize; override;
class function GetControlClassDefaultSize: TPoint; override;
procedure WMHScroll(var Message : TLMHScroll); message LM_HScroll;
procedure WMVScroll(var Message : TLMVScroll); message LM_VScroll;
procedure ScrollBy(DeltaX, DeltaY: Integer);
@ -250,6 +251,7 @@ type
procedure Notification(AComponent: TComponent;
Operation: TOperation); override;
procedure SetParent(AParent: TWinControl); override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
end;
@ -464,6 +466,7 @@ type
function VisibleIsStored: boolean;
function ColorIsStored: boolean; override;
procedure DoSendBoundsToInterface; override;
class function GetControlClassDefaultSize: TPoint; override;
protected
// drag and dock
procedure DoDock(NewDockSite: TWinControl; var ARect: TRect); override;
@ -683,6 +686,7 @@ type
procedure SetHideInterval(Value : Integer);
protected
procedure Paint; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;

View File

@ -30,7 +30,6 @@ begin
FButtonGlyph.OnChange := @GlyphChanged;
Align := alNone;
BorderSpacing.InnerBorder:=4;
SetInitialBounds(0,0,75,30);
RealizeKind;
end;
@ -263,4 +262,10 @@ begin
Result:=BorderSpacing.InnerBorder<>4;
end;
class function TCustomBitBtn.GetControlClassDefaultSize: TPoint;
begin
Result.X:=75;
Result.Y:=30;
end;
// included by buttons.pp

View File

@ -36,7 +36,7 @@ begin
Align := alNone;
BorderSpacing.InnerBorder:=4;
// setup default sizes
SetInitialBounds(0,0,75,25);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
{------------------------------------------------------------------------------
@ -271,6 +271,12 @@ begin
Result:=BorderSpacing.InnerBorder<>2;
end;
class function TCustomButton.GetControlClassDefaultSize: TPoint;
begin
Result.X:=75;
Result.Y:=25;
end;
function TCustomButton.UseRightToLeftAlignment: Boolean;
begin
//Button always has center alignment

View File

@ -26,7 +26,7 @@ begin
FButtonColorSize := 16;
FBorderWidth := 2;
FButtonColorAutoSize := True;
SetInitialBounds(1, 1, 75, 25);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
destructor TColorButton.Destroy;
@ -129,6 +129,12 @@ begin
Canvas.Rectangle(Result);
end;
class function TColorButton.GetControlClassDefaultSize: TPoint;
begin
Result.X:=75;
Result.Y:=25;
end;
procedure TColorButton.SetButtonColorSize(const AValue: Integer);
begin
if FButtonColorSize = AValue then Exit;

View File

@ -2811,6 +2811,7 @@ begin
' NewClientSize='+dbgs(NewBaseParentClientSize)+
'');}
FBaseBounds:=NewBaseBounds;
Include(FControlFlags,cfBaseBoundsValid);
FBaseParentClientSize:=NewBaseParentClientSize;
fLastAlignedBounds:=Rect(0,0,0,0);
end;
@ -4007,7 +4008,7 @@ end;
instead.
Raw: If not Raw then the values will be adjusted by the constraints and
undefined values will be replaced by the current width and height.
undefined values will be replaced by GetDefaultWidth/GetDefaultHeight.
WithThemeSpace: If true, adds space for stacking. For example: TRadioButton
has a minimum size. But for stacking multiple TRadioButtons there should be
@ -4020,17 +4021,31 @@ end;
procedure TControl.GetPreferredSize(var PreferredWidth,
PreferredHeight: integer; Raw: boolean; WithThemeSpace: boolean);
begin
if not (cfPreferredSizeValid in FControlFlags) then begin
CalculatePreferredSize(FPreferredWidth,FPreferredHeight,WithThemeSpace);
Include(FControlFlags,cfPreferredSizeValid);
if WithThemeSpace then begin
if not (cfPreferredSizeValid in FControlFlags) then begin
CalculatePreferredSize(FPreferredWidth,FPreferredHeight,true);
Include(FControlFlags,cfPreferredSizeValid);
end;
PreferredWidth:=FPreferredWidth;
PreferredHeight:=FPreferredHeight;
end else begin
if not (cfPreferredMinSizeValid in FControlFlags) then begin
CalculatePreferredSize(FPreferredMinWidth,FPreferredMinHeight,false);
Include(FControlFlags,cfPreferredMinSizeValid);
end;
PreferredWidth:=FPreferredMinWidth;
PreferredHeight:=FPreferredMinHeight;
end;
PreferredWidth:=FPreferredWidth;
PreferredHeight:=FPreferredHeight;
if not Raw then begin
// use Width and Height for undefined preferred size
if PreferredWidth<=0 then PreferredWidth:=Width;
if PreferredHeight<=0 then PreferredHeight:=Height;
// use defaults for undefined preferred size
if AutoSize then begin
if PreferredWidth<=0 then PreferredWidth:=GetDefaultWidth;
if PreferredHeight<=0 then PreferredHeight:=GetDefaultHeight;
end else begin
if PreferredWidth<=0 then PreferredWidth:=Width;
if PreferredHeight<=0 then PreferredHeight:=Height;
end;
// if this control is aligned adjust PreferredWidth and/or PreferredHeight
if Parent<>nil then begin
@ -4054,6 +4069,71 @@ begin
end;
end;
{------------------------------------------------------------------------------
function TControl.GetDefaultWidth: integer;
The default width for this control independent of any calculated values
like Width and GetPreferredSize.
------------------------------------------------------------------------------}
function TControl.GetDefaultWidth: integer;
begin
if cfBaseBoundsValid in FControlFlags then
Result:=FBaseBounds.Right-FBaseBounds.Left
else if cfWidthLoaded in FControlFlags then
Result:=FReadBounds.Right-FReadBounds.Left
else
Result:=GetControlClassDefaultSize.X;
end;
{------------------------------------------------------------------------------
function TControl.GetDefaultHeight: integer;
The default height for this control independent of any calculated values
like Height and GetPreferredSize.
------------------------------------------------------------------------------}
function TControl.GetDefaultHeight: integer;
begin
if cfBaseBoundsValid in FControlFlags then
Result:=BaseBounds.Bottom-BaseBounds.Top
else if cfHeightLoaded in FControlFlags then
Result:=FReadBounds.Bottom-FReadBounds.Top
else
Result:=GetControlClassDefaultSize.Y;
end;
{------------------------------------------------------------------------------
class function TControl.GetControlClassDefaultSize: TPoint;
The default size of this type of controls.
Used by GetDefaultWidth and GetDefaultHeight.
------------------------------------------------------------------------------}
class function TControl.GetControlClassDefaultSize: TPoint;
begin
Result.X:=75;
Result.Y:=50;
end;
{------------------------------------------------------------------------------
procedure TControl.CNPreferredSizeChanged;
Utility function to retrieve Left,Top,Right and Bottom.
------------------------------------------------------------------------------}
function TControl.GetSidePosition(Side: TAnchorKind): integer;
begin
case Side of
akLeft: Result:=Left;
akTop: Result:=Top;
akRight: Result:=Left+Width;
akBottom: Result:=Top+Height;
end;
end;
{------------------------------------------------------------------------------
procedure TControl.CNPreferredSizeChanged;
Called by the LCL interface, when something changed that effects the result
of the interface values for GetPreferredSize.
------------------------------------------------------------------------------}
procedure TControl.CNPreferredSizeChanged;
begin
InvalidatePreferredSize;
@ -4071,6 +4151,7 @@ begin
AControl:=Self;
while AControl<>nil do begin
Exclude(AControl.FControlFlags,cfPreferredSizeValid);
Exclude(AControl.FControlFlags,cfPreferredMinSizeValid);
AControl:=AControl.Parent;
end;
end;

View File

@ -90,7 +90,7 @@ begin
FState := cbUnchecked;
FAllowGrayed := false;
TabStop := true;
SetInitialBounds(0, 0, 90, 23);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
AutoSize := true;
end;
@ -183,6 +183,12 @@ begin
end;
end;
class function TCustomCheckBox.GetControlClassDefaultSize: TPoint;
begin
Result.X:=90;
Result.Y:=23;
end;
procedure TCustomCheckBox.Loaded;
begin
// Send first the FState to the interface before calling inherited,

View File

@ -41,7 +41,6 @@ begin
ChildSizing.EnlargeVertical:=crsHomogenousChildResize;
ChildSizing.LeftRightSpacing:=6;
ChildSizing.TopBottomSpacing:=6;
SetInitialBounds(0,0,150,100);
end;
destructor TCustomCheckGroup.Destroy;

View File

@ -103,6 +103,12 @@ begin
end;
end;
class function TCustomComboBox.GetControlClassDefaultSize: TPoint;
begin
Result.X:=100;
Result.Y:=25;
end;
procedure TCustomComboBox.DoEnter;
begin
inherited DoEnter;
@ -709,7 +715,7 @@ begin
inherited Create(TheOwner);
fCompStyle := csComboBox;
SetInitialBounds(0,0,100,25);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
FItems := TStringlist.Create;
FItemIndex:=-1;
FMaxLength := -1;

View File

@ -52,7 +52,7 @@ begin
FMaxLength:= -1;
ParentColor := false;
TabStop := true;
SetInitialBounds(0,0,80,23);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
FEchoMode := emNormal;
BorderStyle := bsSingle;
FAutoSelect := False;
@ -347,6 +347,12 @@ begin
Result:=false;
end;
class function TCustomEdit.GetControlClassDefaultSize: TPoint;
begin
Result.X:=80;
Result.Y:=23;
end;
procedure TCustomEdit.KeyUp(var Key: Word; Shift: TShiftState);
begin
inherited KeyUp(Key, Shift);

View File

@ -971,6 +971,12 @@ begin
end;
end;
class function TCustomForm.GetControlClassDefaultSize: TPoint;
begin
Result.X:=320;
Result.Y:=240;
end;
procedure TCustomForm.DoDock(NewDockSite: TWinControl; var ARect: TRect);
begin
if (NewDockSite<>HostDockSite) then begin
@ -1379,7 +1385,7 @@ begin
ControlStyle := ControlStyle + [csAcceptsControls, csCaptureMouse,
csClickEvents, csSetCaption, csDoubleClicks];
SetInitialBounds(0,0,320,240);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
ParentColor := False;
ParentFont := False;
Ctl3D := True;

View File

@ -83,6 +83,12 @@ begin
if Parent<>nil then UpdateActionLists(opInsert);
end;
class function TCustomFrame.GetControlClassDefaultSize: TPoint;
begin
Result.X:=320;
Result.Y:=240;
end;
constructor TCustomFrame.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
@ -92,7 +98,7 @@ begin
if not InitInheritedComponent(Self,TFrame) then
raise EResNotFound.CreateFmt(rsResourceNotFound, [ClassName]);
end else begin
SetInitialBounds(0,0,320,240);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
end;

View File

@ -14,16 +14,21 @@
*****************************************************************************
}
{------------------------------------------------------------------------------}
{ function TCustomGroupBox.Create }
{------------------------------------------------------------------------------}
class function TCustomGroupBox.GetControlClassDefaultSize: TPoint;
begin
Result.X:=185;
Result.Y:=105;
end;
{------------------------------------------------------------------------------
function TCustomGroupBox.Create
------------------------------------------------------------------------------}
constructor TCustomGroupBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fCompStyle := csGroupBox;
ControlStyle := ControlStyle + [csAcceptsControls];
Width:= 185;
Height:= 105;
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
// included by stdctrls.pp

View File

@ -28,7 +28,7 @@ begin
FPicture := TPicture.Create;
FPicture.OnChange := @PictureChanged;
FUseParentCanvas := false;
SetInitialBounds(0,0,100,100);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
destructor TCustomImage.Destroy;
@ -91,7 +91,6 @@ var
end;
begin
if not AutoSize then Exit; // needless to check
if AutoSizing then Exit; // we shouldn't come here in the first place
BeginAutoSizing;
@ -109,7 +108,6 @@ begin
if (NewWidth<>Width) or (NewHeight<>Height)
then begin
SetBounds(Left, Top, NewWidth, NewHeight);
// PictureChanged(Self);
end;
finally
EndAutoSizing;
@ -198,6 +196,12 @@ begin
PreferredHeight := Picture.Height;
end;
class function TCustomImage.GetControlClassDefaultSize: TPoint;
begin
Result.X:=90;
Result.Y:=90;
end;
procedure TCustomImage.Paint;
procedure DrawFrame;

View File

@ -62,6 +62,12 @@ begin
AdjustSize;
end;
class function TCustomLabel.GetControlClassDefaultSize: TPoint;
begin
Result.X:=65;
Result.Y:=17;
end;
function TCustomLabel.HasMultiLine: boolean;
var
s: String;
@ -196,7 +202,7 @@ constructor TCustomLabel.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
ControlStyle := [csSetCaption, csClickEvents, csDoubleClicks, csReplicatable];
setInitialBounds(0,0,65,17);
setInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
FShowAccelChar := True;
Color := clNone;
AutoSize:=true;

View File

@ -105,7 +105,6 @@ begin
FLabelPosition := lpAbove;
FLabelSpacing := 3;
CreateInternalLabel;
SetInitialBounds(0,0,80,25);
end;
procedure TCustomLabeledEdit.CreateInternalLabel;

View File

@ -135,9 +135,15 @@ begin
UnlockSelectionChange;
end;
{------------------------------------------------------------------------------}
{ procedure TCustomListBox.UpdateSelectionMode }
{------------------------------------------------------------------------------}
class function TCustomListBox.GetControlClassDefaultSize: TPoint;
begin
Result.X:=100;
Result.Y:=80;
end;
{------------------------------------------------------------------------------
procedure TCustomListBox.UpdateSelectionMode
------------------------------------------------------------------------------}
procedure TCustomListBox.UpdateSelectionMode;
begin
if not HandleAllocated then exit;
@ -461,9 +467,9 @@ begin
end;
end;
{------------------------------------------------------------------------------}
{ function TCustomListBox.Create }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------
function TCustomListBox.Create
------------------------------------------------------------------------------}
constructor TCustomListBox.Create(TheOwner : TComponent);
begin
inherited Create(TheOwner);
@ -479,13 +485,13 @@ begin
TControlCanvas(FCanvas).Control := Self;
ParentColor := false;
TabStop := true;
SetInitialBounds(0, 0, 100, 80);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
UnlockSelectionChange;
end;
{------------------------------------------------------------------------------}
{ function TCustomListBox.Destroy }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------
function TCustomListBox.Destroy
------------------------------------------------------------------------------}
destructor TCustomListBox.Destroy;
begin
Destroying;

View File

@ -37,7 +37,7 @@ begin
end;
FHoverTime := -1;
TabStop := true;
SetInitialBounds(0,0,100,90);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
ParentColor := False;
Color := clWindow;
FCanvas := TControlCanvas.Create;
@ -45,9 +45,9 @@ begin
FProperties := [lvpColumnClick, lvpHideSelection, lvpShowColumnHeaders, lvpToolTips];
end;
{------------------------------------------------------------------------------}
{ TCustomListView CustomDraw }
{------------------------------------------------------------------------------}
{------------------------------------------------------------------------------
TCustomListView CustomDraw
------------------------------------------------------------------------------}
function TCustomListView.CustomDraw(const ARect: TRect; AStage: TCustomDrawStage): Boolean;
begin
Result := True;

View File

@ -38,7 +38,6 @@ begin
//TMemoStrings(FLines).MemoWidgetClass := TWSCustomMemoClass(WidgetSetClass);
FVertScrollbar := TMemoScrollBar.Create(Self, sbVertical);
FHorzScrollbar := TMemoScrollBar.Create(Self, sbHorizontal);
SetInitialBounds(0,0,150,90);
end;
{------------------------------------------------------------------------------
@ -248,6 +247,12 @@ begin
end;
end;
class function TCustomMemo.GetControlClassDefaultSize: TPoint;
begin
Result.X:=150;
Result.Y:=90;
end;
procedure TCustomMemo.SetWantTabs(const NewWantTabs: boolean);
begin
if FWantTabs = NewWantTabs then exit;

View File

@ -212,7 +212,7 @@ begin
TabPosition := tpTop;
TabStop := true;
ShowTabs := True;
SetInitialBounds(0,0,200,200);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
{------------------------------------------------------------------------------
@ -719,6 +719,12 @@ begin
Result:=(ChildClass<>nil) and (ChildClass.InheritsFrom(PageClass));
end;
class function TCustomNotebook.GetControlClassDefaultSize: TPoint;
begin
Result.X:=200;
Result.Y:=200;
end;
{------------------------------------------------------------------------------
TCustomNotebook Change
------------------------------------------------------------------------------}

View File

@ -41,7 +41,7 @@ begin
FAlignment := taCenter;
FFullRepaint := true;
Color:=clBtnFace;// clBackground;
SetInitialBounds(0,0,170,50);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
ParentColor := True;
end;
@ -138,6 +138,12 @@ begin
InflateRect(Rect, -BevelSize, -BevelSize);
end;
class function TCustomPanel.GetControlClassDefaultSize: TPoint;
begin
Result.X:=170;
Result.Y:=50;
end;
procedure TCustomPanel.Loaded;
begin
inherited Loaded;

View File

@ -33,7 +33,7 @@ begin
FShowAccelChar:= true;
FStaticBorderStyle:=sbsNone;
ControlStyle := ControlStyle + [csOpaque, csReplicatable];
SetInitialBounds(0, 0, 65, 17);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
{------------------------------------------------------------------------------
@ -123,6 +123,12 @@ begin
Result := inherited;
end;
class function TCustomStaticText.GetControlClassDefaultSize: TPoint;
begin
Result.X:=65;
Result.Y:=17;
end;
Procedure TCustomStaticText.SetStaticBorderStyle(Value : TStaticBorderStyle);
procedure RaiseNotImplemented;

View File

@ -209,7 +209,7 @@ begin
FOrientation := udVertical;
MinBtn := TUpDownButton.CreateWithParams(Self, btPrev);
MaxBtn := TUpDownButton.CreateWithParams(Self, btNext);
SetInitialBounds(0,0,17,31);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
BTimerProc := nil;
BTimerBounds := Rect(0,0,0,0);
FArrowKeys := True;
@ -392,6 +392,12 @@ begin
UpdateOrientation;
end;
class function TCustomUpDown.GetControlClassDefaultSize: TPoint;
begin
Result.X:=17;
Result.Y:=31;
end;
procedure TCustomUpDown.Notification(AComponent: TComponent;
Operation: TOperation);
begin

View File

@ -1,4 +1,4 @@
{%MainUnit ../dbctrls.pas}
{%MainUnit ../dbctrls.pp}
{
*****************************************************************************
* *
@ -336,6 +336,12 @@ begin
UpdateButtons;
end;
class function TDBCustomNavigator.GetControlClassDefaultSize: TPoint;
begin
Result.X:=241;
Result.Y:=25;
end;
procedure TDBCustomNavigator.BeginUpdateButtons;
begin
inc(FUpdateButtonsLock);
@ -367,7 +373,7 @@ begin
BevelOuter:=bvNone;
BevelInner:=bvNone;
FConfirmDelete:=True;
SetInitialBounds(0,0,241,25);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
UpdateButtons;
EndUpdateButtons;
UpdateHints;

View File

@ -67,7 +67,7 @@ begin
FSections := CreateSections;
ControlStyle := ControlStyle + [csCaptureMouse, csClickEvents, csNoFocus, csOpaque] -
[csSetCaption];
SetInitialBounds(0, 0, 170, 30);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
destructor TCustomHeaderControl.Destroy;
@ -193,6 +193,12 @@ begin
Sections[i].State := MaxState;
end;
class function TCustomHeaderControl.GetControlClassDefaultSize: TPoint;
begin
Result.X:=170;
Result.Y:=30;
end;
procedure TCustomHeaderControl.Paint;
var
Details: TThemedElementDetails;

View File

@ -36,7 +36,7 @@ begin
Canvas.Font := Screen.HintFont;
BorderStyle := bsNone;
Caption := 'THintWindow';
SetInitialBounds(1,1,25,25);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
FHideInterval := 3000;
TheTimer := TCustomTimer.Create(self);
FAutoHideTimer := TheTimer;
@ -91,6 +91,12 @@ begin
DT_NOPREFIX or DT_CENTER or DT_VCENTER or DT_WORDBREAK);
end;
class function THintWindow.GetControlClassDefaultSize: TPoint;
begin
Result.X:=25;
Result.Y:=25;
end;
procedure THintWindow.ActivateHint(ARect: TRect; const AHint: String);
begin
ActivateHintData(ARect, AHint, nil);

View File

@ -20,7 +20,7 @@ constructor TPaintBox.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csReplicatable];
SetInitialBounds(0,0,105,105);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
procedure TPaintBox.Paint;
@ -45,4 +45,10 @@ begin
end;
end;
class function TPaintBox.GetControlClassDefaultSize: TPoint;
begin
Result.X:=105;
Result.Y:=105;
end;
// included by extctrls.pp

View File

@ -46,13 +46,13 @@ begin
fCompStyle := csProgressBar;
FPosition := 0;
FStep := 10;
FMin := 0;
FMax := 100;
FMin := 0;
FMax := 100;
FSmooth := false;
FOrientation := pbHorizontal;
FBarShowText := false;
FBarTextFormat := '%v from [%l-%u] (=%p%%)';
SetInitialBounds(0,0,100,20);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
{------------------------------------------------------------------------------
@ -75,6 +75,12 @@ begin
ApplyChanges;
end;
class function TCustomProgressBar.GetControlClassDefaultSize: TPoint;
begin
Result.X:=100;
Result.Y:=20;
end;
{------------------------------------------------------------------------------
Method: TCustomProgressBar.GetMin
Params: Nothing

View File

@ -51,7 +51,6 @@ begin
ChildSizing.EnlargeVertical:=crsHomogenousChildResize;
ChildSizing.LeftRightSpacing:=6;
ChildSizing.TopBottomSpacing:=6;
SetInitialBounds(0,0,150,100);
TabStop := True;
end;

View File

@ -62,6 +62,12 @@ begin
UpdateScrollBars;
end;
class function TScrollingWinControl.GetControlClassDefaultSize: TPoint;
begin
Result.X:=150;
Result.Y:=150;
end;
procedure TScrollingWinControl.SetHorzScrollBar(Value: TControlScrollBar);
begin
FHorzScrollbar.Assign(Value);
@ -219,7 +225,7 @@ begin
ControlStyle := [csAcceptsControls, csClickEvents, csDoubleClicks];
SetInitialBounds(0,0, 150, 150);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
destructor TScrollingWinControl.Destroy;

View File

@ -17,7 +17,7 @@
constructor TShape.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
SetInitialBounds(0,0,65,65);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
ControlStyle := ControlStyle + [csReplicatable];
FPen := TPen.Create;
FPen.OnChange := @StyleChanged;
@ -105,3 +105,10 @@ begin
StyleChanged(Self);
end;
end;
class function TShape.GetControlClassDefaultSize: TPoint;
begin
Result.X:=65;
Result.Y:=65;
end;

View File

@ -137,9 +137,9 @@ var
begin
Result:=Width;
MinW:=EffectiveMinWidth;
if (MinW>0) and (Width<MinW) then Width:=MinW;
if (MinW>0) and (Result<MinW) then Result:=MinW;
MaxW:=EffectiveMaxWidth;
if (MaxW>0) and (Width>MaxW) then Width:=MaxW;
if (MaxW>0) and (Result>MaxW) then Result:=MaxW;
end;
function TSizeConstraints.MinMaxHeight(Height: integer): integer;
@ -149,9 +149,9 @@ var
begin
Result:=Height;
MinH:=EffectiveMinHeight;
if (MinH>0) and (Height<MinH) then Height:=MinH;
if (MinH>0) and (Result<MinH) then Result:=MinH;
MaxH:=EffectiveMaxHeight;
if (MaxH>0) and (Height>MaxH) then Height:=MaxH;
if (MaxH>0) and (Result>MaxH) then Result:=MaxH;
end;
{------------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ begin
FGlyph := TButtonGlyph.Create;
FGlyph.OnChange := @GlyphChanged;
SetInitialBounds(0, 0, 23, 22);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
ControlStyle := ControlStyle + [csCaptureMouse]-[csSetCaption, csClickEvents];
FLayout:= blGlyphLeft;
@ -393,6 +393,12 @@ begin
Result := TSpeedButtonActionLink;
end;
class function TCustomSpeedButton.GetControlClassDefaultSize: TPoint;
begin
Result.X:=23;
Result.Y:=22;
end;
{------------------------------------------------------------------------------
Method: TCustomSpeedButton.UpdateExclusive
Params: none

View File

@ -104,6 +104,12 @@ begin
if FUpdatePending then UpdateControl;
end;
class function TCustomFloatSpinEdit.GetControlClassDefaultSize: TPoint;
begin
Result.X:=50;
Result.Y:=23;
end;
procedure TCustomFloatSpinEdit.SetValue(const AValue: Single);
begin
if FValue = AValue then Exit;
@ -146,7 +152,7 @@ begin
FUpdatePending := True;
FValueChanged := True;
SetInitialBounds(0, 0, 50, 23);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
function TCustomFloatSpinEdit.GetLimitedValue(const AValue: Single): Single;

View File

@ -530,6 +530,12 @@ begin
TTabControlStrings(FTabs).TabControlBoundsChange;
end;
class function TCustomTabControl.GetControlClassDefaultSize: TPoint;
begin
Result.X:=200;
Result.Y:=150;
end;
procedure TCustomTabControl.Paint;
var
ARect: TRect;
@ -587,7 +593,7 @@ begin
FImageChangeLink := TChangeLink.Create;
FImageChangeLink.OnChange := @ImageListChange;
FTabs:=TTabControlNoteBookStrings.Create(Self);
SetInitialBounds(0,0,200,150);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
BorderWidth:=2;
FTabControlCreating:=false;
end;

View File

@ -21,7 +21,6 @@ begin
inherited Create(TheOwner);
fCompStyle := csToggleBox;
AutoSize:=false;
SetInitialBounds(0,0,90,25);
end;
{------------------------------------------------------------------------------}

View File

@ -72,7 +72,7 @@ begin
FHotImageChangeLink := TChangeLink.Create;
FHotImageChangeLink.OnChange := @HotImageListChange;
EdgeBorders := [ebTop];
SetInitialBounds(0,0,150,26);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
Align := alTop;
end;
@ -547,6 +547,12 @@ begin
inc(ARect.Left,Indent);
end;
class function TToolBar.GetControlClassDefaultSize: TPoint;
begin
Result.X:=150;
Result.Y:=26;
end;
function TToolBar.FindButtonFromAccel(Accel: Word): TToolButton;
var
i: Integer;

View File

@ -60,7 +60,7 @@ begin
FImageIndex := -1;
FStyle := tbsButton;
ControlStyle := [csCaptureMouse, csSetCaption, csDesignNoSmoothResize];
SetInitialBounds(0,0,23,22);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
procedure TToolButton.MouseDown(Button: TMouseButton; Shift: TShiftState;
@ -811,6 +811,12 @@ begin
end;
end;
class function TToolButton.GetControlClassDefaultSize: TPoint;
begin
Result.X:=23;
Result.Y:=22;
end;
// included by comctrls.pp

View File

@ -70,7 +70,7 @@ begin
FTickMarks:=tmBottomRight;
FTickStyle:=tsAuto;
TabStop := true;
SetInitialBounds(0,0,100,25);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
end;
{------------------------------------------------------------------------------
@ -313,6 +313,12 @@ begin
if Assigned (FOnChange) then FOnChange(Self);
end;
class function TCustomTrackBar.GetControlClassDefaultSize: TPoint;
begin
Result.X:=100;
Result.Y:=25;
end;
{------------------------------------------------------------------------------
Method: TCustomTrackBar.SetScalePos
Params: value : position of the scaling text

File diff suppressed because it is too large Load Diff

View File

@ -101,6 +101,7 @@ type
protected
function GetCursor: TCursor; override;
procedure SetCursor(Value: TCursor); override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(TheOwner: TComponent); override;
destructor Destroy; override;
@ -331,6 +332,12 @@ begin
inherited SetCursor(Value);
end;
class function TCustomPairSplitter.GetControlClassDefaultSize: TPoint;
begin
Result.X:=90;
Result.Y:=90;
end;
constructor TCustomPairSplitter.Create(TheOwner: TComponent);
begin
inherited Create(TheOwner);
@ -338,7 +345,7 @@ begin
ControlStyle := ControlStyle - [csAcceptsControls];
FSplitterType := pstHorizontal;
Cursor := crHSplit;
SetInitialBounds(0, 0, 90, 90);
SetInitialBounds(0,0,GetControlClassDefaultSize.X,GetControlClassDefaultSize.Y);
FPosition:=45;
CreateSides;
end;

View File

@ -60,6 +60,7 @@ type
procedure InitializeWnd; override;
procedure FinalizeWnd; override;
procedure Loaded; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(TheOwner: TComponent); override;
function GetLimitedValue(const AValue: Single): Single;

View File

@ -160,6 +160,7 @@ type
TCustomGroupBox = class (TWinControl)
protected
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); Override;
end;
@ -293,6 +294,7 @@ type
procedure DoExit; override;
procedure DrawItem(Index: Integer; ARect: TRect;
State: TOwnerDrawState); virtual;
class function GetControlClassDefaultSize: TPoint; override;
procedure LMChanged(var Msg); message LM_CHANGED;
procedure Change; dynamic;
procedure Select; dynamic;
@ -484,6 +486,7 @@ type
procedure Loaded; override;
procedure InitializeWnd; override;
procedure FinalizeWnd; override;
class function GetControlClassDefaultSize: TPoint; override;
procedure CheckIndex(const AIndex: Integer);
function GetItemHeight: Integer;
function GetItemIndex: integer; virtual;
@ -671,6 +674,7 @@ type
procedure SetSelText(const Val: string); virtual;
procedure RealSetText(const Value: TCaption); override;
function ChildClassAllowed(ChildClass: TClass): boolean; override;
class function GetControlClassDefaultSize: TPoint; override;
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
procedure WMChar(var Message: TLMChar); message LM_CHAR;
procedure MouseUp(Button: TMouseButton; Shift:TShiftState; X, Y: Integer); override;
@ -752,6 +756,7 @@ type
function WordWrapIsStored: boolean; virtual;
procedure ControlKeyDown(var Key: Word; Shift: TShiftState); override;
procedure CNChar(var Message: TLMKeyUp); message CN_CHAR;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
@ -893,6 +898,7 @@ type
procedure SetFocusControl(Val: TWinControl); virtual;
procedure SetShowAccelChar(Val: boolean); virtual;
function DialogChar(var Message: TLMKey): boolean; override;
class function GetControlClassDefaultSize: TPoint; override;
public
constructor Create(AOwner: TComponent); override;
property Alignment: TAlignment read FAlignment write SetAlignment default taLeftJustify;
@ -1005,6 +1011,7 @@ type
function DialogChar(var Message: TLMKey): boolean; override;
function ChildClassAllowed(ChildClass: TClass): boolean; override;
function IsBorderSpacingInnerBorderStored: Boolean; override;
class function GetControlClassDefaultSize: TPoint; override;
property ParentColor default false;
function UseRightToLeftAlignment: Boolean; override;
procedure WSSetDefault;
@ -1097,6 +1104,7 @@ type
procedure SetChecked(Value: Boolean); override;
procedure RealSetText(const Value: TCaption); override;
procedure ApplyChanges; virtual;
class function GetControlClassDefaultSize: TPoint; override;
procedure Loaded; override;
procedure WSSetText(const AText: String); override;
public
@ -1355,6 +1363,7 @@ type
procedure TextChanged; override;
procedure Resize; override;
procedure FontChanged(Sender: TObject); override;
class function GetControlClassDefaultSize: TPoint; override;
procedure WMActivate(var Message: TLMActivate); message LM_ACTIVATE;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
@ -1380,12 +1389,12 @@ type
property WordWrap: Boolean read FWordWrap write SetWordWrap default false;
property OptimalFill: Boolean read FOptimalFill write SetOptimalFill default false;
public
constructor Create(TheOwner: TComponent); override;
function CalcFittingFontHeight(const TheText: string;
MaxWidth, MaxHeight: Integer; var FontHeight,
NeededWidth, NeededHeight: integer): Boolean;
function ColorIsStored: boolean; override;
function AdjustFontForOptimalFill: Boolean;
constructor Create(TheOwner: TComponent); override;
procedure Paint; override;
property AutoSize default True;
property Color default clNone;