コード例 #1
0
ファイル: wg_msgrouter.cpp プロジェクト: tempbottle/WonderGUI
	bool MsgRouter::setKeyboardFocus( const Widget_p& pFocus )
	{
		// Return if Widget is not child of our root.
	
		if( pFocus && (!pFocus->hook() || pFocus->hook()->root() != m_pRoot) )
			return false;
	
		// Handle old focus.
	
		Widget * pOldFocus = m_keyFocusWidget.rawPtr();
	
		if( pFocus == pOldFocus )
			return true;
	
		if( pOldFocus )
			_setWidgetFocused( pOldFocus, false );
	
		// Handle new focus, possibly switching focus group.
	
		if( pFocus )
		{
			// Check what focus group (if any) this Widget belongs to.
	
			m_keyFocusGroup = 0;
			Container * p = pFocus->_parent();
			while( p )
			{
				if( p->_isPanel() && static_cast<Panel*>(p)->isFocusGroup() )
				{
					m_keyFocusGroup = static_cast<Panel*>(p);
					break;
				}
	
				p = p->_parent();
			}
	
			// Activate focus
	
			_setWidgetFocused( pFocus.rawPtr(), true );
		}
	
		// Set members and exit.
	
		m_keyFocusWidget = pFocus.rawPtr();
		m_focusGroupMap[m_keyFocusGroup] = pFocus.rawPtr();
	
		return true;
	}
コード例 #2
0
ファイル: main2.cpp プロジェクト: tempbottle/WonderGUI
void cbInitDrag( const Msg_p& _pMsg, const Object_p& pObject )
{
	Widget_p pWidget = Widget::cast(pObject);

	FlexHook_p pHook = FlexHook::cast(pWidget->hook());


	dragStartPos = pHook->floatOfs();
	printf( "DRAG START!\n" );
}
コード例 #3
0
ファイル: main2.cpp プロジェクト: tempbottle/WonderGUI
void cbDragWidget( const Msg_p& _pMsg, const Object_p& pObject )
{
	Widget_p pWidget = Widget::cast(pObject);
	
	if( _pMsg->type() != WG_MSG_MOUSE_DRAG || !pWidget->parent() )
		return;

	const MouseDragMsg_p pMsg = MouseDragMsg::cast(_pMsg);



	Coord	dragDistance = pMsg->draggedTotal();

	Coord	ofs = dragStartPos + dragDistance;

//	printf( "AccDistance: %d, %d\n", dragDistance.x, dragDistance.y );
	printf( "ofs: %d, %d   start: %d %d   distance: %d, %d\n", ofs.x, ofs.y, dragStartPos.x, dragStartPos.y, dragDistance.x, dragDistance.y );

	FlexHook_p pHook = FlexHook::cast(pWidget->hook());
	pHook->setOfs(dragStartPos+dragDistance);
}