comparison win/dw.c @ 34:b03b24bb95f8

Added dw_window_default() to set the default focus widget in a dialog. Also some fixes for containers on OS/2.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 03 Sep 2001 23:30:43 +0000
parents 72675de7d229
children 360bc6a5f1c9
comparison
equal deleted inserted replaced
33:72675de7d229 34:b03b24bb95f8
320 return cinfo->buddy; 320 return cinfo->buddy;
321 } 321 }
322 return handle; 322 return handle;
323 } 323 }
324 324
325 int _focus_check_box(Box *box, HWND handle, int start) 325 int _focus_check_box(Box *box, HWND handle, int start, HWND defaultitem)
326 { 326 {
327 int z; 327 int z;
328 static HWND lasthwnd, firsthwnd; 328 static HWND lasthwnd, firsthwnd;
329 static int finish_searching; 329 static int finish_searching;
330 330
354 { 354 {
355 if(box->items[z].type == TYPEBOX) 355 if(box->items[z].type == TYPEBOX)
356 { 356 {
357 Box *thisbox = (Box *)GetWindowLong(box->items[z].hwnd, GWL_USERDATA); 357 Box *thisbox = (Box *)GetWindowLong(box->items[z].hwnd, GWL_USERDATA);
358 358
359 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0)) 359 if(thisbox && _focus_check_box(thisbox, handle, start == 3 ? 3 : 0, defaultitem))
360 return 1; 360 return 1;
361 } 361 }
362 else 362 else
363 { 363 {
364 if(box->items[z].hwnd == handle) 364 if(box->items[z].hwnd == handle)
381 /* Start is 3 when we are looking for the 381 /* Start is 3 when we are looking for the
382 * first valid item in the layout. 382 * first valid item in the layout.
383 */ 383 */
384 if(start == 3) 384 if(start == 3)
385 { 385 {
386 SetFocus(_normalize_handle(box->items[z].hwnd)); 386 if(!defaultitem || (defaultitem && box->items[z].hwnd == defaultitem))
387 return 1; 387 {
388 SetFocus(_normalize_handle(box->items[z].hwnd));
389 return 1;
390 }
388 } 391 }
389 392
390 if(!firsthwnd) 393 if(!firsthwnd)
391 firsthwnd = _normalize_handle(box->items[z].hwnd); 394 firsthwnd = _normalize_handle(box->items[z].hwnd);
392 395
409 412
410 if(array[pageid]->hwnd) 413 if(array[pageid]->hwnd)
411 { 414 {
412 notebox = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA); 415 notebox = (Box *)GetWindowLong(array[pageid]->hwnd, GWL_USERDATA);
413 416
414 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0)) 417 if(notebox && _focus_check_box(notebox, handle, start == 3 ? 3 : 0, defaultitem))
415 return 1; 418 return 1;
416 } 419 }
417 } 420 }
418 } 421 }
419 } 422 }
432 if(handle) 435 if(handle)
433 thisbox = (Box *)GetWindowLong(handle, GWL_USERDATA); 436 thisbox = (Box *)GetWindowLong(handle, GWL_USERDATA);
434 437
435 if(thisbox) 438 if(thisbox)
436 { 439 {
437 _focus_check_box(thisbox, handle, 3); 440 _focus_check_box(thisbox, handle, 3, thisbox->defaultitem);
438 } 441 }
439 } 442 }
440 443
441 /* This function finds the current widget in the 444 /* This function finds the current widget in the
442 * layout and moves the current focus to the next item. 445 * layout and moves the current focus to the next item.
454 } 457 }
455 458
456 thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA); 459 thisbox = (Box *)GetWindowLong(lastbox, GWL_USERDATA);
457 if(thisbox) 460 if(thisbox)
458 { 461 {
459 if(_focus_check_box(thisbox, handle, 1) == 0) 462 if(_focus_check_box(thisbox, handle, 1, 0) == 0)
460 _focus_check_box(thisbox, handle, 2); 463 _focus_check_box(thisbox, handle, 2, 0);
461 } 464 }
462 } 465 }
463 466
464 /* ResetWindow: 467 /* ResetWindow:
465 * Resizes window to the exact same size to trigger 468 * Resizes window to the exact same size to trigger
4559 cinfo->flags = tempflags; 4562 cinfo->flags = tempflags;
4560 4563
4561 4564
4562 for(z=0;z<count;z++) 4565 for(z=0;z<count;z++)
4563 { 4566 {
4564 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM /*| LVCF_FORMAT*/; 4567 if(titles[z])
4565 lvc.pszText = titles[z]; 4568 {
4566 lvc.cchTextMax = strlen(titles[z]); 4569 lvc.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM /*| LVCF_FORMAT*/;
4567 lvc.fmt = flags[z]; 4570 lvc.pszText = titles[z];
4568 lvc.cx = 75; 4571 lvc.cchTextMax = strlen(titles[z]);
4569 lvc.iSubItem = count; 4572 lvc.fmt = flags[z];
4570 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)z + l, (LPARAM)&lvc); 4573 lvc.cx = 75;
4574 lvc.iSubItem = count;
4575 SendMessage(handle, LVM_INSERTCOLUMN, (WPARAM)z + l, (LPARAM)&lvc);
4576 }
4571 } 4577 }
4572 ListView_SetExtendedListViewStyle(handle, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES); 4578 ListView_SetExtendedListViewStyle(handle, LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);
4573 return TRUE; 4579 return TRUE;
4574 } 4580 }
4575 4581
4654 int z; 4660 int z;
4655 static HWND lasthwnd = NULL; 4661 static HWND lasthwnd = NULL;
4656 4662
4657 if(!hSmall || !hLarge) 4663 if(!hSmall || !hLarge)
4658 { 4664 {
4659 hSmall = ImageList_Create(16, 16, FALSE, ICON_INDEX_LIMIT, 0); 4665 hSmall = ImageList_Create(16, 16, ILC_COLOR16, ICON_INDEX_LIMIT, 0);
4660 hLarge = ImageList_Create(32, 32, FALSE, ICON_INDEX_LIMIT, 0); 4666 hLarge = ImageList_Create(32, 32, ILC_COLOR16, ICON_INDEX_LIMIT, 0);
4661 } 4667 }
4662 for(z=0;z<ICON_INDEX_LIMIT;z++) 4668 for(z=0;z<ICON_INDEX_LIMIT;z++)
4663 { 4669 {
4664 if(!lookup[z]) 4670 if(!lookup[z])
4665 { 4671 {
5596 ShowWindow(cinfo->buddy, SW_SHOW); 5602 ShowWindow(cinfo->buddy, SW_SHOW);
5597 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0); 5603 SendMessage(item, UDM_SETBUDDY, (WPARAM)cinfo->buddy, 0);
5598 } 5604 }
5599 } 5605 }
5600 } 5606 }
5607 }
5608
5609 /*
5610 * Sets the default focus item for a window/dialog.
5611 * Parameters:
5612 * window: Toplevel window or dialog.
5613 * defaultitem: Handle to the dialog item to be default.
5614 */
5615 void dw_window_default(HWND window, HWND defaultitem)
5616 {
5617 Box *thisbox = (Box *)GetWindowLong(window, GWL_USERDATA);
5618
5619 if(thisbox)
5620 thisbox->defaultitem = defaultitem;
5601 } 5621 }
5602 5622
5603 /* 5623 /*
5604 * Returns some information about the current operating environment. 5624 * Returns some information about the current operating environment.
5605 * Parameters: 5625 * Parameters: