Exemple #1
0
void RadarCanvas::RenderTexts(int w, int h) {
  int x, y;

  wxString s;

#define MENU_ROUNDING 4
#define MENU_BORDER 8
#define MENU_EXTRA_WIDTH 32

  // Draw Menu in the top right

  s = _("Menu");
  m_FontMenu.GetTextExtent(s, &x, &y);

  // Calculate the size of the rounded rect, this is also where you can 'click'...
  m_menu_size.x = x + 2 * (MENU_BORDER + MENU_EXTRA_WIDTH);
  m_menu_size.y = y + 2 * (MENU_BORDER);

  glColor4ub(40, 40, 100, 128);

  DrawRoundRect(w - m_menu_size.x, 0, m_menu_size.x, m_menu_size.y, 4);

  glColor4ub(100, 255, 255, 255);
  // The Menu text is slightly inside the rect
  m_FontMenu.RenderString(s, w - m_menu_size.x + MENU_BORDER + MENU_EXTRA_WIDTH, MENU_BORDER);

  // Draw - + in mid bottom

  s = wxT("  -   + ");
  m_FontMenuBold.GetTextExtent(s, &x, &y);

  // Calculate the size of the rounded rect, this is also where you can 'click'...
  m_zoom_size.x = x + 2 * (MENU_BORDER);
  m_zoom_size.y = y + 2 * (MENU_BORDER);

  glColor4ub(80, 80, 80, 128);

  DrawRoundRect(w / 2 - m_zoom_size.x / 2, h - m_zoom_size.y + MENU_ROUNDING, m_zoom_size.x, m_zoom_size.y, MENU_ROUNDING);

  glColor4ub(200, 200, 200, 255);
  // The Menu text is slightly inside the rect
  m_FontMenuBold.RenderString(s, w / 2 - m_zoom_size.x / 2 + MENU_BORDER, h - m_zoom_size.y + MENU_BORDER);

  glColor4ub(200, 255, 200, 255);

  s = m_ri->GetCanvasTextTopLeft();
  m_FontBig.RenderString(s, 0, 0);

  s = m_ri->GetCanvasTextBottomLeft();
  if (s.length()) {
    m_FontBig.GetTextExtent(s, &x, &y);
    m_FontBig.RenderString(s, 0, h - y);
  }

  s = m_ri->GetCanvasTextCenter();
  if (s.length()) {
    m_FontBig.GetTextExtent(s, &x, &y);
    m_FontBig.RenderString(s, (w - x) / 2, (h - y) / 2);
  }
}
void loop(){ // run over and over again
	int i;  
	startMillis = millis();
  
	SelectFont(System5x7, BLACK);       // select fixed width system font
	while( millis() - startMillis < 1000){ 		// loop for one second
    DrawRect(0, 0, 64, 61, BLACK); 				// rectangle in left side of screen
    DrawRoundRect(68, 0, 58, 61, 5, BLACK);  	// rounded rectangle around text area   
    for(i=0; i < 62; i += 4)
      DrawLine(1,1,63,i, BLACK);  				// draw lines from upper left down right side of rectangle  
    DrawCircle(32,31,30,BLACK);   				// draw circle centered in the left side of screen  
    FillRect(92,40,16,16, WHITE); 				// clear previous spinner position  
    CursorTo(3,4);               				// locate curser for printing text
    GotoXY(29,40);								// use GotoXY for truetype fonts
    PrintNumber(++iter);         				// print current iteration at the current cursor position
  }

  SelectFont(Arial_Bold_14, BLACK); 	// select truetype font
//
  ClearScreenX();               		// clear the screen  
//
  GotoXY(75,24);						// use GotoXY for truetype fonts
  Puts("FPS= ");             			// print a text string  
  PrintNumber(iter);         			// print a number  
  iter = 0;
 }
void CRectangle::Draw(CDC* pDC,CRect& rcInvalid)
{
	if(m_nPtCount <= 0)
	{
		return;
	}
		
	Graphics graph(pDC->m_hDC);
	graph.SetSmoothingMode(SmoothingModeAntiAlias);

	Matrix mat;
	mat.RotateAt(m_fAngle,m_ptCenter);
	graph.SetTransform(&mat);

	CPoint ptLT;
	CPoint ptRB;
	ptLT.x = (int)m_ptary[0].X;
	ptLT.y = (int)m_ptary[0].Y;
	ptRB.x = (int)m_ptary[1].X;
	ptRB.y = (int)m_ptary[1].Y;
	CRect rc(ptLT,ptRB);
	rc.NormalizeRect();

	if(m_bSelected || m_bEdit)
	{
		DrawHotShape(graph);
	}

	graph.ExcludeClip(&m_RgnErase);

	if(m_nPtCount == 1)
	{
		return;
	}
	if(RS_ROUND == m_nRStyle)
	{
		DrawRoundRect(graph,rc);
	}
	else if(RS_SQUARE == m_nRStyle)
	{
		DrawSquare(graph,rc);
	}
	else if(RS_RECT == m_nRStyle)
	{
		DrawRectangle(graph,rc);
	}
}
Exemple #4
0
void OnPaint(HWND hWnd){
	PAINTSTRUCT ps = {0};
	HDC hdc = BeginPaint(hWnd,&ps);
	
	HPEN hPen = CreatePen(PS_DASH,10,RGB(255,0,0));
	//HBRUSH hBrush = CreateSolidBrush(RGB(0,255,0));
	//HGDIOBJ hBrush = GetStockObject(NULL_BRUSH);
	
	HBITMAP hBmp = LoadBitmap(g_hInstance,MAKEINTRESOURCE(IDB_BITMAP1));
	HBRUSH hBrush = CreatePatternBrush(hBmp);


	HGDIOBJ nOldPen = SelectObject(hdc,hBrush);

	int nOldMode = SetMapMode(hdc,MM_ISOTROPIC);
	SetWindowExtEx(hdc,1,1,NULL);
	SetViewportExtEx(hdc,1,2,NULL);

	switch(g_kind){
		case ID_ARC:
			DrawArc(hdc);
			break;
		case ID_POINT:
			DrawPoint(hdc);
			break;
		case ID_LINE:
			DrawLine(hdc);
			break;
		case ID_RECT:
			DrawRect(hdc);
			break;
		case ID_ROUNDRECT:
			DrawRoundRect(hdc);
			break;
		case ID_CIRCLE:
			DrawCircle(hdc);
			break;
		case ID_BMP:
			DrawBmp(hdc);
			break;
	}
	SelectObject(hdc,nOldPen);
	//DeleteObject(hPen);
	SetMapMode(hdc,nOldMode);
	EndPaint(hWnd,&ps);
}
void loop(){ // run over and over again
int i;
  startMillis = millis();
  while( millis() - startMillis < 1000){ // loop for one second
    DrawRect(0, 0, 64, 61, BLACK); // rectangle in left side of screen
    DrawRoundRect(68, 0, 58, 61, 5, BLACK);  // rounded rectangle around text area   
    for(i=0; i < 62; i += 4)
      DrawLine(1,1,63,i, BLACK);  // draw lines from upper left down right side of rectangle  
    DrawCircle(32,31,30,BLACK);   // draw circle centered in the left side of screen  
    FillRect(92,40,16,16, WHITE); // clear previous spinner position  
    CursorTo(5,5);               // locate curser for printing text
    PrintNumber(++iter);         // print current iteration at the current cursor position 
  } 
//
  ClearScreenX();               // clear the screen  
  CursorTo(13,2);              // positon cursor  
  Puts("FPS= ");               // print a text string  
  PrintNumber(iter);           // print a number 
  iter=0;
 }
Exemple #6
0
 virtual void onDrawContent(SkCanvas* canvas) {
     DrawRoundRect();
     TestOverflowHitTest();
 }
Exemple #7
0
void CRoundRect::OnDrag(int nHitTest,CPointF point)
{
	REAL x,y;
	CClientDC dc(m_pWnd);
	CElastic elastic(&dc,this);

	REAL dx = m_pWnd->GetStartPos().x;
	REAL dy = m_pWnd->GetStartPos().y;

	switch (nHitTest)
	{
	case TopLeft:
		DrawRoundRectXY(&dc,m_pWnd->GetCapturePos().x,m_pWnd->GetCapturePos().y,m_rc.right-dx,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		DrawRoundRectXY(&dc,point.x,point.y,m_rc.right-dx,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		break;
	case Top:
		DrawRoundRectXY(&dc,m_rc.left-dx,m_pWnd->GetCapturePos().y,m_rc.right-dx,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		DrawRoundRectXY(&dc,m_rc.left-dx,point.y,m_rc.right-dx,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		break;
	case TopRight:
		DrawRoundRectXY(&dc,m_rc.left-dx,m_pWnd->GetCapturePos().y,m_pWnd->GetCapturePos().x,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		DrawRoundRectXY(&dc,m_rc.left-dx,point.y,point.x,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		break; 
	case Right:
		DrawRoundRectXY(&dc,m_rc.left-dx,m_rc.top-dy,m_pWnd->GetCapturePos().x,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		DrawRoundRectXY(&dc,m_rc.left-dx,m_rc.top-dy,point.x,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		break;
	case BottomRight:
		DrawRoundRectXY(&dc,m_rc.left-dx,m_rc.top-dy,m_pWnd->GetCapturePos().x,m_pWnd->GetCapturePos().y,m_fXEllipse,m_fYEllipse);
		DrawRoundRectXY(&dc,m_rc.left-dx,m_rc.top-dy,point.x,point.y,m_fXEllipse,m_fYEllipse);
		break;
	case Bottom:
		DrawRoundRectXY(&dc,m_rc.left-dx,m_rc.top-dy,m_rc.right-dx,m_pWnd->GetCapturePos().y,m_fXEllipse,m_fYEllipse);
		DrawRoundRectXY(&dc,m_rc.left-dx,m_rc.top-dy,m_rc.right-dx,point.y,m_fXEllipse,m_fYEllipse);
		break;
	case BottomLeft:
		DrawRoundRectXY(&dc,m_pWnd->GetCapturePos().x,m_rc.top-dy,m_rc.right-dx,m_pWnd->GetCapturePos().y,m_fXEllipse,m_fYEllipse);
		DrawRoundRectXY(&dc,point.x,m_rc.top-dy,m_rc.right-dx,point.y,m_fXEllipse,m_fYEllipse);
		break;
	case Left:
		DrawRoundRectXY(&dc,m_pWnd->GetCapturePos().x,m_rc.top-dy,m_rc.right-dx,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		DrawRoundRectXY(&dc,point.x,m_rc.top-dy,m_rc.right-dx,m_rc.bottom-dy,m_fXEllipse,m_fYEllipse);
		break;
	case Ellipse:
		{
			REAL fWidth = m_rc.Width()*m_fXEllipse;
			REAL fHeight = m_rc.Height()*m_fYEllipse;

			x = m_pWnd->GetCapturePos().x-m_pWnd->GetMarkPos().x;
			y = m_pWnd->GetCapturePos().y-m_pWnd->GetMarkPos().y;
			DrawRoundRect(&dc,m_rc.left-dx,m_rc.top-dy,m_rc.right-dx,m_rc.bottom-dy,fWidth+x*2,fHeight+y*2);

			x = point.x-m_pWnd->GetMarkPos().x;
			y = point.y-m_pWnd->GetMarkPos().y;
			DrawRoundRect(&dc,m_rc.left-dx,m_rc.top-dy,m_rc.right-dx,m_rc.bottom-dy,fWidth+x*2,fHeight+y*2);
		}
		break;
	case Body: 
		x = m_pWnd->GetCapturePos().x-m_pWnd->GetMarkPos().x-dx;
		y = m_pWnd->GetCapturePos().y-m_pWnd->GetMarkPos().y-dy;
		DrawRoundRectXY(&dc,m_rc.left+x,m_rc.top+y,m_rc.right+x,m_rc.bottom+y,m_fXEllipse,m_fYEllipse);

		x = point.x-m_pWnd->GetMarkPos().x-dx;
		y = point.y-m_pWnd->GetMarkPos().y-dy;
		DrawRoundRectXY(&dc,m_rc.left+x,m_rc.top+y,m_rc.right+x,m_rc.bottom+y,m_fXEllipse,m_fYEllipse);
		break;
	default:
		ASSERT(FALSE);
		break;
	}
}
Exemple #8
0
    virtual void onDraw(SkCanvas* canvas) {
        this->drawBG(canvas);

        if (true) {
            canvas->scale(SkIntToScalar(2), SkIntToScalar(2));
            drawmarshmallow(canvas);
            return;
        }

        if (false) {
            SkPaint p;
            p.setStyle(SkPaint::kStroke_Style);
            p.setStrokeWidth(SkIntToScalar(4));
            canvas->drawCircle(SkIntToScalar(100), SkIntToScalar(100), SkIntToScalar(50), p);
            p.setAntiAlias(true);
            canvas->drawCircle(SkIntToScalar(300), SkIntToScalar(100), SkIntToScalar(50), p);
        }
        if (false) {
            SkScalar cx = this->width()/2;
            SkScalar cy = this->height()/2;
            canvas->translate(cx, cy);
            canvas->scale(fScale, fScale);
            canvas->translate(-cx, -cy);
            DrawRoundRect(*canvas);
            return;
        }

        canvas->translate(SkIntToScalar(10), SkIntToScalar(10));

        SkScalar x = SkIntToScalar(32), y = SkIntToScalar(32);
        SkPaint paint;

#if 0
        for (int i = 0; i < fBitmapCount; i++) {
            SkPaint p;

#if 1
            const SkScalar cm[] = {
                SkIntToScalar(2), 0, 0, 0, SkIntToScalar(-255),
                0, SkIntToScalar(2), 0, 0, SkIntToScalar(-255),
                0, 0, SkIntToScalar(2), 0, SkIntToScalar(-255),
                0, 0, 0, SkIntToScalar(1), 0
            };
            SkColorFilter* cf = new SkColorMatrixFilter(cm);
            p.setColorFilter(cf)->unref();
#endif

            canvas->drawBitmap(fBitmaps[i], x, y, &p);
            x += SkIntToScalar(fBitmaps[i].width() + 10);
        }
        return;
#endif

        canvas->drawBitmap(fBitmaps[fCurrIndex], x, y, &paint);
#ifndef SPECIFIC_IMAGE
        if (true) {
            fCurrIndex += 1;
            if (fCurrIndex >= fBitmapCount) {
                fCurrIndex = 0;
            }
            this->inval(NULL);
        }
#endif
    }
/**
 *	Draw container contents.
 */				
void CCalendarManagerContainer::Draw( const TRect& aRect ) const
	{
	g_Space_X = (aRect.Width() - 7) / 8;
	g_Space_Y = (aRect.Height() - 8) / 8;
	g_Pos_Y = 0;
	// [[[ begin generated region: do not modify [Generated Contents]
	CWindowGc& gc = SystemGc();
	gc.Clear( aRect );
	
	// ]]] end generated region [Generated Contents]

	MAknsSkinInstance* i_BgSkin = AknsUtils::SkinInstance();
	MAknsControlContext* i_BgControl = AknsDrawUtils::ControlContext(this);			
	AknsDrawUtils::Background(i_BgSkin, i_BgControl, this, gc, aRect);	
	
	TRgb i_Default_Font_Color1;
	TRgb i_Default_Font_Color2;
	TRgb i_Default_Grid_Color1;
	TRgb i_Default_Grid_Color2;
	TRgb i_Default_Select_Color;
	AknsUtils::GetCachedColor(i_BgSkin, i_Default_Font_Color1, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG22);
	AknsUtils::GetCachedColor(i_BgSkin, i_Default_Font_Color2, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG21);	
	AknsUtils::GetCachedColor(i_BgSkin, i_Default_Grid_Color1, KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG1);
	AknsUtils::GetCachedColor(i_BgSkin, i_Default_Grid_Color2, KAknsIIDQsnLineColors, EAknsCIQsnLineColorsCG2);
	AknsUtils::GetCachedColor(i_BgSkin, i_Default_Select_Color, KAknsIIDQsnTextColors, EAknsCIQsnTextColorsCG11);		
		
	const CFont* i_Font = iEikonEnv->LegendFont();	
	gc.UseFont(i_Font);	
	DrawSchedule(gc, aRect, i_Default_Font_Color1, *i_Font);
	DrawRoundRect(gc, aRect, i_Default_Grid_Color2);
	DrawWeekName(gc, aRect, i_Default_Font_Color1, *i_Font);
	DrawGrid(gc, aRect, i_Default_Grid_Color1);
	DrawDay(gc, aRect, i_Default_Font_Color1, i_Default_Font_Color2, *i_Font);
	DrawCurrentDay(gc, i_BgSkin, i_Default_Select_Color, *i_Font);
	DrawWeek(gc, aRect, i_Default_Font_Color1, *i_Font);		
	gc.DiscardFont();
		
	CAknViewAppUi* i_AppUi = static_cast<CAknViewAppUi*>(iCoeEnv->AppUi());	
	CAknView* i_View = i_AppUi->View(TUid::Uid(ECalendarManagerContainerViewId));
	i_View->HandleCommandL(ECalendarManagerContainerView_KeyCommand);
		
//	TInt p = 20;
//	TInt q = 20;
//	TInt a = 0;
//	TInt b = 20;
//	
//	for (TInt i = 0;i <= 62;i++)
//		{
//		TRgb i_Color;
//		AknsUtils::GetCachedColor(i_BgSkin, i_Color, KAknsIIDQsnTextColors, i);
//		gc.SetPenColor(i_Color);
//		
//		TBuf<10> k;
//		k.AppendNum(i);
//				
//		gc.DrawText(k, TPoint(a, b));
//		a += p;
//		
//		if (i % 10 == 0 && i > 0)
//			{
//			a = 0;
//			b += q;
//			}
//		}
	}
Exemple #10
0
void CBtnRoundImg::DrawItem(LPDRAWITEMSTRUCT lpDrawItemStruct)
{
   CDC dc;
   dc.Attach(lpDrawItemStruct->hDC);       //°´Å¥¿Ø¼þDC  

   COLORREF clrBK = RGB(255,255,255);
   switch(m_nCtrlState)  
   {  
   case CTRL_NOFOCUS:  
      clrBK = m_clrBKUnfocus;
      break;  
   case CTRL_FOCUS:  
      clrBK = m_clrBKFocus;
      break;  
   case CTRL_SELECTED:  
      clrBK = m_clrBKSelected;
      break;  
   default:  
      break;  
   }  

   if (IsWindowEnabled()==FALSE)
   {
      clrBK = m_clrBKDisable;
   }

   //draw background
   CRect rect(lpDrawItemStruct->rcItem);
   //dc.FillSolidRect(&rect,clrBK);
   DrawRoundRect(dc, 5,rect,clrBK);

   //draw image
   if (m_strPngPath != _T(""))
   {
      Gdiplus::Image  imageBtn(m_strPngPath);
      if (imageBtn.GetLastStatus() != Ok)
      {
         ASSERT(FALSE);
      }
      ;
      HRGN hRgnOld = (HRGN)::SelectObject(lpDrawItemStruct->hDC, m_hRgnBtn);

      Gdiplus::Graphics * pGrp = Graphics::FromHDC(lpDrawItemStruct->hDC);
      pGrp->Clear(Color::White);

      CRect rectBtn;
      GetClientRect(&rectBtn);
      int startX = (rectBtn.Width() - imageBtn.GetWidth())/2;
      int startY = (rectBtn.Height() - imageBtn.GetHeight())/2;
      startX = 0;
      startY = 0;
      if (lpDrawItemStruct->itemState & ODS_SELECTED)	//Ñ¡ÖÐ״̬£¬Í¼Æ¬Æ«ÒÆÒ»¸öÏñËØ
      {
         pGrp->DrawImage(&imageBtn, startX+1, startY+1, startX+imageBtn.GetWidth(), startY+imageBtn.GetHeight());
      }
      else	//ĬÈÏ״̬
      {
         pGrp->DrawImage(&imageBtn, startX, startY, startX+imageBtn.GetWidth(), startY+imageBtn.GetHeight());
      }

      delete pGrp;
      pGrp = NULL;
      ::SelectObject(lpDrawItemStruct->hDC, hRgnOld);
   }


   CFont* pOldFont;
   if (m_pFont)
   {
      pOldFont = dc.SelectObject(m_pFont); 
   }
   COLORREF clrOld = dc.SetTextColor(m_clrFont);
   CString strText;
   GetWindowText(strText);
   if (strText != _T(""))
   {
      int test = 1;
   }
   int oldMode = dc.SetBkMode(TRANSPARENT);
   dc.DrawText(strText, -1, &lpDrawItemStruct->rcItem, DT_CENTER|DT_SINGLELINE|DT_VCENTER);  
   dc.SetBkMode(oldMode);
   dc.SetTextColor(clrOld);
   if (m_pFont)
   {
      dc.SelectObject(pOldFont);  
   }

   dc.Detach();
}
void loop(){ // run over and over again	
	char x, y;	
	uchar tempC;
	
	if (counter>9){		
		counter = 0;
		sec++;
	}
	
//
	sensor = analogRead(SENSOR);
	
	if (sec>59){
		sec = 0;
		min++;
	}
	
	if (min>59){
		min = 0;
		hour++;
	}
	
	if (hour>23){
		hour = 0;
	}
	
	SelectFont(VerdanaNumbers, BLACK);
	GotoXY(3,0);
	
	if (hour < 10)
		PutChar('0');
	PrintNumber(hour);
	
	PutChar(':');
	if (min < 10)
		PutChar('0');
	PrintNumber(min);
	
	PutChar(':');
	if (sec < 10)
		PutChar('0');
	PrintNumber(sec);
		
//
	if(!(digitalread(HOUR))){
		hour++;
	}
	if(!(digitalread(MIN))){
		min++;
	}
				
//
	DrawCircle(21,43,18,BLACK);
//
	x = (int) RSEC * sinf(sec*0.10472);
	y = (int) RSEC * cosf(sec*0.10472);
	DrawLine(21,43,21+x,43-y, BLACK);
//
	x = (int) RMIN * sinf(min*0.10472);
	y = (int) RMIN * cosf(min*0.10472);
	DrawLine(21,43,21+x,43-y, BLACK);
//
	x = (int) RHOUR * sinf((hour>12?hour-12:hour)*0.5236);
	y = (int) RHOUR * cosf((hour>12?hour-12:hour)*0.5236);
	DrawLine(21,43,21+x,43-y, BLACK);
	
	DrawRoundRect(63, 28, 50, 30, 10, BLACK); 
//
//
//
	
	tempC  = (int)(0.48876 * sensor);
//
	
	SelectFont(VerdanaNumbers, BLACK);
	GotoXY(70,32);
	PrintNumber(tempC);
//
	Puts(";");

//
	Delayms(25); //just a fine tune to get 100ms with this!
	
	if(!counter)
		ClearScreenX();         // clear the screen
	
	counter++;
 }
void ACanvasSkia::DrawRoundRect(int x1,int y1,int x2,int y2,int round)
{
	DrawRoundRect(ARect(x1,y1,x2,y2),round);
}