1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
| void __fastcall TVCLManipForm::PaintBoxFontOrientationAndEscapementPaint(TObject *Sender)
{
if (Sender->InheritsFrom(__classid(TPaintBox)))
{
TPaintBox *PntBx = (TPaintBox*)Sender;
TRect Rect = PntBx->BoundsRect;
PntBx->Canvas->FillRect(Rect);
LOGFONT ParamFont;
if (GetObject(PntBx->Canvas->Font->Handle, sizeof(ParamFont), &ParamFont) > 0)
{
int OldMode;
if (CheckBoxFontOrientationAndEscapement->Checked)
OldMode = SetGraphicsMode(PntBx->Canvas->Handle, GM_ADVANCED);
else
OldMode = GetGraphicsMode(PntBx->Canvas->Handle);
try
{
TSmallPoint ClicCpt;
ClicCpt = (TSmallPoint&)PntBx->Tag;
if (GetGraphicsMode(PntBx->Canvas->Handle) == GM_ADVANCED)
{
ParamFont.lfEscapement = ClicCpt.y; // tenths of degrees, angle of Text
ParamFont.lfOrientation = ClicCpt.x; // tenths of degrees, angle of Letters
}
else
ParamFont.lfEscapement = ClicCpt.y; // tenths of degrees, angle of Text and Letters
AnsiString OrientationAndEscapement;
OrientationAndEscapement.sprintf("Escapement = %d, Orientation = %d", ClicCpt.y, ClicCpt.x);
DrawText(PntBx->Canvas->Handle, OrientationAndEscapement.c_str(), -1, (LPRECT)&Rect, 0);
HGDIOBJ NewFontHandle = CreateFontIndirect(&ParamFont);
try
{
HGDIOBJ OldFontHandle = SelectObject(PntBx->Canvas->Handle, NewFontHandle);
try
{
int VerticalAlign = CheckBoxFontOrientationAndEscapementCenterOrTopAlign->Checked ? DT_VCENTER : DT_TOP;
DrawText(PntBx->Canvas->Handle, PanelFontOrientationAndEscapement->Caption.c_str(), -1, (LPRECT)&Rect, DT_NOCLIP | DT_SINGLELINE | VerticalAlign | DT_CENTER);
}
__finally
{
SelectObject(PntBx->Canvas->Handle, OldFontHandle);
}
}
__finally
{
DeleteObject(NewFontHandle);
}
}
__finally
{
SetGraphicsMode(PntBx->Canvas->Handle, OldMode);
}
}
}
}
//---------------------------------------------------------------------------
void __fastcall TVCLManipForm::PaintBoxFontOrientationAndEscapementMouseMove(
TObject *Sender, TShiftState Shift, int X, int Y)
{
if (Sender->InheritsFrom(__classid(TPaintBox)))
{
TPaintBox *PntBx = (TPaintBox*)Sender;
TSmallPoint ClicCpt;
ClicCpt = (TSmallPoint&)PntBx->Tag;
if (Shift.Contains(ssCtrl))
{
if (Shift.Contains(ssLeft))
ClicCpt.x--;
else
ClicCpt.x++;
if (ClicCpt.x < -3600)
ClicCpt.x = 0;
if (ClicCpt.x > 3600)
ClicCpt.x = 0;
}
if (Shift.Contains(ssShift))
{
if (Shift.Contains(ssLeft))
ClicCpt.y--;
else
ClicCpt.y++;
if (ClicCpt.y < -3600)
ClicCpt.y = 0;
if (ClicCpt.y > 3600)
ClicCpt.y = 0;
}
PntBx->Tag = (int&)ClicCpt;
PntBx->Invalidate();
}
} |
Partager