QRegion::QRegion( const QPointArray &a, bool winding )
{
    data = new QRegionData;
    Q_CHECK_PTR( data );
    data->hgt = 0;
    data->is_null = FALSE;
    QRect r = a.boundingRect();
    if ( a.isEmpty() || r.isEmpty() ) {
	data->rgn = 0;
    } else {
        HPS hps = qt_display_ps();
        POINTL *pts = new POINTL[ a.size() ]; 
        for ( uint i = 0; i < a.size(); ++ i ) {
            pts[i].x = a[i].x();
            pts[i].y = - (a[i].y() + 1);
        }
        // GpiCreatePolygonRegion() is bogus and always starts a poligon from
        // the current position. Make the last point the current one and reduce
        // the number of points by one.
        GpiMove( hps, &pts[ a.size() - 1 ] );
        POLYGON poly = { a.size() - 1, pts };
        ULONG opts = winding ? POLYGON_WINDING : POLYGON_ALTERNATE;
        data->rgn = GpiCreatePolygonRegion( hps, 1, &poly, opts );
        delete[] pts;
    }
}
Esempio n. 2
0
void KIconEditGrid::drawPointArray(QPointArray a, DrawAction action)
{
  QRect rect = a.boundingRect();
  bool update = false;

  int s = a.size(); //((rect.size().width()) * (rect.size().height()));
  for(int i = 0; i < s; i++)
  {
    int x = a[i].x();
    int y = a[i].y();
    //if(img->valid(x, y) && !QSize(x, y).isNull() && rect.contains(QPoint(x, y)))
    if(img->valid(x, y) && rect.contains(QPoint(x, y)))
    {
      //debug("x: %d - y: %d", x, y);
      switch( action )
      {
        case Draw:
        {
          *((uint*)img->scanLine(y) + x) = currentcolor; //colors[cell]|OPAQUE;
          int cell = y * numCols() + x;
          setColor( cell, currentcolor, false );
          modified = true;
          update = true;
          //updateCell( y, x, FALSE );
          break;
        }
        case Mark:
        case UnMark:
          repaint(x*cellsize,y*cellsize, cellsize, cellsize, false);
          //updateCell( y, x, true );
          break;
        default:
          break;
      }
    }
  }
  if(update)
  {
    updateColors();
    repaint(rect.x()*cellSize()-1, rect.y()*cellSize()-1,
        rect.width()*cellSize()+1, rect.height()*cellSize()+1, false);
    pntarray.resize(0);
  }

}