jdk/src/windows/native/sun/windows/awt_Component.h
author tdv
Tue, 22 Jul 2008 11:24:32 -0700
changeset 888 c7009cf0001f
parent 887 0aab8d3fa11a
child 889 6549643c008c
permissions -rw-r--r--
6728492: typo in copyrights in some files touched by the d3d pipeline port Reviewed-by: prr
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
888
c7009cf0001f 6728492: typo in copyrights in some files touched by the d3d pipeline port
tdv
parents: 887
diff changeset
     2
 * Copyright 1996-2008 Sun Microsystems, Inc.  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
90ce3da70b43 Initial load
duke
parents:
diff changeset
     7
 * published by the Free Software Foundation.  Sun designates this
90ce3da70b43 Initial load
duke
parents:
diff changeset
     8
 * particular file as subject to the "Classpath" exception as provided
90ce3da70b43 Initial load
duke
parents:
diff changeset
     9
 * by Sun in the LICENSE file that accompanied this code.
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
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
    21
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    22
 * CA 95054 USA or visit www.sun.com if you need additional information or
90ce3da70b43 Initial load
duke
parents:
diff changeset
    23
 * have any questions.
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_COMPONENT_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#define AWT_COMPONENT_H
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "awtmsg.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "awt_Object.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
#include "awt_Font.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "awt_Brush.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
#include "awt_Pen.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
#include "awt_Win32GraphicsDevice.h"
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
    35
#include "GDIWindowSurfaceData.h"
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
#include "java_awt_Component.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
#include "sun_awt_windows_WComponentPeer.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
#include "java_awt_event_KeyEvent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
#include "java_awt_event_FocusEvent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
#include "java_awt_event_MouseEvent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
#include "java_awt_event_WindowEvent.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
#include "java_awt_Dimension.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
extern LPCTSTR szAwtComponentClassName;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
static LPCTSTR DrawingStateProp = TEXT("SunAwtDrawingStateProp");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
const UINT IGNORE_KEY = (UINT)-1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
const UINT MAX_ACP_STR_LEN = 7; // ANSI CP identifiers are no longer than this
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
#define LEFT_BUTTON 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
#define MIDDLE_BUTTON 2
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
#define RIGHT_BUTTON 4
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
#define DBL_CLICK 8
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
// Whether to check for embedded frame and adjust location
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
#define CHECK_EMBEDDED 0
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
#define DONT_CHECK_EMBEDDED 1
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
class AwtPopupMenu;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
class AwtDropTarget;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
struct WmComponentSetFocusData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
 * Message routing codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
enum MsgRouting {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
    mrPassAlong,    /* pass along to next in chain */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
    mrDoDefault,    /* skip right to underlying default behavior */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
    mrConsume,      /* consume msg & terminate routing immediatly,
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
                     * don't pass anywhere
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
                     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
 * AwtComponent class
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
class AwtComponent : public AwtObject {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
    enum {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
        // combination of all mouse button flags
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        ALL_MK_BUTTONS = MK_LBUTTON|MK_MBUTTON|MK_RBUTTON
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
    /* java.awt.Component fields and method IDs */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
    static jfieldID peerID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
    static jfieldID xID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
    static jfieldID yID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
    static jfieldID widthID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
    static jfieldID heightID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
    static jfieldID visibleID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
    static jfieldID backgroundID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
    static jfieldID foregroundID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
    static jfieldID enabledID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
    static jfieldID parentID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
    static jfieldID cursorID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
    static jfieldID graphicsConfigID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
    static jfieldID peerGCID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
    static jfieldID focusableID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
    static jfieldID appContextID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
    static jfieldID hwndID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
    static jmethodID getFontMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
    static jmethodID getToolkitMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
    static jmethodID isEnabledMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
    static jmethodID getLocationOnScreenMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
    static jmethodID replaceSurfaceDataMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
    static jmethodID replaceSurfaceDataLaterMID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   113
90ce3da70b43 Initial load
duke
parents:
diff changeset
   114
    static const UINT WmAwtIsComponent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
    AwtComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
    virtual ~AwtComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
     * Dynamic class registration & creation
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
    virtual LPCTSTR GetClassName() = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
     * Fix for 4964237: Win XP: Changing theme changes java dialogs title icon
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
     * WNDCLASS structure has been superseded by the WNDCLASSEX in Win32
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
    virtual void FillClassInfo(WNDCLASSEX *lpwc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
    virtual void RegisterClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
    virtual void UnregisterClass();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
    void CreateHWnd(JNIEnv *env, LPCWSTR title,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
                    DWORD windowStyle, DWORD windowExStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
                    int x, int y, int w, int h,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
                    HWND hWndParent, HMENU hMenu,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                    COLORREF colorForeground, COLORREF colorBackground,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                    jobject peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
    void InitPeerGraphicsConfig(JNIEnv *env, jobject peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
    virtual void Dispose();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
    void UpdateBackground(JNIEnv *env, jobject target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
    virtual void SubclassHWND();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
    virtual void UnsubclassHWND();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
    static LRESULT CALLBACK WndProc(HWND hWnd, UINT message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
        WPARAM wParam, LPARAM lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
     * Access to the various objects of this aggregate component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
    INLINE HWND GetHWnd() { return m_hwnd; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    INLINE void SetHWnd(HWND hwnd) { m_hwnd = hwnd; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
    static AwtComponent* GetComponent(HWND hWnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
     * Access to the properties of the component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    INLINE COLORREF GetColor() { return m_colorForeground; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
    virtual void SetColor(COLORREF c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    HPEN GetForegroundPen();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
    COLORREF GetBackgroundColor();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
    virtual void SetBackgroundColor(COLORREF c);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
    HBRUSH GetBackgroundBrush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    INLINE BOOL IsBackgroundColorSet() { return m_backgroundColorSet; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    virtual void SetFont(AwtFont *pFont);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
    INLINE void SetText(LPCTSTR text) { ::SetWindowText(GetHWnd(), text); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
    INLINE int GetText(LPTSTR buffer, int size) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
        return ::GetWindowText(GetHWnd(), buffer, size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
    INLINE int GetTextLength() { return ::GetWindowTextLength(GetHWnd()); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    virtual void GetInsets(RECT* rect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
        VERIFY(::SetRectEmpty(rect));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
    BOOL IsVisible() { return m_visible;};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
    HDC GetDCFromComponent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
     * Enable/disable component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
    virtual void Enable(BOOL bEnable);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
     * Validate and call handleExpose on rects of UpdateRgn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    void PaintUpdateRgn(const RECT *insets);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    static HWND GetTopLevelParentForWindow(HWND hwndDescendant);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    static jobject FindHeavyweightUnderCursor(BOOL useCache);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
     * Returns the parent component.  If no parent window, or the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
     * parent window isn't an AwtComponent, returns NULL.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    AwtComponent* GetParent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
887
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   204
    /* Get the component's immediate container. Note: may return NULL while
0aab8d3fa11a 6725214: D3D: forward-port the new pipeline from 6u10
tdv
parents: 447
diff changeset
   205
       the component is being reparented in full-screen mode by Direct3D */
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    class AwtWindow* GetContainer();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    /* Is a component a container? Used by above method */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    virtual BOOL IsContainer() { return FALSE;} // Plain components can't
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
     * Perform some actions which by default are being performed by Default Window procedure of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
     * this window class
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
     * For detailed comments see implementation in awt_Component.cpp
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
    virtual BOOL ActMouseMessage(MSG * pMsg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    /**
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
     * Returns TRUE if this message will this component to become focused. Returns FALSE otherwise.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
    inline BOOL IsFocusingMessage(UINT message) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
        return message == WM_LBUTTONDOWN || message == WM_LBUTTONUP || message == WM_LBUTTONDBLCLK;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   222
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    BOOL IsFocusable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
     * Returns an increasing unsigned value used for child control IDs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
     * There is no attempt to reclaim command ID's.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
    INLINE UINT CreateControlID() { return m_nextControlID++; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
    // returns the current keyboard layout
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
    INLINE static HKL GetKeyboardLayout() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
        return m_hkl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
    // returns the current code page that should be used in
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
    // all MultiByteToWideChar and WideCharToMultiByte calls.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
    // This code page should also be use in IsDBCSLeadByteEx.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
    INLINE static UINT GetCodePage()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
        return m_CodePage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
// Added by waleed for BIDI Support
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    // returns the right to left status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    INLINE static BOOL GetRTLReadingOrder() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        return sm_rtlReadingOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
    // returns the right to left status
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
    INLINE static BOOL GetRTL() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
        return sm_rtl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    // returns the current sub language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    INLINE static LANGID GetSubLanguage() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
        return SUBLANGID(m_idLang);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
// end waleed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
    // returns the current input language
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
    INLINE static LANGID GetInputLanguage()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
        return m_idLang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
    // Convert Language ID to CodePage
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
    static UINT LangToCodePage(LANGID idLang);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
     * methods on this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    virtual void Show();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
    virtual void Hide();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    virtual void Reshape(int x, int y, int w, int h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
     * Fix for 4046446.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
     * Component size/position helper, for the values above the short int limit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    static BOOL SetWindowPos(HWND wnd, HWND after,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
                             int x, int y, int w, int h, UINT flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
     * Sets the scrollbar values.  'bar' can be either SB_VERT or
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
     * SB_HORZ.  'min', 'value', and 'max' can have the value INT_MAX
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
     * which means that the value should not be changed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
    void SetScrollValues(UINT bar, int min, int value, int max);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
    INLINE LRESULT SendMessage(UINT msg, WPARAM wParam=0, LPARAM lParam=0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
        DASSERT(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
        return ::SendMessage(GetHWnd(), msg, wParam, lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
    void PostUngrabEvent();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
    INLINE virtual LONG GetStyle() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
        DASSERT(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
        return ::GetWindowLong(GetHWnd(), GWL_STYLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    INLINE virtual void SetStyle(LONG style) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
        DASSERT(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
        // SetWindowLong() error handling as recommended by Win32 API doc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
        ::SetLastError(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        DWORD ret = ::SetWindowLong(GetHWnd(), GWL_STYLE, style);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        DASSERT(ret != 0 || ::GetLastError() == 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    INLINE virtual LONG GetStyleEx() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
        DASSERT(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        return ::GetWindowLong(GetHWnd(), GWL_EXSTYLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
    INLINE virtual void SetStyleEx(LONG style) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
        DASSERT(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
        // SetWindowLong() error handling as recommended by Win32 API doc.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
        ::SetLastError(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
        DWORD ret = ::SetWindowLong(GetHWnd(), GWL_EXSTYLE, style);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
        DASSERT(ret != 0 || ::GetLastError() == 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
    virtual BOOL NeedDblClick() { return FALSE; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
    /* for multifont component */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    static void DrawWindowText(HDC hDC, jobject font, jstring text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
                               int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
    static void DrawGrayText(HDC hDC, jobject font, jstring text,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                             int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    void DrawListItem(JNIEnv *env, DRAWITEMSTRUCT &drawInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
    void MeasureListItem(JNIEnv *env, MEASUREITEMSTRUCT &measureInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    jstring GetItemString(JNIEnv *env, jobject target, jint index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
    jint GetFontHeight(JNIEnv *env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
    virtual jobject PreferredItemSize(JNIEnv *env) {DASSERT(FALSE); return NULL; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
    INLINE BOOL isEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
        if (env->EnsureLocalCapacity(2) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
        jobject self = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
        jobject target = env->GetObjectField(self, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
        BOOL e = env->CallBooleanMethod(target, AwtComponent::isEnabledMID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
        DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
        env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
        return e;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
    INLINE BOOL isRecursivelyEnabled() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
        AwtComponent* p = this;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
        do {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
            if (!p->isEnabled()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
                return FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
        } while (!p->IsTopLevel() &&
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
            (p = p->GetParent()) != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
        return TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    void SendKeyEventToFocusOwner(jint id, jlong when, jint raw, jint cooked,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
                                  jint modifiers, jint keyLocation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
                                  MSG *msg = NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
     * Allocate and initialize a new java.awt.event.KeyEvent, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
     * post it to the peer's target object.  No response is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
     * from the target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    void SendKeyEvent(jint id, jlong when, jint raw, jint cooked,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
                      jint modifiers, jint keyLocation,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
                      MSG *msg = NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
     * Allocate and initialize a new java.awt.event.MouseEvent, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
     * post it to the peer's target object.  No response is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
     * from the target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
    void SendMouseEvent(jint id, jlong when, jint x, jint y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
                        jint modifiers, jint clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
                        jboolean popupTrigger, jint button = 0,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
                        MSG *msg = NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
     * Allocate and initialize a new java.awt.event.MouseWheelEvent, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
     * post it to the peer's target object.  No response is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
     * from the target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    void SendMouseWheelEvent(jint id, jlong when, jint x, jint y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
                             jint modifiers, jint clickCount,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
                             jboolean popupTrigger, jint scrollType,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
                             jint scrollAmount, jint wheelRotation,
121
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 2
diff changeset
   394
                             jdouble preciseWheelRotation, MSG *msg = NULL);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
     * Allocate and initialize a new java.awt.event.FocusEvent, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
     * post it to the peer's target object.  No response is expected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
     * from the target.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
    void SendFocusEvent(jint id, HWND opposite);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
    /* Forward a filtered event directly to the subclassed window.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
       synthetic should be TRUE iff the message was generated because
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
       of a synthetic Java event, rather than a native event. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
    virtual MsgRouting HandleEvent(MSG *msg, BOOL synthetic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
    /* Post a WM_AWT_HANDLE_EVENT message which invokes HandleEvent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
       on the toolkit thread. This method may pre-filter the messages. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
    virtual BOOL PostHandleEventMessage(MSG *msg, BOOL synthetic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    /* Event->message synthesizer methods. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
    void SynthesizeKeyMessage(JNIEnv *env, jobject keyEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
    void SynthesizeMouseMessage(JNIEnv *env, jobject mouseEvent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
    /* Components which inherit native mouse wheel behavior will
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
     * return TRUE.  These are TextArea, Choice, FileDialog, and
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
     * List.  All other Components return FALSE.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
    virtual BOOL InheritsNativeMouseWheelBehavior();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    /* Functions for MouseWheel support on Windows95
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
     * These should only be called if running on 95
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
    static void Wheel95Init();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
    INLINE static UINT Wheel95GetMsg() {return sm_95WheelMessage;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
    static UINT Wheel95GetScrLines();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    /* Determines whether the component is obscured by another window */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    // Called on Toolkit thread
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    static jboolean _IsObscured(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    /* Invalidate the specified rectangle. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
    virtual void Invalidate(RECT* r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
    /* Begin and end deferred window positioning. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    virtual void BeginValidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    virtual void EndValidate();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
    /* Keyboard conversion routines. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
    static void InitDynamicKeyMapTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
    static void BuildDynamicKeyMapTable();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
    static jint GetJavaModifiers();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
    static jint GetButton(int mouseButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    static UINT GetButtonMK(int mouseButton);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
    static UINT WindowsKeyToJavaKey(UINT windowsKey, UINT modifiers);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    static void JavaKeyToWindowsKey(UINT javaKey, UINT *windowsKey, UINT *modifiers, UINT originalWindowsKey);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
    INLINE static void AwtComponent::JavaKeyToWindowsKey(UINT javaKey,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
                                       UINT *windowsKey, UINT *modifiers)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
        JavaKeyToWindowsKey(javaKey, windowsKey, modifiers, IGNORE_KEY);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   453
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   454
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
    enum TransOps {NONE, LOAD, SAVE};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
90ce3da70b43 Initial load
duke
parents:
diff changeset
   457
    UINT WindowsKeyToJavaChar(UINT wkey, UINT modifiers, TransOps ops);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    /* routines used for input method support */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    void SetInputMethod(jobject im, BOOL useNativeCompWindow);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
    void SendInputMethodEvent(jint id, jstring text, int cClause,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
                              int *rgClauseBoundary, jstring *rgClauseReading,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
                              int cAttrBlock, int *rgAttrBoundary,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
                              BYTE *rgAttrValue, int commitedTextLength,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
                              int caretPos, int visiblePos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    void InquireCandidatePosition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    INLINE LPARAM GetCandidateType() { return m_bitsCandType; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    HIMC ImmGetContext();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    HIMC ImmAssociateContext(HIMC himc);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    HWND GetProxyFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    void CallProxyDefWindowProc(UINT message,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
                                WPARAM wParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
                                LPARAM lParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   474
                                LRESULT &retVal,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   475
                                MsgRouting &mr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   476
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
     * Windows message handler functions
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
    virtual LRESULT WindowProc(UINT message, WPARAM wParam, LPARAM lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   481
    virtual LRESULT DefWindowProc(UINT msg, WPARAM wParam, LPARAM lParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   482
90ce3da70b43 Initial load
duke
parents:
diff changeset
   483
    /* return true if msg is processed */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   484
    virtual MsgRouting PreProcessMsg(MSG& msg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   485
90ce3da70b43 Initial load
duke
parents:
diff changeset
   486
    virtual MsgRouting WmCreate() {return mrDoDefault;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   487
    virtual MsgRouting WmClose() {return mrDoDefault;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   488
    virtual MsgRouting WmDestroy();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   489
90ce3da70b43 Initial load
duke
parents:
diff changeset
   490
    virtual MsgRouting WmActivate(UINT nState, BOOL fMinimized, HWND opposite)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   491
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   492
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   493
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   494
90ce3da70b43 Initial load
duke
parents:
diff changeset
   495
    virtual MsgRouting WmEraseBkgnd(HDC hDC, BOOL& didErase)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   497
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   498
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   499
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    virtual MsgRouting WmPaint(HDC hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
    virtual MsgRouting WmGetMinMaxInfo(LPMINMAXINFO lpmmi);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
    virtual MsgRouting WmMove(int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
    virtual MsgRouting WmSize(UINT type, int w, int h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
    virtual MsgRouting WmSizing();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
    virtual MsgRouting WmShowWindow(BOOL show, UINT status);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
    virtual MsgRouting WmSetFocus(HWND hWndLost);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
    virtual MsgRouting WmKillFocus(HWND hWndGot);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   508
    jboolean WmComponentSetFocus(WmComponentSetFocusData *data);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   509
    // Use instead of ::SetFocus to maintain special focusing semantics for
90ce3da70b43 Initial load
duke
parents:
diff changeset
   510
    // Windows which are not Frames/Dialogs.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   511
    BOOL AwtSetFocus();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
    virtual MsgRouting WmCtlColor(HDC hDC, HWND hCtrl,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
                                  UINT ctlColor, HBRUSH& retBrush);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
    virtual MsgRouting WmHScroll(UINT scrollCode, UINT pos, HWND hScrollBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
    virtual MsgRouting WmVScroll(UINT scrollCode, UINT pos, HWND hScrollBar);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
    virtual MsgRouting WmMouseEnter(UINT flags, int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
    virtual MsgRouting WmMouseDown(UINT flags, int x, int y, int button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
    virtual MsgRouting WmMouseUp(UINT flags, int x, int y, int button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    virtual MsgRouting WmMouseMove(UINT flags, int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
    virtual MsgRouting WmMouseExit(UINT flags, int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    virtual MsgRouting WmMouseWheel(UINT flags, int x, int y,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
                                    int wheelRotation);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
    virtual MsgRouting WmNcMouseDown(WPARAM hitTest, int x, int y, int button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
    virtual MsgRouting WmNcMouseUp(WPARAM hitTest, int x, int y, int button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
    virtual MsgRouting WmWindowPosChanging(LPARAM windowPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
    virtual MsgRouting WmWindowPosChanged(LPARAM windowPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
    // NB: 64-bit: vkey is wParam of the message, but other API's take
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
    // vkey parameters of type UINT, so we do the cast before dispatching.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
    virtual MsgRouting WmKeyDown(UINT vkey, UINT repCnt, UINT flags, BOOL system);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
    virtual MsgRouting WmKeyUp(UINT vkey, UINT repCnt, UINT flags, BOOL system);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
    virtual MsgRouting WmChar(UINT character, UINT repCnt, UINT flags, BOOL system);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
    virtual MsgRouting WmIMEChar(UINT character, UINT repCnt, UINT flags, BOOL system);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
    virtual MsgRouting WmInputLangChange(UINT charset, HKL hKeyBoardLayout);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   538
    virtual MsgRouting WmForwardChar(WCHAR character, LPARAM lParam,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                                     BOOL synthethic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
    virtual MsgRouting WmPaste();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    virtual void SetCompositionWindow(RECT &r);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    virtual void OpenCandidateWindow(int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
    virtual void SetCandidateWindow(int iCandType, int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
    virtual MsgRouting WmImeSetContext(BOOL fSet, LPARAM *lplParam);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
    virtual MsgRouting WmImeNotify(WPARAM subMsg, LPARAM bitsCandType);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
    virtual MsgRouting WmImeStartComposition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
    virtual MsgRouting WmImeEndComposition();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
    virtual MsgRouting WmImeComposition(WORD wChar, LPARAM flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
    virtual MsgRouting WmTimer(UINT_PTR timerID) {return mrDoDefault;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
    virtual MsgRouting WmCommand(UINT id, HWND hWndCtrl, UINT notifyCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    /* reflected WmCommand from parent */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
    virtual MsgRouting WmNotify(UINT notifyCode);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    virtual MsgRouting WmCompareItem(UINT /*ctrlId*/,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
                                     COMPAREITEMSTRUCT &compareInfo,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
                                     LRESULT &result);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    virtual MsgRouting WmDeleteItem(UINT /*ctrlId*/,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
                                    DELETEITEMSTRUCT &deleteInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    virtual MsgRouting WmDrawItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
                                  DRAWITEMSTRUCT &drawInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    virtual MsgRouting WmMeasureItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
                                     MEASUREITEMSTRUCT &measureInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    /* Fix 4181790 & 4223341 : These functions get overridden in owner-drawn
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
     * components instead of the Wm... versions.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
    virtual MsgRouting OwnerDrawItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
                                     DRAWITEMSTRUCT &drawInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    virtual MsgRouting OwnerMeasureItem(UINT ctrlId,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
                                        MEASUREITEMSTRUCT &measureInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
    virtual MsgRouting WmPrint(HDC hDC, LPARAM flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    virtual MsgRouting WmPrintClient(HDC hDC, LPARAM flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    virtual MsgRouting WmNcCalcSize(BOOL fCalcValidRects,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
                                    LPNCCALCSIZE_PARAMS lpncsp,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
                                    LRESULT &retVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    virtual MsgRouting WmNcPaint(HRGN hrgn);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    virtual MsgRouting WmNcHitTest(UINT x, UINT y, LRESULT &retVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
    virtual MsgRouting WmSysCommand(UINT uCmdType, int xPos, int yPos);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    virtual MsgRouting WmExitSizeMove();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
    virtual MsgRouting WmEnterMenuLoop(BOOL isTrackPopupMenu);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    virtual MsgRouting WmExitMenuLoop(BOOL isTrackPopupMenu);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
    virtual MsgRouting WmQueryNewPalette(LRESULT &retVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
    virtual MsgRouting WmPaletteChanged(HWND hwndPalChg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
    virtual MsgRouting WmPaletteIsChanging(HWND hwndPalChg);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    virtual MsgRouting WmStyleChanged(int wStyleType, LPSTYLESTRUCT lpss);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
    virtual MsgRouting WmSettingChange(UINT wFlag, LPCTSTR pszSection);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    virtual MsgRouting WmContextMenu(HWND hCtrl, UINT xPos, UINT yPos) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
        return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
    void UpdateColorModel();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    jintArray CreatePrintedPixels(SIZE &loc, SIZE &size);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    static void * GetNativeFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    static void * GetNativeFocusedWindow();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    static void   ClearGlobalFocusOwner();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
     * HWND, AwtComponent and Java Peer interaction
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
     *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
     * Link the C++, Java peer, and HWNDs together.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
    void LinkObjects(JNIEnv *env, jobject peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
    void UnlinkObjects();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
    static BOOL QueryNewPaletteCalled() { return m_QueryNewPaletteCalled; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
90ce3da70b43 Initial load
duke
parents:
diff changeset
   617
#ifdef DEBUG
90ce3da70b43 Initial load
duke
parents:
diff changeset
   618
    virtual void VerifyState(); /* verify component and peer are in sync. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
#else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
    void VerifyState() {}       /* no-op */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
#endif
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
    virtual AwtDropTarget* CreateDropTarget(JNIEnv* env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
    virtual void DestroyDropTarget();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
    INLINE virtual HWND GetDBCSEditHandle() { return NULL; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
    // State for native drawing API
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
    INLINE jint GetDrawState() { return GetDrawState(m_hwnd); }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
    INLINE void SetDrawState(jint state) { SetDrawState(m_hwnd, state); }    // State for native drawing API
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
    INLINE virtual BOOL IsTopLevel() { return FALSE; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
    INLINE virtual BOOL IsEmbeddedFrame() { return FALSE; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
    INLINE virtual BOOL IsScrollbar() { return FALSE; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
    static INLINE BOOL IsTopLevelHWnd(HWND hwnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        AwtComponent *comp = AwtComponent::GetComponent(hwnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
        return (comp != NULL && comp->IsTopLevel());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    static INLINE BOOL IsEmbeddedFrameHWnd(HWND hwnd) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
        AwtComponent *comp = AwtComponent::GetComponent(hwnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
        return (comp != NULL && comp->IsEmbeddedFrame());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    static jint GetDrawState(HWND hwnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    static void SetDrawState(HWND hwnd, jint state);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    static HWND GetHWnd(JNIEnv* env, jobject target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
    static MSG* CreateMessage(UINT message, WPARAM wParam, LPARAM lParam, int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
    static void InitMessage(MSG* msg, UINT message, WPARAM wParam, LPARAM lParam, int x, int y);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
    // Some methods to be called on Toolkit thread via Toolkit.InvokeFunction()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    static void _Show(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    static void _Hide(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    static void _Enable(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    static void _Disable(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
    static jobject _GetLocationOnScreen(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    static void _Reshape(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
    static void _ReshapeNoCheck(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    static void _NativeHandleEvent(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    static void _SetForeground(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    static void _SetBackground(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    static void _SetFont(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    static jboolean _RequestFocus(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
    static void _Start(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
    static void _BeginValidate(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
    static void _EndValidate(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
    static void _UpdateWindow(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
    static jlong _AddNativeDropTarget(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
    static void _RemoveNativeDropTarget(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
    static jintArray _CreatePrintedPixels(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
    static jboolean _NativeHandlesWheelScrolling(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
    static void _SetRectangularShape(void *param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
    static HWND sm_focusOwner;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
    static HWND sm_focusedWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
    static BOOL m_isWin95;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
    static BOOL m_isWin2000;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    static BOOL m_isWinNT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    static BOOL sm_bMenuLoop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
    static INLINE BOOL isMenuLoopActive() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
        return sm_bMenuLoop;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
    // when this component is being destroyed, this method is called
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
    // to find out if there are any messages being processed, and if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    // there are some then disposal of this component is postponed
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
    virtual BOOL CanBeDeleted() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
        return m_MessagesProcessing == 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
protected:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    static AwtComponent* GetComponentImpl(HWND hWnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    static int GetClickCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    HWND     m_hwnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    UINT     m_myControlID;     /* its own ID from the view point of parent */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    BOOL     m_backgroundColorSet;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
    BOOL     m_visible;         /* copy of Component.visible */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
    static BOOL sm_suppressFocusAndActivation;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    static HWND sm_realFocusOpposite;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    virtual void SetDragCapture(UINT flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
    virtual void ReleaseDragCapture(UINT flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
    // 95 support for mouse wheel
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
    static UINT sm_95WheelMessage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    static UINT sm_95WheelSupport;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
private:
447
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   715
    /* A bitmask keeps the button's numbers as MK_LBUTTON, MK_MBUTTON, MK_RBUTTON
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   716
     * which are allowed to
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   717
     * generate the CLICK event after the RELEASE has happened.
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   718
     * There are conditions that must be true for that sending CLICK event:
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   719
     * 1) button was initially PRESSED
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   720
     * 2) no movement or drag has happened until RELEASE
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   721
    */
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   722
    UINT m_mouseButtonClickAllowed;
0fb5f354ad70 6430553: MouseClick event should not be fired if MouseRelease happened without MousePress
dav
parents: 121
diff changeset
   723
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    BOOL m_bSubclassed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    COLORREF m_colorForeground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
    COLORREF m_colorBackground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
    AwtPen*  m_penForeground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    AwtBrush* m_brushBackground;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
    WNDPROC  m_DefWindowProc;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
    // counter for messages being processed by this component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
    UINT     m_MessagesProcessing;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
    // provides a unique ID for child controls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    UINT     m_nextControlID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    // DeferWindowPos handle for batched-up window positioning
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
    HDWP     m_hdwp;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    // Counter to handle nested calls to Begin/EndValidate
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
    UINT     m_validationNestCount;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    AwtDropTarget* m_dropTarget; // associated DropTarget object
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    // When we process WM_INPUTLANGCHANGE we remember the keyboard
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    // layout handle and associated input language and codepage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
    // We also invalidate VK translation table for VK_OEM_* codes
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    static HKL    m_hkl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
    static UINT   m_CodePage;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    static LANGID m_idLang;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    static BOOL sm_rtl;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
    static BOOL sm_rtlReadingOrder;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
    jobject m_InputMethod;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
    BOOL    m_useNativeCompWindow;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    LPARAM  m_bitsCandType;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
    UINT    m_PendingLeadByte;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    void SetComponentInHWND();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
    // Determines whether a given virtual key is on the numpad
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    static BOOL IsNumPadKey(UINT vkey, BOOL extended);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
    // Determines the keyLocation of a given key
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    static jint GetKeyLocation(UINT wkey, UINT flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    static jint GetShiftKeyLocation(UINT wkey, UINT flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    // Cache for FindComponent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    static HWND sm_cursorOn;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    static BOOL m_QueryNewPaletteCalled;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    BOOL m_skipNextSetFocus;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    static AwtComponent* sm_getComponentCache; // a cache for the GetComponent(..) method.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    int windowMoveLockPosX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
    int windowMoveLockPosY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
    int windowMoveLockPosCX;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
    int windowMoveLockPosCY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
121
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 2
diff changeset
   784
    // 6524352: support finer-resolution
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 2
diff changeset
   785
    static int sm_wheelRotationAmount;
c43b2dfab9ac 6524352: support for high-resolution mouse wheel
dcherepanov
parents: 2
diff changeset
   786
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
     * The association list of children's IDs and corresponding components.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
     * Some components like Choice or List are required their sizes while
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
     * the creations of themselfs are in progress.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    class ChildListItem {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
        ChildListItem(UINT id, AwtComponent* component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
            m_ID = id;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
            m_Component = component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
            m_next = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
        ~ChildListItem() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
            if (m_next != NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
                delete m_next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
        UINT m_ID;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
        AwtComponent* m_Component;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
        ChildListItem* m_next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
    };
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
    INLINE void PushChild(UINT id, AwtComponent* component) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
        ChildListItem* child = new ChildListItem(id, component);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
        child->m_next = m_childList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
        m_childList = child;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
    static void SetParent(void * param);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
private:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
    AwtComponent* SearchChild(UINT id);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
    void RemoveChild(UINT id) ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
    ChildListItem* m_childList;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    HCURSOR m_hCursorCache; // the latest cursor which has been active within the heavyweight component
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    inline void setCursorCache(HCURSOR hCursor) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
        m_hCursorCache = hCursor;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
    inline HCURSOR getCursorCache() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        return m_hCursorCache;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
class CounterHelper {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
private:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
    UINT *m_counter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
    explicit CounterHelper(UINT *counter) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
        m_counter = counter;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
        (*m_counter)++;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
    ~CounterHelper() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
        (*m_counter)--;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
        m_counter = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
// DC management objects; these classes are used to track the list of
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
// DC's associated with a given Component.  Then DC's can be released
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
// appropriately on demand or on window destruction to avoid resource
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
// leakage.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
class DCItem {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
    HDC             hDC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
    HWND            hWnd;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
    DCItem          *next;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
class DCList {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
    DCItem          *head;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
    CriticalSection listLock;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
public:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
    DCList() { head = NULL; }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    void            AddDC(HDC hDC, HWND hWnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
    void            AddDCItem(DCItem *newItem);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    DCItem          *RemoveDC(HDC hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    DCItem          *RemoveAllDCs(HWND hWnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    void            RealizePalettes(int screen);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
struct WmComponentSetFocusData {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    jobject lightweightChild;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    jboolean temporary;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
    jboolean focusedWindowChangeAllowed;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    jlong time;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
    jobject cause;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
void ReleaseDCList(HWND hwnd, DCList &list);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
void MoveDCToPassiveList(HDC hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
namespace TimeHelper{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
    jlong getMessageTimeUTC();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
    jlong windowsToUTC(DWORD event_offset);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
#include "ObjectList.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
#endif /* AWT_COMPONENT_H */