/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
#include "awt_List.h"
#include "awt_Canvas.h"
#include "awt_Dimension.h"
#include "awt_Toolkit.h"
#include "awt_Window.h"
#include "ComCtl32Util.h"
/* IMPORTANT! Read the README.JNI file for notes on JNI converted AWT code.
*/
/***********************************************************************/
// struct for _AddItems() method
struct AddItemsStruct {
};
// struct for _DelItems() method
struct DelItemsStruct {
};
// struct for _IsSelected(), _Select(), _Deselect() and _MakeVisible() methods
struct SelectElementStruct {
};
// struct for _SetMultipleSelections() method
struct SetMultipleSelectionsStruct {
};
/************************************************************************
* AwtList methods
*/
}
{
}
return TEXT("LISTBOX");
}
/* Create a new AwtList object and window. */
{
try {
return NULL;
}
/* target is Hjava_awt_List * */
c = new AwtList();
{
/*
* NOTE: WS_CLIPCHILDREN is excluded so that repaint requests
* from Java will pass through the wrap to the native listbox.
*/
/*
* NOTE: WS_VISIBLE is always set for the listbox. Listbox
* visibility is controlled by toggling the wrap's WS_VISIBLE bit.
*/
style |= WS_VISIBLE;
if (GetRTL()) {
if (GetRTLReadingOrder())
}
NULL,
);
/* suppress inheriting awtParent's color. */
c->m_backgroundColorSet = TRUE;
}
} catch (...) {
throw;
}
done:
return c;
}
{
// don't want to interfere with other controls
if (::GetCapture() == NULL) {
::SetCapture(GetListHandle());
}
}
{
::ReleaseCapture();
}
}
{
AwtComponent::Reshape(x, y, w, h);
/*
HWND hList = GetListHandle();
if (hList != NULL) {
long flags = SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOCOPYBITS;
/*
* Fix for bug 4046446.
* /
SetWindowPos(hList, 0, 0, 0, w, h, flags);
}
*/
}
//Netscape : Override the AwtComponent method so we can set the item height
//for each item in the list. Modified by echawkes to avoid race condition.
{
{
}
// Listbox is LBS_OWNERDRAWFIXED so the items have the same height
}
if (ms == isMultiSelect) {
return;
}
/* Copy current box's contents to string array */
int i;
for(i = 0; i < nCount; i++) {
try {
// free char * already allocated
for (int j = 0; j < i; j++) {
delete [] strings[j];
}
delete [] strings;
throw;
}
}
// index for selected item after multi-select mode change
if (!isMultiSelect)
{
// MSDN: for single-select lists LB_GETCURSEL returns
// index of selected item or LB_ERR if no item is selected
{
toSelect = -1;
}
}
else
{
// MSDN: for multi-select lists LB_GETCURSEL returns index
// of the focused item or 0 if no items are selected; if
// some item has focus and is not selected then LB_GETCURSEL
// return its index, so we need IsItemSelected too
(SendListMessage(LB_GETSELCOUNT) == 0) ||
(IsItemSelected(toSelect) == 0))
{
toSelect = -1;
}
}
isMultiSelect = ms;
/* Save old list box's attributes */
if (isMultiSelect) {
style |= LBS_MULTIPLESEL;
} else {
style &= ~LBS_MULTIPLESEL;
}
NULL,
peer);
for (i = 0; i < nCount; i++) {
InsertString(i, strings[i]);
delete [] strings[i];
}
delete[] strings;
if (toSelect != -1) {
}
}
/*
* There currently is no good place to cache java.awt.Dimension field
* ids. If this method gets called a lot, one such place should be found.
* -- br 07/18/97.
*/
{
1).l;
return NULL;
}
/* This size is too big for each item height. */
return dimension;
}
// Every time something gets added to the list, we increase the max width
// of items that have ever been added. If it surpasses the width of the
// listbox, we show the scrollbar. When things get deleted, we shrink
// the scroll region back down and hide the scrollbar, if needed.
{
// The border width is added to the horizontal extent to ensure that we
// can view all of the text when we move the horz. scrollbar to the end.
{
}
}
// This function goes through all strings in the list to find the width,
// in pixels, of the longest string in the list.
{
m_nMaxWidth = 0;
return;
/* target is java.awt.List */
for ( int i=0; i < nCount; i++ )
{
}
// free up the shared DC and release local refs
// Now adjust the horizontal scrollbar extent
}
{
}
{
return mrConsume;
}
{
return mrConsume;
}
{
return mrConsume;
}
}
{
// if this list is in the modal blocked window, this message should be consumed,
// however AwtComponent::WmMouseUp must be called anyway
} else {
if (button == LEFT_BUTTON) {
}
}
}
{
{
return mrConsume;
}
/*
* As we consume WM_LBUTONDOWN the list won't trigger ActionEvent by double click.
* We trigger it ourselves. (see also 6240202)
*/
}
return mrResult;
}
{
return mrConsume;
}
{
}
{
if (IsFocusingMouseMessage(msg)) {
if (isMultiSelect) {
if (IsItemSelected(item)) {
} else {
}
} else {
}
}
delete msg;
return mrConsume;
}
}
}
// Fix for 4665745.
// Override WmPrint to catch when the list control (not wrapper) should
// operate WM_PRINT to be compatible with the "smooth scrolling" feature.
{
if (!isWrapperPrint &&
(flags & PRF_CLIENT) &&
(GetStyleEx() & WS_EX_CLIENTEDGE))
{
DASSERT(nOriginalDC != 0);
// Save a copy of the DC for WmPrintClient
flags &= ~PRF_CLIENT;
}
}
{
/* Fixed an asserion failure when clicking on an empty List. */
if (notifyCode == LBN_SELCHANGE) {
}
else if (notifyCode == LBN_DBLCLK) {
}
}
}
return mrDoDefault;
}
{
{
result = l->GetMaxWidth();
}
ret:
return result;
}
{
{
l->UpdateMaxItemWidth();
}
ret:
}
{
int badAlloc = 0;
{
if (itemCount > 0)
{
{
{
badAlloc = 1;
}
else
{
}
;
}
l->CheckMaxWidth(width);
}
}
ret:
delete ais;
if (badAlloc)
{
}
}
{
{
}
else
{
{
}
}
l->UpdateMaxItemWidth();
}
ret:
delete dis;
}
{
{
}
ret:
delete ses;
}
{
{
}
ret:
delete ses;
}
{
{
}
ret:
delete ses;
}
{
{
}
ret:
delete ses;
return result;
}
{
{
}
ret:
delete sms;
}
/************************************************************************
* WListPeer native methods
*
* This class seems to have numerous bugs in it, but they are all bugs
* which were present before conversion to JNI. -br.
*/
extern "C" {
/*
* Class: sun_awt_windows_WListPeer
* Method: getMaxWidth
* Signature: ()I
*/
{
TRY;
(void *(*)(void *))AwtList::_GetMaxWidth,
(void *)selfGlobalRef);
// selfGlobalRef is deleted in _GetMaxWidth
}
/*
* Class: sun_awt_windows_WListPeer
* Method: updateMaxItemWidth
* Signature: ()V
*/
{
TRY;
(void *)selfGlobalRef);
// selfGlobalRef is deleted in _UpdateMaxItemWidth
}
/*
* Class: sun_awt_windows_WListPeer
* Method: addItems
*/
{
TRY;
// global refs and ais are deleted in _AddItems()
}
/*
* Class: sun_awt_windows_WListPeer
* Method: delItems
* Signature: (II)V
*/
{
TRY;
// global ref and dis are deleted in _DelItems
}
/*
* Class: sun_awt_windows_WListPeer
* Method: select
* Signature: (I)V
*/
{
TRY;
// global ref and ses are deleted in _Select
}
/*
* Class: sun_awt_windows_WListPeer
* Method: deselect
* Signature: (I)V
*/
{
TRY;
// global ref and ses are deleted in _Deselect
}
/*
* Class: sun_awt_windows_WListPeer
* Method: makeVisible
* Signature: (I)V
*/
{
TRY;
// global ref and ses are deleted in _MakeVisible
}
/*
* Class: sun_awt_windows_WListPeer
* Method: setMultipleSelections
* Signature: (Z)V
*/
{
TRY;
// global ref and sms are deleted in AwtList::_SetMultipleSelections
}
/*
* Class: sun_awt_windows_WListPeer
* Method: create
* Signature: (Lsun/awt/windows/WComponentPeer;)V
*/
{
TRY;
}
/*
* Class: sun_awt_windows_WListPeer
* Method: isSelected
* Signature: (I)Z
*/
{
TRY;
// global ref and ses are deleted in _IsSelected
}
} /* extern "C" */