void
AwtChoice::VerifyState()
{
    if ( AwtToolkit::GetInstance().VerifyComponents() == FALSE ) {
        return;
    }

    if ( m_callbacksEnabled == FALSE ) {
        // Component is not fully setup yet.
        return;
    }

    AwtComponent::VerifyState();

    // Compare number of items.

    JNIEnv *env;
    if ( JVM->AttachCurrentThread( (void **)&env, 0 ) != 0 ) {
        return;
    }
    jobject target = GetTarget();

    int nTargetItems = env->CallIntMethod( target,
                                           WCachedIDs.java_awt_Choice_getItemCountMID );
    int nPeerItems = (int)::SendMessage( GetHWnd(), CB_GETCOUNT, 0, 0 );
    ASSERT( nTargetItems == nPeerItems );

    // Compare selection
    int targetIndex = env->CallIntMethod( target,
                                          WCachedIDs.java_awt_Choice_getSelectedIndexMID );
    ASSERT( !env->ExceptionCheck() );
    int peerCurSel = (int)::SendMessage( GetHWnd(), CB_GETCURSEL, 0, 0 );
    ASSERT( targetIndex == peerCurSel );
    return;
}
void AwtCheckbox::VerifyState()
{
    if (AwtToolkit::GetInstance().VerifyComponents() == FALSE) {
        return;
    }

    if (m_callbacksEnabled == FALSE) {
        // Component is not fully setup yet.
        return;
    }

    AwtComponent::VerifyState();

    // prehaps we don't need this?
    //jobject hTarget = GetTarget();
    //jobject target = unhand(hTarget);
    jobject target = GetTarget();

    // Check button style
    DWORD style = ::GetWindowLong(GetHWnd(), GWL_STYLE);
    ASSERT(style & BS_OWNERDRAW);

    // Check label
    int len = ::GetWindowTextLength(GetHWnd());
    TCHAR* peerStr = new TCHAR[len+1];
    GetText(peerStr, len+1);
/* FIXME */
#ifndef UNICODE
    //ASSERT(strcmp(peerStr, JavaStringBuffer(target->label)) == 0);
#else
    //ASSERT(wcscmp(peerStr, JavaStringBuffer(target->label)) == 0);
#endif /* UNICODE */
}
示例#3
0
// This function goes through all strings in the list to find the width,
// in pixels, of the longest string in the list.
void AwtList::UpdateMaxItemWidth()
{
    m_nMaxWidth = 0;

    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    if (env->EnsureLocalCapacity(2) < 0)
        return;

    HDC hDC = ::GetDC(GetHWnd());

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

    /* target is java.awt.List */
    jobject target = env->GetObjectField(self, AwtObject::targetID);
    jobject font = GET_FONT(target, self);

    int nCount = GetCount();
    for ( int i=0; i < nCount; i++ )
    {
        jstring jstr = GetItemString( env, target, i );
        SIZE size = AwtFont::getMFStringSize( hDC, font, jstr );
        if ( size.cx > m_nMaxWidth )
            m_nMaxWidth = size.cx;
        env->DeleteLocalRef( jstr );
    }

    // free up the shared DC and release local refs
    ::ReleaseDC(GetHWnd(), hDC);
    env->DeleteLocalRef( target );
    env->DeleteLocalRef( font );

    // Now adjust the horizontal scrollbar extent
    AdjustHorizontalScrollbar();
}
示例#4
0
MsgRouting AwtCanvas::HandleEvent(MSG *msg, BOOL synthetic)
{
    if (msg->message == WM_LBUTTONDOWN || msg->message == WM_LBUTTONDBLCLK) {
        /*
         * Fix for BugTraq ID 4041703: keyDown not being invoked.
         * Give the focus to a Canvas or Panel if it doesn't have heavyweight
         * subcomponents so that they will behave the same way as on Solaris
         * providing a possibility of giving keyboard focus to an empty Applet.
         * Since ScrollPane doesn't receive focus on mouse press on Solaris,
         * HandleEvent() is overriden there to do nothing with focus.
         */
        if (AwtComponent::sm_focusOwner != GetHWnd() &&
            ::GetWindow(GetHWnd(), GW_CHILD) == NULL)
        {
            JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
            jobject target = GetTarget(env);
            env->CallStaticVoidMethod
                (AwtKeyboardFocusManager::keyboardFocusManagerCls,
                 AwtKeyboardFocusManager::heavyweightButtonDownMID,
                 target, ((jlong)msg->time) & 0xFFFFFFFF);
            env->DeleteLocalRef(target);
            AwtSetFocus();
        }
    }
    return AwtComponent::HandleEvent(msg, synthetic);
}
void AwtChoice::SetFont(AwtFont* font)
{
    AwtComponent::SetFont(font);

    //Get the text metrics and change the height of each item.
    HDC hDC = ::GetDC(GetHWnd());
    DASSERT(hDC != NULL);
    TEXTMETRIC tm;
        
    HANDLE hFont = font->GetHFont();
    VERIFY(::SelectObject(hDC, hFont) != NULL);
    VERIFY(::GetTextMetrics(hDC, &tm));
    long h = tm.tmHeight + tm.tmExternalLeading;
    VERIFY(::ReleaseDC(GetHWnd(), hDC) != 0);

    int nCount = (int)::SendMessage(GetHWnd(), CB_GETCOUNT, 0, 0);
    for(int i = 0; i < nCount; ++i) {
        VERIFY(::SendMessage(GetHWnd(), CB_SETITEMHEIGHT, i, MAKELPARAM(h, 0)) != CB_ERR);
    }
    //Change the height of the Edit Box.
    VERIFY(::SendMessage(GetHWnd(), CB_SETITEMHEIGHT, (UINT)-1,
                         MAKELPARAM(h, 0)) != CB_ERR);

    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    jobject target = GetTarget(env);
    jint height = env->GetIntField(target, AwtComponent::heightID);

    Reshape(env->GetIntField(target, AwtComponent::xID),
            env->GetIntField(target, AwtComponent::yID),
            env->GetIntField(target, AwtComponent::widthID), 
            h);

    env->DeleteLocalRef(target);
}
void AwtScrollPane::SetInsets(JNIEnv *env)
{
    RECT outside;
    RECT inside;
    ::GetWindowRect(GetHWnd(), &outside);
    ::GetClientRect(GetHWnd(), &inside);
    ::MapWindowPoints(GetHWnd(), 0, (LPPOINT)&inside, 2);

    if (env->EnsureLocalCapacity(1) < 0) {
        return;
    }
    jobject insets =
      (env)->GetObjectField(GetPeer(env), AwtPanel::insets_ID);

    DASSERT(!safe_ExceptionOccurred(env));

    if (insets != NULL && (inside.top-outside.top) != 0) {
        (env)->SetIntField(insets, AwtInsets::topID, inside.top - outside.top);
        (env)->SetIntField(insets, AwtInsets::leftID, inside.left - outside.left);
        (env)->SetIntField(insets, AwtInsets::bottomID, outside.bottom - inside.bottom);
        (env)->SetIntField(insets, AwtInsets::rightID, outside.right - inside.right);
    }

    env->DeleteLocalRef(insets);
}
// calculate height of drop-down list part of the combobox
// to show all the items up to a maximum of eight
int AwtChoice::GetDropDownHeight()
{
    int itemHeight =(int)::SendMessage(GetHWnd(), CB_GETITEMHEIGHT, (UINT)0,0);
    int numItemsToShow = (int)::SendMessage(GetHWnd(), CB_GETCOUNT, 0,0);
    numItemsToShow = numItemsToShow > 8 ? 8 : numItemsToShow;
    // drop-down height snaps to nearest line, so add a
    // fudge factor of 1/2 line to ensure last line shows
    return itemHeight*numItemsToShow + itemHeight/2;
}
示例#8
0
void AwtLabel::Enable(BOOL bEnable)
{
    ::EnableWindow(GetHWnd(), bEnable);
    // Fix for Bug #4038881 Labels don't enable and disable properly
    // Fix for Bug #4096745 disable()/enable() make AWT components blink
    // This fix is moved from awt_Component.cpp for Bug #4096745
    ::InvalidateRect(GetHWnd(), NULL, FALSE);
    CriticalSection::Lock l(GetLock());
    VerifyState();
}
// Recalculate and set the drop-down height for the Choice.
void AwtChoice::ResetDropDownHeight()
{
    RECT    rcWindow;

    ::GetWindowRect(GetHWnd(), &rcWindow);
    // resize the drop down to accomodate added/removed items
    int	    totalHeight = GetTotalHeight();
    ::SetWindowPos(GetHWnd(), NULL,
		    0, 0, rcWindow.right - rcWindow.left, totalHeight,
		    SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
}
示例#10
0
void Input::Initalize()
{
	if( pInput == NULL ) {
		HRESULT hr = DirectInput8Create(
			GetHInstace(),
			DIRECTINPUT_VERSION,
			IID_IDirectInput8,
			( LPVOID* )&pInput,
			NULL );

		if( FAILED( hr ) ) {
			CautionMessage( _T( "errorz" ), _T( "DirectInputの初期化に失敗しました" ) );
			return;
		}

		hr = pInput->CreateDevice(
			GUID_SysKeyboard,
			&pKeyDevice,
			NULL );

		if( FAILED( hr ) ) {
			CautionMessage( _T( "errorz" ), _T( "DirectInputDeviceの初期化に失敗しました" ) );
			return;
		}

		pKeyDevice->SetDataFormat( &c_dfDIKeyboard );
		pKeyDevice->SetCooperativeLevel( GetHWnd(),
			DISCL_FOREGROUND | DISCL_NONEXCLUSIVE );

		ZeroMemory( keydata, sizeof( BYTE ) * 256 );
		ZeroMemory( lastkeydata, sizeof( BYTE ) * 256 );

		enumdata ed;
		ed.pInput = pInput;
		ed.ppPadDevice = &pPadDevice;

		pInput->EnumDevices(
			DI8DEVCLASS_GAMECTRL,
			EnumJoyPad,
			&ed,
			DIEDFL_ATTACHEDONLY );

		if( pPadDevice ) {

			pPadDevice->EnumObjects( EnumObject, pPadDevice, DIDFT_AXIS );

			pPadDevice->SetCooperativeLevel( GetHWnd(),
				DISCL_FOREGROUND | DISCL_NONEXCLUSIVE );

			hr = pPadDevice->SetDataFormat( &c_dfDIJoystick2 );
			if( FAILED( hr ) ) { RELEASE( pPadDevice ); }
		}
	}
}
示例#11
0
void AwtChoice::Reshape(int x, int y, int w, int h)
{
    // Choice component height is fixed (when rolled up)
    // so vertically center the choice in it's bounding box
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    jobject target = GetTarget(env);
    jobject parent = env->GetObjectField(target, AwtComponent::parentID);
    RECT rc;

    int fieldHeight = GetFieldHeight();
    if ((parent != NULL && env->GetObjectField(parent, AwtContainer::layoutMgrID) != NULL) &&
            fieldHeight > 0 && fieldHeight < h) {
        y += (h - fieldHeight) / 2;
    }

    /* Fix for 4783342
     * Choice should ignore reshape on height changes,
     * as height is dependent on Font size only.
     */
    AwtComponent* awtParent = GetParent();
    BOOL bReshape = true;
    if (awtParent != NULL) {
        ::GetWindowRect(GetHWnd(), &rc);
        int oldW = rc.right - rc.left;
        RECT parentRc;
        ::GetWindowRect(awtParent->GetHWnd(), &parentRc);
        int oldX = rc.left - parentRc.left;
        int oldY = rc.top - parentRc.top;
        bReshape = (x != oldX || y != oldY || w != oldW);
    }

    if (bReshape)
    {
        int totalHeight = GetTotalHeight();
        AwtComponent::Reshape(x, y, w, totalHeight);
    }

    /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
     * actual size
     * Fix: Set the Choice to its actual size in the component.
     */
    ::GetClientRect(GetHWnd(), &rc);
    env->SetIntField(target, AwtComponent::widthID,  (jint)rc.right);
    env->SetIntField(target, AwtComponent::heightID, (jint)rc.bottom);

    env->DeleteLocalRef(target);
    env->DeleteLocalRef(parent);
}
MsgRouting
AwtScrollbar::HandleEvent(MSG *msg, BOOL synthetic)
{
    if (msg->message == WM_LBUTTONDOWN || msg->message == WM_LBUTTONDBLCLK) {
        if (IsFocusable() && AwtComponent::sm_focusOwner != GetHWnd()) {
            JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
            jobject target = GetTarget(env);
            env->CallStaticVoidMethod
                (AwtKeyboardFocusManager::keyboardFocusManagerCls,
                 AwtKeyboardFocusManager::heavyweightButtonDownMID,
                 target, ((jlong)msg->time) & 0xFFFFFFFF);
            env->DeleteLocalRef(target);
            AwtSetFocus();
        }
	// Left button press was already routed to default window
	// procedure in the WmMouseDown above.  Propagating synthetic
	// press seems like a bad idea as internal message loop
	// doesn't know how to unwrap synthetic release.
	delete msg;
	return mrConsume;
    }
    else {
	return AwtComponent::HandleEvent(msg, synthetic);
    }
}
void AwtScrollPane::SetScrollInfo(int orient, int max, int page, 
                                  BOOL disableNoScroll)
{
    DTRACE_PRINTLN4("AwtScrollPane::SetScrollInfo %d, %d, %d, %d", orient, max, page, disableNoScroll);
    SCROLLINFO si;
    int posBefore;
    int posAfter;
    
    posBefore = GetScrollPos(orient);
    si.cbSize = sizeof(SCROLLINFO);
    si.nMin = 0;
    si.nMax = max;
    si.fMask = SIF_RANGE;
    if (disableNoScroll) {
        si.fMask |= SIF_DISABLENOSCROLL;
    }
    if (page > 0) {
        si.fMask |= SIF_PAGE;
        si.nPage = page;
    }
    ::SetScrollInfo(GetHWnd(), orient, &si, TRUE);
    // scroll position may have changed when thumb is at the end of the bar
    // and the page size changes
    posAfter = GetScrollPos(orient);
    if (posBefore != posAfter) {
	PostScrollEvent(orient, SB_THUMBPOSITION, posAfter);
    }
}
示例#14
0
	void SPWindow::SetTitle( SPString title )
	{
		modificationLock.Lock();
		SetWindowText(GetHWnd(), title.c_str());
		this->title = title;
		modificationLock.Unlock();
	}
示例#15
0
void AwtChoice::Reshape(int x, int y, int w, int h)
{
    // Choice component height is fixed (when rolled up)
    // so vertically center the choice in it's bounding box
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    jobject target = GetTarget(env);
    jobject parent = env->GetObjectField(target, AwtComponent::parentID);
    RECT rc;

    int fieldHeight = GetFieldHeight();
    if ((parent != NULL && env->GetObjectField(parent, AwtContainer::layoutMgrID) != NULL) &&
        fieldHeight > 0 && fieldHeight < h) {
        y += (h - fieldHeight) / 2;
    }

    int totalHeight = GetTotalHeight();
    AwtComponent::Reshape(x, y, w, totalHeight);

    /* Bug 4255631 Solaris: Size returned by Choice.getSize() does not match
     * actual size
     * Fix: Set the Choice to its actual size in the component.
     */
    ::GetClientRect(GetHWnd(), &rc);
    env->SetIntField(target, AwtComponent::widthID,  (jint)rc.right);
    env->SetIntField(target, AwtComponent::heightID, (jint)rc.bottom);

    env->DeleteLocalRef(target);
    env->DeleteLocalRef(parent);
}
/* Set a suitable font to IME against the component font. */
void AwtTextComponent::SetFont(AwtFont* font)
{
    DASSERT(font != NULL);
    if (font->GetAscent() < 0) {
        AwtFont::SetupAscent(font);
    }

    int index = font->GetInputHFontIndex();
    if (index < 0)
        /* In this case, user cannot get any suitable font for input. */
        index = 0;

    //im --- changed for over the spot composing
    m_hFont = font->GetHFont(index);
    SendMessage(WM_SETFONT, (WPARAM)m_hFont, MAKELPARAM(FALSE, 0));
    SendMessage(EM_SETMARGINS, EC_LEFTMARGIN | EC_RIGHTMARGIN,
                MAKELPARAM(1, 1));

    /*
     * WM_SETFONT reverts foreground color to the default for
     * rich edit controls. So we have to restore it manually.
     */
    SetColor(GetColor());
    VERIFY(::InvalidateRect(GetHWnd(), NULL, TRUE));
    //im --- end

}
示例#17
0
/* Fix for Bug 4509045: should release capture only if it is set by SetDragCapture */
void AwtChoice::ReleaseDragCapture(UINT flags)
{
    if ((::GetCapture() == GetHWnd()) && ((flags & ALL_MK_BUTTONS) == 0) && mouseCapture) {
        ::ReleaseCapture();
        mouseCapture = FALSE;
    }
}
示例#18
0
void AwtLabel::LazyPaint()
{
    if (m_callbacksEnabled && m_needPaint ) {
        ::InvalidateRect(GetHWnd(), NULL, TRUE);
        m_needPaint = FALSE;
    }
}
示例#19
0
LRESULT
AwtScrollbar::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    // Delegate real work to super
    LRESULT retValue = AwtComponent::WindowProc(message, wParam, lParam);

    // After-hooks for workarounds
    switch (message) {

      // Work around a windows bug described in KB article Q73839.
      // Need to update focus indicator on scrollbar if thumb
      // proportion or thumb position was changed.

      case WM_SIZE:
      case SBM_SETSCROLLINFO:
      case SBM_SETRANGE:
      case SBM_SETRANGEREDRAW:
          if (AwtComponent::sm_focusOwner == GetHWnd()) {
              UpdateFocusIndicator();
          }
          break;
    }

    return retValue;
}
示例#20
0
void AwtTextField::EditSetSel(CHARRANGE &cr) {
    SendMessage(EM_EXSETSEL, 0, reinterpret_cast<LPARAM>(&cr));

    // 6417581: force expected drawing
    if (IS_WINVISTA && cr.cpMin == cr.cpMax) {
        ::InvalidateRect(GetHWnd(), NULL, TRUE);
    }

}
示例#21
0
LRESULT AwtTextField::WindowProc(UINT message, WPARAM wParam, LPARAM lParam)
{
    if (message == WM_UNDO || message == EM_UNDO || message == EM_CANUNDO) {
        if (GetWindowLong(GetHWnd(), GWL_STYLE) & ES_READONLY) {
            return FALSE;
        }
    }
    return AwtTextComponent::WindowProc(message, wParam, lParam);
}
int AwtScrollPane::GetScrollPos(int orient)
{
    SCROLLINFO si;
    ZeroMemory(&si, sizeof(si));
    si.cbSize = sizeof(si);
    si.fMask = SIF_POS;
    ::GetScrollInfo(GetHWnd(), orient, &si);
    return si.nPos;
}
void AwtScrollPane::VerifyState()
{
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
    if (env->EnsureLocalCapacity(3) < 0) {
        return;
    }

    if (AwtToolkit::GetInstance().VerifyComponents() == FALSE) {
        return;
    }

    if (m_callbacksEnabled == FALSE) {
        /* Component is not fully setup yet. */
        return;
    }

    AwtComponent::VerifyState();

    jobject target = AwtObject::GetTarget(env);
    jobject child = JNU_CallMethodByName(env, NULL, GetPeer(env),
                                         "getScrollSchild",
                                         "()Ljava/awt/Component;").l;

    DASSERT(!safe_ExceptionOccurred(env));

    if (child != NULL) {
        jobject childPeer =
            (env)->GetObjectField(child, AwtComponent::peerID);
        PDATA pData;
        JNI_CHECK_PEER_RETURN(childPeer);
        AwtComponent* awtChild = (AwtComponent *)pData;

        /* Verify child window is positioned correctly. */
        RECT rect, childRect;
        ::GetClientRect(GetHWnd(), &rect);
        ::MapWindowPoints(GetHWnd(), 0, (LPPOINT)&rect, 2);
        ::GetWindowRect(awtChild->GetHWnd(), &childRect);
        DASSERT(childRect.left <= rect.left && childRect.top <= rect.top);

        env->DeleteLocalRef(childPeer);
    }
    env->DeleteLocalRef(target);
    env->DeleteLocalRef(child);
}
void AwtScrollPane::SetScrollPos(int orient, int pos) 
{
    SCROLLINFO si;
     
    ZeroMemory(&si, sizeof(si));
    si.fMask = SIF_POS;
    si.cbSize = sizeof(si);
    si.nPos = pos;
    ::SetScrollInfo(GetHWnd(), orient, &si, TRUE);
}
示例#25
0
/* Fix for the bug 4327666: set the capture for middle
   and right mouse buttons, but leave left button alone */
void AwtChoice::SetDragCapture(UINT flags)
{
    if ((flags & MK_LBUTTON) != 0) {
        if ((::GetCapture() == GetHWnd()) && mouseCapture) {     
            /* On MK_LBUTTON ComboBox captures mouse itself 
               so we should release capture and clear flag to
               prevent releasing capture by ReleaseDragCapture 
             */
            ::ReleaseCapture();
            mouseCapture = FALSE;
        }
        return;
    } 
    // don't want to interfere with other controls
    if (::GetCapture() == NULL) {
        ::SetCapture(GetHWnd());
        mouseCapture = TRUE;
    }
}
// Recalculate and set the drop-down height for the Choice.
void
AwtChoice::ResetDropDownHeight()
{
    JNIEnv *env;
    if ( JVM->AttachCurrentThread( (void **)&env, 0 ) != 0 ) {
        return;
    }
    jobject target = env->GetObjectField( GetPeer(),
                                          WCachedIDs.PPCObjectPeer_targetFID );
    CHECK_NULL( target, "null target" );
    RECT rcWindow;

    ::GetWindowRect( GetHWnd(), &rcWindow );
    // resize the drop down to accomodate added/removed items
    ::SetWindowPos( GetHWnd(), NULL,
                    0, 0, rcWindow.right - rcWindow.left, GetTotalHeight(),
                    SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER );
    return;
}
示例#27
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_CENTER:
              x = (r.left + r.right - size.cx) / 2;
              break;
          case java_awt_Label_RIGHT:
              x = r.right - 2 - size.cx;
              break;
          case java_awt_Label_LEFT:
          default:
              x = r.left + 2;
              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);
    }
}
示例#28
0
void AwtCheckbox::VerifyState()
{
    if (AwtToolkit::GetInstance().VerifyComponents() == FALSE) {
        return;
    }

    if (m_callbacksEnabled == FALSE) {
        /*  Component is not fully setup yet. */
        return;
    }

    AwtComponent::VerifyState();
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);

    if (env->EnsureLocalCapacity(2) < 0) {
        return;
    }

    jobject target = GetTarget(env);

    /*  Check button style */
    DWORD style = ::GetWindowLong(GetHWnd(), GWL_STYLE);
    DASSERT(style & BS_OWNERDRAW);

    /*  Check label */
    int len = ::GetWindowTextLength(GetHWnd());
    LPTSTR peerStr;
    try {
        peerStr = new TCHAR[len+1];
    } catch (std::bad_alloc&) {
        env->DeleteLocalRef(target);
        throw;
    }

    GetText(peerStr, len+1);
    jstring label = (jstring)env->GetObjectField(target, AwtCheckbox::labelID);
    DASSERT(_tcscmp(peerStr, JavaStringBuffer(env, label)) == 0);
    delete [] peerStr;

    env->DeleteLocalRef(target);
    env->DeleteLocalRef(label);
}
示例#29
0
// get the height of the field portion of the combobox
int AwtChoice::GetFieldHeight()
{
    int fieldHeight;
    int borderHeight;
    fieldHeight =(int)::SendMessage(GetHWnd(), CB_GETITEMHEIGHT, (UINT)-1, 0);
    // add top and bottom border lines; border size is different for
    // Win 4.x (3d edge) vs 3.x (1 pixel line)
    borderHeight = ::GetSystemMetrics(IS_WIN4X ? SM_CYEDGE : SM_CYBORDER);
    fieldHeight += borderHeight*2;
    return fieldHeight;
}
示例#30
0
MsgRouting AwtLabel::WmPaint(HDC)
{
    PAINTSTRUCT ps;
    HDC hDC = ::BeginPaint(GetHWnd(), &ps);/* the passed-in HDC is ignored. */
    DASSERT(hDC);
    
    /* fix for 4408606 - incorrect color palette used in 256 color mode */
    
    int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
    AwtWin32GraphicsDevice::SelectPalette(hDC, screen);
    
    RECT& r = ps.rcPaint;
    if (!m_callbacksEnabled) {
        m_needPaint = TRUE;
    } else {
        DoPaint(hDC, r);
    }
    VERIFY(::EndPaint(GetHWnd(), &ps));
    return mrConsume;
}