< prev index next >

src/java.desktop/windows/native/libawt/windows/awt_Component.cpp

Print this page




 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,


4586 {
4587     RECT eraseR = { 0, 0, size.cx, size.cy };
4588     VERIFY(::FillRect(hMemoryDC, &eraseR, GetBackgroundBrush()));
4589 }
4590 
4591 void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
4592 {
4593     if (!bitmapBits) {
4594         return;
4595     }
4596 
4597     DWORD* dest = (DWORD*)bitmapBits;
4598     //XXX: might be optimized to use one loop (cy*cx -> 0)
4599     for (int i = 0; i < size.cy; i++ ) {
4600         for (int j = 0; j < size.cx; j++ ) {
4601             ((BYTE*)(dest++))[3] = alpha;
4602         }
4603     }
4604 }
4605 




























4606 jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) {
4607     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
4608 
4609     if (!::IsWindowVisible(GetHWnd())) {
4610         return NULL;
4611     }
4612 
4613     HDC hdc = GetDCFromComponent();
4614     if (!hdc) {
4615         return NULL;
4616     }
4617     HDC hMemoryDC = ::CreateCompatibleDC(hdc);
4618     void *bitmapBits = NULL;
4619     HBITMAP hBitmap = BitmapUtil::CreateARGBBitmap(size.cx, size.cy, &bitmapBits);
4620     HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemoryDC, hBitmap);
4621     SendMessage(WM_AWT_RELEASEDC, (WPARAM)hdc);
4622 
4623     FillBackground(hMemoryDC, size);
4624 
4625     VERIFY(::SetWindowOrgEx(hMemoryDC, loc.cx, loc.cy, NULL));


4879     GetInsets(&insets);
4880 
4881     static jmethodID mouseEventConst;
4882     if (mouseEventConst == NULL) {
4883         mouseEventConst =
4884             env->GetMethodID(mouseEventCls, "<init>",
4885                  "(Ljava/awt/Component;IJIIIIIIZI)V");
4886         DASSERT(mouseEventConst);
4887         CHECK_NULL(mouseEventConst);
4888     }
4889     if (env->EnsureLocalCapacity(2) < 0) {
4890         return;
4891     }
4892     jobject target = GetTarget(env);
4893     DWORD curMousePos = ::GetMessagePos();
4894     int xAbs = GET_X_LPARAM(curMousePos);
4895     int yAbs = GET_Y_LPARAM(curMousePos);
4896     jobject mouseEvent = env->NewObject(mouseEventCls, mouseEventConst,
4897                                         target,
4898                                         id, when, modifiers,
4899                                         x+insets.left, y+insets.top,
4900                                         xAbs, yAbs,

4901                                         clickCount, popupTrigger, button);
4902 
4903     if (safe_ExceptionOccurred(env)) {
4904         env->ExceptionDescribe();
4905         env->ExceptionClear();
4906     }
4907 
4908     DASSERT(mouseEvent != NULL);
4909     CHECK_NULL(mouseEvent);
4910     if (pMsg != 0) {
4911         AwtAWTEvent::saveMSG(env, pMsg, mouseEvent);
4912     }
4913     SendEvent(mouseEvent);
4914 
4915     env->DeleteLocalRef(mouseEvent);
4916     env->DeleteLocalRef(target);
4917 }
4918 
4919 void
4920 AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y,


4947         mouseWheelEventConst =
4948             env->GetMethodID(mouseWheelEventCls, "<init>",
4949                            "(Ljava/awt/Component;IJIIIIIIZIIID)V");
4950         DASSERT(mouseWheelEventConst);
4951         CHECK_NULL(mouseWheelEventConst);
4952     }
4953     if (env->EnsureLocalCapacity(2) < 0) {
4954         return;
4955     }
4956     jobject target = GetTarget(env);
4957     DWORD curMousePos = ::GetMessagePos();
4958     int xAbs = GET_X_LPARAM(curMousePos);
4959     int yAbs = GET_Y_LPARAM(curMousePos);
4960 
4961     DTRACE_PRINTLN("creating MWE in JNI");
4962 
4963     jobject mouseWheelEvent = env->NewObject(mouseWheelEventCls,
4964                                              mouseWheelEventConst,
4965                                              target,
4966                                              id, when, modifiers,
4967                                              x+insets.left, y+insets.top,
4968                                              xAbs, yAbs,


4969                                              clickCount, popupTrigger,
4970                                              scrollType, scrollAmount,
4971                                              roundedWheelRotation, preciseWheelRotation);
4972 
4973     DASSERT(mouseWheelEvent != NULL);
4974     if (mouseWheelEvent == NULL || safe_ExceptionOccurred(env)) {
4975         env->ExceptionDescribe();
4976         env->ExceptionClear();
4977         env->DeleteLocalRef(target);
4978         return;
4979     }
4980     if (pMsg != NULL) {
4981         AwtAWTEvent::saveMSG(env, pMsg, mouseWheelEvent);
4982     }
4983     SendEvent(mouseWheelEvent);
4984 
4985     env->DeleteLocalRef(mouseWheelEvent);
4986     env->DeleteLocalRef(target);
4987 }
4988 


5454     env->DeleteGlobalRef(self);
5455 }
5456 
5457 jobject AwtComponent::_GetLocationOnScreen(void *param)
5458 {
5459     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
5460 
5461     jobject self = (jobject)param;
5462 
5463     jobject result = NULL;
5464     AwtComponent *p;
5465 
5466     PDATA pData;
5467     JNI_CHECK_PEER_GOTO(self, ret);
5468     p = (AwtComponent *)pData;
5469     if (::IsWindow(p->GetHWnd()))
5470     {
5471         RECT rect;
5472         VERIFY(::GetWindowRect(p->GetHWnd(),&rect));
5473         result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
5474             rect.left, rect.top);

5475     }
5476 ret:
5477     env->DeleteGlobalRef(self);
5478 
5479     if (result != NULL)
5480     {
5481         jobject resultGlobalRef = env->NewGlobalRef(result);
5482         env->DeleteLocalRef(result);
5483         return resultGlobalRef;
5484     }
5485     else
5486     {
5487         return NULL;
5488     }
5489 }
5490 
5491 void AwtComponent::_Reshape(void *param)
5492 {
5493     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
5494 


7042         /* If this component has insets, factor them in, but ignore
7043          * top-level windows.
7044          */
7045         jobject parent2 = env->GetObjectField(parent, AwtComponent::parentID);
7046         if (parent2 != NULL) {
7047             jobject peer = GetPeerForTarget(env, parent);
7048             if (peer != NULL &&
7049                 JNU_IsInstanceOfByName(env, peer,
7050                                        "sun/awt/windows/WPanelPeer") > 0) {
7051                 jobject insets =
7052                     JNU_CallMethodByName(env, NULL, peer,"insets",
7053                                          "()Ljava/awt/Insets;").l;
7054                 x += (env)->GetIntField(insets, AwtInsets::leftID);
7055                 y += (env)->GetIntField(insets, AwtInsets::topID);
7056             }
7057         }
7058         env->DeleteLocalRef(target);
7059         target = parent;
7060     }
7061 





7062     // Test whether component's bounds match the native window's
7063     RECT rect;
7064     VERIFY(::GetWindowRect(GetHWnd(), &rect));
7065 #if 0
7066     DASSERT( (x == rect.left) &&
7067             (y == rect.top) &&
7068             (width == (rect.right-rect.left)) &&
7069             (height == (rect.bottom-rect.top)) );
7070 #else
7071     BOOL fSizeValid = ( (x == rect.left) &&
7072             (y == rect.top) &&
7073             (width == (rect.right-rect.left)) &&
7074             (height == (rect.bottom-rect.top)) );
7075 #endif
7076 
7077     // See if visible state matches
7078     BOOL wndVisible = ::IsWindowVisible(GetHWnd());
7079     jboolean targetVisible;
7080     // To avoid possibly running client code on the toolkit thread, don't
7081     // do the following check if we're running on the toolkit thread.


7235     if ((removedDC = activeDCList.RemoveDC(hDC)) != NULL) {
7236         passiveDCList.AddDCItem(removedDC);
7237     }
7238 }
7239 
7240 void ReleaseDCList(HWND hwnd, DCList &list) {
7241     DCItem *removedDCs = list.RemoveAllDCs(hwnd);
7242     while (removedDCs) {
7243         DCItem *tmpDCList = removedDCs;
7244         DASSERT(::GetObjectType(tmpDCList->hDC) == OBJ_DC);
7245         int retValue = ::ReleaseDC(tmpDCList->hWnd, tmpDCList->hDC);
7246         VERIFY(retValue != 0);
7247         if (retValue != 0) {
7248             // Valid ReleaseDC call; need to decrement GDI object counter
7249             AwtGDIObject::Decrement();
7250         }
7251         removedDCs = removedDCs->next;
7252         delete tmpDCList;
7253     }
7254 }
7255 


 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,


4595 {
4596     RECT eraseR = { 0, 0, size.cx, size.cy };
4597     VERIFY(::FillRect(hMemoryDC, &eraseR, GetBackgroundBrush()));
4598 }
4599 
4600 void AwtComponent::FillAlpha(void *bitmapBits, SIZE &size, BYTE alpha)
4601 {
4602     if (!bitmapBits) {
4603         return;
4604     }
4605 
4606     DWORD* dest = (DWORD*)bitmapBits;
4607     //XXX: might be optimized to use one loop (cy*cx -> 0)
4608     for (int i = 0; i < size.cy; i++ ) {
4609         for (int j = 0; j < size.cx; j++ ) {
4610             ((BYTE*)(dest++))[3] = alpha;
4611         }
4612     }
4613 }
4614 
4615 int AwtComponent::ScaleUpX(int x) {
4616     int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
4617     Devices::InstanceAccess devices;
4618     AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
4619     return device == NULL ? x : device->ScaleUpX(x);
4620 }
4621 
4622 int AwtComponent::ScaleUpY(int y) {
4623     int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
4624     Devices::InstanceAccess devices;
4625     AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
4626     return device == NULL ? y : device->ScaleUpY(y);
4627 }
4628 
4629 int AwtComponent::ScaleDownX(int x) {
4630     int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
4631     Devices::InstanceAccess devices;
4632     AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
4633     return device == NULL ? x : device->ScaleDownX(x);
4634 }
4635 
4636 int AwtComponent::ScaleDownY(int y) {
4637     int screen = AwtWin32GraphicsDevice::DeviceIndexForWindow(GetHWnd());
4638     Devices::InstanceAccess devices;
4639     AwtWin32GraphicsDevice* device = devices->GetDevice(screen);
4640     return device == NULL ? y : device->ScaleDownY(y);
4641 }
4642 
4643 jintArray AwtComponent::CreatePrintedPixels(SIZE &loc, SIZE &size, int alpha) {
4644     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
4645 
4646     if (!::IsWindowVisible(GetHWnd())) {
4647         return NULL;
4648     }
4649 
4650     HDC hdc = GetDCFromComponent();
4651     if (!hdc) {
4652         return NULL;
4653     }
4654     HDC hMemoryDC = ::CreateCompatibleDC(hdc);
4655     void *bitmapBits = NULL;
4656     HBITMAP hBitmap = BitmapUtil::CreateARGBBitmap(size.cx, size.cy, &bitmapBits);
4657     HBITMAP hOldBitmap = (HBITMAP)::SelectObject(hMemoryDC, hBitmap);
4658     SendMessage(WM_AWT_RELEASEDC, (WPARAM)hdc);
4659 
4660     FillBackground(hMemoryDC, size);
4661 
4662     VERIFY(::SetWindowOrgEx(hMemoryDC, loc.cx, loc.cy, NULL));


4916     GetInsets(&insets);
4917 
4918     static jmethodID mouseEventConst;
4919     if (mouseEventConst == NULL) {
4920         mouseEventConst =
4921             env->GetMethodID(mouseEventCls, "<init>",
4922                  "(Ljava/awt/Component;IJIIIIIIZI)V");
4923         DASSERT(mouseEventConst);
4924         CHECK_NULL(mouseEventConst);
4925     }
4926     if (env->EnsureLocalCapacity(2) < 0) {
4927         return;
4928     }
4929     jobject target = GetTarget(env);
4930     DWORD curMousePos = ::GetMessagePos();
4931     int xAbs = GET_X_LPARAM(curMousePos);
4932     int yAbs = GET_Y_LPARAM(curMousePos);
4933     jobject mouseEvent = env->NewObject(mouseEventCls, mouseEventConst,
4934                                         target,
4935                                         id, when, modifiers,
4936                                         ScaleDownX(x + insets.left),
4937                                         ScaleDownY(y + insets.top),
4938                                         ScaleDownX(xAbs), ScaleDownY(yAbs),
4939                                         clickCount, popupTrigger, button);
4940 
4941     if (safe_ExceptionOccurred(env)) {
4942         env->ExceptionDescribe();
4943         env->ExceptionClear();
4944     }
4945 
4946     DASSERT(mouseEvent != NULL);
4947     CHECK_NULL(mouseEvent);
4948     if (pMsg != 0) {
4949         AwtAWTEvent::saveMSG(env, pMsg, mouseEvent);
4950     }
4951     SendEvent(mouseEvent);
4952 
4953     env->DeleteLocalRef(mouseEvent);
4954     env->DeleteLocalRef(target);
4955 }
4956 
4957 void
4958 AwtComponent::SendMouseWheelEvent(jint id, jlong when, jint x, jint y,


4985         mouseWheelEventConst =
4986             env->GetMethodID(mouseWheelEventCls, "<init>",
4987                            "(Ljava/awt/Component;IJIIIIIIZIIID)V");
4988         DASSERT(mouseWheelEventConst);
4989         CHECK_NULL(mouseWheelEventConst);
4990     }
4991     if (env->EnsureLocalCapacity(2) < 0) {
4992         return;
4993     }
4994     jobject target = GetTarget(env);
4995     DWORD curMousePos = ::GetMessagePos();
4996     int xAbs = GET_X_LPARAM(curMousePos);
4997     int yAbs = GET_Y_LPARAM(curMousePos);
4998 
4999     DTRACE_PRINTLN("creating MWE in JNI");
5000 
5001     jobject mouseWheelEvent = env->NewObject(mouseWheelEventCls,
5002                                              mouseWheelEventConst,
5003                                              target,
5004                                              id, when, modifiers,
5005                                              ScaleDownX(x + insets.left),
5006                                              ScaleDownY(y + insets.top),
5007                                              ScaleDownX(xAbs),
5008                                              ScaleDownY(yAbs),
5009                                              clickCount, popupTrigger,
5010                                              scrollType, scrollAmount,
5011                                              roundedWheelRotation, preciseWheelRotation);
5012 
5013     DASSERT(mouseWheelEvent != NULL);
5014     if (mouseWheelEvent == NULL || safe_ExceptionOccurred(env)) {
5015         env->ExceptionDescribe();
5016         env->ExceptionClear();
5017         env->DeleteLocalRef(target);
5018         return;
5019     }
5020     if (pMsg != NULL) {
5021         AwtAWTEvent::saveMSG(env, pMsg, mouseWheelEvent);
5022     }
5023     SendEvent(mouseWheelEvent);
5024 
5025     env->DeleteLocalRef(mouseWheelEvent);
5026     env->DeleteLocalRef(target);
5027 }
5028 


5494     env->DeleteGlobalRef(self);
5495 }
5496 
5497 jobject AwtComponent::_GetLocationOnScreen(void *param)
5498 {
5499     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
5500 
5501     jobject self = (jobject)param;
5502 
5503     jobject result = NULL;
5504     AwtComponent *p;
5505 
5506     PDATA pData;
5507     JNI_CHECK_PEER_GOTO(self, ret);
5508     p = (AwtComponent *)pData;
5509     if (::IsWindow(p->GetHWnd()))
5510     {
5511         RECT rect;
5512         VERIFY(::GetWindowRect(p->GetHWnd(),&rect));
5513         result = JNU_NewObjectByName(env, "java/awt/Point", "(II)V",
5514                                      p->ScaleDownX(rect.left),
5515                                      p->ScaleDownY(rect.top));
5516     }
5517 ret:
5518     env->DeleteGlobalRef(self);
5519 
5520     if (result != NULL)
5521     {
5522         jobject resultGlobalRef = env->NewGlobalRef(result);
5523         env->DeleteLocalRef(result);
5524         return resultGlobalRef;
5525     }
5526     else
5527     {
5528         return NULL;
5529     }
5530 }
5531 
5532 void AwtComponent::_Reshape(void *param)
5533 {
5534     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
5535 


7083         /* If this component has insets, factor them in, but ignore
7084          * top-level windows.
7085          */
7086         jobject parent2 = env->GetObjectField(parent, AwtComponent::parentID);
7087         if (parent2 != NULL) {
7088             jobject peer = GetPeerForTarget(env, parent);
7089             if (peer != NULL &&
7090                 JNU_IsInstanceOfByName(env, peer,
7091                                        "sun/awt/windows/WPanelPeer") > 0) {
7092                 jobject insets =
7093                     JNU_CallMethodByName(env, NULL, peer,"insets",
7094                                          "()Ljava/awt/Insets;").l;
7095                 x += (env)->GetIntField(insets, AwtInsets::leftID);
7096                 y += (env)->GetIntField(insets, AwtInsets::topID);
7097             }
7098         }
7099         env->DeleteLocalRef(target);
7100         target = parent;
7101     }
7102 
7103     x = ScaleUpX(x);
7104     y = ScaleUpY(y);
7105     width = ScaleUpX(width);
7106     height = ScaleUpY(height);
7107 
7108     // Test whether component's bounds match the native window's
7109     RECT rect;
7110     VERIFY(::GetWindowRect(GetHWnd(), &rect));
7111 #if 0
7112     DASSERT( (x == rect.left) &&
7113             (y == rect.top) &&
7114             (width == (rect.right-rect.left)) &&
7115             (height == (rect.bottom-rect.top)) );
7116 #else
7117     BOOL fSizeValid = ( (x == rect.left) &&
7118             (y == rect.top) &&
7119             (width == (rect.right-rect.left)) &&
7120             (height == (rect.bottom-rect.top)) );
7121 #endif
7122 
7123     // See if visible state matches
7124     BOOL wndVisible = ::IsWindowVisible(GetHWnd());
7125     jboolean targetVisible;
7126     // To avoid possibly running client code on the toolkit thread, don't
7127     // do the following check if we're running on the toolkit thread.


7281     if ((removedDC = activeDCList.RemoveDC(hDC)) != NULL) {
7282         passiveDCList.AddDCItem(removedDC);
7283     }
7284 }
7285 
7286 void ReleaseDCList(HWND hwnd, DCList &list) {
7287     DCItem *removedDCs = list.RemoveAllDCs(hwnd);
7288     while (removedDCs) {
7289         DCItem *tmpDCList = removedDCs;
7290         DASSERT(::GetObjectType(tmpDCList->hDC) == OBJ_DC);
7291         int retValue = ::ReleaseDC(tmpDCList->hWnd, tmpDCList->hDC);
7292         VERIFY(retValue != 0);
7293         if (retValue != 0) {
7294             // Valid ReleaseDC call; need to decrement GDI object counter
7295             AwtGDIObject::Decrement();
7296         }
7297         removedDCs = removedDCs->next;
7298         delete tmpDCList;
7299     }
7300 }

< prev index next >