/* return the string key to be used by default the application */
QString QGuiPlatformPlugin::styleName()
{
#if defined(Q_WS_WIN) && defined(Q_WS_WINCE)
    if (qt_wince_is_smartphone() || qt_wince_is_pocket_pc())
        return QLatin1String("WindowsMobile");
    else
        return QLatin1String("WindowsCE");
#elif defined(Q_WS_WIN)
    if ((QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA
        && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
        return QLatin1String("WindowsVista");
    else if ((QSysInfo::WindowsVersion >= QSysInfo::WV_XP
        && QSysInfo::WindowsVersion < QSysInfo::WV_NT_based))
        return QLatin1String("WindowsXP");
    else
        return QLatin1String("Windows");                // default styles for Windows
#elif defined(Q_WS_X11) && defined(Q_OS_SOLARIS)
    return QLatin1String("CDE");                        // default style for X11 on Solaris
#elif defined(Q_WS_S60)
    return QLatin1String("S60");                        // default style for Symbian with S60
#elif defined(Q_OS_SYMBIAN)
    return QLatin1String("Windows");                    // default style for Symbian without S60
#elif defined(Q_WS_X11) && defined(Q_OS_IRIX)
    return QLatin1String("SGI");                        // default style for X11 on IRIX
#elif defined(Q_WS_QWS)
    return QLatin1String("Plastique");                  // default style for X11 and small devices
#elif defined(Q_WS_MAC)
    return QLatin1String("Macintosh");              // default style for all Mac's
#elif defined(Q_WS_X11)
    QString stylename;
    switch(X11->desktopEnvironment) {
    case DE_KDE:
        stylename = QKde::kdeStyle();
        break;
    case DE_GNOME: {
        QStringList availableStyles = QStyleFactory::keys();
        // Set QGtkStyle for GNOME if available
        QString gtkStyleKey = QString::fromLatin1("GTK+");
        if (availableStyles.contains(gtkStyleKey)) {
            stylename = gtkStyleKey;
            break;
        }
        if (X11->use_xrender)
            stylename = QLatin1String("cleanlooks");
        else
            stylename = QLatin1String("windows");
        break;
    }
    case DE_CDE:
        stylename = QLatin1String("cde");
        break;
    default:
        // Don't do anything
        break;
    }
    return stylename;
#endif
}
Beispiel #2
0
bool qt_wince_is_high_dpi() {
    if (!qt_wince_is_pocket_pc())
        return false;
    HDC deviceContext = GetDC(0);
    int dpi = GetDeviceCaps(deviceContext, LOGPIXELSX);
    ReleaseDC(0, deviceContext);
    if ((dpi < 1000) && (dpi > 0))
        return dpi > 96;
    else
        return false;
}
Beispiel #3
0
void QMenuBarPrivate::wceCreateMenuBar(QWidget *parent)
{
    Q_Q(QMenuBar);
    wce_menubar = new QWceMenuBarPrivate(this);

    wce_menubar->parentWindowHandle = parent ? parent->winId() : q->winId();
    wce_menubar->leftButtonAction = defaultAction;

    wce_menubar->menubarHandle = qt_wce_create_menubar(wce_menubar->parentWindowHandle, (HINSTANCE)qWinAppInst(), 0, SHCMBF_EMPTYBAR);
    Q_ASSERT_X(wce_menubar->menubarHandle, "wceCreateMenuBar", "cannot create empty menu bar");
    DrawMenuBar(wce_menubar->menubarHandle);
    nativeMenuBars.append(q);
    wceClassicMenu = (!qt_wince_is_smartphone() && !qt_wince_is_pocket_pc());
}
Beispiel #4
0
QT_BEGIN_NAMESPACE

QPixmap QPixmap::grabWindow(WId winId, int x, int y, int w, int h )
{
    RECT r;
    GetClientRect(winId, &r);

    if (w < 0) w = r.right - r.left;
    if (h < 0) h = r.bottom - r.top;

#ifdef Q_WS_WINCE_WM
    if (qt_wince_is_pocket_pc()) {
        QWidget *widget = QWidget::find(winId);
        if (qobject_cast<QDesktopWidget *>(widget)) {
            RECT rect = {0,0,0,0};
            AdjustWindowRectEx(&rect, WS_BORDER | WS_CAPTION, FALSE, 0);
            int magicNumber = qt_wince_is_high_dpi() ? 4 : 2;
            y += rect.top - magicNumber;
        }
    }
#endif

    // Create and setup bitmap
    HDC display_dc = GetDC(0);
    HDC bitmap_dc = CreateCompatibleDC(display_dc);
    HBITMAP bitmap = CreateCompatibleBitmap(display_dc, w, h);
    HGDIOBJ null_bitmap = SelectObject(bitmap_dc, bitmap);

    // copy data
    HDC window_dc = GetDC(winId);
    BitBlt(bitmap_dc, 0, 0, w, h, window_dc, x, y, SRCCOPY
#ifndef Q_WS_WINCE
                                    | CAPTUREBLT
#endif
            );

    // clean up all but bitmap
    ReleaseDC(winId, window_dc);
    SelectObject(bitmap_dc, null_bitmap);
    DeleteDC(bitmap_dc);

    QPixmap pixmap = QPixmap::fromWinHBITMAP(bitmap);

    DeleteObject(bitmap);
    ReleaseDC(0, display_dc);

    return pixmap;
}
bool qt_wince_is_mobile() {
    return (qt_wince_is_smartphone() || qt_wince_is_pocket_pc());
}