jdk/src/java.desktop/windows/native/libawt/sun/windows/awt_List.cpp
author ddehaven
Tue, 19 Aug 2014 10:32:16 -0700
changeset 26037 508779ce6619
parent 26005 jdk/src/windows/native/sun/windows/awt_List.cpp@25124e230434
parent 25859 jdk/src/windows/native/sun/windows/awt_List.cpp@3317bb8137f4
permissions -rw-r--r--
Merge
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
     1
/*
25194
2972c76c5a15 8040271: Uninitialised memory in jdk/src/windows/native/sun/windows: awt_List.cpp, awt_InputMethod.cpp
serb
parents: 24174
diff changeset
     2
 * Copyright (c) 1996, 2014, 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: 2464
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: 2464
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: 2464
diff changeset
    21
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2464
diff changeset
    22
 * or visit www.oracle.com if you need additional information or have any
202f599c92aa 6943119: Rebrand source copyright notices
ohair
parents: 2464
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
#include "awt_List.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    27
#include "awt_Canvas.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    28
#include "awt_Dimension.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    29
#include "awt_Toolkit.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    30
#include "awt_Window.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    31
90ce3da70b43 Initial load
duke
parents:
diff changeset
    32
#include "ComCtl32Util.h"
90ce3da70b43 Initial load
duke
parents:
diff changeset
    33
90ce3da70b43 Initial load
duke
parents:
diff changeset
    34
/* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code.
90ce3da70b43 Initial load
duke
parents:
diff changeset
    35
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    36
90ce3da70b43 Initial load
duke
parents:
diff changeset
    37
/***********************************************************************/
90ce3da70b43 Initial load
duke
parents:
diff changeset
    38
// struct for _AddItems() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    39
struct AddItemsStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    40
    jobject list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    41
    jobjectArray items;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    42
    jint index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    43
    jint width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    44
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    45
// struct for _DelItems() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    46
struct DelItemsStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    47
    jobject list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    48
    jint start, end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    49
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    50
// struct for _IsSelected(), _Select(), _Deselect() and _MakeVisible() methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    51
struct SelectElementStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    52
    jobject list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    53
    jint index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    54
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    55
// struct for _SetMultipleSelections() method
90ce3da70b43 Initial load
duke
parents:
diff changeset
    56
struct SetMultipleSelectionsStruct {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    57
    jobject list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    58
    jboolean on;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    59
};
90ce3da70b43 Initial load
duke
parents:
diff changeset
    60
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
    61
 * AwtList methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
    62
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    63
90ce3da70b43 Initial load
duke
parents:
diff changeset
    64
AwtList::AwtList() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    65
    isMultiSelect = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    66
    isWrapperPrint = FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    67
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    68
90ce3da70b43 Initial load
duke
parents:
diff changeset
    69
AwtList::~AwtList()
90ce3da70b43 Initial load
duke
parents:
diff changeset
    70
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    71
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    72
90ce3da70b43 Initial load
duke
parents:
diff changeset
    73
LPCTSTR AwtList::GetClassName() {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    74
    return TEXT("LISTBOX");
90ce3da70b43 Initial load
duke
parents:
diff changeset
    75
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
    76
90ce3da70b43 Initial load
duke
parents:
diff changeset
    77
/* Create a new AwtList object and window.   */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    78
AwtList* AwtList::Create(jobject peer, jobject parent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
    79
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
    80
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    81
90ce3da70b43 Initial load
duke
parents:
diff changeset
    82
    jobject target = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    83
    AwtList* c = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    84
90ce3da70b43 Initial load
duke
parents:
diff changeset
    85
    try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    86
        if (env->EnsureLocalCapacity(1) < 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
    87
            return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    88
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
    89
90ce3da70b43 Initial load
duke
parents:
diff changeset
    90
        PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    91
        AwtCanvas* awtParent;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    92
        JNI_CHECK_PEER_GOTO(parent, done);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    93
90ce3da70b43 Initial load
duke
parents:
diff changeset
    94
        awtParent = (AwtCanvas*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
    95
        JNI_CHECK_NULL_GOTO(awtParent, "null awtParent", done);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    96
90ce3da70b43 Initial load
duke
parents:
diff changeset
    97
        /* target is Hjava_awt_List * */
90ce3da70b43 Initial load
duke
parents:
diff changeset
    98
        target = env->GetObjectField(peer, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
    99
        JNI_CHECK_NULL_GOTO(target, "null target", done);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   100
90ce3da70b43 Initial load
duke
parents:
diff changeset
   101
        c = new AwtList();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   102
90ce3da70b43 Initial load
duke
parents:
diff changeset
   103
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   104
90ce3da70b43 Initial load
duke
parents:
diff changeset
   105
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   106
             * NOTE: WS_CLIPCHILDREN is excluded so that repaint requests
90ce3da70b43 Initial load
duke
parents:
diff changeset
   107
             * from Java will pass through the wrap to the native listbox.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   108
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   109
            DWORD wrapStyle = WS_CHILD | WS_CLIPSIBLINGS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   110
            DWORD wrapExStyle = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   111
90ce3da70b43 Initial load
duke
parents:
diff changeset
   112
            DWORD style = WS_CHILD | WS_CLIPSIBLINGS | WS_VSCROLL | WS_HSCROLL |
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   113
                LBS_NOINTEGRALHEIGHT | LBS_NOTIFY | LBS_OWNERDRAWFIXED;
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   114
            DWORD exStyle = WS_EX_CLIENTEDGE;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   115
90ce3da70b43 Initial load
duke
parents:
diff changeset
   116
            /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   117
             * NOTE: WS_VISIBLE is always set for the listbox. Listbox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   118
             * visibility is controlled by toggling the wrap's WS_VISIBLE bit.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   119
             */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   120
            style |= WS_VISIBLE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   121
90ce3da70b43 Initial load
duke
parents:
diff changeset
   122
            if (GetRTL()) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   123
                exStyle |= WS_EX_RIGHT | WS_EX_LEFTSCROLLBAR;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   124
                if (GetRTLReadingOrder())
90ce3da70b43 Initial load
duke
parents:
diff changeset
   125
                    exStyle |= WS_EX_RTLREADING;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   126
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   127
90ce3da70b43 Initial load
duke
parents:
diff changeset
   128
            jint x = env->GetIntField(target, AwtComponent::xID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   129
            jint y = env->GetIntField(target, AwtComponent::yID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   130
            jint width = env->GetIntField(target, AwtComponent::widthID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   131
            jint height = env->GetIntField(target, AwtComponent::heightID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   132
90ce3da70b43 Initial load
duke
parents:
diff changeset
   133
            c->CreateHWnd(env, L"", style, exStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   134
                          x, y, width, height,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   135
                          awtParent->GetHWnd(),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   136
                          NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   137
                          ::GetSysColor(COLOR_WINDOWTEXT),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   138
                          ::GetSysColor(COLOR_WINDOW),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   139
                          peer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   140
                          );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   141
90ce3da70b43 Initial load
duke
parents:
diff changeset
   142
            /* suppress inheriting awtParent's color. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   143
            c->m_backgroundColorSet = TRUE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   144
            c->UpdateBackground(env, target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   145
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   146
    } catch (...) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   147
        env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   148
        throw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   149
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   150
90ce3da70b43 Initial load
duke
parents:
diff changeset
   151
done:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   152
    env->DeleteLocalRef(target);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   153
    return c;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   154
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   155
90ce3da70b43 Initial load
duke
parents:
diff changeset
   156
void AwtList::SetDragCapture(UINT flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   157
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   158
    // don't want to interfere with other controls
90ce3da70b43 Initial load
duke
parents:
diff changeset
   159
    if (::GetCapture() == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   160
        ::SetCapture(GetListHandle());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   161
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   162
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   163
90ce3da70b43 Initial load
duke
parents:
diff changeset
   164
void AwtList::ReleaseDragCapture(UINT flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   165
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   166
    if ((::GetCapture() == GetListHandle()) && ((flags & ALL_MK_BUTTONS) == 0)) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   167
        ::ReleaseCapture();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   168
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   169
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   170
90ce3da70b43 Initial load
duke
parents:
diff changeset
   171
void AwtList::Reshape(int x, int y, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   172
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   173
    AwtComponent::Reshape(x, y, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   174
90ce3da70b43 Initial load
duke
parents:
diff changeset
   175
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   176
    HWND hList = GetListHandle();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   177
    if (hList != NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   178
        long flags = SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   179
        /*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   180
         * Fix for bug 4046446.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   181
         * /
90ce3da70b43 Initial load
duke
parents:
diff changeset
   182
        SetWindowPos(hList, 0, 0, 0, w, h, flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   183
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   184
*/
90ce3da70b43 Initial load
duke
parents:
diff changeset
   185
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   186
90ce3da70b43 Initial load
duke
parents:
diff changeset
   187
//Netscape : Override the AwtComponent method so we can set the item height
90ce3da70b43 Initial load
duke
parents:
diff changeset
   188
//for each item in the list.  Modified by echawkes to avoid race condition.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   189
90ce3da70b43 Initial load
duke
parents:
diff changeset
   190
void AwtList::SetFont(AwtFont* font)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   191
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   192
    DASSERT(font != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   193
    if (font->GetAscent() < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   194
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   195
        AwtFont::SetupAscent(font);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   196
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   197
    HANDLE hFont = font->GetHFont();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   198
    SendListMessage(WM_SETFONT, (WPARAM)hFont, MAKELPARAM(FALSE, 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   199
90ce3da70b43 Initial load
duke
parents:
diff changeset
   200
    HDC hDC = ::GetDC(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   201
90ce3da70b43 Initial load
duke
parents:
diff changeset
   202
    TEXTMETRIC tm;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   203
    VERIFY(::SelectObject(hDC, hFont) != NULL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   204
    VERIFY(::GetTextMetrics(hDC, &tm));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   205
90ce3da70b43 Initial load
duke
parents:
diff changeset
   206
    ::ReleaseDC(GetHWnd(), hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   207
90ce3da70b43 Initial load
duke
parents:
diff changeset
   208
    long h = tm.tmHeight + tm.tmExternalLeading;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   209
    // Listbox is LBS_OWNERDRAWFIXED so the items have the same height
90ce3da70b43 Initial load
duke
parents:
diff changeset
   210
    VERIFY(SendListMessage(LB_SETITEMHEIGHT, 0, MAKELPARAM(h, 0)) != LB_ERR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   211
    VERIFY(::RedrawWindow(GetHWnd(), NULL, NULL, RDW_INVALIDATE |RDW_FRAME |RDW_ERASE));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   212
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   213
90ce3da70b43 Initial load
duke
parents:
diff changeset
   214
void AwtList::SetMultiSelect(BOOL ms) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   215
    if (ms == isMultiSelect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   216
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   217
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   218
90ce3da70b43 Initial load
duke
parents:
diff changeset
   219
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   220
90ce3da70b43 Initial load
duke
parents:
diff changeset
   221
    /* Copy current box's contents to string array */
25194
2972c76c5a15 8040271: Uninitialised memory in jdk/src/windows/native/sun/windows: awt_List.cpp, awt_InputMethod.cpp
serb
parents: 24174
diff changeset
   222
    const int nCount = GetCount();
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   223
    LPTSTR * strings = new LPTSTR[nCount];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   224
    int i;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   225
90ce3da70b43 Initial load
duke
parents:
diff changeset
   226
    for(i = 0; i < nCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   227
        LRESULT len = SendListMessage(LB_GETTEXTLEN, i);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   228
        LPTSTR text = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   229
        try {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   230
            text = new TCHAR[len + 1];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   231
        } catch (std::bad_alloc&) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   232
            // free char * already allocated
90ce3da70b43 Initial load
duke
parents:
diff changeset
   233
            for (int j = 0; j < i; j++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   234
                delete [] strings[j];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   235
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   236
            delete [] strings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   237
            throw;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   238
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   239
90ce3da70b43 Initial load
duke
parents:
diff changeset
   240
        VERIFY(SendListMessage(LB_GETTEXT, i, (LPARAM)text) != LB_ERR);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   241
        strings[i] = text;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   242
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   243
90ce3da70b43 Initial load
duke
parents:
diff changeset
   244
    // index for selected item after multi-select mode change
90ce3da70b43 Initial load
duke
parents:
diff changeset
   245
    int toSelect = SendListMessage(LB_GETCURSEL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   246
    if (!isMultiSelect)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   247
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   248
        // MSDN: for single-select lists LB_GETCURSEL returns
90ce3da70b43 Initial load
duke
parents:
diff changeset
   249
        // index of selected item or LB_ERR if no item is selected
90ce3da70b43 Initial load
duke
parents:
diff changeset
   250
        if (toSelect == LB_ERR)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   251
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   252
            toSelect = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   253
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   254
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   255
    else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   256
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   257
        // MSDN: for multi-select lists LB_GETCURSEL returns index
90ce3da70b43 Initial load
duke
parents:
diff changeset
   258
        // of the focused item or 0 if no items are selected; if
90ce3da70b43 Initial load
duke
parents:
diff changeset
   259
        // some item has focus and is not selected then LB_GETCURSEL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   260
        // return its index, so we need IsItemSelected too
90ce3da70b43 Initial load
duke
parents:
diff changeset
   261
        if ((toSelect == LB_ERR) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   262
            (SendListMessage(LB_GETSELCOUNT) == 0) ||
90ce3da70b43 Initial load
duke
parents:
diff changeset
   263
            (IsItemSelected(toSelect) == 0))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   264
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   265
            toSelect = -1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   266
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   267
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   268
90ce3da70b43 Initial load
duke
parents:
diff changeset
   269
    isMultiSelect = ms;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   270
90ce3da70b43 Initial load
duke
parents:
diff changeset
   271
    HWND parentHWnd = GetParent()->GetHWnd();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   272
90ce3da70b43 Initial load
duke
parents:
diff changeset
   273
    /* Save old list box's attributes */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   274
    RECT rect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   275
    GetWindowRect(GetListHandle(), &rect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   276
    MapWindowPoints(0, parentHWnd, (LPPOINT)&rect, 2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   277
90ce3da70b43 Initial load
duke
parents:
diff changeset
   278
    HANDLE font = (HANDLE)SendListMessage(WM_GETFONT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   279
    LRESULT itemHeight = SendListMessage(LB_GETITEMHEIGHT, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   280
    DWORD style = ::GetWindowLong(GetListHandle(), GWL_STYLE) | WS_VSCROLL | WS_HSCROLL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   281
    if (isMultiSelect) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   282
        style |= LBS_MULTIPLESEL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   283
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   284
        style &= ~LBS_MULTIPLESEL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   285
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   286
    DWORD exStyle = ::GetWindowLong(GetListHandle(), GWL_EXSTYLE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   287
90ce3da70b43 Initial load
duke
parents:
diff changeset
   288
    jobject peer = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   289
90ce3da70b43 Initial load
duke
parents:
diff changeset
   290
    UnsubclassHWND();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   291
    AwtToolkit::DestroyComponentHWND(m_hwnd);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   292
    CreateHWnd(env, L"", style, exStyle,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   293
               rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   294
               parentHWnd,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   295
               NULL,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   296
               ::GetSysColor(COLOR_WINDOWTEXT),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   297
               ::GetSysColor(COLOR_WINDOW),
90ce3da70b43 Initial load
duke
parents:
diff changeset
   298
               peer);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   299
90ce3da70b43 Initial load
duke
parents:
diff changeset
   300
    SendListMessage(WM_SETFONT, (WPARAM)font, (LPARAM)FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   301
    SendListMessage(LB_SETITEMHEIGHT, 0, MAKELPARAM(itemHeight, 0));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   302
    SendListMessage(LB_RESETCONTENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   303
    for (i = 0; i < nCount; i++) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   304
        InsertString(i, strings[i]);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   305
        delete [] strings[i];
90ce3da70b43 Initial load
duke
parents:
diff changeset
   306
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   307
    delete[] strings;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   308
    if (toSelect != -1) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   309
        Select(toSelect);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   310
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   311
90ce3da70b43 Initial load
duke
parents:
diff changeset
   312
    AdjustHorizontalScrollbar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   313
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   314
90ce3da70b43 Initial load
duke
parents:
diff changeset
   315
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   316
 * There currently is no good place to cache java.awt.Dimension field
90ce3da70b43 Initial load
duke
parents:
diff changeset
   317
 * ids. If this method gets called a lot, one such place should be found.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   318
 * -- br 07/18/97.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   319
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   320
jobject AwtList::PreferredItemSize(JNIEnv *env)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   321
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   322
    jobject peer = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   323
    jobject dimension = JNU_CallMethodByName(env, NULL, peer, "preferredSize",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   324
                                             "(I)Ljava/awt/Dimension;",
90ce3da70b43 Initial load
duke
parents:
diff changeset
   325
                                             1).l;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   326
90ce3da70b43 Initial load
duke
parents:
diff changeset
   327
    DASSERT(!safe_ExceptionOccurred(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   328
    if (dimension == NULL) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   329
        return NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   330
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   331
    /* This size is too big for each item height. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   332
    (env)->SetIntField(dimension, AwtDimension::heightID, GetFontHeight(env));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   333
90ce3da70b43 Initial load
duke
parents:
diff changeset
   334
    return dimension;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   335
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   336
90ce3da70b43 Initial load
duke
parents:
diff changeset
   337
// Every time something gets added to the list, we increase the max width
90ce3da70b43 Initial load
duke
parents:
diff changeset
   338
// of items that have ever been added.  If it surpasses the width of the
90ce3da70b43 Initial load
duke
parents:
diff changeset
   339
// listbox, we show the scrollbar.  When things get deleted, we shrink
90ce3da70b43 Initial load
duke
parents:
diff changeset
   340
// the scroll region back down and hide the scrollbar, if needed.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   341
void AwtList::AdjustHorizontalScrollbar()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   342
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   343
    // The border width is added to the horizontal extent to ensure that we
90ce3da70b43 Initial load
duke
parents:
diff changeset
   344
    // can view all of the text when we move the horz. scrollbar to the end.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   345
    int  cxBorders = GetSystemMetrics( SM_CXBORDER ) * 2;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   346
    RECT rect;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   347
    VERIFY(::GetClientRect(GetListHandle(), &rect));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   348
    LRESULT iHorzExt = SendListMessage(LB_GETHORIZONTALEXTENT, 0, 0L ) - cxBorders;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   349
    if ( (m_nMaxWidth > rect.left)  // if strings wider than listbox
90ce3da70b43 Initial load
duke
parents:
diff changeset
   350
      || (iHorzExt != m_nMaxWidth) ) //   or scrollbar not needed anymore.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   351
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   352
        SendListMessage(LB_SETHORIZONTALEXTENT, m_nMaxWidth + cxBorders, 0L);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   353
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   354
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   355
90ce3da70b43 Initial load
duke
parents:
diff changeset
   356
// This function goes through all strings in the list to find the width,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   357
// in pixels, of the longest string in the list.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   358
void AwtList::UpdateMaxItemWidth()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   359
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   360
    m_nMaxWidth = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   361
90ce3da70b43 Initial load
duke
parents:
diff changeset
   362
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   363
    if (env->EnsureLocalCapacity(2) < 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   364
        return;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   365
90ce3da70b43 Initial load
duke
parents:
diff changeset
   366
    HDC hDC = ::GetDC(GetHWnd());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   367
90ce3da70b43 Initial load
duke
parents:
diff changeset
   368
    jobject self = GetPeer(env);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   369
    DASSERT(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   370
90ce3da70b43 Initial load
duke
parents:
diff changeset
   371
    /* target is java.awt.List */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   372
    jobject target = env->GetObjectField(self, AwtObject::targetID);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   373
    jobject font = GET_FONT(target, self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   374
90ce3da70b43 Initial load
duke
parents:
diff changeset
   375
    int nCount = GetCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   376
    for ( int i=0; i < nCount; i++ )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   377
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   378
        jstring jstr = GetItemString( env, target, i );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   379
        SIZE size = AwtFont::getMFStringSize( hDC, font, jstr );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   380
        if ( size.cx > m_nMaxWidth )
90ce3da70b43 Initial load
duke
parents:
diff changeset
   381
            m_nMaxWidth = size.cx;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   382
        env->DeleteLocalRef( jstr );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   383
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   384
90ce3da70b43 Initial load
duke
parents:
diff changeset
   385
    // free up the shared DC and release local refs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   386
    ::ReleaseDC(GetHWnd(), hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   387
    env->DeleteLocalRef( target );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   388
    env->DeleteLocalRef( font );
90ce3da70b43 Initial load
duke
parents:
diff changeset
   389
90ce3da70b43 Initial load
duke
parents:
diff changeset
   390
    // Now adjust the horizontal scrollbar extent
90ce3da70b43 Initial load
duke
parents:
diff changeset
   391
    AdjustHorizontalScrollbar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   392
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   393
90ce3da70b43 Initial load
duke
parents:
diff changeset
   394
MsgRouting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   395
AwtList::WmSize(UINT type, int w, int h)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   396
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   397
    AdjustHorizontalScrollbar();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   398
    return AwtComponent::WmSize(type, w, h);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   399
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   400
90ce3da70b43 Initial load
duke
parents:
diff changeset
   401
MsgRouting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   402
AwtList::OwnerDrawItem(UINT /*ctrlId*/, DRAWITEMSTRUCT& drawInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   403
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   404
    AwtComponent::DrawListItem((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), drawInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   405
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   406
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   407
90ce3da70b43 Initial load
duke
parents:
diff changeset
   408
MsgRouting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   409
AwtList::OwnerMeasureItem(UINT /*ctrlId*/, MEASUREITEMSTRUCT& measureInfo)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   410
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   411
    AwtComponent::MeasureListItem((JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2), measureInfo);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   412
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   413
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   414
90ce3da70b43 Initial load
duke
parents:
diff changeset
   415
MsgRouting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   416
AwtList::WmNcHitTest(UINT x, UINT y, LRESULT& retVal)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   417
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   418
    if (::IsWindow(AwtWindow::GetModalBlocker(AwtComponent::GetTopLevelParentForWindow(GetHWnd())))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   419
        retVal = HTCLIENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   420
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   421
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   422
    return AwtComponent::WmNcHitTest(x, y, retVal);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   423
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   424
90ce3da70b43 Initial load
duke
parents:
diff changeset
   425
MsgRouting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   426
AwtList::WmMouseUp(UINT flags, int x, int y, int button)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   427
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   428
    MsgRouting result = mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   429
    // if this list is in the modal blocked window, this message should be consumed,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   430
    // however AwtComponent::WmMouseUp must be called anyway
90ce3da70b43 Initial load
duke
parents:
diff changeset
   431
    if (::IsWindow(AwtWindow::GetModalBlocker(AwtComponent::GetTopLevelParentForWindow(GetHWnd())))) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   432
        result = mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   433
    } else {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   434
        if (button == LEFT_BUTTON) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   435
            WmCommand(0, GetListHandle(), LBN_SELCHANGE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   436
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   437
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   438
    MsgRouting compResult = AwtComponent::WmMouseUp(flags, x, y, button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   439
    return (result == mrConsume) ? result : compResult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   440
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   441
90ce3da70b43 Initial load
duke
parents:
diff changeset
   442
MsgRouting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   443
AwtList::WmMouseDown(UINT flags, int x, int y, int button)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   444
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   445
    MsgRouting mrResult = AwtComponent::WmMouseDown(flags, x, y, button);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   446
90ce3da70b43 Initial load
duke
parents:
diff changeset
   447
    if (::IsWindow(AwtWindow::GetModalBlocker(AwtComponent::GetTopLevelParentForWindow(GetHWnd()))))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   448
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   449
        return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   450
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   451
90ce3da70b43 Initial load
duke
parents:
diff changeset
   452
    /*
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   453
     * As we consume WM_LBUTONDOWN the list won't trigger ActionEvent by double click.
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   454
     * We trigger it ourselves. (see also 6240202)
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   455
     */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   456
    int clickCount = GetClickCount();
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   457
    if (button == LEFT_BUTTON && clickCount >= 2 && clickCount % 2 == 0) {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   458
        WmCommand(0, GetListHandle(), LBN_DBLCLK);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   459
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   460
    return mrResult;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   461
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   462
90ce3da70b43 Initial load
duke
parents:
diff changeset
   463
MsgRouting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   464
AwtList::WmCtlColor(HDC hDC, HWND hCtrl, UINT ctlColor, HBRUSH& retBrush)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   465
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   466
    DASSERT(ctlColor == CTLCOLOR_LISTBOX);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   467
    DASSERT(hCtrl == GetListHandle());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   468
    ::SetBkColor(hDC, GetBackgroundColor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   469
    ::SetTextColor(hDC, GetColor());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   470
    retBrush = GetBackgroundBrush();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   471
    return mrConsume;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   472
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   473
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   474
BOOL AwtList::IsFocusingMouseMessage(MSG *pMsg)
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   475
{
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   476
    return pMsg->message == WM_LBUTTONDOWN || pMsg->message == WM_LBUTTONDBLCLK;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   477
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   478
90ce3da70b43 Initial load
duke
parents:
diff changeset
   479
MsgRouting AwtList::HandleEvent(MSG *msg, BOOL synthetic)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   480
{
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   481
    if (IsFocusingMouseMessage(msg)) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   482
        LONG item = static_cast<LONG>(SendListMessage(LB_ITEMFROMPOINT, 0, msg->lParam));
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   483
        if (item != LB_ERR) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   484
            if (isMultiSelect) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   485
                if (IsItemSelected(item)) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   486
                    Deselect(item);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   487
                } else {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   488
                    Select(item);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   489
                }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   490
            } else {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   491
                Select(item);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   492
            }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   493
        }
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   494
        delete msg;
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   495
        return mrConsume;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   496
    }
2464
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   497
    if (msg->message == WM_KEYDOWN && msg->wParam == VK_RETURN) {
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   498
        WmNotify(LBN_DBLCLK);
3c6755bdc55f 6806217: implement synthetic focus model for MS Windows
ant
parents: 1954
diff changeset
   499
    }
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   500
    return AwtComponent::HandleEvent(msg, synthetic);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   501
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   502
90ce3da70b43 Initial load
duke
parents:
diff changeset
   503
// Fix for 4665745.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   504
// Override WmPrint to catch when the list control (not wrapper) should
90ce3da70b43 Initial load
duke
parents:
diff changeset
   505
// operate WM_PRINT to be compatible with the "smooth scrolling" feature.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   506
MsgRouting AwtList::WmPrint(HDC hDC, LPARAM flags)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   507
{
1954
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   508
    if (!isWrapperPrint &&
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   509
        (flags & PRF_CLIENT) &&
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   510
        (GetStyleEx() & WS_EX_CLIENTEDGE))
b93b85df3211 6585765: RFE: Remove Unicows-related code from AWT
art
parents: 2
diff changeset
   511
    {
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   512
        int nOriginalDC = ::SaveDC(hDC);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   513
        DASSERT(nOriginalDC != 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   514
        // Save a copy of the DC for WmPrintClient
90ce3da70b43 Initial load
duke
parents:
diff changeset
   515
        VERIFY(::SaveDC(hDC));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   516
        DefWindowProc(WM_PRINT, (WPARAM) hDC,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   517
            (flags & (PRF_CLIENT | PRF_CHECKVISIBLE | PRF_ERASEBKGND)));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   518
        VERIFY(::RestoreDC(hDC, nOriginalDC));
90ce3da70b43 Initial load
duke
parents:
diff changeset
   519
90ce3da70b43 Initial load
duke
parents:
diff changeset
   520
        flags &= ~PRF_CLIENT;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   521
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   522
90ce3da70b43 Initial load
duke
parents:
diff changeset
   523
    return AwtComponent::WmPrint(hDC, flags);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   524
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   525
90ce3da70b43 Initial load
duke
parents:
diff changeset
   526
MsgRouting
90ce3da70b43 Initial load
duke
parents:
diff changeset
   527
AwtList::WmNotify(UINT notifyCode)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   528
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   529
    if (notifyCode == LBN_SELCHANGE || notifyCode == LBN_DBLCLK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   530
        /* Fixed an asserion failure when clicking on an empty List. */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   531
        int nCurrentSelection = SendListMessage(LB_GETCURSEL);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   532
        if (nCurrentSelection != LB_ERR && GetCount() > 0) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   533
            if (notifyCode == LBN_SELCHANGE) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   534
                DoCallback("handleListChanged", "(I)V", nCurrentSelection);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   535
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   536
            else if (notifyCode == LBN_DBLCLK) {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   537
                DoCallback("handleAction", "(IJI)V", nCurrentSelection,
26005
25124e230434 8046495: KeyEvent can not be accepted in quick mouse clicking
anashaty
parents: 25771
diff changeset
   538
                           ::JVM_CurrentTimeMillis(NULL, 0),
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   539
                           (jint)AwtComponent::GetJavaModifiers());
90ce3da70b43 Initial load
duke
parents:
diff changeset
   540
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   541
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   542
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   543
    return mrDoDefault;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   544
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   545
90ce3da70b43 Initial load
duke
parents:
diff changeset
   546
BOOL AwtList::InheritsNativeMouseWheelBehavior() {return true;}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   547
90ce3da70b43 Initial load
duke
parents:
diff changeset
   548
jint AwtList::_GetMaxWidth(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   549
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   550
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   551
90ce3da70b43 Initial load
duke
parents:
diff changeset
   552
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   553
90ce3da70b43 Initial load
duke
parents:
diff changeset
   554
    jint result = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   555
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   556
90ce3da70b43 Initial load
duke
parents:
diff changeset
   557
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   558
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   559
    l = (AwtList *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   560
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   561
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   562
        result = l->GetMaxWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   563
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   564
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   565
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   566
90ce3da70b43 Initial load
duke
parents:
diff changeset
   567
    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   568
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   569
90ce3da70b43 Initial load
duke
parents:
diff changeset
   570
void AwtList::_UpdateMaxItemWidth(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   571
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   572
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   573
90ce3da70b43 Initial load
duke
parents:
diff changeset
   574
    jobject self = (jobject)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   575
90ce3da70b43 Initial load
duke
parents:
diff changeset
   576
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   577
90ce3da70b43 Initial load
duke
parents:
diff changeset
   578
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   579
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   580
    l = (AwtList *)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   581
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   582
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   583
        l->UpdateMaxItemWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   584
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   585
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   586
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   587
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   588
90ce3da70b43 Initial load
duke
parents:
diff changeset
   589
void AwtList::_AddItems(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   590
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   591
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   592
90ce3da70b43 Initial load
duke
parents:
diff changeset
   593
    AddItemsStruct *ais = (AddItemsStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   594
    jobject self = ais->list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   595
    jobjectArray items = ais->items;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   596
    jint index = ais->index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   597
    jint width = ais->width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   598
90ce3da70b43 Initial load
duke
parents:
diff changeset
   599
    int badAlloc = 0;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   600
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   601
90ce3da70b43 Initial load
duke
parents:
diff changeset
   602
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   603
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   604
    JNI_CHECK_NULL_GOTO(items, "null items", ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   605
    l = (AwtList*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   606
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   607
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   608
        int itemCount = env->GetArrayLength(items);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   609
        if (itemCount > 0)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   610
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   611
            AwtList* l = (AwtList*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   612
            l->SendListMessage(WM_SETREDRAW, (WPARAM)FALSE, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   613
            for (jsize i=0; i < itemCount; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   614
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   615
                LPTSTR itemPtr = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   616
                jstring item = (jstring)env->GetObjectArrayElement(items, i);
24174
ea4435b45c3e 8035739: [parfait] JNI exception pending and primitive type mismatch in jdk/src/windows/native/sun/windows/awt_List.cpp
pchelko
parents: 5506
diff changeset
   617
                if (env->ExceptionCheck()) goto ret;
ea4435b45c3e 8035739: [parfait] JNI exception pending and primitive type mismatch in jdk/src/windows/native/sun/windows/awt_List.cpp
pchelko
parents: 5506
diff changeset
   618
                if (item == NULL) goto next_item;
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
   619
                itemPtr = (LPTSTR)JNU_GetStringPlatformChars(env, item, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   620
                if (itemPtr == NULL)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   621
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   622
                    badAlloc = 1;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   623
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   624
                else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   625
                {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   626
                    l->InsertString(index+i, itemPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   627
                    JNU_ReleaseStringPlatformChars(env, item, itemPtr);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   628
                }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   629
                env->DeleteLocalRef(item);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   630
next_item:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   631
                ;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   632
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   633
            l->SendListMessage(WM_SETREDRAW, (WPARAM)TRUE, 0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   634
            l->InvalidateList(NULL, TRUE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   635
            l->CheckMaxWidth(width);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   636
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   637
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   638
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   639
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   640
    env->DeleteGlobalRef(items);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   641
90ce3da70b43 Initial load
duke
parents:
diff changeset
   642
    delete ais;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   643
90ce3da70b43 Initial load
duke
parents:
diff changeset
   644
    if (badAlloc)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   645
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   646
        throw std::bad_alloc();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   647
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   648
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   649
90ce3da70b43 Initial load
duke
parents:
diff changeset
   650
void AwtList::_DelItems(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   651
{        JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   652
90ce3da70b43 Initial load
duke
parents:
diff changeset
   653
    DelItemsStruct *dis = (DelItemsStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   654
    jobject self = dis->list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   655
    jint start = dis->start;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   656
    jint end = dis->end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   657
90ce3da70b43 Initial load
duke
parents:
diff changeset
   658
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   659
90ce3da70b43 Initial load
duke
parents:
diff changeset
   660
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   661
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   662
    l = (AwtList*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   663
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   664
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   665
        int count = l->GetCount();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   666
90ce3da70b43 Initial load
duke
parents:
diff changeset
   667
        if (start == 0 && end == count)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   668
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   669
            l->SendListMessage(LB_RESETCONTENT);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   670
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   671
        else
90ce3da70b43 Initial load
duke
parents:
diff changeset
   672
        {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   673
            for (int i = start; i <= end; i++)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   674
            {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   675
                l->SendListMessage(LB_DELETESTRING, start);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   676
            }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   677
        }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   678
90ce3da70b43 Initial load
duke
parents:
diff changeset
   679
        l->UpdateMaxItemWidth();
90ce3da70b43 Initial load
duke
parents:
diff changeset
   680
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   681
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   682
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   683
90ce3da70b43 Initial load
duke
parents:
diff changeset
   684
    delete dis;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   685
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   686
90ce3da70b43 Initial load
duke
parents:
diff changeset
   687
void AwtList::_Select(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   688
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   689
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   690
90ce3da70b43 Initial load
duke
parents:
diff changeset
   691
    SelectElementStruct *ses = (SelectElementStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   692
    jobject self = ses->list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   693
    jint index = ses->index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   694
90ce3da70b43 Initial load
duke
parents:
diff changeset
   695
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   696
90ce3da70b43 Initial load
duke
parents:
diff changeset
   697
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   698
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   699
    l = (AwtList*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   700
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   701
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   702
        l->Select(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   703
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   704
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   705
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   706
90ce3da70b43 Initial load
duke
parents:
diff changeset
   707
    delete ses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   708
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   709
90ce3da70b43 Initial load
duke
parents:
diff changeset
   710
void AwtList::_Deselect(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   711
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   712
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   713
90ce3da70b43 Initial load
duke
parents:
diff changeset
   714
    SelectElementStruct *ses = (SelectElementStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   715
    jobject self = ses->list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   716
    jint index = ses->index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   717
90ce3da70b43 Initial load
duke
parents:
diff changeset
   718
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   719
90ce3da70b43 Initial load
duke
parents:
diff changeset
   720
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   721
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   722
    l = (AwtList*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   723
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   724
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   725
        l->Deselect(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   726
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   727
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   728
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   729
90ce3da70b43 Initial load
duke
parents:
diff changeset
   730
    delete ses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   731
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   732
90ce3da70b43 Initial load
duke
parents:
diff changeset
   733
void AwtList::_MakeVisible(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   734
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   735
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   736
90ce3da70b43 Initial load
duke
parents:
diff changeset
   737
    SelectElementStruct *ses = (SelectElementStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   738
    jobject self = ses->list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   739
    jint index = ses->index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   740
90ce3da70b43 Initial load
duke
parents:
diff changeset
   741
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   742
90ce3da70b43 Initial load
duke
parents:
diff changeset
   743
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   744
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   745
    l = (AwtList*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   746
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   747
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   748
        l->SendListMessage(LB_SETTOPINDEX, index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   749
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   750
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   751
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   752
90ce3da70b43 Initial load
duke
parents:
diff changeset
   753
    delete ses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   754
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   755
90ce3da70b43 Initial load
duke
parents:
diff changeset
   756
jboolean AwtList::_IsSelected(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   757
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   758
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   759
90ce3da70b43 Initial load
duke
parents:
diff changeset
   760
    SelectElementStruct *ses = (SelectElementStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   761
    jobject self = ses->list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   762
    jint index = ses->index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   763
90ce3da70b43 Initial load
duke
parents:
diff changeset
   764
    jboolean result = JNI_FALSE;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   765
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   766
90ce3da70b43 Initial load
duke
parents:
diff changeset
   767
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   768
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   769
    l = (AwtList*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   770
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   771
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   772
        result = l->IsItemSelected(index);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   773
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   774
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   775
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   776
90ce3da70b43 Initial load
duke
parents:
diff changeset
   777
    delete ses;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   778
90ce3da70b43 Initial load
duke
parents:
diff changeset
   779
    return result;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   780
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   781
90ce3da70b43 Initial load
duke
parents:
diff changeset
   782
void AwtList::_SetMultipleSelections(void *param)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   783
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   784
    JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   785
90ce3da70b43 Initial load
duke
parents:
diff changeset
   786
    SetMultipleSelectionsStruct *sms = (SetMultipleSelectionsStruct *)param;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   787
    jobject self = sms->list;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   788
    jboolean on = sms->on;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   789
90ce3da70b43 Initial load
duke
parents:
diff changeset
   790
    AwtList *l = NULL;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   791
90ce3da70b43 Initial load
duke
parents:
diff changeset
   792
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   793
    JNI_CHECK_PEER_GOTO(self, ret);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   794
    l = (AwtList*)pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   795
    if (::IsWindow(l->GetHWnd()))
90ce3da70b43 Initial load
duke
parents:
diff changeset
   796
    {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   797
        AwtToolkit::GetInstance().SendMessage(WM_AWT_LIST_SETMULTISELECT,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   798
                                              (WPARAM)self, on);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   799
    }
90ce3da70b43 Initial load
duke
parents:
diff changeset
   800
ret:
90ce3da70b43 Initial load
duke
parents:
diff changeset
   801
    env->DeleteGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   802
90ce3da70b43 Initial load
duke
parents:
diff changeset
   803
    delete sms;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   804
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   805
90ce3da70b43 Initial load
duke
parents:
diff changeset
   806
/************************************************************************
90ce3da70b43 Initial load
duke
parents:
diff changeset
   807
 * WListPeer native methods
90ce3da70b43 Initial load
duke
parents:
diff changeset
   808
 *
90ce3da70b43 Initial load
duke
parents:
diff changeset
   809
 * This class seems to have numerous bugs in it, but they are all bugs
90ce3da70b43 Initial load
duke
parents:
diff changeset
   810
 * which were present before conversion to JNI. -br.
90ce3da70b43 Initial load
duke
parents:
diff changeset
   811
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   812
90ce3da70b43 Initial load
duke
parents:
diff changeset
   813
extern "C" {
90ce3da70b43 Initial load
duke
parents:
diff changeset
   814
90ce3da70b43 Initial load
duke
parents:
diff changeset
   815
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   816
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   817
 * Method:    getMaxWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   818
 * Signature: ()I
90ce3da70b43 Initial load
duke
parents:
diff changeset
   819
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   820
JNIEXPORT jint JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   821
Java_sun_awt_windows_WListPeer_getMaxWidth(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   822
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   823
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   824
90ce3da70b43 Initial load
duke
parents:
diff changeset
   825
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   826
90ce3da70b43 Initial load
duke
parents:
diff changeset
   827
    return (jint)AwtToolkit::GetInstance().SyncCall(
90ce3da70b43 Initial load
duke
parents:
diff changeset
   828
        (void *(*)(void *))AwtList::_GetMaxWidth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   829
        (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   830
    // selfGlobalRef is deleted in _GetMaxWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   831
90ce3da70b43 Initial load
duke
parents:
diff changeset
   832
    CATCH_BAD_ALLOC_RET(0);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   833
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   834
90ce3da70b43 Initial load
duke
parents:
diff changeset
   835
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   836
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   837
 * Method:    updateMaxItemWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   838
 * Signature: ()V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   839
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   840
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   841
Java_sun_awt_windows_WListPeer_updateMaxItemWidth(JNIEnv *env, jobject self)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   842
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   843
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   844
90ce3da70b43 Initial load
duke
parents:
diff changeset
   845
    jobject selfGlobalRef = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   846
90ce3da70b43 Initial load
duke
parents:
diff changeset
   847
    AwtToolkit::GetInstance().SyncCall(AwtList::_UpdateMaxItemWidth,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   848
        (void *)selfGlobalRef);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   849
    // selfGlobalRef is deleted in _UpdateMaxItemWidth
90ce3da70b43 Initial load
duke
parents:
diff changeset
   850
90ce3da70b43 Initial load
duke
parents:
diff changeset
   851
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   852
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   853
90ce3da70b43 Initial load
duke
parents:
diff changeset
   854
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   855
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   856
 * Method:    addItems
90ce3da70b43 Initial load
duke
parents:
diff changeset
   857
 * Signature: ([Ljava/lang/String;II)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   858
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   859
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   860
Java_sun_awt_windows_WListPeer_addItems(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   861
                                        jobjectArray items, jint index, jint width)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   862
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   863
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   864
90ce3da70b43 Initial load
duke
parents:
diff changeset
   865
    AddItemsStruct *ais = new AddItemsStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   866
    ais->list = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   867
    ais->items = (jobjectArray)env->NewGlobalRef(items);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   868
    ais->index = index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   869
    ais->width = width;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   870
90ce3da70b43 Initial load
duke
parents:
diff changeset
   871
    AwtToolkit::GetInstance().SyncCall(AwtList::_AddItems, ais);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   872
    // global refs and ais are deleted in _AddItems()
90ce3da70b43 Initial load
duke
parents:
diff changeset
   873
90ce3da70b43 Initial load
duke
parents:
diff changeset
   874
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   875
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   876
90ce3da70b43 Initial load
duke
parents:
diff changeset
   877
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   878
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   879
 * Method:    delItems
90ce3da70b43 Initial load
duke
parents:
diff changeset
   880
 * Signature: (II)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   881
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   882
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   883
Java_sun_awt_windows_WListPeer_delItems(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   884
                                        jint start, jint end)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   885
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   886
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   887
90ce3da70b43 Initial load
duke
parents:
diff changeset
   888
    DelItemsStruct *dis = new DelItemsStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   889
    dis->list = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   890
    dis->start = start;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   891
    dis->end = end;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   892
90ce3da70b43 Initial load
duke
parents:
diff changeset
   893
    AwtToolkit::GetInstance().SyncCall(AwtList::_DelItems, dis);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   894
    // global ref and dis are deleted in _DelItems
90ce3da70b43 Initial load
duke
parents:
diff changeset
   895
90ce3da70b43 Initial load
duke
parents:
diff changeset
   896
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   897
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   898
90ce3da70b43 Initial load
duke
parents:
diff changeset
   899
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   900
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   901
 * Method:    select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   902
 * Signature: (I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   903
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   904
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   905
Java_sun_awt_windows_WListPeer_select(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   906
                                      jint pos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   907
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   908
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   909
90ce3da70b43 Initial load
duke
parents:
diff changeset
   910
    SelectElementStruct *ses = new SelectElementStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   911
    ses->list = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   912
    ses->index = pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   913
90ce3da70b43 Initial load
duke
parents:
diff changeset
   914
    AwtToolkit::GetInstance().SyncCall(AwtList::_Select, ses);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   915
    // global ref and ses are deleted in _Select
90ce3da70b43 Initial load
duke
parents:
diff changeset
   916
90ce3da70b43 Initial load
duke
parents:
diff changeset
   917
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   918
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   919
90ce3da70b43 Initial load
duke
parents:
diff changeset
   920
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   921
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   922
 * Method:    deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   923
 * Signature: (I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   924
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   925
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   926
Java_sun_awt_windows_WListPeer_deselect(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   927
                                        jint pos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   928
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   929
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   930
90ce3da70b43 Initial load
duke
parents:
diff changeset
   931
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   932
    JNI_CHECK_PEER_RETURN(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   933
90ce3da70b43 Initial load
duke
parents:
diff changeset
   934
    SelectElementStruct *ses = new SelectElementStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   935
    ses->list = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   936
    ses->index = pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   937
90ce3da70b43 Initial load
duke
parents:
diff changeset
   938
    AwtToolkit::GetInstance().SyncCall(AwtList::_Deselect, ses);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   939
    // global ref and ses are deleted in _Deselect
90ce3da70b43 Initial load
duke
parents:
diff changeset
   940
90ce3da70b43 Initial load
duke
parents:
diff changeset
   941
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   942
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   943
90ce3da70b43 Initial load
duke
parents:
diff changeset
   944
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   945
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   946
 * Method:    makeVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   947
 * Signature: (I)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   948
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   949
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   950
Java_sun_awt_windows_WListPeer_makeVisible(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   951
                                           jint pos)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   952
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   953
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   954
90ce3da70b43 Initial load
duke
parents:
diff changeset
   955
    SelectElementStruct *ses = new SelectElementStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   956
    ses->list = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   957
    ses->index = pos;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   958
90ce3da70b43 Initial load
duke
parents:
diff changeset
   959
    AwtToolkit::GetInstance().SyncCall(AwtList::_MakeVisible, ses);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   960
    // global ref and ses are deleted in _MakeVisible
90ce3da70b43 Initial load
duke
parents:
diff changeset
   961
90ce3da70b43 Initial load
duke
parents:
diff changeset
   962
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   963
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   964
90ce3da70b43 Initial load
duke
parents:
diff changeset
   965
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   966
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   967
 * Method:    setMultipleSelections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   968
 * Signature: (Z)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   969
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   970
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   971
Java_sun_awt_windows_WListPeer_setMultipleSelections(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   972
                                                     jboolean on)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   973
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   974
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   975
90ce3da70b43 Initial load
duke
parents:
diff changeset
   976
    SetMultipleSelectionsStruct *sms = new SetMultipleSelectionsStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   977
    sms->list = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   978
    sms->on = on;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   979
90ce3da70b43 Initial load
duke
parents:
diff changeset
   980
    AwtToolkit::GetInstance().SyncCall(AwtList::_SetMultipleSelections, sms);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   981
    // global ref and sms are deleted in AwtList::_SetMultipleSelections
90ce3da70b43 Initial load
duke
parents:
diff changeset
   982
90ce3da70b43 Initial load
duke
parents:
diff changeset
   983
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   984
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
   985
90ce3da70b43 Initial load
duke
parents:
diff changeset
   986
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
   987
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
   988
 * Method:    create
90ce3da70b43 Initial load
duke
parents:
diff changeset
   989
 * Signature: (Lsun/awt/windows/WComponentPeer;)V
90ce3da70b43 Initial load
duke
parents:
diff changeset
   990
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
   991
JNIEXPORT void JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
   992
Java_sun_awt_windows_WListPeer_create(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
   993
                                      jobject parent)
90ce3da70b43 Initial load
duke
parents:
diff changeset
   994
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
   995
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   996
90ce3da70b43 Initial load
duke
parents:
diff changeset
   997
    PDATA pData;
90ce3da70b43 Initial load
duke
parents:
diff changeset
   998
    JNI_CHECK_PEER_RETURN(parent);
90ce3da70b43 Initial load
duke
parents:
diff changeset
   999
    AwtToolkit::CreateComponent(self, parent,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1000
                                (AwtToolkit::ComponentFactory)AwtList::Create);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1001
    JNI_CHECK_PEER_CREATION_RETURN(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1002
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1003
    CATCH_BAD_ALLOC;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1004
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1005
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1006
/*
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1007
 * Class:     sun_awt_windows_WListPeer
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1008
 * Method:    isSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1009
 * Signature: (I)Z
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1010
 */
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1011
JNIEXPORT jboolean JNICALL
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1012
Java_sun_awt_windows_WListPeer_isSelected(JNIEnv *env, jobject self,
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1013
                                          jint index)
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1014
{
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1015
    TRY;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1016
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1017
    SelectElementStruct *ses = new SelectElementStruct;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1018
    ses->list = env->NewGlobalRef(self);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1019
    ses->index = index;
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1020
25771
afc878cc2197 8049583: Test closed/java/awt/List/ListMultipleSelectTest/ListMultipleSelectTest fails on Window XP
serb
parents: 25194
diff changeset
  1021
    return (jboolean)AwtToolkit::GetInstance().SyncCall(
afc878cc2197 8049583: Test closed/java/awt/List/ListMultipleSelectTest/ListMultipleSelectTest fails on Window XP
serb
parents: 25194
diff changeset
  1022
        (void *(*)(void *))AwtList::_IsSelected, ses);
2
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1023
    // global ref and ses are deleted in _IsSelected
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1024
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1025
    CATCH_BAD_ALLOC_RET(FALSE);
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1026
}
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1027
90ce3da70b43 Initial load
duke
parents:
diff changeset
  1028
} /* extern "C" */