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")); LKASSERT(wAirspaceList!=NULL); wAirspaceList->SetBorderKind(BORDERLEFT); wAirspaceList->SetEnterCallback(OnAirspaceListEnter); WndOwnerDrawFrame* wAirspaceListEntry = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmAirspaceListEntry")); if(wAirspaceListEntry) { wAirspaceListEntry->SetCanFocus(true); } UpdateList(wAirspaceList); changed = false; wf->ShowModal(); delete wf; return changed; }
static void Main() { WndForm *form = LoadDialog(NULL, main_window, xmlfile.c_str()); if (form == NULL) { _ftprintf(stderr, _T("Failed to load resource '%s'\n"), xmlfile.c_str()); return; } form->ShowModal(); delete form; }
void dlgWeatherShowModal() { WndForm *wf = LoadDialog(nullptr, UIGlobals::GetMainWindow(), _T("IDR_XML_WEATHER")); if (wf == NULL) return; WndProperty* wp; wp = (WndProperty*)wf->FindByName(_T("prpTime")); assert(wp != nullptr); DataFieldEnum *dfe = (DataFieldEnum *)wp->GetDataField(); dfe->addEnumText(_("Now")); for (unsigned i = 1; i < RasterWeather::MAX_WEATHER_TIMES; i++) { if (RASP.isWeatherAvailable(i)) { TCHAR timetext[10]; _stprintf(timetext, _T("%04d"), RASP.IndexToTime(i)); dfe->addEnumText(timetext, i); } } dfe->Set(RASP.GetTime()); wp->RefreshDisplay(); wp = (WndProperty *)wf->FindByName(_T("prpDisplayItem")); assert(wp != nullptr); dfe = (DataFieldEnum *)wp->GetDataField(); dfe->EnableItemHelp(true); dfe->addEnumText(_("Terrain")); for (int i = 1; i <= 15; i++) { const TCHAR *label = RASP.ItemLabel(i); if (label != NULL) dfe->AddChoice(i, label, nullptr, RASP.ItemHelp(i)); } dfe->Set(RASP.GetParameter()); wp->RefreshDisplay(); wf->ShowModal(); wp = (WndProperty *)wf->FindByName(_T("prpTime")); assert(wp != nullptr); dfe = (DataFieldEnum *)wp->GetDataField(); RASP.SetTime(dfe->GetValue()); wp = (WndProperty *)wf->FindByName(_T("prpDisplayItem")); assert(wp != nullptr); dfe = (DataFieldEnum *)wp->GetDataField(); RASP.SetParameter(dfe->GetValue()); delete wf; }
/* * only called by #CAirspaceManager::ProcessAirspaceDetailQueue() * for display AirspaceDetails, use #PopupAirspaceDetail */ void dlgAirspaceDetails() { WndForm* wf = dlgLoadFromXML(CallBackTable, IDR_XML_AIRSPACEDETAILS); if (!wf) return; wf->SetTimerNotify(1000, OnTimer); SetValues(wf); wf->ShowModal(); delete wf; wf = NULL; return; }
// checklistmode: 0=notepad 1=logbook 2=... void dlgChecklistShowModal(short checklistmode){ WndListFrame* wDetails = NULL; WndOwnerDrawFrame* wDetailsEntry = NULL; InitNotepad(); LoadChecklist(checklistmode); // check if loaded really something WndForm* wf = dlgLoadFromXML(CallBackTable, ScreenLandscape ? IDR_XML_CHECKLIST_L : IDR_XML_CHECKLIST_P); aTextLine.clear(); if (!wf) goto deinit; wf->SetKeyDownNotify(FormKeyDown); ((WndButton *)wf->FindByName(TEXT("cmdClose")))->SetOnClickNotify(OnCloseClicked); wDetails = (WndListFrame*)wf->FindByName(TEXT("frmDetails")); if (!wDetails) { StartupStore(_T("..... NOTEPAD ERROR NULL frmDetails!\n")); goto deinit; } wDetails->SetBorderKind(BORDERLEFT); wDetailsEntry = (WndOwnerDrawFrame*)wf->FindByName(TEXT("frmDetailsEntry")); if (!wDetailsEntry) { StartupStore(_T("..... NOTEPAD ERROR NULL frmDetailsEntry!\n")); goto deinit; } wDetailsEntry->SetCanFocus(true); page = 0; NextPage(wf, 0); wf->ShowModal(); deinit: delete wf; DeinitNotepad(); }
void dlgConfigWaypointsShowModal() { WndForm *wf = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(), Layout::landscape ? _T("IDR_XML_CONFIG_WAYPOINTS_L") : _T("IDR_XML_CONFIG_WAYPOINTS")); assert(wf != nullptr); WaypointsNeedSave = false; wf->ShowModal(); if (WaypointsNeedSave && ShowMessageBox(_("Save changes to waypoint file?"), _("Waypoints edited"), MB_YESNO | MB_ICONQUESTION) == IDYES) SaveWaypoints(); delete wf; }
void dlgVegaDemoShowModal() { WndForm *wf = LoadDialog(CallBackTable, UIGlobals::GetMainWindow(), _T("IDR_XML_VEGADEMO")); if (!wf) return; PopupOperationEnvironment env; VarioWriteNMEA(_T("PDVSC,S,DemoMode,0"), env); VarioWriteNMEA(_T("PDVSC,S,DemoMode,3"), env); LoadFormProperty(*wf, _T("prpVegaDemoW"), UnitGroup::VERTICAL_SPEED, VegaDemoW); LoadFormProperty(*wf, _T("prpVegaDemoV"), UnitGroup::VERTICAL_SPEED, VegaDemoV); LoadFormProperty(*wf, _T("prpVegaDemoAudioClimb"), VegaDemoAudioClimb); wf->ShowModal(); delete wf; // deactivate demo. VarioWriteNMEA(_T("PDVSC,S,DemoMode,0"), env); }
static void Main() { PixelSize screen_size(320, 240); if (portrait) std::swap(screen_size.cx, screen_size.cy); Layout::Initialize(screen_size.cx, screen_size.cy); SingleWindow main_window; main_window.Create(_T("RunDialog"), screen_size); main_window.Show(); WndForm *form = LoadDialog(NULL, main_window, xmlfile.c_str()); if (form == NULL) { fprintf(stderr, "Failed to load resource '%s'\n", (const char *)NarrowPathName(xmlfile.c_str())); return; } form->ShowModal(); delete form; }
BOOL CDevCProbe::Config(PDeviceDescriptor_t d){ if(m_pDevice != d) { StartupStore(_T("C-Probe Config : Invalide device descriptor%s"), NEWLINE); return FALSE; } WndForm* wf = dlgLoadFromXML(CallBackTable, IDR_XML_DEVCPROBE); if(wf) { WndButton *wBt = NULL; wBt = (WndButton *)wf->FindByName(TEXT("cmdClose")); if(wBt){ wBt->SetOnClickNotify(OnCloseClicked); } wBt = (WndButton *)wf->FindByName(TEXT("cmdSetCompassCal")); if(wBt){ wBt->SetOnClickNotify(OnCompassCalClicked); } wBt = (WndButton *)wf->FindByName(TEXT("cmdSetCalGyro")); if(wBt){ wBt->SetOnClickNotify(OnCalGyroClicked); } wBt = (WndButton *)wf->FindByName(TEXT("cmdZeroDeltaPress")); if(wBt){ wBt->SetOnClickNotify(OnZeroDeltaPressClicked); } GetFirmwareVersion(m_pDevice); wf->SetTimerNotify(1000, OnTimer); wf->ShowModal(); delete wf; wf=NULL; } return TRUE; }
/** * Displays a MessageBox and returns the pressed button * @param lpText Text displayed inside the MessageBox * @param lpCaption Text displayed in the Caption of the MessageBox * @param uType Type of MessageBox to display (OK+Cancel, Yes+No, etc.) * @return */ 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; assert(lpText != NULL); assert(lpCaption != NULL); // JMW this makes the first key if pressed quickly, ignored // TODO bug: doesn't work sometimes. buttons have to be pressed multiple times (TB) XCSoarInterface::Debounce(); rc = XCSoarInterface::main_window.get_screen_position(); #ifdef ALTAIRSYNC Width = Layout::Scale(220); Height = Layout::Scale(160); #else Width = Layout::Scale(200); Height = Layout::Scale(160); #endif X = ((rc.right - rc.left) - Width) / 2; Y = ((rc.bottom - rc.top) - Height) / 2; y = Layout::Scale(100); w = Layout::Scale(60); h = Layout::Scale(32); // Create dialog wf = new WndForm(&XCSoarInterface::main_window, _T("frmXcSoarMessageDlg"), lpCaption, X, Y, Width, Height); wf->SetFont(MapWindowBoldFont); wf->SetTitleFont(MapWindowBoldFont); wf->SetBackColor(Color(0xDA, 0xDB, 0xAB)); // Create text element wText = new WndFrame(wf, _T("frmMessageDlgText"), 0, Layout::Scale(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 = Layout::Scale(-40); wText->resize(Width, wText->GetTextHeight() + 5); wf->resize(Width, wf->get_size().cy + dY); y += dY; // Create buttons uType = uType & 0x000f; if (uType == MB_OK || uType == MB_OKCANCEL) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("OK")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDOK); ButtonCount++; } if (uType == MB_YESNO || uType == MB_YESNOCANCEL) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("Yes")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDYES); ButtonCount++; wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("No")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDNO); ButtonCount++; } if (uType == MB_ABORTRETRYIGNORE || uType == MB_RETRYCANCEL) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("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, _T(""), gettext(_T("Cancel")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDCANCEL); ButtonCount++; } if (uType == MB_ABORTRETRYIGNORE) { wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("Abort")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDABORT); ButtonCount++; wButtons[ButtonCount] = new WndButton(wf, _T(""), gettext(_T("Ignore")), 0, y, w, h, OnButtonClick); wButtons[ButtonCount]->SetTag(IDIGNORE); ButtonCount++; } d = Width / (ButtonCount); x = d / 2 - w / 2; // Move buttons to the right positions for (i = 0; i < ButtonCount; i++) { wButtons[i]->move(x, y); x += d; } // Show MessageBox and save result res = wf->ShowModal(); delete wf; #ifdef ALTAIRSYNC // force a refresh of the window behind InvalidateRect(hWnd,NULL,true); UpdateWindow(hWnd); #endif return(res); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE LPWSTR lpCmdLine, #else LPSTR lpCmdLine2, #endif int nCmdShow) #endif { #ifdef WIN32 #ifndef _WIN32_WCE /* on Windows (non-CE), the lpCmdLine argument is narrow, and we have to use GetCommandLine() to get the UNICODE string */ LPCTSTR lpCmdLine = GetCommandLine(); #endif #ifdef _WIN32_WCE int argc = 2; WCHAR arg0[] = _T(""); LPWSTR argv[] = { arg0, lpCmdLine, NULL }; #else int argc; LPWSTR* argv = CommandLineToArgvW(lpCmdLine, &argc); #endif ResourceLoader::Init(hInstance); #endif if (argc < 2) { fprintf(stderr, "Usage: RunDialog XMLFILE [-portrait]\n"); return 1; } unsigned screen_width = 320, screen_height = 240; if (argc > 2 && _tcscmp(argv[2], _T("-portrait")) == 0) { screen_width = 240; screen_height = 320; } ScreenGlobalInit screen_init; Layout::Initialize(screen_width, screen_height); SingleWindow main_window; main_window.set(_T("STATIC"), _T("RunDialog"), 0, 0, screen_width, screen_height); main_window.show(); WndForm *form = LoadDialog(NULL, main_window, argv[1]); if (form == NULL) { fprintf(stderr, "Failed to load resource '%s'\n", (const char *)NarrowPathName(argv[1])); return 1; } form->ShowModal(); delete form; return 0; }