Hello
Hello,
I'm working on a TGraphicControl that supports a parent relationship.
With RegisterSprigType I can handle the Drag&Drop in the structure view
I had to use RegisterComponentGuideLines to avoid a call to Parent.GetClientOrigin for a component that do not have a TWinControl Parent.
Now I have to fix two things, when I click on GraphicPanel2 inside GraphicPanel1 (on the form, not in the treeview) GraphicPanel1 is selected...
And the blue points are not relative to GraphicPanel2's parent...
Any idea ?
Thanks
/sub
ReplyDeletePerhaps the answer is to be found in the code.....
ReplyDeletePublish your code. Allow for pull-requests.
ReplyDeletethere's nothing about that in my code.
ReplyDeleteI've added a GraphicParent property that is handled with those well known and documented functions:
procedure SetParentComponent(Value: TComponent); override;
function HasParent: Boolean; override;
function GetParentComponent: TComponent; override;
procedure GetChildren(Proc: TGetChildProc; Root: TComponent); override;
So GraphicPanel2.Parent is nil, and GraphicPanel2.GraphicParent is GraphicPanel1. when GraphicPanel1 is painted, it paints it's child also. There's no magic in that.
And that don't tell my how to tell the IDE to select a child component of a TGraphicControl nor how to change de handles position of a child component when it is selected in the treeview
Still compilable source code would make it a lot easier for other people to take a closer look.
ReplyDeleteMCVE
ReplyDeleteAttila Kovacs yes that's the problem, but how can I tell Delphi to take the parent's origin into account, that is the question. I've change the way the sub-components are drawn, so they match the selection boundaries, but that's not what I want, because Top/Left need to be parent related.
ReplyDeleteWhat I'm looking for is another RegisterSomething() that can override de default behavior.
Anyway, I'm not sure it's possible, the DesignForm source code is not available and I can't find how this works.
I've found something for the selection...TActionManager (TComponent) is parent of the actions (TGraphicControl) displayed in a ActionMainMenuBar (TWinControl)...and it use csDesignInteractive to handle the clicks :)
ReplyDeleteEDIT: dead end, there's an ActionBarDesigner to handle this, I can't use it :/
No idea why you are concealing the code. It would be easy with a MCVE.
ReplyDeletehttps://github.com/tothpaul/Delphi
ReplyDeleteDavid Heffernan good luck :)
ReplyDeleteI've made some changes...not perfect but not too bad :)
ReplyDeletehttps://github.com/tothpaul/Delphi/blob/master/GraphicPanels/GraphicPanel.gif
ahhh ! how many times will I make this mistake :/
ReplyDeletefunction TGraphicPanel.GetClientOrigin: TPoint;
begin
if FGraphicParent = nil then
begin
inherited;
end else begin
Result := FGraphicParent.GetClientOrigin;
Inc(Result.X, Left);
Inc(Result.Y, Top);
end;
end;
Reasoning about client origin spaces is never easy for me either.
ReplyDeleteWarren Postma it's not about the function, but the call to inherited is incorrect, it should be
ReplyDeleteResult := inherited GetClientOrigin;
https://quality.embarcadero.com/browse/RSP-16543
ReplyDelete