mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 17:21:34 +01:00 
			
		
		
		
	LCL: introduced TFlowPanel
git-svn-id: trunk@50372 -
This commit is contained in:
		
							parent
							
								
									b8b626d91e
								
							
						
					
					
						commit
						b3f4d8ce1b
					
				
							
								
								
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
								
							| @ -6148,6 +6148,7 @@ images/components/tfilenameedit.png -text svneol=unset#image/png | |||||||
| images/components/tfiltercombobox.png -text | images/components/tfiltercombobox.png -text | ||||||
| images/components/tfinddialog.png -text svneol=unset#image/png | images/components/tfinddialog.png -text svneol=unset#image/png | ||||||
| images/components/tfloatspinedit.png -text svneol=unset#image/png | images/components/tfloatspinedit.png -text svneol=unset#image/png | ||||||
|  | images/components/tflowpanel.png -text svneol=unset#image/png | ||||||
| images/components/tfontdialog.png -text svneol=unset#image/png | images/components/tfontdialog.png -text svneol=unset#image/png | ||||||
| images/components/tframe.png -text svneol=unset#image/png | images/components/tframe.png -text svneol=unset#image/png | ||||||
| images/components/tgroupbox.png -text svneol=unset#image/png | images/components/tgroupbox.png -text svneol=unset#image/png | ||||||
| @ -6756,6 +6757,7 @@ lcl/include/customdbcombobox.inc svneol=native#text/pascal | |||||||
| lcl/include/customdblistbox.inc svneol=native#text/pascal | lcl/include/customdblistbox.inc svneol=native#text/pascal | ||||||
| lcl/include/customdockform.inc svneol=native#text/pascal | lcl/include/customdockform.inc svneol=native#text/pascal | ||||||
| lcl/include/customedit.inc svneol=native#text/pascal | lcl/include/customedit.inc svneol=native#text/pascal | ||||||
|  | lcl/include/customflowpanel.inc svneol=native#text/pascal | ||||||
| lcl/include/customform.inc svneol=native#text/pascal | lcl/include/customform.inc svneol=native#text/pascal | ||||||
| lcl/include/customframe.inc svneol=native#text/pascal | lcl/include/customframe.inc svneol=native#text/pascal | ||||||
| lcl/include/customgroupbox.inc svneol=native#text/pascal | lcl/include/customgroupbox.inc svneol=native#text/pascal | ||||||
|  | |||||||
							
								
								
									
										
											BIN
										
									
								
								images/components/tflowpanel.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								images/components/tflowpanel.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 1.1 KiB | 
										
											Binary file not shown.
										
									
								
							| @ -51,6 +51,7 @@ components/tfilenameedit.png | |||||||
| components/tfiltercombobox.png | components/tfiltercombobox.png | ||||||
| components/tfinddialog.png | components/tfinddialog.png | ||||||
| components/tfloatspinedit.png | components/tfloatspinedit.png | ||||||
|  | components/tflowpanel.png | ||||||
| components/tfontdialog.png | components/tfontdialog.png | ||||||
| components/tframe.png | components/tframe.png | ||||||
| components/tgroupbox.png | components/tgroupbox.png | ||||||
|  | |||||||
							
								
								
									
										143
									
								
								lcl/extctrls.pp
									
									
									
									
									
								
							
							
						
						
									
										143
									
								
								lcl/extctrls.pp
									
									
									
									
									
								
							| @ -1096,6 +1096,146 @@ type | |||||||
|     property OnUnDock; |     property OnUnDock; | ||||||
|   end; |   end; | ||||||
| 
 | 
 | ||||||
|  |   { TCustomFlowPanel } | ||||||
|  | 
 | ||||||
|  |   TFlowPanel = class; | ||||||
|  |   TCustomFlowPanel = class; | ||||||
|  |   TFlowPanelControl = class; | ||||||
|  |   TFlowPanelControlList = class; | ||||||
|  | 
 | ||||||
|  |   TFlowStyle = (fsLeftRightTopBottom, fsRightLeftTopBottom, fsLeftRightBottomTop, fsRightLeftBottomTop, | ||||||
|  |                 fsTopBottomLeftRight, fsBottomTopLeftRight, fsTopBottomRightLeft, fsBottomTopRightLeft); | ||||||
|  | 
 | ||||||
|  |   TWrapAfter = ( | ||||||
|  |     waAuto,    // auto | ||||||
|  |     waForce,   // always wrap after this control | ||||||
|  |     waAvoid,   // try not to wrap after this control, if the control is already at the beginning of the row, wrap though | ||||||
|  |     waForbid); // never wrap after this control | ||||||
|  | 
 | ||||||
|  |   TFlowPanelControl = class(TCollectionItem) | ||||||
|  |   private | ||||||
|  |     FControl: TControl; | ||||||
|  |     FWrapAfter: TWrapAfter; | ||||||
|  |     procedure SetControl(const aControl: TControl); | ||||||
|  |     procedure SetWrapAfter(const AWrapAfter: TWrapAfter); | ||||||
|  |   protected | ||||||
|  |     procedure SetIndex(Value: Integer); override; | ||||||
|  |     procedure AssignTo(Dest: TPersistent); override; | ||||||
|  |     function FPCollection: TFlowPanelControlList; | ||||||
|  |     function FPOwner: TCustomFlowPanel; | ||||||
|  |   published | ||||||
|  |     property Control: TControl read FControl write SetControl; | ||||||
|  |     property WrapAfter: TWrapAfter read FWrapAfter write SetWrapAfter; | ||||||
|  |     property Index; | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  |   TFlowPanelControlList = class(TOwnedCollection) | ||||||
|  |   private | ||||||
|  |     function GetItem(Index: Integer): TFlowPanelControl; | ||||||
|  |     procedure SetItem(Index: Integer; const AItem: TFlowPanelControl); | ||||||
|  |   protected | ||||||
|  |     function FPOwner: TCustomFlowPanel; | ||||||
|  | 
 | ||||||
|  |     function Add: TFlowPanelControl; | ||||||
|  |     procedure AddControl(AControl: TControl; AIndex: Integer = -1); | ||||||
|  |     procedure RemoveControl(AControl: TControl); | ||||||
|  |   public | ||||||
|  |     constructor Create(AOwner: TPersistent); | ||||||
|  |   public | ||||||
|  |     function IndexOf(AControl: TControl): Integer; | ||||||
|  | 
 | ||||||
|  |     property Items[Index: Integer]: TFlowPanelControl read GetItem write SetItem; default; | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  |   TCustomFlowPanel = class(TCustomPanel) | ||||||
|  |   private | ||||||
|  |     FControlList: TFlowPanelControlList; | ||||||
|  |     FAutoWrap: Boolean; | ||||||
|  |     FFlowStyle: TFlowStyle; | ||||||
|  |     procedure SetAutoWrap(const AAutoWrap: Boolean); | ||||||
|  |     procedure SetControlList(const AControlList: TFlowPanelControlList); | ||||||
|  |     procedure SetFlowStyle(const AFlowStyle: TFlowStyle); | ||||||
|  |   protected | ||||||
|  |     procedure CMControlChange(var Message: TCMControlChange); message CM_CONTROLCHANGE; | ||||||
|  | 
 | ||||||
|  |     procedure AlignControls(AControl: TControl; var RemainingClientRect: TRect); override; | ||||||
|  |     procedure CalculatePreferredSize( | ||||||
|  |                          var PreferredWidth, PreferredHeight: integer; | ||||||
|  |                          WithThemeSpace: Boolean); override; | ||||||
|  |   public | ||||||
|  |     constructor Create(AOwner: TComponent); override; | ||||||
|  |     destructor Destroy; override; | ||||||
|  |   public | ||||||
|  |     function GetControlIndex(AControl: TControl): Integer; | ||||||
|  |     procedure SetControlIndex(AControl: TControl; Index: Integer); | ||||||
|  | 
 | ||||||
|  |     property AutoWrap: Boolean read FAutoWrap write SetAutoWrap; | ||||||
|  |     property ControlList: TFlowPanelControlList read FControlList write SetControlList; | ||||||
|  |     property FlowStyle: TFlowStyle read FFlowStyle write SetFlowStyle; | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|  |   TFlowPanel = class(TCustomFlowPanel) | ||||||
|  |   published | ||||||
|  |     property Align; | ||||||
|  |     property Alignment; | ||||||
|  |     property Anchors; | ||||||
|  |     property AutoSize; | ||||||
|  |     property AutoWrap default True; | ||||||
|  |     property BevelInner; | ||||||
|  |     property BevelOuter; | ||||||
|  |     property BevelWidth; | ||||||
|  |     property BiDiMode; | ||||||
|  |     property BorderWidth; | ||||||
|  |     property BorderStyle; | ||||||
|  |     property Caption; | ||||||
|  |     property Color; | ||||||
|  |     property Constraints; | ||||||
|  |     property ControlList; | ||||||
|  |     property UseDockManager default True; | ||||||
|  |     property DockSite; | ||||||
|  |     property DoubleBuffered; | ||||||
|  |     property DragCursor; | ||||||
|  |     property DragKind; | ||||||
|  |     property DragMode; | ||||||
|  |     property Enabled; | ||||||
|  |     property FlowStyle; | ||||||
|  |     property FullRepaint; | ||||||
|  |     property Font; | ||||||
|  |     property ParentBiDiMode; | ||||||
|  |     property ParentColor; | ||||||
|  |     property ParentFont; | ||||||
|  |     property ParentShowHint; | ||||||
|  |     property PopupMenu; | ||||||
|  |     property ShowHint; | ||||||
|  |     property TabOrder; | ||||||
|  |     property TabStop; | ||||||
|  |     property Visible; | ||||||
|  |     property OnAlignInsertBefore; | ||||||
|  |     property OnAlignPosition; | ||||||
|  |     property OnClick; | ||||||
|  |     property OnConstrainedResize; | ||||||
|  |     property OnContextPopup; | ||||||
|  |     property OnDockDrop; | ||||||
|  |     property OnDockOver; | ||||||
|  |     property OnDblClick; | ||||||
|  |     property OnDragDrop; | ||||||
|  |     property OnDragOver; | ||||||
|  |     property OnEndDock; | ||||||
|  |     property OnEndDrag; | ||||||
|  |     property OnEnter; | ||||||
|  |     property OnExit; | ||||||
|  |     property OnGetSiteInfo; | ||||||
|  |     property OnMouseDown; | ||||||
|  |     property OnMouseEnter; | ||||||
|  |     property OnMouseLeave; | ||||||
|  |     property OnMouseMove; | ||||||
|  |     property OnMouseUp; | ||||||
|  |     property OnResize; | ||||||
|  |     property OnStartDock; | ||||||
|  |     property OnStartDrag; | ||||||
|  |     property OnUnDock; | ||||||
|  |   end; | ||||||
|  | 
 | ||||||
|   { TCustomTrayIcon } |   { TCustomTrayIcon } | ||||||
| 
 | 
 | ||||||
|   TBalloonFlags = (bfNone, bfInfo, bfWarning, bfError); |   TBalloonFlags = (bfNone, bfInfo, bfWarning, bfError); | ||||||
| @ -1468,7 +1608,7 @@ procedure Register; | |||||||
| begin | begin | ||||||
|   RegisterComponents('Standard',[TRadioGroup,TCheckGroup,TPanel]); |   RegisterComponents('Standard',[TRadioGroup,TCheckGroup,TPanel]); | ||||||
|   RegisterComponents('Additional',[TImage,TShape,TBevel,TPaintBox, |   RegisterComponents('Additional',[TImage,TShape,TBevel,TPaintBox, | ||||||
|     TNotebook, TLabeledEdit, TSplitter, TTrayIcon, TControlBar]); |     TNotebook, TLabeledEdit, TSplitter, TTrayIcon, TControlBar, TFlowPanel]); | ||||||
|   RegisterComponents('System',[TTimer,TIdleTimer]); |   RegisterComponents('System',[TTimer,TIdleTimer]); | ||||||
|   RegisterNoIcon([TPage]); |   RegisterNoIcon([TPage]); | ||||||
| end; | end; | ||||||
| @ -1483,6 +1623,7 @@ end; | |||||||
| {$I boundlabel.inc} | {$I boundlabel.inc} | ||||||
| {$I customlabelededit.inc} | {$I customlabelededit.inc} | ||||||
| {$I custompanel.inc} | {$I custompanel.inc} | ||||||
|  | {$I customflowpanel.inc} | ||||||
| {$I radiogroup.inc} | {$I radiogroup.inc} | ||||||
| {$I bevel.inc} | {$I bevel.inc} | ||||||
| {$I customimage.inc} | {$I customimage.inc} | ||||||
|  | |||||||
							
								
								
									
										388
									
								
								lcl/include/customflowpanel.inc
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										388
									
								
								lcl/include/customflowpanel.inc
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,388 @@ | |||||||
|  | {%MainUnit ../extctrls.pp} | ||||||
|  | 
 | ||||||
|  | {****************************************************************************** | ||||||
|  |                             TCustomFlowPanel | ||||||
|  |  ****************************************************************************** | ||||||
|  |                              Ondrej Pokorny | ||||||
|  |  ****************************************************************************** | ||||||
|  |   This file is part of the Lazarus Component Library (LCL) | ||||||
|  | 
 | ||||||
|  |   See the file COPYING.modifiedLGPL.txt, included in this distribution, | ||||||
|  |   for details about the license. | ||||||
|  |  ****************************************************************************** | ||||||
|  | } | ||||||
|  | { | ||||||
|  | 
 | ||||||
|  |   Delphi compatibility: | ||||||
|  | 
 | ||||||
|  |   - TFlowPanel is compatible with Delphi implementation | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | { TFlowPanelControlList } | ||||||
|  | 
 | ||||||
|  | constructor TFlowPanelControlList.Create(AOwner: TPersistent); | ||||||
|  | begin | ||||||
|  |   Assert(AOwner is TCustomFlowPanel); | ||||||
|  |   inherited Create(AOwner, TFlowPanelControl); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | function TFlowPanelControlList.Add: TFlowPanelControl; | ||||||
|  | begin | ||||||
|  |   Result := TFlowPanelControl(inherited Add); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TFlowPanelControlList.AddControl(AControl: TControl; | ||||||
|  |   AIndex: Integer); | ||||||
|  | var | ||||||
|  |   I: Integer; | ||||||
|  |   Item: TFlowPanelControl; | ||||||
|  | begin | ||||||
|  |   if IndexOf(AControl) >= 0 then | ||||||
|  |     Exit; | ||||||
|  | 
 | ||||||
|  |   if AIndex = -1 then | ||||||
|  |     for I := 0 to Count-1 do | ||||||
|  |       if not Assigned(Items[I].Control) then | ||||||
|  |       begin | ||||||
|  |         AIndex := I; | ||||||
|  |         break; | ||||||
|  |       end; | ||||||
|  | 
 | ||||||
|  |   if AIndex = -1 then | ||||||
|  |     Item := Add | ||||||
|  |   else | ||||||
|  |     Item := Items[AIndex]; | ||||||
|  | 
 | ||||||
|  |   Item.FControl := AControl; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | function TFlowPanelControlList.FPOwner: TCustomFlowPanel; | ||||||
|  | begin | ||||||
|  |   Result := TCustomFlowPanel(GetOwner); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | function TFlowPanelControlList.GetItem(Index: Integer | ||||||
|  |   ): TFlowPanelControl; | ||||||
|  | begin | ||||||
|  |   Result := TFlowPanelControl(inherited GetItem(Index)); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | function TFlowPanelControlList.IndexOf(AControl: TControl): Integer; | ||||||
|  | begin | ||||||
|  |   for Result := 0 to Count - 1 do | ||||||
|  |     if Items[Result].Control = AControl then | ||||||
|  |       Exit; | ||||||
|  |   Result := -1; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TFlowPanelControlList.RemoveControl(AControl: TControl); | ||||||
|  | var | ||||||
|  |   I: Integer; | ||||||
|  | begin | ||||||
|  |   for I := Count - 1 downto 0 do | ||||||
|  |     if Items[I].Control = AControl then | ||||||
|  |     begin | ||||||
|  |       Items[I].FControl := nil; | ||||||
|  |       Delete(I); | ||||||
|  |       Exit; | ||||||
|  |     end; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TFlowPanelControlList.SetItem(Index: Integer; | ||||||
|  |   const AItem: TFlowPanelControl); | ||||||
|  | begin | ||||||
|  |   inherited SetItem(Index, AItem); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | { TFlowPanelControl } | ||||||
|  | 
 | ||||||
|  | procedure TFlowPanelControl.AssignTo(Dest: TPersistent); | ||||||
|  | var | ||||||
|  |   xDest: TFlowPanelControl; | ||||||
|  | begin | ||||||
|  |   if Dest is TFlowPanelControl then | ||||||
|  |   begin | ||||||
|  |     xDest := TFlowPanelControl(Dest); | ||||||
|  |     xDest.FWrapAfter := Self.FWrapAfter; | ||||||
|  |   end else | ||||||
|  |     inherited AssignTo(Dest); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | function TFlowPanelControl.FPCollection: TFlowPanelControlList; | ||||||
|  | begin | ||||||
|  |   Result := Collection as TFlowPanelControlList; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | function TFlowPanelControl.FPOwner: TCustomFlowPanel; | ||||||
|  | begin | ||||||
|  |   Result := FPCollection.FPOwner; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TFlowPanelControl.SetControl(const aControl: TControl); | ||||||
|  | begin | ||||||
|  |   if FControl = aControl then Exit; | ||||||
|  |   Assert(FControl = nil); | ||||||
|  |   FControl := aControl; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TFlowPanelControl.SetIndex(Value: Integer); | ||||||
|  | begin | ||||||
|  |   inherited SetIndex(Value); | ||||||
|  | 
 | ||||||
|  |   if FPOwner.ComponentState * [csLoading, csUpdating,  csDestroying] = [] then | ||||||
|  |     FPOwner.ReAlign; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TFlowPanelControl.SetWrapAfter(const AWrapAfter: TWrapAfter); | ||||||
|  | begin | ||||||
|  |   if FWrapAfter = AWrapAfter then exit; | ||||||
|  |   FWrapAfter := AWrapAfter; | ||||||
|  | 
 | ||||||
|  |   if FPOwner.ComponentState * [csLoading, csUpdating,  csDestroying] = [] then | ||||||
|  |     FPOwner.ReAlign; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | { TCustomFlowPanel } | ||||||
|  | 
 | ||||||
|  | constructor TCustomFlowPanel.Create(AOwner: TComponent); | ||||||
|  | begin | ||||||
|  |   inherited Create(AOwner); | ||||||
|  | 
 | ||||||
|  |   FControlList := TFlowPanelControlList.Create(Self); | ||||||
|  |   FAutoWrap := True; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TCustomFlowPanel.AlignControls(AControl: TControl; | ||||||
|  |   var RemainingClientRect: TRect); | ||||||
|  | const | ||||||
|  |   XIncDir:     array[TFlowStyle] of Integer = (1, -1,  1, -1,  1,  1, -1, -1); | ||||||
|  |   YIncDir:     array[TFlowStyle] of Integer = (1,  1, -1, -1,  1, -1,  1, -1); | ||||||
|  |   YDeltaConst: array[TFlowStyle] of Integer = (0,  0, -1, -1,  0,  0,  0,  0); | ||||||
|  |   XDeltaConst: array[TFlowStyle] of Integer = (0,  0,  0,  0,  0,  0, -1, -1); | ||||||
|  | var | ||||||
|  |   I, L: Integer; | ||||||
|  |   MaxHeight, MaxWidth: Integer; | ||||||
|  |   YDelta, XDelta: Integer; | ||||||
|  |   Position: TPoint; | ||||||
|  |   Size, GroupSize: TSize; | ||||||
|  |   Control: TControl; | ||||||
|  |   ConBS: TControlBorderSpacing; | ||||||
|  |   ForceWrap, ForbidWrap: Boolean; | ||||||
|  | begin | ||||||
|  |   DisableAlign; | ||||||
|  |   try | ||||||
|  |   if ControlCount > 0 then | ||||||
|  |   begin | ||||||
|  |     MaxHeight := 0; | ||||||
|  |     MaxWidth := 0; | ||||||
|  |     AdjustClientRect(RemainingClientRect); | ||||||
|  |     case FFlowStyle of | ||||||
|  |       fsLeftRightTopBottom, | ||||||
|  |       fsTopBottomLeftRight: | ||||||
|  |         Position := RemainingClientRect.TopLeft; | ||||||
|  |       fsRightLeftTopBottom, | ||||||
|  |       fsTopBottomRightLeft: | ||||||
|  |         Position := Point(RemainingClientRect.Right, RemainingClientRect.Top); | ||||||
|  |       fsLeftRightBottomTop, | ||||||
|  |       fsBottomTopLeftRight: | ||||||
|  |         Position := Point(RemainingClientRect.Left, RemainingClientRect.Bottom); | ||||||
|  |       fsRightLeftBottomTop, | ||||||
|  |       fsBottomTopRightLeft: | ||||||
|  |         Position := RemainingClientRect.BottomRight; | ||||||
|  |     end; | ||||||
|  | 
 | ||||||
|  |     for I := 0 to FControlList.Count - 1 do | ||||||
|  |     begin | ||||||
|  |       Control := FControlList[I].Control; | ||||||
|  |       ConBS := Control.BorderSpacing; | ||||||
|  |       if not Control.Visible and not (csDesigning in ComponentState) then | ||||||
|  |         continue; | ||||||
|  | 
 | ||||||
|  |       Size.cx := ConBS.ControlWidth; | ||||||
|  |       Size.cy := ConBS.ControlHeight; | ||||||
|  |       GroupSize := Size; | ||||||
|  | 
 | ||||||
|  |       ForceWrap := (I > 0) and (FControlList[I-1].WrapAfter = waForce); | ||||||
|  |       ForbidWrap := (I > 0) and (FControlList[I-1].WrapAfter = waForbid); | ||||||
|  |       if not ForceWrap | ||||||
|  |       and ((I = 0) or not(FControlList[I-1].WrapAfter in [waAvoid, waForbid])) then | ||||||
|  |       begin | ||||||
|  |         for L := I to FControlList.Count-2 do | ||||||
|  |         begin | ||||||
|  |           if FControlList[L].WrapAfter in [waAvoid, waForbid] then | ||||||
|  |           begin | ||||||
|  |             case FFlowStyle of | ||||||
|  |               fsLeftRightTopBottom, fsLeftRightBottomTop, fsRightLeftTopBottom, fsRightLeftBottomTop: | ||||||
|  |                 Inc(GroupSize.cx, FControlList[L+1].Control.BorderSpacing.ControlWidth); | ||||||
|  |               fsTopBottomLeftRight, fsTopBottomRightLeft, fsBottomTopLeftRight, fsBottomTopRightLeft: | ||||||
|  |                 Inc(GroupSize.cy, FControlList[L+1].Control.BorderSpacing.ControlHeight); | ||||||
|  |             end; | ||||||
|  |           end else | ||||||
|  |             break; | ||||||
|  |         end; | ||||||
|  |       end; | ||||||
|  |       case FFlowStyle of | ||||||
|  |         fsLeftRightTopBottom, | ||||||
|  |         fsLeftRightBottomTop: | ||||||
|  |           if (MaxHeight > 0) and FAutoWrap and not ForbidWrap | ||||||
|  |           and (ForceWrap or (Position.X + GroupSize.cx >= RemainingClientRect.Right)) then | ||||||
|  |           begin | ||||||
|  |             Inc(Position.Y, MaxHeight * YIncDir[FFlowStyle]); | ||||||
|  |             MaxHeight := 0; | ||||||
|  |             Position.X := RemainingClientRect.Left; | ||||||
|  |           end; | ||||||
|  |         fsRightLeftTopBottom, | ||||||
|  |         fsRightLeftBottomTop: | ||||||
|  |           begin | ||||||
|  |             Dec(Position.X, GroupSize.cx); | ||||||
|  |             if (MaxHeight > 0) and FAutoWrap and not ForbidWrap | ||||||
|  |             and (ForceWrap or (Position.X <= 0)) then | ||||||
|  |             begin | ||||||
|  |               Inc(Position.Y, MaxHeight * YIncDir[FFlowStyle]); | ||||||
|  |               MaxHeight := 0; | ||||||
|  |               Position.X := RemainingClientRect.Right - Size.cx; | ||||||
|  |             end; | ||||||
|  |           end; | ||||||
|  |         fsTopBottomLeftRight, | ||||||
|  |         fsTopBottomRightLeft: | ||||||
|  |           if (MaxWidth > 0) and FAutoWrap and not ForbidWrap | ||||||
|  |           and (ForceWrap or (Position.Y + GroupSize.cy >= RemainingClientRect.Bottom)) then | ||||||
|  |           begin | ||||||
|  |             Inc(Position.X, MaxWidth * XIncDir[FFlowStyle]); | ||||||
|  |             MaxWidth := 0; | ||||||
|  |             Position.Y := RemainingClientRect.Top; | ||||||
|  |           end; | ||||||
|  |         fsBottomTopLeftRight, | ||||||
|  |         fsBottomTopRightLeft: | ||||||
|  |           begin | ||||||
|  |             Dec(Position.Y, GroupSize.cy); | ||||||
|  |             if (MaxWidth > 0) and FAutoWrap and not ForbidWrap | ||||||
|  |             and (ForceWrap or (Position.Y <= 0)) then | ||||||
|  |             begin | ||||||
|  |               Inc(Position.X, MaxWidth * XIncDir[FFlowStyle]); | ||||||
|  |               MaxWidth := 0; | ||||||
|  |               Position.Y := RemainingClientRect.Bottom - Size.cy; | ||||||
|  |             end; | ||||||
|  |           end; | ||||||
|  |       end; | ||||||
|  |       YDelta := YDeltaConst[FFlowStyle] * Size.cy; | ||||||
|  |       XDelta := XDeltaConst[FFlowStyle] * Size.cx; | ||||||
|  |       if Size.cy > MaxHeight then | ||||||
|  |         MaxHeight := Size.cy; | ||||||
|  |       if Size.cx > MaxWidth then | ||||||
|  |         MaxWidth := Size.cx; | ||||||
|  |       Control.SetBounds( | ||||||
|  |         Position.X + ConBS.Left + ConBS.Around + XDelta, | ||||||
|  |         Position.Y + ConBS.Top + ConBS.Around + YDelta, | ||||||
|  |         Size.cx - (ConBS.Left + ConBS.Right + ConBS.Around*2), | ||||||
|  |         Size.cy - (ConBS.Top + ConBS.Bottom + ConBS.Around*2)); | ||||||
|  |       if FFlowStyle in [fsLeftRightTopBottom, fsLeftRightBottomTop] then | ||||||
|  |         Inc(Position.X, Size.cx * XIncDir[FFlowStyle]) | ||||||
|  |       else if FFlowStyle in [fsTopBottomLeftRight, fsTopBottomRightLeft] then | ||||||
|  |         Inc(Position.Y, Size.cy + YIncDir[FFlowStyle]); | ||||||
|  |     end; | ||||||
|  |   end; | ||||||
|  |   finally | ||||||
|  |     EnableAlign; | ||||||
|  |   end; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TCustomFlowPanel.CalculatePreferredSize(var PreferredWidth, | ||||||
|  |   PreferredHeight: integer; WithThemeSpace: Boolean); | ||||||
|  | var | ||||||
|  |   xControl: TControl; | ||||||
|  |   xTestRect, xClientRect: TRect; | ||||||
|  |   I: Integer; | ||||||
|  | begin | ||||||
|  |   inherited CalculatePreferredSize(PreferredWidth, PreferredHeight, | ||||||
|  |     WithThemeSpace); | ||||||
|  | 
 | ||||||
|  |   if FControlList.Count > 0 then | ||||||
|  |   begin | ||||||
|  |     xTestRect := Rect(0, 0, 100, 100); | ||||||
|  |     xClientRect := xTestRect; | ||||||
|  |     AdjustClientRect(xClientRect); | ||||||
|  |     for I := 0 to ControlCount-1 do | ||||||
|  |     begin | ||||||
|  |       xControl := FControlList.Items[I].Control; | ||||||
|  |       if FFlowStyle in [fsLeftRightTopBottom, fsRightLeftTopBottom, fsLeftRightBottomTop, fsRightLeftBottomTop] then | ||||||
|  |         PreferredHeight := Max(PreferredHeight, | ||||||
|  |           xControl.BoundsRect.Bottom+xControl.BorderSpacing.Around+xControl.BorderSpacing.Bottom + | ||||||
|  |           xTestRect.Bottom-xClientRect.Bottom-xTestRect.Top+xClientRect.Top) | ||||||
|  |       else | ||||||
|  |         PreferredWidth := Max(PreferredWidth, | ||||||
|  |           xControl.BoundsRect.Right+xControl.BorderSpacing.Around+xControl.BorderSpacing.Right + | ||||||
|  |           xTestRect.Right-xClientRect.Right-xTestRect.Left+xClientRect.Left); | ||||||
|  |     end; | ||||||
|  |   end; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TCustomFlowPanel.CMControlChange(var Message: TCMControlChange); | ||||||
|  | begin | ||||||
|  |   //inherited CMControlChange(Message); uncomment if CMControlChange should appear in parent classes
 | ||||||
|  | 
 | ||||||
|  |   if (csLoading in ComponentState) then | ||||||
|  |     Exit; | ||||||
|  | 
 | ||||||
|  |   if Message.Inserting and (Message.Control.Parent = Self) then | ||||||
|  |   begin | ||||||
|  |     DisableAlign; | ||||||
|  |     try | ||||||
|  |       Message.Control.Anchors := []; | ||||||
|  |       Message.Control.Align := alNone; | ||||||
|  |       FControlList.AddControl(Message.Control); | ||||||
|  |       ReAlign; | ||||||
|  |     finally | ||||||
|  |       EnableAlign; | ||||||
|  |     end; | ||||||
|  |   end else | ||||||
|  |     FControlList.RemoveControl(Message.Control); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | destructor TCustomFlowPanel.Destroy; | ||||||
|  | begin | ||||||
|  |   inherited Destroy; | ||||||
|  |   FControlList.Free; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | function TCustomFlowPanel.GetControlIndex(AControl: TControl): Integer; | ||||||
|  | begin | ||||||
|  |   Result := FControlList.IndexOf(AControl); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TCustomFlowPanel.SetAutoWrap(const AAutoWrap: Boolean); | ||||||
|  | begin | ||||||
|  |   if FAutoWrap = AAutoWrap then Exit; | ||||||
|  |   FAutoWrap := AAutoWrap; | ||||||
|  | 
 | ||||||
|  |   ReAlign; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TCustomFlowPanel.SetControlIndex(AControl: TControl; Index: Integer); | ||||||
|  | var | ||||||
|  |   CurIndex: Integer; | ||||||
|  | begin | ||||||
|  |   CurIndex := GetControlIndex(AControl); | ||||||
|  |   if (CurIndex > -1) and (CurIndex <> Index) and (Index < FControlList.Count) then | ||||||
|  |   begin | ||||||
|  |     FControlList.Items[CurIndex].Index := Index; | ||||||
|  |     Realign; | ||||||
|  |   end; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TCustomFlowPanel.SetControlList( | ||||||
|  |   const AControlList: TFlowPanelControlList); | ||||||
|  | begin | ||||||
|  |   FControlList.Assign(AControlList); | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | procedure TCustomFlowPanel.SetFlowStyle(const AFlowStyle: TFlowStyle); | ||||||
|  | begin | ||||||
|  |   if FFlowStyle = AFlowStyle then Exit; | ||||||
|  |   FFlowStyle := AFlowStyle; | ||||||
|  | 
 | ||||||
|  |   ReAlign; | ||||||
|  | end; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | // included by extctrls.pp
 | ||||||
| @ -27,7 +27,7 @@ | |||||||
|     <License Value="modified LGPL-2 |     <License Value="modified LGPL-2 | ||||||
| "/> | "/> | ||||||
|     <Version Major="1" Minor="5"/> |     <Version Major="1" Minor="5"/> | ||||||
|     <Files Count="283"> |     <Files Count="284"> | ||||||
|       <Item1> |       <Item1> | ||||||
|         <Filename Value="checklst.pas"/> |         <Filename Value="checklst.pas"/> | ||||||
|         <UnitName Value="CheckLst"/> |         <UnitName Value="CheckLst"/> | ||||||
| @ -98,7 +98,7 @@ | |||||||
|       </Item17> |       </Item17> | ||||||
|       <Item18> |       <Item18> | ||||||
|         <Filename Value="extgraphics.pas"/> |         <Filename Value="extgraphics.pas"/> | ||||||
|         <UnitName Value="extgraphics"/> |         <UnitName Value="ExtGraphics"/> | ||||||
|       </Item18> |       </Item18> | ||||||
|       <Item19> |       <Item19> | ||||||
|         <Filename Value="filectrl.pp"/> |         <Filename Value="filectrl.pp"/> | ||||||
| @ -226,7 +226,7 @@ | |||||||
|       </Item49> |       </Item49> | ||||||
|       <Item50> |       <Item50> | ||||||
|         <Filename Value="maps.pp"/> |         <Filename Value="maps.pp"/> | ||||||
|         <UnitName Value="maps"/> |         <UnitName Value="Maps"/> | ||||||
|       </Item50> |       </Item50> | ||||||
|       <Item51> |       <Item51> | ||||||
|         <Filename Value="maskedit.pp"/> |         <Filename Value="maskedit.pp"/> | ||||||
| @ -250,7 +250,7 @@ | |||||||
|       </Item55> |       </Item55> | ||||||
|       <Item56> |       <Item56> | ||||||
|         <Filename Value="postscriptunicode.pas"/> |         <Filename Value="postscriptunicode.pas"/> | ||||||
|         <UnitName Value="postscriptunicode"/> |         <UnitName Value="PostScriptUnicode"/> | ||||||
|       </Item56> |       </Item56> | ||||||
|       <Item57> |       <Item57> | ||||||
|         <Filename Value="printers.pas"/> |         <Filename Value="printers.pas"/> | ||||||
| @ -1073,31 +1073,31 @@ | |||||||
|       </Item260> |       </Item260> | ||||||
|       <Item261> |       <Item261> | ||||||
|         <Filename Value="lazcanvas.pas"/> |         <Filename Value="lazcanvas.pas"/> | ||||||
|         <UnitName Value="lazcanvas"/> |         <UnitName Value="LazCanvas"/> | ||||||
|       </Item261> |       </Item261> | ||||||
|       <Item262> |       <Item262> | ||||||
|         <Filename Value="lazdialogs.pas"/> |         <Filename Value="lazdialogs.pas"/> | ||||||
|         <UnitName Value="lazdialogs"/> |         <UnitName Value="LazDialogs"/> | ||||||
|       </Item262> |       </Item262> | ||||||
|       <Item263> |       <Item263> | ||||||
|         <Filename Value="lazregions.pas"/> |         <Filename Value="lazregions.pas"/> | ||||||
|         <UnitName Value="lazregions"/> |         <UnitName Value="LazRegions"/> | ||||||
|       </Item263> |       </Item263> | ||||||
|       <Item264> |       <Item264> | ||||||
|         <Filename Value="customdrawn_common.pas"/> |         <Filename Value="customdrawn_common.pas"/> | ||||||
|         <UnitName Value="customdrawn_common"/> |         <UnitName Value="CustomDrawn_Common"/> | ||||||
|       </Item264> |       </Item264> | ||||||
|       <Item265> |       <Item265> | ||||||
|         <Filename Value="customdrawncontrols.pas"/> |         <Filename Value="customdrawncontrols.pas"/> | ||||||
|         <UnitName Value="customdrawncontrols"/> |         <UnitName Value="CustomDrawnControls"/> | ||||||
|       </Item265> |       </Item265> | ||||||
|       <Item266> |       <Item266> | ||||||
|         <Filename Value="customdrawndrawers.pas"/> |         <Filename Value="customdrawndrawers.pas"/> | ||||||
|         <UnitName Value="customdrawndrawers"/> |         <UnitName Value="CustomDrawnDrawers"/> | ||||||
|       </Item266> |       </Item266> | ||||||
|       <Item267> |       <Item267> | ||||||
|         <Filename Value="lazdeviceapis.pas"/> |         <Filename Value="lazdeviceapis.pas"/> | ||||||
|         <UnitName Value="lazdeviceapis"/> |         <UnitName Value="LazDeviceApis"/> | ||||||
|       </Item267> |       </Item267> | ||||||
|       <Item268> |       <Item268> | ||||||
|         <Filename Value="ldocktree.pas"/> |         <Filename Value="ldocktree.pas"/> | ||||||
| @ -1109,11 +1109,11 @@ | |||||||
|       </Item269> |       </Item269> | ||||||
|       <Item270> |       <Item270> | ||||||
|         <Filename Value="customdrawn_winxp.pas"/> |         <Filename Value="customdrawn_winxp.pas"/> | ||||||
|         <UnitName Value="customdrawn_winxp"/> |         <UnitName Value="CustomDrawn_WinXP"/> | ||||||
|       </Item270> |       </Item270> | ||||||
|       <Item271> |       <Item271> | ||||||
|         <Filename Value="customdrawn_android.pas"/> |         <Filename Value="customdrawn_android.pas"/> | ||||||
|         <UnitName Value="customdrawn_android"/> |         <UnitName Value="CustomDrawn_Android"/> | ||||||
|       </Item271> |       </Item271> | ||||||
|       <Item272> |       <Item272> | ||||||
|         <Filename Value="include/sysenvapis_win.inc"/> |         <Filename Value="include/sysenvapis_win.inc"/> | ||||||
| @ -1154,7 +1154,7 @@ | |||||||
|       </Item280> |       </Item280> | ||||||
|       <Item281> |       <Item281> | ||||||
|         <Filename Value="customdrawn_mac.pas"/> |         <Filename Value="customdrawn_mac.pas"/> | ||||||
|         <UnitName Value="customdrawn_mac"/> |         <UnitName Value="CustomDrawn_Mac"/> | ||||||
|       </Item281> |       </Item281> | ||||||
|       <Item282> |       <Item282> | ||||||
|         <Filename Value="forms/calcform.pas"/> |         <Filename Value="forms/calcform.pas"/> | ||||||
| @ -1164,6 +1164,10 @@ | |||||||
|         <Filename Value="lcltranslator.pas"/> |         <Filename Value="lcltranslator.pas"/> | ||||||
|         <UnitName Value="LCLTranslator"/> |         <UnitName Value="LCLTranslator"/> | ||||||
|       </Item283> |       </Item283> | ||||||
|  |       <Item284> | ||||||
|  |         <Filename Value="include/customflowpanel.inc"/> | ||||||
|  |         <Type Value="Include"/> | ||||||
|  |       </Item284> | ||||||
|     </Files> |     </Files> | ||||||
|     <LazDoc Paths="../docs/xml/lcl"/> |     <LazDoc Paths="../docs/xml/lcl"/> | ||||||
|     <i18n> |     <i18n> | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 ondrej
						ondrej