void QgsComposerMapWidget::updateComposerExtentFromGui()
{
  if ( !mComposerMap )
  {
    return;
  }

  double xmin, ymin, xmax, ymax;
  bool conversionSuccess;

  xmin = mXMinLineEdit->text().toDouble( &conversionSuccess );
  if ( !conversionSuccess )
    return;
  xmax = mXMaxLineEdit->text().toDouble( &conversionSuccess );
  if ( !conversionSuccess )
    return;
  ymin = mYMinLineEdit->text().toDouble( &conversionSuccess );
  if ( !conversionSuccess )
    return;
  ymax = mYMaxLineEdit->text().toDouble( &conversionSuccess );
  if ( !conversionSuccess )
    return;

  QgsRectangle newExtent( xmin, ymin, xmax, ymax );
  mComposerMap->beginCommand( tr( "Map extent changed" ) );
  mComposerMap->setNewExtent( newExtent );
  mComposerMap->endCommand();
}
void GuiTextListCtrl::setSize(Point2I newSize)
{
   mSize = newSize;

   if ( bool( mFont ) )
   {
      if ( mSize.x == 1 && mFitParentWidth )
      {
         GuiScrollCtrl* parent = dynamic_cast<GuiScrollCtrl *>(getParent());
         if ( parent )
            mCellSize.x = parent->getContentExtent().x;
      }
      else
      {
         // Find the maximum width cell:
         S32 maxWidth = 1;
         for ( U32 i = 0; i < mList.size(); i++ )
         {
            U32 rWidth = getRowWidth( &mList[i] );
            if ( rWidth > maxWidth )
               maxWidth = rWidth;
         }

         mCellSize.x = maxWidth + 8;
      }

      mCellSize.y = mFont->getHeight() + 2;
   }

   Point2I newExtent( newSize.x * mCellSize.x + mHeaderDim.x, newSize.y * mCellSize.y + mHeaderDim.y );
   setExtent( newExtent );
}
void ArrayCtrl::setSize(Point2I newSize)
{
   size = newSize;
   Point2I newExtent(newSize.x * cellSize.x + headerDim.x, newSize.y * cellSize.y + headerDim.y);

   resize(position, newExtent);
}
/*! \brief Allocates the next available extent of given length.

	\param length The desired length (in bytes) of the extent.
	\param contiguous If false, signals that an extent of shorter length will
	                  be accepted. This allows for small chunks of
	                  unallocated space to be consumed, provided a
	                  contiguous chunk is not needed.
	\param extent Output parameter into which the extent as allocated
	              is stored. Note that the length field of the extent
	              may be shorter than the length parameter passed
	              to this function is \a contiguous is false.
	\param minimumStartingBlock The minimum acceptable starting block
	                            for the extent (used by the physical
	                            partition allocator).

	\return
	- B_OK: Success.
	- error code: Failure.
*/
status_t
Allocator::GetNextExtent(uint32 _length, bool contiguous,
                         Udf::extent_address &extent,
                         uint32 minimumStartingBlock)
{
    DEBUG_INIT_ETC("Allocator", ("length: %lld, contiguous: %d", _length, contiguous));
    uint32 length = BlocksFor(_length);
    bool isPartial = false;
    status_t error = InitCheck();
    PRINT(("allocation length: %lu\n", Length()));
    if (!error) {
        for (list<Udf::extent_address>::iterator i = fChunkList.begin();
                i != fChunkList.end();
                i++)
        {
            uint32 chunkOffset = i->location();
            uint32 chunkLength = BlocksFor(i->length());
            if (chunkOffset < minimumStartingBlock)
            {
                if (minimumStartingBlock < chunkOffset+chunkLength) {
                    // Start of chunk is below min starting block. See if
                    // any part of the chunk would make for an acceptable
                    // allocation
                    uint32 difference = minimumStartingBlock - chunkOffset;
                    uint32 newOffset = minimumStartingBlock;
                    uint32 newLength = chunkLength-difference;
                    if (length <= newLength) {
                        // new chunk is still long enough
                        Udf::extent_address newExtent(newOffset, _length);
                        if (GetExtent(newExtent) == B_OK) {
                            extent = newExtent;
                            return B_OK;
                        }
                    } else if (!contiguous) {
                        // new chunk is too short, but we're allowed to
                        // allocate a shorter extent, so we'll do it.
                        Udf::extent_address newExtent(newOffset, newLength<<BlockShift());
                        if (GetExtent(newExtent) == B_OK) {
                            extent = newExtent;
                            return B_OK;
                        }
                    }
                }
            } else if (length <= chunkLength) {
                // Chunk is larger than necessary. Allocate first
                // length blocks, and resize the chunk appropriately.
                extent.set_location(chunkOffset);
                extent.set_length(_length);
                if (length != chunkLength) {
                    i->set_location(chunkOffset+length);
                    i->set_length((chunkLength-length)<<BlockShift());
                } else {
                    fChunkList.erase(i);
                }
                return B_OK;
            } else if (!contiguous) {
                extent.set_location(chunkOffset);
                extent.set_length(chunkLength<<BlockShift());
                fChunkList.erase(i);
                return B_OK;
            }
        }
        // No sufficient chunk found, so try to allocate from the tail
        PRINT(("ULONG_MAX: %lu\n", ULONG_MAX));
        uint32 maxLength = ULONG_MAX-Length();
        PRINT(("maxLength: %lu\n", maxLength));
        error = maxLength > 0 ? B_OK : B_DEVICE_FULL;
        if (!error) {
            if (minimumStartingBlock > Tail())
                maxLength -= minimumStartingBlock - Tail();
            uint32 tail = minimumStartingBlock > Tail() ? minimumStartingBlock : Tail();
            if (length > maxLength) {
                if (contiguous)
                    error = B_DEVICE_FULL;
                else {
                    isPartial = true;
                    length = maxLength;
                }
            }
            if (!error) {
                Udf::extent_address newExtent(tail, isPartial ? length<<BlockShift() : _length);
                if (GetExtent(newExtent) == B_OK) {
                    extent = newExtent;
                    return B_OK;
                }
            }
        }
    }
    return error;
}