AnnDefine2 example for C++ Builder
//This example uses static variables to simulate user input to
//'rotate/resize a rectangle around a point on the bottom center line of the rectangle.
//'Intially the rectangle must not be rotated.
void TForm1::ExampleExampleAnnDefine2 (HANNOBJECT hObject )
{
long hContainer ;
L_INT nObjectType ;
double dAngle ;
long lCallCount=0;
double dRectTop ;
double dRectLeft ;
double dRectWidth ;
double dRectHeight;
double dRectRight ;
double dRectBottom;
double dAnchorX ;
double dAnchorY;
double dMoveX;
double dMoveY;
double dAnnPointX;
double dAnnPointY;
nObjectType= LEADAnn1->AnnGetType(hObject);
if (nObjectType != ANNOBJECT_RECT )
ShowMessage ("This object is not Rect Object");
dAngle = LEADAnn1->AnnRotateAngle[hObject];
if (dAngle != 0 )
ShowMessage ("Object must not be rotated");
lCallCount = lCallCount + 1;
switch (lCallCount)
{
case 1:
dRectTop = LEADAnn1->AnnRectTop[hObject];
dRectLeft = LEADAnn1->AnnRectLeft[hObject];
dRectWidth = LEADAnn1->AnnRectWidth[hObject];
dRectHeight = LEADAnn1->AnnRectHeight[hObject];
dRectRight = dRectWidth + dRectLeft;
dRectBottom = dRectHeight + dRectTop;
dAnchorX = (dRectLeft + dRectRight) / 2;
dAnchorY = dRectBottom;
dAnnPointX = (dRectLeft + dRectRight) / 2;
dAnnPointY = dRectTop;
LEADAnn1->AnnDefine2(hObject, dAnchorX, dAnchorY, ANNDEFINE_SETANCHORPOINT);
LEADAnn1->AnnDefine2(hObject, dAnnPointX, dAnnPointY, ANNDEFINE_BEGINMOVEPOINT);
break;
case 2:
dRectTop = LEADAnn1->AnnRectTop[hObject];
dRectLeft = LEADAnn1->AnnRectLeft[hObject];
dRectWidth = LEADAnn1->AnnRectWidth[hObject];
dRectHeight = LEADAnn1->AnnRectHeight[hObject];
dRectRight = dRectWidth + dRectLeft;
dRectBottom = dRectHeight + dRectTop;
LEADAnn1->PointsCount = 1;
LEADAnn1->AnnContainerPointX[1] = dRectRight;
LEADAnn1->AnnContainerPointY[1] = dRectTop;
hContainer = LEADAnn1->AnnContainer;
LEADAnn1->AnnConvert(hContainer, ANNCONVERT_TO_CLIENT);
dMoveX = LEADAnn1->ClientPointX[0];
dMoveY = LEADAnn1->ClientPointY[0];
LEADAnn1->AnnDefine2(hObject, dMoveX, dMoveY, ANNDEFINE_END);
lCallCount = 0;
break;
}
}