Exemple #1
0
BOOL CDUIListBox::SetCurHoverExpand(INT nIndex)
{
	if(nIndex != m_nHoverIndex)
	{
		if(m_nHoverIndex != -1)
		{
			if(m_nHoverIndex >=0 && m_nHoverIndex < GetControlCount())
			{
				IDUIListItem* pListItem = (IDUIListItem*)m_arChildControl[m_nHoverIndex]->GetInterface(IListItem);
				if(pListItem != NULL && m_bHoverExpand)
				{
					pListItem->SetExpand(FALSE);
				}
			}
			m_nHoverIndex = -1;
		}

		if(nIndex != -1)
		{
			if(nIndex >=0 && nIndex < GetControlCount())
			{
				IDUIListItem* pListItem = (IDUIListItem*)m_arChildControl[nIndex]->GetInterface(IListItem);
				if(pListItem != NULL && m_bHoverExpand)
				{
					m_nHoverIndex = nIndex;
					pListItem->SetExpand(TRUE);
				}
			}
		}
		
		UpdateLayout(GetHoverExpand());
	}

	return TRUE;
}
Exemple #2
0
BOOL		CDUITreeNode::SetExpand(BOOL bExpand)
{
	//DUI_ASSERT(HaveChild());

	BOOL bOld = IsExpand();
	if ( bOld != bExpand )
	{
		m_bExpand = bExpand;

		INT nCount = GetControlCount();
		for ( int i=0;i<nCount;i++)
		{
			HDUITREEITEM pItem = GetChild(i);
			if ( pItem )
			{
				if ( bExpand )
					pItem->ModifyStyle(0, CONTROL_STYLE_VISIBLE);
				else
					pItem->ModifyStyle(CONTROL_STYLE_VISIBLE,0);
			}
		}
	}

	return bOld;
}
Exemple #3
0
VOID CDUIListBox::CheckInitGroupStatus()
{
	INT nCount = GetControlCount();
	BOOL bGroup = FALSE;
	BOOL bExpand = TRUE;

	LockLayout(TRUE);
	for(INT i=0; i<nCount; ++i)
	{
		IDUIListItem* pListItem = (IDUIListItem*)m_arChildControl[i]->GetInterface(IListItem);
		if(pListItem == NULL) continue;
		
		if(pListItem->GetGroup())
		{
			bGroup = TRUE;
			bExpand = pListItem->GetExpand();
			continue;
		}
		
		if(!bGroup) continue;

		if(bExpand)
		{
			pListItem->ModifyStyle(0, CONTROL_STYLE_VISIBLE);
		}
		else
		{
			pListItem->ModifyStyle(CONTROL_STYLE_VISIBLE, 0);
		}	
	}
	LockLayout(FALSE);
}
Exemple #4
0
VOID CDUIFramePanel::SetControlRect(const RECT& rt)
{
	m_rtControl = rt;

	if(GetDrawMode() != FRAME_PANEL_SINGLE_COLOR)
	{
		CalculateImageFrame();
	}

	RECT rtAvailable = GetContentRect();
	rtAvailable.left += m_rtFrame.left;
	rtAvailable.right -= m_rtFrame.right;
	rtAvailable.top += m_rtFrame.top;
	rtAvailable.bottom -= m_rtFrame.bottom;

	if(IsRectEmpty(&rtAvailable))
	{
		rtAvailable.right = rtAvailable.left;
		rtAvailable.bottom = rtAvailable.top;
	}

	//DUI_ASSERT(GetControlCount() == 1);
	if(GetControlCount() >= 1)
	{
		GetControlByIndex(0)->SetControlRect(rtAvailable);
	}
}
Exemple #5
0
BOOL CDUIListBox::SetCurSel(INT nIndex)
{
	if(nIndex != m_nSelectIndex)
	{
		if(m_nSelectIndex != -1)
		{
			if(m_nSelectIndex >=0 && m_nSelectIndex < GetControlCount())
			{
				IDUIListItem* pListItem = (IDUIListItem*)m_arChildControl[m_nSelectIndex]->GetInterface(IListItem);
				if(pListItem != NULL && !pListItem->GetGroup())
				{
					pListItem->SetSelect(FALSE);

					if(m_bSelectExpand)
					{
						pListItem->SetExpand(FALSE);
					}
				}
			}
			m_nSelectIndex = -1;
		}

		if(nIndex != -1)
		{
			if(nIndex >=0 && nIndex < GetControlCount())
			{	
				m_nSelectIndex = nIndex;
				IDUIListItem* pListItem = (IDUIListItem*)m_arChildControl[nIndex]->GetInterface(IListItem);
				if(pListItem != NULL && !pListItem->GetGroup())
				{
					pListItem->SetSelect(TRUE);

					if(m_bSelectExpand)
					{
						pListItem->SetExpand(TRUE);
					}
					SendNotify(WM_NOTIFY_LISTBOX_NOTIFY, LBN_WPARAM_SELCHANGE, (LPARAM)GetControlByIndex(nIndex));
				}
			}
		}
		
		UpdateLayout(TRUE);
	}
	return TRUE;
}
Exemple #6
0
int GetControlSelectionCount ( int iControlID )
{
	// confirm control exists
	if ( !ConfirmControlIndex ( iControlID ) )
		return 0;

	// return control data
	return GetControlCount ( iControlID );
}
Exemple #7
0
INT CDUIListBox::GetVisibleItemIndex(IDUIControl* pItem)
{
	INT nCount = GetControlCount();
	for(INT i=m_nTopIndex; (i<nCount && i<=m_nLastIndex); ++i)
	{
		if(m_arChildControl[i].GetPtr() == pItem)
		{
			return i;
		}
	}

	return -1;
}
Exemple #8
0
INT CDUIListBox::GetScrollLineStep()
{
	if(GetControlCount() > 0)
	{
		IDUIListItem* pItem = (IDUIListItem*)GetControlByIndex(0)->GetInterface(IListItem);
		if(pItem != NULL)
		{
			return pItem->GetHeight(FALSE);
		}
	}

	return theBase::GetScrollLineStep();
}
Exemple #9
0
VOID CDUIListBox::ExpandGroup(INT nIndex, BOOL bExpand)
{
	IDUIControl* pItem = GetControlByIndex(nIndex);
	if(pItem != NULL 
		&& (pItem->IsVisible()))
	{
		IDUIListItem* pListItem = (IDUIListItem*)pItem->GetInterface(IListItem);
		if(pListItem != NULL && pListItem->GetGroup()
			&& (pListItem->GetExpand() != bExpand))
		{
			LockLayout(TRUE);

			INT nCount = GetControlCount();
			for(INT i=nIndex+1; i<nCount; ++i)
			{
				IDUIListItem* pItem = (IDUIListItem*)m_arChildControl[i]->GetInterface(IListItem);
				if(pItem == NULL) continue;
				if(pItem->GetGroup()) break;

				if(bExpand)
				{
					pItem->ModifyStyle(0, CONTROL_STYLE_VISIBLE);
				}
				else
				{
					pItem->ModifyStyle(CONTROL_STYLE_VISIBLE, 0);
				}
			}

			pListItem->SetExpand(bExpand);

			LockLayout(FALSE);
			UpdateLayout(TRUE);
		}
	}
}
void __fastcall DesignerHook::KeyDown(TControl* Sender,Word &Key,Classes::TShiftState Shift)
{

    if(0== ControlCount ||(!Shift.Contains(ssShift) && !Shift.Contains(ssCtrl)) ||(VK_CONTROL==Key || VK_SHIFT == Key) ) {
        return;
    }
    if(GetControlCount() == 1 && Controls[0] == Form_){
        return;
    }
    if(Shift.Contains(ssCtrl)){
        switch(Key){
        case VK_UP:
            ShowGrabHandle(false);
            __try{
                /*
                if(LeftNew >0 && (Controls[index]->Width + LeftNew)< Controls[index]->Parent->Width  && KeepChildInArea_){
                    Controls[i]->Left = LeftNew;
                }
                if(TopNew > 0 && (Controls[i]->Height +TopNew )< Controls[index]->Parent->Height && KeepChildInArea_){
                    Controls[i]->Top =  TopNew;
                }
                */
                for(int index=0;index<=GetControlCount() -1 ;++index){
                    int TopNew= Controls[index]->Top - kMoveUpStepByKey;
                    if(TopNew>0 &&  (Controls[index]->Height + TopNew)< Controls[index]->Parent->Height  && KeepChildInArea_)
                        Controls[index]->Top= TopNew;
                }
            }__finally{
                ShowGrabHandle(true);
            }
            break;
        case VK_DOWN:
            ShowGrabHandle(false);
            __try{
                for(int index=0;index<=GetControlCount() -1 ;++index){
                    int TopNew= Controls[index]->Top + kMoveDownStepByKey;
                    if(TopNew>0 &&  (Controls[index]->Height + TopNew)< Controls[index]->Parent->Height  && KeepChildInArea_)
                        Controls[index]->Top= TopNew;
                }
            }__finally{
                ShowGrabHandle(true);
            }
            break;
        case VK_LEFT:
            ShowGrabHandle(false);
            __try{
                for(int index=0;index<=GetControlCount() -1 ;++index){
                    int LeftNew= Controls[index]->Left - kMoveLeftStepByKey ;
                    if(LeftNew>0 && (Controls[index]->Width + LeftNew)< Controls[index]->Parent->Width && KeepChildInArea_ )
                        Controls[index]->Left= LeftNew;
                }
            }__finally{
                ShowGrabHandle(true);
            }
            break;
        case VK_RIGHT:
            ShowGrabHandle(false);
            __try{
                for(int index=0;index<=GetControlCount() -1 ;++index){
                    int LeftNew= Controls[index]->Left + kMoveRightStepByKey ;
                    if(LeftNew>0 && (Controls[index]->Width + LeftNew)< Controls[index]->Parent->Width && KeepChildInArea_ )
                        Controls[index]->Left= LeftNew;
                }
            }__finally{
                ShowGrabHandle(true);
            }
            break;
        }
    }else{
        switch(Key){
Exemple #11
0
BOOL CDUIListBox::OnKeyDown(const DUIEvent& info)
{
	BOOL bRet(FALSE);
	switch(info.wParam)
	{
// 	case VK_SPACE:
// 	case VK_RETURN:
// 		if(m_nSelectIndex >=0 && m_nSelectIndex < GetControlCount())
// 		{
// 			IDUIListItem* pItem = (IDUIListItem*)GetControlByIndex(m_nSelectIndex)->GetInterface(IListItem);
// 			if(pItem != NULL 
// 				&& pItem->IsVisible()
// 				&& pItem->IsEnabled()
// 				&& pItem->GetGroup())
// 			{
// 				ExpandGroup(m_nSelectIndex, !pItem->GetExpand());
// 			}
// 		}
// 		break;

	case VK_LEFT:
	case VK_UP:
		{
			INT nIndex = m_nSelectIndex;
			while(TRUE)
			{
				--nIndex;
				if(nIndex>=0 && nIndex<GetControlCount())
				{
					if((GetControlByIndex(nIndex)->IsVisible()))
					{
						SetCurSel(nIndex);
						if(nIndex < m_nTopIndex
							|| nIndex >= m_nLastIndex)
						{
							SetTopIndex(nIndex);
						}
						break;
					}
				}
				else
				{
					break;
				}
			}
		}

		bRet = TRUE;
		break;

	case VK_RIGHT:
	case VK_DOWN:
		{
			INT nIndex = m_nSelectIndex;
			while(TRUE)
			{
				++nIndex;
				if(nIndex>=0 && nIndex<GetControlCount())
				{
					if(GetControlByIndex(nIndex)->IsVisible())
					{
						SetCurSel(nIndex);
						if(nIndex >= m_nLastIndex
							|| nIndex < m_nTopIndex)
						{
							INT nTopIndex = m_nTopIndex;
							//SetTopIndex(++nTopIndex);
							SetTopIndex(nIndex);
						}
						break;
					}
				}
				else
				{
					break;
				}
			}

		}
		
		bRet = TRUE;
		break;
	}

	return bRet;
}