int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE LPWSTR lpCmdLine, #else LPSTR lpCmdLine2, #endif int nCmdShow) #endif { ScreenGlobalInit screen_init; #ifdef WIN32 ResourceLoader::Init(hInstance); #endif InitialiseFonts(); DialogLook *look = new DialogLook(); look->Initialise(bold_font, normal_font, small_font, bold_font, bold_font); Layout::Initialize(320,240); SingleWindow main_window; main_window.set(_T("STATIC"), _T("RunProgressWindow"), PixelRect{0, 0, 640, 480}); main_window.show(); TestJob job; JobDialog(main_window, *look, _T("RunJobDialog"), job); delete look; DeinitialiseFonts(); return 0; }
static int Main() { dialog_settings.SetDefaults(); ScreenGlobalInit screen_init; Layout::Initialize({600, 800}); InitialiseFonts(); DialogLook dialog_look; dialog_look.Initialise(); TopWindowStyle main_style; main_style.Resizable(); SingleWindow main_window; main_window.Create(_T("XCSoar/KoboMenu"), {600, 800}, main_style); main_window.Show(); global_dialog_look = &dialog_look; global_main_window = &main_window; int action = Main(main_window, dialog_look); main_window.Destroy(); DeinitialiseFonts(); return action; }
int main(int argc, char **argv) { /* enable FreeType anti-aliasing, because we don't use dithering in this program */ FreeType::mono = false; ScreenGlobalInit screen_init; Layout::Initialize({600, 800}); Font::Initialise(); Display::Rotate(DisplayOrientation::PORTRAIT); InitialiseFonts(); { TopCanvas screen; screen.Create(PixelSize(100, 100), true, false); Canvas canvas = screen.Lock(); if (canvas.IsDefined()) { /* all black first, to eliminate E-ink ghost images */ canvas.Clear(COLOR_BLACK); screen.Flip(); screen.Wait(); /* disable dithering, render with 16 shades of gray, to make the (static) display more pretty */ screen.SetEnableDither(false); /* draw the pictuer */ canvas.ClearWhite(); Draw(canvas); /* finish */ screen.Unlock(); screen.Flip(); screen.Wait(); } } /* now we can power off the Kobo; the picture remains on the screen */ if (DetectKoboModel() == KoboModel::GLO_HD) //The GloHD needs -f to not clear screen execl("/sbin/poweroff", "poweroff", "-f", nullptr); else execl("/sbin/poweroff", "poweroff", nullptr); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE LPWSTR lpCmdLine, #else LPSTR lpCmdLine2, #endif int nCmdShow) #endif { PixelRect screen_rc{0, 0, 640, 480}; ScreenGlobalInit screen_init; Layout::Initialize(screen_rc.right - screen_rc.left, screen_rc.bottom - screen_rc.top); InitialiseFonts(); DialogLook *dialog_look = new DialogLook(); dialog_look->Initialise(bold_font, normal_font, small_font, bold_font, bold_font); SingleWindow main_window; main_window.set(_T("STATIC"), _T("RunListControl"), screen_rc); main_window.show(); WndForm form(main_window, *dialog_look, main_window.get_client_rect(), _T("RunListControl")); ContainerWindow &client_area = form.GetClientAreaWindow(); WindowStyle style; style.TabStop(); WndListFrame list(client_area, *dialog_look, 2, 2, client_area.get_width() - 4, client_area.get_height() - 4, style, normal_font.GetHeight() + 4); list.SetPaintItemCallback(PaintItemCallback); list.SetLength(64); list.set_focus(); form.ShowModal(); delete dialog_look; DeinitialiseFonts(); return 0; }
void MainWindow::set(LPCTSTR text, int left, int top, unsigned width, unsigned height) { TopWindow::set(_T("XCSoarMain"), text, left, top, width, height); RECT rc; #ifdef WINDOWSPC rc.left = 0; rc.right = SCREENWIDTH; rc.top = 0; rc.bottom = SCREENHEIGHT; #else rc = get_client_rect(); #endif Layout::Initalize(rc.right - rc.left, rc.bottom - rc.top); StartupStore(TEXT("InfoBox geometry\n")); InfoBoxLayout::ScreenGeometry(rc); // color/pattern chart (must have infobox geometry before this) MapGfx.Initialise(XCSoarInterface::hInst, XCSoarInterface::SettingsMap()); StartupStore(TEXT("Create info boxes\n")); RECT rcsmall = InfoBoxManager::Create(rc); StartupStore(TEXT("Create button labels\n")); ButtonLabel::CreateButtonLabels(*this, rc); ButtonLabel::SetLabelText(0,TEXT("MODE")); StartupStore(TEXT("Initialise fonts\n")); InitialiseFonts(get_canvas(), rc); map.set(*this, rcsmall, rc); map.set_font(MapWindowFont); map.SetMapRect(rcsmall); vario = new GaugeVario(*this, map.GetMapRect()); flarm = new GaugeFLARM(*this); StartupStore(TEXT("Initialise message system\n")); popup.set(rc); }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE LPWSTR lpCmdLine, #else LPSTR lpCmdLine2, #endif int nCmdShow) #endif { ScreenGlobalInit screen_init; airspace_renderer_settings.SetDefaults(); #ifdef USE_GDI ResourceLoader::Init(hInstance); TestWindow::register_class(hInstance); #endif InitialiseFonts(); DialogLook *look = new DialogLook(); look->Initialise(bold_font, normal_font, small_font, bold_font, bold_font); TaskLook *task_look = new TaskLook(); task_look->Initialise(); AirspaceLook *airspace_look = new AirspaceLook(); airspace_look->Initialise(airspace_renderer_settings); TestWindow window(*task_look, *airspace_look); window.set(*look, PixelRect{0, 0, 480, 480}); window.Show(); window.event_loop(); delete airspace_look; delete task_look; delete look; DeinitialiseFonts(); return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, #ifdef _WIN32_WCE LPWSTR lpCmdLine, #else LPSTR lpCmdLine2, #endif int nCmdShow) #endif { #ifdef ENABLE_CMDLINE #ifdef WIN32 Args args(GetCommandLine(), USAGE); #else Args args(argc, argv, USAGE); #endif ParseCommandLine(args); args.ExpectEnd(); #endif #if defined(ENABLE_RESOURCE_LOADER) && defined(USE_GDI) ResourceLoader::Init(hInstance); #endif #ifdef ENABLE_SCREEN ScreenGlobalInit screen_init; Layout::Initialize(640, 480); InitialiseFonts(); #endif #ifdef ENABLE_DIALOG dialog_settings.SetDefaults(); #endif #ifdef ENABLE_LOOK look = new Look(); look->Initialise(normal_font, bold_font, small_font); { UISettings ui_settings; ui_settings.SetDefaults(); look->InitialiseConfigured(ui_settings, normal_font, bold_font, small_font, small_font, monospace_font, normal_font, small_font, #ifndef GNAV small_font, #endif small_font); } dialog_look = &look->dialog; #elif defined(ENABLE_DIALOG_LOOK) dialog_look = new DialogLook(); dialog_look->Initialise(bold_font, normal_font, small_font, bold_font, bold_font, bold_font); #endif #ifdef ENABLE_XML_DIALOG SetXMLDialogLook(*dialog_look); #endif #ifdef ENABLE_DATA_PATH InitialiseDataPath(); #endif #ifdef ENABLE_PROFILE Profile::SetFiles(_T("")); Profile::Load(); #endif #ifdef ENABLE_MAIN_WINDOW main_window.Create(_T("Test"), {640, 480}); main_window.Show(); #endif Main(); #ifdef ENABLE_MAIN_WINDOW main_window.Destroy(); #endif #ifdef ENABLE_DATA_PATH DeinitialiseDataPath(); #endif #ifdef ENABLE_LOOK delete look; #elif defined(ENABLE_DIALOG_LOOK) delete dialog_look; #endif #ifdef ENABLE_SCREEN DeinitialiseFonts(); #endif return 0; }
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine2, int nCmdShow) #endif { #if defined(ENABLE_CMDLINE) || defined(ENABLE_MAIN_WINDOW) #ifdef WIN32 Args args(GetCommandLine(), USAGE); #else Args args(argc, argv, USAGE); #endif #ifdef ENABLE_MAIN_WINDOW PixelSize window_size{640, 480}; const char *a = args.PeekNext(); if (a != nullptr && a[0] == '-' && IsDigitASCII(a[1])) { args.GetNext(); char *p; window_size.cx = ParseUnsigned(a + 1, &p); if (*p != 'x' && *p != 'X') args.UsageError(); a = p; window_size.cy = ParseUnsigned(a + 1, &p); if (*p != '\0') args.UsageError(); } #endif #ifdef ENABLE_CMDLINE ParseCommandLine(args); #endif args.ExpectEnd(); #endif #if defined(ENABLE_RESOURCE_LOADER) && defined(USE_GDI) ResourceLoader::Init(hInstance); #endif #ifdef ENABLE_SCREEN #ifndef ENABLE_MAIN_WINDOW constexpr PixelSize window_size{800, 600}; #endif ScreenGlobalInit screen_init; Layout::Initialize(window_size); InitialiseFonts(); #endif #ifdef ENABLE_DIALOG dialog_settings.SetDefaults(); #endif #ifdef ENABLE_LOOK look = new Look(); look->Initialise(normal_font); { UISettings ui_settings; ui_settings.SetDefaults(); look->InitialiseConfigured(ui_settings, normal_font, bold_font, 100); } dialog_look = &look->dialog; button_look = &dialog_look->button; #elif defined(ENABLE_DIALOG_LOOK) dialog_look = new DialogLook(); dialog_look->Initialise(); button_look = &dialog_look->button; #elif defined(ENABLE_BUTTON_LOOK) button_look = new ButtonLook(); button_look->Initialise(bold_font); #endif #ifdef ENABLE_DATA_PATH InitialiseDataPath(); #endif #ifdef ENABLE_PROFILE Profile::SetFiles(_T("")); Profile::Load(); #endif #ifdef ENABLE_MAIN_WINDOW main_window.Create(_T("Test"), window_size); main_window.Show(); #endif Main(); #ifdef ENABLE_MAIN_WINDOW main_window.Destroy(); #endif #ifdef ENABLE_DATA_PATH DeinitialiseDataPath(); #endif #ifdef ENABLE_LOOK delete look; #elif defined(ENABLE_DIALOG_LOOK) delete dialog_look; #elif defined(ENABLE_BUTTON_LOOK) delete button_look; #endif #ifdef ENABLE_SCREEN DeinitialiseFonts(); #endif return 0; }
// // Reinit screen upon resolution/orientation change detected // // Test is possible from VirtualKeys.cpp, activating the customkey at line 229 // In this case, enable a testbench development option. // void ReinitScreen(void) { static int oldSCREENWIDTH=0; static int oldSCREENHEIGHT=0; RECT WindowSize, rc; // This is needed to hide any menu currently on, as first thing. InputEvents::setMode(TEXT("default")); #if TESTBENCH StartupStore(_T("... ChangeScreen suspending Draw Thread\n")); #endif MapWindow::SuspendDrawingThread(); // MapWndProc will get a WM_SIZE // // Detect the current screen geometry // #if (WINDOWSPC>0) // For PC we assume that the desired resolution is in SCREENxx WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = SCREENWIDTH; WindowSize.bottom = SCREENHEIGHT; #else WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = GetSystemMetrics(SM_CXSCREEN); WindowSize.bottom = GetSystemMetrics(SM_CYSCREEN); #endif // // ----------- DEVELOPMENT TESTBENCH OPTIONS ------------- // #if 0 // Force a test resolution, for testing only! // Using always the same resolution will not work when asking for the same resolution again. // dont know why (yet)... WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = 480; WindowSize.bottom = 272; #endif #if 0 // Simulate changin one resolution to another static bool vhflip=true; if (vhflip) { WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = 480; WindowSize.bottom = 272; vhflip=false; } else { WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = 800; WindowSize.bottom = 480; vhflip=true;; } #endif #if 0 // Simulate Portrait<>Landscape flip/flop WindowSize.left = 0; WindowSize.top = 0; WindowSize.right = SCREENHEIGHT; WindowSize.bottom = SCREENWIDTH; #endif // // --------------------------------------------------------- // if (oldSCREENWIDTH!=WindowSize.right || oldSCREENHEIGHT!=WindowSize.bottom) { #if TESTBENCH StartupStore(_T(".... CHANGING RESOLUTION\n")); #endif #if (WINDOWSPC>0) SCREENWIDTH = WindowSize.right; SCREENHEIGHT= WindowSize.bottom; #endif oldSCREENWIDTH = WindowSize.right; oldSCREENHEIGHT= WindowSize.bottom; } else { // THIS DOES NOT STILL WORK! NO EFFECT. #if TESTBENCH StartupStore(_T(".... CHANGE RESOLUTION, SAME SIZE, WM_SIZE FORCED\n")); #endif #if (WINDOWSPC>0) SCREENWIDTH = WindowSize.right; SCREENHEIGHT= WindowSize.bottom; #endif SendMessage(hWndMapWindow, WM_SIZE, (WPARAM)SIZE_RESTORED, MAKELPARAM(0,0)); } #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; // We must consider the command bar size on PC window MoveWindow(hWndMainWindow, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom, TRUE); MoveWindow(hWndMapWindow, 0, 0, SCREENWIDTH, SCREENHEIGHT, FALSE); // also TRUE? #else // Still to be tested! MoveWindow(hWndMainWindow, WindowSize.left, WindowSize.top, WindowSize.right, WindowSize.bottom, TRUE); MoveWindow(hWndMapWindow, 0, 0, WindowSize.right, WindowSize.bottom, FALSE); #endif GetClientRect(hWndMainWindow, &rc); #if (WINDOWSPC>0) rc.left = 0; rc.right = SCREENWIDTH; rc.top = 0; rc.bottom = SCREENHEIGHT; #endif InitLKScreen(); LKSW_ReloadProfileBitmaps=true; LKObjects_Delete(); LKObjects_Create(); ButtonLabel::Destroy(); ButtonLabel::CreateButtonLabels(rc); extern void InitialiseFonts(RECT rc); InitialiseFonts(rc); InitLKFonts(); ButtonLabel::SetFont(MapWindowBoldFont); Message::Destroy(); Message::Initialize(rc); // creates window, sets fonts LockTerrainDataGraphics(); CloseTerrainRenderer(); UnlockTerrainDataGraphics(); Reset_Single_DoInits(MDI_DRAWLOOK8000); Reset_Single_DoInits(MDI_DRAWTRI); Reset_Single_DoInits(MDI_DRAWHSI); Reset_Single_DoInits(MDI_DRAWASPNEAREST); Reset_Single_DoInits(MDI_DRAWCOMMON); Reset_Single_DoInits(MDI_DRAWFLARMTRAFFIC); Reset_Single_DoInits(MDI_DRAWINFOPAGE); Reset_Single_DoInits(MDI_WRITEINFO); Reset_Single_DoInits(MDI_DRAWLOOK8000); Reset_Single_DoInits(MDI_DRAWMAPSPACE); Reset_Single_DoInits(MDI_DRAWNEAREST); Reset_Single_DoInits(MDI_DRAWTARGET); Reset_Single_DoInits(MDI_DRAWTHERMALHISTORY); Reset_Single_DoInits(MDI_DRAWTRAFFIC); Reset_Single_DoInits(MDI_DRAWVARIO); Reset_Single_DoInits(MDI_PROCESSVIRTUALKEY); Reset_Single_DoInits(MDI_ONPAINTLISTITEM); Reset_Single_DoInits(MDI_DRAWMAPSCALE); Reset_Single_DoInits(MDI_MAPWPLABELADD); Reset_Single_DoInits(MDI_CHECKLABELBLOCK); Reset_Single_DoInits(MDI_LKPROCESS); Reset_Single_DoInits(MDI_COMPASS); Reset_Single_DoInits(MDI_LOOKABLEND); Reset_Single_DoInits(MDI_MAPWPVECTORS); Reset_Single_DoInits(MDI_MAPASP); Reset_Single_DoInits(MDI_MAPRADAR); // doing nothing reallt Reset_Single_DoInits(MDI_FLARMRADAR); Reset_Single_DoInits(MDI_MAPWNDPROC); Reset_Single_DoInits(MDI_DRAWBOTTOMBAR); Reset_Single_DoInits(MDI_DRAWTASK); #if TESTBENCH StartupStore(_T("... ChangeScreen resuming Draw Thread\n")); #endif MapWindow::ResumeDrawingThread(); ShowWindow(hWndMainWindow, SW_SHOWNORMAL); BringWindowToTop(hWndMainWindow); return; }
// // 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; }