diff --git a/components/codetools/stdcodetools.pas b/components/codetools/stdcodetools.pas index 2427db5b2b..1c1c742861 100644 --- a/components/codetools/stdcodetools.pas +++ b/components/codetools/stdcodetools.pas @@ -42,6 +42,7 @@ interface {$I codetools.inc} { $DEFINE IgnoreErrorAfterCursor} +{ $DEFINE VerboseGetStringConstBounds} uses {$IFDEF MEM_CHECK} @@ -1992,11 +1993,11 @@ begin Result:=true; BuildTreeAndGetCleanPos(trAll,CursorPos,CleanCursorPos,[]); {$IFDEF VerboseGetStringConstBounds} - DebugLn('TStandardCodeTool.GetStringConstBounds A ',CleanCursorPos,' "',copy(Src,CleanCursorPos-5,5),'" | "',copy(Src,CleanCursorPos,5),'"'); + DebugLn('TStandardCodeTool.GetStringConstBounds A Start at ',dbgs(CleanCursorPos),' "',copy(Src,CleanCursorPos-5,5),'" | "',copy(Src,CleanCursorPos,5),'"'); {$ENDIF} GetCleanPosInfo(-1,CleanCursorPos,ResolveComments,SameArea); {$IFDEF VerboseGetStringConstBounds} - DebugLn('TStandardCodeTool.GetStringConstBounds B ',SameArea.StartPos,'-',SameArea.EndPos,' "',copy(Src,SameArea.StartPos,SameArea.EndPos-SameArea.StartPos),'"'); + DebugLn('TStandardCodeTool.GetStringConstBounds B Same Area: ',dbgs(SameArea.StartPos),'-',dbgs(SameArea.EndPos),' "',copy(Src,SameArea.StartPos,SameArea.EndPos-SameArea.StartPos),'"'); {$ENDIF} if (SameArea.EndPos=SameArea.StartPos) or (SameArea.StartPos>SrcLen) then exit; @@ -2005,7 +2006,7 @@ begin MoveCursorToCleanPos(SameArea.StartPos); ReadNextAtom; {$IFDEF VerboseGetStringConstBounds} - DebugLn('TStandardCodeTool.GetStringConstBounds read til end of string ',GetAtom); + DebugLn('TStandardCodeTool.GetStringConstBounds read til end of string Atom=',GetAtom); {$ENDIF} CurrentToken:=GetCurrentTokenType; if (CurrentToken=scatNone) then exit; @@ -2016,7 +2017,7 @@ begin LastToken:=CurrentToken; CurrentToken:=GetCurrentTokenType; {$IFDEF VerboseGetStringConstBounds} - DebugLn('TStandardCodeTool.GetStringConstBounds Read Forward: ',GetAtom,' EndCleanPos=',EndCleanPos, + DebugLn('TStandardCodeTool.GetStringConstBounds Read Forward: ',GetAtom,' EndCleanPos=',dbgs(EndCleanPos), ' LastToken=',StrConstTokenTypeName[LastToken], ' CurrentToken=',StrConstTokenTypeName[CurrentToken], ' ',StrConstTokenTypeName[GetCurrentTokenType]); @@ -2047,7 +2048,8 @@ begin if not (LastToken in [scatPlus, scatPoint]) then exit; scatPoint: - if not (LastToken in [scatIdent, scatUp, scatRoundBracketClose]) then + if not (LastToken in [scatIdent, scatUp, scatRoundBracketClose, + scatEdgedBracketClose]) then exit; scatEdgedBracketOpen,scatRoundBracketOpen: @@ -2072,7 +2074,7 @@ begin StartCleanPos:=CurPos.StartPos; ReadPriorAtom; {$IFDEF VerboseGetStringConstBounds} - DebugLn('TStandardCodeTool.GetStringConstBounds Read backward: ',GetAtom,' StartCleanPos=',StartCleanPos); + DebugLn('TStandardCodeTool.GetStringConstBounds Read backward: ',GetAtom,' StartCleanPos=',dbgs(StartCleanPos)); {$ENDIF} LastToken:=CurrentToken; CurrentToken:=GetCurrentTokenType; @@ -2116,7 +2118,7 @@ begin // convert start and end position {$IFDEF VerboseGetStringConstBounds} - DebugLn('TStandardCodeTool.GetStringConstBounds END "',copy(Src,StartCleanPos,EndCleanPos-StartCleanPos),'" StringConstantFound=',StringConstantFound); + DebugLn('TStandardCodeTool.GetStringConstBounds END "',copy(Src,StartCleanPos,EndCleanPos-StartCleanPos),'" StringConstantFound=',dbgs(StringConstantFound)); {$ENDIF} if not StringConstantFound then begin EndCleanPos:=StartCleanPos; diff --git a/ideintf/objinspstrconsts.pas b/ideintf/objinspstrconsts.pas index fc77e748a7..301dc091e6 100644 --- a/ideintf/objinspstrconsts.pas +++ b/ideintf/objinspstrconsts.pas @@ -26,6 +26,8 @@ resourcestring oiscAdd = '&Add'; oiscDelete = '&Delete'; + oisConfirmDelete = 'Confirm delete'; + oisDeleteItem = 'Delete item %s%s%s?'; oisUnknown = 'Unknown'; oisObject = 'Object'; oisClass = 'Class'; diff --git a/ideintf/propedits.pp b/ideintf/propedits.pp index aad9ce3cc2..d7344b25cd 100644 --- a/ideintf/propedits.pp +++ b/ideintf/propedits.pp @@ -3322,7 +3322,7 @@ Type procedure MoveDownButtonClick(Sender: TObject); procedure MoveUpButtonClick(Sender: TObject); protected - CollectionList : TListBox; + CollectionListBox: TListBox; ButtonPanel: TPanel; AddButton: TSpeedButton; DeleteButton: TSpeedButton; @@ -3334,13 +3334,144 @@ Type Collection: TCollection; PersistentName: string; PropertyName: string; - Procedure PropagateList; + procedure FillCollectionListBox; Constructor Create(TheOwner: TComponent); Override; + procedure SelectInObjectInspector(UnselectAll: boolean); end; const CollectionForm : TCollectionPropertyEditorForm = nil; +procedure TCollectionPropertyEditorForm.ListClick(Sender: TObject); +begin + UpdateButtons; + UpdateCaption; + SelectInObjectInspector(false); +end; + +procedure TCollectionPropertyEditorForm.AddClick(Sender: TObject); +begin + Collection.Add; + FillCollectionListBox; +end; + +procedure TCollectionPropertyEditorForm.DeleteClick(Sender: TObject); +var + I : Integer; + NewItemIndex: Integer; +begin + I := CollectionListBox.ItemIndex; + if (i>=0) and (ii then dec(NewItemIndex); + //debugln('TCollectionPropertyEditorForm.DeleteClick A NewItemIndex=',dbgs(NewItemIndex),' ItemIndex=',dbgs(CollectionListBox.ItemIndex),' CollectionListBox.Items.Count=',dbgs(CollectionListBox.Items.Count),' Collection.Count=',dbgs(Collection.Count)); + // unselect all items in OI (collections can act strange on delete) + SelectInObjectInspector(true); + // now delete + Collection.Items[i].Free; + // update listbox after whatever happened + FillCollectionListBox; + // set NewItemIndex + if NewItemIndex=Collection.Count-1 then exit; + Collection.Items[i].Index:=i+1; + CollectionListBox.ItemIndex:=i+1; + FillCollectionListBox; +end; + +procedure TCollectionPropertyEditorForm.MoveUpButtonClick(Sender: TObject); +var + i: LongInt; +begin + i:=CollectionListBox.ItemIndex; + if i<=0 then exit; + Collection.Items[i].Index:=i-1; + CollectionListBox.ItemIndex:=i-1; + FillCollectionListBox; +end; + +procedure TCollectionPropertyEditorForm.UpdateCaption; +var + NewCaption: String; +begin + //I think to match Delphi this should be formated like + //"Editing ComponentName.PropertyName[Index]" + NewCaption:= 'Editing ' + PersistentName + '.' + PropertyName; + If CollectionListBox.ItemIndex > -1 then + NewCaption := NewCaption + '[' + + IntToStr(CollectionListBox.ItemIndex) + ']'; + Caption:=NewCaption; +end; + +procedure TCollectionPropertyEditorForm.UpdateButtons; +var + i: LongInt; +begin + i:=CollectionListBox.ItemIndex; + DeleteButton.Enabled:= i > -1; + MoveUpButton.Enabled:=i>0; + MoveDownButton.Enabled:=(i>=0) and (inil then + Cnt:=Collection.Count + else + Cnt:=0; + // add or replace list items + for I:=0 to Cnt - 1 do begin + CurItem:=Collection.Items[I].DisplayName; + if i>=CollectionListBox.Items.Count then + CollectionListBox.Items.Add(CurItem) + else + CollectionListBox.Items[I]:=CurItem; + end; + // delete unneeded list items + while CollectionListBox.Items.Count>Cnt do begin + CollectionListBox.Items.Delete(CollectionListBox.Items.Count-1); + end; + CollectionListBox.Items.EndUpdate; + + UpdateButtons; + UpdateCaption; +end; + Constructor TCollectionPropertyEditorForm.Create(TheOwner : TComponent); var x: Integer; @@ -3405,8 +3536,8 @@ begin inc(x,w); end; - CollectionList := TListBox.Create(Self); - With CollectionList do begin + CollectionListBox := TListBox.Create(Self); + With CollectionListBox do begin Parent:= Self; Align:= alClient; // MultiSelect:= true; @@ -3414,126 +3545,26 @@ begin end; end; -procedure TCollectionPropertyEditorForm.UpdateCaption; +procedure TCollectionPropertyEditorForm.SelectInObjectInspector( + UnselectAll: boolean); var - NewCaption: String; -begin - //I think to match Delphi this should be formated like - //"Editing ComponentName.PropertyName[Index]" - NewCaption:= 'Editing ' + PersistentName + '.' + PropertyName; - If CollectionList.ItemIndex > -1 then - NewCaption := NewCaption + '[' + - IntToStr(CollectionList.ItemIndex) + ']'; - Caption:=NewCaption; -end; - -procedure TCollectionPropertyEditorForm.UpdateButtons; -var - i: LongInt; -begin - i:=CollectionList.ItemIndex; - DeleteButton.Enabled:= i > -1; - MoveUpButton.Enabled:=i>0; - MoveDownButton.Enabled:=(i>=0) and (inil then - Cnt:=Collection.Count - else - Cnt:=0; - // add or replace list items - for I:=0 to Cnt - 1 do begin - CurItem:=Collection.Items[I].DisplayName; - if i>=CollectionList.Items.Count then - CollectionList.Items.Add(CurItem) - else - CollectionList.Items[I]:=CurItem; - end; - // delete unneeded list items - while CollectionList.Items.Count>Cnt do begin - CollectionList.Items.Delete(CollectionList.Items.Count-1); - end; - CollectionList.Items.EndUpdate; - - UpdateButtons; - UpdateCaption; -end; - -procedure TCollectionPropertyEditorForm.MoveDownButtonClick(Sender: TObject); -var - i: LongInt; -begin - i:=CollectionList.ItemIndex; - if i>=Collection.Count-1 then exit; - Collection.Items[i].Index:=i+1; - CollectionList.ItemIndex:=i+1; - PropagateList; -end; - -procedure TCollectionPropertyEditorForm.MoveUpButtonClick(Sender: TObject); -var - i: LongInt; -begin - i:=CollectionList.ItemIndex; - if i<=0 then exit; - Collection.Items[i].Index:=i-1; - CollectionList.ItemIndex:=i-1; - PropagateList; -end; - -procedure TCollectionPropertyEditorForm.ListClick(Sender: TObject); -var - NewSelection: TPersistentSelectionList; i: Integer; + NewSelection: TPersistentSelectionList; begin - UpdateButtons; - UpdateCaption; // select in OI NewSelection:=TPersistentSelectionList.Create; try - for i:=0 to CollectionList.Items.Count-1 do - if CollectionList.Selected[i] then - NewSelection.Add(Collection.Items[i]); + if not UnselectAll then begin + for i:=0 to CollectionListBox.Items.Count-1 do + if CollectionListBox.Selected[i] then + NewSelection.Add(Collection.Items[i]); + end; GlobalDesignHook.SetSelection(NewSelection); finally NewSelection.Free; end; end; -procedure TCollectionPropertyEditorForm.AddClick(Sender: TObject); -begin - Collection.Add; - PropagateList; -end; - -procedure TCollectionPropertyEditorForm.DeleteClick(Sender: TObject); -var - I : Integer; -begin - I := CollectionList.ItemIndex; - if (i>=0) and (i= CollectionList.Items.Count then - I := I - 1; - If I > -1 then - CollectionList.ItemIndex := I; - end; - end; - UpdateButtons; -end; - // - - - - - - - - - - - - - - - - - - - - - - - - - - function TCollectionPropertyEditor.ReadElement(Index: integer): TPersistent; @@ -3611,7 +3642,7 @@ begin PropertyName := GetPropInfo^.Name; PersistentName := ''; Caption := 'Editing ' + GetPropInfo^.Name; - PropagateList; + FillCollectionListBox; Show; end; end; diff --git a/lcl/controls.pp b/lcl/controls.pp index 53b887f22f..0a7e56cc73 100644 --- a/lcl/controls.pp +++ b/lcl/controls.pp @@ -947,8 +947,8 @@ type procedure SetEnabled(Value: Boolean); virtual; procedure SetHint(const Value: String); virtual; procedure SetName(const Value: TComponentName); override; - procedure SetParent(AParent: TWinControl); virtual; - Procedure SetParentComponent(Value: TComponent); override; + procedure SetParent(NewParent: TWinControl); virtual; + Procedure SetParentComponent(NewParentComponent: TComponent); override; procedure WndProc(var TheMessage: TLMessage); virtual; procedure CaptureChanged; virtual; procedure Notification(AComponent: TComponent; Operation: TOperation); override; @@ -1698,7 +1698,7 @@ type FGrabbersOnTop: Boolean; FFlags: TDockTreeFlags; //FOldRect: TRect; - FOldWndProc: TWndMethod; + //FOldWndProc: TWndMethod; //FReplacementZone: TDockZone; //FScaleBy: Double; //FShiftScaleOrient: TDockOrientation; @@ -1711,16 +1711,15 @@ type FTopXYLimit: Integer; FUpdateCount: Integer; //FVersion: Integer; - procedure WindowProc(var AMessage: TLMessage); procedure DeleteZone(Zone: TDockZone); protected procedure AdjustDockRect(AControl: TControl; var ARect: TRect); virtual; procedure BeginUpdate; override; procedure EndUpdate; override; - procedure GetControlBounds(AControl: TControl; var CtlBounds: TRect); override; + procedure GetControlBounds(AControl: TControl; var ControlBounds: TRect); override; function HitTest(const MousePos: TPoint; var HTFlag: Integer): TControl; virtual; procedure InsertControl(AControl: TControl; InsertAt: TAlign; - DropCtl: TControl); override; + DropControl: TControl); override; procedure LoadFromStream(SrcStream: TStream); override; procedure PaintDockFrame(ACanvas: TCanvas; AControl: TControl; const ARect: TRect); virtual; @@ -2406,6 +2405,9 @@ end. { ============================================================================= $Log$ + Revision 1.236 2004/08/18 09:08:33 mattias + fixed deleting of collection item in prop editor + Revision 1.235 2004/08/16 20:40:26 mattias published TForm.SessionProperties, added property editor and activated the storage components for fpc 1.9.5 because of rttiutils diff --git a/lcl/include/control.inc b/lcl/include/control.inc index 7638ad06e7..fc5ce6b085 100644 --- a/lcl/include/control.inc +++ b/lcl/include/control.inc @@ -2493,16 +2493,28 @@ begin end; {------------------------------------------------------------------------------ - Procedure TControl.SetParent(AParent : TWinControl); + Procedure TControl.SetParent(NewParent : TWinControl); ------------------------------------------------------------------------------} -Procedure TControl.SetParent(AParent : TWinControl); +Procedure TControl.SetParent(NewParent: TWinControl); begin - if FParent = AParent then exit; - CheckNewParent(AParent); + if FParent = NewParent then exit; + CheckNewParent(NewParent); if FParent <> nil then FParent.RemoveControl(Self); - if AParent <> nil then AParent.InsertControl(Self); + if NewParent <> nil then NewParent.InsertControl(Self); end; +{------------------------------------------------------------------------------ + TControl SetParentComponent +------------------------------------------------------------------------------} +Procedure TControl.SetParentComponent(NewParentComponent: TComponent); +Begin + if (NewParentComponent is TWinControl) then + SetParent(TWinControl(NewParentComponent)); +end; + +{------------------------------------------------------------------------------ + procedure TControl.SetParentColor(Value : Boolean); +------------------------------------------------------------------------------} procedure TControl.SetParentColor(Value : Boolean); begin if FParentColor <> Value then @@ -2513,18 +2525,9 @@ begin end; end; - -{------------------------------------------------------------------------------} -{ TControl SetParentComponent } -{------------------------------------------------------------------------------} -Procedure TControl.SetParentComponent(Value : TComponent); -Begin - if (Value is TWinControl) then SetParent(TWinControl(Value)); -end; - -{------------------------------------------------------------------------------} -{ TControl SetParentShowHint } -{------------------------------------------------------------------------------} +{------------------------------------------------------------------------------ + TControl SetParentShowHint +------------------------------------------------------------------------------} Procedure TControl.SetParentShowHint(Value : Boolean); Begin if FParentShowHint <> Value @@ -2798,7 +2801,7 @@ begin HostDockSite.DockManager.GetControlBounds(Self,NewBounds); NewBounds.TopLeft:=HostDockSite.ControlToScreen(NewBounds.TopLeft); end else begin - NewBounds.TopLeft := ControlOrigin; + NewBounds.TopLeft:=ControlOrigin; end; NewBounds := Bounds(NewBounds.Left,NewBounds.Top,UndockWidth,UndockHeight); Result := ManualFloat(NewBounds); @@ -2849,6 +2852,7 @@ begin // create new float dock site and dock this control into it. if Result then begin FloatHost := CreateFloatingDockSite(TheScreenRect); + //debugln('TControl.ManualFloat A '+Name,':',ClassName,' ',dbgs(TheScreenRect)); if FloatHost<>nil then Dock(FloatHost,Rect(0,0,FloatHost.ClientWidth,FloatHost.ClientHeight)) else @@ -3226,6 +3230,9 @@ end; { ============================================================================= $Log$ + Revision 1.209 2004/08/18 09:08:34 mattias + fixed deleting of collection item in prop editor + Revision 1.208 2004/08/17 19:01:36 mattias gtk intf now ignores size notifications of unrealized widgets diff --git a/lcl/include/docktree.inc b/lcl/include/docktree.inc index 71a3ee93cd..52b4995ad3 100644 --- a/lcl/include/docktree.inc +++ b/lcl/include/docktree.inc @@ -21,13 +21,6 @@ const DefaultDockGrabberSize = 12; -procedure TDockTree.WindowProc(var AMessage: TLMessage); -begin - // ToDo - if Assigned(FOldWndProc) then - FOldWndProc(AMessage); -end; - procedure TDockTree.DeleteZone(Zone: TDockZone); begin // ToDo @@ -57,7 +50,8 @@ begin end; end; -procedure TDockTree.GetControlBounds(AControl: TControl; var CtlBounds: TRect); +procedure TDockTree.GetControlBounds(AControl: TControl; + var ControlBounds: TRect); begin // ToDo end; @@ -70,7 +64,7 @@ begin end; procedure TDockTree.InsertControl(AControl: TControl; InsertAt: TAlign; - DropCtl: TControl); + DropControl: TControl); begin // ToDo end; @@ -141,18 +135,10 @@ begin finally EndUpdate; end; - if not (csDesigning in FDockSite.ComponentState) then begin - FOldWndProc := FDockSite.WindowProc; - FDockSite.WindowProc := @WindowProc; - end; end; destructor TDockTree.Destroy; begin - if FOldWndProc=@WindowProc then begin - FDockSite.WindowProc:=FOldWndProc; - FOldWndProc:=nil; - end; DeleteZone(FTopZone); inherited Destroy; end; diff --git a/lcl/interfaces/gtk/gtkobject.inc b/lcl/interfaces/gtk/gtkobject.inc index 45a1413e81..758bdd8eac 100644 --- a/lcl/interfaces/gtk/gtkobject.inc +++ b/lcl/interfaces/gtk/gtkobject.inc @@ -4439,7 +4439,7 @@ begin else gObject := AGTKObject; if gObject = nil then Exit; - // gFixed is the widget with the client area (e.g. TGroupBox, TForm have this) + // gFixed is the widget with the client area (e.g. TGroupBox, TCustomForm have this) gFixed := PGTKObject(GetFixedWidget(gObject)); if gFixed = nil then gFixed := gObject; @@ -6954,7 +6954,7 @@ begin UntransientWindow(PGtkWindow(SenderWIdget)); end; end; - //if Sender is TForm then + //if Sender is TCustomForm then // DebugLn('[TGtkWidgetSet.ShowHide] END ',Sender.ClassName,' Window=',FormWidget^.Window<>nil); end; @@ -9250,6 +9250,9 @@ end; { ============================================================================= $Log$ + Revision 1.528 2004/08/18 09:08:34 mattias + fixed deleting of collection item in prop editor + Revision 1.527 2004/08/17 19:01:36 mattias gtk intf now ignores size notifications of unrealized widgets @@ -10566,7 +10569,7 @@ end; MG: started mouse bugfix and completed Makefile.fpc Revision 1.125 2002/05/16 15:42:54 lazarus - MG: fixed TForm ShowHide repositioning + MG: fixed TCustomForm ShowHide repositioning Revision 1.124 2002/05/15 05:58:17 lazarus MG: added TMainMenu.Parent