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); }
void MsgLogger::receive( const Msg_p& _pMsg ) { if( m_msgFilter[(int)_pMsg->type()] == false ) return; string source; string copyTo; char params[256]; params[0] = 0; // Msg specific parameters switch( _pMsg->type() ) { case MsgType::Dummy: break; case MsgType::Tick: sprintf( params, " millisec=%d", TickMsg::cast(_pMsg)->timediff() ); break; case MsgType::PointerChange: sprintf( params, " style=%s", _formatPointerStyle( PointerChangeMsg::cast(_pMsg)).c_str() ); break; case MsgType::MouseEnter: break; case MsgType::MouseMove: break; case MsgType::MouseLeave: break; case MsgType::MousePress: sprintf( params, " button=%s", _formatMouseButton(MousePressMsg::cast(_pMsg)->button()).c_str() ); break; case MsgType::MouseRepeat: sprintf( params, " button=%s", _formatMouseButton(MouseRepeatMsg::cast(_pMsg)->button()).c_str() ); break; case MsgType::MouseDrag: { MouseDragMsg_p pMsg = MouseDragMsg::cast(_pMsg); Coord now = pMsg->currPos(); Coord prev = pMsg->prevPos(); Coord start = pMsg->startPos(); Coord dragNow = pMsg->draggedNow(); Coord dragTotal=pMsg->draggedTotal(); sprintf( params, " button=%s position(start=%d,%d prev=%d,%d now=%d,%d) dragged(now=%d,%d total=%d,%d)", _formatMouseButton(pMsg->button()).c_str(), start.x, start.y, prev.x, prev.y, now.x, now.y, dragNow.x, dragNow.y, dragTotal.x, dragTotal.y ); break; } case MsgType::MouseRelease: { MouseReleaseMsg_p pMsg = MouseReleaseMsg::cast(_pMsg); const static char outside[] = "outside"; const static char inside[] = "inside"; const char * pPress = outside; const char * pRelease = outside; if( pMsg->releaseInside() ) pRelease = inside; sprintf( params, " button=%s release=%s", _formatMouseButton(pMsg->button()).c_str(), pRelease ); break; } case MsgType::MouseClick: sprintf( params, " button=%s", _formatMouseButton(MouseClickMsg::cast(_pMsg)->button()).c_str() ); break; case MsgType::MouseDoubleClick: sprintf( params, " button=%s", _formatMouseButton(MouseDoubleClickMsg::cast(_pMsg)->button()).c_str() ); break; case MsgType::KeyPress: { KeyPressMsg_p pMsg = KeyPressMsg::cast(_pMsg); sprintf( params, " wg_keycode=%d native_keycode=%d", pMsg->translatedKeyCode(), pMsg->nativeKeyCode() ); break; } case MsgType::KeyRepeat: { KeyRepeatMsg_p pMsg = KeyRepeatMsg::cast(_pMsg); sprintf( params, " wg_keycode=%d native_keycode=%d", pMsg->translatedKeyCode(), pMsg->nativeKeyCode() ); break; } case MsgType::KeyRelease: { KeyReleaseMsg_p pMsg = KeyReleaseMsg::cast(_pMsg); sprintf( params, " wg_keycode=%d native_keycode=%d", pMsg->translatedKeyCode(), pMsg->nativeKeyCode() ); break; } case MsgType::TextInput: sprintf( params, " chars=%s", TextInputMsg::cast(_pMsg)->text().chars() ); break; case MsgType::EditCommand: sprintf( params, " cmd=%s", _formatEditCommand(EditCommandMsg::cast(_pMsg)->command()).c_str() ); break; case MsgType::WheelRoll: { WheelRollMsg_p pMsg = WheelRollMsg::cast(_pMsg); sprintf( params, "wheel=%d distance=(%d,%d)", pMsg->wheel(), pMsg->distance().x, pMsg->distance().y ); break; } case MsgType::Select: break; case MsgType::Toggle: sprintf( params, " set=%d", (int) (ToggleMsg::cast(_pMsg)->isSet()) ); break; case MsgType::ValueUpdate: { ValueUpdateMsg_p pMsg = ValueUpdateMsg::cast(_pMsg); sprintf( params, " value=%ld fraction=%f", pMsg->value(), pMsg->fraction() ); break; } case MsgType::RangeUpdate: { RangeUpdateMsg_p pMsg = RangeUpdateMsg::cast(_pMsg); sprintf( params, " offset=%d length=%d fracOfs=%f fracLen=%f final=%s", pMsg->offset(), pMsg->length(), pMsg->fracOffset(), pMsg->fracLength(), pMsg->isFinal()?"true":"false" ); break; } case MsgType::TextEdit: { TextEditMsg_p pMsg = TextEditMsg::cast(_pMsg); break; } case MsgType::ItemToggle: { ItemToggleMsg_p pMsg = ItemToggleMsg::cast(_pMsg); sprintf( params, " set=%s id=%d object=%p", pMsg->isSet()?"true":"false", pMsg->itemId(), pMsg->itemObject().rawPtr() ); break; } case MsgType::ItemMousePress: { ItemMousePressMsg_p pMsg = ItemMousePressMsg::cast(_pMsg); sprintf( params, " id=%d mouseButton=%s", pMsg->itemId(), _formatMouseButton(pMsg->button()).c_str() ); break; } case MsgType::ItemsSelect: { ItemsSelectMsg_p pMsg = ItemsSelectMsg::cast(_pMsg); sprintf( params, " nbItems=%d", pMsg->nbItems() ); break; } case MsgType::ItemsUnselect: { ItemsUnselectMsg_p pMsg = ItemsUnselectMsg::cast(_pMsg); sprintf( params, " nbItems=%d", pMsg->nbItems() ); break; } case MsgType::LinkMouseEnter: case MsgType::LinkMouseLeave: case MsgType::LinkSelect: { LinkMsg_p pMsg = LinkMsg::cast(_pMsg); sprintf( params, " link=%p string=\"%s\"", pMsg->link().rawPtr(), pMsg->link()->link().c_str() ); break; } case MsgType::LinkMousePress: case MsgType::LinkMouseRepeat: case MsgType::LinkMouseRelease: case MsgType::LinkMouseClick: case MsgType::LinkMouseDoubleClick: { LinkMouseButtonMsg_p pMsg = LinkMouseButtonMsg::cast(_pMsg); sprintf( params, " link=%p button=%s", pMsg->link().rawPtr(), _formatMouseButton(pMsg->button()).c_str() ); break; } case MsgType::ModalMoveOutside: break; case MsgType::ModalBlockedPress: sprintf( params, " button=%s", _formatMouseButton(ModalBlockedPressMsg::cast(_pMsg)->button()).c_str() ); break; case MsgType::ModalBlockedRelease: sprintf( params, " button=%s", _formatMouseButton(ModalBlockedReleaseMsg::cast(_pMsg)->button()).c_str() ); break; default: break; }; source = _formatSource( _pMsg ); copyTo = _formatCopyTo( _pMsg ); string timestamp; string modkeys; string pointerPos; if( _pMsg->isInstanceOf( InputMsg::CLASSNAME ) ) { InputMsg_p p = InputMsg::cast(_pMsg); timestamp = _formatTimestamp( p->timestamp() ); modkeys = _formatModkeys( p ); pointerPos = _formatPointerPos( p ); } m_out << " - " << _pMsg->className() << " - " << source << copyTo << pointerPos << modkeys << params; m_out << std::endl; }