예제 #1
0
void wxRadioButton::SetValue(bool val)
{
    wxRadioButton *cycle;
    if (GetPeer()->GetValue() == val)
        return;

    GetPeer()->SetValue( val );
    if (val)
    {
        cycle = this->NextInCycle();
        if (cycle != NULL)
        {
            while (cycle != this)
            {
                cycle->SetValue( false );
                cycle = cycle->NextInCycle();
            }
        }
    }
}
예제 #2
0
wxMenuItem *wxMenu::DoRemove(wxMenuItem *item)
{
    if ( item->IsRadio() )
    {
        // Check if we're removing the item starting the radio group
        if ( item->IsRadioGroupStart() )
        {
            // Yes, we do, update the next radio group item, if any, to be the
            // start one now.
            const int endGroup = item->GetRadioGroupEnd();

            wxMenuItemList::compatibility_iterator
                node = GetMenuItems().Item(endGroup);
            wxASSERT_MSG( node, wxS("Should have valid radio group end") );

            while ( node->GetData() != item )
            {
                const wxMenuItemList::compatibility_iterator
                    prevNode = node->GetPrevious();
                wxMenuItem* const prevItem = prevNode->GetData();
                if ( prevItem == item )
                {
                    prevItem->SetAsRadioGroupStart();
                    prevItem->SetRadioGroupEnd(endGroup);
                    break;
                }

                node = prevNode;
            }
        }
    }

/*
    // we need to find the items position in the child list
    size_t pos;
    wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst();

    for ( pos = 0; node; pos++ )
    {
        if ( node->GetData() == item )
            break;

        node = node->GetNext();
    }

    // DoRemove() (unlike Remove) can only be called for existing item!
    wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") );

    wxOSXMenuRemoveItem(m_hMenu , pos );
    */
    GetPeer()->Remove( item );
    // and from internal data structures
    return wxMenuBase::DoRemove(item);
}
예제 #3
0
void AwtLabel::DoPaint(HDC hDC, RECT& r)
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    if ((r.right-r.left) > 0 && (r.bottom-r.top) > 0 &&
        m_peerObject != NULL && m_callbacksEnabled) {

        if (env->EnsureLocalCapacity(3) < 0)
            return;
        long x,y;
        SIZE size;

        /* self is sun.awt.windows.WLabelPeer  */

        jobject self = GetPeer(env);
        DASSERT(self);

        /* target is java.awt.Label */
        jobject target = env->GetObjectField(self, AwtObject::targetID);
        jobject font = GET_FONT(target, self);
        jstring text = (jstring)env->GetObjectField(target, AwtLabel::textID);

        size = AwtFont::getMFStringSize(hDC, font, text);
        ::SetTextColor(hDC, GetColor());
        /* Redraw whole label to eliminate display noise during resizing. */
        VERIFY(::GetClientRect(GetHWnd(), &r));
        VERIFY(::FillRect (hDC, &r, GetBackgroundBrush()));
        y = (r.top + r.bottom - size.cy) / 2;

        jint alignment = env->GetIntField(target, AwtLabel::alignmentID);
        switch (alignment) {
           case java_awt_Label_LEFT:
              x = r.left + 2;
              break;
          case java_awt_Label_CENTER:
              x = (r.left + r.right - size.cx) / 2;
              break;
          case java_awt_Label_RIGHT:
              x = r.right - 2 - size.cx;
              break;
        }
        /* draw string */
        if (isEnabled()) {
            AwtComponent::DrawWindowText(hDC, font, text, x, y);
        } else {
            AwtComponent::DrawGrayText(hDC, font, text, x, y);
        }
        DoCallback("handlePaint", "(IIII)V",
                   r.left, r.top, r.right-r.left, r.bottom-r.top);
        env->DeleteLocalRef(target);
        env->DeleteLocalRef(font);
        env->DeleteLocalRef(text);
    }
}
STDMETHODIMP
CPosPassThru::get_StopTime(REFTIME * pllTime)
{
    IMediaPosition* pMP;
    HRESULT hr = GetPeer(&pMP);
    if (FAILED(hr)) {
	return hr;
    }
    hr = pMP->get_StopTime(pllTime);
    pMP->Release();
    return hr;
}
예제 #5
0
void wxChoice::DoClear()
{
    for ( unsigned int i = 0 ; i < GetCount() ; i++ )
    {
        m_popUpMenu->Delete( m_popUpMenu->FindItemByPosition( 0 ) );
    }

    m_strings.Empty() ;
    m_datas.Empty() ;

    GetPeer()->SetMaximum( 0 ) ;
}
STDMETHODIMP
CPosPassThru::put_PrerollTime(REFTIME llTime)
{
    IMediaPosition* pMP;
    HRESULT hr = GetPeer(&pMP);
    if (FAILED(hr)) {
	return hr;
    }
    hr = pMP->put_PrerollTime(llTime);
    pMP->Release();
    return hr;
}
STDMETHODIMP
CPosPassThru::get_Rate(double * pdRate)
{
    IMediaPosition* pMP;
    HRESULT hr = GetPeer(&pMP);
    if (FAILED(hr)) {
	return hr;
    }
    hr = pMP->get_Rate(pdRate);
    pMP->Release();
    return hr;
}
STDMETHODIMP
CPosPassThru::CanSeekBackward(LONG *pCanSeekBackward)
{
    IMediaPosition* pMP;
    HRESULT hr = GetPeer(&pMP);
    if (FAILED(hr)) {
	return hr;
    }
    hr = pMP->CanSeekBackward(pCanSeekBackward);
    pMP->Release();
    return hr;
}
MsgRouting
AwtTextComponent::WmNotify(UINT notifyCode)
{
    if (notifyCode == EN_CHANGE) {
        JNIEnv *env;
        if (JVM->AttachCurrentThread((void **) &env, 0) == 0) {
            env->CallVoidMethod(GetPeer(), 
                                WCachedIDs.PPCTextComponentPeer_valueChangedMID);
        }
    }
    return mrDoDefault;
}
예제 #10
0
void pSocket::cmdPiece(size_t piece, size_t offset, unsigned char *data)
{
	Session *sess = m_sess; 
	if (!sess)
	{
		SetCloseAndDelete();
		return;
	}
	
	Peer *peer = GetPeer();
	
	size_t length = peer ? peer -> GotSlice(piece, offset) : 0;
	
	if (length)
	{
		// Trafic Log
		std::string sMl;
		sMl.append("R ");
		// Local ip @
		sMl.append(m_sess->GetLocalIpAdr());
		sMl.append(" ");
		// Remote ip @
		sMl.append(this->GetRemoteAddress());
		sMl.append(" ");
		// Number of hops to the remote ip @
		std::ostringstream oss;
		oss<<this->m_peer->GetNumberOfHops();
		sMl.append(oss.str());
		sMl.append(" ");
		 // Number of bytes received from the remote peer
		std::ostringstream oss2;
		oss2<<length;
		sMl.append(oss2.str());
		sMl.append("\n");
		if(ACTIVATE_LOG)
		{	
			sess->AddDBytesToTrafficMatrix(this->GetRemoteAddress(), length);
			sess ->matrix_log->add_line(sMl,false);
		}
		sess -> SaveSlice(piece, offset, length, data);
		sess -> SetCheckComplete();
		//TOVERIFY
		sess -> GenerateRequest(peer);
	}
	else
	{
		char sMessage[100];
		sprintf(sMessage,  "(%d)cmdPiece: no length for slice write", m_id);
		if(ACTIVATE_LOG)
			this->pSocket_log->add_line(sMessage,true);
		
	}
}
예제 #11
0
void wxSlider::SetValue(int value)
{
    if ( m_macValueStatic )
    {
        wxString valuestring;
        valuestring.Printf( wxT("%d"), value );
        m_macValueStatic->SetLabel( valuestring );
    }

    // We only invert for the setting of the actual native widget
    GetPeer()->SetValue( ValueInvertOrNot( value ) );
}
예제 #12
0
	bool DarkNetwork::TryDispatchPackets(Packet &pck)
	{
		bool packet_dispatched = false;
		Peer *peer = GetPeer(pck.address);
		if (peer)
		{
			peer->SetInputBuffer(pck.buff);
			packet_dispatched = true;
		}

		return packet_dispatched;
	}
STDMETHODIMP
CPosPassThru::get_Duration(REFTIME * plength)
{
    IMediaPosition* pMP;
    HRESULT hr = GetPeer(&pMP);
    if (FAILED(hr)) {
	return hr;
    }

    hr = pMP->get_Duration(plength);
    pMP->Release();
    return hr;
}
예제 #14
0
wxWindow *wxButton::SetDefault()
{
    wxWindow *btnOldDefault = wxButtonBase::SetDefault();

    if ( btnOldDefault )
    {
        btnOldDefault->GetPeer()->SetDefaultButton( false );
    }

    GetPeer()->SetDefaultButton( true );

    return btnOldDefault;
}
예제 #15
0
CClient::~CClient()
{
	bool bWasChar;

	// update ip history
#ifndef _MTNETWORK
	HistoryIP& history = g_NetworkIn.getIPHistoryManager().getHistoryForIP(GetPeer());
#else
	HistoryIP& history = g_NetworkManager.getIPHistoryManager().getHistoryForIP(GetPeer());
#endif
	if ( GetConnectType() != CONNECT_GAME )
		history.m_connecting--;
	history.m_connected--;

	bWasChar = ( m_pChar != NULL );
	CharDisconnect();	// am i a char in game ?
	Cmd_GM_PageClear();

	// Clear containers (CTAG and TOOLTIP)
	m_TagDefs.Empty();
	m_TooltipData.Clean(true);

	CAccount * pAccount = GetAccount();
	if ( pAccount )
	{
		pAccount->OnLogout(this, bWasChar);
		m_pAccount = NULL;
	}

	if (m_pPopupPacket != NULL)
	{
		delete m_pPopupPacket;
		m_pPopupPacket = NULL;
	}

	if (m_net->isClosed() == false)
		g_Log.EventError("Client being deleted without being safely removed from the network system\n");
}
예제 #16
0
void pSocket::cmdUnchoke()
{
	Peer *peer = GetPeer();
	char sMessage[100];
	sprintf(sMessage, ">(%d)Unchoke", m_id);
	if(ACTIVATE_LOG)
		this->pSocket_log->add_line(sMessage,true);
	
	if (peer)
	{
		peer -> SetChoked(false);
		peer -> RequestAvailable();
	}
}
예제 #17
0
// This function returns a local reference
jobject
AwtMenuItem::GetFont(JNIEnv *env)
{
    jobject self = GetPeer(env);
    jobject target = env->GetObjectField(self, AwtObject::targetID);
    jobject font = JNU_CallMethodByName(env, 0, target, "getFont_NoClientCode", "()Ljava/awt/Font;").l;

    if (font == NULL) {
        font = env->NewLocalRef(GetDefaultFont(env));
    }

    env->DeleteLocalRef(target);
    return font;
}
예제 #18
0
void pSocket::cmdNotinterested()
{
	char sMessage[100];
	sprintf(sMessage, ">(%d)Notinterested", m_id);
	if(ACTIVATE_LOG)
		this->pSocket_log->add_line(sMessage,true);

	Peer *peer = GetPeer();
	if (peer)
		peer -> SetInterested(false);
	// We have modified the choking algorithm 
	//if (!m_choke)
	//	SendChoke(true);
}
예제 #19
0
void wxChoice::DoDeleteOneItem(unsigned int n)
{
    wxCHECK_RET( IsValid(n) , wxT("wxChoice::Delete: invalid index") );

    if ( HasClientObjectData() )
        delete GetClientObject( n );

    m_popUpMenu->Delete( m_popUpMenu->FindItemByPosition( n ) );

    m_strings.RemoveAt( n ) ;
    m_datas.RemoveAt( n ) ;
    GetPeer()->SetMaximum( GetCount() ) ;

}
예제 #20
0
void AwtScrollPane::PostScrollEvent(int orient, int scrollCode, int pos) {
    if (scrollCode == SB_ENDSCROLL) {
	return;
    }

    // convert Windows scroll bar ident to peer ident
    jint jorient;
    if (orient == SB_VERT) {
	jorient = java_awt_Adjustable_VERTICAL;
    } else if (orient == SB_HORZ) {
	jorient = java_awt_Adjustable_HORIZONTAL;
    } else {
	DASSERT(FALSE);
	return;
    }

    // convert Windows scroll code to adjustment type and isAdjusting status
    jint jscrollcode;
    jboolean jadjusting = JNI_FALSE;
    switch (scrollCode) {
      case SB_LINEUP:
	  jscrollcode = java_awt_event_AdjustmentEvent_UNIT_DECREMENT;
	  break;
      case SB_LINEDOWN:
	  jscrollcode = java_awt_event_AdjustmentEvent_UNIT_INCREMENT;
	  break;
      case SB_PAGEUP:
	  jscrollcode = java_awt_event_AdjustmentEvent_BLOCK_DECREMENT;
	  break;
      case SB_PAGEDOWN:
	  jscrollcode = java_awt_event_AdjustmentEvent_BLOCK_INCREMENT;
	  break;
      case SB_THUMBTRACK:
	  jscrollcode = java_awt_event_AdjustmentEvent_TRACK;
	  jadjusting = JNI_TRUE;
	  break;
      case SB_THUMBPOSITION:
	  jscrollcode = java_awt_event_AdjustmentEvent_TRACK;
	  break;
      default:
	  DASSERT(FALSE);
	  return;
    }

    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    env->CallVoidMethod(GetPeer(env), AwtScrollPane::postScrollEventID,
			jorient, jscrollcode, (jint)pos, jadjusting);
    DASSERT(!safe_ExceptionOccurred(env));
}
MsgRouting
AwtChoice::WmNotify( UINT notifyCode )
{
    if ( notifyCode == CBN_SELCHANGE ) {
        JNIEnv *env;
        if ( JVM->AttachCurrentThread( (void **)&env, 0 ) != 0 ) {
            return mrDoDefault; // ?
        }
        env->CallVoidMethod( GetPeer(),
                             WCachedIDs.PPCChoicePeer_handleActionMID,
                             SendMessage( CB_GETCURSEL ) );
        ASSERT( !env->ExceptionCheck() );
    }
    return mrDoDefault;
}
예제 #22
0
jobject AwtChoice::PreferredItemSize(JNIEnv *env)
{
    jobject dimension = JNU_CallMethodByName(env, NULL, GetPeer(env),
					     "preferredSize",
					     "()Ljava/awt/Dimension;").l;
    DASSERT(!safe_ExceptionOccurred(env));
    if (dimension == NULL) {
	return NULL;
    }
    /* This size is window size of choice and it's too big for each
     * drop down item height.
     */
    env->SetIntField(dimension, AwtDimension::heightID,
		       GetFontHeight(env));
    return dimension;
}
예제 #23
0
void wxMenuItem::UpdateItemText()
{
    if ( !m_parentMenu )
        return ;

    wxString text = wxStripMenuCodes(m_text, m_parentMenu != NULL && m_parentMenu->GetNoEventsMode() ? wxStrip_Accel : wxStrip_All);
    if (text.IsEmpty() && !IsSeparator())
    {
        wxASSERT_MSG(wxIsStockID(GetId()), wxT("A non-stock menu item with an empty label?"));
        text = wxGetStockLabel(GetId(), wxSTOCK_WITH_ACCELERATOR|wxSTOCK_WITH_MNEMONIC);
    }

    wxAcceleratorEntry *entry = wxAcceleratorEntry::Create( m_text ) ;
    GetPeer()->SetLabel( text, entry );
    delete entry ;
}
STDMETHODIMP
CPosPassThru::put_Rate(double dRate)
{
    if (0.0 == dRate) {
		return E_INVALIDARG;
    }

    IMediaPosition* pMP;
    HRESULT hr = GetPeer(&pMP);
    if (FAILED(hr)) {
	return hr;
    }
    hr = pMP->put_Rate(dRate);
    pMP->Release();
    return hr;
}
예제 #25
0
/*
 * There currently is no good place to cache java.awt.Dimension field
 * ids. If this method gets called a lot, one such place should be found.
 * -- br 07/18/97.
 */
jobject AwtList::PreferredItemSize(JNIEnv *env)
{
    jobject peer = GetPeer(env);
    jobject dimension = JNU_CallMethodByName(env, NULL, peer, "preferredSize",
                                             "(I)Ljava/awt/Dimension;",
                                             1).l;

    DASSERT(!safe_ExceptionOccurred(env));
    if (dimension == NULL) {
        return NULL;
    }
    /* This size is too big for each item height. */
    (env)->SetIntField(dimension, AwtDimension::heightID, GetFontHeight(env));

    return dimension;
}
예제 #26
0
bool CClient::OnRxConsoleLoginComplete()
{
	ADDTOCALLSTACK("CClient::OnRxConsoleLoginComplete");
	if ( GetConnectType() != CONNECT_TELNET )
		return false;
	if ( !GetPeer().IsValidAddr() )
		return false;

	if ( GetPrivLevel() < PLEVEL_Admin )	// this really should not happen.
	{
		SysMessagef("%s\n", g_Cfg.GetDefaultMsg(DEFMSG_CONSOLE_NO_ADMIN));
		return false;
	}

	SysMessagef("%s '%s' ('%s')\n", g_Cfg.GetDefaultMsg(DEFMSG_CONSOLE_WELCOME_2), GetName(), GetPeerStr());
	return true;
}
예제 #27
0
int CAuthServerHandler::HandleData()
{
    memset(m_pBuffer, 0x00, scgl::BUFFER_SIZE);
    size_t n;
    if ((n = GetPeer().recv(m_pBuffer, scgl::BUFFER_SIZE)) == -1)
    {
        return -1;
    }
    if (n < sizeof TAuthInfo)
    {
        return -1;
    }
    TAuthInfo authInfo;
    authInfo << m_pBuffer;
    tcout << authInfo.id << _T(":") << authInfo.password << std::endl;
    return 0;
}
예제 #28
0
HRESULT CInProcPlugHole::GetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
	TRACE("%#x: GetClassObject(%s) thread %#x\n", GetCurrentThreadId(), GetImagePath());
	
	IIPDolphinPtr piPeer;
	HRESULT hr = GetPeer(&piPeer, rclsid);
	if (FAILED(hr))
	{
		trace("%#x: CInProcPlugHole(%s)::GetClassObject() thread %#x: No peer available\n", GetCurrentThreadId(), GetImagePath());
		return hr;
	}

	hr = piPeer->GetClassObject(rclsid, riid, ppv);
	TRACE("%#x: GetClassObject() request returned %d\n", GetCurrentThreadId(), hr);

	return hr;
}
예제 #29
0
bool wxCheckBox::OSXHandleClicked( double WXUNUSED(timestampsec) )
{
    bool sendEvent = true;
    wxCheckBoxState newState = Get3StateValue();

    if ( !GetPeer()->ButtonClickDidStateChange() )
    {
        wxCheckBoxState origState ;

        newState = origState = Get3StateValue();

        switch (origState)
        {
            case wxCHK_UNCHECKED:
                newState = wxCHK_CHECKED;
                break;

            case wxCHK_CHECKED:
                // If the style flag to allow the user setting the undetermined state is set,
                // then set the state to undetermined; otherwise set state to unchecked.
                newState = Is3rdStateAllowedForUser() ? wxCHK_UNDETERMINED : wxCHK_UNCHECKED;
                break;

            case wxCHK_UNDETERMINED:
                newState = wxCHK_UNCHECKED;
                break;

            default:
                break;
        }
        if (newState == origState)
            sendEvent = false;
    }

    if (sendEvent)
    {
        Set3StateValue( newState );

        wxCommandEvent event( wxEVT_COMMAND_CHECKBOX_CLICKED, m_windowId );
        event.SetInt( newState );
        event.SetEventObject( this );
        ProcessCommand( event );
    }

    return true;
}
예제 #30
0
void AwtMenuItem::DoCommand()
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    // peer is sun.awt.windows.WMenuItemPeer
    jobject peer = GetPeer(env);

    if (IsCheckbox()) {
        UINT nState = ::GetMenuState(GetMenuContainer()->GetHMenu(),
                                     GetID(), MF_BYCOMMAND);
        DASSERT(nState != 0xFFFFFFFF);
        DoCallback("handleAction", "(Z)V", ((nState & MF_CHECKED) == 0));
    } else {
        DoCallback("handleAction", "(JI)V", TimeHelper::getMessageTimeUTC(),
                   (jint)AwtComponent::GetJavaModifiers());
    }
}