diff --git a/ide/main.pp b/ide/main.pp index e17193b9ad..f19aef0b8d 100644 --- a/ide/main.pp +++ b/ide/main.pp @@ -4383,8 +4383,9 @@ var ACaption, AText: String; NewUnitName: String; begin + debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' IsPartOfProject=',dbgs(AnUnitInfo.IsPartOfProject),' '); + // check installed packages - debugln('TMainIDE.DoLoadLFM A ',AnUnitInfo.Filename,' ',dbgs(AnUnitInfo.IsPartOfProject),' '); if (Flags*[ofProjectLoading,ofMultiOpen]=[]) and AnUnitInfo.IsPartOfProject then begin // opening a single form of the project -> check installed packages diff --git a/ideintf/componenttreeview.pas b/ideintf/componenttreeview.pas index d1a4dd67b8..4d714e4f8e 100644 --- a/ideintf/componenttreeview.pas +++ b/ideintf/componenttreeview.pas @@ -44,10 +44,10 @@ type procedure SetSelection(const NewSelection: TPersistentSelectionList); protected procedure DoSelectionChanged; override; - function GetImageFor(AComponent:TComponent):integer; - procedure DropObject(Sender, Source: TObject; X, Y: Integer); - procedure AcceptDrop(Sender, Source: TObject; X, Y: Integer; - State: TDragState; var Accept: Boolean); + function GetImageFor(AComponent: TComponent):integer; + procedure DragDrop(Source: TObject; X,Y: Integer); override; + procedure DragOver(Source: TObject; X,Y: Integer; State: TDragState; + var Accept: Boolean); override; public constructor Create(TheOwner: TComponent); override; destructor Destroy; override; @@ -137,7 +137,7 @@ begin end; end; -procedure TComponentTreeView.DropObject(Sender, Source: TObject; X, Y: Integer); +procedure TComponentTreeView.DragDrop(Source: TObject; X, Y: Integer); var Node, SelNode:TTreeNode; AContainer,AControl:TControl; @@ -153,51 +153,69 @@ begin end; RebuildComponentNodes; end; + inherited DragDrop(Source, X, Y); end; -procedure TComponentTreeView.AcceptDrop(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); +procedure TComponentTreeView.DragOver(Source: TObject; X, Y: Integer; + State: TDragState; var Accept: Boolean); var Node:TTreeNode; AnObject:TObject; AContainer,AControl:TControl; AcceptControl, AcceptContainer:Boolean; begin + //debugln('TComponentTreeView.DragOver START ',dbgs(Accept)); + AcceptContainer := False; + AcceptControl := True; + Node:=GetNodeAt(X, Y); if Assigned(Node) and Assigned(Node.Data) then begin AnObject:=TObject(Node.Data); - if (AnObject is TWinControl) and (csAcceptsControls in TWinControl(AnObject).ControlStyle) then + if (AnObject is TWinControl) + and (csAcceptsControls in TWinControl(AnObject).ControlStyle) then begin AContainer := TWinControl(AnObject); AcceptContainer := True; end; end; - - AcceptControl := True; - Node := GetFirstMultiSelected; - while Assigned(Node) do begin - AnObject:=TObject(Node.Data); - AcceptControl := AcceptControl and (AnObject is TControl); - // Check if one of the parent of the containder is the control itself - if AcceptControl and AcceptContainer then begin - while Assigned(AContainer) do begin - AControl:=TControl(AnObject); - AcceptControl := AcceptControl and (AControl <> AContainer); - AContainer := AContainer.Parent; + + if AcceptContainer then begin + Node := GetFirstMultiSelected; + while Assigned(Node) do begin + AnObject:=TObject(Node.Data); + AcceptControl := AcceptControl and (AnObject is TControl); + // Check if one of the parent of the container is the control itself + if AcceptControl and AcceptContainer then begin + while Assigned(AContainer) do begin + AControl:=TControl(AnObject); + AcceptControl := AcceptControl and (AControl <> AContainer); + AContainer := AContainer.Parent; + end; end; + Node := Node.GetNextMultiSelected; end; - Node := Node.GetNextMultiSelected; end; Accept := AcceptContainer and AcceptControl; + //debugln('TComponentTreeView.DragOver A ',dbgs(Accept)); + inherited DragOver(Source, X, Y, State, Accept); + //debugln('TComponentTreeView.DragOver B ',dbgs(Accept)); + + Accept := AcceptContainer and AcceptControl + and ((OnDragOver=nil) or Accept); end; function TComponentTreeView.GetImageFor(AComponent: TComponent): integer; begin if Assigned(AComponent) then begin - if (AComponent is TControl) and (csAcceptsControls in TControl(AComponent).ControlStyle) then Result := 3 - else if (AComponent is TControl) then Result := 2 - else Result := 1; + if (AComponent is TControl) + and (csAcceptsControls in TControl(AComponent).ControlStyle) then + Result := 3 + else if (AComponent is TControl) then + Result := 2 + else + Result := 1; end else Result := -1; end; @@ -219,8 +237,6 @@ constructor TComponentTreeView.Create(TheOwner: TComponent); begin inherited Create(TheOwner); DragMode := dmAutomatic; - OnDragOver := @AcceptDrop; - OnDragDrop := @DropObject; FComponentList:=TBackupComponentList.Create; Options:=Options+[tvoAllowMultiselect,tvoAutoItemHeight,tvoKeepCollapsedNodes]; FImageList := TImageList.Create(nil); diff --git a/ideintf/objectinspector.pp b/ideintf/objectinspector.pp index e01503aee2..5e6bed7df6 100644 --- a/ideintf/objectinspector.pp +++ b/ideintf/objectinspector.pp @@ -1917,7 +1917,7 @@ begin if FCurrentEdit<>nil then begin // resize the edit component EditCompRect.Left:=EditCompRect.Left-1; - debugln('TOICustomPropertyGrid.AlignEditComponents A ',dbgsName(FCurrentEdit),' ',dbgs(EditCompRect)); + //debugln('TOICustomPropertyGrid.AlignEditComponents A ',dbgsName(FCurrentEdit),' ',dbgs(EditCompRect)); if not CompareRectangles(FCurrentEdit.BoundsRect,EditCompRect) then begin FCurrentEdit.BoundsRect:=EditCompRect; FCurrentEdit.Invalidate; diff --git a/lcl/controls.pp b/lcl/controls.pp index 7166f57eec..7eccc9021d 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -1109,6 +1109,7 @@ type function HasParent: Boolean; override; function IsParentOf(AControl: TControl): boolean; virtual; function IsVisible: Boolean; virtual; + function IsControlVisible: Boolean; procedure Hide; procedure Refresh; procedure Repaint; virtual; @@ -2849,10 +2850,7 @@ begin exit; end; - if ReferenceControl.Visible - or ((csDesigning in ReferenceControl.ComponentState) - and not (csNoDesignVisible in ReferenceControl.ControlStyle)) - then begin + if ReferenceControl.IsControlVisible then begin // ReferenceControl is visible // -> calculate Position OwnerBorderSpacing:=FOwner.BorderSpacing.GetSpace(Kind); diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 917dcec4c7..12e4053fa9 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -344,7 +344,7 @@ begin //DebugLn('TControl.ChangeBounds A ',Name,':',ClassName); if (not (csLoading in ComponentState)) and (not (Self is TWinControl)) then - InvalidateControl(Visible, False, true); + InvalidateControl(IsControlVisible, False, true); //DebugLn('TControl.ChangeBounds B ',Name,':',ClassName); DoSetBounds(ALeft,ATop,AWidth,AHeight); @@ -659,29 +659,39 @@ end; function TControl.IsVisible: Boolean; begin - Result := FVisible and ((Parent = nil) or (Parent.IsVisible)); + Result := (FVisible + or ((csDesigning in ComponentState) + and (not (csNoDesignVisible in ControlStyle)))) + and ((Parent = nil) or (Parent.IsVisible)); end; -{------------------------------------------------------------------------------} -{ TControl.LMCaptureChanged } -{------------------------------------------------------------------------------} +function TControl.IsControlVisible: Boolean; +begin + Result := (FVisible + or ((csDesigning in ComponentState) + and (not (csNoDesignVisible in ControlStyle)))); +end; + +{------------------------------------------------------------------------------ + TControl.LMCaptureChanged +------------------------------------------------------------------------------} Procedure TControl.LMCaptureChanged(Var Message: TLMessage); Begin //DebugLn('[LMCaptureChanged for '+Name+':'+Classname+']'); CaptureChanged; End; -{------------------------------------------------------------------------------} -{ TControl.CMENABLEDCHANGED } -{------------------------------------------------------------------------------} +{------------------------------------------------------------------------------ + TControl.CMENABLEDCHANGED +------------------------------------------------------------------------------} procedure TControl.CMEnabledChanged(var Message: TLMEssage); begin Invalidate; end; -{------------------------------------------------------------------------------} -{ TControl.CMHITTEST } -{------------------------------------------------------------------------------} +{------------------------------------------------------------------------------ + TControl.CMHITTEST +------------------------------------------------------------------------------} procedure TControl.CMHITTEST(var Message : TCMHitTest); begin Message.Result := 1; @@ -1526,7 +1536,7 @@ end; ------------------------------------------------------------------------------} procedure TControl.Invalidate; Begin - InvalidateControl(Visible, csOpaque in ControlStyle); + InvalidateControl(IsVisible, csOpaque in ControlStyle); end; {------------------------------------------------------------------------------ @@ -1945,16 +1955,14 @@ begin Result:=AutoSize and (not AutoSizing) and (not (csDestroying in ComponentState)) - and (Visible or ((csDesigning in ComponentState) - and (not (csNoDesignVisible in ControlStyle)))); + and IsControlVisible; if AutoSize and not Result then begin {$IFDEF VerboseCanAutoSize} DbgOut('TControl.AutoSizeCanStart Self='+DbgSName(Self)+' '); if not AutoSize then DebugLn('not AutoSize') else if AutoSizing then DebugLn('AutoSizing') else if csDestroying in ComponentState then DebugLn('csDestroying in ComponentState') - else if not (Visible or ((csDesigning in ComponentState) - and (not (csNoDesignVisible in ControlStyle)))) then + else if not IsControlVisible then DebugLn('Visible=',dbgs(Visible), ' csDesigning=',dbgs(csDesigning in ComponentState), ' csNoDesignVisible=',dbgs(csNoDesignVisible in ControlStyle)) @@ -1975,7 +1983,7 @@ begin // no autosize during loading or destruction or ([csLoading,csDestroying]*ComponentState<>[]) // no autosize for invisible controls - or ((not Visible) and (not (csDesigning in ComponentState))) + or (not IsControlVisible) // if there is no parent, then this control is not visible // (TCustomForm will override this) or (NeedParentForAutoSize and (Parent=nil)) @@ -2298,7 +2306,7 @@ var Dec(I); C := TControl(List[I]); with C do - if C.Visible and (csOpaque in ControlStyle) then + if C.IsControlVisible and (csOpaque in ControlStyle) then begin IntersectRect(R, Rect, BoundsRect); if EqualRect(R, Rect) then Exit; @@ -2352,9 +2360,7 @@ begin if (Parent=nil) or (not Parent.HandleAllocated) or (csDestroying in ComponentState) then exit; - if (Visible or (csDesigning in ComponentState) - and not (csNoDesignVisible in ControlStyle)) - then + if IsVisible then if csOpaque in ControlStyle then begin {$IFDEF VerboseDsgnPaintMsg} @@ -2881,14 +2887,13 @@ begin end; end; -{------------------------------------------------------------------------------} -{ TControl SetVisible -} -{------------------------------------------------------------------------------} +{------------------------------------------------------------------------------ + TControl SetVisible + +------------------------------------------------------------------------------} procedure TControl.SetVisible(Value : Boolean); begin - if FVisible <> Value then - begin + if FVisible <> Value then begin VisibleChanging; FVisible := Value; Perform(CM_VISIBLECHANGED, WParam(Ord(Value)), 0); @@ -2898,10 +2903,10 @@ begin ControlState:=ControlState+[csVisibleSetInLoading]; end; -{------------------------------------------------------------------------------} -{ TControl.SetZOrder -} -{------------------------------------------------------------------------------} +{------------------------------------------------------------------------------ + TControl.SetZOrder + +------------------------------------------------------------------------------} procedure TControl.SetZOrder(Topmost: Boolean); const POSITION: array[Boolean] of Integer = (0, MaxInt); diff --git a/lcl/include/controlscrollbar.inc b/lcl/include/controlscrollbar.inc index 173d9af91c..af9975da0c 100644 --- a/lcl/include/controlscrollbar.inc +++ b/lcl/include/controlscrollbar.inc @@ -210,7 +210,7 @@ procedure TControlScrollBar.AutoCalcRange; for i := 0 to FControl.ControlCount - 1 do begin c := FControl.Controls[I]; - if not C.Visible then Continue; + if not C.IsControlVisible then Continue; if (c.Align <> alLeft) and (c.Align <> alNone) then Continue; // the left of a control is negative when it is scrolled to the left, @@ -389,7 +389,7 @@ end; function TControlScrollBar.IsScrollBarVisible: Boolean; begin Result := (FControl <> nil) and FControl.HandleAllocated and - (FControl.Visible) and (Self.Visible); + (FControl.IsControlVisible) and (Self.Visible); end; function TControlScrollBar.ScrollPos: Integer; diff --git a/lcl/include/customform.inc b/lcl/include/customform.inc index cc5f4b2ded..5e5c37c0a5 100644 --- a/lcl/include/customform.inc +++ b/lcl/include/customform.inc @@ -312,7 +312,7 @@ Begin {$ENDIF} if not FActive then begin - if not (Visible and Enabled) then + if not (IsControlVisible and Enabled) then RaiseCannotFocus; SetWindowFocus; end; diff --git a/lcl/include/custompanel.inc b/lcl/include/custompanel.inc index dd83cfe154..a83495a096 100644 --- a/lcl/include/custompanel.inc +++ b/lcl/include/custompanel.inc @@ -39,7 +39,8 @@ begin FBevelInner := bvNone; FBevelWidth := 1; FAlignment := taCenter; - Color:=clBtnface;// clBackground; + FFullRepaint := true; + Color:=clBtnFace;// clBackground; SetInitialBounds(0,0,170,50); ParentColor := True; end; @@ -113,6 +114,8 @@ begin TS.SystemFont:=Canvas.Font.IsDefault; Canvas.TextRect(ARect,ARect.Left,ARect.Top, Caption, TS); end; + + inherited Paint; end; function TCustomPanel.CanTab: Boolean; diff --git a/lcl/include/wincontrol.inc b/lcl/include/wincontrol.inc index 4f03df32df..d5d0b4db56 100644 --- a/lcl/include/wincontrol.inc +++ b/lcl/include/wincontrol.inc @@ -1268,9 +1268,7 @@ var if (AControl <> nil) and (AControl.Align = AAlign) and ((AAlign = alNone) - or AControl.Visible - or ((csDesigning in AControl.ComponentState) - and not (csNoDesignVisible in AControl.ControlStyle))) + or AControl.IsControlVisible) then AlignList.Add(AControl); @@ -1281,11 +1279,9 @@ var if (Control.Align = AAlign) and ((AAlign = alNone) - or (Control.Visible + or Control.IsControlVisible or (Control.ControlStyle * [csAcceptsControls, csNoDesignVisible] = - [csAcceptsControls, csNoDesignVisible])) - or ((csDesigning in Control.ComponentState) - and not (csNoDesignVisible in Control.ControlStyle))) then + [csAcceptsControls, csNoDesignVisible])) then begin if Control = AControl then Continue; @@ -1317,7 +1313,7 @@ var for i:=0 to ControlCount-1 do begin Control := Controls[i]; if (Control.Align=alNone) - and Control.Visible + and Control.IsControlVisible and (Control.Anchors=[akLeft,akTop]) and (Control.AnchorSide[akLeft].Control=nil) and (Control.AnchorSide[akTop].Control=nil) @@ -1490,7 +1486,7 @@ begin // move all childs to left and top of client area For I := 0 to ControlCount - 1 do begin AControl:=Controls[I]; - If AControl.Visible then begin + If AControl.IsControlVisible then begin AControl.SetBoundsKeepBase(AControl.Left + dx, AControl.Top + dy, AControl.Width,AControl.Height,true); end; @@ -1574,7 +1570,7 @@ begin begin Control := Self; repeat - if not (Control.FVisible and Control.Enabled) then Exit; + if not (Control.IsVisible and Control.Enabled) then Exit; if Control = Form then break; Control := Control.Parent; until false; @@ -2024,7 +2020,7 @@ begin TWinControl(AChild), idx, NewPos, list); end else begin - AChild.InvalidateControl(AChild.Visible, True, True); + AChild.InvalidateControl(AChild.IsVisible, True, True); end; end; @@ -2121,9 +2117,9 @@ begin end; end; -{------------------------------------------------------------------------------} -{ TWinControl UpdateShowing } -{------------------------------------------------------------------------------} +{------------------------------------------------------------------------------ + TWinControl UpdateShowing +------------------------------------------------------------------------------} procedure TWinControl.UpdateShowing; var bShow: Boolean; @@ -2488,10 +2484,7 @@ procedure TWinControl.PaintHandler(var TheMessage: TLMPaint); function ControlMustBeClipped(AControl: TControl): boolean; begin with AControl do - Result:=(Visible - or ((csDesigning in ComponentState) - and not (csNoDesignVisible in ControlStyle))) - and (csOpaque in ControlStyle); + Result:=IsVisible and (csOpaque in ControlStyle); end; var @@ -2590,9 +2583,7 @@ begin TempControl := TControl(FControls.Items[I]); //DebugLn('TWinControl.PaintControls B Self=',Self.Name,':',Self.ClassName,' Control=',TempControl.Name,':',TempControl.ClassName,' ',TempControl.Left,',',TempControl.Top,',',TempControl.Width,',',TempControl.Height); with TempControl do - if (Visible - or ((csDesigning in ComponentState) - and not (csNoDesignVisible in ControlStyle))) + if IsVisible and RectVisible(DC, Rect(Left, Top, Left + Width, Top + Height)) then begin if csPaintCopy in Self.ControlState then @@ -2624,10 +2615,7 @@ begin for I := 0 to FWinControls.Count - 1 do with TWinControl(FWinControls.Items[I]) do if FCtl3D and (csFramed in ControlStyle) - and (Visible - or ((csDesigning in ComponentState) - and not (csNoDesignVisible in ControlStyle))) - then begin + and IsVisible then begin //TODO: CreateSolidBrush and FrameRect {FrameBrush := CreateSolidBrush(clBtnShadow); FrameRect(DC, Rect(Left - 1, Top - 1, Left + Width, Top + Height), @@ -3132,7 +3120,7 @@ begin Form := GetParentForm(Self); if Form <> nil then Form.FocusControl(Self) - else if Visible and HandleAllocated then + else if IsVisible and HandleAllocated then LCLIntf.SetFocus(Handle); end; @@ -3878,9 +3866,8 @@ Begin if AWinControl.HandleAllocated then AWinControl.DestroyHandle; end else if HandleAllocated then - AControl.InvalidateControl(AControl.Visible, False, True); + AControl.InvalidateControl(AControl.IsVisible, False, True); Remove(AControl); -// Perform(CM_CONTROLLISTCHANGE, WParam(AControl), LParam(False)); Realign; End; @@ -4743,7 +4730,7 @@ begin if FWinControls <> nil then begin for i := 0 to FWinControls.Count - 1 do with TWinControl(FWinControls.Items[i]) do - if Visible then HandleNeeded; + if IsControlVisible then HandleNeeded; end; ChildHandlesCreated; @@ -5294,7 +5281,7 @@ begin SpaceAround:=Rect(0,0,0,0); For I := 0 to ControlCount - 1 do begin AControl:=Controls[I]; - If AControl.Visible then begin + If AControl.IsControlVisible then begin AControl.GetPreferredSize(ChildWidth,ChildHeight,false); // TODO: aligned controls if WithBorderSpace then begin