예제 #1
0
void DigitView::addHandles(const QRect &bounds)
{
  m_handles.clear();

  // show eight handles that represent the bounding rectangle for the selected items. we
  // do not put handles on each point since the points can be too small to fit the
  // handles, and also that would be slower
  for (int i = 0; i < 9; i++)
  {
    QSize handleSize = DefaultSettings::instance().getHandleSize();
    int handleWidth = handleSize.width();
    int handleHeight = handleSize.height();
    
    // looping clockwise starting at top right point
    int x, y;
    if (i < 3)
      x = bounds.left() + bounds.width();
    else if ((i == 3) || (i == 7))
      x = bounds.left() + (bounds.width() + 1) / 2 - handleWidth / 2;
    else
      x = bounds.left() - handleWidth;
    if ((1 < i) && (i < 5))
      y = bounds.top() + bounds.height();
    else if ((i == 1) || (i == 5))
      y = bounds.top() + (bounds.height() + 1) / 2 - handleHeight / 2;
    else
      y = bounds.top() - handleHeight;
    ASSERT_ENGAUGE(document() != 0);
    Q3CanvasRectangle* handle = new Q3CanvasRectangle(x, y, handleWidth, handleHeight, document()->canvas());
    CHECK_PTR_ENGAUGE(handle);
    handle->setBrush(QBrush(Qt::green));
    handle->setPen(QPen(Qt::black, 1));
    handle->setZ(ZHandles);
    handle->show();

    update(0, handle->boundingRect());

    m_handles.append(handle);
  }
}