diff --git a/designer/controlselection.pp b/designer/controlselection.pp index e7b42774ea..2f8216a213 100644 --- a/designer/controlselection.pp +++ b/designer/controlselection.pp @@ -332,7 +332,8 @@ type property RubberbandActive: boolean read FRubberbandActive write FRubberbandActive; procedure DrawRubberband(DC: TDesignerDeviceContext); procedure SelectWithRubberBand(ACustomForm:TCustomForm; - ClearBefore, ExclusiveOr: boolean; var SelectionChanged: boolean); + ClearBefore, ExclusiveOr: boolean; var SelectionChanged: boolean; + MaxParentControl: TControl); procedure Sort(SortProc: TSelectionSortCompare); property Visible:boolean read FVisible write SetVisible; @@ -778,7 +779,7 @@ begin Result:=false; if AComponent=nil then exit; if AComponent is TControl then begin - if csNoDesignVisible in TControl(AComponent).ControlStyle then exit; + if not ControlIsDesignerVisible(TControl(AComponent)) then exit; if Count>0 then begin if OnlyNonVisualComponentsSelected then exit; end; @@ -1643,26 +1644,26 @@ var // DrawRubberband begin - if (FCustomForm=nil) then exit; Diff:=DC.FormOrigin; with FRubberBandBounds do DrawInvertFrameRect(Left-Diff.X,Top-Diff.Y,Right-Diff.X,Bottom-Diff.Y); end; procedure TControlSelection.SelectWithRubberBand(ACustomForm:TCustomForm; - ClearBefore, ExclusiveOr:boolean; var SelectionChanged: boolean); + ClearBefore, ExclusiveOr:boolean; var SelectionChanged: boolean; + MaxParentControl: TControl); var i:integer; function ControlInRubberBand(AComponent:TComponent):boolean; var ALeft,ATop,ARight,ABottom:integer; Origin:TPoint; begin - if (AComponent is TMenuItem) - or ((AComponent is TControl) - and (csNoDesignVisible in TControl(AComponent).ControlStyle)) - then begin - Result:=false; - exit; + Result:=false; + if (AComponent is TMenuItem) then exit; + if (AComponent is TControl) then begin + if not ControlIsDesignerVisible(TControl(AComponent)) then exit; + if (MaxParentControl<>nil) + and (not MaxParentControl.IsParentOf(TControl(AComponent))) then exit; end; Origin:=GetParentFormRelativeTopLeft(AComponent); ALeft:=Origin.X; diff --git a/designer/designerprocs.pas b/designer/designerprocs.pas index ba370dcf22..e887946564 100644 --- a/designer/designerprocs.pas +++ b/designer/designerprocs.pas @@ -96,6 +96,8 @@ function GetComponentHeight(AComponent: TComponent): integer; function GetParentLevel(AControl: TControl): integer; +function ControlIsDesignerVisible(AControl: TControl): boolean; + implementation @@ -254,6 +256,18 @@ begin end; end; +function ControlIsDesignerVisible(AControl: TControl): boolean; +begin + Result:=true; + while AControl<>nil do begin + if csNoDesignVisible in AControl.ControlStyle then begin + Result:=false; + exit; + end; + AControl:=AControl.Parent; + end; +end; + { TDesignerDeviceContext } diff --git a/lcl/include/customnotebook.inc b/lcl/include/customnotebook.inc index 5293f9782c..d3a3dea635 100644 --- a/lcl/include/customnotebook.inc +++ b/lcl/include/customnotebook.inc @@ -217,9 +217,8 @@ begin APage.Parent := fNotebook; if NewZPosition>=0 then fNoteBook.SetControlIndex(APage,NewZPosition); - - // this is workaround til visible=true is default in TControl APage.Visible:=true; + fNoteBook.UpdateDesignerFlags(Index); if FNoteBook.HandleAllocated and (not (csLoading in FNoteBook.ComponentState)) @@ -462,6 +461,7 @@ procedure TCustomNotebook.SetPageIndex(Value: Integer); begin if fPageIndex = Value then exit; fPageIndex := Value; + UpdateAllDesignerFlags; DoSendPageIndex; end; @@ -473,6 +473,9 @@ begin Result := fPageIndex; end; +{------------------------------------------------------------------------------ + function TCustomNotebook.IsStoredActivePage: boolean; + ------------------------------------------------------------------------------} function TCustomNotebook.IsStoredActivePage: boolean; begin Result:=false; @@ -524,6 +527,30 @@ begin DoSendTabPosition; end; +{------------------------------------------------------------------------------ + procedure TCustomNotebook.UpdateAllDesignerFlags; + ------------------------------------------------------------------------------} +procedure TCustomNotebook.UpdateAllDesignerFlags; +var + i: integer; +begin + for i:=0 to PageCount-1 do + UpdateDesignerFlags(i); +end; + +{------------------------------------------------------------------------------ + procedure TCustomNotebook.UpdateDesignerFlags(APageIndex: integer); + ------------------------------------------------------------------------------} +procedure TCustomNotebook.UpdateDesignerFlags(APageIndex: integer); +begin + if APageIndex<>fPageIndex then + Page[APageIndex].ControlStyle:= + Page[APageIndex].ControlStyle+[csNoDesignVisible] + else + Page[APageIndex].ControlStyle:= + Page[APageIndex].ControlStyle-[csNoDesignVisible]; +end; + {------------------------------------------------------------------------------ TCustomNotebook CreateParams ------------------------------------------------------------------------------} @@ -606,6 +633,7 @@ Begin FPageIndex := NMHDR^.idfrom; if FPageIndex>=PageCount then FPageIndex:=-1; + UpdateAllDesignerFlags; Change; if csDesigning in ComponentState then OwnerFormDesignerModified(Self); @@ -630,8 +658,11 @@ begin if not HandleAllocated or (csLoading in ComponentState) then exit; Msg.Parent := Self; Msg.fCompStyle := fCompStyle; - if (FPageIndex<0) and (PageCount>0) then fPageIndex:=0; - Msg.Page := FPageIndex; + if (FPageIndex<0) and (PageCount>0) then begin + fPageIndex:=0; + UpdateAllDesignerFlags; + end; + Msg.Page := fPageIndex; {$IFDEF NOTEBOOK_DEBUG} writeln('[TCustomNotebook.DoSendPageIndex] A ',Name,' PageIndex=',fPageIndex); {$ENDIF} @@ -703,6 +734,9 @@ end;} { ============================================================================= $Log$ + Revision 1.27 2002/11/18 17:06:29 mattias + improved designer rubberband + Revision 1.26 2002/11/18 13:38:44 mattias fixed buffer overrun and added several checks