224
225 for(i = 0; i < nCount; i++) {
226 LRESULT len = SendListMessage(LB_GETTEXTLEN, i);
227 LPTSTR text = NULL;
228 try {
229 text = new TCHAR[len + 1];
230 } catch (std::bad_alloc&) {
231 // free char * already allocated
232 for (int j = 0; j < i; j++) {
233 delete [] strings[j];
234 }
235 delete [] strings;
236 throw;
237 }
238
239 VERIFY(SendListMessage(LB_GETTEXT, i, (LPARAM)text) != LB_ERR);
240 strings[i] = text;
241 }
242
243 // index for selected item after multi-select mode change
244 int toSelect = SendListMessage(LB_GETCURSEL);
245 if (!isMultiSelect)
246 {
247 // MSDN: for single-select lists LB_GETCURSEL returns
248 // index of selected item or LB_ERR if no item is selected
249 if (toSelect == LB_ERR)
250 {
251 toSelect = -1;
252 }
253 }
254 else
255 {
256 // MSDN: for multi-select lists LB_GETCURSEL returns index
257 // of the focused item or 0 if no items are selected; if
258 // some item has focus and is not selected then LB_GETCURSEL
259 // return its index, so we need IsItemSelected too
260 if ((toSelect == LB_ERR) ||
261 (SendListMessage(LB_GETSELCOUNT) == 0) ||
262 (IsItemSelected(toSelect) == 0))
263 {
264 toSelect = -1;
510 {
511 int nOriginalDC = ::SaveDC(hDC);
512 DASSERT(nOriginalDC != 0);
513 // Save a copy of the DC for WmPrintClient
514 VERIFY(::SaveDC(hDC));
515 DefWindowProc(WM_PRINT, (WPARAM) hDC,
516 (flags & (PRF_CLIENT | PRF_CHECKVISIBLE | PRF_ERASEBKGND)));
517 VERIFY(::RestoreDC(hDC, nOriginalDC));
518
519 flags &= ~PRF_CLIENT;
520 }
521
522 return AwtComponent::WmPrint(hDC, flags);
523 }
524
525 MsgRouting
526 AwtList::WmNotify(UINT notifyCode)
527 {
528 if (notifyCode == LBN_SELCHANGE || notifyCode == LBN_DBLCLK) {
529 /* Fixed an asserion failure when clicking on an empty List. */
530 int nCurrentSelection = SendListMessage(LB_GETCURSEL);
531 if (nCurrentSelection != LB_ERR && GetCount() > 0) {
532 if (notifyCode == LBN_SELCHANGE) {
533 DoCallback("handleListChanged", "(I)V", nCurrentSelection);
534 }
535 else if (notifyCode == LBN_DBLCLK) {
536 DoCallback("handleAction", "(IJI)V", nCurrentSelection,
537 ::JVM_CurrentTimeMillis(NULL, 0),
538 (jint)AwtComponent::GetActionModifiers());
539 }
540 }
541 }
542 return mrDoDefault;
543 }
544
545 BOOL AwtList::InheritsNativeMouseWheelBehavior() {return true;}
546
547 jint AwtList::_GetMaxWidth(void *param)
548 {
549 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
550
|
224
225 for(i = 0; i < nCount; i++) {
226 LRESULT len = SendListMessage(LB_GETTEXTLEN, i);
227 LPTSTR text = NULL;
228 try {
229 text = new TCHAR[len + 1];
230 } catch (std::bad_alloc&) {
231 // free char * already allocated
232 for (int j = 0; j < i; j++) {
233 delete [] strings[j];
234 }
235 delete [] strings;
236 throw;
237 }
238
239 VERIFY(SendListMessage(LB_GETTEXT, i, (LPARAM)text) != LB_ERR);
240 strings[i] = text;
241 }
242
243 // index for selected item after multi-select mode change
244 int toSelect = static_cast<int>(SendListMessage(LB_GETCURSEL));
245 if (!isMultiSelect)
246 {
247 // MSDN: for single-select lists LB_GETCURSEL returns
248 // index of selected item or LB_ERR if no item is selected
249 if (toSelect == LB_ERR)
250 {
251 toSelect = -1;
252 }
253 }
254 else
255 {
256 // MSDN: for multi-select lists LB_GETCURSEL returns index
257 // of the focused item or 0 if no items are selected; if
258 // some item has focus and is not selected then LB_GETCURSEL
259 // return its index, so we need IsItemSelected too
260 if ((toSelect == LB_ERR) ||
261 (SendListMessage(LB_GETSELCOUNT) == 0) ||
262 (IsItemSelected(toSelect) == 0))
263 {
264 toSelect = -1;
510 {
511 int nOriginalDC = ::SaveDC(hDC);
512 DASSERT(nOriginalDC != 0);
513 // Save a copy of the DC for WmPrintClient
514 VERIFY(::SaveDC(hDC));
515 DefWindowProc(WM_PRINT, (WPARAM) hDC,
516 (flags & (PRF_CLIENT | PRF_CHECKVISIBLE | PRF_ERASEBKGND)));
517 VERIFY(::RestoreDC(hDC, nOriginalDC));
518
519 flags &= ~PRF_CLIENT;
520 }
521
522 return AwtComponent::WmPrint(hDC, flags);
523 }
524
525 MsgRouting
526 AwtList::WmNotify(UINT notifyCode)
527 {
528 if (notifyCode == LBN_SELCHANGE || notifyCode == LBN_DBLCLK) {
529 /* Fixed an asserion failure when clicking on an empty List. */
530 int nCurrentSelection = static_cast<int>(SendListMessage(LB_GETCURSEL));
531 if (nCurrentSelection != LB_ERR && GetCount() > 0) {
532 if (notifyCode == LBN_SELCHANGE) {
533 DoCallback("handleListChanged", "(I)V", nCurrentSelection);
534 }
535 else if (notifyCode == LBN_DBLCLK) {
536 DoCallback("handleAction", "(IJI)V", nCurrentSelection,
537 ::JVM_CurrentTimeMillis(NULL, 0),
538 (jint)AwtComponent::GetActionModifiers());
539 }
540 }
541 }
542 return mrDoDefault;
543 }
544
545 BOOL AwtList::InheritsNativeMouseWheelBehavior() {return true;}
546
547 jint AwtList::_GetMaxWidth(void *param)
548 {
549 JNIEnv *env = (JNIEnv *)JNU_GetEnv(jvm, JNI_VERSION_1_2);
550
|