946 wp.rcNormalPosition.left = x;
947 wp.rcNormalPosition.top = y;
948 wp.rcNormalPosition.right = x + w;
949 wp.rcNormalPosition.bottom = y + h;
950 if ( flags & SWP_NOACTIVATE ) {
951 wp.showCmd = SW_SHOWNOACTIVATE;
952 }
953 ::SetWindowPlacement(wnd, &wp);
954 return 1;
955 }
956
957
958 void AwtComponent::Reshape(int x, int y, int w, int h)
959 {
960 #if defined(DEBUG)
961 RECT rc;
962 ::GetWindowRect(GetHWnd(), &rc);
963 ::MapWindowPoints(HWND_DESKTOP, ::GetParent(GetHWnd()), (LPPOINT)&rc, 2);
964 DTRACE_PRINTLN4("AwtComponent::Reshape from %d, %d, %d, %d", rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
965 #endif
966 AwtWindow* container = GetContainer();
967 AwtComponent* parent = GetParent();
968 if (container != NULL && container == parent) {
969 container->SubtractInsetPoint(x, y);
970 }
971 DTRACE_PRINTLN4("AwtComponent::Reshape to %d, %d, %d, %d", x, y, w, h);
972 UINT flags = SWP_NOACTIVATE | SWP_NOZORDER;
973
974 RECT r;
975
976 ::GetWindowRect(GetHWnd(), &r);
977 // if the component size is changing , don't copy window bits
978 if (r.right - r.left != w || r.bottom - r.top != h) {
979 flags |= SWP_NOCOPYBITS;
980 }
981
982 if (parent && _tcscmp(parent->GetClassName(), TEXT("SunAwtScrollPane")) == 0) {
983 if (x > 0) {
984 x = 0;
985 }
2195 * Updating rects are divided into mostly vertical and mostly horizontal
2196 * Each group is united together and if not empty painted separately
2197 */
2198 RECT* r = (RECT*)(buffer + rgndata->rdh.dwSize);
2199 RECT* un[2] = {0, 0};
2200 DWORD i;
2201 for (i = 0; i < rgndata->rdh.nCount; i++, r++) {
2202 int width = r->right-r->left;
2203 int height = r->bottom-r->top;
2204 if (width > 0 && height > 0) {
2205 int toAdd = (width > height) ? 0: 1;
2206 if (un[toAdd] != 0) {
2207 ::UnionRect(un[toAdd], un[toAdd], r);
2208 } else {
2209 un[toAdd] = r;
2210 }
2211 }
2212 }
2213 for(i = 0; i < 2; i++) {
2214 if (un[i] != 0) {
2215 DoCallback("handleExpose", "(IIII)V", un[i]->left, un[i]->top,
2216 un[i]->right-un[i]->left, un[i]->bottom-un[i]->top);
2217 }
2218 }
2219 delete [] buffer;
2220 }
2221 ::DeleteObject((HGDIOBJ)rgn);
2222 }
2223
2224 MsgRouting AwtComponent::WmMouseEnter(UINT flags, int x, int y)
2225 {
2226 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_ENTERED,
2227 ::JVM_CurrentTimeMillis(NULL, 0), x, y, GetJavaModifiers(), 0, JNI_FALSE);
2228 if ((flags & ALL_MK_BUTTONS) == 0) {
2229 AwtCursor::UpdateCursor(this);
2230 }
2231 sm_cursorOn = GetHWnd();
2232 return mrConsume; /* Don't pass our synthetic event on! */
2233 }
2234
2235 MSG*
2236 AwtComponent::CreateMessage(UINT message, WPARAM wParam, LPARAM lParam,
4591 {
4592 RECT eraseR = { 0, 0, size.cx, size.cy };
4593 VERIFY(::FillRect(hMemoryDC, &eraseR, GetBackgroundBrush()));
4594 }
4595
4596 void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
4597 {
4598 if (!bitmapBits) {
4599 return;
4600 }
4601
4602 DWORD* dest = (DWORD*)bitmapBits;
4603 //XXX: might be optimized to use one loop (cy*cx -> 0)
4604 for (int i = 0; i < size.cy; i++ ) {
4605 for (int j = 0; j < size.cx; j++ ) {
4606 ((BYTE*)(dest++))[3] = alpha;
4607 }
4608 }
4609 }
4610
4611 jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) {
4612 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
4613
4614 if (!::IsWindowVisible(GetHWnd())) {
4615 return NULL;
4616 }
4617
4618 HDC hdc = GetDCFromComponent();
4619 if (!hdc) {
4620 return NULL;
4621 }
4622 HDC hMemoryDC = ::CreateCompatibleDC(hdc);
4623 void *bitmapBits = NULL;
4624 HBITMAP hBitmap = BitmapUtil::CreateARGBBitmap(size.cx, size.cy, &bitmapBits);
4625 HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemoryDC, hBitmap);
4626 SendMessage(WM_AWT_RELEASEDC, (WPARAM)hdc);
4627
4628 FillBackground(hMemoryDC, size);
4629
4630 VERIFY(::SetWindowOrgEx(hMemoryDC, loc.cx, loc.cy, NULL));
4884 GetInsets(&insets);
4885
4886 static jmethodID mouseEventConst;
4887 if (mouseEventConst == NULL) {
4888 mouseEventConst =
4889 env->GetMethodID(mouseEventCls, "<init>",
4890 "(Ljava/awt/Component;IJIIIIIIZI)V");
4891 DASSERT(mouseEventConst);
4892 CHECK_NULL(mouseEventConst);
4893 }
4894 if (env->EnsureLocalCapacity(2) < 0) {
4895 return;
4896 }
4897 jobject target = GetTarget(env);
4898 DWORD curMousePos = ::GetMessagePos();
4899 int xAbs = GET_X_LPARAM(curMousePos);
4900 int yAbs = GET_Y_LPARAM(curMousePos);
4901 jobject mouseEvent = env->NewObject(mouseEventCls, mouseEventConst,
4902 target,
4903 id, when, modifiers,
4904 x+insets.left, y+insets.top,
4905 xAbs, yAbs,
4906 clickCount, popupTrigger, button);
4907
4908 if (safe_ExceptionOccurred(env)) {
4909 env->ExceptionDescribe();
4910 env->ExceptionClear();
4911 }
4912
4913 DASSERT(mouseEvent != NULL);
4914 CHECK_NULL(mouseEvent);
4915 if (pMsg != 0) {
4916 AwtAWTEvent::saveMSG(env, pMsg, mouseEvent);
4917 }
4918 SendEvent(mouseEvent);
4919
4920 env->DeleteLocalRef(mouseEvent);
4921 env->DeleteLocalRef(target);
4922 }
4923
4924 void
4925 AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y,
4952 mouseWheelEventConst =
4953 env->GetMethodID(mouseWheelEventCls, "<init>",
4954 "(Ljava/awt/Component;IJIIIIIIZIIID)V");
4955 DASSERT(mouseWheelEventConst);
4956 CHECK_NULL(mouseWheelEventConst);
4957 }
4958 if (env->EnsureLocalCapacity(2) < 0) {
4959 return;
4960 }
4961 jobject target = GetTarget(env);
4962 DWORD curMousePos = ::GetMessagePos();
4963 int xAbs = GET_X_LPARAM(curMousePos);
4964 int yAbs = GET_Y_LPARAM(curMousePos);
4965
4966 DTRACE_PRINTLN("creating MWE in JNI");
4967
4968 jobject mouseWheelEvent = env->NewObject(mouseWheelEventCls,
4969 mouseWheelEventConst,
4970 target,
4971 id, when, modifiers,
4972 x+insets.left, y+insets.top,
4973 xAbs, yAbs,
4974 clickCount, popupTrigger,
4975 scrollType, scrollAmount,
4976 roundedWheelRotation, preciseWheelRotation);
4977
4978 DASSERT(mouseWheelEvent != NULL);
4979 if (mouseWheelEvent == NULL || safe_ExceptionOccurred(env)) {
4980 env->ExceptionDescribe();
4981 env->ExceptionClear();
4982 env->DeleteLocalRef(target);
4983 return;
4984 }
4985 if (pMsg != NULL) {
4986 AwtAWTEvent::saveMSG(env, pMsg, mouseWheelEvent);
4987 }
4988 SendEvent(mouseWheelEvent);
4989
4990 env->DeleteLocalRef(mouseWheelEvent);
4991 env->DeleteLocalRef(target);
4992 }
4993
5459 env->DeleteGlobalRef(self);
5460 }
5461
5462 jobject AwtComponent::_GetLocationOnScreen(void *param)
5463 {
5464 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
5465
5466 jobject self = (jobject)param;
5467
5468 jobject result = NULL;
5469 AwtComponent *p;
5470
5471 PDATA pData;
5472 JNI_CHECK_PEER_GOTO(self, ret);
5473 p = (AwtComponent *)pData;
5474 if (::IsWindow(p->GetHWnd()))
5475 {
5476 RECT rect;
5477 VERIFY(::GetWindowRect(p->GetHWnd(),&rect));
5478 result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
5479 rect.left, rect.top);
5480 }
5481 ret:
5482 env->DeleteGlobalRef(self);
5483
5484 if (result != NULL)
5485 {
5486 jobject resultGlobalRef = env->NewGlobalRef(result);
5487 env->DeleteLocalRef(result);
5488 return resultGlobalRef;
5489 }
5490 else
5491 {
5492 return NULL;
5493 }
5494 }
5495
5496 void AwtComponent::_Reshape(void *param)
5497 {
5498 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
5499
7047 /* If this component has insets, factor them in, but ignore
7048 * top-level windows.
7049 */
7050 jobject parent2 = env->GetObjectField(parent, AwtComponent::parentID);
7051 if (parent2 != NULL) {
7052 jobject peer = GetPeerForTarget(env, parent);
7053 if (peer != NULL &&
7054 JNU_IsInstanceOfByName(env, peer,
7055 "sun/awt/windows/WPanelPeer") > 0) {
7056 jobject insets =
7057 JNU_CallMethodByName(env, NULL, peer,"insets",
7058 "()Ljava/awt/Insets;").l;
7059 x += (env)->GetIntField(insets, AwtInsets::leftID);
7060 y += (env)->GetIntField(insets, AwtInsets::topID);
7061 }
7062 }
7063 env->DeleteLocalRef(target);
7064 target = parent;
7065 }
7066
7067 // Test whether component's bounds match the native window's
7068 RECT rect;
7069 VERIFY(::GetWindowRect(GetHWnd(), &rect));
7070 #if 0
7071 DASSERT( (x == rect.left) &&
7072 (y == rect.top) &&
7073 (width == (rect.right-rect.left)) &&
7074 (height == (rect.bottom-rect.top)) );
7075 #else
7076 BOOL fSizeValid = ( (x == rect.left) &&
7077 (y == rect.top) &&
7078 (width == (rect.right-rect.left)) &&
7079 (height == (rect.bottom-rect.top)) );
7080 #endif
7081
7082 // See if visible state matches
7083 BOOL wndVisible = ::IsWindowVisible(GetHWnd());
7084 jboolean targetVisible;
7085 // To avoid possibly running client code on the toolkit thread, don't
7086 // do the following check if we're running on the toolkit thread.
7240 if ((removedDC = activeDCList.RemoveDC(hDC)) != NULL) {
7241 passiveDCList.AddDCItem(removedDC);
7242 }
7243 }
7244
7245 void ReleaseDCList(HWND hwnd, DCList &list) {
7246 DCItem *removedDCs = list.RemoveAllDCs(hwnd);
7247 while (removedDCs) {
7248 DCItem *tmpDCList = removedDCs;
7249 DASSERT(::GetObjectType(tmpDCList->hDC) == OBJ_DC);
7250 int retValue = ::ReleaseDC(tmpDCList->hWnd, tmpDCList->hDC);
7251 VERIFY(retValue != 0);
7252 if (retValue != 0) {
7253 // Valid ReleaseDC call; need to decrement GDI object counter
7254 AwtGDIObject::Decrement();
7255 }
7256 removedDCs = removedDCs->next;
7257 delete tmpDCList;
7258 }
7259 }
7260
|
946 wp.rcNormalPosition.left = x;
947 wp.rcNormalPosition.top = y;
948 wp.rcNormalPosition.right = x + w;
949 wp.rcNormalPosition.bottom = y + h;
950 if ( flags & SWP_NOACTIVATE ) {
951 wp.showCmd = SW_SHOWNOACTIVATE;
952 }
953 ::SetWindowPlacement(wnd, &wp);
954 return 1;
955 }
956
957
958 void AwtComponent::Reshape(int x, int y, int w, int h)
959 {
960 #if defined(DEBUG)
961 RECT rc;
962 ::GetWindowRect(GetHWnd(), &rc);
963 ::MapWindowPoints(HWND_DESKTOP, ::GetParent(GetHWnd()), (LPPOINT)&rc, 2);
964 DTRACE_PRINTLN4("AwtComponent::Reshape from %d, %d, %d, %d", rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top);
965 #endif
966
967 x = ScaleUpX(x);
968 y = ScaleUpY(y);
969 w = ScaleUpX(w);
970 h = ScaleUpY(h);
971
972 AwtWindow* container = GetContainer();
973 AwtComponent* parent = GetParent();
974 if (container != NULL && container == parent) {
975 container->SubtractInsetPoint(x, y);
976 }
977 DTRACE_PRINTLN4("AwtComponent::Reshape to %d, %d, %d, %d", x, y, w, h);
978 UINT flags = SWP_NOACTIVATE | SWP_NOZORDER;
979
980 RECT r;
981
982 ::GetWindowRect(GetHWnd(), &r);
983 // if the component size is changing , don't copy window bits
984 if (r.right - r.left != w || r.bottom - r.top != h) {
985 flags |= SWP_NOCOPYBITS;
986 }
987
988 if (parent && _tcscmp(parent->GetClassName(), TEXT("SunAwtScrollPane")) == 0) {
989 if (x > 0) {
990 x = 0;
991 }
2201 * Updating rects are divided into mostly vertical and mostly horizontal
2202 * Each group is united together and if not empty painted separately
2203 */
2204 RECT* r = (RECT*)(buffer + rgndata->rdh.dwSize);
2205 RECT* un[2] = {0, 0};
2206 DWORD i;
2207 for (i = 0; i < rgndata->rdh.nCount; i++, r++) {
2208 int width = r->right-r->left;
2209 int height = r->bottom-r->top;
2210 if (width > 0 && height > 0) {
2211 int toAdd = (width > height) ? 0: 1;
2212 if (un[toAdd] != 0) {
2213 ::UnionRect(un[toAdd], un[toAdd], r);
2214 } else {
2215 un[toAdd] = r;
2216 }
2217 }
2218 }
2219 for(i = 0; i < 2; i++) {
2220 if (un[i] != 0) {
2221 DoCallback("handleExpose", "(IIII)V",
2222 ScaleDownX(un[i]->left),
2223 ScaleDownY(un[i]->top),
2224 ScaleDownX(un[i]->right - un[i]->left),
2225 ScaleDownY(un[i]->bottom - un[i]->top));
2226 }
2227 }
2228 delete [] buffer;
2229 }
2230 ::DeleteObject((HGDIOBJ)rgn);
2231 }
2232
2233 MsgRouting AwtComponent::WmMouseEnter(UINT flags, int x, int y)
2234 {
2235 SendMouseEvent(java_awt_event_MouseEvent_MOUSE_ENTERED,
2236 ::JVM_CurrentTimeMillis(NULL, 0), x, y, GetJavaModifiers(), 0, JNI_FALSE);
2237 if ((flags & ALL_MK_BUTTONS) == 0) {
2238 AwtCursor::UpdateCursor(this);
2239 }
2240 sm_cursorOn = GetHWnd();
2241 return mrConsume; /* Don't pass our synthetic event on! */
2242 }
2243
2244 MSG*
2245 AwtComponent::CreateMessage(UINT message, WPARAM wParam, LPARAM lParam,
4600 {
4601 RECT eraseR = { 0, 0, size.cx, size.cy };
4602 VERIFY(::FillRect(hMemoryDC, &eraseR, GetBackgroundBrush()));
4603 }
4604
4605 void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
4606 {
4607 if (!bitmapBits) {
4608 return;
4609 }
4610
4611 DWORD* dest = (DWORD*)bitmapBits;
4612 //XXX: might be optimized to use one loop (cy*cx -> 0)
4613 for (int i = 0; i < size.cy; i++ ) {
4614 for (int j = 0; j < size.cx; j++ ) {
4615 ((BYTE*)(dest++))[3] = alpha;
4616 }
4617 }
4618 }
4619
4620 int AwtComponent::ScaleUpX(int x) {
4621 int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
4622 Devices::InstanceAccess devices;
4623 AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
4624 return device == NULL ? x : device->ScaleUpX(x);
4625 }
4626
4627 int AwtComponent::ScaleUpY(int y) {
4628 int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
4629 Devices::InstanceAccess devices;
4630 AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
4631 return device == NULL ? y : device->ScaleUpY(y);
4632 }
4633
4634 int AwtComponent::ScaleDownX(int x) {
4635 int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
4636 Devices::InstanceAccess devices;
4637 AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
4638 return device == NULL ? x : device->ScaleDownX(x);
4639 }
4640
4641 int AwtComponent::ScaleDownY(int y) {
4642 int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
4643 Devices::InstanceAccess devices;
4644 AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
4645 return device == NULL ? y : device->ScaleDownY(y);
4646 }
4647
4648 jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) {
4649 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
4650
4651 if (!::IsWindowVisible(GetHWnd())) {
4652 return NULL;
4653 }
4654
4655 HDC hdc = GetDCFromComponent();
4656 if (!hdc) {
4657 return NULL;
4658 }
4659 HDC hMemoryDC = ::CreateCompatibleDC(hdc);
4660 void *bitmapBits = NULL;
4661 HBITMAP hBitmap = BitmapUtil::CreateARGBBitmap(size.cx, size.cy, &bitmapBits);
4662 HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemoryDC, hBitmap);
4663 SendMessage(WM_AWT_RELEASEDC, (WPARAM)hdc);
4664
4665 FillBackground(hMemoryDC, size);
4666
4667 VERIFY(::SetWindowOrgEx(hMemoryDC, loc.cx, loc.cy, NULL));
4921 GetInsets(&insets);
4922
4923 static jmethodID mouseEventConst;
4924 if (mouseEventConst == NULL) {
4925 mouseEventConst =
4926 env->GetMethodID(mouseEventCls, "<init>",
4927 "(Ljava/awt/Component;IJIIIIIIZI)V");
4928 DASSERT(mouseEventConst);
4929 CHECK_NULL(mouseEventConst);
4930 }
4931 if (env->EnsureLocalCapacity(2) < 0) {
4932 return;
4933 }
4934 jobject target = GetTarget(env);
4935 DWORD curMousePos = ::GetMessagePos();
4936 int xAbs = GET_X_LPARAM(curMousePos);
4937 int yAbs = GET_Y_LPARAM(curMousePos);
4938 jobject mouseEvent = env->NewObject(mouseEventCls, mouseEventConst,
4939 target,
4940 id, when, modifiers,
4941 ScaleDownX(x + insets.left),
4942 ScaleDownY(y + insets.top),
4943 ScaleDownX(xAbs), ScaleDownY(yAbs),
4944 clickCount, popupTrigger, button);
4945
4946 if (safe_ExceptionOccurred(env)) {
4947 env->ExceptionDescribe();
4948 env->ExceptionClear();
4949 }
4950
4951 DASSERT(mouseEvent != NULL);
4952 CHECK_NULL(mouseEvent);
4953 if (pMsg != 0) {
4954 AwtAWTEvent::saveMSG(env, pMsg, mouseEvent);
4955 }
4956 SendEvent(mouseEvent);
4957
4958 env->DeleteLocalRef(mouseEvent);
4959 env->DeleteLocalRef(target);
4960 }
4961
4962 void
4963 AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y,
4990 mouseWheelEventConst =
4991 env->GetMethodID(mouseWheelEventCls, "<init>",
4992 "(Ljava/awt/Component;IJIIIIIIZIIID)V");
4993 DASSERT(mouseWheelEventConst);
4994 CHECK_NULL(mouseWheelEventConst);
4995 }
4996 if (env->EnsureLocalCapacity(2) < 0) {
4997 return;
4998 }
4999 jobject target = GetTarget(env);
5000 DWORD curMousePos = ::GetMessagePos();
5001 int xAbs = GET_X_LPARAM(curMousePos);
5002 int yAbs = GET_Y_LPARAM(curMousePos);
5003
5004 DTRACE_PRINTLN("creating MWE in JNI");
5005
5006 jobject mouseWheelEvent = env->NewObject(mouseWheelEventCls,
5007 mouseWheelEventConst,
5008 target,
5009 id, when, modifiers,
5010 ScaleDownX(x + insets.left),
5011 ScaleDownY(y + insets.top),
5012 ScaleDownX(xAbs),
5013 ScaleDownY(yAbs),
5014 clickCount, popupTrigger,
5015 scrollType, scrollAmount,
5016 roundedWheelRotation, preciseWheelRotation);
5017
5018 DASSERT(mouseWheelEvent != NULL);
5019 if (mouseWheelEvent == NULL || safe_ExceptionOccurred(env)) {
5020 env->ExceptionDescribe();
5021 env->ExceptionClear();
5022 env->DeleteLocalRef(target);
5023 return;
5024 }
5025 if (pMsg != NULL) {
5026 AwtAWTEvent::saveMSG(env, pMsg, mouseWheelEvent);
5027 }
5028 SendEvent(mouseWheelEvent);
5029
5030 env->DeleteLocalRef(mouseWheelEvent);
5031 env->DeleteLocalRef(target);
5032 }
5033
5499 env->DeleteGlobalRef(self);
5500 }
5501
5502 jobject AwtComponent::_GetLocationOnScreen(void *param)
5503 {
5504 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
5505
5506 jobject self = (jobject)param;
5507
5508 jobject result = NULL;
5509 AwtComponent *p;
5510
5511 PDATA pData;
5512 JNI_CHECK_PEER_GOTO(self, ret);
5513 p = (AwtComponent *)pData;
5514 if (::IsWindow(p->GetHWnd()))
5515 {
5516 RECT rect;
5517 VERIFY(::GetWindowRect(p->GetHWnd(),&rect));
5518 result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
5519 p->ScaleDownX(rect.left),
5520 p->ScaleDownY(rect.top));
5521 }
5522 ret:
5523 env->DeleteGlobalRef(self);
5524
5525 if (result != NULL)
5526 {
5527 jobject resultGlobalRef = env->NewGlobalRef(result);
5528 env->DeleteLocalRef(result);
5529 return resultGlobalRef;
5530 }
5531 else
5532 {
5533 return NULL;
5534 }
5535 }
5536
5537 void AwtComponent::_Reshape(void *param)
5538 {
5539 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
5540
7088 /* If this component has insets, factor them in, but ignore
7089 * top-level windows.
7090 */
7091 jobject parent2 = env->GetObjectField(parent, AwtComponent::parentID);
7092 if (parent2 != NULL) {
7093 jobject peer = GetPeerForTarget(env, parent);
7094 if (peer != NULL &&
7095 JNU_IsInstanceOfByName(env, peer,
7096 "sun/awt/windows/WPanelPeer") > 0) {
7097 jobject insets =
7098 JNU_CallMethodByName(env, NULL, peer,"insets",
7099 "()Ljava/awt/Insets;").l;
7100 x += (env)->GetIntField(insets, AwtInsets::leftID);
7101 y += (env)->GetIntField(insets, AwtInsets::topID);
7102 }
7103 }
7104 env->DeleteLocalRef(target);
7105 target = parent;
7106 }
7107
7108 x = ScaleUpX(x);
7109 y = ScaleUpY(y);
7110 width = ScaleUpX(width);
7111 height = ScaleUpY(height);
7112
7113 // Test whether component's bounds match the native window's
7114 RECT rect;
7115 VERIFY(::GetWindowRect(GetHWnd(), &rect));
7116 #if 0
7117 DASSERT( (x == rect.left) &&
7118 (y == rect.top) &&
7119 (width == (rect.right-rect.left)) &&
7120 (height == (rect.bottom-rect.top)) );
7121 #else
7122 BOOL fSizeValid = ( (x == rect.left) &&
7123 (y == rect.top) &&
7124 (width == (rect.right-rect.left)) &&
7125 (height == (rect.bottom-rect.top)) );
7126 #endif
7127
7128 // See if visible state matches
7129 BOOL wndVisible = ::IsWindowVisible(GetHWnd());
7130 jboolean targetVisible;
7131 // To avoid possibly running client code on the toolkit thread, don't
7132 // do the following check if we're running on the toolkit thread.
7286 if ((removedDC = activeDCList.RemoveDC(hDC)) != NULL) {
7287 passiveDCList.AddDCItem(removedDC);
7288 }
7289 }
7290
7291 void ReleaseDCList(HWND hwnd, DCList &list) {
7292 DCItem *removedDCs = list.RemoveAllDCs(hwnd);
7293 while (removedDCs) {
7294 DCItem *tmpDCList = removedDCs;
7295 DASSERT(::GetObjectType(tmpDCList->hDC) == OBJ_DC);
7296 int retValue = ::ReleaseDC(tmpDCList->hWnd, tmpDCList->hDC);
7297 VERIFY(retValue != 0);
7298 if (retValue != 0) {
7299 // Valid ReleaseDC call; need to decrement GDI object counter
7300 AwtGDIObject::Decrement();
7301 }
7302 removedDCs = removedDCs->next;
7303 delete tmpDCList;
7304 }
7305 }
|