wxString wxFileCtrlEvent::GetFile() const { wxASSERT_MSG( !wxDynamicCast( GetEventObject(), wxFileCtrl )->HasMultipleFileSelection(), wxT( "Please use GetFiles() to get all files instead of this function" ) ); wxString string; if (m_files.Count() != 0) string = m_files[0]; return string; }
void SEventSet::FireEvent(EventArgs& args ) { // find event object SEvent* ev = GetEventObject(args.GetID()); // fire the event if present and set is not muted if ((ev != 0) && !m_bMuted) { (*ev)(args); } }
void NetMgrEventHandler::HandleInput() { const int RECV_SIZE = 16384; size_t pos = _recvbuffer.Size(); _recvbuffer.Resize(pos + RECV_SIZE); int ret = ::recv(GetEventObject().GetObject(), _recvbuffer.GetBegin() + pos, RECV_SIZE, 0); if (ret == 0) { LOG_DEBUG("Receive failed: client[%s] disconnectd", _peerAddr.ToString().c_str()); Close(); } else if (ret == -1) { if (errno == EINTR) { return; } else { LOG_WARN("Receive failed: %s, client:[%s]", strerror(errno), _peerAddr.ToString().c_str()); Close(); } } else { LOG_DEBUG("netinfo, recv data:[%s] from src:[%s]", base::Escape(_recvbuffer.GetBegin(), ret).c_str(), _peerAddr.ToString().c_str()); _recvbuffer.AddSpace(ret); ICoder* coder = _networkOption->coder; assert(coder); int usecount = coder->Extract(_recvbuffer.GetBegin(), _recvbuffer.Size(), _peerAddr); if (usecount < 0) { LOG_WARN("Extract package fail,data:[%s], client:[%s]", base::Escape(_recvbuffer.GetBegin(), _recvbuffer.Size()).c_str(), _peerAddr.ToString().c_str()); Close(); } else { if (usecount > 0) { _recvbuffer.Copy(_recvbuffer.GetBegin(), _recvbuffer.GetBegin() + usecount, _recvbuffer.Size() - usecount); _recvbuffer.ReduceSpace(usecount); } timeval tv = {_networkOption->timeout/1000, _networkOption->timeout%1000*1000}; if (GetEventManager()->RegisterHandler(base::ReadMask, this, &tv) == -1) { LOG_ERROR("register read event fail, client:[%s]", _peerAddr.ToString().c_str()); Close(); } } } }
void SNotifyCenter::OnFireEvent( EventArgs *e ) { if(!GetEventObject(e->GetID())) return;//确保事件是已经注册过的已经事件。 FireEvent(*e); if(!e->bubbleUp) return ; SPOSITION pos = m_evtHandlerMap.GetTailPosition(); while(pos) { ISlotFunctor * pSlot = m_evtHandlerMap.GetPrev(pos); (*pSlot)(e); if(!e->bubbleUp) break; } }
bool wxClipboardEvent::SupportsFormat( const wxDataFormat &format ) const { #ifdef __WXGTK20__ for (wxVector<wxDataFormat>::size_type n = 0; n < m_formats.size(); n++) { if (m_formats[n] == format) return true; } return false; #else // All other ports just query the clipboard directly // from here wxClipboard* clipboard = (wxClipboard*) GetEventObject(); return clipboard->IsSupported( format ); #endif }
void Player_::OnNewPresentation(IMFMediaEventPtr pEvent) { IMFPresentationDescriptorPtr pPD; IMFTopologyPtr pTopology; // Get the presentation descriptor from the event. THROW_IF_ERR(GetEventObject(pEvent.Get(), pPD.GetAddressOf())); // Create a partial topology. pTopology = CreatePlaybackTopology(m_pSource, pPD, m_hwndVideo); // Set the topology on the media session. THROW_IF_ERR(m_pSession->SetTopology(0, pTopology.Get())); // m_state = OpenPending; }
bool SEventSet::isEventPresent( const DWORD dwEventID ) { return GetEventObject(dwEventID)!=NULL; }
bool SEventSet::unsubscribeEvent( const DWORD dwEventID, const ISlotFunctor & subscriber ) { if(!isEventPresent(dwEventID)) return false; return GetEventObject(dwEventID)->unsubscribe(subscriber); }
CMusikPlayer & MusikPlayerEvent::MusikPlayer() { return *wxDynamicCast(GetEventObject(),CMusikPlayer); }
void NetMgrEventHandler::HandleOutput() { if (_sendbuffer.Size() <= 0) { return; } int ret = ::send(GetEventObject().GetObject(), _sendbuffer.GetBegin(), _sendbuffer.Size(), MSG_DONTWAIT); if (ret == 0) { LOG_ERROR("Send failed: client[%s] disconnectd", _peerAddr.ToString().c_str()); Close(); } else if (ret == -1) { if (errno == EINTR) { return; } else if (errno == EAGAIN) { timeval tv = {_networkOption->timeout, 0}; if (GetEventManager()->RegisterHandler(base::WriteMask, this, &tv) == -1) { LOG_ERROR("register write event fail, client:[%s]", _peerAddr.ToString().c_str()); Close(); } } else { LOG_WARN("Receive failed: %s, client:[%s]", strerror(errno), _peerAddr.ToString().c_str()); Close(); } } else { LOG_DEBUG("netinfo, send data:[%s] to dest:[%s] succ", base::Escape(_sendbuffer.GetBegin(), ret).c_str(), _peerAddr.ToString().c_str()); if ((size_t)ret == _sendbuffer.Size()) { _sendbuffer.Clear(); } else { _sendbuffer.Copy(_sendbuffer.GetBegin(), _sendbuffer.GetBegin() + ret, _sendbuffer.Size() - ret); _sendbuffer.Resize(_sendbuffer.Size() - ret); } if (_sendbuffer.Empty()) { LOG_DEBUG("netinfo, send data finish, dest:[%s]", _peerAddr.ToString().c_str()); GetEventManager()->RemoveHandler(base::WriteMask, this); } else { timeval tv = {_networkOption->timeout, 0}; if (GetEventManager()->RegisterHandler(base::WriteMask, this, &tv) == -1) { LOG_ERROR("register write event fail, client:[%s]", _peerAddr.ToString().c_str()); Close(); } } } }
void NetMgrEventHandler::HandleClose() { LOG_DEBUG("Connection closed"); ::close(GetEventObject().GetObject()); }