📄 frameobject.cpp
字号:
// ***************************************************************
// FrameObject version: 1.0
// -------------------------------------------------------------
// File Name: FrameObject.cpp
// Created: 2007/07/18
// Modified: 2007/07/18 16:31
// Author: William.Liang
// Msn: lwq49@msn.com
// Email: lwq49@21cn.com, lwq49@msn.com
// Description:
//
// Purpose:
// -------------------------------------------------------------
// license:
//
// The contents of this file are subject to the Mozilla Public
// License Version 1.1 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy
// of the License at http://www.mozilla.org/MPL/ Software dis-
// tributed under the License is distributed on an "AS IS"
// basis, WITHOUT WARRANTY OF ANY KIND, either express or im-
// plied. See the License for the specific language governing
// rights and limitations under the License.
//
// The Initial Developer of the Original Code is William.Liang .
// Copyright (C) 2007 - All Rights Reserved.
// ***************************************************************
#include "StdAfx.h"
#include ".\FrameObject.h"
//************************************
// <p>Description: 构造函数</p>
//************************************
CFrameObject::CFrameObject(void)
{
m_pParent = NULL;
ZeroMemory(&m_BasalInfo, sizeof(m_BasalInfo));
ZeroMemory(m_szName, sizeof(TCHAR)*MAX_NAME);
m_BasalInfo.Visabled = true;
m_BasalInfo.Disabled = false;
m_BasalInfo.Clickabled = true;
LPGDI lpGDI = g_lpDefaultResource->GetGDI();
m_BasalInfo.Size.cx = (float)lpGDI->System_GetState(HGE_SCREENWIDTH);
m_BasalInfo.Size.cy = (float)lpGDI->System_GetState(HGE_SCREENHEIGHT);
m_wCacheType= 0;
m_bChanged = false;
m_enGameType = Type_Unknow;
}
//************************************
// <p>Description: 析构函数</p>
//************************************
CFrameObject::~CFrameObject(void)
{
}
//************************************
// <p>Description: 设置父对象</p>
// <p>Parameters: </p>
// <p> IUnknownEx * pIUnknownEx</p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::SetParent(IUnknownEx* pIUnknownEx){
m_pParent = pIUnknownEx;
}
//************************************
// <p>Description: 返回父对象</p>
// <p>Parameters: </p>
//
// <p>Returns: IUnknownEx*</p>
//************************************
IUnknownEx* CFrameObject::GetParent(){
return m_pParent;
}
//
////对象创建
//bool CFrameObject::Create(LPCTSTR lpName, _SIZE siSize, enGameObjectType enType, ...){
// SetObjectName(lpName);
// this->m_BasalInfo.Size = siSize;
// m_enGameType = enType;
//
// return true;
//}
//************************************
// <p>Description: 设置名字</p>
// <p>Parameters: </p>
// <p> LPCTSTR lpName</p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::SetObjectName(LPCTSTR lpName){
strncpy(m_szName, lpName, MAX_NAME);
}
//************************************
// <p>Description: 获取名字</p>
// <p>Parameters: </p>
//
// <p>Returns: LPCTSTR</p>
//************************************
LPCTSTR CFrameObject::GetObjectName(){
return m_szName;
}
//设置类型
void CFrameObject::SetObjectType(enGameObjectType enGameObjectType){
m_enGameType = enGameObjectType;
}
//************************************
// <p>Description: 返回类型</p>
// <p>Parameters: </p>
//
// <p>Returns: enGameObjectType</p>
//************************************
enGameObjectType CFrameObject::GetObjectType(){
return m_enGameType;
}
//设置缓冲类型
void CFrameObject::SetCacheType(WORD wType){
m_wCacheType = wType;
}
//返回缓冲类型
WORD CFrameObject::GetCacheType(){
return m_wCacheType;
}
//通知变动
void CFrameObject::NotifiyChange(){
m_bChanged = true;
if(m_pParent){
IBaseObject* pParent = GET_OBJECTPTR_INTERFACE(m_pParent, IBaseObject);
if(pParent)
pParent->NotifiyChange();
}
}
//************************************
// <p>Description: 设置可视</p>
// <p>Parameters: </p>
// <p> bool bFlag</p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::SetVisabled(bool bFlag){
m_BasalInfo.Visabled = bFlag;
}
//************************************
// <p>Description: 设置禁用</p>
// <p>Parameters: </p>
// <p> bool bFlag</p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::SetDisabled(bool bFlag){
m_BasalInfo.Disabled = bFlag;
}
//************************************
// <p>Description: 是否可视</p>
//
// <p>Returns: bool</p>
//************************************
bool CFrameObject::IsVisabled(){
return m_BasalInfo.Visabled;
}
//************************************
// <p>Description: 是否禁用</p>
//
// <p>Returns: bool</p>
//************************************
bool CFrameObject::IsDisabled(){
return m_BasalInfo.Disabled;
}
//************************************
// <p>Description: 返回深度</p>
// <p>Parameters: </p>
//
// <p>Returns: DWORD</p>
//************************************
DWORD CFrameObject::GetDepth(){
return m_BasalInfo.Depth;
}
//************************************
// <p>Description: 设置深度</p>
// <p>Parameters: </p>
// <p> DWORD dwDepth</p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::SetDepth(DWORD dwDepth){
m_BasalInfo.Depth = dwDepth;
}
//************************************
// <p>Description: 设置中心</p>
// <p>Parameters: </p>
// <p> _POINT piPoint</p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::SetAnchorPosition(_POINT piPoint){
m_BasalInfo.AnchorPos = piPoint;
}
//************************************
// <p>Description: 返回大小</p>
// <p>Parameters: </p>
// <p> _SIZE siSize</p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::SetSize(_SIZE siSize){
m_BasalInfo.Size = siSize;
}
//************************************
// <p>Description: 返回大小</p>
// <p>Parameters: </p>
//
// <p>Returns: _SIZE</p>
//************************************
_SIZE CFrameObject::GetSize(){
return m_BasalInfo.Size;
}
//************************************
// <p>Description: 返回基本信息</p>
// <p>Parameters: </p>
//
// <p>Returns: BASALINFO&</p>
//************************************
BASALINFO& CFrameObject::GetBasalInfo(){
return m_BasalInfo;
}
//************************************
// <p>Description: 移动对象</p>
// <p>Parameters: </p>
// <p> _POINT piPoint</p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::MoveTo(_POINT piPoint){
m_BasalInfo.LocalPos = piPoint;
//重计坐标
CalcContainerPosition();
}
//************************************
// <p>Description: 返回对象坐标相对于屏幕</p>
// <p>Parameters: </p>
//
// <p>Returns: _POINT</p>
//************************************
_POINT CFrameObject::GetScreenPosition(){
return m_BasalInfo.ScreenPos;
}
//************************************
// <p>Description: 返回对象相对于容器的坐标</p>
// <p>Parameters: </p>
//
// <p>Returns: _POINT</p>
//************************************
_POINT CFrameObject::GetLocalPosition(){
return m_BasalInfo.LocalPos;
}
//************************************
// <p>Description: 返回对象容器坐标</p>
// <p>Parameters: </p>
//
// <p>Returns: _POINT</p>
//************************************
_POINT CFrameObject::GetContainerPosition(){
return m_BasalInfo.ContainerPos;
}
//************************************
// <p>Description: 返回对象容器坐标</p>
// <p>Parameters: </p>
//
// <p>Returns: _POINT</p>
//************************************
_POINT CFrameObject::GetAnchorPosition(){
return m_BasalInfo.AnchorPos;
}
//************************************
// <p>Description: 返回对象容器坐标</p>
// <p>Parameters: </p>
//
// <p>Returns: void</p>
//************************************
void CFrameObject::CalcContainerPosition(){
//设置上一级的容器坐标
if(m_pParent!=NULL){
_POINT piContainerPosition = ((IFrameObject*)m_pParent)->GetScreenPosition();
m_BasalInfo.ContainerPos.x = m_BasalInfo.LocalPos.x + piContainerPosition.x;
m_BasalInfo.ContainerPos.y = m_BasalInfo.LocalPos.y + piContainerPosition.y;
m_BasalInfo.ScreenPos = m_BasalInfo.ContainerPos;
}
else{
m_BasalInfo.ScreenPos = m_BasalInfo.ContainerPos = m_BasalInfo.LocalPos;
}
return;
}
//************************************
// <p>Description: 屏幕坐标转本地坐标</p>
// <p>Parameters: </p>
//
// <p>Returns: void</p>
//************************************
_POINT CFrameObject::ScreenToLocal(_POINT piScreen){
return piScreen - m_BasalInfo.ContainerPos - m_BasalInfo.LocalPos;
}
//************************************
// <p>Description: 本地坐标转屏幕坐标</p>
// <p>Parameters: </p>
//
// <p>Returns: void</p>
//************************************
_POINT CFrameObject::LocalToScreen(_POINT piLocal){
return m_BasalInfo.ContainerPos + m_BasalInfo.LocalPos + piLocal;
}
//渲染场景
void CFrameObject::Render(WPARAM wParam){
////0为不缓冲模式 1为自动模式, 2为手动模式
//if(m_wCacheType==0){
// PreRender(wParam);
//}
//else{
// if(m_bChanged || m_hgeSprite->GetTexture()==NULL){
// //当子对象通知有变动时重新生成缓冲
// LPGDI lpGDI = g_lpDefaultResource->GetGDI();
// //if(m_RenderTarget>0) lpGDI->Target_Free(m_RenderTarget);
// if((m_RenderTarget = lpGDI->Target_Create((int)m_BasalInfo.Size.cx, (int)m_BasalInfo.Size.cy, true))>0){
// //写入纹理缓冲区
// lpGDI->Gfx_BeginScene(m_RenderTarget);
// lpGDI->Gfx_Clear(0);
// PreRender(wParam);
// lpGDI->Gfx_EndScene();
// //设置图形纹理
// if(m_hgeSprite){
// //lpGDI->Texture_Free(m_hgeSprite->GetTexture());
// HTEXTURE hTexture = lpGDI->Target_GetTexture(m_RenderTarget);
// m_hgeSprite->SetTexture(hTexture);
// m_hgeSprite->SetTextureRect(0,0,m_BasalInfo.Size.cx, m_BasalInfo.Size.cy);
// //m_hgeSprite->Render(m_BasalInfo.ScreenPos.x, m_BasalInfo.ScreenPos.y);
// }
// }
// m_bChanged = false;
// }
// else{
// //否则直接输出缓冲
// m_hgeSprite->Render(m_BasalInfo.ScreenPos.x, m_BasalInfo.ScreenPos.y);
// }
//}
}
//************************************
// <p>Description: 接口函数</p>
// <p>Parameters: </p>
// <p> const IID & Guid</p>
// <p> DWORD dwQueryVer</p>
//
// <p>Returns: void*</p>
//************************************
void* CFrameObject::QueryInterface(const IID &Guid, DWORD dwQueryVer){
QUERYINTERFACE(IFrameObject,Guid,dwQueryVer);
QUERYINTERFACE(IBaseObject,Guid,dwQueryVer);
QUERYINTERFACE_IUNKNOWNEX(IFrameObject,Guid,dwQueryVer);
return NULL;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -