/** * "Boots" up XCSoar * @param hInstance Instance handle * @param lpCmdLine Command line string * @return True if bootup successful, False otherwise */ bool XCSoarInterface::Startup(HINSTANCE hInstance, LPTSTR lpCmdLine) { // The title bar text TCHAR szTitle[MAX_LOADSTRING]; // Store instance handle in our global variable hInst = hInstance; // IDS_APP_TITLE = XCSoar (see XCSoar.rc) LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); //If it is already running, then focus on the window if (MainWindow::find(szTitle)) return false; // Send the SettingsMap to the DeviceBlackboard SendSettingsMap(); // Register window classes PaintWindow::register_class(hInst); MainWindow::register_class(hInst); MapWindow::register_class(hInst); // Fill the fast(co)sine table InitSineTable(); PreloadInitialisation(true); // Send the SettingsMap to the DeviceBlackboard SendSettingsMap(); // Creates the main window StartupStore(TEXT("Create main window\n")); RECT WindowSize = SystemWindowSize(); main_window.set(szTitle, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom); if (!main_window.defined()) { return false; } main_window.install_timer(); // Initialize DeviceBlackboard device_blackboard.Initialise(); // Initialize Marks marks = new Marks("xcsoar-marks"); topology = new TopologyStore(marks->GetTopology()); // Show the main and map windows StartupStore(TEXT("Create map window\n")); main_window.show(); main_window.map.show(); #ifdef HAVE_ACTIVATE_INFO SHSetAppKeyWndAssoc(VK_APP1, main_window); SHSetAppKeyWndAssoc(VK_APP2, main_window); SHSetAppKeyWndAssoc(VK_APP3, main_window); SHSetAppKeyWndAssoc(VK_APP4, main_window); // Typical Record Button // Why you can't always get this to work // http://forums.devbuzz.com/m_1185/mpage_1/key_/tm.htm // To do with the fact it is a global hotkey, but you can with code above // Also APPA is record key on some systems SHSetAppKeyWndAssoc(VK_APP5, main_window); SHSetAppKeyWndAssoc(VK_APP6, main_window); #endif // Initialize main blackboard data task.ClearTask(); glide_computer.Initialise(); logger.LinkGRecordDLL(); // try to link DLL if it exists // Load the EGM96 geoid data OpenGeoid(); PreloadInitialisation(false); Profile::LoadWindFromRegistry(); // TODO TB: seems to be out of date?! CalculateNewPolarCoef(); // Calculate polar-related data and saves it to the cache StartupStore(TEXT("GlidePolar::UpdatePolar\n")); GlidePolar::UpdatePolar(false, SettingsComputer()); // Show startup info depending on device StartupInfo(); // Read the topology file(s) topology->Open(); // Read the terrain file terrain.OpenTerrain(); // Read the waypoint files ReadWayPoints(way_points, terrain); // Read and parse the airfield info file ReadAirfieldFile(); // Set the home waypoint SetHome(way_points, terrain, SetSettingsComputer(), false, true); // ReSynchronise the blackboards here since SetHome touches them ReadBlackboardBasic(device_blackboard.Basic()); terrain.ServiceFullReload(Basic().Location); // Scan for weather forecast CreateProgressDialog(gettext(TEXT("Scanning weather forecast"))); StartupStore(TEXT("RASP load\n")); RASP.ScanAll(Basic().Location); // Reads the airspace files ReadAirspace(); // Sorts the airspaces by priority SortAirspace(); // Read the FLARM details file OpenFLARMDetails(); #ifndef DISABLEAUDIOVARIO /* VarioSound_Init(); VarioSound_EnableSound(EnableSoundVario); VarioSound_SetVdead(SoundDeadband); VarioSound_SetV(0); VarioSound_SetSoundVolume(SoundVolume); */ #endif // Start the device thread(s) CreateProgressDialog(gettext(TEXT("Starting devices"))); devStartup(lpCmdLine); // Reset polar in case devices need the data StartupStore(TEXT("GlidePolar::UpdatePolar\n")); GlidePolar::UpdatePolar(true, SettingsComputer()); CreateProgressDialog(gettext(TEXT("Initialising display"))); // Finally ready to go.. all structures must be present before this. // Create the drawing thread StartupStore(TEXT("CreateDrawingThread\n")); draw_thread = new DrawThread(main_window.map, main_window.flarm); draw_thread->start(); // Show the infoboxes StartupStore(TEXT("ShowInfoBoxes\n")); InfoBoxManager::Show(); // Create the calculation thread StartupStore(TEXT("CreateCalculationThread\n")); CreateCalculationThread(); #ifdef NEWTASK { // NEWTASK PeriodClock t; t.reset(); t.update(); CreateProgressDialog(gettext(TEXT("Running test 0"))); test_newtask(0); StartupStore(TEXT("test 0 %d\n"),t.elapsed()); /* t.update(); CreateProgressDialog(gettext(TEXT("Running test 1"))); test_newtask(1); StartupStore(TEXT("test 1 %d\n"),t.elapsed()); t.update(); CreateProgressDialog(gettext(TEXT("Running test 2"))); test_newtask(2); StartupStore(TEXT("test 2 %d\n"),t.elapsed()); t.update(); CreateProgressDialog(gettext(TEXT("Running test 3"))); test_newtask(3); StartupStore(TEXT("test 3 %d\n"),t.elapsed()); t.update(); CreateProgressDialog(gettext(TEXT("Running test 4"))); test_newtask(4); StartupStore(TEXT("test 4 %d\n"),t.elapsed()); */ CreateProgressDialog(gettext(TEXT("test complete"))); } #endif // Initialise the airspace warning dialog StartupStore(TEXT("dlgAirspaceWarningInit\n")); dlgAirspaceWarningInit(); // Find unique ID of this PDA ReadAssetNumber(); StartupStore(TEXT("ProgramStarted\n")); // Give focus to the map main_window.map.set_focus(); // Start calculation thread calculation_thread->start(); // Start instrument thread instrument_thread->start(); globalRunningEvent.trigger(); return true; }
// // FUNCTION: InitInstance() // // PURPOSE: creates main window // // COMMENTS: // // In this function, we create and display the main program window. // BOOL InitInstance() { extern bool CommandResolution; if(!IsEmbedded() && !CommandResolution) { ScreenSizeX = 800; ScreenSizeY = 480; } #if defined(ENABLE_SDL) && defined(USE_FULLSCREEN) #if (SDL_MAJOR_VERSION >= 2) SDL_DisplayMode mode = {}; if(SDL_GetCurrentDisplayMode(0, &mode) == 0) { ScreenSizeX = mode.w; ScreenSizeY = mode.h; } else { fprintf(stderr, "SDL_GetCurrentDisplayMode() has failed: %s\n", ::SDL_GetError()); } #else ScreenSizeX = 0; ScreenSizeY = 0; #endif #endif PreloadInitialisation(true); RECT WindowSize; #ifdef __linux__ #ifdef USE_VIDEOCORE uint32_t iWidth, iHeight; if(graphics_get_display_size(0, &iWidth, &iHeight) >= 0) { ScreenSizeX=iWidth; ScreenSizeY=iHeight; } #endif #ifdef ANDROID const PixelSize Size = native_view->GetSize(); ScreenSizeX=Size.cx; ScreenSizeY=Size.cy; #endif WindowSize=WindowResize(ScreenSizeX, ScreenSizeY); #endif #ifdef WIN32 #if defined(UNDER_CE) || defined(USE_FULLSCREEN) WindowSize=WindowResize( GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); #else WindowSize=WindowResize(ScreenSizeX, ScreenSizeY); #endif #endif #if TESTBENCH StartupStore(TEXT(". Create main window%s"),NEWLINE); #endif if(!MainWindow.Create(WindowSize)) { StartupStore(TEXT(". FAILURE: Create main window%s"),NEWLINE); return FALSE; } const PixelRect rc(MainWindow.GetClientRect()); ScreenSizeX = rc.GetSize().cx; ScreenSizeY = rc.GetSize().cy; ScreenHasChanged(); InitLKScreen(); InitLKFonts(); // causing problems with CreateButtonLabels? LKLoadFixedBitmaps(); LKLoadProfileBitmaps(); LKObjects_Create(); ButtonLabel::CreateButtonLabels(rc); ButtonLabel::SetFont(MapWindowBoldFont); Message::Initialize(rc); // creates window, sets fonts MainWindow.SetVisible(true); return TRUE; }
// // FUNCTION: InitInstance() // // PURPOSE: creates main window // // COMMENTS: // // In this function, we create and display the main program window. // BOOL InitInstance() { extern bool CommandResolution; if(!IsEmbedded() && !CommandResolution) { ScreenSizeX = 800; ScreenSizeY = 480; } #if defined(ENABLE_SDL) && defined(USE_FULLSCREEN) #if (SDL_MAJOR_VERSION >= 2) SDL_DisplayMode mode = {}; if(SDL_GetCurrentDisplayMode(0, &mode) == 0) { ScreenSizeX = mode.w; ScreenSizeY = mode.h; } else { fprintf(stderr, "SDL_GetCurrentDisplayMode() has failed: %s\n", ::SDL_GetError()); } #else ScreenSizeX = 0; ScreenSizeY = 0; #endif #endif PreloadInitialisation(true); RECT WindowSize; #ifdef __linux__ WindowSize=WindowResize(ScreenSizeX, ScreenSizeY); #endif #ifdef WIN32 #ifdef UNDER_CE WindowSize=WindowResize( GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN)); #else WindowSize=WindowResize(ScreenSizeX, ScreenSizeY); #endif #endif if (!goInstallSystem) Poco::Thread::sleep(50); // 091119 #if TESTBENCH StartupStore(TEXT(". Create main window%s"),NEWLINE); #endif if(!MainWindow.Create(WindowSize)) { StartupStore(TEXT(". FAILURE: Create main window%s"),NEWLINE); return FALSE; } const PixelRect rc(MainWindow.GetClientRect()); ScreenSizeX = rc.GetSize().cx; ScreenSizeY = rc.GetSize().cy; InitLKScreen(); InitLKFonts(); // causing problems with CreateButtonLabels? LKLoadFixedBitmaps(); LKLoadProfileBitmaps(); LKObjects_Create(); ButtonLabel::CreateButtonLabels(rc); ButtonLabel::SetLabelText(0,TEXT("MODE")); extern void InitLKFonts(); // reload updating LK fonts after loading profile for fontquality InitLKFonts(); ButtonLabel::SetFont(MapWindowBoldFont); Message::Initialize(rc); // creates window, sets fonts MainWindow.SetVisible(true); return TRUE; }
// // FUNCTION: InitInstance(HANDLE, int) // // PURPOSE: Saves instance handle and creates main window // // COMMENTS: // // In this function, we save the instance handle in a global variable and // create and display the main program window. // BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) { TCHAR szTitle[MAX_LOADSTRING]; // The title bar text TCHAR szWindowClass[MAX_LOADSTRING]; // The window class name RECT rc; hInst = hInstance; // Store instance handle in our global variable LoadString(hInstance, IDC_LK8000, szWindowClass, MAX_LOADSTRING); LoadString(hInstance, IDS_APP_TITLE, szTitle, MAX_LOADSTRING); // If it is already running, then focus on the window // problem was that if two instances are started within a few seconds, both will survive! // We enforceed this with mutex at the beginning of WinMain hWndMainWindow = FindWindow(szWindowClass, szTitle); if (hWndMainWindow) { SetForegroundWindow((HWND)((ULONG) hWndMainWindow | 0x00000001)); return 0; } InitLKScreen(); InitLKFonts(); // causing problems with CreateButtonLabels? PreloadInitialisation(true); MyRegisterClass(hInst, szWindowClass); RECT WindowSize; WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = GetSystemMetrics(SM_CXSCREEN); WindowSize.bottom = GetSystemMetrics(SM_CYSCREEN); #if (WINDOWSPC>0) WindowSize.right = SCREENWIDTH + 2*GetSystemMetrics( SM_CXFIXEDFRAME); WindowSize.left = (GetSystemMetrics(SM_CXSCREEN) - WindowSize.right) / 2; WindowSize.bottom = SCREENHEIGHT + 2*GetSystemMetrics( SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION); WindowSize.top = (GetSystemMetrics(SM_CYSCREEN) - WindowSize.bottom) / 2; /* // // Custom setup for positioning the window , ready to be used // WindowSize.top=768; // top and left corner coords WindowSize.left=1024; WindowSize.right = SCREENWIDTH + 2*GetSystemMetrics( SM_CXFIXEDFRAME); WindowSize.bottom = SCREENHEIGHT + 2*GetSystemMetrics( SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION); */ #endif if (!goInstallSystem) Sleep(50); // 091119 #if TESTBENCH StartupStore(TEXT(". Create main window%s"),NEWLINE); #endif hWndMainWindow = CreateWindow(szWindowClass, szTitle, WS_SYSMENU | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom, NULL, NULL, hInstance, NULL); if (!hWndMainWindow) { return FALSE; } hBrushSelected = (HBRUSH)CreateSolidBrush(ColorSelected); hBrushUnselected = (HBRUSH)CreateSolidBrush(ColorUnselected); hBrushButton = (HBRUSH)CreateSolidBrush(ColorButton); #ifdef LXMINIMAP hBrushButtonHasFocus = (HBRUSH)CreateSolidBrush(ColorButtonHasFocus); #endif GetClientRect(hWndMainWindow, &rc); #if (WINDOWSPC>0) rc.left = 0; rc.right = SCREENWIDTH; rc.top = 0; rc.bottom = SCREENHEIGHT; #endif LKLoadFixedBitmaps(); LKLoadProfileBitmaps(); LKObjects_Create(); ButtonLabel::CreateButtonLabels(rc); ButtonLabel::SetLabelText(0,TEXT("MODE")); extern void InitialiseFonts(RECT rc); InitialiseFonts(rc); InitLKFonts(); // reload updating LK fonts after loading profile for fontquality ButtonLabel::SetFont(MapWindowBoldFont); Message::Initialize(rc); // creates window, sets fonts ShowWindow(hWndMainWindow, SW_SHOW); #if TESTBENCH StartupStore(TEXT(". Create map window%s"),NEWLINE); #endif hWndMapWindow = CreateWindow(TEXT("MapWindowClass"),NULL, WS_VISIBLE | WS_CHILD | WS_CLIPCHILDREN | WS_CLIPSIBLINGS, 0, 0, (rc.right - rc.left), (rc.bottom-rc.top) , hWndMainWindow, NULL ,hInstance,NULL); ShowWindow(hWndMainWindow, nCmdShow); UpdateWindow(hWndMainWindow); // Since MapWndProc is doing static inits, we want them to be recalculated at the end of // initializations, since some values in use might have been not available yet, for example BottomSize. Reset_Single_DoInits(MDI_MAPWNDPROC); return TRUE; }