예제 #1
0
파일: UICombo.cpp 프로젝트: kovrov/scrap
void CDropDownUI::Event(TEventUI& event)
{
	if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() )
	{
		Activate();
		m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED;
	}
	if( event.Type == UIEVENT_MOUSEMOVE )
	{
		if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
			if( ::PtInRect(&m_rcButton, event.ptMouse) ) m_uButtonState |= UISTATE_PUSHED;
			else m_uButtonState &= ~UISTATE_PUSHED;
			Invalidate();
		}
	}
	if( event.Type == UIEVENT_BUTTONUP )
	{
		if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
			m_uButtonState &= ~(UISTATE_PUSHED | UISTATE_CAPTURED);
			Invalidate();
		}
	}
	if( event.Type == UIEVENT_KEYDOWN )
	{
		switch( event.chKey ) {
		case VK_F4:
			Activate();
			return;
		case VK_UP:
			SelectItem(FindSelectable(m_iCurSel - 1, false));
			return;
		case VK_DOWN:
			SelectItem(FindSelectable(m_iCurSel + 1, true));
			return;
		case VK_PRIOR:
			SelectItem(FindSelectable(m_iCurSel - 10, false));
			return;
		case VK_NEXT:
			SelectItem(FindSelectable(m_iCurSel + 10, true));
			return;
		case VK_HOME:
			SelectItem(FindSelectable(0, false));
			return;
		case VK_END:
			SelectItem(FindSelectable(GetCount() - 1, true));
			return;
		}
	}
	if( event.Type == UIEVENT_SCROLLWHEEL )
	{
		bool bDownward = LOWORD(event.wParam) == SB_LINEDOWN;
		SelectItem(FindSelectable(m_iCurSel + (bDownward ? 1 : -1), bDownward));
		return;
	}
	CControlUI::Event(event);
}
예제 #2
0
파일: UIList.cpp 프로젝트: 0buffer/DirectUI
void CListUI::Event(TEventUI& event)
{
   switch( event.Type ) {
   case UIEVENT_KEYDOWN:
      switch( event.chKey ) {
      case VK_UP:
         SelectItem(FindSelectable(m_iCurSel - 1, false));
         EnsureVisible(m_iCurSel);
         return;
      case VK_DOWN:
         SelectItem(FindSelectable(m_iCurSel + 1, true));
         EnsureVisible(m_iCurSel);
         return;
      case VK_PRIOR:
         SelectItem(FindSelectable(m_iCurSel - 10, false));
         EnsureVisible(m_iCurSel);
         return;
      case VK_NEXT:
         SelectItem(FindSelectable(m_iCurSel + 10, true));
         EnsureVisible(m_iCurSel);
         return;
      case VK_HOME:
         SelectItem(FindSelectable(0, false));
         EnsureVisible(m_iCurSel);
         return;
      case VK_END:
         SelectItem(FindSelectable(GetCount() - 1, true));
         EnsureVisible(m_iCurSel);
         return;
      case VK_RETURN:
         if( m_iCurSel != -1 ) GetItem(m_iCurSel)->Activate();
         return;
      }
      break;
   case UIEVENT_SCROLLWHEEL:
      {
         switch( LOWORD(event.wParam) ) {
         case SB_LINEUP:
            SelectItem(FindSelectable(m_iCurSel - 1, false));
            EnsureVisible(m_iCurSel);
            return;
         case SB_LINEDOWN:
            SelectItem(FindSelectable(m_iCurSel + 1, true));
            EnsureVisible(m_iCurSel);
            return;
         }
      }
      break;
   }
   CControlUI::Event(event);
}
예제 #3
0
	bool CComboUI::RemoveAt(int iIndex)
	{
		if (!CContainerUI::RemoveAt(iIndex)) return false;

		for(int i = iIndex; i < GetCount(); ++i) {
			CControlUI* p = GetItemAt(i);
			IListItemUI* pListItem = static_cast<IListItemUI*>(p->GetInterface(_T("ListItem")));
			if( pListItem != NULL ) pListItem->SetIndex(i);
		}

		if( iIndex == m_iCurSel && m_iCurSel >= 0 ) {
			int iSel = m_iCurSel;
			m_iCurSel = -1;
			SelectItem(FindSelectable(iSel, false));
		}
		else if( iIndex < m_iCurSel ) m_iCurSel -= 1;
		return true;
	}
예제 #4
0
int CContainerUI::FindSelectable(int iIndex, bool bForward /*= true*/) const
{
   // NOTE: This is actually a helper-function for the list/combo/ect controls
   //       that allow them to find the next enabled/available selectable item
   if( GetCount() == 0 ) return -1;
   iIndex = CLAMP(iIndex, 0, GetCount() - 1);
   if( bForward ) {
      for( int i = iIndex; i < GetCount(); i++ ) {
         if( GetItem(i)->GetInterface(_T("ListItem")) != NULL 
             && GetItem(i)->IsVisible()
             && GetItem(i)->IsEnabled() ) return i;
      }
      return -1;
   }
   else {
      for( int i = iIndex; i >= 0; --i ) {
         if( GetItem(i)->GetInterface(_T("ListItem")) != NULL 
             && GetItem(i)->IsVisible()
             && GetItem(i)->IsEnabled() ) return i;
      }
      return FindSelectable(0, true);
   }
}
예제 #5
0
void CUIComboBox::Event(TEventUI& event)
{
	if( !CUIControl::Activate() ) return;

	if( event.Type == UIEVENT_SETCURSOR )
	{
		if( ::PtInRect(&m_rcItem, event.ptMouse) && IsEnabled() ) {
			::SetCursor(::LoadCursor(NULL, MAKEINTRESOURCE(IDC_HAND)));
			return;
		}
	}

   if( event.Type == UIEVENT_BUTTONDOWN && IsEnabled() )
   {
      m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED;
	  Invalidate();

	  if( m_pManager != NULL ) m_pManager->SendNotify(this, UI_NOTIFY_CLICK);

	  Activate();
   }
   if( event.Type == UIEVENT_MOUSEMOVE )
   {
      if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
         if( ::PtInRect(&m_rcButton, event.ptMouse) ) m_uButtonState |= UISTATE_PUSHED;
         else m_uButtonState &= ~UISTATE_PUSHED;
         Invalidate();
      }

	  if (m_pWindow != NULL)
	  {
		  m_uButtonState |= UISTATE_PUSHED;
		  Invalidate();	 
	  }
   }
   if( event.Type == UIEVENT_BUTTONUP )
   {
      if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
         m_uButtonState &= ~(UISTATE_PUSHED | UISTATE_CAPTURED);
         Invalidate();
      }
   }
   if( event.Type == UIEVENT_KEYDOWN )
   {
      switch( event.chKey ) {
      case VK_F4:
         Activate();
         return;
      case VK_UP:
         SetCurSel(FindSelectable(m_iCurSel - 1, false));
         return;
      case VK_DOWN:
         SetCurSel(FindSelectable(m_iCurSel + 1, true));
         return;
      }
   }
   if( event.Type == UIEVENT_SCROLLWHEEL )
   {
      bool bDownward = LOWORD(event.wParam) == SB_LINEDOWN;
      //SetCurSel(FindSelectable(m_iCurSel + (bDownward ? 1 : -1), bDownward));
      return;
   }

   if( event.Type == UIEVENT_MOUSEENTER)
   {
	   m_uButtonState |= UISTATE_HOT;
	   Invalidate();
   }
   if( event.Type == UIEVENT_MOUSELEAVE)
   {
	   m_uButtonState &= ~UISTATE_HOT;
	   Invalidate();
   }
   CUIControl::Event(event);
}
예제 #6
0
	void CComboUI::DoEvent(TEventUI& event)
	{
		if( !IsMouseEnabled() && event.Type > UIEVENT__MOUSEBEGIN && event.Type < UIEVENT__MOUSEEND ) {
			if( m_pParent != NULL ) m_pParent->DoEvent(event);
			else CContainerUI::DoEvent(event);
			return;
		}

		if( event.Type == UIEVENT_SETFOCUS ) 
		{
			Invalidate();
		}
		if( event.Type == UIEVENT_KILLFOCUS ) 
		{
			Invalidate();
		}
		if( event.Type == UIEVENT_BUTTONDOWN )
		{
			if( IsEnabled() ) {
				Activate();
				m_uButtonState |= UISTATE_PUSHED | UISTATE_CAPTURED;
			}
			return;
		}
		if( event.Type == UIEVENT_BUTTONUP )
		{
			if( (m_uButtonState & UISTATE_CAPTURED) != 0 ) {
				m_uButtonState &= ~ UISTATE_CAPTURED;
				Invalidate();
			}
			return;
		}
		if( event.Type == UIEVENT_MOUSEMOVE )
		{
			return;
		}
		if( event.Type == UIEVENT_KEYDOWN )
		{
			switch( event.chKey ) {
			case VK_F4:
				Activate();
				return;
			case VK_UP:
				SelectItem(FindSelectable(m_iCurSel - 1, false));
				return;
			case VK_DOWN:
				SelectItem(FindSelectable(m_iCurSel + 1, true));
				return;
			case VK_PRIOR:
				SelectItem(FindSelectable(m_iCurSel - 1, false));
				return;
			case VK_NEXT:
				SelectItem(FindSelectable(m_iCurSel + 1, true));
				return;
			case VK_HOME:
				SelectItem(FindSelectable(0, false));
				return;
			case VK_END:
				SelectItem(FindSelectable(GetCount() - 1, true));
				return;
			}
		}
		if( event.Type == UIEVENT_SCROLLWHEEL )
		{
			bool bDownward = LOWORD(event.wParam) == SB_LINEDOWN;
			SelectItem(FindSelectable(m_iCurSel + (bDownward ? 1 : -1), bDownward));
			return;
		}
		if( event.Type == UIEVENT_CONTEXTMENU )
		{
			return;
		}
		if( event.Type == UIEVENT_MOUSEENTER )
		{
			if( ::PtInRect(&m_rcItem, event.ptMouse ) ) {
				if( (m_uButtonState & UISTATE_HOT) == 0  )
					m_uButtonState |= UISTATE_HOT;
				Invalidate();
			}
			return;
		}
		if( event.Type == UIEVENT_MOUSELEAVE )
		{
			if( (m_uButtonState & UISTATE_HOT) != 0 ) {
				m_uButtonState &= ~UISTATE_HOT;
				Invalidate();
			}
			return;
		}
		CControlUI::DoEvent(event);
	}