本文整理汇总了C++中LKSurface::GetTextHeight方法的典型用法代码示例。如果您正苦于以下问题:C++ LKSurface::GetTextHeight方法的具体用法?C++ LKSurface::GetTextHeight怎么用?C++ LKSurface::GetTextHeight使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LKSurface
的用法示例。
在下文中一共展示了LKSurface::GetTextHeight方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnPaintListItem
static void OnPaintListItem(WindowControl * Sender, LKSurface& Surface) {
if (!Sender) {
return;
}
unsigned int n = UpLimit - LowLimit;
TCHAR sTmp[50];
Surface.SetTextColor(RGB_BLACK);
const int LineHeight = Sender->GetHeight();
const int TextHeight = Surface.GetTextHeight(_T("dp"));
const int TextPos = (LineHeight - TextHeight) / 2; // offset for text vertical center
if (DrawListIndex < n) {
const size_t i = (FullFlag) ? StrIndex[LowLimit + DrawListIndex] : (LowLimit + DrawListIndex);
// Poco::Thread::sleep(100);
const int width = Sender->GetWidth(); // total width
const int w0 = LineHeight; // Picto Width
const int w2 = Surface.GetTextWidth(TEXT(" 000km")); // distance Width
_stprintf(sTmp, _T(" 000%s "), MsgToken(2179));
const int w3 = Surface.GetTextWidth(sTmp); // bearing width
const int w1 = width - w0 - 2*w2 - w3; // Max Name width
// Draw Picto
const RECT PictoRect = {0, 0, w0, LineHeight};
AirspaceSelectInfo[i].airspace->DrawPicto(Surface, PictoRect);
// Draw Name
Surface.DrawTextClip(w0, TextPos, AirspaceSelectInfo[i].airspace->Name() , w1);
LK_tcsncpy(sTmp, CAirspaceManager::GetAirspaceTypeShortText(AirspaceSelectInfo[i].Type) , 4);
const int w4 = Surface.GetTextWidth(sTmp);
Surface.DrawTextClip(w1+w2, TextPos, sTmp,w4);
// Draw Distance : right justified after waypoint Name
_stprintf(sTmp, TEXT("%.0f%s"), AirspaceSelectInfo[i].Distance , Units::GetDistanceName());
const int x2 = width - w3 - Surface.GetTextWidth(sTmp);
Surface.DrawText(x2, TextPos, sTmp);
// Draw Bearing right justified after distance
_stprintf(sTmp, TEXT("%d%s"), iround(AirspaceSelectInfo[i].Direction), MsgToken(2179));
const int x3 = width - Surface.GetTextWidth(sTmp);
Surface.DrawText(x3, TextPos, sTmp);
} else {
if (DrawListIndex == 0) {
// LKTOKEN [email protected]_ = "No Match!"
Surface.DrawText(IBLSCALE(2), TextPos, MsgToken(466));
}
}
}
示例2: OnPaintComboPopupListItem
static void OnPaintComboPopupListItem(WindowControl * Sender, LKSurface& Surface) {
if (Sender) {
if (ComboListPopup->ComboPopupDrawListIndex >= 0 &&
ComboListPopup->ComboPopupDrawListIndex < ComboListPopup->ComboPopupItemCount) {
// Fill Background with Highlight color if Selected Item
if (!Sender->HasFocus() && ComboListPopup->ComboPopupItemIndex == ComboListPopup->ComboPopupDrawListIndex) {
RECT rc = Sender->GetClientRect();
Surface.FillRect(&rc, LKBrush_Higlighted);
}
const int w = Sender->GetWidth();
const int h = Sender->GetHeight();
const TCHAR* szText = ComboListPopup->ComboPopupItemList[ComboListPopup->ComboPopupDrawListIndex]->StringValueFormatted;
Surface.SetBackgroundTransparent();
Surface.SetTextColor(RGB_BLACK);
const int xText = 3 * ScreenScale;
const int yText = (h - Surface.GetTextHeight(szText)) / 2;
Surface.DrawTextClip(xText, yText, szText, w - ScreenScale * 5);
}
}
}
示例3: OnMultiSelectListPaintListItem
static void OnMultiSelectListPaintListItem(WindowControl * Sender, LKSurface& Surface) {
#define PICTO_WIDTH 50
Surface.SetTextColor(RGB_BLACK);
if (TaskDrawListIndex < iNO_Tasks) {
TCHAR *pToken = NULL;
TCHAR *pWClast = NULL;
TCHAR *pWClast2 = NULL;
TCHAR text[180] = {TEXT("empty")};
TCHAR text1[180] = {TEXT("empty")};
TCHAR text2[180] = {TEXT("empty")};
_tcscpy(text, szTaskStrings [TaskDrawListIndex] );
unsigned int i=0;
while (i < _tcslen(text) ) // remove all quotations "
{
if(text[i]== '"') // quotations found ?
{
for (unsigned int j= i ; j < _tcslen(text); j++)
text[j] = text[j+1];
}
i++;
}
pToken = strsep_r(text, TEXT(","), &pWClast) ;
_tcscpy(text1, pToken );
if(*text1 == '\0') _tcscpy(text1, _T("???") );
pToken = strsep_r(pWClast, TEXT(","), &pWClast2) ; // remove takeof point
_tcscpy(text2, pWClast2);
Surface.SetBkColor(LKColor(0xFF, 0xFF, 0xFF));
PixelRect rc = {
0,
0,
0, // DLGSCALE(PICTO_WIDTH),
static_cast<PixelScalar>(Sender->GetHeight())
};
/********************
* show text
********************/
Surface.SetBackgroundTransparent();
Surface.SetTextColor(RGB_BLACK);
Surface.DrawText(rc.right + DLGSCALE(2), DLGSCALE(2), text1);
int ytext2 = Surface.GetTextHeight(text1);
Surface.SetTextColor(RGB_DARKBLUE);
Surface.DrawText(rc.right + DLGSCALE(2), ytext2, text2);
}
}
示例4: OnTaskPaintListItem
static void OnTaskPaintListItem(WindowControl * Sender, LKSurface& Surface){
int n = UpLimit - LowLimit;
TCHAR sTmp[120];
TCHAR wpName[120];
TCHAR landableStr[5] = TEXT(" [X]");
// LKTOKEN [email protected]_ "L"
landableStr[2] = MsgToken(1238)[0];
LockTaskData();
const PixelRect rcClient(Sender->GetClientRect());
const int w0 = rcClient.GetSize().cx - DLGSCALE(1);
const int w1 = Surface.GetTextWidth(TEXT(" 000km"));
_stprintf(sTmp, _T(" 000%s"), MsgToken(2179));
const int w2 = Surface.GetTextWidth(sTmp);
const int TextMargin = (rcClient.GetSize().cy - Surface.GetTextHeight(TEXT("A"))) / 2;
const int p1 = w0-w1-w2- rcClient.GetSize().cy - DLGSCALE(2);
const int p2 = w0-w2- rcClient.GetSize().cy - DLGSCALE(2);
const PixelRect rc = {
0,
0,
rcClient.GetSize().cy,
rcClient.GetSize().cy
};
if (DrawListIndex < n){
int i = LowLimit + DrawListIndex;
// if ((WayPointList[Task[i].Index].Flags & LANDPOINT) >0)
// MapWindow::DrawRunway(hDC, &WayPointList[Task[i].Index], rc, 3000,true);
MapWindow::DrawTaskPicto(Surface, DrawListIndex, rc, 2500);
if (Task[i].Index>=0) {
_stprintf(wpName, TEXT("%s%s"),
WayPointList[Task[i].Index].Name,
(WayPointList[Task[i].Index].Flags & LANDPOINT) ? landableStr : TEXT(""));
if (AATEnabled && ValidTaskPoint(i+1) && (i>0)) {
if (Task[i].AATType==0 || Task[i].AATType==3) {
_stprintf(sTmp, TEXT("%s %.1f"),
wpName, Task[i].AATCircleRadius*DISTANCEMODIFY);
} else {
if(Task[i].AATType==2 && DoOptimizeRoute()) {
_stprintf(sTmp, TEXT("%s %.1f/1"),
wpName, Task[i].PGConeSlope);
} else {
_stprintf(sTmp, TEXT("%s %.1f"),
wpName, Task[i].AATSectorRadius*DISTANCEMODIFY);
}
}
} else {
_stprintf(sTmp, TEXT("%s"), wpName);
}
Surface.SetBackgroundTransparent();
Surface.SetTextColor(RGB_BLACK);
Surface.DrawTextClip(rc.right + DLGSCALE(2), TextMargin, sTmp, p1-DLGSCALE(4));
_stprintf(sTmp, TEXT("%.0f %s"),Task[i].Leg*DISTANCEMODIFY,Units::GetDistanceName());
Surface.DrawText(rc.right+p1+w1-Surface.GetTextWidth(sTmp), TextMargin, sTmp);
_stprintf(sTmp, TEXT("%d%s"), iround(Task[i].InBound),MsgToken(2179));
Surface.DrawText(rc.right +p2+w2-Surface.GetTextWidth(sTmp), TextMargin, sTmp);
}
} else {
Surface.SetTextColor(RGB_BLACK);
// if (DrawListIndex==n) { // patchout 091126
if (DrawListIndex==n && UpLimit < MAXTASKPOINTS) { // patch 091126
// LKTOKEN [email protected]_ = "add waypoint"
_stprintf(sTmp, TEXT(" (%s)"), MsgToken(832));
Surface.DrawText(rc.right +DLGSCALE(2), TextMargin, sTmp);
} else if ((DrawListIndex==n+1) && ValidTaskPoint(0)) {
if (!AATEnabled || ISPARAGLIDER) {
// LKTOKEN [email protected]_ = "Total:"
Surface.DrawText(rc.right +DLGSCALE(2), TextMargin, MsgToken(735));
_stprintf(sTmp, TEXT("%.0f %s%s"), lengthtotal*DISTANCEMODIFY, Units::GetDistanceName(), fai_ok?_T(" FAI"):_T(""));
Surface.DrawText(rc.right +p1+w1-Surface.GetTextWidth(sTmp), TextMargin, sTmp);
} else {
double d1 = CALCULATED_INFO.TaskDistanceToGo;
if ((CALCULATED_INFO.TaskStartTime>0.0) && (CALCULATED_INFO.Flying) && (ActiveTaskPoint>0)) {
d1 += CALCULATED_INFO.TaskDistanceCovered;
}
if (d1==0.0) {
d1 = CALCULATED_INFO.AATTargetDistance;
}
_stprintf(sTmp, TEXT("%s %.0f min %.0f (%.0f) %s"),
// LKTOKEN [email protected]_ = "Total:"
//.........这里部分代码省略.........
示例5: OnMultiSelectListPaintListItem
//.........这里部分代码省略.........
_stprintf(text1, TEXT("%s %s"), WayPointList[idx].Name, Comment);
else
_stprintf(text1, TEXT("%s"), WayPointList[idx].Name);
}
if ((WayPointList[idx].RunwayLen >= 10) ||
(WayPointList[idx].RunwayDir > 0)) {
_stprintf(text2, TEXT("%3.1f%s (%i%s %02i/%02i %i%s)"),
Distance * DISTANCEMODIFY, Units::GetDistanceName(),
(int) (WayPointList[idx].Altitude * ALTITUDEMODIFY),
Units::GetAltitudeName(),
(int) (WayPointList[idx].RunwayDir / 10.0 + 0.5),
(int) (AngleLimit360(WayPointList[idx].RunwayDir + 180.0) /
10.0 + 0.5),
(int) ((double) WayPointList[idx].RunwayLen * ALTITUDEMODIFY),
Units::GetAltitudeName());
} else {
_stprintf(text2, TEXT("%3.1f%s (%i%s) "), Distance * DISTANCEMODIFY,
Units::GetDistanceName(),
(int) (WayPointList[idx].Altitude * ALTITUDEMODIFY),
Units::GetAltitudeName());
}
}// waypoint isLandable
else {
MapWindow::DrawWaypointPicto(Surface, rc, &WayPointList[idx]);
_stprintf(text1, TEXT("%s %s"), WayPointList[idx].Name, Comment);
_stprintf(text2, TEXT("%3.1f%s (%i%s)"), Distance * DISTANCEMODIFY,
Units::GetDistanceName(),
(int) (WayPointList[idx].Altitude * ALTITUDEMODIFY),
Units::GetAltitudeName());
}
}// Elements IM_TASK
else {
int iTaskIdx = Elements[i].iIdx;
MapWindow::DrawTaskPicto(Surface, iTaskIdx, rc, 3000);
int iLastTaskPoint = 0;
while (ValidTaskPoint(iLastTaskPoint))
iLastTaskPoint++;
iLastTaskPoint--;
if (iTaskIdx == 0) {
// [email protected]_ "S" # S = Start Task point
_stprintf(text1, TEXT("%s: (%s)"), MsgToken(2301), WayPointList[idx].Name);
_stprintf(text2, TEXT("Radius %3.1f%s (%i%s)"),
StartRadius * DISTANCEMODIFY, Units::GetDistanceName(),
(int) (WayPointList[idx].Altitude * ALTITUDEMODIFY),
Units::GetAltitudeName());
} else {
if (iTaskIdx == iLastTaskPoint) {
// [email protected]_ "F" // max 30 30 => max 60 char
_stprintf(text1, TEXT("%s: (%s) "), MsgToken(2303),
WayPointList[idx].Name);
_stprintf(text2, TEXT("Radius %3.1f%s (%i%s)"),
FinishRadius * DISTANCEMODIFY, Units::GetDistanceName(),
(int) (WayPointList[idx].Altitude * ALTITUDEMODIFY),
Units::GetAltitudeName());
} else {
// [email protected]_ "T" # F = Finish point // max 30 30 => max 60 char
_stprintf(text1, TEXT("%s%i: (%s) "), MsgToken(2302), iTaskIdx,
WayPointList[idx].Name);
double SecRadius = 0;
SecRadius = SectorRadius;
if (AATEnabled) {
if (Task[iTaskIdx].AATType == SECTOR)
SecRadius = Task[iTaskIdx].AATSectorRadius;
else
SecRadius = Task[iTaskIdx].AATCircleRadius;
}
_stprintf(text2, TEXT("Radius %3.1f%s (%i%s)"),
SecRadius * DISTANCEMODIFY, Units::GetDistanceName(),
(int) (WayPointList[idx].Altitude * ALTITUDEMODIFY),
Units::GetAltitudeName());
}
}
}
}
UnlockTaskData(); // protect from external task changes
break;
}
/********************
* show text
********************/
Surface.SetBackgroundTransparent();
Surface.SetTextColor(RGB_BLACK);
Surface.DrawText(rc.right + DLGSCALE(2), DLGSCALE(2), text1);
int ytext2 = Surface.GetTextHeight(text1);
Surface.SetTextColor(RGB_DARKBLUE);
Surface.DrawText(rc.right + DLGSCALE(2), ytext2, text2);
}
}
示例6: OnTaskPaintListItem
static void OnTaskPaintListItem(WindowControl * Sender, LKSurface& Surface){
(void)Sender;
int n = UpLimit - LowLimit;
TCHAR sTmp[120];
TCHAR wpName[120];
TCHAR landableStr[5] = TEXT(" [X]");
// LKTOKEN [email protected]_ "L"
landableStr[2] = gettext(TEXT("[email protected]_"))[0];
LockTaskData();
int w0 = Sender->GetWidth()-1;
int w1 = Surface.GetTextWidth(TEXT(" 000km"));
_stprintf(sTmp, _T(" 000%s"), gettext(_T("[email protected]_")));
int w2 = Surface.GetTextWidth(sTmp);
int TextMargin = (Sender->GetHeight() - Surface.GetTextHeight(TEXT("A"))) / 2;
int p1 = w0-w1-w2- Sender->GetHeight()-2;
int p2 = w0-w2- Sender->GetHeight()-2;
RECT rc = {0*ScreenScale, 0*ScreenScale, Sender->GetHeight(), Sender->GetHeight()};
if (DrawListIndex < n){
int i = LowLimit + DrawListIndex;
// if ((WayPointList[Task[i].Index].Flags & LANDPOINT) >0)
// MapWindow::DrawRunway(hDC, &WayPointList[Task[i].Index], rc, 3000,true);
MapWindow::DrawTaskPicto(Surface, DrawListIndex, rc, 2500);
if (Task[i].Index>=0) {
_stprintf(wpName, TEXT("%s%s"),
WayPointList[Task[i].Index].Name,
(WayPointList[Task[i].Index].Flags & LANDPOINT) ? landableStr : TEXT(""));
if (AATEnabled && ValidTaskPoint(i+1) && (i>0)) {
if (Task[i].AATType==0) {
_stprintf(sTmp, TEXT("%s %.1f"),
wpName, Task[i].AATCircleRadius*DISTANCEMODIFY);
} else {
if(Task[i].AATType==2 && DoOptimizeRoute()) {
_stprintf(sTmp, TEXT("%s %.1f/1"),
wpName, Task[i].PGConeSlope);
} else {
_stprintf(sTmp, TEXT("%s %.1f"),
wpName, Task[i].AATSectorRadius*DISTANCEMODIFY);
}
}
} else {
_stprintf(sTmp, TEXT("%s"), wpName);
}
Surface.SetBackgroundTransparent();
Surface.SetTextColor(RGB_BLACK);
Surface.DrawTextClip(Sender->GetHeight()+2*ScreenScale, TextMargin,
sTmp, p1-4*ScreenScale);
_stprintf(sTmp, TEXT("%.0f %s"),
Task[i].Leg*DISTANCEMODIFY,
Units::GetDistanceName());
Surface.DrawText(Sender->GetHeight()+p1+w1-Surface.GetTextWidth(sTmp), TextMargin, sTmp, _tcslen(sTmp));
_stprintf(sTmp, TEXT("%d%s"), iround(Task[i].InBound),gettext(_T("[email protected]_")));
Surface.DrawText(Sender->GetHeight()+p2+w2-Surface.GetTextWidth(sTmp), TextMargin, sTmp, _tcslen(sTmp));
}
} else {
Surface.SetTextColor(RGB_BLACK);
// if (DrawListIndex==n) { // patchout 091126
if (DrawListIndex==n && UpLimit < MAXTASKPOINTS) { // patch 091126
// LKTOKEN [email protected]_ = "add waypoint"
_stprintf(sTmp, TEXT(" (%s)"), gettext(TEXT("[email protected]_")));
Surface.DrawText(Sender->GetHeight()+2*ScreenScale, TextMargin, sTmp, _tcslen(sTmp));
} else if ((DrawListIndex==n+1) && ValidTaskPoint(0)) {
if (!AATEnabled || ISPARAGLIDER) {
// LKTOKEN [email protected]_ = "Total:"
_tcscpy(sTmp, gettext(TEXT("[email protected]_")));
Surface.DrawText(Sender->GetHeight()+2*ScreenScale, TextMargin, sTmp, _tcslen(sTmp));
if (fai_ok) {
_stprintf(sTmp, TEXT("%.0f %s FAI"), lengthtotal*DISTANCEMODIFY,
Units::GetDistanceName());
} else {
_stprintf(sTmp, TEXT("%.0f %s"), lengthtotal*DISTANCEMODIFY,
Units::GetDistanceName());
}
Surface.DrawText(Sender->GetHeight()+p1+w1-Surface.GetTextWidth(sTmp), TextMargin, sTmp, _tcslen(sTmp));
} else {
double d1 = CALCULATED_INFO.TaskDistanceToGo;
if ((CALCULATED_INFO.TaskStartTime>0.0) && (CALCULATED_INFO.Flying) && (ActiveWayPoint>0)) {
d1 += CALCULATED_INFO.TaskDistanceCovered;
}
if (d1==0.0) {
d1 = CALCULATED_INFO.AATTargetDistance;
}
_stprintf(sTmp, TEXT("%s %.0f min %.0f (%.0f) %s"),
//.........这里部分代码省略.........