Rotate TextCell only

Hello Wagner and every body
Some time ago I asked the question about how to rotate a Block by code relative to a rotation point that I choose. I've got the Wonderful solution by Wagner:
procedure Rotate(B: TCustomDiagramBlock;NewAngle: Double;x,y:double);
Drawer: TBlockDrawer;
R: TSquare;
B.RotationCenter:=dot(x,y);//x,y are given in relative coordinations
Drawer := TBlockDrawer.Create;
Drawer.RotationType := rtRotationCenter;
Drawer.RotationCenter :=TBlockHack(B).DiagramRotCenter;
Drawer.Angle := -B.Angle;
Drawer.CurRect := B.BoundsRect;
R := Drawer.RotByCenter(B.BoundsRect);
Drawer.Angle := NewAngle;
Drawer.CurRect := R;
B.BoundsRect := Drawer.RotByCenter(R);
B.Angle := NewAngle;

Now I have been struggling with another problem:
When I try to rotate by code only a textCell[0] belonging to a block (ex: textCell[0].angle:=45) , It seems that textcell[0] rotates around the center point of the hosting block, which is not desirable at all!!
My question is: How by code one can perform a rotation of a textcell[0] around the the center point of the textcell it self? It seems that this might require some specific code.
Please Help!

Text cells are always rotated by the block center. The only way to change this behavior is to inherit your own block class, override the method GetTextCellRect and calculate the drawing bounds rect of text cell so that it paints where you want.

Okay. I am going to try that. Good to know it is possible.
Thank you

1 Like

I added a property "MyAngle" to TextCell Class. Then with some math and some Imagination
I succeeded to rotate a textCell[i] inside a block around the center of the textCell without affecting the host Block!!!

1 Like

This topic was automatically closed 60 minutes after the last reply. New replies are no longer allowed.