Code/Resource
Windows Develop
Linux-Unix program
Internet-Socket-Network
Web Server
Browser Client
Ftp Server
Ftp Client
Browser Plugins
Proxy Server
Email Server
Email Client
WEB Mail
Firewall-Security
Telnet Server
Telnet Client
ICQ-IM-Chat
Search Engine
Sniffer Package capture
Remote Control
xml-soap-webservice
P2P
WEB(ASP,PHP,...)
TCP/IP Stack
SNMP
Grid Computing
SilverLight
DNS
Cluster Service
Network Security
Communication-Mobile
Game Program
Editor
Multimedia program
Graph program
Compiler program
Compress-Decompress algrithms
Crypt_Decrypt algrithms
Mathimatics-Numerical algorithms
MultiLanguage
Disk/Storage
Java Develop
assembly language
Applications
Other systems
Database system
Embeded-SCM Develop
FlashMX/Flex
source in ebook
Delphi VCL
OS Develop
MiddleWare
MPI
MacOS develop
LabView
ELanguage
Software/Tools
E-Books
Artical/Document
CPI_InterfacePart_CommandButton.c
Package: VC++视频传输.rar [view]
Upload User: hxb_1234
Upload Date: 2010-03-30
Package Size: 8328k
Code Size: 5k
Category:
Visual C++ Books
Development Platform:
Visual C++
- ////////////////////////////////////////////////////////////////////////////////
- #include "stdafx.h"
- #include "globals.h"
- #include "CPI_InterfacePart.h"
- ////////////////////////////////////////////////////////////////////////////////
- //
- typedef struct _CPs_IPCommandButton
- {
- CPs_Image_WithState* m_pStateImage;
- CPe_ImageState m_enCurrentState;
- wp_Verb m_pfnVerb;
- BOOL m_bDown;
- } CPs_IPCommandButton;
- //
- ////////////////////////////////////////////////////////////////////////////////
- void IPCB_Destroy_PrivateData(CP_HINTERFACEPART hPart);
- void IPCB_Draw(CP_HINTERFACEPART hPart, CPs_DrawContext* pContext);
- void IPCB_onMouseIn(CP_HINTERFACEPART hPart);
- void IPCB_onMouseOut(CP_HINTERFACEPART hPart);
- void IPCB_onMouseButton_LDown(CP_HINTERFACEPART hPart, const POINTS ptMouse);
- void IPCB_onMouseButton_LUp(CP_HINTERFACEPART hPart, const POINTS ptMouse);
- ////////////////////////////////////////////////////////////////////////////////
- //
- //
- //
- CP_HINTERFACEPART IP_Create_CommandButton(wp_Verb pfnVerb, CPs_Image_WithState* pImageWS)
- {
- CPs_InterfacePart* pNewPart;
- CPs_IPCommandButton* pCustomData;
- // Setup custom data
- pCustomData = (CPs_IPCommandButton*)malloc(sizeof(*pCustomData));
- pCustomData->m_pStateImage = pImageWS;
- pCustomData->m_enCurrentState = igsQuiescent;
- pCustomData->m_pfnVerb = pfnVerb;
- pCustomData->m_bDown = FALSE;
- // Create new part and setup callbacks
- pNewPart = (CPs_InterfacePart*)malloc(sizeof(*pNewPart));
- memset(pNewPart, 0, sizeof(*pNewPart));
- pNewPart->Destroy_PrivateData = IPCB_Destroy_PrivateData;
- pNewPart->Draw = IPCB_Draw;
- pNewPart->onMouseIn = IPCB_onMouseIn;
- pNewPart->onMouseOut = IPCB_onMouseOut;
- pNewPart->onMouseButton_LDown = IPCB_onMouseButton_LDown;
- pNewPart->onMouseButton_LUp = IPCB_onMouseButton_LUp;
- pNewPart->m_pPrivateData = pCustomData;
- return pNewPart;
- }
- //
- //
- //
- void IPCB_Draw(CP_HINTERFACEPART hPart, CPs_DrawContext* pContext)
- {
- CPs_InterfacePart* pIP;
- CPs_IPCommandButton* pIPCB;
- // Init
- pIP = (CPs_InterfacePart*)hPart;
- CP_CHECKOBJECT(pIP);
- pIPCB = (CPs_IPCommandButton*)pIP->m_pPrivateData;
- CP_CHECKOBJECT(pIPCB);
- // Perform drawing
- CPIG_DrawStateImage(pContext,
- pIP->m_rLocation.left, pIP->m_rLocation.top,
- pIPCB->m_pStateImage, pIPCB->m_enCurrentState);
- }
- //
- //
- //
- void IPCB_Destroy_PrivateData(CP_HINTERFACEPART hPart)
- {
- CPs_InterfacePart* pIP;
- CPs_IPCommandButton* pIPCB;
- // Init
- pIP = (CPs_InterfacePart*)hPart;
- CP_CHECKOBJECT(pIP);
- pIPCB = (CPs_IPCommandButton*)pIP->m_pPrivateData;
- CP_CHECKOBJECT(pIPCB);
- free(pIPCB);
- }
- //
- //
- //
- void IPCB_onMouseIn(CP_HINTERFACEPART hPart)
- {
- CPs_InterfacePart* pIP;
- CPs_IPCommandButton* pIPCB;
- // Init
- pIP = (CPs_InterfacePart*)hPart;
- CP_CHECKOBJECT(pIP);
- pIPCB = (CPs_IPCommandButton*)pIP->m_pPrivateData;
- CP_CHECKOBJECT(pIPCB);
- // Handler
- if(pIPCB->m_bDown)
- pIPCB->m_enCurrentState = igsActive;
- else
- pIPCB->m_enCurrentState = igsFloatActive;
- IP_Invalidate(hPart);
- }
- //
- //
- //
- void IPCB_onMouseOut(CP_HINTERFACEPART hPart)
- {
- CPs_InterfacePart* pIP;
- CPs_IPCommandButton* pIPCB;
- // Init
- pIP = (CPs_InterfacePart*)hPart;
- CP_CHECKOBJECT(pIP);
- pIPCB = (CPs_IPCommandButton*)pIP->m_pPrivateData;
- CP_CHECKOBJECT(pIPCB);
- // Handler
- pIPCB->m_enCurrentState = igsQuiescent;
- IP_Invalidate(hPart);
- }
- //
- //
- //
- void IPCB_onMouseButton_LDown(CP_HINTERFACEPART hPart, const POINTS ptMouse)
- {
- CPs_InterfacePart* pIP;
- CPs_IPCommandButton* pIPCB;
- // Init
- pIP = (CPs_InterfacePart*)hPart;
- CP_CHECKOBJECT(pIP);
- pIPCB = (CPs_IPCommandButton*)pIP->m_pPrivateData;
- CP_CHECKOBJECT(pIPCB);
- // Handler
- pIPCB->m_bDown = TRUE;
- if(pIPCB->m_enCurrentState == igsFloatActive)
- pIPCB->m_enCurrentState = igsActive;
- IP_Invalidate(hPart);
- }
- //
- //
- //
- void IPCB_onMouseButton_LUp(CP_HINTERFACEPART hPart, const POINTS ptMouse)
- {
- CPs_InterfacePart* pIP;
- CPs_IPCommandButton* pIPCB;
- // Init
- pIP = (CPs_InterfacePart*)hPart;
- CP_CHECKOBJECT(pIP);
- pIPCB = (CPs_IPCommandButton*)pIP->m_pPrivateData;
- CP_CHECKOBJECT(pIPCB);
- // Handler
- pIPCB->m_bDown = FALSE;
- if(pIPCB->m_enCurrentState == igsActive)
- {
- // Mouse is still inside control
- pIPCB->m_enCurrentState = igsFloatActive;
- if(pIPCB->m_pfnVerb)
- pIPCB->m_pfnVerb(vaDoVerb, NULL);
- }
- IP_Invalidate(hPart);
- }
- //
- //
- //