Exemplo n.º 1
0
void COverlappedWindow::On_WM_KEYDOWN(WPARAM wParam, LPARAM lParam) {

	int i_pressed_prev = i_pressed_;
	int j_pressed_prev = j_pressed_;



	if (is_digit_pressed_) {
		if (wParam == VK_RIGHT) {
			i_pressed_ = (i_pressed_ + 1) % 9;
		} else if (wParam == VK_DOWN) {
			j_pressed_ = (j_pressed_ + 1) % 9;
		} else if (wParam == VK_LEFT) {
			i_pressed_ = (i_pressed_ - 1 + 9) % 9;
		} else if (wParam == VK_UP) {
			j_pressed_ = (j_pressed_ - 1 + 9) % 9;
		} else if (wParam == VK_DELETE || wParam == VK_BACK) {
			grid[i_pressed_][j_pressed_] = 0;
		} 

		updateRect(field_rects_[i_pressed_prev][j_pressed_prev]);

	} else if (wParam == VK_RIGHT || wParam == VK_DOWN || wParam == VK_LEFT || wParam == VK_UP) {
		i_pressed_ = 0;
		j_pressed_ = 0;
		is_digit_pressed_ = true;
	}

	updateRect(field_rects_[i_pressed_][j_pressed_]);

}
Exemplo n.º 2
0
/** Loads sprite surface from image file
@param img_fn Image filename
 */
int EasyImageSprite::loadFromFile(char *img_fn){
  SDL_Surface *temp;

	/* Load the sprite image */
	surface = SDL_LoadBMP(img_fn);
	if ( surface == NULL ) {
		fprintf(stderr, "Couldn't load %s: %s", img_fn, SDL_GetError());
		return(-1);
	}	

  /* Set transparent pixel as the pixel at (0,0) */
	SDL_SetColorKey(surface, (SDL_SRCCOLORKEY|SDL_RLEACCEL),
						*(Uint32 *)surface->pixels);
	
	/* Convert sprite to video format */
	temp = SDL_DisplayFormat(surface);
	SDL_FreeSurface(surface);
	if ( temp == NULL ) {
		fprintf(stderr, "Couldn't convert sprite: %s\n",
							SDL_GetError());
		return(-1);
	}
	surface = temp;
	updateRect();
	return 0;
}
Exemplo n.º 3
0
void UserInterface::scrollbarChanged() {
	Common::Rect r(73, 4, 73 + 9, 4 + 38);
	_uiSlots.add(r);
	_uiSlots.draw(false, false);
	drawScroller();
	updateRect(r);
}
Exemplo n.º 4
0
Player::Player(Sprite* pSprite, float x, float y) : m_pSprite(pSprite), m_XPos(x), m_YPos(y)
{
    updateRect();

    m_WalkSpeed = 128.0f;
    m_CurrAction = ActorActions::IDLE;
}
Exemplo n.º 5
0
bool MDragDownView::ccTouchBegan(CCTouch *pTouch, CCEvent *pEvent)
{
    if (isVisible() == false)
    {
        return false;
    }
    
    for (CCNode *c = this->m_pParent; c != NULL; c = c->getParent())
    {
        if (c->isVisible() == false)
        {
            return false;
        }
    }

    updateRect();
    m_touchBeginPosition = pTouch->getLocation();
    
    if (m_viewRect.containsPoint(m_touchBeginPosition) == false)
    {
        return false;
    }
    
    
    if (m_eState != State::NONE)
    {
        return true;
    }
    
    m_isTouchDragBar = m_pDragBar ? m_dragBarRect.containsPoint(m_touchBeginPosition) : false;
    m_viewOldSize = m_viewSize;
    
    return true;
}
Exemplo n.º 6
0
void QgsRubberBand::reset( bool isPolygon )
{
  mPoints.clear();
  mGeometryType = isPolygon ? QGis::Polygon : QGis::Line;
  updateRect();
  update();
}
Exemplo n.º 7
0
/*!
  Remove all points from the shape being created.
  */
void QgsRubberBand::reset( QgsWkbTypes::GeometryType geometryType )
{
  mPoints.clear();
  mGeometryType = geometryType;
  updateRect();
  update();
}
Exemplo n.º 8
0
/*!
  Add a point to the shape being created.
  */
void QgsRubberBand::addPoint( const QgsPoint & p, bool doUpdate /* = true */, int geometryIndex )
{
  if ( geometryIndex < 0 )
  {
    geometryIndex = mPoints.size() - 1;
  }

  if ( geometryIndex < 0 || geometryIndex > mPoints.size() )
  {
    return;
  }

  if ( geometryIndex == mPoints.size() )
  {
    mPoints.push_back( QList<QgsPoint>() << p );
  }

  if ( mPoints.at( geometryIndex ).size() == 2 &&
       mPoints.at( geometryIndex ).at( 0 ) == mPoints.at( geometryIndex ).at( 1 ) )
  {
    mPoints[geometryIndex].last() = p;
  }
  else
  {
    mPoints[geometryIndex] << p;
  }


  if ( doUpdate )
  {
    setVisible( true );
    updateRect();
    update();
  }
}
Exemplo n.º 9
0
void QgsRubberBand::removePoint( int index, bool doUpdate/* = true*/, int geometryIndex/* = 0*/ )
{

  if ( mPoints.size() < geometryIndex + 1 )
  {
    return;
  }


  if ( !mPoints[geometryIndex].isEmpty() )
  {
    // negative index removes from end, e.g., -1 removes last one
    if ( index < 0 )
    {
      index = mPoints.at( geometryIndex ).size() + index;
    }
    mPoints[geometryIndex].removeAt( index );
  }

  if ( doUpdate )
  {
    updateRect();
    update();
  }
}
Exemplo n.º 10
0
void UserInterface::selectObject(int invIndex) {
	if (_selectedInvIndex != invIndex || _inventoryChanged) {
		int oldVocabCount = _selectedInvIndex < 0 ? 0 : _vm->_game->_objects.getItem(_selectedInvIndex)._vocabCount;
		int newVocabCount = invIndex < 0 ? 0 : _vm->_game->_objects.getItem(invIndex)._vocabCount;
		int maxVocab = MAX(oldVocabCount, newVocabCount);

		updateSelection(CAT_INV_LIST, invIndex, &_selectedInvIndex);
		_highlightedItemVocabIndex = -1;
		_selectedItemVocabIdx = -1;

		if (maxVocab) {
			assert(_uiSlots.size() < 50);
			int vocabHeight = maxVocab * 8;

			Common::Rect bounds(240, 3, 240 + 80, 3 + vocabHeight);
			_uiSlots.add(bounds);
			_uiSlots.draw(false, false);
			drawItemVocabList();
			updateRect(bounds);
		}
	}

	if (invIndex == -1) {
		noInventoryAnim();
	} else {
		loadInventoryAnim(_vm->_game->_objects._inventoryList[invIndex]);
		_vm->_palette->setPalette(&_vm->_palette->_mainPalette[7 * 3], 7, 1);
		_vm->_palette->setPalette(&_vm->_palette->_mainPalette[246 * 3], 246, 2);
	}
}
Exemplo n.º 11
0
void DOSBoxMenu::showMenu(bool show) {
    if (menuVisible != show) {
        menuVisible = show;
        needRedraw = true;
        removeFocus();
        updateRect();
    }
}
Exemplo n.º 12
0
void GameObject::initialize(float centerX, float centerY, int width, int height, float angleD, float speed)
{
	setPosition(centerX, centerY);
	setAngleD(angleD);
	setSpeed(speed);
	setSize(width, height);
	updateRect();
}
Exemplo n.º 13
0
void UBGraphicsCache::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
{
    mShapePos = event->pos();

    // Note: if refresh issues occure, replace the following 3 lines by: update();
    update(updateRect(event->pos()));
    mOldShapeWidth = mShapeWidth;
    mOldShapePos = event->pos();
}
Exemplo n.º 14
0
void WallpaperPreview::setWallpaper(Plasma::Wallpaper* wallpaper)
{
    m_wallpaper = wallpaper;
    if (m_wallpaper) {
        connect(m_wallpaper, SIGNAL(update(QRectF)),
                this, SLOT(updateRect(QRectF)));
        resizeEvent(0);
    }
}
Exemplo n.º 15
0
/*!
  \class QgsHighlight
  \brief The QgsHighlight class provides a transparent overlay widget
  for highlightng features on the map.
*/
QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer )
    : QgsMapCanvasItem( mapCanvas )
    , mLayer( layer )
{
  mGeometry = geom ? new QgsGeometry( *geom ) : 0;
  updateRect();
  update();
  setColor( QColor( Qt::lightGray ) );
}
Exemplo n.º 16
0
void Player::update(size_t dt)
{
    switch(m_CurrAction)
    {
        case ActorActions::IDLE:
            // NOTHING TO DO
            break;

        case ActorActions::MOVE_LEFT:
            m_XPos -= m_WalkSpeed * dt / 1000.0f;
            updateRect();
            break;

        case ActorActions::MOVE_RIGHT:
            m_XPos += m_WalkSpeed * dt / 1000.0f;
            updateRect();
            break;
    }
}
Exemplo n.º 17
0
void GameObject::activate()
{
	setSpeedX(_speedX + (_accelX * TIMEMANAGER->getElapsedTime()));
	setSpeedY(_speedY + (_accelY * TIMEMANAGER->getElapsedTime()));

	_centerX += _speedX * TIMEMANAGER->getElapsedTime();
	_centerY += _speedY * TIMEMANAGER->getElapsedTime();

	updateRect();
}
Exemplo n.º 18
0
void UBGraphicsCache::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)
{
    Q_UNUSED(event);
    mDrawMask = false;

    // Note: if refresh issues occure, replace the following 3 lines by: update();
    update(updateRect(event->pos()));
    mOldShapeWidth = mShapeWidth;
    mOldShapePos = event->pos();
}
Exemplo n.º 19
0
void QDeclarativeTextInput::setHAlign(HAlignment align)
{
    Q_D(QDeclarativeTextInput);
    if(align == d->hAlign)
        return;
    d->hAlign = align;
    updateRect();
    d->updateHorizontalScroll();
    emit horizontalAlignmentChanged(d->hAlign);
}
Exemplo n.º 20
0
void COverlappedWindow::On_WM_CHAR(WPARAM wParam, LPARAM lParam) {

	if (is_digit_pressed_) {
		if (wParam >= '0' && wParam <= '9') {
			grid[i_pressed_][j_pressed_] = wParam - '0';
		}
	}

	updateRect(field_rects_[i_pressed_][j_pressed_]);
}
Exemplo n.º 21
0
 void KeepAspectSkin::_setAlign(const MyGUI::IntSize& _oldsize) {
     //mCurrentCoord.set(0, 0, mCroppedParent->getWidth(), mCroppedParent->getHeight());
     if (mRectTexture.empty()) {
         Base::_setAlign(_oldsize);
         return;
     }
     float tw = mRectTexture.width();
     float th = mRectTexture.height();
     updateRect(tw,th);
 }
Exemplo n.º 22
0
void LegendGroup::updateModel() {
	QList<QGraphicsItem*> pool;
	for (auto l : legends) { removeFromGroup(l); pool.append(l); }
	for (auto t : texts) { removeFromGroup(t); pool.append(t); }
	for (auto l : pool) delete l;
	legends.clear();
	texts.clear();
	for (int i=0; i<model->rowCount(); i++) {
		auto marker = model->at(i);
		QString l = marker->label() + "\t:  " + QString::number(marker->count());
		QColor color1 = marker->color1();
		QColor color2 = marker->color2();
		int type = marker->activeType();
		if (0 == type) {
			QRectF r = MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize);
			QLineF l(r.topLeft(), r.bottomRight());
			auto marker = new ArrowItem(l);
			marker->setArrowhead(ArrowHead::Start);
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		else if (1 == type) {
			auto marker = new RectItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize));
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		else {
			auto marker = new EllipseItem(MarkerItem::rectFromClick(origin + QPointF(0, (mySize*2 + myPenWidth + 10) * (i+1)), mySize));
			marker->setColor1(color1);
			marker->setColor2(color2);
			marker->setPenWidth(myPenWidth);
			legends.append(marker);
			addToGroup(marker);
		}
		auto label = new RichTextItem(l);
		label->setFont(myFont);
		label->setFontSize(myFontSize);
		label->setKeyPressFunc([this](QKeyEvent* event) { updateRect(); });
		label->setTextInteractionFlags(Qt::TextEditorInteraction);
		label->setFlag(QGraphicsItem::ItemIsFocusable);
		QPointF textPos = legends.at(i)->boundingRect().center() + 
			QPointF(legends.at(i)->boundingRect().width()/2+20, -label->boundingRect().height()*0.5);
		label->setPos(textPos);
		label->setZValue(1000);
		texts.append(label);
		addToGroup(label);
	}
	calculatePos();
}
Exemplo n.º 23
0
void
DisplayDevice_Haiku::update(const PPRect&r)
{
	// Translate coordinates: tracker -> view
	BRect updateRect(r.x1, r.y1, r.x2, r.y2);
	updateRect.OffsetBy(fMilkyView->TopLeft());

	fDirtyRegion->Include(updateRect);
	release_sem(fBitmapLock);
	acquire_sem(fBitmapLock);
}
Exemplo n.º 24
0
void COverlappedWindow::On_LButtonDown(WPARAM wParam, LPARAM lParam) {

	int x = GET_X_LPARAM(lParam);
	int y = GET_Y_LPARAM(lParam);

	if (wParam == MK_LBUTTON) {
		for (int i = 0; i <= 10; ++i) {
			if (x >= menu_rects_[i].left && x <= menu_rects_[i].right &&
				y >= menu_rects_[i].top && y <= menu_rects_[i].bottom) {
				if (i == 10) {
					menu_buttons_[10] = menu_button_pressed_BMP_;
				} else {
					menu_buttons_[i] = menu_digits_pressed_[i];
				}
				updateRect(menu_rects_[i]);
			}

		}


		for (int i = 0; i < 9; ++i) {
			for (int j = 0; j < 9; ++j) {
				if (x >= i * cell_size_ && x <= (i + 1) * cell_size_ &&
					y >= j * cell_size_ && y <= (j + 1) * cell_size_) {

					if (is_digit_pressed_) {
						updateRect(field_rects_[i_pressed_][j_pressed_]);
					}

					is_digit_pressed_ = true;
					i_pressed_ = i;
					j_pressed_ = j;
					updateRect(field_rects_[i][j]);
				}
			}
		}

	}

	//InvalidateRect(handle, NULL, TRUE);
}
Exemplo n.º 25
0
void KisTransparencyMaskTest::testMoveMaskItself()
{
    KisImageSP image;
    KisPaintLayerSP layer;
    KisPaintDeviceSP dev;
    KisTransparencyMaskSP mask;

    initImage(image, layer, dev, mask);
    mask->initSelection(layer);
    mask->selection()->pixelSelection()->invert();
    mask->select(QRect(50, 50, 100, 100));

    KisFullRefreshWalker walker(image->bounds());
    KisAsyncMerger merger;

    walker.collectRects(layer, image->bounds());
    merger.startMerge(walker);

    // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_before.png");

    QRect initialRect(0,0,200,100);
    QCOMPARE(layer->exactBounds(), initialRect);
    QCOMPARE(image->projection()->exactBounds(), QRect(50,50,100,50));


    //layer->setX(100);
    //layer->setY(100);

    dbgKrita << "Sel. rect before:" << mask->selection()->selectedExactRect();

    mask->setX(50);
    mask->setY(25);

    dbgKrita << "Sel. rect after:" << mask->selection()->selectedExactRect();


    QCOMPARE(mask->selection()->selectedExactRect(), QRect(100, 75, 100, 100));
    QCOMPARE(layer->paintDevice()->exactBounds(), initialRect);
    QCOMPARE(layer->projection()->exactBounds(), QRect(50, 50, 100, 50));

    dbgKrita << "";

    QRect updateRect(0,0,300,300);

    walker.collectRects(mask, updateRect);
    merger.startMerge(walker);

    // image->projection()->convertToQImage(0, 0,0,300,300).save("proj_after.png");

    QCOMPARE(layer->paintDevice()->exactBounds(), initialRect);
    QCOMPARE(layer->projection()->exactBounds(), QRect(100, 75, 100, 25));
}
Exemplo n.º 26
0
void DOSBoxMenu::setScale(size_t s) {
    if (s == 0) s = 1;
    if (s > 2) s = 2;

    if (fontCharScale != s) {
        fontCharScale = s;
        menuBarHeight = menuBarHeightBase * fontCharScale;
        fontCharWidth = fontCharWidthBase * fontCharScale;
        fontCharHeight = fontCharHeightBase * fontCharScale;
        updateRect();
        layoutMenu();
    }
}
Exemplo n.º 27
0
void UserInterface::updateSelection(ScrCategory category, int newIndex, int *idx) {
	Game &game = *_vm->_game;
	Common::Array<int> &invList = game._objects._inventoryList;
	Common::Rect bounds;

	if (category == CAT_INV_LIST && _inventoryChanged) {
		*idx = newIndex;
		bounds = Common::Rect(90, 3, 90 + 69, 3 + 40);
		_uiSlots.add(bounds);
		_uiSlots.draw(false, false);
		drawInventoryList();
		updateRect(bounds);
		_inventoryChanged = false;

		if (invList.size() < 2) {
			_scrollbarElevator = 0;
		} else {
			int v = _inventoryTopIndex * 18 / (invList.size() - 1);
			_scrollbarElevator = MIN(v, 17);
		}
	} else {
		int oldIndex = *idx;
		*idx = newIndex;

		if (oldIndex >= 0) {
			writeVocab(category, oldIndex);

			if (getBounds(category, oldIndex, bounds))
				updateRect(bounds);
		}

		if (newIndex >= 0) {
			writeVocab(category, newIndex);

			if (getBounds(category, newIndex, bounds))
				updateRect(bounds);
		}
	}
}
Exemplo n.º 28
0
void COverlappedWindow::On_LButtonUp(WPARAM wParam, LPARAM lParam) {

	if (menu_buttons_[10] == menu_button_pressed_BMP_) {
		int action = DialogBox(GetModuleHandle(0), MAKEINTRESOURCE(IDD_MENU_DIALOG), handle, reinterpret_cast<DLGPROC>(DialogProc));
		switch (action) {
		case START:
			sudoku.getRandomGrid(grid);
			InvalidateRect(handle, NULL, TRUE);
			break;
		case RESTART:
			sudoku.getPreviousGrid(grid);
			InvalidateRect(handle, NULL, TRUE);
			break;
		case DEV:
			MessageBox(handle, L"The game is created by Serg Popov", L"Developers", MB_OK);
			break;
		default:
			break;
		}

		menu_buttons_[10] = menu_button_BMP_;
		updateRect(menu_rects_[10]);
	}


	for (int i = 0; i <= 9; ++i) {
		if (menu_buttons_[i] == menu_digits_pressed_[i] && is_digit_pressed_) {

			//is_digit_pressed_ = false;
			grid[i_pressed_][j_pressed_] = i;
		}

		menu_buttons_[i] = menu_digits_[i];
		updateRect(menu_rects_[i]);
		updateRect(field_rects_[i_pressed_][j_pressed_]);
	}

}
Exemplo n.º 29
0
/*!
  \class QgsHighlight
  \brief The QgsHighlight class provides a transparent overlay widget
  for highlightng features on the map.
*/
QgsHighlight::QgsHighlight( QgsMapCanvas* mapCanvas, QgsGeometry *geom, QgsVectorLayer *layer )
    : QgsMapCanvasItem( mapCanvas )
    , mLayer( layer )
{
  mGeometry = geom ? new QgsGeometry( *geom ) : 0;
  if ( mapCanvas->mapRenderer()->hasCrsTransformEnabled() )
  {
    QgsCoordinateTransform transform( mLayer->crs(), mapCanvas->mapRenderer()->destinationCrs() );
    mGeometry->transform( transform );
  }
  updateRect();
  update();
  setColor( QColor( Qt::lightGray ) );
}
Exemplo n.º 30
0
void QgsHighlight::init()
{
  if ( mMapCanvas->mapRenderer()->hasCrsTransformEnabled() )
  {
    const QgsCoordinateTransform* ct = mMapCanvas->mapRenderer()->transformation( mLayer );
    if ( ct )
    {
      mGeometry->transform( *ct );
    }
  }
  updateRect();
  update();
  setColor( QColor( Qt::lightGray ) );
}