MCPcopy Create free account
hub / github.com/carbonengine/trinity / WndProc

Method WndProc

trinity/UI/Tr2MainWindow_Windows.cpp:385–666  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

383}
384
385LRESULT Tr2MainWindow::WndProc( HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam )
386{
387 std::pair<int32_t, bool> returnValue = { 0, false };
388
389 int32_t mouseX, mouseY;
390
391 auto mouseCoords = [&]() {
392 RECT rect;
393 ::GetClientRect( m_hwnd, &rect );
394 mouseX = int32_t( double( int32_t( lParam & 0xffff ) ) / ( rect.right - rect.left ) * m_state.width + 0.5 );
395 mouseY = int32_t( double( int32_t( lParam >> 16 ) ) / ( rect.bottom - rect.top ) * m_state.height + 0.5 );
396 };
397
398 switch( msg )
399 {
400 case WM_LBUTTONDOWN:
401 ::SetCapture( hwnd );
402 mouseCoords();
403 m_onMouseDown.CallVoid( int32_t( 0 ), mouseX, mouseY );
404 returnValue = std::make_pair( 0, m_onMouseDown.IsValid() );
405 break;
406 case WM_LBUTTONUP:
407 if( !::GetAsyncKeyState( VK_RBUTTON ) )
408 {
409 ::ReleaseCapture();
410 }
411 mouseCoords();
412 m_onMouseUp.CallVoid( int32_t( 0 ), mouseX, mouseY );
413 returnValue = std::make_pair( 0, m_onMouseUp.IsValid() );
414 break;
415 case WM_RBUTTONDOWN:
416 ::SetCapture( hwnd );
417 mouseCoords();
418 m_onMouseDown.CallVoid( int32_t( 1 ), mouseX, mouseY );
419 returnValue = std::make_pair( 0, m_onMouseDown.IsValid() );
420 break;
421 case WM_RBUTTONUP:
422 if( !::GetAsyncKeyState( VK_LBUTTON ) )
423 {
424 ::ReleaseCapture();
425 }
426 mouseCoords();
427 m_onMouseUp.CallVoid( int32_t( 1 ), mouseX, mouseY );
428 returnValue = std::make_pair( 0, m_onMouseUp.IsValid() );
429 break;
430 case WM_MBUTTONDOWN:
431 mouseCoords();
432 m_onMouseDown.CallVoid( int32_t( 2 ), mouseX, mouseY );
433 returnValue = std::make_pair( 0, m_onMouseDown.IsValid() );
434 break;
435 case WM_MBUTTONUP:
436 mouseCoords();
437 m_onMouseUp.CallVoid( int32_t( 2 ), mouseX, mouseY );
438 returnValue = std::make_pair( 0, m_onMouseUp.IsValid() );
439 break;
440 case WM_XBUTTONDOWN:
441 mouseCoords();
442 m_onMouseDown.CallVoid( int32_t( ( wParam & 0x10000 ) ? 3 : 4 ), mouseX, mouseY );

Callers 1

StaticWndProcMethod · 0.80

Calls 6

SetThrottlingMethod · 0.80
endFunction · 0.50
IsValidMethod · 0.45
ApplyMethod · 0.45
ApplicationActivatedMethod · 0.45
SetSourceMethod · 0.45

Tested by

no test coverage detected