< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  83 LPCTSTR AwtDialog::GetClassName() {
  84   return AWT_DIALOG_WINDOW_CLASS_NAME;
  85 }
  86 
  87 void AwtDialog::FillClassInfo(WNDCLASSEX *lpwc)
  88 {
  89     AwtWindow::FillClassInfo(lpwc);
  90     //Fixed 6280303: REGRESSION: Java cup icon appears in title bar of dialogs
  91     // Dialog inherits icon from its owner dinamically
  92     lpwc->hIcon = NULL;
  93     lpwc->hIconSm = NULL;
  94 }
  95 
  96 /*
  97  * Create a new AwtDialog object and window.
  98  */
  99 AwtDialog* AwtDialog::Create(jobject peer, jobject parent)
 100 {
 101     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 102 
 103     jobject background = NULL;
 104     jobject target = NULL;
 105     AwtDialog* dialog = NULL;
 106 
 107     try {
 108         if (env->EnsureLocalCapacity(2) < 0) {
 109             return NULL;
 110         }
 111 
 112         PDATA pData;
 113         AwtWindow* awtParent = NULL;
 114         HWND hwndParent = NULL;
 115         target = env->GetObjectField(peer, AwtObject::targetID);
 116         JNI_CHECK_NULL_GOTO(target, "null target", done);
 117 
 118         if (parent != NULL) {
 119             JNI_CHECK_PEER_GOTO(parent, done);
 120             awtParent = (AwtWindow *)(JNI_GET_PDATA(parent));
 121             hwndParent = awtParent->GetHWnd();
 122         } else {
 123             // There is no way to prevent a parentless dialog from showing on


 164                                x, y, width, height,
 165                                hwndParent,
 166                                NULL,
 167                                ::GetSysColor(COLOR_WINDOWTEXT),
 168                                ::GetSysColor(colorId),
 169                                peer);
 170 
 171             dialog->RecalcNonClient();
 172             dialog->UpdateSystemMenu();
 173 
 174             /*
 175              * Initialize icon as inherited from parent if it exists
 176              */
 177             if (parent != NULL) {
 178                 dialog->m_hIcon = awtParent->GetHIcon();
 179                 dialog->m_hIconSm = awtParent->GetHIconSm();
 180                 dialog->m_iconInherited = TRUE;
 181             }
 182             dialog->DoUpdateIcon();
 183 
 184 
 185             background = env->GetObjectField(target,
 186                                              AwtComponent::backgroundID);
 187             if (background == NULL) {
 188                 JNU_CallMethodByName(env, NULL,
 189                                      peer, "setDefaultColor", "()V");
 190             }
 191         }
 192     } catch (...) {
 193         env->DeleteLocalRef(background);
 194         env->DeleteLocalRef(target);
 195         throw;
 196     }
 197 
 198 done:
 199     env->DeleteLocalRef(background);
 200     env->DeleteLocalRef(target);
 201 
 202     return dialog;
 203 }
 204 
 205 MsgRouting AwtDialog::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) {
 206     // By the request from Swing team, click on the Dialog's title should generate Ungrab
 207     if (m_grabbedWindow != NULL/* && !m_grabbedWindow->IsOneOfOwnersOf(this)*/) {
 208         m_grabbedWindow->Ungrab();
 209     }
 210 
 211     if (!IsFocusableWindow() && (button & LEFT_BUTTON)) {
 212         // Dialog is non-maximizable
 213         if ((button & DBL_CLICK) && hitTest == HTCAPTION) {
 214             return mrConsume;
 215         }
 216     }
 217     return AwtFrame::WmNcMouseDown(hitTest, x, y, button);
 218 }
 219 


   1 /*
   2  * Copyright (c) 1996, 2016, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


  83 LPCTSTR AwtDialog::GetClassName() {
  84   return AWT_DIALOG_WINDOW_CLASS_NAME;
  85 }
  86 
  87 void AwtDialog::FillClassInfo(WNDCLASSEX *lpwc)
  88 {
  89     AwtWindow::FillClassInfo(lpwc);
  90     //Fixed 6280303: REGRESSION: Java cup icon appears in title bar of dialogs
  91     // Dialog inherits icon from its owner dinamically
  92     lpwc->hIcon = NULL;
  93     lpwc->hIconSm = NULL;
  94 }
  95 
  96 /*
  97  * Create a new AwtDialog object and window.
  98  */
  99 AwtDialog* AwtDialog::Create(jobject peer, jobject parent)
 100 {
 101     JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
 102 

 103     jobject target = NULL;
 104     AwtDialog* dialog = NULL;
 105 
 106     try {
 107         if (env->EnsureLocalCapacity(2) < 0) {
 108             return NULL;
 109         }
 110 
 111         PDATA pData;
 112         AwtWindow* awtParent = NULL;
 113         HWND hwndParent = NULL;
 114         target = env->GetObjectField(peer, AwtObject::targetID);
 115         JNI_CHECK_NULL_GOTO(target, "null target", done);
 116 
 117         if (parent != NULL) {
 118             JNI_CHECK_PEER_GOTO(parent, done);
 119             awtParent = (AwtWindow *)(JNI_GET_PDATA(parent));
 120             hwndParent = awtParent->GetHWnd();
 121         } else {
 122             // There is no way to prevent a parentless dialog from showing on


 163                                x, y, width, height,
 164                                hwndParent,
 165                                NULL,
 166                                ::GetSysColor(COLOR_WINDOWTEXT),
 167                                ::GetSysColor(colorId),
 168                                peer);
 169 
 170             dialog->RecalcNonClient();
 171             dialog->UpdateSystemMenu();
 172 
 173             /*
 174              * Initialize icon as inherited from parent if it exists
 175              */
 176             if (parent != NULL) {
 177                 dialog->m_hIcon = awtParent->GetHIcon();
 178                 dialog->m_hIconSm = awtParent->GetHIconSm();
 179                 dialog->m_iconInherited = TRUE;
 180             }
 181             dialog->DoUpdateIcon();
 182 







 183         }
 184     } catch (...) {

 185         env->DeleteLocalRef(target);
 186         throw;
 187     }
 188 
 189 done:

 190     env->DeleteLocalRef(target);
 191 
 192     return dialog;
 193 }
 194 
 195 MsgRouting AwtDialog::WmNcMouseDown(WPARAM hitTest, int x, int y, int button) {
 196     // By the request from Swing team, click on the Dialog's title should generate Ungrab
 197     if (m_grabbedWindow != NULL/* && !m_grabbedWindow->IsOneOfOwnersOf(this)*/) {
 198         m_grabbedWindow->Ungrab();
 199     }
 200 
 201     if (!IsFocusableWindow() && (button & LEFT_BUTTON)) {
 202         // Dialog is non-maximizable
 203         if ((button & DBL_CLICK) && hitTest == HTCAPTION) {
 204             return mrConsume;
 205         }
 206     }
 207     return AwtFrame::WmNcMouseDown(hitTest, x, y, button);
 208 }
 209 


< prev index next >