jdk/src/windows/native/sun/windows/awt_Dialog.h
author ohair
Wed, 06 Apr 2011 22:06:11 -0700
changeset 9035 1255eb81cc2f
parent 7771 9d852846c077
child 21278 ef8a3a2a72f2
permissions -rw-r--r--
7033660: Update copyright year to 2011 on any files changed in 2011 Reviewed-by: dholmes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
9035
1255eb81cc2f 7033660: Update copyright year to 2011 on any files changed in 2011
ohair
parents: 7771
diff changeset
     2
 * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
90ce3da70b43 Initial load
duke
parents:
diff changeset
     4
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
90ce3da70b43 Initial load
duke
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2472
diff changeset
     7
 * published by the Free Software Foundation.  Oracle designates this
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2472
diff changeset
     9
 * by Oracle in the LICENSE file that accompanied this code.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    10
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    11
 * This code is distributed in the hope that it will be useful, but WITHOUT
90ce3da70b43 Initial load
duke
parents:
diff changeset
    12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    13
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
90ce3da70b43 Initial load
duke
parents:
diff changeset
    14
 * version 2 for more details (a copy is included in the LICENSE file that
90ce3da70b43 Initial load
duke
parents:
diff changeset
    15
 * accompanied this code).
90ce3da70b43 Initial load
duke
parents:
diff changeset
    16
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    17
 * You should have received a copy of the GNU General Public License version
90ce3da70b43 Initial load
duke
parents:
diff changeset
    18
 * 2 along with this work; if not, write to the Free Software Foundation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    19
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    20
 *
5506
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2472
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2472
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2472
diff changeset
    23
 * questions.
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    24
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    25
90ce3da70b43 Initial load
duke
parents:
diff changeset
    26
#ifndef AWT_DIALOG_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define AWT_DIALOG_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "awt_Frame.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "java_awt_Dialog.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "sun_awt_windows_WDialogPeer.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
 * AwtDialog class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
// unification with AwtComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#define AWT_DIALOG_WINDOW_CLASS_NAME TEXT("SunAwtDialog")
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
class AwtDialog : public AwtFrame {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
    /* java.awt.Dialog field ids */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
    static jfieldID titleID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    /* boolean undecorated field for java.awt.Dialog */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    static jfieldID undecoratedID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
    AwtDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
    virtual ~AwtDialog();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    virtual void Dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
    virtual LPCTSTR GetClassName();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
    virtual void  FillClassInfo(WNDCLASSEX *lpwc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    virtual void SetResizable(BOOL isResizable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
    void Show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
    virtual void DoUpdateIcon();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
    virtual HICON GetEffectiveIcon(int iconType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
    /* Create a new AwtDialog.  This must be run on the main thread. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    static AwtDialog* Create(jobject peer, jobject hParent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    virtual MsgRouting WmShowModal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
    virtual MsgRouting WmEndModal();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
    virtual MsgRouting WmStyleChanged(int wStyleType, LPSTYLESTRUCT lpss);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
    virtual MsgRouting WmSize(UINT type, int w, int h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
    MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
     * The check is performed before the dialog is shown.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
     * The focused window can't be blocked at the time it's focused.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
     * Thus we don't have to perform any transitive (a blocker of a blocker) checks.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
    INLINE virtual BOOL IsFocusedWindowModalBlocker() {
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2455
diff changeset
    79
        return (AwtComponent::GetFocusedWindow() != NULL) && (GetModalBlocker(AwtComponent::GetFocusedWindow()) == GetHWnd());
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    // finds and activates some window after the modal dialog is hidden
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    static void ModalActivateNextWindow(HWND dialogHWnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
                                        jobject dialogTarget, jobject dialogPeer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
    // some methods called on Tookit thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    static void _ShowModal(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
    static void _EndModal(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    static void _SetIMMOption(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    static BOOL IsModalExcluded(HWND hwnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    static void CheckInstallModalHook();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    static void CheckUninstallModalHook();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
private:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    void UpdateSystemMenu();
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    HWND m_modalWnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    // checks if the given window can be activated after a modal dialog is hidden
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    inline static BOOL ModalCanBeActivated(HWND hwnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
        return ::IsWindow(hwnd) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
               ::IsWindowVisible(hwnd) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
               ::IsWindowEnabled(hwnd) &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
              !::IsWindow(AwtWindow::GetModalBlocker(hwnd));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
     * Activates the given window
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
     * If the window is an embedded frame, it is activated from Java code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
     *   See WEmbeddedFrame.activateEmbeddingTopLevel() for details.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    static void ModalPerformActivation(HWND hWnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
7771
9d852846c077 6921598: PrinterDialog hidden behind other frames
dcherepanov
parents: 5506
diff changeset
   116
    static void PopupBlockers(HWND blocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar);
9d852846c077 6921598: PrinterDialog hidden behind other frames
dcherepanov
parents: 5506
diff changeset
   117
    static void PopupBlocker(HWND blocker, HWND nextBlocker, BOOL isModalHook, HWND prevFGWindow, BOOL onTaskbar);
2455
e2d60882b891 6769607: PIT : Modal frame hangs for a while for few seconds in 6u12 b01 pit build
dcherepanov
parents: 2
diff changeset
   118
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    // WH_CBT hook procedure used in modality, prevents modal
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    // blocked windows from being activated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
    static LRESULT CALLBACK ModalFilterProc(int code,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                                            WPARAM wParam, LPARAM lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
    // WM_MOUSE hook procedure used in modality, filters some
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    // mouse events for blocked windows and brings blocker
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    // dialog to front
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    static LRESULT CALLBACK MouseHookProc(int code,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
                                          WPARAM wParam, LPARAM lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    // WM_MOUSE hook procedure used in modality, similiar to
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
    // MouseHookProc but installed on non-toolkit threads, for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
    // example on browser's thread when running in Java Plugin
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
    static LRESULT CALLBACK MouseHookProc_NonTT(int code,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                                                WPARAM wParam, LPARAM lParam);
2472
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2455
diff changeset
   135
b7aba00cabb6 6693253: Security Warning appearance requires enhancements
anthony
parents: 2455
diff changeset
   136
    static void AnimateModalBlocker(HWND window);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
#endif /* AWT_DIALOG_H */