CPI_InterfacePart_Indicator.c
上传用户:tuheem
上传日期:2007-05-01
资源大小:21889k
文件大小:3k
源码类别:
多媒体编程
开发平台:
Visual C++
- ////////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "globals.h"
- #include "CPI_InterfacePart.h"
- #include "CPI_Indicators.h"
- ////////////////////////////////////////////////////////////////////////////////
- //
- typedef struct _CPs_IPIndicator
- {
- char* m_pcName;
- } CPs_IPIndicator;
- //
- ////////////////////////////////////////////////////////////////////////////////
- void IPIC_Destroy_PrivateData(CP_HINTERFACEPART hPart);
- void IPIC_Draw(CP_HINTERFACEPART hPart, CPs_DrawContext* pContext);
- ////////////////////////////////////////////////////////////////////////////////
- //
- //
- //
- CP_HINTERFACEPART IP_Create_Indicator(const char* pcName)
- {
- CPs_InterfacePart* pNewPart;
- CPs_IPIndicator* pCustomData;
- // Setup custom data
- pCustomData = (CPs_IPIndicator*)malloc(sizeof(*pCustomData));
- STR_AllocSetString(&pCustomData->m_pcName, pcName, FALSE);
- // Create new part and setup callbacks
- pNewPart = (CPs_InterfacePart*)malloc(sizeof(*pNewPart));
- memset(pNewPart, 0, sizeof(*pNewPart));
- pNewPart->Destroy_PrivateData = IPIC_Destroy_PrivateData;
- pNewPart->Draw = IPIC_Draw;
- pNewPart->m_pPrivateData = pCustomData;
- CPIC_BindIndicatorToControl(pcName, pNewPart);
- return pNewPart;
- }
- //
- //
- //
- void IPIC_Draw(CP_HINTERFACEPART hPart, CPs_DrawContext* pContext)
- {
- CPs_InterfacePart* pIP;
- const char* pcValue;
- CPs_IPIndicator* pIPIC;
- // Init
- pIP = (CPs_InterfacePart*)hPart;
- CP_CHECKOBJECT(pIP);
- pIPIC = (CPs_IPIndicator*)pIP->m_pPrivateData;
- CP_CHECKOBJECT(pIPIC);
- // Draw the window background
- CPIG_TiledFill(pContext, &pIP->m_rLocation, &glb_pSkin->mpl_rListHeader_SourceTile, glb_pSkin->mpl_pListHeader_Down, CIC_TILEDFILOPTIONS_NONE);
- pcValue = CPIC_GetIndicatorValue(pIPIC->m_pcName);
- if(pcValue)
- {
- HFONT hfOld;
- RECT rText;
- rText = pIP->m_rLocation;
- rText.left += glb_pSkin->mpl_rListHeader_SourceTile.left;
- rText.right -= glb_pSkin->mpl_rListHeader_SourceTile.right;
- hfOld = (HFONT)SelectObject(pContext->m_dcDraw, glb_pSkin->mpl_hfFont);
- SetTextColor(pContext->m_dcDraw, glb_pSkin->mpl_ListHeaderColour);
- SetBkMode(pContext->m_dcDraw, TRANSPARENT);
- DrawText(pContext->m_dcDraw, pcValue, -1, &rText, DT_WORD_ELLIPSIS | DT_NOPREFIX | DT_VCENTER);
- SelectObject(pContext->m_dcDraw, hfOld);
- }
- }
- //
- //
- //
- void IPIC_Destroy_PrivateData(CP_HINTERFACEPART hPart)
- {
- CPs_InterfacePart* pIP;
- CPs_IPIndicator* pIPIC;
- // Init
- pIP = (CPs_InterfacePart*)hPart;
- CP_CHECKOBJECT(pIP);
- pIPIC = (CPs_IPIndicator*)pIP->m_pPrivateData;
- CP_CHECKOBJECT(pIPIC);
- free(pIPIC->m_pcName);
- free(pIPIC);
- CPIC_UnBindControl(hPart);
- }
- //
- //
- //