Exemplo n.º 1
0
// Owner-drawn control service function:
void CVectorCtl::DrawItem( LPDRAWITEMSTRUCT lpDrawItemStruct )
{
	CDC *pDC = CDC::FromHandle (lpDrawItemStruct->hDC); // Get CDC to draw

	if (!m_bSelected && lpDrawItemStruct->itemState & ODS_SELECTED) {
			// Just got re-selected (user starts a new mouse dragging session)
	} else if (m_bSelected && // Last state was selected
			   !(lpDrawItemStruct->itemState & ODS_SELECTED) &&     // New state is NOT selected
			   (lpDrawItemStruct->itemState & ODS_FOCUS) &&         // New state is still in focus
			   m_procVectorChanged)     // User asked for a callback
		// User has left the track-ball and asked for a callback.
		m_procVectorChanged ( rotationQuat );

	m_bHasFocus = lpDrawItemStruct->itemState & ODS_FOCUS;      // Update focus status
	m_bSelected = lpDrawItemStruct->itemState & ODS_SELECTED;   // Update selection status

	if (!m_bBmpCreated)  // 1st time
		InitBitmap (lpDrawItemStruct, pDC);
	if (m_bImageChange) {   // Image has changes - recalc it!
		if (m_procVectorChanging)   // User has specified a callback
			m_procVectorChanging ( rotationQuat ); // Call it!
		BuildImage (lpDrawItemStruct);
		m_bImageChange = FALSE;
	}
	pDC->BitBlt (0,0,m_iWidth, m_iHeight, &m_dcMem, 0, 0, SRCCOPY); // Update screen
}
Exemplo n.º 2
0
void BuildChar16(int XPos,int YPos,Wchar Code,int CFont,
          int Width,int Height,int Slant,int RotateAngle,int Color)
{
   unsigned char *pImage;
   int ImageLen,ImageW,ImageH;
   unsigned char *CharBuffer;

   assert(CFont==0);

   ImageH=Height;
   ImageW=(Width+7)/8;
   ImageLen=ImageW*ImageH;
   pImage=(unsigned char *)malloc(ImageLen);
   //if(pImage==NULL)
   if(pImage<0x1000)
   {
       ReportMemoryError("bld16");
       return;
   }

   if(Width!=Height
   || GetCacheData(Code,CFont,Width,pImage,ImageLen)!=OpOK)
   {
      CharBuffer=GetChineseDot(Code);
      memset(pImage,0,ImageLen);        // clear it
      ZoomCharBuffer(CharBuffer,CHINESEWIDTH,CHINESEHIGHT,
          (float)Width/CHINESEWIDTH,(float)Height/CHINESEHIGHT,pImage,ImageW);

      if(Width==Height)
         PutCacheData(Code,CFont,Width,pImage,ImageLen);
   }

   BuildImage(pImage,XPos,YPos,Width,Height,Slant,RotateAngle,Color);
   free(pImage);
}