//-------------------------------------------------------------------------------------- bool CButton::HandleKeyboard ( UINT uMsg, WPARAM wParam, LPARAM lParam ) { if ( !CanHaveFocus () ) return false; switch ( uMsg ) { case WM_KEYDOWN: { switch ( wParam ) { case VK_SPACE: m_bPressed = true; return true; } } case WM_KEYUP: { switch ( wParam ) { case VK_SPACE: if ( m_bPressed ) { m_bPressed = false; SendEvent ( EVENT_CONTROL_CLICKED, true ); } return true; } } } return false; }
//-------------------------------------------------------------------------------------- bool CProgressBarVertical::OnMouseButtonDown ( sMouseEvents e ) { if ( !CanHaveFocus () ) return false; if ( e.eButton == sMouseEvents::LeftButton ) { if ( m_rBoundingBox.ContainsPoint ( e.pos ) ) { // Pressed while inside the control m_bPressed = true; _SetFocus (); m_timer.Start ( PROGRESSBAR_ARROWCLICK_START ); if ( e.pos.m_nY > m_rProgress.m_pos.m_nY + m_rProgress.m_size.cy ) { SetValue ( m_fValue + m_fStep ); return true; } else if ( e.pos.m_nY < m_rProgress.m_pos.m_nY + m_rProgress.m_size.cy ) { SetValue ( m_fValue - m_fStep ); return true; } return true; } } return false; }
//-------------------------------------------------------------------------------------- bool CProgressBarVertical::ContainsPoint ( CVector pos ) { if ( !CanHaveFocus () ) return false; return ( m_rBoundingBox.ContainsPoint ( pos ) || m_rProgress.ContainsPoint ( pos ) ); }
bool CGUITextBox::RequestFocus() { if(m_pParent){ if(CanHaveFocus()){ return ((CGUIWindow*)m_pParent)->SetFocusElement(this); } } return false; }
bool CGUIHorizontalScrollBar::RequestFocus() { if(m_pParent){ if(CanHaveFocus()){ return ((CGUIWindow*)m_pParent)->SetFocusElement(this); } } return false; }
//-------------------------------------------------------------------------------------- bool CProgressBarHorizontal::ContainsRect ( CPos pos ) { if ( !CanHaveFocus () ) return false; return ( m_rBoundingBox.InControlArea ( pos ) || m_rProgress.InControlArea ( pos ) ); }
//-------------------------------------------------------------------------------------- bool CTrackBarVertical::ContainsRect ( CPos pos ) { if ( !CanHaveFocus () ) return false; return ( m_rBoundingBox.InControlArea ( pos ) || m_rThumb.InControlArea ( pos ) ); }
//-------------------------------------------------------------------------------------- bool CScrollBarVertical::ContainsPoint ( Pos pos ) { if ( !CanHaveFocus () ) return false; return ( m_rBoundingBox.ContainsPoint ( pos ) || m_rUpButton.ContainsPoint ( pos ) || m_rDownButton.ContainsPoint ( pos ) || m_rThumb.ContainsPoint ( pos ) ); }
bool CPictureBox::OnKeyDown ( WPARAM wParam ) { if ( !CanHaveFocus () ) return false; if ( wParam == VK_SPACE ) { m_bPressed = true; return true; } return false; }
//-------------------------------------------------------------------------------------- bool CButton::HandleMouse ( UINT uMsg, CPos pos, WPARAM wParam, LPARAM lParam ) { if ( !CanHaveFocus () ) return false; switch ( uMsg ) { case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: { if ( m_rBoundingBox.InControlArea ( pos ) ) { // Pressed while inside the control m_bPressed = true; if ( m_pParent && !m_bHasFocus ) m_pParent->RequestControlFocus ( this ); return true; } break; } case WM_LBUTTONUP: { if ( m_bPressed ) { m_bPressed = false; if ( m_pParent ) m_pParent->ClearControlFocus (); // Button click if ( m_rBoundingBox.InControlArea ( pos ) ) SendEvent ( EVENT_CONTROL_CLICKED, true ); return true; } break; } }; return false; }
bool CPictureBox::OnMouseButtonDown ( sMouseEvents e ) { if ( !CanHaveFocus () ) return false; if ( e.eButton == sMouseEvents::LeftButton ) { if ( m_rBoundingBox.ContainsPoint ( e.pos ) ) { // Pressed while inside the control m_bPressed = true; _SetFocus (); return true; } } return false; }
//-------------------------------------------------------------------------------------- bool CTrackBarVertical::HandleKeyboard ( UINT uMsg, WPARAM wParam, LPARAM lParam ) { if ( !CanHaveFocus () ) return false; switch ( uMsg ) { case WM_KEYDOWN: { switch ( wParam ) { case VK_HOME: SetValue ( m_nMin ); return true; case VK_END: SetValue ( m_nMax ); return true; case VK_LEFT: case VK_DOWN: SetValue ( m_nValue - 1 ); return true; case VK_RIGHT: case VK_UP: SetValue ( m_nValue + 1 ); return true; case VK_NEXT: SetValue ( m_nValue - ( 10 > ( m_nMax - m_nMin ) / 10 ? 10 : ( m_nMax - m_nMin ) / 10 ) ); return true; case VK_PRIOR: SetValue ( m_nValue + ( 10 > ( m_nMax - m_nMin ) / 10 ? 10 : ( m_nMax - m_nMin ) / 10 ) ); return true; } break; } } }
bool CScrollBarVertical::OnMouseButtonDown ( sMouseEvents e ) { if ( !CanHaveFocus () ) return false; if ( e.eButton == sMouseEvents::LeftButton ) { // Check for click on up button if ( m_rUpButton.ContainsPoint ( e.pos ) ) { if ( m_nPosition > m_nStart ) m_nPosition -= m_nStep; UpdateThumbRect (); m_timer.Start ( SCROLLBAR_ARROWCLICK_REPEAT ); m_bPressed = true; m_Arrow = CLICKED_UP; _SetFocus (); return true; } // Check for click on down button if ( m_rDownButton.ContainsPoint ( e.pos ) ) { if ( m_nPosition + m_nPageSize <= m_nEnd ) m_nPosition += m_nStep; UpdateThumbRect (); m_timer.Start ( SCROLLBAR_ARROWCLICK_REPEAT ); m_bPressed = true; m_Arrow = CLICKED_DOWN; _SetFocus (); return true; } // Check for click on thumb if ( m_rThumb.ContainsPoint ( e.pos ) ) { nThumbOffset = e.pos.m_nY - m_rThumb.m_pos.m_nY; m_Arrow = CLICKED_THUMB; m_bDrag = true; m_bPressed = true; _SetFocus (); return true; } // Check for click on track if ( m_rBoundingBox.ContainsPoint ( e.pos ) ) { if ( m_rThumb.m_pos.m_nY > e.pos.m_nY && m_rBoundingBox.m_pos.m_nY <= e.pos.m_nY) { Scroll ( -( m_nPageSize - 1 ) ); _SetFocus (); m_timer.Start ( 0.5 ); m_bPressed = true; m_Arrow = HELD_UP; return true; } else if ( m_rThumb.m_pos.m_nY + m_rThumb.m_size.cy <= e.pos.m_nY && ( m_rBoundingBox.m_pos.m_nY + m_rBoundingBox.m_size.cx ) + m_rBoundingBox.m_size.cy > e.pos.m_nY) { Scroll ( m_nPageSize - 1 ); _SetFocus (); m_timer.Start ( 0.5 ); m_bPressed = true; m_Arrow = HELD_DOWN; return true; } } } return false; }
//-------------------------------------------------------------------------------------- bool CProgressBarHorizontal::HandleMouse ( UINT uMsg, CPos pos, WPARAM wParam, LPARAM lParam ) { if ( !CanHaveFocus () ) return false; switch ( uMsg ) { case WM_MOUSEMOVE: { if ( m_bPressed ) { SetValue ( ValueFromPos ( pos.GetX () - m_rProgress.pos.GetX () ) ); return true; } break; } case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: { if ( m_rBoundingBox.InControlArea ( pos ) ) { // Pressed while inside the control m_bPressed = true; if ( m_pParent ) m_pParent->RequestControlFocus ( this ); m_timer.Start ( PROGRESSBAR_ARROWCLICK_START ); if ( pos.GetX () > m_rProgress.pos.GetX () + m_rProgress.size.cx ) { SetValue ( m_fValue + m_fStep ); return true; } if ( pos.GetX () < m_rProgress.pos.GetX () + m_rProgress.size.cx ) { SetValue ( m_fValue - m_fStep ); return true; } return true; } break; } case WM_LBUTTONUP: { if ( m_bPressed ) { m_bPressed = false; if ( m_pParent ) m_pParent->ClearControlFocus (); return true; } break; } } return false; }
//-------------------------------------------------------------------------------------- bool CTrackBarVertical::HandleMouse ( UINT uMsg, CPos pos, WPARAM wParam, LPARAM lParam ) { if ( !CanHaveFocus () ) return false; switch ( uMsg ) { case WM_LBUTTONDOWN: case WM_LBUTTONDBLCLK: { if ( m_rThumb.InControlArea ( pos ) ) { // Pressed while inside the control m_bPressed = true; m_nDragOffset = pos.GetY () - m_rThumb.pos.GetY (); if ( m_pParent && !m_bHasFocus ) m_pParent->RequestControlFocus ( this ); return true; } if ( m_rBoundingBox.InControlArea ( pos ) ) { m_nDragOffset = 0; // Pressed while inside the control m_bPressed = true; if ( m_pParent && !m_bHasFocus ) m_pParent->RequestControlFocus ( this ); if ( pos.GetY () > m_rThumb.pos.GetY () ) { SetValue ( m_nValue + 1 ); return true; } if ( pos.GetY () < m_rThumb.pos.GetY () ) { SetValue ( m_nValue - 1 ); return true; } } break; } case WM_LBUTTONUP: { if ( m_bPressed ) { m_bPressed = false; SendEvent ( EVENT_CONTROL_SELECT, m_nValue ); if ( m_pParent ) m_pParent->ClearControlFocus (); return true; } break; } case WM_MOUSEMOVE: { if ( m_bPressed ) { SetValue ( ValueFromPos ( pos.GetY () - m_rBoundingBox.pos.GetY () - m_nDragOffset ) ); return true; } break; } case WM_MOUSEWHEEL: { int nScrollAmount = int ( ( short ) HIWORD ( wParam ) ) / WHEEL_DELTA; SetValue ( m_nValue - nScrollAmount ); return true; } }; return false; }