static void OnPaintDetailsListItem(WindowControl * Sender, LKSurface& Surface){ (void)Sender; if (DrawListIndex < (int)aTextLine.size()){ LKASSERT(DrawListIndex>=0); const TCHAR* szText = aTextLine[DrawListIndex]; Surface.SetTextColor(RGB_BLACK); Surface.DrawText(DLGSCALE(2), DLGSCALE(2), szText); } }
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); } }
ListElement* dlgMultiSelectListShowModal(void) { ItemIndex = -1; if (iNO_ELEMENTS == 0) { return NULL; } wf = dlgLoadFromXML(CallBackTable, ScreenLandscape ? IDR_XML_MULTISELECTLIST_L : IDR_XML_MULTISELECTLIST_P); if (!wf) return NULL; wf->SetTimerNotify(1000, OnTimer); wMultiSelectListList = (WndListFrame*) wf->FindByName(TEXT("frmMultiSelectListList")); LKASSERT(wMultiSelectListList != NULL); wMultiSelectListList->SetBorderKind(BORDERLEFT); wMultiSelectListList->SetEnterCallback(OnMultiSelectListListEnter); wMultiSelectListListEntry = (WndOwnerDrawFrame*) wf->FindByName(TEXT("frmMultiSelectListListEntry")); if(wMultiSelectListListEntry) { /* * control height must contains 2 text Line * Check and update Height if necessary */ LKWindowSurface windowSurface(MainWindow); LKBitmapSurface tmpSurface(windowSurface, 1, 1); const auto oldFont = tmpSurface.SelectObject(wMultiSelectListListEntry->GetFont()); const int minHeight = 2 * tmpSurface.GetTextHeight(_T("dp")) + 2 * DLGSCALE(2); tmpSurface.SelectObject(oldFont); const int wHeight = wMultiSelectListListEntry->GetHeight(); if(minHeight > wHeight) { wMultiSelectListListEntry->SetHeight(minHeight); } wMultiSelectListListEntry->SetCanFocus(true); } else LKASSERT(0); UpdateList(); wf->ShowModal(); delete wf; wf = NULL; iNO_ELEMENTS = 0; NoAirfields = 0; NoOutlands = 0; NoWaypoints = 0; NoAirspace = 0; NoTaskPoints = 0; return pResult; }
void GetDefaultWindowControlProps(XMLNode *Node, TCHAR *Name, int *X, int *Y, int *Width, int *Height, int *Popup, int *Font, TCHAR *Caption){ *Popup = StringToIntDflt(Node->getAttribute(TEXT("Popup")), 0); // don't make wndForm block entire screen *X = DLGSCALE(StringToIntDflt(Node->getAttribute(TEXT("X")), 0)); *Y = StringToIntDflt(Node->getAttribute(TEXT("Y")), 0); if (*Y>=0) { // not -1 (*Y) = DLGSCALE(*Y); } *Width = DLGSCALE(StringToIntDflt(Node->getAttribute(TEXT("Width")), 50)); *Height = StringToIntDflt(Node->getAttribute(TEXT("Height")), 50); if (*Height>=0) { (*Height) = DLGSCALE(*Height); } *Font = StringToIntDflt(Node->getAttribute(TEXT("Font")), -1); _tcscpy(Name, StringToStringDflt(Node->getAttribute(TEXT("Name")), TEXT(""))); _tcscpy(Caption, StringToStringDflt(Node->getAttribute(TEXT("Caption")), TEXT(""))); _tcscpy(Caption,LKGetText(Caption)); }
void dlgHelpShowModal(const TCHAR* Caption, const TCHAR* HelpText) { if (!Caption || !HelpText) { return; } std::unique_ptr<WndForm> wf(dlgLoadFromXML(CallBackTable, ScreenLandscape ? IDR_XML_HELP_L : IDR_XML_HELP_P)); if(!wf) { return; } WndListFrame* wHelp = static_cast<WndListFrame*>(wf->FindByName(TEXT("frmDetails"))); if(!wHelp) { return; } wHelp->SetBorderKind(BORDERLEFT); WndOwnerDrawFrame* wHelpEntry = static_cast<WndOwnerDrawFrame*>(wf->FindByName(TEXT("frmDetailsEntry"))); if (!wHelpEntry) { return; }; wHelpEntry->SetCanFocus(true); DrawListIndex=0; TCHAR fullcaption[100]; _stprintf(fullcaption,TEXT("%s: %s"), MsgToken(336), Caption); // Help wf->SetCaption(fullcaption); aTextLine.clear(); { LKWindowSurface Surface(*wHelpEntry); const auto oldFont = Surface.SelectObject(wHelpEntry->GetFont()); const int minHeight = Surface.GetTextHeight(_T("dp")) + 2 * DLGSCALE(2); const int wHeight = wHelpEntry->GetHeight(); if(minHeight != wHeight) { wHelpEntry->SetHeight(minHeight); } aTextLine.update(Surface, wHelpEntry->GetWidth(), LKgethelptext(HelpText)); Surface.SelectObject(oldFont); } wHelp->ResetList(); wHelp->Redraw(); wf->ShowModal(); aTextLine.clear(); }
int dlgTaskSelectListShowModal(void) { TaskIndex = -1; if (iNO_Tasks == 0) return mrCancel; wf = dlgLoadFromXML(TaskCallBackTable, ScreenLandscape ? IDR_XML_MULTISELECTLIST_L : IDR_XML_MULTISELECTLIST_P); if (!wf) return mrCancel; wTaskSelectListList = (WndListFrame*) wf->FindByName(TEXT("frmMultiSelectListList")); LKASSERT(wTaskSelectListList != NULL); wTaskSelectListList->SetBorderKind(BORDERLEFT); wTaskSelectListList->SetEnterCallback(OnTaskSelectListListEnter); wTaskSelectListListEntry = (WndOwnerDrawFrame*) wf->FindByName(TEXT("frmMultiSelectListListEntry")); if(wTaskSelectListListEntry) { /* * control height must contains 2 text Line * Check and update Height if necessary */ LKWindowSurface windowSurface(MainWindow); LKBitmapSurface tmpSurface(windowSurface, 1, 1); const auto oldFont = tmpSurface.SelectObject(wTaskSelectListListEntry->GetFont()); const int minHeight = 2 * tmpSurface.GetTextHeight(_T("dp")) + 2 * DLGSCALE(2); tmpSurface.SelectObject(oldFont); const int wHeight = wTaskSelectListListEntry->GetHeight(); if(minHeight > wHeight) { wTaskSelectListListEntry->SetHeight(minHeight); } wTaskSelectListListEntry->SetCanFocus(true); } else LKASSERT(0); UpdateList(); int result = wf->ShowModal(); wTaskSelectListList->Redraw(); delete wf; wf = NULL; iNO_Tasks = 0; return result; }
static void OnTaskPaintListItem(WindowControl * Sender, LKSurface& Surface){ int n = UpLimit - LowLimit; TCHAR sTmp[120]; TCHAR wpName[120]; TCHAR landableStr[5] = TEXT(" [X]"); // LKTOKEN _@M1238_ "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 _@M832_ = "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 _@M735_ = "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 _@M735_ = "Total:" MsgToken(735), AATTaskLength*1.0, DISTANCEMODIFY*lengthtotal, DISTANCEMODIFY*d1, Units::GetDistanceName()); Surface.DrawText(rc.right +DLGSCALE(2), TextMargin, sTmp); } } } UnlockTaskData(); }
static void OnMultiSelectListPaintListItem(WindowControl * Sender, LKSurface& Surface) { #define PICTO_WIDTH 50 Surface.SetTextColor(RGB_BLACK); if ((DrawListIndex < iNO_ELEMENTS) &&(DrawListIndex >= 0)) { int j; static CAirspaceBase airspace_copy; int i = DrawListIndex; LKASSERT(i < MAX_LIST_ITEMS); PixelRect rc = { 0, 0, DLGSCALE(PICTO_WIDTH), static_cast<PixelScalar>(Sender->GetHeight()) }; const CAirspace* pAS = NULL; int HorDist, Bearing, VertDist; double Distance; unsigned int idx = 0; TCHAR text1[180] = {TEXT("empty")}; TCHAR text2[180] = {TEXT("empty")}; TCHAR Comment[80] = {TEXT("")}; TCHAR Comment1[80] = {TEXT("")}; Surface.SetBkColor(LKColor(0xFF, 0xFF, 0xFF)); LKASSERT(i < MAX_LIST_ITEMS); switch (Elements[i].type) { case IM_AIRSPACE: pAS = (CAirspace*) Elements[i].ptr; if (pAS) { /*********************************************************************** * here we use a local copy of the airspace, only common property exists ***********************************************************************/ airspace_copy = CAirspaceManager::Instance().GetAirspaceCopy(pAS); // airspace type already in name? if (_tcsnicmp(airspace_copy.Name(), airspace_copy.TypeName(), _tcslen(airspace_copy.TypeName())) == 0) { _stprintf(text1, TEXT("%s"), airspace_copy.Name()); // yes, take name only } else { // fixed strings max. 20 NAME_SIZE 30 => max. 30 char _stprintf(text1, TEXT("%s %s"), airspace_copy.TypeName(), airspace_copy.Name()); } CAirspaceManager::Instance().GetSimpleAirspaceAltText(Comment, sizeof (Comment) / sizeof (Comment[0]), airspace_copy.Top()); CAirspaceManager::Instance().GetSimpleAirspaceAltText(Comment1, sizeof (Comment1) / sizeof (Comment1[0]), airspace_copy.Base()); CAirspaceManager::Instance().AirspaceCalculateDistance((CAirspace*) pAS, &HorDist, &Bearing, &VertDist); _stprintf(text2, TEXT("%3.1f%s (%s - %s)"), (double) HorDist*DISTANCEMODIFY, Units::GetDistanceName(), Comment1, Comment); //8 + 8+3 21 /**************************************************************** * for drawing the airspace pictorial, we need the original data. * copy contain only base class property, not geo data, * original data are shared ressources ! * for that we need to grant all called methods are thread safe ****************************************************************/ pAS->DrawPicto(Surface, rc); } break; case IM_TASK_PT: case IM_WAYPOINT: idx = -1; LockTaskData(); // protect from external task changes if (Elements[i].type == IM_TASK_PT) { if(ValidTaskPointFast(Elements[i].iIdx)) { idx = Task[Elements[i].iIdx].Index; } } else { if(ValidWayPointFast(Elements[i].iIdx)) { idx = Elements[i].iIdx; } } // This is not a solution. It will avoid a crash but the solution is to understand // why we are getting a wrong idx, eventually. If ever we got a wrong idx! // And then this "fix" should be changed to something more useful, instead of // adopting a totally wrong waypoint for task. assert(idx < WayPointList.size()); if(idx < WayPointList.size()) { if (WayPointList[idx].Comment != NULL) { LK_tcsncpy(Comment, WayPointList[idx].Comment, 30); } else { _tcscpy(Comment, TEXT("")); } DistanceBearing(GPS_INFO.Latitude, GPS_INFO.Longitude, WayPointList[idx].Latitude, WayPointList[idx].Longitude, &Distance, NULL); if (Elements[i].type != IM_TASK_PT) { if (WayPointCalc[idx].IsLandable) { MapWindow::DrawRunway(Surface, &WayPointList[idx], rc, nullptr, 1.5, true); if (WayPointCalc[idx].IsAirport) { // remove spaces from frequency for (j = 1; j < (CUPSIZE_FREQ); j++) if (WayPointList[idx].Freq[CUPSIZE_FREQ - j] == ' ') WayPointList[idx].Freq[CUPSIZE_FREQ - j] = '\0'; if (_tcslen(WayPointList[idx].Freq) > 2) _stprintf(text1, TEXT("%s %s MHz"), WayPointList[idx].Name, WayPointList[idx].Freq); else _stprintf(text1, TEXT("%s"), WayPointList[idx].Name); } else { if (WayPointList[idx].Comment != NULL) _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) { // _@M2301_ "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) { // _@M2303_ "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 { // _@M2302_ "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); } }
int WINAPI MessageBoxX(HWND hWnd, LPCTSTR lpText, LPCTSTR lpCaption, UINT uType, bool wfullscreen){ WndForm *wf=NULL; WndFrame *wText=NULL; int X, Y, Width, Height; WndButton *wButtons[10]; int ButtonCount = 0; int i,x,y,d,w,h,res,dY; RECT rc; // todo hWnd = hWndMainWindow; ASSERT(hWnd == hWndMainWindow); ASSERT(lpText != NULL); ASSERT(lpCaption != NULL); GetClientRect(hWnd, &rc); if (wfullscreen) { Width = rc.right; Height = rc.bottom; } else if (ScreenLandscape) { Width = DLGSCALE(280); Height = DLGSCALE(160); } else { Width = DLGSCALE(230); Height = DLGSCALE(160); } X = ((rc.right-rc.left) - Width)/2; Y = ((rc.bottom-rc.top) - Height)/2; if (wfullscreen) { if (ScreenLandscape) y = DLGSCALE(160); else y = DLGSCALE(200); } else y = DLGSCALE(100); w = DLGSCALE(60); h = DLGSCALE(32); wf = new WndForm(hWnd, TEXT("frmXcSoarMessageDlg"), (TCHAR*)lpCaption, X, Y, Width, Height); wf->SetFont(MapWindowBoldFont); wf->SetTitleFont(MapWindowBoldFont); wf->SetBackColor(RGB_WINBACKGROUND); wText = new WndFrame(wf, TEXT("frmMessageDlgText"), 0, DLGSCALE(5), Width, Height); wText->SetCaption((TCHAR*)lpText); wText->SetFont(MapWindowBoldFont); wText->SetCaptionStyle( DT_EXPANDTABS | DT_CENTER | DT_NOCLIP | DT_WORDBREAK // | DT_VCENTER ); /* TODO code: this doesnt work to set font height dY = wText->GetLastDrawTextHeight() - Height; */ if (wfullscreen) dY=0; else dY = DLGSCALE(-40); // wText->SetHeight(wText->GetLastDrawTextHeight()+5); wf->SetHeight(wf->GetHeight() + dY); y += dY; uType = uType & 0x000f; if (uType == MB_OK || uType == MB_OKCANCEL ){ wButtons[ButtonCount] = new WndButton(wf, TEXT(""), TEXT("OK"), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDOK); ButtonCount++; } if (uType == MB_YESNO || uType == MB_YESNOCANCEL ){ // LKTOKEN _@M827_ = "Yes" wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("_@M827_")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDYES); ButtonCount++; wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("_@M890_")), // No 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDNO); ButtonCount++; } if (uType == MB_ABORTRETRYIGNORE || uType == MB_RETRYCANCEL ){ wButtons[ButtonCount] = new WndButton(wf, TEXT(""), // LKTOKEN _@M566_ = "Retry" gettext(TEXT("_@M566_")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDRETRY); ButtonCount++; } if (uType == MB_OKCANCEL || uType == MB_RETRYCANCEL || uType == MB_YESNOCANCEL ){ wButtons[ButtonCount] = new WndButton(wf, TEXT(""), // LKTOKEN _@M161_ = "Cancel" gettext(TEXT("_@M161_")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDCANCEL); ButtonCount++; } if (uType == MB_ABORTRETRYIGNORE ){ wButtons[ButtonCount] = new WndButton(wf, TEXT(""), // LKTOKEN _@M47_ = "Abort" gettext(TEXT("_@M47_")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDABORT); ButtonCount++; wButtons[ButtonCount] = new WndButton(wf, TEXT(""), // LKTOKEN _@M349_ = "Ignore" gettext(TEXT("_@M349_")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDIGNORE); ButtonCount++; } d = Width / (ButtonCount); x = d/2-w/2; for (i=0; i<ButtonCount; i++){ wButtons[i]->SetLeft(x); x += d; } res = wf->ShowModal(); delete wf; return(res); }
// Message Box Replacement int WINAPI MessageBoxX(LPCTSTR lpText, LPCTSTR lpCaption, UINT uType) { WndForm *wf=NULL; WndFrame *wText=NULL; int X, Y, Width, Height; WndButton *wButtons[10]; int ButtonCount = 0; int i,x,y,d,w,h,res,dY; RECT rc; // todo assert(lpText != NULL); assert(lpCaption != NULL); // JMW this makes the first key if pressed quickly, ignored XCSoarInterface::Debounce(); rc = XCSoarInterface::main_window.get_position(); #ifdef ALTAIRSYNC Width = DLGSCALE(220); Height = DLGSCALE(160); #else Width = DLGSCALE(200); Height = DLGSCALE(160); #endif X = ((rc.right-rc.left) - Width)/2; Y = ((rc.bottom-rc.top) - Height)/2; y = DLGSCALE(100); w = DLGSCALE(60); h = DLGSCALE(32); wf = new WndForm(&XCSoarInterface::main_window, TEXT("frmXcSoarMessageDlg"), lpCaption, X, Y, Width, Height); wf->SetFont(MapWindowBoldFont); wf->SetTitleFont(MapWindowBoldFont); wf->SetBackColor(Color(0xDA, 0xDB, 0xAB)); wText = new WndFrame(wf, TEXT("frmMessageDlgText"), 0, DLGSCALE(5), Width, Height); wText->SetCaption(lpText); wText->SetFont(MapWindowBoldFont); wText->SetCaptionStyle( DT_EXPANDTABS | DT_CENTER | DT_NOCLIP | DT_WORDBREAK // | DT_VCENTER ); /* TODO code: this doesnt work to set font height dY = wText->GetLastDrawTextHeight() - Height; */ dY = DLGSCALE(-40); wText->SetHeight(wText->GetTextHeight() + 5); wf->SetHeight(wf->GetHeight() + dY); y += dY; uType = uType & 0x000f; if (uType == MB_OK || uType == MB_OKCANCEL ) { wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("OK")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDOK); ButtonCount++; } if (uType == MB_YESNO || uType == MB_YESNOCANCEL ) { wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("Yes")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDYES); ButtonCount++; wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("No")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDNO); ButtonCount++; } if (uType == MB_ABORTRETRYIGNORE || uType == MB_RETRYCANCEL ) { wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("Retry")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDRETRY); ButtonCount++; } if (uType == MB_OKCANCEL || uType == MB_RETRYCANCEL || uType == MB_YESNOCANCEL ) { wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("Cancel")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDCANCEL); ButtonCount++; } if (uType == MB_ABORTRETRYIGNORE ) { wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("Abort")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDABORT); ButtonCount++; wButtons[ButtonCount] = new WndButton(wf, TEXT(""), gettext(TEXT("Ignore")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDIGNORE); ButtonCount++; } d = Width / (ButtonCount); x = d/2-w/2; for (i=0; i<ButtonCount; i++) { wButtons[i]->SetLeft(x); x += d; } res = wf->ShowModal(); delete wf; #ifdef ALTAIRSYNC // force a refresh of the window behind InvalidateRect(hWnd,NULL,true); UpdateWindow(hWnd); #endif return(res); }