Example #1
0
void colorDialog::constructorHelper(bool useSquareColors, flossType type) {

  setAttribute(Qt::WA_DeleteOnClose);

  // left right buttons and label
  leftRightColorPatch_ = new QLabel;
  QPixmap colorPatch(2*LR_BOX + 2*LR_BORDER, LR_BOX + 2*LR_BORDER);
  colorPatch.fill(QColor(180, 180, 180));
  QPainter painter;
  painter.begin(&colorPatch);
  painter.fillRect(LR_BORDER, LR_BORDER, 2*LR_BOX, LR_BOX,
                   inputColor_.qc());
  painter.drawRect(LR_BORDER, LR_BORDER, 2*LR_BOX, LR_BOX);
  painter.drawLine(LR_BORDER + LR_BOX, LR_BORDER,
                   LR_BORDER + LR_BOX, LR_BORDER + LR_BOX);
  painter.end();
  leftRightColorPatch_->setPixmap(colorPatch);

  leftButton_ = new QPushButton(QIcon(":leftArrow.png"), "", this);
  leftButton_->setEnabled(false);
  connect(leftButton_, SIGNAL(clicked()),
          this, SLOT(processLeftClick()));

  rightButton_ = new QPushButton(QIcon(":rightArrow.png"), "", this);
  rightButton_->setEnabled(false);
  connect(rightButton_, SIGNAL(clicked()),
          this, SLOT(processRightClick()));

  leftRightLayout_ = new QHBoxLayout;
  leftRightHolder_ = new QWidget;
  leftRightHolder_->setLayout(leftRightLayout_);
  dialogLayout_->addWidget(leftRightHolder_);

  leftRightLayout_->setAlignment(Qt::AlignHCenter);
  leftRightLayout_->addWidget(leftButton_);
  leftRightLayout_->addWidget(leftRightColorPatch_);
  leftRightLayout_->addWidget(rightButton_);

  // choice box
  modeChoiceBox_ = new QComboBox;
  if (useSquareColors) {
    modeChoiceBox_->addItem(tr("Choose a square color"),
                            QVariant::fromValue(CD_SQUARE));
  }
  modeChoiceBox_->addItem(tr("Choose a color list color"),
                          QVariant::fromValue(CD_LIST));
  if (type == flossDMC || type == flossVariable) {
    modeChoiceBox_->addItem(tr("Choose a DMC floss by color"),
                            QVariant::fromValue(CD_DMC_COLOR));
    modeChoiceBox_->addItem(tr("Choose a DMC floss by color/number"),
                            QVariant::fromValue(CD_DMC_FLOSS));
  }
  if (type == flossAnchor || type == flossVariable) {
    modeChoiceBox_->addItem(tr("Choose an Anchor floss by color"),
                            QVariant::fromValue(CD_ANCHOR_COLOR));
    modeChoiceBox_->addItem(tr("Choose an Anchor floss by color/number"),
                            QVariant::fromValue(CD_ANCHOR_FLOSS));
  }
  modeChoiceBox_->addItem(tr("Choose a color from an image"),
                          QVariant::fromValue(CD_IMAGE));
  if (type == flossVariable) {
    modeChoiceBox_->addItem(tr("Choose a new color"),
                            QVariant::fromValue(CD_NEW));
  }

  connect(modeChoiceBox_, SIGNAL(activated(int )),
          this, SLOT(processModeChange(int )));

  buttonsLayout_ = new QHBoxLayout;
  buttonsLayout_->setSpacing(9);
  dialogLayout_->addLayout(buttonsLayout_);
  buttonsLayout_->addWidget(modeChoiceBox_);
  buttonsLayout_->addWidget(cancelAcceptWidget());
  move(200, 50);
}
Example #2
0
/**
 * Process mouse activity
 */
void MouseHandler::mouseHandler() {
	debugC(2, kDebugMouse, "mouseHandler");

	Status &gameStatus = _vm->getGameStatus();
	Istate inventState = _vm->_inventory->getInventoryState();
	if ((gameStatus._viewState != kViewPlay) && (inventState != kInventoryActive))
		return;

	int16 cx = getMouseX();
	int16 cy = getMouseY();

//	gameStatus._cx = cx;                             // Save cursor coords
//	gameStatus._cy = cy;

	// Don't process if outside client area
	if ((cx < 0) || (cx > kXPix) || (cy < kDibOffY) || (cy > kViewSizeY + kDibOffY))
		return;

	int16 objId = -1;                               // Current source object
	// Process cursor over an object or icon
	if (inventState == kInventoryActive) { // Check inventory icon bar first
		objId = _vm->_inventory->processInventory(kInventoryActionGet, cx, cy);
	} else {
		if (cy < 5 && cy > 0) {
			_vm->_topMenu->runModal();
		}
	}

	if (!gameStatus._gameOverFl) {
		if (objId == -1)                            // No match, check rest of view
			objId = _vm->_object->findObject(cx, cy);

		if (objId >= 0) {                           // Got a match
			// Display object name next to cursor (unless CURSOR_NOCHAR)
			// Note test for swapped hero name
			const char *name = _vm->_text->getNoun(_vm->_object->_objects[(objId == kHeroIndex) ? _vm->_heroImage : objId]._nounIndex, kCursorNameIndex);
			if (name[0] != kCursorNochar)
				cursorText(name, cx, cy, U_FONT8, _TBRIGHTWHITE);

			// Process right click over object in view or iconbar
			if (_rightButtonFl)
				processRightClick(objId, cx, cy);
		}

		// Process cursor over an exit hotspot
		if (objId == -1) {
			int i = findExit(cx, cy, *_vm->_screenPtr);
			if (i != -1 && _hotspots[i]._viewx >= 0) {
				objId = kExitHotspot;
				cursorText(_vm->_text->getTextMouse(kMsExit), cx, cy, U_FONT8, _TBRIGHTWHITE);
			}
		}
	}
	// Left click over icon, object or to move somewhere
	if (_leftButtonFl)
		processLeftClick(objId, cx, cy);

	// Clear mouse click states
	resetLeftButton();
	resetRightButton();
}