示例#1
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() );
}
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);
}
示例#3
0
/**
  Second phase constructor for CParentTestAppView class.\n
  Creates a control's window. The created window is the child of the application's window group.\n
  Sets the view's extent i.e dimensions.\n
  Instantiates a component control of CSimpleParentControl class.\n
  The AppView object is added as the container control for the component control.\n
*/
void CParentTestAppView::ConstructL(const TRect& aRect)
    {
	CreateWindowL();
	SetRect(aRect);
	TRect ctrlRect(10, 10, 20, 20);
	
	iSimpleParentControl = CSimpleParentControl::NewL(*this, ctrlRect);
	iSimpleParentControl->SetContainerWindowL(*this);
		
	}
示例#4
0
/**
  Second phase constructor for CLayoutTestAppView class.\n
  Creates a control's window. The created window is the child of the application's window group.\n
  Sets the view's extent i.e dimenstions.\n
  Instantiates Component controls each of CTest5Control class.\n
  Each component control is appended to a control array.\n
  The AppView object is added as the container control for all the component controls.\n
  The Appview is activated.\n
*/
void CLayoutTestAppView::ConstructL(CLayoutTest* aLayoutMan, const TRect& aRect)
    {
	CreateWindowL();
	SetRect(aRect);
	TRect ctrlRect(10, 10, 20, 20);
	for (TInt ctrlCount = 0; ctrlCount < KNumControls; ctrlCount++)
		{
		CTest5Control* testCtrl = CTest5Control::NewL(aLayoutMan, *this, ctrlRect);
		iCtrlArray.Append(testCtrl);
		testCtrl->SetContainerWindowL(*this);
		TPoint offset(20, 0);
		ctrlRect.iTl += offset;
		ctrlRect.iBr += offset;
		}	
	ActivateL();
	TRect rect(TPoint(0,0), aRect.iBr - TPoint(1,1));
 	SetRect(rect);
	}
示例#5
0
/**
 * Hides the specified form line, if it does not fit to the specified clipping rectangle.
 * The function never hides focused editable lines. If the form layout is single, the whole
 * captioned control is hidden.
 *
 * @param aControl The form line to be hidden
 * @param aClipRect The clipping rectangle
 *
 * @return How many subcontrols remained visible
 */
static TInt HideLines(CEikCaptionedControl *aControl, TRect aClipRect)
{
    TInt visibleCtrls = 3; // Visible subcontrols after hiding
    CEikCaptionedControl *currentdLine = aControl->DialogPage()->CurrentLine();
    if( ( aControl == currentdLine ) && aControl->iIsEditable )
    {
        return visibleCtrls;
    }

    TBool isEdwin = aControl->ControlIsAnEdwin(aControl->iControlType);
    CEikEdwin* edwin( NULL );
    if( isEdwin )
        edwin = (CEikEdwin*)aControl->iControl;
    TRect ctrlRect( aControl->iControl->Rect() );

    if( isEdwin )
    {
        // Adjust rectangle only to the first line (with edwin's top margin)
        TRect textFirstLine;
        edwin->TextLayout()->GetLineRect(ctrlRect.iTl.iY, textFirstLine);
        ctrlRect.iBr.iY = ctrlRect.iTl.iY + edwin->Margins().iTop + textFirstLine.Height();
    }

    // Find the minimal clipping rectangle
    if( aControl->iBitmap )
        GetVertMinRect( aClipRect, aControl->iBitmap->Rect() );
    if( aControl->iCaption )
        GetVertMinRect( aClipRect, aControl->iCaption->Rect() );
    GetVertMinRect( aClipRect, ctrlRect );



    // Try to hide all controls on the current line
    aControl->SetPartiallyVisible( ETrue );
    visibleCtrls -= HideLines_Ctrl( aControl->iBitmap, aClipRect );
    visibleCtrls -= HideLines_Ctrl( aControl->iCaption, aClipRect );
    if( isEdwin )
        visibleCtrls -= HideLines_Edwin( edwin, aClipRect );
    else
        visibleCtrls -= HideLines_Ctrl( aControl->iControl, aClipRect );
    return visibleCtrls;
}
示例#6
0
/**
  Auxilliary Function performing the layout for a control.\n
  Checks if the used up width and height are less that than the available width and height respectively.\n
  If yes, initializes the top left and bottom right coordinates of the control 
  and assigns the same to the control's extent.\n
  
  @return KErrNone if successful else KErrTooBig
*/
TInt CLayoutTest::LayoutControl(TUint aCurCtrlIndex, TSize aCtrlSize)
	{
	TInt layoutSuccess = KErrNone;
	// check that we haven't used all the space left on the screen
	if (((iSizeUsed.iWidth + aCtrlSize.iWidth + KHorizontalBorder) <= iLayoutRect.Width()) &&
		((iSizeUsed.iHeight + aCtrlSize.iHeight + KVerticalBorder) <= iLayoutRect.Height()))
		{
		TPoint topLeft(iSizeUsed.iWidth + KHorizontalBorder, iSizeUsed.iHeight + KVerticalBorder);
		TPoint bottomRight(iSizeUsed.iWidth + aCtrlSize.iWidth + KHorizontalBorder, 
						   iSizeUsed.iHeight + aCtrlSize.iHeight + KVerticalBorder);
		TRect ctrlRect(topLeft, bottomRight);
		CCoeControl* ctrl = iCtrlArray[aCurCtrlIndex];
		ctrl->SetRect(ctrlRect);
		iControlsCompleted++;
		}
	else
		{
		layoutSuccess = KErrTooBig;
		}
	return layoutSuccess;
	}
void GuiProgressCtrl::onRender(Point2I offset, const RectI &updateRect)
{
    RectI ctrlRect(offset, getExtent());

    //draw the progress
    S32 width = (S32)((F32)(getWidth()) * mProgress);
    if (width > 0)
    {
        RectI progressRect = ctrlRect;
        progressRect.extent.x = width;
        GFX->getDrawUtil()->drawRectFill(progressRect, mProfile->mFillColor);
    }

    //now draw the border
    if (mProfile->mBorder)
        GFX->getDrawUtil()->drawRect(ctrlRect, mProfile->mBorderColor);

    Parent::onRender( offset, updateRect );

    //render the children
    renderChildControls(offset, updateRect);
}
示例#8
0
文件: panel.cpp 项目: Logout22/Escape
	void Panel::paint(Graphics &g) {
		bool dirty = UIElement::isDirty();
		Rectangle prect = g.getPaintRect();
		bool ispart = prect.getSize() != getSize();
		paintBackground(g);

		// now paint controls
		for(auto it = _controls.begin(); it != _controls.end(); ++it) {
			shared_ptr<Control> c = *it;
			c->makeDirty(dirty);
			if(!c->isDirty() || ispart) {
				Rectangle ctrlRect(c->getPos(),c->getSize());
				Rectangle inter = intersection(ctrlRect,prect);
				if(!inter.empty()) {
					c->makeDirty(true);
					c->repaintRect(inter.getPos() - c->getPos(),inter.getSize(),false);
				}
			}
			else
				c->repaint(false);
		}
	}
示例#9
0
void GuiInspectorField::onRender( Point2I offset, const RectI &updateRect )
{
   RectI ctrlRect(offset, getExtent());
   
   // Render fillcolor...
   if ( mProfile->mOpaque )
      GFX->getDrawUtil()->drawRectFill(ctrlRect, mProfile->mFillColor);   

   // Render caption...
   if ( mCaption && mCaption[0] )
   {      
      // Backup current ClipRect
      RectI clipBackup = GFX->getClipRect();

      RectI clipRect = updateRect;

      // The rect within this control in which our caption must fit.
      RectI rect( offset + mCaptionRect.point + mProfile->mTextOffset, mCaptionRect.extent + Point2I(1,1) - Point2I(5,0) );

      // Now clipRect is the amount of our caption rect that is actually visible.
      bool hit = clipRect.intersect( rect );

      if ( hit )
      {
         GFX->setClipRect( clipRect );
         GFXDrawUtil *drawer = GFX->getDrawUtil();

         // Backup modulation color
         ColorI currColor;
         drawer->getBitmapModulation( &currColor );

         // Draw caption background...
         if( !isActive() )
            GFX->getDrawUtil()->drawRectFill( clipRect, mProfile->mFillColorNA );
         else if ( mHighlighted )         
            GFX->getDrawUtil()->drawRectFill( clipRect, mProfile->mFillColorHL );             

         // Draw caption text...

         drawer->setBitmapModulation( !isActive() ? mProfile->mFontColorNA : mHighlighted ? mProfile->mFontColorHL : mProfile->mFontColor );
         
         // Clip text with '...' if too long to fit
         String clippedText( mCaption );
         clipText( clippedText, clipRect.extent.x );

         renderJustifiedText( offset + mProfile->mTextOffset, getExtent(), clippedText );

         // Restore modulation color
         drawer->setBitmapModulation( currColor );

         // Restore previous ClipRect
         GFX->setClipRect( clipBackup );
      }
   }

   // Render Children...
   renderChildControls(offset, updateRect);

   // Render border...
   if ( mProfile->mBorder )
      renderBorder(ctrlRect, mProfile);   

   // Render divider...
   Point2I worldPnt = mEditCtrlRect.point + offset;
   GFX->getDrawUtil()->drawLine( worldPnt.x - 5,
      worldPnt.y, 
      worldPnt.x - 5,
      worldPnt.y + getHeight(),
      !isActive() ? mProfile->mBorderColorNA : mHighlighted ? mProfile->mBorderColorHL : mProfile->mBorderColor );
}
示例#10
0
void GuiProgressBitmapCtrl::onRender(Point2I offset, const RectI &updateRect)
{	
	RectI ctrlRect(offset, getExtent());
	
	//grab lowest dimension
	if(getHeight() <= getWidth())
		mDim = getHeight();
	else
		mDim = getWidth();

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

	if(mNumberOfBitmaps == 1)
	{
		//draw the progress with image
		S32 width = (S32)((F32)(getWidth()) * mProgress);
		if (width > 0)
		{
			//drawing stretch bitmap
			RectI progressRect = ctrlRect;
			progressRect.extent.x = width;
			drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[0]);
		}
	}
	else if(mNumberOfBitmaps >= 3)
	{
		//drawing left-end bitmap
		RectI progressRectLeft(ctrlRect.point.x, ctrlRect.point.y, mDim, mDim);
		drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectLeft, mProfile->mBitmapArrayRects[0]);

		//draw the progress with image
		S32 width = (S32)((F32)(getWidth()) * mProgress);
		if (width > mDim)
		{
			//drawing stretch bitmap
			RectI progressRect = ctrlRect;
			progressRect.point.x +=  mDim;
			progressRect.extent.x = (width - mDim - mDim);
			if (progressRect.extent.x < 0)
				progressRect.extent.x = 0;
			drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRect, mProfile->mBitmapArrayRects[1]);
		
			//drawing right-end bitmap
			RectI progressRectRight(progressRect.point.x + progressRect.extent.x, ctrlRect.point.y, mDim, mDim );
			drawUtil->drawBitmapStretchSR(mProfile->mTextureObject, progressRectRight, mProfile->mBitmapArrayRects[2]);
		}
	}
	else
		Con::warnf("guiProgressBitmapCtrl only processes an array of bitmaps == 1 or >= 3");

	//if there's a border, draw it
   if (mProfile->mBorder)
      drawUtil->drawRect(ctrlRect, mProfile->mBorderColor);

   Parent::onRender( offset, updateRect );

   //render the children
   renderChildControls(offset, updateRect);
	
}