float X11Display::queryPPMM() { ::Display * pDisplay = XOpenDisplay(0); float ppmm = getScreenResolution().x/float(DisplayWidthMM(pDisplay, 0)); XCloseDisplay(pDisplay); return ppmm; }
/* * Main function */ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR cmdLine, int showCmd) { // Save handle to application instance. ghAppInst = hInstance; // get screen size int windowWidth = 640; int windowHeight = 480; int screenWidth = 0; int screenHeight = 0; getScreenResolution(screenWidth, screenHeight); // debug output char msgBuff[255]; sprintf_s(msgBuff, 255, "screen: %d x %d \n", screenWidth, screenHeight ); OutputDebugString(msgBuff); // setup window properties with WNDCLASS structure WNDCLASS wnd1 = setupWindow1(); WNDCLASS wnd2 = setupWindow2(); // register window with Windows RegisterClass(&wnd1); // RegisterClass takes a pointer as parameter RegisterClass(&wnd2); // create the window ghMainWnd = ::CreateWindow(wnd1.lpszClassName, "MyWindow", WS_OVERLAPPEDWINDOW | WS_HSCROLL | WS_VSCROLL, (screenWidth/2), 0, windowWidth, windowHeight, 0, 0, ghAppInst, 0); HWND hWindow2 = ::CreateWindow(wnd2.lpszClassName, "MyWindow2", WS_OVERLAPPEDWINDOW, 0, 0, windowWidth, windowHeight, 0, 0, ghAppInst, 0); if(ghMainWnd == 0 || hWindow2 == 0) { ::MessageBox(0, "Couldn't instantiate window!", "ERROR", MB_OK); return false; } // show and update the window ShowWindow(ghMainWnd, SW_SHOW); UpdateWindow(ghMainWnd); ShowWindow(hWindow2, SW_SHOW); UpdateWindow(hWindow2); // Message Loop (i.e. waiting for messages) MSG msg; ZeroMemory(&msg, sizeof(MSG)); // clears out all bits of a variable to zero while(GetMessage(&msg, 0, 0, 0)) { TranslateMessage(&msg); // Keycode to Character-Code translateions DispatchMessage(&msg); // forwards message to window procedure (callback) } // return exit code back to OS return (int)msg.wParam; }
int ScreenOutput::setAntiAliasingFactor(int newAntiAliasingFactor) { if(newAntiAliasingFactor > 0) { return resize(getScreenResolution(), newAntiAliasingFactor); } return 0; }
ScreenData::ScreenData(QObject *parent) : QObject(parent) { getScreenResolution(); CalculateRatio(); QScreen *mScreen = QApplication::screens().at(0); connect(mScreen, SIGNAL(orientationChanged(Qt::ScreenOrientation)), this, SLOT(Orientation(Qt::ScreenOrientation))); }