mirror of
				https://gitlab.com/freepascal.org/lazarus/lazarus.git
				synced 2025-10-31 10:02:30 +01:00 
			
		
		
		
	added DisableAutoSizing/EnableAutoSizing, fixed crash on adding a notebook page with autosized controls
git-svn-id: trunk@7675 -
This commit is contained in:
		
							parent
							
								
									19fb9dc230
								
							
						
					
					
						commit
						90c9bc8170
					
				| @ -40,7 +40,6 @@ Type | ||||
| 
 | ||||
|   TCustomElementEditor = Class(TPanel) | ||||
|   private | ||||
|     FChangedEvent: TNotifyEvent; | ||||
|     Felement : TDomElement; | ||||
|     FGetElementList: TGetElementListEvent; | ||||
|     FSavedNode, | ||||
| @ -519,6 +518,7 @@ begin | ||||
|   If Not Result then | ||||
|     begin | ||||
|     SS:=TStringStream.Create(Head+S+Tail); | ||||
|     D:=nil; | ||||
|     Try | ||||
|       Try | ||||
|         ReadXmlFile(D,SS); | ||||
|  | ||||
| @ -6,14 +6,13 @@ object MainForm: TMainForm | ||||
|   OnCloseQuery = MainFormCloseQuery | ||||
|   OnCreate = MainFormCreate | ||||
|   OnDestroy = MainFormDestroy | ||||
|   PixelsPerInch = 75 | ||||
|   PixelsPerInch = 112 | ||||
|   HorzScrollBar.Page = 601 | ||||
|   VertScrollBar.Page = 517 | ||||
|   Left = 189 | ||||
|   Height = 544 | ||||
|   Width = 602 | ||||
|   object TBMain: TToolBar | ||||
|     BorderSpacing.OnChange = nil | ||||
|     ButtonHeight = 28 | ||||
|     ButtonWidth = 28 | ||||
|     Caption = 'TBMain' | ||||
| @ -188,7 +187,6 @@ object MainForm: TMainForm | ||||
|   end | ||||
|   object PCFiles: TPageControl | ||||
|     Align = alClient | ||||
|     BorderSpacing.OnChange = nil | ||||
|     TabOrder = 1 | ||||
|     Left = 5 | ||||
|     Height = 468 | ||||
|  | ||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| @ -821,8 +821,13 @@ begin | ||||
| end; | ||||
| 
 | ||||
| procedure TMainForm.ApplyOptions; | ||||
| var | ||||
|   i: Integer; | ||||
| begin | ||||
|   ShowHint := ShowHelpHints; | ||||
|   for i:=0 to ComponentCount-1 do | ||||
|     if Components[i] is TToolButton then | ||||
|       TToolButton(Components[i]).ShowHint:=ShowHelpHints; | ||||
| end; | ||||
| 
 | ||||
| 
 | ||||
|  | ||||
| @ -8,11 +8,11 @@ | ||||
|         <SaveOnlyProjectUnits Value="True"/> | ||||
|       </Flags> | ||||
|       <MainUnit Value="0"/> | ||||
|       <ActiveEditorIndexAtStart Value="10"/> | ||||
|       <AutoCreateForms Value="False"/> | ||||
|       <IconPath Value="./"/> | ||||
|       <TargetFileExt Value=".exe"/> | ||||
|       <Title Value="Lazarus Documentation Editor"/> | ||||
|       <ActiveEditorIndexAtStart Value="5"/> | ||||
|     </General> | ||||
|     <Units Count="13"> | ||||
|       <Unit0> | ||||
| @ -21,23 +21,23 @@ | ||||
|         <IsPartOfProject Value="True"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <UnitName Value="lazde"/> | ||||
|         <UsageCount Value="97"/> | ||||
|         <UsageCount Value="98"/> | ||||
|       </Unit0> | ||||
|       <Unit1> | ||||
|         <CursorPos X="17" Y="21"/> | ||||
|         <EditorIndex Value="4"/> | ||||
|         <CursorPos X="15" Y="803"/> | ||||
|         <EditorIndex Value="0"/> | ||||
|         <Filename Value="frmmain.pp"/> | ||||
|         <ComponentName Value="MainForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <ResourceFilename Value="frmmain.lrs"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <TopLine Value="787"/> | ||||
|         <UnitName Value="FrmMain"/> | ||||
|         <UsageCount Value="97"/> | ||||
|         <UsageCount Value="98"/> | ||||
|       </Unit1> | ||||
|       <Unit2> | ||||
|         <CursorPos X="1" Y="23"/> | ||||
|         <EditorIndex Value="2"/> | ||||
|         <EditorIndex Value="10"/> | ||||
|         <Filename Value="frmoptions.pp"/> | ||||
|         <ComponentName Value="OptionsForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
| @ -45,11 +45,11 @@ | ||||
|         <ResourceFilename Value="frmoptions.lrs"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <UnitName Value="frmOptions"/> | ||||
|         <UsageCount Value="94"/> | ||||
|         <UsageCount Value="95"/> | ||||
|       </Unit2> | ||||
|       <Unit3> | ||||
|         <CursorPos X="1" Y="23"/> | ||||
|         <EditorIndex Value="3"/> | ||||
|         <EditorIndex Value="11"/> | ||||
|         <Filename Value="frmnewnode.pp"/> | ||||
|         <ComponentName Value="NewNodeForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
| @ -57,11 +57,11 @@ | ||||
|         <ResourceFilename Value="frmnewnode.lrs"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <UnitName Value="frmNewNode"/> | ||||
|         <UsageCount Value="91"/> | ||||
|         <UsageCount Value="92"/> | ||||
|       </Unit3> | ||||
|       <Unit4> | ||||
|         <CursorPos X="32" Y="27"/> | ||||
|         <EditorIndex Value="6"/> | ||||
|         <EditorIndex Value="13"/> | ||||
|         <Filename Value="frmmakeskel.pp"/> | ||||
|         <ComponentName Value="MakeSkelForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
| @ -69,11 +69,11 @@ | ||||
|         <ResourceFilename Value="frmmakeskel.lrs"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <UnitName Value="FrmMakeSkel"/> | ||||
|         <UsageCount Value="68"/> | ||||
|         <UsageCount Value="69"/> | ||||
|       </Unit4> | ||||
|       <Unit5> | ||||
|         <CursorPos X="11" Y="16"/> | ||||
|         <EditorIndex Value="0"/> | ||||
|         <EditorIndex Value="8"/> | ||||
|         <Filename Value="frmlink.pp"/> | ||||
|         <ComponentName Value="LinkForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
| @ -81,11 +81,11 @@ | ||||
|         <ResourceFilename Value="frmlink.lrs"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <UnitName Value="FrmLink"/> | ||||
|         <UsageCount Value="61"/> | ||||
|         <UsageCount Value="62"/> | ||||
|       </Unit5> | ||||
|       <Unit6> | ||||
|         <CursorPos X="1" Y="23"/> | ||||
|         <EditorIndex Value="1"/> | ||||
|         <EditorIndex Value="9"/> | ||||
|         <Filename Value="frmtable.pp"/> | ||||
|         <ComponentName Value="TableForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
| @ -93,11 +93,11 @@ | ||||
|         <ResourceFilename Value="frmtable.lrs"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <UnitName Value="frmTable"/> | ||||
|         <UsageCount Value="61"/> | ||||
|         <UsageCount Value="62"/> | ||||
|       </Unit6> | ||||
|       <Unit7> | ||||
|         <CursorPos X="35" Y="26"/> | ||||
|         <EditorIndex Value="5"/> | ||||
|         <EditorIndex Value="12"/> | ||||
|         <Filename Value="frmabout.pp"/> | ||||
|         <ComponentName Value="AboutForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
| @ -105,41 +105,37 @@ | ||||
|         <ResourceFilename Value="frmabout.lrs"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <UnitName Value="FrmAbout"/> | ||||
|         <UsageCount Value="52"/> | ||||
|         <UsageCount Value="53"/> | ||||
|       </Unit7> | ||||
|       <Unit8> | ||||
|         <CursorPos X="16" Y="26"/> | ||||
|         <EditorIndex Value="12"/> | ||||
|         <CursorPos X="22" Y="251"/> | ||||
|         <Filename Value="pkeditor.pp"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <TopLine Value="235"/> | ||||
|         <UnitName Value="PkEditor"/> | ||||
|         <UsageCount Value="46"/> | ||||
|         <UsageCount Value="47"/> | ||||
|       </Unit8> | ||||
|       <Unit9> | ||||
|         <CursorPos X="16" Y="497"/> | ||||
|         <EditorIndex Value="7"/> | ||||
|         <CursorPos X="12" Y="521"/> | ||||
|         <EditorIndex Value="14"/> | ||||
|         <Filename Value="eleditor.pp"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <TopLine Value="473"/> | ||||
|         <TopLine Value="500"/> | ||||
|         <UnitName Value="ElEditor"/> | ||||
|         <UsageCount Value="46"/> | ||||
|         <UsageCount Value="47"/> | ||||
|       </Unit9> | ||||
|       <Unit10> | ||||
|         <CursorPos X="34" Y="28"/> | ||||
|         <EditorIndex Value="11"/> | ||||
|         <Filename Value="fpdeutil.pp"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
|         <Loaded Value="True"/> | ||||
|         <TopLine Value="1"/> | ||||
|         <UnitName Value="FPDEUtil"/> | ||||
|         <UsageCount Value="46"/> | ||||
|         <UsageCount Value="47"/> | ||||
|       </Unit10> | ||||
|       <Unit11> | ||||
|         <CursorPos X="15" Y="71"/> | ||||
|         <EditorIndex Value="9"/> | ||||
|         <EditorIndex Value="15"/> | ||||
|         <Filename Value="frmexample.pp"/> | ||||
|         <ComponentName Value="ExampleForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
| @ -147,11 +143,11 @@ | ||||
|         <ResourceFilename Value="frmexample.lrs"/> | ||||
|         <TopLine Value="66"/> | ||||
|         <UnitName Value="FrmExample"/> | ||||
|         <UsageCount Value="37"/> | ||||
|         <UsageCount Value="38"/> | ||||
|       </Unit11> | ||||
|       <Unit12> | ||||
|         <CursorPos X="3" Y="570"/> | ||||
|         <EditorIndex Value="10"/> | ||||
|         <CursorPos X="19" Y="568"/> | ||||
|         <EditorIndex Value="16"/> | ||||
|         <Filename Value="frmbuild.pp"/> | ||||
|         <ComponentName Value="BuildForm"/> | ||||
|         <IsPartOfProject Value="True"/> | ||||
| @ -159,7 +155,7 @@ | ||||
|         <ResourceFilename Value="frmbuild.lrs"/> | ||||
|         <TopLine Value="545"/> | ||||
|         <UnitName Value="frmBuild"/> | ||||
|         <UsageCount Value="32"/> | ||||
|         <UsageCount Value="33"/> | ||||
|       </Unit12> | ||||
|     </Units> | ||||
|     <PublishOptions> | ||||
|  | ||||
| @ -233,6 +233,7 @@ end; | ||||
| 
 | ||||
| procedure TEditorPage.ElementChanged(Sender: TObject); | ||||
| begin | ||||
|   if Sender=nil then ; | ||||
|   TPackageEditor(FPackages).UpdateSelectedNodeStatus; | ||||
| end; | ||||
| 
 | ||||
|  | ||||
| @ -255,8 +255,6 @@ end; | ||||
|   ---------------------------------------------------------------------} | ||||
| 
 | ||||
| Constructor TPackageEditor.Create(AOwner : TComponent); | ||||
| var | ||||
|   TmpPanel: TPanel; | ||||
| 
 | ||||
|   Function NewMenuItem(ACaption : String; AOnClick : TNotifyEvent) : TMenuItem; | ||||
| 
 | ||||
| @ -521,6 +519,7 @@ procedure TPackageEditor.MenuCollapseAllClick(Sender: TObject); | ||||
| var | ||||
|   Node: TTreeNode; | ||||
| begin | ||||
|   if Sender=nil then ; | ||||
|   ElementTree.FullCollapse; | ||||
|   Node := ElementTree.Items.GetFirstNode; | ||||
|   if Node<>nil then | ||||
| @ -529,6 +528,7 @@ end; | ||||
| 
 | ||||
| procedure TPackageEditor.MenuExpandAllClick(Sender: TObject); | ||||
| begin | ||||
|   if Sender=nil then ; | ||||
|   ElementTree.FullExpand; | ||||
| end; | ||||
| 
 | ||||
|  | ||||
| @ -719,6 +719,7 @@ type | ||||
|     FAlign: TAlign; | ||||
|     FAnchors: TAnchors; | ||||
|     FAnchorSides: array[TAnchorKind] of TAnchorSide; | ||||
|     FAutoSizingLockCount: Integer; | ||||
|     FAutoSize: Boolean; | ||||
|     FBaseBounds: TRect; | ||||
|     FBaseBoundsLock: integer; | ||||
| @ -1065,6 +1066,8 @@ type | ||||
|                                Raw: boolean); virtual; | ||||
|     procedure CNPreferredSizeChanged; | ||||
|     procedure InvalidatePreferredSize; virtual; | ||||
|     procedure DisableAutoSizing; | ||||
|     procedure EnableAutoSizing; | ||||
|   public | ||||
|     constructor Create(TheOwner: TComponent);override; | ||||
|     destructor Destroy; override; | ||||
| @ -1600,6 +1603,8 @@ type | ||||
|     procedure InvalidateClientRectCache(WithChildControls: boolean); | ||||
|     function ClientRectNeedsInterfaceUpdate: boolean; | ||||
|     procedure SetBounds(aLeft, aTop, aWidth, aHeight: integer); override; | ||||
|     procedure DisableAlign; | ||||
|     procedure EnableAlign; | ||||
|   public | ||||
|     constructor Create(TheOwner: TComponent);override; | ||||
|     constructor CreateParented(ParentWindow: HWnd); | ||||
| @ -1617,8 +1622,6 @@ type | ||||
|     Procedure BroadCast(var ToAllMessage); | ||||
|     procedure NotifyControls(Msg: Word); | ||||
|     procedure DefaultHandler(var AMessage); override; | ||||
|     Procedure DisableAlign; | ||||
|     Procedure EnableAlign; | ||||
|     function  GetTextLen: Integer; override; | ||||
|     Procedure Invalidate; override; | ||||
|     Procedure InsertControl(AControl: TControl); | ||||
|  | ||||
| @ -1944,8 +1944,9 @@ end; | ||||
| ------------------------------------------------------------------------------} | ||||
| function TControl.AutoSizeDelayed: boolean; | ||||
| begin | ||||
|   Result:=// no autosize during loading or destruction | ||||
|           ([csLoading,csDestroying]*ComponentState<>[]) | ||||
|   Result:=(FAutoSizingLockCount>0) | ||||
|           // no autosize during loading or destruction
 | ||||
|           or ([csLoading,csDestroying]*ComponentState<>[]) | ||||
|           // no autosize for invisible controls
 | ||||
|           or ((not Visible) and (not (csDesigning in ComponentState))) | ||||
|           // if there is no parent, then this control is not visible
 | ||||
| @ -1956,7 +1957,8 @@ begin | ||||
|   {$IFDEF VerboseCanAutoSize} | ||||
|   if Result and AutoSize then begin | ||||
|     DbgOut('TControl.AutoSizeDelayed Self='+DbgSName(Self)+' '); | ||||
|     if csLoading in ComponentState then debugln('csLoading') | ||||
|     if FAutoSizingLockCount>0 then debugln('FAutoSizingLockCount=',dbgs(FAutoSizingLockCount)) | ||||
|     else if csLoading in ComponentState then debugln('csLoading') | ||||
|     else if csDestroying in ComponentState then debugln('csDestroying') | ||||
|     else if not Visible then debugln('Visible') | ||||
|     else if NeedParentForAutoSize and (Parent=nil) then debugln('NeedParentForAutoSize and (Parent=nil)') | ||||
| @ -3512,6 +3514,19 @@ begin | ||||
|   end; | ||||
| end; | ||||
| 
 | ||||
| procedure TControl.DisableAutoSizing; | ||||
| begin | ||||
|   inc(FAutoSizingLockCount); | ||||
| end; | ||||
| 
 | ||||
| procedure TControl.EnableAutoSizing; | ||||
| begin | ||||
|   if FAutoSizingLockCount<=0 then RaiseGDBException('TControl.EnableAutoSizing'); | ||||
|   dec(FAutoSizingLockCount); | ||||
|   if FAutoSizingLockCount=0 then | ||||
|     AdjustSize; | ||||
| end; | ||||
| 
 | ||||
| {------------------------------------------------------------------------------ | ||||
|   Method: TControl.WMWindowPosChanged | ||||
|   Params:   Msg: The message | ||||
|  | ||||
| @ -437,6 +437,8 @@ begin | ||||
|   DebugLn('TCustomNotebook.InsertPage A ',Name,' Index=',Index,' Name=', | ||||
|     APage.Name,' Caption=',APage.Caption); | ||||
|   {$ENDIF} | ||||
|   APage.DisableAutoSizing; | ||||
|   try | ||||
|     if Index<FPageList.Count then | ||||
|       NewZPosition:=GetControlIndex(TCustomPage(fPageList[Index])) | ||||
|     else | ||||
| @ -448,11 +450,11 @@ begin | ||||
|     if PageIndex = -1 then | ||||
|       FPageIndex := Index; | ||||
| 
 | ||||
| {$ifndef WIN32} | ||||
|   {$ifndef WIN32} | ||||
|     // TODO: remove when gtk widgetset fixed to show tabpage tab upon
 | ||||
|     //   AddPage, instead of needing TabPage.Visible := true
 | ||||
|     APage.Visible := true; | ||||
| {$endif} | ||||
|   {$endif} | ||||
| 
 | ||||
|     UpdateDesignerFlags(Index); | ||||
| 
 | ||||
| @ -463,6 +465,9 @@ begin | ||||
|       if PageIndex = Index then | ||||
|         DoSendPageIndex; | ||||
|     end; | ||||
|   finally | ||||
|     APage.EnableAutoSizing; | ||||
|   end; | ||||
|   {$IFDEF NOTEBOOK_DEBUG} | ||||
|   DebugLn('TCustomNotebook.InsertPage END ',Name,' Index=', | ||||
|     Index,' Name=',APage.Name,' Caption=',APage.Caption); | ||||
| @ -486,10 +491,11 @@ begin | ||||
|     TWSCustomNotebookClass(WidgetSetClass).MovePage(Self, APage, NewIndex); | ||||
| end; | ||||
| 
 | ||||
| procedure TCustomNoteBook.ChildPageSetTabVisible(APage: TCustomPage; AValue: Boolean; AIndex: Integer); | ||||
| procedure TCustomNoteBook.ChildPageSetTabVisible(APage: TCustomPage; | ||||
|   AValue: Boolean; AIndex: Integer); | ||||
| var | ||||
| X: Integer; | ||||
| RealIndex: Integer; | ||||
|   X: Integer; | ||||
|   RealIndex: Integer; | ||||
| begin | ||||
|   RealIndex:= AIndex; | ||||
|   for X := 0 to AIndex-1 do | ||||
|  | ||||
| @ -34,6 +34,7 @@ function TWinControl.AutoSizeDelayed: boolean; | ||||
| begin | ||||
|   Result:=// no handle means not visible | ||||
|           (not HandleAllocated) | ||||
|           or (not FShowing) | ||||
|           // during handle creation no autosize
 | ||||
|           or (wcfCreatingChildHandles in FWinControlFlags) | ||||
|           or (inherited AutoSizeDelayed); | ||||
| @ -42,6 +43,7 @@ begin | ||||
|   if Result and AutoSize then begin | ||||
|     DbgOut('TWinControl.AutoSizeDelayed Self='+DbgSName(Self)+' '); | ||||
|     if not HandleAllocated then debugln('not HandleAllocated') | ||||
|     else if not FShowing then debugln('not FShowing') | ||||
|     else if wcfCreatingChildHandles in FWinControlFlags then debugln('wcfCreatingChildHandles') | ||||
|     else debugln('inherited AutoSizeDelayed'); | ||||
|   end; | ||||
| @ -687,6 +689,7 @@ var | ||||
|   Child: TControl; | ||||
|   AWinControl: TWinControl; | ||||
| begin | ||||
|   if AutoSizeDelayed then exit; | ||||
|   for i:=0 to ControlCount-1 do begin | ||||
|     Child:=Controls[i]; | ||||
|     if Child.AutoSizeDelayed then continue; | ||||
| @ -1413,6 +1416,8 @@ begin | ||||
|     if not ok then | ||||
|       FShowing := not bShow; | ||||
|   end; | ||||
|    | ||||
|   if FShowing then ResizeDelayedAutoSizeChilds; | ||||
| end; | ||||
| 
 | ||||
| procedure TWinControl.Update; | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 mattias
						mattias