NS_IMETHODIMP nsXFormsSwitchElement::SetSelected(nsIDOMElement *aCase, PRBool aValue) { if (!mElement) return NS_OK; // There is no need to change the selected case, If we are trying to select // a case which is already selected or if deselecting a case, // which is not selected. if (mSelected && (((mSelected == aCase) && aValue) || ((mSelected != aCase) && !aValue))) return NS_OK; // Swapping the status of the mSelected and aCase, dispatching events. if (aValue && mSelected) { nsCOMPtr<nsIDOMElement> oldSel = mSelected; mSelected = aCase; nsCOMPtr<nsIXFormsCaseElement> deselected(do_QueryInterface(oldSel)); if (deselected) deselected->SetSelected(PR_FALSE); nsCOMPtr<nsIXFormsCaseElement> selected(do_QueryInterface(mSelected)); if (selected) selected->SetSelected(PR_TRUE); SetFocus(oldSel, mSelected); nsXFormsUtils::DispatchEvent(oldSel, eEvent_Deselect); nsXFormsUtils::DispatchEvent(mSelected, eEvent_Select); return NS_OK; } nsCOMPtr<nsIDOMElement> firstCase = FindFirstSelectedCase(aValue ? nsnull : aCase); // If a selectable case was found, bring it to front, set focus // and dispatch events. if (firstCase) { mSelected = firstCase; nsCOMPtr<nsIXFormsCaseElement> deselected(do_QueryInterface(aCase)); if (deselected) deselected->SetSelected(PR_FALSE); nsCOMPtr<nsIXFormsCaseElement> selected(do_QueryInterface(mSelected)); if (selected) selected->SetSelected(PR_TRUE); SetFocus(aCase, mSelected); nsXFormsUtils::DispatchEvent(aCase, eEvent_Deselect); nsXFormsUtils::DispatchEvent(mSelected, eEvent_Select); } // If there is only one case, we (re)select it. No need to // set focus. else { mSelected = aCase; nsCOMPtr<nsIXFormsCaseElement> selected(do_QueryInterface(mSelected)); if (selected) selected->SetSelected(PR_TRUE); nsXFormsUtils::DispatchEvent(mSelected, eEvent_Deselect); nsXFormsUtils::DispatchEvent(mSelected, eEvent_Select); } return NS_OK; }
void SELECTION_TOOL::deselect( BOARD_ITEM* aItem ) { // Modules are treated in a special way - when they are selected, we have to // deselect all the parts that make the module, not the module itself if( aItem->Type() == PCB_MODULE_T ) { MODULE* module = static_cast<MODULE*>( aItem ); module->RunOnChildren( boost::bind( &SELECTION_TOOL::deselectVisually, this, _1 ) ); } deselectVisually( aItem ); int itemIdx = m_selection.items.FindItem( aItem ); if( itemIdx >= 0 ) m_selection.items.RemovePicker( itemIdx ); if( m_selection.Empty() ) { m_frame->SetCurItem( NULL ); m_locked = true; } // Inform other potentially interested tools TOOL_EVENT deselected( DeselectedEvent ); m_toolMgr->ProcessEvent( deselected ); }
void DiagramItem::deselect() { D_METHOD(("DiagramItem::deselect()\n")); if (m_selected) { m_selected = false; deselected(); view()->Invalidate(frame()); } }
void KisLightSource::deselect() { m_moving = true; m_isselected = false; setPixmap(createBackground()); QSize newsize(m_icondiameter, m_icondiameter); QPoint newtopleft(pos().x() + (m_selecthalothickness), pos().y() + (m_selecthalothickness)); setGeometry(QRect(newtopleft, newsize)); m_center = QPointF(qreal(size().width()) / 2, qreal(size().height()) / 2); deselected(); }