📄 gameobjectslider.h
字号:
// ***************************************************************
// GameObject version: 1.0
// -------------------------------------------------------------
// File Name: GameObjectSlider.h
// Created: 2007/07/31
// Modified: 2007/07/31 23:28
// 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.
// ***************************************************************
#ifndef GAME_OBJECT_SLIDER_HEAD_FILE
#define GAME_OBJECT_SLIDER_HEAD_FILE
#pragma once
#include "Objectcom.h"
#include "gameobject.h"
#include "gamegroup.h"
#include "GameObjectSprite.h"
#define CN_SLIDER_TYPE_NORMAL 0
#define CN_SLIDER_TYPE_EXTEND 1
#define CN_SLIDER_DIRECTION_LEFTRIGHT 1
#define CN_SLIDER_DIRECTION_RIGHTLEFT 2
#define CN_SLIDER_DIRECTION_TOPBOTTOM 3
#define CN_SLIDER_DIRECTION_BOTTOMTOP 4
class OBJECT_COM_CLASS CGameObjectSlider :
public IGameObjectSlider, public CGameGroup
{
private:
_SIZE m_siInterval; //间距
protected:
CResource* m_pResource; //图片资源
WORD m_wCurrent; //当前值
WORD m_wMax; //最大值
WORD m_wMin; //最小值
WORD m_wSliderType; //滑动类型
WORD m_wStep; //步长值
WORD m_wDirection; //增长方向
CGameObjectSprite m_GOBar; //Bar的图形
CGameObjectSprite m_GOBlock; //Block的图形
bool m_bDropping; //是否拖动中
HWND m_hWnd; //HGE窗口句柄
private:
//计算间隔
void CalcInterval();
public:
CGameObjectSlider(void);
virtual ~CGameObjectSlider(void);
//公共相关方法
public:
//对象创建
virtual bool __cdecl Create(LPCTSTR lpName, _SIZE siSize, CResource* pResource, _RECT rcBar, _RECT rcBlock, WORD wSliderType=CN_SLIDER_TYPE_NORMAL, WORD wDirection = CN_SLIDER_DIRECTION_LEFTRIGHT, WORD wMax=1, WORD wMin=0, WORD wStep=1);
//渲染对象
virtual void __cdecl Render(WPARAM wParam=NULL);
//调整当前值
virtual bool __cdecl Increase(bool bFlag=true);
public:
//返回当前值
virtual WORD __cdecl GetCurrent();
//返回增长方向
virtual WORD __cdecl GetDirection();
//返回最大值
virtual WORD __cdecl GetMax();
//返回最小值
virtual WORD __cdecl GetMin();
//返回滑动类型
virtual WORD __cdecl GetSliderType();
//返回步长值
virtual WORD __cdecl GetStep();
//设置BAR的纹理区域
virtual void __cdecl SetBarRect(_RECT rcRect);
//设置BLOCK的纹理区域
virtual void __cdecl SetBlockRect(_RECT rcRect);
//设置当前值
virtual void __cdecl SetCurrent(WORD wCurrent);
//设置增长方向
virtual void __cdecl SetDirection(WORD wDirection);
//设置最大值
virtual void __cdecl SetMax(WORD wMax);
//设置最小值
virtual void __cdecl SetMin(WORD wMin);
//设置图片资源
virtual void __cdecl SetResource(CResource* pResource);
//设置滑动类型
virtual void __cdecl SetSliderType(WORD wType);
//设置步长值
virtual void __cdecl SetStep(WORD wStep);
//模板方法
public:
//是否有效
virtual bool __cdecl IsValid() { return AfxIsValidAddress(this,sizeof(CGameObjectSlider))?true:false;};
//释放对象
virtual bool __cdecl Release() { if (IsValid()) delete this; return true; };
//接口查询
virtual void * __cdecl QueryInterface(const IID & Guid, DWORD dwQueryVer);
public:
//操作重载
CGameObjectSlider& operator=(CGameObjectSlider& GameObject);
//事件处理
public:
//鼠标移动
virtual bool __cdecl OnMouseMove(float x, float y, UINT nComboKey);
//鼠标点击
virtual bool __cdecl OnMouseClick(float x, float y, int nType, UINT nMessage, UINT nComboKey);
//鼠标移出
virtual bool __cdecl OnMouseOut(float x, float y, int nType, UINT nMessage, UINT nComboKey);
//键盘事件
virtual bool __cdecl OnKeyDown(TCHAR nKey, UINT nFlag);
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -