Beispiel #1
0
void nuiDecoration::GlobalToClientRect(nuiRect& rRect, const nuiWidget* pWidget) const
{
    nuiRect clientRect = GetIdealClientRect(pWidget);
//  nuiSize bordertop = GetBorder(nuiTop, pWidget);
//  nuiSize borderleft = GetBorder(nuiLeft, pWidget);
    nuiSize borderright = GetBorder(nuiRight, pWidget);
    nuiSize borderbottom = GetBorder(nuiBottom, pWidget);


    float X1 = (float)clientRect.Left();
    float X2 = (float)clientRect.Right();
    float X3 = (float)clientRect.Right()+borderright;

    float Y1 = (float)clientRect.Top();
    float Y2 = (float)clientRect.Bottom();
    float Y3 = (float)clientRect.Bottom()+borderbottom;

    const float x0 = (float)rRect.Left();
    const float x1 = x0 + X1;
    const float x3 = (float)rRect.Right();
    const float x2 = x3 - (X3 - X2);

    const float y0 = (float)rRect.Top();
    const float y1 = y0 + Y1;
    const float y3 = (float)rRect.Bottom();
    const float y2 = y3 - (Y3 - Y2);

    rRect.Set(x1, y1, x2, y2, false);
}
Beispiel #2
0
void nuiPainter::LoadProjectionMatrix(const nuiRect& rViewport, const nuiMatrix& rMatrix)
{
  NGL_ASSERT(!mProjectionMatrixStack.empty());
  mProjectionMatrixStack.top() = rMatrix;

  nuiMatrix LocalMatrix(mMatrixStack.top());
  nuiVector vec1(rViewport.Left(), rViewport.Top(), 0.0f);
  nuiVector vec2(rViewport.Right(), rViewport.Bottom(), 0.0f);
  vec1 = LocalMatrix * vec1;
  vec2 = LocalMatrix * vec2;
  mProjectionViewportStack.top().Set(vec1[0], vec1[1], vec2[0], vec2[1], false);
}
Beispiel #3
0
void nuiTexture::TextureToImageCoord(nuiRect& rRect) const
{
  nuiSize x, y, xx, yy;
  x = rRect.Left();
  y = rRect.Top();
  xx = rRect.Right();
  yy = rRect.Bottom();
  TextureToImageCoord(x, y);
  TextureToImageCoord(xx, yy);
  
  rRect.Set(x, y, xx, yy, false);
}
Beispiel #4
0
static void nuiDrawRect(const nuiRect& out, nuiRenderArray& rArray)
{
  rArray.SetMode(GL_TRIANGLE_STRIP);
  rArray.Reserve(8);
  nuiRect in(out);
  in.Grow(-nuiGetInvScaleFactor(), -nuiGetInvScaleFactor());
  
  rArray.SetVertex(out.Left(), out.Top()); rArray.PushVertex();
  rArray.SetVertex(in.Left(), in.Top()); rArray.PushVertex();

  rArray.SetVertex(out.Right(), out.Top()); rArray.PushVertex();
  rArray.SetVertex(in.Right(), in.Top()); rArray.PushVertex();
  
  rArray.SetVertex(out.Right(), out.Bottom()); rArray.PushVertex();
  rArray.SetVertex(in.Right(), in.Bottom()); rArray.PushVertex();
  
  rArray.SetVertex(out.Left(), out.Bottom()); rArray.PushVertex();
  rArray.SetVertex(in.Left(), in.Bottom()); rArray.PushVertex();

  rArray.SetVertex(out.Left(), out.Top()); rArray.PushVertex();
  rArray.SetVertex(in.Left(), in.Top()); rArray.PushVertex();
}
Beispiel #5
0
void nuiDecoration::ClientToGlobalRect(nuiRect& rRect, const nuiWidget* pWidget) const
{
    nuiSize bordertop = GetBorder(nuiTop, pWidget);
    nuiSize borderleft = GetBorder(nuiLeft, pWidget);
    nuiSize borderright = GetBorder(nuiRight, pWidget);
    nuiSize borderbottom = GetBorder(nuiBottom, pWidget);

    rRect.Set(rRect.Left() - borderleft,
              rRect.Top() - bordertop,
              rRect.Right() + borderright,
              rRect.Bottom() + borderbottom,
              false);


}
Beispiel #6
0
bool nuiPainter::GetClipRect(nuiRect& rRect, bool LocalRect) const
{
  if (mClip.mEnabled)
  {
    rRect = mClip;
  }
  else
  {
    rRect.Set(0, 0, mWidth, mHeight);
  }
  
  if (LocalRect)
  {
    // Transform the rect with the inverse of the current matrix
    nglMatrixf m(GetMatrix());
    m.InvertHomogenous();
    nglVectorf v1(rRect.Left(), rRect.Top(), 0, 1);
    nglVectorf v2(rRect.Right(), rRect.Bottom(), 0, 1);
    v1 = m * v1;
    v2 = m * v2;
    rRect.Set(v1[0], v1[1], v2[0], v2[1], false);
  }
  return mClip.mEnabled;
}
Beispiel #7
0
void nuiGLDrawContext::DrawGradient(const nuiGradient& rGradient, const nuiRect& rEnclosingRect, nuiSize x1, nuiSize y1, nuiSize x2, nuiSize y2)
{
  nglVector2f vec(x2 - x1, y2 - y1);
  nglVector2f para(-vec[1], vec[0]);
  nglVector2f vec1(vec);
  nglVector2f para1(para);
  vec1.Normalize();
  para1.Normalize();

  // What Quadrant are we in?:
  //         |
  //     a   |   b
  //         |
  //  ----------------
  //         |
  //     c   |   d
  //         |
  float xa, xb, xc, xd;
  float ya, yb, yc, yd;
  float x, y;
  float xp, yp;
  float xx, yy;
  float xxp, yyp;

  xa = xc = rEnclosingRect.Left();
  xb = xd = rEnclosingRect.Right();
  ya = yb = rEnclosingRect.Top();
  yc = yd = rEnclosingRect.Bottom();

  if (x1 < x2)
  {
    // Go from a to d or c to b
    if (y1 == y2)
    {
      x  = xa; y  = ya;
      xp = xc; yp = yc;
      xx = xd; yy = yd;
      xxp= xb; yyp= yb;
    }
    else if (y1 < y2)
    {
      // a to d
      IntersectLines(xa,ya, para1[0], para1[1], xb, yb, vec1[0], vec1[1], x, y);
      IntersectLines(xa,ya, para1[0], para1[1], xc, yc, vec1[0], vec1[1], xp, yp);
      IntersectLines(xd,yd, para1[0], para1[1], xc, yc, vec1[0], vec1[1], xx, yy);
      IntersectLines(xd,yd, para1[0], para1[1], xb, yb, vec1[0], vec1[1], xxp, yyp);
    }
    else
    {
      // c to d
      IntersectLines(xc,yc, para1[0], para1[1], xa, ya, vec1[0], vec1[1], x, y);
      IntersectLines(xc,yc, para1[0], para1[1], xd, yd, vec1[0], vec1[1], xp, yp);
      IntersectLines(xb,yb, para1[0], para1[1], xd, yd, vec1[0], vec1[1], xx, yy);
      IntersectLines(xb,yb, para1[0], para1[1], xa, ya, vec1[0], vec1[1], xxp, yyp);
    }
  }
  else
  {
    if (y1 == y2)
    {
      x  = xd; y  = yd;
      xp = xb; yp = yb;
      xx = xa; yy = ya;
      xxp= xc; yyp= yc;
    }
    else if (y1 < y2)
    {
      // b to c
      IntersectLines(xb,yb, para1[0], para1[1], xd, yd, vec1[0], vec1[1], x, y);
      IntersectLines(xb,yb, para1[0], para1[1], xa, ya, vec1[0], vec1[1], xp, yp);
      IntersectLines(xc,yc, para1[0], para1[1], xa, ya, vec1[0], vec1[1], xx, yy);
      IntersectLines(xc,yc, para1[0], para1[1], xd, yd, vec1[0], vec1[1], xxp, yyp);
    }
    else
    {
      // d to a
      IntersectLines(xd,yd, para1[0], para1[1], xc, yc, vec1[0], vec1[1], x, y);
      IntersectLines(xd,yd, para1[0], para1[1], xb, yb, vec1[0], vec1[1], xp, yp);
      IntersectLines(xa,ya, para1[0], para1[1], xb, yb, vec1[0], vec1[1], xx, yy);
      IntersectLines(xa,ya, para1[0], para1[1], xc, yc, vec1[0], vec1[1], xxp, yyp);
    }
  }

  float startx,starty;
  float startxp,startyp;
  float stopx,stopy;
  float stopxp,stopyp;

  if (y1 != y2)
  {
    IntersectLines(x1, y1, para1[0], para1[1], x,  y,  vec1[0], vec1[1], startx,  starty);
    IntersectLines(x1, y1, para1[0], para1[1], xp, yp, vec1[0], vec1[1], startxp, startyp);
    IntersectLines(x2, y2, para1[0], para1[1], x,  y,  vec1[0], vec1[1], stopx,   stopy);
    IntersectLines(x2, y2, para1[0], para1[1], xp, yp, vec1[0], vec1[1], stopxp,  stopyp);
  }
  else
  {
    startx  = x1; starty  = y;
    startxp = x1; startyp = yp;
    stopx   = x2; stopy   = y;
    stopxp  = x2; stopyp  = yp;
  }

  nuiGradientStopList::const_iterator it = rGradient.GetStopList().begin();
  nuiGradientStopList::const_iterator end = rGradient.GetStopList().end();

  float px1, py1;
  float px2, py2;

  PushClipping();
  nuiRect r = rEnclosingRect;
  nglMatrixf m(GetMatrix());
  nglVectorf v1(r.Left(), r.Top(), 0);
  v1 = m * v1;
  nglVectorf v2 = nglVectorf(r.Right(), r.Bottom(), 0);
  v2 = m * v2;
  r.Set(v1[0], v1[1], v2[0], v2[1], false);

  Clip(r);
  SetClipping(true);

  std::vector<nuiShape::CacheElement::Vertex> vertices;

  nuiColor col = it->second;
  vertices.push_back(nuiShape::CacheElement::Vertex(x, y, col));
  vertices.push_back(nuiShape::CacheElement::Vertex(xp, yp, col));

  for ( ; it != end; ++it)
  {
    float r = it->first;
    float rm = 1.0f - r;
    px1 = startx * rm + stopx * r;
    py1 = starty * rm + stopy * r;
    px2 = startxp * rm + stopxp * r;
    py2 = startyp * rm + stopyp * r;

    col = it->second;
    vertices.push_back(nuiShape::CacheElement::Vertex(px1, py1, col));
    vertices.push_back(nuiShape::CacheElement::Vertex(px2, py2, col));
  }

  vertices.push_back(nuiShape::CacheElement::Vertex(xxp, yyp, col));
  vertices.push_back(nuiShape::CacheElement::Vertex(xx, yy, col));

  glEnableClientState(GL_COLOR_ARRAY);
  glEnableClientState(GL_VERTEX_ARRAY);
  glColorPointer(4,  GL_FLOAT, sizeof(nuiShape::CacheElement::Vertex), vertices[0].mColor);
  glVertexPointer(3, GL_FLOAT, sizeof(nuiShape::CacheElement::Vertex), vertices[0].mCoord);

  glDrawArrays(GL_QUAD_STRIP, 0, vertices.size());

  glDisableClientState(GL_COLOR_ARRAY);
  glDisableClientState(GL_VERTEX_ARRAY);

  PopClipping();
}
Beispiel #8
0
void nuiDrawContext::DrawGradient(const nuiGradient& rGradient, const nuiRect& rEnclosingRect, nuiSize x1, nuiSize y1, nuiSize x2, nuiSize y2)
{
  nuiVector2 vec(x2 - x1, y2 - y1);
  nuiVector2 para(-vec[1], vec[0]);
  nuiVector2 vec1(vec);
  nuiVector2 para1(para);
  vec1.Normalize();
  para1.Normalize();

  // What Quadrant are we in?:
  //         |
  //     a   |   b
  //         |
  //  ----------------
  //         |
  //     c   |   d
  //         |
  float xa, xb, xc, xd;
  float ya, yb, yc, yd;
  float x, y;
  float xp, yp;
  float xx, yy;
  float xxp, yyp;

  xa = xc = rEnclosingRect.Left();
  xb = xd = rEnclosingRect.Right();
  ya = yb = rEnclosingRect.Top();
  yc = yd = rEnclosingRect.Bottom();

  if (x1 < x2)
  {
    // Go from a to d or c to b
    if (y1 == y2)
    {
      x  = xa; y  = ya;
      xp = xc; yp = yc;
      xx = xd; yy = yd;
      xxp= xb; yyp= yb;
    }
    else if (y1 < y2)
    {
      // a to d
      IntersectLines(xa,ya, para1[0], para1[1], xb, yb, vec1[0], vec1[1], x, y);
      IntersectLines(xa,ya, para1[0], para1[1], xc, yc, vec1[0], vec1[1], xp, yp);
      IntersectLines(xd,yd, para1[0], para1[1], xc, yc, vec1[0], vec1[1], xx, yy);
      IntersectLines(xd,yd, para1[0], para1[1], xb, yb, vec1[0], vec1[1], xxp, yyp);
    }
    else
    {
      // c to d
      IntersectLines(xc,yc, para1[0], para1[1], xa, ya, vec1[0], vec1[1], x, y);
      IntersectLines(xc,yc, para1[0], para1[1], xd, yd, vec1[0], vec1[1], xp, yp);
      IntersectLines(xb,yb, para1[0], para1[1], xd, yd, vec1[0], vec1[1], xx, yy);
      IntersectLines(xb,yb, para1[0], para1[1], xa, ya, vec1[0], vec1[1], xxp, yyp);
    }
  }
  else
  {
    if (y1 == y2)
    {
      x  = xd; y  = yd;
      xp = xb; yp = yb;
      xx = xa; yy = ya;
      xxp= xc; yyp= yc;
    }
    else if (y1 < y2)
    {
      // b to c
      IntersectLines(xb,yb, para1[0], para1[1], xd, yd, vec1[0], vec1[1], x, y);
      IntersectLines(xb,yb, para1[0], para1[1], xa, ya, vec1[0], vec1[1], xp, yp);
      IntersectLines(xc,yc, para1[0], para1[1], xa, ya, vec1[0], vec1[1], xx, yy);
      IntersectLines(xc,yc, para1[0], para1[1], xd, yd, vec1[0], vec1[1], xxp, yyp);
    }
    else
    {
      // d to a
      IntersectLines(xd,yd, para1[0], para1[1], xc, yc, vec1[0], vec1[1], x, y);
      IntersectLines(xd,yd, para1[0], para1[1], xb, yb, vec1[0], vec1[1], xp, yp);
      IntersectLines(xa,ya, para1[0], para1[1], xb, yb, vec1[0], vec1[1], xx, yy);
      IntersectLines(xa,ya, para1[0], para1[1], xc, yc, vec1[0], vec1[1], xxp, yyp);
    }
  }

  float startx,starty;
  float startxp,startyp;
  float stopx,stopy;
  float stopxp,stopyp;

  if (y1 != y2)
  {
    IntersectLines(x1, y1, para1[0], para1[1], x,  y,  vec1[0], vec1[1], startx,  starty);
    IntersectLines(x1, y1, para1[0], para1[1], xp, yp, vec1[0], vec1[1], startxp, startyp);
    IntersectLines(x2, y2, para1[0], para1[1], x,  y,  vec1[0], vec1[1], stopx,   stopy);
    IntersectLines(x2, y2, para1[0], para1[1], xp, yp, vec1[0], vec1[1], stopxp,  stopyp);
  }
  else
  {
    startx  = x1; starty  = y;
    startxp = x1; startyp = yp;
    stopx   = x2; stopy   = y;
    stopxp  = x2; stopyp  = yp;
  }

  nuiGradientStopList::const_iterator it = rGradient.GetStopList().begin();
  nuiGradientStopList::const_iterator end = rGradient.GetStopList().end();

  float px1, py1;
  float px2, py2;

  PushClipping();
  Clip(rEnclosingRect);
  EnableClipping(true);

  nuiRenderArray* pArray = new nuiRenderArray(GL_TRIANGLE_STRIP);
  pArray->EnableArray(nuiRenderArray::eVertex);
  pArray->EnableArray(nuiRenderArray::eColor);
  
  //  nuiRenderArray Array(GL_LINES);
//  pArray->SetVertexElements(3);
//  pArray->SetColorElements(4);

  nuiColor col = it->second;
  pArray->SetVertex(x, y);
  pArray->SetColor(col);
  pArray->PushVertex();
  pArray->SetVertex(xp, yp);
  pArray->PushVertex();

  for ( ; it != end; ++it)
  {
    float r = it->first;
    float rm = 1.0f - r;
    px1 = startx * rm + stopx * r;
    py1 = starty * rm + stopy * r;
    px2 = startxp * rm + stopxp * r;
    py2 = startyp * rm + stopyp * r;

    col = it->second;
    pArray->SetColor(col);
    pArray->SetVertex(px2, py2);
    pArray->PushVertex();
    pArray->SetVertex(px1, py1);
    pArray->PushVertex();
  }

  pArray->SetVertex(xx, yy);
  pArray->PushVertex();
  pArray->SetVertex(xxp, yyp);
  pArray->PushVertex();

  DrawArray(pArray);

  PopClipping();
}
//virtual
void nuiGradientDecoration::Draw(nuiDrawContext* pContext, nuiWidget* pWidget, const nuiRect& rDestRect)
{
  nuiColor c1 = mColor1;
  nuiColor c2 = mColor2;
  nuiColor c3 = mColor3;
  nuiColor c4 = mColor4;
  nuiColor s = mStrokeColor;
  pContext->PushState();
  pContext->ResetState();
  
  pContext->EnableAntialiasing(false);
  pContext->EnableBlending(true);
  pContext->SetBlendFunc(nuiBlendTransp);
  pContext->EnableTexturing(false);

  
  if (mUseWidgetAlpha && pWidget)
  {
    float widgetAlpha = pWidget->GetMixedAlpha();
    c1.Multiply(widgetAlpha);
    c2.Multiply(widgetAlpha);
    s.Multiply(widgetAlpha);
  }
  
  pContext->SetFillColor(nuiColor(1, 1, 1, 1));
  pContext->SetStrokeColor(s);

  nuiGradient gradient;
  if (!mUserOffsets)
    InitOffsets();
  gradient.AddStop(c1, mOffset1);
  gradient.AddStop(c2, mOffset2);
  if (mGradientType == nuiGradient4Colors)
  {
    if (mUseWidgetAlpha && pWidget)
    {
      float widgetAlpha = pWidget->GetMixedAlpha();
      c3.Multiply(widgetAlpha);
      c4.Multiply(widgetAlpha);
    }

    gradient.AddStop(c3, mOffset3);
    gradient.AddStop(c4, mOffset4);
  }

  if (mOrientation == nuiVertical)
    pContext->DrawGradient(gradient, rDestRect, 0, rDestRect.Top(), 0, rDestRect.Bottom());
  else
  {
    pContext->DrawGradient(gradient, rDestRect, 0, rDestRect.Top(), rDestRect.Right(), rDestRect.Top());
  }
  
  if (((mShapeMode == eStrokeShape) || (mShapeMode == eStrokeAndFillShape)) && mStrokeSize)
  {
    pContext->SetFillColor(s);
    
    nuiRect rect(rDestRect.Left(), rDestRect.Top(), rDestRect.GetWidth(), mStrokeSize);
    pContext->DrawRect(rect, eFillShape);
    
    rect = nuiRect(rDestRect.Left(), rDestRect.Bottom()-mStrokeSize, rDestRect.GetWidth(), mStrokeSize);
    pContext->DrawRect(rect, eFillShape);
    
    rect = nuiRect(rDestRect.Left(), rDestRect.Top(), mStrokeSize, rDestRect.GetHeight());
    pContext->DrawRect(rect, eFillShape);
    
    rect = nuiRect(rDestRect.Right()-mStrokeSize, rDestRect.Top(), mStrokeSize, rDestRect.GetHeight());
    pContext->DrawRect(rect, eFillShape);
    
  }

  pContext->PopState();
}
Beispiel #10
0
// virtual
void nuiBorderDecoration::Draw(nuiDrawContext* pContext, nuiWidget* pWidget, const nuiRect& rDestRect)
{
  pContext->PushState();
  pContext->ResetState();

  pContext->EnableAntialiasing(false);
  pContext->EnableBlending(true);
  pContext->SetBlendFunc(mBlendFunc);
  pContext->EnableTexturing(false);

  pContext->SetLineWidth(mStrokeSize);
  
  if ((mBorderType == eBorderAll) && mUseStrokeGlobalColor)
  {
    pContext->SetStrokeColor(mStrokeColor);
    pContext->DrawRect(rDestRect, eStrokeShape);
    return;
  }


  // left
  if ((mBorderType == eBorderAll) || (mBorderType == eBorderLeft) || (mBorderType == eBorderVertical))
  {
    if (mUseStrokeLeftColor)
      pContext->SetStrokeColor(mStrokeLeftColor);
    else
      pContext->SetStrokeColor(mStrokeColor);
      
    pContext->DrawLine(rDestRect.Left(), rDestRect.Top(), rDestRect.Left(), rDestRect.Bottom());
  }

  // right
  if ((mBorderType == eBorderAll) || (mBorderType == eBorderRight) || (mBorderType == eBorderVertical))
  {
    if (mUseStrokeRightColor)
      pContext->SetStrokeColor(mStrokeRightColor);
    else
      pContext->SetStrokeColor(mStrokeColor);
    
    pContext->DrawLine(rDestRect.Right()-1, rDestRect.Top(), rDestRect.Right()-1, rDestRect.Bottom());
  }
  
  //top
  if ((mBorderType == eBorderAll) || (mBorderType == eBorderTop) || (mBorderType == eBorderHorizontal))
  {
    if (mUseStrokeTopColor)
      pContext->SetStrokeColor(mStrokeTopColor);
    else
      pContext->SetStrokeColor(mStrokeColor);
    
    pContext->DrawLine(rDestRect.Left(), rDestRect.Top(), rDestRect.Right(), rDestRect.Top());
  }

  // bottom
  if ((mBorderType == eBorderAll) || (mBorderType == eBorderBottom) || (mBorderType == eBorderHorizontal))
  {
    if (mUseStrokeBottomColor)
      pContext->SetStrokeColor(mStrokeBottomColor);
    else
      pContext->SetStrokeColor(mStrokeColor);
    
    pContext->DrawLine(rDestRect.Left(), rDestRect.Bottom()-1, rDestRect.Right(), rDestRect.Bottom()-1);
  }
  
  
  pContext->PopState();
}
Beispiel #11
0
// virtual
void nuiFrame::Draw(nuiDrawContext* pContext, nuiWidget* pWidget, const nuiRect& rDestRect)
{
  pContext->PushState();
  pContext->ResetState();

  //  nuiRenderArray* pArray = new nuiRenderArray(GL_TRIANGLES);
  nuiRenderArray* pArray = new nuiRenderArray(GL_TRIANGLE_STRIP);
  pArray->EnableArray(nuiRenderArray::eVertex, true);
  pArray->EnableArray(nuiRenderArray::eTexCoord, true);
  pArray->EnableArray(nuiRenderArray::eColor, false);
  
  
  nuiSize w = mpTexture->GetWidth();
  nuiSize h = mpTexture->GetHeight();
  
  float X0 = 0;
  float X1 = (float)mClientRect.Left();
  float X2 = (float)mClientRect.Right();
  float X3 = (float)w;

  float Y0 = 0;
  float Y1 = (float)mClientRect.Top();
  float Y2 = (float)mClientRect.Bottom();
  float Y3 = (float)h;

  const float x0 = (float)rDestRect.Left();
  const float x1 = x0 + X1;
  const float x3 = (float)rDestRect.Right();
  const float x2 = x3 - (X3 - X2);
  
  const float y0 = (float)rDestRect.Top();
  const float y1 = y0 + Y1;
  const float y3 = (float)rDestRect.Bottom();
  const float y2 = y3 - (Y3 - Y2);

  mpTexture->ImageToTextureCoord(X0, Y0);
  mpTexture->ImageToTextureCoord(X1, Y1);
  mpTexture->ImageToTextureCoord(X2, Y2);
  mpTexture->ImageToTextureCoord(X3, Y3);
  
  
  // Reserve 28 vertices
  pArray->Reserve(28);
  
  //////// TOP PART
  // TopLeft rect:
  pArray->SetVertex(x0, y0);
  pArray->SetTexCoords(X0, Y0);
  pArray->PushVertex();
  
  pArray->SetVertex(x0, y1);
  pArray->SetTexCoords(X0, Y1);
  pArray->PushVertex();
  
  pArray->SetVertex(x1, y0);
  pArray->SetTexCoords(X1, Y0);
  pArray->PushVertex();
  
  pArray->SetVertex(x1, y1);
  pArray->SetTexCoords(X1, Y1);
  pArray->PushVertex();
  
  // TopMiddle rect:
  pArray->SetVertex(x2, y0);
  pArray->SetTexCoords(X2, Y0);
  pArray->PushVertex();
  
  pArray->SetVertex(x2, y1);
  pArray->SetTexCoords(X2, Y1);
  pArray->PushVertex();
  
  // TopRight rect:
  pArray->SetVertex(x3, y0);
  pArray->SetTexCoords(X3, Y0);
  pArray->PushVertex();
  
  pArray->SetVertex(x3, y1);
  pArray->SetTexCoords(X3, Y1);
  pArray->PushVertex();
  // Double the last vertex to create a flat triangle that will not be displayed
  pArray->PushVertex();
  
  ///// MIDDLE PART
  // LeftSide rect:
  pArray->SetVertex(x0, y1);
  pArray->SetTexCoords(X0, Y1);
  pArray->PushVertex();
  // Double the first vertex to create a flat triangle that will not be displayed
  pArray->PushVertex();
  
  pArray->SetVertex(x0, y2);
  pArray->SetTexCoords(X0, Y2);
  pArray->PushVertex();
  
  pArray->SetVertex(x1, y1);
  pArray->SetTexCoords(X1, Y1);
  pArray->PushVertex();
  
  pArray->SetVertex(x1, y2);
  pArray->SetTexCoords(X1, Y2);
  pArray->PushVertex();
  
  // Middle (client) rect:
  pArray->SetVertex(x2, y1);
  pArray->SetTexCoords(X2, Y1);
  pArray->PushVertex();
  
  pArray->SetVertex(x2, y2);
  pArray->SetTexCoords(X2, Y2);
  pArray->PushVertex();
  
  // RightSide rect:
  pArray->SetVertex(x3, y1);
  pArray->SetTexCoords(X3, Y1);
  pArray->PushVertex();
  
  pArray->SetVertex(x3, y2);
  pArray->SetTexCoords(X3, Y2);
  pArray->PushVertex();
  // Double the last vertex to create a flat triangle that will not be displayed
  pArray->PushVertex();
  
  
  
  ///// BOTTOM PART
  // BottomLeft rect:
  pArray->SetVertex(x0, y2);
  pArray->SetTexCoords(X0, Y2);
  pArray->PushVertex();
  // Double the first vertex to create a flat triangle that will not be displayed
  pArray->PushVertex();
  
  pArray->SetVertex(x0, y3);
  pArray->SetTexCoords(X0, Y3);
  pArray->PushVertex();
  
  pArray->SetVertex(x1, y2);
  pArray->SetTexCoords(X1, Y2);
  pArray->PushVertex();
  
  pArray->SetVertex(x1, y3);
  pArray->SetTexCoords(X1, Y3);
  pArray->PushVertex();
  
  // BottomMiddle rect:
  pArray->SetVertex(x2, y2);
  pArray->SetTexCoords(X2, Y2);
  pArray->PushVertex();
  
  pArray->SetVertex(x2, y3);
  pArray->SetTexCoords(X2, Y3);
  pArray->PushVertex();
  
  // BottomRight rect:
  pArray->SetVertex(x3, y2);
  pArray->SetTexCoords(X3, Y2);
  pArray->PushVertex();
  
  pArray->SetVertex(x3, y3);
  pArray->SetTexCoords(X3, Y3);
  pArray->PushVertex();
  
  
  nuiColor color = mColor;
  
  if (pWidget)
  {
    if (mUseWidgetFrameColor)
    {
      nuiAttrib<const nuiColor&> colorAttr(pWidget->GetAttribute(_T("FrameColor")));
      if (colorAttr.IsValid()) {
        color = colorAttr.Get();
      }
    }
    if (mUseWidgetAlpha)
    {
      float widgetAlpha = pWidget->GetMixedAlpha();
      color.Multiply(widgetAlpha);
    }
  }
  pContext->EnableTexturing(true);
  pContext->EnableBlending(true);
  pContext->SetBlendFunc(nuiBlendTransp);
  pContext->SetTexture(mpTexture);
  pContext->SetFillColor(color);
  pContext->DrawArray(pArray);
  
  pContext->PopState();
}