コード例 #1
0
void InvertGrid( HWND hWindow, HDC hDC, LPRECT lpGridRect, int x, int y )
/***********************************************************************/
{
    RECT rRect1, rRect2;

    rRect1 = *lpGridRect;
    Image2Control( (LPINT)&rRect1.left, (LPINT)&rRect1.top );
    Image2Control( (LPINT)&rRect1.right, (LPINT)&rRect1.bottom );
    if ( x == 0 && y == 0 )
    {
        InvertSelection( hWindow, hDC, &rRect1, SL_BLOCK );
        return;
    }

    NewGridFromPoint( lpGridRect, x, y );
    rRect2 = *lpGridRect;
    Image2Control( (LPINT)&rRect2.left, (LPINT)&rRect2.top );
    Image2Control( (LPINT)&rRect2.right, (LPINT)&rRect2.bottom );

    if ( !EqualRect( &rRect1, &rRect2 ) )
    {
        InvertSelection( hWindow, hDC, &rRect1, SL_BLOCK );
        InvertSelection( hWindow, hDC, &rRect2, SL_BLOCK );
    }
}
コード例 #2
0
void DrawFastbitsGrid( HWND hWindow, HDC hDC, LPRECT lpGridRect, int iType )
/***********************************************************************/
{
    RECT rRect;

    rRect = *lpGridRect;
//Image2Control( (LPINT)&rRect.left, (LPINT)&rRect.top );
//Image2Control( (LPINT)&rRect.right, (LPINT)&rRect.bottom );
    InvertSelection( hWindow, hDC, &rRect, iType );
}
コード例 #3
0
void CheckedListWidget::ShowContextMenu( QPoint pos )
{
    if( count() > 0 )
    {
        QMenu menu;
        menu.addAction( tr("Select all"), this, SLOT(SelectAll()) );
        menu.addAction( tr("Unselect all"), this, SLOT(UnselectAll()) );
        menu.addAction( tr("Invert selection"), this, SLOT(InvertSelection()) );
        menu.addSeparator();
        menu.addAction( tr("Scroll to checked"), this, SLOT(ScrollToChecked()) );
        menu.exec( this->mapToGlobal(pos) );
    }
}
コード例 #4
0
ファイル: Selection.cpp プロジェクト: jimmccurdy/ArchiveGit
void CSelection::EndSelection(HWND hWnd, HDC hDC, RECT* lpSelectRect, int fFlags, bool bRemove)
{
	bool fDoc = false;

	if (bRemove)
		InvertSelection(hWnd, hDC, lpSelectRect, fFlags);
	if (fDoc)
	{
//j		SetDisplayHook(hWnd, lpLastDisplayHook);
	}
	if (fDoc)
	{
//j		DisplayInfo(lpSelectRect->right, lpSelectRect->bottom, NULL);
	}
	OrderRect(lpSelectRect, lpSelectRect);
	MessageStatus(0);
}
コード例 #5
0
ファイル: Selection.cpp プロジェクト: jimmccurdy/ArchiveGit
void CSelection::StartSelection(HWND hWnd, HDC hDC, RECT* lpSelectRect, int fFlags, POINT ptCurrent, double fStatusScale)
{
	int minx, maxx, miny, maxy;
	RECT* pRect;
	bool fDoc = false;

	if (fDoc)
	{
//j		lpLastDisplayHook = SetDisplayHook(hWnd, &DisplayHook);
//j		Display2File(hWnd, (LPINT)&ptCurrent.x, (LPINT)&ptCurrent.y);
	}
	else
//j	if ((fFlags & SL_TYPE) == SL_GRID)
//j	{
//j		Control2Image((LPINT)&ptCurrent.x, (LPINT)&ptCurrent.y);
//j	}

	fScale = fStatusScale;

	if (!(fFlags & SL_NOLIMIT))
	{
//j		RECT rBound;
//j		if ((fFlags & SL_TYPE) == SL_GRID)
//j			pRect = GetGridBoundRect(&rBound);
//j		else
			pRect = GetBoundingRect(hWnd);
		ptCurrent.x = bound(ptCurrent.x, pRect->left, pRect->right);
		ptCurrent.y = bound(ptCurrent.y, pRect->top, pRect->bottom);
	}

	ptAnchor = ptCurrent;

	Mode = DRAG_MODE;
	if (fFlags & SL_SPECIAL)
	{ // Setup a selection rectangle at the current location
		Constrain = 0;
		lpSelectRect->left = ptCurrent.x;
		lpSelectRect->top = ptCurrent.y;
		lpSelectRect->right = ptCurrent.x;
		lpSelectRect->bottom = ptCurrent.y;
		InvertSelection(hWnd, hDC, lpSelectRect, fFlags);
		GetCenter(lpSelectRect, &ptCenter);
		return;
	}

	// Modify the existing selection rectangle
	// First clip it to the window's client area
	if (!(fFlags & SL_NOLIMIT))
	{
//j		if ((fFlags & SL_TYPE) == SL_GRID)
//j		 	IntersectRect(lpSelectRect, lpSelectRect, GetGridBoundRect(&rBound));
//j		else
			IntersectRect(lpSelectRect, lpSelectRect, GetBoundingRect(hWnd));
	}

	// Figure out which side or corner to drag
	// The bottom right point is always the one that moves
	Constrain = CONSTRAINX | CONSTRAINY;
	if (ptCurrent.x >= lpSelectRect->left - CLOSENESS &&
		ptCurrent.x <= lpSelectRect->right + CLOSENESS &&
		ptCurrent.y >= lpSelectRect->top - CLOSENESS &&
		ptCurrent.y <= lpSelectRect->bottom + CLOSENESS)
	{
		if ((fFlags & SL_TYPE) == SL_BOXHANDLES)
			ConstrainHandles(ptCurrent, lpSelectRect);
		else
		{
			if (abs(ptCurrent.y - lpSelectRect->bottom) <= CLOSENESS)
				Constrain ^= CONSTRAINY;
			else
			if (abs(ptCurrent.y - lpSelectRect->top) <= CLOSENESS)
			{
				Constrain ^= CONSTRAINY;
				int tmp = lpSelectRect->top;
				lpSelectRect->top = lpSelectRect->bottom;
				lpSelectRect->bottom = tmp;
			}
			if (abs(ptCurrent.x - lpSelectRect->right) <= CLOSENESS)
				Constrain ^= CONSTRAINX;
			else
			if (abs(ptCurrent.x - lpSelectRect->left) <= CLOSENESS)
			{
				Constrain ^= CONSTRAINX;
				int tmp = lpSelectRect->left;
				lpSelectRect->left = lpSelectRect->right;
				lpSelectRect->right = tmp;
			}
		}
		if (Constrain == (CONSTRAINX | CONSTRAINY))
		{
			minx = min(lpSelectRect->left, lpSelectRect->right)+CLOSENESS;
			maxx = max(lpSelectRect->left, lpSelectRect->right)-CLOSENESS;
			miny = min(lpSelectRect->top, lpSelectRect->bottom)+CLOSENESS;
			maxy = max(lpSelectRect->top, lpSelectRect->bottom)-CLOSENESS;
			if (ptCurrent.x >= minx && ptCurrent.x <= maxx &&
				ptCurrent.y >= miny && ptCurrent.y <= maxy)
			{
				Mode = MOVE_MODE;
				lpSelectRect->left = minx-CLOSENESS;
				lpSelectRect->right = maxx+CLOSENESS;
				lpSelectRect->top = miny-CLOSENESS;
				lpSelectRect->bottom = maxy+CLOSENESS;
			}
		}
	}

	GetCenter(lpSelectRect, &ptCenter);
	if (fDoc)
	{
//j		LPIMAGE lpImage = GetImagePtr(hWnd);
//j		DisplayInfo(ptCurrent.x, ptCurrent.y, lpSelectRect);
//j		StatusOfRectangle(lpSelectRect, fScale, FrameResolution(ImgGetBaseEditFrame(lpImage)));
	}
	else
		StatusOfRectangle(lpSelectRect, fScale, 1000);
}
コード例 #6
0
ファイル: Selection.cpp プロジェクト: jimmccurdy/ArchiveGit
void CSelection::UpdateSelection(HWND hWnd, HDC hDC, RECT* lpSelectRect, int fFlags, POINT ptCurrent, bool bConstrain, long AspectX, long AspectY, bool bMove, bool bFromCenter)
{
	RECT* pRect;
	bool fNeedDC;
	int dx, dy;
	POINT ptSaved;
	RECT OldRect, drect;
	bool fDoc = false;

	if (Mode == MOVE_MODE)
		bMove = true;
	else
	if (Constrain == (CONSTRAINX | CONSTRAINY)) // It hasn't been started yet
		StartSelection(hWnd, hDC, lpSelectRect, fFlags, ptCurrent, fScale);

	if (fDoc)
	{
//j		Display2File(hWnd, (LPINT)&ptCurrent.x, (LPINT)&ptCurrent.y);
	}
//j	else
//j	if ((fFlags & SL_TYPE) == SL_GRID)
//j		Control2Image((LPINT)&ptCurrent.x, (LPINT)&ptCurrent.y);

	if (!(fFlags & SL_NOLIMIT))
	{ // Constrain point to window client area
//j		RECT rBound;
//j		if ((fFlags & SL_TYPE) == SL_GRID)
//j			pRect = GetGridBoundRect(&rBound);
//j		else
			pRect = GetBoundingRect(hWnd);
		ptCurrent.x = bound(ptCurrent.x, pRect->left, pRect->right);
		ptCurrent.y = bound(ptCurrent.y, pRect->top, pRect->bottom);
	}

	ptSaved = ptCurrent;

	if (!bMove)
	{
		// Constrain point in x-direction based on where grabbed
		if (Constrain & CONSTRAINX)
			ptCurrent.x = lpSelectRect->right;

		// Constrain point in y-direction based on where grabbed
		if (Constrain & CONSTRAINY)
			ptCurrent.y = lpSelectRect->bottom;
	}

	if (fNeedDC = (!hDC))
		hDC = GetDC(hWnd);

	switch (fFlags & SL_TYPE)
	{
		case SL_BOX:
		case SL_BOXHANDLES:
		case SL_GRID:
		case SL_LINE:
		case SL_ELLIPSE:
		{
			InvertSelection(hWnd, hDC, lpSelectRect, fFlags);
			if (bMove)
			{
				dx = ptCurrent.x - ptAnchor.x;
				dy = ptCurrent.y - ptAnchor.y;
				lpSelectRect->right  += dx;
				lpSelectRect->bottom += dy;
				lpSelectRect->top	 += dy;
				lpSelectRect->left	 += dx;
				ptCenter.x += dx;
				ptCenter.y += dy;
			}
			else
			{
				dx = ptCurrent.x - lpSelectRect->right;
				dy = ptCurrent.y - lpSelectRect->bottom;
				lpSelectRect->right = ptCurrent.x;
				lpSelectRect->bottom = ptCurrent.y;
			}
			if (bConstrain)
				ConstrainSelection(lpSelectRect, AspectX, AspectY, bFromCenter);
			dx = lpSelectRect->right - lpSelectRect->left;
			dy = lpSelectRect->bottom - lpSelectRect->top;
			if (bFromCenter)
			{
				lpSelectRect->left	 = ptCenter.x - dx/2;
				lpSelectRect->top	 = ptCenter.y - dy/2;
				lpSelectRect->right  = ptCenter.x + dx - dx/2;
				lpSelectRect->bottom = ptCenter.y + dy - dy/2;
			}
			GetCenter(lpSelectRect, &ptCenter);
			// Keep the new rectangle inside the window's client area
			if (!(fFlags & SL_NOLIMIT))
			{
//j				if ((fFlags & SL_TYPE) == SL_GRID)
//j					MoveInsideRect(lpSelectRect, GetGridBoundRect(&rBound));
//j				else
					MoveInsideRect(lpSelectRect, GetBoundingRect(hWnd));
			}
			InvertSelection(hWnd, hDC, lpSelectRect, fFlags);
			break;
		}
		case SL_BLOCK:
		{
			OldRect = *lpSelectRect;
			dx = ptCurrent.x - lpSelectRect->right;
			dy = ptCurrent.y - lpSelectRect->bottom;
			lpSelectRect->right = ptCurrent.x;
			lpSelectRect->bottom = ptCurrent.y;
			if (bConstrain)
				ConstrainSelection(lpSelectRect, AspectX, AspectY, bFromCenter);
			if (bFromCenter)
			{
				lpSelectRect->left	 = ptCenter.x - dx/2;
				lpSelectRect->top	 = ptCenter.y - dy/2;
				lpSelectRect->right  = ptCenter.x + dx - dx/2;
				lpSelectRect->bottom = ptCenter.y + dy - dy/2;
			}
			GetCenter(lpSelectRect, &ptCenter);
			drect.left = OldRect.left - lpSelectRect->left;
			drect.right = OldRect.right - lpSelectRect->right;
			drect.top = OldRect.top - lpSelectRect->top;
			drect.bottom = OldRect.bottom - lpSelectRect->bottom;
			PatBlt(hDC, lpSelectRect->left, lpSelectRect->bottom,
				OldRect.right - lpSelectRect->left,
				drect.bottom, DSTINVERT);
			PatBlt(hDC, lpSelectRect->right, OldRect.top,
				drect.right,
				lpSelectRect->bottom - OldRect.top, DSTINVERT);
			PatBlt(hDC, OldRect.left, OldRect.top,
				lpSelectRect->right-OldRect.left,
				drect.top, DSTINVERT);
			PatBlt(hDC, OldRect.left, lpSelectRect->top,
				drect.left,
				OldRect.bottom-lpSelectRect->top, DSTINVERT);
			break;
		}
	}

	ptAnchor = ptSaved;
	if (fDoc)
	{
//j		LPIMAGE lpImage = GetImagePtr(hWnd);
//j		DisplayInfo(ptCurrent.x, ptCurrent.y, lpSelectRect);
//j		StatusOfRectangle(lpSelectRect, fScale, FrameResolution(ImgGetBaseEditFrame(lpImage)));
	}
	else
		StatusOfRectangle(lpSelectRect, fScale, 1000);
	if (fNeedDC)
		ReleaseDC(hWnd, hDC);
}
コード例 #7
0
ファイル: ripcd.cpp プロジェクト: RaoulChartreuse/Clementine
RipCD::RipCD(QWidget* parent)
    : QDialog(parent),
      transcoder_(new Transcoder(this)),
      queued_(0),
      finished_success_(0),
      finished_failed_(0),
      ui_(new Ui_RipCD) {

  // Init
  ui_->setupUi(this);

  // Set column widths in the QTableWidget.
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kCheckboxColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kTrackNumberColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(kTrackTitleColumn,
                                                      QHeaderView::Stretch);

  // Add a rip button
  rip_button_ = ui_->button_box->addButton(tr("Start ripping"),
                                           QDialogButtonBox::ActionRole);
  cancel_button_ = ui_->button_box->button(QDialogButtonBox::Cancel);
  close_button_ = ui_->button_box->button(QDialogButtonBox::Close);

  // Hide elements
  cancel_button_->hide();
  ui_->progress_group->hide();

  connect(ui_->select_all_button, SIGNAL(clicked()), SLOT(SelectAll()));
  connect(ui_->select_none_button, SIGNAL(clicked()), SLOT(SelectNone()));
  connect(ui_->invert_selection_button, SIGNAL(clicked()),
          SLOT(InvertSelection()));
  connect(rip_button_, SIGNAL(clicked()), SLOT(ClickedRipButton()));
  connect(cancel_button_, SIGNAL(clicked()), SLOT(Cancel()));
  connect(close_button_, SIGNAL(clicked()), SLOT(hide()));

  connect(transcoder_, SIGNAL(JobComplete(QString, bool)),
          SLOT(JobComplete(QString, bool)));
  connect(transcoder_, SIGNAL(AllJobsComplete()), SLOT(AllJobsComplete()));
  connect(transcoder_, SIGNAL(JobOutputName(QString)),
          SLOT(AppendOutput(QString)));
  connect(this, SIGNAL(RippingComplete()), SLOT(ThreadedTranscoding()));
  connect(this, SIGNAL(SignalUpdateProgress()), SLOT(UpdateProgress()));

  connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
  connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));

  setWindowTitle(tr("Rip CD"));
  AddDestinationDirectory(QDir::homePath());

  cdio_ = cdio_open(nullptr, DRIVER_UNKNOWN);
  if (!cdio_) {
    qLog(Error) << "Failed to read CD drive";
    return;
  } else {
    i_tracks_ = cdio_get_num_tracks(cdio_);
    ui_->tableWidget->setRowCount(i_tracks_);
    for (int i = 1; i <= i_tracks_; i++) {
      QCheckBox* checkbox_i = new QCheckBox(ui_->tableWidget);
      checkbox_i->setCheckState(Qt::Checked);
      checkboxes_.append(checkbox_i);
      ui_->tableWidget->setCellWidget(i - 1, kCheckboxColumn, checkbox_i);
      ui_->tableWidget->setCellWidget(i - 1, kTrackNumberColumn,
                                      new QLabel(QString::number(i)));
      QString track_title = QString("Track %1").arg(i);
      QLineEdit* line_edit_track_title_i =
          new QLineEdit(track_title, ui_->tableWidget);
      track_names_.append(line_edit_track_title_i);
      ui_->tableWidget->setCellWidget(i - 1, kTrackTitleColumn,
                                      line_edit_track_title_i);
    }
  }
  // Get presets
  QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
  qSort(presets.begin(), presets.end(), ComparePresetsByName);
  for (const TranscoderPreset& preset : presets) {
    ui_->format->addItem(
        QString("%1 (.%2)").arg(preset.name_, preset.extension_),
        QVariant::fromValue(preset));
  }

  // Load settings
  QSettings s;
  s.beginGroup(kSettingsGroup);
  last_add_dir_ = s.value("last_add_dir", QDir::homePath()).toString();

  QString last_output_format = s.value("last_output_format", "ogg").toString();
  for (int i = 0; i < ui_->format->count(); ++i) {
    if (last_output_format ==
        ui_->format->itemData(i).value<TranscoderPreset>().extension_) {
      ui_->format->setCurrentIndex(i);
      break;
    }
  }

  ui_->progress_bar->setValue(0);
  ui_->progress_bar->setMaximum(100);
}
コード例 #8
0
ファイル: ripcddialog.cpp プロジェクト: Chemrat/Clementine
RipCDDialog::RipCDDialog(QWidget* parent)
    : QDialog(parent),
      ui_(new Ui_RipCDDialog),
      ripper_(new Ripper(this)),
      working_(false) {
  // Init
  ui_->setupUi(this);

  // Set column widths in the QTableWidget.
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kCheckboxColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(
      kTrackNumberColumn, QHeaderView::ResizeToContents);
  ui_->tableWidget->horizontalHeader()->setResizeMode(kTrackTitleColumn,
                                                      QHeaderView::Stretch);

  // Add a rip button
  rip_button_ = ui_->button_box->addButton(tr("Start ripping"),
                                           QDialogButtonBox::ActionRole);
  cancel_button_ = ui_->button_box->button(QDialogButtonBox::Cancel);
  close_button_ = ui_->button_box->button(QDialogButtonBox::Close);

  // Hide elements
  cancel_button_->hide();
  ui_->progress_group->hide();

  connect(ui_->select_all_button, SIGNAL(clicked()), SLOT(SelectAll()));
  connect(ui_->select_none_button, SIGNAL(clicked()), SLOT(SelectNone()));
  connect(ui_->invert_selection_button, SIGNAL(clicked()),
          SLOT(InvertSelection()));
  connect(rip_button_, SIGNAL(clicked()), SLOT(ClickedRipButton()));
  connect(cancel_button_, SIGNAL(clicked()), ripper_, SLOT(Cancel()));
  connect(close_button_, SIGNAL(clicked()), SLOT(hide()));

  connect(ui_->options, SIGNAL(clicked()), SLOT(Options()));
  connect(ui_->select, SIGNAL(clicked()), SLOT(AddDestination()));

  connect(ripper_, SIGNAL(Finished()), SLOT(Finished()));
  connect(ripper_, SIGNAL(Cancelled()), SLOT(Cancelled()));
  connect(ripper_, SIGNAL(ProgressInterval(int, int)),
          SLOT(SetupProgressBarLimits(int, int)));
  connect(ripper_, SIGNAL(Progress(int)), SLOT(UpdateProgressBar(int)));

  setWindowTitle(tr("Rip CD"));
  AddDestinationDirectory(QDir::homePath());

  // Get presets
  QList<TranscoderPreset> presets = Transcoder::GetAllPresets();
  qSort(presets.begin(), presets.end(), ComparePresetsByName);
  for (const TranscoderPreset& preset : presets) {
    ui_->format->addItem(
        QString("%1 (.%2)").arg(preset.name_).arg(preset.extension_),
        QVariant::fromValue(preset));
  }

  // Load settings
  QSettings s;
  s.beginGroup(kSettingsGroup);
  last_add_dir_ = s.value("last_add_dir", QDir::homePath()).toString();

  QString last_output_format = s.value("last_output_format", "ogg").toString();
  for (int i = 0; i < ui_->format->count(); ++i) {
    if (last_output_format ==
        ui_->format->itemData(i).value<TranscoderPreset>().extension_) {
      ui_->format->setCurrentIndex(i);
      break;
    }
  }
}