本文整理汇总了C++中CMouse类的典型用法代码示例。如果您正苦于以下问题:C++ CMouse类的具体用法?C++ CMouse怎么用?C++ CMouse使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMouse类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
//--------------------------------------------------------------------------------------
void CProgressBarVertical::Draw ( void )
{
if ( !m_bVisible )
return;
CMouse *pMouse = m_pDialog->GetMouse ();
if ( pMouse &&
m_bPressed &&
m_rBoundingBox.ContainsPoint ( pMouse->GetPos () ) &&
!m_timer.Running() )
{
if ( pMouse->GetPos ().m_nY > m_rProgress.m_pos.m_nY + m_rProgress.m_size.cx )
{
m_timer.Start ( PROGRESSBAR_ARROWCLICK_START );
SetValue ( m_fValue + m_fStep );
}
else if ( pMouse->GetPos ().m_nY < m_rProgress.m_pos.m_nY + m_rProgress.m_size.cx )
{
m_timer.Start ( PROGRESSBAR_ARROWCLICK_START );
SetValue ( m_fValue - m_fStep );
}
}
m_pDialog->DrawBox ( m_rBoundingBox, m_sControlColor.d3dColorBoxBack, m_sControlColor.d3dColorOutline, m_bAntAlias );
m_pDialog->DrawBox ( m_rProgress, m_sControlColor.d3dColorBoxSel, m_sControlColor.d3dColorOutline, m_bAntAlias );
}
示例2: OnShow
void CBuildDialog::OnShow(){
CDialog::OnShow();
CMouse* mouse = CMouse::GetMouse();
if(this->PtInRect(mouse->Point())){
char woodStr[100]="",foodStr[100]="",stoneStr[100]="",goldStr[100]="";
if(resourceTable.Wood()!=0){
sprintf(woodStr,"木頭:%d ",resourceTable.Wood());
}
if(resourceTable.Food()!=0){
sprintf(foodStr,"食物:%d ",resourceTable.Food());
}
if(resourceTable.Gold()!=0){
sprintf(goldStr,"金礦:%d ",resourceTable.Gold());
}
if(resourceTable.Stone()!=0){
sprintf(stoneStr,"石頭:%d ",resourceTable.Stone());
}
char output[100];
CDC *pDC = CDDraw::GetBackCDC(); // 取得 Back Plain 的 CDC
CFont f,*fp;
f.CreatePointFont(100,"Times New Roman"); // 產生 font f; 160表示16 point的字
fp=pDC->SelectObject(&f); // 選用 font f
pDC->SetBkColor(RGB(0,0,0));
pDC->SetTextColor(RGB(255,255,0));
sprintf(output,"%s%s%s%s",woodStr,foodStr,goldStr,stoneStr);
pDC->TextOutA(mouse->Point().x,mouse->Point().y-20,output);
pDC->SelectObject(fp); // 放掉 font f (千萬不要漏了放掉)
CDDraw::ReleaseBackCDC(); // 放掉 Back Plain 的 CDC
}
}
示例3: Draw
//--------------------------------------------------------------------------------------
void CProgressBarHorizontal::Draw ( void )
{
if ( !m_bVisible )
return;
CMouse *pMouse = m_pDialog->GetMouse ();
assert ( pMouse && "Invalid mouse pointer" );
if ( pMouse &&
m_bPressed &&
m_rBoundingBox.InControlArea ( pMouse->GetPos () ) &&
!m_timer.Running() )
{
if ( pMouse->GetPos ().GetX () > m_rProgress.pos.GetX () + m_rProgress.size.cx )
{
m_timer.Start ( PROGRESSBAR_ARROWCLICK_REPEAT );
SetValue ( m_fValue + m_fStep );
}
else if ( pMouse->GetPos ().GetX () < m_rProgress.pos.GetX () + m_rProgress.size.cx )
{
m_timer.Start ( PROGRESSBAR_ARROWCLICK_REPEAT );
SetValue ( m_fValue - m_fStep );
}
}
m_pDialog->DrawBox ( m_rBoundingBox, m_sControlColor.d3dColorBoxBack, m_sControlColor.d3dColorOutline, m_bAntAlias );
m_pDialog->DrawBox ( m_rProgress, m_sControlColor.d3dColorBoxSel, m_sControlColor.d3dColorOutline, m_bAntAlias );
}
示例4: main
int main(void)
{
CMouse *pMx = new CMouse;
pMx->m_ix = 5; (*pMx).m_iy = 7; // 設定老鼠的位置
*(pMx->m_pcIcon) = '#'; // 設定老鼠的圖示
pMx->Show(); // 在螢幕上顯示老鼠
delete pMx; // 釋放取得的資源
system("pause"); return(0);
}
示例5: GetGameEngine
void CDebugCamera::Update( const FLOAT fFrameTime, BOOL bIsCurrent )
{
CMouse* pMouse = GetGameEngine()->GetInput()->GetMouse();
VECTOR vScroll = GetScroll();
if ( pMouse->IsMouseDown( EMouseButton_Middle ) )
{
VECTOR vMove = pMouse->GetMousePosition() - m_vLastMousePos;
vMove = vMove * GetGameEngine()->GetView()->GetZoom();
vScroll = vScroll - vMove;
SetScroll( vScroll );
}
m_vLastMousePos = pMouse->GetMousePosition();
}
示例6: main
int main(void) {
char cIn;
int iStatus;
CMouse mouseX; // 建立時就會自動呼叫 CMouse 建構元
mouseX.Show(); // 讓老鼠自己畫出自己的位置
iStatus = mouseX.GetStatus();
while( iStatus != 0 ) { // 只要老鼠還在正常狀態就繼續讓使用者輸入
cIn = getch();
if( cIn == 'b' ) g_bBoss = !g_bBoss; // 判斷是否按下按鍵 b
iStatus = mouseX.Update(cIn); // 讓老鼠自己更新狀態
if( iStatus ) mouseX.Show(); // 老鼠沒有死亡, 就必須更新老鼠位置的顯示
else cout << "老鼠已經死亡,遊戲結束" << endl;
}
system("pause"); return(0);
}
示例7: uisession
void UIMouseHandler::captureMouse(ulong uScreenId)
{
/* Do not try to capture mouse if its captured already: */
if (uisession()->isMouseCaptured())
return;
/* If such viewport exists: */
if (m_viewports.contains(uScreenId))
{
/* Store mouse-capturing state value: */
uisession()->setMouseCaptured(true);
/* Memorize the index of machine-view-viewport captured mouse: */
m_iMouseCaptureViewIndex = uScreenId;
/* Memorize the host position where the cursor was captured: */
m_capturedMousePos = QCursor::pos();
/* Acquiring visible viewport rectangle in global coodrinates: */
QRect visibleRectangle = m_viewports[m_iMouseCaptureViewIndex]->visibleRegion().boundingRect();
QPoint visibleRectanglePos = m_views[m_iMouseCaptureViewIndex]->mapToGlobal(m_viewports[m_iMouseCaptureViewIndex]->pos());
visibleRectangle.translate(visibleRectanglePos);
visibleRectangle = visibleRectangle.intersected(QApplication::desktop()->availableGeometry());
#ifdef Q_WS_WIN
/* Move the mouse to the center of the visible area: */
m_lastMousePos = visibleRectangle.center();
QCursor::setPos(m_lastMousePos);
/* Update mouse clipping: */
updateMouseCursorClipping();
#elif defined (Q_WS_MAC)
/* Grab all mouse events: */
::darwinMouseGrab(m_viewports[m_iMouseCaptureViewIndex]);
#else /* Q_WS_MAC */
/* Remember current mouse position: */
m_lastMousePos = QCursor::pos();
/* Grab all mouse events: */
m_viewports[m_iMouseCaptureViewIndex]->grabMouse();
#endif /* !Q_WS_MAC */
/* Switch guest mouse to the relative mode: */
CMouse mouse = session().GetConsole().GetMouse();
mouse.PutMouseEvent(0, 0, 0, 0, 0);
/* Emit signal if required: */
emit mouseStateChanged(mouseState());
}
}
示例8: releaseMouse
/* Mouse capability-change handler: */
void UIMouseHandler::sltMouseCapabilityChanged()
{
/* If mouse supports absolute pointing and mouse-integration activated: */
if (uisession()->isMouseSupportsAbsolute() && uisession()->isMouseIntegrated())
{
/* Release the mouse: */
releaseMouse();
/* Also we should switch guest mouse to the absolute mode: */
CMouse mouse = session().GetConsole().GetMouse();
mouse.PutMouseEventAbsolute(-1, -1, 0, 0, 0);
}
#if 0 /* current team's decision is NOT to capture mouse on mouse-absolute mode loosing! */
/* If mouse-integration deactivated or mouse doesn't supports absolute pointing: */
else
{
/* Search for the machine-view focused now: */
int iFocusedView = -1;
QList<ulong> screenIds = m_views.keys();
for (int i = 0; i < screenIds.size(); ++i)
{
if (m_views[screenIds[i]]->hasFocus())
{
iFocusedView = screenIds[i];
break;
}
}
/* If there is no focused view but views are present we will use the first one: */
if (iFocusedView == -1 && !screenIds.isEmpty())
iFocusedView = screenIds[0];
/* Capture mouse using that view: */
if (iFocusedView != -1)
captureMouse(iFocusedView);
}
#else /* but just to switch the guest mouse into relative mode! */
/* If mouse-integration deactivated or mouse doesn't supports absolute pointing: */
else
{
示例9: MouseInput
void ScrollBar::MouseInput(CMouse &rMouse, int32_t iButton, int32_t iX, int32_t iY, DWORD dwKeyParam)
{
// inherited
Element::MouseInput(rMouse, iButton, iX, iY, dwKeyParam);
// not if scrolling is disabled
if (!fScrolling) return;
// reset arrow states
bool fPrevDown = fTopDown || fBottomDown;
fTopDown = fBottomDown = false;
// not if dragging
if (rMouse.pDragElement) return;
// left mouse button down?
if (rMouse.IsLDown())
// non-scroll-direction area check
if (fHorizontal ? Inside<int32_t>(iY, 0, C4GUI_ScrollBarHgt) : Inside<int32_t>(iX, 0, C4GUI_ScrollBarWdt))
{
// scroll-direction area check: up/left arrow
if (fHorizontal ? Inside<int32_t>(iX, 0, C4GUI_ScrollArrowWdt-1) : Inside<int32_t>(iY, 0, C4GUI_ScrollArrowHgt-1))
fTopDown = true;
// check down arrow
else if (fHorizontal ? Inside<int32_t>(iX, GetBounds().Wdt-C4GUI_ScrollArrowWdt, GetBounds().Wdt-1)
: Inside<int32_t>(iY, GetBounds().Hgt-C4GUI_ScrollArrowHgt, GetBounds().Hgt-1))
fBottomDown = true;
else if (HasPin() && (fHorizontal ? Inside<int32_t>(iX, C4GUI_ScrollArrowWdt, GetBounds().Wdt-C4GUI_ScrollArrowWdt-1)
: Inside<int32_t>(iY, C4GUI_ScrollArrowHgt, GetBounds().Hgt-C4GUI_ScrollArrowHgt-1)))
{
// move thumb here
iScrollPos = GetScrollByPos(iX, iY);
// reflect movement in associated window or do CB
OnPosChanged();
// start dragging
rMouse.pDragElement = this;
GUISound("UI::Select");
}
}
// sound effekt when buttons are pressed
if ((fTopDown || fBottomDown) != fPrevDown) GUISound("UI::Tick");
}
示例10: GetMouse
/*
* 功能: 场景相机玩家操作处理
* 摘要: -
* 参数: -
* 返回值: -
* 作者: lpf
* 创建日期: 2008.02.02
* 修改日志:
* 2008.07.09- lpf
* 增加了对摄象机旋转角度的锁定,主要针对玩家通过鼠标键盘控制摄象机时;
* 2008.07.23- lpf
* 恢复相机操作可以被键盘和鼠标中键的视距缩放操作中断;
* 2008.07.30- lpf
* 鼠标右键双击恢复视角的点击事件时,不恢复视距;
* 2008.10.17 - lpf
* 增加了游戏垂直视角控制由鼠标右键按下上下拖动;
* 2008.12.04 - lpf
* 增加了如果应用程序失去焦点,则清空鼠标信息的处理;
* 2008.12.16 - lpf
* 取消了使用键盘水平旋转视角的过度处理.在收到键盘旋转消息时,直接改变旋转角度,然后就立即改变m_nScorll变量值为0,以停止旋转;
*/
void CRegionCamera::Run(void)
{
// 输入设备对象
CMouse * pMouse = GetMouse();
CKeyBoard * pKeyboard = GetKeyboard();
// 鼠标到左右边缘,左右旋转
POINT ptMouse;
ptMouse.x = pMouse->GetMouseX();
ptMouse.y = pMouse->GetMouseY();
// 键盘控制转方向
if (m_dwState & SCS_KEYBOARD_ABLE)
{
if (m_dwState & SCS_ROTATE_H_ABLE && !(m_dwState & SCS_LOCK_ROTATE))
{
if (pKeyboard->IsKeyDown(DIK_LEFT) && pKeyboard->IsKeyDown(DIK_LCONTROL))
{
//|| GetGame()->GetSetup()->lControl == 1 && pMouse->GetMouseX()<5
//&& pMouse->GetMouseY()>0 && pMouse->GetMouseY()<SCREEN_HEIGHT)
m_nScorll =- 1;
ResumeCamera();
}
if (m_nScorll < 0)
{
// left
m_iHoriAngle -= 3;
m_iHoriAngle = m_iHoriAngle % 360;
// if (abs(m_iHoriAngle%10) <= 1)
m_nScorll=0;
}
if (pKeyboard->IsKeyDown(DIK_RIGHT) && pKeyboard->IsKeyDown(DIK_LCONTROL))
{
//|| GetGame()->GetSetup()->lControl == 1 && pMouse->GetMouseX()>SCREEN_WIDTH-5
//&& pMouse->GetMouseY()>0 && pMouse->GetMouseY()<SCREEN_HEIGHT)
m_nScorll = 1;
ResumeCamera();
}
if (m_nScorll > 0)
{
// right
m_iHoriAngle += 3;
m_iHoriAngle = m_iHoriAngle % 360;
//if (abs(m_iHoriAngle%45) <= 1)
m_nScorll = 0;
}
if (pKeyboard->IsKeyDown(DIK_NEXT) && pKeyboard->IsKeyDown(DIK_LCONTROL))
{
++m_iVertAngle;
if (m_iVertAngle > m_iMaxVertAngle)
m_iVertAngle = m_iMaxVertAngle;
ResumeCamera();
}
if (pKeyboard->IsKeyDown(DIK_PRIOR) && pKeyboard->IsKeyDown(DIK_LCONTROL))
{
--m_iVertAngle;
if (m_iVertAngle < m_iMinVertAngle)
m_iVertAngle = m_iMinVertAngle;
ResumeCamera();
}
}
// 有输入框时无效
//IGUIRoot *pRoot = IGUIRoot::GetGUIInstance();
//if(!pRoot->GetFocusComp())
//{
// // 键盘放缩
// if (pKeyboard->IsKeyDown(DIK_SUBTRACT) || pKeyboard->IsKeyDown(DIK_UP))
// {
// s_fDistance -= 0.5f;
//.........这里部分代码省略.........
示例11: WinMain
//.........这里部分代码省略.........
// ウィンドウモード
presentParameter.Windowed = TRUE;
// デプスバッファ(Zバッファ)とステンシルバッファを作成
presentParameter.EnableAutoDepthStencil = TRUE;
// デプスバッファの利用方法
// D3DFMT_D16 デプスバッファのみを16bitとして扱う
// D3DFMT_D24S8 デプスバッファを24bit ステンシルバッファを8bitとして扱う
presentParameter.AutoDepthStencilFormat = D3DFMT_D24S8;
// ウィンドウモード
presentParameter.FullScreen_RefreshRateInHz = 0;
presentParameter.PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
//--------------------------------------------------------------------
direct3D->CreateDevice(D3DADAPTER_DEFAULT,
D3DDEVTYPE_HAL,
windowHandle,
D3DCREATE_HARDWARE_VERTEXPROCESSING,
&presentParameter,
&device);
CDebug* debug = new CDebug();
debug->Init(device);
CKeyboard* keyboard = new CKeyboard();
keyboard->Init(_instanceHandle, windowHandle);
CMouse* mouse = new CMouse();
mouse->Init(_instanceHandle, windowHandle);
CWiiController* wiiController = new CWiiController();
// メッセージループ
for (;;)
{
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT)
{
// PostQuitMessage()が呼ばれたらループ終了
break;
}
else
{
// メッセージの翻訳とディスパッチ
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
else
{
currentTime = timeGetTime();
if ((currentTime - LastTimeFPS) >= 500)
{
#ifdef _DEBUG
countFPS = flameCount * 1000 / (currentTime - LastTimeFPS);
#endif
LastTimeFPS = currentTime;
示例12: WindowProc
/***********************************************************************************
WindowProc - Main message handler
***********************************************************************************/
LRESULT CALLBACK WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static TRACKMOUSEEVENT tme;
switch(message)
{
case WM_CREATE:
g_pStateIntro->Initialize();
g_pStateMain->Initialize();
g_pStateControl->Initialize();
g_pStateCredits->Initialize();
g_pStatePlay1->Initialize();
//#define _WIN32_WINNT 0x0500 added before <windows.h> in order to get this to work
tme.cbSize = sizeof(tme);
tme.dwFlags = 0x00000002;//TME_LEAVE;
tme.hwndTrack = hWnd;
TrackMouseEvent(&tme);
return 0;
case WM_MOUSEMOVE:
TrackMouseEvent(&tme);
return 0;
case WM_LBUTTONDBLCLK:
return 0;
case WM_LBUTTONDOWN:
mouse.SetLeftButtonDown(true);
return 0;
case WM_LBUTTONUP:
mouse.SetLeftButtonDown(false);
return 0;
case WM_RBUTTONDOWN:
mouse.SetRightButtonDown(true);
return 0;
case WM_RBUTTONUP:
mouse.SetRightButtonDown(false);
return 0;
case WM_MOUSELEAVE:
mouse.SetLeftButtonDown(false);
mouse.SetRightButtonDown(false);
return 0;
case WM_DESTROY:
{
PostQuitMessage(0);
return 0;
} break;
}
return DefWindowProc (hWnd, message, wParam, lParam);
}
示例13: onPassiveMotion
void onPassiveMotion(int x, int y){
mouse.onPassiveMotion(x,y);
}
示例14: WinMain
/***********************************************************************************
WinMain - Entry point for program.
***********************************************************************************/
int WINAPI WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
CLog *pLog = CLog::Instance();
pLog->Log(" ");
pLog->Log("***************************************");
pLog->Log("Program Start");
pLog->LogDate();
pLog->Log("***************************************");
//request player choose fullscreen or windowed mode
CConfigData cfg;
cfg.LoadConfigFile("assets//data//config.cfg");
bool bFullscreen = false;
bFullscreen = cfg.FullScreen;
int msgReturn = ::MessageBox(NULL, "Fullscreen? (Y/N)", "Select Display Option", MB_YESNO);
if(msgReturn == IDYES)
bFullscreen = true;
//variable declarations
CGameData gameData;
CTimer gTimerFPS;
int gLoopCount = 0;
int gSecondCount = 0;
bool g_bRunning = true;
bool gExitProgram = false; //this is set true with ESC, for rendering to stop properly
if(bFullscreen == true)
gameData.m_windowedYOffset = 0;
else
gameData.m_windowedYOffset = 21;
//determine if we play new or saved game
/*
gameData.m_playNewGame = true;
HRESULT hr = ::MessageBox(0, "Play new game?", "New or saved game!", MB_YESNO);
if(hr == IDYES)
gameData.m_playNewGame = true;
else
gameData.m_playNewGame = false;
*/
//gameData.m_playNewGame = true;
//setup game data
pLog->Log("Program Name", cfg.ProgramName);
pLog->Log("Version", cfg.ProgramVersion);
//create window
HWND hWnd;
WNDCLASSEX wc;
ZeroMemory(&wc, sizeof(WNDCLASSEX));
wc.cbSize = sizeof(WNDCLASSEX);
wc.style = CS_HREDRAW | CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)WindowProc;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszClassName = "WindowClass";
wc.hIconSm = LoadIcon (hInstance, MAKEINTRESOURCE(IDI_ICON1));
RegisterClassEx(&wc);
/*
//screen data - need at least 800x600
int cxScreen = ::GetSystemMetrics(SM_CXFULLSCREEN);
int cyScreen = ::GetSystemMetrics(SM_CYFULLSCREEN);
if(cfg.ScreenWidth < 800 || cfg.ScreenWidth > cxScreen)
cfg.ScreenWidth = cxScreen;
if(cfg.ScreenHeight < 600 || cfg.ScreenHeight > cyScreen)
cfg.ScreenHeight = cyScreen;
cfg.ScreenLeft = cxScreen/2 - cfg.ScreenWidth/2;
cfg.ScreenTop = cyScreen/2 - cfg.ScreenHeight/2;
*/
if(!bFullscreen)
{
if(cfg.ScreenWidth < 800)
{
cfg.ScreenWidth = 800;
}
if(cfg.ScreenHeight < 600)
{
cfg.ScreenHeight = 600;
}
}
cfg.ScreenLeft = 0;
cfg.ScreenTop = 0;
/*
// set up and initialize Direct3D
CGraphics con();// cfg.FullScreen);
int screenWidth = 0;
int screenHeight = 0;
if(con.InitializeDirectX(screenWidth, screenHeight, bFullscreen) == false){
pLog->Log("Failure initializing DirectX!");
::MessageBox(0,"Failed to initialize DirectX", "Error", 0);
//.........这里部分代码省略.........
示例15: reshape
void reshape(int width, int height){
openglContext.reshapeWindow(width,height);
mouse.centerMouse();
}