void GuiSplitContainer::solvePanelConstraints( Point2I newDragPos, GuiContainer * firstPanel, GuiContainer * secondPanel, RectI clientRect )
{
   if( !firstPanel || !secondPanel )
      return;

   if ( mOrientation == Horizontal )
   {
      // Constrain based on Y axis (Horizontal Splitter)

      // This accounts for the splitter width 
      S32 splitterSize = (S32)(mSplitRect.extent.y * 0.5);

      // Collapsed fixed panel
      if ( mFixedPanel == SecondPanel && !secondPanel->isVisible() )
      {
         newDragPos = Point2I(mSplitPoint.x, getExtent().y - splitterSize );
      }
      else if( mFixedPanel == SecondPanel && !firstPanel->isVisible() )
      {
         newDragPos = Point2I(mSplitPoint.x, splitterSize );
      }
      else // Normal constraints
      {
         //newDragPos.y -= splitterSize;
         S32 newPosition = mClamp( newDragPos.y, 
                                   firstPanel->getMinExtent().y + splitterSize,
                                   getExtent().y - secondPanel->getMinExtent().y - splitterSize );
         newDragPos = Point2I( mSplitPoint.x, newPosition );
      }
   }
   else
   {
      // Constrain based on X axis (Vertical Splitter)

      // This accounts for the splitter width 
      S32 splitterSize = (S32)(mSplitRect.extent.x * 0.5);

      // Collapsed fixed panel
      if ( mFixedPanel == SecondPanel && !secondPanel->isVisible() )
      {
         newDragPos = Point2I(getExtent().x - splitterSize, mSplitPoint.y  );
      }
      else if ( mFixedPanel == FirstPanel && !firstPanel->isVisible() )
      {
         newDragPos = Point2I( splitterSize, mSplitPoint.x );
      }
      else // Normal constraints
      {
         S32 newPosition = mClamp( newDragPos.x, firstPanel->getMinExtent().x + splitterSize,
            getExtent().x - secondPanel->getMinExtent().x - splitterSize );
         newDragPos = Point2I( newPosition, mSplitPoint.y );
      }
   }

   // Just in case, clamp to bounds of controls
   newDragPos.x = mClamp( newDragPos.x, clientRect.point.x, clientRect.point.x + clientRect.extent.x );
   newDragPos.y = mClamp( newDragPos.y, clientRect.point.y, clientRect.point.y + clientRect.extent.y );

   mSplitPoint = newDragPos;
}
Ejemplo n.º 2
0
void GuiEaseViewCtrl::onRender(Point2I offset, const RectI &updateRect)
{
   const F32 W = getExtent().x;
   const F32 H = getExtent().y;
   const F32 plotW = W;
   const F32 plotH = H;
   const F32 zeroX = offset.x + 1.f;
   const F32 zeroY = offset.y;
   
   // Draw axis.

	GFX->getDrawUtil()->drawLine( zeroX,  zeroY + 0.0f,  zeroX,          zeroY + plotH,  mAxisColor );
	GFX->getDrawUtil()->drawLine( zeroX,  zeroY + plotH, zeroX + plotW,  zeroY + plotH,  mAxisColor );
   
	F32 numPoints = W;
	F32 lastX = zeroX;
	F32 lastY = zeroY + plotH;

   // Draw curve.

	for( S32 i = 1; i <= numPoints; ++ i )
	{
		F32 x = ( F32 ) i / ( F32 ) numPoints;
      F32 y = mEase.getValue( x, 0, 1, 1 );

		x = zeroX + x * plotW;
      y = zeroY + plotH - y * plotH;
      
		GFX->getDrawUtil()->drawLine( lastX, lastY, x, y, mEaseColor );

		lastX = x;
		lastY = y;
	}
}
Ejemplo n.º 3
0
TProgram::TProgram() :
    TProgInit( &TProgram::initStatusLine,
                  &TProgram::initMenuBar,
                  &TProgram::initDeskTop
                ),
    TGroup( TRect( 0,0,TScreen::screenWidth,TScreen::screenHeight ) )
{
    application = this;
    initScreen();
    state = sfVisible | sfSelected | sfFocused | sfModal | sfExposed;
    options = 0;
    buffer = TScreen::screenBuffer;

    if( createDeskTop != 0 &&
        (deskTop = createDeskTop( getExtent() )) != 0
      )
        insert(deskTop);

    if( createStatusLine != 0 &&
        (statusLine = createStatusLine( getExtent() )) != 0
      )
        insert(statusLine);

    if( createMenuBar != 0 &&
        (menuBar = createMenuBar( getExtent() )) != 0
      )
        insert(menuBar);

}
Ejemplo n.º 4
0
void ScrollBar::setMajorAxisScrollBarPosition(const Pnt2f& Pos)
{

    UInt16 MajorAxis, MinorAxis;
    if(getOrientation() == ScrollBar::VERTICAL_ORIENTATION)
    {
        MajorAxis = 1;
    }
    else
    {
        MajorAxis = 0;
    }
    MinorAxis = (MajorAxis+1)%2;

    //Calculate the Value Based on the Bar Position
    //Int32 ScrollValue( static_cast<Real32>(Pos - editScrollField()->getPosition()[MajorAxis])/static_cast<Real32>(editScrollField()->getSize()[MajorAxis]) * (getMaximum() - getMinimum()) + getMinimum());
    Int32 ScrollValue(calculateValueFromPosition(Pos));
    if(ScrollValue < getMinimum())
    {
        ScrollValue = getMinimum();
    }
    else if(ScrollValue + getExtent() > getMaximum())
    {
        ScrollValue = getMaximum() - getExtent();
    }
    getRangeModel()->setValue(ScrollValue);
}
Ejemplo n.º 5
0
TProgram::TProgram() :
#ifndef __MSDOS__
    TSystemInit(),
#endif  // !__MSDOS__
    TProgInit( TProgram::initStatusLine,
                  TProgram::initMenuBar,
                  TProgram::initDeskTop
                ),
    TGroup( TRect( 0,0,TScreen::screenWidth,TScreen::screenHeight ) )
{
    application = this;
    initScreen();
    state = sfVisible | sfSelected | sfFocused | sfModal | sfExposed;
    options = 0;
    buffer = (ushort far *)TScreen::screenBuffer;

    if( createDeskTop != 0 &&
        (deskTop = createDeskTop( getExtent() )) != 0
      )
        insert(deskTop);

    if( createStatusLine != 0 &&
        (statusLine = createStatusLine( getExtent() )) != 0
      )
        insert(statusLine);

    if( createMenuBar != 0 &&
        (menuBar = createMenuBar( getExtent() )) != 0
      )
        insert(menuBar);
}
Ejemplo n.º 6
0
TAsciiChart::TAsciiChart() :
        TWindowInit(&TAsciiChart::initFrame), TWindow(TRect(0, 0, 34, 12), "ASCII Chart",
                wnNoNumber) {
    TView *control;

    flags &= ~(wfGrow | wfZoom);
    palette = wpGrayWindow;

    TRect r = getExtent();
    r.grow(-1, -1);
    r.a.y = r.b.y - 1;
    control = new TReport(r);
    control->options |= ofFramed;
    control->eventMask |= evBroadcast;
    insert(control);

    r = getExtent();
    r.grow(-1, -1);
    r.b.y = r.b.y - 2;
    control = new TTable(r);
    control->options |= ofFramed;
    control->options |= ofSelectable;
    control->blockCursor();
    insert(control);
    control->select();
}
Ejemplo n.º 7
0
void GuiPaneControl::setCollapsed(bool isCollapsed)
{
   // Get the child
   if(size() == 0 || !mCollapsable) return;

   GuiControl *gc = dynamic_cast<GuiControl*>(operator[](0));

   if(mCollapsed && !isCollapsed)
   {
      resize(getPosition(), mOriginalExtents);
      mCollapsed = false;

      if(gc)
         gc->setVisible(true);
   }
   else if(!mCollapsed && isCollapsed)
   {
      mCollapsed = true;

      mOriginalExtents = getExtent();
      resize(getPosition(), Point2I(getExtent().x, mThumbSize.y));

      if(gc)
         gc->setVisible(false);
   }
}
void PhysicsQuadTreeSpace::initQuadTree(dSpaceID space)
{
    dVector3 c, e;
    c[0]=getCenter().x();
    c[1]=getCenter().y();
    c[2]=getCenter().z();
    e[0]=getExtent().x();
    e[1]=getExtent().y();
    e[2]=getExtent().z();
    _SpaceID = dQuadTreeSpaceCreate(space, c, e, getDepth());
}
Ejemplo n.º 9
0
//-------------------------------------
void GuiBitmapCtrl::inspectPostApply()
{
   // if the extent is set to (0,0) in the gui editor and appy hit, this control will
   // set it's extent to be exactly the size of the bitmap (if present)
   Parent::inspectPostApply();

   if (!mWrap && (getExtent().x == 0) && (getExtent().y == 0) && mTextureObject)
   {
      setExtent( mTextureObject->getWidth(), mTextureObject->getHeight());
   }
}
Ejemplo n.º 10
0
void GuiTextEditSliderCtrl::onMouseDown(const GuiEvent &event)
{
   // If we're not active then skip out.
   if ( !mActive || !mAwake || !mVisible )
   {
      Parent::onMouseDown(event);
      return;
   }

   char txt[20];
   Parent::getText(txt);
   mValue = dAtof(txt);

   mMouseDownTime = Sim::getCurrentTime();
   GuiControl *parent = getParent();
   if(!parent)
      return;
   Point2I camPos  = event.mousePoint;
   Point2I point = parent->localToGlobalCoord(getPosition());

   if(camPos.x > point.x + getExtent().x - 14)
   {
      if(camPos.y > point.y + (getExtent().y/2))
      {
         mValue -=mIncAmount;
         mTextAreaHit = ArrowDown;
         mMulInc = -0.15f;
      }
      else
      {
         mValue +=mIncAmount;
         mTextAreaHit = ArrowUp;
         mMulInc = 0.15f;
      }

      checkRange();
      setValue();
      mouseLock();

      // We should get the focus and set the 
      // cursor to the start of the text to 
      // mimic the standard Windows behavior.
      setFirstResponder();
      mCursorPos = mBlockStart = mBlockEnd = 0;
      setUpdate();

      return;
   }

   Parent::onMouseDown(event);
}
Ejemplo n.º 11
0
bool GuiSliderCtrl::onWake()
{
   if( !Parent::onWake() )
      return false;
      
   mHasTexture = mProfile->constructBitmapArray() >= NumBitmaps;  
	if( mHasTexture )
   {
      mBitmapBounds = mProfile->mBitmapArrayRects.address();
		mThumbSize = Point2I( mBitmapBounds[ SliderButtonNormal ].extent.x, mBitmapBounds[ SliderButtonNormal ].extent.y );
	}

   F32 value;
   if( mConsoleVariable[ 0 ] )
      value = getFloatVariable();
   else
      value = mValue;

   mValue = mClampF( value, mRange.x, mRange.y );

   // mouse scroll increment percentage is 5% of the range
   mIncAmount = ( ( mRange.y - mRange.x ) * 0.05 );

   if( ( mThumbSize.y + mProfile->mFont->getHeight() - 4 ) <= getExtent().y )
      mDisplayValue = true;
   else
      mDisplayValue = false;

   _updateThumb( mValue, mSnap, true );

   return true;
}
Ejemplo n.º 12
0
bool MgEllipse::_hitTestBox(const Box2d& rect) const
{
    if (!getExtent().isIntersect(rect))
        return false;
    
    return mgnear::beziersIntersectBox(rect, 13, _bzpts, true);
}
Ejemplo n.º 13
0
    DiskLoc ExtentManager::_createExtentInFile( int fileNo, DataFile* f,
                                                int size, int maxFileNoForQuota ) {

        size = ExtentManager::quantizeExtentSize( size );

        if ( maxFileNoForQuota > 0 && fileNo - 1 >= maxFileNoForQuota ) {
            if ( cc().hasWrittenThisPass() ) {
                warning() << "quota exceeded, but can't assert" << endl;
            }
            else {
                _quotaExceeded();
            }
        }

        massert( 10358, "bad new extent size", size >= Extent::minSize() && size <= Extent::maxSize() );

        DiskLoc loc = f->allocExtentArea( size );
        loc.assertOk();

        Extent *e = getExtent( loc, false );
        verify( e );

        getDur().writing(e)->init("", size, fileNo, loc.getOfs(), false);

        return loc;
    }
Ejemplo n.º 14
0
void ScrollGroup::focusSubView(TView* view)
{
	TRect rview = view->getBounds();

	TRect r = getExtent();
	r.intersect(rview);
	if(r != rview)
		{
		int dx, dy;

		dx = delta.x;
		if(view->origin.x < 0)
			dx = delta.x + view->origin.x;
		else if(view->origin.x + view->size.x > size.x)
			dx = delta.x+view->origin.x+view->size.x-size.x;

		dy = delta.y;
		if(view->origin.y < 0)
			dy = delta.y + view->origin.y;
		else if(view->origin.y + view->size.y > size.y)
			dy = delta.y+view->origin.y+view->size.y-size.y;

		scrollTo(dx, dy);
		}
}
Ejemplo n.º 15
0
void GuiGradientCtrl::onRender(Point2I offset, const RectI& updateRect)
{
   if (mStateBlock.isNull())
   {
      GFXStateBlockDesc desc;
      desc.setBlend(true, GFXBlendSrcAlpha, GFXBlendInvSrcAlpha);
      desc.setZReadWrite(false);
      desc.zWriteEnable = false;
      desc.setCullMode(GFXCullNone);
      mStateBlock = GFX->createStateBlock( desc );
   }

   RectI boundsRect(offset, getExtent()); 
   renderColorBox(boundsRect);

   if (mPositionChanged) 
   {
      mPositionChanged = false;

      // Now do onAction() if we are allowed
      if (mActionOnMove) 
			onAction();  
   }
   
   //render the children
   renderChildControls( offset, updateRect);
}
Ejemplo n.º 16
0
TEditWindow::TEditWindow( const TRect& bounds,
                          const char *fileName,
                          int aNumber
                        ) :
    TWindowInit( &TEditWindow::initFrame ),
    TWindow( bounds, 0, aNumber )
{
    options |= ofTileable;

    TScrollBar *hScrollBar =
        new TScrollBar( TRect( 18, size.y - 1, size.x - 2, size.y ) );
    hScrollBar->hide();
    insert(hScrollBar);

    TScrollBar *vScrollBar =
        new TScrollBar( TRect( size.x - 1, 1, size.x, size.y - 1 ) );
    vScrollBar->hide();
    insert(vScrollBar);

    TIndicator *indicator =
        new TIndicator( TRect( 2, size.y - 1, 16, size.y ) );
    indicator->hide();
    insert(indicator);


    TRect r( getExtent() );
    r.grow(-1, -1);
    editor = new TFileEditor( r, hScrollBar, vScrollBar, indicator, fileName );
    insert(editor);
}
Ejemplo n.º 17
0
    Extent* ExtentManager::_createExtentInFile( int fileNo, DataFile* f,
                                                const char* ns, int size, bool newCapped,
                                                bool enforceQuota ) {

        size = ExtentManager::quantizeExtentSize( size );

        if ( enforceQuota ) {
            if ( fileIndexExceedsQuota( ns, fileNo - 1 ) ) {
                if ( cc().hasWrittenThisPass() ) {
                    warning() << "quota exceeded, but can't assert "
                              << " going over quota for: " << ns << " " << fileNo << endl;
                }
                else {
                    _quotaExceeded();
                }
            }
        }

        massert( 10358, "bad new extent size", size >= Extent::minSize() && size <= Extent::maxSize() );

        DiskLoc loc = f->allocExtentArea( size );
        loc.assertOk();

        Extent *e = getExtent( loc, false );
        verify( e );

        DiskLoc emptyLoc = getDur().writing(e)->init(ns, size, fileNo, loc.getOfs(), newCapped);

        addNewExtentToNamespace(ns, e, loc, emptyLoc, newCapped);

        LOG(1) << "ExtentManager: creating new extent for: " << ns << " in file: " << fileNo
               << " size: " << size << endl;

        return e;
    }
    DiskLoc DummyExtentManager::allocateExtent( OperationContext* txn,
                                                bool capped,
                                                int size,
                                                bool enforceQuota ) {
        size = quantizeExtentSize( size );

        ExtentInfo info;
        info.data = static_cast<char*>( malloc( size ) );
        info.length = size;

        DiskLoc loc( _extents.size(), 0 );
        _extents.push_back( info );

        Extent* e = getExtent( loc, false );
        e->magic = Extent::extentSignature;
        e->myLoc = loc;
        e->xnext.Null();
        e->xprev.Null();
        e->length = size;
        e->firstRecord.Null();
        e->lastRecord.Null();

        return loc;

    }
Ejemplo n.º 19
0
void GuiConsoleTextCtrl::onRender( Point2I offset, const RectI &updateRect )
{
   RectI ctrlRect( offset, getExtent() );

   // if opaque, fill the update rect with the fill color
   if ( mProfile->mOpaque )
      GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColor );

   // if there's a border, draw the border
   if ( mProfile->mBorder )
      renderBorder( ctrlRect, mProfile );

   // If we have text to render.
   if ( mResult.isNotEmpty() )
   {
      GFont *font = mProfile->mFont;      
      
      GFX->getDrawUtil()->setBitmapModulation( mProfile->mFontColor );

      for ( U32 i = 0; i < mLineLen.size(); i++ )
      {      
         Point2I tempOffset = offset; 
         tempOffset += mProfile->mTextOffset;
         tempOffset.y += i * font->getHeight();
         
         const UTF8 *line = mResult.c_str() + mStartLineOffset[i];
         U32 lineLen = mLineLen[i];
         GFX->getDrawUtil()->drawTextN( font, tempOffset, line, lineLen, mProfile->mFontColors );
      }
   }

   // render the child controlsmResult
   renderChildControls(offset, updateRect);
}
Ejemplo n.º 20
0
void GuiTextEditCtrl::onRender( Point2I offset, const RectI &updateRect )
{
   RectI ctrlRect( offset, getExtent() );

   //if opaque, fill the update rect with the fill color
   if ( mProfile->mOpaque )
   {
      if ( !mTextValid )
         GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorERR );
      else if ( isFirstResponder() )
         GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorHL );
      else
         GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColor );
   }

   //if there's a border, draw the border
   if ( mProfile->mBorder )
   {
      renderBorder( ctrlRect, mProfile );
      if ( !mTextValid )
         GFX->getDrawUtil()->drawRectFill( ctrlRect, mProfile->mFillColorERR );
   }

   drawText( ctrlRect, isFirstResponder() );
}
Ejemplo n.º 21
0
bool GuiSplitContainer::resize( const Point2I &newPosition, const Point2I &newExtent )
{
   // Save previous extent.
   Point2I oldExtent = getExtent();

   // Resize ourselves.
   if ( !Parent::resize( newPosition, newExtent ) || size() < 2 )
      return false;

   GuiContainer *panelOne = dynamic_cast<GuiContainer*>( at(0) );
   GuiContainer *panelTwo = dynamic_cast<GuiContainer*>( at(1) );
	
   // 
   AssertFatal( panelOne && panelTwo, "GuiSplitContainer::resize - Missing/Invalid Subordinate Controls! Split contained controls must derive from GuiContainer!" );

   // We only need to update the split point if our second panel is fixed.  
   // If the first is fixed, then we can leave the split point alone because
   // the remainder of the size will be added to or taken from the second panel
   Point2I newDragPos;
   if ( mFixedPanel == SecondPanel )
   {      
      S32 deltaX = newExtent.x - oldExtent.x;
      S32 deltaY = newExtent.y - oldExtent.y;

      if( mOrientation == Horizontal )
         mSplitPoint.y += deltaY;
      else
         mSplitPoint.x += deltaX;
   }

   // If we got here, parent returned true
   return true;
}
Ejemplo n.º 22
0
void GuiSwatchButtonCtrl::onRender( Point2I offset, const RectI &updateRect )
{
   bool highlight = mMouseOver;

   ColorI borderColor = mActive ? ( highlight ? mProfile->mBorderColorHL : mProfile->mBorderColor ) : mProfile->mBorderColorNA;

   RectI renderRect( offset, getExtent() );
   if ( !highlight )
      renderRect.inset( 1, 1 );      

   GFXDrawUtil *drawer = GFX->getDrawUtil();
   drawer->clearBitmapModulation();

   // Draw background transparency grid texture...
   if ( mGrid.isValid() )
      drawer->drawBitmapStretch( mGrid, renderRect );

   // Draw swatch color as fill...
   if (!mUseSRGB)
      drawer->drawRectFill( renderRect, mSwatchColor.toGamma() );
   else
      drawer->drawRectFill(renderRect, mSwatchColor);

   // Draw any borders...
   drawer->drawRect( renderRect, borderColor );
}
Ejemplo n.º 23
0
void GuiSliderCtrl::_updateThumb( F32 _value, bool snap, bool onWake, bool doCallback )
{      
   if( snap && mTicks > 0 )
   {
      // If the shift key is held, snap to the nearest tick, if any are being drawn

      F32 tickStep = (mRange.y - mRange.x) / F32(mTicks + 1);

      F32 tickSteps = (_value - mRange.x) / tickStep;
      S32 actualTick = S32(tickSteps + 0.5);

      _value = actualTick * tickStep + mRange.x;
   }
   
   // Clamp the thumb to legal values.

   if( _value < mRange.x )
      _value = mRange.x;
   if( _value > mRange.y )
      _value = mRange.y;
      
   // If value hasn't changed and this isn't the initial update on
   // waking, do nothing.

   if( mValue == _value && !onWake )
      return;

   mValue = _value;

   Point2I ext = getExtent();
	ext.x -= ( mShiftExtent + mThumbSize.x ) / 2;
   // update the bounding thumb rect
   if (getWidth() >= getHeight())
   {  // HORZ thumb
      S32 mx = (S32)((F32(ext.x) * (mValue-mRange.x) / (mRange.y-mRange.x)));
      S32 my = ext.y/2;
      if(mDisplayValue)
         my = mThumbSize.y/2;

      mThumb.point.x  = mx - (mThumbSize.x/2);
      mThumb.point.y  = my - (mThumbSize.y/2);
      mThumb.extent   = mThumbSize;
   }
   else
   {  // VERT thumb
      S32 mx = ext.x/2;
      S32 my = (S32)((F32(ext.y) * (mValue-mRange.x) / (mRange.y-mRange.x)));
      mThumb.point.x  = mx - (mThumbSize.y/2);
      mThumb.point.y  = my - (mThumbSize.x/2);
      mThumb.extent.x = mThumbSize.y;
      mThumb.extent.y = mThumbSize.x;
   }
   
   setFloatVariable(mValue);
   setUpdate();

   // Use the alt console command if you want to continually update:
   if ( !onWake && doCallback )
      execAltConsoleCallback();
}
Ejemplo n.º 24
0
bool ComponentExtent::realIntersect(Vector const & begin, Vector const & end, Vector * surfaceNormal, real * time) const
{
	float bestTime = REAL_MAX;
	bool hit = false;

	int const numberOfExtents = getExtentCount();
	for (int i = 0; i < numberOfExtents; ++i)
	{
		Vector normal;
		float t;
		Vector * const normalPtr = (surfaceNormal != 0) ? &normal : 0;
		BaseExtent const * const extent = getExtent(i);
		if (extent->intersect(begin, end, normalPtr, &t))
		{
			if (t < bestTime)
			{
				if (surfaceNormal) 
					*surfaceNormal = normal;

				if (time) 
					*time = t;

				bestTime = t;
			}

			hit = true;
		}
	}

	return hit;
}
Ejemplo n.º 25
0
    DiskLoc MmapV1ExtentManager::_createExtentInFile( TransactionExperiment* txn,
                                                int fileNo,
                                                DataFile* f,
                                                int size,
                                                int maxFileNoForQuota ) {

        size = MmapV1ExtentManager::quantizeExtentSize( size );

        if ( maxFileNoForQuota > 0 && fileNo - 1 >= maxFileNoForQuota ) {
            if ( cc().hasWrittenSinceCheckpoint() ) {
                warning() << "quota exceeded, but can't assert" << endl;
            }
            else {
                _quotaExceeded();
            }
        }

        massert( 10358, "bad new extent size", size >= minSize() && size <= maxSize() );

        DiskLoc loc = f->allocExtentArea( txn, size );
        loc.assertOk();

        Extent *e = getExtent( loc, false );
        verify( e );

        *txn->writing(&e->magic) = Extent::extentSignature;
        *txn->writing(&e->myLoc) = loc;
        *txn->writing(&e->length) = size;

        return loc;
    }
Ejemplo n.º 26
0
void *TGroup::read( ipstream& is )
{
    ushort index;

    TView::read( is );
    clip = getExtent();
    TGroup *ownerSave = owner;
    owner = this;
    last = 0;
    phase = TView::phFocused;
    current = 0;
    buffer = 0;
    lockFlag = 0;
    endState = 0;
    int count;
    is >> count;
    TView *tv;
    for( int i = 0; i < count; i++ )
        {
        is >> tv;
        if( tv != 0 )
            insertView( tv, 0 );
        }
    owner = ownerSave;
    TView *current;
    is >> index;
    current = at(index);
    setCurrent( current, TView::normalSelect );
    if (ownerGroup == NULL)
        awaken();
    return this;
}
Ejemplo n.º 27
0
void Graphic::GetCenter (float& x, float& y) {
    FullGraphic gs;
    float l, b, tol;

    totalGS(gs);
    getExtent(l, b, x, y, tol, &gs);
}
Ejemplo n.º 28
0
bool MgShapeDoc::save(MgStorage* s, int startIndex) const
{
    bool ret = true;
    Box2d rect;

    if (!s || !s->writeNode("shapedoc", -1, false)) {
        return false;
    }

    if (startIndex == 0) {
        s->writeFloatArray("transform", &im->xf.m11, 6);
        s->writeFloatArray("pageExtent", im->rectWInitial.isEmpty() ?
                           &im->rectW.xmin : &im->rectWInitial.xmin, 4);
        s->writeFloat("viewScale", im->viewScale);
        rect = getExtent();
        s->writeFloatArray("extent", &rect.xmin, 4);
        s->writeInt("count", (int)im->layers.size());
    }

    for (unsigned i = 0; i < im->layers.size(); i++) {
        ret = im->layers[i]->save(s, startIndex) || ret;
        startIndex = -1;
    }

    s->writeNode("shapedoc", -1, true);

    return ret;
}
Ejemplo n.º 29
0
bool GuiInspectorDynamicField::updateRects()
{   
   Point2I fieldExtent = getExtent();   
   S32 dividerPos, dividerMargin;
   mInspector->getDivider( dividerPos, dividerMargin );

   S32 editWidth = dividerPos - dividerMargin;

   mEditCtrlRect.set( fieldExtent.x - dividerPos + dividerMargin, 1, editWidth, fieldExtent.y - 1 );
   mCaptionRect.set( 0, 0, fieldExtent.x - dividerPos - dividerMargin, fieldExtent.y );
   mValueRect.set( mEditCtrlRect.point, mEditCtrlRect.extent - Point2I( 20, 0 ) );
   mDeleteRect.set( fieldExtent.x - 20, 2, 16, fieldExtent.y - 4 );

   // This is probably being called during Parent::onAdd
   // so our special controls haven't been created yet but are just about to
   // so we just need to calculate the extents.
   if ( mRenameCtrl == NULL )
      return false;

   bool sized0 = mRenameCtrl->resize( mCaptionRect.point, mCaptionRect.extent );
   bool sized1 = mEdit->resize( mValueRect.point, mValueRect.extent );
   bool sized2 = mDeleteButton->resize(Point2I(getWidth() - 20,2), Point2I(16, 16));

   return ( sized0 || sized1 || sized2 );
}
Ejemplo n.º 30
0
bool CLine2d::intersects(const CLine2d& otherLine) const
{
   bool retval = false;

   if (getExtent().intersects(otherLine.getExtent()))
   {
      int ccw0 = ccw(otherLine.m_p0) * ccw(otherLine.m_p1);

      if (ccw0 == 0)
      {
         retval = true;
      }
      else
      {
         int ccw1 = otherLine.ccw(m_p0) * otherLine.ccw(m_p1);

         if (ccw1 == 0)
         {
            retval = true;
         }
         else
         {
            retval = ((ccw0 < 0) && (ccw1 < 0));
         }
      }
   }

   return retval;
}