예제 #1
0
void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, ulong timestamp, const QPointF &local, const QPointF &global, Qt::MouseButtons b, Qt::KeyboardModifiers mods)
{
    if (mWindowDecoration->handleMouse(inputDevice,local,global,b,mods))
        return;

    QMargins marg = frameMargins();
    QRect windowRect(0 + marg.left(),
                     0 + marg.top(),
                     geometry().size().width() - marg.right(),
                     geometry().size().height() - marg.bottom());
    if (windowRect.contains(local.toPoint()) || mMousePressedInContentArea != Qt::NoButton) {
        QPointF localTranslated = local;
        QPointF globalTranslated = global;
        localTranslated.setX(localTranslated.x() - marg.left());
        localTranslated.setY(localTranslated.y() - marg.top());
        globalTranslated.setX(globalTranslated.x() - marg.left());
        globalTranslated.setY(globalTranslated.y() - marg.top());
        if (!mMouseEventsInContentArea) {
            restoreMouseCursor(inputDevice);
            QWindowSystemInterface::handleEnterEvent(window());
        }
        QWindowSystemInterface::handleMouseEvent(window(), timestamp, localTranslated, globalTranslated, b, mods);
        mMouseEventsInContentArea = true;
        mMousePressedInContentArea = b;
    } else {
        if (mMouseEventsInContentArea) {
            QWindowSystemInterface::handleLeaveEvent(window());
            mMouseEventsInContentArea = false;
        }
        mWindowDecoration->handleMouse(inputDevice,local,global,b,mods);
    }
}
예제 #2
0
파일: clock.cpp 프로젝트: mmanley/Antares
THelloApplication::THelloApplication()
		  :BApplication(kAppSignature)
{
	BRect windowRect(100, 100, 182, 182);
	myWindow = new TClockWindow(windowRect, "Clock");
	myWindow->Show();
}
예제 #3
0
Page* ChromeClientAndroid::createWindow(Frame* frame, const FrameLoadRequest&,
        const WindowFeatures& features, const NavigationAction&)
{
    ASSERT(frame);
#ifdef ANDROID_MULTIPLE_WINDOWS
    if (frame->settings() && !(frame->settings()->supportMultipleWindows()))
        // If the client doesn't support multiple windows, just return the current page
        return frame->page();
#endif

    FloatRect window = windowRect();
    bool dialog = features.dialog || !features.resizable
            || (features.heightSet && features.height < window.height()
                    && features.widthSet && features.width < window.width())
            || (!features.menuBarVisible && !features.statusBarVisible
                    && !features.toolBarVisible && !features.locationBarVisible
                    && !features.scrollbarsVisible);
    // fullscreen definitely means no dialog
    if (features.fullscreen)
        dialog = false;
    WebCore::Frame* newFrame = m_webFrame->createWindow(dialog,
            ScriptController::processingUserGesture());
    if (newFrame) {
        WebCore::Page* page = newFrame->page();
        page->setGroupName(frame->page()->groupName());
        return page;
    }
    return NULL;
}
예제 #4
0
FloatRect ChromeClientImpl::pageRect()
{
    // We hide the details of the window's border thickness from the web page by
    // simple re-using the window position here.  So, from the point-of-view of
    // the web page, the window has no border.
    return windowRect();
}
예제 #5
0
void TwWindow::setWindowRect( const TwRect<int>& rc )
{
    if (windowRect() != rc)
    {
        m_windowRect = rc;
        m_nativeWindow->setWindowRect(rc);
    }
}
예제 #6
0
bool A2DDevice::Create( HWND window, bool windowed, CSize size, UINT refreshRate )
{
	if (!IsWindow(window))
		return false;

	if (size.cx <= 0 || size.cy <= 0)
	{
		if (windowed)
		{
			CRect windowRect;
			if (!GetClientRect(window, windowRect))
				return false;
			size = windowRect.Size();
		}
		else
			return false;
	}
	else if (window) 
	{
		CRect windowRect(CPoint(0, 0), size);
		DWORD windowStyle = GetWindowLongW(window, GWL_STYLE);
		BOOL windowHasMenu = (GetMenu(window) != nullptr);
		DWORD windowExStyle = GetWindowLongW(window, GWL_EXSTYLE);
		if (!AdjustWindowRectEx(windowRect, windowStyle, windowHasMenu, windowExStyle))
			return false;
		SetWindowPos(window, nullptr, 0, 0, windowRect.Width(), windowRect.Height(), SWP_NOMOVE | SWP_NOZORDER);
	}
	
	CComPtr<IDirect3D9> d3d = Direct3DCreate9(D3D_SDK_VERSION);
	if (d3d == nullptr)
		return false;

	D3DPRESENT_PARAMETERS d3dParams;
	ZeroMemory(&d3dParams, sizeof(d3dParams));
	d3dParams.BackBufferWidth = size.cx;
	d3dParams.BackBufferHeight = size.cy;
	d3dParams.BackBufferFormat = D3DFMT_X8R8G8B8;
	d3dParams.BackBufferCount = 1;
	d3dParams.MultiSampleType = D3DMULTISAMPLE_NONE;
	d3dParams.SwapEffect = D3DSWAPEFFECT_COPY;
	d3dParams.hDeviceWindow = window;
	d3dParams.Windowed = windowed;
	d3dParams.EnableAutoDepthStencil = FALSE;
	d3dParams.FullScreen_RefreshRateInHz = windowed ? 0 : refreshRate;
	d3dParams.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;

	CComPtr<IDirect3DDevice9> d3dDevice;
	if (d3d->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, nullptr, D3DCREATE_MULTITHREADED | D3DCREATE_SOFTWARE_VERTEXPROCESSING, 
		&d3dParams, &d3dDevice) != S_OK)
		return false;

	m_d3d = d3d;
	m_d3dParams = d3dParams;
	m_d3dDevice = d3dDevice;
	return true;
}
예제 #7
0
      void
      ImageSceneState::drawOverlay(QPainter* painter)
      {
	QRectF rect = m_imageScene.sceneRect();
	QString name;

	if (isPicking()) {
	  if (getResource())
	    name = QString::fromStdString(getResource()->getName());
	}
	else {
	  name = m_imageScene.getWidget().getName();
	  if (getResource() && !getResource()->getName().empty())
	    name += " (" + QString::fromStdString(getResource()->getName()) + ")";
	}

	int textHeight = painter->fontMetrics().height();
	painter->setPen(Qt::black);
	// scale the textHeight since it seems (visual check) that the font metrics
	// return 1.5 the actual printed height
	painter->drawText(QPointF(nameBorderInPercent*rect.width(),
				  nameBorderInPercent*rect.height() + 2/3.0 * textHeight),
			  name);

	auto res = getResource();
	if (res) {
	  float width  = getWidth();
	  float height = getHeight();

	  painter->drawLine(QPointF((1 - 0.015) * width, 0.12 * height),
			    QPointF((1 - 0.045) * width, 0.12 * height));
	  painter->drawLine(QPointF((1 - 0.015) * width, 0.88 * height),
			    QPointF((1 - 0.045) * width, 0.88 * height));
	  painter->drawLine(QPointF((1 - 0.03) * width, 0.12 * height),
			    QPointF((1 - 0.03) * width, 0.88 * height));

	  static const float epsilon = 0.0025f;

	  painter->setPen(Qt::white);
	  float ww = getViewWindow()->getWidth();
	  float wl = getViewWindow()->getLevel();

	  float minHeight = (0.12f + (0.76f-epsilon) * (wl + ww/2.0f)) * height;
	  float maxHeight = (0.12f + (0.76f-epsilon) * (wl - ww/2.0f)) * height;
	  QLinearGradient gradient(QPointF(0, minHeight), QPointF(0, maxHeight));
	  static const QColor gradColTop(0, 0, 0);
	  static const QColor gradColBott(255, 255, 255);
	  gradient.setColorAt(0, gradColTop);
	  gradient.setColorAt(1, gradColBott);
	  QRectF windowRect((1 - 0.04) * width, minHeight, 0.02 * width, maxHeight-minHeight);
	  painter->fillRect(windowRect, gradient);
	}
      }
예제 #8
0
void CMainWindow::LoadWindowRect()
{
	Framework::Win32::CRect windowRect(0, 0, 0, 0);
	windowRect.SetLeft(CAppConfig::GetInstance().GetPreferenceInteger(PREF_MAINWINDOW_RECT_LEFT));
	windowRect.SetTop(CAppConfig::GetInstance().GetPreferenceInteger(PREF_MAINWINDOW_RECT_TOP));
	windowRect.SetRight(CAppConfig::GetInstance().GetPreferenceInteger(PREF_MAINWINDOW_RECT_RIGHT));
	windowRect.SetBottom(CAppConfig::GetInstance().GetPreferenceInteger(PREF_MAINWINDOW_RECT_BOTTOM));
	bool maximized = CAppConfig::GetInstance().GetPreferenceBoolean(PREF_MAINWINDOW_MAXIMIZED);
	if(windowRect.Width() != 0 && windowRect.Height() != 0)
	{
		SetSizePosition(windowRect);
	}
	Show(maximized ? SW_SHOWMAXIMIZED : SW_SHOW);
}
void NassiDiagramWindow::PaintBackground(wxDC &dc)
{
    wxColour backgroundColour = GetBackgroundColour();
    if ( !backgroundColour.Ok())
        backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE);

    dc.SetBrush(wxBrush(backgroundColour));
    dc.SetPen(wxPen(backgroundColour, 1));
    wxRect windowRect(wxPoint(0,0), GetClientSize());
    CalcUnscrolledPosition(windowRect.x, windowRect.y, &windowRect.x, &windowRect.y);
    dc.DrawRectangle(windowRect);
    dc.SetBrush(wxNullBrush);
    dc.SetPen(wxNullPen);
}
예제 #10
0
void MouseSpawner::spawn()
{

	if (spawnTimer.getElapsedTime().asSeconds() >= spawnInterval())
	{
	    spawnTimer.restart();

		if (active && spawnedMice.size() < maximumSpawnedMice())
		{
			std::unique_ptr<Mouse> mouse = std::make_unique<Mouse>(nextId, m_mouseTexture);

			sf::FloatRect windowRect(0, 0, static_cast<float>(window->getSize().x-m_mouseTexture.getSize().x), static_cast<float>(window->getSize().y - m_mouseTexture.getSize().y));
			bool success;
			do
			{
				success = true;

				//get random spawn position
				auto xPosition = xDistribution(randomEngine);
				auto yPosition = yDistribution(randomEngine);
				mouse->setBodyPosition(static_cast<float>(xPosition), static_cast<float>(yPosition));

//                if (m_snake->checkForCollision(mouse->getBodyRect())) //check it doesn't collide with the snake
//                {
//                    success = false;
//                }
//                else if (!windowRect.contains({ mouse->getBodyRect().left,mouse->getBodyRect().top }))    // check it's in the window
//                {
//                    success = false;
//                }
//                else
//                {
//                    //check the rest of the mice for collisions
//                    for (auto& otherMouse : spawnedMice)
//                    {
//                        if (mouse->getBodyRect().intersects(otherMouse.second->getBodyRect()))
//                        {
//                            success = false;
//                            break;
//                        }
//                    }
//                }
			} while (!success);
     
            spawnedMice.emplace(nextId, std::move(mouse));

            ++nextId;
	    }
	}
}
예제 #11
0
/// Paint the background
void InstanceCtrl::PaintBackground(wxDC& dc)
{
	wxColour backgroundColour = GetBackgroundColour();
	if (!backgroundColour.Ok())
		backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW);
		
	// Clear the background
	dc.SetBrush(wxBrush(backgroundColour));
	dc.SetPen(*wxTRANSPARENT_PEN);
	wxRect windowRect(wxPoint(0, 0), GetClientSize());
	
	// We need to shift the rectangle to take into account
	// scrolling. Converting device to logical coordinates.
	CalcUnscrolledPosition(windowRect.x, windowRect.y, & windowRect.x, & windowRect.y);
	dc.DrawRectangle(windowRect);
}
예제 #12
0
void QWaylandWindow::handleMouseEventWithDecoration(QWaylandInputDevice *inputDevice, const QWaylandPointerEvent &e)
{
    if (mMousePressedInContentArea == Qt::NoButton &&
        mWindowDecoration->handleMouse(inputDevice, e.local, e.global, e.buttons, e.modifiers)) {
        if (mMouseEventsInContentArea)
            QWindowSystemInterface::handleLeaveEvent(window());
        return;
    }

    QMargins marg = frameMargins();
    QRect windowRect(0 + marg.left(),
                     0 + marg.top(),
                     geometry().size().width() - marg.right(),
                     geometry().size().height() - marg.bottom());
    if (windowRect.contains(e.local.toPoint()) || mMousePressedInContentArea != Qt::NoButton) {
        QPointF localTranslated = e.local;
        QPointF globalTranslated = e.global;
        localTranslated.setX(localTranslated.x() - marg.left());
        localTranslated.setY(localTranslated.y() - marg.top());
        globalTranslated.setX(globalTranslated.x() - marg.left());
        globalTranslated.setY(globalTranslated.y() - marg.top());
        if (!mMouseEventsInContentArea) {
            restoreMouseCursor(inputDevice);
            QWindowSystemInterface::handleEnterEvent(window());
        }

        switch (e.type) {
            case QWaylandPointerEvent::Enter:
                QWindowSystemInterface::handleEnterEvent(window(), localTranslated, globalTranslated);
                break;
            case QWaylandPointerEvent::Motion:
                QWindowSystemInterface::handleMouseEvent(window(), e.timestamp, localTranslated, globalTranslated, e.buttons, e.modifiers);
                break;
            case QWaylandPointerEvent::Wheel:
                QWindowSystemInterface::handleWheelEvent(window(), e.timestamp, localTranslated, globalTranslated, e.pixelDelta, e.angleDelta);
                break;
        }

        mMouseEventsInContentArea = true;
        mMousePressedInContentArea = e.buttons;
    } else {
        if (mMouseEventsInContentArea) {
            QWindowSystemInterface::handleLeaveEvent(window());
            mMouseEventsInContentArea = false;
        }
    }
}
예제 #13
0
파일: mainwindow.cpp 프로젝트: maxxant/qt
void MainWindow::setupWidget()
{
    QRect screenRect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen());
    QRect windowRect(0, 0, 800, 600);
    if (screenRect.width() < 800)
        windowRect.setWidth(screenRect.width());
    if (screenRect.height() < 600)
        windowRect.setHeight(screenRect.height());
    windowRect.moveCenter(screenRect.center());
    this->setGeometry(windowRect);
    this->setMinimumSize(80, 60);
    setWindowTitle(tr("Qt Examples and Demos"));
    setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
    setFrameStyle(QFrame::NoFrame);
    this->setRenderingSystem();
    connect(&this->updateTimer, SIGNAL(timeout()), this, SLOT(tick()));
}
예제 #14
0
Window::Window()
{
    hide();

    controller = new Controller(Settings::getUserName());

    createActions();
    createTrayIcon();
    createMenus();
    createStatusBar();

    textLog = new QPlainTextEdit;
    textLog->appendPlainText(tr("Welcome") + ", " + Settings::getUserName() + "!");
    textLog->appendPlainText(tr("If it is not you, choose Main->Profile to introduce yourself."));
    textLog->appendPlainText("");
    textLog->setReadOnly(true);
    setCentralWidget(textLog);

    appIcon = new QIcon();
    appIcon->addFile(":/img/app.png", QSize(32, 32));
    appIcon->addFile(":/img/tray.png", QSize(16, 16));

    QRect screenRect = QApplication::desktop()->screenGeometry(QApplication::desktop()->primaryScreen());
    QRect windowRect(0, 0, 400, 300);

    if (screenRect.width() < 400) {
        windowRect.setWidth(screenRect.width());
    }
    if (screenRect.height() < 300) {
        windowRect.setHeight(screenRect.height());
    }
    windowRect.moveCenter(screenRect.center());

    setGeometry(windowRect);
    setFixedSize(400, 300);

    setWindowTitle(tr("QeyLogger Control Center"));
    setWindowIcon(*appIcon);

    show();
}
예제 #15
0
//
// ScreenForRect
//
// Returns the screen that contains the rectangle. If the rect overlaps
// multiple screens, it picks the screen with the greatest area of intersection.
//
// The coordinates are in desktop pixels.
//
NS_IMETHODIMP
nsScreenManagerGtk::ScreenForRect(int32_t aX, int32_t aY,
                                  int32_t aWidth, int32_t aHeight,
                                  nsIScreen **aOutScreen)
{
  nsresult rv;
  rv = EnsureInit();
  if (NS_FAILED(rv)) {
    NS_ERROR("nsScreenManagerGtk::EnsureInit() failed from ScreenForRect");
    return rv;
  }

  // which screen ( index from zero ) should we return?
  uint32_t which = 0;
  // Optimize for the common case.  If the number of screens is only
  // one then this will fall through with which == 0 and will get the
  // primary screen.
  if (mCachedScreenArray.Count() > 1) {
    // walk the list of screens and find the one that has the most
    // surface area.
    uint32_t area = 0;
    nsIntRect windowRect(aX, aY, aWidth, aHeight);
    for (int32_t i = 0, i_end = mCachedScreenArray.Count(); i < i_end; ++i) {
      int32_t  x, y, width, height;
      x = y = width = height = 0;
      mCachedScreenArray[i]->GetRect(&x, &y, &width, &height);
      // calculate the surface area
      nsIntRect screenRect(x, y, width, height);
      screenRect.IntersectRect(screenRect, windowRect);
      uint32_t tempArea = screenRect.width * screenRect.height;
      if (tempArea >= area) {
        which = i;
        area = tempArea;
      }
    }
  }
  *aOutScreen = mCachedScreenArray.SafeObjectAt(which);
  NS_IF_ADDREF(*aOutScreen);
  return NS_OK;

} // ScreenForRect
예제 #16
0
TwPoint<int> TwWindow::mapFromWindowToScreen( const TwPoint<int>& pt ) const
{
    return pt + windowRect().topLeft();
}
예제 #17
0
TwPoint<int> TwWindow::mapFromScreenToWindow( const TwPoint<int>& pt ) const
{
    return pt - windowRect().topLeft();
}
예제 #18
0
TwRect<int> TwWindow::localRect() const
{
    return windowRect().movedTo(0,0);
}
예제 #19
0
void TwWindow::setHeight( int h )
{
    setWindowRect(windowRect().setHeight(h));
}
예제 #20
0
int TwWindow::height() const
{
    return windowRect().height();
}
예제 #21
0
int TwWindow::width() const
{
    return windowRect().width();
}
예제 #22
0
TwSize<int> TwWindow::size() const
{
    return windowRect().size();
}
예제 #23
0
TwPoint<int> TwWindow::pos() const
{
    return windowRect().topLeft();
}
예제 #24
0
void TrackViewDelegate::paintDisk(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const Disk *disk) const
{
    QRect paintRect = option.rect;
    paintRect.setLeft(0);

    if (option.state & QStyle::State_Selected)
        QStyledItemDelegate::paint(painter, option, index);
    else
        painter->fillRect(option.rect, mTrackView->palette().base().color());


    //cache = self.cache(index)
    painter->save();
    painter->setClipRect(option.rect);
    QFont titleFont = this->titleFont(painter);
    QFont filesFont = this->filesFont(painter);


    int topPadding = index.row() ? TOP_PADDING : 0;

    painter->translate(option.rect.topLeft());

    QRect windowRect(MARGIN + MARGIN,
                     MARGIN + topPadding,
                     option.rect.right() - 2 * MARGIN,
                     option.rect.height() - 2 * MARGIN - topPadding - BOTTOM_PADDING);

    // Draw cover image ................................
    if (mNoCoverImg.height() != windowRect.height())
    {
        mNoCoverImg = QImage(":noCover").scaledToHeight(windowRect.height(), Qt::SmoothTransformation);
    }

    QRect imgRect(windowRect.topLeft(), mNoCoverImg.size());
    painter->fillRect(imgRect, mTrackView->palette().base().color());
    painter->fillRect(imgRect, Qt::white);
    painter->drawImage(imgRect, mNoCoverImg);


    // Rectangle for text drawing ......................
    QRect textRect(windowRect);
    textRect.setLeft(imgRect.right() + MARGIN);

    // Draw album & artist .............................
    painter->setFont(titleFont);
    QString album =  index.sibling(index.row(), TrackView::ColumnAlbum).data().toString();
    QString artist = index.sibling(index.row(), TrackView::ColumnArtist).data().toString();
    if (!album.isEmpty() || !artist.isEmpty())
        painter->drawText(textRect, Qt::AlignLeft, QString("%1 / %2").arg(artist, album));

    // Draw audio filename .............................
    painter->setFont(filesFont);
    int th = painter->fontMetrics().height();
    int tTop = windowRect.bottom() - 2 * th - 2;
    int aTop = windowRect.bottom() - th + 1;

    // Draw labels ........
    QRect tLabelRect(textRect.left(), tTop, windowRect.width(), th);
    QRect aLabelRect(textRect.left(), aTop, windowRect.width(), th);

    tLabelRect = drawLabel(tr("Tracks:"), tLabelRect, painter);
    aLabelRect = drawLabel(tr("Audio:"),  aLabelRect, painter);

    // Draw filenames .....
    int l = qMax(tLabelRect.right(), aLabelRect.right()) + 6;
    QRect tFileRect(l, tTop, windowRect.width(), th);
    QRect aFileRect(l, aTop, windowRect.width(), th);

    tFileRect = drawFile(disk->tagsTitle(), tFileRect, painter);
    QFileInfo fi(disk->audioFileName());
    aFileRect = drawFile(fi.fileName(), aFileRect, painter);


    // Draw buttons ......
    l = qMax(tLabelRect.right() + 80, qMax(tFileRect.right(), aFileRect.right()) + 8);

    QRect tBtnRect(0, 0, mTrackBtnPix.height(), mTrackBtnPix.width());
    tBtnRect.moveCenter(tLabelRect.center());
    tBtnRect.moveLeft(l);
    painter->drawPixmap(tBtnRect, mTrackBtnPix);

    QRect aBtnRect(0, 0, mAudioBtnPix.height(), mAudioBtnPix.width());
    aBtnRect.moveCenter(aLabelRect.center());
    aBtnRect.moveLeft(l);
    painter->drawPixmap(aBtnRect, mAudioBtnPix);

    TrackViewCacheItem *cache = mCache->item(index);
    QRect tClickRect = tBtnRect.united(tLabelRect).adjusted(0, -3, 4, 1);
    cache->trackBtn = tClickRect;
    //painter->drawRect(tClickRect);

    QRect aClickRect = aBtnRect.united(aLabelRect).adjusted(0, -3, 4, 1);
    cache->audioBtn = aClickRect;
    //painter->drawRect(aClickRect);

    // Draw bottom line ................................
    painter->setPen(mTrackView->palette().dark().color());
    int y = option.rect.height() - BOTTOM_PADDING - 2;
    painter->drawLine(MARGIN, y, windowRect.right(), y);

    // Draw warning mark ...............................
    QRect markRect(imgRect.right() - MARK_HEIGHT, imgRect.bottom() - MARK_HEIGHT, MARK_HEIGHT, MARK_HEIGHT);
    if (!disk->canConvert())
        painter->drawPixmap(markRect, mWarnPix);

    cache->isWaiting = disk->isDownloads();
    if (cache->isWaiting)
    {
        painter->drawPixmap(markRect, mDownloadMovie.currentPixmap());
    }

    cache->markBtn = markRect;

    painter->restore();    
}
예제 #25
0
파일: snaphelper.cpp 프로젝트: 8l/kwin
void SnapHelperEffect::postPaintScreen()
{
    effects->postPaintScreen();
    if (m_timeline.currentValue() != 0.0) {
        // Display the guide
        if (effects->isOpenGLCompositing()) {
            GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
            vbo->reset();
            vbo->setUseColor(true);
            ShaderBinder binder(ShaderManager::ColorShader);
            glEnable(GL_BLEND);
            glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

            QColor color;
            color.setRedF(0.5);
            color.setGreenF(0.5);
            color.setBlueF(0.5);
            color.setAlphaF(m_timeline.currentValue() * 0.5);
            vbo->setColor(color);
            glLineWidth(4.0);
            QVector<float> verts;
            verts.reserve(effects->numScreens() * 24);
            for (int i = 0; i < effects->numScreens(); ++i) {
                const QRect& rect = effects->clientArea(ScreenArea, i, 0);
                int midX = rect.x() + rect.width() / 2;
                int midY = rect.y() + rect.height() / 2 ;
                int halfWidth = m_window->width() / 2;
                int halfHeight = m_window->height() / 2;

                // Center lines
                verts << rect.x() + rect.width() / 2 << rect.y();
                verts << rect.x() + rect.width() / 2 << rect.y() + rect.height();
                verts << rect.x() << rect.y() + rect.height() / 2;
                verts << rect.x() + rect.width() << rect.y() + rect.height() / 2;

                // Window outline
                // The +/- 2 is to prevent line overlap
                verts << midX - halfWidth + 2 << midY - halfHeight;
                verts << midX + halfWidth + 2 << midY - halfHeight;
                verts << midX + halfWidth << midY - halfHeight + 2;
                verts << midX + halfWidth << midY + halfHeight + 2;
                verts << midX + halfWidth - 2 << midY + halfHeight;
                verts << midX - halfWidth - 2 << midY + halfHeight;
                verts << midX - halfWidth << midY + halfHeight - 2;
                verts << midX - halfWidth << midY - halfHeight - 2;
            }
            vbo->setData(verts.count() / 2, 2, verts.data(), NULL);
            vbo->render(GL_LINES);

            glDisable(GL_BLEND);
            glLineWidth(1.0);
        }
        if ( effects->compositingType() == XRenderCompositing ) {
#ifdef KWIN_HAVE_XRENDER_COMPOSITING
            for (int i = 0; i < effects->numScreens(); ++i) {
                const QRect& rect = effects->clientArea( ScreenArea, i, 0 );
                int midX = rect.x() + rect.width() / 2;
                int midY = rect.y() + rect.height() / 2 ;
                int halfWidth = m_window->width() / 2;
                int halfHeight = m_window->height() / 2;

                xcb_rectangle_t rects[6];
                // Center lines
                rects[0].x = rect.x() + rect.width() / 2 - 2;
                rects[0].y = rect.y();
                rects[0].width = 4;
                rects[0].height = rect.height();
                rects[1].x = rect.x();
                rects[1].y = rect.y() + rect.height() / 2 - 2;
                rects[1].width = rect.width();
                rects[1].height = 4;

                // Window outline
                // The +/- 4 is to prevent line overlap
                rects[2].x = midX - halfWidth + 4;
                rects[2].y = midY - halfHeight;
                rects[2].width = 2*halfWidth - 4;
                rects[2].height = 4;
                rects[3].x = midX + halfWidth - 4;
                rects[3].y = midY - halfHeight + 4;
                rects[3].width = 4;
                rects[3].height = 2*halfHeight - 4;
                rects[4].x = midX - halfWidth;
                rects[4].y = midY + halfHeight - 4;
                rects[4].width = 2*halfWidth - 4;
                rects[4].height = 4;
                rects[5].x = midX - halfWidth;
                rects[5].y = midY - halfHeight;
                rects[5].width = 4;
                rects[5].height = 2*halfHeight - 4;

                xcb_render_fill_rectangles(xcbConnection(), XCB_RENDER_PICT_OP_OVER, effects->xrenderBufferPicture(),
                                           preMultiply(QColor(128, 128, 128, m_timeline.currentValue()*128)), 6, rects);
            }
#endif
        }
        if (effects->compositingType() == QPainterCompositing) {
            QPainter *painter = effects->scenePainter();
            painter->save();
            QColor color;
            color.setRedF(0.5);
            color.setGreenF(0.5);
            color.setBlueF(0.5);
            color.setAlphaF(m_timeline.currentValue() * 0.5);
            QPen pen(color);
            pen.setWidth(4);
            painter->setPen(pen);
            painter->setBrush(Qt::NoBrush);

            for (int i = 0; i < effects->numScreens(); ++i) {
                const QRect &rect = effects->clientArea(ScreenArea, i, 0);
                // Center lines
                painter->drawLine(rect.center().x(), rect.y(), rect.center().x(), rect.y() + rect.height());
                painter->drawLine(rect.x(), rect.center().y(), rect.x() + rect.width(), rect.center().y());

                // window outline
                QRect windowRect(rect.center(), m_window->geometry().size());
                painter->drawRect(windowRect.translated(-windowRect.width()/2, -windowRect.height()/2));
            }
            painter->restore();
        }
    } else if (m_window && !m_active) {
        if (m_window->isDeleted())
            m_window->unrefWindow();
        m_window = NULL;
    }
}
예제 #26
0
FloatRect ChromeClientWinCE::pageRect()
{
    return windowRect();
}
예제 #27
0
void TrackViewDelegate::paintTrack(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index, const Track *track) const
{
    QStyledItemDelegate::paint(painter, option, index);

    if (index.column() != TrackView::ColumnPercent)
        return;

    const QPixmap *icon = 0;
    QString txt;
    int progress = track->progress();

    switch (track->status())
    {
    case Track::NotRunning: txt = "";               progress = -1;      break;
    case Track::Canceled:   txt = "";                                   break;
    case Track::Error:      txt = tr("Error");      icon = &mErrorPix;  break;
    case Track::Aborted:    txt = tr("Aborted");                        break;
    case Track::OK:         txt = tr("OK");         icon = &mOkPix;     break;
    case Track::Splitting:  txt = tr("Extracting");                     break;
    case Track::Encoding:   txt = tr("Encoding");                       break;
    case Track::Queued:     txt = tr("Queued");                         break;
    case Track::CalcGain:   txt = tr("Calculate gain");                 break;
    case Track::WaitGain:   txt = tr("Wait gain");                      break;
    case Track::WriteGain:  txt = tr("Write gain");                     break;

    }



    painter->save();
    painter->translate(option.rect.left() + 30, option.rect.top());
    QRect windowRect(0, 0, option.rect.width() - 31, option.rect.height());
    painter->setClipRect(windowRect);

    if (progress > -1)
    {
        QStyleOptionProgressBar opt;
        opt.rect = windowRect.adjusted(4, 3, -4, -3);
        opt.minimum = 0;
        opt.maximum = 100;
        opt.progress = progress;
        opt.text = QString("%1 %2%").arg(txt).arg(opt.progress);

        QApplication::style()->drawControl(QStyle::CE_ProgressBarContents, &opt, painter);
        QApplication::style()->drawControl(QStyle::CE_ProgressBarLabel, &opt, painter);
    }
    else
    {
        if (icon)
        {
            int textWidth = painter->fontMetrics().width(txt);
            int imgLeft = (windowRect.width() - LINE_MARK_HEIGHT - 4 - textWidth) / 2;
            painter->drawPixmap(imgLeft, (windowRect.height() - LINE_MARK_HEIGHT) / 2, *icon);

            QRect textRect(QPoint(imgLeft + LINE_MARK_HEIGHT + 4, 0), windowRect.bottomRight());
            painter->drawText(textRect, Qt::AlignLeft | Qt::AlignVCenter, txt);
        }
        else
        {
            painter->drawText(windowRect, Qt::AlignCenter | Qt::AlignVCenter, txt);
        }
    }

    painter->restore();
}
예제 #28
0
void TwWindow::setWidth( int w )
{
    setWindowRect(windowRect().setWidth(w));
}
예제 #29
0
void
CronoView::MessageReceived(BMessage *message)
{
	switch(message->what)
	{
		case MSG_CLOSE:
		{
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;
		}

		case MSG_ABOUT:
		{
			AboutRequested();
			break;
		}

		case MSG_HOMEPAGE:
		{
			const char* homepage = CRONO_HOMEPAGE_URL;
			be_roster->Launch("text/html",1, const_cast<char**>(&homepage));
			break;
		}

		case MSG_HELP:
		{
			const char* guide = CRONO_USERGUIDE_URL;
			be_roster->Launch("text/html",1, const_cast<char**>(&guide));
			break;
		}

		case MSG_SETTINGS:
		{
			BRect windowRect(150,150,460,445);
			SettingsWindow *settWindow = new SettingsWindow(windowRect, fCore);
			settWindow->Show();
			break;
		}

		case MSG_START:
		{
			status_t ret = fCore->Start();
			if (ret != B_OK) {
				BString str("\nError starting Crono :\n");
				str << strerror(ret);
				BAlert *alert = new BAlert("Error", 
					str.String(),
					"OK", NULL, NULL, B_WIDTH_FROM_WIDEST, B_EVEN_SPACING,
					B_INFO_ALERT);
					alert->Go();
				break;
			}
			fStartButton->SetEnabled(false);
			fStopButton->SetEnabled(true);
			fStopButton->MakeDefault(true);
			fEditMenu->FindItem(MSG_SETTINGS)->SetEnabled(false);
			fFileMenu->FindItem(MSG_START)->SetEnabled(false);
			fFileMenu->FindItem(MSG_STOP)->SetEnabled(true);
			break;
		}

		case MSG_STOP:
		{
			fCore->Stop();
			fStopButton->SetEnabled(false);
			fStartButton->SetEnabled(true);
			fStartButton->MakeDefault(true);
			fEditMenu->FindItem(MSG_SETTINGS)->SetEnabled(true);
			fFileMenu->FindItem(MSG_START)->SetEnabled(true);
			fFileMenu->FindItem(MSG_STOP)->SetEnabled(false);
			break;
		}

		case MSG_VOLUME:
		{
			float position = fVolumeSlider->Position();
			fCore->SetVolume(position);
			fVolumeSlider->SetLabel(BString() << position);
			break;
		}

		case MSG_METER_RADIO:
		{
			int selected = _GetCurrentMeter();

			// If "Other" is selected, enable the fTempoEntry
			if (fTempoRadios[4]->Value() == true) {
				fTempoEntry->SetEnabled(true);
			} else {
				fTempoEntry->SetEnabled(false);
			}
			fCore->SetMeter(selected);

			if (gCronoSettings.AccentTable)
				_SetAccentCheckBox(selected);
			break;
		}

		case MSG_METER_ENTRY:
		{
			int position = abs(atoi(fTempoEntry->Text()));
			if (position < 1) {
				fTempoEntry->SetText("1");
				position = 1;
				return;
			} else if (position > 100) {
				fTempoEntry->SetText("100");
				position = 100;		
			}

			fCore->SetMeter(position);
			_SetAccentCheckBox(position);
			break;
		}

		case MSG_SPEED_ENTRY:
		{
			unsigned bpm = abs(atoi(fSpeedEntry->Text()));

			if (bpm > MAX_SPEED) {
				fSpeedEntry->SetText(BString() << MAX_SPEED);
				bpm = MAX_SPEED;
			} else if (bpm < MIN_SPEED) {
				fSpeedEntry->SetText(BString() << MIN_SPEED);
				bpm = MIN_SPEED;
			}

			fCore->SetSpeed(((int) bpm));
			fSpeedSlider->SetPosition(((float) bpm / MAX_SPEED));
			printf("Crono Speed: %s %d\n", fSpeedEntry->Text(), bpm);
			_UpdateTempoName(bpm);
			break;
		}

		case MSG_SPEED_SLIDER:
		{
			int v = fSpeedSlider->Value();

			BString str;
			fSpeedEntry->SetText(str << v);
			fCore->SetSpeed(v);
			_UpdateTempoName(v);
			break;
		}

		case MSG_ACCENT_TABLE:
		{
			bool marked = !fAccentTableItem->IsMarked();
			gCronoSettings.AccentTable = marked;

			_ShowTable(marked);
			break;
		}

		default:
			BView::MessageReceived(message);
	}
}
예제 #30
0
void TwWindow::setPos( const TwPoint<int>& pt )
{
    setWindowRect(windowRect().moveTo(pt));
}