JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_select (JNIEnv *env, 
                                                   jobject thisObj,
                                                   jint start, jint end)
{
    CHECK_PEER(thisObj);
    AwtComponent* c = PDATA(AwtComponent, thisObj);

    c->SendMessage(EM_SETSEL, 
		   getWin32SelPos((AwtTextComponent*)c, start),
		   getWin32SelPos((AwtTextComponent*)c, end));

    c->SendMessage(EM_SCROLLCARET);    
}
JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCCheckboxPeer_setState (JNIEnv *env, jobject thisObj,
                                                  jboolean state)
{
    CHECK_PEER(thisObj);
    AwtComponent* c = (AwtComponent*) env->GetIntField(thisObj,
                  WCachedIDs.PPCObjectPeer_pDataFID);

    //when multifont and group checkbox receive setState native method,
    //it must be redraw to display correct check mark
    jobject target =
       env -> GetObjectField(thisObj, WCachedIDs.PPCObjectPeer_targetFID);

    if (env->CallObjectMethod(target, WCachedIDs.java_awt_Checkbox_getCheckboxGroupMID) != NULL) {
        HWND hWnd = c->GetHWnd();
        RECT rect;
        VERIFY(::GetWindowRect(hWnd,&rect));
        VERIFY(::ScreenToClient(hWnd, (LPPOINT)&rect));
        VERIFY(::ScreenToClient(hWnd, ((LPPOINT)&rect)+1));
        VERIFY(::InvalidateRect(hWnd,&rect,TRUE));
        VERIFY(::UpdateWindow(hWnd));
    } else {
        c->SendMessage(BM_SETCHECK, (WPARAM)(state ? BST_CHECKED : BST_UNCHECKED));
        VERIFY(::InvalidateRect(c->GetHWnd(), NULL, FALSE));
    }

    c->VerifyState();
}
Exemplo n.º 3
0
/*
 * Class:     sun_awt_windows_WCheckboxPeer
 * Method:    setState
 * Signature: (Z)V
 */
JNIEXPORT void JNICALL 
Java_sun_awt_windows_WCheckboxPeer_setState(JNIEnv *env, jobject self,
					    jboolean state) 
{
    TRY;

    PDATA pData;
    JNI_CHECK_PEER_RETURN(self);
    AwtComponent* c = (AwtComponent*)JNI_GET_PDATA(self);
    /* 
     * when multifont and group checkbox receive setState native
     * method, it must be redraw to display correct check mark 
     */
    jobject target = env->GetObjectField(self, AwtObject::targetID);

    jobject group = env->GetObjectField(target, AwtCheckbox::groupID);
    if (group != NULL) {
	HWND hWnd = c->GetHWnd();
        RECT rect;
        VERIFY(::GetWindowRect(hWnd,&rect));
        VERIFY(::ScreenToClient(hWnd, (LPPOINT)&rect));
        VERIFY(::ScreenToClient(hWnd, ((LPPOINT)&rect)+1));
        VERIFY(::InvalidateRect(hWnd,&rect,TRUE));
        VERIFY(::UpdateWindow(hWnd));
    } else {
	c->SendMessage(BM_SETCHECK, (WPARAM)(state ? BST_CHECKED : 
					     BST_UNCHECKED));
	VERIFY(::InvalidateRect(c->GetHWnd(), NULL, FALSE));
    }
    c->VerifyState();

    CATCH_BAD_ALLOC;
}
JNIEXPORT void JNICALL
Java_sun_awt_pocketpc_PPCTextFieldPeer_setEchoCharacter (JNIEnv *env, 
                                                         jobject self, jchar ch)
{
    CHECK_PEER(self);
    AwtComponent* c = PDATA(AwtComponent, self);
    c->SendMessage(EM_SETPASSWORDCHAR, ch);
}
long
Java_sun_awt_pocketpc_PPCCheckboxPeer_getState(JNIEnv * env, jobject self)
{
    CHECK_PEER_RETURN(self);
    AwtComponent* c = (AwtComponent*) env->GetIntField(self,
                  WCachedIDs.PPCObjectPeer_pDataFID);
    c->VerifyState();
    return c->SendMessage(BM_GETCHECK);
}
JNIEXPORT jint JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_getSelectionEnd (JNIEnv *env, 
                                                            jobject self)
{
     CHECK_PEER_RETURN(self);
     AwtComponent* c = PDATA(AwtComponent, self);
     long end;
     c->SendMessage(EM_GETSEL, 0, (LPARAM)&end);
     return getJavaSelPos((AwtTextComponent*)c, end);    
}
JNIEXPORT jint JNICALL
Java_sun_awt_pocketpc_PPCTextComponentPeer_getSelectionStart (JNIEnv *env,
                                                              jobject thisObj)
{
    CHECK_PEER_RETURN(thisObj);
    AwtComponent* c = PDATA(AwtComponent, thisObj);
    long start;
    c->SendMessage(EM_GETSEL, (WPARAM)&start);
    return getJavaSelPos((AwtTextComponent*)c, start);

}
Exemplo n.º 8
0
/*
 * Class:     sun_awt_windows_WComponentPeer
 * Method:    handleEvent
 * Signature: (Lsun/awt/windows/WComponentPeer;Ljava/awt/AWTEvent;)V
 */
JNIEXPORT void JNICALL
Java_sun_awt_windows_WInputMethod_handleNativeIMEEvent(JNIEnv *env, jobject self, 
                                                       jobject peer, jobject event)
{
    TRY;

    PDATA pData;
    JNI_CHECK_PEER_RETURN(peer);
    AwtComponent* p = (AwtComponent *)pData;

    JNI_CHECK_NULL_RETURN(event, "null AWTEvent");
    if (env->EnsureLocalCapacity(1) < 0) {
	return;
    }
    jbyteArray bdata = (jbyteArray)(env)->GetObjectField(event, AwtAWTEvent::bdataID);
    if (bdata == 0) {
	return;
    }
    MSG msg;
    (env)->GetByteArrayRegion(bdata, 0, sizeof(MSG), (jbyte *)&msg);
    (env)->DeleteLocalRef(bdata);
    BOOL isConsumed =
      (BOOL)(env)->GetBooleanField(event, AwtAWTEvent::consumedID);
    int id = (env)->GetIntField(event, AwtAWTEvent::idID);
    DASSERT(!safe_ExceptionOccurred(env));

    if (isConsumed || p==NULL)	return;

    if (id >= java_awt_event_InputMethodEvent_INPUT_METHOD_FIRST &&
        id <= java_awt_event_InputMethodEvent_INPUT_METHOD_LAST) 
    {
	long modifiers = p->GetJavaModifiers();
        if (msg.message==WM_CHAR || msg.message==WM_SYSCHAR) {
            WCHAR unicodeChar = L'\0';
	    unicodeChar = (WCHAR)msg.wParam;
            p->SendKeyEvent(java_awt_event_KeyEvent_KEY_TYPED, 
                            0, //to be fixed nowMillis(), 
                            java_awt_event_KeyEvent_CHAR_UNDEFINED, 
                            unicodeChar, 
                            modifiers, 
                            java_awt_event_KeyEvent_KEY_LOCATION_UNKNOWN, (jlong)0,
                            &msg);
        } else {
            MSG* pCopiedMsg = new MSG;
            *pCopiedMsg = msg;
            p->SendMessage(WM_AWT_HANDLE_EVENT, (WPARAM) FALSE,
			(LPARAM) pCopiedMsg);
        }
        (env)->SetBooleanField(event, AwtAWTEvent::consumedID, JNI_TRUE);
    }

    CATCH_BAD_ALLOC;
}
void
Java_sun_awt_pocketpc_PPCCheckboxPeer_setCheckboxGroup(JNIEnv *env,
						       jobject self,
						       jobject group)
{
    CHECK_PEER(self);
#ifdef DEBUG
    if (group != NULL) {
        CHECK_OBJ(group);
	jclass cls = env->FindClass("java/awt/CheckboxGroup");
        ASSERT(env->IsInstanceOf(group, cls));
    }
#endif
    AwtComponent* c = (AwtComponent*) env->GetIntField(self,
                  WCachedIDs.PPCObjectPeer_pDataFID);
    c->SendMessage(BM_SETSTYLE, (WPARAM)BS_OWNERDRAW, (LPARAM)TRUE);
    c->VerifyState();
}
Exemplo n.º 10
0
    /*
     * Class:     sun_awt_windows_WTextFieldPeer
     * Method:    setEchoCharacter
     * Signature: (C)V
     */
    JNIEXPORT void JNICALL
    Java_sun_awt_windows_WTextFieldPeer_setEchoCharacter(JNIEnv *env, jobject self,
            jchar ch)
    {
        TRY;

        PDATA pData;
        JNI_CHECK_PEER_RETURN(self);
        AwtComponent* c = (AwtComponent*)pData;
        c->SendMessage(EM_SETPASSWORDCHAR, ch);
        /*
         * Fix for BugTraq ID 4307281.
         * Force redraw so that changes will take effect.
         */
        VERIFY(::InvalidateRect(c->GetHWnd(), NULL, FALSE));

        CATCH_BAD_ALLOC;
    }
Exemplo n.º 11
0
/*
 * Class:     sun_awt_windows_WCheckboxPeer
 * Method:    setCheckboxGroup
 * Signature: (Ljava/awt/CheckboxGroup;)V
 */
JNIEXPORT void JNICALL
Java_sun_awt_windows_WCheckboxPeer_setCheckboxGroup(JNIEnv *env, jobject self,
						    jobject group) 
{
    TRY;

    PDATA pData;
    JNI_CHECK_PEER_RETURN(self);

/* REMIND
#ifdef DEBUG
    if (group != NULL) {
        DASSERT(IsInstanceOf((HObject*)group, "java/awt/CheckboxGroup"));
    }
#endif
*/
    AwtComponent* c = (AwtComponent*)JNI_GET_PDATA(self);
    c->SendMessage(BM_SETSTYLE, (WPARAM)BS_OWNERDRAW, (LPARAM)TRUE);
    c->VerifyState();

    CATCH_BAD_ALLOC;
}