Exemplo n.º 1
0
void VSliderControl::Init(void)
{
    m_oMutex.Acquire();
   
    if (!m_bUsesStateBitmapRects) {
        for (int row = 0; row < m_iNumThumbStates; row++) {
            for (int i = 0; i < m_iNumFrames; i++) {
                int iFrameWidth, iFrameHeight;
                Rect oFrameRect;

                if (m_bHorizontalBitmap) {
                    iFrameWidth = (m_oBitmapRect.Width() + 1) / 3;
                    iFrameHeight = (m_oBitmapRect.Height() + 1) /
                                   m_iNumThumbStates;
                    oFrameRect = m_oBitmapRect;
                    oFrameRect.x1 += i * iFrameWidth;
                    oFrameRect.x2 = oFrameRect.x1 + iFrameWidth - 1;
                    oFrameRect.y1 += row * iFrameHeight;
                    oFrameRect.y2 = oFrameRect.y1 + iFrameHeight - 1;
                }
                else {
                    iFrameHeight = (m_oBitmapRect.Height() + 1) / 3;
                    iFrameWidth = (m_oBitmapRect.Width() + 1) /
                                  m_iNumThumbStates;
                    oFrameRect = m_oBitmapRect;
                    oFrameRect.x1 += row * iFrameWidth;
                    oFrameRect.x2 = oFrameRect.x1 + iFrameWidth - 1;
                    oFrameRect.y1 += i * iFrameHeight;
                    oFrameRect.y2 = oFrameRect.y1 + iFrameHeight - 1;
                }

                switch (i) {
                    case 0:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Normal, row);
                        break;
                    case 1:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_MouseOver, row);
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Dragging, row);
                        break;
                    case 2:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Disabled, row);
                        break;
                    default:
                        break;
                }
           }
        }
    }

    m_iThumbHeight = m_oStateBitmapRect[0][CS_Normal].Height(); 
    m_iRange = m_oRect.Height() - m_iThumbHeight;

    m_oMutex.Release();
    
    Transition(CT_None, NULL);
}
Exemplo n.º 2
0
void ButtonControl::Init(void)
{
    m_oMutex.Acquire();

    m_eCurrentState = CS_Normal;

    if (!m_bUsesStateBitmapRects) {
        for (int i = 0; i < 4; i++) {
           int iFrameWidth;
           Rect oFrameRect;
           
           if (m_bHorizontalBitmap) {
               iFrameWidth = (m_oBitmapRect.Width() + 1) / 4;
               oFrameRect = m_oBitmapRect;
               oFrameRect.x1 += i * iFrameWidth;
               oFrameRect.x2 = oFrameRect.x1 + iFrameWidth - 1;
           }
           else {
               iFrameWidth = (m_oBitmapRect.Height() + 1) / 4;
               oFrameRect = m_oBitmapRect;
               oFrameRect.y1 += i * iFrameWidth;
               oFrameRect.y2 = oFrameRect.y1 + iFrameWidth - 1;
           }

           switch (i) {
               case 0:
                   SetStateBitmap(m_pBitmap, oFrameRect, CS_Normal);
                    break;
               case 1:
                   SetStateBitmap(m_pBitmap, oFrameRect, CS_MouseOver);
                    break;
               case 2:
                   SetStateBitmap(m_pBitmap, oFrameRect, CS_Pressed);
                    break;
               case 3:
                   SetStateBitmap(m_pBitmap, oFrameRect, CS_Disabled);
                    break;
                default:
                   break;
            }
        }
    }

    if (m_oRect.x2 == -1 && m_oRect.y2 == -1)
    {
        m_oRect.x2 = m_oRect.x1 + m_oStateBitmapRect[0][CS_Normal].x2 - 
                     m_oStateBitmapRect[0][CS_Normal].x1;
        m_oRect.y2 = m_oRect.y1 + m_oStateBitmapRect[0][CS_Normal].y2 -
                     m_oStateBitmapRect[0][CS_Normal].y1;
    }    
    m_oMutex.Release();

    Transition(CT_None, NULL);
}
Exemplo n.º 3
0
void PixSliderControl::Init(void)
{
    m_oMutex.Acquire();

    if (!m_bUsesStateBitmapRects) {
        for (int row = 0; row < m_iNumStates; row++) { 
            for (int i = 0; i < 4; i++) {
                int iFrameWidth, iFrameHeight;
                Rect oFrameRect;
    
                iFrameWidth = (m_oBitmapRect.Width() + 1) / 4;
                iFrameHeight = (m_oBitmapRect.Height() + 1) / m_iNumStates;
     
                oFrameRect = m_oBitmapRect;
                oFrameRect.x1 += i * iFrameWidth;
                oFrameRect.x2 = oFrameRect.x1 + iFrameWidth - 1;
                oFrameRect.y1 += row * iFrameHeight;
                oFrameRect.y2 = oFrameRect.y1 + iFrameHeight - 1;

                switch (i) {
                    case 0:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Normal, row);
                        break;
                    case 1:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_MouseOver, row);
                        break;
                    case 2:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Pressed, row);
                        break;
                    case 3:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Disabled, row);
                        break;
                    default:
                        break;
                }
            }
        }
    }

    if (m_oRect.x2 == -1 && m_oRect.y2 == -1)
    {
        m_oRect.x2 = m_oRect.x1 + m_oStateBitmapRect[0][CS_Normal].x2 -
                     m_oStateBitmapRect[0][CS_Normal].x1; 
        m_oRect.y2 = m_oRect.y1 + m_oStateBitmapRect[0][CS_Normal].y2 -
                     m_oStateBitmapRect[0][CS_Normal].y1; 
    }    
    m_oMutex.Release();
    
    if (!m_bActivationReveal) 
        BlitFrame(CS_Normal, m_iState);
}
Exemplo n.º 4
0
// 设置默认风格,nStyle 0-2,3个文字按钮,1-4个文字按钮
void CBmpButton::SetDefaultButton(int nStyle)
{
	if (nStyle==0)
	{
		SetStateBitmap(_T("skin\\btndefault1normal.bmp"), _T("skin\\btndefault1Click.bmp"), _T("skin\\btndefault1over.bmp"), _T("skin\\btndefault1normal.bmp"));
	}
	else if (nStyle==1)
	{
		SetStateBitmap(_T("skin\\btndefault2normal.bmp"), _T("skin\\btndefault2click.bmp"), _T("skin\\btndefault2over.bmp"), _T("skin\\btndefault2normal.bmp"));
	}
	else if (nStyle==2)
	{
		SetStateBitmap(_T("skin\\btndefault3normal.bmp"), _T("skin\\btndefault3click.bmp"), _T("skin\\btndefault3over.bmp"), _T("skin\\btndefault3normal.bmp"));
	}
}
Exemplo n.º 5
0
void MultiStateControl::Init(void)
{
    uint32 iOffset;
    int    iRet;
    char  *szDup;

    m_oMutex.Acquire();

    szDup = strdup(m_oDesc.c_str());
    iOffset = 0;
    for(;;)
    {
        iRet = sscanf((char *)m_oDesc.c_str() + iOffset, "%[^|]", szDup);
        if (iRet < 1) 
            break;
            
        m_oDescs.push_back(string(szDup));
            
        iOffset += strlen(szDup) + 2;
        if (iOffset > m_oDesc.length())
            break;
    }
    free(szDup);

    szDup = strdup(m_oToolTip.c_str());
    iOffset = 0;
    for(;;)
    {
        iRet = sscanf((char *)m_oToolTip.c_str() + iOffset, "%[^|]", szDup);
        if (iRet < 1) 
            break;
            
        m_oTips.push_back(string(szDup));
            
        iOffset += strlen(szDup) + 2;
        if (iOffset > m_oToolTip.length())
            break;
    }
    free(szDup);

    if (!m_bUsesStateBitmapRects) {
        for (int row = 0; row < m_iNumStates; row++) { 
            for (int i = 0; i < 4; i++) {
                int iFrameWidth, iFrameHeight;
                Rect oFrameRect;
    
                iFrameWidth = (m_oBitmapRect.Width() + 1) / 4;
                iFrameHeight = (m_oBitmapRect.Height() + 1) / m_iNumStates;
     
                oFrameRect = m_oBitmapRect;
                oFrameRect.x1 += i * iFrameWidth;
                oFrameRect.x2 = oFrameRect.x1 + iFrameWidth - 1;
                oFrameRect.y1 += row * iFrameHeight;
                oFrameRect.y2 = oFrameRect.y1 + iFrameHeight - 1;

                switch (i) {
                    case 0:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Normal, row);
                        break;
                    case 1:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_MouseOver, row);
                        break;
                    case 2:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Pressed, row);
                        break;
                    case 3:
                        SetStateBitmap(m_pBitmap, oFrameRect, CS_Disabled, row);
                        break;
                    default:
                        break;
                }
            }
        }
    }

    if (m_oRect.x2 == -1 && m_oRect.y2 == -1)
    {
        m_oRect.x2 = m_oRect.x1 + m_oStateBitmapRect[0][CS_Normal].x2 -
                     m_oStateBitmapRect[0][CS_Normal].x1; 
        m_oRect.y2 = m_oRect.y1 + m_oStateBitmapRect[0][CS_Normal].y2 -
                     m_oStateBitmapRect[0][CS_Normal].y1; 
        //m_oOrigRect = m_oRect;
    }    
    m_oMutex.Release();
    
    BlitFrame(CS_Normal, m_iState);
}
Exemplo n.º 6
0
void CBmpButton::SetStateBitmap(
								  LPCTSTR lpUnNormal,LPCTSTR lpUnSelect,
								  LPCTSTR lpUnOver,LPCTSTR lpDisabel,
								  LPCTSTR lpChNormal, LPCTSTR lpChSelect,
								  LPCTSTR lpChNormalOver )
{
	CBitmap *pBmpUncheckedNormal	= new CBitmap;
	CBitmap *pBmpUncheckedSelect	= new CBitmap;
	CBitmap *pBmpUncheckedOver		= new CBitmap;
	CBitmap *pBmpCheckedNormal		= new CBitmap;
	CBitmap *pBmpCheckedSelect		= new CBitmap;
	CBitmap *pBmpCheckedOver		= new CBitmap;
	CBitmap *pBmpDisable			= new CBitmap;
	
	HBITMAP hBmpUnNormal = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),lpUnNormal,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
	pBmpUncheckedNormal->Attach(hBmpUnNormal);
	
	HBITMAP hBmpUnSelect = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),lpUnSelect,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
	pBmpUncheckedSelect->Attach(hBmpUnSelect);
	
	HBITMAP hBmpUnOver = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),lpUnOver,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
	pBmpUncheckedOver->Attach(hBmpUnOver);
	

	if (lpDisabel != lpUnNormal)
	{
		HBITMAP hBmpDisable = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),lpDisabel,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
		if (hBmpDisable)
			pBmpDisable->Attach(hBmpDisable);
	}
	else
	{
		pBmpDisable->Attach(hBmpUnNormal);
	}

	if (lpChNormal == lpUnSelect || lpChSelect == lpUnSelect)
	{
		pBmpCheckedNormal->Attach(hBmpUnSelect);
		pBmpCheckedSelect->Attach(hBmpUnSelect);
		pBmpCheckedOver->Attach(hBmpUnOver);
	}
	else
	{
		if (lpChNormal)
		{
			HBITMAP hBmpChNormal = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),lpChNormal,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
			pBmpCheckedNormal->Attach(hBmpChNormal);
		}
		if (lpChSelect != NULL )
		{
			HBITMAP hBmpChSelect = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),lpChSelect,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
			if (hBmpChSelect)
				pBmpCheckedSelect->Attach(hBmpChSelect);
		}
		if (lpChNormalOver != NULL)
		{
			HBITMAP hBmpChOver = (HBITMAP)::LoadImage(AfxGetInstanceHandle(),lpChNormalOver,IMAGE_BITMAP,0,0,LR_LOADFROMFILE|LR_CREATEDIBSECTION|LR_DEFAULTSIZE);
			if (hBmpChOver)
				pBmpCheckedOver->Attach(hBmpChOver);
		}

	}
	
	SetStateBitmap(pBmpUncheckedNormal,pBmpUncheckedSelect,pBmpUncheckedOver,pBmpDisable,pBmpCheckedNormal,pBmpCheckedSelect,pBmpCheckedOver);
	
	m_bBmpIsCreateBySelf = TRUE;
}