コード例 #1
0
ファイル: kcompletionbox.cpp プロジェクト: vasi/kdelibs
void KCompletionBox::sizeAndPosition()
{
    int currentGeom = height();
    QPoint currentPos = pos();
    QRect geom = calculateGeometry();
    resize( geom.size() );

    int x = currentPos.x(), y = currentPos.y();
    if ( d->m_parent ) {
      if ( !isVisible() ) {
        QPoint orig = globalPositionHint();
        QRect screenSize = KGlobalSettings::desktopGeometry(orig);

        x = orig.x() + geom.x();
        y = orig.y() + geom.y();

        if ( x + width() > screenSize.right() )
            x = screenSize.right() - width();
        if (y + height() > screenSize.bottom() ) {
            y = y - height() - d->m_parent->height();
            d->upwardBox = true;
        }
      }
      else {
        // Are we above our parent? If so we must keep bottom edge anchored.
        if (d->upwardBox)
          y += (currentGeom-height());
      }
      move( x, y);
    }
}
コード例 #2
0
void WeatherWallpaper::paint(QPainter * painter, const QRectF & exposedRect)
{
    // Check if geometry changed
    if (m_size != boundingRect().size().toSize()) {
        calculateGeometry();
        if (!m_size.isEmpty() && !m_img.isEmpty()) { // We have previous image
            renderWallpaper();
            return;
        }
    }

    if (m_pixmap.isNull()) {
        painter->fillRect(exposedRect, QBrush(m_color));
        return;
    }

    if (painter->worldMatrix() == QMatrix()) {
        // draw the background untransformed when possible;(saves lots of per-pixel-math)
        painter->resetTransform();
    }

    // blit the background (saves all the per-pixel-products that blending does)
    painter->setCompositionMode(QPainter::CompositionMode_Source);

    // for pixmaps we draw only the exposed part (untransformed since the
    // bitmapBackground already has the size of the viewport)
    painter->drawPixmap(exposedRect, m_pixmap, exposedRect.translated(-boundingRect().topLeft()));

    if (!m_oldFadedPixmap.isNull()) {
        // Put old faded image on top.
        painter->setCompositionMode(QPainter::CompositionMode_SourceAtop);
        painter->drawPixmap(exposedRect, m_oldFadedPixmap,
                            exposedRect.translated(-boundingRect().topLeft()));
    }
}
コード例 #3
0
TEST_F(WebPluginContainerTest, ClippedRectsForIframedElement)
{
    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_container.html"));
    URLTestHelpers::registerMockedURLFromBaseURL(WebString::fromUTF8(m_baseURL.c_str()), WebString::fromUTF8("plugin_containing_page.html"));

    TestPluginWebFrameClient pluginWebFrameClient; // Must outlive webViewHelper.
    FrameTestHelpers::WebViewHelper webViewHelper;
    WebView* webView = webViewHelper.initializeAndLoad(m_baseURL + "plugin_containing_page.html", true, &pluginWebFrameClient);
    ASSERT(webView);
    webView->settings()->setPluginsEnabled(true);
    webView->resize(WebSize(300, 300));
    webView->updateAllLifecyclePhases();
    runPendingTasks();

    WebElement pluginElement = webView->mainFrame()->firstChild()->document().getElementById("translated-plugin");
    RefPtrWillBeRawPtr<WebPluginContainerImpl> pluginContainerImpl = toWebPluginContainerImpl(pluginElement.pluginContainer());

    ASSERT(pluginContainerImpl.get());
    pluginContainerImpl->setFrameRect(IntRect(0, 0, 300, 300));

    IntRect windowRect, clipRect, unobscuredRect;
    Vector<IntRect> cutOutRects;
    calculateGeometry(pluginContainerImpl.get(), windowRect, clipRect, unobscuredRect, cutOutRects);
    EXPECT_RECT_EQ(IntRect(10, 210, 300, 300), windowRect);
    EXPECT_RECT_EQ(IntRect(0, 0, 240, 90), clipRect);
    EXPECT_RECT_EQ(IntRect(0, 0, 240, 160), unobscuredRect);

    // Cause the plugin's frame to be detached.
    webViewHelper.reset();
}
コード例 #4
0
void WebPluginContainerImpl::reportGeometry()
{
    if (!parent())
        return;

    IntRect windowRect, clipRect;
    Vector<IntRect> cutOutRects;
    calculateGeometry(frameRect(), windowRect, clipRect, cutOutRects);

    m_webPlugin->updateGeometry(windowRect, clipRect, cutOutRects, isVisible());
}
コード例 #5
0
ファイル: image.cpp プロジェクト: mgottschlag/kwin-tiling
void Image::init(const KConfigGroup &config)
{
    m_timer.stop();

    if (renderingMode().name().isEmpty()) {
        m_mode = "SingleImage";
    } else {
        m_mode = renderingMode().name();
    }

    calculateGeometry();

    m_delay = config.readEntry("slideTimer", 10);
    setResizeMethodHint((ResizeMethod)config.readEntry("wallpaperposition", (int)ScaledResize));
    m_wallpaper = config.readEntry("wallpaper", QString());
    if (m_wallpaper.isEmpty()) {
        useSingleImageDefaults();
    }

    m_color = config.readEntry("wallpapercolor", QColor(Qt::black));
    m_usersWallpapers = config.readEntry("userswallpapers", QStringList());
    m_dirs = config.readEntry("slidepaths", QStringList());

    if (m_dirs.isEmpty()) {
        m_dirs << KStandardDirs::installPath("wallpaper");
    }

    setUsingRenderingCache(m_mode == "SingleImage");

    if (m_mode == "SingleImage") {
        setSingleImage();
        setContextualActions(QList<QAction*>());
    } else {
        m_nextWallpaperAction = new QAction(KIcon("user-desktop"), i18n("Next Wallpaper Image"), this);
        connect(m_nextWallpaperAction, SIGNAL(triggered(bool)), this, SLOT(nextSlide()));
        m_openImageAction = new QAction(KIcon("document-open"), i18n("Open Wallpaper Image"), this);
        connect(m_openImageAction, SIGNAL(triggered(bool)), this, SLOT(openSlide()));
        QTimer::singleShot(200, this, SLOT(startSlideshow()));
        QList<QAction*> actions;
        actions.push_back(m_nextWallpaperAction);
        actions.push_back(m_openImageAction);
        setContextualActions(actions);
        updateWallpaperActions();
    }

    m_animation = new QPropertyAnimation(this, "fadeValue");
    m_animation->setProperty("easingCurve", QEasingCurve::InQuad);
    m_animation->setProperty("duration", 500);
    m_animation->setProperty("startValue", 0.0);
    m_animation->setProperty("endValue", 1.0);
}
コード例 #6
0
ファイル: gboggle.cpp プロジェクト: mtle/OnlineCScources
/*
 * Function: drawBoard
 * -------------------
 * Exported function to draw a new board.  Sets up named colors, draws the
 * yellow border, draws the empty cubes, the labels on the scoreboard, and
 * resets scores to zero and words lists to empty.
 */
void drawBoard(int numRows, int numCols) {
   if (numRows < 0 || numRows > MAX_DIMENSION
                   || numCols < 0 || numCols > MAX_DIMENSION) {
      error("drawBoard called with invalid dimensions.");
   }
   gwp->clear();
   gwp->setWindowTitle("Welcome to Boggle!");
   calculateGeometry(numRows, numCols);

   // Draws a filled rect underneath cubes in the oh-so-familiar yellow color
   fillBox(gState.board.x, gState.board.y, gState.board.w, gState.board.h,
           BOARD_COLOR);
   drawEmptyCubes();
   drawPlayerLabel(HUMAN, "Me");
   drawPlayerLabel(COMPUTER, "Computer");
}
コード例 #7
0
void WeatherWallpaper::init(const KConfigGroup & config)
{
    // Connect to weather engine.
    weatherEngine = dataEngine(QLatin1String( "weather" ));

    // Set custom weather options
    m_source = config.readEntry("source");
    m_weatherUpdateTime = config.readEntry("updateWeather", 30);

    m_color = config.readEntry("wallpapercolor", QColor(56, 111, 150));
    m_dir = KStandardDirs::installPath("wallpaper");
    m_usersWallpapers = config.readEntry("userswallpapers", QStringList());
    m_resizeMethod = (ResizeMethod)config.readEntry("wallpaperposition", (int)ScaledResize);

    m_animation = new QPropertyAnimation(this, "fadeValue");
    m_animation->setProperty("easingCurve", QEasingCurve::InQuad);
    m_animation->setProperty("duration", 1000);
    m_animation->setProperty("startValue", 0.0);
    m_animation->setProperty("endValue", 1.0);

    m_weatherMap[QLatin1String( "weather-clear" )] = config.readEntry("clearPaper", QString(m_dir + QLatin1String( "Fields_of_Peace/" )));
    m_weatherMap[QLatin1String( "weather-few-clouds" )] = config.readEntry("partlyCloudyPaper", QString(m_dir + QLatin1String( "Evening/" )));
    m_weatherMap[QLatin1String( "weather-clouds" )] = config.readEntry("cloudyPaper", QString(m_dir + QLatin1String( "Colorado_Farm/" )));
    m_weatherMap[QLatin1String( "weather-many-clouds" )] = config.readEntry("manyCloudsPaper", QString(m_dir + QLatin1String( "Beach_Reflecting_Clouds/" )));
    m_weatherMap[QLatin1String( "weather-showers" )] = config.readEntry("showersPaper", QString(m_dir + QLatin1String( "There_is_Rain_on_the_Table/" )));
    m_weatherMap[QLatin1String( "weather-showers-scattered" )] = config.readEntry("showersScatteredPaper", QString(m_dir + QLatin1String( "There_is_Rain_on_the_Table/" )));
    m_weatherMap[QLatin1String( "weather-rain" )] = config.readEntry("rainPaper", QString(m_dir + QLatin1String( "There_is_Rain_on_the_Table/" )));
    m_weatherMap[QLatin1String( "weather-mist" )] = config.readEntry("mistPaper", QString(m_dir + QLatin1String( "Fresh_Morning/" )));
    m_weatherMap[QLatin1String( "weather-storm" )] = config.readEntry("stormPaper", QString(m_dir + QLatin1String( "Storm/" )));
    m_weatherMap[QLatin1String( "weather-scattered-storms" )] = m_weatherMap[QLatin1String( "weather-storm" )];
    m_weatherMap[QLatin1String( "weather-hail" )] = config.readEntry("hailPaper", QString(m_dir + QLatin1String( "Storm/" )));
    m_weatherMap[QLatin1String( "weather-snow" )] = config.readEntry("snowPaper", QString(m_dir + QLatin1String( "Winter_Track/" )));
    m_weatherMap[QLatin1String( "weather-snow-scattered" )] = config.readEntry("snowScatteredPaper", QString(m_dir + QLatin1String( "Winter_Track/" )));
    m_weatherMap[QLatin1String( "weather-few-clouds-night" )] = config.readEntry("partlyCloudyNightPaper", QString(m_dir + QLatin1String( "JK_Bridge_at_Night/" )));
    m_weatherMap[QLatin1String( "weather-clouds-night" )] = config.readEntry("cloudyNightPaper", QString(m_dir + QLatin1String( "JK_Bridge_at_Night/" )));
    m_weatherMap[QLatin1String( "weather-clear-night" )] = config.readEntry("clearNightPaper", QString(m_dir + QLatin1String( "City_at_Night/" )));
    m_weatherMap[QLatin1String( "weather-freezing-rain" )] = config.readEntry("freezingRainPaper", QString(m_dir + QLatin1String( "Icy_Tree/" )));
    m_weatherMap[QLatin1String( "weather-snow-rain" )] = config.readEntry("snowRainPaper", QString(m_dir + QLatin1String( "Icy_Tree/" )));

    calculateGeometry();
    connectWeatherSource();
}
コード例 #8
0
ファイル: bogglegui.cpp プロジェクト: jacksonsierra/Boggle
    void initialize(int rowCount, int columnCount) {
        if (rowCount < 0 || rowCount > MAX_DIMENSION
                        || columnCount < 0 || columnCount > MAX_DIMENSION) {
            error("init called with invalid dimensions.");
        }

        if (!isInitialized()) {
            gwp = new GWindow(BOGGLE_WINDOW_WIDTH, BOGGLE_WINDOW_HEIGHT);
            gwp->setWindowTitle("CS 106X Boggle");
            gwp->setExitOnClose(true);
            gState.rowCount = rowCount;
            gState.columnCount = columnCount;
            letterCubes.resize(rowCount, columnCount);
            calculateGeometry(rowCount, columnCount);

            gState.wordCount[HUMAN] = 0;
            gState.wordCount[COMPUTER] = 0;

            // draw the overall background
            gwp->setColor(BOARD_COLOR);
            gwp->fillRect(gState.board.x, gState.board.y, gState.board.w, gState.board.h);

            // draw the labels of player names and score labels
            setupPlayerLabels(HUMAN, "Human");
            setupPlayerLabels(COMPUTER, "Computer");

            // set up status label
            statusLabel = new GLabel("");
            statusLabel->setFont(SCORE_FONT + "-" + integerToString(SCORE_FONT_SIZE));
            statusLabel->setColor(LABEL_COLOR);
            gwp->add(statusLabel, gState.statusBox.x, gState.statusBox.y);

            // draw the 4x4 grid of Boggle letter cubes
            setupLetterCubes();
        }

        reset();
    }
コード例 #9
0
ファイル: kcompletionbox.cpp プロジェクト: vasi/kdelibs
QSize KCompletionBox::sizeHint() const
{
    return calculateGeometry().size();
}
コード例 #10
0
void QsCompletionBox::popup()
{
    KCompletionBox::popup();
    resize(calculateGeometry().size());
}