pForm->SetModalResult(mrOK); } } return; } } static void OnAdvancedClicked(WndButton* Sender){ showAdvanced = !showAdvanced; UpdateAdvanced(); } static CallBackTableEntry_t CallBackTable[]={ OnPaintCallbackEntry(OnTaskPaintListItem), OnListCallbackEntry(OnTaskListInfo), ClickNotifyCallbackEntry(OnDeclareClicked), ClickNotifyCallbackEntry(OnCalcClicked), ClickNotifyCallbackEntry(OnClearClicked), ClickNotifyCallbackEntry(OnCloseClicked), ClickNotifyCallbackEntry(OnAdvancedClicked), ClickNotifyCallbackEntry(OnSaveClicked), ClickNotifyCallbackEntry(OnLoadClicked), ClickNotifyCallbackEntry(OnDeleteClicked), ClickNotifyCallbackEntry(OnAnalysisClicked), ClickNotifyCallbackEntry(OnTimegatesClicked), EndCallBackEntry() };
retStatus=1; wf->SetModalResult(mrOK); } static void OnTaskClicked(WndButton* pWnd){ retStatus=5; wf->SetModalResult(mrOK); } static CallBackTableEntry_t CallBackTable[]={ ClickNotifyCallbackEntry(OnGotoClicked), ClickNotifyCallbackEntry(OnSetAlt1Clicked), ClickNotifyCallbackEntry(OnSetAlt2Clicked), ClickNotifyCallbackEntry(OnTaskClicked), ClickNotifyCallbackEntry(OnCancelClicked), OnPaintCallbackEntry(OnPaintWaypointPicto), EndCallBackEntry() }; // Will return 0 if cancel or error, 1 if details needed, 2 if goto, 3 if alt1, 4 if alt2 short dlgWayQuickShowModal(void){ wf = NULL; TCHAR filename[MAX_PATH]; TCHAR sTmp[128]; if (ScreenLandscape) { LocalPathS(filename, TEXT("dlgWayQuick.xml")); wf = dlgLoadFromXML(CallBackTable, filename, TEXT("IDR_XML_WAYPOINTQUICK")); } else {
Surface.SetTextColor(RGB_WHITE); Surface.SetBackgroundTransparent(); InflateRect(&PrintAreaR, -NIBLSCALE(2), -NIBLSCALE(2)); const TCHAR* text = Sender->GetCaption(); Surface.DrawText(text, &PrintAreaR, DT_VCENTER|DT_SINGLELINE); Surface.SelectObject(ohB); Surface.SelectObject(ohP); Surface.SelectObject(oldFont); } CallBackTableEntry_t CallBackTable[] = { OnPaintCallbackEntry(OnSplashPaint), OnPaintCallbackEntry(OnProgressPaint), EndCallBackEntry() }; class dlgProgress final { public: dlgProgress(); ~dlgProgress(); dlgProgress( const dlgProgress& ) = delete; dlgProgress& operator=( const dlgProgress& ) = delete; void SetProgressText(const TCHAR* szText); private:
static void OnClearClicked(WndButton* pWnd) { LockTaskData(); for (int i=0; i<MAXSTARTPOINTS; i++) { StartPoints[i].Index = -1; StartPoints[i].Active = false; } StartPoints[0].Index = Task[0].Index; StartPoints[0].Active = true; changed = true; UnlockTaskData(); UpdateList(); } static CallBackTableEntry_t CallBackTable[]= { OnPaintCallbackEntry(OnStartPointPaintListItem), OnListCallbackEntry(OnStartPointListInfo), ClickNotifyCallbackEntry(OnCloseClicked), ClickNotifyCallbackEntry(OnClearClicked), EndCallBackEntry() }; static void CheckStartPointInTask(void) { LockTaskData(); if (Task[0].Index != -1) { // ensure current start point is in task int index_last = 0; for (int i=MAXSTARTPOINTS-1; i>=0; i--) { if (StartPoints[i].Index == Task[0].Index) { index_last = -1;
namespace DlgBluetooth { WndForm *wfBth = NULL; size_t DrawListIndex = 0; size_t ItemIndex = 0; void OnClose(WndButton* pWnd) { wfBth->SetModalResult(mrOK); } void OnPair(WndButton* pWnd) { CBtHandler* pBtHandler = CBtHandler::Get(); if (pBtHandler) { CBtDevice * SelectedDevice = pBtHandler->GetDevice(ItemIndex); if (SelectedDevice && SelectedDevice->m_src == BDSRC_LOOKUP) { TCHAR szPin[20] = {0}; dlgTextEntryShowModal(szPin, 20, false); if (!pBtHandler->Pair(SelectedDevice->m_ba, SelectedDevice->GetName().c_str(), szPin)) { StartupStore(_T("Bluetooth pairing <%s> : Failed%s"), SelectedDevice->GetName().c_str(), NEWLINE); MessageBoxX(LKGetText(TEXT("_@M1835_")), TEXT("Bluetooth"), mbOk, false); } else { StartupStore(_T("Bluetooth pairing <%s> : success%s"), SelectedDevice->GetName().c_str(), NEWLINE); SelectedDevice->m_src |= BDSRC_REGNAV; } } WndListFrame* BthList = (WndListFrame*) wfBth->FindByName(TEXT("frmBthList")); if (BthList) { BthList->ResetList(); BthList->Redraw(); } } } void OnUnpair(WndButton* pWnd) { CBtHandler* pBtHandler = CBtHandler::Get(); if (pBtHandler) { CBtDevice * SelectedDevice = pBtHandler->GetDevice(ItemIndex); if (SelectedDevice && SelectedDevice->m_src != BDSRC_LOOKUP) { if (!pBtHandler->Unpair(SelectedDevice->m_ba)) { StartupStore(_T("%s[%s] : UnPairing Error%s"), SelectedDevice->GetName().c_str(), SelectedDevice->BTPortName().c_str(), NEWLINE); } else { pBtHandler->RemoveDevice(SelectedDevice->m_ba); } } WndListFrame* BthList = (WndListFrame*) wfBth->FindByName(TEXT("frmBthList")); if (BthList) { BthList->ResetList(); BthList->Redraw(); } } } void OnLookup(WndButton* pWnd) { StartHourglassCursor(); CBtHandler * pBtHandler = CBtHandler::Get(); if (pBtHandler && pBtHandler->StartHW() && pBtHandler->LookupDevices()) { WndListFrame* BthList = (WndListFrame*) wfBth->FindByName(TEXT("frmBthList")); if (BthList) { BthList->ResetList(); BthList->Redraw(); } } StopHourglassCursor(); } void OnPaintListItem(WindowControl * Sender, LKSurface& Surface) { CBtHandler* pBtHandler = CBtHandler::Get(); if (pBtHandler) { CBtDevice * bt = pBtHandler->GetDevice(DrawListIndex); if (bt) { int w1 = Surface.GetTextWidth(TEXT("PAIRED")); int w0 = Sender->GetWidth(); Surface.DrawTextClip(2 * ScreenScale, 2 * ScreenScale, bt->GetName().c_str(), w0 - w1 - ScreenScale * 5); if ((bt->m_src & (BDSRC_REGSVC | BDSRC_REGNAV | BDSRC_REGPIN))) { Surface.DrawTextClip(2 * ScreenScale + w0 - w1, 2 * ScreenScale, _T("Paired"), w1); } } } } void OnListInfo(WindowControl * Sender, WndListFrame::ListInfo_t * ListInfo) { (void) Sender; CBtHandler* pBtHandler = CBtHandler::Get(); if (pBtHandler) { ListInfo->ItemCount = pBtHandler->m_devices.size(); if (ListInfo->DrawIndex != -1) { DrawListIndex = ListInfo->DrawIndex + ListInfo->ScrollIndex; ItemIndex = ListInfo->ItemIndex + ListInfo->ScrollIndex; } } } CallBackTableEntry_t CallBackTable[] = { ClickNotifyCallbackEntry(OnClose), ClickNotifyCallbackEntry(OnPair), ClickNotifyCallbackEntry(OnUnpair), ClickNotifyCallbackEntry(OnLookup), OnPaintCallbackEntry(OnPaintListItem), OnListCallbackEntry(OnListInfo), EndCallBackEntry() }; void Show() { TCHAR filename[MAX_PATH]; const TCHAR *resName = NULL; if (!ScreenLandscape) { LocalPathS(filename, TEXT("dlgBluetooth_L.xml")); resName = TEXT("IDR_XML_BLUETOOTH_L"); } else { LocalPathS(filename, TEXT("dlgBluetooth.xml")); resName = TEXT("IDR_XML_BLUETOOTH"); } wfBth = dlgLoadFromXML(CallBackTable, filename, resName); if (wfBth) { WndListFrame* BthList = (WndListFrame*) wfBth->FindByName(TEXT("frmBthList")); if (BthList) { BthList->SetBorderKind(BORDERLEFT | BORDERTOP | BORDERRIGHT | BORDERBOTTOM); BthList->SetWidth(wfBth->GetWidth() - BthList->GetLeft() - IBLSCALE(4)); // Bug : we need ClientHeight, but Cleint Rect is Calculated by OnPaint // BthList->SetHeight(wfBth->GetHeight() - BthList->GetTop() - 2); if (BthList->ScrollbarWidth == -1) { BthList->ScrollbarWidth = (int) (SCROLLBARWIDTH_INITIAL * ScreenDScale); } WndOwnerDrawFrame* BthListEntry = (WndOwnerDrawFrame*) wfBth->FindByName(TEXT("frmBthListEntry")); if (BthListEntry) { BthListEntry->SetCanFocus(true); BthListEntry->SetWidth(BthList->GetWidth() - BthList->ScrollbarWidth - 5); } BthList->ResetList(); BthList->Redraw(); } if (wfBth->ShowModal()) { CBtHandler * pBtHandler = CBtHandler::Get(); if (pBtHandler) { pBtHandler->ClearDevices(); pBtHandler->FillDevices(); } RefreshComPortList(); } delete wfBth; wfBth = NULL; } } };
static CallBackTableEntry_t CallBackTable[]={ ClickNotifyCallbackEntry(OnMoveClicked), ClickNotifyCallbackEntry(OnSelectClicked), ClickNotifyCallbackEntry(OnDetailsClicked), ClickNotifyCallbackEntry(OnRemoveClicked), ClickNotifyCallbackEntry(OnCloseClicked), ClickNotifyCallbackEntry(OnStartPointClicked), ClickNotifyCallbackEntry(OnMoveAfterClicked), ClickNotifyCallbackEntry(OnMoveBeforeClicked), DataAccessCallbackEntry(OnAATEnabled), ClickNotifyCallbackEntry(OnTaskRulesClicked), OnPaintCallbackEntry(OnTaskPointPicto), EndCallBackEntry() }; void dlgTaskWaypointShowModal(int itemindex, int tasktype, bool addonly, bool Moveallowed){ wf = dlgLoadFromXML(CallBackTable, ScreenLandscape ? IDR_XML_TASKWAYPOINT_L : IDR_XML_TASKWAYPOINT_P); if (ISPARAGLIDER) { if(DoOptimizeRoute()) AATEnabled=TRUE; EnableMultipleStartPoints=false; } twItemIndex = itemindex;
static void OnDetailsListInfo(WindowControl * Sender, WndListFrame::ListInfo_t *ListInfo){ (void)Sender; if (ListInfo->DrawIndex == -1){ ListInfo->ItemCount = aTextLine.size(); } else { DrawListIndex = ListInfo->DrawIndex+ListInfo->ScrollIndex; } } static CallBackTableEntry_t CallBackTable[]={ ClickNotifyCallbackEntry(OnCloseClicked), OnPaintCallbackEntry(OnPaintDetailsListItem), OnListCallbackEntry(OnDetailsListInfo), EndCallBackEntry() }; void dlgHelpShowModal(const TCHAR* Caption, const TCHAR* HelpText) { if (!Caption || !HelpText) { return; } InitHelp(); wf = dlgLoadFromXML(CallBackTable, ScreenLandscape ? TEXT("dlgHelp_L.xml") : TEXT("dlgHelp_P.xml"), ScreenLandscape ? IDR_XML_HELP_L : IDR_XML_HELP_P); LKASSERT(wf);
if(pWnd) { WndForm * pForm = pWnd->GetParentWndForm(); if(pForm) { pForm->SetModalResult(mrOK); } } } static CallBackTableEntry_t CallBackTable[]={ ClickNotifyCallbackEntry(OnAcknowledgeClicked), ClickNotifyCallbackEntry(OnDetailsClicked), ClickNotifyCallbackEntry(OnFlyClicked), ClickNotifyCallbackEntry(OnCloseClicked), ClickNotifyCallbackEntry(OnSelectClicked), ClickNotifyCallbackEntry(OnSetFrequency), OnPaintCallbackEntry(OnPaintAirspacePicto), EndCallBackEntry() }; static void SetValues(WndForm* wf) { WndProperty* wp; WndButton *wb; TCHAR buffer[80]; TCHAR buffer2[160]; // must contain buffer int bearing; int hdist; int vdist;
WndForm * pForm = pWnd->GetParentWndForm(); if(pForm) { pForm->SetModalResult(mrOK); } } } static void OnLookupClicked(WndButton* pWnd){ (void)pWnd; dlgAirspaceSelect(); } static CallBackTableEntry_t CallBackTable[]={ OnPaintCallbackEntry(OnAirspacePaintListItem), OnListCallbackEntry(OnAirspaceListInfo), ClickNotifyCallbackEntry(OnCloseClicked), ClickNotifyCallbackEntry(OnLookupClicked), EndCallBackEntry() }; bool dlgAirspaceShowModal(bool coloredit){ colormode = coloredit; WndForm *wf = dlgLoadFromXML(CallBackTable, ScreenLandscape ? IDR_XML_AIRSPACE_L : IDR_XML_AIRSPACE_P); if (!wf) return false; WndListFrame* wAirspaceList = (WndListFrame*)wf->FindByName(TEXT("frmAirspaceList"));
TaskIndex = iNO_Tasks - 1; } if (TaskIndex >= 0) { if(Sender) { WndForm * pForm = Sender->GetParentWndForm(); if(pForm) { pForm->SetModalResult(mrOK); } } } } static CallBackTableEntry_t TaskCallBackTable[] = { OnPaintCallbackEntry(OnMultiSelectListPaintListItem), OnListCallbackEntry(OnMultiSelectListListInfo), ClickNotifyCallbackEntry(OnCloseClicked), ClickNotifyCallbackEntry(OnUpClicked), ClickNotifyCallbackEntry(OnEnterClicked), ClickNotifyCallbackEntry(OnDownClicked), EndCallBackEntry() }; int dlgTaskSelectListShowModal(void) { TaskIndex = -1; if (iNO_Tasks == 0) return mrCancel;
namespace DlgIgcFile { WndForm *wfDlg = NULL; typedef std::vector<std::tstring> FileList_t; FileList_t FileList; size_t DrawListIndex = (~0); size_t ItemIndex = (~0); void ScanFile() { FileList.clear(); TCHAR szPath[MAX_PATH] = _T("\0"); TCHAR tmpPath[MAX_PATH]; LocalPath(szPath, _T(LKD_LOGS)); size_t nLen = _tcslen(szPath); if (szPath[nLen - 1] != _T('\\')) { _tcscat(szPath, _T(DIRSEP)); } _tcscpy(tmpPath,szPath); _tcscat(tmpPath, _T("*.igc")); for(lk::filesystem::directory_iterator It(tmpPath); It; ++It) { if(!It.isDirectory()) { FileList.push_back(It.getName()); } } _tcscpy(tmpPath,szPath); _tcscat(tmpPath, _T("*.IGC")); for(lk::filesystem::directory_iterator It(tmpPath); It; ++It) { if(!It.isDirectory()) { FileList.push_back(It.getName()); } } std::sort(FileList.rbegin(), FileList.rend()); // sort in desc order. } void OnClose(WndButton* pWnd) { wfDlg->SetModalResult(mrOK); } void OnSend(WndButton* pWnd) { if(ItemIndex < FileList.size()) { StartHourglassCursor(); //Start Bluetooth if needed... #ifdef UNDER_CE CObexPush Obex; if(Obex.Startup()) { StartupStore(_T("Startup OK \n")); size_t nDevice = Obex.LookupDevice(); StartupStore(_T("LookupDevice OK \n")); if(nDevice == 0) { StopHourglassCursor(); MessageBoxX(_T("No Device"), _T("Error"), mbOk); StartHourglassCursor(); } else { WndProperty* wp = (WndProperty*)wfDlg->FindByName(TEXT("prpDeviceList")); DataFieldEnum* dfe = NULL; if (wp) { dfe = (DataFieldEnum*)wp->GetDataField(); } if(dfe) { dfe->Clear(); dfe->addEnumText(_T("none")); } for(size_t i = 0; i < nDevice; ++i) { TCHAR szDeviceName[100] = {0}; if(!Obex.GetDeviceName(i, szDeviceName, array_size(szDeviceName))) { _stprintf(szDeviceName, _T("Unknown device <%d>"), i); } StartupStore(_T("GetDeviceName <%d><%s> \n"), i, szDeviceName); if(dfe) { dfe->addEnumText(szDeviceName); } } if(wp) { if(dfe) { dfe->SetAsInteger(0); } wp->SetReadOnly(false); wp->RefreshDisplay(); } StopHourglassCursor(); size_t DeviceIndex = 0; if(dfe && wp) { dlgComboPicker(wp); DeviceIndex = dfe->GetAsInteger(); } StartHourglassCursor(); if(DeviceIndex != 0) { DeviceIndex--; TCHAR szFileFullPath[MAX_PATH] = _T("\0"); LocalPath(szFileFullPath, _T(LKD_LOGS)); size_t nLen = _tcslen(szFileFullPath); if (szFileFullPath[nLen - 1] != _T('\\')) { _tcscat(szFileFullPath, _T("\\")); } FileList_t::const_iterator ItFileName = FileList.begin(); std::advance(ItFileName, ItemIndex); _tcscat(szFileFullPath, ItFileName->c_str()); if(!Obex.SendFile(DeviceIndex, szFileFullPath)) { StopHourglassCursor(); MessageBoxX(_T("Send Failed"), _T("Error"), mbOk); StartHourglassCursor(); } else { StopHourglassCursor(); MessageBoxX(_T("File sent!"), _T("Success"), mbOk); StartHourglassCursor(); } } } Obex.Shutdown(); } else { MessageBoxX(_T("Unsupported on this device"), _T("Error"), mbOk); } #else MessageBoxX(_T("Unsupported on this device"), _T("Error"), mbOk); #endif StopHourglassCursor(); } } void OnIgcFileListInfo(WindowControl * Sender, WndListFrame::ListInfo_t * ListInfo) { (void) Sender; ListInfo->ItemCount = FileList.size(); if (ListInfo->DrawIndex != -1) { DrawListIndex = ListInfo->DrawIndex + ListInfo->ScrollIndex; ItemIndex = ListInfo->ItemIndex + ListInfo->ScrollIndex; } } void OnPaintIgcFileListItem(WindowControl * Sender, LKSurface& Surface) { if (DrawListIndex < FileList.size()) { FileList_t::const_iterator ItFileName = FileList.begin(); std::advance(ItFileName, DrawListIndex); int w0 = Sender->GetWidth(); Surface.SetTextColor(RGB_BLACK); Surface.DrawTextClip(2 * ScreenScale, 2 * ScreenScale, ItFileName->c_str(), w0 - ScreenScale * 5); } } CallBackTableEntry_t CallBackTable[] = { ClickNotifyCallbackEntry(OnClose), ClickNotifyCallbackEntry(OnSend), OnListCallbackEntry(OnIgcFileListInfo), OnPaintCallbackEntry(OnPaintIgcFileListItem), EndCallBackEntry() }; }
static void OnComboPopupListEnter(WindowControl * Sender, WndListFrame::ListInfo_t *ListInfo) { // double-click on item -- NOT in callback table because added manually (void)Sender; wf->SetModalResult(mrOK); } static void OnCancelClicked(WndButton* pWnd){ (void)pWnd; ComboListPopup->ComboPopupItemIndex= -1; wf->SetModalResult(mrCancel); } static CallBackTableEntry_t CallBackTable[]={ OnListCallbackEntry(OnComboPopupListInfo), OnPaintCallbackEntry(OnPaintComboPopupListItem), OnHelpCallbackEntry(OnHelpClicked), ClickNotifyCallbackEntry(OnCloseClicked), ClickNotifyCallbackEntry(OnCancelClicked), EndCallBackEntry() }; int dlgComboPicker(WndProperty* theProperty){ static bool bInComboPicker=false;
ListInfo->ItemCount = NUMAIRSPACECOLORS; } else { DrawListIndex = ListInfo->DrawIndex+ListInfo->ScrollIndex; ItemIndex = ListInfo->ItemIndex+ListInfo->ScrollIndex; } } static void OnCloseClicked(WndButton* pWnd){ (void)pWnd; ItemIndex = -1; wf->SetModalResult(mrOK); } static CallBackTableEntry_t CallBackTable[]={ OnPaintCallbackEntry(OnAirspaceColoursPaintListItem), OnListCallbackEntry(OnAirspaceColoursListInfo), ClickNotifyCallbackEntry(OnCloseClicked), EndCallBackEntry() }; int dlgAirspaceColoursShowModal(void){ ItemIndex = -1; wf = dlgLoadFromXML(CallBackTable, ScreenLandscape ? TEXT("dlgAirspaceColours_L.xml") : TEXT("dlgAirspaceColours_P.xml"), ScreenLandscape ? IDR_XML_AIRSPACECOLOURS_L : IDR_XML_AIRSPACECOLOURS_P); if (!wf) return -1;
static void OnNickelClick(WndButton* pWnd) { RUN_MODE = RUN_EXIT; RestartToNickel = true; LKSound(_T("LK_SLIDE.WAV")); if(pWnd) { WndForm * pForm = pWnd->GetParentWndForm(); if(pForm) { pForm->SetModalResult(mrOK); } } } #endif static CallBackTableEntry_t CallBackTable[] = { OnPaintCallbackEntry(OnSplashPaint), ClickNotifyCallbackEntry(OnPILOTClicked), ClickNotifyCallbackEntry(OnDEVICEClicked), ClickNotifyCallbackEntry(OnAIRCRAFTClicked), ClickNotifyCallbackEntry(OnPROFILEClicked), ClickNotifyCallbackEntry(OnEXITClicked), ClickNotifyCallbackEntry(OnDUALPROFILEClicked), ClickNotifyCallbackEntry(OnFLYClicked), ClickNotifyCallbackEntry(OnSIMClicked), ClickNotifyCallbackEntry(OnCloseClicked), EndCallBackEntry() }; static WndForm* InitFlySim() {