?? cpi_interfacepart_indicator.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);
}
//
//
//
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -