//-----------------------------------------------------------------------------------
    void ItemSelectorViewManager::addItemSelector(const Ogre::String& displayText)
    {
        // add a new item selector
        // determine new index for item
        assert(mScrollablePane);
        const size_t idx = mItemSelectorContainer.size();
        mItemSelectorContainer.push_back(ItemSelector());
        ItemSelector& item = mItemSelectorContainer.back();
        // create new checkbox
        CEGUI::Checkbox* checkbox = item.CheckBoxWidget = (CEGUI::Checkbox*)CEGUI::WindowManager::getSingleton().createWindow("TaharezLook/Checkbox",
                                    ( ("ItemCheckbox" + Ogre::StringConverter::toString(idx)).c_str() ));
        // set checkbox ID to selector ID
        checkbox->setID(idx);
        checkbox->setSize(CEGUI::UVector2(CEGUI::UDim(0, 140), CEGUI::UDim(0, ITEM_YSIZE)));
        checkbox->setText(displayText.c_str());
        checkbox->setProperty("HoverTextColour", CEGUI::PropertyHelper::colourToString(CEGUI::colour(1.0, 1.0, 0.0)));
        // add event handler for when checkbox state changes
        checkbox->subscribeEvent(CEGUI::Checkbox::EventCheckStateChanged, CEGUI::Event::Subscriber(&ItemSelectorViewManager::handleCheckStateChanged, this ));
        checkbox->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 12 + (ITEM_YSIZE + ITEM_YSPACING)* static_cast<float>(idx))));
        // add checkbox to the scroll pane
        mScrollablePane->addChildWindow(checkbox);
    }
Example #2
0
void CFormEditor::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if(!m_pDialog)
		return;
	if(!IsCTRLpressed())
		m_pDialog->SendMessage(WM_ENDSELECT);

	CRect Rect;
	bool bSelect=1;
	if (m_FormSelector)
	{
		if(m_pDialog->bReadOnly == 0)
		if(abs(m_FormSelector->m_rect.bottom-point.y)<5||abs(m_FormSelector->m_rect.right-point.x)<5)
		{
			bSelect=!m_FormSelector->Track(this, point, TRUE);
			if(!bSelect)
			{
				m_pDialog->MoveWindow(m_FormSelector->m_rect,1);
/*
				SIZE size;
				size.cx=m_FormSelector->m_rect.Width()-5;
				size.cy=m_FormSelector->m_rect.Height()-5;
				SetScrollSizes( MM_TEXT, size,size,size);
				GetParentFrame()->RecalcLayout();
*/
				Invalidate();
				SetModifiedFlag(1);
			}
		}
	}

	m_pDialog->GetWindowRect(&Rect) ;
	m_pDialog->ScreenToClient(&Rect) ;
	if(m_FormSelector)
		delete m_FormSelector;
	m_FormSelector = new CMultiRectTracker(Rect,CRectTracker::dottedLine | CRectTracker::resizeInside  | CRectTracker::resizeOutside | CRectTracker::hatchedBorder );
	m_FormSelector->bNotMove=1;


	ShowProperty(0);
	InvalidateSelector();


	if(bSelect)
	{
		Rect.left=Rect.right=point.x;
		Rect.top=Rect.bottom=point.y;
		CMultiRectTracker ItemSelector(Rect,CRectTracker::solidLine  | CRectTracker::resizeOutside);
		BOOL bRes=ItemSelector.Track(this, point, TRUE);
		if(bRes)
		{
			for(int i=0;i<m_pDialog->aWindowsList.GetSize();i++)
			{
				CRect newrect=ItemSelector.m_rect;
				newrect.NormalizeRect();

				CRect Rect;
				::GetWindowRect(m_pDialog->aWindowsList[i],&Rect);
				ScreenToClient(&Rect);
				CPoint point1;
				point1.x=Rect.left;
				point1.y=Rect.top;
				CPoint point2;
				point2.x=Rect.right;
				point2.y=Rect.bottom;
				if(newrect.PtInRect(point1)&&newrect.PtInRect(point2))
				{
					m_pDialog->SelectItem(CWnd::FromHandle(m_pDialog->aWindowsList[i]),1);
				}
			}
		}
	}



	CBaseClass::OnLButtonDown(nFlags, point);
}